@agoric/casting 0.4.3-other-dev-8f8782b.0 → 0.4.3-other-dev-fbe72e7.0.fbe72e7
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/CHANGELOG.md +0 -8
- package/README.md +3 -4
- package/package.json +32 -29
- package/src/casting-spec.d.ts +8 -8
- package/src/casting-spec.d.ts.map +1 -1
- package/src/casting-spec.js +7 -9
- package/src/change-follower.d.ts +1 -1
- package/src/change-follower.d.ts.map +1 -1
- package/src/change-follower.js +2 -2
- package/src/defaults.d.ts +9 -5
- package/src/defaults.d.ts.map +1 -1
- package/src/defaults.js +11 -2
- package/src/follower-cosmjs.d.ts +2 -2
- package/src/follower-cosmjs.d.ts.map +1 -1
- package/src/follower-cosmjs.js +56 -23
- package/src/follower.d.ts +1 -1
- package/src/follower.d.ts.map +1 -1
- package/src/follower.js +6 -6
- package/src/iterable.d.ts +12 -12
- package/src/iterable.d.ts.map +1 -1
- package/src/iterable.js +2 -1
- package/src/leader-netconfig.d.ts +3 -3
- package/src/leader-netconfig.d.ts.map +1 -1
- package/src/leader-netconfig.js +1 -2
- package/src/leader.d.ts +1 -1
- package/src/leader.d.ts.map +1 -1
- package/src/leader.js +1 -5
- package/src/main.d.ts +1 -0
- package/src/main.js +3 -0
- package/src/makeHttpClient.d.ts +3 -0
- package/src/makeHttpClient.d.ts.map +1 -0
- package/src/makeHttpClient.js +59 -0
- package/src/netconfig.d.ts.map +1 -1
- package/src/shuffle.d.ts +1 -1
- package/src/shuffle.d.ts.map +1 -1
- package/src/types.d.ts +18 -12
- package/src/types.d.ts.map +1 -1
- package/src/types.js +11 -8
- package/test/interpose-net-access.test.js +122 -0
- package/test/lockdown.js +0 -1
- package/test/{test-mvp.js → mvp.test.js} +58 -2
- package/test/net-access-fixture.js +196 -0
- package/test/types.test-d.ts +31 -0
- package/tsconfig.build.json +6 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/{jsconfig.json → tsconfig.json} +3 -2
- package/jsconfig.build.json +0 -12
- package/node-fetch-shim.d.ts +0 -2
- package/node-fetch-shim.d.ts.map +0 -1
- package/node-fetch-shim.js +0 -7
- /package/test/{test-netconfig.js → netconfig.test.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,14 +3,6 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
### [0.4.3-u11.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/casting@0.4.2...@agoric/casting@0.4.3-u11.0) (2023-08-24)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @agoric/casting
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
6
|
### [0.4.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/casting@0.4.1...@agoric/casting@0.4.2) (2023-06-02)
|
|
15
7
|
|
|
16
8
|
**Note:** Version bump only for package @agoric/casting
|
package/README.md
CHANGED
|
@@ -13,7 +13,6 @@ An example of following an on-chain mailbox in code (using this package) is:
|
|
|
13
13
|
```js
|
|
14
14
|
// First, obtain a Hardened JS environment via Endo.
|
|
15
15
|
import '@endo/init/pre-remoting.js'; // needed only for the next line
|
|
16
|
-
import '@agoric/casting/node-fetch-shim.js'; // needed for Node.js
|
|
17
16
|
import '@endo/init';
|
|
18
17
|
|
|
19
18
|
import {
|
|
@@ -42,7 +41,7 @@ The `followerOpts` argument in `makeFollower(leader, key, followerOpts)` provide
|
|
|
42
41
|
- the `decode` option is a function to translate `buf: Uint8Array` into `data: string`
|
|
43
42
|
- (default) - interpret buf as a utf-8 string, then `JSON.parse` it
|
|
44
43
|
- the `unserializer` option can be
|
|
45
|
-
- (default) - release unserialized objects using
|
|
44
|
+
- (default) - release unserialized objects using [@endo/marshal](https://www.npmjs.com/package/@endo/marshal)'s `makeMarshal()`
|
|
46
45
|
- `null` - don't additionally unserialize data before releasing it
|
|
47
46
|
- any unserializer object supporting `E(unserializer).fromCapData(data)`
|
|
48
47
|
- the `crasher` option can be
|
|
@@ -65,8 +64,8 @@ The `followerOpts` argument in `makeFollower(leader, key, followerOpts)` provide
|
|
|
65
64
|
|
|
66
65
|
This package currently depends on:
|
|
67
66
|
- Hardened Javascript
|
|
68
|
-
-
|
|
69
|
-
-
|
|
67
|
+
- [@agoric/notifier](../notifier) async iterable adapters to implement `iterateLatest`
|
|
68
|
+
- [@endo/marshal](https://www.npmjs.com/package/@endo/marshal) for default object unserialization
|
|
70
69
|
- [CosmJS](https://github.com/cosmos/cosmjs) for proof verification, although [it does not yet support light client tracking of the validator set](https://github.com/cosmos/cosmjs/issues/492)
|
|
71
70
|
- a bespoke follower of [WebSocket Tendermint events](https://docs.tendermint.com/master/tendermint-core/subscription.html#legacy-streaming-api)
|
|
72
71
|
|
package/package.json
CHANGED
|
@@ -1,62 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/casting",
|
|
3
|
-
"version": "0.4.3-other-dev-
|
|
3
|
+
"version": "0.4.3-other-dev-fbe72e7.0.fbe72e7",
|
|
4
4
|
"description": "Agoric's OCap broadcasting system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main.js",
|
|
7
7
|
"repository": "https://github.com/Agoric/agoric-sdk",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "exit 0",
|
|
10
|
-
"prepack": "tsc --build
|
|
11
|
-
"postpack": "git clean -f '*.d
|
|
10
|
+
"prepack": "yarn run -T tsc --build tsconfig.build.json",
|
|
11
|
+
"postpack": "git clean -f '*.d.*ts*' '*.tsbuildinfo'",
|
|
12
12
|
"demo": "node -e 'import(\"./test/fake-rpc-server.js\").then(ns => ns.develop())'",
|
|
13
13
|
"test": "ava",
|
|
14
|
-
"test:c8": "c8 $C8_OPTIONS ava
|
|
14
|
+
"test:c8": "c8 --all ${C8_OPTIONS:-} ava",
|
|
15
15
|
"test:xs": "exit 0",
|
|
16
16
|
"lint-fix": "yarn lint:eslint --fix",
|
|
17
|
-
"lint": "run-s --continue-on-error lint:*",
|
|
18
|
-
"lint:types": "
|
|
19
|
-
"lint:eslint": "
|
|
17
|
+
"lint": "yarn run -T run-s --continue-on-error 'lint:*'",
|
|
18
|
+
"lint:types": "yarn run -T tsc",
|
|
19
|
+
"lint:eslint": "yarn run -T eslint ."
|
|
20
20
|
},
|
|
21
21
|
"keywords": [],
|
|
22
22
|
"author": "Agoric",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@agoric/internal": "0.3.3-other-dev-
|
|
26
|
-
"@agoric/notifier": "0.6.3-other-dev-
|
|
27
|
-
"@agoric/
|
|
28
|
-
"@
|
|
29
|
-
"@cosmjs/
|
|
30
|
-
"@cosmjs/
|
|
31
|
-
"@cosmjs/
|
|
32
|
-
"@
|
|
33
|
-
"@endo/far": "
|
|
34
|
-
"@endo/init": "
|
|
35
|
-
"@endo/lockdown": "0.
|
|
36
|
-
"@endo/marshal": "
|
|
37
|
-
"@endo/promise-kit": "
|
|
38
|
-
"node-fetch": "^2.6.0"
|
|
25
|
+
"@agoric/internal": "0.3.3-other-dev-fbe72e7.0.fbe72e7",
|
|
26
|
+
"@agoric/notifier": "0.6.3-other-dev-fbe72e7.0.fbe72e7",
|
|
27
|
+
"@agoric/store": "0.9.3-other-dev-fbe72e7.0.fbe72e7",
|
|
28
|
+
"@cosmjs/encoding": "^0.36.0",
|
|
29
|
+
"@cosmjs/proto-signing": "^0.36.0",
|
|
30
|
+
"@cosmjs/stargate": "^0.36.0",
|
|
31
|
+
"@cosmjs/tendermint-rpc": "^0.36.0",
|
|
32
|
+
"@endo/errors": "^1.2.13",
|
|
33
|
+
"@endo/far": "^1.1.14",
|
|
34
|
+
"@endo/init": "^1.1.12",
|
|
35
|
+
"@endo/lockdown": "^1.0.18",
|
|
36
|
+
"@endo/marshal": "^1.8.0",
|
|
37
|
+
"@endo/promise-kit": "^1.1.13"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"ava": "^5.
|
|
44
|
-
"c8": "^
|
|
45
|
-
"express": "^
|
|
40
|
+
"@agoric/cosmic-proto": "0.4.1-other-dev-fbe72e7.0.fbe72e7",
|
|
41
|
+
"@endo/ses-ava": "^1.3.2",
|
|
42
|
+
"ava": "^5.3.0",
|
|
43
|
+
"c8": "^10.1.3",
|
|
44
|
+
"express": "^5.0.1",
|
|
45
|
+
"tsd": "^0.33.0",
|
|
46
46
|
"ws": "^7.2.0"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
|
-
"node": "
|
|
52
|
+
"node": "^20.9 || ^22.11"
|
|
53
53
|
},
|
|
54
54
|
"ava": {
|
|
55
55
|
"files": [
|
|
56
|
-
"test
|
|
56
|
+
"test/**/*.test.*"
|
|
57
57
|
],
|
|
58
58
|
"timeout": "20m",
|
|
59
59
|
"workerThreads": false
|
|
60
60
|
},
|
|
61
|
-
"
|
|
61
|
+
"typeCoverage": {
|
|
62
|
+
"atLeast": 89.19
|
|
63
|
+
},
|
|
64
|
+
"gitHead": "fbe72e72107f9997f788674e668c660d92ec4492"
|
|
62
65
|
}
|
package/src/casting-spec.d.ts
CHANGED
|
@@ -2,15 +2,15 @@ export function vstorageKeySpecToPath({ storeName, storeSubkey }: VStorageKey):
|
|
|
2
2
|
/**
|
|
3
3
|
* @param {string} storagePath
|
|
4
4
|
* @param {string} [storeName]
|
|
5
|
-
* @returns {import('./types').CastingSpec}
|
|
5
|
+
* @returns {import('./types.js').CastingSpec}
|
|
6
6
|
*/
|
|
7
|
-
export function DEFAULT_PATH_CONVERTER(storagePath: string, storeName?: string
|
|
7
|
+
export function DEFAULT_PATH_CONVERTER(storagePath: string, storeName?: string): import("./types.js").CastingSpec;
|
|
8
8
|
/**
|
|
9
|
-
* @type {Record<string, (path: string) => import('./types').CastingSpec>}
|
|
9
|
+
* @type {Record<string, (path: string) => import('./types.js').CastingSpec>}
|
|
10
10
|
*/
|
|
11
|
-
export const pathPrefixToConverters: Record<string, (path: string) => import(
|
|
12
|
-
export function makeCastingSpecFromString(specString: string): import(
|
|
13
|
-
export function makeCastingSpecFromObject(specObj: any): import(
|
|
14
|
-
export function makeCastingSpecFromRef(specCap: ERef<any>): Promise<import(
|
|
15
|
-
export function makeCastingSpec(sourceP: ERef<unknown>): Promise<import(
|
|
11
|
+
export const pathPrefixToConverters: Record<string, (path: string) => import("./types.js").CastingSpec>;
|
|
12
|
+
export function makeCastingSpecFromString(specString: string): import("./types.js").CastingSpec;
|
|
13
|
+
export function makeCastingSpecFromObject(specObj: any): import("./types.js").CastingSpec;
|
|
14
|
+
export function makeCastingSpecFromRef(specCap: ERef<any>): Promise<import("./types.js").CastingSpec>;
|
|
15
|
+
export function makeCastingSpec(sourceP: ERef<unknown>): Promise<import("./types.js").CastingSpec>;
|
|
16
16
|
//# sourceMappingURL=casting-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"casting-spec.d.ts","sourceRoot":"","sources":["casting-spec.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"casting-spec.d.ts","sourceRoot":"","sources":["casting-spec.js"],"names":[],"mappings":"AA6CO,kEAHI,WAAW,GACT,MAAM,CAYlB;AAlCD;;;;GAIG;AACH,oDAJW,MAAM,cACN,MAAM,GACJ,OAAO,YAAY,EAAE,WAAW,CAa5C;AAsBD;;GAEG;AACH,qCAFU,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,YAAY,EAAE,WAAW,CAAC,CAMzE;AAMI,sDAHI,MAAM,GACJ,OAAO,YAAY,EAAE,WAAW,CAc5C;AAQM,mDAHI,GAAG,GACD,OAAO,YAAY,EAAE,WAAW,CAmC5C;AAMM,gDAHI,IAAI,CAAC,GAAG,CAAC,GACP,OAAO,CAAC,OAAO,YAAY,EAAE,WAAW,CAAC,CAKrD;AAQM,yCAHI,IAAI,CAAC,OAAO,CAAC,GACX,OAAO,CAAC,OAAO,YAAY,EAAE,WAAW,CAAC,CAgBrD"}
|
package/src/casting-spec.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import * as encodingStar from '@cosmjs/encoding';
|
|
2
2
|
import { E, getInterfaceOf } from '@endo/far';
|
|
3
3
|
|
|
4
|
-
import './types.js';
|
|
5
|
-
|
|
6
4
|
const { toAscii } = encodingStar;
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* @param {string} storagePath
|
|
10
|
-
* @returns {import('./types').CastingSpec}
|
|
8
|
+
* @returns {import('./types.js').CastingSpec}
|
|
11
9
|
*/
|
|
12
10
|
const swingsetPathToCastingSpec = storagePath =>
|
|
13
11
|
harden({
|
|
@@ -24,7 +22,7 @@ const NO_DATA_VALUE = new Uint8Array([255]);
|
|
|
24
22
|
/**
|
|
25
23
|
* @param {string} storagePath
|
|
26
24
|
* @param {string} [storeName]
|
|
27
|
-
* @returns {import('./types').CastingSpec}
|
|
25
|
+
* @returns {import('./types.js').CastingSpec}
|
|
28
26
|
*/
|
|
29
27
|
const vstoragePathToCastingSpec = (storagePath, storeName = 'vstorage') => {
|
|
30
28
|
const elems = storagePath ? storagePath.split('.') : [];
|
|
@@ -60,7 +58,7 @@ export const vstorageKeySpecToPath = ({ storeName, storeSubkey }) => {
|
|
|
60
58
|
export const DEFAULT_PATH_CONVERTER = vstoragePathToCastingSpec;
|
|
61
59
|
|
|
62
60
|
/**
|
|
63
|
-
* @type {Record<string, (path: string) => import('./types').CastingSpec>}
|
|
61
|
+
* @type {Record<string, (path: string) => import('./types.js').CastingSpec>}
|
|
64
62
|
*/
|
|
65
63
|
export const pathPrefixToConverters = harden({
|
|
66
64
|
'swingset:': swingsetPathToCastingSpec,
|
|
@@ -70,7 +68,7 @@ export const pathPrefixToConverters = harden({
|
|
|
70
68
|
|
|
71
69
|
/**
|
|
72
70
|
* @param {string} specString
|
|
73
|
-
* @returns {import('./types').CastingSpec}
|
|
71
|
+
* @returns {import('./types.js').CastingSpec}
|
|
74
72
|
*/
|
|
75
73
|
export const makeCastingSpecFromString = specString => {
|
|
76
74
|
assert.typeof(specString, 'string');
|
|
@@ -90,7 +88,7 @@ const te = new TextEncoder();
|
|
|
90
88
|
|
|
91
89
|
/**
|
|
92
90
|
* @param {any} specObj
|
|
93
|
-
* @returns {import('./types').CastingSpec}
|
|
91
|
+
* @returns {import('./types.js').CastingSpec}
|
|
94
92
|
*/
|
|
95
93
|
export const makeCastingSpecFromObject = specObj => {
|
|
96
94
|
const {
|
|
@@ -129,7 +127,7 @@ export const makeCastingSpecFromObject = specObj => {
|
|
|
129
127
|
|
|
130
128
|
/**
|
|
131
129
|
* @param {ERef<any>} specCap
|
|
132
|
-
* @returns {Promise<import('./types').CastingSpec>}
|
|
130
|
+
* @returns {Promise<import('./types.js').CastingSpec>}
|
|
133
131
|
*/
|
|
134
132
|
export const makeCastingSpecFromRef = async specCap => {
|
|
135
133
|
const specObj = await E(specCap).getStoreKey();
|
|
@@ -140,7 +138,7 @@ export const makeCastingSpecFromRef = async specCap => {
|
|
|
140
138
|
* Create an abstract type from a given source representation
|
|
141
139
|
*
|
|
142
140
|
* @param {ERef<unknown>} sourceP
|
|
143
|
-
* @returns {Promise<import('./types').CastingSpec>}
|
|
141
|
+
* @returns {Promise<import('./types.js').CastingSpec>}
|
|
144
142
|
*/
|
|
145
143
|
export const makeCastingSpec = async sourceP => {
|
|
146
144
|
const spec = await sourceP;
|
package/src/change-follower.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function makePollingChangeFollower(leader: import(
|
|
1
|
+
export function makePollingChangeFollower(leader: import("./types.js").Leader): Promise<import("./types.js").Follower<import("./types.js").CastingChange>>;
|
|
2
2
|
//# sourceMappingURL=change-follower.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change-follower.d.ts","sourceRoot":"","sources":["change-follower.js"],"names":[],"mappings":"AASO,kDAHI,OAAO,
|
|
1
|
+
{"version":3,"file":"change-follower.d.ts","sourceRoot":"","sources":["change-follower.js"],"names":[],"mappings":"AASO,kDAHI,OAAO,YAAY,EAAE,MAAM,GACzB,OAAO,CAAC,OAAO,YAAY,EAAE,QAAQ,CAAC,OAAO,YAAY,EAAE,aAAa,CAAC,CAAC,CA6CtF"}
|
package/src/change-follower.js
CHANGED
|
@@ -4,8 +4,8 @@ import { DEFAULT_KEEP_POLLING } from './defaults.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Just return an unspecified allegedValue every poll period.
|
|
6
6
|
*
|
|
7
|
-
* @param {import('./types').Leader} leader
|
|
8
|
-
* @returns {Promise<import('./types.js').Follower<import('./types').CastingChange>>}
|
|
7
|
+
* @param {import('./types.js').Leader} leader
|
|
8
|
+
* @returns {Promise<import('./types.js').Follower<import('./types.js').CastingChange>>}
|
|
9
9
|
*/
|
|
10
10
|
export const makePollingChangeFollower = async leader => {
|
|
11
11
|
const { keepPolling = DEFAULT_KEEP_POLLING } = await E(leader).getOptions();
|
package/src/defaults.d.ts
CHANGED
|
@@ -5,17 +5,21 @@ export const DEFAULT_BOOTSTRAP: "http://localhost:26657";
|
|
|
5
5
|
export const DEFAULT_JITTER_SECONDS: 5;
|
|
6
6
|
export const DEFAULT_POLL_WITH_EVENTS_SECONDS: 600;
|
|
7
7
|
export const DEFAULT_KEEP_POLLING_SECONDS: 5;
|
|
8
|
+
/**
|
|
9
|
+
* Default backoff is the block interval.
|
|
10
|
+
*/
|
|
11
|
+
export const DEFAULT_MAX_BACKOFF: 6000;
|
|
8
12
|
export function delay(ms: number): Promise<void>;
|
|
9
|
-
export function randomBackoff(range: number, cap?: number
|
|
10
|
-
export function exponentialBackoff(attempt?: number
|
|
13
|
+
export function randomBackoff(range: number, cap?: number): number;
|
|
14
|
+
export function exponentialBackoff(attempt?: number, base?: number, cap?: number): number;
|
|
11
15
|
export function DEFAULT_JITTER(where: string): Promise<void>;
|
|
12
|
-
export function DEFAULT_RETRY_CALLBACK(where: string, err: any, attempt?: number
|
|
16
|
+
export function DEFAULT_RETRY_CALLBACK(where: string, err: any, attempt?: number): Promise<void>;
|
|
13
17
|
export function DEFAULT_KEEP_POLLING(): Promise<boolean>;
|
|
14
18
|
export function MAKE_DEFAULT_DECODER(): (str: any) => any;
|
|
15
19
|
/**
|
|
16
20
|
* Unserialize the JSONable data.
|
|
17
21
|
*
|
|
18
|
-
* @type {() => import('./types').Unserializer}
|
|
22
|
+
* @type {() => import('./types.js').Unserializer}
|
|
19
23
|
*/
|
|
20
|
-
export const MAKE_DEFAULT_UNSERIALIZER: () => import(
|
|
24
|
+
export const MAKE_DEFAULT_UNSERIALIZER: () => import("./types.js").Unserializer;
|
|
21
25
|
//# sourceMappingURL=defaults.d.ts.map
|
package/src/defaults.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["defaults.js"],"names":[],"mappings":"AAIA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["defaults.js"],"names":[],"mappings":"AAIA;;GAEG;AACH,gCAAiC,wBAAwB,CAAC;AAE1D,qCAAsC,CAAC,CAAC;AAExC,+CAAgD,GAAG,CAAC;AAEpD,2CAA4C,CAAC,CAAC;AAE9C;;GAEG;AACH,kCAAmC,IAAK,CAAC;AAUlC,0BAHI,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAEgD;AAMnE,qCAHI,MAAM,QACN,MAAM,UAIhB;AAOM,6CAJI,MAAM,SACN,MAAM,QACN,MAAM,UAQhB;AAQM,sCAHI,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAMzB;AAUM,8CALI,MAAM,OACN,GAAG,YACH,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CASzB;AAOM,wCAFM,OAAO,CAAC,OAAO,CAAC,CAGgD;AAEtE,0DAaN;AAED;;;;GAIG;AACH,wCAFU,MAAM,OAAO,YAAY,EAAE,YAAY,CA2B/C"}
|
package/src/defaults.js
CHANGED
|
@@ -13,6 +13,11 @@ export const DEFAULT_POLL_WITH_EVENTS_SECONDS = 600;
|
|
|
13
13
|
|
|
14
14
|
export const DEFAULT_KEEP_POLLING_SECONDS = 5;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Default backoff is the block interval.
|
|
18
|
+
*/
|
|
19
|
+
export const DEFAULT_MAX_BACKOFF = 6_000;
|
|
20
|
+
|
|
16
21
|
/**
|
|
17
22
|
* Resolve a Promise after a given number of milliseconds.
|
|
18
23
|
*
|
|
@@ -36,7 +41,11 @@ export const randomBackoff = (range, cap = range) => {
|
|
|
36
41
|
* @param {number} [base]
|
|
37
42
|
* @param {number} [cap]
|
|
38
43
|
*/
|
|
39
|
-
export const exponentialBackoff = (
|
|
44
|
+
export const exponentialBackoff = (
|
|
45
|
+
attempt = 0,
|
|
46
|
+
base = 1_000,
|
|
47
|
+
cap = DEFAULT_MAX_BACKOFF,
|
|
48
|
+
) => {
|
|
40
49
|
return randomBackoff(2 ** attempt * base, cap);
|
|
41
50
|
};
|
|
42
51
|
|
|
@@ -95,7 +104,7 @@ export const MAKE_DEFAULT_DECODER = () => {
|
|
|
95
104
|
/**
|
|
96
105
|
* Unserialize the JSONable data.
|
|
97
106
|
*
|
|
98
|
-
* @type {() => import('./types').Unserializer}
|
|
107
|
+
* @type {() => import('./types.js').Unserializer}
|
|
99
108
|
*/
|
|
100
109
|
export const MAKE_DEFAULT_UNSERIALIZER = () => {
|
|
101
110
|
const ifaceAllegedPrefix = 'Alleged: ';
|
package/src/follower-cosmjs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function makeCosmjsFollower<T>(sourceP: any, leaderOrMaker?: import("./types.js").LeaderOrMaker
|
|
2
|
-
export type ValueFollower<T> = import(
|
|
1
|
+
export function makeCosmjsFollower<T>(sourceP: any, leaderOrMaker?: import("./types.js").LeaderOrMaker, options?: import("./types.js").FollowerOptions): ValueFollower<T>;
|
|
2
|
+
export type ValueFollower<T> = import("./types.js").Follower<import("./types.js").ValueFollowerElement<T>>;
|
|
3
3
|
/**
|
|
4
4
|
* The response of an ABCI query to Tendermint.
|
|
5
5
|
* This is a subset of `tendermint34.AbciQueryResponse` in order
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"follower-cosmjs.d.ts","sourceRoot":"","sources":["follower-cosmjs.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"follower-cosmjs.d.ts","sourceRoot":"","sources":["follower-cosmjs.js"],"names":[],"mappings":"AA4GO,mCANM,CAAC,WACH,GAAG,kBACH,OAAO,YAAY,EAAE,aAAa,YAClC,OAAO,YAAY,EAAE,eAAe,GAClC,aAAa,CAAC,CAAC,CAAC,CA4f5B;0BA7kBa,CAAC,IAAW,OAAO,YAAY,EAAE,QAAQ,CAAC,OAAO,YAAY,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;;;iCAIxF;IACZ,QAAY,CAAC,KAAK,EAAE,UAAU,CAAC;IAC/B,QAAY,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB"}
|
package/src/follower-cosmjs.js
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
/// <reference types="ses"/>
|
|
2
|
-
/* eslint-disable no-await-in-loop, @jessie.js/no-nested-await */
|
|
1
|
+
/// <reference types="ses" />
|
|
3
2
|
|
|
3
|
+
import { X, q, Fail, makeError } from '@endo/errors';
|
|
4
4
|
import { E, Far } from '@endo/far';
|
|
5
5
|
import * as tendermint34 from '@cosmjs/tendermint-rpc';
|
|
6
6
|
import * as stargateStar from '@cosmjs/stargate';
|
|
7
7
|
|
|
8
8
|
import { isStreamCell } from '@agoric/internal/src/lib-chainStorage.js';
|
|
9
|
-
|
|
10
9
|
import { MAKE_DEFAULT_DECODER, MAKE_DEFAULT_UNSERIALIZER } from './defaults.js';
|
|
11
10
|
import { makeCastingSpec } from './casting-spec.js';
|
|
12
11
|
import { makeLeader as defaultMakeLeader } from './leader-netconfig.js';
|
|
13
12
|
|
|
13
|
+
// A lot of cosmjs classes end up hardened through instances shared by this
|
|
14
|
+
// package so preemptively harden them all.
|
|
15
|
+
// However we cannot directly harden a module namespace object (exotic behavior
|
|
16
|
+
// for bindings) so spread the namespace instead
|
|
17
|
+
harden({
|
|
18
|
+
tendermint34: { ...tendermint34 },
|
|
19
|
+
stargateStar: { ...stargateStar },
|
|
20
|
+
});
|
|
21
|
+
|
|
14
22
|
const { QueryClient } = stargateStar;
|
|
15
23
|
const { Tendermint34Client } = tendermint34;
|
|
16
|
-
const { details: X, quote: q, Fail } = assert;
|
|
17
24
|
const textDecoder = new TextDecoder();
|
|
18
25
|
|
|
19
26
|
/** @template T @typedef {import('./types.js').Follower<import('./types.js').ValueFollowerElement<T>>} ValueFollower */
|
|
@@ -85,14 +92,18 @@ const collectSingle = values => {
|
|
|
85
92
|
return head[0];
|
|
86
93
|
};
|
|
87
94
|
|
|
95
|
+
// NB: 'none' is the only value that works. We've left the other cases
|
|
96
|
+
// in anticipation of the ecosystem providing JS proofs again.
|
|
97
|
+
// See https://github.com/cosmos/cosmjs/issues/1618#issuecomment-2574934505
|
|
98
|
+
// and https://github.com/cosmos/ics23/pull/353?email_source=slack
|
|
88
99
|
// Coordinate with switch/case of tryGetDataAtHeight.
|
|
89
100
|
const proofs = ['strict', 'none', 'optimistic'];
|
|
90
101
|
|
|
91
102
|
/**
|
|
92
103
|
* @template T
|
|
93
104
|
* @param {any} sourceP
|
|
94
|
-
* @param {import('./types').LeaderOrMaker} [leaderOrMaker]
|
|
95
|
-
* @param {import('./types').FollowerOptions} [options]
|
|
105
|
+
* @param {import('./types.js').LeaderOrMaker} [leaderOrMaker]
|
|
106
|
+
* @param {import('./types.js').FollowerOptions} [options]
|
|
96
107
|
* @returns {ValueFollower<T>}
|
|
97
108
|
*/
|
|
98
109
|
export const makeCosmjsFollower = (
|
|
@@ -103,7 +114,7 @@ export const makeCosmjsFollower = (
|
|
|
103
114
|
const {
|
|
104
115
|
decode = MAKE_DEFAULT_DECODER(),
|
|
105
116
|
unserializer = MAKE_DEFAULT_UNSERIALIZER(),
|
|
106
|
-
proof = '
|
|
117
|
+
proof = 'none',
|
|
107
118
|
crasher = null,
|
|
108
119
|
} = options;
|
|
109
120
|
|
|
@@ -210,14 +221,20 @@ export const makeCosmjsFollower = (
|
|
|
210
221
|
};
|
|
211
222
|
|
|
212
223
|
/**
|
|
224
|
+
* @deprecated no longer supported https://github.com/cosmos/cosmjs/pull/1623
|
|
213
225
|
* @param {number} [height]
|
|
214
226
|
* @returns {Promise<QueryStoreResponse>}
|
|
215
227
|
*/
|
|
216
228
|
const getProvenDataAtHeight = async height => {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
229
|
+
console.error(
|
|
230
|
+
'getProvenDataAtHeight',
|
|
231
|
+
height,
|
|
232
|
+
'is no longer supported; use',
|
|
233
|
+
{ proof: 'none' },
|
|
234
|
+
);
|
|
235
|
+
throw makeError(
|
|
236
|
+
X`Verified queries are no longer supported; use { proof: 'none' }`,
|
|
237
|
+
);
|
|
221
238
|
};
|
|
222
239
|
|
|
223
240
|
/**
|
|
@@ -240,6 +257,7 @@ export const makeCosmjsFollower = (
|
|
|
240
257
|
* @returns {Promise<QueryStoreResponse>}
|
|
241
258
|
*/
|
|
242
259
|
const tryGetDataAtHeight = async blockHeight => {
|
|
260
|
+
await null;
|
|
243
261
|
if (proof === 'strict') {
|
|
244
262
|
// Crash hard if we can't prove.
|
|
245
263
|
return getProvenDataAtHeight(blockHeight).catch(crash);
|
|
@@ -255,7 +273,7 @@ export const makeCosmjsFollower = (
|
|
|
255
273
|
return;
|
|
256
274
|
}
|
|
257
275
|
crash(
|
|
258
|
-
|
|
276
|
+
makeError(
|
|
259
277
|
X`Alleged value ${alleged.value} did not match proof ${proven.value}`,
|
|
260
278
|
),
|
|
261
279
|
);
|
|
@@ -274,6 +292,7 @@ export const makeCosmjsFollower = (
|
|
|
274
292
|
* @param {number} [blockHeight] desired height, or the latest height if not set
|
|
275
293
|
*/
|
|
276
294
|
const getDataAtHeight = async blockHeight => {
|
|
295
|
+
await null;
|
|
277
296
|
for (let attempt = 0; ; attempt += 1) {
|
|
278
297
|
try {
|
|
279
298
|
// AWAIT
|
|
@@ -330,11 +349,16 @@ export const makeCosmjsFollower = (
|
|
|
330
349
|
blockHeight,
|
|
331
350
|
currentBlockHeight,
|
|
332
351
|
) => {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
352
|
+
await null;
|
|
353
|
+
try {
|
|
354
|
+
// AWAIT
|
|
355
|
+
const value = await /** @type {T} */ (
|
|
356
|
+
unserializer ? E(unserializer).fromCapData(data) : data
|
|
357
|
+
);
|
|
358
|
+
return { value, blockHeight, currentBlockHeight };
|
|
359
|
+
} catch (e) {
|
|
360
|
+
return { blockHeight, currentBlockHeight, error: e, value: undefined };
|
|
361
|
+
}
|
|
338
362
|
};
|
|
339
363
|
|
|
340
364
|
/**
|
|
@@ -351,6 +375,7 @@ export const makeCosmjsFollower = (
|
|
|
351
375
|
);
|
|
352
376
|
}
|
|
353
377
|
}
|
|
378
|
+
harden(allValuesFromCell);
|
|
354
379
|
|
|
355
380
|
/**
|
|
356
381
|
* @param {import('./types.js').StreamCell<T>} streamCell
|
|
@@ -366,6 +391,7 @@ export const makeCosmjsFollower = (
|
|
|
366
391
|
);
|
|
367
392
|
}
|
|
368
393
|
}
|
|
394
|
+
harden(reverseValuesFromCell);
|
|
369
395
|
|
|
370
396
|
/**
|
|
371
397
|
* @param {import('./types.js').StreamCell<T>} streamCell
|
|
@@ -383,6 +409,7 @@ export const makeCosmjsFollower = (
|
|
|
383
409
|
);
|
|
384
410
|
}
|
|
385
411
|
}
|
|
412
|
+
harden(lastValueFromCell);
|
|
386
413
|
|
|
387
414
|
/**
|
|
388
415
|
* @yields {ValueFollowerElement<T>}
|
|
@@ -391,6 +418,7 @@ export const makeCosmjsFollower = (
|
|
|
391
418
|
/** @type {number | undefined} the last known latest height */
|
|
392
419
|
let lastHeight;
|
|
393
420
|
let lastValue;
|
|
421
|
+
await null;
|
|
394
422
|
for (;;) {
|
|
395
423
|
const latest = await getDataAtHeight();
|
|
396
424
|
if (lastHeight && latest.height <= lastHeight) {
|
|
@@ -427,6 +455,7 @@ export const makeCosmjsFollower = (
|
|
|
427
455
|
lastValue = latest.value;
|
|
428
456
|
}
|
|
429
457
|
}
|
|
458
|
+
harden(getLatestIterable);
|
|
430
459
|
|
|
431
460
|
/**
|
|
432
461
|
* @param {number} [cursorBlockHeight]
|
|
@@ -441,11 +470,13 @@ export const makeCosmjsFollower = (
|
|
|
441
470
|
// block.
|
|
442
471
|
// If the block has no corresponding data, wait for the first block to
|
|
443
472
|
// contain data.
|
|
473
|
+
await null;
|
|
444
474
|
for (;;) {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
475
|
+
let thisHeight;
|
|
476
|
+
({ value: cursorData, height: thisHeight } =
|
|
477
|
+
await getDataAtHeight(cursorBlockHeight));
|
|
448
478
|
if (cursorData.length !== 0) {
|
|
479
|
+
cursorBlockHeight = thisHeight;
|
|
449
480
|
const cursorStreamCell = streamCellForData(
|
|
450
481
|
cursorBlockHeight,
|
|
451
482
|
cursorData,
|
|
@@ -543,6 +574,7 @@ export const makeCosmjsFollower = (
|
|
|
543
574
|
cursorData = currentData;
|
|
544
575
|
}
|
|
545
576
|
}
|
|
577
|
+
harden(getEachIterableAtHeight);
|
|
546
578
|
|
|
547
579
|
/**
|
|
548
580
|
* @param {number} [cursorBlockHeight]
|
|
@@ -553,10 +585,10 @@ export const makeCosmjsFollower = (
|
|
|
553
585
|
// cursorBlockHeight) so we know not to emit duplicates
|
|
554
586
|
// of that cell.
|
|
555
587
|
let cursorData;
|
|
588
|
+
await null;
|
|
556
589
|
while (cursorBlockHeight === undefined || cursorBlockHeight > 0) {
|
|
557
|
-
({ value: cursorData, height: cursorBlockHeight } =
|
|
558
|
-
cursorBlockHeight
|
|
559
|
-
));
|
|
590
|
+
({ value: cursorData, height: cursorBlockHeight } =
|
|
591
|
+
await getDataAtHeight(cursorBlockHeight));
|
|
560
592
|
if (cursorData.length === 0) {
|
|
561
593
|
// No data at the cursor height, so signal beginning of stream.
|
|
562
594
|
return;
|
|
@@ -566,6 +598,7 @@ export const makeCosmjsFollower = (
|
|
|
566
598
|
cursorBlockHeight = cursorStreamCell.blockHeight - 1;
|
|
567
599
|
}
|
|
568
600
|
}
|
|
601
|
+
harden(getReverseIterableAtHeight);
|
|
569
602
|
|
|
570
603
|
/** @type {ValueFollower<T>} */
|
|
571
604
|
return Far('chain follower', {
|
package/src/follower.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function makeFollower<T>(specP: ERef<import(
|
|
1
|
+
export function makeFollower<T>(specP: ERef<import("./types.js").CastingSpec> | string, leaderOrMaker?: import("./types.js").LeaderOrMaker, options?: import("./types.js").FollowerOptions): Promise<import("./follower-cosmjs.js").ValueFollower<T>>;
|
|
2
2
|
//# sourceMappingURL=follower.d.ts.map
|
package/src/follower.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"follower.d.ts","sourceRoot":"","sources":["follower.js"],"names":[],"mappings":"AA4DO,
|
|
1
|
+
{"version":3,"file":"follower.d.ts","sourceRoot":"","sources":["follower.js"],"names":[],"mappings":"AA4DO,6BANM,CAAC,SACH,IAAI,CAAC,OAAO,YAAY,EAAE,WAAW,CAAC,GAAG,MAAM,kBAC/C,OAAO,YAAY,EAAE,aAAa,YAClC,OAAO,YAAY,EAAE,eAAe,GAClC,OAAO,CAAC,OAAO,sBAAsB,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CASpE"}
|
package/src/follower.js
CHANGED
|
@@ -11,12 +11,12 @@ import { makeCastingSpec } from './casting-spec.js';
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @template T
|
|
14
|
-
* @param {ERef<import('./types').CastingSpec>} spec
|
|
14
|
+
* @param {ERef<import('./types.js').CastingSpec>} spec
|
|
15
15
|
*/
|
|
16
16
|
const makeSubscriptionFollower = spec => {
|
|
17
17
|
const transform = value =>
|
|
18
18
|
harden({ value, blockHeight: NaN, currentBlockHeight: NaN });
|
|
19
|
-
/** @type {import('./types').Follower<import('./types.js').ValueFollowerElement<T>>} */
|
|
19
|
+
/** @type {import('./types.js').Follower<import('./types.js').ValueFollowerElement<T>>} */
|
|
20
20
|
const follower = Far('subscription/notifier follower', {
|
|
21
21
|
getLatestIterable: async () => {
|
|
22
22
|
const { notifier, subscription } = await spec;
|
|
@@ -53,10 +53,10 @@ const makeSubscriptionFollower = spec => {
|
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* @template T
|
|
56
|
-
* @param {ERef<import('./types').CastingSpec> | string} specP
|
|
57
|
-
* @param {import('./types').LeaderOrMaker} [leaderOrMaker]
|
|
58
|
-
* @param {import('./types').FollowerOptions} [options]
|
|
59
|
-
* @returns {Promise<import('./follower-cosmjs').ValueFollower<T>>}
|
|
56
|
+
* @param {ERef<import('./types.js').CastingSpec> | string} specP
|
|
57
|
+
* @param {import('./types.js').LeaderOrMaker} [leaderOrMaker]
|
|
58
|
+
* @param {import('./types.js').FollowerOptions} [options]
|
|
59
|
+
* @returns {Promise<import('./follower-cosmjs.js').ValueFollower<T>>}
|
|
60
60
|
*/
|
|
61
61
|
export const makeFollower = async (specP, leaderOrMaker, options) => {
|
|
62
62
|
const spec = await makeCastingSpec(specP);
|
package/src/iterable.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
export function mapAsyncIterable<TIn, TOut>(iterable: AsyncIterable<TIn>, transform: (value: TIn) => TOut): AsyncIterable<TOut>;
|
|
2
|
-
export function iterateLatest<T>(follower: ERef<import("./types").Follower<T>>): {
|
|
2
|
+
export function iterateLatest<T>(follower: ERef<import("./types.js").Follower<T>>): {
|
|
3
3
|
/** @returns {AsyncIterator<T>} */
|
|
4
|
-
[Symbol.asyncIterator]: () => AsyncIterator<T
|
|
5
|
-
} & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
4
|
+
[Symbol.asyncIterator]: () => AsyncIterator<T>;
|
|
5
|
+
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
6
6
|
/** @returns {AsyncIterator<T>} */
|
|
7
|
-
[Symbol.asyncIterator]: () => AsyncIterator<T
|
|
7
|
+
[Symbol.asyncIterator]: () => AsyncIterator<T>;
|
|
8
8
|
}>;
|
|
9
|
-
export function iterateEach<T>(follower: ERef<import("./types").Follower<T>>, options?: import("./types").IterateEachOptions
|
|
9
|
+
export function iterateEach<T>(follower: ERef<import("./types.js").Follower<T>>, options?: import("./types.js").IterateEachOptions): {
|
|
10
10
|
/** @returns {AsyncIterator<T>} */
|
|
11
|
-
[Symbol.asyncIterator]: () => AsyncIterator<T
|
|
12
|
-
} & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
11
|
+
[Symbol.asyncIterator]: () => AsyncIterator<T>;
|
|
12
|
+
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
13
13
|
/** @returns {AsyncIterator<T>} */
|
|
14
|
-
[Symbol.asyncIterator]: () => AsyncIterator<T
|
|
14
|
+
[Symbol.asyncIterator]: () => AsyncIterator<T>;
|
|
15
15
|
}>;
|
|
16
|
-
export function iterateReverse<T>(follower: ERef<import("./types").Follower<T>>, options?: import("./types").IterateEachOptions
|
|
16
|
+
export function iterateReverse<T>(follower: ERef<import("./types.js").Follower<T>>, options?: import("./types.js").IterateEachOptions): {
|
|
17
17
|
/** @returns {AsyncIterator<T>} */
|
|
18
|
-
[Symbol.asyncIterator]: () => AsyncIterator<T
|
|
19
|
-
} & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
18
|
+
[Symbol.asyncIterator]: () => AsyncIterator<T>;
|
|
19
|
+
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
20
20
|
/** @returns {AsyncIterator<T>} */
|
|
21
|
-
[Symbol.asyncIterator]: () => AsyncIterator<T
|
|
21
|
+
[Symbol.asyncIterator]: () => AsyncIterator<T>;
|
|
22
22
|
}>;
|
|
23
23
|
export { subscribeEach, subscribeLatest } from "@agoric/notifier/subscribe.js";
|
|
24
24
|
//# sourceMappingURL=iterable.d.ts.map
|