@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.
Files changed (286) hide show
  1. package/lib/cjs/agent/actor.d.ts +15 -1
  2. package/lib/cjs/agent/actor.d.ts.map +1 -1
  3. package/lib/cjs/agent/actor.js +37 -91
  4. package/lib/cjs/agent/actor.js.map +1 -1
  5. package/lib/cjs/agent/agent/api.d.ts +29 -6
  6. package/lib/cjs/agent/agent/api.d.ts.map +1 -1
  7. package/lib/cjs/agent/agent/api.js.map +1 -1
  8. package/lib/cjs/agent/agent/http/expiry.d.ts +36 -0
  9. package/lib/cjs/agent/agent/http/expiry.d.ts.map +1 -0
  10. package/lib/cjs/agent/agent/http/expiry.js +92 -0
  11. package/lib/cjs/agent/agent/http/expiry.js.map +1 -0
  12. package/lib/cjs/agent/agent/http/index.d.ts +11 -2
  13. package/lib/cjs/agent/agent/http/index.d.ts.map +1 -1
  14. package/lib/cjs/agent/agent/http/index.js +142 -73
  15. package/lib/cjs/agent/agent/http/index.js.map +1 -1
  16. package/lib/cjs/agent/agent/http/transforms.d.ts +1 -35
  17. package/lib/cjs/agent/agent/http/transforms.d.ts.map +1 -1
  18. package/lib/cjs/agent/agent/http/transforms.js +6 -90
  19. package/lib/cjs/agent/agent/http/transforms.js.map +1 -1
  20. package/lib/cjs/agent/agent/http/types.d.ts +1 -1
  21. package/lib/cjs/agent/agent/http/types.d.ts.map +1 -1
  22. package/lib/cjs/agent/auth.d.ts +1 -1
  23. package/lib/cjs/agent/auth.d.ts.map +1 -1
  24. package/lib/cjs/agent/canisterStatus/index.d.ts +5 -4
  25. package/lib/cjs/agent/canisterStatus/index.d.ts.map +1 -1
  26. package/lib/cjs/agent/canisterStatus/index.js +6 -10
  27. package/lib/cjs/agent/canisterStatus/index.js.map +1 -1
  28. package/lib/cjs/agent/cbor.js +2 -2
  29. package/lib/cjs/agent/cbor.js.map +1 -1
  30. package/lib/cjs/agent/certificate.d.ts +4 -4
  31. package/lib/cjs/agent/certificate.d.ts.map +1 -1
  32. package/lib/cjs/agent/certificate.js +6 -10
  33. package/lib/cjs/agent/certificate.js.map +1 -1
  34. package/lib/cjs/agent/constants.d.ts +4 -4
  35. package/lib/cjs/agent/constants.d.ts.map +1 -1
  36. package/lib/cjs/agent/der.d.ts.map +1 -1
  37. package/lib/cjs/agent/der.js +26 -21
  38. package/lib/cjs/agent/der.js.map +1 -1
  39. package/lib/cjs/agent/errors.d.ts +27 -18
  40. package/lib/cjs/agent/errors.d.ts.map +1 -1
  41. package/lib/cjs/agent/errors.js +18 -15
  42. package/lib/cjs/agent/errors.js.map +1 -1
  43. package/lib/cjs/agent/observable.d.ts +1 -1
  44. package/lib/cjs/agent/observable.d.ts.map +1 -1
  45. package/lib/cjs/agent/polling/backoff.d.ts +7 -7
  46. package/lib/cjs/agent/polling/backoff.d.ts.map +1 -1
  47. package/lib/cjs/agent/polling/backoff.js +3 -5
  48. package/lib/cjs/agent/polling/backoff.js.map +1 -1
  49. package/lib/cjs/agent/polling/index.d.ts +11 -10
  50. package/lib/cjs/agent/polling/index.d.ts.map +1 -1
  51. package/lib/cjs/agent/polling/index.js +8 -6
  52. package/lib/cjs/agent/polling/index.js.map +1 -1
  53. package/lib/cjs/agent/polling/strategy.d.ts +2 -5
  54. package/lib/cjs/agent/polling/strategy.d.ts.map +1 -1
  55. package/lib/cjs/agent/polling/strategy.js.map +1 -1
  56. package/lib/cjs/agent/polling/types.d.ts +18 -0
  57. package/lib/cjs/agent/polling/types.d.ts.map +1 -0
  58. package/lib/cjs/agent/polling/types.js +3 -0
  59. package/lib/cjs/agent/polling/types.js.map +1 -0
  60. package/lib/cjs/agent/public_key.d.ts +1 -1
  61. package/lib/cjs/agent/public_key.d.ts.map +1 -1
  62. package/lib/cjs/agent/request_id.d.ts.map +1 -1
  63. package/lib/cjs/agent/request_id.js +7 -7
  64. package/lib/cjs/agent/request_id.js.map +1 -1
  65. package/lib/cjs/agent/subnetStatus/index.d.ts +5 -4
  66. package/lib/cjs/agent/subnetStatus/index.d.ts.map +1 -1
  67. package/lib/cjs/agent/subnetStatus/index.js +6 -10
  68. package/lib/cjs/agent/subnetStatus/index.js.map +1 -1
  69. package/lib/cjs/agent/utils/buffer.d.ts.map +1 -1
  70. package/lib/cjs/agent/utils/buffer.js +4 -2
  71. package/lib/cjs/agent/utils/buffer.js.map +1 -1
  72. package/lib/cjs/agent/utils/certificateReject.d.ts +11 -0
  73. package/lib/cjs/agent/utils/certificateReject.d.ts.map +1 -0
  74. package/lib/cjs/agent/utils/certificateReject.js +19 -0
  75. package/lib/cjs/agent/utils/certificateReject.js.map +1 -0
  76. package/lib/cjs/agent/utils/expirableMap.d.ts +4 -4
  77. package/lib/cjs/agent/utils/expirableMap.d.ts.map +1 -1
  78. package/lib/cjs/agent/utils/expirableMap.js +2 -2
  79. package/lib/cjs/agent/utils/readState.d.ts +3 -3
  80. package/lib/cjs/agent/utils/readState.d.ts.map +1 -1
  81. package/lib/cjs/candid/candid-core.d.ts +1 -1
  82. package/lib/cjs/candid/candid-core.d.ts.map +1 -1
  83. package/lib/cjs/candid/candid-core.js +7 -9
  84. package/lib/cjs/candid/candid-core.js.map +1 -1
  85. package/lib/cjs/candid/candid-ui.d.ts.map +1 -1
  86. package/lib/cjs/candid/candid-ui.js +8 -24
  87. package/lib/cjs/candid/candid-ui.js.map +1 -1
  88. package/lib/cjs/candid/idl.d.ts +14 -1
  89. package/lib/cjs/candid/idl.d.ts.map +1 -1
  90. package/lib/cjs/candid/idl.js +164 -125
  91. package/lib/cjs/candid/idl.js.map +1 -1
  92. package/lib/cjs/candid/utils/leb128.d.ts.map +1 -1
  93. package/lib/cjs/candid/utils/leb128.js +1 -3
  94. package/lib/cjs/candid/utils/leb128.js.map +1 -1
  95. package/lib/cjs/identity/identity/delegation.d.ts +4 -3
  96. package/lib/cjs/identity/identity/delegation.d.ts.map +1 -1
  97. package/lib/cjs/identity/identity/delegation.js +3 -3
  98. package/lib/cjs/identity/identity/delegation.js.map +1 -1
  99. package/lib/cjs/identity/identity/ecdsa.d.ts +2 -2
  100. package/lib/cjs/identity/identity/ecdsa.d.ts.map +1 -1
  101. package/lib/cjs/identity/identity/ecdsa.js +2 -4
  102. package/lib/cjs/identity/identity/ecdsa.js.map +1 -1
  103. package/lib/cjs/identity/identity/ed25519.d.ts.map +1 -1
  104. package/lib/cjs/identity/identity/ed25519.js +9 -10
  105. package/lib/cjs/identity/identity/ed25519.js.map +1 -1
  106. package/lib/cjs/identity/identity/partial.d.ts +1 -1
  107. package/lib/cjs/identity/identity/partial.d.ts.map +1 -1
  108. package/lib/cjs/identity/identity/webauthn.js +4 -5
  109. package/lib/cjs/identity/identity/webauthn.js.map +1 -1
  110. package/lib/cjs/identity/secp256k1/der.d.ts.map +1 -1
  111. package/lib/cjs/identity/secp256k1/der.js +27 -22
  112. package/lib/cjs/identity/secp256k1/der.js.map +1 -1
  113. package/lib/cjs/identity/secp256k1/pem.js +1 -1
  114. package/lib/cjs/identity/secp256k1/pem.js.map +1 -1
  115. package/lib/cjs/identity/secp256k1/secp256k1.d.ts.map +1 -1
  116. package/lib/cjs/identity/secp256k1/secp256k1.js +6 -6
  117. package/lib/cjs/identity/secp256k1/secp256k1.js.map +1 -1
  118. package/lib/cjs/principal/principal.d.ts +2 -2
  119. package/lib/cjs/principal/principal.d.ts.map +1 -1
  120. package/lib/cjs/principal/principal.js +10 -6
  121. package/lib/cjs/principal/principal.js.map +1 -1
  122. package/lib/esm/agent/actor.d.ts +15 -1
  123. package/lib/esm/agent/actor.d.ts.map +1 -1
  124. package/lib/esm/agent/actor.js +40 -94
  125. package/lib/esm/agent/actor.js.map +1 -1
  126. package/lib/esm/agent/agent/api.d.ts +29 -6
  127. package/lib/esm/agent/agent/api.d.ts.map +1 -1
  128. package/lib/esm/agent/agent/api.js.map +1 -1
  129. package/lib/esm/agent/agent/http/expiry.d.ts +36 -0
  130. package/lib/esm/agent/agent/http/expiry.d.ts.map +1 -0
  131. package/lib/esm/agent/agent/http/expiry.js +88 -0
  132. package/lib/esm/agent/agent/http/expiry.js.map +1 -0
  133. package/lib/esm/agent/agent/http/index.d.ts +11 -2
  134. package/lib/esm/agent/agent/http/index.d.ts.map +1 -1
  135. package/lib/esm/agent/agent/http/index.js +145 -76
  136. package/lib/esm/agent/agent/http/index.js.map +1 -1
  137. package/lib/esm/agent/agent/http/transforms.d.ts +1 -35
  138. package/lib/esm/agent/agent/http/transforms.d.ts.map +1 -1
  139. package/lib/esm/agent/agent/http/transforms.js +2 -87
  140. package/lib/esm/agent/agent/http/transforms.js.map +1 -1
  141. package/lib/esm/agent/agent/http/types.d.ts +1 -1
  142. package/lib/esm/agent/agent/http/types.d.ts.map +1 -1
  143. package/lib/esm/agent/auth.d.ts +1 -1
  144. package/lib/esm/agent/auth.d.ts.map +1 -1
  145. package/lib/esm/agent/canister-env/index.d.ts +2 -2
  146. package/lib/esm/agent/canister-env/index.d.ts.map +1 -1
  147. package/lib/esm/agent/canisterStatus/index.d.ts +5 -4
  148. package/lib/esm/agent/canisterStatus/index.d.ts.map +1 -1
  149. package/lib/esm/agent/canisterStatus/index.js +6 -10
  150. package/lib/esm/agent/canisterStatus/index.js.map +1 -1
  151. package/lib/esm/agent/cbor.js +1 -1
  152. package/lib/esm/agent/cbor.js.map +1 -1
  153. package/lib/esm/agent/certificate.d.ts +4 -4
  154. package/lib/esm/agent/certificate.d.ts.map +1 -1
  155. package/lib/esm/agent/certificate.js +6 -10
  156. package/lib/esm/agent/certificate.js.map +1 -1
  157. package/lib/esm/agent/constants.d.ts +4 -4
  158. package/lib/esm/agent/constants.d.ts.map +1 -1
  159. package/lib/esm/agent/der.d.ts.map +1 -1
  160. package/lib/esm/agent/der.js +26 -21
  161. package/lib/esm/agent/der.js.map +1 -1
  162. package/lib/esm/agent/errors.d.ts +27 -18
  163. package/lib/esm/agent/errors.d.ts.map +1 -1
  164. package/lib/esm/agent/errors.js +16 -13
  165. package/lib/esm/agent/errors.js.map +1 -1
  166. package/lib/esm/agent/observable.d.ts +1 -1
  167. package/lib/esm/agent/observable.d.ts.map +1 -1
  168. package/lib/esm/agent/polling/backoff.d.ts +7 -7
  169. package/lib/esm/agent/polling/backoff.d.ts.map +1 -1
  170. package/lib/esm/agent/polling/backoff.js +3 -5
  171. package/lib/esm/agent/polling/backoff.js.map +1 -1
  172. package/lib/esm/agent/polling/index.d.ts +11 -10
  173. package/lib/esm/agent/polling/index.d.ts.map +1 -1
  174. package/lib/esm/agent/polling/index.js +9 -7
  175. package/lib/esm/agent/polling/index.js.map +1 -1
  176. package/lib/esm/agent/polling/strategy.d.ts +2 -5
  177. package/lib/esm/agent/polling/strategy.d.ts.map +1 -1
  178. package/lib/esm/agent/polling/strategy.js.map +1 -1
  179. package/lib/esm/agent/polling/types.d.ts +18 -0
  180. package/lib/esm/agent/polling/types.d.ts.map +1 -0
  181. package/lib/esm/agent/polling/types.js +2 -0
  182. package/lib/esm/agent/polling/types.js.map +1 -0
  183. package/lib/esm/agent/public_key.d.ts +1 -1
  184. package/lib/esm/agent/public_key.d.ts.map +1 -1
  185. package/lib/esm/agent/request_id.d.ts.map +1 -1
  186. package/lib/esm/agent/request_id.js +7 -7
  187. package/lib/esm/agent/request_id.js.map +1 -1
  188. package/lib/esm/agent/subnetStatus/index.d.ts +5 -4
  189. package/lib/esm/agent/subnetStatus/index.d.ts.map +1 -1
  190. package/lib/esm/agent/subnetStatus/index.js +6 -10
  191. package/lib/esm/agent/subnetStatus/index.js.map +1 -1
  192. package/lib/esm/agent/utils/buffer.d.ts.map +1 -1
  193. package/lib/esm/agent/utils/buffer.js +4 -2
  194. package/lib/esm/agent/utils/buffer.js.map +1 -1
  195. package/lib/esm/agent/utils/certificateReject.d.ts +11 -0
  196. package/lib/esm/agent/utils/certificateReject.d.ts.map +1 -0
  197. package/lib/esm/agent/utils/certificateReject.js +16 -0
  198. package/lib/esm/agent/utils/certificateReject.js.map +1 -0
  199. package/lib/esm/agent/utils/expirableMap.d.ts +4 -4
  200. package/lib/esm/agent/utils/expirableMap.d.ts.map +1 -1
  201. package/lib/esm/agent/utils/expirableMap.js +2 -2
  202. package/lib/esm/agent/utils/readState.d.ts +3 -3
  203. package/lib/esm/agent/utils/readState.d.ts.map +1 -1
  204. package/lib/esm/candid/candid-core.d.ts +1 -1
  205. package/lib/esm/candid/candid-core.d.ts.map +1 -1
  206. package/lib/esm/candid/candid-core.js +7 -9
  207. package/lib/esm/candid/candid-core.js.map +1 -1
  208. package/lib/esm/candid/candid-ui.d.ts.map +1 -1
  209. package/lib/esm/candid/candid-ui.js +7 -23
  210. package/lib/esm/candid/candid-ui.js.map +1 -1
  211. package/lib/esm/candid/idl.d.ts +14 -1
  212. package/lib/esm/candid/idl.d.ts.map +1 -1
  213. package/lib/esm/candid/idl.js +162 -124
  214. package/lib/esm/candid/idl.js.map +1 -1
  215. package/lib/esm/candid/utils/leb128.d.ts.map +1 -1
  216. package/lib/esm/candid/utils/leb128.js +1 -3
  217. package/lib/esm/candid/utils/leb128.js.map +1 -1
  218. package/lib/esm/identity/identity/delegation.d.ts +4 -3
  219. package/lib/esm/identity/identity/delegation.d.ts.map +1 -1
  220. package/lib/esm/identity/identity/delegation.js +3 -3
  221. package/lib/esm/identity/identity/delegation.js.map +1 -1
  222. package/lib/esm/identity/identity/ecdsa.d.ts +2 -2
  223. package/lib/esm/identity/identity/ecdsa.d.ts.map +1 -1
  224. package/lib/esm/identity/identity/ecdsa.js +2 -4
  225. package/lib/esm/identity/identity/ecdsa.js.map +1 -1
  226. package/lib/esm/identity/identity/ed25519.d.ts.map +1 -1
  227. package/lib/esm/identity/identity/ed25519.js +9 -10
  228. package/lib/esm/identity/identity/ed25519.js.map +1 -1
  229. package/lib/esm/identity/identity/partial.d.ts +1 -1
  230. package/lib/esm/identity/identity/partial.d.ts.map +1 -1
  231. package/lib/esm/identity/identity/webauthn.js +4 -5
  232. package/lib/esm/identity/identity/webauthn.js.map +1 -1
  233. package/lib/esm/identity/secp256k1/der.d.ts.map +1 -1
  234. package/lib/esm/identity/secp256k1/der.js +27 -22
  235. package/lib/esm/identity/secp256k1/der.js.map +1 -1
  236. package/lib/esm/identity/secp256k1/pem.js +1 -1
  237. package/lib/esm/identity/secp256k1/pem.js.map +1 -1
  238. package/lib/esm/identity/secp256k1/secp256k1.d.ts.map +1 -1
  239. package/lib/esm/identity/secp256k1/secp256k1.js +6 -6
  240. package/lib/esm/identity/secp256k1/secp256k1.js.map +1 -1
  241. package/lib/esm/principal/principal.d.ts +2 -2
  242. package/lib/esm/principal/principal.d.ts.map +1 -1
  243. package/lib/esm/principal/principal.js +10 -6
  244. package/lib/esm/principal/principal.js.map +1 -1
  245. package/package.json +13 -13
  246. package/src/agent/actor.ts +74 -126
  247. package/src/agent/agent/api.ts +36 -6
  248. package/src/agent/agent/http/expiry.ts +107 -0
  249. package/src/agent/agent/http/index.ts +217 -90
  250. package/src/agent/agent/http/transforms.ts +2 -106
  251. package/src/agent/agent/http/types.ts +1 -1
  252. package/src/agent/auth.ts +1 -1
  253. package/src/agent/canister-env/index.ts +2 -2
  254. package/src/agent/canisterStatus/index.ts +10 -12
  255. package/src/agent/cbor.ts +1 -1
  256. package/src/agent/certificate.ts +11 -13
  257. package/src/agent/der.ts +40 -19
  258. package/src/agent/errors.ts +41 -31
  259. package/src/agent/fetch_candid.ts +1 -1
  260. package/src/agent/observable.ts +1 -1
  261. package/src/agent/polling/backoff.ts +9 -10
  262. package/src/agent/polling/index.ts +14 -26
  263. package/src/agent/polling/strategy.ts +5 -9
  264. package/src/agent/polling/types.ts +28 -0
  265. package/src/agent/public_key.ts +1 -1
  266. package/src/agent/request_id.ts +15 -8
  267. package/src/agent/subnetStatus/index.ts +10 -12
  268. package/src/agent/utils/buffer.ts +6 -2
  269. package/src/agent/utils/certificateReject.ts +25 -0
  270. package/src/agent/utils/expirableMap.ts +4 -4
  271. package/src/agent/utils/random.ts +2 -2
  272. package/src/agent/utils/readState.ts +3 -3
  273. package/src/candid/candid-core.ts +9 -11
  274. package/src/candid/candid-ui.ts +8 -16
  275. package/src/candid/idl.ts +210 -112
  276. package/src/candid/utils/leb128.ts +1 -2
  277. package/src/identity/identity/delegation.ts +5 -5
  278. package/src/identity/identity/ecdsa.ts +12 -8
  279. package/src/identity/identity/ed25519.ts +16 -9
  280. package/src/identity/identity/partial.ts +1 -1
  281. package/src/identity/identity/webauthn.ts +21 -21
  282. package/src/identity/secp256k1/der.ts +41 -20
  283. package/src/identity/secp256k1/pem.ts +1 -1
  284. package/src/identity/secp256k1/secp256k1.ts +12 -6
  285. package/src/principal/principal.ts +18 -8
  286. 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 type SubnetStatusOptions = {
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) return false;
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]) return false;
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 type ExpirableMapOptions<K, V> = {
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<any, any>} options - options for the map.
21
- * @param {Iterable<[any, any]>} options.source - an optional source of entries to initialize the map with.
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
- type nodeCrypto = {
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 { type DerEncodedPublicKey } from '../auth.ts';
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 type BaseSubnetStatus = {
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 = 'InputError: ' + (err as Error).message;
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
 
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
- /* eslint-disable @typescript-eslint/no-unused-vars */
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 === 0) {
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;