@agoric/client-utils 0.1.1-dev-1c730f2.0 → 0.1.1-dev-f80bb26.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/client-utils",
3
- "version": "0.1.1-dev-1c730f2.0+1c730f2",
3
+ "version": "0.1.1-dev-f80bb26.0+f80bb26",
4
4
  "description": "Utilities for building Agoric clients",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
@@ -13,6 +13,8 @@
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",
@@ -27,12 +29,12 @@
27
29
  "ts-blank-space": "^0.6.1"
28
30
  },
29
31
  "dependencies": {
30
- "@agoric/casting": "0.4.3-dev-1c730f2.0+1c730f2",
31
- "@agoric/cosmic-proto": "0.4.1-dev-1c730f2.0+1c730f2",
32
- "@agoric/ertp": "0.16.3-dev-1c730f2.0+1c730f2",
33
- "@agoric/internal": "0.3.3-dev-1c730f2.0+1c730f2",
34
- "@agoric/smart-wallet": "0.5.4-dev-1c730f2.0+1c730f2",
35
- "@agoric/vats": "0.15.2-dev-1c730f2.0+1c730f2",
32
+ "@agoric/casting": "0.4.3-dev-f80bb26.0+f80bb26",
33
+ "@agoric/cosmic-proto": "0.4.1-dev-f80bb26.0+f80bb26",
34
+ "@agoric/ertp": "0.16.3-dev-f80bb26.0+f80bb26",
35
+ "@agoric/internal": "0.3.3-dev-f80bb26.0+f80bb26",
36
+ "@agoric/smart-wallet": "0.5.4-dev-f80bb26.0+f80bb26",
37
+ "@agoric/vats": "0.15.2-dev-f80bb26.0+f80bb26",
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": "1c730f2199678c14aec52792a0663d93a63741b1"
65
+ "gitHead": "f80bb26afd3941d14a34ff01ecdfa29913ee4e47"
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
@@ -0,0 +1,6 @@
1
+ export function fetchEnvNetworkConfig({ env, fetch }: {
2
+ env: typeof process.env;
3
+ fetch: typeof globalThis.fetch;
4
+ }): Promise<MinimalNetworkConfig>;
5
+ import type { MinimalNetworkConfig } from './network-config.js';
6
+ //# sourceMappingURL=cli.d.ts.map
@@ -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,10 @@
1
+ export * from "./cli.js";
2
+ export * from "./network-config.js";
3
+ export * from "./rpc.js";
4
+ export * from "./smart-wallet-kit.js";
5
+ export * from "./sync-tools.js";
6
+ export * from "./vstorage.js";
7
+ export * from "./vstorage-kit.js";
8
+ export * from "./wallet-utils.js";
9
+ export * from "./types-index.js";
10
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.js"],"names":[],"mappings":""}
package/src/main.js CHANGED
@@ -8,4 +8,4 @@ export * from './vstorage-kit.js';
8
8
  export * from './wallet-utils.js';
9
9
 
10
10
  // eslint-disable-next-line import/export -- just types
11
- export * from './types.js';
11
+ 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
@@ -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"}
@@ -0,0 +1,2 @@
1
+ // Export all the types this package provides
2
+ export type * from './types.js';
package/src/types.d.ts CHANGED
@@ -1,54 +1,28 @@
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 {
5
- OutcomeRecord,
6
- QuestionDetails,
7
- } from '@agoric/governance/src/types.js';
8
- import type { MetricsNotification as VaultManagerMetrics } from '@agoric/inter-protocol/src/vaultFactory/vaultManager.js';
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
- 'auction.governance': { current: AuctionParamRecord };
22
- 'auction.schedule': ScheduleNotification;
23
- 'vaultFactory.metrics': { rewardPoolAllocation: RewardPoolAllocationRecord };
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
- ? PublishedTypeMap[T]
32
- : T extends `wallet.${string}.current`
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"}
@@ -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
 
@@ -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"}
@@ -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