@icp-sdk/core 5.0.0-beta.2 → 5.1.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/lib/cjs/agent/actor.d.ts +15 -1
- package/lib/cjs/agent/actor.d.ts.map +1 -1
- package/lib/cjs/agent/actor.js +37 -91
- package/lib/cjs/agent/actor.js.map +1 -1
- package/lib/cjs/agent/agent/api.d.ts +29 -6
- package/lib/cjs/agent/agent/api.d.ts.map +1 -1
- package/lib/cjs/agent/agent/api.js.map +1 -1
- package/lib/cjs/agent/agent/http/expiry.d.ts +36 -0
- package/lib/cjs/agent/agent/http/expiry.d.ts.map +1 -0
- package/lib/cjs/agent/agent/http/expiry.js +92 -0
- package/lib/cjs/agent/agent/http/expiry.js.map +1 -0
- package/lib/cjs/agent/agent/http/index.d.ts +11 -2
- package/lib/cjs/agent/agent/http/index.d.ts.map +1 -1
- package/lib/cjs/agent/agent/http/index.js +142 -73
- package/lib/cjs/agent/agent/http/index.js.map +1 -1
- package/lib/cjs/agent/agent/http/transforms.d.ts +1 -35
- package/lib/cjs/agent/agent/http/transforms.d.ts.map +1 -1
- package/lib/cjs/agent/agent/http/transforms.js +6 -90
- package/lib/cjs/agent/agent/http/transforms.js.map +1 -1
- package/lib/cjs/agent/agent/http/types.d.ts +1 -1
- package/lib/cjs/agent/agent/http/types.d.ts.map +1 -1
- package/lib/cjs/agent/auth.d.ts +1 -1
- package/lib/cjs/agent/auth.d.ts.map +1 -1
- package/lib/cjs/agent/canisterStatus/index.d.ts +5 -4
- package/lib/cjs/agent/canisterStatus/index.d.ts.map +1 -1
- package/lib/cjs/agent/canisterStatus/index.js +6 -10
- package/lib/cjs/agent/canisterStatus/index.js.map +1 -1
- package/lib/cjs/agent/cbor.js +2 -2
- package/lib/cjs/agent/cbor.js.map +1 -1
- package/lib/cjs/agent/certificate.d.ts +4 -4
- package/lib/cjs/agent/certificate.d.ts.map +1 -1
- package/lib/cjs/agent/certificate.js +6 -10
- package/lib/cjs/agent/certificate.js.map +1 -1
- package/lib/cjs/agent/constants.d.ts +4 -4
- package/lib/cjs/agent/constants.d.ts.map +1 -1
- package/lib/cjs/agent/der.d.ts.map +1 -1
- package/lib/cjs/agent/der.js +26 -21
- package/lib/cjs/agent/der.js.map +1 -1
- package/lib/cjs/agent/errors.d.ts +27 -18
- package/lib/cjs/agent/errors.d.ts.map +1 -1
- package/lib/cjs/agent/errors.js +18 -15
- package/lib/cjs/agent/errors.js.map +1 -1
- package/lib/cjs/agent/observable.d.ts +1 -1
- package/lib/cjs/agent/observable.d.ts.map +1 -1
- package/lib/cjs/agent/polling/backoff.d.ts +7 -7
- package/lib/cjs/agent/polling/backoff.d.ts.map +1 -1
- package/lib/cjs/agent/polling/backoff.js +3 -5
- package/lib/cjs/agent/polling/backoff.js.map +1 -1
- package/lib/cjs/agent/polling/index.d.ts +11 -10
- package/lib/cjs/agent/polling/index.d.ts.map +1 -1
- package/lib/cjs/agent/polling/index.js +8 -6
- package/lib/cjs/agent/polling/index.js.map +1 -1
- package/lib/cjs/agent/polling/strategy.d.ts +2 -5
- package/lib/cjs/agent/polling/strategy.d.ts.map +1 -1
- package/lib/cjs/agent/polling/strategy.js.map +1 -1
- package/lib/cjs/agent/polling/types.d.ts +18 -0
- package/lib/cjs/agent/polling/types.d.ts.map +1 -0
- package/lib/cjs/agent/polling/types.js +3 -0
- package/lib/cjs/agent/polling/types.js.map +1 -0
- package/lib/cjs/agent/public_key.d.ts +1 -1
- package/lib/cjs/agent/public_key.d.ts.map +1 -1
- package/lib/cjs/agent/request_id.d.ts.map +1 -1
- package/lib/cjs/agent/request_id.js +7 -7
- package/lib/cjs/agent/request_id.js.map +1 -1
- package/lib/cjs/agent/subnetStatus/index.d.ts +5 -4
- package/lib/cjs/agent/subnetStatus/index.d.ts.map +1 -1
- package/lib/cjs/agent/subnetStatus/index.js +6 -10
- package/lib/cjs/agent/subnetStatus/index.js.map +1 -1
- package/lib/cjs/agent/utils/buffer.d.ts.map +1 -1
- package/lib/cjs/agent/utils/buffer.js +4 -2
- package/lib/cjs/agent/utils/buffer.js.map +1 -1
- package/lib/cjs/agent/utils/certificateReject.d.ts +11 -0
- package/lib/cjs/agent/utils/certificateReject.d.ts.map +1 -0
- package/lib/cjs/agent/utils/certificateReject.js +19 -0
- package/lib/cjs/agent/utils/certificateReject.js.map +1 -0
- package/lib/cjs/agent/utils/expirableMap.d.ts +4 -4
- package/lib/cjs/agent/utils/expirableMap.d.ts.map +1 -1
- package/lib/cjs/agent/utils/expirableMap.js +2 -2
- package/lib/cjs/agent/utils/readState.d.ts +3 -3
- package/lib/cjs/agent/utils/readState.d.ts.map +1 -1
- package/lib/cjs/candid/candid-core.d.ts +1 -1
- package/lib/cjs/candid/candid-core.d.ts.map +1 -1
- package/lib/cjs/candid/candid-core.js +7 -9
- package/lib/cjs/candid/candid-core.js.map +1 -1
- package/lib/cjs/candid/candid-ui.d.ts.map +1 -1
- package/lib/cjs/candid/candid-ui.js +8 -24
- package/lib/cjs/candid/candid-ui.js.map +1 -1
- package/lib/cjs/candid/idl.d.ts +14 -1
- package/lib/cjs/candid/idl.d.ts.map +1 -1
- package/lib/cjs/candid/idl.js +164 -125
- package/lib/cjs/candid/idl.js.map +1 -1
- package/lib/cjs/candid/utils/leb128.d.ts.map +1 -1
- package/lib/cjs/candid/utils/leb128.js +1 -3
- package/lib/cjs/candid/utils/leb128.js.map +1 -1
- package/lib/cjs/identity/identity/delegation.d.ts +4 -3
- package/lib/cjs/identity/identity/delegation.d.ts.map +1 -1
- package/lib/cjs/identity/identity/delegation.js +3 -3
- package/lib/cjs/identity/identity/delegation.js.map +1 -1
- package/lib/cjs/identity/identity/ecdsa.d.ts +2 -2
- package/lib/cjs/identity/identity/ecdsa.d.ts.map +1 -1
- package/lib/cjs/identity/identity/ecdsa.js +2 -4
- package/lib/cjs/identity/identity/ecdsa.js.map +1 -1
- package/lib/cjs/identity/identity/ed25519.d.ts.map +1 -1
- package/lib/cjs/identity/identity/ed25519.js +9 -10
- package/lib/cjs/identity/identity/ed25519.js.map +1 -1
- package/lib/cjs/identity/identity/partial.d.ts +1 -1
- package/lib/cjs/identity/identity/partial.d.ts.map +1 -1
- package/lib/cjs/identity/identity/webauthn.js +4 -5
- package/lib/cjs/identity/identity/webauthn.js.map +1 -1
- package/lib/cjs/identity/secp256k1/der.d.ts.map +1 -1
- package/lib/cjs/identity/secp256k1/der.js +27 -22
- package/lib/cjs/identity/secp256k1/der.js.map +1 -1
- package/lib/cjs/identity/secp256k1/pem.js +1 -1
- package/lib/cjs/identity/secp256k1/pem.js.map +1 -1
- package/lib/cjs/identity/secp256k1/secp256k1.d.ts.map +1 -1
- package/lib/cjs/identity/secp256k1/secp256k1.js +6 -6
- package/lib/cjs/identity/secp256k1/secp256k1.js.map +1 -1
- package/lib/cjs/principal/principal.d.ts +2 -2
- package/lib/cjs/principal/principal.d.ts.map +1 -1
- package/lib/cjs/principal/principal.js +10 -6
- package/lib/cjs/principal/principal.js.map +1 -1
- package/lib/esm/agent/actor.d.ts +15 -1
- package/lib/esm/agent/actor.d.ts.map +1 -1
- package/lib/esm/agent/actor.js +40 -94
- package/lib/esm/agent/actor.js.map +1 -1
- package/lib/esm/agent/agent/api.d.ts +29 -6
- package/lib/esm/agent/agent/api.d.ts.map +1 -1
- package/lib/esm/agent/agent/api.js.map +1 -1
- package/lib/esm/agent/agent/http/expiry.d.ts +36 -0
- package/lib/esm/agent/agent/http/expiry.d.ts.map +1 -0
- package/lib/esm/agent/agent/http/expiry.js +88 -0
- package/lib/esm/agent/agent/http/expiry.js.map +1 -0
- package/lib/esm/agent/agent/http/index.d.ts +11 -2
- package/lib/esm/agent/agent/http/index.d.ts.map +1 -1
- package/lib/esm/agent/agent/http/index.js +145 -76
- package/lib/esm/agent/agent/http/index.js.map +1 -1
- package/lib/esm/agent/agent/http/transforms.d.ts +1 -35
- package/lib/esm/agent/agent/http/transforms.d.ts.map +1 -1
- package/lib/esm/agent/agent/http/transforms.js +2 -87
- package/lib/esm/agent/agent/http/transforms.js.map +1 -1
- package/lib/esm/agent/agent/http/types.d.ts +1 -1
- package/lib/esm/agent/agent/http/types.d.ts.map +1 -1
- package/lib/esm/agent/auth.d.ts +1 -1
- package/lib/esm/agent/auth.d.ts.map +1 -1
- package/lib/esm/agent/canister-env/index.d.ts +2 -2
- package/lib/esm/agent/canister-env/index.d.ts.map +1 -1
- package/lib/esm/agent/canisterStatus/index.d.ts +5 -4
- package/lib/esm/agent/canisterStatus/index.d.ts.map +1 -1
- package/lib/esm/agent/canisterStatus/index.js +6 -10
- package/lib/esm/agent/canisterStatus/index.js.map +1 -1
- package/lib/esm/agent/cbor.js +1 -1
- package/lib/esm/agent/cbor.js.map +1 -1
- package/lib/esm/agent/certificate.d.ts +4 -4
- package/lib/esm/agent/certificate.d.ts.map +1 -1
- package/lib/esm/agent/certificate.js +6 -10
- package/lib/esm/agent/certificate.js.map +1 -1
- package/lib/esm/agent/constants.d.ts +4 -4
- package/lib/esm/agent/constants.d.ts.map +1 -1
- package/lib/esm/agent/der.d.ts.map +1 -1
- package/lib/esm/agent/der.js +26 -21
- package/lib/esm/agent/der.js.map +1 -1
- package/lib/esm/agent/errors.d.ts +27 -18
- package/lib/esm/agent/errors.d.ts.map +1 -1
- package/lib/esm/agent/errors.js +16 -13
- package/lib/esm/agent/errors.js.map +1 -1
- package/lib/esm/agent/observable.d.ts +1 -1
- package/lib/esm/agent/observable.d.ts.map +1 -1
- package/lib/esm/agent/polling/backoff.d.ts +7 -7
- package/lib/esm/agent/polling/backoff.d.ts.map +1 -1
- package/lib/esm/agent/polling/backoff.js +3 -5
- package/lib/esm/agent/polling/backoff.js.map +1 -1
- package/lib/esm/agent/polling/index.d.ts +11 -10
- package/lib/esm/agent/polling/index.d.ts.map +1 -1
- package/lib/esm/agent/polling/index.js +9 -7
- package/lib/esm/agent/polling/index.js.map +1 -1
- package/lib/esm/agent/polling/strategy.d.ts +2 -5
- package/lib/esm/agent/polling/strategy.d.ts.map +1 -1
- package/lib/esm/agent/polling/strategy.js.map +1 -1
- package/lib/esm/agent/polling/types.d.ts +18 -0
- package/lib/esm/agent/polling/types.d.ts.map +1 -0
- package/lib/esm/agent/polling/types.js +2 -0
- package/lib/esm/agent/polling/types.js.map +1 -0
- package/lib/esm/agent/public_key.d.ts +1 -1
- package/lib/esm/agent/public_key.d.ts.map +1 -1
- package/lib/esm/agent/request_id.d.ts.map +1 -1
- package/lib/esm/agent/request_id.js +7 -7
- package/lib/esm/agent/request_id.js.map +1 -1
- package/lib/esm/agent/subnetStatus/index.d.ts +5 -4
- package/lib/esm/agent/subnetStatus/index.d.ts.map +1 -1
- package/lib/esm/agent/subnetStatus/index.js +6 -10
- package/lib/esm/agent/subnetStatus/index.js.map +1 -1
- package/lib/esm/agent/utils/buffer.d.ts.map +1 -1
- package/lib/esm/agent/utils/buffer.js +4 -2
- package/lib/esm/agent/utils/buffer.js.map +1 -1
- package/lib/esm/agent/utils/certificateReject.d.ts +11 -0
- package/lib/esm/agent/utils/certificateReject.d.ts.map +1 -0
- package/lib/esm/agent/utils/certificateReject.js +16 -0
- package/lib/esm/agent/utils/certificateReject.js.map +1 -0
- package/lib/esm/agent/utils/expirableMap.d.ts +4 -4
- package/lib/esm/agent/utils/expirableMap.d.ts.map +1 -1
- package/lib/esm/agent/utils/expirableMap.js +2 -2
- package/lib/esm/agent/utils/readState.d.ts +3 -3
- package/lib/esm/agent/utils/readState.d.ts.map +1 -1
- package/lib/esm/candid/candid-core.d.ts +1 -1
- package/lib/esm/candid/candid-core.d.ts.map +1 -1
- package/lib/esm/candid/candid-core.js +7 -9
- package/lib/esm/candid/candid-core.js.map +1 -1
- package/lib/esm/candid/candid-ui.d.ts.map +1 -1
- package/lib/esm/candid/candid-ui.js +7 -23
- package/lib/esm/candid/candid-ui.js.map +1 -1
- package/lib/esm/candid/idl.d.ts +14 -1
- package/lib/esm/candid/idl.d.ts.map +1 -1
- package/lib/esm/candid/idl.js +162 -124
- package/lib/esm/candid/idl.js.map +1 -1
- package/lib/esm/candid/utils/leb128.d.ts.map +1 -1
- package/lib/esm/candid/utils/leb128.js +1 -3
- package/lib/esm/candid/utils/leb128.js.map +1 -1
- package/lib/esm/identity/identity/delegation.d.ts +4 -3
- package/lib/esm/identity/identity/delegation.d.ts.map +1 -1
- package/lib/esm/identity/identity/delegation.js +3 -3
- package/lib/esm/identity/identity/delegation.js.map +1 -1
- package/lib/esm/identity/identity/ecdsa.d.ts +2 -2
- package/lib/esm/identity/identity/ecdsa.d.ts.map +1 -1
- package/lib/esm/identity/identity/ecdsa.js +2 -4
- package/lib/esm/identity/identity/ecdsa.js.map +1 -1
- package/lib/esm/identity/identity/ed25519.d.ts.map +1 -1
- package/lib/esm/identity/identity/ed25519.js +9 -10
- package/lib/esm/identity/identity/ed25519.js.map +1 -1
- package/lib/esm/identity/identity/partial.d.ts +1 -1
- package/lib/esm/identity/identity/partial.d.ts.map +1 -1
- package/lib/esm/identity/identity/webauthn.js +4 -5
- package/lib/esm/identity/identity/webauthn.js.map +1 -1
- package/lib/esm/identity/secp256k1/der.d.ts.map +1 -1
- package/lib/esm/identity/secp256k1/der.js +27 -22
- package/lib/esm/identity/secp256k1/der.js.map +1 -1
- package/lib/esm/identity/secp256k1/pem.js +1 -1
- package/lib/esm/identity/secp256k1/pem.js.map +1 -1
- package/lib/esm/identity/secp256k1/secp256k1.d.ts.map +1 -1
- package/lib/esm/identity/secp256k1/secp256k1.js +6 -6
- package/lib/esm/identity/secp256k1/secp256k1.js.map +1 -1
- package/lib/esm/principal/principal.d.ts +2 -2
- package/lib/esm/principal/principal.d.ts.map +1 -1
- package/lib/esm/principal/principal.js +10 -6
- package/lib/esm/principal/principal.js.map +1 -1
- package/package.json +13 -13
- package/src/agent/actor.ts +74 -126
- package/src/agent/agent/api.ts +36 -6
- package/src/agent/agent/http/expiry.ts +107 -0
- package/src/agent/agent/http/index.ts +217 -90
- package/src/agent/agent/http/transforms.ts +2 -106
- package/src/agent/agent/http/types.ts +1 -1
- package/src/agent/auth.ts +1 -1
- package/src/agent/canister-env/index.ts +2 -2
- package/src/agent/canisterStatus/index.ts +10 -12
- package/src/agent/cbor.ts +1 -1
- package/src/agent/certificate.ts +11 -13
- package/src/agent/der.ts +40 -19
- package/src/agent/errors.ts +41 -31
- package/src/agent/fetch_candid.ts +1 -1
- package/src/agent/observable.ts +1 -1
- package/src/agent/polling/backoff.ts +9 -10
- package/src/agent/polling/index.ts +14 -26
- package/src/agent/polling/strategy.ts +5 -9
- package/src/agent/polling/types.ts +28 -0
- package/src/agent/public_key.ts +1 -1
- package/src/agent/request_id.ts +15 -8
- package/src/agent/subnetStatus/index.ts +10 -12
- package/src/agent/utils/buffer.ts +6 -2
- package/src/agent/utils/certificateReject.ts +25 -0
- package/src/agent/utils/expirableMap.ts +4 -4
- package/src/agent/utils/random.ts +2 -2
- package/src/agent/utils/readState.ts +3 -3
- package/src/candid/candid-core.ts +9 -11
- package/src/candid/candid-ui.ts +8 -16
- package/src/candid/idl.ts +210 -112
- package/src/candid/utils/leb128.ts +1 -2
- package/src/identity/identity/delegation.ts +5 -5
- package/src/identity/identity/ecdsa.ts +12 -8
- package/src/identity/identity/ed25519.ts +16 -9
- package/src/identity/identity/partial.ts +1 -1
- package/src/identity/identity/webauthn.ts +21 -21
- package/src/identity/secp256k1/der.ts +41 -20
- package/src/identity/secp256k1/pem.ts +1 -1
- package/src/identity/secp256k1/secp256k1.ts +12 -6
- package/src/principal/principal.ts +18 -8
- package/LICENSE +0 -201
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
ProtocolError,
|
|
11
11
|
LookupErrorCode,
|
|
12
12
|
} from '../errors.ts';
|
|
13
|
-
import { HttpAgent } from '../agent/http/index.ts';
|
|
13
|
+
import type { HttpAgent } from '../agent/http/index.ts';
|
|
14
14
|
import {
|
|
15
15
|
type Cert,
|
|
16
16
|
type CanisterRanges,
|
|
@@ -23,11 +23,11 @@ import {
|
|
|
23
23
|
import * as cbor from '../cbor.ts';
|
|
24
24
|
import { decodeTime } from '../utils/leb.ts';
|
|
25
25
|
import { utf8ToBytes } from '@noble/hashes/utils';
|
|
26
|
+
import type { CustomPath } from '../utils/readState.ts';
|
|
26
27
|
import {
|
|
27
28
|
type BaseStatus,
|
|
28
29
|
type BaseSubnetStatus,
|
|
29
30
|
type SubnetNodeKeys,
|
|
30
|
-
CustomPath,
|
|
31
31
|
decodeValue,
|
|
32
32
|
isCustomPath,
|
|
33
33
|
lookupNodeKeysFromCertificate,
|
|
@@ -53,7 +53,7 @@ export type Path = 'time' | 'canisterRanges' | 'publicKey' | 'nodeKeys' | Custom
|
|
|
53
53
|
|
|
54
54
|
export type StatusMap = Map<Path | string, Status>;
|
|
55
55
|
|
|
56
|
-
export
|
|
56
|
+
export interface SubnetStatusOptions {
|
|
57
57
|
/**
|
|
58
58
|
* The subnet ID to query. Use {@link IC_ROOT_SUBNET_ID} for the IC mainnet root subnet.
|
|
59
59
|
* You can use {@link HttpAgent.getSubnetIdFromCanister} to get a subnet ID from a canister.
|
|
@@ -73,7 +73,7 @@ export type SubnetStatusOptions = {
|
|
|
73
73
|
* @default false
|
|
74
74
|
*/
|
|
75
75
|
disableCertificateTimeVerification?: boolean;
|
|
76
|
-
}
|
|
76
|
+
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Requests information from a subnet's `read_state` endpoint.
|
|
@@ -129,12 +129,11 @@ export async function request(options: SubnetStatusOptions): Promise<StatusMap>
|
|
|
129
129
|
path: lookupPath,
|
|
130
130
|
data,
|
|
131
131
|
};
|
|
132
|
-
} else {
|
|
133
|
-
return {
|
|
134
|
-
path: lookupPath,
|
|
135
|
-
data: lookupResultToBuffer(cert.lookup_path(encodedPath)),
|
|
136
|
-
};
|
|
137
132
|
}
|
|
133
|
+
return {
|
|
134
|
+
path: lookupPath,
|
|
135
|
+
data: lookupResultToBuffer(cert.lookup_path(encodedPath)),
|
|
136
|
+
};
|
|
138
137
|
};
|
|
139
138
|
|
|
140
139
|
const { path, data } = lookup(certificate, uniquePaths[index]);
|
|
@@ -250,10 +249,9 @@ export function encodePath(path: Path, subnetId: Principal): Uint8Array[] {
|
|
|
250
249
|
const encoded =
|
|
251
250
|
typeof path['path'] === 'string' ? utf8ToBytes(path['path']) : path['path'];
|
|
252
251
|
return [utf8ToBytes('subnet'), subnetUint8Array, encoded];
|
|
253
|
-
} else {
|
|
254
|
-
// For non-simple paths, return the provided custom path
|
|
255
|
-
return path['path'];
|
|
256
252
|
}
|
|
253
|
+
// For non-simple paths, return the provided custom path
|
|
254
|
+
return path['path'];
|
|
257
255
|
}
|
|
258
256
|
}
|
|
259
257
|
}
|
|
@@ -52,9 +52,13 @@ export function uint8ToBuf(arr: Uint8Array): ArrayBuffer {
|
|
|
52
52
|
* @returns True if the Uint8Arrays are equal, false otherwise.
|
|
53
53
|
*/
|
|
54
54
|
export function uint8Equals(a: Uint8Array, b: Uint8Array): boolean {
|
|
55
|
-
if (a.length !== b.length)
|
|
55
|
+
if (a.length !== b.length) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
56
58
|
for (let i = 0; i < a.length; i++) {
|
|
57
|
-
if (a[i] !== b[i])
|
|
59
|
+
if (a[i] !== b[i]) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
58
62
|
}
|
|
59
63
|
return true;
|
|
60
64
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Certificate, type NodePath, lookupResultToBuffer } from '../certificate.ts';
|
|
2
|
+
import { CertifiedRejectErrorCode } from '../errors.ts';
|
|
3
|
+
import type { RequestId } from '../request_id.ts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Read certified reject details from a certificate at the given request status path.
|
|
7
|
+
* @param certificate The certificate to read reject details from.
|
|
8
|
+
* @param path The lookup path prefix (e.g. `['request_status', requestId]`).
|
|
9
|
+
* @param requestId The request ID associated with the rejection.
|
|
10
|
+
*/
|
|
11
|
+
export function readCertifiedReject(
|
|
12
|
+
certificate: Certificate,
|
|
13
|
+
path: NodePath,
|
|
14
|
+
requestId: RequestId,
|
|
15
|
+
): CertifiedRejectErrorCode {
|
|
16
|
+
const rejectCode = new Uint8Array(
|
|
17
|
+
lookupResultToBuffer(certificate.lookup_path([...path, 'reject_code']))!,
|
|
18
|
+
)[0];
|
|
19
|
+
const rejectMessage = new TextDecoder().decode(
|
|
20
|
+
lookupResultToBuffer(certificate.lookup_path([...path, 'reject_message']))!,
|
|
21
|
+
);
|
|
22
|
+
const errorCodeBuf = lookupResultToBuffer(certificate.lookup_path([...path, 'error_code']));
|
|
23
|
+
const errorCode = errorCodeBuf ? new TextDecoder().decode(errorCodeBuf) : undefined;
|
|
24
|
+
return new CertifiedRejectErrorCode(requestId, rejectCode, rejectMessage, errorCode);
|
|
25
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ExpirableMapOptions<K, V> {
|
|
2
2
|
source?: Iterable<[K, V]>;
|
|
3
3
|
expirationTime?: number;
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A map that expires entries after a given time.
|
|
@@ -17,8 +17,8 @@ export class ExpirableMap<K, V> implements Map<K, V> {
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new ExpirableMap.
|
|
20
|
-
* @param {ExpirableMapOptions<
|
|
21
|
-
* @param {Iterable<[
|
|
20
|
+
* @param {ExpirableMapOptions<K, V>} options - options for the map.
|
|
21
|
+
* @param {Iterable<[K, V]>} options.source - an optional source of entries to initialize the map with.
|
|
22
22
|
* @param {number} options.expirationTime - the time in milliseconds after which entries will expire.
|
|
23
23
|
*/
|
|
24
24
|
constructor(options: ExpirableMapOptions<K, V> = {}) {
|
|
@@ -16,9 +16,9 @@ export const randomNumber = (): number => {
|
|
|
16
16
|
return array[0];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
interface nodeCrypto {
|
|
20
20
|
randomInt: (min: number, max: number) => number;
|
|
21
|
-
}
|
|
21
|
+
}
|
|
22
22
|
|
|
23
23
|
// determine whether node crypto is available
|
|
24
24
|
if (typeof crypto !== 'undefined' && (crypto as unknown as nodeCrypto).randomInt) {
|
|
@@ -2,7 +2,7 @@ import { Principal } from '#principal';
|
|
|
2
2
|
import * as cbor from '../cbor.ts';
|
|
3
3
|
import { decodeLeb128 } from '../utils/leb.ts';
|
|
4
4
|
import { bytesToHex, utf8ToBytes } from '@noble/hashes/utils';
|
|
5
|
-
import {
|
|
5
|
+
import type { DerEncodedPublicKey } from '../auth.ts';
|
|
6
6
|
import {
|
|
7
7
|
type Cert,
|
|
8
8
|
flatten_forks,
|
|
@@ -32,7 +32,7 @@ export type SubnetNodeKeys = Map<string, DerEncodedPublicKey>;
|
|
|
32
32
|
/**
|
|
33
33
|
* Represents the useful information about a subnet
|
|
34
34
|
*/
|
|
35
|
-
export
|
|
35
|
+
export interface BaseSubnetStatus {
|
|
36
36
|
/**
|
|
37
37
|
* The subnet ID
|
|
38
38
|
*/
|
|
@@ -45,7 +45,7 @@ export type BaseSubnetStatus = {
|
|
|
45
45
|
* Not supported
|
|
46
46
|
*/
|
|
47
47
|
metrics?: never;
|
|
48
|
-
}
|
|
48
|
+
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Base types of an entry on the status map.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-this-alias */
|
|
3
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
-
import * as IDL from './idl.ts';
|
|
3
|
+
import type * as IDL from './idl.ts';
|
|
5
4
|
|
|
6
5
|
export interface ParseConfig {
|
|
7
6
|
random?: boolean;
|
|
@@ -71,7 +70,7 @@ export class InputBox {
|
|
|
71
70
|
} catch (err) {
|
|
72
71
|
input.classList.add('reject');
|
|
73
72
|
this.status.style.display = 'block';
|
|
74
|
-
this.status.innerHTML =
|
|
73
|
+
this.status.innerHTML = `InputError: ${(err as Error).message}`;
|
|
75
74
|
this.value = undefined;
|
|
76
75
|
return undefined;
|
|
77
76
|
}
|
|
@@ -149,9 +148,9 @@ export class RecordForm extends InputForm {
|
|
|
149
148
|
const input = this.ui.render(type);
|
|
150
149
|
// eslint-disable-next-line
|
|
151
150
|
if (this.ui.labelMap && this.ui.labelMap.hasOwnProperty(key)) {
|
|
152
|
-
input.label = this.ui.labelMap[key]
|
|
151
|
+
input.label = `${this.ui.labelMap[key]} `;
|
|
153
152
|
} else {
|
|
154
|
-
input.label = key
|
|
153
|
+
input.label = `${key} `;
|
|
155
154
|
}
|
|
156
155
|
return input;
|
|
157
156
|
});
|
|
@@ -239,13 +238,12 @@ export class OptionForm extends InputForm {
|
|
|
239
238
|
public parse<T>(config: ParseConfig): [T] | [] | undefined {
|
|
240
239
|
if (this.form.length === 0) {
|
|
241
240
|
return [];
|
|
242
|
-
} else {
|
|
243
|
-
const value = this.form[0].parse(config);
|
|
244
|
-
if (value === undefined) {
|
|
245
|
-
return undefined;
|
|
246
|
-
}
|
|
247
|
-
return [value];
|
|
248
241
|
}
|
|
242
|
+
const value = this.form[0].parse(config);
|
|
243
|
+
if (value === undefined) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
return [value];
|
|
249
247
|
}
|
|
250
248
|
}
|
|
251
249
|
|
package/src/candid/candid-ui.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import * as IDL from './idl.ts';
|
|
4
4
|
import { Principal } from '#principal';
|
|
5
5
|
import * as UI from './candid-core.ts';
|
|
@@ -121,16 +121,14 @@ class Parse extends IDL.Visitor<string, any> {
|
|
|
121
121
|
public visitFixedInt(t: IDL.FixedIntClass, v: string): number | bigint {
|
|
122
122
|
if (t._bits <= 32) {
|
|
123
123
|
return parseInt(v, 10);
|
|
124
|
-
} else {
|
|
125
|
-
return BigInt(v);
|
|
126
124
|
}
|
|
125
|
+
return BigInt(v);
|
|
127
126
|
}
|
|
128
127
|
public visitFixedNat(t: IDL.FixedNatClass, v: string): number | bigint {
|
|
129
128
|
if (t._bits <= 32) {
|
|
130
129
|
return parseInt(v, 10);
|
|
131
|
-
} else {
|
|
132
|
-
return BigInt(v);
|
|
133
130
|
}
|
|
131
|
+
return BigInt(v);
|
|
134
132
|
}
|
|
135
133
|
public visitNumber(_t: IDL.PrimitiveType, v: string): bigint {
|
|
136
134
|
return BigInt(v);
|
|
@@ -170,34 +168,30 @@ class Random extends IDL.Visitor<string, any> {
|
|
|
170
168
|
const x = this.generateNumber(true);
|
|
171
169
|
if (t._bits <= 32) {
|
|
172
170
|
return x;
|
|
173
|
-
} else {
|
|
174
|
-
return BigInt(v);
|
|
175
171
|
}
|
|
172
|
+
return BigInt(v);
|
|
176
173
|
}
|
|
177
174
|
public visitFixedNat(t: IDL.FixedNatClass, v: string): number | bigint {
|
|
178
175
|
const x = this.generateNumber(false);
|
|
179
176
|
if (t._bits <= 32) {
|
|
180
177
|
return x;
|
|
181
|
-
} else {
|
|
182
|
-
return BigInt(v);
|
|
183
178
|
}
|
|
179
|
+
return BigInt(v);
|
|
184
180
|
}
|
|
185
181
|
private generateNumber(signed: boolean): number {
|
|
186
182
|
const num = Math.floor(Math.random() * 100);
|
|
187
183
|
if (signed && Math.random() < 0.5) {
|
|
188
184
|
return -num;
|
|
189
|
-
} else {
|
|
190
|
-
return num;
|
|
191
185
|
}
|
|
186
|
+
return num;
|
|
192
187
|
}
|
|
193
188
|
}
|
|
194
189
|
|
|
195
190
|
function parsePrimitive(t: IDL.Type, config: UI.ParseConfig, d: string) {
|
|
196
191
|
if (config.random && d === '') {
|
|
197
192
|
return t.accept(new Random(), d);
|
|
198
|
-
} else {
|
|
199
|
-
return t.accept(new Parse(), d);
|
|
200
193
|
}
|
|
194
|
+
return t.accept(new Parse(), d);
|
|
201
195
|
}
|
|
202
196
|
|
|
203
197
|
/**
|
|
@@ -238,9 +232,7 @@ class RenderValue extends IDL.Visitor<ValueConfig, void> {
|
|
|
238
232
|
renderValue(ty, d.input, d.value);
|
|
239
233
|
}
|
|
240
234
|
public visitOpt<T>(_t: IDL.OptClass<T>, ty: IDL.Type<T>, d: ValueConfig): void {
|
|
241
|
-
if (d.value.length
|
|
242
|
-
return;
|
|
243
|
-
} else {
|
|
235
|
+
if (d.value.length !== 0) {
|
|
244
236
|
const form = d.input.ui.form!;
|
|
245
237
|
const open = form.ui.open as HTMLInputElement;
|
|
246
238
|
open.checked = true;
|