@agoric/orchestration 0.1.1-calypso-dev-84eb287.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 (120) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +5 -0
  3. package/index.d.ts +4 -0
  4. package/index.js +7 -0
  5. package/package.json +95 -0
  6. package/src/chain-info.d.ts +2318 -0
  7. package/src/chain-info.d.ts.map +1 -0
  8. package/src/chain-info.js +114 -0
  9. package/src/cosmos-api.d.ts +174 -0
  10. package/src/cosmos-api.d.ts.map +1 -0
  11. package/src/cosmos-api.ts +231 -0
  12. package/src/ethereum-api.d.ts +8 -0
  13. package/src/ethereum-api.d.ts.map +1 -0
  14. package/src/ethereum-api.ts +7 -0
  15. package/src/examples/sendAnywhere.contract.d.ts +31 -0
  16. package/src/examples/sendAnywhere.contract.d.ts.map +1 -0
  17. package/src/examples/sendAnywhere.contract.js +171 -0
  18. package/src/examples/stakeBld.contract.d.ts +121 -0
  19. package/src/examples/stakeBld.contract.d.ts.map +1 -0
  20. package/src/examples/stakeBld.contract.js +133 -0
  21. package/src/examples/stakeIca.contract.d.ts +93 -0
  22. package/src/examples/stakeIca.contract.d.ts.map +1 -0
  23. package/src/examples/stakeIca.contract.js +143 -0
  24. package/src/examples/swapExample.contract.d.ts +34 -0
  25. package/src/examples/swapExample.contract.d.ts.map +1 -0
  26. package/src/examples/swapExample.contract.js +155 -0
  27. package/src/examples/unbondExample.contract.d.ts +21 -0
  28. package/src/examples/unbondExample.contract.d.ts.map +1 -0
  29. package/src/examples/unbondExample.contract.js +105 -0
  30. package/src/exos/README.md +56 -0
  31. package/src/exos/agoric-names-tools.d.ts +27 -0
  32. package/src/exos/agoric-names-tools.d.ts.map +1 -0
  33. package/src/exos/agoric-names-tools.js +109 -0
  34. package/src/exos/chain-account-kit.d.ts +88 -0
  35. package/src/exos/chain-account-kit.d.ts.map +1 -0
  36. package/src/exos/chain-account-kit.js +210 -0
  37. package/src/exos/chain-hub.d.ts +77 -0
  38. package/src/exos/chain-hub.d.ts.map +1 -0
  39. package/src/exos/chain-hub.js +214 -0
  40. package/src/exos/cosmos-orchestration-account.d.ts +207 -0
  41. package/src/exos/cosmos-orchestration-account.d.ts.map +1 -0
  42. package/src/exos/cosmos-orchestration-account.js +536 -0
  43. package/src/exos/icq-connection-kit.d.ts +50 -0
  44. package/src/exos/icq-connection-kit.d.ts.map +1 -0
  45. package/src/exos/icq-connection-kit.js +135 -0
  46. package/src/exos/local-chain-facade.d.ts +81 -0
  47. package/src/exos/local-chain-facade.d.ts.map +1 -0
  48. package/src/exos/local-chain-facade.js +113 -0
  49. package/src/exos/local-orchestration-account.d.ts +176 -0
  50. package/src/exos/local-orchestration-account.d.ts.map +1 -0
  51. package/src/exos/local-orchestration-account.js +446 -0
  52. package/src/exos/orchestrator.d.ts +91 -0
  53. package/src/exos/orchestrator.d.ts.map +1 -0
  54. package/src/exos/orchestrator.js +141 -0
  55. package/src/exos/remote-chain-facade.d.ts +144 -0
  56. package/src/exos/remote-chain-facade.d.ts.map +1 -0
  57. package/src/exos/remote-chain-facade.js +145 -0
  58. package/src/facade.d.ts +57 -0
  59. package/src/facade.d.ts.map +1 -0
  60. package/src/facade.js +132 -0
  61. package/src/fetched-chain-info.d.ts +2311 -0
  62. package/src/fetched-chain-info.d.ts.map +1 -0
  63. package/src/fetched-chain-info.js +2288 -0
  64. package/src/internal.d.ts +13 -0
  65. package/src/internal.d.ts.map +1 -0
  66. package/src/internal.ts +20 -0
  67. package/src/orchestration-api.d.ts +158 -0
  68. package/src/orchestration-api.d.ts.map +1 -0
  69. package/src/orchestration-api.ts +201 -0
  70. package/src/proposals/orchestration-proposal.d.ts +53 -0
  71. package/src/proposals/orchestration-proposal.d.ts.map +1 -0
  72. package/src/proposals/orchestration-proposal.js +179 -0
  73. package/src/proposals/revise-chain-info.d.ts +21 -0
  74. package/src/proposals/revise-chain-info.d.ts.map +1 -0
  75. package/src/proposals/revise-chain-info.js +44 -0
  76. package/src/proposals/start-stakeAtom.d.ts +109 -0
  77. package/src/proposals/start-stakeAtom.d.ts.map +1 -0
  78. package/src/proposals/start-stakeAtom.js +105 -0
  79. package/src/proposals/start-stakeBld.d.ts +154 -0
  80. package/src/proposals/start-stakeBld.d.ts.map +1 -0
  81. package/src/proposals/start-stakeBld.js +103 -0
  82. package/src/proposals/start-stakeOsmo.d.ts +108 -0
  83. package/src/proposals/start-stakeOsmo.d.ts.map +1 -0
  84. package/src/proposals/start-stakeOsmo.js +106 -0
  85. package/src/service.d.ts +97 -0
  86. package/src/service.d.ts.map +1 -0
  87. package/src/service.js +259 -0
  88. package/src/typeGuards.d.ts +55 -0
  89. package/src/typeGuards.d.ts.map +1 -0
  90. package/src/typeGuards.js +104 -0
  91. package/src/types.d.ts +11 -0
  92. package/src/types.d.ts.map +1 -0
  93. package/src/types.ts +11 -0
  94. package/src/utils/address.d.ts +14 -0
  95. package/src/utils/address.d.ts.map +1 -0
  96. package/src/utils/address.js +79 -0
  97. package/src/utils/cosmos.d.ts +9 -0
  98. package/src/utils/cosmos.d.ts.map +1 -0
  99. package/src/utils/cosmos.js +36 -0
  100. package/src/utils/orc.d.ts +17 -0
  101. package/src/utils/orc.d.ts.map +1 -0
  102. package/src/utils/orc.js +38 -0
  103. package/src/utils/orchestrationAccount.d.ts +10 -0
  104. package/src/utils/orchestrationAccount.d.ts.map +1 -0
  105. package/src/utils/orchestrationAccount.js +22 -0
  106. package/src/utils/packet.d.ts +57 -0
  107. package/src/utils/packet.d.ts.map +1 -0
  108. package/src/utils/packet.js +112 -0
  109. package/src/utils/registry.d.ts +13 -0
  110. package/src/utils/registry.d.ts.map +1 -0
  111. package/src/utils/registry.js +131 -0
  112. package/src/utils/start-helper.d.ts +51 -0
  113. package/src/utils/start-helper.d.ts.map +1 -0
  114. package/src/utils/start-helper.js +109 -0
  115. package/src/utils/time.d.ts +31 -0
  116. package/src/utils/time.d.ts.map +1 -0
  117. package/src/utils/time.js +63 -0
  118. package/src/vat-orchestration.d.ts +58 -0
  119. package/src/vat-orchestration.d.ts.map +1 -0
  120. package/src/vat-orchestration.js +24 -0
