@agoric/client-utils 0.1.1-upgrade-20-dev-086463b.0 → 0.1.1-upgrade-21-dev-43b4090.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/README.md +8 -0
- package/package.json +15 -13
- package/src/chain.d.ts +11 -0
- package/src/chain.d.ts.map +1 -0
- package/src/cli.d.ts +6 -0
- package/src/cli.d.ts.map +1 -0
- package/src/clock-timer.d.ts +9 -0
- package/src/clock-timer.d.ts.map +1 -0
- package/src/main.d.ts +12 -0
- package/src/main.d.ts.map +1 -0
- package/src/main.js +4 -1
- package/src/network-config.d.ts +15 -0
- package/src/network-config.d.ts.map +1 -0
- package/src/rpc.d.ts +13 -0
- package/src/rpc.d.ts.map +1 -0
- package/src/smart-wallet-kit.d.ts +46 -0
- package/src/smart-wallet-kit.d.ts.map +1 -0
- package/src/sync-tools.d.ts +72 -0
- package/src/sync-tools.d.ts.map +1 -0
- package/src/sync-tools.js +13 -14
- package/src/types-index.d.ts +2 -0
- package/src/types.d.ts +22 -48
- package/src/types.d.ts.map +1 -0
- package/src/types.ts +58 -0
- package/src/vstorage-kit.d.ts +53 -0
- package/src/vstorage-kit.d.ts.map +1 -0
- package/src/vstorage-kit.js +5 -6
- package/src/vstorage.d.ts +45 -0
- package/src/vstorage.d.ts.map +1 -0
- package/src/vstorage.js +96 -84
- package/src/wallet-utils.d.ts +42 -0
- package/src/wallet-utils.d.ts.map +1 -0
- /package/src/{types.js → types-index.js} +0 -0
package/README.md
CHANGED
|
@@ -15,6 +15,14 @@ This package will be used in several kinds of clients:
|
|
|
15
15
|
|
|
16
16
|
As such the modules cannot assume they're running in Node. There are some ambient authorities in common in the above environments (e.g. `setTimeout`) but a further constraint is that these modules will not export ambient authority. Instead they will provide interfaces that are ergonomic for creating empowered objects in the client context.
|
|
17
17
|
|
|
18
|
+
### Layering
|
|
19
|
+
|
|
20
|
+
1. HTTP (fetch)
|
|
21
|
+
2. RPC (fetch + cosmic-proto)
|
|
22
|
+
3. vstorage - layer at which protobuf is involved (vstorage.js)
|
|
23
|
+
4. marshalling (vstorage-kit.js)
|
|
24
|
+
5. agoricNames / board (smart-wallet-kit.js)
|
|
25
|
+
|
|
18
26
|
## Related packages
|
|
19
27
|
|
|
20
28
|
### cli
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/client-utils",
|
|
3
|
-
"version": "0.1.1-upgrade-
|
|
3
|
+
"version": "0.1.1-upgrade-21-dev-43b4090.0+43b4090",
|
|
4
4
|
"description": "Utilities for building Agoric clients",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -13,26 +13,28 @@
|
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "exit 0",
|
|
16
|
+
"prepack": "tsc --build tsconfig.build.json",
|
|
17
|
+
"postpack": "git clean -f '*.d.ts*' '*.tsbuildinfo'",
|
|
16
18
|
"test": "ava",
|
|
17
19
|
"test:c8": "c8 --all $C8_OPTIONS ava",
|
|
18
20
|
"test:xs": "exit 0",
|
|
19
21
|
"lint-fix": "yarn lint:eslint --fix",
|
|
20
|
-
"lint": "run-s --continue-on-error lint:*",
|
|
21
|
-
"lint:
|
|
22
|
-
"lint:
|
|
22
|
+
"lint": "yarn run -T run-s --continue-on-error 'lint:*'",
|
|
23
|
+
"lint:eslint": "yarn run -T eslint .",
|
|
24
|
+
"lint:types": "yarn run -T tsc"
|
|
23
25
|
},
|
|
24
26
|
"devDependencies": {
|
|
25
27
|
"ava": "^5.3.0",
|
|
26
|
-
"c8": "^10.1.
|
|
27
|
-
"ts-blank-space": "^0.
|
|
28
|
+
"c8": "^10.1.3",
|
|
29
|
+
"ts-blank-space": "^0.6.1"
|
|
28
30
|
},
|
|
29
31
|
"dependencies": {
|
|
30
|
-
"@agoric/casting": "
|
|
31
|
-
"@agoric/cosmic-proto": "
|
|
32
|
-
"@agoric/ertp": "
|
|
33
|
-
"@agoric/internal": "
|
|
34
|
-
"@agoric/smart-wallet": "
|
|
35
|
-
"@agoric/vats": "
|
|
32
|
+
"@agoric/casting": "workspace:*",
|
|
33
|
+
"@agoric/cosmic-proto": "workspace:*",
|
|
34
|
+
"@agoric/ertp": "workspace:*",
|
|
35
|
+
"@agoric/internal": "workspace:*",
|
|
36
|
+
"@agoric/smart-wallet": "workspace:*",
|
|
37
|
+
"@agoric/vats": "workspace:*",
|
|
36
38
|
"@cosmjs/stargate": "^0.33.0",
|
|
37
39
|
"@cosmjs/tendermint-rpc": "^0.33.0",
|
|
38
40
|
"@endo/base64": "^1.0.9",
|
|
@@ -60,5 +62,5 @@
|
|
|
60
62
|
],
|
|
61
63
|
"timeout": "20m"
|
|
62
64
|
},
|
|
63
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "43b409040628dd3706a1279098534d3cf1d18ab7"
|
|
64
66
|
}
|
package/src/chain.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function pollBlocks(opts: {
|
|
2
|
+
client: StargateClient;
|
|
3
|
+
delay: (ms: number) => Promise<void>;
|
|
4
|
+
period?: number;
|
|
5
|
+
retryMessage?: string;
|
|
6
|
+
}): <T>(l: (b: {
|
|
7
|
+
time: string;
|
|
8
|
+
height: number;
|
|
9
|
+
}) => Promise<T>) => Promise<T>;
|
|
10
|
+
import type { StargateClient } from '@cosmjs/stargate';
|
|
11
|
+
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["chain.js"],"names":[],"mappings":"AAaO,iCARI;IACN,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GACS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CA2BrF;oCArCgC,kBAAkB"}
|
package/src/cli.d.ts
ADDED
package/src/cli.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["cli.js"],"names":[],"mappings":"AAeO,sDAJI;IAAE,GAAG,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC;IAAC,KAAK,EAAE,uBAAY,CAAA;CAAE,GAC9C,OAAO,CAAC,oBAAoB,CAAC,CAOzC;0CAhBsC,qBAAqB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function makeIntervalIterable(intervalMs: number, { setTimeout, clearTimeout, now }: IntervalIO): {
|
|
2
|
+
[Symbol.asyncIterator]: () => AsyncGenerator<number, void, void>;
|
|
3
|
+
};
|
|
4
|
+
export type IntervalIO = {
|
|
5
|
+
setTimeout: typeof setTimeout;
|
|
6
|
+
clearTimeout: typeof clearTimeout;
|
|
7
|
+
now: typeof Date.now;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=clock-timer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clock-timer.d.ts","sourceRoot":"","sources":["clock-timer.js"],"names":[],"mappings":"AAiBO,iDANI,MAAM,qCACN,UAAU,GACR;IACZ,CAAK,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;CACjE,CAkCH;;gBA7Ca,OAAO,UAAU;kBACjB,OAAO,YAAY;SACnB,OAAO,IAAI,CAAC,GAAG"}
|
package/src/main.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { VBankAccount };
|
|
2
|
+
export * from "./cli.js";
|
|
3
|
+
export * from "./network-config.js";
|
|
4
|
+
export * from "./rpc.js";
|
|
5
|
+
export * from "./smart-wallet-kit.js";
|
|
6
|
+
export * from "./sync-tools.js";
|
|
7
|
+
export * from "./vstorage.js";
|
|
8
|
+
export * from "./vstorage-kit.js";
|
|
9
|
+
export * from "./wallet-utils.js";
|
|
10
|
+
export * from "./types-index.js";
|
|
11
|
+
import { VBankAccount } from '@agoric/internal/src/config.js';
|
|
12
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.js"],"names":[],"mappings":";;;;;;;;;;6BAA6B,gCAAgC"}
|
package/src/main.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { VBankAccount } from '@agoric/internal/src/config.js';
|
|
2
|
+
|
|
3
|
+
export { VBankAccount };
|
|
1
4
|
export * from './cli.js';
|
|
2
5
|
export * from './network-config.js';
|
|
3
6
|
export * from './rpc.js';
|
|
@@ -8,4 +11,4 @@ export * from './vstorage-kit.js';
|
|
|
8
11
|
export * from './wallet-utils.js';
|
|
9
12
|
|
|
10
13
|
// eslint-disable-next-line import/export -- just types
|
|
11
|
-
export * from './types.js';
|
|
14
|
+
export * from './types-index.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function toNetworkConfigUrl(agoricNetSubdomain: any): string;
|
|
2
|
+
export function toRpcUrl(agoricNetSubdomain: any): string;
|
|
3
|
+
export namespace LOCAL_CONFIG {
|
|
4
|
+
let rpcAddrs: string[];
|
|
5
|
+
let chainName: string;
|
|
6
|
+
}
|
|
7
|
+
export const LOCAL_CONFIG_KEY: "local";
|
|
8
|
+
export function fetchNetworkConfig(spec: string, { fetch }: {
|
|
9
|
+
fetch: typeof globalThis.fetch;
|
|
10
|
+
}): Promise<MinimalNetworkConfig>;
|
|
11
|
+
export type MinimalNetworkConfig = {
|
|
12
|
+
rpcAddrs: string[];
|
|
13
|
+
chainName: string;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=network-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-config.d.ts","sourceRoot":"","sources":["network-config.js"],"names":[],"mappings":"AAIO,oEACoD;AAEpD,0DAC6C;;;;;AAQpD,+BAAgC,OAAO,CAAC;AASjC,yCAJI,MAAM,aACN;IAAE,KAAK,EAAE,uBAAY,CAAA;CAAE,GACrB,OAAO,CAAC,oBAAoB,CAAC,CAkBzC;mCAxCY;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE"}
|
package/src/rpc.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function pickEndpoint({ rpcAddrs }: {
|
|
2
|
+
rpcAddrs: any;
|
|
3
|
+
}): any;
|
|
4
|
+
export function makeTendermint34Client(endpoint: string, { fetch }: {
|
|
5
|
+
fetch: typeof window.fetch;
|
|
6
|
+
}): Promise<Tendermint34Client>;
|
|
7
|
+
export function makeStargateClient(config: MinimalNetworkConfig, { fetch }: {
|
|
8
|
+
fetch: typeof window.fetch;
|
|
9
|
+
}): Promise<StargateClient>;
|
|
10
|
+
import { Tendermint34Client } from '@cosmjs/tendermint-rpc';
|
|
11
|
+
import type { MinimalNetworkConfig } from './network-config.js';
|
|
12
|
+
import { StargateClient } from '@cosmjs/stargate';
|
|
13
|
+
//# sourceMappingURL=rpc.d.ts.map
|
package/src/rpc.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["rpc.js"],"names":[],"mappings":"AASO;;QAAkD;AAOlD,iDAJI,MAAM,aACN;IAAE,KAAK,EAAE,OAAO,MAAM,CAAC,KAAK,CAAA;CAAE,GAC5B,OAAO,CAAC,kBAAkB,CAAC,CAKvC;AAOM,2CAJI,oBAAoB,aACpB;IAAE,KAAK,EAAE,OAAO,MAAM,CAAC,KAAK,CAAA;CAAE,GAC5B,OAAO,CAAC,cAAc,CAAC,CAMnC;mCA5BkC,wBAAwB;0CAGpB,qBAAqB;+BAJ7B,kBAAkB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export function makeSmartWalletKit({ fetch, delay }: {
|
|
2
|
+
fetch: typeof globalThis.fetch;
|
|
3
|
+
delay: (ms: number) => Promise<void>;
|
|
4
|
+
}, networkConfig: MinimalNetworkConfig): Promise<{
|
|
5
|
+
agoricNames: import("@agoric/vats/tools/board-utils.js").AgoricNamesRemotes;
|
|
6
|
+
networkConfig: MinimalNetworkConfig;
|
|
7
|
+
getLastUpdate: (addr: string) => Promise<UpdateRecord>;
|
|
8
|
+
getCurrentWalletRecord: (addr: string) => Promise<CurrentWalletRecord>;
|
|
9
|
+
storedWalletState: (from: string, minHeight?: number | string) => Promise<{
|
|
10
|
+
invitationsReceived: Map<import("@agoric/smart-wallet/src/offers.js").OfferId, {
|
|
11
|
+
acceptedIn: import("@agoric/smart-wallet/src/offers.js").OfferId;
|
|
12
|
+
description: string;
|
|
13
|
+
instance: Instance;
|
|
14
|
+
}>;
|
|
15
|
+
offerStatuses: Map<import("@agoric/smart-wallet/src/offers.js").OfferId, import("@agoric/smart-wallet/src/offers.js").OfferStatus>;
|
|
16
|
+
balances: Map<Brand, Amount>;
|
|
17
|
+
}>;
|
|
18
|
+
pollOffer: (from: string, id: string | number, minHeight: number | string, untilNumWantsSatisfied?: boolean) => Promise<import("@agoric/smart-wallet/src/offers.js").OfferStatus>;
|
|
19
|
+
fromBoard: {
|
|
20
|
+
convertSlotToVal: (boardId: any, iface: any) => any;
|
|
21
|
+
};
|
|
22
|
+
marshaller: Omit<import("@endo/marshal").Marshal<string | null>, "serialize" | "unserialize">;
|
|
23
|
+
readLatestHead: (path: string) => Promise<unknown>;
|
|
24
|
+
readPublished: <T extends string>(subpath: T) => Promise<import("./types.js").TypedPublished<T>>;
|
|
25
|
+
unserializeHead: (txt: string | {
|
|
26
|
+
value: string;
|
|
27
|
+
}) => unknown;
|
|
28
|
+
vstorage: {
|
|
29
|
+
readStorage: <T extends "children" | "data">(path?: string, { kind, height }?: {
|
|
30
|
+
kind?: T | undefined;
|
|
31
|
+
height?: number | bigint | undefined;
|
|
32
|
+
}) => Promise<T extends "children" ? import("@agoric/cosmic-proto/agoric/vstorage/query.js").QueryChildrenResponse : import("@agoric/cosmic-proto/agoric/vstorage/query.js").QueryDataResponse>;
|
|
33
|
+
readLatest(path?: string): Promise<import("@agoric/cosmic-proto/agoric/vstorage/query.js").QueryDataResponse>;
|
|
34
|
+
keys(path?: string): Promise<string[]>;
|
|
35
|
+
readAt(path: string, height?: number): Promise<import("@agoric/internal/src/lib-chainStorage.js").StreamCell<unknown>>;
|
|
36
|
+
readFully(path: string, minHeight?: number | string): Promise<string[]>;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
export type SmartWalletKit = EReturn<typeof makeSmartWalletKit>;
|
|
40
|
+
import type { MinimalNetworkConfig } from './network-config.js';
|
|
41
|
+
import type { UpdateRecord } from '@agoric/smart-wallet/src/smartWallet.js';
|
|
42
|
+
import type { CurrentWalletRecord } from '@agoric/smart-wallet/src/smartWallet.js';
|
|
43
|
+
import type { Brand } from '@agoric/ertp/src/types.js';
|
|
44
|
+
import type { Amount } from '@agoric/ertp/src/types.js';
|
|
45
|
+
import type { EReturn } from '@endo/far';
|
|
46
|
+
//# sourceMappingURL=smart-wallet-kit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-wallet-kit.d.ts","sourceRoot":"","sources":["smart-wallet-kit.js"],"names":[],"mappings":"AAqBO,qDAJJ;IAAuC,KAAK,EAApC,OAAO,UAAU,CAAC,KAAK;IACc,KAAK,EAA1C,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;CACrC,iBAAQ,oBAAoB;;;0BAoElB,MAAM,KACJ,OAAO,CAAC,YAAY,CAAC;mCAOvB,MAAM,KACJ,OAAO,CAAC,mBAAmB,CAAC;8BAnE9B,MAAM,cACN,MAAM,GAAC,MAAM;;;;;;;;;sBA0Bb,MAAM,MACN,MAAM,GAAC,MAAM,aACb,MAAM,GAAC,MAAM,2BACb,OAAO;;;;;;;;;;;;;;;;;;;;GAqDnB;6BACa,QAAQ,OAAO,kBAAkB,CAAC;0CAxGT,qBAAqB;kCADR,yCAAyC;yCAAzC,yCAAyC;2BAD7D,2BAA2B;4BAA3B,2BAA2B;6BADjC,WAAW"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export function sleep(ms: number, { log, setTimeout }: {
|
|
2
|
+
log: (message: string) => void;
|
|
3
|
+
setTimeout: typeof global.setTimeout;
|
|
4
|
+
}): Promise<any>;
|
|
5
|
+
export function retryUntilCondition<T = unknown>(operation: () => Promise<T>, condition: (result: T) => boolean, message: string, { maxRetries, retryIntervalMs, reusePromise, renderResult, log, setTimeout, }: RetryOptions & {
|
|
6
|
+
log?: typeof console.log;
|
|
7
|
+
setTimeout: typeof global.setTimeout;
|
|
8
|
+
}): Promise<T>;
|
|
9
|
+
export function waitUntilContractDeployed(contractName: string, ambientAuthority: {
|
|
10
|
+
log: (message: string) => void;
|
|
11
|
+
follow: () => object;
|
|
12
|
+
setTimeout: typeof global.setTimeout;
|
|
13
|
+
}, options: WaitUntilOptions): Promise<{
|
|
14
|
+
[k: string]: any;
|
|
15
|
+
}>;
|
|
16
|
+
export function waitUntilAccountFunded(destAcct: string, io: {
|
|
17
|
+
log?: (message: string) => void;
|
|
18
|
+
query: () => Promise<object>;
|
|
19
|
+
setTimeout: typeof global.setTimeout;
|
|
20
|
+
}, threshold: {
|
|
21
|
+
denom: string;
|
|
22
|
+
value: number;
|
|
23
|
+
}, options: WaitUntilOptions): Promise<any>;
|
|
24
|
+
export function waitUntilOfferResult(addr: string, offerId: string, waitForPayouts: boolean, io: {
|
|
25
|
+
log?: typeof console.log;
|
|
26
|
+
follow: () => object;
|
|
27
|
+
setTimeout: typeof global.setTimeout;
|
|
28
|
+
}, options: WaitUntilOptions): Promise<any>;
|
|
29
|
+
export function waitUntilInvitationReceived(addr: string, io: {
|
|
30
|
+
follow: () => object;
|
|
31
|
+
log: typeof console.log;
|
|
32
|
+
setTimeout: typeof global.setTimeout;
|
|
33
|
+
}, options: WaitUntilOptions): Promise<any>;
|
|
34
|
+
export function waitUntilOfferExited(addr: string, offerId: string, io: {
|
|
35
|
+
follow: () => object;
|
|
36
|
+
log: typeof console.log;
|
|
37
|
+
setTimeout: typeof global.setTimeout;
|
|
38
|
+
}, options: WaitUntilOptions): Promise<any>;
|
|
39
|
+
export function waitUntilElectionResult(committeePathBase: string, expectedResult: {
|
|
40
|
+
outcome: string;
|
|
41
|
+
deadline: bigint;
|
|
42
|
+
}, io: {
|
|
43
|
+
vstorage: import("./vstorage-kit").VstorageKit;
|
|
44
|
+
log: typeof console.log;
|
|
45
|
+
setTimeout: typeof global.setTimeout;
|
|
46
|
+
}, options: WaitUntilOptions): Promise<ElectionResult>;
|
|
47
|
+
export type RetryOptions = {
|
|
48
|
+
maxRetries?: number | undefined;
|
|
49
|
+
retryIntervalMs?: number | undefined;
|
|
50
|
+
reusePromise?: boolean | undefined;
|
|
51
|
+
renderResult?: ((value: unknown) => unknown) | undefined;
|
|
52
|
+
};
|
|
53
|
+
export type WaitUntilOptions = RetryOptions & {
|
|
54
|
+
errorMessage: string;
|
|
55
|
+
};
|
|
56
|
+
export type CosmosBalanceThreshold = {
|
|
57
|
+
denom: string;
|
|
58
|
+
value: number;
|
|
59
|
+
};
|
|
60
|
+
export type ElectionResult = {
|
|
61
|
+
latestOutcome: {
|
|
62
|
+
outcome: string;
|
|
63
|
+
question: import("@endo/marshal").RemotableObject;
|
|
64
|
+
};
|
|
65
|
+
latestQuestion: {
|
|
66
|
+
closingRule: {
|
|
67
|
+
deadline: bigint;
|
|
68
|
+
};
|
|
69
|
+
questionHandle: import("@endo/marshal").RemotableObject;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=sync-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-tools.d.ts","sourceRoot":"","sources":["sync-tools.js"],"names":[],"mappings":"AAmCO,0BAHI,MAAM,uBACN;IAAC,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,UAAU,EAAE,OAAO,MAAM,CAAC,UAAU,CAAA;CAAC,gBAM7E;AAYG,oCAPO,CAAC,uBACJ,MAAM,OAAO,CAAC,CAAC,CAAC,aAChB,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,WACtB,MAAM,iFACN,YAAY,GAAG;IAAC,GAAG,CAAC,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC;IAAC,UAAU,EAAE,OAAO,MAAM,CAAC,UAAU,CAAA;CAAC,GAC7E,OAAO,CAAC,CAAC,CAAC,CAqEtB;AAiCM,wDAJI,MAAM,oBACN;IAAE,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,MAAM,CAAC,UAAU,CAAA;CAAE,WAC9F,gBAAgB;;GAiB1B;AA0BM,iDALI,MAAM,MACN;IAAE,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAAC,UAAU,EAAE,OAAO,MAAM,CAAC,UAAU,CAAA;CAAC,aACtG;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,WAC9B,gBAAgB,gBAa1B;AAqCM,2CANI,MAAM,WACN,MAAM,kBACN,OAAO,MACP;IAAE,GAAG,CAAC,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC;IAAC,MAAM,EAAE,MAAM,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,MAAM,CAAC,UAAU,CAAA;CAAE,WACxF,gBAAgB,gBAmB1B;AAwBM,kDAJI,MAAM,MACN;IAAE,MAAM,EAAE,MAAM,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC;IAAC,UAAU,EAAE,OAAO,MAAM,CAAC,UAAU,CAAA;CAAC,WACtF,gBAAgB,gBAa1B;AA0BM,2CALI,MAAM,WACN,MAAM,MACN;IAAE,MAAM,EAAE,MAAM,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC;IAAC,UAAU,EAAE,OAAO,MAAM,CAAC,UAAU,CAAA;CAAC,WACtF,gBAAgB,gBAa1B;AA+EM,2DAZI,MAAM,kBACN;IACN,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,MACO;IACN,QAAQ,EAAE,OAAO,gBAAgB,EAAE,WAAW,CAAC;IAC/C,GAAG,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC;IACxB,UAAU,EAAE,OAAO,MAAM,CAAC,UAAU,CAAA;CACrC,WACO,gBAAgB,2BAoB1B;;;;;4BAtZqB,OAAO,KAAK,OAAO;;+BAE5B,YAAY,GAAG;IAAC,YAAY,EAAE,MAAM,CAAA;CAAC;;WAGpC,MAAM;WACN,MAAM;;6BAqTP;IACR,aAAa,EAAE;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,OAAO,eAAe,EAAE,eAAe,CAAA;KAClD,CAAC;IACF,cAAc,EAAE;QACd,WAAW,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC;QAClC,cAAc,EAAE,OAAO,eAAe,EAAE,eAAe,CAAA;KACxD,CAAA;CACF"}
|
package/src/sync-tools.js
CHANGED
|
@@ -63,7 +63,7 @@ export const retryUntilCondition = async (
|
|
|
63
63
|
setTimeout,
|
|
64
64
|
},
|
|
65
65
|
) => {
|
|
66
|
-
|
|
66
|
+
log({ maxRetries, retryIntervalMs, message });
|
|
67
67
|
|
|
68
68
|
await null; // separate sync prologue
|
|
69
69
|
|
|
@@ -109,7 +109,7 @@ export const retryUntilCondition = async (
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
retries += 1;
|
|
112
|
-
|
|
112
|
+
log(
|
|
113
113
|
`Retry ${retries}/${maxRetries} - Waiting for ${retryIntervalMs}ms for ${message}...`,
|
|
114
114
|
);
|
|
115
115
|
await sleep(retryIntervalMs, { log, setTimeout });
|
|
@@ -120,14 +120,13 @@ export const retryUntilCondition = async (
|
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* @param {WaitUntilOptions} options
|
|
123
|
-
* @returns {WaitUntilOptions
|
|
123
|
+
* @returns {WaitUntilOptions}
|
|
124
124
|
*/
|
|
125
125
|
const overrideDefaultOptions = options => {
|
|
126
126
|
const defaultValues = {
|
|
127
127
|
maxRetries: 6,
|
|
128
128
|
retryIntervalMs: 3500,
|
|
129
129
|
errorMessage: 'Error',
|
|
130
|
-
log: console.log,
|
|
131
130
|
};
|
|
132
131
|
|
|
133
132
|
return { ...defaultValues, ...options };
|
|
@@ -155,7 +154,7 @@ export const waitUntilContractDeployed = (
|
|
|
155
154
|
ambientAuthority,
|
|
156
155
|
options,
|
|
157
156
|
) => {
|
|
158
|
-
const { follow, setTimeout } = ambientAuthority;
|
|
157
|
+
const { log, follow, setTimeout } = ambientAuthority;
|
|
159
158
|
const getInstances = makeGetInstances(follow);
|
|
160
159
|
const { errorMessage, ...resolvedOptions } = overrideDefaultOptions(options);
|
|
161
160
|
|
|
@@ -163,7 +162,7 @@ export const waitUntilContractDeployed = (
|
|
|
163
162
|
getInstances,
|
|
164
163
|
instanceObject => Object.keys(instanceObject).includes(contractName),
|
|
165
164
|
errorMessage,
|
|
166
|
-
{ setTimeout, ...resolvedOptions },
|
|
165
|
+
{ log, setTimeout, ...resolvedOptions },
|
|
167
166
|
);
|
|
168
167
|
};
|
|
169
168
|
|
|
@@ -192,7 +191,7 @@ const checkCosmosBalance = (balances, threshold) => {
|
|
|
192
191
|
* @param {WaitUntilOptions} options
|
|
193
192
|
*/
|
|
194
193
|
export const waitUntilAccountFunded = (destAcct, io, threshold, options) => {
|
|
195
|
-
const { query, setTimeout } = io;
|
|
194
|
+
const { log, query, setTimeout } = io;
|
|
196
195
|
const queryCosmosBalance = makeQueryCosmosBalance(query);
|
|
197
196
|
const { errorMessage, ...resolvedOptions } = overrideDefaultOptions(options);
|
|
198
197
|
|
|
@@ -200,7 +199,7 @@ export const waitUntilAccountFunded = (destAcct, io, threshold, options) => {
|
|
|
200
199
|
async () => queryCosmosBalance(destAcct),
|
|
201
200
|
balances => checkCosmosBalance(balances, threshold),
|
|
202
201
|
errorMessage,
|
|
203
|
-
{ setTimeout, ...resolvedOptions },
|
|
202
|
+
{ log, setTimeout, ...resolvedOptions },
|
|
204
203
|
);
|
|
205
204
|
};
|
|
206
205
|
|
|
@@ -246,7 +245,7 @@ export const waitUntilOfferResult = (
|
|
|
246
245
|
io,
|
|
247
246
|
options,
|
|
248
247
|
) => {
|
|
249
|
-
const { follow, setTimeout } = io;
|
|
248
|
+
const { log, follow, setTimeout } = io;
|
|
250
249
|
const queryWallet = makeQueryWallet(follow);
|
|
251
250
|
const { errorMessage, ...resolvedOptions } = overrideDefaultOptions(options);
|
|
252
251
|
|
|
@@ -254,7 +253,7 @@ export const waitUntilOfferResult = (
|
|
|
254
253
|
async () => queryWallet(addr),
|
|
255
254
|
status => checkOfferState(status, waitForPayouts, offerId),
|
|
256
255
|
errorMessage,
|
|
257
|
-
{ reusePromise: true, setTimeout, ...resolvedOptions },
|
|
256
|
+
{ log, reusePromise: true, setTimeout, ...resolvedOptions },
|
|
258
257
|
);
|
|
259
258
|
};
|
|
260
259
|
|
|
@@ -281,7 +280,7 @@ const checkForInvitation = update => {
|
|
|
281
280
|
* @param {WaitUntilOptions} options
|
|
282
281
|
*/
|
|
283
282
|
export const waitUntilInvitationReceived = (addr, io, options) => {
|
|
284
|
-
const { follow, setTimeout } = io;
|
|
283
|
+
const { log, follow, setTimeout } = io;
|
|
285
284
|
const queryWallet = makeQueryWallet(follow);
|
|
286
285
|
const { errorMessage, ...resolvedOptions } = overrideDefaultOptions(options);
|
|
287
286
|
|
|
@@ -289,7 +288,7 @@ export const waitUntilInvitationReceived = (addr, io, options) => {
|
|
|
289
288
|
async () => queryWallet(addr),
|
|
290
289
|
checkForInvitation,
|
|
291
290
|
errorMessage,
|
|
292
|
-
{ reusePromise: true, setTimeout, ...resolvedOptions },
|
|
291
|
+
{ log, reusePromise: true, setTimeout, ...resolvedOptions },
|
|
293
292
|
);
|
|
294
293
|
};
|
|
295
294
|
|
|
@@ -318,7 +317,7 @@ const checkLiveOffers = (update, offerId) => {
|
|
|
318
317
|
* @param {WaitUntilOptions} options
|
|
319
318
|
*/
|
|
320
319
|
export const waitUntilOfferExited = async (addr, offerId, io, options) => {
|
|
321
|
-
const { follow, setTimeout } = io;
|
|
320
|
+
const { log, follow, setTimeout } = io;
|
|
322
321
|
const queryWalletCurrent = makeQueryWalletCurrent(follow);
|
|
323
322
|
const { errorMessage, ...resolvedOptions } = overrideDefaultOptions(options);
|
|
324
323
|
|
|
@@ -326,7 +325,7 @@ export const waitUntilOfferExited = async (addr, offerId, io, options) => {
|
|
|
326
325
|
async () => queryWalletCurrent(addr),
|
|
327
326
|
update => checkLiveOffers(update, offerId),
|
|
328
327
|
errorMessage,
|
|
329
|
-
{ setTimeout, ...resolvedOptions },
|
|
328
|
+
{ log, setTimeout, ...resolvedOptions },
|
|
330
329
|
);
|
|
331
330
|
};
|
|
332
331
|
|
package/src/types.d.ts
CHANGED
|
@@ -1,54 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '@agoric/
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
CurrentWalletRecord,
|
|
11
|
-
UpdateRecord,
|
|
12
|
-
} from '@agoric/smart-wallet/src/smartWallet.js';
|
|
13
|
-
import type {
|
|
14
|
-
ContractRecord,
|
|
15
|
-
PoolMetrics,
|
|
16
|
-
TransactionRecord,
|
|
17
|
-
} from '@agoric/fast-usdc';
|
|
18
|
-
|
|
19
|
-
// For static string key types. String template matching has to be in the ternary below.
|
|
1
|
+
import type { Brand } from '@agoric/ertp';
|
|
2
|
+
import type { ContractRecord, FeeConfig, PoolMetrics, TransactionRecord } from '@agoric/fast-usdc';
|
|
3
|
+
import type { OutcomeRecord, QuestionDetails } from '@agoric/governance/src/types.js';
|
|
4
|
+
import type { BookDataNotification } from '@agoric/inter-protocol/src/auction/auctionBook.js';
|
|
5
|
+
import type { AuctionParamRecord } from '@agoric/inter-protocol/src/auction/params.js';
|
|
6
|
+
import type { ScheduleNotification } from '@agoric/inter-protocol/src/auction/scheduler.js';
|
|
7
|
+
import type { MetricsNotification as VaultDirectorMetrics } from '@agoric/inter-protocol/src/vaultFactory/vaultDirector.js';
|
|
8
|
+
import type { CurrentWalletRecord, UpdateRecord } from '@agoric/smart-wallet/src/smartWallet.js';
|
|
9
|
+
import type { Instance } from '@agoric/zoe/src/zoeService/types.js';
|
|
20
10
|
type PublishedTypeMap = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
'auction.governance': {
|
|
12
|
+
current: AuctionParamRecord;
|
|
13
|
+
};
|
|
14
|
+
'auction.schedule': ScheduleNotification;
|
|
15
|
+
'vaultFactory.metrics': VaultDirectorMetrics;
|
|
16
|
+
'agoricNames.instance': Array<[string, Instance]>;
|
|
17
|
+
'agoricNames.brand': Array<[string, Brand]>;
|
|
18
|
+
fastUsdc: ContractRecord;
|
|
19
|
+
'fastUsdc.feeConfig': FeeConfig;
|
|
20
|
+
'fastUsdc.poolMetrics': PoolMetrics;
|
|
24
21
|
};
|
|
25
|
-
|
|
26
22
|
/**
|
|
27
23
|
* Utility type to the type that would result from unmarshalling the latest
|
|
28
24
|
* value at a vstorage `published` path.
|
|
29
25
|
*/
|
|
30
|
-
export type TypedPublished<T extends string> = T extends keyof PublishedTypeMap
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
? CurrentWalletRecord
|
|
34
|
-
: T extends `wallet.${string}`
|
|
35
|
-
? UpdateRecord
|
|
36
|
-
: T extends `committees.${string}.latestQuestion`
|
|
37
|
-
? QuestionDetails
|
|
38
|
-
: T extends `committees.${string}.latestOutcome`
|
|
39
|
-
? OutcomeRecord
|
|
40
|
-
: T extends `vaultFactory.managers.manager${number}.metrics`
|
|
41
|
-
? VaultManagerMetrics
|
|
42
|
-
: T extends 'agoricNames.instance'
|
|
43
|
-
? Array<[string, Instance]>
|
|
44
|
-
: T extends 'agoricNames.brand'
|
|
45
|
-
? Array<[string, Brand]>
|
|
46
|
-
: T extends 'fastUsdc'
|
|
47
|
-
? ContractRecord
|
|
48
|
-
: T extends 'fastUsdc.feeConfig'
|
|
49
|
-
? FeeConfig
|
|
50
|
-
: T extends 'fastUsdc.poolMetrics'
|
|
51
|
-
? PoolMetrics
|
|
52
|
-
: T extends `fastUsdc.txns.${string}`
|
|
53
|
-
? TransactionRecord
|
|
54
|
-
: unknown;
|
|
26
|
+
export type TypedPublished<T extends string> = T extends keyof PublishedTypeMap ? PublishedTypeMap[T] : T extends `wallet.${string}.current` ? CurrentWalletRecord : T extends `wallet.${string}` ? UpdateRecord : T extends `committees.${string}.latestQuestion` ? QuestionDetails : T extends `committees.${string}.latestOutcome` ? OutcomeRecord : T extends `vaultFactory.managers.manager${number}.metrics` ? VaultDirectorMetrics : T extends `fastUsdc.txns.${string}` ? TransactionRecord : T extends `auction.book${number}` ? BookDataNotification : unknown;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,WAAW,EACX,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AAC9F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AAC5F,OAAO,KAAK,EAAE,mBAAmB,IAAI,oBAAoB,EAAE,MAAM,0DAA0D,CAAC;AAC5H,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACb,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAGpE,KAAK,gBAAgB,GAAG;IACtB,oBAAoB,EAAE;QAAE,OAAO,EAAE,kBAAkB,CAAA;KAAE,CAAC;IACtD,kBAAkB,EAAE,oBAAoB,CAAC;IACzC,sBAAsB,EAAE,oBAAoB,CAAC;IAC7C,sBAAsB,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAClD,mBAAmB,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5C,QAAQ,EAAE,cAAc,CAAC;IACzB,oBAAoB,EAAE,SAAS,CAAC;IAChC,sBAAsB,EAAE,WAAW,CAAC;CACrC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAAM,gBAAgB,GAC3E,gBAAgB,CAAC,CAAC,CAAC,GACnB,CAAC,SAAS,UAAU,MAAM,UAAU,GAClC,mBAAmB,GACnB,CAAC,SAAS,UAAU,MAAM,EAAE,GAC1B,YAAY,GACZ,CAAC,SAAS,cAAc,MAAM,iBAAiB,GAC7C,eAAe,GACf,CAAC,SAAS,cAAc,MAAM,gBAAgB,GAC5C,aAAa,GACb,CAAC,SAAS,gCAAgC,MAAM,UAAU,GACxD,oBAAoB,GACpB,CAAC,SAAS,iBAAiB,MAAM,EAAE,GACjC,iBAAiB,GACjB,CAAC,SAAS,eAAe,MAAM,EAAE,GAC/B,oBAAoB,GACpB,OAAO,CAAC"}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @file types for the client-utils package
|
|
2
|
+
// NB: this doesn't follow best practices for TS in JS because this package will likely soon be written in TS
|
|
3
|
+
|
|
4
|
+
import type { Brand } from '@agoric/ertp';
|
|
5
|
+
import type {
|
|
6
|
+
ContractRecord,
|
|
7
|
+
FeeConfig,
|
|
8
|
+
PoolMetrics,
|
|
9
|
+
TransactionRecord,
|
|
10
|
+
} from '@agoric/fast-usdc';
|
|
11
|
+
import type {
|
|
12
|
+
OutcomeRecord,
|
|
13
|
+
QuestionDetails,
|
|
14
|
+
} from '@agoric/governance/src/types.js';
|
|
15
|
+
import type { BookDataNotification } from '@agoric/inter-protocol/src/auction/auctionBook.js';
|
|
16
|
+
import type { AuctionParamRecord } from '@agoric/inter-protocol/src/auction/params.js';
|
|
17
|
+
import type { ScheduleNotification } from '@agoric/inter-protocol/src/auction/scheduler.js';
|
|
18
|
+
import type { MetricsNotification as VaultDirectorMetrics } from '@agoric/inter-protocol/src/vaultFactory/vaultDirector.js';
|
|
19
|
+
import type {
|
|
20
|
+
CurrentWalletRecord,
|
|
21
|
+
UpdateRecord,
|
|
22
|
+
} from '@agoric/smart-wallet/src/smartWallet.js';
|
|
23
|
+
import type { Instance } from '@agoric/zoe/src/zoeService/types.js';
|
|
24
|
+
|
|
25
|
+
// For static string key types. String template matching has to be in the ternary below.
|
|
26
|
+
type PublishedTypeMap = {
|
|
27
|
+
'auction.governance': { current: AuctionParamRecord };
|
|
28
|
+
'auction.schedule': ScheduleNotification;
|
|
29
|
+
'vaultFactory.metrics': VaultDirectorMetrics;
|
|
30
|
+
'agoricNames.instance': Array<[string, Instance]>;
|
|
31
|
+
'agoricNames.brand': Array<[string, Brand]>;
|
|
32
|
+
fastUsdc: ContractRecord;
|
|
33
|
+
'fastUsdc.feeConfig': FeeConfig;
|
|
34
|
+
'fastUsdc.poolMetrics': PoolMetrics;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Utility type to the type that would result from unmarshalling the latest
|
|
39
|
+
* value at a vstorage `published` path.
|
|
40
|
+
*/
|
|
41
|
+
export type TypedPublished<T extends string> = T extends keyof PublishedTypeMap
|
|
42
|
+
? PublishedTypeMap[T]
|
|
43
|
+
: T extends `wallet.${string}.current`
|
|
44
|
+
? CurrentWalletRecord
|
|
45
|
+
: T extends `wallet.${string}`
|
|
46
|
+
? UpdateRecord
|
|
47
|
+
: T extends `committees.${string}.latestQuestion`
|
|
48
|
+
? QuestionDetails
|
|
49
|
+
: T extends `committees.${string}.latestOutcome`
|
|
50
|
+
? OutcomeRecord
|
|
51
|
+
: T extends `vaultFactory.managers.manager${number}.metrics`
|
|
52
|
+
? VaultDirectorMetrics
|
|
53
|
+
: T extends `fastUsdc.txns.${string}`
|
|
54
|
+
? TransactionRecord
|
|
55
|
+
: T extends `auction.book${number}`
|
|
56
|
+
? BookDataNotification
|
|
57
|
+
: unknown;
|
|
58
|
+
// static string keys are defined in PublishedTypeMap
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export { boardSlottingMarshaller };
|
|
2
|
+
export function makeFromBoard(): {
|
|
3
|
+
convertSlotToVal: (boardId: any, iface: any) => any;
|
|
4
|
+
};
|
|
5
|
+
export namespace storageHelper {
|
|
6
|
+
function parseCapData(txt: {
|
|
7
|
+
value: string;
|
|
8
|
+
} | string): {
|
|
9
|
+
blockHeight: any;
|
|
10
|
+
capDatas: {
|
|
11
|
+
body: string;
|
|
12
|
+
slots: string[];
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
function unserializeTxt(txt: {
|
|
16
|
+
value: string;
|
|
17
|
+
} | string, ctx: IdMap): any[];
|
|
18
|
+
function parseMany(capDataStrings: string[]): {
|
|
19
|
+
body: string;
|
|
20
|
+
slots: string[];
|
|
21
|
+
}[];
|
|
22
|
+
}
|
|
23
|
+
export function makeAgoricNames(ctx: IdMap, vstorage: VStorage): Promise<import("@agoric/vats/tools/board-utils.js").AgoricNamesRemotes>;
|
|
24
|
+
export function makeVstorageKit({ fetch }: {
|
|
25
|
+
fetch: typeof window.fetch;
|
|
26
|
+
}, config: MinimalNetworkConfig): {
|
|
27
|
+
fromBoard: {
|
|
28
|
+
convertSlotToVal: (boardId: any, iface: any) => any;
|
|
29
|
+
};
|
|
30
|
+
marshaller: Omit<import("@endo/marshal").Marshal<string | null>, "serialize" | "unserialize">;
|
|
31
|
+
readLatestHead: (path: string) => Promise<unknown>;
|
|
32
|
+
readPublished: <T extends string>(subpath: T) => Promise<TypedPublished<T>>;
|
|
33
|
+
unserializeHead: (txt: string | {
|
|
34
|
+
value: string;
|
|
35
|
+
}) => unknown;
|
|
36
|
+
vstorage: {
|
|
37
|
+
readStorage: <T extends "children" | "data">(path?: string, { kind, height }?: {
|
|
38
|
+
kind?: T | undefined;
|
|
39
|
+
height?: number | bigint | undefined;
|
|
40
|
+
}) => Promise<T extends "children" ? import("@agoric/cosmic-proto/agoric/vstorage/query.js").QueryChildrenResponse : import("@agoric/cosmic-proto/agoric/vstorage/query.js").QueryDataResponse>;
|
|
41
|
+
readLatest(path?: string): Promise<import("@agoric/cosmic-proto/agoric/vstorage/query.js").QueryDataResponse>;
|
|
42
|
+
keys(path?: string): Promise<string[]>;
|
|
43
|
+
readAt(path: string, height?: number): Promise<import("@agoric/internal/src/lib-chainStorage.js").StreamCell<unknown>>;
|
|
44
|
+
readFully(path: string, minHeight?: number | string): Promise<string[]>;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type IdMap = ReturnType<typeof makeFromBoard>;
|
|
48
|
+
export type VstorageKit = ReturnType<typeof makeVstorageKit>;
|
|
49
|
+
import { boardSlottingMarshaller } from '@agoric/vats/tools/board-utils.js';
|
|
50
|
+
import type { VStorage } from './vstorage.js';
|
|
51
|
+
import type { MinimalNetworkConfig } from './network-config.js';
|
|
52
|
+
import type { TypedPublished } from './types-index.js';
|
|
53
|
+
//# sourceMappingURL=vstorage-kit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vstorage-kit.d.ts","sourceRoot":"","sources":["vstorage-kit.js"],"names":[],"mappings":";AAgBO;;EAWN;;IAMe,2BADD;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM;;;kBAuBhB,MAAM;mBAAS,MAAM,EAAE;;MAd3C;IAKe,6BAHJ;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM,OACzB,KAAK,SAOf;IAEU,mCADC,MAAM,EAAE;cAGC,MAAM;eAAS,MAAM,EAAE;QAS3C;;AAUI,qCAJI,KAAK,YACL,QAAQ,GACN,OAAO,CAAC,OAAO,mCAAmC,EAAE,kBAAkB,CAAC,CAqBnF;AAMM,2CAHI;IAAE,KAAK,EAAE,OAAO,MAAM,CAAC,KAAK,CAAA;CAAE,UAC9B,oBAAoB;;;;;2BAeV,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC;oBAajC,CAAC,SAAS,MAAM,WAAW,CAAC,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;2BAnBrD,MAAM,GAAG;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,KAAK,OAAO;;;;;;;;;;;EAoCxD;oBAlHa,UAAU,CAAC,OAAO,aAAa,CAAC;0BAmHhC,UAAU,CAAC,OAAO,eAAe,CAAC;wCA5IzC,mCAAmC;8BASf,eAAe;0CAFH,qBAAqB;oCAC3B,kBAAkB"}
|
package/src/vstorage-kit.js
CHANGED
|
@@ -9,7 +9,7 @@ export { boardSlottingMarshaller };
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @import {MinimalNetworkConfig} from './network-config.js';
|
|
12
|
-
* @import {TypedPublished} from './types.js';
|
|
12
|
+
* @import {TypedPublished} from './types-index.js';
|
|
13
13
|
* @import {VStorage} from './vstorage.js';
|
|
14
14
|
*/
|
|
15
15
|
|
|
@@ -30,11 +30,10 @@ export const makeFromBoard = () => {
|
|
|
30
30
|
|
|
31
31
|
/** @deprecated */
|
|
32
32
|
export const storageHelper = {
|
|
33
|
-
/** @param { string } txt */
|
|
33
|
+
/** @param { {value: string} | string } txt */
|
|
34
34
|
parseCapData: txt => {
|
|
35
|
-
assert(typeof txt === 'string', typeof txt);
|
|
36
35
|
/** @type {{ value: string }} */
|
|
37
|
-
const { value } = JSON.parse(txt);
|
|
36
|
+
const { value } = typeof txt === 'string' ? JSON.parse(txt) : txt;
|
|
38
37
|
const specimen = JSON.parse(value);
|
|
39
38
|
const { blockHeight, values } = specimen;
|
|
40
39
|
assert(values, `empty values in specimen ${value}`);
|
|
@@ -42,7 +41,7 @@ export const storageHelper = {
|
|
|
42
41
|
return { blockHeight, capDatas };
|
|
43
42
|
},
|
|
44
43
|
/**
|
|
45
|
-
* @param {string} txt
|
|
44
|
+
* @param { {value: string} | string } txt
|
|
46
45
|
* @param {IdMap} ctx
|
|
47
46
|
*/
|
|
48
47
|
unserializeTxt: (txt, ctx) => {
|
|
@@ -105,7 +104,7 @@ export const makeVstorageKit = ({ fetch }, config) => {
|
|
|
105
104
|
|
|
106
105
|
const marshaller = boardSlottingMarshaller(fromBoard.convertSlotToVal);
|
|
107
106
|
|
|
108
|
-
/** @type {(txt: string) => unknown} */
|
|
107
|
+
/** @type {(txt: string | {value: string}) => unknown} */
|
|
109
108
|
const unserializeHead = txt =>
|
|
110
109
|
storageHelper.unserializeTxt(txt, fromBoard).at(-1);
|
|
111
110
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export function makeAbciQuery<T extends "data" | "children">(path?: string, { kind, height }?: {
|
|
2
|
+
kind?: T | undefined;
|
|
3
|
+
height?: number | bigint | undefined;
|
|
4
|
+
}): `/abci_query?${string}`;
|
|
5
|
+
export function makeVStorage({ fetch }: {
|
|
6
|
+
fetch: typeof window.fetch;
|
|
7
|
+
}, config: MinimalNetworkConfig): {
|
|
8
|
+
readStorage: <T extends "children" | "data">(path?: string, { kind, height }?: {
|
|
9
|
+
kind?: T | undefined;
|
|
10
|
+
height?: number | bigint | undefined;
|
|
11
|
+
}) => Promise<T extends "children" ? QueryChildrenResponse : QueryDataResponse>;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {string} path
|
|
15
|
+
* @returns {Promise<QueryDataResponse>} latest vstorage value at path
|
|
16
|
+
*/
|
|
17
|
+
readLatest(path?: string): Promise<QueryDataResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Keys of children at the path
|
|
20
|
+
*
|
|
21
|
+
* @param {string} path
|
|
22
|
+
* @returns {Promise<string[]>}
|
|
23
|
+
*/
|
|
24
|
+
keys(path?: string): Promise<string[]>;
|
|
25
|
+
/**
|
|
26
|
+
* @param {string} path
|
|
27
|
+
* @param {number} [height] default is highest
|
|
28
|
+
* @returns {Promise<StreamCell<unknown>>}
|
|
29
|
+
*/
|
|
30
|
+
readAt(path: string, height?: number): Promise<StreamCell<unknown>>;
|
|
31
|
+
/**
|
|
32
|
+
* Read values going back as far as available
|
|
33
|
+
*
|
|
34
|
+
* @param {string} path
|
|
35
|
+
* @param {number | string} [minHeight]
|
|
36
|
+
* @returns {Promise<string[]>}
|
|
37
|
+
*/
|
|
38
|
+
readFully(path: string, minHeight?: number | string): Promise<string[]>;
|
|
39
|
+
};
|
|
40
|
+
export type VStorage = ReturnType<typeof makeVStorage>;
|
|
41
|
+
import type { MinimalNetworkConfig } from './network-config.js';
|
|
42
|
+
import { QueryChildrenResponse } from '@agoric/cosmic-proto/agoric/vstorage/query.js';
|
|
43
|
+
import { QueryDataResponse } from '@agoric/cosmic-proto/agoric/vstorage/query.js';
|
|
44
|
+
import type { StreamCell } from '@agoric/internal/src/lib-chainStorage.js';
|
|
45
|
+
//# sourceMappingURL=vstorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vstorage.d.ts","sourceRoot":"","sources":["vstorage.js"],"names":[],"mappings":"AA6CO,8BAP4B,CAAC,SAAtB,MAAM,GAAG,UAAW,SACvB,MAAM,qBAEd;IAAiB,IAAI;IACU,MAAM;CACrC,GAAU,eAAe,MAAM,EAAE,CAYnC;AAOM,wCAHJ;IAAoC,KAAK,EAAjC,OAAO,MAAM,CAAC,KAAK;CAC3B,UAAQ,oBAAoB;kBAsBM,CAAC,SAAtB,UAAU,GAAG,MAAO,SACvB,MAAM,qBAEd;QAAiB,IAAI;QACU,MAAM;KACrC,KAAU,OAAO,CAAC,CAAC,SAAS,UAAU,GAAG,qBAAqB,GAAE,iBAAiB,CAAE;IAsCpF;;;;OAIG;sBAFQ,MAAM,GACJ,OAAO,CAAC,iBAAiB,CAAC;IAKvC;;;;;OAKG;gBAFQ,MAAM,GACJ,OAAO,CAAC,MAAM,EAAE,CAAC;IAM9B;;;;OAIG;iBAHQ,MAAM,WACN,MAAM,GACJ,OAAO,CAAC,WAAW,OAAO,CAAC,CAAC;IASzC;;;;;;OAMG;oBAHQ,MAAM,cACN,MAAM,GAAG,MAAM,GACb,OAAO,CAAC,MAAM,EAAE,CAAC;EAyCjC;uBACa,UAAU,CAAC,OAAO,YAAY,CAAC;0CA3LN,qBAAqB;sCANrD,+CAA+C;kCAA/C,+CAA+C;gCAKzB,0CAA0C"}
|
package/src/vstorage.js
CHANGED
|
@@ -1,30 +1,59 @@
|
|
|
1
|
+
import { decodeBase64 } from '@endo/base64';
|
|
2
|
+
import { encodeHex } from '@agoric/internal/src/hex.js';
|
|
3
|
+
import { StreamCellShape } from '@agoric/internal/src/lib-chainStorage.js';
|
|
4
|
+
import { mustMatch } from '@agoric/internal';
|
|
1
5
|
import {
|
|
2
6
|
QueryChildrenRequest,
|
|
3
7
|
QueryChildrenResponse,
|
|
4
8
|
QueryDataRequest,
|
|
5
9
|
QueryDataResponse,
|
|
6
10
|
} from '@agoric/cosmic-proto/agoric/vstorage/query.js';
|
|
7
|
-
import { decodeBase64 } from '@endo/base64';
|
|
8
|
-
import { encodeHex } from '@agoric/internal/src/hex.js';
|
|
9
11
|
|
|
10
12
|
/**
|
|
13
|
+
* @import {AbciQueryResponse} from '@cosmjs/tendermint-rpc';
|
|
14
|
+
* @import {JsonSafe} from '@agoric/cosmic-proto';
|
|
15
|
+
* @import {StreamCell} from '@agoric/internal/src/lib-chainStorage.js';
|
|
11
16
|
* @import {MinimalNetworkConfig} from './network-config.js';
|
|
12
17
|
*/
|
|
13
18
|
|
|
19
|
+
const kindToRpc = /** @type {const} */ ({
|
|
20
|
+
__proto__: null,
|
|
21
|
+
children: '/agoric.vstorage.Query/Children',
|
|
22
|
+
data: '/agoric.vstorage.Query/Data',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// TODO move down to cosmic-proto, probably generated with Telescope
|
|
14
26
|
const codecs = {
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
__proto__: null,
|
|
28
|
+
'/agoric.vstorage.Query/Children': {
|
|
17
29
|
request: QueryChildrenRequest,
|
|
18
30
|
response: QueryChildrenResponse,
|
|
19
31
|
},
|
|
20
|
-
|
|
21
|
-
rpc: '/agoric.vstorage.Query/Data',
|
|
32
|
+
'/agoric.vstorage.Query/Data': {
|
|
22
33
|
request: QueryDataRequest,
|
|
23
34
|
response: QueryDataResponse,
|
|
24
35
|
},
|
|
25
36
|
};
|
|
26
37
|
|
|
27
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* @template {'data' | 'children'} T
|
|
40
|
+
* @param {string} [path]
|
|
41
|
+
* @param {object} [opts]
|
|
42
|
+
* @param {T} [opts.kind]
|
|
43
|
+
* @param {number | bigint} [opts.height] 0 is the same as omitting height and implies the highest block
|
|
44
|
+
* @returns {`/abci_query?${string}`}
|
|
45
|
+
*/
|
|
46
|
+
export const makeAbciQuery = (
|
|
47
|
+
path = 'published',
|
|
48
|
+
{ kind = /** @type {T} */ ('children'), height = 0 } = {},
|
|
49
|
+
) => {
|
|
50
|
+
const rpc = kindToRpc[kind];
|
|
51
|
+
const { request } = codecs[rpc];
|
|
52
|
+
const buf = request.toProto({ path });
|
|
53
|
+
|
|
54
|
+
const hexData = encodeHex(buf);
|
|
55
|
+
return `/abci_query?path=%22${rpc}%22&data=0x${hexData}&height=${height}`;
|
|
56
|
+
};
|
|
28
57
|
|
|
29
58
|
/**
|
|
30
59
|
* @param {object} powers
|
|
@@ -33,114 +62,96 @@ const codecs = {
|
|
|
33
62
|
*/
|
|
34
63
|
export const makeVStorage = ({ fetch }, config) => {
|
|
35
64
|
/**
|
|
36
|
-
* @
|
|
65
|
+
* @template {'data' | 'children'} T
|
|
66
|
+
* @param {string} vstoragePath
|
|
67
|
+
* @param {object} [opts]
|
|
68
|
+
* @param {T} [opts.kind]
|
|
69
|
+
* @param {number | bigint} [opts.height] 0 is the same as omitting height and implies the highest block
|
|
70
|
+
* @returns {Promise<{result: {response: JsonSafe<AbciQueryResponse>}}>}
|
|
37
71
|
*/
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
72
|
+
const getVstorageJson = async (
|
|
73
|
+
vstoragePath,
|
|
74
|
+
{ kind = /** @type {T} */ ('children'), height = 0 } = {},
|
|
75
|
+
) => {
|
|
76
|
+
const url =
|
|
77
|
+
config.rpcAddrs[0] + makeAbciQuery(vstoragePath, { kind, height });
|
|
41
78
|
const res = await fetch(url, { keepalive: true });
|
|
42
79
|
return res.json();
|
|
43
80
|
};
|
|
44
81
|
|
|
45
82
|
/**
|
|
46
|
-
* @template {
|
|
83
|
+
* @template {'children' | 'data'} T
|
|
47
84
|
* @param {string} [path]
|
|
48
85
|
* @param {object} [opts]
|
|
49
86
|
* @param {T} [opts.kind]
|
|
50
87
|
* @param {number | bigint} [opts.height] 0 is the same as omitting height and implies the highest block
|
|
88
|
+
* @returns {Promise<T extends 'children' ? QueryChildrenResponse :QueryDataResponse >}
|
|
51
89
|
*/
|
|
52
|
-
const
|
|
90
|
+
const readStorage = async (
|
|
53
91
|
path = 'published',
|
|
54
92
|
{ kind = /** @type {T} */ ('children'), height = 0 } = {},
|
|
55
93
|
) => {
|
|
56
|
-
|
|
57
|
-
if (!codec) {
|
|
58
|
-
throw Error(`unknown rpc kind: ${kind}`);
|
|
59
|
-
}
|
|
94
|
+
await null;
|
|
60
95
|
|
|
61
|
-
const
|
|
62
|
-
const
|
|
96
|
+
const rpc = kindToRpc[kind];
|
|
97
|
+
const codec = codecs[rpc];
|
|
63
98
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
99
|
+
let data;
|
|
100
|
+
try {
|
|
101
|
+
data = await getVstorageJson(path, { kind, height });
|
|
102
|
+
} catch (err) {
|
|
103
|
+
throw Error(`cannot read ${kind} of ${path}: ${err.message}`);
|
|
104
|
+
}
|
|
67
105
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.catch(err => {
|
|
81
|
-
throw Error(`cannot read ${kind} of ${path}: ${err.message}`);
|
|
82
|
-
})
|
|
83
|
-
.then(data => {
|
|
84
|
-
const {
|
|
85
|
-
result: { response },
|
|
86
|
-
} = data;
|
|
87
|
-
if (response?.code !== 0) {
|
|
88
|
-
/** @type {any} */
|
|
89
|
-
const err = Error(
|
|
90
|
-
`error code ${response?.code} reading ${kind} of ${path}: ${response.log}`,
|
|
91
|
-
);
|
|
92
|
-
err.code = response?.code;
|
|
93
|
-
err.codespace = response?.codespace;
|
|
94
|
-
throw err;
|
|
95
|
-
}
|
|
106
|
+
const {
|
|
107
|
+
result: { response },
|
|
108
|
+
} = data;
|
|
109
|
+
if (response?.code !== 0) {
|
|
110
|
+
/** @type {any} */
|
|
111
|
+
const err = Error(
|
|
112
|
+
`error code ${response?.code} reading ${kind} of ${path}: ${response.log}`,
|
|
113
|
+
);
|
|
114
|
+
err.code = response?.code;
|
|
115
|
+
err.codespace = response?.codespace;
|
|
116
|
+
throw err;
|
|
117
|
+
}
|
|
96
118
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return { ...data, codec: codec.response };
|
|
102
|
-
});
|
|
119
|
+
const { value: b64Value } = response;
|
|
120
|
+
// @ts-expect-error cast
|
|
121
|
+
return codec.response.decode(decodeBase64(b64Value));
|
|
122
|
+
};
|
|
103
123
|
|
|
104
124
|
const vstorage = {
|
|
105
|
-
|
|
125
|
+
readStorage,
|
|
106
126
|
/**
|
|
107
|
-
*
|
|
127
|
+
*
|
|
128
|
+
* @param {string} path
|
|
129
|
+
* @returns {Promise<QueryDataResponse>} latest vstorage value at path
|
|
108
130
|
*/
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (code !== 0) {
|
|
112
|
-
throw response;
|
|
113
|
-
}
|
|
114
|
-
const { value: b64Value } = response;
|
|
115
|
-
if (!codec) {
|
|
116
|
-
return atob(b64Value);
|
|
117
|
-
}
|
|
118
|
-
return JSON.stringify(codec.decode(decodeBase64(b64Value)));
|
|
131
|
+
async readLatest(path = 'published') {
|
|
132
|
+
return readStorage(path, { kind: 'data' });
|
|
119
133
|
},
|
|
120
134
|
/**
|
|
135
|
+
* Keys of children at the path
|
|
121
136
|
*
|
|
122
137
|
* @param {string} path
|
|
123
|
-
* @returns {Promise<string>}
|
|
138
|
+
* @returns {Promise<string[]>}
|
|
124
139
|
*/
|
|
125
|
-
async readLatest(path = 'published') {
|
|
126
|
-
const raw = await readStorage(path, { kind: 'data' });
|
|
127
|
-
return vstorage.decode(raw);
|
|
128
|
-
},
|
|
129
140
|
async keys(path = 'published') {
|
|
130
|
-
const
|
|
131
|
-
return
|
|
141
|
+
const response = await readStorage(path, { kind: 'children' });
|
|
142
|
+
return response.children;
|
|
132
143
|
},
|
|
133
144
|
/**
|
|
134
145
|
* @param {string} path
|
|
135
146
|
* @param {number} [height] default is highest
|
|
136
|
-
* @returns {Promise<
|
|
147
|
+
* @returns {Promise<StreamCell<unknown>>}
|
|
137
148
|
*/
|
|
138
149
|
async readAt(path, height = undefined) {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return
|
|
150
|
+
const response = await readStorage(path, { kind: 'data', height });
|
|
151
|
+
/** @type {unknown} */
|
|
152
|
+
const cell = harden(JSON.parse(response.value));
|
|
153
|
+
mustMatch(cell, StreamCellShape);
|
|
154
|
+
return cell;
|
|
144
155
|
},
|
|
145
156
|
/**
|
|
146
157
|
* Read values going back as far as available
|
|
@@ -152,6 +163,7 @@ export const makeVStorage = ({ fetch }, config) => {
|
|
|
152
163
|
async readFully(path, minHeight = undefined) {
|
|
153
164
|
const parts = [];
|
|
154
165
|
// undefined the first iteration, to query at the highest
|
|
166
|
+
/** @type {string | undefined} */
|
|
155
167
|
let blockHeight;
|
|
156
168
|
await null;
|
|
157
169
|
do {
|
|
@@ -160,7 +172,7 @@ export const makeVStorage = ({ fetch }, config) => {
|
|
|
160
172
|
try {
|
|
161
173
|
({ blockHeight, values } = await vstorage.readAt(
|
|
162
174
|
path,
|
|
163
|
-
blockHeight
|
|
175
|
+
blockHeight === undefined ? undefined : Number(blockHeight) - 1,
|
|
164
176
|
));
|
|
165
177
|
// console.debug('readAt returned', { blockHeight });
|
|
166
178
|
} catch (err) {
|
|
@@ -182,8 +194,8 @@ export const makeVStorage = ({ fetch }, config) => {
|
|
|
182
194
|
// console.debug('PUSHED', values);
|
|
183
195
|
// console.debug('NEW', { blockHeight, minHeight });
|
|
184
196
|
if (minHeight && Number(blockHeight) <= Number(minHeight)) break;
|
|
185
|
-
} while (blockHeight > 0);
|
|
186
|
-
return parts.flat();
|
|
197
|
+
} while (Number(blockHeight) > 0);
|
|
198
|
+
return /** @type {string[]} */ (parts.flat());
|
|
187
199
|
},
|
|
188
200
|
};
|
|
189
201
|
return vstorage;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** @typedef {import('./smart-wallet-kit.js').SmartWalletKit} WalletUtils */
|
|
2
|
+
/** @deprecated use `makeSmartWalletKit` */
|
|
3
|
+
export const makeWalletUtils: ({ fetch, delay }: {
|
|
4
|
+
fetch: typeof globalThis.fetch;
|
|
5
|
+
delay: (ms: number) => Promise<void>;
|
|
6
|
+
}, networkConfig: import("./network-config.js").MinimalNetworkConfig) => Promise<{
|
|
7
|
+
agoricNames: import("@agoric/vats/tools/board-utils.js").AgoricNamesRemotes;
|
|
8
|
+
networkConfig: import("./network-config.js").MinimalNetworkConfig;
|
|
9
|
+
getLastUpdate: (addr: string) => Promise<import("@agoric/smart-wallet/src/smartWallet.js").UpdateRecord>;
|
|
10
|
+
getCurrentWalletRecord: (addr: string) => Promise<import("@agoric/smart-wallet/src/smartWallet.js").CurrentWalletRecord>;
|
|
11
|
+
storedWalletState: (from: string, minHeight?: number | string) => Promise<{
|
|
12
|
+
invitationsReceived: Map<import("@agoric/smart-wallet/src/offers.js").OfferId, {
|
|
13
|
+
acceptedIn: import("@agoric/smart-wallet/src/offers.js").OfferId;
|
|
14
|
+
description: string;
|
|
15
|
+
instance: Instance;
|
|
16
|
+
}>;
|
|
17
|
+
offerStatuses: Map<import("@agoric/smart-wallet/src/offers.js").OfferId, import("@agoric/smart-wallet/src/offers.js").OfferStatus>;
|
|
18
|
+
balances: Map<globalThis.Brand, globalThis.Amount>;
|
|
19
|
+
}>;
|
|
20
|
+
pollOffer: (from: string, id: string | number, minHeight: number | string, untilNumWantsSatisfied?: boolean) => Promise<import("@agoric/smart-wallet/src/offers.js").OfferStatus>;
|
|
21
|
+
fromBoard: {
|
|
22
|
+
convertSlotToVal: (boardId: any, iface: any) => any;
|
|
23
|
+
};
|
|
24
|
+
marshaller: Omit<import("@endo/marshal").Marshal<string | null>, "serialize" | "unserialize">;
|
|
25
|
+
readLatestHead: (path: string) => Promise<unknown>;
|
|
26
|
+
readPublished: <T extends string>(subpath: T) => Promise<import("./types.js").TypedPublished<T>>;
|
|
27
|
+
unserializeHead: (txt: string | {
|
|
28
|
+
value: string;
|
|
29
|
+
}) => unknown;
|
|
30
|
+
vstorage: {
|
|
31
|
+
readStorage: <T extends "children" | "data">(path?: string, { kind, height }?: {
|
|
32
|
+
kind?: T | undefined;
|
|
33
|
+
height?: number | bigint | undefined;
|
|
34
|
+
}) => Promise<T extends "children" ? import("@agoric/cosmic-proto/agoric/vstorage/query.js").QueryChildrenResponse : import("@agoric/cosmic-proto/agoric/vstorage/query.js").QueryDataResponse>;
|
|
35
|
+
readLatest(path?: string): Promise<import("@agoric/cosmic-proto/agoric/vstorage/query.js").QueryDataResponse>;
|
|
36
|
+
keys(path?: string): Promise<string[]>;
|
|
37
|
+
readAt(path: string, height?: number): Promise<import("@agoric/internal/src/lib-chainStorage.js").StreamCell<unknown>>;
|
|
38
|
+
readFully(path: string, minHeight?: number | string): Promise<string[]>;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
export type WalletUtils = import("./smart-wallet-kit.js").SmartWalletKit;
|
|
42
|
+
//# sourceMappingURL=wallet-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-utils.d.ts","sourceRoot":"","sources":["wallet-utils.js"],"names":[],"mappings":"AAIA,6EAA6E;AAE7E,2CAA2C;AAC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAkD;0BAHpC,OAAO,uBAAuB,EAAE,cAAc"}
|
|
File without changes
|