Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added dfinity-candid-3.0.0-patch.tgz
Binary file not shown.
24 changes: 12 additions & 12 deletions idl_instance_1/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions idl_instance_1/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"main": "index.js",
"dependencies": {
"@dfinity/candid": "^2.3.0"
"@dfinity/candid": "file:../dfinity-candid-3.0.0-patch.tgz"
}
}
24 changes: 12 additions & 12 deletions idl_instance_2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions idl_instance_2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"main": "index.js",
"dependencies": {
"@dfinity/candid": "^2.3.0"
"@dfinity/candid": "file:../dfinity-candid-3.0.0-patch.tgz"
}
}
18 changes: 14 additions & 4 deletions test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import { IDL as IDL1 } from "./idl_instance_1";
import { IDL as IDL2 } from "./idl_instance_2";

function test(): Uint8Array {
function test(): [Uint8Array, Uint8Array] {
const blobIDL1 = IDL1.Vec(IDL1.Nat8);
const blobIDL2 = IDL2.Vec(IDL2.Nat8);

const encoded = IDL1.encode([blobIDL1], [[1, 2, 3]]);
const decoded = IDL2.decode([blobIDL1], encoded);
// this was fine even before the patch
const decoded = IDL2.decode([blobIDL2], encoded);

return decoded[0] as unknown as Uint8Array;
// this was broken before the patch
const decodedUsingIdl1Types = IDL2.decode([blobIDL1], encoded);

console.log({ decoded, decodedUsingIdl1Types });

return [
decoded[0] as unknown as Uint8Array,
decodedUsingIdl1Types[0] as unknown as Uint8Array,
];
}

const result = test();

console.log(result);
// Should print out something like: Uint8Array(3) [ 1, 2, 3 ]
// Should print out something like: [ Uint8Array(3) [ 1, 2, 3 ], Uint8Array(3) [ 1, 2, 3 ] ]