@agoric/orchestration 0.1.1-dev-d756c83.0.d756c83 → 0.1.1-dev-e9efaa1.0.e9efaa1

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.
@@ -1,405 +0,0 @@
1
- /**
2
- * @file General API of orchestration
3
- * - must not have chain-specific types without runtime narrowing by chain id
4
- * - should remain relatively stable.
5
- */
6
- import type { Amount, Brand, NatAmount } from '@agoric/ertp/src/types.js';
7
- // eslint-disable-next-line @typescript-eslint/no-unused-vars -- fails to notice the @see uses
8
- import type { CurrentWalletRecord } from '@agoric/smart-wallet/src/smartWallet.js';
9
- import type { Timestamp } from '@agoric/time';
10
- import type { QueryManyFn } from '@agoric/vats/src/localchain.js';
11
- import type { ResolvedPublicTopic } from '@agoric/zoe/src/contractSupport/topics.js';
12
- import type { Passable } from '@endo/marshal';
13
- import type { SendOptions } from '@agoric/network';
14
- import type {
15
- AgoricChainMethods,
16
- CosmosChainAccountMethods,
17
- CosmosChainInfo,
18
- IBCMsgTransferOptions,
19
- KnownChains,
20
- LocalAccountMethods,
21
- ICQQueryFunction,
22
- KnownNamespace,
23
- NobleMethods,
24
- Bech32Address,
25
- ProgressTracker,
26
- } from './types.js';
27
-
28
- import type { ResolvedContinuingOfferResult } from './utils/zoe-tools.js';
29
-
30
- export type OrchestrationOptions = {
31
- progressTracker?: ProgressTracker;
32
- };
33
-
34
- export type PacketOptions = OrchestrationOptions & {
35
- sendOpts?: SendOptions;
36
- };
37
-
38
- /**
39
- * Options relevant to all queries (non-mutating).
40
- */
41
- export type QuerierOptions = PacketOptions & {
42
- queryOpts?: Record<string, any>;
43
- };
44
-
45
- /**
46
- * Options relevant to all actions (mutating).
47
- */
48
- export type ActionOptions = PacketOptions & {
49
- txOpts?: Record<string, any>;
50
- };
51
-
52
- /**
53
- * A denom that designates a path to a token type on some blockchain.
54
- *
55
- * Multiple denoms may designate the same underlying base denom (e.g., `uist`,
56
- * `uatom`) on different Chains or on the same Chain via different paths. On
57
- * Cosmos chains, all but the base denom are IBC style denoms, but that may vary
58
- * across other chains. All the denoms that designate the same underlying base
59
- * denom form an equivalence class, along with the unique Brand on the local
60
- * Chain. Some operations accept any member of the equivalence class to
61
- * effectively designate the corresponding token type on the target chain.
62
- */
63
- export type Denom = string; // ibc/... or uist
64
-
65
- // ??? when multiple Denoms provide paths to the same remote token type,
66
- // should the brand be 1:1 with that equivalence class or each Denom?
67
- /**
68
- * In many cases, either a denom string or a local Brand can be used to
69
- * designate a remote token type.
70
- */
71
- export type DenomArg = Denom | Brand<'nat'>;
72
-
73
- /**
74
- * Count of some fungible token on some blockchain.
75
- *
76
- * @see {@link Orchestrator.asAmount} to convert to an Amount surjectively
77
- */
78
- export type DenomAmount = {
79
- denom: Denom;
80
- value: bigint; // Nat
81
- };
82
-
83
- /** Amounts can be provided as pure data using denoms or as ERTP Amounts */
84
- export type AmountArg = DenomAmount | Amount<'nat'>;
85
-
86
- /**
87
- * Per `chain_id` in CAIP-2. In that spec all chain IDs are scoped
88
- * (namespace:reference) but in the Cosmos ecosystem the namespace is implied
89
- * and they use `chain_id`/`chainId` for what CAIP-2 calls the `reference`. We
90
- * qualify the term here to avoid confusion.
91
- *
92
- * @see {@link https://chainagnostic.org/CAIPs/caip-2}
93
- */
94
- export type CaipChainId = `${string}:${string}`;
95
-
96
- /**
97
- * à la CAIP-10
98
- *
99
- * account_id: chain_id + ":" + account_address
100
- * chain_id: [-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32} (See [CAIP-2][])
101
- * account_address: [-.%a-zA-Z0-9]{1,128}
102
- *
103
- * @see {@link https://chainagnostic.org/CAIPs/caip-10}
104
- */
105
- export type AccountId = `${CaipChainId}:${string}`;
106
-
107
- /**
108
- * Specific to Cosmos chains
109
- * @see {AccountId} for universal account identifier
110
- */
111
- export type CosmosChainAddress = {
112
- /** Within the Cosmos ecosystem. e.g. `agoric-3' or 'cosmoshub-4' */
113
- chainId: string;
114
- /** The address value used on-chain */
115
- value: Bech32Address;
116
- encoding: 'bech32';
117
- };
118
-
119
- /**
120
- * Info used to identify blockchains across ecosystems
121
- * @see {@link https://chainagnostic.org/CAIPs/caip-2}
122
- */
123
- export interface BaseChainInfo<N extends KnownNamespace = KnownNamespace> {
124
- /** CAIP-2 namespace, e.g. 'cosmos', 'eip155' */
125
- namespace: N;
126
- /** CAIP-2 reference, `e.g. `1`, `agoric-3` */
127
- reference: N extends 'eip155' ? `${number}` : string;
128
- /**
129
- * Circle CCTP Destination Domain
130
- * @see {@link https://developers.circle.com/stablecoins/supported-domains}
131
- */
132
- cctpDestinationDomain?: number;
133
- }
134
-
135
- /**
136
- * Shape that `ChainHub` is expecting
137
- */
138
- export type ChainInfo<N extends KnownNamespace = KnownNamespace> =
139
- N extends 'cosmos' ? CosmosChainInfo : BaseChainInfo<N>;
140
-
141
- /**
142
- * A value that can be converted mechanically to an AccountId.
143
- * @see {@link ChainHub.resolveAccountId}
144
- */
145
- export type AccountIdArg = AccountId | CosmosChainAddress;
146
-
147
- export type Caip10Record = {
148
- namespace: string;
149
- reference: string;
150
- accountAddress: string;
151
- };
152
-
153
- /**
154
- * Object that controls an account on a particular chain.
155
- *
156
- * The methods available depend on the chain and its capabilities.
157
- */
158
- export type OrchestrationAccount<CI extends Partial<ChainInfo>> =
159
- OrchestrationAccountCommon &
160
- (CI extends { chainId: string }
161
- ? CI['chainId'] extends `agoric${string}`
162
- ? LocalAccountMethods
163
- : CI['chainId'] extends `noble${string}`
164
- ? CosmosChainAccountMethods<CI> & NobleMethods
165
- : CosmosChainAccountMethods<CI>
166
- : object);
167
-
168
- /**
169
- * An object for access the core functions of a remote chain.
170
- *
171
- * Note that "remote" can mean the local chain; it's just that
172
- * accounts are treated as remote/arms length for consistency.
173
- */
174
- export interface Chain<CI extends Partial<ChainInfo>> {
175
- getChainInfo: () => Promise<CI>;
176
-
177
- // "makeAccount" suggests an operation within a vat
178
- // TODO: scope to { icaEnabled: true }. Currently, only scoped to `namespace: 'cosmos'` chains
179
- /**
180
- * Creates a new Orchestration Account on the current Chain.
181
- * @returns an object that controls the account
182
- */
183
- makeAccount: (
184
- opts?: OrchestrationOptions,
185
- ) => CI extends { chainId: string }
186
- ? Promise<OrchestrationAccount<CI>>
187
- : never;
188
- // FUTURE supply optional port object; also fetch port object
189
-
190
- query: CI extends { icqEnabled: true }
191
- ? ICQQueryFunction
192
- : CI extends { chainId: string }
193
- ? CI['chainId'] extends `agoric${string}`
194
- ? QueryManyFn
195
- : never
196
- : never;
197
-
198
- // TODO provide a way to get the local denom/brand/whatever for this chain
199
- }
200
-
201
- /**
202
- * Used with `orch.getDenomInfo('ibc/1234')`. See {@link Orchestrator.getDenomInfo}
203
- */
204
- export interface DenomInfo<
205
- HoldingChain extends keyof KnownChains,
206
- IssuingChain extends keyof KnownChains,
207
- > {
208
- /** The well-known Brand on Agoric for the direct asset */
209
- brand?: Brand;
210
- /** The Chain at which the argument `denom` exists (where the asset is currently held) */
211
- chain: Chain<KnownChains[HoldingChain]>;
212
- /** The Chain that is the issuer of the underlying asset */
213
- base: Chain<KnownChains[IssuingChain]>;
214
- /** the Denom for the underlying asset on its issuer chain */
215
- baseDenom: Denom;
216
- }
217
-
218
- /**
219
- * Provided in the callback to `orchestrate()`.
220
- */
221
- export interface Orchestrator {
222
- /**
223
- * Get a Chain object for working with the given chain.
224
- *
225
- * @param {C} chainName name of the chain in KnownChains or the ChainHub backing the Orchestrator
226
- */
227
- getChain: <C extends string>(
228
- chainName: C,
229
- ) => Promise<
230
- Chain<C extends keyof KnownChains ? KnownChains[C] : any> &
231
- (C extends 'agoric' ? AgoricChainMethods : object)
232
- >;
233
-
234
- /**
235
- * For a denom, return information about a denom including the equivalent
236
- * local Brand, the Chain on which the denom is held, and the Chain that
237
- * issues the corresponding asset.
238
- * @param denom
239
- */
240
- getDenomInfo: <
241
- HoldingChain extends keyof KnownChains,
242
- IssuingChain extends keyof KnownChains,
243
- >(
244
- denom: Denom,
245
- srcChainName: HoldingChain,
246
- ) => DenomInfo<HoldingChain, IssuingChain>;
247
-
248
- /**
249
- * Convert an amount described in native data to a local, structured Amount.
250
- * @param amount - the described amount
251
- * @returns the Amount in local structuerd format
252
- */
253
- asAmount: (amount: DenomAmount) => NatAmount;
254
- }
255
-
256
- /**
257
- * An object that supports high-level operations for an account on a remote chain.
258
- */
259
- export interface OrchestrationAccountCommon {
260
- /**
261
- * @returns the address of the account on the remote chain
262
- */
263
- getAddress: () => CosmosChainAddress;
264
-
265
- /**
266
- * @returns an array of amounts for every balance in the account.
267
- *
268
- * @throws when prohibited (see `icqEnabled` in {@link CosmosChainInfo})
269
- */
270
- getBalances: (opts?: QuerierOptions) => Promise<DenomAmount[]>;
271
-
272
- /**
273
- * @returns the balance of a specific denom for the account.
274
- *
275
- * @throws when prohibited (see `icqEnabled` in {@link CosmosChainInfo})
276
- */
277
- getBalance: (denom: DenomArg, opts?: QuerierOptions) => Promise<DenomAmount>;
278
-
279
- /**
280
- * @returns a progressTracker that can be used to give incremental updates to an
281
- * orchestration client.
282
- */
283
- makeProgressTracker: () => ProgressTracker;
284
-
285
- /**
286
- * Transfer amount to another account on the same chain. The promise settles when the transfer is complete.
287
- * @param toAccount - the account to send the amount to. MUST be on the same chain
288
- * @param amount - the amount to send
289
- * @param [opts] - transaction submission options
290
- * @returns unknown
291
- */
292
- send: (
293
- toAccount: AccountIdArg,
294
- amount: AmountArg,
295
- opts?: ActionOptions,
296
- ) => Promise<unknown>;
297
-
298
- /**
299
- * Transfer multiple amounts to another account on the same chain. The promise settles when the transfer is complete.
300
- * @param toAccount - the account to send the amount to. MUST be on the same chain
301
- * @param amounts - the amounts to send
302
- * @param [opts] - transaction submission options
303
- * @returns unknown
304
- */
305
- sendAll: (
306
- toAccount: CosmosChainAddress,
307
- amounts: AmountArg[],
308
- opts?: ActionOptions,
309
- ) => Promise<unknown>;
310
-
311
- /**
312
- * Transfer an amount to another account, typically on another chain.
313
- * The promise settles when the transfer is complete.
314
- * @param amount - the amount to transfer. Can be provided as pure data using denoms or as ERTP Amounts.
315
- * @param destination - the account to transfer the amount to.
316
- * @param [opts] - an optional memo to include with the transfer, which could drive custom PFM behavior, and timeout parameters
317
- * @returns {Promise<unknown>} The promise fulfills with the successful acknowledgement of the transfer
318
- * @throws {Error} if route is not determinable, asset is not recognized, or
319
- * the transfer is rejected (insufficient funds, timeout, error ack)
320
- */
321
- transfer: (
322
- destination: AccountIdArg,
323
- amount: AmountArg,
324
- opts?: IBCMsgTransferOptions,
325
- ) => Promise<unknown>;
326
-
327
- /**
328
- * Transfer an amount to another account in multiple steps. The promise settles when
329
- * the entire path of the transfer is complete.
330
- * @param amount - the amount to transfer
331
- * @param msg - the transfer message, including follow-up steps
332
- * @returns unknown
333
- */
334
- transferSteps: (amount: AmountArg, msg: TransferMsg) => Promise<unknown>;
335
-
336
- /**
337
- * Returns `invitationMakers` and `publicSubscribers` to the account
338
- * holder's smart wallet so they can continue interacting with the account
339
- * and read account state in vstorage if published.
340
- */
341
- asContinuingOffer: () => Promise<ResolvedContinuingOfferResult>;
342
-
343
- /**
344
- * Public topics are a map to different vstorage paths and subscribers that
345
- * can be shared with on or offchain clients.
346
- * When returned as part of a continuing invitation, it will appear
347
- * in the {@link CurrentWalletRecord} in vstorage.
348
- */
349
- getPublicTopics: () => Promise<Record<string, ResolvedPublicTopic<unknown>>>;
350
- }
351
-
352
- /**
353
- * Flows to orchestrate are regular Javascript functions but have some
354
- * constraints to fulfill the requirements of resumability after termination of
355
- * the enclosing vat. Some requirements for each orchestration flow:
356
- * - must not close over any values that could change between invocations
357
- * - must satisfy the `OrchestrationFlow` interface
358
- * - must be hardened
359
- * - must not use `E()` (eventual send)
360
- *
361
- * The call to `orchestrate` using a flow function in reincarnations of the vat
362
- * must have the same `durableName` as before. To help enforce these
363
- * constraints, we recommend:
364
- *
365
- * - keeping flows in a `.flows.js` module
366
- * - importing them all with `import * as flows` to get a single object keyed by
367
- * the export name
368
- * - using `orchestrateAll` to treat each export name as the `durableName` of
369
- * the flow
370
- * - adopting `@agoric/eslint-config` that has rules to help detect problems
371
- */
372
- export interface OrchestrationFlow<CT = unknown> {
373
- (orc: Orchestrator, ctx: CT, ...args: Passable[]): Promise<unknown>;
374
- }
375
-
376
- /**
377
- * Internal structure for TransferMsgs.
378
- * The type must be able to express transfers across different chains and transports.
379
- *
380
- * NOTE Expected to change, so consider an opaque structure.
381
- * @internal
382
- */
383
- export interface TransferMsg {
384
- toAccount: CosmosChainAddress;
385
- timeout?: Timestamp;
386
- next?: TransferMsg;
387
- data?: object;
388
- }
389
-
390
- /** @alpha */
391
- export interface AfterAction {
392
- destChain: string;
393
- destAddress: CosmosChainAddress;
394
- }
395
- /** @alpha */
396
- export interface SwapExact {
397
- amountIn: Amount;
398
- amountOut: Amount;
399
- }
400
- /** @alpha */
401
- export interface SwapMaxSlippage {
402
- amountIn: Amount;
403
- brandOut: Brand;
404
- slippage: number;
405
- }
package/src/types.ts DELETED
@@ -1,27 +0,0 @@
1
- /** @file Rollup of all type definitions in the package, for local import and external export */
2
-
3
- import type { ZCF } from '@agoric/zoe';
4
-
5
- export type * from './chain-info.js';
6
- export type * from './cosmos-api.js';
7
- export type * from './exos/chain-hub.js';
8
- export type * from './exos/combine-invitation-makers.js';
9
- export type * from './exos/cosmos-interchain-service.js';
10
- export type * from './exos/exo-interfaces.js';
11
- export type * from './exos/ica-account-kit.js';
12
- export type * from './exos/icq-connection-kit.js';
13
- export type * from './exos/local-chain-facade.js';
14
- export type * from './exos/portfolio-holder-kit.js';
15
- export type * from './orchestration-api.js';
16
- export type * from './vat-orchestration.js';
17
- export type * from './utils/start-helper.js';
18
- export type * from './utils/progress.js';
19
-
20
- /**
21
- * ({@link ZCF})-like tools for use in {@link OrchestrationFlow}s.
22
- */
23
- export interface ZcfTools {
24
- assertUniqueKeyword: ZCF['assertUniqueKeyword'];
25
- atomicRearrange: ZCF['atomicRearrange'];
26
- makeInvitation: ZCF['makeInvitation'];
27
- }
@@ -1,13 +0,0 @@
1
- import type { TypedDataType, TypedData } from 'abitype';
2
-
3
- // Redefine abitype's TypedDataParameter to make it generic
4
- export type TypedDataParameter<
5
- TN extends string = string,
6
- TT extends string =
7
- | TypedDataType
8
- | keyof TypedData
9
- | `${keyof TypedData}[${string | ''}]`,
10
- > = {
11
- name: TN;
12
- type: TT;
13
- };
@@ -1,18 +0,0 @@
1
- import type {
2
- ByteArray,
3
- Hex,
4
- Signature,
5
- TypedData,
6
- TypedDataDefinition,
7
- } from 'viem';
8
-
9
- export type WithSignature<T> = T & {
10
- signature: Hex | ByteArray | Signature;
11
- };
12
-
13
- export type SignedTypedDataDefinition<
14
- typedData extends TypedData | Record<string, unknown> = TypedData,
15
- primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,
16
- ///
17
- primaryTypes = typedData extends TypedData ? keyof typedData : string,
18
- > = WithSignature<TypedDataDefinition<typedData, primaryType, primaryTypes>>;
File without changes
File without changes
File without changes