From 11aea6561865a8ac17c449a6fcf226dcd52e7c22 Mon Sep 17 00:00:00 2001 From: 0xPatrick Date: Fri, 14 Jun 2024 15:53:03 -0400 Subject: [PATCH] fix(undelegate): `delegatorAddress` should not be user supplied --- packages/orchestration/src/cosmos-api.ts | 4 +++- packages/orchestration/src/exos/cosmosOrchestrationAccount.js | 4 ++-- packages/orchestration/src/typeGuards.js | 1 - packages/orchestration/test/staking-ops.test.ts | 1 - 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/orchestration/src/cosmos-api.ts b/packages/orchestration/src/cosmos-api.ts index 2eefdd7b9f8..08a95916ccd 100644 --- a/packages/orchestration/src/cosmos-api.ts +++ b/packages/orchestration/src/cosmos-api.ts @@ -151,7 +151,9 @@ export interface StakingAccountActions { * The unbonding time is padded by 10 minutes to account for clock skew. * @param delegations - the delegation to undelegate */ - undelegate: (delegations: Delegation[]) => Promise; + undelegate: ( + delegations: Omit[], + ) => Promise; /** * Withdraw rewards from all validators. The promise settles when the rewards are withdrawn. diff --git a/packages/orchestration/src/exos/cosmosOrchestrationAccount.js b/packages/orchestration/src/exos/cosmosOrchestrationAccount.js index c69f01b6b27..529f35c77d4 100644 --- a/packages/orchestration/src/exos/cosmosOrchestrationAccount.js +++ b/packages/orchestration/src/exos/cosmosOrchestrationAccount.js @@ -234,7 +234,7 @@ export const prepareCosmosOrchestrationAccountKit = ( return this.facets.holder.withdrawReward(validator); }, 'WithdrawReward'); }, - /** @param {Delegation[]} delegations */ + /** @param {Omit[]} delegations */ Undelegate(delegations) { trace('Undelegate', delegations); @@ -407,7 +407,7 @@ export const prepareCosmosOrchestrationAccountKit = ( throw assert.error('Not implemented'); }, - /** @param {Delegation[]} delegations */ + /** @param {Omit[]} delegations */ async undelegate(delegations) { trace('undelegate', delegations); const { helper } = this.facets; diff --git a/packages/orchestration/src/typeGuards.js b/packages/orchestration/src/typeGuards.js index 6cc02a4dbad..e3a836cf2dc 100644 --- a/packages/orchestration/src/typeGuards.js +++ b/packages/orchestration/src/typeGuards.js @@ -25,7 +25,6 @@ export const ChainAmountShape = harden({ denom: M.string(), value: M.nat() }); export const AmountArgShape = M.or(AmountShape, ChainAmountShape); export const DelegationShape = harden({ - delegatorAddress: M.string(), validatorAddress: M.string(), shares: M.string(), // TODO: bigint? }); diff --git a/packages/orchestration/test/staking-ops.test.ts b/packages/orchestration/test/staking-ops.test.ts index 5c07ade3e19..f6eb1bd8e9a 100644 --- a/packages/orchestration/test/staking-ops.test.ts +++ b/packages/orchestration/test/staking-ops.test.ts @@ -378,7 +378,6 @@ test(`undelegate waits for unbonding period`, async t => { const value = BigInt(Object.values(delegations)[0].amount); const anAmount = { brand: Far('Token'), value } as Amount<'nat'>; const delegation = { - delegatorAddress: account.getAddress().address, shares: `${anAmount.value}`, validatorAddress: validator.address, };