From fec5d7915d125ebb96854d802b9c03160253367e Mon Sep 17 00:00:00 2001 From: 0xPatrick Date: Thu, 3 Oct 2024 16:55:00 -0400 Subject: [PATCH] feat(portfolio-holder): optional invitationArgs in `Proxying` invitationMaker --- .../orchestration/src/exos/portfolio-holder-kit.js | 12 +++++------- .../test/exos/portfolio-holder-kit.test.ts | 13 +++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/orchestration/src/exos/portfolio-holder-kit.js b/packages/orchestration/src/exos/portfolio-holder-kit.js index 059eebe03e1..a163dab1981 100644 --- a/packages/orchestration/src/exos/portfolio-holder-kit.js +++ b/packages/orchestration/src/exos/portfolio-holder-kit.js @@ -43,11 +43,9 @@ const preparePortfolioHolderKit = (zone, { asVow, when }) => { 'PortfolioHolderKit', { invitationMakers: M.interface('InvitationMakers', { - Proxying: M.call( - ChainNameShape, - M.string(), - M.arrayOf(M.any()), - ).returns(M.promise()), + Proxying: M.call(ChainNameShape, M.string()) + .optional(M.arrayOf(M.any())) + .returns(M.promise()), }), holder: M.interface('Holder', { asContinuingOffer: M.call().returns(VowShape), @@ -92,7 +90,7 @@ const preparePortfolioHolderKit = (zone, { asVow, when }) => { * @template {unknown[]} IA * @param {string} chainName key where the account is stored * @param {string} action invitation maker name, e.g. 'Delegate' - * @param {IA} invitationArgs + * @param {IA} [invitationArgs] * @returns {Promise>} */ Proxying(chainName, action, invitationArgs) { @@ -101,7 +99,7 @@ const preparePortfolioHolderKit = (zone, { asVow, when }) => { const account = accounts.get(chainName); // @ts-expect-error XXX invitationMakers return when(E(account).asContinuingOffer(), ({ invitationMakers }) => - E(invitationMakers)[action](...invitationArgs), + E(invitationMakers)[action](...(invitationArgs || [])), ); }, }, diff --git a/packages/orchestration/test/exos/portfolio-holder-kit.test.ts b/packages/orchestration/test/exos/portfolio-holder-kit.test.ts index 62f48203f25..a498b9b0c2c 100644 --- a/packages/orchestration/test/exos/portfolio-holder-kit.test.ts +++ b/packages/orchestration/test/exos/portfolio-holder-kit.test.ts @@ -102,6 +102,19 @@ test('portfolio holder kit behaviors', async t => { 'any invitation maker accessible via Proxying', ); + // scenario with optional invitationArgs + const transferInv = await E(invitationMakers).Proxying( + 'cosmoshub', + 'Transfer', + ); + t.is( + transferInv, + // note: mocked zcf (we are not in a contract) returns inv description + // @ts-expect-error Argument of type 'string' is not assignable to parameter of type 'Vow' + 'Transfer', + 'invitationArgs are optional', + ); + const osmosisAccount = await makeCosmosAccount({ chainId: 'osmosis-99', hostConnectionId: 'connection-2' as const,