@agoric/internal 0.4.0-upgrade-14-dev-c8f9e7b.0 → 0.4.0-upgrade-16-dev-07b0130.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/README.md +7 -2
- package/exported.js +2 -0
- package/package.json +32 -16
- package/src/batched-deliver.d.ts +9 -6
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/batched-deliver.js +9 -3
- package/src/callback.d.ts +23 -16
- package/src/callback.d.ts.map +1 -1
- package/src/callback.js +35 -39
- package/src/chain-storage-paths.d.ts +2 -3
- package/src/chain-storage-paths.d.ts.map +1 -1
- package/src/chain-storage-paths.js +2 -3
- package/src/config.d.ts +23 -12
- package/src/config.d.ts.map +1 -1
- package/src/config.js +22 -10
- package/src/debug.d.ts +1 -1
- package/src/index.d.ts +3 -0
- package/src/index.js +7 -1
- package/src/install-ses-debug.d.ts +2 -0
- package/src/install-ses-debug.d.ts.map +1 -0
- package/src/install-ses-debug.js +6 -0
- package/src/lib-chainStorage.d.ts +42 -52
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +82 -74
- package/src/lib-nodejs/engine-gc.d.ts +3 -0
- package/src/lib-nodejs/engine-gc.d.ts.map +1 -0
- package/src/lib-nodejs/engine-gc.js +22 -0
- package/src/lib-nodejs/gc-and-finalize.d.ts +2 -0
- package/src/lib-nodejs/gc-and-finalize.d.ts.map +1 -0
- package/src/lib-nodejs/gc-and-finalize.js +91 -0
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts +15 -0
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -0
- package/src/lib-nodejs/spawnSubprocessWorker.js +89 -0
- package/src/lib-nodejs/waitUntilQuiescent.d.ts +2 -0
- package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -0
- package/src/lib-nodejs/waitUntilQuiescent.js +18 -0
- package/src/lib-nodejs/worker-protocol.d.ts +4 -0
- package/src/lib-nodejs/worker-protocol.d.ts.map +1 -0
- package/src/lib-nodejs/worker-protocol.js +54 -0
- package/src/magic-cookie-test-only.js +2 -2
- package/src/marshal.d.ts +20 -0
- package/src/marshal.d.ts.map +1 -0
- package/src/marshal.js +138 -0
- package/src/method-tools.d.ts +1 -0
- package/src/method-tools.d.ts.map +1 -1
- package/src/method-tools.js +29 -16
- package/src/netstring.d.ts +24 -0
- package/src/netstring.d.ts.map +1 -0
- package/src/netstring.js +124 -0
- package/src/node/buffer-line-transform.d.ts +17 -13
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/buffer-line-transform.js +11 -8
- package/src/node/fs-stream.d.ts.map +1 -1
- package/src/node/fs-stream.js +2 -3
- package/src/node/utils.d.ts +9 -0
- package/src/node/utils.d.ts.map +1 -0
- package/src/node/utils.js +46 -0
- package/src/priority-senders.d.ts +1 -1
- package/src/priority-senders.d.ts.map +1 -1
- package/src/priority-senders.js +7 -3
- package/src/queue.d.ts +1 -1
- package/src/queue.d.ts.map +1 -1
- package/src/queue.js +7 -8
- package/src/scratch.d.ts +1 -1
- package/src/scratch.d.ts.map +1 -1
- package/src/storage-test-utils.d.ts +43 -81
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +103 -40
- package/src/tagged.d.ts +155 -0
- package/src/testing-utils.d.ts.map +1 -1
- package/src/testing-utils.js +7 -5
- package/src/tokens.d.ts +34 -0
- package/src/tokens.d.ts.map +1 -0
- package/src/tokens.js +35 -0
- package/src/typeGuards.d.ts +2 -0
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +8 -0
- package/src/types.d.ts +46 -0
- package/src/types.js +2 -0
- package/src/upgrade-api.d.ts +13 -4
- package/src/upgrade-api.d.ts.map +1 -1
- package/src/upgrade-api.js +26 -18
- package/src/utils.d.ts +26 -31
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +53 -227
- package/CHANGELOG.md +0 -137
package/src/tagged.d.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/** @file adapted from https://raw.githubusercontent.com/sindresorhus/type-fest/main/source/opaque.d.ts */
|
|
2
|
+
|
|
3
|
+
declare const tag: unique symbol;
|
|
4
|
+
|
|
5
|
+
export type TagContainer<Token> = {
|
|
6
|
+
readonly [tag]: Token;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{
|
|
10
|
+
[K in Token]: TagMetadata;
|
|
11
|
+
}>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
Attach a "tag" to an arbitrary type. This allows you to create distinct types, that aren't assignable to one another, for distinct concepts in your program that should not be interchangeable, even if their runtime values have the same type. (See examples.)
|
|
15
|
+
|
|
16
|
+
A type returned by `Tagged` can be passed to `Tagged` again, to create a type with multiple tags.
|
|
17
|
+
|
|
18
|
+
[Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
|
|
19
|
+
|
|
20
|
+
A tag's name is usually a string (and must be a string, number, or symbol), but each application of a tag can also contain an arbitrary type as its "metadata". See {@link GetTagMetadata} for examples and explanation.
|
|
21
|
+
|
|
22
|
+
A type `A` returned by `Tagged` is assignable to another type `B` returned by `Tagged` if and only if:
|
|
23
|
+
- the underlying (untagged) type of `A` is assignable to the underlying type of `B`;
|
|
24
|
+
- `A` contains at least all the tags `B` has;
|
|
25
|
+
- and the metadata type for each of `A`'s tags is assignable to the metadata type of `B`'s corresponding tag.
|
|
26
|
+
|
|
27
|
+
There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
|
|
28
|
+
- [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
|
|
29
|
+
- [Microsoft/TypeScript#4895](https://github.com/microsoft/TypeScript/issues/4895)
|
|
30
|
+
- [Microsoft/TypeScript#33290](https://github.com/microsoft/TypeScript/pull/33290)
|
|
31
|
+
|
|
32
|
+
@example
|
|
33
|
+
```
|
|
34
|
+
import type {Tagged} from 'type-fest';
|
|
35
|
+
|
|
36
|
+
type AccountNumber = Tagged<number, 'AccountNumber'>;
|
|
37
|
+
type AccountBalance = Tagged<number, 'AccountBalance'>;
|
|
38
|
+
|
|
39
|
+
function createAccountNumber(): AccountNumber {
|
|
40
|
+
// As you can see, casting from a `number` (the underlying type being tagged) is allowed.
|
|
41
|
+
return 2 as AccountNumber;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance {
|
|
45
|
+
return 4 as AccountBalance;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// This will compile successfully.
|
|
49
|
+
getMoneyForAccount(createAccountNumber());
|
|
50
|
+
|
|
51
|
+
// But this won't, because it has to be explicitly passed as an `AccountNumber` type!
|
|
52
|
+
// Critically, you could not accidentally use an `AccountBalance` as an `AccountNumber`.
|
|
53
|
+
getMoneyForAccount(2);
|
|
54
|
+
|
|
55
|
+
// You can also use tagged values like their underlying, untagged type.
|
|
56
|
+
// I.e., this will compile successfully because an `AccountNumber` can be used as a regular `number`.
|
|
57
|
+
// In this sense, the underlying base type is not hidden, which differentiates tagged types from opaque types in other languages.
|
|
58
|
+
const accountNumber = createAccountNumber() + 2;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
@example
|
|
62
|
+
```
|
|
63
|
+
import type {Tagged} from 'type-fest';
|
|
64
|
+
|
|
65
|
+
// You can apply multiple tags to a type by using `Tagged` repeatedly.
|
|
66
|
+
type Url = Tagged<string, 'URL'>;
|
|
67
|
+
type SpecialCacheKey = Tagged<Url, 'SpecialCacheKey'>;
|
|
68
|
+
|
|
69
|
+
// You can also pass a union of tag names, so this is equivalent to the above, although it doesn't give you the ability to assign distinct metadata to each tag.
|
|
70
|
+
type SpecialCacheKey2 = Tagged<string, 'URL' | 'SpecialCacheKey'>;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
@category Type
|
|
74
|
+
*/
|
|
75
|
+
export type Tagged<
|
|
76
|
+
Type,
|
|
77
|
+
TagName extends PropertyKey,
|
|
78
|
+
TagMetadata = never,
|
|
79
|
+
> = Type & Tag<TagName, TagMetadata>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
Given a type and a tag name, returns the metadata associated with that tag on that type.
|
|
83
|
+
|
|
84
|
+
In the example below, one could use `Tagged<string, 'JSON'>` to represent "a string that is valid JSON". That type might be useful -- for instance, it communicates that the value can be safely passed to `JSON.parse` without it throwing an exception. However, it doesn't indicate what type of value will be produced on parse (which is sometimes known). `JsonOf<T>` solves this; it represents "a string that is valid JSON and that, if parsed, would produce a value of type T". The type T is held in the metadata associated with the `'JSON'` tag.
|
|
85
|
+
|
|
86
|
+
This article explains more about [how tag metadata works and when it can be useful](https://medium.com/@ethanresnick/advanced-typescript-tagged-types-improved-with-type-level-metadata-5072fc125fcf).
|
|
87
|
+
|
|
88
|
+
@example
|
|
89
|
+
```
|
|
90
|
+
import type {Tagged} from 'type-fest';
|
|
91
|
+
|
|
92
|
+
type JsonOf<T> = Tagged<string, 'JSON', T>;
|
|
93
|
+
|
|
94
|
+
function stringify<T>(it: T) {
|
|
95
|
+
return JSON.stringify(it) as JsonOf<T>;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function parse<T extends JsonOf<unknown>>(it: T) {
|
|
99
|
+
return JSON.parse(it) as GetTagMetadata<T, 'JSON'>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const x = stringify({ hello: 'world' });
|
|
103
|
+
const parsed = parse(x); // The type of `parsed` is { hello: string }
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
@category Type
|
|
107
|
+
*/
|
|
108
|
+
export type GetTagMetadata<
|
|
109
|
+
Type extends Tag<TagName, unknown>,
|
|
110
|
+
TagName extends PropertyKey,
|
|
111
|
+
> = Type[typeof tag][TagName];
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
Revert a tagged type back to its original type by removing all tags.
|
|
115
|
+
|
|
116
|
+
Why is this necessary?
|
|
117
|
+
|
|
118
|
+
1. Use a `Tagged` type as object keys
|
|
119
|
+
2. Prevent TS4058 error: "Return type of exported function has or is using name X from external module Y but cannot be named"
|
|
120
|
+
|
|
121
|
+
@example
|
|
122
|
+
```
|
|
123
|
+
import type {Tagged, UnwrapTagged} from 'type-fest';
|
|
124
|
+
|
|
125
|
+
type AccountType = Tagged<'SAVINGS' | 'CHECKING', 'AccountType'>;
|
|
126
|
+
|
|
127
|
+
const moneyByAccountType: Record<UnwrapTagged<AccountType>, number> = {
|
|
128
|
+
SAVINGS: 99,
|
|
129
|
+
CHECKING: 0.1
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// Without UnwrapTagged, the following expression would throw a type error.
|
|
133
|
+
const money = moneyByAccountType.SAVINGS; // TS error: Property 'SAVINGS' does not exist
|
|
134
|
+
|
|
135
|
+
// Attempting to pass an non-Tagged type to UnwrapTagged will raise a type error.
|
|
136
|
+
type WontWork = UnwrapTagged<string>;
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
@category Type
|
|
140
|
+
*/
|
|
141
|
+
export type UnwrapTagged<TaggedType extends Tag<PropertyKey, any>> =
|
|
142
|
+
RemoveAllTags<TaggedType>;
|
|
143
|
+
|
|
144
|
+
type RemoveAllTags<T> =
|
|
145
|
+
T extends Tag<PropertyKey, any>
|
|
146
|
+
? {
|
|
147
|
+
[ThisTag in keyof T[typeof tag]]: T extends Tagged<
|
|
148
|
+
infer Type,
|
|
149
|
+
ThisTag,
|
|
150
|
+
T[typeof tag][ThisTag]
|
|
151
|
+
>
|
|
152
|
+
? RemoveAllTags<Type>
|
|
153
|
+
: never;
|
|
154
|
+
}[keyof T[typeof tag]]
|
|
155
|
+
: T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-utils.d.ts","sourceRoot":"","sources":["testing-utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testing-utils.d.ts","sourceRoot":"","sources":["testing-utils.js"],"names":[],"mappings":"AAaO,mDACwC"}
|
package/src/testing-utils.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* @file note this cannot be called test-utils.js due to
|
|
3
|
+
* https://github.com/Agoric/agoric-sdk/issues/7503
|
|
4
|
+
*/
|
|
2
5
|
/* global setImmediate */
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* A workaround for some issues with fake time in tests.
|
|
6
9
|
*
|
|
7
|
-
* Lines of test code can depend on async promises outside the test
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Note that this doesn't mean all outstanding promises.
|
|
10
|
+
* Lines of test code can depend on async promises outside the test resolving
|
|
11
|
+
* before they run. Awaiting this function result ensures that all promises that
|
|
12
|
+
* can do resolve. Note that this doesn't mean all outstanding promises.
|
|
11
13
|
*/
|
|
12
14
|
export const eventLoopIteration = async () =>
|
|
13
15
|
new Promise(resolve => setImmediate(resolve));
|
package/src/tokens.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export namespace Stable {
|
|
2
|
+
export let symbol: "IST";
|
|
3
|
+
export let denom: "uist";
|
|
4
|
+
export let proposedName: "Agoric stable token";
|
|
5
|
+
export { NAT as assetKind };
|
|
6
|
+
export namespace displayInfo {
|
|
7
|
+
export let decimalPlaces: 6;
|
|
8
|
+
export { NAT as assetKind };
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export namespace Stake {
|
|
12
|
+
let symbol_1: "BLD";
|
|
13
|
+
export { symbol_1 as symbol };
|
|
14
|
+
let denom_1: "ubld";
|
|
15
|
+
export { denom_1 as denom };
|
|
16
|
+
let proposedName_1: "Agoric staking token";
|
|
17
|
+
export { proposedName_1 as proposedName };
|
|
18
|
+
export { NAT as assetKind };
|
|
19
|
+
export namespace displayInfo_1 {
|
|
20
|
+
let decimalPlaces_1: 6;
|
|
21
|
+
export { decimalPlaces_1 as decimalPlaces };
|
|
22
|
+
export { NAT as assetKind };
|
|
23
|
+
}
|
|
24
|
+
export { displayInfo_1 as displayInfo };
|
|
25
|
+
}
|
|
26
|
+
export type TokenKeyword = "IST" | "BLD";
|
|
27
|
+
/** @typedef {'IST' | 'BLD'} TokenKeyword */
|
|
28
|
+
/**
|
|
29
|
+
* This is defined by ERTP. For dependency pragmatism it's repeated here. We
|
|
30
|
+
* rely on the static type check and unit tests to detect any incompatibility.
|
|
31
|
+
*/
|
|
32
|
+
declare const NAT: "nat";
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["tokens.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;2BAEc,KAAK,GAAG,KAAK;AAA3B,4CAA4C;AAE5C;;;GAGG;AACH,yBAAkB"}
|
package/src/tokens.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/** @typedef {'IST' | 'BLD'} TokenKeyword */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This is defined by ERTP. For dependency pragmatism it's repeated here. We
|
|
7
|
+
* rely on the static type check and unit tests to detect any incompatibility.
|
|
8
|
+
*/
|
|
9
|
+
const NAT = 'nat';
|
|
10
|
+
|
|
11
|
+
export const Stable = harden(
|
|
12
|
+
/** @type {const} */ ({
|
|
13
|
+
symbol: 'IST',
|
|
14
|
+
denom: 'uist',
|
|
15
|
+
proposedName: 'Agoric stable token',
|
|
16
|
+
assetKind: NAT,
|
|
17
|
+
displayInfo: {
|
|
18
|
+
decimalPlaces: 6,
|
|
19
|
+
assetKind: NAT,
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export const Stake = harden(
|
|
25
|
+
/** @type {const} */ ({
|
|
26
|
+
symbol: 'BLD',
|
|
27
|
+
denom: 'ubld',
|
|
28
|
+
proposedName: 'Agoric staking token',
|
|
29
|
+
assetKind: NAT,
|
|
30
|
+
displayInfo: {
|
|
31
|
+
decimalPlaces: 6,
|
|
32
|
+
assetKind: NAT,
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
);
|
package/src/typeGuards.d.ts
CHANGED
package/src/typeGuards.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA,gEAA2D"}
|
|
1
|
+
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAIA,gEAA2D;AAE3D,iFAAiF;AACjF,4EAKE"}
|
package/src/typeGuards.js
CHANGED
|
@@ -3,3 +3,11 @@
|
|
|
3
3
|
import { M } from '@endo/patterns';
|
|
4
4
|
|
|
5
5
|
export const StorageNodeShape = M.remotable('StorageNode');
|
|
6
|
+
|
|
7
|
+
/** To be used only for 'helper' facets where the calls are from trusted code. */
|
|
8
|
+
export const UnguardedHelperI = M.interface(
|
|
9
|
+
'helper',
|
|
10
|
+
{},
|
|
11
|
+
// not exposed so sloppy okay
|
|
12
|
+
{ sloppy: true },
|
|
13
|
+
);
|
package/src/types.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import type { ERef, RemotableBrand } from '@endo/eventual-send';
|
|
3
|
+
import type { Primitive } from '@endo/pass-style';
|
|
4
|
+
import type { Callable } from './utils.js';
|
|
5
|
+
|
|
2
6
|
export declare class Callback<I extends (...args: unknown[]) => any> {
|
|
3
7
|
private iface: I;
|
|
4
8
|
|
|
@@ -18,3 +22,45 @@ export declare class SyncCallback<
|
|
|
18
22
|
|
|
19
23
|
public isSync: true;
|
|
20
24
|
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
Returns a boolean for whether the given type is primitive value or primitive type.
|
|
28
|
+
|
|
29
|
+
@example
|
|
30
|
+
```
|
|
31
|
+
IsPrimitive<'string'>
|
|
32
|
+
//=> true
|
|
33
|
+
|
|
34
|
+
IsPrimitive<string>
|
|
35
|
+
//=> true
|
|
36
|
+
|
|
37
|
+
IsPrimitive<Object>
|
|
38
|
+
//=> false
|
|
39
|
+
```
|
|
40
|
+
*/
|
|
41
|
+
export type IsPrimitive<T> = [T] extends [Primitive] ? true : false;
|
|
42
|
+
|
|
43
|
+
/** Recursively extract the non-callable properties of T */
|
|
44
|
+
export type DataOnly<T> =
|
|
45
|
+
IsPrimitive<T> extends true
|
|
46
|
+
? T
|
|
47
|
+
: T extends Callable
|
|
48
|
+
? never
|
|
49
|
+
: { [P in keyof T as T[P] extends Callable ? never : P]: DataOnly<T[P]> };
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A type that doesn't assume its parameter is local, but is satisfied with both
|
|
53
|
+
* local and remote references. It accepts both near and marshalled references
|
|
54
|
+
* that were returned from `Remotable` or `Far`.
|
|
55
|
+
*/
|
|
56
|
+
export type Remote<Primary, Local = DataOnly<Primary>> =
|
|
57
|
+
| Primary
|
|
58
|
+
| RemotableBrand<Local, Primary>;
|
|
59
|
+
|
|
60
|
+
// TODO: Add type tests for FarRef and Remote.
|
|
61
|
+
/**
|
|
62
|
+
* Potentially remote promises or settled references.
|
|
63
|
+
*/
|
|
64
|
+
export type FarRef<Primary, Local = DataOnly<Primary>> = ERef<
|
|
65
|
+
Remote<Primary, Local>
|
|
66
|
+
>;
|
package/src/types.js
ADDED
package/src/upgrade-api.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export namespace UpgradeDisconnectionShape {
|
|
2
|
+
let name: string;
|
|
3
|
+
let upgradeMessage: import("@endo/patterns").Matcher;
|
|
4
|
+
let incarnationNumber: import("@endo/patterns").Matcher;
|
|
5
|
+
}
|
|
6
|
+
export function makeUpgradeDisconnection(upgradeMessage: string, toIncarnationNumber: number): UpgradeDisconnection;
|
|
7
|
+
export function isUpgradeDisconnection(reason: any): reason is UpgradeDisconnection;
|
|
8
|
+
/**
|
|
9
|
+
* An Error-like object for use as the rejection reason of promises abandoned by
|
|
10
|
+
* upgrade.
|
|
11
|
+
*/
|
|
12
|
+
export type UpgradeDisconnection = {
|
|
13
|
+
name: "vatUpgraded";
|
|
5
14
|
upgradeMessage: string;
|
|
6
15
|
incarnationNumber: number;
|
|
7
16
|
};
|
package/src/upgrade-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade-api.d.ts","sourceRoot":"","sources":["upgrade-api.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upgrade-api.d.ts","sourceRoot":"","sources":["upgrade-api.js"],"names":[],"mappings":";;;;;AAgCO,yDAJI,MAAM,uBACN,MAAM,GACJ,oBAAoB,CAO7B;AASG,+CALI,GAAG,GAGD,MAAM,IAAI,oBAAoB,CAGqB;;;;;mCApCnD;IACZ,IAAQ,EAAE,aAAa,CAAC;IACxB,cAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAqB,EAAE,MAAM,CAAC;CAC3B"}
|
package/src/upgrade-api.js
CHANGED
|
@@ -1,18 +1,34 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
// @jessie-check
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import { M, matches } from '@endo/patterns';
|
|
5
|
+
|
|
6
|
+
const { isFrozen } = Object;
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
|
-
*
|
|
9
|
+
* An Error-like object for use as the rejection reason of promises abandoned by
|
|
10
|
+
* upgrade.
|
|
11
|
+
*
|
|
12
|
+
* @typedef {{
|
|
13
|
+
* name: 'vatUpgraded';
|
|
14
|
+
* upgradeMessage: string;
|
|
15
|
+
* incarnationNumber: number;
|
|
16
|
+
* }} UpgradeDisconnection
|
|
7
17
|
*/
|
|
8
18
|
|
|
19
|
+
export const UpgradeDisconnectionShape = harden({
|
|
20
|
+
name: 'vatUpgraded',
|
|
21
|
+
upgradeMessage: M.string(),
|
|
22
|
+
incarnationNumber: M.number(),
|
|
23
|
+
});
|
|
24
|
+
|
|
9
25
|
/**
|
|
10
|
-
* Makes an Error-like object for use as the rejection
|
|
26
|
+
* Makes an Error-like object for use as the rejection reason of promises
|
|
11
27
|
* abandoned by upgrade.
|
|
12
28
|
*
|
|
13
29
|
* @param {string} upgradeMessage
|
|
14
30
|
* @param {number} toIncarnationNumber
|
|
15
|
-
* @returns {
|
|
31
|
+
* @returns {UpgradeDisconnection}
|
|
16
32
|
*/
|
|
17
33
|
export const makeUpgradeDisconnection = (upgradeMessage, toIncarnationNumber) =>
|
|
18
34
|
harden({
|
|
@@ -22,20 +38,12 @@ export const makeUpgradeDisconnection = (upgradeMessage, toIncarnationNumber) =>
|
|
|
22
38
|
});
|
|
23
39
|
harden(makeUpgradeDisconnection);
|
|
24
40
|
|
|
25
|
-
// TODO: Simplify once we have @endo/patterns (or just export the shape).
|
|
26
|
-
// const upgradeDisconnectionShape = harden({
|
|
27
|
-
// name: 'vatUpgraded',
|
|
28
|
-
// upgradeMessage: M.string(),
|
|
29
|
-
// incarnationNumber: M.number(),
|
|
30
|
-
// });
|
|
31
|
-
// const isUpgradeDisconnection = err => matches(err, upgradeDisconnectionShape);
|
|
32
41
|
/**
|
|
33
|
-
* @param {any}
|
|
34
|
-
*
|
|
42
|
+
* @param {any} reason If `reason` is not frozen, it cannot be an
|
|
43
|
+
* UpgradeDisconnection, so returns false without even checking against the
|
|
44
|
+
* shape.
|
|
45
|
+
* @returns {reason is UpgradeDisconnection}
|
|
35
46
|
*/
|
|
36
|
-
export const isUpgradeDisconnection =
|
|
37
|
-
|
|
38
|
-
err.name === 'vatUpgraded' &&
|
|
39
|
-
typeof err.upgradeMessage === 'string' &&
|
|
40
|
-
typeof err.incarnationNumber === 'number';
|
|
47
|
+
export const isUpgradeDisconnection = reason =>
|
|
48
|
+
isFrozen(reason) && matches(reason, UpgradeDisconnectionShape);
|
|
41
49
|
harden(isUpgradeDisconnection);
|
package/src/utils.d.ts
CHANGED
|
@@ -1,67 +1,62 @@
|
|
|
1
1
|
export const BASIS_POINTS: 10000n;
|
|
2
|
-
|
|
3
|
-
export function objectMap<O extends Record<string, any>, R>(original: O, mapFn: (value: O[keyof O], key: keyof O) => R): { [P in keyof O]: R; };
|
|
4
|
-
export function listDifference(leftNames: Array<string | symbol>, rightNames: Array<string | symbol>): (string | symbol)[];
|
|
5
|
-
export function throwLabeled(innerErr: Error, label: string | number, ErrorConstructor?: ErrorConstructor | undefined): never;
|
|
6
|
-
export function applyLabelingError<A, R>(func: (...args: A[]) => R, args: A[], label?: string | number | undefined): R;
|
|
2
|
+
/** @import {ERef} from '@endo/far' */
|
|
7
3
|
/**
|
|
8
4
|
* @template T
|
|
9
|
-
* @typedef {{[KeyType in keyof T]: T[KeyType]} & {}} Simplify
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* @typedef {{ [KeyType in keyof T]: T[KeyType] } & {}} Simplify flatten the
|
|
6
|
+
* type output to improve type hints shown in editors
|
|
7
|
+
* https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.ts
|
|
12
8
|
*/
|
|
13
9
|
/**
|
|
14
10
|
* @typedef {(...args: any[]) => any} Callable
|
|
15
11
|
*/
|
|
16
12
|
/**
|
|
17
13
|
* @template {{}} T
|
|
18
|
-
* @typedef {{
|
|
14
|
+
* @typedef {{
|
|
15
|
+
* [K in keyof T]: T[K] extends Callable ? T[K] : DeeplyAwaited<T[K]>;
|
|
16
|
+
* }} DeeplyAwaitedObject
|
|
19
17
|
*/
|
|
20
18
|
/**
|
|
21
19
|
* @template T
|
|
22
|
-
* @typedef {T extends PromiseLike<any>
|
|
20
|
+
* @typedef {T extends PromiseLike<any>
|
|
21
|
+
* ? Awaited<T>
|
|
22
|
+
* : T extends {}
|
|
23
|
+
* ? Simplify<DeeplyAwaitedObject<T>>
|
|
24
|
+
* : Awaited<T>} DeeplyAwaited
|
|
23
25
|
*/
|
|
24
26
|
/**
|
|
25
27
|
* A more constrained version of {deeplyFulfilled} for type safety until
|
|
26
|
-
* https://github.com/endojs/endo/issues/1257
|
|
27
|
-
*
|
|
28
|
-
* in order to be durable.
|
|
28
|
+
* https://github.com/endojs/endo/issues/1257 Useful in starting contracts that
|
|
29
|
+
* need all terms to be fulfilled in order to be durable.
|
|
29
30
|
*
|
|
30
31
|
* @type {<T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>}
|
|
31
32
|
*/
|
|
32
33
|
export const deeplyFulfilledObject: <T extends {}>(unfulfilledTerms: T) => Promise<DeeplyAwaited<T>>;
|
|
33
|
-
export function makeMeasureSeconds(currentTimeMillisec: typeof import(
|
|
34
|
+
export function makeMeasureSeconds(currentTimeMillisec: typeof import("perf_hooks").performance.now): <T>(fn: () => Promise<T>) => Promise<{
|
|
34
35
|
result: T;
|
|
35
36
|
duration: number;
|
|
36
37
|
}>;
|
|
37
|
-
export function makeAggregateError(errors: Error[], message?: string | undefined): Error;
|
|
38
|
-
export function PromiseAllOrErrors<T>(items: readonly (T | PromiseLike<T>)[]): Promise<T[]>;
|
|
39
|
-
/**
|
|
40
|
-
* @type {<T>(
|
|
41
|
-
* trier: () => Promise<T>,
|
|
42
|
-
* finalizer: (error?: unknown) => Promise<void>,
|
|
43
|
-
* ) => Promise<T>}
|
|
44
|
-
*/ export const aggregateTryFinally: <T>(trier: () => Promise<T>, finalizer: (error?: unknown) => Promise<void>) => Promise<T>;
|
|
45
38
|
export function assertAllDefined<T extends Record<string, unknown>>(obj: T): asserts obj is AllDefined<T>;
|
|
46
39
|
export const forever: AsyncIterable<undefined>;
|
|
47
40
|
export function whileTrue<T>(produce: () => T): AsyncIterable<Awaited<T>>;
|
|
48
41
|
export function untilTrue<T>(produce: () => T): AsyncIterable<Awaited<T>>;
|
|
49
|
-
/** @type {
|
|
42
|
+
/** @type {<X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
|
|
50
43
|
export const zip: <X, Y>(xs: X[], ys: Y[]) => [X, Y][];
|
|
51
|
-
/** @type { <T extends Record<string, ERef<any>>>(obj: T) => Promise<{ [K in keyof T]: Awaited<T[K]>}> } */
|
|
52
|
-
export const allValues: <T extends Record<string, any>>(obj: T) => Promise<{ [K in keyof T]: Awaited<T[K]>; }>;
|
|
53
|
-
export function synchronizedTee<T = unknown>(sourceStream: AsyncIterator<T, void, void>, readerCount: number): AsyncGenerator<T, void, void>[];
|
|
54
44
|
/**
|
|
55
|
-
* <T
|
|
45
|
+
* @type {<T extends Record<string, ERef<any>>>(
|
|
46
|
+
* obj: T,
|
|
47
|
+
* ) => Promise<{ [K in keyof T]: Awaited<T[K]> }>}
|
|
56
48
|
*/
|
|
57
|
-
export
|
|
49
|
+
export const allValues: <T extends Record<string, ERef<any>>>(obj: T) => Promise<{ [K in keyof T]: Awaited<T[K]>; }>;
|
|
50
|
+
export function synchronizedTee<T = unknown>(sourceStream: AsyncIterator<T, void, void>, readerCount: number): AsyncGenerator<T, void, void>[];
|
|
58
51
|
/**
|
|
59
|
-
* flatten the
|
|
60
|
-
*
|
|
52
|
+
* flatten the
|
|
53
|
+
* type output to improve type hints shown in editors
|
|
54
|
+
* https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.ts
|
|
61
55
|
*/
|
|
62
|
-
export type Simplify<T> = { [
|
|
56
|
+
export type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
|
|
63
57
|
export type Callable = (...args: any[]) => any;
|
|
64
58
|
export type DeeplyAwaitedObject<T extends {}> = { [K in keyof T]: T[K] extends Callable ? T[K] : DeeplyAwaited<T[K]>; };
|
|
65
59
|
export type DeeplyAwaited<T> = T extends PromiseLike<any> ? Awaited<T> : T extends {} ? Simplify<DeeplyAwaitedObject<T>> : Awaited<T>;
|
|
66
60
|
export type AllDefined<T extends Record<string, unknown>> = { [P in keyof T]: Exclude<T[P], undefined>; };
|
|
61
|
+
import type { ERef } from '@endo/far';
|
|
67
62
|
//# sourceMappingURL=utils.d.ts.map
|
package/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["utils.js"],"names":[],"mappings":"AAYA,kCAAoC;AAEpC,sCAAsC;AAEtC;;;;;GAKG;AAEH;;GAEG;AAEH;;;;;GAKG;AAEH;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,oCAFU,CAAC,CAAY,SAAF,EAAE,EAAE,gBAAgB,EAAE,CAAC,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAKxE;AAYK,wDALI,cAAc,YAAY,EAAE,WAAW,CAAC,GAAG,GACzC,CAAC,CAAC,EACd,EAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KACjB,OAAO,CAAC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAW/C;AAgBM,iCALgC,CAAC,SAA1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE,OAC3B,CAAC,GACC,QAAQ,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAaxC;AAQD,+CAAoD;AAS7C,0BANM,CAAC,WACH,MAAM,CAAC,GAGL,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAYlC;AASG,0BANM,CAAC,WACH,MAAM,CAAC,GAGL,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAelC;AAEJ,mDAAmD;AACnD,kBADW,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CACsB;AAErE;;;;GAIG;AACH,wBAJU,CAAC,CAAmC,SAAzB,MAAM,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,EAC7C,GAAO,EAAE,CAAC,KACH,OAAO,CAAC,GAAG,CAAY,IAAP,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAE,CAAC,CAMhD;AAWK,gCAJO,CAAC,0BACJ,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,eAC5B,MAAM,mCAwGhB;;;;;;qBAnQY,CAAC,IACD,GAAG,OAAkB,IAAP,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAE,GAAG,EAAE;uBAMzC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;gCAIlB,CAAC,SAAN,EAAI,IACJ,GACP,CAAY,IAAP,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACnE;0BAIS,CAAC,IACD,CAAC,SAAS,WAAW,CAAC,GAAG,CAAC,GAC9B,OAAO,CAAC,CAAC,CAAC,GACV,CAAC,SAAS,EAAE,GACV,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,GAChC,OAAO,CAAC,CAAC,CAAC;uBAqCkB,CAAC,SAA1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE,IACzB,GAAG,CAAY,IAAP,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAE;0BAhEjC,WAAW"}
|