diff --git a/packages/orchestration/src/examples/unbond.flows.js b/packages/orchestration/src/examples/unbond.flows.js index d5b9482b63b..99f19e3655f 100644 --- a/packages/orchestration/src/examples/unbond.flows.js +++ b/packages/orchestration/src/examples/unbond.flows.js @@ -4,7 +4,6 @@ const trace = makeTracer('UnbondAndTransfer'); /** * @import {Orchestrator, OrchestrationFlow, CosmosDelegationResponse} from '../types.js' - * @import {DelegationResponse} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js'; */ /** @@ -14,27 +13,27 @@ const trace = makeTracer('UnbondAndTransfer'); * @param {ZCF} ctx.zcf */ export const unbondAndTransfer = async (orch, { zcf }) => { - console.log('zcf within the membrane', zcf); + trace('zcf within the membrane', zcf); // Osmosis is one of the few chains with icqEnabled const osmosis = await orch.getChain('osmosis'); - // In a real world scenario, accounts would be re-used across invokations of the handler + const osmoDenom = (await osmosis.getChainInfo()).stakingTokens[0].denom; + + // In a real world scenario, accounts would be reused across invokations of the handler. + // See the staking-combinations contract for an example of how to reuse an account. const osmoAccount = await osmosis.makeAccount(); /** @type {CosmosDelegationResponse[]} Cosmos */ const delegations = await osmoAccount.getDelegations(); trace('delegations', delegations); + const osmoDelegations = delegations.filter(d => d.amount.denom === osmoDenom); + // wait for the undelegations to be complete (may take weeks) - await osmoAccount.undelegate(delegations); + await osmoAccount.undelegate(osmoDelegations); - // ??? should this be synchronous? depends on how names are resolved. const stride = await orch.getChain('stride'); const strideAccount = await stride.makeAccount(); - // TODO the `TIA` string actually needs to be the Brand from AgoricNames - // const tiaAmt = await celestiaAccount.getBalance('TIA'); - // await celestiaAccount.transfer(tiaAmt, strideAccount.getAddress()); - // TODO https://github.com/Agoric/agoric-sdk/issues/10017 - // await strideAccount.liquidStake(tiaAmt); - console.log(osmoAccount, strideAccount); + const balance = await osmoAccount.getBalance(osmoDenom); + await osmoAccount.transfer(balance, strideAccount.getAddress()); }; harden(unbondAndTransfer); diff --git a/packages/orchestration/test/examples/unbond.contract.test.ts b/packages/orchestration/test/examples/unbond.contract.test.ts index ff89c24aa2b..05958266b2c 100644 --- a/packages/orchestration/test/examples/unbond.contract.test.ts +++ b/packages/orchestration/test/examples/unbond.contract.test.ts @@ -6,6 +6,8 @@ import path from 'path'; import { inspectMapStore } from '@agoric/internal/src/testing-utils.js'; import { QueryDelegatorDelegationsResponse } from '@agoric/cosmic-proto/cosmos/staking/v1beta1/query.js'; import { MsgUndelegateResponse } from '@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js'; +import { MsgTransferResponse } from '@agoric/cosmic-proto/ibc/applications/transfer/v1/tx.js'; +import { QueryBalanceResponse } from '@agoric/cosmic-proto/cosmos/bank/v1beta1/query.js'; import { commonSetup } from '../supports.js'; import { buildMsgResponseString, @@ -50,6 +52,12 @@ test('start', async t => { makeDelegationsResponse(), 'eyJ0eXBlIjoxLCJkYXRhIjoiQ2xzS0pTOWpiM050YjNNdWMzUmhhMmx1Wnk1Mk1XSmxkR0V4TGsxeloxVnVaR1ZzWldkaGRHVVNNZ29MWTI5emJXOXpNWFJsYzNRU0VXTnZjMjF2YzNaaGJHOXdaWEl4ZUhsNkdoQUtCWFZ2YzIxdkVnY3hNREF3TURBdyIsIm1lbW8iOiIifQ==': makeUndelegateResponse(), + 'eyJkYXRhIjoiQ2pvS0ZBb0xZMjl6Ylc5ek1YUmxjM1FTQlhWdmMyMXZFaUl2WTI5emJXOXpMbUpoYm1zdWRqRmlaWFJoTVM1UmRXVnllUzlDWVd4aGJtTmwiLCJtZW1vIjoiIn0=': + buildQueryResponseString(QueryBalanceResponse, { + balance: { denom: 'uosmo', amount: '1234' }, + }), + 'eyJ0eXBlIjoxLCJkYXRhIjoiQ25rS0tTOXBZbU11WVhCd2JHbGpZWFJwYjI1ekxuUnlZVzV6Wm1WeUxuWXhMazF6WjFSeVlXNXpabVZ5RWt3S0NIUnlZVzV6Wm1WeUVndGphR0Z1Ym1Wc0xUTXlOaG9OQ2dWMWIzTnRieElFTVRJek5DSUxZMjl6Ylc5ek1YUmxjM1FxREdOdmMyMXZjekYwWlhOME1USUFPSUR3MXRUQ3pySUciLCJtZW1vIjoiIn0=': + buildMsgResponseString(MsgTransferResponse, {}), }; };