@agoric/orchestration 0.1.1-dev-b395841.0 → 0.1.1-dev-0561702.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/stakeAtom.contract.d.ts.map +1 -1
- package/src/examples/stakeAtom.contract.js +1 -1
- package/src/examples/stakeBld.contract.d.ts +24 -16
- package/src/examples/stakeBld.contract.d.ts.map +1 -1
- package/src/examples/stakeBld.contract.js +7 -1
- package/src/examples/swapExample.contract.d.ts +1 -1
- package/src/examples/swapExample.contract.d.ts.map +1 -1
- package/src/examples/unbondExample.contract.d.ts +3 -4
- package/src/examples/unbondExample.contract.d.ts.map +1 -1
- package/src/examples/unbondExample.contract.js +6 -4
- package/src/exos/local-chain-account-kit.d.ts +26 -10
- package/src/exos/local-chain-account-kit.d.ts.map +1 -1
- package/src/exos/local-chain-account-kit.js +87 -41
- package/src/exos/stakingAccountKit.d.ts +2 -9
- package/src/exos/stakingAccountKit.d.ts.map +1 -1
- package/src/exos/stakingAccountKit.js +21 -45
- package/src/facade.d.ts +1 -1
- package/src/facade.d.ts.map +1 -1
- package/src/proposals/start-stakeAtom.d.ts.map +1 -1
- package/src/proposals/start-stakeBld.d.ts +19 -17
- package/src/proposals/start-stakeBld.d.ts.map +1 -1
- package/src/utils/cosmos.d.ts +9 -0
- package/src/utils/cosmos.d.ts.map +1 -0
- package/src/utils/cosmos.js +37 -0
- package/src/utils/time.d.ts +1 -0
- package/src/utils/time.d.ts.map +1 -1
- package/src/utils/time.js +9 -0
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-0561702.0+0561702",
|
|
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-0561702.0+0561702",
|
|
35
|
+
"@agoric/cosmic-proto": "0.4.1-dev-0561702.0+0561702",
|
|
36
|
+
"@agoric/ertp": "0.16.3-dev-0561702.0+0561702",
|
|
37
|
+
"@agoric/internal": "0.3.3-dev-0561702.0+0561702",
|
|
38
|
+
"@agoric/network": "0.1.1-dev-0561702.0+0561702",
|
|
39
|
+
"@agoric/notifier": "0.6.3-dev-0561702.0+0561702",
|
|
40
|
+
"@agoric/store": "0.9.3-dev-0561702.0+0561702",
|
|
41
|
+
"@agoric/time": "0.3.3-dev-0561702.0+0561702",
|
|
42
|
+
"@agoric/vat-data": "0.5.3-dev-0561702.0+0561702",
|
|
43
|
+
"@agoric/vats": "0.15.2-dev-0561702.0+0561702",
|
|
44
|
+
"@agoric/vow": "0.1.1-dev-0561702.0+0561702",
|
|
45
|
+
"@agoric/zoe": "0.26.3-dev-0561702.0+0561702",
|
|
46
|
+
"@agoric/zone": "0.2.3-dev-0561702.0+0561702",
|
|
47
47
|
"@endo/base64": "^1.0.5",
|
|
48
48
|
"@endo/far": "^1.1.2",
|
|
49
49
|
"@endo/marshal": "^1.5.0",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"typeCoverage": {
|
|
85
85
|
"atLeast": 97.38
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "05617020e12bcf015b88e5c1de25717deec914c5"
|
|
88
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stakeAtom.contract.d.ts","sourceRoot":"","sources":["stakeAtom.contract.js"],"names":[],"mappings":";;;;;;;;;AAkDO,2BATI,GAAG,CAAC,cAAc,CAAC;;;;;;;;;iBAGb,WAAW;gBACZ,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+
|
|
1
|
+
{"version":3,"file":"stakeAtom.contract.d.ts","sourceRoot":"","sources":["stakeAtom.contract.js"],"names":[],"mappings":";;;;;;;;;AAkDO,2BATI,GAAG,CAAC,cAAc,CAAC;;;;;;;;;iBAGb,WAAW;gBACZ,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+FAiFu/E,OAAO,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;GAH7hF;;;;eAxFc,MAAM;;0BA0FP,OAAO,KAAK;iCAzHmB,kBAAkB;kCAC7B,cAAc;kCAYf,cAAc;6BAFnB,kBAAkB"}
|
|
@@ -6,6 +6,9 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
6
6
|
timerBrand: TimerBrand;
|
|
7
7
|
}, baggage: import("@agoric/vat-data").Baggage): Promise<{
|
|
8
8
|
publicFacet: import("@endo/exo").Guarded<{
|
|
9
|
+
/**
|
|
10
|
+
* Invitation to make an account, initialized with the give's BLD
|
|
11
|
+
*/
|
|
9
12
|
makeStakeBldInvitation(): Promise<Invitation<{
|
|
10
13
|
publicSubscribers: {
|
|
11
14
|
account: {
|
|
@@ -15,9 +18,10 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
15
18
|
};
|
|
16
19
|
};
|
|
17
20
|
invitationMakers: import("@endo/exo").Guarded<{
|
|
18
|
-
Delegate(validatorAddress:
|
|
21
|
+
Delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
19
22
|
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
20
|
-
}
|
|
23
|
+
}>, undefined>>;
|
|
24
|
+
Undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<void, undefined>>;
|
|
21
25
|
CloseAccount(): never;
|
|
22
26
|
}>;
|
|
23
27
|
account: import("@endo/exo").Guarded<{
|
|
@@ -28,15 +32,15 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
28
32
|
storagePath: Promise<string>;
|
|
29
33
|
};
|
|
30
34
|
};
|
|
31
|
-
|
|
35
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
32
36
|
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
33
|
-
}
|
|
34
|
-
|
|
37
|
+
}>>;
|
|
38
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<void>;
|
|
35
39
|
deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
|
|
36
40
|
withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
|
|
37
41
|
executeTx<MT extends {
|
|
38
42
|
'@type': string;
|
|
39
|
-
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]
|
|
43
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
|
|
40
44
|
getAddress(): string;
|
|
41
45
|
transfer(amount: import("../orchestration-api.js").AmountArg, destination: import("../orchestration-api.js").ChainAddress, opts?: import("../cosmos-api.js").IBCMsgTransferOptions | undefined): Promise<void>;
|
|
42
46
|
}>;
|
|
@@ -49,18 +53,21 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
49
53
|
storagePath: Promise<string>;
|
|
50
54
|
};
|
|
51
55
|
};
|
|
52
|
-
|
|
56
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
53
57
|
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
54
|
-
}
|
|
55
|
-
|
|
58
|
+
}>>;
|
|
59
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<void>;
|
|
56
60
|
deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
|
|
57
61
|
withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
|
|
58
62
|
executeTx<MT extends {
|
|
59
63
|
'@type': string;
|
|
60
|
-
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]
|
|
64
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
|
|
61
65
|
getAddress(): string;
|
|
62
66
|
transfer(amount: import("../orchestration-api.js").AmountArg, destination: import("../orchestration-api.js").ChainAddress, opts?: import("../cosmos-api.js").IBCMsgTransferOptions | undefined): Promise<void>;
|
|
63
67
|
}>>;
|
|
68
|
+
/**
|
|
69
|
+
* Invitation to make an account, without any funds
|
|
70
|
+
*/
|
|
64
71
|
makeAccountInvitationMaker(): Promise<Invitation<{
|
|
65
72
|
publicSubscribers: {
|
|
66
73
|
account: {
|
|
@@ -70,9 +77,10 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
70
77
|
};
|
|
71
78
|
};
|
|
72
79
|
invitationMakers: import("@endo/exo").Guarded<{
|
|
73
|
-
Delegate(validatorAddress:
|
|
80
|
+
Delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
74
81
|
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
75
|
-
}
|
|
82
|
+
}>, undefined>>;
|
|
83
|
+
Undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<void, undefined>>;
|
|
76
84
|
CloseAccount(): never;
|
|
77
85
|
}>;
|
|
78
86
|
account: import("@endo/exo").Guarded<{
|
|
@@ -83,15 +91,15 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
83
91
|
storagePath: Promise<string>;
|
|
84
92
|
};
|
|
85
93
|
};
|
|
86
|
-
|
|
94
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
87
95
|
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
88
|
-
}
|
|
89
|
-
|
|
96
|
+
}>>;
|
|
97
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<void>;
|
|
90
98
|
deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
|
|
91
99
|
withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
|
|
92
100
|
executeTx<MT extends {
|
|
93
101
|
'@type': string;
|
|
94
|
-
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]
|
|
102
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
|
|
95
103
|
getAddress(): string;
|
|
96
104
|
transfer(amount: import("../orchestration-api.js").AmountArg, destination: import("../orchestration-api.js").ChainAddress, opts?: import("../cosmos-api.js").IBCMsgTransferOptions | undefined): Promise<void>;
|
|
97
105
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stakeBld.contract.d.ts","sourceRoot":"","sources":["stakeBld.contract.js"],"names":[],"mappings":"AAgCO,2BAVI,GAAG;gBAEG,OAAO,gCAAgC,EAAE,UAAU;gBACnD,UAAU;iBACT,WAAW;;;YAIlB,OAAO,kBAAkB,EAAE,OAAO
|
|
1
|
+
{"version":3,"file":"stakeBld.contract.d.ts","sourceRoot":"","sources":["stakeBld.contract.js"],"names":[],"mappings":"AAgCO,2BAVI,GAAG;gBAEG,OAAO,gCAAgC,EAAE,UAAU;gBACnD,UAAU;iBACT,WAAW;;;YAIlB,OAAO,kBAAkB,EAAE,OAAO;;QA+CvC;;WAEG;;;;;;;;;;+DAuCwC,OACrC,KAAR,CAAC;;;iEAUgT,OAAO,KAAK,CAAC;;;;;;;;;;;+DAAi5B,OAAO,KAAK,CAAC;;;iEAA0zB,OAAO,KAAK,CAAC;iCArErgE,QAAQ,KAAK,CAAC,mBACxB,OAAO;iCAiBN,OAAO,KAAK,CAAC;;;+BAclB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;QAiBhB;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiBR;kCAjH0C,cAAc;gCAAd,cAAc"}
|
|
@@ -48,7 +48,7 @@ export const start = async (zcf, privateArgs, baggage) => {
|
|
|
48
48
|
const agoricChainInfo = prepareMockChainInfo(zone);
|
|
49
49
|
|
|
50
50
|
const makeLocalChainAccountKit = prepareLocalChainAccountKit(
|
|
51
|
-
|
|
51
|
+
zone,
|
|
52
52
|
makeRecorderKit,
|
|
53
53
|
zcf,
|
|
54
54
|
privateArgs.timerService,
|
|
@@ -75,6 +75,9 @@ export const start = async (zcf, privateArgs, baggage) => {
|
|
|
75
75
|
makeStakeBldInvitation: M.callWhen().returns(InvitationShape),
|
|
76
76
|
}),
|
|
77
77
|
{
|
|
78
|
+
/**
|
|
79
|
+
* Invitation to make an account, initialized with the give's BLD
|
|
80
|
+
*/
|
|
78
81
|
makeStakeBldInvitation() {
|
|
79
82
|
return zcf.makeInvitation(
|
|
80
83
|
async seat => {
|
|
@@ -104,6 +107,9 @@ export const start = async (zcf, privateArgs, baggage) => {
|
|
|
104
107
|
const { holder } = await makeLocalAccountKit();
|
|
105
108
|
return holder;
|
|
106
109
|
},
|
|
110
|
+
/**
|
|
111
|
+
* Invitation to make an account, without any funds
|
|
112
|
+
*/
|
|
107
113
|
makeAccountInvitationMaker() {
|
|
108
114
|
trace('makeCreateAccountInvitation');
|
|
109
115
|
return zcf.makeInvitation(async seat => {
|
|
@@ -21,7 +21,7 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
21
21
|
withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
|
|
22
22
|
executeTx<MT extends {
|
|
23
23
|
'@type': string;
|
|
24
|
-
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]
|
|
24
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
|
|
25
25
|
}>>;
|
|
26
26
|
query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
|
|
27
27
|
'@type': string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swapExample.contract.d.ts","sourceRoot":"","sources":["swapExample.contract.js"],"names":[],"mappings":"AASA;;;;;;;GAOG;AAEH,2BAA2B;AAC3B,mBADW,YAAY,CAUrB;AASK,0CAHI,KAAK;;;EAIsC;AAY/C,2BATI,GAAG;;;;
|
|
1
|
+
{"version":3,"file":"swapExample.contract.d.ts","sourceRoot":"","sources":["swapExample.contract.js"],"names":[],"mappings":"AASA;;;;;;;GAOG;AAEH,2BAA2B;AAC3B,mBADW,YAAY,CAUrB;AASK,0CAHI,KAAK;;;EAIsC;AAY/C,2BATI,GAAG;;;;8BAGb,MAAK,KAAK,CAAC;6BAgBR,QAAI,KAAK,CAAC,mBAEN,OAAO;6BAeT,OAAA,KAAK,CAAC;;;2BAeJ,EAAC;;uBAoCiwC,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;;;;;;;;;;;;;;oBA9Dz9D,MAAM,CAAC,KAAK,CAAC;;;;;oBAAb,MAAM,CAAC,KAAK,CAAC;;;;GA6DxD;4BAlHwB,kBAAkB;gCAHwB,aAAa;kCACjD,cAAc;0BAItB,cAAc;4CAL8B,aAAa"}
|
|
@@ -7,7 +7,7 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
7
7
|
withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
|
|
8
8
|
executeTx<MT extends {
|
|
9
9
|
'@type': string;
|
|
10
|
-
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]
|
|
10
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
|
|
11
11
|
}>>;
|
|
12
12
|
query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
|
|
13
13
|
'@type': string;
|
|
@@ -29,8 +29,7 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
29
29
|
}>>;
|
|
30
30
|
storageNode: Remote<globalThis.StorageNode>;
|
|
31
31
|
timerService: Remote<TimerService>;
|
|
32
|
-
|
|
33
|
-
}): Promise<{
|
|
32
|
+
}, baggage: Baggage): Promise<{
|
|
34
33
|
publicFacet: {
|
|
35
34
|
makeUnbondAndLiquidStakeInvitation: () => Promise<Invitation<unknown, never>>;
|
|
36
35
|
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
@@ -40,5 +39,5 @@ export function start(zcf: ZCF, privateArgs: {
|
|
|
40
39
|
import type { Remote } from '@agoric/internal';
|
|
41
40
|
import type { IcaAccount } from '../types.js';
|
|
42
41
|
import type { TimerService } from '@agoric/time';
|
|
43
|
-
import type {
|
|
42
|
+
import type { Baggage } from '@agoric/vat-data';
|
|
44
43
|
//# sourceMappingURL=unbondExample.contract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unbondExample.contract.d.ts","sourceRoot":"","sources":["unbondExample.contract.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unbondExample.contract.d.ts","sourceRoot":"","sources":["unbondExample.contract.js"],"names":[],"mappings":"AAwBO,2BATI,GAAG;;;;8BA8BO,MAAM,KAAK,CAAC;6BAQjB,QAAQ,KAAK,CAAC,mBAGxB,OADI;6BAcA,OAAO,KAAK,CAAC;;;2BAiB+I,EAAE;;uBAAupE,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;;;;;;;;;;;;;;;;GADzjG;4BA3EwB,kBAAkB;gCAJwB,aAAa;kCACjD,cAAc;6BACnB,kBAAkB"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Far } from '@endo/far';
|
|
2
2
|
import { M } from '@endo/patterns';
|
|
3
|
+
import { makeDurableZone } from '@agoric/zone/durable.js';
|
|
3
4
|
import { makeOrchestrationFacade } from '../facade.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* @import {Orchestrator, IcaAccount, CosmosValidatorAddress} from '../types.js'
|
|
7
8
|
* @import {TimerService} from '@agoric/time';
|
|
9
|
+
* @import {Baggage} from '@agoric/vat-data';
|
|
8
10
|
* @import {LocalChain} from '@agoric/vats/src/localchain.js';
|
|
9
11
|
* @import {Remote} from '@agoric/internal';
|
|
10
12
|
* @import {OrchestrationService} from '../service.js';
|
|
11
|
-
* @import {Zone} from '@agoric/zone';
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -18,12 +19,13 @@ import { makeOrchestrationFacade } from '../facade.js';
|
|
|
18
19
|
* orchestrationService: Remote<OrchestrationService>;
|
|
19
20
|
* storageNode: Remote<StorageNode>;
|
|
20
21
|
* timerService: Remote<TimerService>;
|
|
21
|
-
* zone: Zone;
|
|
22
22
|
* }} privateArgs
|
|
23
|
+
* @param {Baggage} baggage
|
|
23
24
|
*/
|
|
24
|
-
export const start = async (zcf, privateArgs) => {
|
|
25
|
-
const { localchain, orchestrationService, storageNode, timerService
|
|
25
|
+
export const start = async (zcf, privateArgs, baggage) => {
|
|
26
|
+
const { localchain, orchestrationService, storageNode, timerService } =
|
|
26
27
|
privateArgs;
|
|
28
|
+
const zone = makeDurableZone(baggage);
|
|
27
29
|
|
|
28
30
|
const { orchestrate } = makeOrchestrationFacade({
|
|
29
31
|
localchain,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function prepareLocalChainAccountKit(
|
|
1
|
+
export function prepareLocalChainAccountKit(zone: Zone, makeRecorderKit: <T>(storageNode: StorageNode | Awaited<import("@endo/far").FarRef<StorageNode>>, valueShape?: import("@agoric/zoe/src/contractSupport/recorder.js").TypedMatcher<T> | undefined) => RecorderKit<T>, zcf: ZCF, timerService: TimerService, timerBrand: TimerBrand, agoricChainInfo: AgoricChainInfo): (args_0: {
|
|
2
2
|
account: import("@endo/exo").Guarded<{
|
|
3
3
|
getAddress(): Promise<string>;
|
|
4
4
|
getBalance(brand: Brand<"nat">): Promise<import("@agoric/ertp/src/types.js").NatAmount>;
|
|
@@ -6,15 +6,25 @@ export function prepareLocalChainAccountKit(baggage: Baggage, makeRecorderKit: <
|
|
|
6
6
|
withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
|
|
7
7
|
executeTx<MT extends {
|
|
8
8
|
'@type': string;
|
|
9
|
-
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto/vatsafe").ResponseTo<MT[K]
|
|
9
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/vatsafe").ResponseTo<MT[K]>>; }>;
|
|
10
10
|
}>;
|
|
11
11
|
address: string;
|
|
12
12
|
storageNode: StorageNode;
|
|
13
13
|
}) => import("@endo/exo").GuardedKit<{
|
|
14
14
|
invitationMakers: {
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param {string} validatorAddress
|
|
18
|
+
* @param {Amount<'nat'>} ertpAmount
|
|
19
|
+
*/
|
|
20
|
+
Delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
16
21
|
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
17
|
-
}
|
|
22
|
+
}>, undefined>>;
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} validatorAddress
|
|
25
|
+
* @param {Amount<'nat'>} ertpAmount
|
|
26
|
+
*/
|
|
27
|
+
Undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<void, undefined>>;
|
|
18
28
|
CloseAccount(): never;
|
|
19
29
|
};
|
|
20
30
|
holder: {
|
|
@@ -30,10 +40,16 @@ export function prepareLocalChainAccountKit(baggage: Baggage, makeRecorderKit: <
|
|
|
30
40
|
* @param {string} validatorAddress
|
|
31
41
|
* @param {Amount<'nat'>} ertpAmount
|
|
32
42
|
*/
|
|
33
|
-
|
|
43
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
34
44
|
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
35
|
-
}
|
|
36
|
-
|
|
45
|
+
}>>;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @param {string} validatorAddress
|
|
49
|
+
* @param {Amount<'nat'>} ertpAmount
|
|
50
|
+
* @returns {Promise<void>}
|
|
51
|
+
*/
|
|
52
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<void>;
|
|
37
53
|
/**
|
|
38
54
|
* Starting a transfer revokes the account holder. The associated updater
|
|
39
55
|
* will get a special notification that the account is being transferred.
|
|
@@ -45,7 +61,7 @@ export function prepareLocalChainAccountKit(baggage: Baggage, makeRecorderKit: <
|
|
|
45
61
|
/** @type {LocalChainAccount['executeTx']} */
|
|
46
62
|
executeTx<MT extends {
|
|
47
63
|
'@type': string;
|
|
48
|
-
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto/vatsafe").ResponseTo<MT[K]
|
|
64
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/vatsafe").ResponseTo<MT[K]>>; }>;
|
|
49
65
|
/**
|
|
50
66
|
* @returns {ChainAddress['address']}
|
|
51
67
|
*/
|
|
@@ -74,12 +90,12 @@ export type State = {
|
|
|
74
90
|
withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
|
|
75
91
|
executeTx<MT extends {
|
|
76
92
|
'@type': string;
|
|
77
|
-
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto/vatsafe").ResponseTo<MT[K]
|
|
93
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/vatsafe").ResponseTo<MT[K]>>; }>;
|
|
78
94
|
}>;
|
|
79
95
|
address: string;
|
|
80
96
|
};
|
|
81
97
|
export type LocalChainAccountKit = ReturnType<ReturnType<typeof prepareLocalChainAccountKit>>;
|
|
82
|
-
import type {
|
|
98
|
+
import type { Zone } from '@agoric/zone';
|
|
83
99
|
import type { RecorderKit } from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
84
100
|
import type { TimerService } from '@agoric/time';
|
|
85
101
|
import type { TimerBrand } from '@agoric/time';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-chain-account-kit.d.ts","sourceRoot":"","sources":["local-chain-account-kit.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"local-chain-account-kit.d.ts","sourceRoot":"","sources":["local-chain-account-kit.js"],"names":[],"mappings":"AAsEO,0FAuEC,WACL,GAAG,QACA,OAAM,WACL,EAAE,MAAM,CAAC,WAAW,CAC3B,CAAC,0HAhFU,GAAG,uEAGH,eAAe;;;0BA5Bd,MAAM,KAAK,CAAC;yBAWX,QAAQ,KAAK,CAAC,mBACZ,OAAO;yBAkBmB,OACvC,KAAK,CACP;;;uBAiBoB,EAAE;;;iBASP,WAAW;;;QAalB;;;;WAIG;mCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;QAYxB;;;WAGG;qCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;;;;;;;;;QA0BxB;;;;WAIG;mCAFQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC;;;QAsBxB;;;;;WAKG;qCAHQ,MAAM,cACN,MAAM,CAAC,KAAK,CAAC,GACX,OAAO,CAAC,IAAI,CAAC;QA2B1B;;;WAGG;QACH,2CAA2C;yBAnKtC,QAAQ,KAAK,CAAC,mBACZ,OAAO;QAsKd,4CAA4C;yBApJX,OACvC,KAAK,CACP;QAsJQ,6CAA6C;;;uBArIjC,EAAE;QA0Id;;WAEG;;QAIH;;;;;WAKG;0GADU,OAAO,CAAC,IAAI,CAAC;;GA6CjC;;;;;aAzPa,MAAM;;;;;;0BAOR,MAAM,KAAK,CAAC;yBAWX,QAAQ,KAAK,CAAC,mBACZ,OAAO;yBAkBmB,OACvC,KAAK,CACP;;;uBAiBoB,EAAE;;;;mCAkMR,UAAU,CAAC,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC;0BAtQjD,cAAc;iCADU,6CAA6C;kCAEjD,cAAc;gCAAd,cAAc;+BAHsC,uBAAuB;kCAAvB,uBAAuB;2CAAvB,uBAAuB"}
|
|
@@ -3,23 +3,24 @@ import { NonNullish } from '@agoric/assert';
|
|
|
3
3
|
import { typedJson } from '@agoric/cosmic-proto/vatsafe';
|
|
4
4
|
import { AmountShape, PaymentShape } from '@agoric/ertp';
|
|
5
5
|
import { makeTracer } from '@agoric/internal';
|
|
6
|
-
import { M
|
|
6
|
+
import { M } from '@agoric/vat-data';
|
|
7
7
|
import { TopicsRecordShape } from '@agoric/zoe/src/contractSupport/index.js';
|
|
8
|
+
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
|
|
8
9
|
import { E } from '@endo/far';
|
|
9
10
|
import {
|
|
10
11
|
AmountArgShape,
|
|
11
12
|
ChainAddressShape,
|
|
12
13
|
IBCTransferOptionsShape,
|
|
13
14
|
} from '../typeGuards.js';
|
|
14
|
-
import {
|
|
15
|
+
import { maxClockSkew } from '../utils/cosmos.js';
|
|
16
|
+
import { dateInSeconds, makeTimestampHelper } from '../utils/time.js';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* @import {LocalChainAccount} from '@agoric/vats/src/localchain.js';
|
|
18
20
|
* @import {AmountArg, ChainAddress, DenomAmount, IBCMsgTransferOptions, CosmosChainInfo} from '@agoric/orchestration';
|
|
19
21
|
* @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js'.
|
|
20
|
-
* @import {
|
|
22
|
+
* @import {Zone} from '@agoric/zone';
|
|
21
23
|
* @import {TimerService, TimerBrand} from '@agoric/time';
|
|
22
|
-
* @import {TimestampHelper} from '../utils/time.js';
|
|
23
24
|
*/
|
|
24
25
|
|
|
25
26
|
// partial until #8879
|
|
@@ -43,8 +44,8 @@ const { Fail } = assert;
|
|
|
43
44
|
|
|
44
45
|
const HolderI = M.interface('holder', {
|
|
45
46
|
getPublicTopics: M.call().returns(TopicsRecordShape),
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
delegate: M.call(M.string(), AmountShape).returns(M.promise()),
|
|
48
|
+
undelegate: M.call(M.string(), AmountShape).returns(M.promise()),
|
|
48
49
|
deposit: M.callWhen(PaymentShape).returns(AmountShape),
|
|
49
50
|
withdraw: M.callWhen(AmountShape).returns(PaymentShape),
|
|
50
51
|
transfer: M.call(AmountArgShape, ChainAddressShape)
|
|
@@ -60,7 +61,7 @@ const PUBLIC_TOPICS = {
|
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
/**
|
|
63
|
-
* @param {
|
|
64
|
+
* @param {Zone} zone
|
|
64
65
|
* @param {MakeRecorderKit} makeRecorderKit
|
|
65
66
|
* @param {ZCF} zcf
|
|
66
67
|
* @param {TimerService} timerService
|
|
@@ -68,7 +69,7 @@ const PUBLIC_TOPICS = {
|
|
|
68
69
|
* @param {AgoricChainInfo} agoricChainInfo
|
|
69
70
|
*/
|
|
70
71
|
export const prepareLocalChainAccountKit = (
|
|
71
|
-
|
|
72
|
+
zone,
|
|
72
73
|
makeRecorderKit,
|
|
73
74
|
zcf,
|
|
74
75
|
timerService,
|
|
@@ -79,14 +80,16 @@ export const prepareLocalChainAccountKit = (
|
|
|
79
80
|
/**
|
|
80
81
|
* Make an object wrapping an LCA with Zoe interfaces.
|
|
81
82
|
*/
|
|
82
|
-
const makeLocalChainAccountKit =
|
|
83
|
-
baggage,
|
|
83
|
+
const makeLocalChainAccountKit = zone.exoClassKit(
|
|
84
84
|
'LCA Kit',
|
|
85
85
|
{
|
|
86
86
|
holder: HolderI,
|
|
87
87
|
invitationMakers: M.interface('invitationMakers', {
|
|
88
|
-
Delegate:
|
|
89
|
-
|
|
88
|
+
Delegate: M.callWhen(M.string(), AmountShape).returns(InvitationShape),
|
|
89
|
+
Undelegate: M.callWhen(M.string(), AmountShape).returns(
|
|
90
|
+
InvitationShape,
|
|
91
|
+
),
|
|
92
|
+
CloseAccount: M.call().returns(M.promise()),
|
|
90
93
|
}),
|
|
91
94
|
},
|
|
92
95
|
/**
|
|
@@ -106,14 +109,36 @@ export const prepareLocalChainAccountKit = (
|
|
|
106
109
|
},
|
|
107
110
|
{
|
|
108
111
|
invitationMakers: {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @param {string} validatorAddress
|
|
115
|
+
* @param {Amount<'nat'>} ertpAmount
|
|
116
|
+
*/
|
|
117
|
+
async Delegate(validatorAddress, ertpAmount) {
|
|
118
|
+
trace('Delegate', validatorAddress, ertpAmount);
|
|
119
|
+
|
|
120
|
+
return zcf.makeInvitation(async seat => {
|
|
121
|
+
// TODO should it allow delegating more BLD?
|
|
122
|
+
seat.exit();
|
|
123
|
+
return this.facets.holder.delegate(validatorAddress, ertpAmount);
|
|
124
|
+
}, 'Delegate');
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @param {string} validatorAddress
|
|
129
|
+
* @param {Amount<'nat'>} ertpAmount
|
|
130
|
+
*/
|
|
131
|
+
async Undelegate(validatorAddress, ertpAmount) {
|
|
132
|
+
trace('Undelegate', validatorAddress, ertpAmount);
|
|
133
|
+
|
|
134
|
+
return zcf.makeInvitation(async seat => {
|
|
135
|
+
// TODO should it allow delegating more BLD?
|
|
136
|
+
seat.exit();
|
|
137
|
+
return this.facets.holder.undelegate(validatorAddress, ertpAmount);
|
|
138
|
+
}, 'Undelegate');
|
|
114
139
|
},
|
|
115
140
|
CloseAccount() {
|
|
116
|
-
|
|
141
|
+
throw Error('not yet implemented');
|
|
117
142
|
},
|
|
118
143
|
},
|
|
119
144
|
holder: {
|
|
@@ -132,35 +157,56 @@ export const prepareLocalChainAccountKit = (
|
|
|
132
157
|
* @param {string} validatorAddress
|
|
133
158
|
* @param {Amount<'nat'>} ertpAmount
|
|
134
159
|
*/
|
|
135
|
-
async
|
|
136
|
-
trace('makeDelegateInvitation', validatorAddress, ertpAmount);
|
|
137
|
-
|
|
160
|
+
async delegate(validatorAddress, ertpAmount) {
|
|
138
161
|
// TODO #9211 lookup denom from brand
|
|
139
162
|
const amount = {
|
|
140
163
|
amount: String(ertpAmount.value),
|
|
141
164
|
denom: 'ubld',
|
|
142
165
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}),
|
|
157
|
-
]);
|
|
158
|
-
trace('got result', result);
|
|
159
|
-
return result;
|
|
160
|
-
}, 'Delegate');
|
|
166
|
+
const { account: lca } = this.state;
|
|
167
|
+
trace('lca', lca);
|
|
168
|
+
const delegatorAddress = await E(lca).getAddress();
|
|
169
|
+
trace('delegatorAddress', delegatorAddress);
|
|
170
|
+
const [result] = await E(lca).executeTx([
|
|
171
|
+
typedJson('/cosmos.staking.v1beta1.MsgDelegate', {
|
|
172
|
+
amount,
|
|
173
|
+
validatorAddress,
|
|
174
|
+
delegatorAddress,
|
|
175
|
+
}),
|
|
176
|
+
]);
|
|
177
|
+
trace('got result', result);
|
|
178
|
+
return result;
|
|
161
179
|
},
|
|
162
|
-
|
|
163
|
-
|
|
180
|
+
/**
|
|
181
|
+
*
|
|
182
|
+
* @param {string} validatorAddress
|
|
183
|
+
* @param {Amount<'nat'>} ertpAmount
|
|
184
|
+
* @returns {Promise<void>}
|
|
185
|
+
*/
|
|
186
|
+
async undelegate(validatorAddress, ertpAmount) {
|
|
187
|
+
// TODO #9211 lookup denom from brand
|
|
188
|
+
const amount = {
|
|
189
|
+
amount: String(ertpAmount.value),
|
|
190
|
+
denom: 'ubld',
|
|
191
|
+
};
|
|
192
|
+
const { account: lca } = this.state;
|
|
193
|
+
trace('lca', lca);
|
|
194
|
+
const delegatorAddress = await E(lca).getAddress();
|
|
195
|
+
trace('delegatorAddress', delegatorAddress);
|
|
196
|
+
const [response] = await E(lca).executeTx([
|
|
197
|
+
typedJson('/cosmos.staking.v1beta1.MsgUndelegate', {
|
|
198
|
+
amount,
|
|
199
|
+
validatorAddress,
|
|
200
|
+
delegatorAddress,
|
|
201
|
+
}),
|
|
202
|
+
]);
|
|
203
|
+
trace('undelegate response', response);
|
|
204
|
+
const { completionTime } = response;
|
|
205
|
+
|
|
206
|
+
await E(timerService).wakeAt(
|
|
207
|
+
// TODO clean up date handling once we have real data
|
|
208
|
+
dateInSeconds(new Date(completionTime)) + maxClockSkew,
|
|
209
|
+
);
|
|
164
210
|
},
|
|
165
211
|
/**
|
|
166
212
|
* Starting a transfer revokes the account holder. The associated updater
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** maximum clock skew, in seconds, for unbonding time reported from other chain */
|
|
2
|
-
export const maxClockSkew: bigint;
|
|
3
1
|
/**
|
|
4
2
|
* @typedef {object} StakingAccountNotification
|
|
5
3
|
* @property {ChainAddress} chainAddress
|
|
@@ -24,13 +22,8 @@ export const IcaAccountHolderI: import("@endo/patterns").InterfaceGuard<{
|
|
|
24
22
|
withdrawRewards: import("@endo/patterns").MethodGuard;
|
|
25
23
|
undelegate: import("@endo/patterns").MethodGuard;
|
|
26
24
|
}>;
|
|
27
|
-
export function encodeTxResponse(response: any, toProtoMsg: any): string;
|
|
28
25
|
export const trivialDelegateResponse: string;
|
|
29
|
-
export function
|
|
30
|
-
typeUrl: string;
|
|
31
|
-
value: Uint8Array;
|
|
32
|
-
}) => T): T;
|
|
33
|
-
export function prepareStakingAccountKit(baggage: Baggage, makeRecorderKit: <T>(storageNode: StorageNode | Awaited<import("@endo/far").FarRef<StorageNode>>, valueShape?: import("@agoric/zoe/src/contractSupport/recorder.js").TypedMatcher<T> | undefined) => RecorderKit<T>, zcf: ZCF): (chainAddress: ChainAddress, bondDenom: string, io: {
|
|
26
|
+
export function prepareStakingAccountKit(zone: Zone, makeRecorderKit: <T>(storageNode: StorageNode | Awaited<import("@endo/far").FarRef<StorageNode>>, valueShape?: import("@agoric/zoe/src/contractSupport/recorder.js").TypedMatcher<T> | undefined) => RecorderKit<T>, zcf: ZCF): (chainAddress: ChainAddress, bondDenom: string, io: {
|
|
34
27
|
account: IcaAccount;
|
|
35
28
|
storageNode: StorageNode;
|
|
36
29
|
icqConnection: import("@endo/exo").Guarded<{
|
|
@@ -133,7 +126,7 @@ export type State = {
|
|
|
133
126
|
};
|
|
134
127
|
export type StakingAccountKit = ReturnType<ReturnType<typeof prepareStakingAccountKit>>;
|
|
135
128
|
export type StakingAccounHolder = StakingAccountKit["holder"];
|
|
136
|
-
import type {
|
|
129
|
+
import type { Zone } from '@agoric/zone';
|
|
137
130
|
import type { RecorderKit } from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
138
131
|
import type { ChainAddress } from '../types.js';
|
|
139
132
|
import type { IcaAccount } from '../types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stakingAccountKit.d.ts","sourceRoot":"","sources":["stakingAccountKit.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stakingAccountKit.d.ts","sourceRoot":"","sources":["stakingAccountKit.js"],"names":[],"mappings":"AAmDA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH;;;;;;;;;GAeG;AAOH,6CAGE;AAgBK,uFAqCK,WAAW,GAAE,QAAS,OAC5B,WAAO,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,0HAxCxB,GAAG;;iBAkCC,WAAW;;;;;;;;;QAelB,wDAAwD;;;QAWxD;;;WAGG;;;;QAgBH;;;;WAIG;4DADQ,MAAM,CAAC,KAAK,CAAC;QAUxB;;;;WAIG;;QAaH,gDAAgD;;QAShD;;WAEG;;;QAYH;;;WAGG;;;;;;;;;;;QAmBH,8BAA8B;;QAI9B;;;;WAIG;;QAkBH;;;;;WAKG;;QAmBH;;;WAGG;;QAmBH;;;WAGG;;;QA0BH;;WAEG;;;GA0CV;;;;;;;;;;;;;eAvVc,MAAM;;;gCAyVP,UAAU,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC;kCACvD,iBAAiB,CAAC,QAAQ,CAAC;0BA3WlB,cAAc;iCAJU,6CAA6C;kCADqC,aAAa;gCAAb,aAAa;kCAI/G,cAAc;+BAJoF,aAAa;0BAEvH,kDAAkD;4CAFwD,aAAa;iCAAb,aAAa;gCAGjH,wDAAwD"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/** @file Use-object for the owner of a staking account */
|
|
2
|
+
import { toRequestQueryJson } from '@agoric/cosmic-proto';
|
|
3
|
+
import {
|
|
4
|
+
QueryBalanceRequest,
|
|
5
|
+
QueryBalanceResponse,
|
|
6
|
+
} from '@agoric/cosmic-proto/cosmos/bank/v1beta1/query.js';
|
|
2
7
|
import {
|
|
3
8
|
MsgWithdrawDelegatorReward,
|
|
4
9
|
MsgWithdrawDelegatorRewardResponse,
|
|
@@ -10,19 +15,14 @@ import {
|
|
|
10
15
|
MsgUndelegate,
|
|
11
16
|
MsgUndelegateResponse,
|
|
12
17
|
} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js';
|
|
13
|
-
import {
|
|
14
|
-
QueryBalanceRequest,
|
|
15
|
-
QueryBalanceResponse,
|
|
16
|
-
} from '@agoric/cosmic-proto/cosmos/bank/v1beta1/query.js';
|
|
17
18
|
import { Any } from '@agoric/cosmic-proto/google/protobuf/any.js';
|
|
18
19
|
import { AmountShape } from '@agoric/ertp';
|
|
19
20
|
import { makeTracer } from '@agoric/internal';
|
|
20
|
-
import { M
|
|
21
|
+
import { M } from '@agoric/vat-data';
|
|
21
22
|
import { TopicsRecordShape } from '@agoric/zoe/src/contractSupport/index.js';
|
|
22
23
|
import { InvitationShape } from '@agoric/zoe/src/typeGuards.js';
|
|
23
|
-
import { decodeBase64
|
|
24
|
+
import { decodeBase64 } from '@endo/base64';
|
|
24
25
|
import { E } from '@endo/far';
|
|
25
|
-
import { toRequestQueryJson } from '@agoric/cosmic-proto';
|
|
26
26
|
import {
|
|
27
27
|
AmountArgShape,
|
|
28
28
|
ChainAddressShape,
|
|
@@ -30,17 +30,20 @@ import {
|
|
|
30
30
|
CoinShape,
|
|
31
31
|
DelegationShape,
|
|
32
32
|
} from '../typeGuards.js';
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
import {
|
|
34
|
+
encodeTxResponse,
|
|
35
|
+
maxClockSkew,
|
|
36
|
+
tryDecodeResponse,
|
|
37
|
+
} from '../utils/cosmos.js';
|
|
38
|
+
import { dateInSeconds } from '../utils/time.js';
|
|
36
39
|
|
|
37
40
|
/**
|
|
38
|
-
* @import {AmountArg, IcaAccount, ChainAddress,
|
|
41
|
+
* @import {AmountArg, IcaAccount, ChainAddress, CosmosValidatorAddress, ICQConnection, StakingAccountActions, DenomAmount} from '../types.js';
|
|
39
42
|
* @import {RecorderKit, MakeRecorderKit} from '@agoric/zoe/src/contractSupport/recorder.js';
|
|
40
|
-
* @import {
|
|
41
|
-
* @import {
|
|
42
|
-
* @import { Delegation } from '@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js';
|
|
43
|
+
* @import {Coin} from '@agoric/cosmic-proto/cosmos/base/v1beta1/coin.js';
|
|
44
|
+
* @import {Delegation} from '@agoric/cosmic-proto/cosmos/staking/v1beta1/staking.js';
|
|
43
45
|
* @import {TimerService} from '@agoric/time';
|
|
46
|
+
* @import {Zone} from '@agoric/zone';
|
|
44
47
|
*/
|
|
45
48
|
|
|
46
49
|
const trace = makeTracer('StakingAccountHolder');
|
|
@@ -84,14 +87,6 @@ const PUBLIC_TOPICS = {
|
|
|
84
87
|
account: ['Staking Account holder status', M.any()],
|
|
85
88
|
};
|
|
86
89
|
|
|
87
|
-
export const encodeTxResponse = (response, toProtoMsg) => {
|
|
88
|
-
const protoMsg = toProtoMsg(response);
|
|
89
|
-
const any1 = Any.fromPartial(protoMsg);
|
|
90
|
-
const any2 = Any.fromPartial({ value: Any.encode(any1).finish() });
|
|
91
|
-
const ackStr = encodeBase64(Any.encode(any2).finish());
|
|
92
|
-
return ackStr;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
90
|
export const trivialDelegateResponse = encodeTxResponse(
|
|
96
91
|
{},
|
|
97
92
|
MsgDelegateResponse.toProtoMsg,
|
|
@@ -103,34 +98,16 @@ const expect = (actual, expected, message) => {
|
|
|
103
98
|
}
|
|
104
99
|
};
|
|
105
100
|
|
|
106
|
-
/**
|
|
107
|
-
* @template T
|
|
108
|
-
* @param {string} ackStr
|
|
109
|
-
* @param {(p: {typeUrl: string, value: Uint8Array}) => T} fromProtoMsg
|
|
110
|
-
*/
|
|
111
|
-
export const tryDecodeResponse = (ackStr, fromProtoMsg) => {
|
|
112
|
-
try {
|
|
113
|
-
const any = Any.decode(decodeBase64(ackStr));
|
|
114
|
-
const protoMsg = Any.decode(any.value);
|
|
115
|
-
|
|
116
|
-
const msg = fromProtoMsg(protoMsg);
|
|
117
|
-
return msg;
|
|
118
|
-
} catch (cause) {
|
|
119
|
-
throw assert.error(`bad response: ${ackStr}`, undefined, { cause });
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
101
|
/** @type {(c: { denom: string, amount: string }) => DenomAmount} */
|
|
124
102
|
const toDenomAmount = c => ({ denom: c.denom, value: BigInt(c.amount) });
|
|
125
103
|
|
|
126
104
|
/**
|
|
127
|
-
* @param {
|
|
105
|
+
* @param {Zone} zone
|
|
128
106
|
* @param {MakeRecorderKit} makeRecorderKit
|
|
129
107
|
* @param {ZCF} zcf
|
|
130
108
|
*/
|
|
131
|
-
export const prepareStakingAccountKit = (
|
|
132
|
-
const makeStakingAccountKit =
|
|
133
|
-
baggage,
|
|
109
|
+
export const prepareStakingAccountKit = (zone, makeRecorderKit, zcf) => {
|
|
110
|
+
const makeStakingAccountKit = zone.exoClassKit(
|
|
134
111
|
'Staking Account Holder',
|
|
135
112
|
{
|
|
136
113
|
helper: M.interface('helper', {
|
|
@@ -408,9 +385,8 @@ export const prepareStakingAccountKit = (baggage, makeRecorderKit, zcf) => {
|
|
|
408
385
|
);
|
|
409
386
|
trace('undelegate response', response);
|
|
410
387
|
const { completionTime } = response;
|
|
411
|
-
const endTime = BigInt(completionTime.getTime() / 1000);
|
|
412
388
|
|
|
413
|
-
await E(timer).wakeAt(
|
|
389
|
+
await E(timer).wakeAt(dateInSeconds(completionTime) + maxClockSkew);
|
|
414
390
|
},
|
|
415
391
|
},
|
|
416
392
|
},
|
package/src/facade.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export function makeOrchestrationFacade({ zone, timerService, zcf, storageNode,
|
|
|
19
19
|
withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
|
|
20
20
|
executeTx<MT extends {
|
|
21
21
|
'@type': string;
|
|
22
|
-
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]
|
|
22
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
|
|
23
23
|
}>>;
|
|
24
24
|
query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
|
|
25
25
|
'@type': string;
|
package/src/facade.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["facade.js"],"names":[],"mappings":"AA+IO;;;SANG,GAAG;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"facade.d.ts","sourceRoot":"","sources":["facade.js"],"names":[],"mappings":"AA+IO;;;SANG,GAAG;;;;;;;;;;;;;8BA7ER,MAAM,KAAK,CAAC;6BAeT,QAAA,KAAK,CAAC,mBACA,OAAO;6BAkBX,OAAG,KAAK,CAAC;;;2BAiBW,EAAE;;uBA8E0L,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;IA7Bj9B;;;;;;;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;0BAvLjC,cAAc;kCACN,cAAc;4BAEpB,kBAAkB;kCAE4B,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-stakeAtom.d.ts","sourceRoot":"","sources":["start-stakeAtom.js"],"names":[],"mappings":"AAYO,0OAHI,eAAe,GAAG;IAAE,YAAY,EAAE;QAAC,OAAO,EAAE;YAAC,SAAS,EAAE,YAAY,OAgCtB,IAAI,cACtD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"start-stakeAtom.d.ts","sourceRoot":"","sources":["start-stakeAtom.js"],"names":[],"mappings":"AAYO,0OAHI,eAAe,GAAG;IAAE,YAAY,EAAE;QAAC,OAAO,EAAE;YAAC,SAAS,EAAE,YAAY,OAgCtB,IAAI,cACtD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2GAsDinH,OAAO,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;eAvFpgH,CAAA;SAAC,CAAA;KAAC,CAAA;CAAC;;kBAuDpI;AAGM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BN;oCA3FgD,gCAAgC"}
|
|
@@ -10,7 +10,7 @@ export function startStakeBld({ consume: { board, chainStorage, chainTimerServic
|
|
|
10
10
|
withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
|
|
11
11
|
executeTx<MT extends {
|
|
12
12
|
'@type': string;
|
|
13
|
-
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]
|
|
13
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
|
|
14
14
|
}>>;
|
|
15
15
|
query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
|
|
16
16
|
'@type': string;
|
|
@@ -42,9 +42,10 @@ export function startStakeBld({ consume: { board, chainStorage, chainTimerServic
|
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
44
|
invitationMakers: import("@endo/exo").Guarded<{
|
|
45
|
-
Delegate(validatorAddress:
|
|
45
|
+
Delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
46
46
|
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
47
|
-
}
|
|
47
|
+
}>, undefined>>;
|
|
48
|
+
Undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<void, undefined>>;
|
|
48
49
|
CloseAccount(): never;
|
|
49
50
|
}>;
|
|
50
51
|
account: import("@endo/exo").Guarded<{
|
|
@@ -55,15 +56,15 @@ export function startStakeBld({ consume: { board, chainStorage, chainTimerServic
|
|
|
55
56
|
storagePath: Promise<string>;
|
|
56
57
|
};
|
|
57
58
|
};
|
|
58
|
-
|
|
59
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
59
60
|
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
60
|
-
}
|
|
61
|
-
|
|
61
|
+
}>>;
|
|
62
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<void>;
|
|
62
63
|
deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
|
|
63
64
|
withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
|
|
64
65
|
executeTx<MT extends {
|
|
65
66
|
'@type': string;
|
|
66
|
-
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]
|
|
67
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
|
|
67
68
|
getAddress(): string;
|
|
68
69
|
transfer(amount: import("../orchestration-api.js").AmountArg, destination: import("../orchestration-api.js").ChainAddress, opts?: import("../cosmos-api.js").IBCMsgTransferOptions | undefined): Promise<void>;
|
|
69
70
|
}>;
|
|
@@ -76,15 +77,15 @@ export function startStakeBld({ consume: { board, chainStorage, chainTimerServic
|
|
|
76
77
|
storagePath: Promise<string>;
|
|
77
78
|
};
|
|
78
79
|
};
|
|
79
|
-
|
|
80
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
80
81
|
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
81
|
-
}
|
|
82
|
-
|
|
82
|
+
}>>;
|
|
83
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<void>;
|
|
83
84
|
deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
|
|
84
85
|
withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
|
|
85
86
|
executeTx<MT extends {
|
|
86
87
|
'@type': string;
|
|
87
|
-
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]
|
|
88
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
|
|
88
89
|
getAddress(): string;
|
|
89
90
|
transfer(amount: import("../orchestration-api.js").AmountArg, destination: import("../orchestration-api.js").ChainAddress, opts?: import("../cosmos-api.js").IBCMsgTransferOptions | undefined): Promise<void>;
|
|
90
91
|
}>>;
|
|
@@ -97,9 +98,10 @@ export function startStakeBld({ consume: { board, chainStorage, chainTimerServic
|
|
|
97
98
|
};
|
|
98
99
|
};
|
|
99
100
|
invitationMakers: import("@endo/exo").Guarded<{
|
|
100
|
-
Delegate(validatorAddress:
|
|
101
|
+
Delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
101
102
|
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
102
|
-
}
|
|
103
|
+
}>, undefined>>;
|
|
104
|
+
Undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<Invitation<void, undefined>>;
|
|
103
105
|
CloseAccount(): never;
|
|
104
106
|
}>;
|
|
105
107
|
account: import("@endo/exo").Guarded<{
|
|
@@ -110,15 +112,15 @@ export function startStakeBld({ consume: { board, chainStorage, chainTimerServic
|
|
|
110
112
|
storagePath: Promise<string>;
|
|
111
113
|
};
|
|
112
114
|
};
|
|
113
|
-
|
|
115
|
+
delegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto/cosmos/staking/v1beta1/tx.js").MsgDelegateResponse & {
|
|
114
116
|
'@type': "/cosmos.staking.v1beta1.MsgDelegateResponse";
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
+
}>>;
|
|
118
|
+
undelegate(validatorAddress: string, ertpAmount: Amount<"nat">): Promise<void>;
|
|
117
119
|
deposit(payment: Payment<"nat">, optAmountShape?: Pattern): Promise<globalThis.Amount>;
|
|
118
120
|
withdraw(amount: Amount<"nat">): Promise<globalThis.Payment<"nat">>;
|
|
119
121
|
executeTx<MT extends {
|
|
120
122
|
'@type': string;
|
|
121
|
-
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]
|
|
123
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").JsonSafe<import("@agoric/cosmic-proto").ResponseTo<MT[K]>>; }>;
|
|
122
124
|
getAddress(): string;
|
|
123
125
|
transfer(amount: import("../orchestration-api.js").AmountArg, destination: import("../orchestration-api.js").ChainAddress, opts?: import("../cosmos-api.js").IBCMsgTransferOptions | undefined): Promise<void>;
|
|
124
126
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-stakeBld.d.ts","sourceRoot":"","sources":["start-stakeBld.js"],"names":[],"mappings":"AAUO,kSAFI,eAAe,GAAG;IAAC,YAAY,EAAE;QAAC,OAAO,EAAE;YAAC,QAAQ,EAAE,YAAY,OAmBvE,GACL;;;;
|
|
1
|
+
{"version":3,"file":"start-stakeBld.d.ts","sourceRoot":"","sources":["start-stakeBld.js"],"names":[],"mappings":"AAUO,kSAFI,eAAe,GAAG;IAAC,YAAY,EAAE;QAAC,OAAO,EAAE;YAAC,QAAQ,EAAE,YAAY,OAmBvE,GACL;;;;0CAoBe,MAAM,KAAK,CAAC;yCAoBR,QAAS,KAAI,CAAC,mBACR,OACrB;yCAkB4K,OAAO,KAAK,CAAC;;;uCAAgiB,EAAE;;mCAAupE,OAAO,sBAAsB,EAAE,SAAS;;;wCAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;;;;;;;;;wBAtDnlH,OAAO,kBAAkB,EAAE,OAEzD;;;;;;;;;;;2EAoDqgD,OAAO,KAAK,CAAC;;;6EAAid,OAAO,KAAK,CAAC;;;;;;;;;;;2EAAi5B,OAAO,KAAK,CAAC;;;6EAA0zB,OAAO,KAAK,CAAC;6CApBlsH,QAAS,KAAI,CAAC,mBACR,OACrB;6CAkB4K,OAAO,KAAK,CAAC;;;2CAAgiB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAhF1lB,CAAA;SAAC,CAAA;KAAC,CAAA;CAAC,iBAkDxI;AAGM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BN;sBArFqB,gCAAgC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** maximum clock skew, in seconds, for unbonding time reported from other chain */
|
|
2
|
+
export const maxClockSkew: bigint;
|
|
3
|
+
export function encodeTxResponse(response: unknown, toProtoMsg: (msg: any) => Any): string;
|
|
4
|
+
export function tryDecodeResponse<T>(ackStr: string, fromProtoMsg: (p: {
|
|
5
|
+
typeUrl: string;
|
|
6
|
+
value: Uint8Array;
|
|
7
|
+
}) => T): T;
|
|
8
|
+
import { Any } from '@agoric/cosmic-proto/google/protobuf/any.js';
|
|
9
|
+
//# sourceMappingURL=cosmos.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cosmos.d.ts","sourceRoot":"","sources":["cosmos.js"],"names":[],"mappings":"AAIA,mFAAmF;AACnF,kCAAsC;AAQ/B,2CAJI,OAAO,cACP,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,GACf,MAAM,CAQlB;AAOM,kCAFiD,CAAC,UAD9C,MAAM,gBACN,CAAC,CAAC,EAAE;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAC,KAAK,CAAC,KAYxD;oBAnCmB,6CAA6C"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { assert } from '@agoric/assert';
|
|
2
|
+
import { Any } from '@agoric/cosmic-proto/google/protobuf/any.js';
|
|
3
|
+
import { decodeBase64, encodeBase64 } from '@endo/base64';
|
|
4
|
+
|
|
5
|
+
/** maximum clock skew, in seconds, for unbonding time reported from other chain */
|
|
6
|
+
export const maxClockSkew = 10n * 60n;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {unknown} response
|
|
11
|
+
* @param {(msg: any) => Any} toProtoMsg
|
|
12
|
+
* @returns {string}
|
|
13
|
+
*/
|
|
14
|
+
export const encodeTxResponse = (response, toProtoMsg) => {
|
|
15
|
+
const protoMsg = toProtoMsg(response);
|
|
16
|
+
const any1 = Any.fromPartial(protoMsg);
|
|
17
|
+
const any2 = Any.fromPartial({ value: Any.encode(any1).finish() });
|
|
18
|
+
const ackStr = encodeBase64(Any.encode(any2).finish());
|
|
19
|
+
return ackStr;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @template T
|
|
24
|
+
* @param {string} ackStr
|
|
25
|
+
* @param {(p: {typeUrl: string, value: Uint8Array}) => T} fromProtoMsg
|
|
26
|
+
*/
|
|
27
|
+
export const tryDecodeResponse = (ackStr, fromProtoMsg) => {
|
|
28
|
+
try {
|
|
29
|
+
const any = Any.decode(decodeBase64(ackStr));
|
|
30
|
+
const protoMsg = Any.decode(any.value);
|
|
31
|
+
|
|
32
|
+
const msg = fromProtoMsg(protoMsg);
|
|
33
|
+
return msg;
|
|
34
|
+
} catch (cause) {
|
|
35
|
+
throw assert.error(`bad response: ${ackStr}`, undefined, { cause });
|
|
36
|
+
}
|
|
37
|
+
};
|
package/src/utils/time.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export function makeTimestampHelper(timer: TimerService, timerBrand: TimerBrand)
|
|
|
18
18
|
*/
|
|
19
19
|
export const SECONDS_PER_MINUTE: 60n;
|
|
20
20
|
export const NANOSECONDS_PER_SECOND: 1000000000n;
|
|
21
|
+
export function dateInSeconds(date: Date): bigint;
|
|
21
22
|
export type TimestampHelper = Awaited<ReturnType<typeof makeTimestampHelper>>;
|
|
22
23
|
import type { TimerService } from '@agoric/time';
|
|
23
24
|
import type { TimerBrand } from '@agoric/time';
|
package/src/utils/time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["time.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;IAEI;;;;;;OAMG;0EADU,OAAO,CAAC,MAAM,CAAC;EAa/B;AAhCD;;;GAGG;AAEH,qCAAsC;AACtC,iDAAqD;
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["time.js"],"names":[],"mappings":"AAWA;;;GAGG;AACH;IAEI;;;;;;OAMG;0EADU,OAAO,CAAC,MAAM,CAAC;EAa/B;AAhCD;;;GAGG;AAEH,qCAAsC;AACtC,iDAAqD;AAqC9C,oCAHI,IAAI,GACF,MAAM,CAE2D;8BAThE,OAAO,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC;kCAjCE,cAAc;gCAAd,cAAc;wCAAd,cAAc"}
|
package/src/utils/time.js
CHANGED
|
@@ -36,3 +36,12 @@ export function makeTimestampHelper(timer, timerBrand) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/** @typedef {Awaited<ReturnType<typeof makeTimestampHelper>>} TimestampHelper */
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Convert a Date from a Cosmos message, which has millisecond precision,
|
|
42
|
+
* to a BigInt for number of seconds since epoch, for use in a timer.
|
|
43
|
+
*
|
|
44
|
+
* @param {Date} date
|
|
45
|
+
* @returns {bigint}
|
|
46
|
+
*/
|
|
47
|
+
export const dateInSeconds = date => BigInt(Math.floor(date.getTime() / 1000));
|