diff --git a/packages/dapp-svelte-wallet/api/deploy.js b/packages/dapp-svelte-wallet/api/deploy.js index e1b1bae8e03..934631931fd 100644 --- a/packages/dapp-svelte-wallet/api/deploy.js +++ b/packages/dapp-svelte-wallet/api/deploy.js @@ -13,7 +13,7 @@ export default async function deployWallet( const home = await homePromise; // console.log('have home', home); const { - agoric: { board, faucet, zoe }, + agoric: { agoricNames, namesByAddress, board, faucet, zoe }, local: { http, spawner, wallet: oldWallet }, } = home; @@ -25,6 +25,8 @@ export default async function deployWallet( // Wallet for both end-user client and dapp dev client const walletVat = await E(walletInstall).spawn({ + agoricNames, + namesByAddress, zoe, board, faucet, diff --git a/packages/dapp-svelte-wallet/api/src/lib-wallet.js b/packages/dapp-svelte-wallet/api/src/lib-wallet.js index e1f92f80a39..d5f452c95b1 100644 --- a/packages/dapp-svelte-wallet/api/src/lib-wallet.js +++ b/packages/dapp-svelte-wallet/api/src/lib-wallet.js @@ -53,6 +53,8 @@ const cmp = (a, b) => { * @typedef {Object} MakeWalletParams * @property {ZoeService} zoe * @property {Board} board + * @property {NameHub} agoricNames + * @property {NameHub} namesByAddress * @property {(state: any) => void} [pursesStateChangeHandler=noActionStateChangeHandler] * @property {(state: any) => void} [inboxStateChangeHandler=noActionStateChangeHandler] * @param {MakeWalletParams} param0 @@ -60,6 +62,8 @@ const cmp = (a, b) => { export function makeWallet({ zoe, board, + agoricNames, + namesByAddress, pursesStateChangeHandler = noActionStateChangeHandler, inboxStateChangeHandler = noActionStateChangeHandler, }) { @@ -1472,6 +1476,12 @@ export function makeWallet({ getBoard() { return board; }, + getAgoricNames(...path) { + return E(agoricNames).lookup(...path); + }, + getNamesByAddress(...path) { + return E(namesByAddress).lookup(...path); + }, }); const initialize = async () => { diff --git a/packages/dapp-svelte-wallet/api/src/types.js b/packages/dapp-svelte-wallet/api/src/types.js index d08ff34373e..54d06983db7 100644 --- a/packages/dapp-svelte-wallet/api/src/types.js +++ b/packages/dapp-svelte-wallet/api/src/types.js @@ -7,6 +7,10 @@ * @typedef {import('@agoric/cosmic-swingset/lib/ag-solo/vats/lib-board').Board} Board */ +/** + * @typedef {import('@agoric/cosmic-swingset/lib/ag-solo/vats/types').NameHub} NameHub + */ + /** * @typedef {string | string[]} Petname A petname can either be a plain string * or a path for which the first element is a petname for the origin, and the @@ -83,6 +87,10 @@ * Get the Zoe Service * @property {() => Promise} getBoard * Get the Board + * @property {(...path: Array) => Promise} getAgoricNames + * Get the curated Agoric public naming hub + * @property {(...path: Array) => Promise} getNamesByAddress + * Get the Agoric address mapped to its public naming hub * @property {(brands: Array) => Promise>} * getBrandPetnames * Get the petnames for the brands that are passed in diff --git a/packages/dapp-svelte-wallet/api/src/wallet.js b/packages/dapp-svelte-wallet/api/src/wallet.js index 95eceea260a..30e55173dc2 100644 --- a/packages/dapp-svelte-wallet/api/src/wallet.js +++ b/packages/dapp-svelte-wallet/api/src/wallet.js @@ -75,8 +75,10 @@ export function buildRootObject(_vatPowers) { }, }); - async function startup({ zoe, board }) { + async function startup({ zoe, board, agoricNames, namesByAddress }) { const w = makeWallet({ + agoricNames, + namesByAddress, zoe, board, pursesStateChangeHandler: pursesPublish, @@ -178,6 +180,14 @@ export function buildRootObject(_vatPowers) { await approve(); return walletAdmin.getBoard(); }, + async getAgoricNames(...path) { + await approve(); + return walletAdmin.getAgoricNames(...path); + }, + async getNamesByAddress(...path) { + await approve(); + return walletAdmin.getNamesByAddress(...path); + }, async getBrandPetnames(brands) { await approve(); return walletAdmin.getBrandPetnames(brands); @@ -227,6 +237,12 @@ export function buildRootObject(_vatPowers) { async getBoard() { return walletAdmin.getBoard(); }, + async getAgoricNames(...path) { + return walletAdmin.getAgoricNames(...path); + }, + async getNamesByAddress(...path) { + return walletAdmin.getNamesByAddress(...path); + }, async getBrandPetnames(brands) { return walletAdmin.getBrandPetnames(brands); },