diff --git a/packages/orchestration/src/cosmos-api.ts b/packages/orchestration/src/cosmos-api.ts index c68645ec44b5..8c9893043259 100644 --- a/packages/orchestration/src/cosmos-api.ts +++ b/packages/orchestration/src/cosmos-api.ts @@ -10,7 +10,7 @@ import type { LocalIbcAddress, RemoteIbcAddress, } from '@agoric/vats/tools/ibc-utils.js'; -import type { AmountArg, ChainAddress, ChainAmount } from './types.js'; +import type { AmountArg, ChainAddress, DenomAmount } from './types.js'; /** A helper type for type extensions. */ export type TypeUrl = string; @@ -93,14 +93,14 @@ export interface StakingAccountQueries { * Get the pending rewards for the account. * @returns the amounts of the account's rewards pending from all validators */ - getRewards: () => Promise; + getRewards: () => Promise; /** * Get the rewards pending with a specific validator. * @param validator - the validator address to query for * @returns the amount of the account's rewards pending from a specific validator */ - getReward: (validator: CosmosValidatorAddress) => Promise; + getReward: (validator: CosmosValidatorAddress) => Promise; } export interface StakingAccountActions { /** @@ -140,14 +140,14 @@ export interface StakingAccountActions { * Withdraw rewards from all validators. The promise settles when the rewards are withdrawn. * @returns The total amounts of rewards withdrawn */ - withdrawRewards: () => Promise; + withdrawRewards: () => Promise; /** * Withdraw rewards from a specific validator. The promise settles when the rewards are withdrawn. * @param validator - the validator to withdraw rewards from * @returns */ - withdrawReward: (validator: CosmosValidatorAddress) => Promise; + withdrawReward: (validator: CosmosValidatorAddress) => Promise; } /** diff --git a/packages/orchestration/src/exos/stakingAccountKit.js b/packages/orchestration/src/exos/stakingAccountKit.js index 128c70340334..c019cda7d5e2 100644 --- a/packages/orchestration/src/exos/stakingAccountKit.js +++ b/packages/orchestration/src/exos/stakingAccountKit.js @@ -35,7 +35,7 @@ import { export const maxClockSkew = 10n * 60n; /** - * @import {AmountArg, IcaAccount, ChainAddress, ChainAmount, CosmosValidatorAddress, ICQConnection, StakingAccountActions} from '../types.js'; + * @import {AmountArg, IcaAccount, ChainAddress, ChainAmount, CosmosValidatorAddress, ICQConnection, StakingAccountActions, DenomAmount} from '../types.js'; * @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js'; * @import {Baggage} from '@agoric/swingset-liveslots'; * @import {AnyJson} from '@agoric/cosmic-proto'; @@ -128,8 +128,8 @@ export const tryDecodeResponse = (ackStr, fromProtoMsg) => { } }; -/** @type {(c: { denom: string, amount: string }) => ChainAmount} */ -const toChainAmount = c => ({ denom: c.denom, value: BigInt(c.amount) }); +/** @type {(c: { denom: string, amount: string }) => DenomAmount} */ +const toDenomAmount = c => ({ denom: c.denom, value: BigInt(c.amount) }); /** * @param {Baggage} baggage @@ -341,7 +341,7 @@ export const prepareStakingAccountKit = (baggage, makeRecorderKit, zcf) => { /** * @param {CosmosValidatorAddress} validator - * @returns {Promise} + * @returns {Promise} */ async withdrawReward(validator) { trace('withdrawReward', validator); @@ -359,11 +359,11 @@ export const prepareStakingAccountKit = (baggage, makeRecorderKit, zcf) => { ); trace('withdrawReward response', response); const { amount: coins } = response; - return harden(coins.map(toChainAmount)); + return harden(coins.map(toDenomAmount)); }, /** - * @param {ChainAmount['denom']} [denom] - defaults to bondDenom - * @returns {Promise} + * @param {DenomAmount['denom']} [denom] - defaults to bondDenom + * @returns {Promise} */ async getBalance(denom) { const { chainAddress, icqConnection, bondDenom } = this.state; @@ -383,7 +383,7 @@ export const prepareStakingAccountKit = (baggage, makeRecorderKit, zcf) => { decodeBase64(result.key), ); if (!balance) throw Fail`Result lacked balance key: ${result}`; - return harden(toChainAmount(balance)); + return harden(toDenomAmount(balance)); }, withdrawRewards() { diff --git a/packages/orchestration/src/orchestration-api.ts b/packages/orchestration/src/orchestration-api.ts index d418f336b1db..08682c348844 100644 --- a/packages/orchestration/src/orchestration-api.ts +++ b/packages/orchestration/src/orchestration-api.ts @@ -32,16 +32,15 @@ export type DenomArg = Denom | Brand; /** * Count of some fungible token on some blockchain. * - * NB: this is not an instance of the `Amount` type from ERTP but can be - * converted to one surjectively + * @see {@link Orchestrator.asAmount} to convert to an Amount surjectively */ -export type ChainAmount = { +export type DenomAmount = { denom: Denom; value: bigint; // Nat }; /** Amounts can be provided as pure data using denoms or as native Amounts */ -export type AmountArg = ChainAmount | Amount; +export type AmountArg = DenomAmount | Amount; /** An address on some blockchain, e.g., cosmos, eth, etc. */ export type ChainAddress = { @@ -111,7 +110,7 @@ export interface Orchestrator { * @param amount - the described amount * @returns the Amount in local structuerd format */ - asAmount: (amount: ChainAmount) => NatAmount; + asAmount: (amount: DenomAmount) => NatAmount; } /** @@ -124,10 +123,10 @@ export interface OrchestrationAccountI { getAddress: () => ChainAddress; /** @returns an array of amounts for every balance in the account. */ - getBalances: () => Promise; + getBalances: () => Promise; /** @returns the balance of a specific denom for the account. */ - getBalance: (denom: DenomArg) => Promise; + getBalance: (denom: DenomArg) => Promise; /** * Transfer amount to another account on the same chain. The promise settles when the transfer is complete.