@agoric/client-utils 0.2.0-upgrade-20-dev-ef71cfd.0 → 0.2.0-upgrade-19-devnet-dev-5428c4d.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.2.0-upgrade-20-dev-ef71cfd.0+ef71cfd",
3
+ "version": "0.2.0-upgrade-19-devnet-dev-5428c4d.0+5428c4d",
4
4
  "description": "Utilities for building Agoric clients",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
@@ -27,21 +27,19 @@
27
27
  "ts-blank-space": "^0.4.4"
28
28
  },
29
29
  "dependencies": {
30
- "@agoric/casting": "0.5.0-upgrade-20-dev-ef71cfd.0+ef71cfd",
31
- "@agoric/cosmic-proto": "0.5.0-upgrade-20-dev-ef71cfd.0+ef71cfd",
32
- "@agoric/ertp": "0.16.3-upgrade-20-dev-ef71cfd.0+ef71cfd",
33
- "@agoric/internal": "0.4.0-upgrade-20-dev-ef71cfd.0+ef71cfd",
34
- "@agoric/smart-wallet": "0.5.4-upgrade-20-dev-ef71cfd.0+ef71cfd",
35
- "@agoric/vats": "0.16.0-upgrade-20-dev-ef71cfd.0+ef71cfd",
36
- "@cosmjs/stargate": "^0.33.0",
37
- "@cosmjs/tendermint-rpc": "^0.33.0",
38
- "@endo/base64": "^1.0.9",
39
- "@endo/common": "^1.2.10",
40
- "@endo/errors": "^1.2.10",
41
- "@endo/marshal": "^1.6.4",
42
- "@endo/pass-style": "^1.5.0",
43
- "@endo/patterns": "^1.5.0",
44
- "@endo/promise-kit": "^1.1.10"
30
+ "@agoric/casting": "0.4.3-upgrade-19-devnet-dev-5428c4d.0+5428c4d",
31
+ "@agoric/ertp": "0.16.3-upgrade-19-devnet-dev-5428c4d.0+5428c4d",
32
+ "@agoric/internal": "0.4.0-upgrade-19-devnet-dev-5428c4d.0+5428c4d",
33
+ "@agoric/smart-wallet": "0.5.4-upgrade-19-devnet-dev-5428c4d.0+5428c4d",
34
+ "@agoric/vats": "0.16.0-upgrade-19-devnet-dev-5428c4d.0+5428c4d",
35
+ "@cosmjs/stargate": "^0.32.3",
36
+ "@cosmjs/tendermint-rpc": "^0.32.3",
37
+ "@endo/common": "^1.2.9",
38
+ "@endo/errors": "^1.2.9",
39
+ "@endo/marshal": "^1.6.3",
40
+ "@endo/pass-style": "^1.4.8",
41
+ "@endo/patterns": "^1.4.8",
42
+ "@endo/promise-kit": "^1.1.9"
45
43
  },
46
44
  "ava": {
47
45
  "extensions": {
@@ -60,5 +58,5 @@
60
58
  ],
61
59
  "timeout": "20m"
62
60
  },
63
- "gitHead": "ef71cfdc9e62572cab9a3d2821dc446ce0d700c3"
61
+ "gitHead": "5428c4da67b53cef7ff53ba7b2a28cf6ec8f643a"
64
62
  }
package/src/types.d.ts CHANGED
@@ -10,11 +10,7 @@ import type {
10
10
  CurrentWalletRecord,
11
11
  UpdateRecord,
12
12
  } from '@agoric/smart-wallet/src/smartWallet.js';
13
- import type {
14
- ContractRecord,
15
- PoolMetrics,
16
- TransactionRecord,
17
- } from '@agoric/fast-usdc';
13
+ import type { ContractRecord, PoolMetrics } from '@agoric/fast-usdc';
18
14
 
19
15
  // For static string key types. String template matching has to be in the ternary below.
