@icp-sdk/core 5.0.0-beta.0 → 5.0.0-beta.1

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.
Files changed (137) hide show
  1. package/lib/cjs/agent/actor.js +2 -2
  2. package/lib/cjs/agent/actor.js.map +1 -1
  3. package/lib/cjs/agent/agent/api.d.ts +6 -6
  4. package/lib/cjs/agent/agent/api.js +4 -4
  5. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.d.ts +30 -0
  6. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -1
  7. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js +33 -1
  8. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -1
  9. package/lib/cjs/agent/agent/http/index.d.ts +22 -3
  10. package/lib/cjs/agent/agent/http/index.d.ts.map +1 -1
  11. package/lib/cjs/agent/agent/http/index.js +131 -51
  12. package/lib/cjs/agent/agent/http/index.js.map +1 -1
  13. package/lib/cjs/agent/canisterStatus/index.d.ts +18 -50
  14. package/lib/cjs/agent/canisterStatus/index.d.ts.map +1 -1
  15. package/lib/cjs/agent/canisterStatus/index.js +30 -92
  16. package/lib/cjs/agent/canisterStatus/index.js.map +1 -1
  17. package/lib/cjs/agent/certificate.d.ts +68 -10
  18. package/lib/cjs/agent/certificate.d.ts.map +1 -1
  19. package/lib/cjs/agent/certificate.js +198 -27
  20. package/lib/cjs/agent/certificate.js.map +1 -1
  21. package/lib/cjs/agent/constants.d.ts +4 -0
  22. package/lib/cjs/agent/constants.d.ts.map +1 -1
  23. package/lib/cjs/agent/constants.js +5 -1
  24. package/lib/cjs/agent/constants.js.map +1 -1
  25. package/lib/cjs/agent/errors.d.ts +7 -1
  26. package/lib/cjs/agent/errors.d.ts.map +1 -1
  27. package/lib/cjs/agent/errors.js +19 -7
  28. package/lib/cjs/agent/errors.js.map +1 -1
  29. package/lib/cjs/agent/index.d.ts +97 -3
  30. package/lib/cjs/agent/index.d.ts.map +1 -1
  31. package/lib/cjs/agent/index.js +92 -9
  32. package/lib/cjs/agent/index.js.map +1 -1
  33. package/lib/cjs/agent/polling/index.js +1 -1
  34. package/lib/cjs/agent/polling/index.js.map +1 -1
  35. package/lib/cjs/agent/subnetStatus/index.d.ts +70 -0
  36. package/lib/cjs/agent/subnetStatus/index.d.ts.map +1 -0
  37. package/lib/cjs/agent/subnetStatus/index.js +224 -0
  38. package/lib/cjs/agent/subnetStatus/index.js.map +1 -0
  39. package/lib/cjs/agent/utils/readState.d.ts +84 -0
  40. package/lib/cjs/agent/utils/readState.d.ts.map +1 -0
  41. package/lib/cjs/agent/utils/readState.js +149 -0
  42. package/lib/cjs/agent/utils/readState.js.map +1 -0
  43. package/lib/cjs/candid/index.d.ts +20 -1
  44. package/lib/cjs/candid/index.d.ts.map +1 -1
  45. package/lib/cjs/candid/index.js +20 -1
  46. package/lib/cjs/candid/index.js.map +1 -1
  47. package/lib/cjs/identity/index.d.ts +30 -7
  48. package/lib/cjs/identity/index.d.ts.map +1 -1
  49. package/lib/cjs/identity/index.js +31 -11
  50. package/lib/cjs/identity/index.js.map +1 -1
  51. package/lib/cjs/identity/secp256k1/index.d.ts +48 -1
  52. package/lib/cjs/identity/secp256k1/index.d.ts.map +1 -1
  53. package/lib/cjs/identity/secp256k1/index.js +48 -1
  54. package/lib/cjs/identity/secp256k1/index.js.map +1 -1
  55. package/lib/cjs/principal/index.d.ts +15 -0
  56. package/lib/cjs/principal/index.d.ts.map +1 -1
  57. package/lib/cjs/principal/index.js +15 -0
  58. package/lib/cjs/principal/index.js.map +1 -1
  59. package/lib/esm/agent/actor.js +3 -3
  60. package/lib/esm/agent/actor.js.map +1 -1
  61. package/lib/esm/agent/agent/api.d.ts +6 -6
  62. package/lib/esm/agent/agent/api.js +3 -3
  63. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts +30 -0
  64. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -1
  65. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js +33 -1
  66. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -1
  67. package/lib/esm/agent/agent/http/index.d.ts +22 -3
  68. package/lib/esm/agent/agent/http/index.d.ts.map +1 -1
  69. package/lib/esm/agent/agent/http/index.js +134 -54
  70. package/lib/esm/agent/agent/http/index.js.map +1 -1
  71. package/lib/esm/agent/canister-env/index.d.ts +2 -1
  72. package/lib/esm/agent/canister-env/index.d.ts.map +1 -1
  73. package/lib/esm/agent/canister-env/index.js +2 -1
  74. package/lib/esm/agent/canister-env/index.js.map +1 -1
  75. package/lib/esm/agent/canisterStatus/index.d.ts +18 -50
  76. package/lib/esm/agent/canisterStatus/index.d.ts.map +1 -1
  77. package/lib/esm/agent/canisterStatus/index.js +31 -93
  78. package/lib/esm/agent/canisterStatus/index.js.map +1 -1
  79. package/lib/esm/agent/certificate.d.ts +68 -10
  80. package/lib/esm/agent/certificate.d.ts.map +1 -1
  81. package/lib/esm/agent/certificate.js +196 -29
  82. package/lib/esm/agent/certificate.js.map +1 -1
  83. package/lib/esm/agent/constants.d.ts +4 -0
  84. package/lib/esm/agent/constants.d.ts.map +1 -1
  85. package/lib/esm/agent/constants.js +4 -0
  86. package/lib/esm/agent/constants.js.map +1 -1
  87. package/lib/esm/agent/errors.d.ts +7 -1
  88. package/lib/esm/agent/errors.d.ts.map +1 -1
  89. package/lib/esm/agent/errors.js +15 -4
  90. package/lib/esm/agent/errors.js.map +1 -1
  91. package/lib/esm/agent/index.d.ts +97 -3
  92. package/lib/esm/agent/index.d.ts.map +1 -1
  93. package/lib/esm/agent/index.js +97 -3
  94. package/lib/esm/agent/index.js.map +1 -1
  95. package/lib/esm/agent/polling/index.js +1 -1
  96. package/lib/esm/agent/polling/index.js.map +1 -1
  97. package/lib/esm/agent/subnetStatus/index.d.ts +70 -0
  98. package/lib/esm/agent/subnetStatus/index.d.ts.map +1 -0
  99. package/lib/esm/agent/subnetStatus/index.js +183 -0
  100. package/lib/esm/agent/subnetStatus/index.js.map +1 -0
  101. package/lib/esm/agent/utils/readState.d.ts +84 -0
  102. package/lib/esm/agent/utils/readState.d.ts.map +1 -0
  103. package/lib/esm/agent/utils/readState.js +107 -0
  104. package/lib/esm/agent/utils/readState.js.map +1 -0
  105. package/lib/esm/candid/index.d.ts +20 -1
  106. package/lib/esm/candid/index.d.ts.map +1 -1
  107. package/lib/esm/candid/index.js +20 -1
  108. package/lib/esm/candid/index.js.map +1 -1
  109. package/lib/esm/identity/index.d.ts +30 -7
  110. package/lib/esm/identity/index.d.ts.map +1 -1
  111. package/lib/esm/identity/index.js +30 -9
  112. package/lib/esm/identity/index.js.map +1 -1
  113. package/lib/esm/identity/secp256k1/index.d.ts +48 -1
  114. package/lib/esm/identity/secp256k1/index.d.ts.map +1 -1
  115. package/lib/esm/identity/secp256k1/index.js +48 -1
  116. package/lib/esm/identity/secp256k1/index.js.map +1 -1
  117. package/lib/esm/principal/index.d.ts +15 -0
  118. package/lib/esm/principal/index.d.ts.map +1 -1
  119. package/lib/esm/principal/index.js +15 -0
  120. package/lib/esm/principal/index.js.map +1 -1
  121. package/package.json +1 -1
  122. package/src/agent/actor.ts +3 -3
  123. package/src/agent/agent/api.ts +8 -8
  124. package/src/agent/agent/http/index.ts +171 -58
  125. package/src/agent/canister-env/index.ts +2 -1
  126. package/src/agent/canisterStatus/index.ts +46 -191
  127. package/src/agent/certificate.ts +271 -52
  128. package/src/agent/constants.ts +5 -0
  129. package/src/agent/errors.ts +17 -4
  130. package/src/agent/index.ts +97 -3
  131. package/src/agent/polling/index.ts +1 -1
  132. package/src/agent/subnetStatus/index.ts +270 -0
  133. package/src/agent/utils/readState.ts +180 -0
  134. package/src/candid/index.ts +20 -1
  135. package/src/identity/index.ts +30 -10
  136. package/src/identity/secp256k1/index.ts +48 -1
  137. package/src/principal/index.ts +16 -0
