You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wasm_url.protocol was an empty string (thanks to the local dev server / NextJS). Might it be worth including "" as a case here?
I'm getting the following error from my local dev server. Strangely, I use another "wasmbuilt" module in the same project, and it works as expected. Not sure why the other is producing this particular error.
Uncaught (in promise) Error: Unsupported protocol:
at instantiateModule (mod.generated.js:286:19)
at eval (mod.generated.js:232:41)
at instantiateWithInstance (mod.generated.js:245:11)
at instantiate (mod.generated.js:212:19)
at Ss58 (mod.js:10:90)
at eval (submitAndWatchExtrinsic.js:24:85)
at Runtime.eval (submitAndWatchExtrinsic.js:31:11)
at eval (run.js:58:59)
at async eval (run.js:66:46)
at async Promise.all (:3000/index 2)
at async eval (run.js:66:46)
at async Promise.all (:3000/index 5)
at async eval (run.js:66:46)
at async Promise.all (:3000/index 2)
at async eval (run.js:66:46)
at async Module.value (run.js:24:44)
Below are both of the JS binding files:
The one that works
// @generated file from wasmbuild -- do not edit// deno-lint-ignore-file// deno-fmt-ignore-file// source-hash: 03396dbc62654de6e23aa312b7716c60b0b3ef0eimport*asdntShimfrom"../_dnt.shims.js";letwasm;constheap=newArray(32).fill(undefined);heap.push(undefined,null,true,false);functiongetObject(idx){returnheap[idx];}letheap_next=heap.length;functiondropObject(idx){if(idx<36)return;heap[idx]=heap_next;heap_next=idx;}functiontakeObject(idx){constret=getObject(idx);dropObject(idx);returnret;}constcachedTextDecoder=newTextDecoder("utf-8",{ignoreBOM: true,fatal: true,});cachedTextDecoder.decode();letcachedUint8Memory0;functiongetUint8Memory0(){if(cachedUint8Memory0.byteLength===0){cachedUint8Memory0=newUint8Array(wasm.memory.buffer);}returncachedUint8Memory0;}functiongetStringFromWasm0(ptr,len){returncachedTextDecoder.decode(getUint8Memory0().subarray(ptr,ptr+len));}functionaddHeapObject(obj){if(heap_next===heap.length)heap.push(heap.length+1);constidx=heap_next;heap_next=heap[idx];heap[idx]=obj;returnidx;}letWASM_VECTOR_LEN=0;functionpassArray8ToWasm0(arg,malloc){constptr=malloc(arg.length*1);getUint8Memory0().set(arg,ptr/1);WASM_VECTOR_LEN=arg.length;returnptr;}/** * @param {Uint8Array} data * @returns {Uint8Array} */exportfunctionblake2_128(data){constptr0=passArray8ToWasm0(data,wasm.__wbindgen_malloc);constlen0=WASM_VECTOR_LEN;constret=wasm.blake2_128(ptr0,len0);returntakeObject(ret);}/** * @param {Uint8Array} data * @returns {Uint8Array} */exportfunctionblake2_256(data){constptr0=passArray8ToWasm0(data,wasm.__wbindgen_malloc);constlen0=WASM_VECTOR_LEN;constret=wasm.blake2_256(ptr0,len0);returntakeObject(ret);}/** * @param {Uint8Array} data * @returns {Uint8Array} */exportfunctionblake2_128Concat(data){constptr0=passArray8ToWasm0(data,wasm.__wbindgen_malloc);constlen0=WASM_VECTOR_LEN;constret=wasm.blake2_128Concat(ptr0,len0);returntakeObject(ret);}/** * @param {Uint8Array} data * @returns {Uint8Array} */exportfunctiontwox128(data){constptr0=passArray8ToWasm0(data,wasm.__wbindgen_malloc);constlen0=WASM_VECTOR_LEN;constret=wasm.twox128(ptr0,len0);returntakeObject(ret);}/** * @param {Uint8Array} data * @returns {Uint8Array} */exportfunctiontwox256(data){constptr0=passArray8ToWasm0(data,wasm.__wbindgen_malloc);constlen0=WASM_VECTOR_LEN;constret=wasm.twox256(ptr0,len0);returntakeObject(ret);}/** * @param {Uint8Array} data * @returns {Uint8Array} */exportfunctiontwox64Concat(data){constptr0=passArray8ToWasm0(data,wasm.__wbindgen_malloc);constlen0=WASM_VECTOR_LEN;constret=wasm.twox64Concat(ptr0,len0);returntakeObject(ret);}constcachedTextEncoder=newTextEncoder("utf-8");constencodeString=function(arg,view){returncachedTextEncoder.encodeInto(arg,view);};functionpassStringToWasm0(arg,malloc,realloc){if(realloc===undefined){constbuf=cachedTextEncoder.encode(arg);constptr=malloc(buf.length);getUint8Memory0().subarray(ptr,ptr+buf.length).set(buf);WASM_VECTOR_LEN=buf.length;returnptr;}letlen=arg.length;letptr=malloc(len);constmem=getUint8Memory0();letoffset=0;for(;offset<len;offset++){constcode=arg.charCodeAt(offset);if(code>0x7F)break;mem[ptr+offset]=code;}if(offset!==len){if(offset!==0){arg=arg.slice(offset);}ptr=realloc(ptr,len,len=offset+arg.length*3);constview=getUint8Memory0().subarray(ptr+offset,ptr+len);constret=encodeString(arg,view);offset+=ret.written;}WASM_VECTOR_LEN=offset;returnptr;}letcachedInt32Memory0;functiongetInt32Memory0(){if(cachedInt32Memory0.byteLength===0){cachedInt32Memory0=newInt32Array(wasm.memory.buffer);}returncachedInt32Memory0;}constimports={__wbindgen_placeholder__: {__wbindgen_object_drop_ref: function(arg0){takeObject(arg0);},__wbg_new_693216e109162396: function(){constret=newError();returnaddHeapObject(ret);},__wbg_stack_0ddaca5d1abfb52f: function(arg0,arg1){constret=getObject(arg1).stack;constptr0=passStringToWasm0(ret,wasm.__wbindgen_malloc,wasm.__wbindgen_realloc);constlen0=WASM_VECTOR_LEN;getInt32Memory0()[arg0/4+1]=len0;getInt32Memory0()[arg0/4+0]=ptr0;},__wbg_error_09919627ac0992f5: function(arg0,arg1){try{console.error(getStringFromWasm0(arg0,arg1));}finally{wasm.__wbindgen_free(arg0,arg1);}},__wbg_buffer_de1150f91b23aa89: function(arg0){constret=getObject(arg0).buffer;returnaddHeapObject(ret);},__wbg_newwithbyteoffsetandlength_9ca61320599a2c84: function(arg0,arg1,arg2){constret=newUint8Array(getObject(arg0),arg1>>>0,arg2>>>0);returnaddHeapObject(ret);},__wbg_new_97cf52648830a70d: function(arg0){constret=newUint8Array(getObject(arg0));returnaddHeapObject(ret);},__wbindgen_throw: function(arg0,arg1){thrownewError(getStringFromWasm0(arg0,arg1));},__wbindgen_memory: function(){constret=wasm.memory;returnaddHeapObject(ret);},},};constwasm_url=newURL("mod_bg.wasm",import.meta.url);/** * Decompression callback * * @callback decompressCallback * @param {Uint8Array} compressed * @return {Uint8Array} decompressed *//** Instantiates an instance of the Wasm module returning its functions. * @remarks It is safe to call this multiple times and once successfully * loaded it will always return a reference to the same object. * @param {decompressCallback=} transform */exportasyncfunctioninstantiate(transform){return(awaitinstantiateWithInstance(transform)).exports;}letinstanceWithExports;letlastLoadPromise;/** Instantiates an instance of the Wasm module along with its exports. * @remarks It is safe to call this multiple times and once successfully * loaded it will always return a reference to the same object. * @param {decompressCallback=} transform * @returns {Promise<{ * instance: WebAssembly.Instance; * exports: { blake2_128: typeof blake2_128; blake2_256: typeof blake2_256; blake2_128Concat: typeof blake2_128Concat; twox128: typeof twox128; twox256: typeof twox256; twox64Concat: typeof twox64Concat } * }>} */exportfunctioninstantiateWithInstance(transform){if(instanceWithExports!=null){returnPromise.resolve(instanceWithExports);}if(lastLoadPromise==null){lastLoadPromise=(async()=>{try{constinstance=(awaitinstantiateModule(transform)).instance;wasm=instance.exports;cachedInt32Memory0=newInt32Array(wasm.memory.buffer);cachedUint8Memory0=newUint8Array(wasm.memory.buffer);instanceWithExports={
instance,exports: getWasmInstanceExports(),};returninstanceWithExports;}finally{lastLoadPromise=null;}})();}returnlastLoadPromise;}functiongetWasmInstanceExports(){return{
blake2_128,
blake2_256,
blake2_128Concat,
twox128,
twox256,
twox64Concat,};}/** Gets if the Wasm module has been instantiated. */exportfunctionisInstantiated(){returninstanceWithExports!=null;}asyncfunctioninstantiateModule(transform){switch(wasm_url.protocol){case"file:": {if(typeofdntShim.Deno!=="object"){thrownewError("file urls are not supported in this environment");}if("permissions"indntShim.Deno){awaitdntShim.Deno.permissions.request({name: "read",path: wasm_url});}constwasmCode=awaitdntShim.Deno.readFile(wasm_url);returnWebAssembly.instantiate(!transform ? wasmCode : transform(wasmCode),imports);}case"https:":
case"http:": {if(typeofdntShim.Deno==="object"&&"permissions"indntShim.Deno){awaitdntShim.Deno.permissions.request({name: "net",host: wasm_url.host});}constwasmResponse=awaitfetch(wasm_url);if(transform){constwasmCode=newUint8Array(awaitwasmResponse.arrayBuffer());returnWebAssembly.instantiate(transform(wasmCode),imports);}if(wasmResponse.headers.get("content-type")?.toLowerCase().startsWith("application/wasm")){returnWebAssembly.instantiateStreaming(wasmResponse,imports);}else{returnWebAssembly.instantiate(awaitwasmResponse.arrayBuffer(),imports);}}default:
thrownewError(`Unsupported protocol: ${wasm_url.protocol}`);}}//# sourceMappingURL=mod.generated.js.map
The one that does not work
// @generated file from wasmbuild -- do not edit// deno-lint-ignore-file// deno-fmt-ignore-file// source-hash: 2acb6246693ffbe50215ec91ed141cc7e96e8f48import*asdntShimfrom"../_dnt.shims.js";letwasm;constcachedTextDecoder=newTextDecoder("utf-8",{ignoreBOM: true,fatal: true,});cachedTextDecoder.decode();letcachedUint8Memory0;functiongetUint8Memory0(){if(cachedUint8Memory0.byteLength===0){cachedUint8Memory0=newUint8Array(wasm.memory.buffer);}returncachedUint8Memory0;}functiongetStringFromWasm0(ptr,len){returncachedTextDecoder.decode(getUint8Memory0().subarray(ptr,ptr+len));}constheap=newArray(32).fill(undefined);heap.push(undefined,null,true,false);letheap_next=heap.length;functionaddHeapObject(obj){if(heap_next===heap.length)heap.push(heap.length+1);constidx=heap_next;heap_next=heap[idx];heap[idx]=obj;returnidx;}functiongetObject(idx){returnheap[idx];}functiondropObject(idx){if(idx<36)return;heap[idx]=heap_next;heap_next=idx;}functiontakeObject(idx){constret=getObject(idx);dropObject(idx);returnret;}letWASM_VECTOR_LEN=0;constcachedTextEncoder=newTextEncoder("utf-8");constencodeString=function(arg,view){returncachedTextEncoder.encodeInto(arg,view);};functionpassStringToWasm0(arg,malloc,realloc){if(realloc===undefined){constbuf=cachedTextEncoder.encode(arg);constptr=malloc(buf.length);getUint8Memory0().subarray(ptr,ptr+buf.length).set(buf);WASM_VECTOR_LEN=buf.length;returnptr;}letlen=arg.length;letptr=malloc(len);constmem=getUint8Memory0();letoffset=0;for(;offset<len;offset++){constcode=arg.charCodeAt(offset);if(code>0x7F)break;mem[ptr+offset]=code;}if(offset!==len){if(offset!==0){arg=arg.slice(offset);}ptr=realloc(ptr,len,len=offset+arg.length*3);constview=getUint8Memory0().subarray(ptr+offset,ptr+len);constret=encodeString(arg,view);offset+=ret.written;}WASM_VECTOR_LEN=offset;returnptr;}letcachedInt32Memory0;functiongetInt32Memory0(){if(cachedInt32Memory0.byteLength===0){cachedInt32Memory0=newInt32Array(wasm.memory.buffer);}returncachedInt32Memory0;}/** * @param {string} text * @returns {Array<any>} */exportfunctiondecode(text){try{constretptr=wasm.__wbindgen_add_to_stack_pointer(-16);constptr0=passStringToWasm0(text,wasm.__wbindgen_malloc,wasm.__wbindgen_realloc);constlen0=WASM_VECTOR_LEN;wasm.decode(retptr,ptr0,len0);varr0=getInt32Memory0()[retptr/4+0];varr1=getInt32Memory0()[retptr/4+1];varr2=getInt32Memory0()[retptr/4+2];if(r2){throwtakeObject(r1);}returntakeObject(r0);}finally{wasm.__wbindgen_add_to_stack_pointer(16);}}/** * @param {number} prefix * @param {string} pub_key * @returns {string} */exportfunctionencode(prefix,pub_key){try{constretptr=wasm.__wbindgen_add_to_stack_pointer(-16);constptr0=passStringToWasm0(pub_key,wasm.__wbindgen_malloc,wasm.__wbindgen_realloc);constlen0=WASM_VECTOR_LEN;wasm.encode(retptr,prefix,ptr0,len0);varr0=getInt32Memory0()[retptr/4+0];varr1=getInt32Memory0()[retptr/4+1];varr2=getInt32Memory0()[retptr/4+2];varr3=getInt32Memory0()[retptr/4+3];varptr1=r0;varlen1=r1;if(r3){ptr1=0;len1=0;throwtakeObject(r2);}returngetStringFromWasm0(ptr1,len1);}finally{wasm.__wbindgen_add_to_stack_pointer(16);wasm.__wbindgen_free(ptr1,len1);}}constimports={__wbindgen_placeholder__: {__wbindgen_error_new: function(arg0,arg1){constret=newError(getStringFromWasm0(arg0,arg1));returnaddHeapObject(ret);},__wbindgen_number_new: function(arg0){constret=arg0;returnaddHeapObject(ret);},__wbindgen_object_drop_ref: function(arg0){takeObject(arg0);},__wbindgen_string_new: function(arg0,arg1){constret=getStringFromWasm0(arg0,arg1);returnaddHeapObject(ret);},__wbg_new_693216e109162396: function(){constret=newError();returnaddHeapObject(ret);},__wbg_stack_0ddaca5d1abfb52f: function(arg0,arg1){constret=getObject(arg1).stack;constptr0=passStringToWasm0(ret,wasm.__wbindgen_malloc,wasm.__wbindgen_realloc);constlen0=WASM_VECTOR_LEN;getInt32Memory0()[arg0/4+1]=len0;getInt32Memory0()[arg0/4+0]=ptr0;},__wbg_error_09919627ac0992f5: function(arg0,arg1){try{console.error(getStringFromWasm0(arg0,arg1));}finally{wasm.__wbindgen_free(arg0,arg1);}},__wbg_new_2ab697f1555e0dbc: function(){constret=newArray();returnaddHeapObject(ret);},__wbg_push_811c8b08bf4ff9d5: function(arg0,arg1){constret=getObject(arg0).push(getObject(arg1));returnret;},__wbindgen_throw: function(arg0,arg1){thrownewError(getStringFromWasm0(arg0,arg1));},},};constwasm_url=newURL("mod_bg.wasm",import.meta.url);/** * Decompression callback * * @callback decompressCallback * @param {Uint8Array} compressed * @return {Uint8Array} decompressed *//** Instantiates an instance of the Wasm module returning its functions. * @remarks It is safe to call this multiple times and once successfully * loaded it will always return a reference to the same object. * @param {decompressCallback=} transform */exportasyncfunctioninstantiate(transform){return(awaitinstantiateWithInstance(transform)).exports;}letinstanceWithExports;letlastLoadPromise;/** Instantiates an instance of the Wasm module along with its exports. * @remarks It is safe to call this multiple times and once successfully * loaded it will always return a reference to the same object. * @param {decompressCallback=} transform * @returns {Promise<{ * instance: WebAssembly.Instance; * exports: { decode: typeof decode; encode: typeof encode } * }>} */exportfunctioninstantiateWithInstance(transform){if(instanceWithExports!=null){returnPromise.resolve(instanceWithExports);}if(lastLoadPromise==null){lastLoadPromise=(async()=>{try{constinstance=(awaitinstantiateModule(transform)).instance;wasm=instance.exports;cachedInt32Memory0=newInt32Array(wasm.memory.buffer);cachedUint8Memory0=newUint8Array(wasm.memory.buffer);instanceWithExports={
instance,exports: getWasmInstanceExports(),};returninstanceWithExports;}finally{lastLoadPromise=null;}})();}returnlastLoadPromise;}functiongetWasmInstanceExports(){return{ decode, encode };}/** Gets if the Wasm module has been instantiated. */exportfunctionisInstantiated(){returninstanceWithExports!=null;}asyncfunctioninstantiateModule(transform){switch(wasm_url.protocol){case"file:": {if(typeofdntShim.Deno!=="object"){thrownewError("file urls are not supported in this environment");}if("permissions"indntShim.Deno){awaitdntShim.Deno.permissions.request({name: "read",path: wasm_url});}constwasmCode=awaitdntShim.Deno.readFile(wasm_url);returnWebAssembly.instantiate(!transform ? wasmCode : transform(wasmCode),imports);}case"https:":
case"http:": {if(typeofdntShim.Deno==="object"&&"permissions"indntShim.Deno){awaitdntShim.Deno.permissions.request({name: "net",host: wasm_url.host});}constwasmResponse=awaitfetch(wasm_url);if(transform){constwasmCode=newUint8Array(awaitwasmResponse.arrayBuffer());returnWebAssembly.instantiate(transform(wasmCode),imports);}if(wasmResponse.headers.get("content-type")?.toLowerCase().startsWith("application/wasm")){returnWebAssembly.instantiateStreaming(wasmResponse,imports);}else{returnWebAssembly.instantiate(awaitwasmResponse.arrayBuffer(),imports);}}default:
thrownewError(`Unsupported protocol: ${wasm_url.protocol}`);}}//# sourceMappingURL=mod.generated.js.map
Any tips to get this working would be greatly appreciated!
The text was updated successfully, but these errors were encountered:
[EDIT]
wasm_url.protocol
was an empty string (thanks to the local dev server / NextJS). Might it be worth including""
as a case here?I'm getting the following error from my local dev server. Strangely, I use another "wasmbuilt" module in the same project, and it works as expected. Not sure why the other is producing this particular error.
Below are both of the JS binding files:
The one that works
The one that does not work
Any tips to get this working would be greatly appreciated!
The text was updated successfully, but these errors were encountered: