@agoric/orchestration 0.1.1-dev-980ff41.0 → 0.1.1-dev-8343a0c.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 +15 -15
- package/src/examples/swapExample.contract.d.ts +34 -2
- package/src/examples/swapExample.contract.d.ts.map +1 -1
- package/src/examples/swapExample.contract.js +42 -17
- package/src/examples/unbondExample.contract.d.ts +19 -1
- package/src/examples/unbondExample.contract.d.ts.map +1 -1
- package/src/examples/unbondExample.contract.js +8 -8
- package/src/facade.d.ts +24 -5
- package/src/facade.d.ts.map +1 -1
- package/src/facade.js +143 -4
- package/src/utils/orc.d.ts +1 -0
- package/src/utils/orc.d.ts.map +1 -1
- package/src/utils/orc.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/orchestration",
|
|
3
|
-
"version": "0.1.1-dev-
|
|
3
|
+
"version": "0.1.1-dev-8343a0c.0+8343a0c",
|
|
4
4
|
"description": "Chain abstraction for Agoric's orchestration clients",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -31,19 +31,19 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/Agoric/agoric-sdk#readme",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@agoric/assert": "0.6.1-dev-
|
|
35
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
36
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
37
|
-
"@agoric/internal": "0.3.3-dev-
|
|
38
|
-
"@agoric/network": "0.1.1-dev-
|
|
39
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
40
|
-
"@agoric/store": "0.9.3-dev-
|
|
41
|
-
"@agoric/time": "0.3.3-dev-
|
|
42
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
43
|
-
"@agoric/vats": "0.15.2-dev-
|
|
44
|
-
"@agoric/vow": "0.1.1-dev-
|
|
45
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
46
|
-
"@agoric/zone": "0.2.3-dev-
|
|
34
|
+
"@agoric/assert": "0.6.1-dev-8343a0c.0+8343a0c",
|
|
35
|
+
"@agoric/cosmic-proto": "0.4.1-dev-8343a0c.0+8343a0c",
|
|
36
|
+
"@agoric/ertp": "0.16.3-dev-8343a0c.0+8343a0c",
|
|
37
|
+
"@agoric/internal": "0.3.3-dev-8343a0c.0+8343a0c",
|
|
38
|
+
"@agoric/network": "0.1.1-dev-8343a0c.0+8343a0c",
|
|
39
|
+
"@agoric/notifier": "0.6.3-dev-8343a0c.0+8343a0c",
|
|
40
|
+
"@agoric/store": "0.9.3-dev-8343a0c.0+8343a0c",
|
|
41
|
+
"@agoric/time": "0.3.3-dev-8343a0c.0+8343a0c",
|
|
42
|
+
"@agoric/vat-data": "0.5.3-dev-8343a0c.0+8343a0c",
|
|
43
|
+
"@agoric/vats": "0.15.2-dev-8343a0c.0+8343a0c",
|
|
44
|
+
"@agoric/vow": "0.1.1-dev-8343a0c.0+8343a0c",
|
|
45
|
+
"@agoric/zoe": "0.26.3-dev-8343a0c.0+8343a0c",
|
|
46
|
+
"@agoric/zone": "0.2.3-dev-8343a0c.0+8343a0c",
|
|
47
47
|
"@endo/base64": "^1.0.5",
|
|
48
48
|
"@endo/far": "^1.1.2",
|
|
49
49
|
"@endo/marshal": "^1.5.0",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"typeCoverage": {
|
|
86
86
|
"atLeast": 97.38
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "8343a0ca16603ce52aeb4818d4dbf2529b9a59f7"
|
|
89
89
|
}
|
|
@@ -1,4 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Orchestrator, IcaAccount, CosmosValidatorAddress} from '../types.js'
|
|
3
|
+
* @import {TimerService} from '@agoric/time';
|
|
4
|
+
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
|
|
5
|
+
* @import {ERef} from '@endo/far'
|
|
6
|
+
* @import {OrchestrationService} from '../service.js';
|
|
7
|
+
* @import {Zone} from '@agoric/zone';
|
|
8
|
+
*/
|
|
9
|
+
/** @type {ContractMeta} */
|
|
10
|
+
export const meta: ContractMeta;
|
|
11
|
+
export function makeNatAmountShape(brand: Brand, min?: bigint | undefined): {
|
|
12
|
+
brand: globalThis.Brand;
|
|
13
|
+
value: import("@endo/patterns").Matcher;
|
|
14
|
+
};
|
|
1
15
|
export function start(zcf: ZCF, privateArgs: {
|
|
16
|
+
localchain: ERef<import("@endo/exo").Guarded<{
|
|
17
|
+
makeAccount(): Promise<import("@endo/exo").Guarded<{
|
|
18
|
+
getAddress(): Promise<string>;
|
|
19
|
+
deposit(payment: Payment): Promise<import("@agoric/ertp/src/types.js").NatAmount | import("@agoric/ertp/src/types.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/src/types.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/src/types.js").CopyBagAmount<import("@endo/patterns").Key>>;
|
|
20
|
+
executeTx<MT extends {
|
|
21
|
+
'@type': string;
|
|
22
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]>; }>;
|
|
23
|
+
}>>;
|
|
24
|
+
query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
|
|
25
|
+
'@type': string;
|
|
26
|
+
}>;
|
|
27
|
+
queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
|
|
28
|
+
error?: string | undefined;
|
|
29
|
+
reply: {
|
|
30
|
+
'@type': string;
|
|
31
|
+
};
|
|
32
|
+
}[]>;
|
|
33
|
+
}>>;
|
|
2
34
|
orchestrationService: ERef<import("@endo/exo").Guarded<{
|
|
3
35
|
makeAccount(hostConnectionId: `connection-${number}`, controllerConnectionId: `connection-${number}`): Promise<IcaAccount>;
|
|
4
36
|
provideICQConnection(controllerConnectionId: `connection-${number}`): Promise<import("@endo/exo").Guarded<{
|
|
@@ -16,15 +48,15 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
16
48
|
staked: Amount<"nat">;
|
|
17
49
|
validator: CosmosValidatorAddress;
|
|
18
50
|
}>>;
|
|
19
|
-
} & import("@endo/
|
|
51
|
+
} & import("@endo/marshal").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
20
52
|
makeSwapAndStakeInvitation: () => Promise<Invitation<unknown, {
|
|
21
53
|
staked: Amount<"nat">;
|
|
22
54
|
validator: CosmosValidatorAddress;
|
|
23
55
|
}>>;
|
|
24
56
|
}>;
|
|
25
57
|
}>;
|
|
26
|
-
import type { IcaAccount } from '../types.js';
|
|
27
58
|
import type { ERef } from '@endo/far';
|
|
59
|
+
import type { IcaAccount } from '../types.js';
|
|
28
60
|
import type { TimerService } from '@agoric/time';
|
|
29
61
|
import type { Zone } from '@agoric/zone';
|
|
30
62
|
import type { CosmosValidatorAddress } from '../types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swapExample.contract.d.ts","sourceRoot":"","sources":["swapExample.contract.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"swapExample.contract.d.ts","sourceRoot":"","sources":["swapExample.contract.js"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AAEH,2BAA2B;AAC3B,mBADW,YAAY,CAUrB;AASK,0CAHI,KAAK;;;EAIsC;AAY/C,2BATI,GAAG;;;;6BAUH,OAAO;;;2BAmB4D,EAAE;;uBAyD8a,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;;;;;;;;;;;;;;oBA7D7sC,MAAM,CAAC,KAAK,CAAC;;;;;oBAAb,MAAM,CAAC,KAAK,CAAC;;;;GA4DxD;0BAjHsB,WAAW;gCAHiC,aAAa;kCACjD,cAAc;0BAItB,cAAc;4CAL8B,aAAa"}
|
|
@@ -1,21 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { StorageNodeShape } from '@agoric/internal';
|
|
2
|
+
import { withdrawFromSeat } from '@agoric/zoe/src/contractSupport/zoeHelpers.js';
|
|
3
|
+
import { Far } from '@endo/far';
|
|
4
|
+
import { deeplyFulfilled } from '@endo/marshal';
|
|
5
|
+
import { M, objectMap } from '@endo/patterns';
|
|
5
6
|
import { makeOrchestrationFacade } from '../facade.js';
|
|
6
7
|
import { orcUtils } from '../utils/orc.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @import {Orchestrator, IcaAccount, CosmosValidatorAddress} from '../types.js'
|
|
10
11
|
* @import {TimerService} from '@agoric/time';
|
|
12
|
+
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
|
|
11
13
|
* @import {ERef} from '@endo/far'
|
|
12
14
|
* @import {OrchestrationService} from '../service.js';
|
|
13
15
|
* @import {Zone} from '@agoric/zone';
|
|
14
16
|
*/
|
|
15
17
|
|
|
18
|
+
/** @type {ContractMeta} */
|
|
19
|
+
export const meta = {
|
|
20
|
+
privateArgsShape: {
|
|
21
|
+
localchain: M.any(),
|
|
22
|
+
orchestrationService: M.any(),
|
|
23
|
+
storageNode: StorageNodeShape,
|
|
24
|
+
timerService: M.any(),
|
|
25
|
+
zone: M.any(),
|
|
26
|
+
},
|
|
27
|
+
upgradability: 'canUpgrade',
|
|
28
|
+
};
|
|
29
|
+
harden(meta);
|
|
30
|
+
|
|
31
|
+
// XXX copied from inter-protocol
|
|
32
|
+
// TODO move to new `@agoric/contracts` package when we have it
|
|
33
|
+
/**
|
|
34
|
+
* @param {Brand} brand must be a 'nat' brand, not checked
|
|
35
|
+
* @param {NatValue} [min]
|
|
36
|
+
*/
|
|
37
|
+
export const makeNatAmountShape = (brand, min) =>
|
|
38
|
+
harden({ brand, value: min ? M.gte(min) : M.nat() });
|
|
39
|
+
|
|
16
40
|
/**
|
|
17
41
|
* @param {ZCF} zcf
|
|
18
42
|
* @param {{
|
|
43
|
+
* localchain: ERef<LocalChain>;
|
|
19
44
|
* orchestrationService: ERef<OrchestrationService>;
|
|
20
45
|
* storageNode: ERef<StorageNode>;
|
|
21
46
|
* timerService: ERef<TimerService>;
|
|
@@ -23,12 +48,16 @@ import { orcUtils } from '../utils/orc.js';
|
|
|
23
48
|
* }} privateArgs
|
|
24
49
|
*/
|
|
25
50
|
export const start = async (zcf, privateArgs) => {
|
|
26
|
-
const {
|
|
51
|
+
const { brands } = zcf.getTerms();
|
|
52
|
+
|
|
53
|
+
const { localchain, orchestrationService, storageNode, timerService, zone } =
|
|
54
|
+
privateArgs;
|
|
27
55
|
|
|
28
56
|
const { orchestrate } = makeOrchestrationFacade({
|
|
29
57
|
zone,
|
|
30
58
|
timerService,
|
|
31
59
|
zcf,
|
|
60
|
+
localchain,
|
|
32
61
|
storageNode,
|
|
33
62
|
orchestrationService,
|
|
34
63
|
});
|
|
@@ -41,7 +70,6 @@ export const start = async (zcf, privateArgs) => {
|
|
|
41
70
|
// eslint-disable-next-line no-shadow -- this `zcf` is enclosed in a membrane
|
|
42
71
|
async (/** @type {Orchestrator} */ orch, { zcf }, seat, offerArgs) => {
|
|
43
72
|
const { give } = seat.getProposal();
|
|
44
|
-
!AmountMath.isEmpty(give.USDC.value) || Fail`Must provide USDC.`;
|
|
45
73
|
|
|
46
74
|
const celestia = await orch.getChain('celestia');
|
|
47
75
|
const agoric = await orch.getChain('agoric');
|
|
@@ -51,33 +79,30 @@ export const start = async (zcf, privateArgs) => {
|
|
|
51
79
|
agoric.makeAccount(),
|
|
52
80
|
]);
|
|
53
81
|
|
|
54
|
-
const tiaAddress =
|
|
82
|
+
const tiaAddress = celestiaAccount.getAddress();
|
|
55
83
|
|
|
56
84
|
// deposit funds from user seat to LocalChainAccount
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
// seat.exit() // exit user seat now, or later?
|
|
60
|
-
const payment = await E(seatKit.userSeat).getPayout('USDC');
|
|
61
|
-
await localAccount.deposit(payment);
|
|
85
|
+
const payments = await withdrawFromSeat(zcf, seat, give);
|
|
86
|
+
await deeplyFulfilled(objectMap(payments, localAccount.deposit));
|
|
62
87
|
|
|
63
88
|
// build swap instructions with orcUtils library
|
|
64
89
|
const transferMsg = orcUtils.makeOsmosisSwap({
|
|
65
90
|
destChain: 'celestia',
|
|
66
91
|
destAddress: tiaAddress,
|
|
67
|
-
amountIn: give.
|
|
68
|
-
brandOut:
|
|
92
|
+
amountIn: give.Stable,
|
|
93
|
+
brandOut: /** @type {any} */ ('FIXME'),
|
|
69
94
|
slippage: 0.03,
|
|
70
95
|
});
|
|
71
96
|
|
|
72
97
|
await localAccount
|
|
73
|
-
.transferSteps(give.
|
|
98
|
+
.transferSteps(give.Stable, transferMsg)
|
|
74
99
|
.then(_txResult =>
|
|
75
100
|
celestiaAccount.delegate(offerArgs.validator, offerArgs.staked),
|
|
76
101
|
)
|
|
77
102
|
.catch(e => console.error(e));
|
|
78
103
|
|
|
79
104
|
// XXX close localAccount?
|
|
80
|
-
|
|
105
|
+
// return continuing inv since this is an offer?
|
|
81
106
|
},
|
|
82
107
|
);
|
|
83
108
|
|
|
@@ -87,7 +112,7 @@ export const start = async (zcf, privateArgs) => {
|
|
|
87
112
|
'Swap for TIA and stake',
|
|
88
113
|
undefined,
|
|
89
114
|
harden({
|
|
90
|
-
give: {
|
|
115
|
+
give: { Stable: makeNatAmountShape(brands.Stable, 1n) },
|
|
91
116
|
want: {}, // XXX ChainAccount Ownable?
|
|
92
117
|
exit: M.any(),
|
|
93
118
|
}),
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
export function start(zcf: ZCF, privateArgs: {
|
|
2
|
+
localchain: ERef<import("@endo/exo").Guarded<{
|
|
3
|
+
makeAccount(): Promise<import("@endo/exo").Guarded<{
|
|
4
|
+
getAddress(): Promise<string>;
|
|
5
|
+
deposit(payment: Payment): Promise<import("@agoric/ertp/src/types.js").NatAmount | import("@agoric/ertp/src/types.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/src/types.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/src/types.js").CopyBagAmount<import("@endo/patterns").Key>>;
|
|
6
|
+
executeTx<MT extends {
|
|
7
|
+
'@type': string;
|
|
8
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]>; }>;
|
|
9
|
+
}>>;
|
|
10
|
+
query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
|
|
11
|
+
'@type': string;
|
|
12
|
+
}>;
|
|
13
|
+
queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
|
|
14
|
+
error?: string | undefined;
|
|
15
|
+
reply: {
|
|
16
|
+
'@type': string;
|
|
17
|
+
};
|
|
18
|
+
}[]>;
|
|
19
|
+
}>>;
|
|
2
20
|
orchestrationService: ERef<import("@endo/exo").Guarded<{
|
|
3
21
|
makeAccount(hostConnectionId: `connection-${number}`, controllerConnectionId: `connection-${number}`): Promise<IcaAccount>;
|
|
4
22
|
provideICQConnection(controllerConnectionId: `connection-${number}`): Promise<import("@endo/exo").Guarded<{
|
|
@@ -17,8 +35,8 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
17
35
|
makeUnbondAndLiquidStakeInvitation: () => Promise<Invitation<unknown, never>>;
|
|
18
36
|
}>;
|
|
19
37
|
}>;
|
|
20
|
-
import type { IcaAccount } from '../types.js';
|
|
21
38
|
import type { ERef } from '@endo/far';
|
|
39
|
+
import type { IcaAccount } from '../types.js';
|
|
22
40
|
import type { TimerService } from '@agoric/time';
|
|
23
41
|
import type { Zone } from '@agoric/zone';
|
|
24
42
|
//# sourceMappingURL=unbondExample.contract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unbondExample.contract.d.ts","sourceRoot":"","sources":["unbondExample.contract.js"],"names":[],"mappings":"AAuBO,
|
|
1
|
+
{"version":3,"file":"unbondExample.contract.d.ts","sourceRoot":"","sources":["unbondExample.contract.js"],"names":[],"mappings":"AAuBO,2BATI,GAAG;;;;6BAgCyB,OAAO;;;2BAYV,EAAE;;uBA0B4+C,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;;;;;;;;;;;;;;;;;GAD5wE;0BA3EsB,WAAW;gCAHiC,aAAa;kCACjD,cAAc;0BAItB,cAAc"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Fail } from '@agoric/assert';
|
|
2
|
-
import { AmountMath, AmountShape } from '@agoric/ertp';
|
|
3
1
|
import { Far } from '@endo/far';
|
|
4
2
|
import { M } from '@endo/patterns';
|
|
5
3
|
import { makeOrchestrationFacade } from '../facade.js';
|
|
@@ -7,6 +5,7 @@ import { makeOrchestrationFacade } from '../facade.js';
|
|
|
7
5
|
/**
|
|
8
6
|
* @import {Orchestrator, IcaAccount, CosmosValidatorAddress} from '../types.js'
|
|
9
7
|
* @import {TimerService} from '@agoric/time';
|
|
8
|
+
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
|
|
10
9
|
* @import {ERef} from '@endo/far'
|
|
11
10
|
* @import {OrchestrationService} from '../service.js';
|
|
12
11
|
* @import {Zone} from '@agoric/zone';
|
|
@@ -15,6 +14,7 @@ import { makeOrchestrationFacade } from '../facade.js';
|
|
|
15
14
|
/**
|
|
16
15
|
* @param {ZCF} zcf
|
|
17
16
|
* @param {{
|
|
17
|
+
* localchain: ERef<LocalChain>;
|
|
18
18
|
* orchestrationService: ERef<OrchestrationService>;
|
|
19
19
|
* storageNode: ERef<StorageNode>;
|
|
20
20
|
* timerService: ERef<TimerService>;
|
|
@@ -22,9 +22,11 @@ import { makeOrchestrationFacade } from '../facade.js';
|
|
|
22
22
|
* }} privateArgs
|
|
23
23
|
*/
|
|
24
24
|
export const start = async (zcf, privateArgs) => {
|
|
25
|
-
const { orchestrationService, storageNode, timerService, zone } =
|
|
25
|
+
const { localchain, orchestrationService, storageNode, timerService, zone } =
|
|
26
|
+
privateArgs;
|
|
26
27
|
|
|
27
28
|
const { orchestrate } = makeOrchestrationFacade({
|
|
29
|
+
localchain,
|
|
28
30
|
zone,
|
|
29
31
|
timerService,
|
|
30
32
|
zcf,
|
|
@@ -37,11 +39,8 @@ export const start = async (zcf, privateArgs) => {
|
|
|
37
39
|
'LSTTia',
|
|
38
40
|
{ zcf },
|
|
39
41
|
// eslint-disable-next-line no-shadow -- this `zcf` is enclosed in a membrane
|
|
40
|
-
async (/** @type {Orchestrator} */ orch, { zcf },
|
|
42
|
+
async (/** @type {Orchestrator} */ orch, { zcf }, _seat, _offerArgs) => {
|
|
41
43
|
console.log('zcf within the membrane', zcf);
|
|
42
|
-
const { give } = seat.getProposal();
|
|
43
|
-
!AmountMath.isEmpty(give.USDC.value) || Fail`Must provide USDC.`;
|
|
44
|
-
|
|
45
44
|
// We would actually alreaady have the account from the orchestrator
|
|
46
45
|
// ??? could these be passed in? It would reduce the size of this handler,
|
|
47
46
|
// keeping it focused on long-running operations.
|
|
@@ -70,7 +69,8 @@ export const start = async (zcf, privateArgs) => {
|
|
|
70
69
|
'Unbond and liquid stake',
|
|
71
70
|
undefined,
|
|
72
71
|
harden({
|
|
73
|
-
give
|
|
72
|
+
// Nothing to give; the funds come from undelegating
|
|
73
|
+
give: {},
|
|
74
74
|
want: {}, // XXX ChainAccount Ownable?
|
|
75
75
|
exit: M.any(),
|
|
76
76
|
}),
|
package/src/facade.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode, orchestrationService, }: {
|
|
1
|
+
export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode, orchestrationService, localchain, }: {
|
|
2
2
|
zone: Zone;
|
|
3
|
-
timerService:
|
|
4
|
-
zcf:
|
|
5
|
-
storageNode: ERef<StorageNode>;
|
|
6
|
-
orchestrationService:
|
|
3
|
+
timerService: ERef<TimerService>;
|
|
4
|
+
zcf: ZCF;
|
|
5
|
+
storageNode: ERef<globalThis.StorageNode>;
|
|
6
|
+
orchestrationService: ERef<import("@endo/exo").Guarded<{
|
|
7
7
|
makeAccount(hostConnectionId: `connection-${number}`, controllerConnectionId: `connection-${number}`): Promise<import("./cosmos-api.js").IcaAccount>;
|
|
8
8
|
provideICQConnection(controllerConnectionId: `connection-${number}`): Promise<import("@endo/exo").Guarded<{
|
|
9
9
|
getLocalAddress(): `/ibc-port/${string}`;
|
|
@@ -11,6 +11,24 @@ export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode,
|
|
|
11
11
|
query(msgs: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/tendermint/abci/types.js").RequestQuery>[]): Promise<import("@agoric/cosmic-proto").Base64Any<import("@agoric/cosmic-proto/tendermint/abci/types.js").ResponseQuery>[]>;
|
|
12
12
|
}>>;
|
|
13
13
|
}>>;
|
|
14
|
+
localchain: ERef<import("@endo/exo").Guarded<{
|
|
15
|
+
makeAccount(): Promise<import("@endo/exo").Guarded<{
|
|
16
|
+
getAddress(): Promise<string>;
|
|
17
|
+
deposit(payment: Payment): Promise<import("@agoric/ertp/src/types.js").NatAmount | import("@agoric/ertp/src/types.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/src/types.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/src/types.js").CopyBagAmount<import("@endo/patterns").Key>>;
|
|
18
|
+
executeTx<MT extends {
|
|
19
|
+
'@type': string;
|
|
20
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]>; }>;
|
|
21
|
+
}>>;
|
|
22
|
+
query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
|
|
23
|
+
'@type': string;
|
|
24
|
+
}>;
|
|
25
|
+
queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
|
|
26
|
+
error?: string | undefined;
|
|
27
|
+
reply: {
|
|
28
|
+
'@type': string;
|
|
29
|
+
};
|
|
30
|
+
}[]>;
|
|
31
|
+
}>>;
|
|
14
32
|
}): {
|
|
15
33
|
/**
|
|
16
34
|
* @template Context
|
|
@@ -25,5 +43,6 @@ export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode,
|
|
|
25
43
|
export type OrchestrationFacade = ReturnType<typeof makeOrchestrationFacade>;
|
|
26
44
|
import type { Zone } from '@agoric/zone';
|
|
27
45
|
import type { TimerService } from '@agoric/time';
|
|
46
|
+
import type { ERef } from '@endo/far';
|
|
28
47
|
import type { Orchestrator } from './types.js';
|
|
29
48
|
//# 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":"AAgJO;;;SANG,GAAG;;;;;;;;;;;;;6BA7EK,OAChB;;;2BAkBM,EAAN;;uBAoF6B,OAC1B,sBAAoB,EACpB,SAAG;;;4BAuBK,OAAM,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;IA5BlD;;;;;;;OAOG;gBAFkC,OAAO,EACrB,IAAI,6BAHhB,MAAM,OAEoB,OAAO,AAD1B,gCACmB,OAAO,WACrB,IAAI,AADgC,KAAK,MAAM,GACzD,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,OAAO,CAAC;EAoBnD;kCAEa,UAAU,CAAC,OAAO,uBAAuB,CAAC;0BAxLjC,cAAc;kCACN,cAAc;0BAEtB,WAAW;kCAEqC,YAAY"}
|
package/src/facade.js
CHANGED
|
@@ -1,20 +1,145 @@
|
|
|
1
1
|
/** @file Orchestration service */
|
|
2
2
|
|
|
3
|
+
import { E } from '@endo/far';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* @import {Zone} from '@agoric/zone';
|
|
5
7
|
* @import {TimerService} from '@agoric/time';
|
|
8
|
+
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
|
|
9
|
+
* @import {ERef} from '@endo/far';
|
|
6
10
|
* @import {OrchestrationService} from './service.js';
|
|
7
|
-
* @import {Orchestrator} from './types.js';
|
|
11
|
+
* @import {Chain, ChainInfo, OrchestrationAccount, Orchestrator} from './types.js';
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** @type {any} */
|
|
15
|
+
const anyVal = null;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {ERef<LocalChain>} localchain
|
|
19
|
+
* @returns {Chain}
|
|
8
20
|
*/
|
|
21
|
+
const makeLocalChainFacade = localchain => {
|
|
22
|
+
return {
|
|
23
|
+
/** @returns {Promise<ChainInfo>} */
|
|
24
|
+
async getChainInfo() {
|
|
25
|
+
return {
|
|
26
|
+
allegedName: 'agoric',
|
|
27
|
+
allowedMessages: [],
|
|
28
|
+
allowedQueries: [],
|
|
29
|
+
chainId: 'agoric-3',
|
|
30
|
+
ibcConnectionInfo: anyVal,
|
|
31
|
+
ibcHooksEnabled: true,
|
|
32
|
+
icaEnabled: true,
|
|
33
|
+
icqEnabled: true,
|
|
34
|
+
pfmEnabled: true,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
async makeAccount() {
|
|
38
|
+
const account = await E(localchain).makeAccount();
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
deposit(payment) {
|
|
42
|
+
console.log('deposit got', payment);
|
|
43
|
+
// XXX yet again tripped up on remote methods looking local statically
|
|
44
|
+
return E(account).deposit(payment);
|
|
45
|
+
},
|
|
46
|
+
transferSteps(amount, msg) {
|
|
47
|
+
console.log('transferSteps got', amount, msg);
|
|
48
|
+
return Promise.resolve();
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @template {string} C
|
|
57
|
+
* @param {C} name
|
|
58
|
+
* @returns {Chain}
|
|
59
|
+
*/
|
|
60
|
+
const makeRemoteChainFacade = name => {
|
|
61
|
+
const chainInfo = {
|
|
62
|
+
allegedName: name,
|
|
63
|
+
chainId: 'fixme',
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
/** @returns {Promise<ChainInfo>} */
|
|
67
|
+
getChainInfo: async () => anyVal,
|
|
68
|
+
/** @returns {Promise<OrchestrationAccount<C>>} */
|
|
69
|
+
makeAccount: async () => {
|
|
70
|
+
console.log('makeAccount for', name);
|
|
71
|
+
// @ts-expect-error fake yet
|
|
72
|
+
return {
|
|
73
|
+
delegate(validator, amount) {
|
|
74
|
+
console.log('delegate got', validator, amount);
|
|
75
|
+
return Promise.resolve();
|
|
76
|
+
},
|
|
77
|
+
deposit(payment) {
|
|
78
|
+
console.log('deposit got', payment);
|
|
79
|
+
return Promise.resolve();
|
|
80
|
+
},
|
|
81
|
+
getAddress() {
|
|
82
|
+
return {
|
|
83
|
+
chainId: chainInfo.chainId,
|
|
84
|
+
address: 'an address!',
|
|
85
|
+
addressEncoding: 'bech32',
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
getBalance(_denom) {
|
|
89
|
+
console.error('getBalance not yet implemented');
|
|
90
|
+
return Promise.resolve({ denom: 'fixme', value: 0n });
|
|
91
|
+
},
|
|
92
|
+
getBalances() {
|
|
93
|
+
throw new Error('not yet implemented');
|
|
94
|
+
},
|
|
95
|
+
getDelegations() {
|
|
96
|
+
console.error('getDelegations not yet implemented');
|
|
97
|
+
return [];
|
|
98
|
+
},
|
|
99
|
+
getRedelegations() {
|
|
100
|
+
throw new Error('not yet implemented');
|
|
101
|
+
},
|
|
102
|
+
getUnbondingDelegations() {
|
|
103
|
+
throw new Error('not yet implemented');
|
|
104
|
+
},
|
|
105
|
+
liquidStake() {
|
|
106
|
+
console.error('liquidStake not yet implemented');
|
|
107
|
+
return 0n;
|
|
108
|
+
},
|
|
109
|
+
send(toAccount, amount) {
|
|
110
|
+
console.log('send got', toAccount, amount);
|
|
111
|
+
return Promise.resolve();
|
|
112
|
+
},
|
|
113
|
+
transfer(amount, destination, memo) {
|
|
114
|
+
console.log('transfer got', amount, destination, memo);
|
|
115
|
+
return Promise.resolve();
|
|
116
|
+
},
|
|
117
|
+
transferSteps(amount, msg) {
|
|
118
|
+
console.log('transferSteps got', amount, msg);
|
|
119
|
+
return Promise.resolve();
|
|
120
|
+
},
|
|
121
|
+
undelegate(validator, amount) {
|
|
122
|
+
console.log('undelegate got', validator, amount);
|
|
123
|
+
return Promise.resolve();
|
|
124
|
+
},
|
|
125
|
+
withdraw(amount) {
|
|
126
|
+
console.log('withdraw got', amount);
|
|
127
|
+
return Promise.resolve();
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
};
|
|
9
133
|
|
|
10
134
|
/**
|
|
11
135
|
*
|
|
12
136
|
* @param {{
|
|
13
137
|
* zone: Zone;
|
|
14
138
|
* timerService: ERef<TimerService>;
|
|
15
|
-
* zcf:
|
|
139
|
+
* zcf: ZCF;
|
|
16
140
|
* storageNode: ERef<StorageNode>;
|
|
17
141
|
* orchestrationService: ERef<OrchestrationService>;
|
|
142
|
+
* localchain: ERef<LocalChain>;
|
|
18
143
|
* }} powers
|
|
19
144
|
*/
|
|
20
145
|
export const makeOrchestrationFacade = ({
|
|
@@ -23,6 +148,7 @@ export const makeOrchestrationFacade = ({
|
|
|
23
148
|
zcf,
|
|
24
149
|
storageNode,
|
|
25
150
|
orchestrationService,
|
|
151
|
+
localchain,
|
|
26
152
|
}) => {
|
|
27
153
|
console.log('makeOrchestrationFacade got', {
|
|
28
154
|
zone,
|
|
@@ -42,8 +168,21 @@ export const makeOrchestrationFacade = ({
|
|
|
42
168
|
* @returns {(...args: Args) => Promise<unknown>}
|
|
43
169
|
*/
|
|
44
170
|
orchestrate(durableName, ctx, fn) {
|
|
45
|
-
|
|
46
|
-
|
|
171
|
+
/** @type {Orchestrator} */
|
|
172
|
+
const orc = {
|
|
173
|
+
async getChain(name) {
|
|
174
|
+
if (name === 'agoric') {
|
|
175
|
+
return makeLocalChainFacade(localchain);
|
|
176
|
+
}
|
|
177
|
+
return makeRemoteChainFacade(name);
|
|
178
|
+
},
|
|
179
|
+
makeLocalAccount() {
|
|
180
|
+
return E(localchain).makeAccount();
|
|
181
|
+
},
|
|
182
|
+
getBrandInfo: anyVal,
|
|
183
|
+
asAmount: anyVal,
|
|
184
|
+
};
|
|
185
|
+
return async (...args) => fn(orc, ctx, ...args);
|
|
47
186
|
},
|
|
48
187
|
};
|
|
49
188
|
};
|
package/src/utils/orc.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export namespace orcUtils {
|
|
|
9
9
|
function makeOsmosisSwap(_args: (SwapExact | SwapMaxSlippage) & (AfterAction | Record<string, never>)): TransferMsg;
|
|
10
10
|
}
|
|
11
11
|
import type { TransferMsg } from '../types.js';
|
|
12
|
+
import type { SwapExact } from '../types.js';
|
|
12
13
|
import type { SwapMaxSlippage } from '../types.js';
|
|
13
14
|
import type { AfterAction } from '../types.js';
|
|
14
15
|
//# sourceMappingURL=orc.d.ts.map
|
package/src/utils/orc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orc.d.ts","sourceRoot":"","sources":["orc.js"],"names":[],"mappings":";IASmB,wEAShB;IACD;;;;;OAKG;IACH,oHASC;;
|
|
1
|
+
{"version":3,"file":"orc.d.ts","sourceRoot":"","sources":["orc.js"],"names":[],"mappings":";IASmB,wEAShB;IACD;;;;;OAKG;IACH,oHASC;;iCAlCqE,aAAa;+BAAb,aAAa;qCAAb,aAAa;iCAAb,aAAa"}
|
package/src/utils/orc.js
CHANGED