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

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 (154) hide show
  1. package/README.md +0 -2
  2. package/lib/cjs/agent/actor.js +2 -2
  3. package/lib/cjs/agent/actor.js.map +1 -1
  4. package/lib/cjs/agent/agent/api.d.ts +6 -6
  5. package/lib/cjs/agent/agent/api.js +4 -4
  6. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.d.ts +30 -0
  7. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -1
  8. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js +33 -1
  9. package/lib/cjs/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -1
  10. package/lib/cjs/agent/agent/http/index.d.ts +23 -5
  11. package/lib/cjs/agent/agent/http/index.d.ts.map +1 -1
  12. package/lib/cjs/agent/agent/http/index.js +201 -86
  13. package/lib/cjs/agent/agent/http/index.js.map +1 -1
  14. package/lib/cjs/agent/agent/index.d.ts +2 -0
  15. package/lib/cjs/agent/agent/index.d.ts.map +1 -1
  16. package/lib/cjs/agent/agent/index.js +2 -0
  17. package/lib/cjs/agent/agent/index.js.map +1 -1
  18. package/lib/cjs/agent/canisterStatus/index.d.ts +18 -50
  19. package/lib/cjs/agent/canisterStatus/index.d.ts.map +1 -1
  20. package/lib/cjs/agent/canisterStatus/index.js +30 -97
  21. package/lib/cjs/agent/canisterStatus/index.js.map +1 -1
  22. package/lib/cjs/agent/certificate.d.ts +68 -10
  23. package/lib/cjs/agent/certificate.d.ts.map +1 -1
  24. package/lib/cjs/agent/certificate.js +198 -27
  25. package/lib/cjs/agent/certificate.js.map +1 -1
  26. package/lib/cjs/agent/constants.d.ts +4 -0
  27. package/lib/cjs/agent/constants.d.ts.map +1 -1
  28. package/lib/cjs/agent/constants.js +5 -1
  29. package/lib/cjs/agent/constants.js.map +1 -1
  30. package/lib/cjs/agent/errors.d.ts +9 -2
  31. package/lib/cjs/agent/errors.d.ts.map +1 -1
  32. package/lib/cjs/agent/errors.js +19 -7
  33. package/lib/cjs/agent/errors.js.map +1 -1
  34. package/lib/cjs/agent/index.d.ts +97 -5
  35. package/lib/cjs/agent/index.d.ts.map +1 -1
  36. package/lib/cjs/agent/index.js +92 -11
  37. package/lib/cjs/agent/index.js.map +1 -1
  38. package/lib/cjs/agent/polling/index.js +1 -1
  39. package/lib/cjs/agent/polling/index.js.map +1 -1
  40. package/lib/cjs/agent/subnetStatus/index.d.ts +70 -0
  41. package/lib/cjs/agent/subnetStatus/index.d.ts.map +1 -0
  42. package/lib/cjs/agent/subnetStatus/index.js +219 -0
  43. package/lib/cjs/agent/subnetStatus/index.js.map +1 -0
  44. package/lib/cjs/agent/utils/readState.d.ts +84 -0
  45. package/lib/cjs/agent/utils/readState.d.ts.map +1 -0
  46. package/lib/cjs/agent/utils/readState.js +149 -0
  47. package/lib/cjs/agent/utils/readState.js.map +1 -0
  48. package/lib/cjs/candid/index.d.ts +20 -1
  49. package/lib/cjs/candid/index.d.ts.map +1 -1
  50. package/lib/cjs/candid/index.js +20 -1
  51. package/lib/cjs/candid/index.js.map +1 -1
  52. package/lib/cjs/identity/index.d.ts +30 -7
  53. package/lib/cjs/identity/index.d.ts.map +1 -1
  54. package/lib/cjs/identity/index.js +31 -11
  55. package/lib/cjs/identity/index.js.map +1 -1
  56. package/lib/cjs/identity/secp256k1/index.d.ts +48 -1
  57. package/lib/cjs/identity/secp256k1/index.d.ts.map +1 -1
  58. package/lib/cjs/identity/secp256k1/index.js +48 -1
  59. package/lib/cjs/identity/secp256k1/index.js.map +1 -1
  60. package/lib/cjs/identity/secp256k1/pem.d.ts.map +1 -1
  61. package/lib/cjs/identity/secp256k1/pem.js +1 -2
  62. package/lib/cjs/identity/secp256k1/pem.js.map +1 -1
  63. package/lib/cjs/principal/index.d.ts +15 -0
  64. package/lib/cjs/principal/index.d.ts.map +1 -1
  65. package/lib/cjs/principal/index.js +15 -0
  66. package/lib/cjs/principal/index.js.map +1 -1
  67. package/lib/esm/agent/actor.js +3 -3
  68. package/lib/esm/agent/actor.js.map +1 -1
  69. package/lib/esm/agent/agent/api.d.ts +6 -6
  70. package/lib/esm/agent/agent/api.js +3 -3
  71. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts +30 -0
  72. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.d.ts.map +1 -1
  73. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js +33 -1
  74. package/lib/esm/agent/agent/http/__certificates__/goldenCertificates.js.map +1 -1
  75. package/lib/esm/agent/agent/http/index.d.ts +23 -5
  76. package/lib/esm/agent/agent/http/index.d.ts.map +1 -1
  77. package/lib/esm/agent/agent/http/index.js +203 -84
  78. package/lib/esm/agent/agent/http/index.js.map +1 -1
  79. package/lib/esm/agent/agent/index.d.ts +2 -0
  80. package/lib/esm/agent/agent/index.d.ts.map +1 -1
  81. package/lib/esm/agent/agent/index.js +2 -0
  82. package/lib/esm/agent/agent/index.js.map +1 -1
  83. package/lib/esm/agent/canister-env/index.d.ts +2 -1
  84. package/lib/esm/agent/canister-env/index.d.ts.map +1 -1
  85. package/lib/esm/agent/canister-env/index.js +2 -1
  86. package/lib/esm/agent/canister-env/index.js.map +1 -1
  87. package/lib/esm/agent/canisterStatus/index.d.ts +18 -50
  88. package/lib/esm/agent/canisterStatus/index.d.ts.map +1 -1
  89. package/lib/esm/agent/canisterStatus/index.js +31 -98
  90. package/lib/esm/agent/canisterStatus/index.js.map +1 -1
  91. package/lib/esm/agent/certificate.d.ts +68 -10
  92. package/lib/esm/agent/certificate.d.ts.map +1 -1
  93. package/lib/esm/agent/certificate.js +196 -29
  94. package/lib/esm/agent/certificate.js.map +1 -1
  95. package/lib/esm/agent/constants.d.ts +4 -0
  96. package/lib/esm/agent/constants.d.ts.map +1 -1
  97. package/lib/esm/agent/constants.js +4 -0
  98. package/lib/esm/agent/constants.js.map +1 -1
  99. package/lib/esm/agent/errors.d.ts +9 -2
  100. package/lib/esm/agent/errors.d.ts.map +1 -1
  101. package/lib/esm/agent/errors.js +15 -4
  102. package/lib/esm/agent/errors.js.map +1 -1
  103. package/lib/esm/agent/index.d.ts +97 -5
  104. package/lib/esm/agent/index.d.ts.map +1 -1
  105. package/lib/esm/agent/index.js +97 -5
  106. package/lib/esm/agent/index.js.map +1 -1
  107. package/lib/esm/agent/polling/index.js +1 -1
  108. package/lib/esm/agent/polling/index.js.map +1 -1
  109. package/lib/esm/agent/subnetStatus/index.d.ts +70 -0
  110. package/lib/esm/agent/subnetStatus/index.d.ts.map +1 -0
  111. package/lib/esm/agent/subnetStatus/index.js +178 -0
  112. package/lib/esm/agent/subnetStatus/index.js.map +1 -0
  113. package/lib/esm/agent/utils/readState.d.ts +84 -0
  114. package/lib/esm/agent/utils/readState.d.ts.map +1 -0
  115. package/lib/esm/agent/utils/readState.js +107 -0
  116. package/lib/esm/agent/utils/readState.js.map +1 -0
  117. package/lib/esm/candid/index.d.ts +20 -1
  118. package/lib/esm/candid/index.d.ts.map +1 -1
  119. package/lib/esm/candid/index.js +20 -1
  120. package/lib/esm/candid/index.js.map +1 -1
  121. package/lib/esm/identity/index.d.ts +30 -7
  122. package/lib/esm/identity/index.d.ts.map +1 -1
  123. package/lib/esm/identity/index.js +30 -9
  124. package/lib/esm/identity/index.js.map +1 -1
  125. package/lib/esm/identity/secp256k1/index.d.ts +48 -1
  126. package/lib/esm/identity/secp256k1/index.d.ts.map +1 -1
  127. package/lib/esm/identity/secp256k1/index.js +48 -1
  128. package/lib/esm/identity/secp256k1/index.js.map +1 -1
  129. package/lib/esm/identity/secp256k1/pem.d.ts.map +1 -1
  130. package/lib/esm/identity/secp256k1/pem.js +1 -2
  131. package/lib/esm/identity/secp256k1/pem.js.map +1 -1
  132. package/lib/esm/principal/index.d.ts +15 -0
  133. package/lib/esm/principal/index.d.ts.map +1 -1
  134. package/lib/esm/principal/index.js +15 -0
  135. package/lib/esm/principal/index.js.map +1 -1
  136. package/package.json +3 -1
  137. package/src/agent/actor.ts +3 -3
  138. package/src/agent/agent/api.ts +8 -8
  139. package/src/agent/agent/http/index.ts +259 -97
  140. package/src/agent/agent/index.ts +2 -0
  141. package/src/agent/canister-env/index.ts +2 -1
  142. package/src/agent/canisterStatus/index.ts +46 -196
  143. package/src/agent/certificate.ts +271 -52
  144. package/src/agent/constants.ts +5 -0
  145. package/src/agent/errors.ts +19 -5
  146. package/src/agent/index.ts +97 -5
  147. package/src/agent/polling/index.ts +1 -1
  148. package/src/agent/subnetStatus/index.ts +265 -0
  149. package/src/agent/utils/readState.ts +180 -0
  150. package/src/candid/index.ts +20 -1
  151. package/src/identity/index.ts +30 -10
  152. package/src/identity/secp256k1/index.ts +48 -1
  153. package/src/identity/secp256k1/pem.ts +1 -2
  154. package/src/principal/index.ts +16 -0
@@ -2,116 +2,40 @@ import { Principal } from '#principal';
2
2
  import {
3
3
  CertificateVerificationErrorCode,
4
4
  MissingRootKeyErrorCode,
5
- CertificateNotAuthorizedErrorCode,
6
- LookupErrorCode,
7
- DerKeyLengthMismatchErrorCode,
8
5
  ExternalError,
9
- ProtocolError,
10
- TrustError,
11
6
  AgentError,
12
7
  UnknownError,
13
- HashTreeDecodeErrorCode,
14
8
  UnexpectedErrorCode,
15
9
  InputError,
16
10
  CertificateTimeErrorCode,
17
11
  } from '../errors.ts';
18
12
  import { HttpAgent } from '../agent/http/index.ts';
19
- import {
20
- type Cert,
21
- Certificate,
22
- flatten_forks,
23
- check_canister_ranges,
24
- LookupPathStatus,
25
- lookup_path,
26
- lookupResultToBuffer,
27
- lookup_subtree,
28
- type LabeledHashTree,
29
- LookupSubtreeStatus,
30
- } from '../certificate.ts';
13
+ import { type Cert, Certificate, lookupResultToBuffer } from '../certificate.ts';
31
14
  import * as cbor from '../cbor.ts';
32
- import { decodeLeb128, decodeTime } from '../utils/leb.ts';
33
- import { type DerEncodedPublicKey } from '../auth.ts';
15
+ import { decodeTime } from '../utils/leb.ts';
34
16
  import { utf8ToBytes, bytesToHex } from '@noble/hashes/utils';