20
16
  type PublishedTypeMap = {
@@ -45,10 +41,6 @@ export type TypedPublished<T extends string> = T extends keyof PublishedTypeMap
45
41
  ? Array<[string, Brand]>
46
42
  : T extends 'fastUsdc'
47
43
  ? 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;
44
+ : T extends 'fastUsdc.poolMetrics'
45
+ ? PoolMetrics
46
+ : unknown;
package/src/vstorage.js CHANGED
@@ -1,81 +1,26 @@
1
- import {
2
- QueryChildrenRequest,
3
- QueryChildrenResponse,
4
- QueryDataRequest,
5
- QueryDataResponse,
6
- } from '@agoric/cosmic-proto/agoric/vstorage/query.js';
7
- import { decodeBase64 } from '@endo/base64';
8
- import { encodeHex } from '@agoric/internal/src/hex.js';
1
+ /* global Buffer */
9
2
 
10
3
  /**
11
4
  * @import {MinimalNetworkConfig} from './network-config.js';
12
5
  */
13
6
 
14
- const codecs = {
15
- children: {
16
- rpc: '/agoric.vstorage.Query/Children',
17
- request: QueryChildrenRequest,
18
- response: QueryChildrenResponse,
19
- },
20
- data: {
21
- rpc: '/agoric.vstorage.Query/Data',
22
- request: QueryDataRequest,
23
- response: QueryDataResponse,
24
- },
25
- };
26
-
27
- /** @typedef {(typeof codecs)[keyof typeof codecs]['response']} ResponseCodec */
28
-
29
7
  /**
30
8
  * @param {object} powers
31
9
  * @param {typeof window.fetch} powers.fetch
32
10
  * @param {MinimalNetworkConfig} config
33
11
  */
34
12
  export const makeVStorage = ({ fetch }, config) => {
35
- /**
36
- * @param {string} path
37
- */
38
- const getJSON = async path => {
13
+ /** @param {string} path */
14
+ const getJSON = path => {
39
15
  const url = config.rpcAddrs[0] + path;
40
16
  // console.warn('fetching', url);
41
- const res = await fetch(url, { keepalive: true });
42
- return res.json();
43
- };
44
-
45
- /**
46
- * @template {keyof codecs} T
47
- * @param {string} [path]
48
- * @param {object} [opts]
49
- * @param {T} [opts.kind]
50
- * @param {number | bigint} [opts.height] 0 is the same as omitting height and implies the highest block
51
- */
52
- const url = (
53
- path = 'published',
54
- { kind = /** @type {T} */ ('children'), height = 0 } = {},
55
- ) => {
56
- const codec = codecs[kind];
57
- if (!codec) {
58
- throw Error(`unknown rpc kind: ${kind}`);
59
- }
60
-
61
- const { rpc, request } = codec;
62
- const buf = request.toProto({ path });
63
-
64
- const hexData = encodeHex(buf);
65
- return `/abci_query?path=%22${rpc}%22&data=0x${hexData}&height=${height}`;
17
+ return fetch(url, { keepalive: true }).then(res => res.json());
66
18
  };
19
+ // height=0 is the same as omitting height and implies the highest block
20
+ const url = (path = 'published', { kind = 'children', height = 0 } = {}) =>
21
+ `/abci_query?path=%22/custom/vstorage/${kind}/${path}%22&height=${height}`;
67
22
 
68
- /**
69
- * @template {keyof codecs} T
70
- * @param {string} [path]
71
- * @param {object} [opts]
72
- * @param {T} [opts.kind]
73
- * @param {number | bigint} [opts.height] 0 is the same as omitting height and implies the highest block
74
- */
75
- const readStorage = (
76
- path = 'published',
77
- { kind = /** @type {T} */ ('children'), height = 0 } = {},
78
- ) =>
23
+ const readStorage = (path = 'published', { kind = 'children', height = 0 }) =>
79
24
  getJSON(url(path, { kind, height }))
80
25
  .catch(err => {
81
26
  throw Error(`cannot read ${kind} of ${path}: ${err.message}`);
@@ -93,29 +38,18 @@ export const makeVStorage = ({ fetch }, config) => {
93
38
  err.codespace = response?.codespace;
94
39
  throw err;
95
40
  }
96
-
97
- const codec = codecs[kind];
98
- if (!codec) {
99
- throw Error(`unknown codec for kind: ${kind}`);
100
- }
101
- return { ...data, codec: codec.response };
41
+ return data;
102
42
  });
103
43
 
104
44
  const vstorage = {
105
45
  url,
106
- /**
107
- * @param {{ result: { response: { value: string, code: number } }, codec?: ResponseCodec }} param0
108
- */
109
- decode({ result: { response }, codec }) {
46
+ decode({ result: { response } }) {
110
47
  const { code } = response;
111
48
  if (code !== 0) {
112
49
  throw response;
113
50
  }
114
- const { value: b64Value } = response;
115
- if (!codec) {
116
- return atob(b64Value);
117
- }
118
- return JSON.stringify(codec.decode(decodeBase64(b64Value)));
51
+ const { value } = response;
52
+ return Buffer.from(value, 'base64').toString();
119
53
  },
120
54
  /**
121
55
  *