Skip to content

Commit

Permalink
feat(portfolio-holder): optional invitationArgs in Proxying invitat…
Browse files Browse the repository at this point in the history
…ionMaker
  • Loading branch information
0xpatrickdev committed Oct 4, 2024
1 parent 4e129e2 commit 47e754e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/orchestration/src/exos/portfolio-holder-kit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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<Invitation<unknown, IA>>}
*/
Proxying(chainName, action, invitationArgs) {
Expand All @@ -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 || [])),
);
},
},
Expand Down
13 changes: 13 additions & 0 deletions packages/orchestration/test/exos/portfolio-holder-kit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>'
'Transfer',
'invitationArgs are optional',
);

const osmosisAccount = await makeCosmosAccount({
chainId: 'osmosis-99',
hostConnectionId: 'connection-2' as const,
Expand Down

0 comments on commit 47e754e

Please sign in to comment.