17
+ import {
18
+ type BaseSubnetStatus,
19
+ type BaseStatus,
20
+ CustomPath,
21
+ decodeValue,
22
+ decodeControllers,
23
+ encodeMetadataPath,
24
+ isCustomPath,
25
+ lookupNodeKeysFromCertificate,
26
+ IC_ROOT_SUBNET_ID,
27
+ } from '../utils/readState.ts';
35
28
 
36
- /**
37
- * Represents the useful information about a subnet
38
- * @param {string} subnetId the principal id of the canister's subnet
39
- * @param {string[]} nodeKeys the keys of the individual nodes in the subnet
40
- */
41
- export type SubnetStatus = {
42
- // Principal as a string
43
- subnetId: string;
44
- nodeKeys: Map<string, DerEncodedPublicKey>;
45
- metrics?: {
46
- num_canisters: bigint;
47
- canister_state_bytes: bigint;
48
- consumed_cycles_total: {
49
- current: bigint;
50
- deleted: bigint;
51
- };
52
- update_transactions_total: bigint;
53
- };
54
- };
55
-
56
- /**
57
- * Types of an entry on the canisterStatus map.
58
- * An entry of null indicates that the request failed, due to lack of permissions or the result being missing.
59
- */
60
- export type Status =
61
- | string
62
- | Uint8Array
63
- | Date
64
- | Uint8Array[]
65
- | Principal[]
66
- | SubnetStatus
67
- | bigint
68
- | null;
69
-
70
- /**
71
- * Interface to define a custom path. Nested paths will be represented as individual buffers, and can be created from text using TextEncoder.
72
- * @param {string} key the key to use to access the returned value in the canisterStatus map
73
- * @param {Uint8Array[]} path the path to the desired value, represented as an array of buffers
74
- * @param {string} decodeStrategy the strategy to use to decode the returned value
75
- */
76
- export class CustomPath implements CustomPath {
77
- public key: string;
78
- public path: Uint8Array[] | string;
79
- public decodeStrategy: 'cbor' | 'hex' | 'leb128' | 'utf-8' | 'raw';
80
- constructor(
81
- key: string,
82
- path: Uint8Array[] | string,
83
- decodeStrategy: 'cbor' | 'hex' | 'leb128' | 'utf-8' | 'raw',
84
- ) {
85
- this.key = key;
86
- this.path = path;
87
- this.decodeStrategy = decodeStrategy;
88
- }
89
- }
29
+ // Re-export shared types for backwards compatibility
30
+ export { type DecodeStrategy, CustomPath } from '../utils/readState.ts';
90
31
 
