From 5c0ea369508de6d38cd34727580226b69b5e1afc Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Tue, 25 Jun 2024 16:42:30 -0500 Subject: [PATCH 1/2] chore: contractState.account type alignment --- .../orchestration/src/examples/sendAnywhere.contract.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/orchestration/src/examples/sendAnywhere.contract.js b/packages/orchestration/src/examples/sendAnywhere.contract.js index 47c8b4d0f60..44a2362f88d 100644 --- a/packages/orchestration/src/examples/sendAnywhere.contract.js +++ b/packages/orchestration/src/examples/sendAnywhere.contract.js @@ -38,7 +38,7 @@ const { entries } = Object; * @param {object} ctx * @param {ZCF} ctx.zcf * @param {any} ctx.agoricNamesTools TODO Give this a better type - * @param {{ account: OrchestrationAccount }} ctx.contractState + * @param {{ account: OrchestrationAccount | undefined }} ctx.contractState * @param {ZCFSeat} seat * @param {object} offerArgs * @param {string} offerArgs.chainName @@ -68,8 +68,8 @@ const sendItFn = async ( const { chainId } = info; assert(typeof chainId === 'string', 'bad chainId'); const { [kw]: pmtP } = await withdrawFromSeat(zcf, seat, give); - await E.when(pmtP, pmt => contractState.account.deposit(pmt)); - await contractState.account.transfer( + await E.when(pmtP, pmt => contractState.account?.deposit(pmt)); + await contractState.account?.transfer( { denom, value: amt.value }, { address: destAddr, From e12036c50a317f622ee16cbd79a96582f689f5f8 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Tue, 25 Jun 2024 17:22:51 -0500 Subject: [PATCH 2/2] chore: preserve type thru makeStateRecord() --- packages/async-flow/src/endowments.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/async-flow/src/endowments.js b/packages/async-flow/src/endowments.js index 8eb8b948583..209eae0c8f2 100644 --- a/packages/async-flow/src/endowments.js +++ b/packages/async-flow/src/endowments.js @@ -59,8 +59,10 @@ export const forwardingMethods = rem => { * gets and sets, but is implemented using accessors, so it will be recognized * as a state record. * - * @param {object} dataRecord - * @returns {object} + * @template { string | number | symbol } K + * @template {Record} R + * @param {R} dataRecord + * @returns {R} */ export const makeStateRecord = dataRecord => harden(