@agoric/casting 0.4.3-other-dev-3eb1a1d.0 → 0.4.3-other-dev-d15096d.0.d15096d
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 +27 -26
- package/src/casting-spec.d.ts +9 -8
- package/src/casting-spec.d.ts.map +1 -1
- package/src/casting-spec.js +11 -7
- package/src/change-follower.d.ts +4 -1
- package/src/change-follower.d.ts.map +1 -1
- package/src/change-follower.js +8 -2
- package/src/defaults.d.ts +13 -5
- package/src/defaults.d.ts.map +1 -1
- package/src/defaults.js +15 -2
- package/src/follower-cosmjs.d.ts +6 -2
- package/src/follower-cosmjs.d.ts.map +1 -1
- package/src/follower-cosmjs.js +32 -13
- package/src/follower.d.ts +5 -1
- package/src/follower.d.ts.map +1 -1
- package/src/follower.js +15 -6
- package/src/iterable.d.ts +5 -3
- package/src/iterable.d.ts.map +1 -1
- package/src/iterable.js +10 -5
- package/src/leader-netconfig.d.ts +5 -3
- package/src/leader-netconfig.d.ts.map +1 -1
- package/src/leader-netconfig.js +11 -6
- package/src/leader.d.ts +3 -1
- package/src/leader.d.ts.map +1 -1
- package/src/leader.js +7 -2
- package/src/main.js +1 -1
- package/src/makeHttpClient.d.ts +3 -2
- package/src/makeHttpClient.d.ts.map +1 -1
- package/src/makeHttpClient.js +7 -2
- package/src/types.d.ts +8 -6
- package/src/types.d.ts.map +1 -1
- package/src/types.js +5 -3
- package/test/fake-rpc-server.js +5 -1
- package/test/interpose-net-access.test.js +6 -1
- package/test/mvp.test.js +9 -4
- package/test/netconfig.test.js +6 -2
- package/test/types.test-d.ts +31 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +2 -2
package/package.json
CHANGED
|
@@ -1,54 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/casting",
|
|
3
|
-
"version": "0.4.3-other-dev-
|
|
3
|
+
"version": "0.4.3-other-dev-d15096d.0.d15096d",
|
|
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 tsconfig.build.json",
|
|
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 --all $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": "tsc",
|
|
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/store": "0.9.3-other-dev-
|
|
28
|
-
"@cosmjs/encoding": "^0.
|
|
29
|
-
"@cosmjs/proto-signing": "^0.
|
|
30
|
-
"@cosmjs/stargate": "^0.
|
|
31
|
-
"@cosmjs/tendermint-rpc": "^0.
|
|
32
|
-
"@endo/errors": "^1.2.
|
|
33
|
-
"@endo/far": "^1.1.
|
|
34
|
-
"@endo/init": "^1.1.
|
|
35
|
-
"@endo/lockdown": "^1.0.
|
|
36
|
-
"@endo/marshal": "^1.
|
|
37
|
-
"@endo/promise-kit": "^1.1.
|
|
25
|
+
"@agoric/internal": "0.3.3-other-dev-d15096d.0.d15096d",
|
|
26
|
+
"@agoric/notifier": "0.6.3-other-dev-d15096d.0.d15096d",
|
|
27
|
+
"@agoric/store": "0.9.3-other-dev-d15096d.0.d15096d",
|
|
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"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@agoric/cosmic-proto": "0.4.1-other-dev-
|
|
41
|
-
"@endo/ses-ava": "^1.2
|
|
40
|
+
"@agoric/cosmic-proto": "0.4.1-other-dev-d15096d.0.d15096d",
|
|
41
|
+
"@endo/ses-ava": "^1.3.2",
|
|
42
42
|
"ava": "^5.3.0",
|
|
43
|
-
"c8": "^10.1.
|
|
43
|
+
"c8": "^10.1.3",
|
|
44
44
|
"express": "^5.0.1",
|
|
45
|
+
"tsd": "^0.33.0",
|
|
45
46
|
"ws": "^7.2.0"
|
|
46
47
|
},
|
|
47
48
|
"publishConfig": {
|
|
48
49
|
"access": "public"
|
|
49
50
|
},
|
|
50
51
|
"engines": {
|
|
51
|
-
"node": "^
|
|
52
|
+
"node": "^20.9 || ^22.11"
|
|
52
53
|
},
|
|
53
54
|
"ava": {
|
|
54
55
|
"files": [
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
"workerThreads": false
|
|
59
60
|
},
|
|
60
61
|
"typeCoverage": {
|
|
61
|
-
"atLeast":
|
|
62
|
+
"atLeast": 89.19
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "d15096dc4ff8b96e9b6cd11954c20d3a9efbb393"
|
|
64
65
|
}
|
package/src/casting-spec.d.ts
CHANGED
|
@@ -2,15 +2,16 @@ export function vstorageKeySpecToPath({ storeName, storeSubkey }: VStorageKey):
|
|
|
2
2
|
/**
|
|
3
3
|
* @param {string} storagePath
|
|
4
4
|
* @param {string} [storeName]
|
|
5
|
-
* @returns {
|
|
5
|
+
* @returns {CastingSpec}
|
|
6
6
|
*/
|
|
7
|
-
export function DEFAULT_PATH_CONVERTER(storagePath: string, storeName?: string
|
|
7
|
+
export function DEFAULT_PATH_CONVERTER(storagePath: string, storeName?: string): CastingSpec;
|
|
8
8
|
/**
|
|
9
|
-
* @type {Record<string, (path: string) =>
|
|
9
|
+
* @type {Record<string, (path: string) => CastingSpec>}
|
|
10
10
|
*/
|
|
11
|
-
export const pathPrefixToConverters: Record<string, (path: string) =>
|
|
12
|
-
export function makeCastingSpecFromString(specString: string):
|
|
13
|
-
export function makeCastingSpecFromObject(specObj: any):
|
|
14
|
-
export function makeCastingSpecFromRef(specCap: ERef<any>): Promise<
|
|
15
|
-
export function makeCastingSpec(sourceP: ERef<unknown>): Promise<
|
|
11
|
+
export const pathPrefixToConverters: Record<string, (path: string) => CastingSpec>;
|
|
12
|
+
export function makeCastingSpecFromString(specString: string): CastingSpec;
|
|
13
|
+
export function makeCastingSpecFromObject(specObj: any): CastingSpec;
|
|
14
|
+
export function makeCastingSpecFromRef(specCap: ERef<any>): Promise<CastingSpec>;
|
|
15
|
+
export function makeCastingSpec(sourceP: ERef<unknown>): Promise<CastingSpec>;
|
|
16
|
+
import type { CastingSpec } from './types.js';
|
|
16
17
|
//# 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":"AAiDO,kEAHI,WAAW,GACT,MAAM,CAYlB;AAlCD;;;;GAIG;AACH,oDAJW,MAAM,cACN,MAAM,GACJ,WAAW,CAavB;AAsBD;;GAEG;AACH,qCAFU,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,CAAC,CAMpD;AAMI,sDAHI,MAAM,GACJ,WAAW,CAcvB;AAQM,mDAHI,GAAG,GACD,WAAW,CAmCvB;AAMM,gDAHI,IAAI,CAAC,GAAG,CAAC,GACP,OAAO,CAAC,WAAW,CAAC,CAKhC;AAQM,yCAHI,IAAI,CAAC,OAAO,CAAC,GACX,OAAO,CAAC,WAAW,CAAC,CAgBhC;iCA5J6B,YAAY"}
|
package/src/casting-spec.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import * as encodingStar from '@cosmjs/encoding';
|
|
2
2
|
import { E, getInterfaceOf } from '@endo/far';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @import {CastingSpec} from './types.js';
|
|
6
|
+
*/
|
|
7
|
+
|
|
4
8
|
const { toAscii } = encodingStar;
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* @param {string} storagePath
|
|
8
|
-
* @returns {
|
|
12
|
+
* @returns {CastingSpec}
|
|
9
13
|
*/
|
|
10
14
|
const swingsetPathToCastingSpec = storagePath =>
|
|
11
15
|
harden({
|
|
@@ -22,7 +26,7 @@ const NO_DATA_VALUE = new Uint8Array([255]);
|
|
|
22
26
|
/**
|
|
23
27
|
* @param {string} storagePath
|
|
24
28
|
* @param {string} [storeName]
|
|
25
|
-
* @returns {
|
|
29
|
+
* @returns {CastingSpec}
|
|
26
30
|
*/
|
|
27
31
|
const vstoragePathToCastingSpec = (storagePath, storeName = 'vstorage') => {
|
|
28
32
|
const elems = storagePath ? storagePath.split('.') : [];
|
|
@@ -58,7 +62,7 @@ export const vstorageKeySpecToPath = ({ storeName, storeSubkey }) => {
|
|
|
58
62
|
export const DEFAULT_PATH_CONVERTER = vstoragePathToCastingSpec;
|
|
59
63
|
|
|
60
64
|
/**
|
|
61
|
-
* @type {Record<string, (path: string) =>
|
|
65
|
+
* @type {Record<string, (path: string) => CastingSpec>}
|
|
62
66
|
*/
|
|
63
67
|
export const pathPrefixToConverters = harden({
|
|
64
68
|
'swingset:': swingsetPathToCastingSpec,
|
|
@@ -68,7 +72,7 @@ export const pathPrefixToConverters = harden({
|
|
|
68
72
|
|
|
69
73
|
/**
|
|
70
74
|
* @param {string} specString
|
|
71
|
-
* @returns {
|
|
75
|
+
* @returns {CastingSpec}
|
|
72
76
|
*/
|
|
73
77
|
export const makeCastingSpecFromString = specString => {
|
|
74
78
|
assert.typeof(specString, 'string');
|
|
@@ -88,7 +92,7 @@ const te = new TextEncoder();
|
|
|
88
92
|
|
|
89
93
|
/**
|
|
90
94
|
* @param {any} specObj
|
|
91
|
-
* @returns {
|
|
95
|
+
* @returns {CastingSpec}
|
|
92
96
|
*/
|
|
93
97
|
export const makeCastingSpecFromObject = specObj => {
|
|
94
98
|
const {
|
|
@@ -127,7 +131,7 @@ export const makeCastingSpecFromObject = specObj => {
|
|
|
127
131
|
|
|
128
132
|
/**
|
|
129
133
|
* @param {ERef<any>} specCap
|
|
130
|
-
* @returns {Promise<
|
|
134
|
+
* @returns {Promise<CastingSpec>}
|
|
131
135
|
*/
|
|
132
136
|
export const makeCastingSpecFromRef = async specCap => {
|
|
133
137
|
const specObj = await E(specCap).getStoreKey();
|
|
@@ -138,7 +142,7 @@ export const makeCastingSpecFromRef = async specCap => {
|
|
|
138
142
|
* Create an abstract type from a given source representation
|
|
139
143
|
*
|
|
140
144
|
* @param {ERef<unknown>} sourceP
|
|
141
|
-
* @returns {Promise<
|
|
145
|
+
* @returns {Promise<CastingSpec>}
|
|
142
146
|
*/
|
|
143
147
|
export const makeCastingSpec = async sourceP => {
|
|
144
148
|
const spec = await sourceP;
|
package/src/change-follower.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export function makePollingChangeFollower(leader:
|
|
1
|
+
export function makePollingChangeFollower(leader: Leader): Promise<Follower<CastingChange>>;
|
|
2
|
+
import type { Leader } from './types.js';
|
|
3
|
+
import type { CastingChange } from './types.js';
|
|
4
|
+
import type { Follower } from './types.js';
|
|
2
5
|
//# sourceMappingURL=change-follower.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change-follower.d.ts","sourceRoot":"","sources":["change-follower.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"change-follower.d.ts","sourceRoot":"","sources":["change-follower.js"],"names":[],"mappings":"AAeO,kDAHI,MAAM,GACJ,OAAO,CAAC,SAAS,aAAa,CAAC,CAAC,CA6C5C;4BAtDwB,YAAY;mCAEL,YAAY;8BADjB,YAAY"}
|
package/src/change-follower.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { E, Far } from '@endo/far';
|
|
2
2
|
import { DEFAULT_KEEP_POLLING } from './defaults.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @import {Leader} from './types.js';
|
|
6
|
+
* @import {Follower} from './types.js';
|
|
7
|
+
* @import {CastingChange} from './types.js';
|
|
8
|
+
*/
|
|
9
|
+
|
|
4
10
|
/**
|
|
5
11
|
* Just return an unspecified allegedValue every poll period.
|
|
6
12
|
*
|
|
7
|
-
* @param {
|
|
8
|
-
* @returns {Promise<
|
|
13
|
+
* @param {Leader} leader
|
|
14
|
+
* @returns {Promise<Follower<CastingChange>>}
|
|
9
15
|
*/
|
|
10
16
|
export const makePollingChangeFollower = async leader => {
|
|
11
17
|
const { keepPolling = DEFAULT_KEEP_POLLING } = await E(leader).getOptions();
|
package/src/defaults.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Unserializer} from './types.js';
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* Default to the local chain.
|
|
3
6
|
*/
|
|
@@ -5,17 +8,22 @@ export const DEFAULT_BOOTSTRAP: "http://localhost:26657";
|
|
|
5
8
|
export const DEFAULT_JITTER_SECONDS: 5;
|
|
6
9
|
export const DEFAULT_POLL_WITH_EVENTS_SECONDS: 600;
|
|
7
10
|
export const DEFAULT_KEEP_POLLING_SECONDS: 5;
|
|
11
|
+
/**
|
|
12
|
+
* Default backoff is the block interval.
|
|
13
|
+
*/
|
|
14
|
+
export const DEFAULT_MAX_BACKOFF: 6000;
|
|
8
15
|
export function delay(ms: number): Promise<void>;
|
|
9
|
-
export function randomBackoff(range: number, cap?: number
|
|
10
|
-
export function exponentialBackoff(attempt?: number
|
|
16
|
+
export function randomBackoff(range: number, cap?: number): number;
|
|
17
|
+
export function exponentialBackoff(attempt?: number, base?: number, cap?: number): number;
|
|
11
18
|
export function DEFAULT_JITTER(where: string): Promise<void>;
|
|
12
|
-
export function DEFAULT_RETRY_CALLBACK(where: string, err: any, attempt?: number
|
|
19
|
+
export function DEFAULT_RETRY_CALLBACK(where: string, err: any, attempt?: number): Promise<void>;
|
|
13
20
|
export function DEFAULT_KEEP_POLLING(): Promise<boolean>;
|
|
14
21
|
export function MAKE_DEFAULT_DECODER(): (str: any) => any;
|
|
15
22
|
/**
|
|
16
23
|
* Unserialize the JSONable data.
|
|
17
24
|
*
|
|
18
|
-
* @type {() =>
|
|
25
|
+
* @type {() => Unserializer}
|
|
19
26
|
*/
|
|
20
|
-
export const MAKE_DEFAULT_UNSERIALIZER: () =>
|
|
27
|
+
export const MAKE_DEFAULT_UNSERIALIZER: () => Unserializer;
|
|
28
|
+
import type { Unserializer } from './types.js';
|
|
21
29
|
//# 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;AAEH;;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,YAAY,CA2B1B;kCApI6B,YAAY"}
|
package/src/defaults.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import { Far } from '@endo/far';
|
|
3
3
|
import { makeMarshal } from '@endo/marshal';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @import {Unserializer} from './types.js';
|
|
7
|
+
*/
|
|
8
|
+
|
|
5
9
|
/**
|
|
6
10
|
* Default to the local chain.
|
|
7
11
|
*/
|
|
@@ -13,6 +17,11 @@ export const DEFAULT_POLL_WITH_EVENTS_SECONDS = 600;
|
|
|
13
17
|
|
|
14
18
|
export const DEFAULT_KEEP_POLLING_SECONDS = 5;
|
|
15
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Default backoff is the block interval.
|
|
22
|
+
*/
|
|
23
|
+
export const DEFAULT_MAX_BACKOFF = 6_000;
|
|
24
|
+
|
|
16
25
|
/**
|
|
17
26
|
* Resolve a Promise after a given number of milliseconds.
|
|
18
27
|
*
|
|
@@ -36,7 +45,11 @@ export const randomBackoff = (range, cap = range) => {
|
|
|
36
45
|
* @param {number} [base]
|
|
37
46
|
* @param {number} [cap]
|
|
38
47
|
*/
|
|
39
|
-
export const exponentialBackoff = (
|
|
48
|
+
export const exponentialBackoff = (
|
|
49
|
+
attempt = 0,
|
|
50
|
+
base = 1_000,
|
|
51
|
+
cap = DEFAULT_MAX_BACKOFF,
|
|
52
|
+
) => {
|
|
40
53
|
return randomBackoff(2 ** attempt * base, cap);
|
|
41
54
|
};
|
|
42
55
|
|
|
@@ -95,7 +108,7 @@ export const MAKE_DEFAULT_DECODER = () => {
|
|
|
95
108
|
/**
|
|
96
109
|
* Unserialize the JSONable data.
|
|
97
110
|
*
|
|
98
|
-
* @type {() =>
|
|
111
|
+
* @type {() => Unserializer}
|
|
99
112
|
*/
|
|
100
113
|
export const MAKE_DEFAULT_UNSERIALIZER = () => {
|
|
101
114
|
const ifaceAllegedPrefix = 'Alleged: ';
|
package/src/follower-cosmjs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export function makeCosmjsFollower<T>(sourceP: any, leaderOrMaker?:
|
|
2
|
-
export type ValueFollower<T> =
|
|
1
|
+
export function makeCosmjsFollower<T>(sourceP: any, leaderOrMaker?: LeaderOrMaker, options?: FollowerOptions): ValueFollower<T>;
|
|
2
|
+
export type ValueFollower<T> = Follower<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
|
|
@@ -9,4 +9,8 @@ export type QueryStoreResponse = {
|
|
|
9
9
|
readonly value: Uint8Array;
|
|
10
10
|
readonly height: number;
|
|
11
11
|
};
|
|
12
|
+
import type { LeaderOrMaker } from './types.js';
|
|
13
|
+
import type { FollowerOptions } from './types.js';
|
|
14
|
+
import type { ValueFollowerElement } from './types.js';
|
|
15
|
+
import type { Follower } from './types.js';
|
|
12
16
|
//# sourceMappingURL=follower-cosmjs.d.ts.map
|
|
@@ -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":"AAqHO,mCANM,CAAC,WACH,GAAG,kBACH,aAAa,YACb,eAAe,GACb,aAAa,CAAC,CAAC,CAAC,CA4f5B;0BA7kBa,CAAC,IAAW,SAAS,qBAAqB,CAAC,CAAC,CAAC;;;;;;iCAI9C;IACZ,QAAY,CAAC,KAAK,EAAE,UAAU,CAAC;IAC/B,QAAY,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;mCA1B4B,YAAY;qCACV,YAAY;0CAFP,YAAY;8BADxB,YAAY"}
|
package/src/follower-cosmjs.js
CHANGED
|
@@ -10,6 +10,15 @@ import { MAKE_DEFAULT_DECODER, MAKE_DEFAULT_UNSERIALIZER } from './defaults.js';
|
|
|
10
10
|
import { makeCastingSpec } from './casting-spec.js';
|
|
11
11
|
import { makeLeader as defaultMakeLeader } from './leader-netconfig.js';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @import {Follower} from './types.js';
|
|
15
|
+
* @import {ValueFollowerElement} from './types.js';
|
|
16
|
+
* @import {LeaderOrMaker} from './types.js';
|
|
17
|
+
* @import {FollowerOptions} from './types.js';
|
|
18
|
+
* @import {QueryClient} from '@cosmjs/stargate';
|
|
19
|
+
* @import {StreamCell} from './types.js';
|
|
20
|
+
*/
|
|
21
|
+
|
|
13
22
|
// A lot of cosmjs classes end up hardened through instances shared by this
|
|
14
23
|
// package so preemptively harden them all.
|
|
15
24
|
// However we cannot directly harden a module namespace object (exotic behavior
|
|
@@ -23,7 +32,7 @@ const { QueryClient } = stargateStar;
|
|
|
23
32
|
const { Tendermint34Client } = tendermint34;
|
|
24
33
|
const textDecoder = new TextDecoder();
|
|
25
34
|
|
|
26
|
-
/** @template T @typedef {
|
|
35
|
+
/** @template T @typedef {Follower<ValueFollowerElement<T>>} ValueFollower */
|
|
27
36
|
|
|
28
37
|
// Copied from https://github.com/cosmos/cosmjs/pull/1328/files until release
|
|
29
38
|
/**
|
|
@@ -92,14 +101,18 @@ const collectSingle = values => {
|
|
|
92
101
|
return head[0];
|
|
93
102
|
};
|
|
94
103
|
|
|
104
|
+
// NB: 'none' is the only value that works. We've left the other cases
|
|
105
|
+
// in anticipation of the ecosystem providing JS proofs again.
|
|
106
|
+
// See https://github.com/cosmos/cosmjs/issues/1618#issuecomment-2574934505
|
|
107
|
+
// and https://github.com/cosmos/ics23/pull/353?email_source=slack
|
|
95
108
|
// Coordinate with switch/case of tryGetDataAtHeight.
|
|
96
109
|
const proofs = ['strict', 'none', 'optimistic'];
|
|
97
110
|
|
|
98
111
|
/**
|
|
99
112
|
* @template T
|
|
100
113
|
* @param {any} sourceP
|
|
101
|
-
* @param {
|
|
102
|
-
* @param {
|
|
114
|
+
* @param {LeaderOrMaker} [leaderOrMaker]
|
|
115
|
+
* @param {FollowerOptions} [options]
|
|
103
116
|
* @returns {ValueFollower<T>}
|
|
104
117
|
*/
|
|
105
118
|
export const makeCosmjsFollower = (
|
|
@@ -110,7 +123,7 @@ export const makeCosmjsFollower = (
|
|
|
110
123
|
const {
|
|
111
124
|
decode = MAKE_DEFAULT_DECODER(),
|
|
112
125
|
unserializer = MAKE_DEFAULT_UNSERIALIZER(),
|
|
113
|
-
proof = '
|
|
126
|
+
proof = 'none',
|
|
114
127
|
crasher = null,
|
|
115
128
|
} = options;
|
|
116
129
|
|
|
@@ -147,7 +160,7 @@ export const makeCosmjsFollower = (
|
|
|
147
160
|
return clientP;
|
|
148
161
|
};
|
|
149
162
|
|
|
150
|
-
/** @type {Map<string,
|
|
163
|
+
/** @type {Map<string, QueryClient>} */
|
|
151
164
|
const endpointToQueryClient = new Map();
|
|
152
165
|
|
|
153
166
|
/**
|
|
@@ -217,14 +230,20 @@ export const makeCosmjsFollower = (
|
|
|
217
230
|
};
|
|
218
231
|
|
|
219
232
|
/**
|
|
233
|
+
* @deprecated no longer supported https://github.com/cosmos/cosmjs/pull/1623
|
|
220
234
|
* @param {number} [height]
|
|
221
235
|
* @returns {Promise<QueryStoreResponse>}
|
|
222
236
|
*/
|
|
223
237
|
const getProvenDataAtHeight = async height => {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
238
|
+
console.error(
|
|
239
|
+
'getProvenDataAtHeight',
|
|
240
|
+
height,
|
|
241
|
+
'is no longer supported; use',
|
|
242
|
+
{ proof: 'none' },
|
|
243
|
+
);
|
|
244
|
+
throw makeError(
|
|
245
|
+
X`Verified queries are no longer supported; use { proof: 'none' }`,
|
|
246
|
+
);
|
|
228
247
|
};
|
|
229
248
|
|
|
230
249
|
/**
|
|
@@ -332,7 +351,7 @@ export const makeCosmjsFollower = (
|
|
|
332
351
|
* @param {any} data
|
|
333
352
|
* @param {number} blockHeight
|
|
334
353
|
* @param {number} currentBlockHeight
|
|
335
|
-
* @returns {Promise<
|
|
354
|
+
* @returns {Promise<ValueFollowerElement<T>>}
|
|
336
355
|
*/
|
|
337
356
|
const followerElementFromStreamCellValue = async (
|
|
338
357
|
data,
|
|
@@ -352,7 +371,7 @@ export const makeCosmjsFollower = (
|
|
|
352
371
|
};
|
|
353
372
|
|
|
354
373
|
/**
|
|
355
|
-
* @param {
|
|
374
|
+
* @param {StreamCell<T>} streamCell
|
|
356
375
|
* @param {number} currentBlockHeight
|
|
357
376
|
* @yields {ValueFollowerElement<T>}
|
|
358
377
|
*/
|
|
@@ -368,7 +387,7 @@ export const makeCosmjsFollower = (
|
|
|
368
387
|
harden(allValuesFromCell);
|
|
369
388
|
|
|
370
389
|
/**
|
|
371
|
-
* @param {
|
|
390
|
+
* @param {StreamCell<T>} streamCell
|
|
372
391
|
* @param {number} currentBlockHeight
|
|
373
392
|
* @yields {ValueFollowerElement<T>}
|
|
374
393
|
*/
|
|
@@ -384,7 +403,7 @@ export const makeCosmjsFollower = (
|
|
|
384
403
|
harden(reverseValuesFromCell);
|
|
385
404
|
|
|
386
405
|
/**
|
|
387
|
-
* @param {
|
|
406
|
+
* @param {StreamCell<T>} streamCell
|
|
388
407
|
* @param {number} currentBlockHeight
|
|
389
408
|
* @yields {ValueFollowerElement<T>}
|
|
390
409
|
*/
|
package/src/follower.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export function makeFollower<T>(specP: ERef<
|
|
1
|
+
export function makeFollower<T>(specP: ERef<CastingSpec> | string, leaderOrMaker?: LeaderOrMaker, options?: FollowerOptions): Promise<ValueFollower<T>>;
|
|
2
|
+
import type { CastingSpec } from './types.js';
|
|
3
|
+
import type { LeaderOrMaker } from './types.js';
|
|
4
|
+
import type { FollowerOptions } from './types.js';
|
|
5
|
+
import type { ValueFollower } from './follower-cosmjs.js';
|
|
2
6
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"follower.d.ts","sourceRoot":"","sources":["follower.js"],"names":[],"mappings":"AAqEO,6BANM,CAAC,SACH,IAAI,CAAC,WAAW,CAAC,GAAG,MAAM,kBAC1B,aAAa,YACb,eAAe,GACb,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CASrC;iCAhE6B,YAAY;mCAGV,YAAY;qCACV,YAAY;mCACd,sBAAsB"}
|
package/src/follower.js
CHANGED
|
@@ -9,14 +9,23 @@ import {
|
|
|
9
9
|
import { makeCosmjsFollower } from './follower-cosmjs.js';
|
|
10
10
|
import { makeCastingSpec } from './casting-spec.js';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* @import {CastingSpec} from './types.js';
|
|
14
|
+
* @import {Follower} from './types.js';
|
|
15
|
+
* @import {ValueFollowerElement} from './types.js';
|
|
16
|
+
* @import {LeaderOrMaker} from './types.js';
|
|
17
|
+
* @import {FollowerOptions} from './types.js';
|
|
18
|
+
* @import {ValueFollower} from './follower-cosmjs.js';
|
|
19
|
+
*/
|
|
20
|
+
|
|
12
21
|
/**
|
|
13
22
|
* @template T
|
|
14
|
-
* @param {ERef<
|
|
23
|
+
* @param {ERef<CastingSpec>} spec
|
|
15
24
|
*/
|
|
16
25
|
const makeSubscriptionFollower = spec => {
|
|
17
26
|
const transform = value =>
|
|
18
27
|
harden({ value, blockHeight: NaN, currentBlockHeight: NaN });
|
|
19
|
-
/** @type {
|
|
28
|
+
/** @type {Follower<ValueFollowerElement<T>>} */
|
|
20
29
|
const follower = Far('subscription/notifier follower', {
|
|
21
30
|
getLatestIterable: async () => {
|
|
22
31
|
const { notifier, subscription } = await spec;
|
|
@@ -53,10 +62,10 @@ const makeSubscriptionFollower = spec => {
|
|
|
53
62
|
|
|
54
63
|
/**
|
|
55
64
|
* @template T
|
|
56
|
-
* @param {ERef<
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {
|
|
59
|
-
* @returns {Promise<
|
|
65
|
+
* @param {ERef<CastingSpec> | string} specP
|
|
66
|
+
* @param {LeaderOrMaker} [leaderOrMaker]
|
|
67
|
+
* @param {FollowerOptions} [options]
|
|
68
|
+
* @returns {Promise<ValueFollower<T>>}
|
|
60
69
|
*/
|
|
61
70
|
export const makeFollower = async (specP, leaderOrMaker, options) => {
|
|
62
71
|
const spec = await makeCastingSpec(specP);
|
package/src/iterable.d.ts
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
export function mapAsyncIterable<TIn, TOut>(iterable: AsyncIterable<TIn>, transform: (value: TIn) => TOut): AsyncIterable<TOut>;
|
|
2
|
-
export function iterateLatest<T>(follower: ERef<
|
|
2
|
+
export function iterateLatest<T>(follower: ERef<Follower<T>>): {
|
|
3
3
|
/** @returns {AsyncIterator<T>} */
|
|
4
4
|
[Symbol.asyncIterator]: () => AsyncIterator<T>;
|
|
5
5
|
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
6
6
|
/** @returns {AsyncIterator<T>} */
|
|
7
7
|
[Symbol.asyncIterator]: () => AsyncIterator<T>;
|
|
8
8
|
}>;
|
|
9
|
-
export function iterateEach<T>(follower: ERef<
|
|
9
|
+
export function iterateEach<T>(follower: ERef<Follower<T>>, options?: IterateEachOptions): {
|
|
10
10
|
/** @returns {AsyncIterator<T>} */
|
|
11
11
|
[Symbol.asyncIterator]: () => AsyncIterator<T>;
|
|
12
12
|
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
13
13
|
/** @returns {AsyncIterator<T>} */
|
|
14
14
|
[Symbol.asyncIterator]: () => AsyncIterator<T>;
|
|
15
15
|
}>;
|
|
16
|
-
export function iterateReverse<T>(follower: ERef<
|
|
16
|
+
export function iterateReverse<T>(follower: ERef<Follower<T>>, options?: IterateEachOptions): {
|
|
17
17
|
/** @returns {AsyncIterator<T>} */
|
|
18
18
|
[Symbol.asyncIterator]: () => AsyncIterator<T>;
|
|
19
19
|
} & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, {
|
|
20
20
|
/** @returns {AsyncIterator<T>} */
|
|
21
21
|
[Symbol.asyncIterator]: () => AsyncIterator<T>;
|
|
22
22
|
}>;
|
|
23
|
+
import type { Follower } from './types.js';
|
|
24
|
+
import type { IterateEachOptions } from './types.js';
|
|
23
25
|
export { subscribeEach, subscribeLatest } from "@agoric/notifier/subscribe.js";
|
|
24
26
|
//# sourceMappingURL=iterable.d.ts.map
|
package/src/iterable.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterable.d.ts","sourceRoot":"","sources":["iterable.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"iterable.d.ts","sourceRoot":"","sources":["iterable.js"],"names":[],"mappings":"AAgBO,iCANM,GAAG,EACH,IAAI,YACN,aAAa,CAAC,GAAG,CAAC,aAClB,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GAClB,aAAa,CAAC,IAAI,CAAC,CAU/B;AAQM,8BAHM,CAAC,YACH,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAKxB,kCAAkC;kCAApB,aAAa,CAAC,CAAC,CAAC;;IAA9B,kCAAkC;kCAApB,aAAa,CAAC,CAAC,CAAC;GAQ9B;AASG,4BAJM,CAAC,YACH,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,YACjB,kBAAkB;IAKzB,kCAAkC;kCAApB,aAAa,CAAC,CAAC,CAAC;;IAA9B,kCAAkC;kCAApB,aAAa,CAAC,CAAC,CAAC;GAQ9B;AAOG,+BAJM,CAAC,YACH,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,YACjB,kBAAkB;IAKzB,kCAAkC;kCAApB,aAAa,CAAC,CAAC,CAAC;;IAA9B,kCAAkC;kCAApB,aAAa,CAAC,CAAC,CAAC;GAQ9B;8BA9EuB,YAAY;wCACF,YAAY"}
|
package/src/iterable.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { E, Far } from '@endo/far';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @import {Follower} from './types.js';
|
|
5
|
+
* @import {IterateEachOptions} from './types.js';
|
|
6
|
+
*/
|
|
7
|
+
|
|
3
8
|
export { subscribeEach, subscribeLatest } from '@agoric/notifier/subscribe.js';
|
|
4
9
|
|
|
5
10
|
/**
|
|
@@ -23,7 +28,7 @@ export const mapAsyncIterable = (iterable, transform) => {
|
|
|
23
28
|
* TODO: Remove this function when we have an @endo/publish-kit that suppports pull topics
|
|
24
29
|
*
|
|
25
30
|
* @template T
|
|
26
|
-
* @param {ERef<
|
|
31
|
+
* @param {ERef<Follower<T>>} follower
|
|
27
32
|
*/
|
|
28
33
|
export const iterateLatest = follower =>
|
|
29
34
|
// For now, just pass through the iterable.
|
|
@@ -42,8 +47,8 @@ export const iterateLatest = follower =>
|
|
|
42
47
|
* TODO: Remove this function when we have an @endo/publish-kit that suppports pull topics
|
|
43
48
|
*
|
|
44
49
|
* @template T
|
|
45
|
-
* @param {ERef<
|
|
46
|
-
* @param {
|
|
50
|
+
* @param {ERef<Follower<T>>} follower
|
|
51
|
+
* @param {IterateEachOptions} [options]
|
|
47
52
|
*/
|
|
48
53
|
export const iterateEach = (follower, options) =>
|
|
49
54
|
// For now, just pass through the iterable.
|
|
@@ -60,8 +65,8 @@ export const iterateEach = (follower, options) =>
|
|
|
60
65
|
|
|
61
66
|
/**
|
|
62
67
|
* @template T
|
|
63
|
-
* @param {ERef<
|
|
64
|
-
* @param {
|
|
68
|
+
* @param {ERef<Follower<T>>} follower
|
|
69
|
+
* @param {IterateEachOptions} [options]
|
|
65
70
|
*/
|
|
66
71
|
export const iterateReverse = (follower, options) =>
|
|
67
72
|
// For now, just pass through the iterable.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export function makeLeaderFromRpcAddresses(rpcAddrs: string[], leaderOptions?:
|
|
2
|
-
export function makeLeaderFromNetworkConfig(netconfigURL: string, options?:
|
|
3
|
-
export function makeLeader(bootstrap?: string
|
|
1
|
+
export function makeLeaderFromRpcAddresses(rpcAddrs: string[], leaderOptions?: LeaderOptions): Leader;
|
|
2
|
+
export function makeLeaderFromNetworkConfig(netconfigURL: string, options?: LeaderOptions): Promise<any>;
|
|
3
|
+
export function makeLeader(bootstrap?: string, options?: LeaderOptions): ERef<Leader>;
|
|
4
|
+
import type { LeaderOptions } from './types.js';
|
|
5
|
+
import type { Leader } from './types.js';
|
|
4
6
|
//# sourceMappingURL=leader-netconfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leader-netconfig.d.ts","sourceRoot":"","sources":["leader-netconfig.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"leader-netconfig.d.ts","sourceRoot":"","sources":["leader-netconfig.js"],"names":[],"mappings":"AAoBO,qDAJI,MAAM,EAAE,kBACR,aAAa,GACX,MAAM,CAelB;AAMM,0DAHI,MAAM,YACN,aAAa,gBAmCvB;AAOM,uCAJI,MAAM,YACN,aAAa,GACX,IAAI,CAAC,MAAM,CAAC,CAOxB;mCAzE+B,YAAY;4BACnB,YAAY"}
|
package/src/leader-netconfig.js
CHANGED
|
@@ -8,10 +8,15 @@ import {
|
|
|
8
8
|
} from './defaults.js';
|
|
9
9
|
import { assertNetworkConfig } from './netconfig.js';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @import {LeaderOptions} from './types.js';
|
|
13
|
+
* @import {Leader} from './types.js';
|
|
14
|
+
*/
|
|
15
|
+
|
|
11
16
|
/**
|
|
12
17
|
* @param {string[]} rpcAddrs
|
|
13
|
-
* @param {
|
|
14
|
-
* @returns {
|
|
18
|
+
* @param {LeaderOptions} [leaderOptions]
|
|
19
|
+
* @returns {Leader}
|
|
15
20
|
*/
|
|
16
21
|
export const makeLeaderFromRpcAddresses = (rpcAddrs, leaderOptions) => {
|
|
17
22
|
Array.isArray(rpcAddrs) || Fail`rpcAddrs ${rpcAddrs} must be an array`;
|
|
@@ -30,12 +35,12 @@ export const makeLeaderFromRpcAddresses = (rpcAddrs, leaderOptions) => {
|
|
|
30
35
|
|
|
31
36
|
/**
|
|
32
37
|
* @param {string} netconfigURL
|
|
33
|
-
* @param {
|
|
38
|
+
* @param {LeaderOptions} [options]
|
|
34
39
|
*/
|
|
35
40
|
export const makeLeaderFromNetworkConfig = (netconfigURL, options = {}) => {
|
|
36
41
|
const { retryCallback = DEFAULT_RETRY_CALLBACK, jitter = DEFAULT_JITTER } =
|
|
37
42
|
options;
|
|
38
|
-
/** @type {
|
|
43
|
+
/** @type {LeaderOptions['retryCallback']} */
|
|
39
44
|
const retry = async (where, err, attempt) => {
|
|
40
45
|
if (retryCallback) {
|
|
41
46
|
return retryCallback(where, err, attempt);
|
|
@@ -69,8 +74,8 @@ export const makeLeaderFromNetworkConfig = (netconfigURL, options = {}) => {
|
|
|
69
74
|
|
|
70
75
|
/**
|
|
71
76
|
* @param {string} [bootstrap]
|
|
72
|
-
* @param {
|
|
73
|
-
* @returns {ERef<
|
|
77
|
+
* @param {LeaderOptions} [options]
|
|
78
|
+
* @returns {ERef<Leader>}
|
|
74
79
|
*/
|
|
75
80
|
export const makeLeader = (bootstrap = DEFAULT_BOOTSTRAP, options) => {
|
|
76
81
|
if (bootstrap.includes('network-config')) {
|
package/src/leader.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export function makeRoundRobinLeader(endpoints: string[], leaderOptions?:
|
|
1
|
+
export function makeRoundRobinLeader(endpoints: string[], leaderOptions?: LeaderOptions): Leader;
|
|
2
|
+
import type { LeaderOptions } from './types.js';
|
|
3
|
+
import type { Leader } from './types.js';
|
|
2
4
|
//# sourceMappingURL=leader.d.ts.map
|
package/src/leader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"leader.d.ts","sourceRoot":"","sources":["leader.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"leader.d.ts","sourceRoot":"","sources":["leader.js"],"names":[],"mappings":"AAgBO,gDAHI,MAAM,EAAE,kBACR,aAAa,UAuEvB;mCA/E+B,YAAY;4BACnB,YAAY"}
|
package/src/leader.js
CHANGED
|
@@ -3,11 +3,16 @@ import { DEFAULT_RETRY_CALLBACK, DEFAULT_JITTER } from './defaults.js';
|
|
|
3
3
|
import { shuffle } from './shuffle.js';
|
|
4
4
|
import { makePollingChangeFollower } from './change-follower.js';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @import {LeaderOptions} from './types.js';
|
|
8
|
+
* @import {Leader} from './types.js';
|
|
9
|
+
*/
|
|
10
|
+
|
|
6
11
|
/**
|
|
7
12
|
* Create a chain leader that rotates through a list of endpoints.
|
|
8
13
|
*
|
|
9
14
|
* @param {string[]} endpoints
|
|
10
|
-
* @param {
|
|
15
|
+
* @param {LeaderOptions} leaderOptions
|
|
11
16
|
*/
|
|
12
17
|
export const makeRoundRobinLeader = (endpoints, leaderOptions = {}) => {
|
|
13
18
|
const { retryCallback = DEFAULT_RETRY_CALLBACK, jitter = DEFAULT_JITTER } =
|
|
@@ -21,7 +26,7 @@ export const makeRoundRobinLeader = (endpoints, leaderOptions = {}) => {
|
|
|
21
26
|
let thisAttempt = 0;
|
|
22
27
|
let retrying;
|
|
23
28
|
|
|
24
|
-
/** @type {
|
|
29
|
+
/** @type {Leader} */
|
|
25
30
|
const leader = Far('round robin leader', {
|
|
26
31
|
getOptions: () => leaderOptions,
|
|
27
32
|
jitter: async where => jitter && jitter(where),
|
package/src/main.js
CHANGED
package/src/makeHttpClient.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export function makeTendermintRpcClient(url: string, fetch: typeof window.fetch):
|
|
2
|
-
export function makeHttpClient(url: string, fetch: typeof window.fetch):
|
|
1
|
+
export function makeTendermintRpcClient(url: string, fetch: typeof window.fetch): RpcClient;
|
|
2
|
+
export function makeHttpClient(url: string, fetch: typeof window.fetch): RpcClient;
|
|
3
|
+
import type { RpcClient } from '@cosmjs/tendermint-rpc';
|
|
3
4
|
//# sourceMappingURL=makeHttpClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeHttpClient.d.ts","sourceRoot":"","sources":["makeHttpClient.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"makeHttpClient.d.ts","sourceRoot":"","sources":["makeHttpClient.js"],"names":[],"mappings":"AAgCO,6CAJI,MAAM,SACN,OAAO,MAAM,CAAC,KAAK,GACjB,SAAS,CA8BrB;AA5BM,oCAJI,MAAM,SACN,OAAO,MAAM,CAAC,KAAK,GACjB,SAAS,CA8BrB;+BAzD2B,wBAAwB"}
|
package/src/makeHttpClient.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @import {RpcClient} from '@cosmjs/tendermint-rpc';
|
|
5
|
+
* @import {JsonRpcRequest} from '@cosmjs/json-rpc';
|
|
6
|
+
*/
|
|
7
|
+
|
|
3
8
|
const { freeze } = Object;
|
|
4
9
|
|
|
5
10
|
const filterBadStatus = res => {
|
|
@@ -23,7 +28,7 @@ const filterBadStatus = res => {
|
|
|
23
28
|
*
|
|
24
29
|
* @param {string} url
|
|
25
30
|
* @param {typeof window.fetch} fetch
|
|
26
|
-
* @returns {
|
|
31
|
+
* @returns {RpcClient}
|
|
27
32
|
*/
|
|
28
33
|
export const makeTendermintRpcClient = (url, fetch) => {
|
|
29
34
|
const headers = {}; // XXX needed?
|
|
@@ -37,7 +42,7 @@ export const makeTendermintRpcClient = (url, fetch) => {
|
|
|
37
42
|
},
|
|
38
43
|
|
|
39
44
|
/**
|
|
40
|
-
* @param {
|
|
45
|
+
* @param {JsonRpcRequest} request
|
|
41
46
|
*/
|
|
42
47
|
execute: async request => {
|
|
43
48
|
const settings = {
|
package/src/types.d.ts
CHANGED
|
@@ -30,21 +30,21 @@ export type ValueFollowerElement<T> = ValueFollowerBase & ({
|
|
|
30
30
|
value: undefined;
|
|
31
31
|
error: any;
|
|
32
32
|
});
|
|
33
|
-
export type Unserializer = Pick<
|
|
33
|
+
export type Unserializer = Pick<Marshal<unknown>, "fromCapData" | "unserialize">;
|
|
34
34
|
export type Crasher = {
|
|
35
35
|
crash: (...args: unknown[]) => void;
|
|
36
36
|
};
|
|
37
37
|
export type FollowerOptions = {
|
|
38
|
-
unserializer?:
|
|
38
|
+
unserializer?: FarRef<Unserializer> | null | undefined;
|
|
39
39
|
decode?: ((text: string) => any) | undefined;
|
|
40
40
|
proof?: "none" | "strict" | "optimistic" | undefined;
|
|
41
|
-
crasher?:
|
|
41
|
+
crasher?: FarRef<Crasher> | undefined;
|
|
42
42
|
};
|
|
43
43
|
export type CastingSpec = {
|
|
44
44
|
storeName?: string | undefined;
|
|
45
|
-
storeSubkey?: Uint8Array | undefined;
|
|
46
|
-
dataPrefixBytes?: Uint8Array | undefined;
|
|
47
|
-
noDataValue?: Uint8Array | undefined;
|
|
45
|
+
storeSubkey?: Uint8Array<ArrayBufferLike> | undefined;
|
|
46
|
+
dataPrefixBytes?: Uint8Array<ArrayBufferLike> | undefined;
|
|
47
|
+
noDataValue?: Uint8Array<ArrayBufferLike> | undefined;
|
|
48
48
|
subscription?: globalThis.ERef<Subscription<any>> | undefined;
|
|
49
49
|
notifier?: globalThis.ERef<Notifier<any>> | undefined;
|
|
50
50
|
};
|
|
@@ -55,6 +55,8 @@ export type StreamCell<T> = {
|
|
|
55
55
|
blockHeight: number;
|
|
56
56
|
values: Array<T>;
|
|
57
57
|
};
|
|
58
|
+
import type { Marshal } from '@endo/marshal';
|
|
59
|
+
import type { FarRef } from '@endo/far';
|
|
58
60
|
import type { Subscription } from '@agoric/notifier';
|
|
59
61
|
import type { Notifier } from '@agoric/notifier';
|
|
60
62
|
//# sourceMappingURL=types.d.ts.map
|
package/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":";6BAa8B,MAAM,OAAO,GAAG,YAAY,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;sBAC5D,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;2BACxB,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC;;;;YAMnC,UAAU,EAAE;;;WAKZ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;YAC9D,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;gBAChC,MAAM,aAAa;kBACnB,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC;kBAC9E,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;;4BAG7D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC;qBAGpC,CAAC;uBAEA,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;qBAC/B,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;wBAC3D,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;;;iBAK3D,MAAM;wBACN,MAAM;;iCAKP,CAAC,IACD,iBAAiB,GAAG,CAAC;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,CAAC;2BAIrE,IAAI,CAAC,QAAQ,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,CAAC;;WAKpD,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI;;;;qBAMrB,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;uBAqBtB,CAAC;iBAEA,MAAM;YACN,KAAK,CAAC,CAAC,CAAC;;6BApFI,eAAe;4BAChB,WAAW;kCAFK,kBAAkB;8BAAlB,kBAAkB"}
|
package/src/types.js
CHANGED
|
@@ -5,6 +5,8 @@ export {};
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @import {Notifier, Subscription} from '@agoric/notifier';
|
|
8
|
+
* @import {Marshal} from '@endo/marshal';
|
|
9
|
+
* @import {FarRef} from '@endo/far';
|
|
8
10
|
*/
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -52,7 +54,7 @@ export {};
|
|
|
52
54
|
*/
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
|
-
* @typedef {Pick<
|
|
57
|
+
* @typedef {Pick<Marshal<unknown>, 'fromCapData' | 'unserialize'>} Unserializer
|
|
56
58
|
*/
|
|
57
59
|
|
|
58
60
|
/**
|
|
@@ -62,10 +64,10 @@ export {};
|
|
|
62
64
|
|
|
63
65
|
/**
|
|
64
66
|
* @typedef {object} FollowerOptions
|
|
65
|
-
* @property {null |
|
|
67
|
+
* @property {null | FarRef<Unserializer>} [unserializer]
|
|
66
68
|
* @property {(text: string) => any} [decode]
|
|
67
69
|
* @property {'strict'|'optimistic'|'none'} [proof]
|
|
68
|
-
* @property {
|
|
70
|
+
* @property {FarRef<Crasher>} [crasher]
|
|
69
71
|
*/
|
|
70
72
|
|
|
71
73
|
/**
|
package/test/fake-rpc-server.js
CHANGED
|
@@ -8,6 +8,10 @@ import express from 'express';
|
|
|
8
8
|
|
|
9
9
|
import { toAscii, toBase64 } from '@cosmjs/encoding';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @import {ExecutionContext} from 'ava';
|
|
13
|
+
*/
|
|
14
|
+
|
|
11
15
|
const chainName = 'fakeChain';
|
|
12
16
|
|
|
13
17
|
let lastPort = 8989;
|
|
@@ -72,7 +76,7 @@ const fakeStatusResult = {
|
|
|
72
76
|
},
|
|
73
77
|
};
|
|
74
78
|
|
|
75
|
-
/** @typedef {Partial<
|
|
79
|
+
/** @typedef {Partial<ExecutionContext<{cleanups: Array<() => void>}>> & {context}} FakeServerTestContext */
|
|
76
80
|
/**
|
|
77
81
|
* @param {FakeServerTestContext} t
|
|
78
82
|
* @param {Array<{any}>} fakeValues
|
|
@@ -15,7 +15,12 @@ import {
|
|
|
15
15
|
import { makeTendermintRpcClient } from '../src/makeHttpClient.js';
|
|
16
16
|
import { captureIO, replayIO, web1, web2 } from './net-access-fixture.js';
|
|
17
17
|
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* @import {EReturn} from '@endo/far';
|
|
20
|
+
* @import {TestFn} from 'ava';
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** @type {TestFn<EReturn<typeof makeTestContext>>} */
|
|
19
24
|
const test = /** @type {any} */ (anyTest);
|
|
20
25
|
|
|
21
26
|
const RECORDING = false;
|
package/test/mvp.test.js
CHANGED
|
@@ -16,6 +16,11 @@ import {
|
|
|
16
16
|
import { delay } from '../src/defaults.js';
|
|
17
17
|
import { startFakeServer } from './fake-rpc-server.js';
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @import {LeaderOptions} from '../src/types.js';
|
|
21
|
+
* @import {FollowerOptions} from '../src/types.js';
|
|
22
|
+
*/
|
|
23
|
+
|
|
19
24
|
// TODO: Replace with test.macro({title, exec}).
|
|
20
25
|
const testHappyPath = (label, ...input) => {
|
|
21
26
|
// eslint-disable-next-line no-shadow
|
|
@@ -31,13 +36,13 @@ const testHappyPath = (label, ...input) => {
|
|
|
31
36
|
options,
|
|
32
37
|
);
|
|
33
38
|
controller.advance(start);
|
|
34
|
-
/** @type {
|
|
39
|
+
/** @type {LeaderOptions} */
|
|
35
40
|
const lo = {
|
|
36
41
|
retryCallback: null, // fail fast, no retries
|
|
37
42
|
keepPolling: () => delay(1000).then(() => true), // poll really quickly
|
|
38
43
|
jitter: null, // no jitter
|
|
39
44
|
};
|
|
40
|
-
/** @type {
|
|
45
|
+
/** @type {FollowerOptions} */
|
|
41
46
|
const so = {
|
|
42
47
|
proof: 'none',
|
|
43
48
|
};
|
|
@@ -186,13 +191,13 @@ test('yields error on bad capdata without terminating', async t => {
|
|
|
186
191
|
options,
|
|
187
192
|
);
|
|
188
193
|
controller.advance(0);
|
|
189
|
-
/** @type {
|
|
194
|
+
/** @type {LeaderOptions} */
|
|
190
195
|
const lo = {
|
|
191
196
|
retryCallback: null, // fail fast, no retries
|
|
192
197
|
keepPolling: () => delay(1000).then(() => true), // poll really quickly
|
|
193
198
|
jitter: null, // no jitter
|
|
194
199
|
};
|
|
195
|
-
/** @type {
|
|
200
|
+
/** @type {FollowerOptions} */
|
|
196
201
|
const so = {
|
|
197
202
|
proof: 'none',
|
|
198
203
|
};
|
package/test/netconfig.test.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { test } from './prepare-test-env-ava.js';
|
|
2
2
|
import { assertNetworkConfig } from '../src/netconfig.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @import {NetworkConfig} from '@agoric/casting/src/netconfig.js';
|
|
6
|
+
*/
|
|
7
|
+
|
|
4
8
|
test('https://main.agoric.net/network-config 2022-10-27', t => {
|
|
5
9
|
/**
|
|
6
|
-
* @type {
|
|
10
|
+
* @type {NetworkConfig}
|
|
7
11
|
*/
|
|
8
12
|
const specimen = {
|
|
9
13
|
chainName: 'agoric-3',
|
|
@@ -23,7 +27,7 @@ test('https://main.agoric.net/network-config 2022-10-27', t => {
|
|
|
23
27
|
|
|
24
28
|
test('https://ollinet.agoric.net/network-config 2022-10-27', t => {
|
|
25
29
|
/**
|
|
26
|
-
* @type {
|
|
30
|
+
* @type {NetworkConfig}
|
|
27
31
|
*/
|
|
28
32
|
const specimen = {
|
|
29
33
|
chainName: 'agoricollinet-44',
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { E } from '@endo/far';
|
|
2
|
+
import { expectType } from 'tsd';
|
|
3
|
+
import type { ValueFollower } from '../src/follower-cosmjs.js';
|
|
4
|
+
import { makeFollower } from '../src/follower.js';
|
|
5
|
+
import { iterateLatest } from '../src/iterable.js';
|
|
6
|
+
import { makeLeader } from '../src/leader-netconfig.js';
|
|
7
|
+
import type { ValueFollowerElement } from '../src/types.js';
|
|
8
|
+
|
|
9
|
+
type ThePublishedDatum = { a: 1; b: 'two' };
|
|
10
|
+
type TheFollowerElement = ValueFollowerElement<ThePublishedDatum>;
|
|
11
|
+
|
|
12
|
+
const leader = makeLeader();
|
|
13
|
+
|
|
14
|
+
{
|
|
15
|
+
const f = makeFollower<ThePublishedDatum>('', leader, {});
|
|
16
|
+
expectType<ValueFollower<ThePublishedDatum>>(await f);
|
|
17
|
+
|
|
18
|
+
expectType<AsyncIterable<TheFollowerElement>>(await E(f).getLatestIterable());
|
|
19
|
+
|
|
20
|
+
expectType<AsyncIterable<TheFollowerElement>>(await E(f).getLatestIterable());
|
|
21
|
+
|
|
22
|
+
expectType<AsyncIterable<TheFollowerElement>>(
|
|
23
|
+
await E(f).getReverseIterable(),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const iter = iterateLatest(f);
|
|
27
|
+
for await (const { value } of iter) {
|
|
28
|
+
assert(value, 'value undefined');
|
|
29
|
+
expectType<ThePublishedDatum>(value);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/casting-spec.js","./src/change-follower.js","./src/defaults.js","./src/follower-cosmjs.js","./src/follower.js","./src/iterable.js","./src/leader-netconfig.js","./src/leader.js","./src/main.js","./src/makeHttpClient.js","./src/netconfig.js","./src/shuffle.js","./src/types.js"],"version":"5.
|
|
1
|
+
{"root":["./src/casting-spec.js","./src/change-follower.js","./src/defaults.js","./src/follower-cosmjs.js","./src/follower.js","./src/iterable.js","./src/leader-netconfig.js","./src/leader.js","./src/main.js","./src/makeHttpClient.js","./src/netconfig.js","./src/shuffle.js","./src/types.js"],"version":"5.9.3"}
|