91
- /**
92
- * @deprecated Use {@link CustomPath} instead
93
- * @param {string} key the key to use to access the returned value in the canisterStatus map
94
- * @param {string} path the path to the desired value, represented as a string
95
- * @param {string} decodeStrategy the strategy to use to decode the returned value
96
- */
97
- export interface MetaData {
98
- kind: 'metadata';
99
- key: string;
100
- path: string | Uint8Array;
101
- decodeStrategy: 'cbor' | 'hex' | 'leb128' | 'utf-8' | 'raw';
102
- }
32
+ export type SubnetStatus = BaseSubnetStatus;
33
+ export type Status = BaseStatus | SubnetStatus;
103
34
 
104
35
  /**
105
36
  * Pre-configured fields for canister status paths
106
37
  */
107
- export type Path =
108
- | 'time'
109
- | 'controllers'
110
- | 'subnet'
111
- | 'module_hash'
112
- | 'candid'
113
- | MetaData
114
- | CustomPath;
38
+ export type Path = 'time' | 'controllers' | 'subnet' | 'module_hash' | 'candid' | CustomPath;
115
39
 
116
40
  export type StatusMap = Map<Path | string, Status>;
117
41
 
@@ -139,6 +63,10 @@ export type CanisterStatusOptions = {
139
63
  /**
140
64
  * Requests information from a canister's `read_state` endpoint.
141
65
  * Can be used to request information about the canister's controllers, time, module hash, candid interface, and more.
66
+ *
67
+ * > [!WARNING]
68
+ * > Requesting the `subnet` path from the canister status might be deprecated in the future.
69
+ * > Use {@link https://js.icp.build/core/latest/libs/agent/api/namespaces/subnetstatus/functions/request | SubnetStatus.request} to fetch subnet information instead.
142
70
  * @param {CanisterStatusOptions} options The configuration for the canister status request.
143
71
  * @see {@link CanisterStatusOptions} for detailed options.
144
72
  * @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.
@@ -175,7 +103,7 @@ export const request = async (options: CanisterStatusOptions): Promise<StatusMap
175
103
  const certificate = await Certificate.create({
176
104
  certificate: response.certificate,
177
105
  rootKey,
178
- canisterId,
106
+ principal: { canisterId },
179
107
  disableTimeVerification: disableCertificateTimeVerification,
180
108
  agent,
181
109
  });
@@ -199,7 +127,6 @@ export const request = async (options: CanisterStatusOptions): Promise<StatusMap
199
127
  const { path, data } = lookup(certificate, uniquePaths[index]);
200
128
  if (!data) {
201
129
  // Typically, the cert lookup will throw
202
- console.warn(`Expected to find result for path ${path}, but instead found nothing.`);
203
130
  if (typeof path === 'string') {
204
131
  status.set(path, null);
205
132
  } else {
@@ -229,27 +156,8 @@ export const request = async (options: CanisterStatusOptions): Promise<StatusMap
229
156
  }
230
157
  default: {
231
158
  // Check for CustomPath signature
232
- if (typeof path !== 'string' && 'key' in path && 'path' in path) {
233
- switch (path.decodeStrategy) {
234
- case 'raw':
235
- status.set(path.key, data);
236
- break;
237
- case 'leb128': {
238
- status.set(path.key, decodeLeb128(data));
239
- break;
240
- }
241
- case 'cbor': {
242
- status.set(path.key, cbor.decode(data));
243
- break;
244
- }
245
- case 'hex': {
246
- status.set(path.key, bytesToHex(data));
247
- break;
248
- }
249
- case 'utf-8': {
250
- status.set(path.key, new TextDecoder().decode(data));
251
- }
252
- }
159
+ if (isCustomPath(path)) {
160
+ status.set(path.key, decodeValue(data, path.decodeStrategy));
253
161
  }
254
162
  }
255
163
  }
@@ -263,15 +171,11 @@ export const request = async (options: CanisterStatusOptions): Promise<StatusMap
263
171
  ) {
264
172
  throw error;
265
173
  }
266
- if (typeof path !== 'string' && 'key' in path && 'path' in path) {
174
+ if (isCustomPath(path)) {
267
175
  status.set(path.key, null);
268
176
  } else {
269
177
  status.set(path, null);
270
178
  }
271
- console.group();
272
- console.warn(`Expected to find result for path ${path}, but instead found nothing.`);
273
- console.warn(error);
274
- console.groupEnd();
275
179
  }
276
180
  })();
277
181
  });
@@ -282,81 +186,39 @@ export const request = async (options: CanisterStatusOptions): Promise<StatusMap
282
186
  return status;
283
187
  };
284
188
 
189
+ /**
190
+ * Lookup node keys from a certificate for a given canister.
191
+ * The certificate is assumed to be already verified, including whether the canister is in range of the subnet.
192
+ * @param certificate the certificate to lookup node keys from
193
+ * @param canisterId the canister ID to lookup node keys for
194
+ * @param root_key the root key to use to lookup node keys
195
+ * @returns a map of node IDs to public keys
196
+ */
285
197
  export const fetchNodeKeys = (
286
198
  certificate: Uint8Array,
287
199
  canisterId: Principal,
288
200
  root_key?: Uint8Array,
289
- ): SubnetStatus => {
201
+ ): BaseSubnetStatus => {
290
202
  if (!canisterId._isPrincipal) {
291
203
  throw InputError.fromCode(new UnexpectedErrorCode('Invalid canisterId'));
292
204
  }
293
205
  const cert = cbor.decode<Cert>(certificate);
294
- const tree = cert.tree;
295
- let delegation = cert.delegation;
206
+ const { delegation } = cert;
296
207
  let subnetId: Principal;
297
208
  if (delegation && delegation.subnet_id) {
298
209
  subnetId = Principal.fromUint8Array(new Uint8Array(delegation.subnet_id));
299
- }
300
-
301
- // On local replica, with System type subnet, there is no delegation
302
- else if (!delegation && typeof root_key !== 'undefined') {
210
+ } else if (!delegation && typeof root_key !== 'undefined') {
211
+ // On local replica, with System type subnet, there is no delegation
303
212
  subnetId = Principal.selfAuthenticating(new Uint8Array(root_key));
304
- delegation = {
305
- subnet_id: subnetId.toUint8Array(),
306
- certificate: new Uint8Array(0),
307
- };
308
- }
309
- // otherwise use default NNS subnet id
310
- else {
311
- subnetId = Principal.selfAuthenticating(
312
- Principal.fromText(
313
- 'tdb26-jop6k-aogll-7ltgs-eruif-6kk7m-qpktf-gdiqx-mxtrf-vb5e6-eqe',
314
- ).toUint8Array(),
315
- );
316
- delegation = {
317
- subnet_id: subnetId.toUint8Array(),
318
- certificate: new Uint8Array(0),
319
- };
320
- }
321
-
322
- const canisterInRange = check_canister_ranges({ canisterId, subnetId, tree });
323
- if (!canisterInRange) {
324
- throw TrustError.fromCode(new CertificateNotAuthorizedErrorCode(canisterId, subnetId));
213
+ } else {
214
+ // otherwise use default NNS subnet id
215
+ subnetId = IC_ROOT_SUBNET_ID;
325
216
  }
326
217
 
327
- const subnetLookupResult = lookup_subtree(['subnet', delegation.subnet_id, 'node'], tree);
328
- if (subnetLookupResult.status !== LookupSubtreeStatus.Found) {
329
- throw ProtocolError.fromCode(new LookupErrorCode('Node not found', subnetLookupResult.status));
330
- }
331
- if (subnetLookupResult.value instanceof Uint8Array) {
332
- throw UnknownError.fromCode(new HashTreeDecodeErrorCode('Invalid node tree'));
333
- }
334
-
335
- // The forks are all labeled trees with the <node_id> label
336
- const nodeForks = flatten_forks(subnetLookupResult.value) as Array<LabeledHashTree>;
337
- const nodeKeys = new Map<string, DerEncodedPublicKey>();
338
-
339
- nodeForks.forEach(fork => {
340
- const node_id = Principal.from(fork[1]).toText();
341
- const publicKeyLookupResult = lookup_path(['public_key'], fork[2]);
342
- if (publicKeyLookupResult.status !== LookupPathStatus.Found) {
343
- throw ProtocolError.fromCode(
344
- new LookupErrorCode('Public key not found', publicKeyLookupResult.status),
345
- );
346
- }
347
-
348
- const derEncodedPublicKey = publicKeyLookupResult.value;
349
- if (derEncodedPublicKey.byteLength !== 44) {
350
- throw ProtocolError.fromCode(
351
- new DerKeyLengthMismatchErrorCode(44, derEncodedPublicKey.byteLength),
352
- );
353
- } else {
354
- nodeKeys.set(node_id, derEncodedPublicKey as DerEncodedPublicKey);
355
- }
356
- });
218
+ const nodeKeys = lookupNodeKeysFromCertificate(cert, subnetId);
357
219
 
358
220
  return {
359
- subnetId: Principal.fromUint8Array(new Uint8Array(delegation.subnet_id)).toText(),
221
+ subnetId: subnetId.toText(),
360
222
  nodeKeys,
361
223
  };
362
224
  };
@@ -381,16 +243,12 @@ export const encodePath = (path: Path, canisterId: Principal): Uint8Array[] => {
381
243
  ];
382
244
  default: {
383
245
  // Check for CustomPath signature
384
- if ('key' in path && 'path' in path) {
246
+ if (isCustomPath(path)) {
385
247
  // For simplified metadata queries
386
248
  if (typeof path['path'] === 'string' || path['path'] instanceof Uint8Array) {
387
- const metaPath = path.path;
388
- const encoded = typeof metaPath === 'string' ? utf8ToBytes(metaPath) : metaPath;
389
-
390
- return [utf8ToBytes('canister'), canisterUint8Array, utf8ToBytes('metadata'), encoded];
391
-
392
- // For non-metadata, return the provided custompath
249
+ return encodeMetadataPath(path.path, canisterUint8Array);
393
250
  } else {
251
+ // For non-metadata, return the provided custom path
394
252
  return path['path'];
395
253
  }
396
254
  }
@@ -402,11 +260,3 @@ export const encodePath = (path: Path, canisterId: Principal): Uint8Array[] => {
402
260
  ),
403
261
  );
404
262
  };
405
-
406
- // Controllers are CBOR-encoded buffers
407
- const decodeControllers = (buf: Uint8Array): Principal[] => {
408
- const controllersRaw = cbor.decode<Uint8Array[]>(buf);
409
- return controllersRaw.map(buf => {
410
- return Principal.fromUint8Array(buf);
411
- });
412
- };