From dd61e16283693c71bd0e8dc392c5986dc42d5689 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 17 Sep 2024 13:35:49 -0700 Subject: [PATCH] feat(examples): logging progress --- .../src/examples/send-anywhere.contract.js | 11 ++++- .../src/examples/send-anywhere.flows.js | 10 +++-- .../snapshots/send-anywhere.test.ts.md | 42 +++++++++++------- .../snapshots/send-anywhere.test.ts.snap | Bin 1288 -> 1309 bytes 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/packages/orchestration/src/examples/send-anywhere.contract.js b/packages/orchestration/src/examples/send-anywhere.contract.js index ebe77f1af7d..b05bab026a9 100644 --- a/packages/orchestration/src/examples/send-anywhere.contract.js +++ b/packages/orchestration/src/examples/send-anywhere.contract.js @@ -1,12 +1,15 @@ import { makeSharedStateRecord } from '@agoric/async-flow'; + import { AmountShape } from '@agoric/ertp'; import { InvitationShape } from '@agoric/zoe/src/typeGuards.js'; import { M } from '@endo/patterns'; +import { E } from '@endo/far'; import { withOrchestration } from '../utils/start-helper.js'; import * as flows from './send-anywhere.flows.js'; import { prepareChainHubAdmin } from '../exos/chain-hub-admin.js'; /** + * @import {Vow} from '@agoric/vow'; * @import {Zone} from '@agoric/zone'; * @import {OrchestrationPowers, OrchestrationTools} from '../utils/start-helper.js'; */ @@ -33,7 +36,7 @@ const contract = async ( zcf, privateArgs, zone, - { chainHub, orchestrateAll, zoeTools }, + { chainHub, orchestrateAll, vowTools, zoeTools }, ) => { const contractState = makeSharedStateRecord( /** @type {{ account: OrchestrationAccount | undefined }} */ { @@ -43,10 +46,16 @@ const contract = async ( const creatorFacet = prepareChainHubAdmin(zone, chainHub); + // UNTIL https://github.com/Agoric/agoric-sdk/issues/9066 + const logNode = E(privateArgs.storageNode).makeChildNode('log'); + /** @type {(msg: string) => Vow} */ + const log = msg => vowTools.watch(E(logNode).setValue(msg)); + // orchestrate uses the names on orchestrationFns to do a "prepare" of the associated behavior const orchFns = orchestrateAll(flows, { zcf, contractState, + log, localTransfer: zoeTools.localTransfer, }); diff --git a/packages/orchestration/src/examples/send-anywhere.flows.js b/packages/orchestration/src/examples/send-anywhere.flows.js index 6c7128df268..191109d025b 100644 --- a/packages/orchestration/src/examples/send-anywhere.flows.js +++ b/packages/orchestration/src/examples/send-anywhere.flows.js @@ -3,6 +3,7 @@ import { M, mustMatch } from '@endo/patterns'; /** * @import {GuestOf} from '@agoric/async-flow'; + * @import {Vow} from '@agoric/vow'; * @import {ZoeTools} from '../utils/zoe-tools.js'; * @import {Orchestrator, LocalAccountMethods, OrchestrationAccountI, OrchestrationFlow} from '../types.js'; */ @@ -18,12 +19,13 @@ const { entries } = Object; * @param {object} ctx * @param {{ localAccount?: OrchestrationAccountI & LocalAccountMethods }} ctx.contractState * @param {GuestOf} ctx.localTransfer + * @param {GuestOf<(msg: string) => Vow>} ctx.log * @param {ZCFSeat} seat * @param {{ chainName: string; destAddr: string }} offerArgs */ export const sendIt = async ( orch, - { contractState, localTransfer }, + { contractState, localTransfer, log }, seat, offerArgs, ) => { @@ -32,8 +34,10 @@ export const sendIt = async ( // NOTE the proposal shape ensures that the `give` is a single asset const { give } = seat.getProposal(); const [[_kw, amt]] = entries(give); + void log(`sending {${amt.value}} from ${chainName} to ${destAddr}`); const agoric = await orch.getChain('agoric'); const assets = await agoric.getVBankAssetInfo(); + void log(`got info for denoms: ${assets.map(a => a.denom).join(', ')}`); const { denom } = NonNullish( assets.find(a => a.brand === amt.brand), `${amt.brand} not registered in vbank`, @@ -41,8 +45,7 @@ export const sendIt = async ( const chain = await orch.getChain(chainName); if (!contractState.localAccount) { - const agoricChain = await orch.getChain('agoric'); - contractState.localAccount = await agoricChain.makeAccount(); + contractState.localAccount = await agoric.makeAccount(); } const info = await chain.getChainInfo(); @@ -65,5 +68,6 @@ export const sendIt = async ( }, ); seat.exit(); + void log(`transfer complete, seat exited`); }; harden(sendIt); diff --git a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md index 9cc05e0959f..874ee76b50c 100644 --- a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md +++ b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md @@ -1,6 +1,6 @@ -# Snapshot report for `test/examples/sendAnywhere.test.ts` +# Snapshot report for `test/examples/send-anywhere.test.ts` -The actual snapshot is saved in `sendAnywhere.test.ts.snap`. +The actual snapshot is saved in `send-anywhere.test.ts.snap`. Generated by [AVA](https://avajs.dev). @@ -27,8 +27,10 @@ Generated by [AVA](https://avajs.dev). chainHub: { ChainHub_kindHandle: 'Alleged: kind', ChainHub_singleton: 'Alleged: ChainHub', + brandDenom: {}, chainInfos: {}, connectionInfos: {}, + denom: {}, lookupChainInfo_kindHandle: 'Alleged: kind', lookupChainsAndConnection_kindHandle: 'Alleged: kind', lookupConnectionInfo_kindHandle: 'Alleged: kind', @@ -38,7 +40,21 @@ Generated by [AVA](https://avajs.dev). 'ChainHub Admin_singleton': 'Alleged: ChainHub Admin', 'Send PF_kindHandle': 'Alleged: kind', 'Send PF_singleton': 'Alleged: Send PF', - findBrandInVBank_kindHandle: 'Alleged: kind', + orchestration: { + sendIt: { + asyncFlow_kindHandle: 'Alleged: kind', + endowments: { + 0: { + contractState_kindHandle: 'Alleged: kind', + contractState_singleton: 'Alleged: contractState', + localTransfer_kindHandle: 'Alleged: kind', + localTransfer_singleton: 'Alleged: localTransfer', + log_kindHandle: 'Alleged: kind', + log_singleton: 'Alleged: log', + }, + }, + }, + }, }, orchestration: { 'Cosmos Orchestration Account Holder_kindHandle': 'Alleged: kind', @@ -46,18 +62,14 @@ Generated by [AVA](https://avajs.dev). LocalChainFacade_kindHandle: 'Alleged: kind', Orchestrator_kindHandle: 'Alleged: kind', RemoteChainFacade_kindHandle: 'Alleged: kind', - sendIt: { - asyncFlow_kindHandle: 'Alleged: kind', - endowments: { - 1: { - contractState_kindHandle: 'Alleged: kind', - contractState_singleton: 'Alleged: contractState', - findBrandInVBank_kindHandle: 'Alleged: kind', - findBrandInVBank_singleton: 'Alleged: findBrandInVBank', - localTransfer_kindHandle: 'Alleged: kind', - localTransfer_singleton: 'Alleged: localTransfer', - }, - }, + chainName: {}, + ibcTools: { + IBCTransferSenderKit_kindHandle: 'Alleged: kind', + ibcResultWatcher_kindHandle: 'Alleged: kind', + ibcResultWatcher_singleton: 'Alleged: ibcResultWatcher', + }, + packetTools: { + PacketToolsKit_kindHandle: 'Alleged: kind', }, }, vows: { diff --git a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap index db5e4fcd09358ecf830457f606c586941142ccf2..e29cb8eb0e236ac0f9b1c6e76002f7fa3332e0c7 100644 GIT binary patch literal 1309 zcmV+&1>*WaRzVmgOD0om5@h0u1h$j#BCgQ<^V8MfjLZMJl@Zdo&f}mh_HnThP zCRujkUUr$^|Nndc@Asd*z1?tywd>!y!=xi!)@;yblQx;-bK3TIg!FISv27~p>$Qh@ zl+pbVjp%CtHUNAA;68xg0OSa;K!BGC@EQRoNoj(V)*EjzOA^xmS*z7R3=j>(#3ad0 zkvvFof}FY#c(mcN`bN-j9e=0(sw3arb-2Akx$Uw@%vf|?)@1fe^)9AxOl~qucsBD! zP^=QNO@Ij2sehAO%dY5z(AP0Yvv#P%SAs@}{F6Wgmmalbh`g8^AcpX)9p+1qN=NVz zz7c~9H$=w|pMDj4ntxZYZg|HZ^RvqDsi^ zu|Zc&^*TG?)+@Bhyz6wAdA;8ICMGq}ms+Nd8+fcI@-Qy4?TXH_@YVxqi59z-%9b94 zR$ij*=*e{7v<{=YmuNc-L0ECR8la{9DU&ro$NGw?^i1^imf|Dq@0e4ShDW)5fpO6a zv6=B077o5uzAbveI2XfAOK{#R&4IvHOrU7@I1{$cxkBs)?WKq}tFKSR^!-I{FZGSc z%JjrOQ^Jc8NDPpoTA@*Jd%c`_Rw(L2W<^p`t%EJb?fS-Y*7GMKz0|?AzS_P>nB=#| z55MLPxYwUw5`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