@agoric/orchestration 0.1.1-dev-252b405.0 → 0.1.1-dev-4e588de.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 (55) hide show
  1. package/package.json +16 -16
  2. package/src/cosmos-api.d.ts +15 -9
  3. package/src/cosmos-api.d.ts.map +1 -1
  4. package/src/cosmos-api.ts +21 -9
  5. package/src/examples/auto-stake-it-tap-kit.d.ts +3 -3
  6. package/src/examples/auto-stake-it-tap-kit.d.ts.map +1 -1
  7. package/src/examples/auto-stake-it-tap-kit.js +7 -7
  8. package/src/examples/send-anywhere.flows.d.ts.map +1 -1
  9. package/src/examples/send-anywhere.flows.js +0 -1
  10. package/src/examples/stake-bld.contract.d.ts +4 -4
  11. package/src/examples/stake-bld.contract.d.ts.map +1 -1
  12. package/src/examples/stake-bld.contract.js +0 -1
  13. package/src/examples/stake-ica.contract.d.ts +5 -7
  14. package/src/examples/stake-ica.contract.d.ts.map +1 -1
  15. package/src/examples/staking-combinations.contract.js +4 -4
  16. package/src/examples/staking-combinations.flows.d.ts +2 -2
  17. package/src/examples/staking-combinations.flows.d.ts.map +1 -1
  18. package/src/examples/staking-combinations.flows.js +4 -4
  19. package/src/exos/chain-hub.d.ts +16 -8
  20. package/src/exos/chain-hub.d.ts.map +1 -1
  21. package/src/exos/chain-hub.js +60 -17
  22. package/src/exos/cosmos-orchestration-account.d.ts +14 -16
  23. package/src/exos/cosmos-orchestration-account.d.ts.map +1 -1
  24. package/src/exos/cosmos-orchestration-account.js +32 -21
  25. package/src/exos/ica-account-kit.d.ts +4 -4
  26. package/src/exos/ica-account-kit.d.ts.map +1 -1
  27. package/src/exos/ica-account-kit.js +5 -6
  28. package/src/exos/local-chain-facade.d.ts.map +1 -1
  29. package/src/exos/local-chain-facade.js +3 -4
  30. package/src/exos/local-orchestration-account.d.ts +12 -11
  31. package/src/exos/local-orchestration-account.d.ts.map +1 -1
  32. package/src/exos/local-orchestration-account.js +8 -7
  33. package/src/exos/portfolio-holder-kit.d.ts.map +1 -1
  34. package/src/exos/portfolio-holder-kit.js +0 -1
  35. package/src/exos/remote-chain-facade.d.ts.map +1 -1
  36. package/src/exos/remote-chain-facade.js +6 -6
  37. package/src/orchestration-api.d.ts +36 -10
  38. package/src/orchestration-api.d.ts.map +1 -1
  39. package/src/orchestration-api.ts +42 -10
  40. package/src/typeGuards.d.ts +11 -4
  41. package/src/typeGuards.d.ts.map +1 -1
  42. package/src/typeGuards.js +27 -12
  43. package/src/utils/address.d.ts +9 -2
  44. package/src/utils/address.d.ts.map +1 -1
  45. package/src/utils/address.js +45 -5
  46. package/src/utils/cosmos.d.ts.map +1 -1
  47. package/src/utils/cosmos.js +0 -2
  48. package/src/utils/orc.d.ts.map +1 -1
  49. package/src/utils/orc.js +0 -2
  50. package/src/utils/orchestrationAccount.js +6 -5
  51. package/src/utils/start-helper.d.ts +3 -2
  52. package/src/utils/start-helper.d.ts.map +1 -1
  53. package/tools/ibc-mocks.d.ts +4 -4
  54. package/tools/ibc-mocks.d.ts.map +1 -1
  55. package/tools/ibc-mocks.ts +4 -4
@@ -28,7 +28,7 @@ import { TransferRouteShape } from './chain-hub.js';
28
28
  /**
29
29
  * @import {HostOf} from '@agoric/async-flow';
30
30
  * @import {LocalChain, LocalChainAccount} from '@agoric/vats/src/localchain.js';
31
- * @import {AmountArg, ChainAddress, DenomAmount, IBCMsgTransferOptions, IBCConnectionInfo, OrchestrationAccountCommon, LocalAccountMethods, TransferRoute} from '@agoric/orchestration';
31
+ * @import {AmountArg, CosmosChainAddress, DenomAmount, IBCMsgTransferOptions, IBCConnectionInfo, OrchestrationAccountCommon, LocalAccountMethods, TransferRoute, AccountId, AccountIdArg} from '@agoric/orchestration';
32
32
  * @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js'.
33
33
  * @import {Zone} from '@agoric/zone';
34
34
  * @import {Remote} from '@agoric/internal';
@@ -60,7 +60,7 @@ const EVow$ = shape => M.or(Vow$(shape), M.promise(/* shape */));
60
60
  * topicKit: RecorderKit<LocalChainAccountNotification> | undefined;
61
61
  * packetTools: PacketTools;
62
62
  * account: LocalChainAccount;
63
- * address: ChainAddress;
63
+ * address: CosmosChainAddress;
64
64
  * }} State
65
65
  * Internal to the LocalOrchestrationAccount exo
66
66
  */
