@@ -5,10 +5,10 @@ import { showPurseBalance, setupIssuers } from './helpers';
5
5
import { makePrintLog } from './printLog' ;
6
6
7
7
const build = async ( log , zoe , issuers , payments , installations , timer ) => {
8
- const { moola, simoleans, purses } = await setupIssuers ( zoe , issuers ) ;
8
+ const { moola, simoleans, bucks , purses } = await setupIssuers ( zoe , issuers ) ;
9
9
const [ moolaPurseP , simoleanPurseP ] = purses ;
10
- const [ moolaPayment , simoleanPayment ] = payments ;
11
- const [ moolaIssuer , simoleanIssuer ] = issuers ;
10
+ const [ moolaPayment , simoleanPayment , bucksPayment ] = payments ;
11
+ const [ moolaIssuer , simoleanIssuer , bucksIssuer ] = issuers ;
12
12
13
13
const doAutomaticRefund = async bobP => {
14
14
log ( `=> alice.doCreateAutomaticRefund called` ) ;
@@ -418,6 +418,71 @@ const build = async (log, zoe, issuers, payments, installations, timer) => {
418
418
log ( 'alice earned: ' , currentPurseBalance ) ;
419
419
} ;
420
420
421
+ const doOTCDesk = async bobP => {
422
+ const { creatorFacet } = await E ( zoe ) . startInstance (
423
+ installations . otcDesk ,
424
+ undefined ,
425
+ { coveredCallInstallation : installations . coveredCall } ,
426
+ ) ;
427
+
428
+ // Add inventory
429
+ const addInventoryInvitation = await E (
430
+ creatorFacet ,
431
+ ) . makeAddInventoryInvitation ( {
432
+ Moola : moolaIssuer ,
433
+ Simolean : simoleanIssuer ,
434
+ Buck : bucksIssuer ,
435
+ } ) ;
436
+ const addInventoryProposal = harden ( {
437
+ give : {
438
+ Moola : moola ( 10000 ) ,
439
+ Simolean : simoleans ( 10000 ) ,
440
+ Buck : bucks ( 10000 ) ,
441
+ } ,
442
+ } ) ;
443
+ const addInventoryPayments = {
444
+ Moola : moolaPayment ,
445
+ Simolean : simoleanPayment ,
446
+ Buck : bucksPayment ,
447
+ } ;
448
+
449
+ const addInventorySeat = await E ( zoe ) . offer (
450
+ addInventoryInvitation ,
451
+ addInventoryProposal ,
452
+ addInventoryPayments ,
453
+ ) ;
454
+ const addInventoryOfferResult = await E ( addInventorySeat ) . getOfferResult ( ) ;
455
+ log ( addInventoryOfferResult ) ;
456
+ const bobInvitation = await E ( creatorFacet ) . makeQuote (
457
+ { Simolean : simoleans ( 4 ) } ,
458
+ { Moola : moola ( 3 ) } ,
459
+ timer ,
460
+ 1 ,
461
+ ) ;
462
+
463
+ await E ( bobP ) . doOTCDesk ( bobInvitation ) ;
464
+
465
+ // Remove Inventory
466
+ const removeInventoryInvitation = await E (
467
+ creatorFacet ,
468
+ ) . makeRemoveInventoryInvitation ( ) ;
469
+ // Intentionally do not remove it all
470
+ const removeInventoryProposal = harden ( {
471
+ want : { Simolean : simoleans ( 2 ) } ,
472
+ } ) ;
473
+ const removeInventorySeat = await E ( zoe ) . offer (
474
+ removeInventoryInvitation ,
475
+ removeInventoryProposal ,
476
+ ) ;
477
+ const removeInventoryOfferResult = await E (
478
+ removeInventorySeat ,
479
+ ) . getOfferResult ( ) ;
480
+ log ( removeInventoryOfferResult ) ;
481
+ const simoleanPayout = await E ( removeInventorySeat ) . getPayout ( 'Simolean' ) ;
482
+
483
+ log ( await E ( simoleanIssuer ) . getAmountOf ( simoleanPayout ) ) ;
484
+ } ;
485
+
421
486
return harden ( {
422
487
startTest : async ( testName , bobP , carolP , daveP ) => {
423
488
switch ( testName ) {
@@ -448,6 +513,9 @@ const build = async (log, zoe, issuers, payments, installations, timer) => {
448
513
case 'sellTicketsOk' : {
449
514
return doSellTickets ( bobP , carolP , daveP ) ;
450
515
}
516
+ case 'otcDeskOk' : {
517
+ return doOTCDesk ( bobP ) ;
518
+ }
451
519
default : {
452
520
throw new Error ( `testName ${ testName } not recognized` ) ;
453
521
}
0 commit comments