@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,109 @@
1
+ import { prepareAsyncFlowTools } from '@agoric/async-flow';
2
+ import { prepareVowTools } from '@agoric/vow';
3
+ import { prepareRecorderKitMakers } from '@agoric/zoe/src/contractSupport/recorder.js';
4
+ import { makeDurableZone } from '@agoric/zone/durable.js';
5
+ import { prepareLocalOrchestrationAccountKit } from '../exos/local-orchestration-account.js';
6
+ import { makeOrchestrationFacade } from '../facade.js';
7
+ import { makeChainHub } from '../exos/chain-hub.js';
8
+ import { prepareRemoteChainFacade } from '../exos/remote-chain-facade.js';
9
+ import { prepareCosmosOrchestrationAccount } from '../exos/cosmos-orchestration-account.js';
10
+ import { prepareLocalChainFacade } from '../exos/local-chain-facade.js';
11
+
12
+ /**
13
+ * @import {PromiseKit} from '@endo/promise-kit'
14
+ * @import {LocalChain} from '@agoric/vats/src/localchain.js';
15
+ * @import {TimerService, TimerBrand} from '@agoric/time';
16
+ * @import {Baggage} from '@agoric/vat-data';
17
+ * @import {NameHub} from '@agoric/vats';
18
+ * @import {Remote} from '@agoric/vow';
19
+ * @import {OrchestrationService} from '../service.js';
20
+ */
21
+
22
+ /**
23
+ * @typedef {{
24
+ * localchain: Remote<LocalChain>;
25
+ * orchestrationService: Remote<OrchestrationService>;
26
+ * storageNode: Remote<StorageNode>;
27
+ * timerService: Remote<TimerService>;
28
+ * agoricNames: Remote<NameHub>;
29
+ * }} OrchestrationPowers
30
+ */
31
+
32
+ /**
33
+ * Helper that a contract start function can use to set up the objects needed
34
+ * for orchestration.
35
+ *
36
+ * @param {ZCF} zcf
37
+ * @param {Baggage} baggage
38
+ * @param {OrchestrationPowers} remotePowers
39
+ * @param {Marshaller} marshaller
40
+ */
41
+ export const provideOrchestration = (
42
+ zcf,
43
+ baggage,
44
+ remotePowers,
45
+ marshaller,
46
+ ) => {
47
+ const zone = makeDurableZone(baggage);
48
+ const { agoricNames, timerService } = remotePowers;
49
+
50
+ const chainHub = makeChainHub(agoricNames);
51
+
52
+ const vowTools = prepareVowTools(zone.subZone('vows'));
53
+
54
+ const { makeRecorderKit } = prepareRecorderKitMakers(baggage, marshaller);
55
+ const makeLocalOrchestrationAccountKit = prepareLocalOrchestrationAccountKit(
56
+ zone,
57
+ makeRecorderKit,
58
+ zcf,
59
+ timerService,
60
+ vowTools,
61
+ chainHub,
62
+ );
63
+
64
+ const asyncFlowTools = prepareAsyncFlowTools(zone.subZone('asyncFlow'), {
65
+ vowTools,
66
+ });
67
+
68
+ const makeCosmosOrchestrationAccount = prepareCosmosOrchestrationAccount(
69
+ // FIXME what zone?
70
+ zone,
71
+ makeRecorderKit,
72
+ vowTools,
73
+ zcf,
74
+ );
75
+
76
+ const makeRemoteChainFacade = prepareRemoteChainFacade(zone, {
77
+ makeCosmosOrchestrationAccount,
78
+ orchestration: remotePowers.orchestrationService,
79
+ storageNode: remotePowers.storageNode,
80
+ timer: remotePowers.timerService,
81
+ vowTools,
82
+ });
83
+
84
+ const makeLocalChainFacade = prepareLocalChainFacade(zone, {
85
+ makeLocalOrchestrationAccountKit,
86
+ localchain: remotePowers.localchain,
87
+ // FIXME what path?
88
+ storageNode: remotePowers.storageNode,
89
+ orchestration: remotePowers.orchestrationService,
90
+ timer: remotePowers.timerService,
91
+ vowTools,
92
+ });
93
+
94
+ const facade = makeOrchestrationFacade({
95
+ zcf,
96
+ zone,
97
+ chainHub,
98
+ makeLocalOrchestrationAccountKit,
99
+ makeRecorderKit,
100
+ makeCosmosOrchestrationAccount,
101
+ makeLocalChainFacade,
102
+ makeRemoteChainFacade,
103
+ asyncFlowTools,
104
+ vowTools,
105
+ ...remotePowers,
106
+ });
107
+ return { ...facade, chainHub, vowTools, zone };
108
+ };
109
+ harden(provideOrchestration);
@@ -0,0 +1,31 @@
1
+ /**
2
+ * XXX should this be durable? resumable?
3
+ *
4
+ * @param {Remote<TimerService>} timer
5
+ */
6
+ export function makeTimestampHelper(timer: Remote<TimerService>): {
7
+ /**
8
+ * XXX do this need to be resumable / use Vows?
9
+ *
10
+ * Takes the current time from ChainTimerService and adds a relative time to
11
+ * determine a timeout timestamp in nanoseconds. Useful for
12
+ * {@link MsgTransfer.timeoutTimestamp}.
13
+ *
14
+ * @param {RelativeTimeRecord} [relativeTime] defaults to 5 minutes
15
+ * @returns {Promise<bigint>} Timeout timestamp in absolute nanoseconds
16
+ * since unix epoch
17
+ */
18
+ getTimeoutTimestampNS(relativeTime?: RelativeTimeRecord | undefined): Promise<bigint>;
19
+ };
20
+ /**
21
+ * @import {RelativeTimeRecord, TimerBrand, TimerService} from '@agoric/time';
22
+ * @import {Remote} from '@agoric/internal';
23
+ */
24
+ export const SECONDS_PER_MINUTE: 60n;
25
+ export const NANOSECONDS_PER_SECOND: 1000000000n;
26
+ export function dateInSeconds(date: Date): bigint;
27
+ export type TimestampHelper = Awaited<ReturnType<typeof makeTimestampHelper>>;
28
+ import type { TimerService } from '@agoric/time';
29
+ import type { Remote } from '@agoric/internal';
30
+ import type { RelativeTimeRecord } from '@agoric/time';
31
+ //# sourceMappingURL=time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["time.js"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,2CAFW,OAAO,YAAY,CAAC;IAY3B;;;;;;;;;;OAUG;0EAFU,OAAO,CAAC,MAAM,CAAC;EAiB/B;AAhDD;;;GAGG;AAEH,qCAAsC;AACtC,iDAAqD;AAqD9C,oCAHI,IAAI,GACF,MAAM,CAE2D;8BAThE,OAAO,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;kCAjDE,cAAc;4BACpD,kBAAkB;wCADoB,cAAc"}
@@ -0,0 +1,63 @@
1
+ import { E } from '@endo/far';
2
+ import { TimeMath } from '@agoric/time';
3
+
4
+ /**
5
+ * @import {RelativeTimeRecord, TimerBrand, TimerService} from '@agoric/time';
6
+ * @import {Remote} from '@agoric/internal';
7
+ */
8
+
9
+ export const SECONDS_PER_MINUTE = 60n;
10
+ export const NANOSECONDS_PER_SECOND = 1_000_000_000n;
11
+
12
+ /**
13
+ * XXX should this be durable? resumable?
14
+ *
15
+ * @param {Remote<TimerService>} timer
16
+ */
17
+ export function makeTimestampHelper(timer) {
18
+ /** @type {TimerBrand | undefined} */
19
+ let brandCache;
20
+ const getBrand = async () => {
21
+ if (brandCache) return brandCache;
22
+ brandCache = await E(timer).getTimerBrand();
23
+ return brandCache;
24
+ };
25
+
26
+ return harden({
27
+ /**
28
+ * XXX do this need to be resumable / use Vows?
29
+ *
30
+ * Takes the current time from ChainTimerService and adds a relative time to
31
+ * determine a timeout timestamp in nanoseconds. Useful for
32
+ * {@link MsgTransfer.timeoutTimestamp}.
33
+ *
34
+ * @param {RelativeTimeRecord} [relativeTime] defaults to 5 minutes
35
+ * @returns {Promise<bigint>} Timeout timestamp in absolute nanoseconds
36
+ * since unix epoch
37
+ */
38
+ async getTimeoutTimestampNS(relativeTime) {
39
+ const currentTime = await E(timer).getCurrentTimestamp();
40
+ const timeout =
41
+ relativeTime ||
42
+ TimeMath.coerceRelativeTimeRecord(
43
+ SECONDS_PER_MINUTE * 5n,
44
+ await getBrand(),
45
+ );
46
+ return (
47
+ TimeMath.addAbsRel(currentTime, timeout).absValue *
48
+ NANOSECONDS_PER_SECOND
49
+ );
50
+ },
51
+ });
52
+ }
53
+
54
+ /** @typedef {Awaited<ReturnType<typeof makeTimestampHelper>>} TimestampHelper */
55
+
56
+ /**
57
+ * Convert a Date from a Cosmos message, which has millisecond precision, to a
58
+ * BigInt for number of seconds since epoch, for use in a timer.
59
+ *
60
+ * @param {Date} date
61
+ * @returns {bigint}
62
+ */
63
+ export const dateInSeconds = date => BigInt(Math.floor(date.getTime() / 1000));
@@ -0,0 +1,58 @@
1
+ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
2
+ /** @param {Partial<OrchestrationPowers>} [initialPowers] */
3
+ makeOrchestrationKit(initialPowers?: Partial<OrchestrationPowers> | undefined): import("@endo/exo").GuardedKit<{
4
+ requestICAChannelWatcher: {
5
+ onFulfilled(port: import("@agoric/network").Port, { chainId, remoteConnAddr }: {
6
+ chainId: string;
7
+ remoteConnAddr: import("@agoric/vats/tools/ibc-utils.js").RemoteIbcAddress;
8
+ }): import("@agoric/vow").Vow<any>;
9
+ };
10
+ requestICQChannelWatcher: {
11
+ onFulfilled(port: import("@agoric/network").Port, { remoteConnAddr, controllerConnectionId }: {
12
+ remoteConnAddr: import("@agoric/vats/tools/ibc-utils.js").RemoteIbcAddress;
13
+ controllerConnectionId: import("@agoric/vats").IBCConnectionID;
14
+ }): import("@agoric/vow").Vow<any>;
15
+ };
16
+ channelOpenWatcher: {
17
+ onFulfilled(_connection: import("@agoric/network").Connection, { connectionKit, returnFacet, saveICQConnection }: {
18
+ connectionKit: ConnectionKit;
19
+ returnFacet: string;
20
+ saveICQConnection?: import("@agoric/vats").IBCConnectionID;
21
+ }): any;
22
+ };
23
+ public: {
24
+ makeAccount(chainId: string, hostConnectionId: import("@agoric/vats").IBCConnectionID, controllerConnectionId: import("@agoric/vats").IBCConnectionID): import("@agoric/vow").Vow<import("./cosmos-api.js").IcaAccount>;
25
+ provideICQConnection(controllerConnectionId: import("@agoric/vats").IBCConnectionID): import("@agoric/vow").Vow<import("./types.js").ICQConnection> | import("./types.js").ICQConnection;
26
+ };
27
+ }>;
28
+ } & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
29
+ /** @param {Partial<OrchestrationPowers>} [initialPowers] */
30
+ makeOrchestrationKit(initialPowers?: Partial<OrchestrationPowers> | undefined): import("@endo/exo").GuardedKit<{
31
+ requestICAChannelWatcher: {
32
+ onFulfilled(port: import("@agoric/network").Port, { chainId, remoteConnAddr }: {
33
+ chainId: string;
34
+ remoteConnAddr: import("@agoric/vats/tools/ibc-utils.js").RemoteIbcAddress;
35
+ }): import("@agoric/vow").Vow<any>;
36
+ };
37
+ requestICQChannelWatcher: {
38
+ onFulfilled(port: import("@agoric/network").Port, { remoteConnAddr, controllerConnectionId }: {
39
+ remoteConnAddr: import("@agoric/vats/tools/ibc-utils.js").RemoteIbcAddress;
40
+ controllerConnectionId: import("@agoric/vats").IBCConnectionID;
41
+ }): import("@agoric/vow").Vow<any>;
42
+ };
43
+ channelOpenWatcher: {
44
+ onFulfilled(_connection: import("@agoric/network").Connection, { connectionKit, returnFacet, saveICQConnection }: {
45
+ connectionKit: ConnectionKit;
46
+ returnFacet: string;
47
+ saveICQConnection?: import("@agoric/vats").IBCConnectionID;
48
+ }): any;
49
+ };
50
+ public: {
51
+ makeAccount(chainId: string, hostConnectionId: import("@agoric/vats").IBCConnectionID, controllerConnectionId: import("@agoric/vats").IBCConnectionID): import("@agoric/vow").Vow<import("./cosmos-api.js").IcaAccount>;
52
+ provideICQConnection(controllerConnectionId: import("@agoric/vats").IBCConnectionID): import("@agoric/vow").Vow<import("./types.js").ICQConnection> | import("./types.js").ICQConnection;
53
+ };
54
+ }>;
55
+ }>;
56
+ export type OrchestrationVat = ReturnType<typeof buildRootObject>;
57
+ import type { OrchestrationPowers } from './service.js';
58
+ //# sourceMappingURL=vat-orchestration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vat-orchestration.d.ts","sourceRoot":"","sources":["vat-orchestration.js"],"names":[],"mappings":"AAOO;IASH,4DAA4D;;;;;;;;;;;;;;;;;;iCAQ01J,CAAC;;;;;;;;;IARv5J,4DAA4D;;;;;;;;;;;;;;;;;;iCAQ01J,CAAC;;;;;;;;GAH15J;+BAEa,UAAU,CAAC,OAAO,eAAe,CAAC;yCAlBT,cAAc"}
@@ -0,0 +1,24 @@
1
+ import { Far } from '@endo/far';
2
+ import { prepareVowTools } from '@agoric/vow/vat.js';
3
+ import { makeDurableZone } from '@agoric/zone/durable.js';
4
+ import { prepareOrchestrationTools } from './service.js';
5
+
6
+ /** @import {OrchestrationPowers} from './service.js' */
7
+
8
+ export const buildRootObject = (_vatPowers, _args, baggage) => {
9
+ const zone = makeDurableZone(baggage);
10
+ const vowTools = prepareVowTools(zone.subZone('VowTools'));
11
+ const { makeOrchestrationKit } = prepareOrchestrationTools(
12
+ zone.subZone('orchestration'),
13
+ vowTools,
14
+ );
15
+
16
+ return Far('OrchestrationVat', {
17
+ /** @param {Partial<OrchestrationPowers>} [initialPowers] */
18
+ makeOrchestrationKit(initialPowers = {}) {
19
+ return makeOrchestrationKit(initialPowers);
20
+ },
21
+ });
22
+ };
23
+
24
+ /** @typedef {ReturnType<typeof buildRootObject>} OrchestrationVat */