Skip to content

Commit

Permalink
make deno 2.0 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrokonrad committed Nov 18, 2024
1 parent 868fb09 commit 95893df
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 353 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v2

- name: Use Deno
uses: denoland/setup-deno@v1
uses: denoland/setup-deno@v2

- name: Build Core
run: deno task build:core
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"tasks": {
"build": "deno run --allow-env --allow-write --allow-read --allow-net --allow-run build.ts",
"build:core": "cd src/core/libs/cardano_multiplatform_lib && deno run -A https://raw.githubusercontent.com/spacebudz/wasmbuild/a0fec73985b0f0a9120b5077e292963d513795d4/main.ts --out ./; cd ../cardano_message_signing && deno run -A https://raw.githubusercontent.com/spacebudz/wasmbuild/a0fec73985b0f0a9120b5077e292963d513795d4/main.ts --out ./",
"build:core": "cd src/core/libs/cardano_multiplatform_lib && deno run -A https://raw.githubusercontent.com/spacebudz/wasmbuild/94be5fad4afcbce42fa1bc940bf30a11c3bf9e65/main.ts --out ./; cd ../cardano_message_signing && deno run -A https://raw.githubusercontent.com/spacebudz/wasmbuild/94be5fad4afcbce42fa1bc940bf30a11c3bf9e65/main.ts --out ./",
"publish": "deno task build && deno task test && npm publish dist",
"test": "deno test --allow-env --allow-read --allow-net tests",
"test:core": "cd src/core/libs/cardano_multiplatform_lib && cargo test; cd ../cardano_message_signing && cargo test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3818,7 +3818,8 @@ async function instantiateModule(opts) {
const isFile = wasmUrl.protocol === "file:";

// make file urls work in Node via dnt
const isNode = globalThis.process?.versions?.node != null;
const isNode = globalThis.process?.versions?.node != null &&
typeof Deno === "undefined";
if (isNode && isFile) {
// requires fs to be set externally on globalThis
const wasmCode = fs.readFileSync(wasmUrl);
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
// @generated file from wasmbuild -- do not edit
// deno-lint-ignore-file
// deno-fmt-ignore-file
// source-hash: bfd95ebe53d43f00db0f8f58f0273ee50ec6421a
// source-hash: b5577307687d9545e9f9dcf6952c9999ef861a4f
let wasm;

const heap = new Array(128).fill(undefined);

heap.push(undefined, null, true, false);

function getObject(idx) {
return heap[idx];
}

let heap_next = heap.length;

function dropObject(idx) {
if (idx < 132) return;
heap[idx] = heap_next;
heap_next = idx;
}

function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}

const cachedTextDecoder = new TextDecoder("utf-8", {
ignoreBOM: true,
fatal: true,
Expand All @@ -24,12 +46,6 @@ function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}

const heap = new Array(128).fill(undefined);

heap.push(undefined, null, true, false);

let heap_next = heap.length;

function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
Expand All @@ -39,22 +55,6 @@ function addHeapObject(obj) {
return idx;
}

function getObject(idx) {
return heap[idx];
}

function dropObject(idx) {
if (idx < 132) return;
heap[idx] = heap_next;
heap_next = idx;
}

function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}

let WASM_VECTOR_LEN = 0;

const cachedTextEncoder = new TextEncoder("utf-8");
Expand Down Expand Up @@ -207,11 +207,12 @@ function makeMutClosure(arg0, arg1, dtor, f) {
return real;
}
function __wbg_adapter_30(arg0, arg1, arg2) {
wasm.wasm_bindgen__convert__closures__invoke1_mut__h9aff1b1babe72eb2(
arg0,
arg1,
addHeapObject(arg2),
);
wasm
._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h9e9f569ee887aad3(
arg0,
arg1,
addHeapObject(arg2),
);
}

function _assertClass(instance, klass) {
Expand Down Expand Up @@ -834,7 +835,7 @@ function handleError(f, args) {
}
}
function __wbg_adapter_1684(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__he7061673dd7691f9(
wasm.wasm_bindgen__convert__closures__invoke2_mut__h47a64803251cf63a(
arg0,
arg1,
addHeapObject(arg2),
Expand Down Expand Up @@ -5295,7 +5296,7 @@ export class Data {
*/
static new(plutus_data) {
_assertClass(plutus_data, PlutusData);
const ret = wasm.data_new(plutus_data.ptr);
const ret = wasm.data_get(plutus_data.ptr);
return Data.__wrap(ret);
}
/**
Expand Down Expand Up @@ -11010,7 +11011,7 @@ export class MultiHostName {
*/
static new(dns_name) {
_assertClass(dns_name, DNSRecordSRV);
const ret = wasm.multihostname_new(dns_name.ptr);
const ret = wasm.anchor_anchor_url(dns_name.ptr);
return MultiHostName.__wrap(ret);
}
}
Expand Down Expand Up @@ -11846,7 +11847,7 @@ export class NewConstitution {
*/
static new(hash) {
_assertClass(hash, DataHash);
const ret = wasm.newconstitution_new(hash.ptr);
const ret = wasm.genesiskeydelegation_vrf_keyhash(hash.ptr);
return NewConstitution.__wrap(ret);
}
}
Expand Down Expand Up @@ -12266,7 +12267,7 @@ export class ParameterChangeAction {
* @returns {ProtocolParamUpdate}
*/
protocol_param_update() {
const ret = wasm.parameterchangeaction_protocol_param_update(this.ptr);
const ret = wasm.governanceaction_new_parameter_change_action(this.ptr);
return ProtocolParamUpdate.__wrap(ret);
}
/**
Expand All @@ -12275,7 +12276,9 @@ export class ParameterChangeAction {
*/
static new(protocol_param_update) {
_assertClass(protocol_param_update, ProtocolParamUpdate);
const ret = wasm.parameterchangeaction_new(protocol_param_update.ptr);
const ret = wasm.governanceaction_new_parameter_change_action(
protocol_param_update.ptr,
);
return ParameterChangeAction.__wrap(ret);
}
}
Expand Down Expand Up @@ -17642,7 +17645,7 @@ export class ScriptAll {
*/
static new(native_scripts) {
_assertClass(native_scripts, NativeScripts);
const ret = wasm.scriptall_new(native_scripts.ptr);
const ret = wasm.scriptall_native_scripts(native_scripts.ptr);
return ScriptAll.__wrap(ret);
}
}
Expand Down Expand Up @@ -17787,7 +17790,7 @@ export class ScriptAny {
*/
static new(native_scripts) {
_assertClass(native_scripts, NativeScripts);
const ret = wasm.scriptall_new(native_scripts.ptr);
const ret = wasm.scriptall_native_scripts(native_scripts.ptr);
return ScriptAny.__wrap(ret);
}
}
Expand Down Expand Up @@ -18559,7 +18562,9 @@ export class ScriptPubkey {
*/
static new(addr_keyhash) {
_assertClass(addr_keyhash, Ed25519KeyHash);
const ret = wasm.scriptpubkey_new(addr_keyhash.ptr);
const ret = wasm.regcommitteehotkeycert_committee_cold_keyhash(
addr_keyhash.ptr,
);
return ScriptPubkey.__wrap(ret);
}
}
Expand Down Expand Up @@ -18697,7 +18702,7 @@ export class ScriptRef {
*/
static new(script) {
_assertClass(script, Script);
const ret = wasm.scriptref_new(script.ptr);
const ret = wasm.scriptref_get(script.ptr);
return ScriptRef.__wrap(ret);
}
/**
Expand Down Expand Up @@ -25026,7 +25031,7 @@ export class TreasuryWithdrawalsAction {
* @returns {TreasuryWithdrawals}
*/
withdrawals() {
const ret = wasm.treasurywithdrawalsaction_withdrawals(this.ptr);
const ret = wasm.treasurywithdrawalsaction_new(this.ptr);
return TreasuryWithdrawals.__wrap(ret);
}
/**
Expand Down Expand Up @@ -25496,7 +25501,9 @@ export class UnregCommitteeHotKeyCert {
*/
static new(committee_cold_keyhash) {
_assertClass(committee_cold_keyhash, Ed25519KeyHash);
const ret = wasm.scriptpubkey_new(committee_cold_keyhash.ptr);
const ret = wasm.regcommitteehotkeycert_committee_cold_keyhash(
committee_cold_keyhash.ptr,
);
return UnregCommitteeHotKeyCert.__wrap(ret);
}
}
Expand Down Expand Up @@ -26655,14 +26662,14 @@ export class Vkey {
*/
static new(pk) {
_assertClass(pk, PublicKey);
const ret = wasm.vkey_new(pk.ptr);
const ret = wasm.genesiskeydelegation_vrf_keyhash(pk.ptr);
return Vkey.__wrap(ret);
}
/**
* @returns {PublicKey}
*/
public_key() {
const ret = wasm.vkey_public_key(this.ptr);
const ret = wasm.genesiskeydelegation_vrf_keyhash(this.ptr);
return PublicKey.__wrap(ret);
}
}
Expand Down Expand Up @@ -28063,13 +28070,13 @@ export class Withdrawals {

const imports = {
__wbindgen_placeholder__: {
__wbindgen_object_drop_ref: function (arg0) {
takeObject(arg0);
},
__wbindgen_string_new: function (arg0, arg1) {
const ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
},
__wbindgen_object_drop_ref: function (arg0) {
takeObject(arg0);
},
__wbindgen_json_parse: function (arg0, arg1) {
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
Expand Down Expand Up @@ -28158,6 +28165,10 @@ const imports = {
const ret = false;
return ret;
},
__wbg_static_accessor_NODE_MODULE_06b864c18e8ae506: function () {
const ret = module;
return addHeapObject(ret);
},
__wbg_process_5615a087a47ba544: function (arg0) {
const ret = getObject(arg0).process;
return addHeapObject(ret);
Expand Down Expand Up @@ -28193,10 +28204,6 @@ const imports = {
const ret = getObject(arg0).msCrypto;
return addHeapObject(ret);
},
__wbg_static_accessor_NODE_MODULE_06b864c18e8ae506: function () {
const ret = module;
return addHeapObject(ret);
},
__wbg_randomFillSync_2f6909f8132a175d: function () {
return handleError(function (arg0, arg1, arg2) {
getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
Expand Down Expand Up @@ -28370,8 +28377,8 @@ const imports = {
const ret = wasm.memory;
return addHeapObject(ret);
},
__wbindgen_closure_wrapper7045: function (arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 200, __wbg_adapter_30);
__wbindgen_closure_wrapper7096: function (arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 225, __wbg_adapter_30);
return addHeapObject(ret);
},
},
Expand Down Expand Up @@ -28658,7 +28665,8 @@ async function instantiateModule(opts) {
const isFile = wasmUrl.protocol === "file:";

// make file urls work in Node via dnt
const isNode = globalThis.process?.versions?.node != null;
const isNode = globalThis.process?.versions?.node != null &&
typeof Deno === "undefined";
if (isNode && isFile) {
// requires fs to be set externally on globalThis
const wasmCode = fs.readFileSync(wasmUrl);
Expand Down
Binary file not shown.
Loading

0 comments on commit 95893df

Please sign in to comment.