@agoric/client-utils 0.1.1-upgrade-21-dev-07d4845.0 → 0.1.1-ymax-v0.2-alpha-dev-a527ef4.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 +2 -2
- package/src/main.d.ts +1 -0
- package/src/main.d.ts.map +1 -1
- package/src/main.js +1 -0
- package/src/marshalTables.d.ts +11 -0
- package/src/marshalTables.d.ts.map +1 -0
- package/src/marshalTables.js +87 -0
- package/src/smart-wallet-kit.d.ts +2 -1
- package/src/smart-wallet-kit.d.ts.map +1 -1
- package/src/smart-wallet-kit.js +8 -2
- package/src/types.d.ts +4 -1
- package/src/types.d.ts.map +1 -1
- package/src/types.ts +4 -1
- package/src/wallet-utils.d.ts +2 -1
- package/src/wallet-utils.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/client-utils",
|
|
3
|
-
"version": "0.1.1-
|
|
3
|
+
"version": "0.1.1-ymax-v0.2-alpha-dev-a527ef4.0+a527ef4",
|
|
4
4
|
"description": "Utilities for building Agoric clients",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
],
|
|
63
63
|
"timeout": "20m"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "a527ef456b970107c2395833dce9abd87689959e"
|
|
66
66
|
}
|
package/src/main.d.ts
CHANGED
package/src/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["main.js"],"names":[],"mappings":";;;;;;;;;;;6BAA6B,gCAAgC"}
|
package/src/main.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function makeClientMarshaller(valToSlot?: (v: unknown) => string): {
|
|
2
|
+
toCapData: import("@endo/marshal").ToCapData<string | null>;
|
|
3
|
+
fromCapData: import("@endo/marshal").FromCapData<string | null>;
|
|
4
|
+
serialize: import("@endo/marshal").ToCapData<string | null>;
|
|
5
|
+
unserialize: import("@endo/marshal").FromCapData<string | null>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The null slot indicates that identity is not intended to be preserved.
|
|
9
|
+
*/
|
|
10
|
+
export type WildSlot = string | null;
|
|
11
|
+
//# sourceMappingURL=marshalTables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marshalTables.d.ts","sourceRoot":"","sources":["marshalTables.js"],"names":[],"mappings":"AA0EO,iDAFI,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM;;;;;EAchC;;;;uBAxEa,MAAM,GAAG,IAAI"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file marshal tools for vstorage clients
|
|
3
|
+
*
|
|
4
|
+
* TODO: integrate back into @agoric/rpc
|
|
5
|
+
* - fixes: calls to makeClientMarshaller share static mutable state
|
|
6
|
+
* https://github.com/Agoric/ui-kit/issues/73
|
|
7
|
+
* - fits in this plain .js project
|
|
8
|
+
*/
|
|
9
|
+
/** global harden */
|
|
10
|
+
import { Far, makeMarshal } from '@endo/marshal';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The null slot indicates that identity is not intended to be preserved.
|
|
14
|
+
*
|
|
15
|
+
* @typedef { string | null } WildSlot
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Implement conventional parts of convertValToSlot, convertSlotToVal functions
|
|
20
|
+
* for use with makeMarshal based on a slot <-> value translation table,
|
|
21
|
+
* indexed in both directions. Caller supplies functions for making
|
|
22
|
+
* slots, values when not present in the table.
|
|
23
|
+
*
|
|
24
|
+
* @template Val
|
|
25
|
+
* @param {(val: Val, size: number) => string} makeSlot
|
|
26
|
+
* @param {(slot: WildSlot, iface: string | undefined) => Val} makeVal
|
|
27
|
+
*/
|
|
28
|
+
const makeTranslationTable = (makeSlot, makeVal) => {
|
|
29
|
+
/** @type {Map<Val, string>} */
|
|
30
|
+
const valToSlot = new Map();
|
|
31
|
+
/** @type {Map<string, Val>} */
|
|
32
|
+
const slotToVal = new Map();
|
|
33
|
+
|
|
34
|
+
/** @type {(val: Val) => string} */
|
|
35
|
+
const convertValToSlot = val => {
|
|
36
|
+
if (valToSlot.has(val)) {
|
|
37
|
+
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/13086
|
|
38
|
+
return valToSlot.get(val);
|
|
39
|
+
}
|
|
40
|
+
const slot = makeSlot(val, valToSlot.size);
|
|
41
|
+
valToSlot.set(val, slot);
|
|
42
|
+
slotToVal.set(slot, val);
|
|
43
|
+
return slot;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** @type {(slot: WildSlot, iface: string | undefined) => Val} */
|
|
47
|
+
const convertSlotToVal = (slot, iface) => {
|
|
48
|
+
if (slot === null) return makeVal(slot, iface);
|
|
49
|
+
if (slotToVal.has(slot)) {
|
|
50
|
+
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/13086
|
|
51
|
+
return slotToVal.get(slot);
|
|
52
|
+
}
|
|
53
|
+
const val = makeVal(slot, iface);
|
|
54
|
+
valToSlot.set(val, slot);
|
|
55
|
+
slotToVal.set(slot, val);
|
|
56
|
+
return val;
|
|
57
|
+
};
|
|
58
|
+
return harden({ convertValToSlot, convertSlotToVal });
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** @type {(slot: string, iface: string | undefined) => any} */
|
|
62
|
+
const synthesizeRemotable = (slot, iface) => {
|
|
63
|
+
const ifaceStr = iface ?? '';
|
|
64
|
+
const suffix = ifaceStr.endsWith(`#${slot}`) ? '' : `#${slot}`;
|
|
65
|
+
return Far(`${ifaceStr.replace(/^Alleged: /, '')}${suffix}`, {});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Make a marshaller that synthesizes a remotable the first
|
|
70
|
+
* time it sees a slot identifier, allowing clients to recognize
|
|
71
|
+
* object identity for brands, instances, etc.
|
|
72
|
+
*
|
|
73
|
+
* @param {(v: unknown) => string} [valToSlot]
|
|
74
|
+
*/
|
|
75
|
+
export const makeClientMarshaller = valToSlot => {
|
|
76
|
+
const noNewSlots = val => {
|
|
77
|
+
throw Error(`unknown value: ${val}`);
|
|
78
|
+
};
|
|
79
|
+
const { convertValToSlot, convertSlotToVal } = makeTranslationTable(
|
|
80
|
+
valToSlot || noNewSlots,
|
|
81
|
+
synthesizeRemotable,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return makeMarshal(convertValToSlot, convertSlotToVal, {
|
|
85
|
+
serializeBodyFormat: 'smallcaps',
|
|
86
|
+
});
|
|
87
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export function makeSmartWalletKit({ fetch, delay }: {
|
|
1
|
+
export function makeSmartWalletKit({ fetch, delay, names }: {
|
|
2
2
|
fetch: typeof globalThis.fetch;
|
|
3
3
|
delay: (ms: number) => Promise<void>;
|
|
4
|
+
names?: boolean | undefined;
|
|
4
5
|
}, networkConfig: MinimalNetworkConfig): Promise<{
|
|
5
6
|
agoricNames: import("@agoric/vats/tools/board-utils.js").AgoricNamesRemotes;
|
|
6
7
|
networkConfig: MinimalNetworkConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-wallet-kit.d.ts","sourceRoot":"","sources":["smart-wallet-kit.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"smart-wallet-kit.d.ts","sourceRoot":"","sources":["smart-wallet-kit.js"],"names":[],"mappings":"AAsBO,4DALJ;IAAuC,KAAK,EAApC,OAAO,UAAU,CAAC,KAAK;IACc,KAAK,EAA1C,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;IACb,KAAK;CAC7B,iBAAQ,oBAAoB;;;0BAyElB,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;0CA9GT,qBAAqB;kCADR,yCAAyC;yCAAzC,yCAAyC;2BAD7D,2BAA2B;4BAA3B,2BAA2B;6BADjC,WAAW"}
|
package/src/smart-wallet-kit.js
CHANGED
|
@@ -17,14 +17,20 @@ import { makeAgoricNames, makeVstorageKit } from './vstorage-kit.js';
|
|
|
17
17
|
* @param {object} root0
|
|
18
18
|
* @param {typeof globalThis.fetch} root0.fetch
|
|
19
19
|
* @param {(ms: number) => Promise<void>} root0.delay
|
|
20
|
+
* @param {boolean} [root0.names]
|
|
20
21
|
* @param {MinimalNetworkConfig} networkConfig
|
|
21
22
|
*/
|
|
22
|
-
export const makeSmartWalletKit = async (
|
|
23
|
+
export const makeSmartWalletKit = async (
|
|
24
|
+
{ fetch, delay, names = true },
|
|
25
|
+
networkConfig,
|
|
26
|
+
) => {
|
|
23
27
|
const vsk = makeVstorageKit({ fetch }, networkConfig);
|
|
24
28
|
|
|
25
29
|
const client = await makeStargateClient(networkConfig, { fetch });
|
|
26
30
|
|
|
27
|
-
const agoricNames = await
|
|
31
|
+
const agoricNames = await (names
|
|
32
|
+
? makeAgoricNames(vsk.fromBoard, vsk.vstorage)
|
|
33
|
+
: /** @type {import('@agoric/vats/tools/board-utils.js').AgoricNamesRemotes} */ ({}));
|
|
28
34
|
|
|
29
35
|
/**
|
|
30
36
|
* @param {string} from
|
package/src/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Brand } from '@agoric/ertp';
|
|
1
|
+
import type { Brand, Issuer } from '@agoric/ertp';
|
|
2
2
|
import type { ContractRecord, FeeConfig, PoolMetrics, TransactionRecord } from '@agoric/fast-usdc';
|
|
3
3
|
import type { OutcomeRecord, QuestionDetails } from '@agoric/governance/src/types.js';
|
|
4
4
|
import type { BookDataNotification } from '@agoric/inter-protocol/src/auction/auctionBook.js';
|
|
@@ -6,6 +6,7 @@ import type { AuctionParamRecord } from '@agoric/inter-protocol/src/auction/para
|
|
|
6
6
|
import type { ScheduleNotification } from '@agoric/inter-protocol/src/auction/scheduler.js';
|
|
7
7
|
import type { MetricsNotification as VaultDirectorMetrics } from '@agoric/inter-protocol/src/vaultFactory/vaultDirector.js';
|
|
8
8
|
import type { CurrentWalletRecord, UpdateRecord } from '@agoric/smart-wallet/src/smartWallet.js';
|
|
9
|
+
import type { AssetInfo } from '@agoric/vats/src/vat-bank.js';
|
|
9
10
|
import type { Instance } from '@agoric/zoe/src/zoeService/types.js';
|
|
10
11
|
type PublishedTypeMap = {
|
|
11
12
|
'auction.governance': {
|
|
@@ -15,6 +16,8 @@ type PublishedTypeMap = {
|
|
|
15
16
|
'vaultFactory.metrics': VaultDirectorMetrics;
|
|
16
17
|
'agoricNames.instance': Array<[string, Instance]>;
|
|
17
18
|
'agoricNames.brand': Array<[string, Brand]>;
|
|
19
|
+
'agoricNames.issuer': Array<[string, Issuer]>;
|
|
20
|
+
'agoricNames.vbankAsset': Array<[string, AssetInfo]>;
|
|
18
21
|
fastUsdc: ContractRecord;
|
|
19
22
|
'fastUsdc.feeConfig': FeeConfig;
|
|
20
23
|
'fastUsdc.poolMetrics': PoolMetrics;
|
package/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAG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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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @file types for the client-utils package
|
|
2
2
|
// NB: this doesn't follow best practices for TS in JS because this package will likely soon be written in TS
|
|
3
3
|
|
|
4
|
-
import type { Brand } from '@agoric/ertp';
|
|
4
|
+
import type { Brand, Issuer } from '@agoric/ertp';
|
|
5
5
|
import type {
|
|
6
6
|
ContractRecord,
|
|
7
7
|
FeeConfig,
|
|
@@ -20,6 +20,7 @@ import type {
|
|
|
20
20
|
CurrentWalletRecord,
|
|
21
21
|
UpdateRecord,
|
|
22
22
|
} from '@agoric/smart-wallet/src/smartWallet.js';
|
|
23
|
+
import type { AssetInfo } from '@agoric/vats/src/vat-bank.js';
|
|
23
24
|
import type { Instance } from '@agoric/zoe/src/zoeService/types.js';
|
|
24
25
|
|
|
25
26
|
// For static string key types. String template matching has to be in the ternary below.
|
|
@@ -29,6 +30,8 @@ type PublishedTypeMap = {
|
|
|
29
30
|
'vaultFactory.metrics': VaultDirectorMetrics;
|
|
30
31
|
'agoricNames.instance': Array<[string, Instance]>;
|
|
31
32
|
'agoricNames.brand': Array<[string, Brand]>;
|
|
33
|
+
'agoricNames.issuer': Array<[string, Issuer]>;
|
|
34
|
+
'agoricNames.vbankAsset': Array<[string, AssetInfo]>;
|
|
32
35
|
fastUsdc: ContractRecord;
|
|
33
36
|
'fastUsdc.feeConfig': FeeConfig;
|
|
34
37
|
'fastUsdc.poolMetrics': PoolMetrics;
|
package/src/wallet-utils.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/** @typedef {import('./smart-wallet-kit.js').SmartWalletKit} WalletUtils */
|
|
2
2
|
/** @deprecated use `makeSmartWalletKit` */
|
|
3
|
-
export const makeWalletUtils: ({ fetch, delay }: {
|
|
3
|
+
export const makeWalletUtils: ({ fetch, delay, names }: {
|
|
4
4
|
fetch: typeof globalThis.fetch;
|
|
5
5
|
delay: (ms: number) => Promise<void>;
|
|
6
|
+
names?: boolean | undefined;
|
|
6
7
|
}, networkConfig: import("./network-config.js").MinimalNetworkConfig) => Promise<{
|
|
7
8
|
agoricNames: import("@agoric/vats/tools/board-utils.js").AgoricNamesRemotes;
|
|
8
9
|
networkConfig: import("./network-config.js").MinimalNetworkConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet-utils.d.ts","sourceRoot":"","sources":["wallet-utils.js"],"names":[],"mappings":"AAIA,6EAA6E;AAE7E,2CAA2C;AAC3C
|
|
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"}
|