@@ -180,7 +180,7 @@ export const prepareLocalOrchestrationAccountKit = (
180
180
  /**
181
181
  * @param {object} initState
182
182
  * @param {LocalChainAccount} initState.account
183
- * @param {ChainAddress} initState.address
183
+ * @param {CosmosChainAddress} initState.address
184
184
  * @param {Remote<StorageNode>} [initState.storageNode]
185
185
  * @returns {State}
186
186
  */
@@ -265,7 +265,7 @@ export const prepareLocalOrchestrationAccountKit = (
265
265
  /**
266
266
  * @type {OfferHandler<
267
267
  * Vow<void>,
268
- * { toAccount: ChainAddress; amount: AmountArg }
268
+ * { toAccount: CosmosChainAddress; amount: AmountArg }
269
269
  * >}
270
270
  */
271
271
  const offerHandler = (seat, { toAccount, amount }) => {
@@ -278,7 +278,7 @@ export const prepareLocalOrchestrationAccountKit = (
278
278
  /**
279
279
  * @type {OfferHandler<
280
280
  * Vow<void>,
281
- * { toAccount: ChainAddress; amounts: AmountArg[] }
281
+ * { toAccount: CosmosChainAddress; amounts: AmountArg[] }
282
282
  * >}
283
283
  */
284
284
  const offerHandler = (seat, { toAccount, amounts }) => {
@@ -293,7 +293,7 @@ export const prepareLocalOrchestrationAccountKit = (
293
293
  * Vow<void>,
294
294
  * {
295
295
  * amount: AmountArg;
296
- * destination: ChainAddress;
296
+ * destination: CosmosChainAddress;
297
297
  * opts?: IBCMsgTransferOptions;
298
298
  * }
299
299
  * >}
@@ -671,7 +671,7 @@ export const prepareLocalOrchestrationAccountKit = (
671
671
  });
672
672
  },
673
673
  /**
674
- * @param {ChainAddress} destination
674
+ * @param {AccountIdArg} destination
675
675
  * @param {AmountArg} amount an ERTP {@link Amount} or a
676
676
  * {@link DenomAmount}
677
677
  * @param {IBCMsgTransferOptions} [opts] if either timeoutHeight or
@@ -685,6 +685,7 @@ export const prepareLocalOrchestrationAccountKit = (
685
685
  transfer(destination, amount, opts) {
686
686
  return asVow(() => {
687
687
  trace('Transferring funds over IBC');
688
+
688
689
  const denomAmount = coerceDenomAmount(chainHub, amount);
689
690
 
690
691
  const { forwardOpts, ...rest } = opts ?? {};
@@ -1 +1 @@
1
- {"version":3,"file":"portfolio-holder-kit.d.ts","sourceRoot":"","sources":["portfolio-holder-kit.js"],"names":[],"mappings":"AAgOO,6CANI,IAAI,YACJ,QAAQ,GACN,CACZ,GAAO,IAAI,EAAE,UAAU,CAAC,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,KAC9D,UAAU,CAAC,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAKzE;mCAhNY;IACR,QAAQ,EAAE,SAAS,MAAM,EAAE,cAAc,qBAAqB,GAAG,CAAC,CAAC,CAAC,CAAC;IACrE,YAAY,EAAE,SAAS,MAAM,EAAE,oBAAoB,OAAO,CAAC,CAAC,CAAC;CAC9D;kCA8MU,UAAU,CAAC,OAAO,sBAAsB,CAAC;8BACzC,UAAU,CAAC,mBAAmB,CAAC;0BAvNtB,cAAc;8BAFV,aAAa;AAqBxC;;;;;;GAMG;AACH,iDAHW,IAAI,mBACJ,QAAQ;;QAkDX;;;;;;WAMG;iBALsB,EAAE,SAAb,OAAO,EAAG,aACb,MAAM,UACN,MAAM,mBACN,EAAE,GACA,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;;;;;;;;gBAL7C;;;;;;mBAMG;yBALsB,EAAE,SAAb,OAAO,EAAG,aACb,MAAM,UACN,MAAM,mBACN,EAAE,GACA,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;;;;;;QA+B7C;;;;WAIG;8BAHQ,MAAM,WACN,cAAc,qBAAqB,GAAG,CAAC,CAAC,eACxC,oBAAoB,OAAO,CAAC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BAAuB"}
@@ -200,7 +200,6 @@ const preparePortfolioHolderKit = (zone, { asVow, when }) => {
200
200
  * {
201
201
  * value: 'cosmos1valoper',
202
202
  * chainId: 'cosmoshub-99',
203
- * encoding: 'bech32',
204
203
  * },
205
204
  * {
206
205
  * denom: 'uatom',
@@ -1 +1 @@
1
- {"version":3,"file":"remote-chain-facade.d.ts","sourceRoot":"","sources":["remote-chain-facade.js"],"names":[],"mappings":"AAuQO,+CAHI,IAAI,UACJ,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAKjC;sCA5OY;IACR,8BAA8B,EAAE,UAAU,CAC9C,wCAA8C,CACzC,CAAC;IACF,aAAa,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC/C,WAAW,EAAE,OAAO,WAAW,CAAC,GAAG,SAAS,CAAC;IAC7C,KAAK,EAAE,OAAO,YAAY,CAAC,CAAC;IAC5B,QAAQ,EAAE,QAAQ,CAAC;CACpB;qCAIS;IACR,eAAe,EAAE,eAAe,CAAC;IACjC,cAAc,EAAE,iBAAiB,CAAC;IAClC,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;CAC1C;oCA+NU,UAAU,CAAC,OAAO,wBAAwB,CAAC;gCAC3C,UAAU,CAAC,qBAAqB,CAAC;0BA/PxB,mBAAmB;uCAS2D,aAAa;yBAJlF,aAAa;uDAGO,mCAAmC;6CAD7C,qBAAqB;4BAHtC,kBAAkB;kCADZ,cAAc;8BAEb,aAAa;qCAIwD,aAAa;mCAAb,aAAa"}
1
+ {"version":3,"file":"remote-chain-facade.d.ts","sourceRoot":"","sources":["remote-chain-facade.js"],"names":[],"mappings":"AAuQO,+CAHI,IAAI,UACJ,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAKjC;sCA5OY;IACR,8BAA8B,EAAE,UAAU,CAC9C,wCAA8C,CACzC,CAAC;IACF,aAAa,EAAE,OAAO,uBAAuB,CAAC,CAAC;IAC/C,WAAW,EAAE,OAAO,WAAW,CAAC,GAAG,SAAS,CAAC;IAC7C,KAAK,EAAE,OAAO,YAAY,CAAC,CAAC;IAC5B,QAAQ,EAAE,QAAQ,CAAC;CACpB;qCAIS;IACR,eAAe,EAAE,eAAe,CAAC;IACjC,cAAc,EAAE,iBAAiB,CAAC;IAClC,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;CAC1C;oCA+NU,UAAU,CAAC,OAAO,wBAAwB,CAAC;gCAC3C,UAAU,CAAC,qBAAqB,CAAC;0BA/PxB,mBAAmB;uCASiE,aAAa;yBAJxF,aAAa;uDAGO,mCAAmC;6CAD7C,qBAAqB;4BAHtC,kBAAkB;kCADZ,cAAc;8BAEb,aAAa;qCAI8D,aAAa;mCAAb,aAAa"}
@@ -6,7 +6,7 @@ import { M } from '@endo/patterns';
6
6
  import { pickFacet } from '@agoric/vat-data';
7
7
  import { VowShape } from '@agoric/vow';
8
8
  import {
9
- ChainAddressShape,
9
+ CosmosChainAddressShape,
10
10
  chainFacadeMethods,
11
11
  ICQMsgShape,
12
12
  } from '../typeGuards.js';
@@ -22,7 +22,7 @@ import {
22
22
  * @import {LocalIbcAddress, RemoteIbcAddress} from '@agoric/vats/tools/ibc-utils.js';
23
23
  * @import {CosmosInterchainService} from './exo-interfaces.js';
24
24
  * @import {prepareCosmosOrchestrationAccount} from './cosmos-orchestration-account.js';
25
- * @import {CosmosChainInfo, IBCConnectionInfo, ChainAddress, IcaAccount, Chain, ICQConnection} from '../types.js';
25
+ * @import {CosmosChainInfo, IBCConnectionInfo, CosmosChainAddress, IcaAccount, Chain, ICQConnection} from '../types.js';
26
26
  */
27
27
 
28
28
  const trace = makeTracer('RemoteChainFacade');
@@ -89,14 +89,14 @@ const prepareRemoteChainFacadeKit = (
89
89
  ),
90
90
  getAddressesWatcher: M.interface('getAddressWatcher', {
91
91
  onFulfilled: M.call(
92
- [ChainAddressShape, M.string(), M.string()],
92
+ [CosmosChainAddressShape, M.string(), M.string()],
93
93
  M.remotable(),
94
94
  ).returns(VowShape),
95
95
  }),
96
96
  makeChildNodeWatcher: M.interface('makeChildNodeWatcher', {
97
97
  onFulfilled: M.call(M.or(M.remotable(), M.undefined()), {
98
98
  account: M.remotable(),
99
- chainAddress: ChainAddressShape,
99
+ chainAddress: CosmosChainAddressShape,
100
100
  localAddress: M.string(),
101
101
  remoteAddress: M.string(),
102
102
  }).returns(M.remotable()),
@@ -206,7 +206,7 @@ const prepareRemoteChainFacadeKit = (
206
206
  },
207
207
  getAddressesWatcher: {
208
208
  /**
209
- * @param {[ChainAddress, LocalIbcAddress, RemoteIbcAddress]} chainAddresses
209
+ * @param {[CosmosChainAddress, LocalIbcAddress, RemoteIbcAddress]} chainAddresses
210
210
  * @param {IcaAccount} account
211
211
  */
212
212
  onFulfilled([chainAddress, localAddress, remoteAddress], account) {
@@ -226,7 +226,7 @@ const prepareRemoteChainFacadeKit = (
226
226
  * @param {Remote<StorageNode> | undefined} childNode
227
227
  * @param {{
228
228
  * account: IcaAccount;
229
- * chainAddress: ChainAddress;
229
+ * chainAddress: CosmosChainAddress;
230
230
  * localAddress: LocalIbcAddress;
231
231
  * remoteAddress: RemoteIbcAddress;
232
232
  * }} ctx
@@ -38,14 +38,40 @@ export type DenomAmount = {
38
38
  };
39
39
  /** Amounts can be provided as pure data using denoms or as ERTP Amounts */
40
40
  export type AmountArg = DenomAmount | Amount<'nat'>;
41
- /** An address on some blockchain, e.g., cosmos, eth, etc. */
42
- export type ChainAddress = {
43
- /** e.g. 1 for Ethereum, agoric-3 for Agoric, cosmoshub-4 for Cosmos */
41
+ /**
42
+ * Per `chain_id` in CAIP-2. In that spec all chain IDs are scoped
43
+ * (namespace:reference) but in the Cosmos ecosystem the namespace is implied
44
+ * and they use `chain_id`/`chainId` for what CAIP-2 calls the `reference`. We
45
+ * qualify the term here to avoid confusion.
46
+ *
47
+ * @see {@link https://chainagnostic.org/CAIPs/caip-2}
48
+ */
49
+ export type ScopedChainId = `${string}:${string}`;
50
+ /**
51
+ * à la CAIP-10
52
+ *
53
+ * account_id: chain_id + ":" + account_address
54
+ * chain_id: [-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32} (See [CAIP-2][])
55
+ * account_address: [-.%a-zA-Z0-9]{1,128}
56
+ *
57
+ * @see {@link https://chainagnostic.org/CAIPs/caip-10}
58
+ */
59
+ export type AccountId = `${ScopedChainId}:${string}`;
60
+ /**
61
+ * Specific to Cosmos chains
62
+ * @see {AccountId} for universal account identifier
63
+ */
64
+ export type CosmosChainAddress = {
65
+ /** Within the Cosmos ecosystem. e.g. `agoric-3' or 'cosmoshub-4' */
44
66
  chainId: string;
45
67
  /** The address value used on-chain */
46
68
  value: string;
47
- encoding: 'bech32' | 'ethereum';
48
69
  };
70
+ /**
71
+ * A value that can be converted mechanically to an AccountId.
72
+ * @see {@link ChainHub.resolveAccountId}
73
+ */
74
+ export type AccountIdArg = AccountId | CosmosChainAddress;
49
75
  /**
50
76
  * Object that controls an account on a particular chain.
51
77
  *
@@ -113,7 +139,7 @@ export interface OrchestrationAccountCommon {
113
139
  /**
114
140
  * @returns the address of the account on the remote chain
115
141
  */
116
- getAddress: () => ChainAddress;
142
+ getAddress: () => CosmosChainAddress;
117
143
  /** @returns an array of amounts for every balance in the account. */
118
144
  getBalances: () => Promise<DenomAmount[]>;
119
145
  /** @returns the balance of a specific denom for the account. */
@@ -124,14 +150,14 @@ export interface OrchestrationAccountCommon {
124
150
  * @param amount - the amount to send
125
151
  * @returns void
126
152
  */
127
- send: (toAccount: ChainAddress, amount: AmountArg) => Promise<void>;
153
+ send: (toAccount: CosmosChainAddress, amount: AmountArg) => Promise<void>;
128
154
  /**
129
155
  * Transfer multiple amounts to another account on the same chain. The promise settles when the transfer is complete.
130
156
  * @param toAccount - the account to send the amount to. MUST be on the same chain
131
157
  * @param amounts - the amounts to send
132
158
  * @returns void
133
159
  */
134
- sendAll: (toAccount: ChainAddress, amounts: AmountArg[]) => Promise<void>;
160
+ sendAll: (toAccount: CosmosChainAddress, amounts: AmountArg[]) => Promise<void>;
135
161
  /**
136
162
  * Transfer an amount to another account, typically on another chain.
137
163
  * The promise settles when the transfer is complete.
@@ -142,7 +168,7 @@ export interface OrchestrationAccountCommon {
142
168
  * @throws {Error} if route is not determinable, asset is not recognized, or
143
169
  * the transfer is rejected (insufficient funds, timeout)
144
170
  */
145
- transfer: (destination: ChainAddress, amount: AmountArg, opts?: IBCMsgTransferOptions) => Promise<void>;
171
+ transfer: (destination: AccountIdArg, amount: AmountArg, opts?: IBCMsgTransferOptions) => Promise<void>;
146
172
  /**
147
173
  * Transfer an amount to another account in multiple steps. The promise settles when
148
174
  * the entire path of the transfer is complete.
@@ -196,7 +222,7 @@ export interface OrchestrationFlow<CT = unknown> {
196
222
  * @internal
197
223
  */
198
224
  export interface TransferMsg {
199
- toAccount: ChainAddress;
225
+ toAccount: CosmosChainAddress;
200
226
  timeout?: Timestamp;
201
227
  next?: TransferMsg;
202
228
  data?: object;
@@ -204,7 +230,7 @@ export interface TransferMsg {
204
230
  /** @alpha */
205
231
  export interface AfterAction {
206
232
  destChain: string;
207
- destAddress: ChainAddress;
233
+ destAddress: CosmosChainAddress;
208
234
  }
209
235
  /** @alpha */
210
236
  export interface SwapExact {
@@ -1 +1 @@
1
- {"version":3,"file":"orchestration-api.d.ts","sourceRoot":"","sources":["orchestration-api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EACV,kBAAkB,EAClB,SAAS,EACT,yBAAyB,EACzB,eAAe,EACf,qBAAq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as ERTP Amounts */
56
56
  export type AmountArg = DenomAmount | Amount<'nat'>;
57
57
 
58
- /** An address on some blockchain, e.g., cosmos, eth, etc. */
59
- export type ChainAddress = {
60
- /** e.g. 1 for Ethereum, agoric-3 for Agoric, cosmoshub-4 for Cosmos */
58
+ /**
59
+ * Per `chain_id` in CAIP-2. In that spec all chain IDs are scoped
60
+ * (namespace:reference) but in the Cosmos ecosystem the namespace is implied
61
+ * and they use `chain_id`/`chainId` for what CAIP-2 calls the `reference`. We
62
+ * qualify the term here to avoid confusion.
63
+ *
64
+ * @see {@link https://chainagnostic.org/CAIPs/caip-2}
65
+ */
66
+ export type ScopedChainId = `${string}:${string}`;
67
+
68
+ /**
69
+ * à la CAIP-10
70
+ *
71
+ * account_id: chain_id + ":" + account_address
72
+ * chain_id: [-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32} (See [CAIP-2][])
73
+ * account_address: [-.%a-zA-Z0-9]{1,128}
74
+ *
75
+ * @see {@link https://chainagnostic.org/CAIPs/caip-10}
76
+ */
77
+ export type AccountId = `${ScopedChainId}:${string}`;
78
+
79
+ /**
80
+ * Specific to Cosmos chains
81
+ * @see {AccountId} for universal account identifier
82
+ */
83
+ export type CosmosChainAddress = {
84
+ /** Within the Cosmos ecosystem. e.g. `agoric-3' or 'cosmoshub-4' */
61
85
  chainId: string;
62
86
  /** The address value used on-chain */
63
87
  value: string;
64
- encoding: 'bech32' | 'ethereum';
65
88
  };
66
89
 
90
+ /**
91
+ * A value that can be converted mechanically to an AccountId.
92
+ * @see {@link ChainHub.resolveAccountId}
93
+ */
94
+ export type AccountIdArg = AccountId | CosmosChainAddress;
95
+
67
96
  /**
68
97
  * Object that controls an account on a particular chain.
69
98
  *
@@ -165,7 +194,7 @@ export interface OrchestrationAccountCommon {
165
194
  /**
166
195
  * @returns the address of the account on the remote chain
167
196
  */
168
- getAddress: () => ChainAddress;
197
+ getAddress: () => CosmosChainAddress;
169
198
 
170
199
  /** @returns an array of amounts for every balance in the account. */
171
200
  getBalances: () => Promise<DenomAmount[]>;
@@ -179,7 +208,7 @@ export interface OrchestrationAccountCommon {
179
208
  * @param amount - the amount to send
180
209
  * @returns void
181
210
  */
182
- send: (toAccount: ChainAddress, amount: AmountArg) => Promise<void>;
211
+ send: (toAccount: CosmosChainAddress, amount: AmountArg) => Promise<void>;
183
212
 
184
213
  /**
185
214
  * Transfer multiple amounts to another account on the same chain. The promise settles when the transfer is complete.
@@ -187,7 +216,10 @@ export interface OrchestrationAccountCommon {
187
216
  * @param amounts - the amounts to send
188
217
  * @returns void
189
218
  */
190
- sendAll: (toAccount: ChainAddress, amounts: AmountArg[]) => Promise<void>;
219
+ sendAll: (
220
+ toAccount: CosmosChainAddress,
221
+ amounts: AmountArg[],
222
+ ) => Promise<void>;
191
223
 
192
224
  /**
193
225
  * Transfer an amount to another account, typically on another chain.
@@ -200,7 +232,7 @@ export interface OrchestrationAccountCommon {
200
232
  * the transfer is rejected (insufficient funds, timeout)
201
233
  */
202
234
  transfer: (
203
- destination: ChainAddress,
235
+ destination: AccountIdArg,
204
236
  amount: AmountArg,
205
237
  opts?: IBCMsgTransferOptions,
206
238
  ) => Promise<void>;
@@ -262,7 +294,7 @@ export interface OrchestrationFlow<CT = unknown> {
262
294
  * @internal
263
295
  */
264
296
  export interface TransferMsg {
265
- toAccount: ChainAddress;
297
+ toAccount: CosmosChainAddress;
266
298
  timeout?: Timestamp;
267
299
  next?: TransferMsg;
268
300
  data?: object;
@@ -271,7 +303,7 @@ export interface TransferMsg {
271
303
  /** @alpha */
272
304
  export interface AfterAction {
273
305
  destChain: string;
274
- destAddress: ChainAddress;
306
+ destAddress: CosmosChainAddress;
275
307
  }
276
308
  /** @alpha */
277
309
  export interface SwapExact {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @import {TypedPattern} from '@agoric/internal';
3
- * @import {ChainAddress, CosmosAssetInfo, Chain, ChainInfo, CosmosChainInfo, DenomAmount, DenomInfo, AmountArg, CosmosValidatorAddress, OrchestrationPowers, ForwardInfo, IBCMsgTransferOptions} from './types.js';
3
+ * @import {CosmosAssetInfo, ChainInfo, CosmosChainInfo, DenomAmount, DenomInfo, AmountArg, CosmosValidatorAddress, OrchestrationPowers, ForwardInfo, IBCMsgTransferOptions, AccountIdArg} from './types.js';
4
4
  * @import {Any as Proto3Msg} from '@agoric/cosmic-proto/google/protobuf/any.js';
5
5
  * @import {TxBody} from '@agoric/cosmic-proto/cosmos/tx/v1beta1/tx.js';
6
6
  * @import {Coin} from '@agoric/cosmic-proto/cosmos/base/v1beta1/coin.js';
@@ -16,8 +16,15 @@ export const OutboundConnectionHandlerI: import("@endo/patterns").InterfaceGuard
16
16
  onOpen: import("@endo/patterns").MethodGuard;
17
17
  onClose: import("@endo/patterns").MethodGuard;
18
18
  }>;
19
- /** @type {TypedPattern<ChainAddress>} */
20
- export const ChainAddressShape: TypedPattern<ChainAddress>;
19
+ export const CosmosChainAddressShape: import("@endo/patterns").Matcher;
20
+ /** @deprecated use CosmosChainAddressShape */
21
+ export const ChainAddressShape: import("@endo/patterns").Matcher;
22
+ /**
23
+ * NB: For the AccountId case does not fully verify it is CAIP-10 (only string)
24
+ *
25
+ * @type {TypedPattern<AccountIdArg>}
26
+ */
27
+ export const AccountArgShape: TypedPattern<AccountIdArg>;
21
28
  /** @type {TypedPattern<Proto3Msg>} */
22
29
  export const Proto3Shape: TypedPattern<Proto3Msg>;
23
30
  /** @internal */
@@ -95,7 +102,7 @@ export const ForwardOptsShape: TypedPattern<IBCMsgTransferOptions["forwardOpts"]
95
102
  * @internal
96
103
  */
97
104
  export const IBCTransferOptionsShape: TypedPattern<IBCMsgTransferOptions>;
98
- import type { ChainAddress } from './types.js';
105
+ import type { AccountIdArg } from './types.js';
99
106
  import type { TypedPattern } from '@agoric/internal';
100
107
  import type { Any as Proto3Msg } from '@agoric/cosmic-proto/google/protobuf/any.js';
101
108
  import type { CosmosAssetInfo } from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"typeGuards.d.ts","s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;AAExE;;;;;GAKG;AACH,8BALU,aAAa;IAClB,SAAS,EAAE,sBAAsB,CAAC;IAClC,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC,CAQH;AAEF,sCAAsC;AACtC,2DAGE;AAEF,sCAAsC;AACtC,6BADW,aAAa,SAAS,CAAC,CACmC;;;;;;;;;AAmBrE;;;;GAIG;AACH,+DAQE;AAEF;;;GAGG;AACH,mEAGE;AAEF,gDAAgD;AAChD,uCADW,aAAa,mBAAmB,CAAC,CAO1C;AAYF,wCAAwC;AACxC,+BADW,aAAa,WAAW,CAAC,CAWlC;AAGF;;;;GAIG;AACH,+BAFU,aAAa,qBAAqB,CAAC,aAAa,CAAC,CAAC,CAU1D;AAEF;;;GAGG;AACH,sCAHU,aAAa,qBAAqB,CAAC,CAc3C;kCApR8L,YAAY;kCAD7K,kBAAkB;sCAEd,6CAA6C;qCADgH,YAAY;qCAAZ,YAAY;+BAAZ,YAAY;0BAGrL,kDAAkD;+BAHuH,YAAY;iCAK9K,qBAAqB;iCAL6I,YAAY;+BAAZ,YAAY;4CAAZ,YAAY;+BAIhL,sBAAsB;yCAJ8I,YAAY;iCAAZ,YAAY;2CAAZ,YAAY"}
package/src/typeGuards.js CHANGED
@@ -4,7 +4,7 @@ import { M } from '@endo/patterns';
4
4
 
5
5
  /**
6
6
  * @import {TypedPattern} from '@agoric/internal';
7
- * @import {ChainAddress, CosmosAssetInfo, Chain, ChainInfo, CosmosChainInfo, DenomAmount, DenomInfo, AmountArg, CosmosValidatorAddress, OrchestrationPowers, ForwardInfo, IBCMsgTransferOptions} from './types.js';
7
+ * @import {CosmosAssetInfo, ChainInfo, CosmosChainInfo, DenomAmount, DenomInfo, AmountArg, CosmosValidatorAddress, OrchestrationPowers, ForwardInfo, IBCMsgTransferOptions, AccountIdArg} from './types.js';
8
8
  * @import {Any as Proto3Msg} from '@agoric/cosmic-proto/google/protobuf/any.js';
9
9
  * @import {TxBody} from '@agoric/cosmic-proto/cosmos/tx/v1beta1/tx.js';
10
10
  * @import {Coin} from '@agoric/cosmic-proto/cosmos/base/v1beta1/coin.js';
@@ -27,17 +27,32 @@ export const OutboundConnectionHandlerI = M.interface(
27
27
  },
28
28
  );
29
29
 
30
- /** @type {TypedPattern<ChainAddress>} */
31
- export const ChainAddressShape = {
32
- chainId: M.string(),
33
- encoding: M.string(),
34
- value: M.string(),
35
- };
36
- harden(ChainAddressShape);
30
+ // XXX @type {TypedPattern<CosmosChainAddress>} but that's causing error:
31
+ // Declaration emit for this file requires using private name 'validatedType' from module '"/opt/agoric/agoric-sdk/packages/internal/src/types"'. An explicit type annotation may unblock declaration emit.
32
+ export const CosmosChainAddressShape = M.splitRecord(
33
+ {
34
+ chainId: M.string(),
35
+ value: M.string(),
36
+ },
37
+ {
38
+ // Ignored but maintained for backwards compatibility
39
+ encoding: 'bech32',
40
+ },
41
+ );
42
+ harden(CosmosChainAddressShape);
43
+ /** @deprecated use CosmosChainAddressShape */
44
+ export const ChainAddressShape = CosmosChainAddressShape;
45
+
46
+ /**
47
+ * NB: For the AccountId case does not fully verify it is CAIP-10 (only string)
48
+ *
49
+ * @type {TypedPattern<AccountIdArg>}
50
+ */
51
+ export const AccountArgShape = M.or(M.string(), CosmosChainAddressShape);
37
52
 
38
53
  /** @type {TypedPattern<Proto3Msg>} */
39
54
  export const Proto3Shape = { typeUrl: M.string(), value: M.string() };
40
- harden(ChainAddressShape);
55
+ harden(Proto3Shape);
41
56
 
42
57
  /** @internal */
43
58
  export const IBCChannelIDShape = M.string();
@@ -146,10 +161,10 @@ export const AmountArgShape = M.or(AnyNatAmountShape, DenomAmountShape);
146
161
  */
147
162
  export const DelegationShape = M.splitRecord(
148
163
  {
149
- validator: ChainAddressShape,
164
+ validator: CosmosChainAddressShape,
150
165
  amount: AmountArgShape,
151
166
  },
152
- { delegator: ChainAddressShape },
167
+ { delegator: CosmosChainAddressShape },
153
168
  );
154
169
 
155
170
  /** Approximately @see RequestQuery */
@@ -245,7 +260,7 @@ export const ForwardOptsShape = M.splitRecord(
245
260
  {
246
261
  timeout: M.string(),
247
262
  retries: M.number(),
248
- intermediateRecipient: ChainAddressShape,
263
+ intermediateRecipient: CosmosChainAddressShape,
249
264
  },
250
265
  {},
251
266
  );
@@ -1,8 +1,15 @@
1
1
  export function makeICAChannelAddress(hostConnectionId: IBCConnectionID, controllerConnectionId: IBCConnectionID, { version, encoding, ordering, txType, }?: ICAChannelAddressOpts): RemoteIbcAddress;
2
2
  export const DEFAULT_ICQ_VERSION: "icq-1";
3
3
  export function makeICQChannelAddress(controllerConnectionId: IBCConnectionID, version?: string): RemoteIbcAddress;
4
- export function findAddressField(remoteAddressString: RemoteIbcAddress): ChainAddress["value"] | undefined;
4
+ export function findAddressField(remoteAddressString: RemoteIbcAddress): CosmosChainAddress["value"] | undefined;
5
5
  export function getBech32Prefix(address: string): string;
6
+ export function parseAccountId(partialId: string): {
7
+ namespace: string;
8
+ reference: string;
9
+ accountAddress: string;
10
+ } | {
11
+ accountAddress: string;
12
+ };
6
13
  export type ICAChannelAddressOpts = {
7
14
  /**
8
15
  * message encoding format for the
@@ -25,5 +32,5 @@ export type ICAChannelAddressOpts = {
25
32
  };
26
33
  import type { IBCConnectionID } from '@agoric/vats';
27
34
  import type { RemoteIbcAddress } from '@agoric/vats/tools/ibc-utils.js';
28
- import type { ChainAddress } from '../types.js';
35
+ import type { CosmosChainAddress } from '../types.js';
29
36
  //# sourceMappingURL=address.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["address.js"],"names":[],"mappings":"AAwBO,wDALI,eAAe,0BACf,eAAe,6CACf,qBAAqB,GACnB,gBAAgB,CAuB5B;AAGD,kCAAmC,OAAO,CAAC;AAOpC,8DAJI,eAAe,YACf,MAAM,GACJ,gBAAgB,CAQ5B;AAaM,sDAJI,gBAAgB,GAEd,YAAY,CAAC,OAAO,CAAC,GAAG,SAAS,CAY7C;AAYM,yCAFI,MAAM,UAQhB;;;;;;;;;;;;;;;;;;;;;qCAnGiC,cAAc;sCAEb,iCAAiC;kCADrC,aAAa"}
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["address.js"],"names":[],"mappings":"AAwBO,wDALI,eAAe,0BACf,eAAe,6CACf,qBAAqB,GACnB,gBAAgB,CAuB5B;AAGD,kCAAmC,OAAO,CAAC;AAOpC,8DAJI,eAAe,YACf,MAAM,GACJ,gBAAgB,CAQ5B;AAaM,sDAJI,gBAAgB,GAEd,kBAAkB,CAAC,OAAO,CAAC,GAAG,SAAS,CAYnD;AAaM,yCAHI,MAAM,GACJ,MAAM,CAQlB;AAgBM,0CAXI,MAAM,GACJ;IACJ,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB,GACD;IACE,cAAc,EAAE,MAAM,CAAC;CACxB,CAyBP;;;;;;;;;;;;;;;;;;;;;qCA1IiC,cAAc;sCAEb,iCAAiC;wCADhB,aAAa"}
@@ -2,7 +2,7 @@ import { Fail, q } from '@endo/errors';
2
2
 
3
3
  /**
4
4
  * @import {IBCConnectionID} from '@agoric/vats';
5
- * @import {ChainAddress} from '../types.js';
5
+ * @import {CosmosChainAddress, ScopedChainId} from '../types.js';
6
6
  * @import {RemoteIbcAddress} from '@agoric/vats/tools/ibc-utils.js';
7
7
  */
8
8
 
@@ -70,7 +70,7 @@ harden(makeICQChannelAddress);
70
70
  *
71
71
  * @param {RemoteIbcAddress} remoteAddressString - remote address string,
72
72
  * including version
73
- * @returns {ChainAddress['value'] | undefined} returns undefined on error
73
+ * @returns {CosmosChainAddress['value'] | undefined} returns undefined on error
74
74
  */
75
75
  export const findAddressField = remoteAddressString => {
76
76
  try {
@@ -86,13 +86,14 @@ export const findAddressField = remoteAddressString => {
86
86
  harden(findAddressField);
87
87
 
88
88
  /**
89
- * Extracts the human readable part (HRP), aka `bech32Prefix`, from an address.
89
+ * Extracts the human-readable part (HRP), aka `bech32Prefix`, from an address.
90
90
  *
91
91
  * see
92
92
  * [bech32.js](https://github.com/bitcoinjs/bech32/blob/5ceb0e3d4625561a459c85643ca6947739b2d83c/src/index.ts#L146)
93
- * for reference implementation
93
+ * for the reference implementation.
94
94
  *
95
- * @param {string} address
95
+ * @param {string} address - The full Bech32-encoded address.
96
+ * @returns {string} - The extracted HRP (prefix).
96
97
  */
97
98
  export const getBech32Prefix = address => {
98
99
  assert(address, 'address is required');
@@ -101,3 +102,42 @@ export const getBech32Prefix = address => {
101
102
  if (split === 0) return Fail`Missing prefix for ${q(address)}`;
102
103
  return address.slice(0, split);
103
104
  };
105
+
106
+ /**
107
+ * Parses an account ID into a structured format following CAIP-10 standards.
108
+ *
109
+ * @param {string} partialId CAIP-10 account ID or an unscoped on-chain address
110
+ * @returns {{
111
+ * namespace: string;
112
+ * reference: string;
113
+ * accountAddress: string;
114
+ * }
115
+ * | {
116
+ * accountAddress: string;
117
+ * }}
118
+ * - The parsed account details.
119
+ */
120
+ export const parseAccountId = partialId => {
121
+ if (typeof partialId !== 'string' || !partialId.length) {
122
+ Fail`Empty accountId: ${q(partialId)}`;
123
+ }
124
+
125
+ const parts = partialId.split(':');
126
+
127
+ if (parts.length === 3) {
128
+ // Full CAIP-10
129
+ const [namespace, reference, accountAddress] = parts;
130
+ return {
131
+ namespace,
132
+ reference,
133
+ accountAddress,
134
+ };
135
+ } else if (parts.length === 1) {
136
+ return {
137
+ accountAddress: partialId,
138
+ };
139
+ }
140
+
141
+ throw Fail`Invalid accountId: ${q(partialId)}`;
142
+ };
143
+ harden(parseAccountId);
@@ -1 +1 @@
1
- {"version":3,"file":"cosmos.d.ts","sourceRoot":"","sources":["cosmos.js"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH,mFAAmF;AACnF,kCAAsC;AAO/B,kCAJM,CAAC,UACH,MAAM,gBACN,CAAC,CAAC,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,KAAK,CAAC,KAY1D;AAED;;;;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B;AAEH;;;;;;;;GAQG;AACH,yCALU,CACL,SAAS,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EAC9B,CAAC,EAAE,kBAAkB,KAClB,wBAAwB,CAS7B;iCA1E6E,aAAa;4CAAb,aAAa;wCAExD,wDAAwD;8CAFb,aAAa"}
@@ -57,7 +57,6 @@ export const toTruncatedDenomAmount = c => ({
57
57
  * ) => CosmosValidatorAddress}
58
58
  */
59
59
  export const toCosmosValidatorAddress = (r, chainId) => ({
60
- encoding: 'bech32',
61
60
  value: /** @type {CosmosValidatorAddress['value']} */ (r.validatorAddress),
62
61
  chainId,
63
62
  });
@@ -74,7 +73,6 @@ export const toCosmosValidatorAddress = (r, chainId) => ({
74
73
  export const toCosmosDelegationResponse = ({ chainId }, r) => ({
75
74
  delegator: {
76
75
  chainId,
77
- encoding: 'bech32',
78
76
  value: r.delegation.delegatorAddress,
79
77
  },
80
78
  validator: toCosmosValidatorAddress(r.delegation, chainId),
@@ -1 +1 @@
1
- {"version":3,"file":"orc.d.ts","sourceRoot":"","sources":["orc.js"],"names":[],"mappings":";IASmB,gCAHN,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GACvB,WAAW,CAWvB;IACD;;;;;;;OAOG;IACH,gCALW,CAAC,SAAS,GAAG,eAAe,CAAC,GACvC,CAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,GAE7B,WAAW,CAWvB;;iCApCqE,aAAa;+BAAb,aAAa;qCAAb,aAAa;iCAAb,aAAa"}
1
+ {"version":3,"file":"orc.d.ts","sourceRoot":"","sources":["orc.js"],"names":[],"mappings":";IASmB,gCAHN,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GACvB,WAAW,CAUvB;IACD;;;;;;;OAOG;IACH,gCALW,CAAC,SAAS,GAAG,eAAe,CAAC,GACvC,CAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,GAE7B,WAAW,CAUvB;;iCAlCqE,aAAa;+BAAb,aAAa;qCAAb,aAAa;iCAAb,aAAa"}
package/src/utils/orc.js CHANGED
@@ -13,7 +13,6 @@ export const orcUtils = {
13
13
  toAccount: {
14
14
  chainId: 'osmosis-test',
15
15
  value: 'osmo1234',
16
- encoding: 'bech32',
17
16
  },
18
17
  };
19
18
  },
@@ -31,7 +30,6 @@ export const orcUtils = {
31
30
  toAccount: {
32
31
  chainId: 'osmosis-test',
33
32
  value: 'osmo1234',
34
- encoding: 'bech32',
35
33
  },
36
34
  };
37
35
  },