@agoric/orchestration 0.1.1-dev-a035bbe.0 → 0.1.1-dev-c244e96.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/package.json +16 -16
- package/src/chain-info.js +1 -1
- package/src/examples/sendAnywhere.contract.d.ts.map +1 -1
- package/src/examples/sendAnywhere.contract.js +3 -2
- package/src/examples/stakeBld.contract.d.ts +23 -11
- package/src/examples/stakeBld.contract.d.ts.map +1 -1
- package/src/examples/stakeBld.contract.js +9 -5
- package/src/examples/stakeIca.contract.d.ts +3 -3
- package/src/examples/stakeIca.contract.js +1 -1
- package/src/examples/swapExample.contract.d.ts.map +1 -1
- package/src/examples/swapExample.contract.js +6 -1
- package/src/exos/{chainAccountKit.d.ts → chain-account-kit.d.ts} +1 -1
- package/src/exos/chain-account-kit.d.ts.map +1 -0
- package/src/exos/{chainAccountKit.js → chain-account-kit.js} +2 -2
- package/src/exos/{cosmosOrchestrationAccount.d.ts → cosmos-orchestration-account.d.ts} +1 -1
- package/src/exos/cosmos-orchestration-account.d.ts.map +1 -0
- package/src/exos/{icqConnectionKit.d.ts → icq-connection-kit.d.ts} +1 -1
- package/src/exos/icq-connection-kit.d.ts.map +1 -0
- package/src/exos/local-chain-facade.d.ts +105 -0
- package/src/exos/local-chain-facade.d.ts.map +1 -0
- package/src/exos/local-chain-facade.js +67 -0
- package/src/exos/{local-chain-account-kit.d.ts → local-orchestration-account.d.ts} +33 -63
- package/src/exos/{local-chain-account-kit.d.ts.map → local-orchestration-account.d.ts.map} +1 -1
- package/src/exos/{local-chain-account-kit.js → local-orchestration-account.js} +48 -30
- package/src/exos/orchestrator.d.ts +4763 -0
- package/src/exos/orchestrator.d.ts.map +1 -0
- package/src/exos/orchestrator.js +93 -0
- package/src/exos/remote-chain-facade.d.ts +84 -0
- package/src/exos/remote-chain-facade.d.ts.map +1 -0
- package/src/exos/remote-chain-facade.js +81 -0
- package/src/facade.d.ts +88 -4
- package/src/facade.d.ts.map +1 -1
- package/src/facade.js +30 -169
- package/src/proposals/start-stakeAtom.d.ts +3 -3
- package/src/proposals/start-stakeAtom.d.ts.map +1 -1
- package/src/proposals/start-stakeBld.d.ts +23 -11
- package/src/proposals/start-stakeBld.d.ts.map +1 -1
- package/src/proposals/start-stakeOsmo.d.ts +3 -3
- package/src/proposals/start-stakeOsmo.d.ts.map +1 -1
- package/src/service.js +3 -3
- package/src/typeGuards.d.ts +14 -0
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +15 -0
- package/src/types.d.ts +2 -2
- package/src/types.d.ts.map +1 -1
- package/src/types.ts +2 -2
- package/src/utils/chainHub.d.ts +15 -3
- package/src/utils/chainHub.d.ts.map +1 -1
- package/src/utils/chainHub.js +1 -1
- package/src/utils/orc.js +2 -2
- package/src/utils/orchestrationAccount.js +3 -4
- package/src/utils/start-helper.d.ts +9 -0
- package/src/utils/start-helper.d.ts.map +1 -1
- package/src/utils/start-helper.js +32 -3
- package/src/exos/chainAccountKit.d.ts.map +0 -1
- package/src/exos/cosmosOrchestrationAccount.d.ts.map +0 -1
- package/src/exos/icqConnectionKit.d.ts.map +0 -1
- /package/src/exos/{cosmosOrchestrationAccount.js → cosmos-orchestration-account.js} +0 -0
- /package/src/exos/{icqConnectionKit.js → icq-connection-kit.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["orchestrator.js"],"names":[],"mappings":"AAgCA,0BAA0B;AAC1B;;;;;GAKG;AAiBI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAwBG,CAAF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAZF,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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endo/patterns';
|
|
6
|
+
import {
|
|
7
|
+
ChainInfoShape,
|
|
8
|
+
LocalChainAccountShape,
|
|
9
|
+
DenomShape,
|
|
10
|
+
BrandInfoShape,
|
|
11
|
+
DenomAmountShape,
|
|
12
|
+
} from '../typeGuards.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @import {Zone} from '@agoric/base-zone';
|
|
16
|
+
* @import {ChainHub} from '../utils/chainHub.js';
|
|
17
|
+
* @import {AsyncFlowTools} from '@agoric/async-flow';
|
|
18
|
+
* @import {Vow} from '@agoric/vow';
|
|
19
|
+
* @import {TimerService} from '@agoric/time';
|
|
20
|
+
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
|
|
21
|
+
* @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js'.
|
|
22
|
+
* @import {Remote} from '@agoric/internal';
|
|
23
|
+
* @import {OrchestrationService} from '../service.js';
|
|
24
|
+
* @import {MakeLocalOrchestrationAccountKit} from './local-orchestration-account.js';
|
|
25
|
+
* @import {MakeLocalChainFacade} from './local-chain-facade.js';
|
|
26
|
+
* @import {MakeRemoteChainFacade} from './remote-chain-facade.js';
|
|
27
|
+
* @import {Chain, ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount, Orchestrator} from '../types.js';
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
const { Fail } = assert;
|
|
31
|
+
const trace = makeTracer('Orchestrator');
|
|
32
|
+
|
|
33
|
+
/** @see {Orchestrator} */
|
|
34
|
+
export const OrchestratorI = M.interface('Orchestrator', {
|
|
35
|
+
getChain: M.callWhen(M.string()).returns(ChainInfoShape),
|
|
36
|
+
makeLocalAccount: M.callWhen().returns(LocalChainAccountShape),
|
|
37
|
+
getBrandInfo: M.call(DenomShape).returns(BrandInfoShape),
|
|
38
|
+
asAmount: M.call(DenomAmountShape).returns(AmountShape),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {Zone} zone
|
|
43
|
+
* @param {{
|
|
44
|
+
* asyncFlowTools: AsyncFlowTools;
|
|
45
|
+
* chainHub: ChainHub;
|
|
46
|
+
* localchain: Remote<LocalChain>;
|
|
47
|
+
* makeRecorderKit: MakeRecorderKit;
|
|
48
|
+
* makeLocalChainFacade: MakeLocalChainFacade;
|
|
49
|
+
* makeRemoteChainFacade: MakeRemoteChainFacade;
|
|
50
|
+
* orchestrationService: Remote<OrchestrationService>;
|
|
51
|
+
* storageNode: Remote<StorageNode>;
|
|
52
|
+
* timerService: Remote<TimerService>;
|
|
53
|
+
* zcf: ZCF;
|
|
54
|
+
* }} powers
|
|
55
|
+
*/
|
|
56
|
+
export const prepareOrchestrator = (
|
|
57
|
+
zone,
|
|
58
|
+
{ chainHub, localchain, makeLocalChainFacade, makeRemoteChainFacade },
|
|
59
|
+
) =>
|
|
60
|
+
zone.exoClass(
|
|
61
|
+
'Orchestrator',
|
|
62
|
+
OrchestratorI,
|
|
63
|
+
() => {
|
|
64
|
+
trace('making an Orchestrator');
|
|
65
|
+
return {};
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
/** @type {Orchestrator['getChain']} */
|
|
69
|
+
getChain: async name => {
|
|
70
|
+
const agoricChainInfo = await chainHub.getChainInfo('agoric');
|
|
71
|
+
|
|
72
|
+
if (name === 'agoric') {
|
|
73
|
+
// @ts-expect-error XXX chainInfo generic
|
|
74
|
+
return makeLocalChainFacade(agoricChainInfo);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const remoteChainInfo = await chainHub.getChainInfo(name);
|
|
78
|
+
const connectionInfo = await chainHub.getConnectionInfo(
|
|
79
|
+
agoricChainInfo.chainId,
|
|
80
|
+
remoteChainInfo.chainId,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// @ts-expect-error XXX chainInfo generic
|
|
84
|
+
return makeRemoteChainFacade(remoteChainInfo, connectionInfo);
|
|
85
|
+
},
|
|
86
|
+
makeLocalAccount() {
|
|
87
|
+
return V(localchain).makeAccount();
|
|
88
|
+
},
|
|
89
|
+
getBrandInfo: () => Fail`not yet implemented`,
|
|
90
|
+
asAmount: () => Fail`not yet implemented`,
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
harden(prepareOrchestrator);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export function prepareRemoteChainFacade(zone: Zone, { makeCosmosOrchestrationAccount, orchestration, storageNode, timer }: {
|
|
2
|
+
makeCosmosOrchestrationAccount: (chainAddress: import("../orchestration-api.js").ChainAddress, bondDenom: string, io: {
|
|
3
|
+
account: import("../cosmos-api.js").IcaAccount;
|
|
4
|
+
storageNode: Remote<globalThis.StorageNode>;
|
|
5
|
+
icqConnection: import("@endo/exo").Guarded<{
|
|
6
|
+
getLocalAddress(): `/ibc-port/${string}`;
|
|
7
|
+
getRemoteAddress(): `/${string}ibc-port/${string}/ordered/${string}` | `/${string}ibc-port/${string}/unordered/${string}`;
|
|
8
|
+
query(msgs: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/tendermint/abci/types.js").RequestQuery>[]): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/tendermint/abci/types.js").ResponseQuery>[]>;
|
|
9
|
+
}> | undefined;
|
|
10
|
+
timer: Remote<TimerService>;
|
|
11
|
+
}) => import("@endo/exo").Guarded<{
|
|
12
|
+
asContinuingOffer(): {
|
|
13
|
+
publicSubscribers: {
|
|
14
|
+
account: {
|
|
15
|
+
description: string;
|
|
16
|
+
subscriber: globalThis.Subscriber<import("./cosmos-orchestration-account.js").ComosOrchestrationAccountNotification>;
|
|
17
|
+
storagePath: Promise<string>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
invitationMakers: import("@endo/exo").Guarded<{
|
|
21
|
+
Delegate(validator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Promise<Invitation<void, undefined>>;
|
|
22
|
+
Redelegate(srcValidator: import("../cosmos-api.js").CosmosValidatorAddress, dstValidator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Promise<Invitation<void, undefined>>;
|
|
23
|
+
WithdrawReward(validator: import("../cosmos-api.js").CosmosValidatorAddress): Promise<Invitation<import("../orchestration-api.js").DenomAmount[], undefined>>;
|
|
24
|
+
Undelegate(delegations: Omit<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js").Delegation, "delegatorAddress">[]): Promise<Invitation<void, undefined>>;
|
|
25
|
+
CloseAccount(): never;
|
|
26
|
+
TransferAccount(): never;
|
|
27
|
+
}>;
|
|
28
|
+
holder: import("@endo/exo").Guarded<any>;
|
|
29
|
+
};
|
|
30
|
+
getPublicTopics(): {
|
|
31
|
+
account: {
|
|
32
|
+
description: string;
|
|
33
|
+
subscriber: globalThis.Subscriber<import("./cosmos-orchestration-account.js").ComosOrchestrationAccountNotification>;
|
|
34
|
+
storagePath: Promise<string>;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
getAddress(): import("../orchestration-api.js").ChainAddress;
|
|
38
|
+
delegate(validator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Promise<void>;
|
|
39
|
+
deposit(payment: any): Promise<void>;
|
|
40
|
+
getBalances(): Promise<never>;
|
|
41
|
+
redelegate(srcValidator: import("../cosmos-api.js").CosmosValidatorAddress, dstValidator: import("../cosmos-api.js").CosmosValidatorAddress, amount: import("../orchestration-api.js").AmountArg): Promise<void>;
|
|
42
|
+
withdrawReward(validator: import("../cosmos-api.js").CosmosValidatorAddress): Promise<import("../orchestration-api.js").DenomAmount[]>;
|
|
43
|
+
getBalance(denom: import("../orchestration-api.js").DenomArg): Promise<import("../orchestration-api.js").DenomAmount>;
|
|
44
|
+
send(toAccount: any, amount: any): never;
|
|
45
|
+
transfer(amount: any, msg: any): never;
|
|
46
|
+
transferSteps(amount: any, msg: any): never;
|
|
47
|
+
withdrawRewards(): never;
|
|
48
|
+
undelegate(delegations: Omit<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js").Delegation, "delegatorAddress">[]): Promise<void>;
|
|
49
|
+
}>;
|
|
50
|
+
orchestration: Remote<import("@endo/exo").Guarded<{
|
|
51
|
+
makeAccount(chainId: string, hostConnectionId: `connection-${number}`, controllerConnectionId: `connection-${number}`): Promise<import("../cosmos-api.js").IcaAccount>;
|
|
52
|
+
provideICQConnection(controllerConnectionId: `connection-${number}`): Promise<import("@endo/exo").Guarded<{
|
|
53
|
+
getLocalAddress(): `/ibc-port/${string}`;
|
|
54
|
+
getRemoteAddress(): `/${string}ibc-port/${string}/ordered/${string}` | `/${string}ibc-port/${string}/unordered/${string}`;
|
|
55
|
+
query(msgs: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/tendermint/abci/types.js").RequestQuery>[]): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/tendermint/abci/types.js").ResponseQuery>[]>;
|
|
56
|
+
}>>;
|
|
57
|
+
}>>;
|
|
58
|
+
storageNode: Remote<globalThis.StorageNode>;
|
|
59
|
+
timer: Remote<TimerService>;
|
|
60
|
+
}): (remoteChainInfo: Readonly<{
|
|
61
|
+
chainId: string;
|
|
62
|
+
connections?: Record<string, IBCConnectionInfo> | undefined;
|
|
63
|
+
icqEnabled?: boolean | undefined;
|
|
64
|
+
stakingTokens?: readonly {
|
|
65
|
+
denom: string;
|
|
66
|
+
}[] | undefined;
|
|
67
|
+
}>, connectionInfo: IBCConnectionInfo) => import("@endo/exo").Guarded<{
|
|
68
|
+
getChainInfo(): Promise<Readonly<{
|
|
69
|
+
chainId: string;
|
|
70
|
+
connections?: Record<string, IBCConnectionInfo> | undefined;
|
|
71
|
+
icqEnabled?: boolean | undefined;
|
|
72
|
+
stakingTokens?: readonly {
|
|
73
|
+
denom: string;
|
|
74
|
+
}[] | undefined;
|
|
75
|
+
}>>;
|
|
76
|
+
/** @returns {Promise<OrchestrationAccount<ChainInfo>>} */
|
|
77
|
+
makeAccount(): Promise<import("../orchestration-api.js").OrchestrationAccountI>;
|
|
78
|
+
}>;
|
|
79
|
+
export type MakeRemoteChainFacade = ReturnType<typeof prepareRemoteChainFacade>;
|
|
80
|
+
import type { Zone } from '@agoric/base-zone';
|
|
81
|
+
import type { Remote } from '@agoric/internal';
|
|
82
|
+
import type { TimerService } from '@agoric/time';
|
|
83
|
+
import type { IBCConnectionInfo } from '../types.js';
|
|
84
|
+
//# 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":"AAgCO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsBD,0DAA0D;;GAwB7D;oCAEW,UAAU,CAAC,OAAO,wBAAwB,CAAC;0BAzElC,mBAAmB;4BAEjB,kBAAkB;kCADZ,cAAc;uCAIyC,aAAa"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** @file ChainAccount exo */
|
|
2
|
+
import { makeTracer } from '@agoric/internal';
|
|
3
|
+
import { V } from '@agoric/vow/vat.js';
|
|
4
|
+
|
|
5
|
+
import { ChainFacadeI } from '../typeGuards.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @import {Zone} from '@agoric/base-zone';
|
|
9
|
+
* @import {TimerService} from '@agoric/time';
|
|
10
|
+
* @import {Remote} from '@agoric/internal';
|
|
11
|
+
* @import {OrchestrationService} from '../service.js';
|
|
12
|
+
* @import {prepareCosmosOrchestrationAccount} from './cosmos-orchestration-account.js';
|
|
13
|
+
* @import {ChainInfo, CosmosChainInfo, IBCConnectionInfo, OrchestrationAccount} from '../types.js';
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const { Fail } = assert;
|
|
17
|
+
const trace = makeTracer('RemoteChainFacade');
|
|
18
|
+
|
|
19
|
+
/** @type {any} */
|
|
20
|
+
const anyVal = null;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {Zone} zone
|
|
24
|
+
* @param {{
|
|
25
|
+
* makeCosmosOrchestrationAccount: ReturnType<
|
|
26
|
+
* typeof prepareCosmosOrchestrationAccount
|
|
27
|
+
* >;
|
|
28
|
+
* orchestration: Remote<OrchestrationService>;
|
|
29
|
+
* storageNode: Remote<StorageNode>;
|
|
30
|
+
* timer: Remote<TimerService>;
|
|
31
|
+
* }} powers
|
|
32
|
+
*/
|
|
33
|
+
export const prepareRemoteChainFacade = (
|
|
34
|
+
zone,
|
|
35
|
+
{ makeCosmosOrchestrationAccount, orchestration, storageNode, timer },
|
|
36
|
+
) =>
|
|
37
|
+
zone.exoClass(
|
|
38
|
+
'RemoteChainFacade',
|
|
39
|
+
ChainFacadeI,
|
|
40
|
+
/**
|
|
41
|
+
* @param {CosmosChainInfo} remoteChainInfo
|
|
42
|
+
* @param {IBCConnectionInfo} connectionInfo
|
|
43
|
+
*/
|
|
44
|
+
(remoteChainInfo, connectionInfo) => {
|
|
45
|
+
trace('making an RemoteChainFacade');
|
|
46
|
+
return { remoteChainInfo, connectionInfo };
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
async getChainInfo() {
|
|
50
|
+
return this.state.remoteChainInfo;
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
// FIXME parameterize on the remoteChainInfo to make()
|
|
54
|
+
// That used to work but got lost in the migration to Exo
|
|
55
|
+
/** @returns {Promise<OrchestrationAccount<ChainInfo>>} */
|
|
56
|
+
async makeAccount() {
|
|
57
|
+
const { remoteChainInfo, connectionInfo } = this.state;
|
|
58
|
+
|
|
59
|
+
const icaAccount = await V(orchestration).makeAccount(
|
|
60
|
+
remoteChainInfo.chainId,
|
|
61
|
+
connectionInfo.id,
|
|
62
|
+
connectionInfo.counterparty.connection_id,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const address = await V(icaAccount).getAddress();
|
|
66
|
+
|
|
67
|
+
const stakingDenom = remoteChainInfo.stakingTokens?.[0]?.denom;
|
|
68
|
+
if (!stakingDenom) {
|
|
69
|
+
throw Fail`chain info lacks staking denom`;
|
|
70
|
+
}
|
|
71
|
+
return makeCosmosOrchestrationAccount(address, stakingDenom, {
|
|
72
|
+
account: icaAccount,
|
|
73
|
+
storageNode,
|
|
74
|
+
icqConnection: anyVal,
|
|
75
|
+
timer,
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
harden(prepareRemoteChainFacade);
|
|
81
|
+
/** @typedef {ReturnType<typeof prepareRemoteChainFacade>} MakeRemoteChainFacade */
|
package/src/facade.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode, orchestrationService, localchain, chainHub,
|
|
1
|
+
export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode, orchestrationService, localchain, chainHub, makeLocalOrchestrationAccountKit, makeRecorderKit, makeLocalChainFacade, makeRemoteChainFacade, asyncFlowTools, }: {
|
|
2
2
|
zone: Zone;
|
|
3
3
|
timerService: Remote<TimerService>;
|
|
4
4
|
zcf: ZCF;
|
|
@@ -35,8 +35,90 @@ export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode,
|
|
|
35
35
|
}>; }>;
|
|
36
36
|
}>>;
|
|
37
37
|
chainHub: import("./utils/chainHub.js").ChainHub;
|
|
38
|
-
|
|
38
|
+
makeLocalOrchestrationAccountKit: (args_0: {
|
|
39
|
+
account: import("@endo/exo").Guarded<{
|
|
40
|
+
getAddress(): string;
|
|
41
|
+
getBalance(brand: Brand<"nat">): import("@agoric/vow").PromiseVow<import("@agoric/ertp/src/types.js").NatAmount>;
|
|
42
|
+
deposit(payment: Payment<"nat">, optAmountShape?: Pattern): import("@agoric/vow").PromiseVow<import("@agoric/ertp/src/types.js").NatAmount>;
|
|
43
|
+
withdraw(amount: Amount<"nat">): import("@agoric/vow").PromiseVow<globalThis.Payment<"nat">>;
|
|
44
|
+
executeTx<MT extends {
|
|
45
|
+
'@type': string;
|
|
46
|
+
}[]>(messages: MT): import("@agoric/vats/src/localchain.js").PromiseVowOfTupleMappedToGenerics<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
|
|
47
|
+
monitorTransfers(tap: import("@agoric/vats/src/bridge-target.js").TargetApp): import("@agoric/vow").PromiseVow<import("@agoric/vats/src/bridge-target.js").TargetRegistration>;
|
|
48
|
+
}>;
|
|
49
|
+
address: import("./orchestration-api.js").ChainAddress;
|
|
50
|
+
storageNode: Remote<globalThis.StorageNode>;
|
|
51
|
+
}) => import("@endo/exo").GuardedKit<{
|
|
52
|
+
invitationMakers: {
|
|
53
|
+
Delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
54
|
+
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
55
|
+
}>, undefined>>;
|
|
56
|
+
Undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<void, undefined>>;
|
|
57
|
+
CloseAccount(): never;
|
|
58
|
+
};
|
|
59
|
+
holder: {
|
|
60
|
+
getBalance(denom: DenomArg): Promise<import("./orchestration-api.js").DenomAmount>;
|
|
61
|
+
getBalances(): never;
|
|
62
|
+
getPublicTopics(): {
|
|
63
|
+
account: {
|
|
64
|
+
description: string;
|
|
65
|
+
subscriber: globalThis.Subscriber<import("./exos/local-orchestration-account.js").LocalChainAccountNotification>;
|
|
66
|
+
storagePath: Promise<string>;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
70
|
+
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
71
|
+
}>>;
|
|
72
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<void>;
|
|
73
|
+
deposit(payment: globalThis.Payment<"nat">): Promise<void>;
|
|
74
|
+
withdraw(amount: Amount<"nat">): import("@agoric/vow").PromiseVow<globalThis.Payment<"nat">>;
|
|
75
|
+
executeTx<MT extends {
|
|
76
|
+
'@type': string;
|
|
77
|
+
}[]>(messages: MT): import("@agoric/vats/src/localchain.js").PromiseVowOfTupleMappedToGenerics<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
|
|
78
|
+
getAddress(): import("./orchestration-api.js").ChainAddress;
|
|
79
|
+
send(toAccount: any, amount: any): Promise<void>;
|
|
80
|
+
transfer(amount: import("./orchestration-api.js").AmountArg, destination: import("./orchestration-api.js").ChainAddress, opts?: import("./cosmos-api.js").IBCMsgTransferOptions | undefined): Promise<void>;
|
|
81
|
+
transferSteps(amount: AmountArg, msg: TransferMsg): Promise<void>;
|
|
82
|
+
};
|
|
83
|
+
}>;
|
|
39
84
|
makeRecorderKit: <T_1>(storageNode: StorageNode | Awaited<import("@endo/far").FarRef<StorageNode>>, valueShape?: import("@agoric/zoe/src/contractSupport/recorder.js").TypedMatcher<T_1> | undefined) => RecorderKit<T_1>;
|
|
85
|
+
makeCosmosOrchestrationAccount: any;
|
|
86
|
+
makeLocalChainFacade: (localChainInfo: Readonly<{
|
|
87
|
+
chainId: string;
|
|
88
|
+
connections?: Record<string, IBCConnectionInfo> | undefined;
|
|
89
|
+
icqEnabled?: boolean | undefined;
|
|
90
|
+
stakingTokens?: readonly {
|
|
91
|
+
denom: string;
|
|
92
|
+
}[] | undefined;
|
|
93
|
+
}>) => import("@endo/exo").Guarded<{
|
|
94
|
+
getChainInfo(): Promise<Readonly<{
|
|
95
|
+
chainId: string;
|
|
96
|
+
connections?: Record<string, IBCConnectionInfo> | undefined;
|
|
97
|
+
icqEnabled?: boolean | undefined;
|
|
98
|
+
stakingTokens?: readonly {
|
|
99
|
+
denom: string;
|
|
100
|
+
}[] | undefined;
|
|
101
|
+
}>>;
|
|
102
|
+
makeAccount(): Promise<import("./orchestration-api.js").OrchestrationAccountI>;
|
|
103
|
+
}>;
|
|
104
|
+
makeRemoteChainFacade: (remoteChainInfo: Readonly<{
|
|
105
|
+
chainId: string;
|
|
106
|
+
connections?: Record<string, IBCConnectionInfo> | undefined;
|
|
107
|
+
icqEnabled?: boolean | undefined;
|
|
108
|
+
stakingTokens?: readonly {
|
|
109
|
+
denom: string;
|
|
110
|
+
}[] | undefined;
|
|
111
|
+
}>, connectionInfo: IBCConnectionInfo) => import("@endo/exo").Guarded<{
|
|
112
|
+
getChainInfo(): Promise<Readonly<{
|
|
113
|
+
chainId: string;
|
|
114
|
+
connections?: Record<string, IBCConnectionInfo> | undefined;
|
|
115
|
+
icqEnabled?: boolean | undefined;
|
|
116
|
+
stakingTokens?: readonly {
|
|
117
|
+
denom: string;
|
|
118
|
+
}[] | undefined;
|
|
119
|
+
}>>;
|
|
120
|
+
makeAccount(): Promise<import("./orchestration-api.js").OrchestrationAccountI>;
|
|
121
|
+
}>;
|
|
40
122
|
asyncFlowTools: {
|
|
41
123
|
prepareAsyncFlowKit: (zone: Zone, tag: string, guestAsyncFunc: import("../../../node_modules/@agoric/async-flow/src/types.js").GuestAsyncFunc, options?: {
|
|
42
124
|
startEager?: boolean | undefined;
|
|
@@ -45,8 +127,8 @@ export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode,
|
|
|
45
127
|
getFlowState(): import("../../../node_modules/@agoric/async-flow/src/types.js").FlowState;
|
|
46
128
|
restart(eager?: boolean | undefined): void;
|
|
47
129
|
wake(): void;
|
|
48
|
-
getOutcome():
|
|
49
|
-
dump(): ([op: "doFulfill", vow:
|
|
130
|
+
getOutcome(): Vow<any>;
|
|
131
|
+
dump(): ([op: "doFulfill", vow: Vow<import("@endo/pass-style").Passable>, fulfillment: import("@endo/pass-style").Passable] | [op: "doReject", vow: Vow<import("@endo/pass-style").Passable>, reason: import("@endo/pass-style").Passable] | [op: "doReturn", callIndex: number, result: import("@endo/pass-style").Passable] | [op: "doThrow", callIndex: number, problem: import("@endo/pass-style").Passable] | [op: "checkCall", target: import("@endo/pass-style").Passable, optVerb: PropertyKey | undefined, args: import("@endo/pass-style").Passable[], callIndex: number])[];
|
|
50
132
|
getOptFatalProblem(): any;
|
|
51
133
|
};
|
|
52
134
|
admin: {
|
|
@@ -86,5 +168,7 @@ import type { Zone } from '@agoric/zone';
|
|
|
86
168
|
import type { TimerService } from '@agoric/time';
|
|
87
169
|
import type { Remote } from '@agoric/internal';
|
|
88
170
|
import type { RecorderKit } from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
171
|
+
import type { IBCConnectionInfo } from './types.js';
|
|
172
|
+
import type { Vow } from '@agoric/vow';
|
|
89
173
|
import type { Orchestrator } from './types.js';
|
|
90
174
|
//# sourceMappingURL=facade.d.ts.map
|
package/src/facade.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["facade.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["facade.js"],"names":[],"mappings":"AAuCO;;;SAbG,GAAG;;;;;;;;;;;;;8BAyEiH,MAAM,KAAK,CAAC;6BAA6gB,QAAQ,KAAK,CAAC,mBAA6B,OAAO;6BAAwjB,OAAO,KAAK,CAAC;;;2BAA6rB,EAAE;;;;;;;oBAAqjG,CAAC;;;uBAA6lB,EAAE;;;;;cArEnlL,OAAO,qBAAqB,EAAE,QAAQ;;;;8BAqEyE,MAAM,KAAK,CAAC;6BAA6gB,QAAQ,KAAK,CAAC,mBAA6B,OAAO;6BAAwjB,OAAO,KAAK,CAAC;;;2BAA6rB,EAAE;;;;;;;2DAAxlD,OAAO,KAAK,CAAC;;;6DAAid,OAAO,KAAK,CAAC;;;;8BAA0tB,QAAS;;;;;;;;;2DAAiyB,OAAO,KAAK,CAAC;;;6DAA+yB,OAAO,KAAK,CAAC;;6BAA56D,OAAO,KAAK,CAAC;;;2BAA6rB,EAAE;;;;kCAA46B,SAAU,OAAM,WAAY;;;wCAA/xC,WAAW,GAAE,QAAS,OAAO,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;oCAlE/oD,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgDpC;;;;;;;;OAQG;gBAFkC,OAAO,EACrB,IAAI,6BAJhB,MAAM,OAGoB,OAAO,AAD1B,gCACmB,OAAO,WACrB,IAAI,AADgC,KAAK,MAAM,GACzD,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,OAAO,CAAC;EAQnD;kCAEa,UAAU,CAAC,OAAO,uBAAuB,CAAC;0BA1FjC,cAAc;kCAEN,cAAc;4BAIpB,kBAAkB;iCADI,6CAA6C;uCAGe,YAAY;yBAPjG,aAAa;kCAOwE,YAAY"}
|
package/src/facade.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/** @file Orchestration service */
|
|
2
2
|
|
|
3
|
-
import { V as E } from '@agoric/vow/vat.js';
|
|
4
3
|
import { Fail } from '@agoric/assert';
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
import { prepareOrchestrator } from './exos/orchestrator.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @import {AsyncFlowTools} from '@agoric/async-flow';
|
|
9
9
|
* @import {Zone} from '@agoric/zone';
|
|
10
|
+
* @import {Vow} from '@agoric/vow';
|
|
10
11
|
* @import {TimerService} from '@agoric/time';
|
|
11
12
|
* @import {IBCConnectionID} from '@agoric/vats';
|
|
12
13
|
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
|
|
@@ -14,137 +15,11 @@ import { prepareCosmosOrchestrationAccount } from './exos/cosmosOrchestrationAcc
|
|
|
14
15
|
* @import {Remote} from '@agoric/internal';
|
|
15
16
|
* @import {OrchestrationService} from './service.js';
|
|
16
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';
|
|
17
21
|
*/
|
|
18
22
|
|
|
19
|
-
/** @type {any} */
|
|
20
|
-
const anyVal = null;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @param {Remote<LocalChain>} localchain
|
|
24
|
-
* @param {ReturnType<
|
|
25
|
-
* typeof import('./exos/local-chain-account-kit.js').prepareLocalChainAccountKit
|
|
26
|
-
* >} makeLocalChainAccountKit
|
|
27
|
-
* @param {ChainInfo} localInfo
|
|
28
|
-
* @returns {Chain}
|
|
29
|
-
*/
|
|
30
|
-
const makeLocalChainFacade = (
|
|
31
|
-
localchain,
|
|
32
|
-
makeLocalChainAccountKit,
|
|
33
|
-
localInfo,
|
|
34
|
-
) => {
|
|
35
|
-
return {
|
|
36
|
-
/** @returns {Promise<ChainInfo>} */
|
|
37
|
-
async getChainInfo() {
|
|
38
|
-
return localInfo;
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
async makeAccount() {
|
|
42
|
-
const lcaP = E(localchain).makeAccount();
|
|
43
|
-
const [lca, address] = await Promise.all([lcaP, E(lcaP).getAddress()]);
|
|
44
|
-
const { holder: account } = makeLocalChainAccountKit({
|
|
45
|
-
account: lca,
|
|
46
|
-
address,
|
|
47
|
-
// @ts-expect-error TODO: Remote
|
|
48
|
-
storageNode: null,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
async deposit(payment) {
|
|
53
|
-
console.log('deposit got', payment);
|
|
54
|
-
await E(account).deposit(payment);
|
|
55
|
-
},
|
|
56
|
-
getAddress() {
|
|
57
|
-
const addressStr = account.getAddress();
|
|
58
|
-
return {
|
|
59
|
-
address: addressStr,
|
|
60
|
-
chainId: localInfo.chainId,
|
|
61
|
-
addressEncoding: 'bech32',
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
async getBalance(denomArg) {
|
|
65
|
-
// FIXME look up real values
|
|
66
|
-
// UNTIL https://github.com/Agoric/agoric-sdk/issues/9211
|
|
67
|
-
const [brand, denom] =
|
|
68
|
-
typeof denomArg === 'string'
|
|
69
|
-
? [/** @type {any} */ (null), denomArg]
|
|
70
|
-
: [denomArg, 'FIXME'];
|
|
71
|
-
|
|
72
|
-
const natAmount = await E(lca).getBalance(brand);
|
|
73
|
-
return harden({ denom, value: natAmount.value });
|
|
74
|
-
},
|
|
75
|
-
getBalances() {
|
|
76
|
-
throw new Error('not yet implemented');
|
|
77
|
-
},
|
|
78
|
-
async send(toAccount, amount) {
|
|
79
|
-
// FIXME implement
|
|
80
|
-
console.log('send got', toAccount, amount);
|
|
81
|
-
},
|
|
82
|
-
async transfer(amount, destination, opts) {
|
|
83
|
-
console.log('transfer got', amount, destination, opts);
|
|
84
|
-
return account.transfer(amount, destination, opts);
|
|
85
|
-
},
|
|
86
|
-
transferSteps(amount, msg) {
|
|
87
|
-
console.log('transferSteps got', amount, msg);
|
|
88
|
-
return Promise.resolve();
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @template {CosmosChainInfo} CCI
|
|
97
|
-
* @param {CCI} chainInfo
|
|
98
|
-
* @param {IBCConnectionInfo} connectionInfo
|
|
99
|
-
* @param {object} io
|
|
100
|
-
* @param {Remote<OrchestrationService>} io.orchestration
|
|
101
|
-
* @param {MakeRecorderKit} io.makeRecorderKit
|
|
102
|
-
* @param {Remote<StorageNode>} io.storageNode
|
|
103
|
-
* @param {Remote<TimerService>} io.timer
|
|
104
|
-
* @param {ZCF} io.zcf
|
|
105
|
-
* @param {Zone} io.zone
|
|
106
|
-
* @returns {Chain<CCI>}
|
|
107
|
-
*/
|
|
108
|
-
const makeRemoteChainFacade = (
|
|
109
|
-
chainInfo,
|
|
110
|
-
connectionInfo,
|
|
111
|
-
{ orchestration, makeRecorderKit, storageNode, timer, zcf, zone },
|
|
112
|
-
) => {
|
|
113
|
-
const makeCosmosOrchestrationAccount = prepareCosmosOrchestrationAccount(
|
|
114
|
-
zone.subZone(chainInfo.chainId),
|
|
115
|
-
makeRecorderKit,
|
|
116
|
-
zcf,
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
getChainInfo: async () => chainInfo,
|
|
121
|
-
/** @returns {Promise<OrchestrationAccount<CCI>>} */
|
|
122
|
-
makeAccount: async () => {
|
|
123
|
-
const icaAccount = await E(orchestration).makeAccount(
|
|
124
|
-
chainInfo.chainId,
|
|
125
|
-
connectionInfo.id,
|
|
126
|
-
connectionInfo.counterparty.connection_id,
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
const address = await E(icaAccount).getAddress();
|
|
130
|
-
|
|
131
|
-
const [{ denom: bondDenom }] = chainInfo.stakingTokens || [
|
|
132
|
-
{
|
|
133
|
-
denom: null,
|
|
134
|
-
},
|
|
135
|
-
];
|
|
136
|
-
assert(bondDenom, 'missing bondDenom');
|
|
137
|
-
// @ts-expect-error XXX dynamic method availability
|
|
138
|
-
return makeCosmosOrchestrationAccount(address, bondDenom, {
|
|
139
|
-
account: icaAccount,
|
|
140
|
-
storageNode,
|
|
141
|
-
icqConnection: anyVal,
|
|
142
|
-
timer,
|
|
143
|
-
});
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
|
|
148
23
|
/**
|
|
149
24
|
* @param {{
|
|
150
25
|
* zone: Zone;
|
|
@@ -154,10 +29,11 @@ const makeRemoteChainFacade = (
|
|
|
154
29
|
* orchestrationService: Remote<OrchestrationService>;
|
|
155
30
|
* localchain: Remote<LocalChain>;
|
|
156
31
|
* chainHub: import('./utils/chainHub.js').ChainHub;
|
|
157
|
-
*
|
|
158
|
-
* typeof import('./exos/local-chain-account-kit.js').prepareLocalChainAccountKit
|
|
159
|
-
* >;
|
|
32
|
+
* makeLocalOrchestrationAccountKit: MakeLocalOrchestrationAccountKit;
|
|
160
33
|
* makeRecorderKit: MakeRecorderKit;
|
|
34
|
+
* makeCosmosOrchestrationAccount: any;
|
|
35
|
+
* makeLocalChainFacade: MakeLocalChainFacade;
|
|
36
|
+
* makeRemoteChainFacade: MakeRemoteChainFacade;
|
|
161
37
|
* asyncFlowTools: AsyncFlowTools;
|
|
162
38
|
* }} powers
|
|
163
39
|
*/
|
|
@@ -169,8 +45,10 @@ export const makeOrchestrationFacade = ({
|
|
|
169
45
|
orchestrationService,
|
|
170
46
|
localchain,
|
|
171
47
|
chainHub,
|
|
172
|
-
|
|
48
|
+
makeLocalOrchestrationAccountKit,
|
|
173
49
|
makeRecorderKit,
|
|
50
|
+
makeLocalChainFacade,
|
|
51
|
+
makeRemoteChainFacade,
|
|
174
52
|
asyncFlowTools,
|
|
175
53
|
}) => {
|
|
176
54
|
(zone &&
|
|
@@ -179,12 +57,27 @@ export const makeOrchestrationFacade = ({
|
|
|
179
57
|
storageNode &&
|
|
180
58
|
orchestrationService &&
|
|
181
59
|
// @ts-expect-error type says defined but double check
|
|
182
|
-
|
|
60
|
+
makeLocalOrchestrationAccountKit &&
|
|
183
61
|
// @ts-expect-error type says defined but double check
|
|
184
62
|
makeRecorderKit &&
|
|
63
|
+
// @ts-expect-error type says defined but double check
|
|
64
|
+
makeRemoteChainFacade &&
|
|
185
65
|
asyncFlowTools) ||
|
|
186
66
|
Fail`params missing`;
|
|
187
67
|
|
|
68
|
+
const makeOrchestrator = prepareOrchestrator(zone, {
|
|
69
|
+
asyncFlowTools,
|
|
70
|
+
chainHub,
|
|
71
|
+
localchain,
|
|
72
|
+
makeRecorderKit,
|
|
73
|
+
makeLocalChainFacade,
|
|
74
|
+
makeRemoteChainFacade,
|
|
75
|
+
orchestrationService,
|
|
76
|
+
storageNode,
|
|
77
|
+
timerService,
|
|
78
|
+
zcf,
|
|
79
|
+
});
|
|
80
|
+
|
|
188
81
|
return {
|
|
189
82
|
/**
|
|
190
83
|
* @template Context
|
|
@@ -196,40 +89,8 @@ export const makeOrchestrationFacade = ({
|
|
|
196
89
|
* @returns {(...args: Args) => Promise<unknown>}
|
|
197
90
|
*/
|
|
198
91
|
orchestrate(durableName, ctx, fn) {
|
|
199
|
-
|
|
200
|
-
const orc = {
|
|
201
|
-
async getChain(name) {
|
|
202
|
-
const agoricChainInfo = await chainHub.getChainInfo('agoric');
|
|
203
|
-
|
|
204
|
-
if (name === 'agoric') {
|
|
205
|
-
return makeLocalChainFacade(
|
|
206
|
-
localchain,
|
|
207
|
-
makeLocalChainAccountKit,
|
|
208
|
-
agoricChainInfo,
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const remoteChainInfo = await chainHub.getChainInfo(name);
|
|
213
|
-
const connectionInfo = await chainHub.getConnectionInfo(
|
|
214
|
-
agoricChainInfo.chainId,
|
|
215
|
-
remoteChainInfo.chainId,
|
|
216
|
-
);
|
|
92
|
+
const orc = makeOrchestrator();
|
|
217
93
|
|
|
218
|
-
return makeRemoteChainFacade(remoteChainInfo, connectionInfo, {
|
|
219
|
-
orchestration: orchestrationService,
|
|
220
|
-
makeRecorderKit,
|
|
221
|
-
storageNode,
|
|
222
|
-
timer: timerService,
|
|
223
|
-
zcf,
|
|
224
|
-
zone,
|
|
225
|
-
});
|
|
226
|
-
},
|
|
227
|
-
makeLocalAccount() {
|
|
228
|
-
return E(localchain).makeAccount();
|
|
229
|
-
},
|
|
230
|
-
getBrandInfo: anyVal,
|
|
231
|
-
asAmount: anyVal,
|
|
232
|
-
};
|
|
233
94
|
return async (...args) => fn(orc, ctx, ...args);
|
|
234
95
|
},
|
|
235
96
|
};
|