It worked, we can now import it. Now I have a new problem when creating the verifyCertification
object. Below I have copied the code to create the verifyCertification object, the error and the content of the necessary variables. It seems an encoding problem but we cannot figure out:
verifyCertification
object creation code:
const nnsSubnet = pic.getNnsSubnet();
if (!nnsSubnet) {
throw new Error('NNS subnet not found');
}
const rootKey = await pic.getPubKey(nnsSubnet.id);
let data_cert: []|[DataCertificate] = await can.icrc3_get_tip_certificate();// : async ?Trechain.DataCertificate
if (data_cert != null) {
let ddddd: undefined|DataCertificate = data_cert[0];
if (typeof ddddd != "undefined") {
const certificate = ddddd.certificate;
const witness = ddddd.hash_tree;
const tree = await verifyCertification({
canisterId: Principal.fromText(canCanisterId.toString()),
encodedCertificate: new Uint8Array(certificate).buffer,
encodedTree: new Uint8Array(witness).buffer,
rootKey: rootKey,//pubKey,//agent.rootKey,
maxCertificateTimeOffsetMs: 50000,
});
Error:
unexpected end of buffer
118 | console.log("inputs:", inputs)
119 |
> 120 | const tree = await verifyCertification({
| ^
121 | canisterId: Principal.fromText(canCanisterId.toString()),
122 | encodedCertificate: new Uint8Array(certificate),
123 | encodedTree: new Uint8Array(witness),
at eob (node_modules/@dfinity/candid/src/utils/leb128.ts:12:9)
at safeReadUint8 (node_modules/@dfinity/candid/src/utils/leb128.ts:34:5)
at lebDecode (node_modules/@dfinity/candid/src/utils/leb128.ts:80:12)
at p (node_modules/@dfinity/certificate-verification/dist/certificate-verification.js:28:14)
at E (node_modules/@dfinity/certificate-verification/dist/certificate-verification.js:25:10)
at Object.<anonymous> (cert.spec.ts:120:22)
Content of variables used to create verifyCertification
object:
inputs: {
canisterId: Principal {
_arr: Uint8Array(10) [
255, 255, 255, 255, 255,
208, 0, 0, 1, 1
],
_isPrincipal: true
},
encodedCertificate: Uint8Array(794) [
217, 217, 247, 163, 100, 116, 114, 101, 101, 131, 1, 131,
1, 131, 1, 131, 2, 72, 99, 97, 110, 105, 115, 116,
101, 114, 131, 2, 74, 255, 255, 255, 255, 255, 208, 0,
0, 1, 1, 131, 1, 131, 1, 131, 2, 78, 99, 101,
114, 116, 105, 102, 105, 101, 100, 95, 100, 97, 116, 97,
130, 3, 88, 32, 131, 224, 242, 181, 74, 123, 162, 150,
129, 46, 207, 222, 77, 5, 126, 76, 171, 119, 133, 88,
203, 114, 250, 36, 92, 227, 50, 166, 207, 20, 176, 31,
130, 4, 88, 32,
... 694 more items
],
encodedTree: Uint8Array(82) [
217, 217, 247, 131, 1, 131, 2, 79, 108, 97, 115, 116,
95, 98, 108, 111, 99, 107, 95, 104, 97, 115, 104, 130,
3, 88, 32, 224, 251, 149, 223, 148, 8, 157, 207, 254,
39, 44, 50, 148, 155, 66, 210, 219, 241, 251, 28, 9,
232, 98, 236, 184, 140, 126, 33, 63, 173, 98, 104, 131,
2, 80, 108, 97, 115, 116, 95, 98, 108, 111, 99, 107,
95, 105, 110, 100, 101, 120, 130, 3, 65, 1
],
rootKey: Uint8Array(133) [
48, 129, 130, 48, 29, 6, 13, 43, 6, 1, 4, 1,
130, 220, 124, 5, 3, 1, 2, 1, 6, 12, 43, 6,
1, 4, 1, 130, 220, 124, 5, 3, 2, 1, 3, 97,
0, 173, 246, 86, 56, 165, 48, 86, 178, 34, 44, 145,
187, 36, 87, 176, 39, 75, 202, 149, 25, 138, 90, 203,
218, 223, 231, 253, 114, 23, 143, 6, 155, 222, 168, 217,
158, 148, 121, 216, 8, 122, 38, 134, 252, 129, 191, 60,
75, 17, 254, 39, 85, 112, 212, 129, 241, 105, 143, 121,
212, 104, 175, 224,
... 33 more items
],
maxCertificateTimeOffsetMs: 500000000
}