@@ -1,5 +1,92 @@
1
1
  /**
2
- * @module api
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
3
90
  */
4
91
  export * from './actor.ts';
5
92
  export * from './agent/index.ts';
@@ -7,7 +94,7 @@ export * from './agent/http/transforms.ts';
7
94
  export * from './agent/http/types.ts';
8
95
  export * from './auth.ts';
9
96
  export * from './certificate.ts';
10
- export { IC_REQUEST_DOMAIN_SEPARATOR, IC_RESPONSE_DOMAIN_SEPARATOR, IC_REQUEST_AUTH_DELEGATION_DOMAIN_SEPARATOR, } from './constants.ts';
97
+ export { IC_REQUEST_DOMAIN_SEPARATOR, IC_RESPONSE_DOMAIN_SEPARATOR, IC_REQUEST_AUTH_DELEGATION_DOMAIN_SEPARATOR, IC_STATE_ROOT_DOMAIN_SEPARATOR, } from './constants.ts';
11
98
  export * from './der.ts';
12
99
  export * from './errors.ts';
13
100
  export * from './fetch_candid.ts';
@@ -19,7 +106,7 @@ export * from './utils/buffer.ts';
19
106
  export * from './utils/random.ts';
20
107
  export * as polling from './polling/index.ts';
21
108
  import * as CanisterStatus from './canisterStatus/index.ts';
