@icp-sdk/core 5.4.0 → 6.0.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 +7 -3
- package/lib/cjs/agent/actor.d.ts.map +1 -1
- package/lib/cjs/agent/actor.js +18 -5
- package/lib/cjs/agent/actor.js.map +1 -1
- package/lib/cjs/agent/agent/api.d.ts +19 -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/index.d.ts +8 -11
- package/lib/cjs/agent/agent/http/index.d.ts.map +1 -1
- package/lib/cjs/agent/agent/http/index.js +190 -166
- package/lib/cjs/agent/agent/http/index.js.map +1 -1
- package/lib/cjs/agent/auth.d.ts +6 -5
- package/lib/cjs/agent/auth.d.ts.map +1 -1
- package/lib/cjs/agent/auth.js +3 -3
- package/lib/cjs/agent/auth.js.map +1 -1
- package/lib/cjs/agent/canisterStatus/index.d.ts.map +1 -1
- package/lib/cjs/agent/canisterStatus/index.js +10 -10
- package/lib/cjs/agent/canisterStatus/index.js.map +1 -1
- package/lib/cjs/agent/cbor.d.ts +2 -1
- package/lib/cjs/agent/cbor.d.ts.map +1 -1
- package/lib/cjs/agent/cbor.js +4 -1
- package/lib/cjs/agent/cbor.js.map +1 -1
- package/lib/cjs/agent/certificate.d.ts +5 -4
- package/lib/cjs/agent/certificate.d.ts.map +1 -1
- package/lib/cjs/agent/certificate.js +14 -18
- package/lib/cjs/agent/certificate.js.map +1 -1
- package/lib/cjs/agent/der.d.ts +3 -2
- package/lib/cjs/agent/der.d.ts.map +1 -1
- package/lib/cjs/agent/der.js.map +1 -1
- package/lib/cjs/agent/errors.d.ts +7 -1
- package/lib/cjs/agent/errors.d.ts.map +1 -1
- package/lib/cjs/agent/errors.js +34 -16
- package/lib/cjs/agent/errors.js.map +1 -1
- package/lib/cjs/agent/polling/index.d.ts +3 -4
- package/lib/cjs/agent/polling/index.d.ts.map +1 -1
- package/lib/cjs/agent/polling/index.js +17 -10
- package/lib/cjs/agent/polling/index.js.map +1 -1
- package/lib/cjs/agent/polling/strategy.d.ts.map +1 -1
- package/lib/cjs/agent/polling/strategy.js +6 -6
- package/lib/cjs/agent/polling/strategy.js.map +1 -1
- package/lib/cjs/agent/polling/types.d.ts +3 -4
- package/lib/cjs/agent/polling/types.d.ts.map +1 -1
- package/lib/cjs/agent/public_key.d.ts +3 -2
- package/lib/cjs/agent/public_key.d.ts.map +1 -1
- package/lib/cjs/agent/public_key.js +2 -2
- package/lib/cjs/agent/public_key.js.map +1 -1
- package/lib/cjs/agent/request_id.js +10 -10
- package/lib/cjs/agent/request_id.js.map +1 -1
- package/lib/cjs/agent/subnetStatus/index.js +7 -7
- package/lib/cjs/agent/subnetStatus/index.js.map +1 -1
- package/lib/cjs/agent/utils/bls.d.ts.map +1 -1
- package/lib/cjs/agent/utils/bls.js +7 -6
- package/lib/cjs/agent/utils/bls.js.map +1 -1
- package/lib/cjs/agent/utils/readState.d.ts +2 -2
- package/lib/cjs/agent/utils/readState.d.ts.map +1 -1
- package/lib/cjs/agent/utils/readState.js +4 -4
- package/lib/cjs/agent/utils/readState.js.map +1 -1
- package/lib/cjs/agent/utils/target.d.ts +15 -0
- package/lib/cjs/agent/utils/target.d.ts.map +1 -0
- package/lib/cjs/agent/utils/target.js +27 -0
- package/lib/cjs/agent/utils/target.js.map +1 -0
- package/lib/cjs/candid/utils/buffer.d.ts +2 -1
- package/lib/cjs/candid/utils/buffer.d.ts.map +1 -1
- package/lib/cjs/candid/utils/buffer.js +5 -2
- package/lib/cjs/candid/utils/buffer.js.map +1 -1
- package/lib/cjs/identity/identity/delegation.d.ts +10 -3
- package/lib/cjs/identity/identity/delegation.d.ts.map +1 -1
- package/lib/cjs/identity/identity/delegation.js +25 -12
- 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 +3 -2
- package/lib/cjs/identity/identity/ecdsa.js.map +1 -1
- package/lib/cjs/identity/identity/ed25519.d.ts +3 -2
- package/lib/cjs/identity/identity/ed25519.d.ts.map +1 -1
- package/lib/cjs/identity/identity/ed25519.js +18 -15
- package/lib/cjs/identity/identity/ed25519.js.map +1 -1
- package/lib/cjs/identity/identity/webauthn.d.ts +4 -3
- package/lib/cjs/identity/identity/webauthn.d.ts.map +1 -1
- package/lib/cjs/identity/identity/webauthn.js +12 -11
- package/lib/cjs/identity/identity/webauthn.js.map +1 -1
- package/lib/cjs/identity/secp256k1/der.d.ts +2 -1
- package/lib/cjs/identity/secp256k1/der.d.ts.map +1 -1
- package/lib/cjs/identity/secp256k1/der.js.map +1 -1
- package/lib/cjs/identity/secp256k1/pem.d.ts +4 -3
- package/lib/cjs/identity/secp256k1/pem.d.ts.map +1 -1
- package/lib/cjs/identity/secp256k1/pem.js +2 -2
- package/lib/cjs/identity/secp256k1/pem.js.map +1 -1
- package/lib/cjs/identity/secp256k1/secp256k1.d.ts +5 -4
- package/lib/cjs/identity/secp256k1/secp256k1.d.ts.map +1 -1
- package/lib/cjs/identity/secp256k1/secp256k1.js +17 -20
- package/lib/cjs/identity/secp256k1/secp256k1.js.map +1 -1
- package/lib/cjs/principal/principal.js +5 -5
- package/lib/cjs/principal/principal.js.map +1 -1
- package/lib/esm/agent/actor.d.ts +7 -3
- package/lib/esm/agent/actor.d.ts.map +1 -1
- package/lib/esm/agent/actor.js +18 -5
- package/lib/esm/agent/actor.js.map +1 -1
- package/lib/esm/agent/agent/api.d.ts +19 -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/index.d.ts +8 -11
- package/lib/esm/agent/agent/http/index.d.ts.map +1 -1
- package/lib/esm/agent/agent/http/index.js +183 -159
- package/lib/esm/agent/agent/http/index.js.map +1 -1
- package/lib/esm/agent/auth.d.ts +6 -5
- package/lib/esm/agent/auth.d.ts.map +1 -1
- package/lib/esm/agent/auth.js +1 -1
- package/lib/esm/agent/auth.js.map +1 -1
- package/lib/esm/agent/canister-env/index.js +1 -1
- package/lib/esm/agent/canister-env/index.js.map +1 -1
- package/lib/esm/agent/canisterStatus/index.d.ts.map +1 -1
- package/lib/esm/agent/canisterStatus/index.js +2 -2
- package/lib/esm/agent/canisterStatus/index.js.map +1 -1
- package/lib/esm/agent/cbor.d.ts +2 -1
- package/lib/esm/agent/cbor.d.ts.map +1 -1
- package/lib/esm/agent/cbor.js +4 -1
- package/lib/esm/agent/cbor.js.map +1 -1
- package/lib/esm/agent/certificate.d.ts +5 -4
- package/lib/esm/agent/certificate.d.ts.map +1 -1
- package/lib/esm/agent/certificate.js +5 -9
- package/lib/esm/agent/certificate.js.map +1 -1
- package/lib/esm/agent/der.d.ts +3 -2
- package/lib/esm/agent/der.d.ts.map +1 -1
- package/lib/esm/agent/der.js.map +1 -1
- package/lib/esm/agent/errors.d.ts +7 -1
- package/lib/esm/agent/errors.d.ts.map +1 -1
- package/lib/esm/agent/errors.js +18 -1
- package/lib/esm/agent/errors.js.map +1 -1
- package/lib/esm/agent/polling/index.d.ts +3 -4
- package/lib/esm/agent/polling/index.d.ts.map +1 -1
- package/lib/esm/agent/polling/index.js +15 -8
- package/lib/esm/agent/polling/index.js.map +1 -1
- package/lib/esm/agent/polling/strategy.d.ts.map +1 -1
- package/lib/esm/agent/polling/strategy.js +6 -6
- package/lib/esm/agent/polling/strategy.js.map +1 -1
- package/lib/esm/agent/polling/types.d.ts +3 -4
- package/lib/esm/agent/polling/types.d.ts.map +1 -1
- package/lib/esm/agent/public_key.d.ts +3 -2
- package/lib/esm/agent/public_key.d.ts.map +1 -1
- package/lib/esm/agent/public_key.js +2 -2
- package/lib/esm/agent/public_key.js.map +1 -1
- package/lib/esm/agent/request_id.js +2 -2
- package/lib/esm/agent/request_id.js.map +1 -1
- package/lib/esm/agent/subnetStatus/index.js +1 -1
- package/lib/esm/agent/subnetStatus/index.js.map +1 -1
- package/lib/esm/agent/utils/bls.d.ts.map +1 -1
- package/lib/esm/agent/utils/bls.js +7 -6
- package/lib/esm/agent/utils/bls.js.map +1 -1
- package/lib/esm/agent/utils/readState.d.ts +2 -2
- package/lib/esm/agent/utils/readState.d.ts.map +1 -1
- package/lib/esm/agent/utils/readState.js +1 -1
- package/lib/esm/agent/utils/readState.js.map +1 -1
- package/lib/esm/agent/utils/target.d.ts +15 -0
- package/lib/esm/agent/utils/target.d.ts.map +1 -0
- package/lib/esm/agent/utils/target.js +23 -0
- package/lib/esm/agent/utils/target.js.map +1 -0
- package/lib/esm/candid/utils/buffer.d.ts +2 -1
- package/lib/esm/candid/utils/buffer.d.ts.map +1 -1
- package/lib/esm/candid/utils/buffer.js +5 -2
- package/lib/esm/candid/utils/buffer.js.map +1 -1
- package/lib/esm/identity/identity/delegation.d.ts +10 -3
- package/lib/esm/identity/identity/delegation.d.ts.map +1 -1
- package/lib/esm/identity/identity/delegation.js +22 -9
- 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 +3 -2
- package/lib/esm/identity/identity/ecdsa.js.map +1 -1
- package/lib/esm/identity/identity/ed25519.d.ts +3 -2
- package/lib/esm/identity/identity/ed25519.d.ts.map +1 -1
- package/lib/esm/identity/identity/ed25519.js +10 -7
- package/lib/esm/identity/identity/ed25519.js.map +1 -1
- package/lib/esm/identity/identity/webauthn.d.ts +4 -3
- package/lib/esm/identity/identity/webauthn.d.ts.map +1 -1
- package/lib/esm/identity/identity/webauthn.js +8 -7
- package/lib/esm/identity/identity/webauthn.js.map +1 -1
- package/lib/esm/identity/secp256k1/der.d.ts +2 -1
- package/lib/esm/identity/secp256k1/der.d.ts.map +1 -1
- package/lib/esm/identity/secp256k1/der.js.map +1 -1
- package/lib/esm/identity/secp256k1/pem.d.ts +4 -3
- package/lib/esm/identity/secp256k1/pem.d.ts.map +1 -1
- package/lib/esm/identity/secp256k1/pem.js +2 -2
- package/lib/esm/identity/secp256k1/pem.js.map +1 -1
- package/lib/esm/identity/secp256k1/secp256k1.d.ts +5 -4
- package/lib/esm/identity/secp256k1/secp256k1.d.ts.map +1 -1
- package/lib/esm/identity/secp256k1/secp256k1.js +10 -13
- package/lib/esm/identity/secp256k1/secp256k1.js.map +1 -1
- package/lib/esm/principal/principal.js +2 -2
- package/lib/esm/principal/principal.js.map +1 -1
- package/package.json +20 -10
- package/src/agent/actor.ts +0 -524
- package/src/agent/agent/api.ts +0 -310
- package/src/agent/agent/http/expiry.ts +0 -107
- package/src/agent/agent/http/index.ts +0 -1724
- package/src/agent/agent/http/transforms.ts +0 -54
- package/src/agent/agent/http/types.ts +0 -145
- package/src/agent/agent/index.ts +0 -4
- package/src/agent/auth.ts +0 -147
- package/src/agent/canister-env/index.ts +0 -192
- package/src/agent/canisterStatus/index.ts +0 -260
- package/src/agent/cbor.ts +0 -63
- package/src/agent/certificate.ts +0 -1058
- package/src/agent/constants.ts +0 -24
- package/src/agent/der.ts +0 -191
- package/src/agent/errors.ts +0 -962
- package/src/agent/fetch_candid.ts +0 -37
- package/src/agent/index.ts +0 -130
- package/src/agent/observable.ts +0 -49
- package/src/agent/polling/backoff.ts +0 -129
- package/src/agent/polling/index.ts +0 -238
- package/src/agent/polling/strategy.ts +0 -140
- package/src/agent/polling/types.ts +0 -28
- package/src/agent/public_key.ts +0 -65
- package/src/agent/request_id.ts +0 -99
- package/src/agent/subnetStatus/index.ts +0 -263
- package/src/agent/utils/bls.ts +0 -18
- package/src/agent/utils/buffer.ts +0 -64
- package/src/agent/utils/certificateReject.ts +0 -25
- package/src/agent/utils/createExpirableStore.ts +0 -31
- package/src/agent/utils/expirableStore.ts +0 -47
- package/src/agent/utils/inMemoryExpirableStore.ts +0 -49
- package/src/agent/utils/indexedDBExpirableStore.ts +0 -191
- package/src/agent/utils/leb.ts +0 -14
- package/src/agent/utils/random.ts +0 -30
- package/src/agent/utils/readState.ts +0 -180
- package/src/candid/candid-core.ts +0 -274
- package/src/candid/candid-ui.ts +0 -281
- package/src/candid/idl.ts +0 -2654
- package/src/candid/index.ts +0 -35
- package/src/candid/types.ts +0 -7
- package/src/candid/utils/bigint-math.ts +0 -26
- package/src/candid/utils/buffer.ts +0 -221
- package/src/candid/utils/hash.ts +0 -31
- package/src/candid/utils/leb128.ts +0 -233
- package/src/identity/identity/attributes.ts +0 -91
- package/src/identity/identity/delegation.ts +0 -411
- package/src/identity/identity/ecdsa.ts +0 -162
- package/src/identity/identity/ed25519.ts +0 -246
- package/src/identity/identity/partial.ts +0 -60
- package/src/identity/identity/webauthn.ts +0 -265
- package/src/identity/index.ts +0 -44
- package/src/identity/secp256k1/der.ts +0 -177
- package/src/identity/secp256k1/index.ts +0 -52
- package/src/identity/secp256k1/pem.ts +0 -39
- package/src/identity/secp256k1/secp256k1.ts +0 -276
- package/src/index.ts +0 -3
- package/src/principal/index.ts +0 -19
- package/src/principal/principal.ts +0 -181
- package/src/principal/utils/base32.ts +0 -101
- package/src/principal/utils/getCrc.ts +0 -52
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Principal } from '#principal';
|
|
2
|
-
import * as CanisterStatus from './canisterStatus/index.ts';
|
|
3
|
-
import type { IDL } from '#candid';
|
|
4
|
-
import { HttpAgent } from './agent/http/index.ts';
|
|
5
|
-
import { Actor, type ActorSubclass } from './actor.ts';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Retrieves the Candid interface for the specified canister.
|
|
9
|
-
* @param canisterId A string corresponding to the canister ID
|
|
10
|
-
* @param agent The agent to use for the request (usually an `HttpAgent`)
|
|
11
|
-
* @returns Candid source code
|
|
12
|
-
*/
|
|
13
|
-
export async function fetchCandid(canisterId: string, agent?: HttpAgent): Promise<string> {
|
|
14
|
-
if (!agent) {
|
|
15
|
-
// Create an anonymous `HttpAgent` (adapted from Candid UI)
|
|
16
|
-
agent = await HttpAgent.create();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Attempt to use canister metadata
|
|
20
|
-
const status = await CanisterStatus.request({
|
|
21
|
-
agent,
|
|
22
|
-
canisterId: Principal.fromText(canisterId),
|
|
23
|
-
paths: ['candid'],
|
|
24
|
-
});
|
|
25
|
-
const candid = status.get('candid') as string | undefined;
|
|
26
|
-
if (candid) {
|
|
27
|
-
return candid;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Use `__get_candid_interface_tmp_hack` for canisters without Candid metadata
|
|
31
|
-
const tmpHackInterface: IDL.InterfaceFactory = ({ IDL }) =>
|
|
32
|
-
IDL.Service({
|
|
33
|
-
__get_candid_interface_tmp_hack: IDL.Func([], [IDL.Text], ['query']),
|
|
34
|
-
});
|
|
35
|
-
const actor: ActorSubclass = Actor.createActor(tmpHackInterface, { agent, canisterId });
|
|
36
|
-
return (await actor.__get_candid_interface_tmp_hack()) as string;
|
|
37
|
-
}
|
package/src/agent/index.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JavaScript and TypeScript module to interact with the [Internet Computer](https://internetcomputer.org/) for Node.js and browser applications.
|
|
3
|
-
*
|
|
4
|
-
* ## Usage
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* import { HttpAgent } from '@icp-sdk/core/agent';
|
|
8
|
-
*
|
|
9
|
-
* const agent = await HttpAgent.create({
|
|
10
|
-
* host: 'https://icp-api.io',
|
|
11
|
-
* });
|
|
12
|
-
*
|
|
13
|
-
* agent.call(..) // Send an update call to the canister
|
|
14
|
-
* agent.query(..) // Send a query call to the canister
|
|
15
|
-
* agent.readState(..) // Read the state of the canister
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* ### Using an Agent
|
|
19
|
-
*
|
|
20
|
-
* The agent is a low-level interface that the Actor uses to encode and decode messages to the Internet Computer. It provides `call`, `query` and `readState` methods to the Actor, as well as a few additional utilities. For the most part, calls through the agent are intended to be structured through an Actor, configured with a canister interface that can be automatically generated from a [Candid](https://github.com/dfinity/candid) interface.
|
|
21
|
-
*
|
|
22
|
-
* ### Initializing an Actor
|
|
23
|
-
*
|
|
24
|
-
* The most common use for the agent is to create an actor. This is done by calling the `Actor.createActor` constructor:
|
|
25
|
-
*
|
|
26
|
-
* ```ts
|
|
27
|
-
* Actor.createActor(interfaceFactory: InterfaceFactory, configuration: ActorConfig): ActorSubclass<T>
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* The `interfaceFactory` is a function that returns a runtime interface that the Actor uses to strucure calls to a canister. The interfaceFactory can be written manually, but it is recommended to use the `dfx generate` command to generate the interface for your project, or to use the `didc` tool to generate the interface for your project.
|
|
31
|
-
*
|
|
32
|
-
* Actors can also be initialized to include the boundary node http headers, This is done by calling the `Actor.createActor` constructor:
|
|
33
|
-
*
|
|
34
|
-
* ```ts
|
|
35
|
-
* Actor.createActorWithHttpDetails(interfaceFactory: InterfaceFactory, configuration: ActorConfig): ActorSubclass<ActorMethodMappedWithHttpDetails<T>>
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* ### Inspecting an actor's agent
|
|
39
|
-
*
|
|
40
|
-
* Use the `Actor.agentOf` method to get the agent of an actor:
|
|
41
|
-
*
|
|
42
|
-
* ```ts
|
|
43
|
-
* const defaultAgent = Actor.agentOf(defaultActor);
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* This is useful if you need to replace or invalidate the identity used by an actor's agent.
|
|
47
|
-
*
|
|
48
|
-
* For example, if you want to replace the identity of an actor's agent with a newly authenticated identity from [Internet Identity](https://identity.internetcomputer.org), you can do so by calling the `Actor.replaceAgent` method:
|
|
49
|
-
*
|
|
50
|
-
* ```ts
|
|
51
|
-
* defaultAgent.replaceIdentity(await authClient.getIdentity());
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* ### Tips for using fetch
|
|
55
|
-
*
|
|
56
|
-
* The agent uses the browser `fetch` API to make calls to the Internet Computer. If you are not using the agent in the browser, you can pass a custom `fetch` implementation to the agent's constructor. This is useful if you want to use a custom fetch implementation, such as one that adds authentication headers to the request. We recommend using the [isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch) package to provide a consistent fetch API across Node.js and the browser. You will also need to provide a `host` option to the agent's constructor, as the agent will not be able to determine the host from the global context.
|
|
57
|
-
*
|
|
58
|
-
* For example,
|
|
59
|
-
*
|
|
60
|
-
* ```ts
|
|
61
|
-
* import fetch from 'isomorphic-fetch';
|
|
62
|
-
* import { HttpAgent } from '@icp-sdk/core/agent';
|
|
63
|
-
*
|
|
64
|
-
* const host = process.env.DFX_NETWORK === 'local' ? 'http://127.0.0.1:4943' : 'https://icp-api.io';
|
|
65
|
-
*
|
|
66
|
-
* const agent = new HttpAgent({ fetch, host });
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
|
-
* You can also pass `fetchOptions` to the agent's constructor, which will be passed to the `fetch` implementation. This is useful if you want to pass additional options to the `fetch` implementation, such as a custom header.
|
|
70
|
-
*
|
|
71
|
-
* For example,
|
|
72
|
-
*
|
|
73
|
-
* ```ts
|
|
74
|
-
* import fetch from 'isomorphic-fetch';
|
|
75
|
-
* import { HttpAgent } from '@icp-sdk/core/agent';
|
|
76
|
-
*
|
|
77
|
-
* const host = process.env.DFX_NETWORK === 'local' ? 'http://127.0.0.1:4943' : 'https://ic0.app';
|
|
78
|
-
*
|
|
79
|
-
* const fetchOptions: RequestInit = {
|
|
80
|
-
* headers: {
|
|
81
|
-
* 'X-Custom-Header': 'value',
|
|
82
|
-
* },
|
|
83
|
-
* };
|
|
84
|
-
*
|
|
85
|
-
* const agent = new HttpAgent({ fetch, host, fetchOptions });
|
|
86
|
-
* ```
|
|
87
|
-
*
|
|
88
|
-
* <!-- split here -->
|
|
89
|
-
* @module libs/agent/api
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
export * from './actor.ts';
|
|
93
|
-
export * from './agent/index.ts';
|
|
94
|
-
export * from './auth.ts';
|
|
95
|
-
export * from './certificate.ts';
|
|
96
|
-
export {
|
|
97
|
-
IC_REQUEST_DOMAIN_SEPARATOR,
|
|
98
|
-
IC_RESPONSE_DOMAIN_SEPARATOR,
|
|
99
|
-
IC_REQUEST_AUTH_DELEGATION_DOMAIN_SEPARATOR,
|
|
100
|
-
IC_STATE_ROOT_DOMAIN_SEPARATOR,
|
|
101
|
-
} from './constants.ts';
|
|
102
|
-
export * from './der.ts';
|
|
103
|
-
export * from './errors.ts';
|
|
104
|
-
export * from './fetch_candid.ts';
|
|
105
|
-
export * from './observable.ts';
|
|
106
|
-
export * from './public_key.ts';
|
|
107
|
-
export * from './request_id.ts';
|
|
108
|
-
export * from './utils/bls.ts';
|
|
109
|
-
export * from './utils/buffer.ts';
|
|
110
|
-
export * from './utils/random.ts';
|
|
111
|
-
export { type ExpirableStore } from './utils/expirableStore.ts';
|
|
112
|
-
export * as polling from './polling/index.ts';
|
|
113
|
-
import * as CanisterStatus from './canisterStatus/index.ts';
|
|
114
|
-
import * as SubnetStatus from './subnetStatus/index.ts';
|
|
115
|
-
/**
|
|
116
|
-
* The CanisterStatus utility is used to request structured data directly from the IC public API. This data can be accessed using agent.readState, but CanisterStatus provides a helpful abstraction with some known paths.
|
|
117
|
-
*
|
|
118
|
-
* You can request a canisters Controllers, ModuleHash, Candid interface, Subnet, or Time, or provide a custom path {@link CanisterStatus.CustomPath} and pass arbitrary buffers for valid paths identified in https://internetcomputer.org/docs/current/references/ic-interface-spec.
|
|
119
|
-
*
|
|
120
|
-
* The primary method for this namespace is {@link CanisterStatus.request}
|
|
121
|
-
*/
|
|
122
|
-
export { CanisterStatus };
|
|
123
|
-
/**
|
|
124
|
-
* The SubnetStatus utility is used to request structured data directly from the IC public API. This data can be accessed using agent.readSubnetState, but SubnetStatus provides a helpful abstraction with some known paths.
|
|
125
|
-
*
|
|
126
|
-
* The primary method for this namespace is {@link SubnetStatus.request}
|
|
127
|
-
*/
|
|
128
|
-
export { SubnetStatus };
|
|
129
|
-
export { Cbor, ToCborValue } from './cbor.ts';
|
|
130
|
-
export * from './polling/index.ts';
|
package/src/agent/observable.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { AgentError } from './errors.ts';
|
|
2
|
-
|
|
3
|
-
export type ObserveFunction<T> = (data: T, ...rest: unknown[]) => void;
|
|
4
|
-
|
|
5
|
-
export class Observable<T> {
|
|
6
|
-
observers: ObserveFunction<T>[];
|
|
7
|
-
|
|
8
|
-
constructor() {
|
|
9
|
-
this.observers = [];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
subscribe(func: ObserveFunction<T>) {
|
|
13
|
-
this.observers.push(func);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
unsubscribe(func: ObserveFunction<T>) {
|
|
17
|
-
this.observers = this.observers.filter(observer => observer !== func);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
notify(data: T, ...rest: unknown[]) {
|
|
21
|
-
this.observers.forEach(observer => observer(data, ...rest));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type AgentLog =
|
|
26
|
-
| {
|
|
27
|
-
message: string;
|
|
28
|
-
level: 'warn' | 'info';
|
|
29
|
-
}
|
|
30
|
-
| {
|
|
31
|
-
message: string;
|
|
32
|
-
level: 'error';
|
|
33
|
-
error: AgentError;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export class ObservableLog extends Observable<AgentLog> {
|
|
37
|
-
constructor() {
|
|
38
|
-
super();
|
|
39
|
-
}
|
|
40
|
-
print(message: string, ...rest: unknown[]) {
|
|
41
|
-
this.notify({ message, level: 'info' }, ...rest);
|
|
42
|
-
}
|
|
43
|
-
warn(message: string, ...rest: unknown[]) {
|
|
44
|
-
this.notify({ message, level: 'warn' }, ...rest);
|
|
45
|
-
}
|
|
46
|
-
error(message: string, error: AgentError, ...rest: unknown[]) {
|
|
47
|
-
this.notify({ message, level: 'error', error }, ...rest);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
const RANDOMIZATION_FACTOR = 0.5;
|
|
2
|
-
const MULTIPLIER = 1.5;
|
|
3
|
-
const INITIAL_INTERVAL_MSEC = 500;
|
|
4
|
-
const MAX_INTERVAL_MSEC = 60_000;
|
|
5
|
-
const MAX_ELAPSED_TIME_MSEC = 900_000;
|
|
6
|
-
const MAX_ITERATIONS = 10;
|
|
7
|
-
|
|
8
|
-
export interface BackoffStrategy {
|
|
9
|
-
next: () => number | null;
|
|
10
|
-
currentInterval?: number;
|
|
11
|
-
count?: number;
|
|
12
|
-
ellapsedTimeInMsec?: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface BackoffStrategyArgs {
|
|
16
|
-
maxIterations?: number;
|
|
17
|
-
maxElapsedTime?: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type BackoffStrategyFactory = (args?: BackoffStrategyArgs) => BackoffStrategy;
|
|
21
|
-
|
|
22
|
-
// export type BackoffStrategyGenerator = Generator<number, void, unknown>;
|
|
23
|
-
|
|
24
|
-
export interface ExponentialBackoffOptions {
|
|
25
|
-
initialInterval?: number;
|
|
26
|
-
randomizationFactor?: number;
|
|
27
|
-
multiplier?: number;
|
|
28
|
-
maxInterval?: number;
|
|
29
|
-
maxElapsedTime?: number;
|
|
30
|
-
maxIterations?: number;
|
|
31
|
-
date?: DateConstructor;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Exponential backoff strategy.
|
|
36
|
-
*/
|
|
37
|
-
export class ExponentialBackoff {
|
|
38
|
-
#currentInterval: number;
|
|
39
|
-
#randomizationFactor: number;
|
|
40
|
-
#multiplier: number;
|
|
41
|
-
#maxInterval: number;
|
|
42
|
-
#startTime: number;
|
|
43
|
-
#maxElapsedTime: number;
|
|
44
|
-
#maxIterations: number;
|
|
45
|
-
#date: DateConstructor;
|
|
46
|
-
#count = 0;
|
|
47
|
-
|
|
48
|
-
static default = {
|
|
49
|
-
initialInterval: INITIAL_INTERVAL_MSEC,
|
|
50
|
-
randomizationFactor: RANDOMIZATION_FACTOR,
|
|
51
|
-
multiplier: MULTIPLIER,
|
|
52
|
-
maxInterval: MAX_INTERVAL_MSEC,
|
|
53
|
-
// 1 minute
|
|
54
|
-
maxElapsedTime: MAX_ELAPSED_TIME_MSEC,
|
|
55
|
-
maxIterations: MAX_ITERATIONS,
|
|
56
|
-
date: Date,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
constructor(options: ExponentialBackoffOptions = ExponentialBackoff.default) {
|
|
60
|
-
const {
|
|
61
|
-
initialInterval = INITIAL_INTERVAL_MSEC,
|
|
62
|
-
randomizationFactor = RANDOMIZATION_FACTOR,
|
|
63
|
-
multiplier = MULTIPLIER,
|
|
64
|
-
maxInterval = MAX_INTERVAL_MSEC,
|
|
65
|
-
maxElapsedTime = MAX_ELAPSED_TIME_MSEC,
|
|
66
|
-
maxIterations = MAX_ITERATIONS,
|
|
67
|
-
date = Date,
|
|
68
|
-
} = options;
|
|
69
|
-
this.#currentInterval = initialInterval;
|
|
70
|
-
this.#randomizationFactor = randomizationFactor;
|
|
71
|
-
this.#multiplier = multiplier;
|
|
72
|
-
this.#maxInterval = maxInterval;
|
|
73
|
-
this.#date = date;
|
|
74
|
-
this.#startTime = date.now();
|
|
75
|
-
this.#maxElapsedTime = maxElapsedTime;
|
|
76
|
-
this.#maxIterations = maxIterations;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
get ellapsedTimeInMsec() {
|
|
80
|
-
return this.#date.now() - this.#startTime;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
get currentInterval() {
|
|
84
|
-
return this.#currentInterval;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
get count() {
|
|
88
|
-
return this.#count;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
get randomValueFromInterval() {
|
|
92
|
-
const delta = this.#randomizationFactor * this.#currentInterval;
|
|
93
|
-
const min = this.#currentInterval - delta;
|
|
94
|
-
const max = this.#currentInterval + delta;
|
|
95
|
-
return Math.random() * (max - min) + min;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
public incrementCurrentInterval() {
|
|
99
|
-
this.#currentInterval = Math.min(this.#currentInterval * this.#multiplier, this.#maxInterval);
|
|
100
|
-
this.#count++;
|
|
101
|
-
|
|
102
|
-
return this.#currentInterval;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
public next() {
|
|
106
|
-
if (this.ellapsedTimeInMsec >= this.#maxElapsedTime || this.#count >= this.#maxIterations) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
this.incrementCurrentInterval();
|
|
110
|
-
return this.randomValueFromInterval;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Utility function to create an exponential backoff iterator.
|
|
115
|
-
* @param options - for the exponential backoff
|
|
116
|
-
* @returns an iterator that yields the next delay in the exponential backoff
|
|
117
|
-
* @yields {number} the next delay in the exponential backoff
|
|
118
|
-
*/
|
|
119
|
-
export function* exponentialBackoff(
|
|
120
|
-
options: ExponentialBackoffOptions = ExponentialBackoff.default,
|
|
121
|
-
) {
|
|
122
|
-
const backoff = new ExponentialBackoff(options);
|
|
123
|
-
|
|
124
|
-
let next = backoff.next();
|
|
125
|
-
while (next) {
|
|
126
|
-
yield next;
|
|
127
|
-
next = backoff.next();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import type { RequestId } from '../request_id.ts';
|
|
2
|
-
import {
|
|
3
|
-
type CreateCertificateOptions,
|
|
4
|
-
Certificate,
|
|
5
|
-
lookupResultToBuffer,
|
|
6
|
-
} from '../certificate.ts';
|
|
7
|
-
import { readCertifiedReject } from '../utils/certificateReject.ts';
|
|
8
|
-
import type { Agent, ReadStateResponse } from '../agent/api.ts';
|
|
9
|
-
import type { Principal } from '#principal';
|
|
10
|
-
import {
|
|
11
|
-
ExternalError,
|
|
12
|
-
InputError,
|
|
13
|
-
InvalidReadStateRequestErrorCode,
|
|
14
|
-
MissingRootKeyErrorCode,
|
|
15
|
-
RejectError,
|
|
16
|
-
RequestStatusDoneNoReplyErrorCode,
|
|
17
|
-
UnknownError,
|
|
18
|
-
UNREACHABLE_ERROR,
|
|
19
|
-
} from '../errors.ts';
|
|
20
|
-
|
|
21
|
-
export * as strategy from './strategy.ts';
|
|
22
|
-
import { defaultStrategy } from './strategy.ts';
|
|
23
|
-
import type { PollStrategy, PollForResponseResult } from './types.ts';
|
|
24
|
-
import { ReadRequestType, type ReadStateRequest } from '../agent/http/types.ts';
|
|
25
|
-
import { RequestStatusResponseStatus } from '../agent/http/types.ts';
|
|
26
|
-
import { utf8ToBytes } from '@noble/hashes/utils';
|
|
27
|
-
export { defaultStrategy } from './strategy.ts';
|
|
28
|
-
export type { PollStrategy, PollForResponseResult } from './types.ts';
|
|
29
|
-
|
|
30
|
-
interface SignedReadStateRequestWithExpiry extends ReadStateRequest {
|
|
31
|
-
body: {
|
|
32
|
-
content: Pick<ReadStateRequest, 'request_type' | 'ingress_expiry'>;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Options for controlling polling behavior
|
|
38
|
-
*/
|
|
39
|
-
export interface PollingOptions {
|
|
40
|
-
/**
|
|
41
|
-
* A polling strategy that dictates how much and often we should poll the
|
|
42
|
-
* read_state endpoint to get the result of an update call.
|
|
43
|
-
* @default {@link defaultStrategy}
|
|
44
|
-
*/
|
|
45
|
-
strategy?: PollStrategy;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Whether to reuse the same signed request for polling or create a new unsigned request each time.
|
|
49
|
-
* @default false
|
|
50
|
-
*/
|
|
51
|
-
preSignReadStateRequest?: boolean;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Optional replacement function that verifies the BLS signature of a certificate.
|
|
55
|
-
*/
|
|
56
|
-
blsVerify?: CreateCertificateOptions['blsVerify'];
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* The request to use for polling. If not provided, a new request will be created.
|
|
60
|
-
* This is only used if `preSignReadStateRequest` is set to false.
|
|
61
|
-
*/
|
|
62
|
-
request?: ReadStateRequest;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export const DEFAULT_POLLING_OPTIONS: PollingOptions = {
|
|
66
|
-
preSignReadStateRequest: false,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Check if an object has a property
|
|
71
|
-
* @param value the object that might have the property
|
|
72
|
-
* @param property the key of property we're looking for
|
|
73
|
-
*/
|
|
74
|
-
function hasProperty<O extends object, P extends string>(
|
|
75
|
-
value: O,
|
|
76
|
-
property: P,
|
|
77
|
-
): value is O & Record<P, unknown> {
|
|
78
|
-
return Object.prototype.hasOwnProperty.call(value, property);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function isObjectWithProperty<O extends object, P extends string>(
|
|
82
|
-
value: unknown,
|
|
83
|
-
property: P,
|
|
84
|
-
): value is O & Record<P, unknown> {
|
|
85
|
-
return value !== null && typeof value === 'object' && hasProperty(value, property);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function hasFunction<O extends object, P extends string>(
|
|
89
|
-
value: O,
|
|
90
|
-
property: P,
|
|
91
|
-
): value is O & Record<P, (...args: unknown[]) => unknown> {
|
|
92
|
-
return hasProperty(value, property) && typeof value[property] === 'function';
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Check if value is a signed read state request with expiry
|
|
97
|
-
* @param value to check
|
|
98
|
-
*/
|
|
99
|
-
function isSignedReadStateRequestWithExpiry(
|
|
100
|
-
value: unknown,
|
|
101
|
-
): value is SignedReadStateRequestWithExpiry {
|
|
102
|
-
return (
|
|
103
|
-
isObjectWithProperty(value, 'body') &&
|
|
104
|
-
isObjectWithProperty(value.body, 'content') &&
|
|
105
|
-
(value.body.content as { request_type: ReadRequestType }).request_type ===
|
|
106
|
-
ReadRequestType.ReadState &&
|
|
107
|
-
isObjectWithProperty(value.body.content, 'ingress_expiry') &&
|
|
108
|
-
typeof value.body.content.ingress_expiry === 'object' &&
|
|
109
|
-
value.body.content.ingress_expiry !== null &&
|
|
110
|
-
hasFunction(value.body.content.ingress_expiry, 'toHash')
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Polls the IC to check the status of the given request then
|
|
116
|
-
* returns the response bytes once the request has been processed.
|
|
117
|
-
* @param agent The agent to use to poll read_state.
|
|
118
|
-
* @param canisterId The effective canister ID.
|
|
119
|
-
* @param requestId The Request ID to poll status for.
|
|
120
|
-
* @param options polling options to control behavior
|
|
121
|
-
* @returns The certificate, reply bytes, and raw certificate bytes for the request.
|
|
122
|
-
* @throws {ExternalError} If the agent's root key is not available.
|
|
123
|
-
* @throws {RejectError} If the request was rejected by the canister.
|
|
124
|
-
* @throws {UnknownError} If the request reached `done` status without a reply.
|
|
125
|
-
*/
|
|
126
|
-
export async function pollForResponse(
|
|
127
|
-
agent: Agent,
|
|
128
|
-
canisterId: Principal,
|
|
129
|
-
requestId: RequestId,
|
|
130
|
-
options: PollingOptions = {},
|
|
131
|
-
): Promise<PollForResponseResult> {
|
|
132
|
-
const path = [utf8ToBytes('request_status'), requestId];
|
|
133
|
-
|
|
134
|
-
let state: ReadStateResponse;
|
|
135
|
-
let currentRequest: ReadStateRequest | undefined;
|
|
136
|
-
const preSignReadStateRequest = options.preSignReadStateRequest ?? false;
|
|
137
|
-
if (preSignReadStateRequest) {
|
|
138
|
-
// If preSignReadStateRequest is true, we need to create a new request
|
|
139
|
-
currentRequest = await constructRequest({
|
|
140
|
-
paths: [path],
|
|
141
|
-
agent,
|
|
142
|
-
pollingOptions: options,
|
|
143
|
-
});
|
|
144
|
-
state = await agent.readState(canisterId, { paths: [path] }, undefined, currentRequest);
|
|
145
|
-
} else {
|
|
146
|
-
// If preSignReadStateRequest is false, we use the default strategy and sign the request each time
|
|
147
|
-
state = await agent.readState(canisterId, { paths: [path] });
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (agent.rootKey == null) {
|
|
151
|
-
throw ExternalError.fromCode(new MissingRootKeyErrorCode());
|
|
152
|
-
}
|
|
153
|
-
const cert = await Certificate.create({
|
|
154
|
-
certificate: state.certificate,
|
|
155
|
-
rootKey: agent.rootKey,
|
|
156
|
-
principal: { canisterId },
|
|
157
|
-
blsVerify: options.blsVerify,
|
|
158
|
-
agent,
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
const maybeBuf = lookupResultToBuffer(cert.lookup_path([...path, utf8ToBytes('status')]));
|
|
162
|
-
let status;
|
|
163
|
-
if (typeof maybeBuf === 'undefined') {
|
|
164
|
-
// Missing requestId means we need to wait
|
|
165
|
-
status = RequestStatusResponseStatus.Unknown;
|
|
166
|
-
} else {
|
|
167
|
-
status = new TextDecoder().decode(maybeBuf);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
switch (status) {
|
|
171
|
-
case RequestStatusResponseStatus.Replied: {
|
|
172
|
-
return {
|
|
173
|
-
reply: lookupResultToBuffer(cert.lookup_path([...path, 'reply']))!,
|
|
174
|
-
certificate: cert,
|
|
175
|
-
rawCertificate: state.certificate,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
case RequestStatusResponseStatus.Received:
|
|
180
|
-
case RequestStatusResponseStatus.Unknown:
|
|
181
|
-
case RequestStatusResponseStatus.Processing: {
|
|
182
|
-
// Execute the polling strategy, then retry.
|
|
183
|
-
const strategy = options.strategy ?? defaultStrategy();
|
|
184
|
-
await strategy(canisterId, requestId, status);
|
|
185
|
-
|
|
186
|
-
return pollForResponse(agent, canisterId, requestId, {
|
|
187
|
-
...options,
|
|
188
|
-
// Pass over either the strategy already provided or the new one created above
|
|
189
|
-
strategy,
|
|
190
|
-
request: currentRequest,
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
case RequestStatusResponseStatus.Rejected: {
|
|
195
|
-
throw RejectError.fromCode(readCertifiedReject(cert, path, requestId));
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
case RequestStatusResponseStatus.Done:
|
|
199
|
-
// This is _technically_ not an error, but we still didn't see the `Replied` status so
|
|
200
|
-
// we don't know the result and cannot decode it.
|
|
201
|
-
throw UnknownError.fromCode(new RequestStatusDoneNoReplyErrorCode(requestId));
|
|
202
|
-
}
|
|
203
|
-
throw UNREACHABLE_ERROR;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// Determine if we should reuse the read state request or create a new one
|
|
207
|
-
// based on the options provided.
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Constructs a read state request for the given paths.
|
|
211
|
-
* If the request is already signed and has an expiry, it will be returned as is.
|
|
212
|
-
* Otherwise, a new request will be created.
|
|
213
|
-
* @param options The options to use for creating the request.
|
|
214
|
-
* @param options.paths The paths to read from.
|
|
215
|
-
* @param options.agent The agent to use to create the request.
|
|
216
|
-
* @param options.pollingOptions The options to use for creating the request.
|
|
217
|
-
* @returns The read state request.
|
|
218
|
-
*/
|
|
219
|
-
export async function constructRequest(options: {
|
|
220
|
-
paths: Uint8Array[][];
|
|
221
|
-
agent: Agent;
|
|
222
|
-
pollingOptions: PollingOptions;
|
|
223
|
-
}): Promise<ReadStateRequest> {
|
|
224
|
-
const { paths, agent, pollingOptions } = options;
|
|
225
|
-
if (pollingOptions.request && isSignedReadStateRequestWithExpiry(pollingOptions.request)) {
|
|
226
|
-
return pollingOptions.request;
|
|
227
|
-
}
|
|
228
|
-
const request = await agent.createReadStateRequest?.(
|
|
229
|
-
{
|
|
230
|
-
paths,
|
|
231
|
-
},
|
|
232
|
-
undefined,
|
|
233
|
-
);
|
|
234
|
-
if (!isSignedReadStateRequestWithExpiry(request)) {
|
|
235
|
-
throw InputError.fromCode(new InvalidReadStateRequestErrorCode(request));
|
|
236
|
-
}
|
|
237
|
-
return request;
|
|
238
|
-
}
|