Skip to content

Commit

Permalink
WIP fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Sep 11, 2024
1 parent 41cca56 commit 81a8fec
Showing 1 changed file with 44 additions and 15 deletions.
59 changes: 44 additions & 15 deletions packages/orchestration/src/exos/cosmos-orchestration-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ import {
} from '../utils/cosmos.js';
import { orchestrationAccountMethods } from '../utils/orchestrationAccount.js';
import { makeTimestampHelper } from '../utils/time.js';
import { QueryDelegationRewardsRequest } from '@agoric/cosmic-proto/cosmos/distribution/v1beta1/query.js';
import {
QueryDelegationRequest,
QueryDelegatorDelegationsRequest,
QueryDelegatorUnbondingDelegationsRequest,
QueryRedelegationsRequest,
QueryUnbondingDelegationRequest,
} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/query.js';

/**
* @import {HostOf} from '@agoric/async-flow';
Expand Down Expand Up @@ -661,8 +669,8 @@ export const prepareCosmosOrchestrationAccountKit = (
const results = E(icqConnection).query([
toRequestQueryJson(
QueryDelegationRequest.toProtoMsg({
delegatorAddress: chainAddress.value,
validatorAddress: validator.value,
delegatorAddr: chainAddress.value,
validatorAddr: validator.value,
}),
),
]);
Expand All @@ -680,8 +688,8 @@ export const prepareCosmosOrchestrationAccountKit = (
}
const results = E(icqConnection).query([
toRequestQueryJson(
QueryDelegationsRequest.toProtoMsg({
delegatorAddress: chainAddress.value,
QueryDelegatorDelegationsRequest.toProtoMsg({
delegatorAddr: chainAddress.value,
}),
),
]);
Expand All @@ -700,8 +708,8 @@ export const prepareCosmosOrchestrationAccountKit = (
const results = E(icqConnection).query([
toRequestQueryJson(
QueryUnbondingDelegationRequest.toProtoMsg({
delegatorAddress: chainAddress.value,
validatorAddress: validator.value,
delegatorAddr: chainAddress.value,
validatorAddr: validator.value,
}),
),
]);
Expand All @@ -719,8 +727,8 @@ export const prepareCosmosOrchestrationAccountKit = (
}
const results = E(icqConnection).query([
toRequestQueryJson(
QueryUnbondingDelegationsRequest.toProtoMsg({
delegatorAddress: chainAddress.value,
QueryDelegatorUnbondingDelegationsRequest.toProtoMsg({
delegatorAddr: chainAddress.value,
}),
),
]);
Expand All @@ -738,10 +746,10 @@ export const prepareCosmosOrchestrationAccountKit = (
}
const results = E(icqConnection).query([
toRequestQueryJson(
QueryRedelegationRequest.toProtoMsg({
delegatorAddress: chainAddress.value,
validatorSrcAddress: srcValidator.value,
validatorDstAddress: dstValidator.value,
QueryRedelegationsRequest.toProtoMsg({
delegatorAddr: chainAddress.value,
srcValidatorAddr: srcValidator.value,
dstValidatorAddr: dstValidator?.value,
}),
),
]);
Expand All @@ -760,7 +768,7 @@ export const prepareCosmosOrchestrationAccountKit = (
const results = E(icqConnection).query([
toRequestQueryJson(
QueryRedelegationsRequest.toProtoMsg({
delegatorAddress: chainAddress.value,
delegatorAddr: chainAddress.value,
}),
),
]);
Expand All @@ -778,7 +786,7 @@ export const prepareCosmosOrchestrationAccountKit = (
}
const results = E(icqConnection).query([
toRequestQueryJson(
QueryRewardRequest.toProtoMsg({
QueryDelegationRewardsRequest.toProtoMsg({
delegatorAddress: chainAddress.value,
validatorAddress: validator.value,
}),
Expand All @@ -798,7 +806,7 @@ export const prepareCosmosOrchestrationAccountKit = (
}
const results = E(icqConnection).query([
toRequestQueryJson(
QueryRewardsRequest.toProtoMsg({
QueryDelegationRewardsRequest.toProtoMsg({
delegatorAddress: chainAddress.value,
}),
),
Expand All @@ -807,6 +815,27 @@ export const prepareCosmosOrchestrationAccountKit = (
});
},

/** @type {HostOf<OrchestrationAccountI['send']>} */
send(toAccount, amount) {
return asVow(() => {
trace('send', toAccount, amount);
const { helper } = this.facets;
const { chainAddress } = this.state;
return watch(
E(helper.owned()).executeEncodedTx([
Any.toJSON(
MsgSend.toProtoMsg({
fromAddress: chainAddress.value,
toAddress: toAccount.value,
amount: [helper.amountToCoin(amount)],
}),
),
]),
this.facets.returnVoidWatcher,
);
});
},

/** @type {HostOf<OrchestrationAccountI['sendAll']>} */
sendAll(toAccount, amounts) {
return asVow(() => {
Expand Down

0 comments on commit 81a8fec

Please sign in to comment.