22
- export { CanisterStatus };
109
+ import * as SubnetStatus from './subnetStatus/index.ts';
23
110
  /**
24
111
  * 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.
25
112
  *
@@ -27,6 +114,13 @@ export { CanisterStatus };
27
114
  *
28
115
  * The primary method for this namespace is {@link CanisterStatus.request}
29
116
  */
117
+ export { CanisterStatus };
118
+ /**
119
+ * 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.
120
+ *
121
+ * The primary method for this namespace is {@link SubnetStatus.request}
122
+ */
123
+ export { SubnetStatus };
30
124
  export { Cbor, ToCborValue } from './cbor.ts';
31
125
  export * from './polling/index.ts';
32
126
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,OAAO,EACL,2BAA2B,EAC3B,4BA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M,oBAAoB,CAAC;AAC9C,OAAO,KAAK,cAAc,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAC;AACxD;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC9C,cAAc,oBAAoB,CAAC"}
@@ -1,5 +1,92 @@
1
1
  /**
2
- * @module api
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
3
90
  */
4
91
  export * from "./actor.js";
5
92
  export * from "./agent/index.js";
@@ -7,7 +94,7 @@ export * from "./agent/http/transforms.js";
7
94
  export * from "./agent/http/types.js";
8
95
  export * from "./auth.js";
