@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.
- package/LICENSE +201 -0
- package/README.md +5 -0
- package/index.d.ts +4 -0
- package/index.js +7 -0
- package/package.json +95 -0
- package/src/chain-info.d.ts +2318 -0
- package/src/chain-info.d.ts.map +1 -0
- package/src/chain-info.js +114 -0
- package/src/cosmos-api.d.ts +174 -0
- package/src/cosmos-api.d.ts.map +1 -0
- package/src/cosmos-api.ts +231 -0
- package/src/ethereum-api.d.ts +8 -0
- package/src/ethereum-api.d.ts.map +1 -0
- package/src/ethereum-api.ts +7 -0
- package/src/examples/sendAnywhere.contract.d.ts +31 -0
- package/src/examples/sendAnywhere.contract.d.ts.map +1 -0
- package/src/examples/sendAnywhere.contract.js +171 -0
- package/src/examples/stakeBld.contract.d.ts +121 -0
- package/src/examples/stakeBld.contract.d.ts.map +1 -0
- package/src/examples/stakeBld.contract.js +133 -0
- package/src/examples/stakeIca.contract.d.ts +93 -0
- package/src/examples/stakeIca.contract.d.ts.map +1 -0
- package/src/examples/stakeIca.contract.js +143 -0
- package/src/examples/swapExample.contract.d.ts +34 -0
- package/src/examples/swapExample.contract.d.ts.map +1 -0
- package/src/examples/swapExample.contract.js +155 -0
- package/src/examples/unbondExample.contract.d.ts +21 -0
- package/src/examples/unbondExample.contract.d.ts.map +1 -0
- package/src/examples/unbondExample.contract.js +105 -0
- package/src/exos/README.md +56 -0
- package/src/exos/agoric-names-tools.d.ts +27 -0
- package/src/exos/agoric-names-tools.d.ts.map +1 -0
- package/src/exos/agoric-names-tools.js +109 -0
- package/src/exos/chain-account-kit.d.ts +88 -0
- package/src/exos/chain-account-kit.d.ts.map +1 -0
- package/src/exos/chain-account-kit.js +210 -0
- package/src/exos/chain-hub.d.ts +77 -0
- package/src/exos/chain-hub.d.ts.map +1 -0
- package/src/exos/chain-hub.js +214 -0
- package/src/exos/cosmos-orchestration-account.d.ts +207 -0
- package/src/exos/cosmos-orchestration-account.d.ts.map +1 -0
- package/src/exos/cosmos-orchestration-account.js +536 -0
- package/src/exos/icq-connection-kit.d.ts +50 -0
- package/src/exos/icq-connection-kit.d.ts.map +1 -0
- package/src/exos/icq-connection-kit.js +135 -0
- package/src/exos/local-chain-facade.d.ts +81 -0
- package/src/exos/local-chain-facade.d.ts.map +1 -0
- package/src/exos/local-chain-facade.js +113 -0
- package/src/exos/local-orchestration-account.d.ts +176 -0
- package/src/exos/local-orchestration-account.d.ts.map +1 -0
- package/src/exos/local-orchestration-account.js +446 -0
- package/src/exos/orchestrator.d.ts +91 -0
- package/src/exos/orchestrator.d.ts.map +1 -0
- package/src/exos/orchestrator.js +141 -0
- package/src/exos/remote-chain-facade.d.ts +144 -0
- package/src/exos/remote-chain-facade.d.ts.map +1 -0
- package/src/exos/remote-chain-facade.js +145 -0
- package/src/facade.d.ts +57 -0
- package/src/facade.d.ts.map +1 -0
- package/src/facade.js +132 -0
- package/src/fetched-chain-info.d.ts +2311 -0
- package/src/fetched-chain-info.d.ts.map +1 -0
- package/src/fetched-chain-info.js +2288 -0
- package/src/internal.d.ts +13 -0
- package/src/internal.d.ts.map +1 -0
- package/src/internal.ts +20 -0
- package/src/orchestration-api.d.ts +158 -0
- package/src/orchestration-api.d.ts.map +1 -0
- package/src/orchestration-api.ts +201 -0
- package/src/proposals/orchestration-proposal.d.ts +53 -0
- package/src/proposals/orchestration-proposal.d.ts.map +1 -0
- package/src/proposals/orchestration-proposal.js +179 -0
- package/src/proposals/revise-chain-info.d.ts +21 -0
- package/src/proposals/revise-chain-info.d.ts.map +1 -0
- package/src/proposals/revise-chain-info.js +44 -0
- package/src/proposals/start-stakeAtom.d.ts +109 -0
- package/src/proposals/start-stakeAtom.d.ts.map +1 -0
- package/src/proposals/start-stakeAtom.js +105 -0
- package/src/proposals/start-stakeBld.d.ts +154 -0
- package/src/proposals/start-stakeBld.d.ts.map +1 -0
- package/src/proposals/start-stakeBld.js +103 -0
- package/src/proposals/start-stakeOsmo.d.ts +108 -0
- package/src/proposals/start-stakeOsmo.d.ts.map +1 -0
- package/src/proposals/start-stakeOsmo.js +106 -0
- package/src/service.d.ts +97 -0
- package/src/service.d.ts.map +1 -0
- package/src/service.js +259 -0
- package/src/typeGuards.d.ts +55 -0
- package/src/typeGuards.d.ts.map +1 -0
- package/src/typeGuards.js +104 -0
- package/src/types.d.ts +11 -0
- package/src/types.d.ts.map +1 -0
- package/src/types.ts +11 -0
- package/src/utils/address.d.ts +14 -0
- package/src/utils/address.d.ts.map +1 -0
- package/src/utils/address.js +79 -0
- package/src/utils/cosmos.d.ts +9 -0
- package/src/utils/cosmos.d.ts.map +1 -0
- package/src/utils/cosmos.js +36 -0
- package/src/utils/orc.d.ts +17 -0
- package/src/utils/orc.d.ts.map +1 -0
- package/src/utils/orc.js +38 -0
- package/src/utils/orchestrationAccount.d.ts +10 -0
- package/src/utils/orchestrationAccount.d.ts.map +1 -0
- package/src/utils/orchestrationAccount.js +22 -0
- package/src/utils/packet.d.ts +57 -0
- package/src/utils/packet.d.ts.map +1 -0
- package/src/utils/packet.js +112 -0
- package/src/utils/registry.d.ts +13 -0
- package/src/utils/registry.d.ts.map +1 -0
- package/src/utils/registry.js +131 -0
- package/src/utils/start-helper.d.ts +51 -0
- package/src/utils/start-helper.d.ts.map +1 -0
- package/src/utils/start-helper.js +109 -0
- package/src/utils/time.d.ts +31 -0
- package/src/utils/time.d.ts.map +1 -0
- package/src/utils/time.js +63 -0
- package/src/vat-orchestration.d.ts +58 -0
- package/src/vat-orchestration.d.ts.map +1 -0
- package/src/vat-orchestration.js +24 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/** @file ICQConnection Exo */
|
|
2
|
+
import { NonNullish } from '@agoric/assert';
|
|
3
|
+
import { makeTracer } from '@agoric/internal';
|
|
4
|
+
import { E } from '@endo/far';
|
|
5
|
+
import { M } from '@endo/patterns';
|
|
6
|
+
import { makeQueryPacket, parseQueryPacket } from '../utils/packet.js';
|
|
7
|
+
import { OutboundConnectionHandlerI } from '../typeGuards.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @import {Zone} from '@agoric/base-zone';
|
|
11
|
+
* @import {Connection, Port} from '@agoric/network';
|
|
12
|
+
* @import {Remote, VowTools} from '@agoric/vow';
|
|
13
|
+
* @import {JsonSafe} from '@agoric/cosmic-proto';
|
|
14
|
+
* @import {RequestQuery, ResponseQuery} from '@agoric/cosmic-proto/tendermint/abci/types.js';
|
|
15
|
+
* @import {LocalIbcAddress, RemoteIbcAddress} from '@agoric/vats/tools/ibc-utils.js';
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const { Fail } = assert;
|
|
19
|
+
const trace = makeTracer('Orchestration:ICQConnection');
|
|
20
|
+
|
|
21
|
+
export const ICQMsgShape = M.splitRecord(
|
|
22
|
+
{ path: M.string(), data: M.string() },
|
|
23
|
+
{ height: M.string(), prove: M.boolean() },
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const ICQConnectionI = M.interface('ICQConnection', {
|
|
27
|
+
getLocalAddress: M.call().returns(M.string()),
|
|
28
|
+
getRemoteAddress: M.call().returns(M.string()),
|
|
29
|
+
query: M.call(M.arrayOf(ICQMsgShape)).returns(M.promise()),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {{
|
|
34
|
+
* port: Port;
|
|
35
|
+
* connection: Remote<Connection> | undefined;
|
|
36
|
+
* localAddress: LocalIbcAddress | undefined;
|
|
37
|
+
* remoteAddress: RemoteIbcAddress | undefined;
|
|
38
|
+
* }} ICQConnectionKitState
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Prepares an ICQ Connection Kit based on the
|
|
43
|
+
* {@link https://github.com/cosmos/ibc-apps/blob/e9b46e4bf0ad0a66cf6bc53b5e5496f6e2b4b02b/modules/async-icq/README.md | `icq/v1` IBC application protocol}.
|
|
44
|
+
*
|
|
45
|
+
* `icq/v1`, also referred to as `async-icq`, is a protocol for asynchronous
|
|
46
|
+
* queries between IBC-enabled chains. It allows a chain to send queries to
|
|
47
|
+
* another chain and receive responses asynchronously.
|
|
48
|
+
*
|
|
49
|
+
* The ICQ connection kit provides the necessary functionality to establish and
|
|
50
|
+
* manage an ICQ connection between two chains. It includes methods for
|
|
51
|
+
* retrieving the local and remote addresses of the connection, as well as
|
|
52
|
+
* sending queries and handling connection events.
|
|
53
|
+
*
|
|
54
|
+
* @param {Zone} zone
|
|
55
|
+
* @param {VowTools} vowTools
|
|
56
|
+
*/
|
|
57
|
+
export const prepareICQConnectionKit = (zone, { watch, when }) =>
|
|
58
|
+
zone.exoClassKit(
|
|
59
|
+
'ICQConnectionKit',
|
|
60
|
+
{
|
|
61
|
+
connection: ICQConnectionI,
|
|
62
|
+
connectionHandler: OutboundConnectionHandlerI,
|
|
63
|
+
parseQueryPacketWatcher: M.interface('ParseQueryPacketWatcher', {
|
|
64
|
+
onFulfilled: M.call(M.string())
|
|
65
|
+
.optional(M.arrayOf(M.undefined())) // does not need watcherContext
|
|
66
|
+
.returns(M.arrayOf(M.record())),
|
|
67
|
+
}),
|
|
68
|
+
},
|
|
69
|
+
/** @param {Port} port */
|
|
70
|
+
port =>
|
|
71
|
+
/** @type {ICQConnectionKitState} */ ({
|
|
72
|
+
port,
|
|
73
|
+
connection: undefined,
|
|
74
|
+
remoteAddress: undefined,
|
|
75
|
+
localAddress: undefined,
|
|
76
|
+
}),
|
|
77
|
+
{
|
|
78
|
+
connection: {
|
|
79
|
+
getLocalAddress() {
|
|
80
|
+
return NonNullish(
|
|
81
|
+
this.state.localAddress,
|
|
82
|
+
'local address not available',
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
getRemoteAddress() {
|
|
86
|
+
return NonNullish(
|
|
87
|
+
this.state.remoteAddress,
|
|
88
|
+
'remote address not available',
|
|
89
|
+
);
|
|
90
|
+
},
|
|
91
|
+
/**
|
|
92
|
+
* @param {JsonSafe<RequestQuery>[]} msgs
|
|
93
|
+
* @returns {Promise<JsonSafe<ResponseQuery>[]>}
|
|
94
|
+
* @throws {Error} if packet fails to send or an error is returned
|
|
95
|
+
*/
|
|
96
|
+
query(msgs) {
|
|
97
|
+
const { connection } = this.state;
|
|
98
|
+
// TODO #9281 do not throw synchronously when returning a promise; return a rejected Vow
|
|
99
|
+
/// see https://github.com/Agoric/agoric-sdk/pull/9454#discussion_r1626898694
|
|
100
|
+
if (!connection) throw Fail`connection not available`;
|
|
101
|
+
return when(
|
|
102
|
+
watch(
|
|
103
|
+
E(connection).send(makeQueryPacket(msgs)),
|
|
104
|
+
this.facets.parseQueryPacketWatcher,
|
|
105
|
+
),
|
|
106
|
+
);
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
parseQueryPacketWatcher: {
|
|
110
|
+
/** @param {string} ack packet acknowledgement string */
|
|
111
|
+
onFulfilled(ack) {
|
|
112
|
+
return parseQueryPacket(ack);
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
connectionHandler: {
|
|
116
|
+
/**
|
|
117
|
+
* @param {Remote<Connection>} connection
|
|
118
|
+
* @param {LocalIbcAddress} localAddr
|
|
119
|
+
* @param {RemoteIbcAddress} remoteAddr
|
|
120
|
+
*/
|
|
121
|
+
async onOpen(connection, localAddr, remoteAddr) {
|
|
122
|
+
trace(`ICQ Channel Opened for ${localAddr} at ${remoteAddr}`);
|
|
123
|
+
this.state.connection = connection;
|
|
124
|
+
this.state.remoteAddress = remoteAddr;
|
|
125
|
+
this.state.localAddress = localAddr;
|
|
126
|
+
},
|
|
127
|
+
async onClose(_connection, reason) {
|
|
128
|
+
trace(`ICQ Channel closed. Reason: ${reason}`);
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
/** @typedef {ReturnType<ReturnType<typeof prepareICQConnectionKit>>} ICQConnectionKit */
|
|
135
|
+
/** @typedef {ICQConnectionKit['connection']} ICQConnection */
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export function prepareLocalChainFacade(zone: Zone, powers: LocalChainFacadePowers): (localChainInfo: Readonly<{
|
|
2
|
+
chainId: string;
|
|
3
|
+
connections?: Record<string, IBCConnectionInfo>;
|
|
4
|
+
icqEnabled?: boolean;
|
|
5
|
+
stakingTokens?: Readonly<Array<{
|
|
6
|
+
denom: string;
|
|
7
|
+
}>>;
|
|
8
|
+
}>) => ReturnType<(localChainInfo: Readonly<{
|
|
9
|
+
chainId: string;
|
|
10
|
+
connections?: Record<string, IBCConnectionInfo>;
|
|
11
|
+
icqEnabled?: boolean;
|
|
12
|
+
stakingTokens?: Readonly<Array<{
|
|
13
|
+
denom: string;
|
|
14
|
+
}>>;
|
|
15
|
+
}>) => 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 {[LocalChainAccount, ChainAddress['address']]} results
|
|
31
|
+
*/
|
|
32
|
+
onFulfilled([account, address]: [LocalChainAccount, ChainAddress["address"]]): import("@endo/exo").Guarded<{
|
|
33
|
+
getBalance(denom: import("../orchestration-api.js").DenomArg): Vow<import("../orchestration-api.js").DenomAmount>;
|
|
34
|
+
getBalances(): Vow<never>;
|
|
35
|
+
getPublicTopics(): {
|
|
36
|
+
account: {
|
|
37
|
+
description: string;
|
|
38
|
+
subscriber: globalThis.Subscriber<import("./local-orchestration-account.js").LocalChainAccountNotification>;
|
|
39
|
+
storagePath: Promise<string>;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Vow<Record<unknown, unknown>>;
|
|
43
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Vow<void | import("@agoric/time").TimestampRecord>;
|
|
44
|
+
deposit(payment: globalThis.Payment<"nat">): Vow<void>;
|
|
45
|
+
withdraw(amount: import("@agoric/ertp/src/types.js").NatAmount): Vow<globalThis.Payment<"nat"> | Vow<globalThis.Payment<"nat">>>;
|
|
46
|
+
executeTx(messages: {
|
|
47
|
+
'@type': string;
|
|
48
|
+
}[]): Vow<import("@agoric/cosmic-proto").JsonSafe<{
|
|
49
|
+
'@type': string;
|
|
50
|
+
}>[]>;
|
|
51
|
+
getAddress(): ChainAddress;
|
|
52
|
+
send(toAccount: any, amount: any): Vow<never>;
|
|
53
|
+
transfer(amount: import("../orchestration-api.js").AmountArg, destination: ChainAddress, opts?: import("../cosmos-api.js").IBCMsgTransferOptions | undefined): Vow<void>;
|
|
54
|
+
transferSteps(amount: import("../orchestration-api.js").AmountArg, msg: import("../orchestration-api.js").TransferMsg): Vow<void>;
|
|
55
|
+
}>;
|
|
56
|
+
};
|
|
57
|
+
}>>["public"];
|
|
58
|
+
export type LocalChainFacadePowers = {
|
|
59
|
+
makeLocalOrchestrationAccountKit: MakeLocalOrchestrationAccountKit;
|
|
60
|
+
orchestration: Remote<OrchestrationService>;
|
|
61
|
+
storageNode: Remote<StorageNode>;
|
|
62
|
+
timer: Remote<TimerService>;
|
|
63
|
+
localchain: Remote<LocalChain>;
|
|
64
|
+
vowTools: VowTools;
|
|
65
|
+
};
|
|
66
|
+
export type MakeLocalChainFacade = ReturnType<typeof prepareLocalChainFacade>;
|
|
67
|
+
import type { Zone } from '@agoric/base-zone';
|
|
68
|
+
import type { IBCConnectionInfo } from '../types.js';
|
|
69
|
+
import type { Vow } from '@agoric/vow';
|
|
70
|
+
import type { ChainInfo } from '../types.js';
|
|
71
|
+
import type { OrchestrationAccount } from '../types.js';
|
|
72
|
+
import type { PromiseToVow } from '../types.js';
|
|
73
|
+
import type { LocalChainAccount } from '@agoric/vats/src/localchain.js';
|
|
74
|
+
import type { ChainAddress } from '../types.js';
|
|
75
|
+
import type { MakeLocalOrchestrationAccountKit } from './local-orchestration-account.js';
|
|
76
|
+
import type { OrchestrationService } from '../service.js';
|
|
77
|
+
import type { Remote } from '@agoric/internal';
|
|
78
|
+
import type { TimerService } from '@agoric/time';
|
|
79
|
+
import type { LocalChain } from '@agoric/vats/src/localchain.js';
|
|
80
|
+
import type { VowTools } from '@agoric/vow';
|
|
81
|
+
//# sourceMappingURL=local-chain-facade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-chain-facade.d.ts","sourceRoot":"","sources":["local-chain-facade.js"],"names":[],"mappings":"AA0GO,8CAHI,IAAI,UACJ,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;QAtCzB,oEAAoE;uBAAtD,IAAI,aAAa,qBAAqB,SAAS,CAAC,CAAC,CAAC;;;QAchE;;WAEG;wCADQ,CAAC,iBAAiB,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;cA4B9D;qCA1FY;IACZ,gCAAoC,EAAE,gCAAgC,CAAC;IACvE,aAAiB,EAAE,OAAO,oBAAoB,CAAC,CAAC;IAChD,WAAe,EAAE,OAAO,WAAW,CAAC,CAAC;IACrC,KAAS,EAAE,OAAO,YAAY,CAAC,CAAC;IAChC,UAAc,EAAE,OAAO,UAAU,CAAC,CAAC;IACnC,QAAY,EAAE,QAAQ,CAAC;CACpB;mCAsFU,UAAU,CAAC,OAAO,uBAAuB,CAAC;0BAxGjC,mBAAmB;uCAOwE,aAAa;yBAH/F,aAAa;+BAGqE,aAAa;0CAAb,aAAa;kCAAb,aAAa;uCAJ/E,gCAAgC;kCAIkC,aAAa;sDAD5E,kCAAkC;0CAD9C,eAAe;4BAH7B,kBAAkB;kCADZ,cAAc;gCAEG,gCAAgC;8BAChD,aAAa"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/** @file ChainAccount exo */
|
|
2
|
+
import { E } from '@endo/far';
|
|
3
|
+
import { M } from '@endo/patterns';
|
|
4
|
+
import { pickFacet } from '@agoric/vat-data';
|
|
5
|
+
|
|
6
|
+
import { ChainFacadeI } from '../typeGuards.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @import {Zone} from '@agoric/base-zone';
|
|
10
|
+
* @import {TimerService} from '@agoric/time';
|
|
11
|
+
* @import {Remote} from '@agoric/internal';
|
|
12
|
+
* @import {LocalChain, LocalChainAccount} from '@agoric/vats/src/localchain.js';
|
|
13
|
+
* @import {Vow, VowTools} from '@agoric/vow';
|
|
14
|
+
* @import {OrchestrationService} from '../service.js';
|
|
15
|
+
* @import {MakeLocalOrchestrationAccountKit} from './local-orchestration-account.js';
|
|
16
|
+
* @import {ChainAddress, ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, PromiseToVow} from '../types.js';
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {{
|
|
21
|
+
* makeLocalOrchestrationAccountKit: MakeLocalOrchestrationAccountKit;
|
|
22
|
+
* orchestration: Remote<OrchestrationService>;
|
|
23
|
+
* storageNode: Remote<StorageNode>;
|
|
24
|
+
* timer: Remote<TimerService>;
|
|
25
|
+
* localchain: Remote<LocalChain>;
|
|
26
|
+
* vowTools: VowTools;
|
|
27
|
+
* }} LocalChainFacadePowers
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param {Zone} zone
|
|
32
|
+
* @param {LocalChainFacadePowers} powers
|
|
33
|
+
*/
|
|
34
|
+
const prepareLocalChainFacadeKit = (
|
|
35
|
+
zone,
|
|
36
|
+
{
|
|
37
|
+
makeLocalOrchestrationAccountKit,
|
|
38
|
+
localchain,
|
|
39
|
+
storageNode,
|
|
40
|
+
vowTools: { allVows, watch },
|
|
41
|
+
},
|
|
42
|
+
) =>
|
|
43
|
+
zone.exoClassKit(
|
|
44
|
+
'LocalChainFacade',
|
|
45
|
+
{
|
|
46
|
+
public: ChainFacadeI,
|
|
47
|
+
makeAccountWatcher: M.interface('undelegateWatcher', {
|
|
48
|
+
onFulfilled: M.call([M.remotable('LCA Account'), M.string()])
|
|
49
|
+
.optional(M.arrayOf(M.undefined())) // empty context
|
|
50
|
+
.returns(M.remotable()),
|
|
51
|
+
}),
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* @param {CosmosChainInfo} localChainInfo
|
|
55
|
+
*/
|
|
56
|
+
localChainInfo => {
|
|
57
|
+
return { localChainInfo };
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
public: {
|
|
61
|
+
getChainInfo() {
|
|
62
|
+
return watch(this.state.localChainInfo);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
// FIXME parameterize on the remoteChainInfo to make()
|
|
66
|
+
// That used to work but got lost in the migration to Exo
|
|
67
|
+
/** @returns {Vow<PromiseToVow<OrchestrationAccount<ChainInfo>>>} */
|
|
68
|
+
makeAccount() {
|
|
69
|
+
const lcaP = E(localchain).makeAccount();
|
|
70
|
+
// TODO #9449 fix types
|
|
71
|
+
// @ts-expect-error Type 'Vow<Voidless>' is not assignable to type 'Vow<OrchestrationAccountI>'.
|
|
72
|
+
return watch(
|
|
73
|
+
// TODO #9449 fix types
|
|
74
|
+
// @ts-expect-error Property 'getAddress' does not exist on type 'EMethods<Required<Guarded<{ getAddress()...
|
|
75
|
+
allVows([lcaP, E(lcaP).getAddress()]),
|
|
76
|
+
this.facets.makeAccountWatcher,
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
makeAccountWatcher: {
|
|
81
|
+
/**
|
|
82
|
+
* @param {[LocalChainAccount, ChainAddress['address']]} results
|
|
83
|
+
*/
|
|
84
|
+
onFulfilled([account, address]) {
|
|
85
|
+
const { localChainInfo } = this.state;
|
|
86
|
+
const { holder } = makeLocalOrchestrationAccountKit({
|
|
87
|
+
account,
|
|
88
|
+
address: harden({
|
|
89
|
+
address,
|
|
90
|
+
addressEncoding: 'bech32',
|
|
91
|
+
chainId: localChainInfo.chainId,
|
|
92
|
+
}),
|
|
93
|
+
// FIXME storage path https://github.com/Agoric/agoric-sdk/issues/9066
|
|
94
|
+
storageNode,
|
|
95
|
+
});
|
|
96
|
+
return holder;
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
harden(prepareLocalChainFacadeKit);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @param {Zone} zone
|
|
105
|
+
* @param {LocalChainFacadePowers} powers
|
|
106
|
+
*/
|
|
107
|
+
export const prepareLocalChainFacade = (zone, powers) => {
|
|
108
|
+
const makeLocalChainFacadeKit = prepareLocalChainFacadeKit(zone, powers);
|
|
109
|
+
return pickFacet(makeLocalChainFacadeKit, 'public');
|
|
110
|
+
};
|
|
111
|
+
harden(prepareLocalChainFacade);
|
|
112
|
+
|
|
113
|
+
/** @typedef {ReturnType<typeof prepareLocalChainFacade>} MakeLocalChainFacade */
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
export function prepareLocalOrchestrationAccountKit(zone: Zone, makeRecorderKit: MakeRecorderKit, zcf: ZCF, timerService: Remote<TimerService>, { watch, allVows, asVow }: VowTools, chainHub: ChainHub): (args_0: {
|
|
2
|
+
account: LocalChainAccount;
|
|
3
|
+
address: ChainAddress;
|
|
4
|
+
storageNode: Remote<StorageNode>;
|
|
5
|
+
}) => import("@endo/exo").GuardedKit<{
|
|
6
|
+
invitationMakers: {
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} validatorAddress
|
|
9
|
+
* @param {Amount<'nat'>} ertpAmount
|
|
10
|
+
*/
|
|
11
|
+
Delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<Vow<Record<unknown, unknown>>, undefined>>;
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} validatorAddress
|
|
14
|
+
* @param {Amount<'nat'>} ertpAmount
|
|
15
|
+
*/
|
|
16
|
+
Undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<Vow<TimestampRecord>, undefined>>;
|
|
17
|
+
CloseAccount(): never;
|
|
18
|
+
};
|
|
19
|
+
undelegateWatcher: {
|
|
20
|
+
/**
|
|
21
|
+
* @param {[
|
|
22
|
+
* JsonSafe<
|
|
23
|
+
* TypedJson<'/cosmos.staking.v1beta1.MsgUndelegateResponse'>
|
|
24
|
+
* >,
|
|
25
|
+
* ]} response
|
|
26
|
+
*/
|
|
27
|
+
onFulfilled(response: [JsonSafe<TypedJson<"/cosmos.staking.v1beta1.MsgUndelegateResponse">>]): Vow<TimestampRecord>;
|
|
28
|
+
};
|
|
29
|
+
getChainInfoWatcher: {
|
|
30
|
+
/**
|
|
31
|
+
* @param {ChainInfo} agoricChainInfo
|
|
32
|
+
* @param {ChainAddress} destination
|
|
33
|
+
*/
|
|
34
|
+
onFulfilled(agoricChainInfo: ChainInfo, destination: ChainAddress): Vow<IBCConnectionInfo>;
|
|
35
|
+
};
|
|
36
|
+
transferWatcher: {
|
|
37
|
+
/**
|
|
38
|
+
* @param {[
|
|
39
|
+
* { transferChannel: IBCConnectionInfo['transferChannel'] },
|
|
40
|
+
* bigint,
|
|
41
|
+
* ]} results
|
|
42
|
+
* @param {{
|
|
43
|
+
* destination: ChainAddress;
|
|
44
|
+
* opts: IBCMsgTransferOptions;
|
|
45
|
+
* amount: DenomAmount;
|
|
46
|
+
* }} ctx
|
|
47
|
+
*/
|
|
48
|
+
onFulfilled([{ transferChannel }, timeoutTimestamp]: [{
|
|
49
|
+
transferChannel: IBCConnectionInfo["transferChannel"];
|
|
50
|
+
}, bigint], { opts, amount, destination }: {
|
|
51
|
+
destination: ChainAddress;
|
|
52
|
+
opts: IBCMsgTransferOptions;
|
|
53
|
+
amount: DenomAmount;
|
|
54
|
+
}): Vow<JsonSafe<import("@agoric/cosmic-proto/ibc/applications/transfer/v1/tx.js").MsgTransferResponse & {
|
|
55
|
+
'@type': "/ibc.applications.transfer.v1.MsgTransferResponse";
|
|
56
|
+
}>[]>;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* takes an array of results (from `executeEncodedTx`) and returns the
|
|
60
|
+
* first result
|
|
61
|
+
*/
|
|
62
|
+
extractFirstResultWatcher: {
|
|
63
|
+
/**
|
|
64
|
+
* @param {Record<unknown, unknown>[]} results
|
|
65
|
+
*/
|
|
66
|
+
onFulfilled(results: Record<unknown, unknown>[]): Record<unknown, unknown>;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* takes an array of results (from `executeEncodedTx`) and returns void
|
|
70
|
+
* since we are not interested in the result
|
|
71
|
+
*/
|
|
72
|
+
returnVoidWatcher: {
|
|
73
|
+
/**
|
|
74
|
+
* @param {unknown} _result
|
|
75
|
+
*/
|
|
76
|
+
onFulfilled(_result: unknown): undefined;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* handles a request for balance from a bank purse and returns the balance
|
|
80
|
+
* as a Chain Amount
|
|
81
|
+
*/
|
|
82
|
+
getBalanceWatcher: {
|
|
83
|
+
/**
|
|
84
|
+
* @param {Amount<'nat'>} natAmount
|
|
85
|
+
* @param {DenomAmount['denom']} denom
|
|
86
|
+
* @returns {DenomAmount}
|
|
87
|
+
*/
|
|
88
|
+
onFulfilled(natAmount: Amount<"nat">, denom: DenomAmount["denom"]): DenomAmount;
|
|
89
|
+
};
|
|
90
|
+
holder: {
|
|
91
|
+
/**
|
|
92
|
+
* TODO: balance lookups for non-vbank assets
|
|
93
|
+
*
|
|
94
|
+
* @type {PromiseToVow<OrchestrationAccount<any>['getBalance']>}
|
|
95
|
+
*/
|
|
96
|
+
getBalance(denom: import("@agoric/orchestration").DenomArg): Vow<DenomAmount>;
|
|
97
|
+
getBalances(): Vow<never>;
|
|
98
|
+
getPublicTopics(): {
|
|
99
|
+
account: {
|
|
100
|
+
description: string;
|
|
101
|
+
subscriber: globalThis.Subscriber<LocalChainAccountNotification>;
|
|
102
|
+
storagePath: Promise<string>;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* @param {string} validatorAddress
|
|
107
|
+
* @param {Amount<'nat'>} ertpAmount
|
|
108
|
+
*/
|
|
109
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Vow<Record<unknown, unknown>>;
|
|
110
|
+
/**
|
|
111
|
+
* @param {string} validatorAddress
|
|
112
|
+
* @param {Amount<'nat'>} ertpAmount
|
|
113
|
+
* @returns {Vow<void | TimestampRecord>}
|
|
114
|
+
*/
|
|
115
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Vow<void | TimestampRecord>;
|
|
116
|
+
/**
|
|
117
|
+
* Starting a transfer revokes the account holder. The associated
|
|
118
|
+
* updater will get a special notification that the account is being
|
|
119
|
+
* transferred.
|
|
120
|
+
*/
|
|
121
|
+
/** @type {PromiseToVow<OrchestrationAccount<any>['deposit']>} */
|
|
122
|
+
deposit(payment: globalThis.Payment<"nat">): Vow<void>;
|
|
123
|
+
/** @type {PromiseToVow<LocalChainAccount['withdraw']>} */
|
|
124
|
+
withdraw(amount: import("@agoric/ertp/src/types.js").NatAmount): Vow<globalThis.Payment<"nat"> | Vow<globalThis.Payment<"nat">>>;
|
|
125
|
+
/** @type {PromiseToVow<LocalChainAccount['executeTx']>} */
|
|
126
|
+
executeTx(messages: {
|
|
127
|
+
'@type': string;
|
|
128
|
+
}[]): Vow<JsonSafe<{
|
|
129
|
+
'@type': string;
|
|
130
|
+
}>[]>;
|
|
131
|
+
/** @type {OrchestrationAccount<any>['getAddress']} */
|
|
132
|
+
getAddress(): ChainAddress;
|
|
133
|
+
send(toAccount: any, amount: any): Vow<never>;
|
|
134
|
+
/**
|
|
135
|
+
* @param {AmountArg} amount an ERTP {@link Amount} or a
|
|
136
|
+
* {@link DenomAmount}
|
|
137
|
+
* @param {ChainAddress} destination
|
|
138
|
+
* @param {IBCMsgTransferOptions} [opts] if either timeoutHeight or
|
|
139
|
+
* timeoutTimestamp are not supplied, a default timeoutTimestamp will
|
|
140
|
+
* be set for 5 minutes in the future
|
|
141
|
+
* @returns {Vow<void>}
|
|
142
|
+
*/
|
|
143
|
+
transfer(amount: AmountArg, destination: ChainAddress, opts?: IBCMsgTransferOptions | undefined): Vow<void>;
|
|
144
|
+
/** @type {PromiseToVow<OrchestrationAccount<any>['transferSteps']>} */
|
|
145
|
+
transferSteps(amount: AmountArg, msg: import("@agoric/orchestration").TransferMsg): Vow<void>;
|
|
146
|
+
};
|
|
147
|
+
}>;
|
|
148
|
+
export type LocalChainAccountNotification = {
|
|
149
|
+
address: string;
|
|
150
|
+
};
|
|
151
|
+
export type State = {
|
|
152
|
+
topicKit: RecorderKit<LocalChainAccountNotification>;
|
|
153
|
+
account: LocalChainAccount;
|
|
154
|
+
address: ChainAddress;
|
|
155
|
+
};
|
|
156
|
+
export type MakeLocalOrchestrationAccountKit = ReturnType<typeof prepareLocalOrchestrationAccountKit>;
|
|
157
|
+
export type LocalOrchestrationAccountKit = ReturnType<MakeLocalOrchestrationAccountKit>;
|
|
158
|
+
import type { Zone } from '@agoric/zone';
|
|
159
|
+
import type { MakeRecorderKit } from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
160
|
+
import type { TimerService } from '@agoric/time';
|
|
161
|
+
import type { Remote } from '@agoric/internal';
|
|
162
|
+
import type { VowTools } from '@agoric/vow';
|
|
163
|
+
import type { ChainHub } from './chain-hub.js';
|
|
164
|
+
import type { LocalChainAccount } from '@agoric/vats/src/localchain.js';
|
|
165
|
+
import type { ChainAddress } from '@agoric/orchestration';
|
|
166
|
+
import type { Vow } from '@agoric/vow';
|
|
167
|
+
import type { TimestampRecord } from '@agoric/time';
|
|
168
|
+
import type { TypedJson } from '@agoric/cosmic-proto';
|
|
169
|
+
import type { JsonSafe } from '@agoric/cosmic-proto';
|
|
170
|
+
import type { ChainInfo } from '@agoric/orchestration';
|
|
171
|
+
import type { IBCConnectionInfo } from '@agoric/orchestration';
|
|
172
|
+
import type { IBCMsgTransferOptions } from '@agoric/orchestration';
|
|
173
|
+
import type { DenomAmount } from '@agoric/orchestration';
|
|
174
|
+
import type { AmountArg } from '@agoric/orchestration';
|
|
175
|
+
import type { RecorderKit } from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
176
|
+
//# sourceMappingURL=local-orchestration-account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-orchestration-account.d.ts","sourceRoot":"","sources":["local-orchestration-account.js"],"names":[],"mappings":"AAwEO,0DAPI,IAAI,mBACJ,eAAe,OACf,GAAG,gBACH,OAAO,YAAY,CAAC,6BACpB,QAAQ,YACR,QAAQ;aA2DJ,iBAAiB;aACjB,YAAY;iBACZ,OAAO,WAAW,CAAC;;;QAY1B;;;WAGG;mCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;QAYxB;;;WAGG;qCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;;QAiBxB;;;;;;WAMG;8BALQ,CACV,SACA,UAAgB,+CAA+C,CAAC,CAC3D,CACF;;;QAaJ;;;WAGG;6DADQ,YAAY;;;QAUvB;;;;;;;;;;WAUG;6DATQ,CACV;YAAM,eAAe,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,CAAA;SAAE,EAC7D,MAAU,CACP,iCACO;YACV,WAAe,EAAE,YAAY,CAAC;YAC9B,IAAQ,EAAE,qBAAqB,CAAC;YAChC,MAAU,EAAE,WAAW,CAAC;SACrB;;;;IA4BN;;;OAGG;;QAED;;WAEG;6BADQ,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE;;IAQvC;;;OAGG;;QAED;;WAEG;6BADQ,OAAO;;IAMpB;;;OAGG;;QAED;;;;WAIG;+BAHQ,MAAM,CAAC,KAAK,CAAC,SACb,WAAW,CAAC,OAAO,CAAC,GAClB,WAAW;;;QAOxB;;;;WAIG;;;;;;;;;;QA8BH;;;WAGG;mCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;QAqBxB;;;;WAIG;qCAHQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC,GACX,IAAI,IAAI,GAAG,eAAe,CAAC;QAoBxC;;;;WAIG;QACH,iEAAiE;;QAOjE,0DAA0D;;QAI1D,2DAA2D;;;;;;QAI3D,sDAAsD;;;QAWtD;;;;;;;;WAQG;yBAPQ,SAAS,eAET,YAAY,6CAIV,IAAI,IAAI,CAAC;QA8BtB,uEAAuE;;;GAW9E;;aApZa,MAAM;;oBAIP;IACZ,QAAY,EAAE,YAAY,6BAA6B,CAAC,CAAC;IACzD,OAAW,EAAE,iBAAiB,CAAC;IAC/B,OAAW,EAAE,YAAY,CAAC;CACvB;+CA6YU,UAAU,CAAC,OAAO,mCAAmC,CAAC;2CACtD,UAAU,CAAC,gCAAgC,CAAC;0BAranC,cAAc;qCADU,6CAA6C;kCAGhC,cAAc;4BADjD,kBAAkB;8BAEC,aAAa;8BAE9B,gBAAgB;uCARP,gCAAgC;kCAC4E,uBAAuB;yBAK3H,aAAa;qCADG,cAAc;+BAEpC,sBAAsB;8BAAtB,sBAAsB;+BANoF,uBAAuB;uCAAvB,uBAAuB;2CAAvB,uBAAuB;iCAAvB,uBAAuB;+BAAvB,uBAAuB;iCACxH,6CAA6C"}
|