@@ -73,6 +73,9 @@ export function makeWallet({
73
73
pursesStateChangeHandler = noActionStateChangeHandler ,
74
74
inboxStateChangeHandler = noActionStateChangeHandler ,
75
75
} ) {
76
+ /** @type {Purse= } */
77
+ let zoeFeePurse ;
78
+
76
79
// Create the petname maps so we can dehydrate information sent to
77
80
// the frontend.
78
81
const { makeMapping, dehydrate, edgeMapping } = makeDehydrator ( ) ;
@@ -361,7 +364,7 @@ export function makeWallet({
361
364
async function updateInboxState ( id , offer , doPush = true ) {
362
365
// Only sent the uncompiled offer to the client.
363
366
const { proposalTemplate } = offer ;
364
- const { instance, installation } = idToOffer . get ( id ) ;
367
+ const { instance, installation, invitationDetails } = idToOffer . get ( id ) ;
365
368
if ( ! instance || ! installation ) {
366
369
// We haven't yet deciphered the invitation, so don't send
367
370
// this offer.
@@ -372,14 +375,18 @@ export function makeWallet({
372
375
const alreadyDisplayed =
373
376
inboxState . has ( id ) && inboxState . get ( id ) . proposalForDisplay ;
374
377
378
+ const feePursePetname =
379
+ zoeFeePurse && purseMapping . valToPetname . get ( zoeFeePurse ) ;
375
380
const offerForDisplay = {
376
381
...offer ,
377
382
// We cannot store the actions, installation, and instance in the
378
- // displayed offer objects because they are presences are presences and we
383
+ // displayed offer objects because they are presences and we
379
384
// don't wish to send presences to the frontend.
380
385
actions : undefined ,
381
386
installation : undefined ,
382
387
instance : undefined ,
388
+ feePursePetname,
389
+ invitationDetails : display ( invitationDetails ) ,
383
390
proposalTemplate,
384
391
instancePetname : instanceDisplay . petname ,
385
392
installationPetname : installationDisplay . petname ,
@@ -548,7 +555,13 @@ export function makeWallet({
548
555
const paymentKeywords = await withdrawAllPayments ;
549
556
const paymentKeywordRecord = harden ( Object . fromEntries ( paymentKeywords ) ) ;
550
557
551
- const seat = E ( zoe ) . offer ( inviteP , harden ( proposal ) , paymentKeywordRecord ) ;
558
+ const seat = E ( zoe ) . offer (
559
+ inviteP ,
560
+ harden ( proposal ) ,
561
+ paymentKeywordRecord ,
562
+ undefined ,
563
+ zoeFeePurse ,
564
+ ) ;
552
565
// By the time Zoe settles the seat promise, the escrow should be complete.
553
566
// Reclaim if it is somehow not.
554
567
seat . finally ( tryReclaimingWithdrawnPayments ) ;
@@ -583,7 +596,11 @@ export function makeWallet({
583
596
// === API
584
597
585
598
const addIssuer = async ( petnameForBrand , issuerP , makePurse = false ) => {
586
- const { brand, issuer } = await brandTable . initIssuer ( issuerP ) ;
599
+ const issuer = await issuerP ;
600
+ const recP = brandTable . hasByIssuer ( issuer )
601
+ ? brandTable . getByIssuer ( issuer )
602
+ : brandTable . initIssuer ( issuer ) ;
603
+ const { brand } = await recP ;
587
604
if ( ! issuerToBoardId . has ( issuer ) ) {
588
605
const issuerBoardId = await E ( board ) . getId ( issuer ) ;
589
606
issuerToBoardId . init ( issuer , issuerBoardId ) ;
@@ -769,7 +786,6 @@ export function makeWallet({
769
786
} = proposalTemplate ;
770
787
771
788
const purseKeywordRecord = { } ;
772
-
773
789
const compile = amountKeywordRecord => {
774
790
return harden (
775
791
Object . fromEntries (
@@ -814,16 +830,16 @@ export function makeWallet({
814
830
offer ,
815
831
) ;
816
832
817
- const { installation, instance } = await E ( zoe ) . getInvitationDetails (
818
- invitationP ,
819
- ) ;
833
+ const invitationDetails = await E ( zoe ) . getInvitationDetails ( invitationP ) ;
834
+ const { instance, installation } = invitationDetails ;
820
835
821
836
return {
837
+ invitationDetails,
838
+ instance,
839
+ installation,
822
840
proposal,
823
841
inviteP : invitationP ,
824
842
purseKeywordRecord,
825
- installation,
826
- instance,
827
843
} ;
828
844
} ;
829
845
@@ -1556,6 +1572,9 @@ export function makeWallet({
1556
1572
} ,
1557
1573
getUINotifier,
1558
1574
getZoe ( ) {
1575
+ // Return a Zoe that requires fees from its caller.
1576
+ // TODO: We will need to wrap zoe with something that prompts the user to
1577
+ // pay fees.
1559
1578
return zoe ;
1560
1579
} ,
1561
1580
getBoard ( ) {
@@ -1575,6 +1594,28 @@ export function makeWallet({
1575
1594
} ) ;
1576
1595
1577
1596
const initialize = async ( ) => {
1597
+ /**
1598
+ * @param {Object } param0
1599
+ * @param {string } param0.proposedName
1600
+ * @param {string } param0.issuerName
1601
+ */
1602
+ const addZoeFeePurse = async ( { proposedName, issuerName } ) => {
1603
+ const feeIssuer = await E ( zoe ) . getFeeIssuer ( ) ;
1604
+
1605
+ // Install the fee purse.
1606
+ await addIssuer ( issuerName , feeIssuer ) ;
1607
+ const purse = await E ( zoe ) . makeFeePurse ( ) ;
1608
+ await internalUnsafeImportPurse ( issuerName , proposedName , false , purse ) ;
1609
+
1610
+ return purse ;
1611
+ } ;
1612
+
1613
+ // Create a default fee purse and use it in this contract.
1614
+ zoeFeePurse = await addZoeFeePurse ( {
1615
+ proposedName : 'Zoe fees' ,
1616
+ issuerName : 'RUN' ,
1617
+ } ) ;
1618
+
1578
1619
// Allow people to send us payments.
1579
1620
const selfDepositFacet = Far ( 'contact' , {
1580
1621
receive ( payment ) {
0 commit comments