Skip to content

Commit

Permalink
fixup! feat: lookupAsset in getBalance
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Aug 28, 2024
1 parent 51f433f commit d89e8dc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
17 changes: 13 additions & 4 deletions packages/orchestration/src/examples/stakeBld.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
* @file Stake BLD contract
*/
import { makeTracer } from '@agoric/internal';
import { heapVowE as E, prepareVowTools } from '@agoric/vow/vat.js';
import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/recorder.js';
import { withdrawFromSeat } from '@agoric/zoe/src/contractSupport/zoeHelpers.js';
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
import { makeDurableZone } from '@agoric/zone/durable.js';
import { prepareVowTools, heapVowE as E } from '@agoric/vow/vat.js';
import { deeplyFulfilled } from '@endo/marshal';
import { M } from '@endo/patterns';
import { prepareLocalOrchestrationAccountKit } from '../exos/local-orchestration-account.js';
import { makeChainHub } from '../exos/chain-hub.js';
import { prepareChainHubAdmin } from '../exos/chain-hub-admin.js';
import { prepareLocalOrchestrationAccountKit } from '../exos/local-orchestration-account.js';
import fetchedChainInfo from '../fetched-chain-info.js';

/**
* @import {NameHub} from '@agoric/vats';
Expand Down Expand Up @@ -59,6 +59,15 @@ export const start = async (zcf, privateArgs, baggage) => {
const BLD = zcf.getTerms().brands.In;
const bldAmountShape = await E(BLD).getAmountShape();

// XXX big dependency, will probably already be registered in agoricNames
chainHub.registerChain('agoric', fetchedChainInfo.agoric);
chainHub.registerAsset('ubld', {
baseName: 'agoric',
baseDenom: 'ubld',
brand: BLD,
chainName: 'agoric',
});

async function makeLocalAccountKit() {
const account = await E(privateArgs.localchain).makeAccount();
const address = await E(account).getAddress();
Expand Down Expand Up @@ -124,6 +133,6 @@ export const start = async (zcf, privateArgs, baggage) => {
},
);

return { creatorFacet: prepareChainHubAdmin(zone, chainHub), publicFacet };
return { publicFacet };
};
harden(start);
26 changes: 4 additions & 22 deletions packages/orchestration/test/examples/stake-bld.contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { setUpZoeForTest } from '@agoric/zoe/tools/setup-zoe.js';
import path from 'path';
import type { CosmosChainInfo } from '../../src/cosmos-api.js';
import { commonSetup } from '../supports.js';
import knownChains from '../../src/fetched-chain-info.js';

const dirname = path.dirname(new URL(import.meta.url).pathname);

Expand All @@ -34,7 +33,7 @@ const startContract = async ({
const installation: Installation<StartFn> =
await bundleAndInstall(contractFile);

const { creatorFacet, publicFacet } = await E(zoe).startInstance(
const { publicFacet } = await E(zoe).startInstance(
installation,
{ In: bld.issuer },
{},
Expand All @@ -46,7 +45,7 @@ const startContract = async ({
timerService: timer,
},
);
return { creatorFacet, publicFacet, zoe };
return { publicFacet, zoe };
};

test('makeAccount, deposit, withdraw', async t => {
Expand All @@ -55,7 +54,7 @@ test('makeAccount, deposit, withdraw', async t => {
brands: { bld },
utils,
} = await commonSetup(t);
const { creatorFacet, publicFacet } = await startContract({
const { publicFacet } = await startContract({
...bootstrap,
bld,
});
Expand All @@ -68,16 +67,6 @@ test('makeAccount, deposit, withdraw', async t => {
const depositResp = await E(account).deposit(
await utils.pourPayment(bld.units(100)),
);
await t.throwsAsync(E(account).getBalance('ubld'), {
message: '"denom" not found: "ubld"',
});
// try again after registering the asset
await E(creatorFacet).registerAsset('ubld', {
baseName: 'agoric',
baseDenom: 'ubld',
brand: bld.brand,
chainName: 'agoric',
});
t.deepEqual(await E(account).getBalance('ubld'), {
denom: 'ubld',
value: bld.units(100).value,
Expand All @@ -104,7 +93,7 @@ test('makeStakeBldInvitation', async t => {
brands: { bld },
utils,
} = await commonSetup(t);
const { creatorFacet, publicFacet, zoe } = await startContract({
const { publicFacet, zoe } = await startContract({
...bootstrap,
bld,
});
Expand All @@ -124,13 +113,6 @@ test('makeStakeBldInvitation', async t => {
const { invitationMakers } = await E(userSeat).getOfferResult();
t.truthy(invitationMakers, 'received continuing invitation');

await E(creatorFacet).registerAsset('ubld', {
baseName: 'agoric',
baseDenom: 'ubld',
brand: bld.brand,
chainName: 'agoric',
});

t.log('make Delegate offer using invitationMakers');
{
const delegateInv = await E(invitationMakers).Delegate(
Expand Down

0 comments on commit d89e8dc

Please sign in to comment.