@agoric/orchestration 0.1.1-dev-a446a00.0 → 0.1.1-dev-ceec1d5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/package.json +15 -15
  2. package/src/chain-info.d.ts +5 -2
  3. package/src/chain-info.d.ts.map +1 -1
  4. package/src/chain-info.ts +3 -3
  5. package/src/cosmos-api.d.ts +2 -5
  6. package/src/cosmos-api.d.ts.map +1 -1
  7. package/src/cosmos-api.ts +1 -3
  8. package/src/examples/stakeAtom.contract.d.ts +32 -19
  9. package/src/examples/stakeAtom.contract.d.ts.map +1 -1
  10. package/src/examples/stakeAtom.contract.js +21 -24
  11. package/src/examples/stakeBld.contract.d.ts.map +1 -1
  12. package/src/examples/stakeBld.contract.js +1 -1
  13. package/src/examples/swapExample.contract.d.ts +17 -6
  14. package/src/examples/swapExample.contract.d.ts.map +1 -1
  15. package/src/examples/swapExample.contract.js +9 -6
  16. package/src/examples/unbondExample.contract.d.ts.map +1 -1
  17. package/src/examples/unbondExample.contract.js +9 -7
  18. package/src/exos/chainAccountKit.d.ts +6 -8
  19. package/src/exos/chainAccountKit.d.ts.map +1 -1
  20. package/src/exos/chainAccountKit.js +23 -24
  21. package/src/exos/{stakingAccountKit.d.ts → cosmosOrchestrationAccount.d.ts} +69 -24
  22. package/src/exos/cosmosOrchestrationAccount.d.ts.map +1 -0
  23. package/src/exos/{stakingAccountKit.js → cosmosOrchestrationAccount.js} +89 -34
  24. package/src/exos/icqConnectionKit.d.ts.map +1 -1
  25. package/src/exos/icqConnectionKit.js +6 -8
  26. package/src/exos/local-chain-account-kit.d.ts +1 -1
  27. package/src/exos/local-chain-account-kit.d.ts.map +1 -1
  28. package/src/exos/local-chain-account-kit.js +5 -3
  29. package/src/facade.d.ts +3 -3
  30. package/src/facade.d.ts.map +1 -1
  31. package/src/facade.js +95 -80
  32. package/src/orchestration-api.d.ts +1 -1
  33. package/src/orchestration-api.d.ts.map +1 -1
  34. package/src/orchestration-api.ts +1 -1
  35. package/src/proposals/start-stakeAtom.d.ts +27 -19
  36. package/src/proposals/start-stakeAtom.d.ts.map +1 -1
  37. package/src/utils/mockChainInfo.d.ts +1 -2
  38. package/src/utils/mockChainInfo.d.ts.map +1 -1
  39. package/src/utils/mockChainInfo.js +2 -10
  40. package/src/utils/orchestrationAccount.d.ts +10 -0
  41. package/src/utils/orchestrationAccount.d.ts.map +1 -0
  42. package/src/utils/orchestrationAccount.js +19 -0
  43. package/src/exos/stakingAccountKit.d.ts.map +0 -1
@@ -1,15 +1,15 @@
1
1
  /** @file ChainAccount exo */
2
2
  import { NonNullish } from '@agoric/assert';
3
+ import { PurseShape } from '@agoric/ertp';
3
4
  import { makeTracer } from '@agoric/internal';
4
5
  import { V as E } from '@agoric/vow/vat.js';
5
6
  import { M } from '@endo/patterns';
6
- import { PaymentShape, PurseShape } from '@agoric/ertp';
7
- import { findAddressField } from '../utils/address.js';
8
7
  import {
9
- ConnectionHandlerI,
10
8
  ChainAddressShape,
9
+ ConnectionHandlerI,
11
10
  Proto3Shape,
12
11
  } from '../typeGuards.js';
12
+ import { findAddressField } from '../utils/address.js';
13
13
  import { makeTxPacket, parseTxPacket } from '../utils/packet.js';
14
14
 
15
15
  /**
@@ -30,6 +30,8 @@ const UNPARSABLE_CHAIN_ADDRESS = 'UNPARSABLE_CHAIN_ADDRESS';
30
30
 
31
31
  export const ChainAccountI = M.interface('ChainAccount', {
32
32
  getAddress: M.call().returns(ChainAddressShape),
33
+ getBalance: M.callWhen(M.string()).returns(M.any()),
34
+ getBalances: M.callWhen().returns(M.any()),
33
35
  getLocalAddress: M.call().returns(M.string()),
34
36
  getRemoteAddress: M.call().returns(M.string()),
35
37
  getPort: M.call().returns(M.remotable('Port')),
@@ -38,7 +40,6 @@ export const ChainAccountI = M.interface('ChainAccount', {
38
40
  .optional(M.record())
39
41
  .returns(M.promise()),
40
42
  close: M.callWhen().returns(M.undefined()),
41
- deposit: M.callWhen(PaymentShape).returns(M.undefined()),
42
43
  getPurse: M.callWhen().returns(PurseShape),
43
44
  });
44
45
 
@@ -63,27 +64,31 @@ export const prepareChainAccountKit = zone =>
63
64
  * @param {string} requestedRemoteAddress
64
65
  */
65
66
  (port, requestedRemoteAddress) =>
