Skip to content

Commit

Permalink
refactor: use heapVowE
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jun 22, 2024
1 parent 9128f27 commit 3b0c8c1
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 42 deletions.
10 changes: 5 additions & 5 deletions packages/orchestration/src/examples/sendAnywhere.contract.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { withdrawFromSeat } from '@agoric/zoe/src/contractSupport/zoeHelpers.js';
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
import { E } from '@endo/far';
import { M, mustMatch } from '@endo/patterns';
import { V } from '@agoric/vow/vat.js';
import { heapVowE as E } from '@agoric/vow/vat.js';
import { AmountShape } from '@agoric/ertp';
import { CosmosChainInfoShape } from '../typeGuards.js';
import { provideOrchestration } from '../utils/start-helper.js';
Expand Down Expand Up @@ -58,6 +57,7 @@ export const start = async (zcf, privateArgs, baggage) => {
const findBrandInVBank = async brand => {
const assets = await E(
E(privateArgs.agoricNames).lookup('vbankAsset'),
// @ts-expect-error XXX heapVowE
).values();
const it = assets.find(a => a.brand === brand);
it || Fail`brand ${brand} not in agoricNames.vbankAsset`;
Expand All @@ -84,12 +84,12 @@ export const start = async (zcf, privateArgs, baggage) => {
if (!contractAccount) {
const agoricChain = await orch.getChain('agoric');
// XXX when() until membrane
contractAccount = await V.when(agoricChain.makeAccount());
contractAccount = await E.when(agoricChain.makeAccount());
console.log('contractAccount', contractAccount);
}

// XXX when() until membrane
const info = await V.when(chain.getChainInfo());
const info = await E.when(chain.getChainInfo());
console.log('info', info);
const { chainId } = info;
assert(typeof chainId === 'string', 'bad chainId');
Expand Down Expand Up @@ -141,7 +141,7 @@ export const start = async (zcf, privateArgs, baggage) => {
const chainKey = `${chainInfo.chainId}-${(nonce += 1n)}`;
// when() because chainHub methods return vows. If this were inside
// orchestrate() the membrane would wrap/unwrap automatically.
const agoricChainInfo = await V.when(chainHub.getChainInfo('agoric'));
const agoricChainInfo = await E.when(chainHub.getChainInfo('agoric'));
chainHub.registerChain(chainKey, chainInfo);
chainHub.registerConnection(
agoricChainInfo.chainId,
Expand Down
9 changes: 4 additions & 5 deletions packages/orchestration/src/examples/stakeBld.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/record
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, V } from '@agoric/vow/vat.js';
import { E } from '@endo/far';
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';
Expand Down Expand Up @@ -58,8 +57,8 @@ export const start = async (zcf, privateArgs, baggage) => {
const bldAmountShape = await E(BLD).getAmountShape();

async function makeLocalAccountKit() {
const account = await V(privateArgs.localchain).makeAccount();
const address = await V(account).getAddress();
const account = await E(privateArgs.localchain).makeAccount();
const address = await E(account).getAddress();
// FIXME 'address' is implied by 'account'; use an async maker that get the value itself
return makeLocalOrchestrationAccountKit({
account,
Expand Down Expand Up @@ -92,7 +91,7 @@ export const start = async (zcf, privateArgs, baggage) => {
const { In } = await deeplyFulfilled(
withdrawFromSeat(zcf, seat, give),
);
await V(holder).deposit(In);
await E(holder).deposit(In);
seat.exit();
return harden({
publicSubscribers: holder.getPublicTopics(),
Expand Down
2 changes: 1 addition & 1 deletion packages/orchestration/src/examples/stakeIca.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { makeTracer, StorageNodeShape } from '@agoric/internal';
import { TimerServiceShape } from '@agoric/time';
import { V as E, prepareVowTools } from '@agoric/vow/vat.js';
import { heapVowE as E, prepareVowTools } from '@agoric/vow/vat.js';
import {
prepareRecorderKitMakers,
provideAll,
Expand Down
4 changes: 2 additions & 2 deletions packages/orchestration/src/exos/local-chain-facade.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @file ChainAccount exo */
import { V, heapVowTools } from '@agoric/vow/vat.js';
import { heapVowE as E, heapVowTools } from '@agoric/vow/vat.js';

import { ChainFacadeI } from '../typeGuards.js';

Expand Down Expand Up @@ -53,7 +53,7 @@ export const prepareLocalChainFacade = (
/** @returns {Vow<OrchestrationAccount<ChainInfo>>} */
makeAccount() {
const { localChainInfo } = this.state;
const lcaP = V(localchain).makeAccount();
const lcaP = E(localchain).makeAccount();
// FIXME use watch() from vowTools
return heapVowTools.watch(allVows([lcaP, E(lcaP).getAddress()]), {
onFulfilled: ([lca, address]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import { AmountShape, PaymentShape } from '@agoric/ertp';
import { makeTracer } from '@agoric/internal';
import { M } from '@agoric/vat-data';
import { VowShape } from '@agoric/vow';
import { V } from '@agoric/vow/vat.js';
import { heapVowE as E } from '@agoric/vow/vat.js';
import { TopicsRecordShape } from '@agoric/zoe/src/contractSupport/index.js';
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
import { E } from '@endo/far';
import {
ChainAddressShape,
ChainAmountShape,
Expand Down Expand Up @@ -285,7 +284,7 @@ export const prepareLocalOrchestrationAccountKit = (
? [/** @type {any} */ (null), denomArg]
: [denomArg, 'FIXME'];

const natAmount = await V.when(
const natAmount = await E.when(
E(this.state.account).getBalance(brand),
);
return harden({ denom, value: natAmount.value });
Expand Down
6 changes: 3 additions & 3 deletions packages/orchestration/src/exos/remote-chain-facade.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @file ChainAccount exo */
import { makeTracer } from '@agoric/internal';
import { V, heapVowTools } from '@agoric/vow/vat.js';
import { heapVowE as E, heapVowTools } from '@agoric/vow/vat.js';

import { ChainFacadeI } from '../typeGuards.js';

Expand Down Expand Up @@ -69,14 +69,14 @@ export const prepareRemoteChainFacade = (
throw Fail`chain info lacks staking denom`;
}

const icaP = V(orchestration).makeAccount(
const icaP = E(orchestration).makeAccount(
remoteChainInfo.chainId,
connectionInfo.id,
connectionInfo.counterparty.connection_id,
);

// FIXME use watch() from vowTools
return heapVowTools.watch(allVows([icaP, V(icaP).getAddress()]), {
return heapVowTools.watch(allVows([icaP, E(icaP).getAddress()]), {
onFulfilled: ([account, address]) => {
return makeCosmosOrchestrationAccount(address, stakingDenom, {
account,
Expand Down
5 changes: 2 additions & 3 deletions packages/orchestration/src/proposals/start-stakeAtom.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { makeTracer } from '@agoric/internal';
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
import { E } from '@endo/far';
import { V } from '@agoric/vow/vat.js';
import { heapVowE as E } from '@agoric/vow/vat.js';
import { makeChainHub } from '../exos/chain-hub.js';

/**
Expand Down Expand Up @@ -47,7 +46,7 @@ export const startStakeAtom = async ({

const chainHub = makeChainHub(await agoricNames);

const [_, cosmoshub, connectionInfo] = await V.when(
const [_, cosmoshub, connectionInfo] = await E.when(
chainHub.getChainsAndConnection('agoric', 'cosmoshub'),
);

Expand Down
5 changes: 2 additions & 3 deletions packages/orchestration/src/proposals/start-stakeOsmo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { makeTracer } from '@agoric/internal';
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js';
import { V } from '@agoric/vow/vat.js';
import { E } from '@endo/far';
import { heapVowE as E } from '@agoric/vow/vat.js';
import { makeChainHub } from '../exos/chain-hub.js';

/**
Expand Down Expand Up @@ -48,7 +47,7 @@ export const startStakeOsmo = async ({

const chainHub = makeChainHub(await agoricNames);

const [_, osmosis, connectionInfo] = await V.when(
const [_, osmosis, connectionInfo] = await E.when(
chainHub.getChainsAndConnection('agoric', 'osmosis'),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { AmountMath } from '@agoric/ertp';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import { V } from '@agoric/vow/vat.js';
import { heapVowE as E } from '@agoric/vow/vat.js';
import { setUpZoeForTest } from '@agoric/zoe/tools/setup-zoe.js';
import { E } from '@endo/far';
import path from 'path';
import { commonSetup } from '../supports.js';

Expand Down Expand Up @@ -54,7 +53,7 @@ test('makeAccount, deposit, withdraw', async t => {
t.truthy(account, 'account is returned');

t.log('deposit 100 bld to account');
const depositResp = await V(account).deposit(
const depositResp = await E(account).deposit(
await utils.pourPayment(bld.units(100)),
);
// FIXME #9211
Expand All @@ -63,7 +62,7 @@ test('makeAccount, deposit, withdraw', async t => {
await eventLoopIteration();

t.log('withdraw bld from account');
const withdrawResp = await V(account).withdraw(bld.units(100));
const withdrawResp = await E(account).withdraw(bld.units(100));
const withdrawAmt = await bld.issuer.getAmountOf(withdrawResp);
t.true(AmountMath.isEqual(withdrawAmt, bld.units(100)), 'withdraw');

Expand Down
6 changes: 3 additions & 3 deletions packages/orchestration/test/exos/chain-hub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import test from '@endo/ses-ava/prepare-endo.js';

import { makeNameHubKit } from '@agoric/vats';
import { V } from '@agoric/vow/vat.js';
import { heapVowE as E } from '@agoric/vow/vat.js';
import { makeChainHub } from '../../src/exos/chain-hub.js';

const connection = {
Expand Down Expand Up @@ -38,11 +38,11 @@ test('getConnectionInfo', async t => {

// Look up by string or info object
t.deepEqual(
await V.when(chainHub.getConnectionInfo(aChain.chainId, bChain.chainId)),
await E.when(chainHub.getConnectionInfo(aChain.chainId, bChain.chainId)),
connection,
);
t.deepEqual(
await V.when(chainHub.getConnectionInfo(aChain, bChain)),
await E.when(chainHub.getConnectionInfo(aChain, bChain)),
connection,
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { AmountMath } from '@agoric/ertp';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import { V as E } from '@agoric/vow/vat.js';
import { heapVowE as E } from '@agoric/vow/vat.js';
import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/recorder.js';
import { Far } from '@endo/far';
import { prepareLocalOrchestrationAccountKit } from '../../src/exos/local-orchestration-account.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/orchestration/test/facade.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { V } from '@agoric/vow/vat.js';
import { heapVowE as E } from '@agoric/vow/vat.js';
import { setupZCFTest } from '@agoric/zoe/test/unitTests/zcf/setupZcfTest.js';
import type { CosmosChainInfo, IBCConnectionInfo } from '../src/cosmos-api.js';
import type { Chain } from '../src/orchestration-api.js';
Expand Down Expand Up @@ -74,7 +74,7 @@ test('chain info', async t => {
});

const result = (await handle()) as Chain<any>;
t.deepEqual(await V.when(result.getChainInfo()), mockChainInfo);
t.deepEqual(await E.when(result.getChainInfo()), mockChainInfo);
});

test.todo('contract upgrade');
2 changes: 1 addition & 1 deletion packages/vats/src/proposals/localchain-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
import { V as E } from '@agoric/vow/vat.js';
import { heapVowE as E } from '@agoric/vow/vat.js';
import { typedJson } from '@agoric/cosmic-proto/vatsafe';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/vats/src/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { isPromise } from '@endo/promise-kit';
import { Far } from '@endo/far';
import { V as E } from '@agoric/vow/vat.js';
import { heapVowE as E } from '@agoric/vow/vat.js';
import * as vowExports from '@agoric/vow/vat.js';
import * as farExports from '@endo/far';

Expand Down
2 changes: 1 addition & 1 deletion packages/vats/test/localchain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { withAmountUtils } from '@agoric/zoe/tools/test-utils.js';
import { makeDurableZone } from '@agoric/zone/durable.js';
import { getInterfaceOf } from '@endo/marshal';
import { VTRANSFER_IBC_EVENT } from '@agoric/internal';
import { prepareVowTools, V as E } from '@agoric/vow/vat.js';
import { prepareVowTools, heapVowE as E } from '@agoric/vow/vat.js';
import { prepareLocalChainTools } from '../src/localchain.js';
import { prepareBridgeTargetModule } from '../src/bridge-target.js';
import { prepareTransferTools } from '../src/transfer.js';
Expand Down
8 changes: 4 additions & 4 deletions packages/vow/test/vat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import test from 'ava';
import { E, Far } from '@endo/far';

import { V, heapVowTools } from '../vat.js';
import { heapVowE, heapVowTools } from '../vat.js';

const { makeVowKit } = heapVowTools;

Expand All @@ -13,7 +13,7 @@ test('heap messages', async t => {

/** @type {ReturnType<typeof makeVowKit<typeof greeter>>} */
const { vow, resolver } = makeVowKit();
const retP = V(vow).hello('World');
const retP = heapVowE(vow).hello('World');
resolver.resolve(greeter);

// Happy path: WE(vow)[method](...args) calls the method.
Expand All @@ -29,10 +29,10 @@ test('heap messages', async t => {
);

// Happy path: await WE.when unwraps the vow.
t.is(await V.when(vow), greeter);
t.is(await heapVowE.when(vow), greeter);

t.is(
await V.when(vow, res => {
await heapVowE.when(vow, res => {
t.is(res, greeter);
return 'done';
}),
Expand Down

0 comments on commit 3b0c8c1

Please sign in to comment.