-
Notifications
You must be signed in to change notification settings - Fork 42
Closed
Milestone
Description
Running this code
import { IDL } from '@dfinity/candid';
const RecursiveBlob = IDL.Rec();
RecursiveBlob.fill(IDL.Vec(IDL.Nat8));
const UsesRecursiveBlob = IDL.Rec();
UsesRecursiveBlob.fill(
IDL.Record({
myBlob: RecursiveBlob
})
);
const RecursiveRecord = IDL.Rec();
RecursiveRecord.fill(
IDL.Record({
field1: IDL.Vec(IDL.Nat8),
field2: IDL.Vec(IDL.Nat8)
})
);
const RecReturn = IDL.Rec();
RecReturn.fill(
IDL.Opt(
IDL.Record({
rec_rec: RecursiveRecord,
rec_blob: UsesRecursiveBlob
})
)
);
const toEncode = [];
const encoded = IDL.encode([RecReturn], [toEncode]);
console.log(encoded);
const decoded = IDL.decode([RecReturn], encoded);
console.log(decoded);
gives the following error
Uint8Array(46) [
68, 73, 68, 76, 5, 110, 4, 108, 2, 183,
156, 186, 132, 8, 2, 184, 156, 186, 132, 8,
2, 108, 1, 233, 221, 211, 226, 6, 4, 108,
2, 161, 191, 159, 179, 2, 1, 236, 251, 182,
207, 6, 3, 1, 0, 0
]
node_modules/@dfinity/candid/src/idl.ts:1734
throw new Error('Illegal op_code: ' + ty);
^
Error: Illegal op_code: 1
at readTypeTable (node_modules/@dfinity/candid/src/idl.ts:1734:17)
at Object.decode (node_modules/@dfinity/candid/src/idl.ts:1745:32)
at <anonymous> (test.ts:35:21)
at ModuleJob.run (node:internal/modules/esm/module_job:271:25)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)
Node.js v22.14.0
Metadata
Metadata
Assignees
Labels
No labels