@@ -0,0 +1,144 @@
1
+ export function prepareRemoteChainFacade(zone: Zone, powers: RemoteChainFacadePowers): (remoteChainInfo: Readonly<{
2
+ chainId: string;
3
+ connections?: Record<string, IBCConnectionInfo>;
4
+ icqEnabled?: boolean;
5
+ stakingTokens?: Readonly<Array<{
6
+ denom: string;
7
+ }>>;
8
+ }>, connectionInfo: IBCConnectionInfo) => ReturnType<(remoteChainInfo: Readonly<{
9
+ chainId: string;
10
+ connections?: Record<string, IBCConnectionInfo>;
11
+ icqEnabled?: boolean;
12
+ stakingTokens?: Readonly<Array<{
13
+ denom: string;
14
+ }>>;
15
+ }>, connectionInfo: IBCConnectionInfo) => import("@endo/exo").GuardedKit<{
16
+ public: {
17
+ getChainInfo(): Vow<Readonly<{
18
+ chainId: string;
19
+ connections?: Record<string, IBCConnectionInfo>;
20
+ icqEnabled?: boolean;
21
+ stakingTokens?: Readonly<Array<{
22
+ denom: string;
23
+ }>>;
24
+ }>>;
25
+ /** @returns {Vow<PromiseToVow<OrchestrationAccount<ChainInfo>>>} */
26
+ makeAccount(): Vow<PromiseToVow<OrchestrationAccount<ChainInfo>>>;
27
+ };
28
+ makeAccountWatcher: {
29
+ /**
30
+ * @param {IcaAccount} account
31
+ * @param {Denom} stakingDenom
32
+ */
33
+ onFulfilled(account: IcaAccount, stakingDenom: Denom): Vow<import("@endo/exo").Guarded<{
34
+ asContinuingOffer(): {
35
+ publicSubscribers: {
36
+ account: {
37
+ description: string;
38
+ subscriber: globalThis.Subscriber<import("./cosmos-orchestration-account.js").ComosOrchestrationAccountNotification>;
39
+ storagePath: Promise<string>;
40
+ };
41
+ };
42
+ invitationMakers: import("@endo/exo").Guarded<{
43
+ Delegate(validator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Promise<Invitation<Vow<undefined>, undefined>>;
44
+ Redelegate(srcValidator: import("../cosmos-api.js").CosmosValidatorAddress, dstValidator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Promise<Invitation<Vow<undefined>, undefined>>;
45
+ WithdrawReward(validator: import("../cosmos-api.js").CosmosValidatorAddress): Promise<Invitation<Vow<import("../orchestration-api.js").DenomAmount[]>, undefined>>;
46
+ Undelegate(delegations: Omit<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js").Delegation, "delegatorAddress">[]): Promise<Invitation<Vow<undefined>, undefined>>;
47
+ CloseAccount(): never;
48
+ TransferAccount(): never;
49
+ }>;
50
+ holder: import("@endo/exo").Guarded<any>;
51
+ };
52
+ getPublicTopics(): {
53
+ account: {
54
+ description: string;
55
+ subscriber: globalThis.Subscriber<import("./cosmos-orchestration-account.js").ComosOrchestrationAccountNotification>;
56
+ storagePath: Promise<string>;
57
+ };
58
+ };
59
+ getAddress(): ChainAddress;
60
+ delegate(validator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Vow<undefined>;
61
+ deposit(payment: any): void;
62
+ getBalances(): Vow<never>;
63
+ redelegate(srcValidator: import("../cosmos-api.js").CosmosValidatorAddress, dstValidator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Vow<undefined>;
64
+ withdrawReward(validator: import("../cosmos-api.js").CosmosValidatorAddress): Vow<import("../orchestration-api.js").DenomAmount[]>;
65
+ getBalance(denom: import("../orchestration-api.js").DenomArg): Vow<import("../orchestration-api.js").DenomAmount>;
66
+ send(toAccount: any, amount: any): Vow<never>;
67
+ transfer(amount: any, msg: any): Vow<never>;
68
+ transferSteps(amount: any, msg: any): Vow<never>;
69
+ withdrawRewards(): Vow<never>;
70
+ undelegate(delegations: Omit<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js").Delegation, "delegatorAddress">[]): Vow<undefined>;
71
+ }>>;
72
+ };
73
+ getAddressWatcher: {
74
+ /**
75
+ * @param {ChainAddress} chainAddress
76
+ * @param {{ stakingDenom: Denom; account: IcaAccount }} ctx
77
+ */
78
+ onFulfilled(chainAddress: ChainAddress, { account, stakingDenom }: {
79
+ stakingDenom: Denom;
80
+ account: IcaAccount;
81
+ }): import("@endo/exo").Guarded<{
82
+ asContinuingOffer(): {
83
+ publicSubscribers: {
84
+ account: {
85
+ description: string;
86
+ subscriber: globalThis.Subscriber<import("./cosmos-orchestration-account.js").ComosOrchestrationAccountNotification>;
87
+ storagePath: Promise<string>;
88
+ };
89
+ };
90
+ invitationMakers: import("@endo/exo").Guarded<{
91
+ Delegate(validator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Promise<Invitation<Vow<undefined>, undefined>>;
92
+ Redelegate(srcValidator: import("../cosmos-api.js").CosmosValidatorAddress, dstValidator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Promise<Invitation<Vow<undefined>, undefined>>;
93
+ WithdrawReward(validator: import("../cosmos-api.js").CosmosValidatorAddress): Promise<Invitation<Vow<import("../orchestration-api.js").DenomAmount[]>, undefined>>;
94
+ Undelegate(delegations: Omit<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js").Delegation, "delegatorAddress">[]): Promise<Invitation<Vow<undefined>, undefined>>;
95
+ CloseAccount(): never;
96
+ TransferAccount(): never;
97
+ }>;
98
+ holder: import("@endo/exo").Guarded<any>;
99
+ };
100
+ getPublicTopics(): {
101
+ account: {
102
+ description: string;
103
+ subscriber: globalThis.Subscriber<import("./cosmos-orchestration-account.js").ComosOrchestrationAccountNotification>;
104
+ storagePath: Promise<string>;
105
+ };
106
+ };
107
+ getAddress(): ChainAddress;
108
+ delegate(validator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Vow<undefined>;
109
+ deposit(payment: any): void;
110
+ getBalances(): Vow<never>;
111
+ redelegate(srcValidator: import("../cosmos-api.js").CosmosValidatorAddress, dstValidator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Vow<undefined>;
112
+ withdrawReward(validator: import("../cosmos-api.js").CosmosValidatorAddress): Vow<import("../orchestration-api.js").DenomAmount[]>;
113
+ getBalance(denom: import("../orchestration-api.js").DenomArg): Vow<import("../orchestration-api.js").DenomAmount>;
114
+ send(toAccount: any, amount: any): Vow<never>;
115
+ transfer(amount: any, msg: any): Vow<never>;
116
+ transferSteps(amount: any, msg: any): Vow<never>;
117
+ withdrawRewards(): Vow<never>;
118
+ undelegate(delegations: Omit<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js").Delegation, "delegatorAddress">[]): Vow<undefined>;
119
+ }>;
120
+ };
121
+ }>>["public"];
122
+ export type RemoteChainFacadePowers = {
123
+ makeCosmosOrchestrationAccount: ReturnType<typeof prepareCosmosOrchestrationAccount>;
124
+ orchestration: Remote<OrchestrationService>;
125
+ storageNode: Remote<StorageNode>;
126
+ timer: Remote<TimerService>;
127
+ vowTools: VowTools;
128
+ };
129
+ export type MakeRemoteChainFacade = ReturnType<typeof prepareRemoteChainFacade>;
130
+ import type { Zone } from '@agoric/base-zone';
131
+ import type { IBCConnectionInfo } from '../types.js';
132
+ import type { Vow } from '@agoric/vow';
133
+ import type { ChainInfo } from '../types.js';
134
+ import type { OrchestrationAccount } from '../types.js';
135
+ import type { PromiseToVow } from '../types.js';
136
+ import type { IcaAccount } from '../types.js';
137
+ import type { Denom } from '../types.js';
138
+ import type { ChainAddress } from '../types.js';
139
+ import type { prepareCosmosOrchestrationAccount } from './cosmos-orchestration-account.js';
140
+ import type { OrchestrationService } from '../service.js';
141
+ import type { Remote } from '@agoric/internal';
142
+ import type { TimerService } from '@agoric/time';
143
+ import type { VowTools } from '@agoric/vow';
144
+ //# sourceMappingURL=remote-chain-facade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-chain-facade.d.ts","sourceRoot":"","sources":["remote-chain-facade.js"],"names":[],"mappings":"AA0IO,+CAHI,IAAI,UACJ,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;QAzD1B,oEAAoE;uBAAtD,IAAI,aAAa,qBAAqB,SAAS,CAAC,CAAC,CAAC;;;QAwBhE;;;WAGG;6BAFQ,UAAU,gBACV,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAUhB;;;WAGG;kCAFQ,YAAY,6BACZ;YAAE,YAAY,EAAE,KAAK,CAAC;YAAC,OAAO,EAAE,UAAU,CAAA;SAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwB9D;sCApHY;IACZ,8BAAkC,EAAE,UAAU,CAC9C,wCAA8C,CACzC,CAAC;IACN,aAAiB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IAChD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,KAAS,EAAE,OAAO,YAAY,CAAC,CAAC;IAChC,QAAY,EAAE,QAAQ,CAAC;CACpB;oCA+GU,UAAU,CAAC,OAAO,wBAAwB,CAAC;0BAvIlC,mBAAmB;uCAM2F,aAAa;yBAHlH,aAAa;+BAGwF,aAAa;0CAAb,aAAa;kCAAb,aAAa;gCAAb,aAAa;2BAAb,aAAa;kCAAb,aAAa;uDAD9F,mCAAmC;0CADhD,eAAe;4BAF7B,kBAAkB;kCADZ,cAAc;8BAEb,aAAa"}
@@ -0,0 +1,145 @@
1
+ /** @file ChainAccount exo */
2
+ import { makeTracer } from '@agoric/internal';
3
+ import { E } from '@endo/far';
4
+ import { M } from '@endo/patterns';
5
+ import { pickFacet } from '@agoric/vat-data';
6
+ import { VowShape } from '@agoric/vow';
7
+ import { ChainFacadeI } from '../typeGuards.js';
8
+
9
+ /**
10
+ * @import {Zone} from '@agoric/base-zone';
11
+ * @import {TimerService} from '@agoric/time';
12
+ * @import {Remote} from '@agoric/internal';
13
+ * @import {Vow, VowTools} from '@agoric/vow';
14
+ * @import {OrchestrationService} from '../service.js';
15
+ * @import {prepareCosmosOrchestrationAccount} from './cosmos-orchestration-account.js';
16
+ * @import {ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, ChainAddress, IcaAccount, PromiseToVow, Denom} from '../types.js';
17
+ */
18
+
19
+ const { Fail } = assert;
20
+ const trace = makeTracer('RemoteChainFacade');
21
+
22
+ /** @type {any} */
23
+ const anyVal = null;
24
+
25
+ /**
26
+ * @typedef {{
27
+ * makeCosmosOrchestrationAccount: ReturnType<
28
+ * typeof prepareCosmosOrchestrationAccount
29
+ * >;
30
+ * orchestration: Remote<OrchestrationService>;
31
+ * storageNode: Remote<StorageNode>;
32
+ * timer: Remote<TimerService>;
33
+ * vowTools: VowTools;
34
+ * }} RemoteChainFacadePowers
35
+ */
36
+
37
+ /**
38
+ * @param {Zone} zone
39
+ * @param {RemoteChainFacadePowers} powers
40
+ */
41
+ const prepareRemoteChainFacadeKit = (
42
+ zone,
43
+ {
44
+ makeCosmosOrchestrationAccount,
45
+ orchestration,
46
+ storageNode,
47
+ timer,
48
+ vowTools: { asVow, watch },
49
+ },
50
+ ) =>
51
+ zone.exoClassKit(
52
+ 'RemoteChainFacade',
53
+ {
54
+ public: ChainFacadeI,
55
+ makeAccountWatcher: M.interface('makeAccountWatcher', {
56
+ onFulfilled: M.call(M.remotable())
57
+ .optional(M.string())
58
+ .returns(VowShape),
59
+ }),
60
+ getAddressWatcher: M.interface('makeAccountWatcher', {
61
+ onFulfilled: M.call(M.record())
62
+ .optional({ stakingDenom: M.string(), account: M.remotable() })
63
+ .returns(M.remotable()),
64
+ }),
65
+ },
66
+ /**
67
+ * @param {CosmosChainInfo} remoteChainInfo
68
+ * @param {IBCConnectionInfo} connectionInfo
69
+ */
70
+ (remoteChainInfo, connectionInfo) => {
71
+ trace('making a RemoteChainFacade');
72
+ return { remoteChainInfo, connectionInfo };
73
+ },
74
+ {
75
+ public: {
76
+ getChainInfo() {
77
+ return watch(this.state.remoteChainInfo);
78
+ },
79
+
80
+ /** @returns {Vow<PromiseToVow<OrchestrationAccount<ChainInfo>>>} */
81
+ makeAccount() {
82
+ // TODO #9449 fix types
83
+ // @ts-expect-error Type 'Vow<Voidless>' is not assignable to type 'Vow<OrchestrationAccountI>'
84
+ return asVow(() => {
85
+ const { remoteChainInfo, connectionInfo } = this.state;
86
+ const stakingDenom = remoteChainInfo.stakingTokens?.[0]?.denom;
87
+ if (!stakingDenom) {
88
+ throw Fail`chain info lacks staking denom`;
89
+ }
90
+
91
+ return watch(
92
+ E(orchestration).makeAccount(
93
+ remoteChainInfo.chainId,
94
+ connectionInfo.id,
95
+ connectionInfo.counterparty.connection_id,
96
+ ),
97
+ this.facets.makeAccountWatcher,
98
+ stakingDenom,
99
+ );
100
+ });
101
+ },
102
+ },
103
+ makeAccountWatcher: {
104
+ /**
105
+ * @param {IcaAccount} account
106
+ * @param {Denom} stakingDenom
107
+ */
108
+ onFulfilled(account, stakingDenom) {
109
+ return watch(E(account).getAddress(), this.facets.getAddressWatcher, {
110
+ stakingDenom,
111
+ account,
112
+ });
113
+ },
114
+ },
115
+ getAddressWatcher: {
116
+ /**
117
+ * @param {ChainAddress} chainAddress
118
+ * @param {{ stakingDenom: Denom; account: IcaAccount }} ctx
119
+ */
120
+ onFulfilled(chainAddress, { account, stakingDenom }) {
121
+ return makeCosmosOrchestrationAccount(chainAddress, stakingDenom, {
122
+ account,
123
+ storageNode,
124
+ // FIXME provide real ICQ connection
125
+ // FIXME make Query Connection available via chain, not orchestrationAccount
126
+ icqConnection: anyVal,
127
+ timer,
128
+ });
129
+ },
130
+ },
131
+ },
132
+ );
133
+ harden(prepareRemoteChainFacadeKit);
134
+
135
+ /**
136
+ * @param {Zone} zone
137
+ * @param {RemoteChainFacadePowers} powers
138
+ */
139
+ export const prepareRemoteChainFacade = (zone, powers) => {
140
+ const makeLocalChainFacadeKit = prepareRemoteChainFacadeKit(zone, powers);
141
+ return pickFacet(makeLocalChainFacadeKit, 'public');
142
+ };
143
+ harden(prepareRemoteChainFacade);
144
+
145
+ /** @typedef {ReturnType<typeof prepareRemoteChainFacade>} MakeRemoteChainFacade */
@@ -0,0 +1,57 @@
1
+ export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode, orchestrationService, localchain, chainHub, makeLocalOrchestrationAccountKit, makeRecorderKit, makeLocalChainFacade, makeRemoteChainFacade, vowTools, asyncFlowTools, }: {
2
+ zone: Zone;
3
+ timerService: Remote<TimerService>;
4
+ zcf: ZCF;
5
+ storageNode: Remote<StorageNode>;
6
+ orchestrationService: Remote<OrchestrationService>;
7
+ localchain: Remote<LocalChain>;
8
+ chainHub: import("./exos/chain-hub.js").ChainHub;
9
+ makeLocalOrchestrationAccountKit: MakeLocalOrchestrationAccountKit;
10
+ makeRecorderKit: MakeRecorderKit;
11
+ makeCosmosOrchestrationAccount: any;
12
+ makeLocalChainFacade: MakeLocalChainFacade;
13
+ makeRemoteChainFacade: MakeRemoteChainFacade;
14
+ vowTools: VowTools;
15
+ asyncFlowTools: AsyncFlowTools;
16
+ }): {
17
+ /**
18
+ * @template GuestReturn
19
+ * @template HostReturn
20
+ * @template GuestContext
21
+ * @template HostContext
22
+ * @template {any[]} GuestArgs
23
+ * @template {any[]} HostArgs
24
+ * @param {string} durableName - the orchestration flow identity in the zone
25
+ * (to resume across upgrades)
26
+ * @param {HostContext} hostCtx - values to pass through the async flow
27
+ * membrane
28
+ * @param {(
29
+ * guestOrc: Orchestrator,
30
+ * guestCtx: GuestContext,
31
+ * ...args: GuestArgs
32
+ * ) => Promise<GuestReturn>} guestFn
33
+ * @returns {(...args: HostArgs) => Promise<HostReturn>} TODO returns a
34
+ * Promise for now for compat before use of asyncFlow. But really should
35
+ * be `Vow<HostReturn>`
36
+ */
37
+ orchestrate<GuestReturn, HostReturn, GuestContext, HostContext, GuestArgs extends any[], HostArgs extends any[]>(durableName: string, hostCtx: HostContext, guestFn: (guestOrc: Orchestrator, guestCtx: GuestContext, ...args: GuestArgs) => Promise<GuestReturn>): (...args: HostArgs) => Promise<HostReturn>;
38
+ adminAsyncFlow: import("@endo/exo").Guarded<{
39
+ getFailures(): import("@endo/patterns").CopyMap<any, import("@endo/pass-style").Passable>;
40
+ wakeAll(): void;
41
+ getFlowForOutcomeVow(outcomeVow: any): any;
42
+ }>;
43
+ };
44
+ export type OrchestrationFacade = ReturnType<typeof makeOrchestrationFacade>;
45
+ import type { Zone } from '@agoric/zone';
46
+ import type { TimerService } from '@agoric/time';
47
+ import type { Remote } from '@agoric/internal';
48
+ import type { OrchestrationService } from './service.js';
49
+ import type { LocalChain } from '@agoric/vats/src/localchain.js';
50
+ import type { MakeLocalOrchestrationAccountKit } from './exos/local-orchestration-account.js';
51
+ import type { MakeRecorderKit } from '@agoric/zoe/src/contractSupport/recorder.js';
52
+ import type { MakeLocalChainFacade } from './exos/local-chain-facade.js';
53
+ import type { MakeRemoteChainFacade } from './exos/remote-chain-facade.js';
54
+ import type { VowTools } from '@agoric/vow';
55
+ import type { AsyncFlowTools } from '@agoric/async-flow';
56
+ import type { Orchestrator } from './types.js';
57
+ //# sourceMappingURL=facade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["facade.js"],"names":[],"mappings":"AAwCO,yPAjBI;IACV,IAAQ,EAAE,IAAI,CAAC;IACf,YAAgB,EAAE,OAAO,YAAY,CAAC,CAAC;IACvC,GAAO,EAAE,GAAG,CAAC;IACb,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,oBAAwB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IACvD,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,QAAY,EAAE,OAAO,qBAAqB,EAAE,QAAQ,CAAC;IACrD,gCAAoC,EAAE,gCAAgC,CAAC;IACvE,eAAmB,EAAE,eAAe,CAAC;IACrC,8BAAkC,EAAE,GAAG,CAAC;IACxC,oBAAwB,EAAE,oBAAoB,CAAC;IAC/C,qBAAyB,EAAE,qBAAqB,CAAC;IACjD,QAAY,EAAE,QAAQ,CAAC;IACvB,cAAkB,EAAE,cAAc,CAAC;CAChC;IAmDA;;;;;;;;;;;;;;;;;;;OAmBG;gBAlBU,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACH,SAAS,SAAhB,GAAG,EAAG,EACC,QAAQ,SAAf,GAAG,EAAG,eACT,MAAM,WAEN,WAAW,WAEX,CACV,QAAY,EAAE,YAAY,EAC1B,QAAY,EAAE,YAAY,EAC1B,GAAO,IAAI,EAAE,SAAS,KACf,OAAO,CAAC,WAAW,CAAC,GACf,CAAC,GAAG,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,UAAU,CAAC;;;;;;EAwB1D;kCAEa,UAAU,CAAC,OAAO,uBAAuB,CAAC;0BA3HjC,cAAc;kCAEN,cAAc;4BAIpB,kBAAkB;0CACJ,cAAc;gCAHxB,gCAAgC;sDAOV,uCAAuC;qCAN3C,6CAA6C;0CAIrD,8BAA8B;2CAC7B,+BAA+B;8BATvC,aAAa;oCAFZ,oBAAoB;kCASsD,YAAY"}
package/src/facade.js ADDED
@@ -0,0 +1,132 @@
1
+ /** @file Orchestration service */
2
+
3
+ import { Fail } from '@agoric/assert';
4
+ import { pickFacet } from '@agoric/vat-data';
5
+ import { prepareOrchestratorKit } from './exos/orchestrator.js';
6
+
7
+ /**
8
+ * @import {AsyncFlowTools} from '@agoric/async-flow';
9
+ * @import {Zone} from '@agoric/zone';
10
+ * @import {Vow, VowTools} from '@agoric/vow';
11
+ * @import {TimerService} from '@agoric/time';
12
+ * @import {IBCConnectionID} from '@agoric/vats';
13
+ * @import {LocalChain} from '@agoric/vats/src/localchain.js';
14
+ * @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js'.
15
+ * @import {Remote} from '@agoric/internal';
16
+ * @import {OrchestrationService} from './service.js';
17
+ * @import {Chain, ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, Orchestrator} from './types.js';
18
+ * @import {MakeLocalChainFacade} from './exos/local-chain-facade.js';
19
+ * @import {MakeRemoteChainFacade} from './exos/remote-chain-facade.js';
20
+ * @import {MakeLocalOrchestrationAccountKit} from './exos/local-orchestration-account.js';
21
+ */
22
+
23
+ /**
24
+ * @param {{
25
+ * zone: Zone;
26
+ * timerService: Remote<TimerService>;
27
+ * zcf: ZCF;
28
+ * storageNode: Remote<StorageNode>;
29
+ * orchestrationService: Remote<OrchestrationService>;
30
+ * localchain: Remote<LocalChain>;
31
+ * chainHub: import('./exos/chain-hub.js').ChainHub;
32
+ * makeLocalOrchestrationAccountKit: MakeLocalOrchestrationAccountKit;
33
+ * makeRecorderKit: MakeRecorderKit;
34
+ * makeCosmosOrchestrationAccount: any;
35
+ * makeLocalChainFacade: MakeLocalChainFacade;
36
+ * makeRemoteChainFacade: MakeRemoteChainFacade;
37
+ * vowTools: VowTools;
38
+ * asyncFlowTools: AsyncFlowTools;
39
+ * }} powers
40
+ */
41
+ export const makeOrchestrationFacade = ({
42
+ zone,
43
+ timerService,
44
+ zcf,
45
+ storageNode,
46
+ orchestrationService,
47
+ localchain,
48
+ chainHub,
49
+ makeLocalOrchestrationAccountKit,
50
+ makeRecorderKit,
51
+ makeLocalChainFacade,
52
+ makeRemoteChainFacade,
53
+ vowTools,
54
+ asyncFlowTools,
55
+ }) => {
56
+ (zone &&
57
+ timerService &&
58
+ zcf &&
59
+ storageNode &&
60
+ orchestrationService &&
61
+ // @ts-expect-error type says defined but double check
62
+ makeLocalOrchestrationAccountKit &&
63
+ // @ts-expect-error type says defined but double check
64
+ makeRecorderKit &&
65
+ // @ts-expect-error type says defined but double check
66
+ makeRemoteChainFacade &&
67
+ asyncFlowTools) ||
68
+ Fail`params missing`;
69
+
70
+ const makeOrchestratorKit = prepareOrchestratorKit(zone, {
71
+ asyncFlowTools,
72
+ chainHub,
73
+ localchain,
74
+ makeRecorderKit,
75
+ makeLocalChainFacade,
76
+ makeRemoteChainFacade,
77
+ orchestrationService,
78
+ storageNode,
79
+ timerService,
80
+ vowTools,
81
+ zcf,
82
+ });
83
+ const makeOrchestrator = pickFacet(makeOrchestratorKit, 'orchestrator');
84
+
85
+ const { prepareEndowment, asyncFlow, adminAsyncFlow } = asyncFlowTools;
86
+
87
+ const { when } = vowTools;
88
+
89
+ return {
90
+ /**
91
+ * @template GuestReturn
92
+ * @template HostReturn
93
+ * @template GuestContext
94
+ * @template HostContext
95
+ * @template {any[]} GuestArgs
96
+ * @template {any[]} HostArgs
97
+ * @param {string} durableName - the orchestration flow identity in the zone
98
+ * (to resume across upgrades)
99
+ * @param {HostContext} hostCtx - values to pass through the async flow
100
+ * membrane
101
+ * @param {(
102
+ * guestOrc: Orchestrator,
103
+ * guestCtx: GuestContext,
104
+ * ...args: GuestArgs
105
+ * ) => Promise<GuestReturn>} guestFn
106
+ * @returns {(...args: HostArgs) => Promise<HostReturn>} TODO returns a
107
+ * Promise for now for compat before use of asyncFlow. But really should
108
+ * be `Vow<HostReturn>`
109
+ */
110
+ orchestrate(durableName, hostCtx, guestFn) {
111
+ const subZone = zone.subZone(durableName);
112
+
113
+ const hostOrc = makeOrchestrator();
114
+
115
+ const [wrappedOrc, wrappedCtx] = prepareEndowment(subZone, 'endowments', [
116
+ hostOrc,
117
+ hostCtx,
118
+ ]);
119
+
120
+ const hostFn = asyncFlow(subZone, 'asyncFlow', guestFn);
121
+
122
+ const orcFn = (...args) =>
123
+ // TODO remove the `when` after fixing the return type
124
+ // to `Vow<HostReturn>`
125
+ when(hostFn(wrappedOrc, wrappedCtx, ...args));
126
+ return harden(orcFn);
127
+ },
128
+ adminAsyncFlow,
129
+ };
130
+ };
131
+ harden(makeOrchestrationFacade);
132
+ /** @typedef {ReturnType<typeof makeOrchestrationFacade>} OrchestrationFacade */