@agoric/vats 0.15.2-dev-822ab08.0 → 0.15.2-dev-4685ea9.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 +17 -17
- package/src/localchain.d.ts +95 -69
- package/src/localchain.d.ts.map +1 -1
- package/src/localchain.js +76 -118
- package/src/proposals/localchain-proposal.d.ts +1 -5
- package/src/proposals/localchain-proposal.d.ts.map +1 -1
- package/src/proposals/localchain-proposal.js +3 -33
- package/src/vat-localchain.d.ts +34 -44
- package/src/vat-localchain.d.ts.map +1 -1
- package/src/vat-localchain.js +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/vats",
|
|
3
|
-
"version": "0.15.2-dev-
|
|
3
|
+
"version": "0.15.2-dev-4685ea9.0+4685ea9",
|
|
4
4
|
"description": "Agoric's Vat library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -22,20 +22,20 @@
|
|
|
22
22
|
"author": "Agoric",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@agoric/assert": "0.6.1-dev-
|
|
26
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
27
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
28
|
-
"@agoric/governance": "0.10.4-dev-
|
|
29
|
-
"@agoric/internal": "0.3.3-dev-
|
|
30
|
-
"@agoric/network": "0.1.1-dev-
|
|
31
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
32
|
-
"@agoric/store": "0.9.3-dev-
|
|
33
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
34
|
-
"@agoric/time": "0.3.3-dev-
|
|
35
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
36
|
-
"@agoric/vow": "0.1.1-dev-
|
|
37
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
38
|
-
"@agoric/zone": "0.2.3-dev-
|
|
25
|
+
"@agoric/assert": "0.6.1-dev-4685ea9.0+4685ea9",
|
|
26
|
+
"@agoric/cosmic-proto": "0.4.1-dev-4685ea9.0+4685ea9",
|
|
27
|
+
"@agoric/ertp": "0.16.3-dev-4685ea9.0+4685ea9",
|
|
28
|
+
"@agoric/governance": "0.10.4-dev-4685ea9.0+4685ea9",
|
|
29
|
+
"@agoric/internal": "0.3.3-dev-4685ea9.0+4685ea9",
|
|
30
|
+
"@agoric/network": "0.1.1-dev-4685ea9.0+4685ea9",
|
|
31
|
+
"@agoric/notifier": "0.6.3-dev-4685ea9.0+4685ea9",
|
|
32
|
+
"@agoric/store": "0.9.3-dev-4685ea9.0+4685ea9",
|
|
33
|
+
"@agoric/swingset-vat": "0.32.3-dev-4685ea9.0+4685ea9",
|
|
34
|
+
"@agoric/time": "0.3.3-dev-4685ea9.0+4685ea9",
|
|
35
|
+
"@agoric/vat-data": "0.5.3-dev-4685ea9.0+4685ea9",
|
|
36
|
+
"@agoric/vow": "0.1.1-dev-4685ea9.0+4685ea9",
|
|
37
|
+
"@agoric/zoe": "0.26.3-dev-4685ea9.0+4685ea9",
|
|
38
|
+
"@agoric/zone": "0.2.3-dev-4685ea9.0+4685ea9",
|
|
39
39
|
"@endo/base64": "^1.0.5",
|
|
40
40
|
"@endo/far": "^1.1.2",
|
|
41
41
|
"@endo/import-bundle": "^1.1.2",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"jessie.js": "^0.3.4"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
50
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-4685ea9.0+4685ea9",
|
|
51
51
|
"@endo/bundle-source": "^3.2.3",
|
|
52
52
|
"@endo/init": "^1.1.2",
|
|
53
53
|
"ava": "^5.3.0",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"typeCoverage": {
|
|
82
82
|
"atLeast": 91.33
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "4685ea97ebea26b2aad1f75f9d553558156eb5f6"
|
|
85
85
|
}
|
package/src/localchain.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {BankManager, Bank} from './vat-bank.js';
|
|
3
|
+
* @import {ScopedBridgeManager} from './types.js';
|
|
4
|
+
*/
|
|
5
|
+
/** @import {TypedJson, ResponseTo} from '@agoric/cosmic-proto'; */
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {{
|
|
8
|
+
* system: ScopedBridgeManager;
|
|
9
|
+
* bank: Bank;
|
|
10
|
+
* }} AccountPowers
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {{
|
|
14
|
+
* system: ScopedBridgeManager;
|
|
15
|
+
* bankManager: BankManager;
|
|
16
|
+
* }} LocalChainPowers
|
|
17
|
+
*/
|
|
1
18
|
export const LocalChainAccountI: import("@endo/patterns").InterfaceGuard<{
|
|
2
19
|
getAddress: import("@endo/patterns").MethodGuard;
|
|
3
20
|
deposit: import("@endo/patterns").MethodGuard;
|
|
@@ -13,90 +30,99 @@ export const LocalChainI: import("@endo/patterns").InterfaceGuard<{
|
|
|
13
30
|
query: import("@endo/patterns").MethodGuard;
|
|
14
31
|
queryMany: import("@endo/patterns").MethodGuard;
|
|
15
32
|
}>;
|
|
16
|
-
export const LocalChainAdminI: import("@endo/patterns").InterfaceGuard<{
|
|
17
|
-
setPower: import("@endo/patterns").MethodGuard;
|
|
18
|
-
}>;
|
|
19
33
|
export function prepareLocalChainTools(zone: import("@agoric/base-zone").Zone): {
|
|
20
|
-
makeLocalChain: (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
public: {
|
|
30
|
-
/**
|
|
31
|
-
* Allocate a fresh address that doesn't correspond with a public key,
|
|
32
|
-
* and follows the ICA guidelines to help reduce collisions. See
|
|
33
|
-
* x/vlocalchain/keeper/keeper.go AllocateAddress for the use of the app
|
|
34
|
-
* hash and block data hash.
|
|
35
|
-
*/
|
|
36
|
-
makeAccount(): Promise<import("@endo/exo").Guarded<{
|
|
37
|
-
getAddress(): Promise<string>;
|
|
38
|
-
/**
|
|
39
|
-
* Deposit a payment into the bank purse that matches the alleged brand.
|
|
40
|
-
* This is safe, since even if the payment lies about its brand, ERTP will
|
|
41
|
-
* reject spoofed payment objects when depositing into a purse.
|
|
42
|
-
*
|
|
43
|
-
* @param {Payment} payment
|
|
44
|
-
*/
|
|
45
|
-
deposit(payment: Payment): Promise<import("@agoric/ertp/exported.js").NatAmount | import("@agoric/ertp/exported.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").CopyBagAmount<import("@endo/patterns").Key>>;
|
|
46
|
-
/**
|
|
47
|
-
* Execute a batch of transactions and return the responses. Use
|
|
48
|
-
* `typedJson()` on the arguments to get typed return values.
|
|
49
|
-
*
|
|
50
|
-
* @template {TypedJson[]} MT messages tuple (use const with multiple
|
|
51
|
-
* elements or it will be a mixed array)
|
|
52
|
-
* @param {MT} messages
|
|
53
|
-
* @returns {Promise<{ [K in keyof MT]: ResponseTo<MT[K]> }>}
|
|
54
|
-
*/
|
|
55
|
-
executeTx<MT extends {
|
|
56
|
-
'@type': string;
|
|
57
|
-
}[]>(messages: MT): Promise<{ [K_1 in keyof MT]: ResponseTo<MT[K_1]>; }>;
|
|
58
|
-
}>>;
|
|
34
|
+
makeLocalChain: (powers: LocalChainPowers) => import("@endo/exo").Guarded<{
|
|
35
|
+
/**
|
|
36
|
+
* Allocate a fresh address that doesn't correspond with a public key, and
|
|
37
|
+
* follows the ICA guidelines to help reduce collisions. See
|
|
38
|
+
* x/vlocalchain/keeper/keeper.go AllocateAddress for the use of the app
|
|
39
|
+
* hash and block data hash.
|
|
40
|
+
*/
|
|
41
|
+
makeAccount(): Promise<import("@endo/exo").Guarded<{
|
|
42
|
+
getAddress(): Promise<string>;
|
|
59
43
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
44
|
+
* Deposit a payment into the bank purse that matches the alleged brand.
|
|
45
|
+
* This is safe, since even if the payment lies about its brand, ERTP will
|
|
46
|
+
* reject spoofed payment objects when depositing into a purse.
|
|
63
47
|
*
|
|
64
|
-
* @param {
|
|
65
|
-
* @returns {Promise<import('@agoric/cosmic-proto').TypedJson>}
|
|
48
|
+
* @param {Payment} payment
|
|
66
49
|
*/
|
|
67
|
-
|
|
50
|
+
deposit(payment: Payment): Promise<import("@agoric/ertp/exported.js").NatAmount | import("@agoric/ertp/exported.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").CopyBagAmount<import("@endo/patterns").Key>>;
|
|
68
51
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* failure.
|
|
52
|
+
* Execute a batch of transactions and return the responses. Use
|
|
53
|
+
* `typedJson()` on the arguments to get typed return values.
|
|
72
54
|
*
|
|
73
|
-
* @
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* reply: import('@agoric/cosmic-proto').TypedJson;
|
|
78
|
-
* }[]
|
|
79
|
-
* >}
|
|
55
|
+
* @template {TypedJson[]} MT messages tuple (use const with multiple
|
|
56
|
+
* elements or it will be a mixed array)
|
|
57
|
+
* @param {MT} messages
|
|
58
|
+
* @returns {Promise<{ [K in keyof MT]: ResponseTo<MT[K]> }>}
|
|
80
59
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
60
|
+
executeTx<MT extends {
|
|
61
|
+
'@type': string;
|
|
62
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: ResponseTo<MT[K]>; }>;
|
|
63
|
+
}>>;
|
|
64
|
+
/**
|
|
65
|
+
* Make a single query to the local chain. Will reject with an error if
|
|
66
|
+
* the query fails. Otherwise, return the response as a JSON-compatible
|
|
67
|
+
* object.
|
|
68
|
+
*
|
|
69
|
+
* @param {import('@agoric/cosmic-proto').TypedJson} request
|
|
70
|
+
* @returns {Promise<import('@agoric/cosmic-proto').TypedJson>}
|
|
71
|
+
*/
|
|
72
|
+
query(request: import("@agoric/cosmic-proto").TypedJson): Promise<import("@agoric/cosmic-proto").TypedJson>;
|
|
73
|
+
/**
|
|
74
|
+
* Send a batch of query requests to the local chain. Unless there is a
|
|
75
|
+
* system error, will return all results to indicate their success or
|
|
76
|
+
* failure.
|
|
77
|
+
*
|
|
78
|
+
* @param {import('@agoric/cosmic-proto').TypedJson[]} requests
|
|
79
|
+
* @returns {Promise<
|
|
80
|
+
* {
|
|
81
|
+
* error?: string;
|
|
82
|
+
* reply: import('@agoric/cosmic-proto').TypedJson;
|
|
83
|
+
* }[]
|
|
84
|
+
* >}
|
|
85
|
+
*/
|
|
86
|
+
queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
|
|
87
|
+
error?: string;
|
|
88
|
+
reply: import("@agoric/cosmic-proto").TypedJson;
|
|
89
|
+
}[]>;
|
|
86
90
|
}>;
|
|
87
91
|
};
|
|
92
|
+
export type AccountPowers = {
|
|
93
|
+
system: ScopedBridgeManager;
|
|
94
|
+
bank: Bank;
|
|
95
|
+
};
|
|
88
96
|
export type LocalChainPowers = {
|
|
89
|
-
system:
|
|
90
|
-
bankManager: import("
|
|
97
|
+
system: ScopedBridgeManager;
|
|
98
|
+
bankManager: import("@endo/exo").Guarded<{
|
|
99
|
+
getAssetSubscription(): globalThis.IterableEachTopic<import("./vat-bank.js").AssetDescriptor>;
|
|
100
|
+
getRewardDistributorDepositFacet(denom: string, feeKit: AssetIssuerKit): globalThis.ERef<{
|
|
101
|
+
/**
|
|
102
|
+
* Deposit all the contents of payment
|
|
103
|
+
* into the purse that made this facet, returning the amount. If the optional
|
|
104
|
+
* argument `optAmount` does not equal the amount of digital assets in the
|
|
105
|
+
* payment, throw an error.
|
|
106
|
+
*
|
|
107
|
+
* If payment is a promise, throw an error.
|
|
108
|
+
*/
|
|
109
|
+
receive: (args_0: globalThis.Payment, args_1?: globalThis.Pattern) => globalThis.ERef<globalThis.Amount>;
|
|
110
|
+
}>;
|
|
111
|
+
getModuleAccountAddress(moduleName: string): Promise<string | null>;
|
|
112
|
+
addAsset(denom: string, issuerName: string, proposedName: string, kit: AssetIssuerKit & {
|
|
113
|
+
payment?: ERef<Payment>;
|
|
114
|
+
}): Promise<void>;
|
|
115
|
+
getBankForAddress(address: string): Promise<Bank>;
|
|
116
|
+
}>;
|
|
91
117
|
};
|
|
92
|
-
export type PowerStore = MapStore<keyof LocalChainPowers, LocalChainPowers[keyof LocalChainPowers]>;
|
|
93
118
|
export type LocalChainAccount = Awaited<ReturnType<Awaited<ReturnType<typeof prepareLocalChainAccount>>>>;
|
|
94
119
|
export type LocalChainTools = ReturnType<typeof prepareLocalChainTools>;
|
|
95
|
-
export type
|
|
96
|
-
export type LocalChain = LocalChainKit["public"];
|
|
120
|
+
export type LocalChain = ReturnType<LocalChainTools["makeLocalChain"]>;
|
|
97
121
|
import type { ResponseTo } from '@agoric/cosmic-proto';
|
|
122
|
+
import type { ScopedBridgeManager } from './types.js';
|
|
123
|
+
import type { Bank } from './vat-bank.js';
|
|
98
124
|
/** @param {import('@agoric/base-zone').Zone} zone */
|
|
99
|
-
declare function prepareLocalChainAccount(zone: import("@agoric/base-zone").Zone): (address: string, powers:
|
|
125
|
+
declare function prepareLocalChainAccount(zone: import("@agoric/base-zone").Zone): (address: string, powers: AccountPowers) => import("@endo/exo").Guarded<{
|
|
100
126
|
getAddress(): Promise<string>;
|
|
101
127
|
/**
|
|
102
128
|
* Deposit a payment into the bank purse that matches the alleged brand.
|
package/src/localchain.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localchain.d.ts","sourceRoot":"","sources":["localchain.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"localchain.d.ts","sourceRoot":"","sources":["localchain.js"],"names":[],"mappings":"AAOA;;;GAGG;AAEH,mEAAmE;AAEnE;;;;;GAKG;AAEH;;;;;GAKG;AAEH;;;;GAMG;AAwDH;;;;GAIG;AAEH;;;;GAIG;AAwEI,6CADK,OAAO,mBAAmB,EAAE,IAAI;;QAxDtC;;;;;WAKG;;;YArEH;;;;;;eAMG;6BADQ,OAAO;YASlB;;;;;;;;eAQG;sBADgD,EAAE;;2BAAF,EAAE,AADxC;;QA0Db;;;;;;;WAOG;uBAFQ,OAAO,sBAAsB,EAAE,SAAS,GACtC,OAAO,CAAC,OAAO,sBAAsB,EAAE,SAAS,CAAC;QAa9D;;;;;;;;;;;;WAYG;4BAPQ,OAAO,sBAAsB,EAAE,SAAS,EAAE,GACxC,OAAO,CACnB;YACA,KAAW,CAAC,EAAE,MAAM,CAAC;YACrB,KAAW,EAAE,OAAO,sBAAsB,EAAE,SAAS,CAAC;SACjD,EAAE,CACJ;;EAkBT;;;;;;;;;gEAKgua,cAAc;;;;;;;;;;;;+EAAgiD,cAAc,GAAE;YAAE,OAAQ,CAAC,EAAC,KAAM,OAAO,CAAC,CAAA;SAAE;;;;gCA3F9yd,OAAO,CACnB,UAAc,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CACjE;8BAuFU,UAAU,CAAC,OAAO,sBAAsB,CAAC;yBACzC,UAAU,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;gCAzKlB,sBAAsB;yCAHzB,YAAY;0BADd,eAAe;AA4BnD,qDAAqD;AACrD,gDADY,OAAO,mBAAmB,EAAE,IAAI;;IAetC;;;;;;OAMG;qBADQ,OAAO;IASlB;;;;;;;;OAQG;cADgD,EAAE;;mBAAF,EAAE,AADxC;GAkBhB"}
|
package/src/localchain.js
CHANGED
|
@@ -3,31 +3,28 @@ import { E } from '@endo/far';
|
|
|
3
3
|
import { M } from '@endo/patterns';
|
|
4
4
|
import { AmountShape } from '@agoric/ertp';
|
|
5
5
|
|
|
6
|
-
const { Fail
|
|
6
|
+
const { Fail } = assert;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @import {BankManager, Bank} from './vat-bank.js';
|
|
10
|
+
* @import {ScopedBridgeManager} from './types.js';
|
|
11
|
+
*/
|
|
7
12
|
|
|
8
13
|
/** @import {TypedJson, ResponseTo} from '@agoric/cosmic-proto'; */
|
|
9
14
|
|
|
10
15
|
/**
|
|
11
16
|
* @typedef {{
|
|
12
|
-
* system:
|
|
13
|
-
*
|
|
14
|
-
* }}
|
|
15
|
-
*
|
|
16
|
-
* @typedef {MapStore<
|
|
17
|
-
* keyof LocalChainPowers,
|
|
18
|
-
* LocalChainPowers[keyof LocalChainPowers]
|
|
19
|
-
* >} PowerStore
|
|
17
|
+
* system: ScopedBridgeManager;
|
|
18
|
+
* bank: Bank;
|
|
19
|
+
* }} AccountPowers
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* @
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* @typedef {{
|
|
24
|
+
* system: ScopedBridgeManager;
|
|
25
|
+
* bankManager: BankManager;
|
|
26
|
+
* }} LocalChainPowers
|
|
26
27
|
*/
|
|
27
|
-
const getPower = (powers, name) => {
|
|
28
|
-
powers.has(name) || Fail`need powers.${bare(name)} for this method`;
|
|
29
|
-
return /** @type {LocalChainPowers[K]} */ (powers.get(name));
|
|
30
|
-
};
|
|
31
28
|
|
|
32
29
|
export const LocalChainAccountI = M.interface('LocalChainAccount', {
|
|
33
30
|
getAddress: M.callWhen().returns(M.string()),
|
|
@@ -44,9 +41,9 @@ const prepareLocalChainAccount = zone =>
|
|
|
44
41
|
LocalChainAccountI,
|
|
45
42
|
/**
|
|
46
43
|
* @param {string} address
|
|
47
|
-
* @param {
|
|
44
|
+
* @param {AccountPowers} powers
|
|
48
45
|
*/
|
|
49
|
-
(address, powers) => ({ address, powers }),
|
|
46
|
+
(address, powers) => ({ address, ...powers, reserved: undefined }),
|
|
50
47
|
{
|
|
51
48
|
// Information that the account creator needs.
|
|
52
49
|
async getAddress() {
|
|
@@ -60,14 +57,11 @@ const prepareLocalChainAccount = zone =>
|
|
|
60
57
|
* @param {Payment} payment
|
|
61
58
|
*/
|
|
62
59
|
async deposit(payment) {
|
|
63
|
-
const {
|
|
64
|
-
|
|
65
|
-
const bankManager = getPower(powers, 'bankManager');
|
|
60
|
+
const { bank } = this.state;
|
|
66
61
|
|
|
67
62
|
const allegedBrand = await E(payment).getAllegedBrand();
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
return E(allegedPurse).deposit(payment);
|
|
63
|
+
const purse = E(bank).getPurse(allegedBrand);
|
|
64
|
+
return E(purse).deposit(payment);
|
|
71
65
|
},
|
|
72
66
|
/**
|
|
73
67
|
* Execute a batch of transactions and return the responses. Use
|
|
@@ -79,7 +73,7 @@ const prepareLocalChainAccount = zone =>
|
|
|
79
73
|
* @returns {Promise<{ [K in keyof MT]: ResponseTo<MT[K]> }>}
|
|
80
74
|
*/
|
|
81
75
|
async executeTx(messages) {
|
|
82
|
-
const { address,
|
|
76
|
+
const { address, system } = this.state;
|
|
83
77
|
messages.length > 0 || Fail`need at least one message to execute`;
|
|
84
78
|
|
|
85
79
|
const obj = {
|
|
@@ -90,7 +84,6 @@ const prepareLocalChainAccount = zone =>
|
|
|
90
84
|
address,
|
|
91
85
|
messages,
|
|
92
86
|
};
|
|
93
|
-
const system = getPower(powers, 'system');
|
|
94
87
|
return E(system).toBridge(obj);
|
|
95
88
|
},
|
|
96
89
|
},
|
|
@@ -107,105 +100,71 @@ export const LocalChainI = M.interface('LocalChain', {
|
|
|
107
100
|
queryMany: M.callWhen(M.arrayOf(M.record())).returns(M.arrayOf(M.record())),
|
|
108
101
|
});
|
|
109
102
|
|
|
110
|
-
export const LocalChainAdminI = M.interface('LocalChainAdmin', {
|
|
111
|
-
setPower: M.callWhen(M.string(), M.await(M.any())).returns(),
|
|
112
|
-
});
|
|
113
|
-
|
|
114
103
|
/**
|
|
115
104
|
* @param {import('@agoric/base-zone').Zone} zone
|
|
116
105
|
* @param {ReturnType<typeof prepareLocalChainAccount>} makeAccount
|
|
117
106
|
*/
|
|
118
107
|
const prepareLocalChain = (zone, makeAccount) =>
|
|
119
|
-
zone.
|
|
108
|
+
zone.exoClass(
|
|
120
109
|
'LocalChain',
|
|
121
|
-
|
|
122
|
-
/** @param {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const powers = zone.detached().mapStore('PowerStore');
|
|
126
|
-
if (initialPowers) {
|
|
127
|
-
for (const [name, power] of Object.entries(initialPowers)) {
|
|
128
|
-
powers.init(/** @type {keyof LocalChainPowers} */ (name), power);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return { powers };
|
|
110
|
+
LocalChainI,
|
|
111
|
+
/** @param {LocalChainPowers} powers */
|
|
112
|
+
powers => {
|
|
113
|
+
return { ...powers };
|
|
132
114
|
},
|
|
133
115
|
{
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
powers.set(name, power);
|
|
148
|
-
} else {
|
|
149
|
-
// Add a new power.
|
|
150
|
-
powers.init(name, power);
|
|
151
|
-
}
|
|
152
|
-
},
|
|
116
|
+
/**
|
|
117
|
+
* Allocate a fresh address that doesn't correspond with a public key, and
|
|
118
|
+
* follows the ICA guidelines to help reduce collisions. See
|
|
119
|
+
* x/vlocalchain/keeper/keeper.go AllocateAddress for the use of the app
|
|
120
|
+
* hash and block data hash.
|
|
121
|
+
*/
|
|
122
|
+
async makeAccount() {
|
|
123
|
+
const { system, bankManager } = this.state;
|
|
124
|
+
const address = await E(system).toBridge({
|
|
125
|
+
type: 'VLOCALCHAIN_ALLOCATE_ADDRESS',
|
|
126
|
+
});
|
|
127
|
+
const bank = await E(bankManager).getBankForAddress(address);
|
|
128
|
+
return makeAccount(address, { system, bank });
|
|
153
129
|
},
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
*
|
|
193
|
-
* @param {import('@agoric/cosmic-proto').TypedJson[]} requests
|
|
194
|
-
* @returns {Promise<
|
|
195
|
-
* {
|
|
196
|
-
* error?: string;
|
|
197
|
-
* reply: import('@agoric/cosmic-proto').TypedJson;
|
|
198
|
-
* }[]
|
|
199
|
-
* >}
|
|
200
|
-
*/
|
|
201
|
-
async queryMany(requests) {
|
|
202
|
-
const { powers } = this.state;
|
|
203
|
-
const system = getPower(powers, 'system');
|
|
204
|
-
return E(system).toBridge({
|
|
205
|
-
type: 'VLOCALCHAIN_QUERY_MANY',
|
|
206
|
-
messages: requests,
|
|
207
|
-
});
|
|
208
|
-
},
|
|
130
|
+
/**
|
|
131
|
+
* Make a single query to the local chain. Will reject with an error if
|
|
132
|
+
* the query fails. Otherwise, return the response as a JSON-compatible
|
|
133
|
+
* object.
|
|
134
|
+
*
|
|
135
|
+
* @param {import('@agoric/cosmic-proto').TypedJson} request
|
|
136
|
+
* @returns {Promise<import('@agoric/cosmic-proto').TypedJson>}
|
|
137
|
+
*/
|
|
138
|
+
async query(request) {
|
|
139
|
+
const requests = harden([request]);
|
|
140
|
+
const results = await E(this.self).queryMany(requests);
|
|
141
|
+
results.length === 1 ||
|
|
142
|
+
Fail`expected exactly one result; got ${results}`;
|
|
143
|
+
const { error, reply } = results[0];
|
|
144
|
+
if (error) {
|
|
145
|
+
throw Fail`query failed: ${error}`;
|
|
146
|
+
}
|
|
147
|
+
return reply;
|
|
148
|
+
},
|
|
149
|
+
/**
|
|
150
|
+
* Send a batch of query requests to the local chain. Unless there is a
|
|
151
|
+
* system error, will return all results to indicate their success or
|
|
152
|
+
* failure.
|
|
153
|
+
*
|
|
154
|
+
* @param {import('@agoric/cosmic-proto').TypedJson[]} requests
|
|
155
|
+
* @returns {Promise<
|
|
156
|
+
* {
|
|
157
|
+
* error?: string;
|
|
158
|
+
* reply: import('@agoric/cosmic-proto').TypedJson;
|
|
159
|
+
* }[]
|
|
160
|
+
* >}
|
|
161
|
+
*/
|
|
162
|
+
async queryMany(requests) {
|
|
163
|
+
const { system } = this.state;
|
|
164
|
+
return E(system).toBridge({
|
|
165
|
+
type: 'VLOCALCHAIN_QUERY_MANY',
|
|
166
|
+
messages: requests,
|
|
167
|
+
});
|
|
209
168
|
},
|
|
210
169
|
},
|
|
211
170
|
);
|
|
@@ -220,5 +179,4 @@ export const prepareLocalChainTools = zone => {
|
|
|
220
179
|
harden(prepareLocalChainTools);
|
|
221
180
|
|
|
222
181
|
/** @typedef {ReturnType<typeof prepareLocalChainTools>} LocalChainTools */
|
|
223
|
-
/** @typedef {ReturnType<LocalChainTools['makeLocalChain']>}
|
|
224
|
-
/** @typedef {LocalChainKit['public']} LocalChain */
|
|
182
|
+
/** @typedef {ReturnType<LocalChainTools['makeLocalChain']>} LocalChain */
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
export function setupLocalChainVat({ consume: { loadCriticalVat, bridgeManager: bridgeManagerP, localchainBridgeManager: localchainBridgeManagerP, bankManager, }, produce: { localchainVat, localchain,
|
|
1
|
+
export function setupLocalChainVat({ consume: { loadCriticalVat, bridgeManager: bridgeManagerP, localchainBridgeManager: localchainBridgeManagerP, bankManager, }, produce: { localchainVat, localchain, localchainBridgeManager }, }: BootstrapPowers & {
|
|
2
2
|
consume: {
|
|
3
3
|
loadCriticalVat: VatLoader<any>;
|
|
4
|
-
bridgeManager: import("../types").BridgeManager;
|
|
5
4
|
localchainBridgeManager: import("../types").ScopedBridgeManager;
|
|
6
|
-
bankManager: Promise<import("../vat-bank.js").BankManager>;
|
|
7
5
|
};
|
|
8
6
|
produce: {
|
|
9
7
|
localchain: Producer<any>;
|
|
10
|
-
localchainAdmin: Producer<any>;
|
|
11
8
|
localchainVat: Producer<any>;
|
|
12
9
|
localchainBridgeManager: Producer<any>;
|
|
13
10
|
};
|
|
@@ -37,7 +34,6 @@ export function getManifestForLocalChain(_powers: any, { localchainRef }: {
|
|
|
37
34
|
};
|
|
38
35
|
produce: {
|
|
39
36
|
localchain: string;
|
|
40
|
-
localchainAdmin: string;
|
|
41
37
|
localchainVat: string;
|
|
42
38
|
localchainBridgeManager: string;
|
|
43
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localchain-proposal.d.ts","sourceRoot":"","sources":["localchain-proposal.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"localchain-proposal.d.ts","sourceRoot":"","sources":["localchain-proposal.js"],"names":[],"mappings":"AAuBO,uOAlBI,eAAe,GAAG;IAC5B,OAAW,EAAE;QACb,eAAqB,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;QACtC,uBAA6B,EAAE,OAAO,UAAU,EAAE,mBAAmB,CAAC;KACjE,CAAC;IACN,OAAW,EAAE;QACb,UAAgB,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChC,aAAmB,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;QACnC,uBAA6B,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;KACxC,CAAC;CACH;IAEgD,OAAO,EAAhD;QAAE,aAAa,EAAE,YAAY,CAAA;KAAE;kBA0DzC;AAUM,2EAPI,eAAe,GAAG;IAC5B,OAAW,EAAE;QACb,UAAgB,EAAE,OAAO,kBAAkB,EAAE,UAAU,CAAC;KACnD,CAAC;CACH,YACO,MAAM,iBAOhB;AAEM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2BL;6BApGW;IACZ,UAAc,EAAE,IAAI,CAAC,OAAO,sBAAsB,EAAE,aAAa,CAAC,CAAC;CAChE"}
|
|
@@ -6,13 +6,10 @@ import { BridgeId as BRIDGE_ID } from '@agoric/internal';
|
|
|
6
6
|
* @param {BootstrapPowers & {
|
|
7
7
|
* consume: {
|
|
8
8
|
* loadCriticalVat: VatLoader<any>;
|
|
9
|
-
* bridgeManager: import('../types').BridgeManager;
|
|
10
9
|
* localchainBridgeManager: import('../types').ScopedBridgeManager;
|
|
11
|
-
* bankManager: Promise<import('../vat-bank.js').BankManager>;
|
|
12
10
|
* };
|
|
13
11
|
* produce: {
|
|
14
12
|
* localchain: Producer<any>;
|
|
15
|
-
* localchainAdmin: Producer<any>;
|
|
16
13
|
* localchainVat: Producer<any>;
|
|
17
14
|
* localchainBridgeManager: Producer<any>;
|
|
18
15
|
* };
|
|
@@ -32,12 +29,7 @@ export const setupLocalChainVat = async (
|
|
|
32
29
|
localchainBridgeManager: localchainBridgeManagerP,
|
|
33
30
|
bankManager,
|
|
34
31
|
},
|
|
35
|
-
produce: {
|
|
36
|
-
localchainVat,
|
|
37
|
-
localchain,
|
|
38
|
-
localchainAdmin: localchainAdminP,
|
|
39
|
-
localchainBridgeManager,
|
|
40
|
-
},
|
|
32
|
+
produce: { localchainVat, localchain, localchainBridgeManager },
|
|
41
33
|
},
|
|
42
34
|
options,
|
|
43
35
|
) => {
|
|
@@ -74,34 +66,13 @@ export const setupLocalChainVat = async (
|
|
|
74
66
|
);
|
|
75
67
|
}
|
|
76
68
|
|
|
77
|
-
const
|
|
78
|
-
vats.localchain,
|
|
79
|
-
).makeLocalChain({
|
|
69
|
+
const newLocalChain = await E(vats.localchain).makeLocalChain({
|
|
80
70
|
system: scopedManager,
|
|
71
|
+
bankManager: await bankManager,
|
|
81
72
|
});
|
|
82
73
|
|
|
83
74
|
localchain.reset();
|
|
84
75
|
localchain.resolve(newLocalChain);
|
|
85
|
-
localchainAdminP.reset();
|
|
86
|
-
localchainAdminP.resolve(localChainAdmin);
|
|
87
|
-
|
|
88
|
-
/** @type {Record<string, Promise<void>>} */
|
|
89
|
-
const descToPromise = {
|
|
90
|
-
'bank manager power': bankManager.then(bm =>
|
|
91
|
-
E(localChainAdmin).setPower('bankManager', bm),
|
|
92
|
-
),
|
|
93
|
-
};
|
|
94
|
-
void Promise.all(
|
|
95
|
-
Object.entries(descToPromise).map(([desc, p]) =>
|
|
96
|
-
p
|
|
97
|
-
.then(() =>
|
|
98
|
-
console.info(`Completed configuration of localchain with ${desc}`),
|
|
99
|
-
)
|
|
100
|
-
.catch(e =>
|
|
101
|
-
console.error(`Failed to configure localchain with ${desc}:`, e),
|
|
102
|
-
),
|
|
103
|
-
),
|
|
104
|
-
);
|
|
105
76
|
};
|
|
106
77
|
|
|
107
78
|
/**
|
|
@@ -131,7 +102,6 @@ export const getManifestForLocalChain = (_powers, { localchainRef }) => ({
|
|
|
131
102
|
},
|
|
132
103
|
produce: {
|
|
133
104
|
localchain: 'localchain',
|
|
134
|
-
localchainAdmin: 'localchain',
|
|
135
105
|
localchainVat: 'localchain',
|
|
136
106
|
localchainBridgeManager: 'localchain',
|
|
137
107
|
},
|
package/src/vat-localchain.d.ts
CHANGED
|
@@ -3,60 +3,50 @@ export function buildRootObject(_vatPowers: any, _args: any, baggage: any): {
|
|
|
3
3
|
* Create a local chain that allows permissionlessly making fresh local
|
|
4
4
|
* chain accounts, then using them to send chain queries and transactions.
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {import('./localchain.js').LocalChainPowers} powers
|
|
7
7
|
*/
|
|
8
|
-
makeLocalChain(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
makeAccount(): Promise<import("@endo/exo").Guarded<{
|
|
14
|
-
getAddress(): Promise<string>;
|
|
15
|
-
deposit(payment: Payment): Promise<import("@agoric/ertp/exported.js").NatAmount | import("@agoric/ertp/exported.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").CopyBagAmount<import("@endo/patterns").Key>>;
|
|
16
|
-
executeTx<MT extends {
|
|
17
|
-
'@type': string;
|
|
18
|
-
}[]>(messages: MT): Promise<{ [K_1 in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K_1]>; }>;
|
|
19
|
-
}>>;
|
|
20
|
-
query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
|
|
8
|
+
makeLocalChain(powers: import("./localchain.js").LocalChainPowers): import("@endo/exo").Guarded<{
|
|
9
|
+
makeAccount(): Promise<import("@endo/exo").Guarded<{
|
|
10
|
+
getAddress(): Promise<string>;
|
|
11
|
+
deposit(payment: Payment): Promise<import("@agoric/ertp/exported.js").NatAmount | import("@agoric/ertp/exported.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").CopyBagAmount<import("@endo/patterns").Key>>;
|
|
12
|
+
executeTx<MT extends {
|
|
21
13
|
'@type': string;
|
|
22
|
-
}>;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]>; }>;
|
|
15
|
+
}>>;
|
|
16
|
+
query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
|
|
17
|
+
'@type': string;
|
|
18
|
+
}>;
|
|
19
|
+
queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
|
|
20
|
+
error?: string | undefined;
|
|
21
|
+
reply: {
|
|
22
|
+
'@type': string;
|
|
23
|
+
};
|
|
24
|
+
}[]>;
|
|
30
25
|
}>;
|
|
31
26
|
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
32
27
|
/**
|
|
33
28
|
* Create a local chain that allows permissionlessly making fresh local
|
|
34
29
|
* chain accounts, then using them to send chain queries and transactions.
|
|
35
30
|
*
|
|
36
|
-
* @param {
|
|
31
|
+
* @param {import('./localchain.js').LocalChainPowers} powers
|
|
37
32
|
*/
|
|
38
|
-
makeLocalChain(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
makeLocalChain(powers: import("./localchain.js").LocalChainPowers): import("@endo/exo").Guarded<{
|
|
34
|
+
makeAccount(): Promise<import("@endo/exo").Guarded<{
|
|
35
|
+
getAddress(): Promise<string>;
|
|
36
|
+
deposit(payment: Payment): Promise<import("@agoric/ertp/exported.js").NatAmount | import("@agoric/ertp/exported.js").CopySetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").SetAmount<import("@endo/patterns").Key> | import("@agoric/ertp/exported.js").CopyBagAmount<import("@endo/patterns").Key>>;
|
|
37
|
+
executeTx<MT extends {
|
|
38
|
+
'@type': string;
|
|
39
|
+
}[]>(messages: MT): Promise<{ [K in keyof MT]: import("@agoric/cosmic-proto").ResponseTo<MT[K]>; }>;
|
|
40
|
+
}>>;
|
|
41
|
+
query(request: import("@agoric/cosmic-proto").TypedJson): Promise<{
|
|
42
|
+
'@type': string;
|
|
43
|
+
}>;
|
|
44
|
+
queryMany(requests: import("@agoric/cosmic-proto").TypedJson[]): Promise<{
|
|
45
|
+
error?: string | undefined;
|
|
46
|
+
reply: {
|
|
51
47
|
'@type': string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
error?: string | undefined;
|
|
55
|
-
reply: {
|
|
56
|
-
'@type': string;
|
|
57
|
-
};
|
|
58
|
-
}[]>;
|
|
59
|
-
};
|
|
48
|
+
};
|
|
49
|
+
}[]>;
|
|
60
50
|
}>;
|
|
61
51
|
}>;
|
|
62
52
|
export type LocalChainVat = ReturnType<typeof buildRootObject>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vat-localchain.d.ts","sourceRoot":"","sources":["vat-localchain.js"],"names":[],"mappings":"AAMO;IAKH;;;;;OAKG;;;
|
|
1
|
+
{"version":3,"file":"vat-localchain.d.ts","sourceRoot":"","sources":["vat-localchain.js"],"names":[],"mappings":"AAMO;IAKH;;;;;OAKG;2BADQ,OAAO,iBAAiB,EAAE,gBAAgB;;;6BAS+sB,OAAO;;;2BAA+iB,EAAE;;uBAA6oE,OAAO,sBAAsB,EAAE,SAAS;;;4BAAyqB,OAAO,sBAAsB,EAAE,SAAS,EAAE;;;;;;;;IAbpsI;;;;;OAKG;2BADQ,OAAO,iBAAiB,EAAE,gBAAgB;;;;;;;;sDASm7G,SAAS;;;2DAAwsB,SAAS;;;;;;;GAHrsI;4BAEa,UAAU,CAAC,OAAO,eAAe,CAAC"}
|
package/src/vat-localchain.js
CHANGED
|
@@ -13,10 +13,10 @@ export const buildRootObject = (_vatPowers, _args, baggage) => {
|
|
|
13
13
|
* Create a local chain that allows permissionlessly making fresh local
|
|
14
14
|
* chain accounts, then using them to send chain queries and transactions.
|
|
15
15
|
*
|
|
16
|
-
* @param {
|
|
16
|
+
* @param {import('./localchain.js').LocalChainPowers} powers
|
|
17
17
|
*/
|
|
18
|
-
makeLocalChain(
|
|
19
|
-
return makeLocalChain(
|
|
18
|
+
makeLocalChain(powers) {
|
|
19
|
+
return makeLocalChain(powers);
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
22
|
};
|