66
- /** @type {State} */ (
67
- harden({
68
- port,
69
- connection: undefined,
70
- requestedRemoteAddress,
71
- remoteAddress: undefined,
72
- chainAddress: undefined,
73
- localAddress: undefined,
74
- })
75
- ),
67
+ /** @type {State} */ ({
68
+ port,
69
+ connection: undefined,
70
+ requestedRemoteAddress,
71
+ remoteAddress: undefined,
72
+ chainAddress: undefined,
73
+ localAddress: undefined,
74
+ }),
76
75
  {
77
76
  account: {
78
- /**
79
- * @returns {ChainAddress}
80
- */
77
+ /** @returns {ChainAddress} */
81
78
  getAddress() {
82
79
  return NonNullish(
83
80
  this.state.chainAddress,
84
81
  'ICA channel creation acknowledgement not yet received.',
85
82
  );
86
83
  },
84
+ getBalance(_denom) {
85
+ // UNTIL https://github.com/Agoric/agoric-sdk/issues/9326
86
+ throw new Error('not yet implemented');
87
+ },
88
+ getBalances() {
89
+ // UNTIL https://github.com/Agoric/agoric-sdk/issues/9326
90
+ throw new Error('not yet implemented');
91
+ },
87
92
  getLocalAddress() {
88
93
  return NonNullish(
89
94
  this.state.localAddress,
@@ -121,9 +126,7 @@ export const prepareChainAccountKit = zone =>
121
126
  ack => parseTxPacket(ack),
122
127
  );
123
128
  },
124
- /**
125
- * Close the remote account
126
- */
129
+ /** Close the remote account */
127
130
  async close() {
128
131
  /// XXX what should the behavior be here? and `onClose`?
129
132
  // - retrieve assets?
@@ -132,10 +135,6 @@ export const prepareChainAccountKit = zone =>
132
135
  if (!connection) throw Fail`connection not available`;
133
136
  await E(connection).close();
134
137
  },
135
- async deposit(payment) {
136
- console.log('deposit got', payment);
137
- throw new Error('not yet implemented');
138
- },
139
138
  /**
140
139
  * get Purse for a brand to .withdraw() a Payment from the account
141
140
  *
@@ -1,42 +1,49 @@
1
1
  /**
2
- * @typedef {object} StakingAccountNotification
2
+ * @typedef {object} ComosOrchestrationAccountNotification
3
3
  * @property {ChainAddress} chainAddress
4
4
  */
5
5
  /**
6
6
  * @typedef {{
7
- * topicKit: RecorderKit<StakingAccountNotification>;
7
+ * topicKit: RecorderKit<ComosOrchestrationAccountNotification>;
8
8
  * account: IcaAccount;
9
9
  * chainAddress: ChainAddress;
10
10
  * icqConnection: ICQConnection;
11
11
  * bondDenom: string;
12
- * timer: TimerService;
12
+ * timer: Remote<TimerService>;
13
13
  * }} State
14
14
  */
15
+ /** @see {OrchestrationAccountI} */
15
16
  export const IcaAccountHolderI: import("@endo/patterns").InterfaceGuard<{
17
+ asContinuingOffer: import("@endo/patterns").MethodGuard;
16
18
  getPublicTopics: import("@endo/patterns").MethodGuard;
17
- getAddress: import("@endo/patterns").MethodGuard;
18
- getBalance: import("@endo/patterns").MethodGuard;
19
19
  delegate: import("@endo/patterns").MethodGuard;
20
20
  redelegate: import("@endo/patterns").MethodGuard;
21
21
  withdrawReward: import("@endo/patterns").MethodGuard;
22
22
  withdrawRewards: import("@endo/patterns").MethodGuard;
23
23
  undelegate: import("@endo/patterns").MethodGuard;
24
+ getAddress: import("@endo/patterns").MethodGuard;
25
+ getBalance: import("@endo/patterns").MethodGuard;
26
+ getBalances: import("@endo/patterns").MethodGuard;
27
+ send: import("@endo/patterns").MethodGuard;
28
+ transfer: import("@endo/patterns").MethodGuard;
29
+ transferSteps: import("@endo/patterns").MethodGuard;
30
+ deposit: import("@endo/patterns").MethodGuard;
24
31
  }>;
25
32
  export const trivialDelegateResponse: string;
26
- export function prepareStakingAccountKit(zone: Zone, makeRecorderKit: <T>(storageNode: StorageNode | Awaited<import("@endo/far").FarRef<StorageNode>>, valueShape?: import("@agoric/zoe/src/contractSupport/recorder.js").TypedMatcher<T> | undefined) => RecorderKit<T>, zcf: ZCF): (chainAddress: ChainAddress, bondDenom: string, io: {
33
+ export function prepareCosmosOrchestrationAccountKit(zone: Zone, makeRecorderKit: <T>(storageNode: StorageNode | Awaited<import("@endo/far").FarRef<StorageNode>>, valueShape?: import("@agoric/zoe/src/contractSupport/recorder.js").TypedMatcher<T> | undefined) => RecorderKit<T>, zcf: ZCF): (chainAddress: ChainAddress, bondDenom: string, io: {
27
34
  account: IcaAccount;
28
- storageNode: StorageNode;
35
+ storageNode: Remote<globalThis.StorageNode>;
29
36
  icqConnection: import("@endo/exo").Guarded<{
30
37
  getLocalAddress(): `/ibc-port/${string}`;
31
38
  getRemoteAddress(): `/${string}ibc-port/${string}/ordered/${string}` | `/${string}ibc-port/${string}/unordered/${string}`;
32
39
  query(msgs: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/tendermint/abci/types.js").RequestQuery>[]): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/tendermint/abci/types.js").ResponseQuery>[]>;
33
40
  }>;
34
- timer: TimerService;
41
+ timer: Remote<TimerService>;
35
42
  }) => import("@endo/exo").GuardedKit<{
36
43
  helper: {
37
44
  /** @throws if this holder no longer owns the account */
38
45
  owned(): IcaAccount;
39
- getUpdater(): import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<StakingAccountNotification>;
46
+ getUpdater(): import("@agoric/zoe/src/contractSupport/recorder.js").Recorder<ComosOrchestrationAccountNotification>;
40
47
  /**
41
48
  * @param {AmountArg} amount
42
49
  * @returns {Coin}
@@ -57,9 +64,7 @@ export function prepareStakingAccountKit(zone: Zone, makeRecorderKit: <T>(storag
57
64
  Redelegate(srcValidator: CosmosValidatorAddress, dstValidator: CosmosValidatorAddress, amount: AmountArg): Promise<Invitation<void, undefined>>;
58
65
  /** @param {CosmosValidatorAddress} validator */
59
66
  WithdrawReward(validator: CosmosValidatorAddress): Promise<Invitation<DenomAmount[], undefined>>;
60
- /**
61
- * @param {Delegation[]} delegations
62
- */
67
+ /** @param {Delegation[]} delegations */
63
68
  Undelegate(delegations: Delegation[]): Promise<Invitation<void, undefined>>;
64
69
  CloseAccount(): never;
65
70
  /**
@@ -70,10 +75,44 @@ export function prepareStakingAccountKit(zone: Zone, makeRecorderKit: <T>(storag
70
75
  TransferAccount(): never;
71
76
  };
72
77
  holder: {
78
+ asContinuingOffer(): {
79
+ publicSubscribers: {
80
+ account: {
81
+ description: string;
82
+ subscriber: globalThis.Subscriber<ComosOrchestrationAccountNotification>;
83
+ storagePath: Promise<string>;
84
+ };
85
+ };
86
+ invitationMakers: import("@endo/exo").Guarded<{
87
+ /**
88
+ * @param {CosmosValidatorAddress} validator
89
+ * @param {Amount<'nat'>} amount
90
+ */
91
+ Delegate(validator: CosmosValidatorAddress, amount: Amount<"nat">): Promise<Invitation<void, undefined>>;
92
+ /**
93
+ * @param {CosmosValidatorAddress} srcValidator
94
+ * @param {CosmosValidatorAddress} dstValidator
95
+ * @param {AmountArg} amount
96
+ */
97
+ Redelegate(srcValidator: CosmosValidatorAddress, dstValidator: CosmosValidatorAddress, amount: AmountArg): Promise<Invitation<void, undefined>>;
98
+ /** @param {CosmosValidatorAddress} validator */
99
+ WithdrawReward(validator: CosmosValidatorAddress): Promise<Invitation<DenomAmount[], undefined>>;
100
+ /** @param {Delegation[]} delegations */
101
+ Undelegate(delegations: Delegation[]): Promise<Invitation<void, undefined>>;
102
+ CloseAccount(): never;
103
+ /**
104
+ * Starting a transfer revokes the account holder. The associated
105
+ * updater will get a special notification that the account is being
106
+ * transferred.
107
+ */
108
+ TransferAccount(): never;
109
+ }>;
110
+ holder: import("@endo/exo").Guarded<any>;
111
+ };
73
112
  getPublicTopics(): {
74
113
  account: {
75
114
  description: string;
76
- subscriber: globalThis.Subscriber<StakingAccountNotification>;
115
+ subscriber: globalThis.Subscriber<ComosOrchestrationAccountNotification>;
77
116
  storagePath: Promise<string>;
78
117
  };
79
118
  };
@@ -86,6 +125,8 @@ export function prepareStakingAccountKit(zone: Zone, makeRecorderKit: <T>(storag
86
125
  * @param {AmountArg} amount
87
126
  */
88
127
  delegate(validator: CosmosValidatorAddress, amount: AmountArg): Promise<void>;
128
+ deposit(payment: any): Promise<void>;
129
+ getBalances(): Promise<never>;
89
130
  /**
90
131
  * _Assumes users has already sent funds to their ICA, until #9193
91
132
  *
@@ -100,22 +141,24 @@ export function prepareStakingAccountKit(zone: Zone, makeRecorderKit: <T>(storag
100
141
  */
101
142
  withdrawReward(validator: CosmosValidatorAddress): Promise<DenomAmount[]>;
102
143
  /**
103
- * @param {DenomAmount['denom']} [denom] - defaults to bondDenom
144
+ * @param {DenomArg} denom
104
145
  * @returns {Promise<DenomAmount>}
105
146
  */
106
- getBalance(denom?: string | undefined): Promise<DenomAmount>;
147
+ getBalance(denom: DenomArg): Promise<DenomAmount>;
148
+ send(toAccount: any, amount: any): never;
149
+ transfer(amount: any, msg: any): never;
150
+ transferSteps(amount: any, msg: any): never;
107
151
  withdrawRewards(): never;
108
- /**
109
- * @param {Delegation[]} delegations
110
- */
152
+ /** @param {Delegation[]} delegations */
111
153
  undelegate(delegations: Delegation[]): Promise<void>;
112
154
  };
113
155
  }>;
114
- export type StakingAccountNotification = {
156
+ export function prepareCosmosOrchestrationAccount(zone: Zone, makeRecorderKit: <T>(storageNode: StorageNode | Awaited<import("@endo/far").FarRef<StorageNode>>, valueShape?: import("@agoric/zoe/src/contractSupport/recorder.js").TypedMatcher<T> | undefined) => RecorderKit<T>, zcf: ZCF): (...args: Parameters<ReturnType<typeof prepareCosmosOrchestrationAccountKit>>) => CosmosOrchestrationAccountKit["holder"];
157
+ export type ComosOrchestrationAccountNotification = {
115
158
  chainAddress: ChainAddress;
116
159
  };
117
160
  export type State = {
118
- topicKit: RecorderKit<StakingAccountNotification>;
161
+ topicKit: RecorderKit<ComosOrchestrationAccountNotification>;
119
162
  account: IcaAccount;
120
163
  chainAddress: ChainAddress;
121
164
  icqConnection: import("@endo/exo").Guarded<{
@@ -124,18 +167,20 @@ export type State = {
124
167
  query(msgs: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/tendermint/abci/types.js").RequestQuery>[]): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/tendermint/abci/types.js").ResponseQuery>[]>;
125
168
  }>;
126
169
  bondDenom: string;
127
- timer: TimerService;
170
+ timer: Remote<TimerService>;
128
171
  };
129
- export type StakingAccountKit = ReturnType<ReturnType<typeof prepareStakingAccountKit>>;
130
- export type StakingAccounHolder = StakingAccountKit["holder"];
172
+ export type CosmosOrchestrationAccountKit = ReturnType<ReturnType<typeof prepareCosmosOrchestrationAccountKit>>;
173
+ export type CosmosOrchestrationAccount = CosmosOrchestrationAccountKit["holder"];
131
174
  import type { Zone } from '@agoric/zone';
132
175
  import type { RecorderKit } from '@agoric/zoe/src/contractSupport/recorder.js';
133
176
  import type { ChainAddress } from '../types.js';
134
177
  import type { IcaAccount } from '../types.js';
178
+ import type { Remote } from '@agoric/internal';
135
179
  import type { TimerService } from '@agoric/time';
136
180
  import type { AmountArg } from '../types.js';
137
181
  import type { Coin } from '@agoric/cosmic-proto/cosmos/base/v1beta1/coin.js';
138
182
  import type { CosmosValidatorAddress } from '../types.js';
139
183
  import type { DenomAmount } from '../types.js';
140
184
  import type { Delegation } from '@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js';
141
- //# sourceMappingURL=stakingAccountKit.d.ts.map
185
+ import type { DenomArg } from '../types.js';
186
+ //# sourceMappingURL=cosmosOrchestrationAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cosmosOrchestrationAccount.d.ts","sourceRoot":"","sources":["cosmosOrchestrationAccount.js"],"names":[],"mappings":"AAoDA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,mCAAmC;AACnC;;;;;;;;;;;;;;;GAmBG;AAOH,6CAGE;AAgBK,mGAgCW,WAAW,GAAE,QAAS,OACnC,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,0HAnC3B,GAAG;;;;;;;;;;;QAqDN,wDAAwD;;;QAWxD;;;WAGG;;;;QAgBH;;;WAGG;4DADQ,MAAM,CAAC,KAAK,CAAC;QAUxB;;;;WAIG;;QAaH,gDAAgD;;QAShD,wCAAwC;;;QAYxC;;;;WAIG;;;;;;;;;;;;;gBAtDH;;;mBAGG;oEADQ,MAAM,CAAC,KAAK,CAAC;gBAUxB;;;;mBAIG;;gBAaH,gDAAgD;;gBAShD,wCAAwC;;;gBAYxC;;;;mBAIG;;;;;;;;;;;;QA2BH,8BAA8B;;QAI9B;;;;;WAKG;;;;QA2BH;;;;;;WAMG;;QAmBH;;;WAGG;;QAmBH;;;WAGG;;;;;;QAyCH,wCAAwC;;;GAgC/C;AAkBM,0IAlTW,MAAM,wIA2Sb,GAAG,GACD,CACZ,GAAO,IAAI,EAAE,UAAU,CACvB,UAAgB,CAAC,OAAO,oCAAoC,CAAC,CACxD,KACE,6BAA6B,CAAC,QAAQ,CAAC,CAa9C;;;;;;;;;;;;;eAjZe,MAAM;;;4CAuXT,UAAU,CACtB,UAAc,CAAC,OAAO,oCAAoC,CAAC,CACxD;yCAyBU,6BAA6B,CAAC,QAAQ,CAAC;0BAna9B,cAAc;iCALU,6CAA6C;kCADsE,aAAa;gCAAb,aAAa;4BAItJ,kBAAkB;kCACZ,cAAc;+BALqH,aAAa;0BAExJ,kDAAkD;4CAFyF,aAAa;iCAAb,aAAa;gCAGlJ,wDAAwD;8BAH6E,aAAa"}
@@ -27,7 +27,6 @@ import {
27
27
  AmountArgShape,
28
28
  ChainAddressShape,
29
29
  ChainAmountShape,
30
- CoinShape,
31
30
  DelegationShape,
32
31
  } from '../typeGuards.js';
33
32
  import {
@@ -35,40 +34,47 @@ import {
35
34
  maxClockSkew,
36
35
  tryDecodeResponse,
37
36
  } from '../utils/cosmos.js';
37
+ import { orchestrationAccountMethods } from '../utils/orchestrationAccount.js';
38
38
  import { dateInSeconds } from '../utils/time.js';
39
39
 
40
40
  /**
41
- * @import {AmountArg, IcaAccount, ChainAddress, CosmosValidatorAddress, ICQConnection, StakingAccountActions, DenomAmount} from '../types.js';
41
+ * @import {AmountArg, IcaAccount, ChainAddress, CosmosValidatorAddress, ICQConnection, StakingAccountActions, DenomAmount, OrchestrationAccountI, DenomArg} from '../types.js';
42
42
  * @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js';
43
43
  * @import {Coin} from '@agoric/cosmic-proto/cosmos/base/v1beta1/coin.js';
44
44
  * @import {Delegation} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js';
45
+ * @import {Remote} from '@agoric/internal';
45
46
  * @import {TimerService} from '@agoric/time';
46
47
  * @import {Zone} from '@agoric/zone';
47
48
  */
48
49
 
49
- const trace = makeTracer('StakingAccountHolder');
50
+ const trace = makeTracer('ComosOrchestrationAccountHolder');
50
51
 
51
52
  const { Fail } = assert;
52
53
  /**
53
- * @typedef {object} StakingAccountNotification
54
+ * @typedef {object} ComosOrchestrationAccountNotification
54
55
  * @property {ChainAddress} chainAddress
55
56
  */
56
57
 
57
58
  /**
58
59
  * @typedef {{
59
- * topicKit: RecorderKit<StakingAccountNotification>;
60
+ * topicKit: RecorderKit<ComosOrchestrationAccountNotification>;
60
61
  * account: IcaAccount;
61
62
  * chainAddress: ChainAddress;
62
63
  * icqConnection: ICQConnection;
63
64
  * bondDenom: string;
64
- * timer: TimerService;
65
+ * timer: Remote<TimerService>;
65
66
  * }} State
66
67
  */
67
68
 
69
+ /** @see {OrchestrationAccountI} */
68
70
  export const IcaAccountHolderI = M.interface('IcaAccountHolder', {
71
+ ...orchestrationAccountMethods,
72
+ asContinuingOffer: M.call().returns({
73
+ publicSubscribers: M.any(),
74
+ invitationMakers: M.any(),
75
+ holder: M.any(),
76
+ }),
69
77
  getPublicTopics: M.call().returns(TopicsRecordShape),
70
- getAddress: M.call().returns(ChainAddressShape),
71
- getBalance: M.callWhen().optional(M.string()).returns(CoinShape),
72
78
  delegate: M.callWhen(ChainAddressShape, AmountShape).returns(M.undefined()),
73
79
  redelegate: M.callWhen(
74
80
  ChainAddressShape,
@@ -106,8 +112,12 @@ const toDenomAmount = c => ({ denom: c.denom, value: BigInt(c.amount) });
106
112
  * @param {MakeRecorderKit} makeRecorderKit
107
113
  * @param {ZCF} zcf
108
114
  */
109
- export const prepareStakingAccountKit = (zone, makeRecorderKit, zcf) => {
110
- const makeStakingAccountKit = zone.exoClassKit(
115
+ export const prepareCosmosOrchestrationAccountKit = (
116
+ zone,
117
+ makeRecorderKit,
118
+ zcf,
119
+ ) => {
120
+ const makeCosmosOrchestrationAccountKit = zone.exoClassKit(
111
121
  'Staking Account Holder',
112
122
  {
113
123
  helper: M.interface('helper', {
@@ -138,9 +148,9 @@ export const prepareStakingAccountKit = (zone, makeRecorderKit, zcf) => {
138
148
  * @param {string} bondDenom e.g. 'uatom'
139
149
  * @param {object} io
140
150
  * @param {IcaAccount} io.account
141
- * @param {StorageNode} io.storageNode
151
+ * @param {Remote<StorageNode>} io.storageNode
142
152
  * @param {ICQConnection} io.icqConnection
143
- * @param {TimerService} io.timer
153
+ * @param {Remote<TimerService>} io.timer
144
154
  * @returns {State}
145
155
  */
146
156
  (chainAddress, bondDenom, io) => {
@@ -221,9 +231,7 @@ export const prepareStakingAccountKit = (zone, makeRecorderKit, zcf) => {
221
231
  return this.facets.holder.withdrawReward(validator);
222
232
  }, 'WithdrawReward');
223
233
  },
224
- /**
225
- * @param {Delegation[]} delegations
226
- */
234
+ /** @param {Delegation[]} delegations */
227
235
  Undelegate(delegations) {
228
236
  trace('Undelegate', delegations);
229
237
 
@@ -245,6 +253,14 @@ export const prepareStakingAccountKit = (zone, makeRecorderKit, zcf) => {
245
253
  },
246
254
  },
247
255
  holder: {
256
+ asContinuingOffer() {
257
+ const { holder, invitationMakers } = this.facets;
258
+ return harden({
259
+ publicSubscribers: holder.getPublicTopics(),
260
+ invitationMakers,
261
+ holder,
262
+ });
263
+ },
248
264
  getPublicTopics() {
249
265
  const { topicKit } = this.state;
250
266
  return harden({
@@ -285,6 +301,15 @@ export const prepareStakingAccountKit = (zone, makeRecorderKit, zcf) => {
285
301
 
286
302
  expect(result, trivialDelegateResponse, 'MsgDelegateResponse');
287
303
  },
304
+ async deposit(payment) {
305
+ trace('deposit', payment);
306
+ console.error(
307
+ 'FIXME deposit noop until https://github.com/Agoric/agoric-sdk/issues/9193',
308
+ );
309
+ },
310
+ async getBalances() {
311
+ throw Error('not yet implemented');
312
+ },
288
313
  /**
289
314
  * _Assumes users has already sent funds to their ICA, until #9193
290
315
  *
@@ -333,12 +358,12 @@ export const prepareStakingAccountKit = (zone, makeRecorderKit, zcf) => {
333
358
  return harden(coins.map(toDenomAmount));
334
359
  },
335
360
  /**
336
- * @param {DenomAmount['denom']} [denom] - defaults to bondDenom
361
+ * @param {DenomArg} denom
337
362
  * @returns {Promise<DenomAmount>}
338
363
  */
339
364
  async getBalance(denom) {
340
- const { chainAddress, icqConnection, bondDenom } = this.state;
341
- denom ||= bondDenom;
365
+ const { chainAddress, icqConnection } = this.state;
366
+ // TODO #9211 lookup denom from brand
342
367
  assert.typeof(denom, 'string');
343
368
 
344
369
  const [result] = await E(icqConnection).query([
@@ -357,13 +382,26 @@ export const prepareStakingAccountKit = (zone, makeRecorderKit, zcf) => {
357
382
  return harden(toDenomAmount(balance));
358
383
  },
359
384
 
385
+ send(toAccount, amount) {
386
+ console.log('send got', toAccount, amount);
387
+ throw Error('not yet implemented');
388
+ },
389
+
390
+ transfer(amount, msg) {
391
+ console.log('transferSteps got', amount, msg);
392
+ throw Error('not yet implemented');
393
+ },
394
+
395
+ transferSteps(amount, msg) {
396
+ console.log('transferSteps got', amount, msg);
397
+ throw Error('not yet implemented');
398
+ },
399
+
360
400
  withdrawRewards() {
361
401
  throw assert.error('Not implemented');
362
402
  },
363
403
 
364
- /**
365
- * @param {Delegation[]} delegations
366
- */
404
+ /** @param {Delegation[]} delegations */
367
405
  async undelegate(delegations) {
368
406
  trace('undelegate', delegations);
369
407
  const { helper } = this.facets;
@@ -394,18 +432,35 @@ export const prepareStakingAccountKit = (zone, makeRecorderKit, zcf) => {
394
432
  },
395
433
  );
396
434
 
397
- /** check holder facet against StakingAccountActions interface. */
398
- // eslint-disable-next-line no-unused-vars
399
- const typeCheck = () => {
400
- /** @type {any} */
401
- const arg = null;
402
- /** @satisfies {StakingAccountActions} */
403
- // eslint-disable-next-line no-unused-vars
404
- const kit = makeStakingAccountKit(arg, arg, arg).holder;
405
- };
406
-
407
- return makeStakingAccountKit;
435
+ return makeCosmosOrchestrationAccountKit;
408
436
  };
409
437
 
410
- /** @typedef {ReturnType<ReturnType<typeof prepareStakingAccountKit>>} StakingAccountKit */
411
- /** @typedef {StakingAccountKit['holder']} StakingAccounHolder */
438
+ /**
439
+ * @typedef {ReturnType<
440
+ * ReturnType<typeof prepareCosmosOrchestrationAccountKit>
441
+ * >} CosmosOrchestrationAccountKit
442
+ */
443
+
444
+ /**
445
+ * @param {Zone} zone
446
+ * @param {MakeRecorderKit} makeRecorderKit
447
+ * @param {ZCF} zcf
448
+ * @returns {(
449
+ * ...args: Parameters<
450
+ * ReturnType<typeof prepareCosmosOrchestrationAccountKit>
451
+ * >
452
+ * ) => CosmosOrchestrationAccountKit['holder']}
453
+ */
454
+ export const prepareCosmosOrchestrationAccount = (
455
+ zone,
456
+ makeRecorderKit,
457
+ zcf,
458
+ ) => {
459
+ const makeKit = prepareCosmosOrchestrationAccountKit(
460
+ zone,
461
+ makeRecorderKit,
462
+ zcf,
463
+ );
464
+ return (...args) => makeKit(...args).holder;
465
+ };
466
+ /** @typedef {CosmosOrchestrationAccountKit['holder']} CosmosOrchestrationAccount */
@@ -1 +1 @@
1
- {"version":3,"file":"icqConnectionKit.d.ts","sourceRoot":"","sources":["icqConnectionKit.js"],"names":[],"mappings":"AAoBA,2DAGE;AAEF;;;;GAIG;AA0BI;;;;QA8BC;;;;WAIG;;;;QAYH;;;;WAIG;;;;;GAgBR;;;;;;;+BAEW,UAAU,CAAC,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;4BACtD,gBAAgB,CAAC,YAAY,CAAC;0BAnHrB,mBAAmB;0BACP,iBAAiB;kCAGN,+CAA+C;8BADlE,sBAAsB;mCACH,+CAA+C;gCAH1D,iBAAiB;4BAC3B,aAAa"}
1
+ {"version":3,"file":"icqConnectionKit.d.ts","sourceRoot":"","sources":["icqConnectionKit.js"],"names":[],"mappings":"AAoBA,2DAGE;AAEF;;;;GAIG;AA0BI;;;;QA4BC;;;;WAIG;;;;QAYH;;;;WAIG;;;;;GAgBR;;;;;;;+BAEW,UAAU,CAAC,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;4BACtD,gBAAgB,CAAC,YAAY,CAAC;0BAjHrB,mBAAmB;0BACP,iBAAiB;kCAGN,+CAA+C;8BADlE,sBAAsB;mCACH,+CAA+C;gCAH1D,iBAAiB;4BAC3B,aAAa"}
@@ -61,14 +61,12 @@ export const prepareICQConnectionKit = zone =>
61
61
  * @param {Port} port
62
62
  */
63
63
  port =>
64
- /** @type {ICQConnectionKitState} */ (
65
- harden({
66
- port,
67
- connection: undefined,
68
- remoteAddress: undefined,
69
- localAddress: undefined,
70
- })
71
- ),
64
+ /** @type {ICQConnectionKitState} */ ({
65
+ port,
66
+ connection: undefined,
67
+ remoteAddress: undefined,
68
+ localAddress: undefined,
69
+ }),
72
70
  {
73
71
  connection: {
74
72
  getLocalAddress() {
@@ -77,7 +77,7 @@ export function prepareLocalChainAccountKit(zone: Zone, makeRecorderKit: <T>(sto
77
77
  };
78
78
  }>;
79
79
  export type AgoricChainInfo = {
80
- connections: globalThis.MapStore<string, import("@agoric/orchestration").IBCConnectionInfo>;
80
+ connections: Record<string, import("@agoric/orchestration").IBCConnectionInfo>;
81
81
  };
82
82
  export type LocalChainAccountNotification = {
83
83
  address: string;
@@ -1 +1 @@
1
- {"version":3,"file":"local-chain-account-kit.d.ts","sourceRoot":"","sources":["local-chain-account-kit.js"],"names":[],"mappings":"AAsEO,0FAuED,WACD,GAAE,QACC,OAAA,WAAU,EAAE,MAAM,CAChB,WAAA,CAAC,CAAC,0HA/ED,GAAG,uEAGH,eAAe;;;0BA5Bd,MAAM,KAAK,CAAC;yBAWX,QAAQ,KAAK,CAAC,mBACZ,OAAO;yBAkBmB,OACvC,KAAK,CACP;;;uBAiBoB,EAAE;;;iBASP,WAAW;;;QAalB;;;WAGG;mCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;QAYxB;;;WAGG;qCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;;;;;;;;;QA0BxB;;;WAGG;mCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;QAsBxB;;;;WAIG;qCAHQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC,GACX,OAAO,CAAC,IAAI,CAAC;QA2B1B;;;;WAIG;QACH,2CAA2C;yBAjKtC,QAAQ,KAAK,CAAC,mBACZ,OAAO;QAoKd,4CAA4C;yBAlJX,OACvC,KAAK,CACP;QAoJQ,6CAA6C;;;uBAnIjC,EAAE;QAwId;;WAEG;;QAIH;;;;;;;;WAQG;0GADU,OAAO,CAAC,IAAI,CAAC;;GA6CjC;;;;;aA1Pa,MAAM;;;;;;0BAOR,MAAM,KAAK,CAAC;yBAWX,QAAQ,KAAK,CAAC,mBACZ,OAAO;yBAkBmB,OACvC,KAAK,CACP;;;uBAiBoB,EAAE;;;;mCAmMR,UAAU,CAAC,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC;0BAvQjD,cAAc;iCADU,6CAA6C;kCAEjD,cAAc;gCAAd,cAAc;+BAHsC,uBAAuB;kCAAvB,uBAAuB;2CAAvB,uBAAuB"}
1
+ {"version":3,"file":"local-chain-account-kit.d.ts","sourceRoot":"","sources":["local-chain-account-kit.js"],"names":[],"mappings":"AAsEO,0FAuED,WACD,GAAE,QACC,OAAA,WAAU,EAAE,MAAM,CAChB,WAAA,CAAC,CAAC,0HA/ED,GAAG,uEAGH,eAAe;;;0BA5Bd,MAAM,KAAK,CAAC;yBAWX,QAAQ,KAAK,CAAC,mBACZ,OAAO;yBAkBmB,OACvC,KAAK,CACP;;;uBAiBoB,EAAE;;;iBASP,WAAW;;;QAalB;;;WAGG;mCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;QAYxB;;;WAGG;qCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;;;;;;;;;QA0BxB;;;WAGG;mCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;QAsBxB;;;;WAIG;qCAHQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC,GACX,OAAO,CAAC,IAAI,CAAC;QA2B1B;;;;WAIG;QACH,2CAA2C;yBAjKtC,QAAQ,KAAK,CAAC,mBACZ,OAAO;QAoKd,4CAA4C;yBAlJX,OACvC,KAAK,CACP;QAoJQ,6CAA6C;;;uBAnIjC,EAAE;QAwId;;WAEG;;QAIH;;;;;;;;WAQG;0GADU,OAAO,CAAC,IAAI,CAAC;;GA+CjC;;;;;aA5Pa,MAAM;;;;;;0BAOR,MAAM,KAAK,CAAC;yBAWX,QAAQ,KAAK,CAAC,mBACZ,OAAO;yBAkBmB,OACvC,KAAK,CACP;;;uBAiBoB,EAAE;;;;mCAqMR,UAAU,CAAC,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC;0BAzQjD,cAAc;iCADU,6CAA6C;kCAEjD,cAAc;gCAAd,cAAc;+BAHsC,uBAAuB;kCAAvB,uBAAuB;2CAAvB,uBAAuB"}
@@ -243,10 +243,12 @@ export const prepareLocalChainAccountKit = (
243
243
  // TODO #9211 lookup denom from brand
244
244
  if ('brand' in amount) throw Fail`ERTP Amounts not yet supported`;
245
245
 
246
+ destination.chainId in agoricChainInfo.connections ||
247
+ Fail`Unknown chain ${destination.chainId}`;
248
+
246
249
  // TODO #8879 chainInfo and #9063 well-known chains
247
- const { transferChannel } = agoricChainInfo.connections.get(
248
- destination.chainId,
249
- );
250
+ const { transferChannel } =
251
+ agoricChainInfo.connections[destination.chainId];
250
252
 
251
253
  await null;
252
254
  // set a `timeoutTimestamp` if caller does not supply either `timeoutHeight` or `timeoutTimestamp`
package/src/facade.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode, orchestrationService, localchain, }: {
2
2
  zone: Zone;
3
- timerService: Remote<TimerService> | null;
3
+ timerService: Remote<TimerService>;
4
4
  zcf: ZCF;
5
5
  storageNode: Remote<globalThis.StorageNode>;
6
6
  orchestrationService: Remote<import("@endo/exo").Guarded<{
7
7
  makeAccount(hostConnectionId: `connection-${number}`, controllerConnectionId: `connection-${number}`): Promise<import("./cosmos-api.js").IcaAccount>;
8
8
  provideICQConnection(controllerConnectionId: `connection-${number}`): Promise<import("@endo/exo").Guarded<{
9
- getLocalAddress(): `/ibc-port/${string}`;
9
+ getLocalAddress(): `/ibc-port/${string}`; /** @type {CosmosChainInfo} */
10
10
  getRemoteAddress(): `/${string}ibc-port/${string}/ordered/${string}` | `/${string}ibc-port/${string}/unordered/${string}`;
11
11
  query(msgs: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/tendermint/abci/types.js").RequestQuery>[]): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/tendermint/abci/types.js").ResponseQuery>[]>;
12
12
  }>>;
13
- }>> | null;
13
+ }>>;
14
14
  localchain: Remote<import("@endo/exo").Guarded<{
15
15
  makeAccount(): Promise<import("@endo/exo").Guarded<{
16
16
  getAddress(): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["facade.js"],"names":[],"mappings":"AA8IO;;;SANG,GAAG;;;;;;;;;;;;;8BA5ER,MAAM,KAAK,CAAC;6BAeT,QAAA,KAAK,CAAC,mBACA,OAAO;6BAkBX,OAAG,KAAK,CAAC;;;2BAiBW,EAAE;;uBA6E6L,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;IA7Bp9B;;;;;;;OAOG;gBAFkC,OAAO,EACrB,IAAI,6BAHhB,MAAM,OAEoB,OAAO,AAD1B,gCACmB,OAAO,WACrB,IAAI,AADgC,KAAK,MAAM,GACzD,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,OAAO,CAAC;EAoBnD;kCAEa,UAAU,CAAC,OAAO,uBAAuB,CAAC;0BAtLjC,cAAc;kCACN,cAAc;4BAEpB,kBAAkB;kCAE4B,YAAY"}
1
+ {"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["facade.js"],"names":[],"mappings":"AAuJO;;;SANG,GAAG;;;;;sDAnDO,8BAA8B;;;;;;;;8BA1CxC,MAAC,KAAK,CAAC;6BAgBP,QADG,KAAI,CAAC,mBACF,OAAO;6BAqBhB,OAAO,KAAK,CAAC;;;2BAmBhB,EAAA;;uBAyF6C,OAC7C,sBAGI,EAAE,SAAS;;;4BAEujB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;IAnChnB;;;;;;;OAOG;gBAFkC,OAAO,EACrB,IAAI,6BAHhB,MAAM,OAEoB,OAAO,AAD1B,gCACmB,OAAO,WACrB,IAAI,AADgC,KAAK,MAAM,GACzD,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,OAAO,CAAC;EA0BnD;kCAEa,UAAU,CAAC,OAAO,uBAAuB,CAAC;0BApMjC,cAAc;kCACN,cAAc;4BAEpB,kBAAkB;kCAE0D,YAAY"}