From 7e2a61973d87a0aa2e7450c7220510a609c221e4 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Tue, 16 Jul 2024 11:04:49 -0700 Subject: [PATCH] =?UTF-8?q?refactor:=20ChainAmountShape=20=E2=86=92=20Deno?= =?UTF-8?q?mAmountShape?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/exos/cosmos-orchestration-account.js | 13 ++++++------- .../src/exos/local-orchestration-account.js | 3 +-- packages/orchestration/src/typeGuards.js | 6 ++---- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/orchestration/src/exos/cosmos-orchestration-account.js b/packages/orchestration/src/exos/cosmos-orchestration-account.js index befa67d8616b..50293b4253ad 100644 --- a/packages/orchestration/src/exos/cosmos-orchestration-account.js +++ b/packages/orchestration/src/exos/cosmos-orchestration-account.js @@ -1,7 +1,4 @@ /** @file Use-object for the owner of a staking account */ -import { Fail } from '@endo/errors'; -import { decodeBase64 } from '@endo/base64'; -import { E } from '@endo/far'; import { toRequestQueryJson } from '@agoric/cosmic-proto'; import { QueryBalanceRequest, @@ -22,12 +19,14 @@ import { makeTracer } from '@agoric/internal'; import { Shape as NetworkShape } from '@agoric/network'; import { M } from '@agoric/vat-data'; import { VowShape } from '@agoric/vow'; +import { decodeBase64 } from '@endo/base64'; +import { Fail } from '@endo/errors'; +import { E } from '@endo/far'; import { AmountArgShape, ChainAddressShape, - ChainAmountShape, - DenomAmountShape, DelegationShape, + DenomAmountShape, } from '../typeGuards.js'; import { maxClockSkew, tryDecodeResponse } from '../utils/cosmos.js'; import { orchestrationAccountMethods } from '../utils/orchestrationAccount.js'; @@ -78,9 +77,9 @@ export const IcaAccountHolderI = M.interface('IcaAccountHolder', { AmountArgShape, ).returns(VowShape), withdrawReward: M.call(ChainAddressShape).returns( - Vow$(M.arrayOf(ChainAmountShape)), + Vow$(M.arrayOf(DenomAmountShape)), ), - withdrawRewards: M.call().returns(Vow$(M.arrayOf(ChainAmountShape))), + withdrawRewards: M.call().returns(Vow$(M.arrayOf(DenomAmountShape))), undelegate: M.call(M.arrayOf(DelegationShape)).returns(VowShape), }); diff --git a/packages/orchestration/src/exos/local-orchestration-account.js b/packages/orchestration/src/exos/local-orchestration-account.js index 4159912c91dd..2a21a9053683 100644 --- a/packages/orchestration/src/exos/local-orchestration-account.js +++ b/packages/orchestration/src/exos/local-orchestration-account.js @@ -8,7 +8,6 @@ import { VowShape } from '@agoric/vow'; import { E } from '@endo/far'; import { ChainAddressShape, - ChainAmountShape, DenomAmountShape, DenomShape, IBCTransferOptionsShape, @@ -105,7 +104,7 @@ export const prepareLocalOrchestrationAccountKit = ( .optional({ destination: ChainAddressShape, opts: M.or(M.undefined(), IBCTransferOptionsShape), - amount: ChainAmountShape, + amount: DenomAmountShape, }) .returns(Vow$(M.record())), }), diff --git a/packages/orchestration/src/typeGuards.js b/packages/orchestration/src/typeGuards.js index 896b4f282c85..800b2ced1ca4 100644 --- a/packages/orchestration/src/typeGuards.js +++ b/packages/orchestration/src/typeGuards.js @@ -35,10 +35,6 @@ export const Proto3Shape = { value: M.string(), }; -export const ChainAmountShape = harden({ denom: M.string(), value: M.nat() }); - -export const AmountArgShape = M.or(AmountShape, ChainAmountShape); - // FIXME missing `delegatorAddress` from the type /** @type {TypedPattern} */ export const DelegationShape = harden({ @@ -108,6 +104,8 @@ export const BrandInfoShape = M.any(); /** @type {TypedPattern} */ export const DenomAmountShape = { denom: DenomShape, value: M.bigint() }; +export const AmountArgShape = M.or(AmountShape, DenomAmountShape); + /** @see {Chain} */ export const ChainFacadeI = M.interface('ChainFacade', { getChainInfo: M.call().returns(VowShape),