Skip to content

Commit

Permalink
chore: add getZoe & getBoard (Agoric#2175)
Browse files Browse the repository at this point in the history
* chore: add `getZoe` & `getBoard`

* chore: add approve()
  • Loading branch information
katelynsills authored Jan 10, 2021
1 parent 372b014 commit 3f12d58
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
6 changes: 6 additions & 0 deletions packages/dapp-svelte-wallet/api/src/lib-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,12 @@ export function makeWallet({
return paymentsNotifier;
},
getUINotifier,
getZoe() {
return zoe;
},
getBoard() {
return board;
},
});

const initialize = async () => {
Expand Down
11 changes: 8 additions & 3 deletions packages/dapp-svelte-wallet/api/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@
* @property {(petname: Petname, instanceBoardId: string) => Promise<void>}
* suggestInstance Introduce a Zoe contract instance to the wallet, with
* suggested petname.
* @property {(rawId: string) => Promise<Notifier<any>>} getUINotifier Get the UI notifier from the offerResult
* for a particular offer, identified by id. This notifier should only
* contain information that is safe to pass to the dapp UI.
* @property {(rawId: string) => Promise<Notifier<any>>} getUINotifier
* Get the UI notifier from the offerResult for a particular offer,
* identified by id. This notifier should only contain information that
* is safe to pass to the dapp UI.
* @property {() => Promise<ZoeService>} getZoe
* Get the Zoe Service
* @property {() => Promise<Board>} getBoard
* Get the Board
*/

/**
Expand Down
14 changes: 14 additions & 0 deletions packages/dapp-svelte-wallet/api/src/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ export function buildRootObject(_vatPowers) {
await approve();
return walletAdmin.getUINotifier(rawId, dappOrigin);
},
async getZoe() {
await approve();
return walletAdmin.getZoe();
},
async getBoard() {
await approve();
return walletAdmin.getBoard();
},
};
return harden(bridge);
};
Expand Down Expand Up @@ -202,6 +210,12 @@ export function buildRootObject(_vatPowers) {
getUINotifier(rawId) {
return walletAdmin.getUINotifier(rawId);
},
async getZoe() {
return walletAdmin.getZoe();
},
async getBoard() {
return walletAdmin.getBoard();
},
};
harden(preapprovedBridge);

Expand Down
19 changes: 19 additions & 0 deletions packages/dapp-svelte-wallet/api/test/test-lib-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1099,3 +1099,22 @@ test('addOffer makeContinuingInvitation', async t => {

t.is(update2.value, 'second offer made');
});

test('getZoe, getBoard', async t => {
const zoe = makeZoe(fakeVatAdmin);
const board = makeBoard();

const pursesStateChangeHandler = _data => {};
const inboxStateChangeHandler = _data => {};

const { admin: wallet, initialized } = makeWallet({
zoe,
board,
pursesStateChangeHandler,
inboxStateChangeHandler,
});
await initialized;

t.is(await E(wallet).getZoe(), zoe);
t.is(await E(wallet).getBoard(), board);
});

0 comments on commit 3f12d58

Please sign in to comment.