9
96
  export * from "./certificate.js";
10
- export { IC_REQUEST_DOMAIN_SEPARATOR, IC_RESPONSE_DOMAIN_SEPARATOR, IC_REQUEST_AUTH_DELEGATION_DOMAIN_SEPARATOR, } from "./constants.js";
97
+ export { IC_REQUEST_DOMAIN_SEPARATOR, IC_RESPONSE_DOMAIN_SEPARATOR, IC_REQUEST_AUTH_DELEGATION_DOMAIN_SEPARATOR, IC_STATE_ROOT_DOMAIN_SEPARATOR, } from "./constants.js";
11
98
  export * from "./der.js";
12
99
  export * from "./errors.js";
13
100
  export * from "./fetch_candid.js";
@@ -19,7 +106,7 @@ export * from "./utils/buffer.js";
19
106
  export * from "./utils/random.js";
20
107
  export * as polling from "./polling/index.js";
21
108
  import * as CanisterStatus from "./canisterStatus/index.js";
22
- export { CanisterStatus };
109
+ import * as SubnetStatus from "./subnetStatus/index.js";
23
110
  /**
24
111
  * 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.
25
112
  *
@@ -27,6 +114,13 @@ export { CanisterStatus };
27
114
  *
28
115
  * The primary method for this namespace is {@link CanisterStatus.request}
29
116
  */
117
+ export { CanisterStatus };
118
+ /**
119
+ * 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.
120
+ *
121
+ * The primary method for this namespace is {@link SubnetStatus.request}
122
+ */
123
+ export { SubnetStatus };
30
124
  export { Cbor, ToCborValue } from "./cbor.js";
31
125
  export * from "./polling/index.js";
