@agoric/orchestration 0.1.1-dev-6b5e706.0 → 0.1.1-dev-2dc53d7.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 (72) hide show
  1. package/index.d.ts +4 -0
  2. package/index.js +0 -1
  3. package/package.json +17 -15
  4. package/src/chain-info.d.ts +37 -0
  5. package/src/chain-info.d.ts.map +1 -0
  6. package/src/chain-info.ts +64 -0
  7. package/src/cosmos-api.d.ts +159 -0
  8. package/src/cosmos-api.d.ts.map +1 -0
  9. package/src/cosmos-api.ts +199 -0
  10. package/src/ethereum-api.d.ts +8 -0
  11. package/src/ethereum-api.d.ts.map +1 -0
  12. package/src/ethereum-api.ts +7 -0
  13. package/src/examples/stakeAtom.contract.d.ts +84 -0
  14. package/src/examples/stakeAtom.contract.d.ts.map +1 -0
  15. package/src/examples/stakeAtom.contract.js +0 -1
  16. package/src/examples/stakeBld.contract.d.ts +39 -0
  17. package/src/examples/stakeBld.contract.d.ts.map +1 -0
  18. package/src/examples/stakeBld.contract.js +0 -1
  19. package/src/examples/swapExample.contract.d.ts +31 -0
  20. package/src/examples/swapExample.contract.d.ts.map +1 -0
  21. package/src/examples/swapExample.contract.js +2 -3
  22. package/src/examples/unbondExample.contract.d.ts +24 -0
  23. package/src/examples/unbondExample.contract.d.ts.map +1 -0
  24. package/src/examples/unbondExample.contract.js +1 -2
  25. package/src/exos/chainAccountKit.d.ts +71 -0
  26. package/src/exos/chainAccountKit.d.ts.map +1 -0
  27. package/src/exos/chainAccountKit.js +0 -1
  28. package/src/exos/icqConnectionKit.d.ts +43 -0
  29. package/src/exos/icqConnectionKit.d.ts.map +1 -0
  30. package/src/exos/icqConnectionKit.js +0 -1
  31. package/src/exos/localchainAccountKit.d.ts +68 -0
  32. package/src/exos/localchainAccountKit.d.ts.map +1 -0
  33. package/src/exos/localchainAccountKit.js +0 -1
  34. package/src/exos/stakingAccountKit.d.ts +146 -0
  35. package/src/exos/stakingAccountKit.d.ts.map +1 -0
  36. package/src/exos/stakingAccountKit.js +12 -13
  37. package/src/facade.d.ts +29 -0
  38. package/src/facade.d.ts.map +1 -0
  39. package/src/facade.js +7 -3
  40. package/src/orchestration-api.d.ts +158 -0
  41. package/src/orchestration-api.d.ts.map +1 -0
  42. package/src/orchestration-api.ts +195 -0
  43. package/src/proposals/orchestration-proposal.d.ts +629 -0
  44. package/src/proposals/orchestration-proposal.d.ts.map +1 -0
  45. package/src/proposals/orchestration-proposal.js +0 -1
  46. package/src/proposals/start-stakeAtom.d.ts +115 -0
  47. package/src/proposals/start-stakeAtom.d.ts.map +1 -0
  48. package/src/proposals/start-stakeAtom.js +0 -1
  49. package/src/proposals/start-stakeBld.d.ts +80 -0
  50. package/src/proposals/start-stakeBld.d.ts.map +1 -0
  51. package/src/proposals/start-stakeBld.js +2 -2
  52. package/src/service.d.ts +67 -0
  53. package/src/service.d.ts.map +1 -0
  54. package/src/service.js +2 -3
  55. package/src/typeGuards.d.ts +28 -0
  56. package/src/typeGuards.d.ts.map +1 -0
  57. package/src/types.d.ts +8 -482
  58. package/src/types.d.ts.map +1 -0
  59. package/src/types.ts +10 -0
  60. package/src/utils/address.d.ts +11 -0
  61. package/src/utils/address.d.ts.map +1 -0
  62. package/src/utils/address.js +0 -1
  63. package/src/utils/orc.d.ts +14 -0
  64. package/src/utils/orc.d.ts.map +1 -0
  65. package/src/utils/orc.js +0 -1
  66. package/src/utils/packet.d.ts +52 -0
  67. package/src/utils/packet.d.ts.map +1 -0
  68. package/src/utils/packet.js +0 -1
  69. package/src/vat-orchestration.d.ts +36 -0
  70. package/src/vat-orchestration.d.ts.map +1 -0
  71. package/src/vat-orchestration.js +0 -1
  72. package/src/types.js +0 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["facade.js"],"names":[],"mappings":"AAmBO;;;SALG,IAAI,CAAC,GAAG,CAAC;iBACD,IAAI,CAAC,WAAW,CAAC;;;;;;;;;;IAoB/B;;;;;;;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;EAOnD;kCAEa,UAAU,CAAC,OAAO,uBAAuB,CAAC;0BA/CjC,cAAc;kCACN,cAAc;kCAEd,YAAY"}