32
126
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,2CAA2C,GAC5C,MAAM,gBAAgB,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,cAAc,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC9C,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,2CAA2C,EAC3C,8BAA8B,GAC/B,MAAM,gBAAgB,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,cAAc,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAC;AACxD;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC9C,cAAc,oBAAoB,CAAC"}
@@ -69,7 +69,7 @@ export async function pollForResponse(agent, canisterId, requestId, options = {}
69
69
  const cert = await Certificate.create({
70
70
  certificate: state.certificate,
71
71
  rootKey: agent.rootKey,
72
- canisterId: canisterId,
72
+ principal: { canisterId },
73
73
  blsVerify: options.blsVerify,
74
74
  agent,
75
75
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/agent/polling/index.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,WAAW,EACX,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,wBAAwB,EACxB,aAAa,EACb,UAAU,EACV,gCAAgC,EAChC,uBAAuB,EACvB,WAAW,EACX,iCAAiC,EACjC,YAAY,EACZ,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAA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AAC,CAAC;IAClF,CAAC;IACD,MAAM,iBAAiB,CAAC;AAC1B,CAAC;AAED,0EAA0E;AAC1E,iCAAiC;AAEjC;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAItC;IACC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IACjD,IAAI,cAAc,CAAC,OAAO,IAAI,kCAAkC,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;QACzF,OAAO,cAAc,CAAC,OAAO,CAAC;IAChC,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,sBAAsB,EAAE,CAClD;QACE,KAAK;KACN,EACD,SAAS,CACV,CAAC;IACF,IAAI,CAAC,kCAAkC,CAAC,OAAO,CAAC,EAAE,CAAC;QACjD,MAAM,UAAU,CAAC,QAAQ,CAAC,IAAI,gCAAgC,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { Principal } from '../../principal/index.js';
2
+ import { HttpAgent } from '../agent/http/index.ts';
3
+ import { type CanisterRanges } from '../certificate.ts';
4
+ import { type BaseStatus, type BaseSubnetStatus, type SubnetNodeKeys, CustomPath } from '../utils/readState.ts';
5
+ export { type DecodeStrategy, CustomPath, IC_ROOT_SUBNET_ID } from '../utils/readState.ts';
6
+ export type SubnetStatus = BaseSubnetStatus & {
7
+ /**
8
+ * The public key of the subnet
9
+ */
10
+ publicKey: Uint8Array;
11
+ };
12
+ export type Status = BaseStatus | SubnetNodeKeys | CanisterRanges;
13
+ /**
14
+ * Pre-configured fields for subnet status paths
15
+ */
16
+ export type Path = 'time' | 'canisterRanges' | 'publicKey' | 'nodeKeys' | CustomPath;
17
+ export type StatusMap = Map<Path | string, Status>;
18
+ export type SubnetStatusOptions = {
19
+ /**
20
+ * The subnet ID to query. Use {@link IC_ROOT_SUBNET_ID} for the IC mainnet root subnet.
21
+ * You can use {@link HttpAgent.getSubnetIdFromCanister} to get a subnet ID from a canister.
22
+ */
23
+ subnetId: Principal;
24
+ /**
25
+ * The agent to use to make the subnet request.
26
+ */
27
+ agent: HttpAgent;
28
+ /**
29
+ * The paths to request.
30
+ * @default []
31
+ */
32
+ paths?: Path[] | Set<Path>;
33
+ /**
34
+ * Whether to disable the certificate freshness checks.
35
+ * @default false
36
+ */
37
+ disableCertificateTimeVerification?: boolean;
38
+ };
39
+ /**
40
+ * Requests information from a subnet's `read_state` endpoint.
41
+ * Can be used to request information about the subnet's time, canister ranges, public key, node keys, and metrics.
42
+ * @param {SubnetStatusOptions} options The configuration for the subnet status request.
43
+ * @see {@link SubnetStatusOptions} for detailed options.
44
+ * @returns {Promise<StatusMap>} A map populated with data from the requested paths. Each path is a key in the map, and the value is the data obtained from the certificate for that path.
45
+ * @example
46
+ * const status = await subnetStatus.request({
47
+ * subnetId: IC_ROOT_SUBNET_ID,
48
+ * paths: ['time', 'nodeKeys'],
49
+ * agent,
50
+ * });
51
+ *
52
+ * const time = status.get('time');
53
+ * const nodeKeys = status.get('nodeKeys');
54
+ */
55
+ export declare function request(options: SubnetStatusOptions): Promise<StatusMap>;
56
+ /**
57
+ * Fetch subnet info including node keys from a certificate
58
+ * @param certificate the certificate bytes
59
+ * @param subnetId the subnet ID
60
+ * @returns SubnetStatus with subnet ID and node keys
61
+ */
62
+ export declare function lookupSubnetInfo(certificate: Uint8Array, subnetId: Principal): SubnetStatus;
63
+ /**
64
+ * Encode a path for subnet state queries
65
+ * @param path the path to encode
66
+ * @param subnetId the subnet ID
67
+ * @returns the encoded path as an array of Uint8Arrays
68
+ */
69
+ export declare function encodePath(path: Path, subnetId: Principal): Uint8Array[];
70
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/agent/subnetStatus/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,S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AI,EAAE,QAAQ,EAAE,SAAS,GAAG,UAAU,EAAE,CA+BxE"}
@@ -0,0 +1,183 @@
1
+ import { Principal } from '../../principal/index.js';
2
+ import { CertificateVerificationErrorCode, MissingRootKeyErrorCode, ExternalError, AgentError, UnknownError, UnexpectedErrorCode, CertificateTimeErrorCode, ProtocolError, LookupErrorCode, } from "../errors.js";
3
+ import { Certificate, lookupResultToBuffer, decodeCanisterRanges, lookup_path, LookupPathStatus, } from "../certificate.js";
4
+ import * as cbor from "../cbor.js";
5
+ import { decodeTime } from "../utils/leb.js";
6
+ import { utf8ToBytes } from '@noble/hashes/utils';
7
+ import { decodeValue, isCustomPath, lookupNodeKeysFromCertificate, } from "../utils/readState.js";
8
+ // Re-export shared types and functions
9
+ export { CustomPath, IC_ROOT_SUBNET_ID } from "../utils/readState.js";
10
+ /**
11
+ * Requests information from a subnet's `read_state` endpoint.
12
+ * Can be used to request information about the subnet's time, canister ranges, public key, node keys, and metrics.
13
+ * @param {SubnetStatusOptions} options The configuration for the subnet status request.
14
+ * @see {@link SubnetStatusOptions} for detailed options.
15
+ * @returns {Promise<StatusMap>} A map populated with data from the requested paths. Each path is a key in the map, and the value is the data obtained from the certificate for that path.
16
+ * @example
17
+ * const status = await subnetStatus.request({
18
+ * subnetId: IC_ROOT_SUBNET_ID,
19
+ * paths: ['time', 'nodeKeys'],
20
+ * agent,
21
+ * });
22
+ *
23
+ * const time = status.get('time');
24
+ * const nodeKeys = status.get('nodeKeys');
25
+ */
26
+ export async function request(options) {
27
+ const { agent, paths, disableCertificateTimeVerification = false } = options;
28
+ const subnetId = Principal.from(options.subnetId);
29
+ const uniquePaths = [...new Set(paths)];
30
+ const status = new Map();
31
+ const promises = uniquePaths.map((path, index) => {
32
+ const encodedPath = encodePath(path, subnetId);
33
+ return (async () => {
34
+ try {
35
+ if (agent.rootKey === null) {
36
+ throw ExternalError.fromCode(new MissingRootKeyErrorCode());
37
+ }
38
+ const rootKey = agent.rootKey;
39
+ const response = await agent.readSubnetState(subnetId, {
40
+ paths: [encodedPath],
41
+ });
42
+ const certificate = await Certificate.create({
43
+ certificate: response.certificate,
44
+ rootKey,
45
+ principal: { subnetId },
46
+ disableTimeVerification: disableCertificateTimeVerification,
47
+ agent,
48
+ });
49
+ const lookup = (cert, lookupPath) => {
50
+ if (lookupPath === 'nodeKeys') {
51
+ // For node keys, we need to parse the certificate directly
52
+ const data = lookupNodeKeysFromCertificate(cert.cert, subnetId);
53
+ return {
54
+ path: lookupPath,
55
+ data,
56
+ };
57
+ }
58
+ else {
59
+ return {
60
+ path: lookupPath,
61
+ data: lookupResultToBuffer(cert.lookup_path(encodedPath)),
62
+ };
63
+ }
64
+ };
65
+ const { path, data } = lookup(certificate, uniquePaths[index]);
66
+ if (!data) {
67
+ console.warn(`Expected to find result for path ${path}, but instead found nothing.`);
68
+ if (typeof path === 'string') {
69
+ status.set(path, null);
70
+ }
71
+ else {
72
+ status.set(path.key, null);
73
+ }
74
+ }
75
+ else {
76
+ switch (path) {
77
+ case 'time': {
78
+ status.set(path, decodeTime(data));
79
+ break;
80
+ }
81
+ case 'canisterRanges': {
82
+ status.set(path, decodeCanisterRanges(data));
83
+ break;
84
+ }
85
+ case 'publicKey': {
86
+ status.set(path, data);
87
+ break;
88
+ }
89
+ case 'nodeKeys': {
90
+ status.set(path, data);
91
+ break;
92
+ }
93
+ default: {
94
+ // Check for CustomPath signature
95
+ if (isCustomPath(path)) {
96
+ status.set(path.key, decodeValue(data, path.decodeStrategy));
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+ catch (error) {
103
+ // Throw on certificate errors
104
+ if (error instanceof AgentError &&
105
+ (error.hasCode(CertificateVerificationErrorCode) ||
106
+ error.hasCode(CertificateTimeErrorCode))) {
107
+ throw error;
108
+ }
109
+ if (isCustomPath(path)) {
110
+ status.set(path.key, null);
111
+ }
112
+ else {
113
+ status.set(path, null);
114
+ }
115
+ console.group();
116
+ console.warn(`Expected to find result for path ${path}, but instead found nothing.`);
117
+ console.warn(error);
118
+ console.groupEnd();
119
+ }
120
+ })();
121
+ });
122
+ // Fetch all values separately, as each option can fail
123
+ await Promise.all(promises);
124
+ return status;
125
+ }
126
+ /**
127
+ * Fetch subnet info including node keys from a certificate
128
+ * @param certificate the certificate bytes
129
+ * @param subnetId the subnet ID
130
+ * @returns SubnetStatus with subnet ID and node keys
131
+ */
132
+ export function lookupSubnetInfo(certificate, subnetId) {
133
+ const cert = cbor.decode(certificate);
134
+ const nodeKeys = lookupNodeKeysFromCertificate(cert, subnetId);
135
+ const publicKey = lookupSubnetPublicKey(cert, subnetId);
136
+ return {
137
+ subnetId: subnetId.toText(),
138
+ nodeKeys,
139
+ publicKey,
140
+ };
141
+ }
142
+ function lookupSubnetPublicKey(certificate, subnetId) {
143
+ const subnetLookupResult = lookup_path(['subnet', subnetId.toUint8Array(), 'public_key'], certificate.tree);
144
+ if (subnetLookupResult.status !== LookupPathStatus.Found) {
145
+ throw ProtocolError.fromCode(new LookupErrorCode('Public key not found', subnetLookupResult.status));
146
+ }
147
+ return subnetLookupResult.value;
148
+ }
149
+ /**
150
+ * Encode a path for subnet state queries
151
+ * @param path the path to encode
152
+ * @param subnetId the subnet ID
153
+ * @returns the encoded path as an array of Uint8Arrays
154
+ */
155
+ export function encodePath(path, subnetId) {
156
+ const subnetUint8Array = subnetId.toUint8Array();
157
+ switch (path) {
158
+ case 'time':
159
+ return [utf8ToBytes('time')];
160
+ case 'canisterRanges':
161
+ return [utf8ToBytes('canister_ranges'), subnetUint8Array];
162
+ case 'publicKey':
163
+ return [utf8ToBytes('subnet'), subnetUint8Array, utf8ToBytes('public_key')];
164
+ case 'nodeKeys':
165
+ return [utf8ToBytes('subnet'), subnetUint8Array, utf8ToBytes('node')];
166
+ default: {
167
+ // Check for CustomPath signature
168
+ if (isCustomPath(path)) {
169
+ if (typeof path['path'] === 'string' || path['path'] instanceof Uint8Array) {
170
+ // For string paths, treat as a subnet path segment
171
+ const encoded = typeof path['path'] === 'string' ? utf8ToBytes(path['path']) : path['path'];
172
+ return [utf8ToBytes('subnet'), subnetUint8Array, encoded];
173
+ }
174
+ else {
175
+ // For non-simple paths, return the provided custom path
176
+ return path['path'];
177
+ }
178
+ }
179
+ }
180
+ }
181
+ throw UnknownError.fromCode(new UnexpectedErrorCode(`Error while encoding your path for subnet status. Please ensure that your path ${path} was formatted correctly.`));
182
+ }
183
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/agent/subnetStatus/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EACvB,aAAa,EACb,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,EACxB,aAAa,EACb,eAAe,GAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAGL,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,IAAI,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAKL,WAAW,EACX,YAAY,EACZ,6BAA6B,GAE9B,MAAM,uBAAuB,CAAC;AAE/B,uCAAuC;AACvC,OAAO,EAAuB,UAAU,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAwC3F;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAA4B;IACxD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,kCAAkC,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAC7E,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAElD,MAAM,WAAW,GAAG,CAAC,G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CAAC,YAAY,UAAU,EAAE,CAAC;oBAC3E,mDAAmD;oBACnD,MAAM,OAAO,GACX,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAC9E,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;gBAC5D,CAAC;qBAAM,CAAC;oBACN,wDAAwD;oBACxD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,MAAM,YAAY,CAAC,QAAQ,CACzB,IAAI,mBAAmB,CACrB,kFAAkF,IAAI,2BAA2B,CAClH,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,84 @@
1
+ import { Principal } from '../../principal/index.js';
2
+ import { type DerEncodedPublicKey } from '../auth.ts';
3
+ import { type Cert } from '../certificate.ts';
4
+ /**
5
+ * The root subnet ID for IC mainnet
6
+ */
7
+ export declare const IC_ROOT_SUBNET_ID: Principal;
8
+ export type SubnetNodeKeys = Map<string, DerEncodedPublicKey>;
9
+ /**
10
+ * Represents the useful information about a subnet
11
+ */
12
+ export type BaseSubnetStatus = {
13
+ /**
14
+ * The subnet ID
15
+ */
16
+ subnetId: string;
17
+ /**
18
+ * The node keys of the subnet
19
+ */
20
+ nodeKeys: SubnetNodeKeys;
21
+ /**
22
+ * Not supported
23
+ */
24
+ metrics?: never;
25
+ };
26
+ /**
27
+ * Base types of an entry on the status map.
28
+ * An entry of null indicates that the request failed, due to lack of permissions or the result being missing.
29
+ */
30
+ export type BaseStatus = string | Uint8Array | Date | Uint8Array[] | Principal[] | bigint | null;
31
+ /**
32
+ * Decode strategy for custom paths
33
+ */
34
+ export type DecodeStrategy = 'cbor' | 'hex' | 'leb128' | 'utf-8' | 'raw';
35
+ /**
36
+ * Interface to define a custom path. Nested paths will be represented as individual buffers, and can be created from text using TextEncoder.
37
+ * @param {string} key the key to use to access the returned value in the status map
38
+ * @param {Uint8Array[]} path the path to the desired value, represented as an array of buffers
39
+ * @param {string} decodeStrategy the strategy to use to decode the returned value
40
+ */
41
+ export declare class CustomPath implements CustomPath {
42
+ key: string;
43
+ path: Uint8Array[] | string;
44
+ decodeStrategy: DecodeStrategy;
45
+ constructor(key: string, path: Uint8Array[] | string, decodeStrategy: DecodeStrategy);
46
+ }
47
+ /**
48
+ * Decode a value based on the specified strategy
49
+ * @param data the raw data to decode
50
+ * @param strategy the decode strategy to use
51
+ * @returns the decoded value
52
+ */
53
+ export declare function decodeValue(data: Uint8Array, strategy: DecodeStrategy): BaseStatus;
54
+ /**
55
+ * Decode controllers from CBOR-encoded buffer
56
+ * @param buf the CBOR-encoded buffer to decode
57
+ * @returns an array of principal IDs
58
+ */
59
+ export declare function decodeControllers(buf: Uint8Array): Principal[];
60
+ /**
61
+ * Encode a metadata path for canister metadata queries
62
+ * @param metaPath the metadata path (string or Uint8Array)
63
+ * @param canisterUint8Array the canister ID as Uint8Array
64
+ * @returns the encoded path
65
+ */
66
+ export declare function encodeMetadataPath(metaPath: string | Uint8Array, canisterUint8Array: Uint8Array): Uint8Array[];
67
+ /**
68
+ * Check if a path object has custom path signature (has 'key' and 'path' properties)
69
+ * @param path the path to check
70
+ * @returns true if the path has custom path signature, false otherwise
71
+ */
72
+ export declare function isCustomPath<T>(path: T): path is T & {
73
+ key: string;
74
+ path: unknown;
75
+ };
76
+ /**
77
+ * Lookup node keys from a certificate for a given subnet
78
+ * This can be used for both canister and subnet status queries
79
+ * @param certificate the certificate to fetch node keys from
80
+ * @param subnetId the subnet ID to fetch node keys for
81
+ * @returns a map of node IDs to public keys
82
+ */
83
+ export declare function lookupNodeKeysFromCertificate(certificate: Cert, subnetId: Principal): SubnetNodeKeys;
84
+ //# sourceMappingURL=readState.d.ts.map