package/src/facade.js CHANGED
@@ -1,11 +1,10 @@
1
- // @ts-check
2
1
  /** @file Orchestration service */
3
2
 
4
3
  /**
5
4
  * @import {Zone} from '@agoric/zone';
6
5
  * @import {TimerService} from '@agoric/time';
7
6
  * @import {OrchestrationService} from './service.js';
8
- * @import {OrchestrationHandlerMaker} from './types.js';
7
+ * @import {Orchestrator} from './types.js';
9
8
  */
10
9
 
11
10
  /**
@@ -35,7 +34,12 @@ export const makeOrchestrationFacade = ({
35
34
 
36
35
  return {
37
36
  /**
38
- * @type {OrchestrationHandlerMaker}
37
+ * @template Context
38
+ * @template {any[]} Args
39
+ * @param {string} durableName
40
+ * @param {Context} ctx
41
+ * @param {(orc: Orchestrator, ctx2: Context, ...args: Args) => object} fn
42
+ * @returns {(...args: Args) => Promise<unknown>}
39
43
  */
40
44
  orchestrate(durableName, ctx, fn) {
41
45
  console.log('orchestrate got', durableName, ctx, fn);
@@ -0,0 +1,158 @@
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, Payment } from '@agoric/ertp/exported.js';
7
+ import type { LocalChainAccount } from '@agoric/vats/src/localchain.js';
8
+ import type { Timestamp } from '@agoric/time';
9
+ import type { KnownChains } from './types.js';
10
+ /**
11
+ * A denom that designates a path to a token type on some blockchain.
12
+ *
13
+ * Multiple denoms may designate the same underlying base denom (e.g., `uist`,
14
+ * `uatom`) on different Chains or on the same Chain via different paths. On
15
+ * Cosmos chains, all but the base denom are IBC style denoms, but that may vary
16
+ * across other chains. All the denoms that designate the same underlying base
17
+ * denom form an equivalence class, along with the unique Brand on the local
18
+ * Chain. Some operations accept any member of the equivalence class to
19
+ * effectively designate the corresponding token type on the target chain.
20
+ */
21
+ export type Denom = string;
22
+ /**
23
+ * In many cases, either a denom string or a local Brand can be used to
24
+ * designate a remote token type.
25
+ */
26
+ export type DenomArg = Denom | Brand;
27
+ /**
28
+ * Count of some fungible token on some blockchain.
29
+ *
30
+ * @see {@link Orchestrator.asAmount} to convert to an Amount surjectively
31
+ */
32
+ export type DenomAmount = {
33
+ denom: Denom;
34
+ value: bigint;
35
+ };
36
+ /** Amounts can be provided as pure data using denoms or as native Amounts */
37
+ export type AmountArg = DenomAmount | Amount;
38
+ /** An address on some blockchain, e.g., cosmos, eth, etc. */
39
+ export type ChainAddress = {
40
+ /** e.g. 1 for Ethereum, agoric-3 for Agoric, cosmoshub-4 for Cosmos */
41
+ chainId: string;
42
+ address: string;
43
+ addressEncoding: 'bech32' | 'ethereum';
44
+ };
45
+ export type OrchestrationAccount<C extends keyof KnownChains> = OrchestrationAccountI & KnownChains[C]['methods'];
46
+ /**
47
+ * An object for access the core functions of a remote chain.
48
+ *
49
+ * Note that "remote" can mean the local chain; it's just that
50
+ * accounts are treated as remote/arms length for consistency.
51
+ */
52
+ export interface Chain<C extends keyof KnownChains> {
53
+ getChainInfo: () => Promise<KnownChains[C]['info']>;
54
+ /**
55
+ * Creates a new account on the remote chain.
56
+ * @returns an object that controls a new remote account on Chain
57
+ */
58
+ makeAccount: () => Promise<OrchestrationAccount<C>>;
59
+ }
60
+ /**
61
+ * Provided in the callback to `orchestrate()`.
62
+ */
63
+ export interface Orchestrator {
64
+ getChain: <C extends keyof KnownChains>(chainName: C) => Promise<Chain<C>>;
65
+ makeLocalAccount: () => Promise<LocalChainAccount>;
66
+ /**
67
+ * For a denom, return information about a denom including the equivalent
68
+ * local Brand, the Chain on which the denom is held, and the Chain that
69
+ * issues the corresponding asset.
70
+ * @param denom
71
+ */
72
+ getBrandInfo: <HoldingChain extends keyof KnownChains, IssuingChain extends keyof KnownChains>(denom: Denom) => {
73
+ /** The well-known Brand on Agoric for the direct asset */
74
+ brand?: Brand;
75
+ /** The Chain at which the argument `denom` exists (where the asset is currently held) */
76
+ chain: Chain<HoldingChain>;
77
+ /** The Chain that is the issuer of the underlying asset */
78
+ base: Chain<IssuingChain>;
79
+ /** the Denom for the underlying asset on its issuer chain */
80
+ baseDenom: Denom;
81
+ };
82
+ /**
83
+ * Convert an amount described in native data to a local, structured Amount.
84
+ * @param amount - the described amount
85
+ * @returns the Amount in local structuerd format
86
+ */
87
+ asAmount: (amount: DenomAmount) => NatAmount;
88
+ }
89
+ /**
90
+ * An object that supports high-level operations for an account on a remote chain.
91
+ */
92
+ export interface OrchestrationAccountI {
93
+ /**
94
+ * @returns the address of the account on the remote chain
95
+ */
96
+ getAddress: () => ChainAddress;
97
+ /** @returns an array of amounts for every balance in the account. */
98
+ getBalances: () => Promise<DenomAmount[]>;
99
+ /** @returns the balance of a specific denom for the account. */
100
+ getBalance: (denom: DenomArg) => Promise<DenomAmount>;
101
+ /**
102
+ * Transfer amount to another account on the same chain. The promise settles when the transfer is complete.
103
+ * @param toAccount - the account to send the amount to. MUST be on the same chain
104
+ * @param amount - the amount to send
105
+ * @returns void
106
+ */
107
+ send: (toAccount: ChainAddress, amount: AmountArg) => Promise<void>;
108
+ /**
109
+ * Transfer an amount to another account, typically on another chain.
110
+ * The promise settles when the transfer is complete.
111
+ * @param amount - the amount to transfer.
112
+ * @param destination - the account to transfer the amount to.
113
+ * @param memo - an optional memo to include with the transfer, which could drive custom PFM behavior
114
+ * @returns void
115
+ *
116
+ * TODO document the mapping from the address to the destination chain.
117
+ */
118
+ transfer: (amount: AmountArg, destination: ChainAddress, memo?: string) => Promise<void>;
119
+ /**
120
+ * Transfer an amount to another account in multiple steps. The promise settles when
121
+ * the entire path of the transfer is complete.
122
+ * @param amount - the amount to transfer
123
+ * @param msg - the transfer message, including follow-up steps
124
+ * @returns void
125
+ */
126
+ transferSteps: (amount: AmountArg, msg: TransferMsg) => Promise<void>;
127
+ /**
128
+ * deposit payment from zoe to the account. For remote accounts,
129
+ * an IBC Transfer will be executed to transfer funds there.
130
+ */
131
+ deposit: (payment: Payment) => Promise<void>;
132
+ }
133
+ /**
134
+ * Internal structure for TransferMsgs.
135
+ * The type must be able to express transfers across different chains and transports.
136
+ *
137
+ * NOTE Expected to change, so consider an opaque structure.
138
+ */
139
+ export type TransferMsg = {
140
+ toAccount: ChainAddress;
141
+ timeout?: Timestamp;
142
+ next?: TransferMsg;
143
+ data?: object;
144
+ };
145
+ export type AfterAction = {
146
+ destChain: string;
147
+ destAddress: ChainAddress;
148
+ };
149
+ export type SwapExact = {
150
+ amountIn: Amount;
151
+ amountOut: Amount;
152
+ };
153
+ export type SwapMaxSlippage = {
154
+ amountIn: Amount;
155
+ brandOut: Brand;
156
+ slippage: number;
157
+ };
158
+ //# sourceMappingURL=orchestration-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestration-api.d.ts","sourceRoot":"","sources":["orchestration-api.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,OAAO,KAAK,EACV,MAAM,EACN,KAAK,EACL,SAAS,EACT,OAAO,EACR,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;;;GAUG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAI3B;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,CAAC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AAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,KAAK,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
@@ -0,0 +1,195 @@
1
+ /* eslint-disable no-use-before-define */
2
+ /**
3
+ * @file General API of orchestration
4
+ * - must not have chain-specific types without runtime narrowing by chain id
5
+ * - should remain relatively stable.
6
+ */
7
+ import type {
8
+ Amount,
9
+ Brand,
10
+ NatAmount,
11
+ Payment,
12
+ } from '@agoric/ertp/exported.js';
13
+ import type { LocalChainAccount } from '@agoric/vats/src/localchain.js';
14
+ import type { Timestamp } from '@agoric/time';
15
+ import type { KnownChains } from './types.js';
16
+
17
+ /**
18
+ * A denom that designates a path to a token type on some blockchain.
19
+ *
20
+ * Multiple denoms may designate the same underlying base denom (e.g., `uist`,
21
+ * `uatom`) on different Chains or on the same Chain via different paths. On
22
+ * Cosmos chains, all but the base denom are IBC style denoms, but that may vary
23
+ * across other chains. All the denoms that designate the same underlying base
24
+ * denom form an equivalence class, along with the unique Brand on the local
25
+ * Chain. Some operations accept any member of the equivalence class to
26
+ * effectively designate the corresponding token type on the target chain.
27
+ */
28
+ export type Denom = string; // ibc/... or uist
29
+
30
+ // ??? when multiple Denoms provide paths to the same remote token type,
31
+ // should the brand be 1:1 with that equivalence class or each Denom?
32
+ /**
33
+ * In many cases, either a denom string or a local Brand can be used to
34
+ * designate a remote token type.
35
+ */
36
+ export type DenomArg = Denom | Brand;
37
+
38
+ /**
39
+ * Count of some fungible token on some blockchain.
40
+ *
41
+ * @see {@link Orchestrator.asAmount} to convert to an Amount surjectively
42
+ */
43
+ export type DenomAmount = {
44
+ denom: Denom;
45
+ value: bigint; // Nat
46
+ };
47
+
48
+ /** Amounts can be provided as pure data using denoms or as native Amounts */
49
+ export type AmountArg = DenomAmount | Amount;
50
+
51
+ /** An address on some blockchain, e.g., cosmos, eth, etc. */
52
+ export type ChainAddress = {
53
+ /** e.g. 1 for Ethereum, agoric-3 for Agoric, cosmoshub-4 for Cosmos */
54
+ chainId: string;
55
+ address: string;
56
+ // TODO what's the right way to scope the address? it's not chainId
57
+ addressEncoding: 'bech32' | 'ethereum';
58
+ };
59
+
60
+ export type OrchestrationAccount<C extends keyof KnownChains> =
61
+ OrchestrationAccountI & KnownChains[C]['methods'];
62
+
63
+ /**
64
+ * An object for access the core functions of a remote chain.
65
+ *
66
+ * Note that "remote" can mean the local chain; it's just that
67
+ * accounts are treated as remote/arms length for consistency.
68
+ */
69
+ export interface Chain<C extends keyof KnownChains> {
70
+ getChainInfo: () => Promise<KnownChains[C]['info']>;
71
+
72
+ // "makeAccount" suggests an operation within a vat
73
+ /**
74
+ * Creates a new account on the remote chain.
75
+ * @returns an object that controls a new remote account on Chain
76
+ */
77
+ makeAccount: () => Promise<OrchestrationAccount<C>>;
78
+ // FUTURE supply optional port object; also fetch port object
79
+
80
+ // TODO provide a way to get the local denom/brand/whatever for this chain
81
+ }
82
+
83
+ /**
84
+ * Provided in the callback to `orchestrate()`.
85
+ */
86
+ export interface Orchestrator {
87
+ // TODO we need a way to work with a chain its native way vs generic way
88
+ // E.g. an Osmosis delegate that looks Cosmos-y or no different from an Ethereum delegate
89
+ getChain: <C extends keyof KnownChains>(chainName: C) => Promise<Chain<C>>;
90
+
91
+ makeLocalAccount: () => Promise<LocalChainAccount>;
92
+ /**
93
+ * For a denom, return information about a denom including the equivalent
94
+ * local Brand, the Chain on which the denom is held, and the Chain that
95
+ * issues the corresponding asset.
96
+ * @param denom
97
+ */
98
+ getBrandInfo: <
99
+ HoldingChain extends keyof KnownChains,
100
+ IssuingChain extends keyof KnownChains,
101
+ >(
102
+ denom: Denom,
103
+ ) => {
104
+ /** The well-known Brand on Agoric for the direct asset */
105
+ brand?: Brand;
106
+ /** The Chain at which the argument `denom` exists (where the asset is currently held) */
107
+ chain: Chain<HoldingChain>;
108
+ /** The Chain that is the issuer of the underlying asset */
109
+ base: Chain<IssuingChain>;
110
+ /** the Denom for the underlying asset on its issuer chain */
111
+ baseDenom: Denom;
112
+ };
113
+ // TODO preload the mapping so this can be synchronous
114
+ /**
115
+ * Convert an amount described in native data to a local, structured Amount.
116
+ * @param amount - the described amount
117
+ * @returns the Amount in local structuerd format
118
+ */
119
+ asAmount: (amount: DenomAmount) => NatAmount;
120
+ }
121
+
122
+ /**
123
+ * An object that supports high-level operations for an account on a remote chain.
124
+ */
125
+ export interface OrchestrationAccountI {
126
+ /**
127
+ * @returns the address of the account on the remote chain
128
+ */
129
+ getAddress: () => ChainAddress;
130
+
131
+ /** @returns an array of amounts for every balance in the account. */
132
+ getBalances: () => Promise<DenomAmount[]>;
133
+
134
+ /** @returns the balance of a specific denom for the account. */
135
+ getBalance: (denom: DenomArg) => Promise<DenomAmount>;
136
+
137
+ /**
138
+ * Transfer amount to another account on the same chain. The promise settles when the transfer is complete.
139
+ * @param toAccount - the account to send the amount to. MUST be on the same chain
140
+ * @param amount - the amount to send
141
+ * @returns void
142
+ */
143
+ send: (toAccount: ChainAddress, amount: AmountArg) => Promise<void>;
144
+
145
+ /**
146
+ * Transfer an amount to another account, typically on another chain.
147
+ * The promise settles when the transfer is complete.
148
+ * @param amount - the amount to transfer.
149
+ * @param destination - the account to transfer the amount to.
150
+ * @param memo - an optional memo to include with the transfer, which could drive custom PFM behavior
151
+ * @returns void
152
+ *
153
+ * TODO document the mapping from the address to the destination chain.
154
+ */
155
+ transfer: (
156
+ amount: AmountArg,
157
+ destination: ChainAddress,
158
+ memo?: string,
159
+ ) => Promise<void>;
160
+
161
+ /**
162
+ * Transfer an amount to another account in multiple steps. The promise settles when
163
+ * the entire path of the transfer is complete.
164
+ * @param amount - the amount to transfer
165
+ * @param msg - the transfer message, including follow-up steps
166
+ * @returns void
167
+ */
168
+ transferSteps: (amount: AmountArg, msg: TransferMsg) => Promise<void>;
169
+ /**
170
+ * deposit payment from zoe to the account. For remote accounts,
171
+ * an IBC Transfer will be executed to transfer funds there.
172
+ */
173
+ deposit: (payment: Payment) => Promise<void>;
174
+ }
175
+
176
+ /**
177
+ * Internal structure for TransferMsgs.
178
+ * The type must be able to express transfers across different chains and transports.
179
+ *
180
+ * NOTE Expected to change, so consider an opaque structure.
181
+ */
182
+ export type TransferMsg = {
183
+ toAccount: ChainAddress;
184
+ timeout?: Timestamp;
185
+ next?: TransferMsg;
186
+ data?: object;
187
+ };
188
+
189
+ export type AfterAction = { destChain: string; destAddress: ChainAddress };
190
+ export type SwapExact = { amountIn: Amount; amountOut: Amount };
191
+ export type SwapMaxSlippage = {
192
+ amountIn: Amount;
193
+ brandOut: Brand;
194
+ slippage: number;
195
+ };