diff --git a/Dockerfile b/Dockerfile index 1dcae6d..624449c 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,35 +1,5 @@ # syntax=docker/dockerfile:1.4 -# Stage 1: Build WASM for web target -FROM rust:1.82-alpine AS wasm-builder -WORKDIR /build - -# Install dependencies for WASM compilation -RUN apk update && apk add --no-cache git openssh-client curl nodejs npm build-base pkgconfig clang llvm musl-dev - -# Install wasm-bindgen-cli -RUN cargo install wasm-bindgen-cli --version 0.2.103 --locked && rustup target add wasm32-unknown-unknown - -# Setup SSH for git clone -RUN mkdir -p /root/.ssh && ssh-keyscan git.4nkweb.com >> /root/.ssh/known_hosts - -# Copy project files -COPY . ihm_client/ - -# Clone and build sdk_client for web target -RUN --mount=type=ssh git clone -b dev ssh://git@git.4nkweb.com/4nk/sdk_client.git -WORKDIR /build/sdk_client - -# Build WASM for web target (ES modules) -RUN cargo build --target wasm32-unknown-unknown --profile dev && \ - wasm-bindgen target/wasm32-unknown-unknown/debug/sdk_client.wasm \ - --out-dir /build/ihm_client/pkg \ - --typescript \ - --target web \ - --no-reference-types \ - --debug - -# Stage 2: Final application FROM node:20-alpine WORKDIR /app @@ -39,8 +9,10 @@ RUN apk update && apk add --no-cache git nginx # Copy project files COPY . . -# Copy the web-compiled WASM package -COPY --from=wasm-builder /build/ihm_client/pkg ./pkg +# Copy the provided prebuilt WASM package (ESM) +# The directory pkg is provided in the build context +# and already contains sdk_client.js (ES module) and wasm +# so no compilation is required here. # Installation des dépendances Node.js RUN npm install diff --git a/pkg/.gitignore b/pkg/.gitignore new file mode 100644 index 0000000..f59ec20 --- /dev/null +++ b/pkg/.gitignore @@ -0,0 +1 @@ +* \ No newline at end of file diff --git a/pkg/README.md b/pkg/README.md deleted file mode 100644 index 73ee464..0000000 --- a/pkg/README.md +++ /dev/null @@ -1,34 +0,0 @@ -## sdk_client — bibliothèque cliente Silent Payments (WASM) - -Ce dépôt fournit une bibliothèque cliente visant l’intégration WebAssembly pour gérer appareil, portefeuille, processus et échanges chiffrés associés aux Silent Payments. Cette documentation renvoie vers `docs/` pour les spécifications détaillées, sans exemples exécutables. - -## 📋 Table des Matières - -- [📚 Documentation](#-documentation) -- [🧪 Tests](#-tests) -- [🛠️ Développement](#️-développement) -- [🚨 Dépannage](#-dépannage) - -## 📚 Documentation - -- [Architecture](docs/ARCHITECTURE.md) -- [Référence API](docs/API.md) -- [Configuration](docs/CONFIGURATION.md) -- [Tests](docs/TESTING.md) - -## 🧪 Tests - -- Tests natifs: `cargo test` -- Tests WASM (Windows): utiliser le script PowerShell `scripts/run-wasm-tests.ps1` (prérequis LLVM/Clang, voir `docs/TESTING.md`). - -## 🛠️ Développement - -La surface de code est centrée sur `src/` (Rust) avec export WASM. Les invariants sont décrits dans `docs/ARCHITECTURE.md` et `docs/API.md`. - -## 🚨 Dépannage - -Consulter `docs/TESTING.md` (section WASM Windows) pour les variables d’environnement et le runner wasm-bindgen. - ---- - -Documentation de référence: voir `docs/` pour la table des matières. diff --git a/pkg/package.json b/pkg/package.json index 04d749a..6d2d710 100644 --- a/pkg/package.json +++ b/pkg/package.json @@ -1,11 +1,17 @@ { "name": "sdk_client", - "version": "0.1.3", + "type": "module", + "version": "0.1.0", "files": [ "sdk_client_bg.wasm", "sdk_client.js", + "sdk_client_bg.js", "sdk_client.d.ts" ], "main": "sdk_client.js", - "types": "sdk_client.d.ts" + "types": "sdk_client.d.ts", + "sideEffects": [ + "./sdk_client.js", + "./snippets/*" + ] } \ No newline at end of file diff --git a/pkg/sdk_client.d.ts b/pkg/sdk_client.d.ts index ce6a913..6c3a7a7 100644 --- a/pkg/sdk_client.d.ts +++ b/pkg/sdk_client.d.ts @@ -6,11 +6,14 @@ export function get_member(): Member; export function restore_device(device: any): void; export function create_device_from_sp_wallet(sp_wallet: string): string; export function create_new_device(birthday: number, network_str: string): string; -export function scan_blocks(tip_height: number, blindbit_url: string): Promise; export function is_paired(): boolean; export function pair_device(process_id: string, sp_addresses: string[]): void; export function unpair_device(): void; export function dump_wallet(): string; +export function reset_process_cache(): void; +export function dump_process_cache(): string; +export function set_process_cache(processes: any): void; +export function add_to_process_cache(process_id: string, process: string): void; export function reset_shared_secrets(): void; export function set_shared_secrets(secrets: string): void; export function get_pairing_process_id(): string; @@ -18,11 +21,8 @@ export function dump_device(): Device; export function dump_neutered_device(): Device; export function reset_device(): void; export function get_txid(transaction: string): string; -export function get_prevouts(transaction: string): string[]; -export function get_opreturn(transaction: string): string; -export function process_commit_new_state(process: Process, state_id: string, new_tip: string): Process; export function parse_new_tx(new_tx_msg: string, block_height: number, members_list: OutPointMemberMap): ApiReturn; -export function parse_cipher(cipher_msg: string, members_list: OutPointMemberMap, processes: OutPointProcessMap): ApiReturn; +export function parse_cipher(cipher_msg: string, members_list: OutPointMemberMap): ApiReturn; export function get_outputs(): any; export function get_available_amount(): bigint; /** @@ -50,15 +50,15 @@ export function decode_value(value: Uint8Array): any; export function hash_value(value: any, commited_in: string, label: string): string; /** * Generate a merkle proof for a specific attribute in a process state. - * + * * This function creates a merkle proof that proves the existence of a specific attribute * in a given state of a process. The proof can be used to verify that the attribute * was indeed part of the state without revealing the entire state. - * + * * # Arguments * * `process_state` - The process state object as a JavaScript value * * `attribute_name` - The name of the attribute to generate a proof for - * + * * # Returns * A MerkleProofResult object containing: * * `proof` - The merkle proof as a hex string @@ -66,7 +66,7 @@ export function hash_value(value: any, commited_in: string, label: string): stri * * `attribute` - The attribute name that was proven * * `attribute_index` - The index of the attribute in the merkle tree * * `total_leaves_count` - The total number of leaves in the merkle tree - * + * * # Errors * * "Failed to deserialize process state" - If the process state cannot be deserialized from JsValue * * "Attribute not found in state" - If the attribute doesn't exist in the state @@ -74,18 +74,18 @@ export function hash_value(value: any, commited_in: string, label: string): stri export function get_merkle_proof(process_state: any, attribute_name: string): MerkleProofResult; /** * Validate a merkle proof for a specific attribute. - * + * * This function verifies that a merkle proof is valid and proves the existence * of a specific attribute in a given state. It checks that the proof correctly * leads to the claimed root when combined with the attribute hash. - * + * * # Arguments * * `proof_result` - a JsValue expected to contain a MerkleProofResult with the proof and metadata * * `hash` - The hash of the attribute data as a hex string (the leaf value) - * + * * # Returns * A boolean indicating whether the proof is valid - * + * * # Errors * * "serde_wasm_bindgen deserialization error" - If the proof is not a valid MerkleProofResult * * "Invalid proof format" - If the proof cannot be parsed @@ -144,10 +144,7 @@ export interface Device { paired_member: Member; } -export interface SecretsStore { - shared_secrets: Record; - unconfirmed_secrets: AnkSharedSecretHash[]; -} +export type TsUnsignedTransaction = SilentPaymentUnsignedTransaction; /** * A process is basically a succession of states @@ -190,16 +187,19 @@ export interface Member { sp_addresses: string[]; } -export type TsUnsignedTransaction = SilentPaymentUnsignedTransaction; - export type OutPointProcessMap = Record; export type OutPointMemberMap = Record; +export interface SecretsStore { + shared_secrets: Record; + unconfirmed_secrets: AnkSharedSecretHash[]; +} + export interface Prd { prd_type: PrdType; process_id: OutPoint; - sender: OutPoint | null; + sender: Member; keys: Record; pcd_commitments: PcdCommitments; validation_tokens: Proof[]; diff --git a/pkg/sdk_client.js b/pkg/sdk_client.js index 9c7d6df..e3c7dd7 100644 --- a/pkg/sdk_client.js +++ b/pkg/sdk_client.js @@ -1,1672 +1,5 @@ - -let imports = {}; -imports['__wbindgen_placeholder__'] = module.exports; -let wasm; -const { TextEncoder, TextDecoder } = require(`util`); - -let WASM_VECTOR_LEN = 0; - -let cachedUint8ArrayMemory0 = null; - -function getUint8ArrayMemory0() { - if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { - cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); - } - return cachedUint8ArrayMemory0; -} - -let cachedTextEncoder = new TextEncoder('utf-8'); - -const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' - ? function (arg, view) { - return cachedTextEncoder.encodeInto(arg, view); -} - : function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length - }; -}); - -function passStringToWasm0(arg, malloc, realloc) { - - if (typeof(arg) !== 'string') throw new Error(`expected a string argument, found ${typeof(arg)}`); - - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length, 1) >>> 0; - getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - - let len = arg.length; - let ptr = malloc(len, 1) >>> 0; - - const mem = getUint8ArrayMemory0(); - - let offset = 0; - - for (; offset < len; offset++) { - const code = 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, 1) >>> 0; - const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); - const ret = encodeString(arg, view); - if (ret.read !== arg.length) throw new Error('failed to pass whole string'); - offset += ret.written; - ptr = realloc(ptr, len, offset, 1) >>> 0; - } - - WASM_VECTOR_LEN = offset; - return ptr; -} - -let cachedDataViewMemory0 = null; - -function getDataViewMemory0() { - if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { - cachedDataViewMemory0 = new DataView(wasm.memory.buffer); - } - return cachedDataViewMemory0; -} - -function logError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - let error = (function () { - try { - return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString(); - } catch(_) { - return ""; - } - }()); - console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error); - throw e; - } -} - -let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -function getStringFromWasm0(ptr, len) { - ptr = ptr >>> 0; - return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); -} - -function addToExternrefTable0(obj) { - const idx = wasm.__externref_table_alloc(); - wasm.__wbindgen_export_4.set(idx, obj); - return idx; -} - -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - const idx = addToExternrefTable0(e); - wasm.__wbindgen_exn_store(idx); - } -} - -function _assertBoolean(n) { - if (typeof(n) !== 'boolean') { - throw new Error(`expected a boolean argument, found ${typeof(n)}`); - } -} - -function _assertNum(n) { - if (typeof(n) !== 'number') throw new Error(`expected a number argument, found ${typeof(n)}`); -} - -function isLikeNone(x) { - return x === undefined || x === null; -} - -function _assertBigInt(n) { - if (typeof(n) !== 'bigint') throw new Error(`expected a bigint argument, found ${typeof(n)}`); -} - -const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(state => { - wasm.__wbindgen_export_5.get(state.dtor)(state.a, state.b) -}); - -function makeMutClosure(arg0, arg1, dtor, f) { - const state = { a: arg0, b: arg1, cnt: 1, dtor }; - const real = (...args) => { - // First up with a closure we increment the internal reference - // count. This ensures that the Rust closure environment won't - // be deallocated while we're invoking it. - state.cnt++; - const a = state.a; - state.a = 0; - try { - return f(a, state.b, ...args); - } finally { - if (--state.cnt === 0) { - wasm.__wbindgen_export_5.get(state.dtor)(a, state.b); - CLOSURE_DTORS.unregister(state); - } else { - state.a = a; - } - } - }; - real.original = state; - CLOSURE_DTORS.register(real, state, state); - return real; -} - -function debugString(val) { - // primitive types - const type = typeof val; - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}`; - } - if (type == 'string') { - return `"${val}"`; - } - if (type == 'symbol') { - const description = val.description; - if (description == null) { - return 'Symbol'; - } else { - return `Symbol(${description})`; - } - } - if (type == 'function') { - const name = val.name; - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})`; - } else { - return 'Function'; - } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = '['; - if (length > 0) { - debug += debugString(val[0]); - } - for(let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]); - } - debug += ']'; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches && builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')'; - } catch (_) { - return 'Object'; - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; -} - -module.exports.setup = function() { - wasm.setup(); -}; - -function takeFromExternrefTable0(idx) { - const value = wasm.__wbindgen_export_4.get(idx); - wasm.__externref_table_dealloc(idx); - return value; -} -/** - * @returns {string} - */ -module.exports.get_address = function() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.get_address(); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } -}; - -/** - * @returns {Member} - */ -module.exports.get_member = function() { - const ret = wasm.get_member(); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {any} device - */ -module.exports.restore_device = function(device) { - const ret = wasm.restore_device(device); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } -}; - -/** - * @param {string} sp_wallet - * @returns {string} - */ -module.exports.create_device_from_sp_wallet = function(sp_wallet) { - let deferred3_0; - let deferred3_1; - try { - const ptr0 = passStringToWasm0(sp_wallet, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.create_device_from_sp_wallet(ptr0, len0); - var ptr2 = ret[0]; - var len2 = ret[1]; - if (ret[3]) { - ptr2 = 0; len2 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred3_0 = ptr2; - deferred3_1 = len2; - return getStringFromWasm0(ptr2, len2); - } finally { - wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); - } -}; - -/** - * @param {number} birthday - * @param {string} network_str - * @returns {string} - */ -module.exports.create_new_device = function(birthday, network_str) { - let deferred3_0; - let deferred3_1; - try { - _assertNum(birthday); - const ptr0 = passStringToWasm0(network_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.create_new_device(birthday, ptr0, len0); - var ptr2 = ret[0]; - var len2 = ret[1]; - if (ret[3]) { - ptr2 = 0; len2 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred3_0 = ptr2; - deferred3_1 = len2; - return getStringFromWasm0(ptr2, len2); - } finally { - wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); - } -}; - -/** - * @param {number} tip_height - * @param {string} blindbit_url - * @returns {Promise} - */ -module.exports.scan_blocks = function(tip_height, blindbit_url) { - _assertNum(tip_height); - const ptr0 = passStringToWasm0(blindbit_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.scan_blocks(tip_height, ptr0, len0); - return ret; -}; - -/** - * @returns {boolean} - */ -module.exports.is_paired = function() { - const ret = wasm.is_paired(); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return ret[0] !== 0; -}; - -function passArrayJsValueToWasm0(array, malloc) { - const ptr = malloc(array.length * 4, 4) >>> 0; - for (let i = 0; i < array.length; i++) { - const add = addToExternrefTable0(array[i]); - getDataViewMemory0().setUint32(ptr + 4 * i, add, true); - } - WASM_VECTOR_LEN = array.length; - return ptr; -} -/** - * @param {string} process_id - * @param {string[]} sp_addresses - */ -module.exports.pair_device = function(process_id, sp_addresses) { - const ptr0 = passStringToWasm0(process_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArrayJsValueToWasm0(sp_addresses, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.pair_device(ptr0, len0, ptr1, len1); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } -}; - -module.exports.unpair_device = function() { - const ret = wasm.unpair_device(); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } -}; - -/** - * @returns {string} - */ -module.exports.dump_wallet = function() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.dump_wallet(); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } -}; - -module.exports.reset_shared_secrets = function() { - const ret = wasm.reset_shared_secrets(); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } -}; - -/** - * @param {string} secrets - */ -module.exports.set_shared_secrets = function(secrets) { - const ptr0 = passStringToWasm0(secrets, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.set_shared_secrets(ptr0, len0); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } -}; - -/** - * @returns {string} - */ -module.exports.get_pairing_process_id = function() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.get_pairing_process_id(); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } -}; - -/** - * @returns {Device} - */ -module.exports.dump_device = function() { - const ret = wasm.dump_device(); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @returns {Device} - */ -module.exports.dump_neutered_device = function() { - const ret = wasm.dump_neutered_device(); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -module.exports.reset_device = function() { - const ret = wasm.reset_device(); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } -}; - -/** - * @param {string} transaction - * @returns {string} - */ -module.exports.get_txid = function(transaction) { - let deferred3_0; - let deferred3_1; - try { - const ptr0 = passStringToWasm0(transaction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.get_txid(ptr0, len0); - var ptr2 = ret[0]; - var len2 = ret[1]; - if (ret[3]) { - ptr2 = 0; len2 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred3_0 = ptr2; - deferred3_1 = len2; - return getStringFromWasm0(ptr2, len2); - } finally { - wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); - } -}; - -function getArrayJsValueFromWasm0(ptr, len) { - ptr = ptr >>> 0; - const mem = getDataViewMemory0(); - const result = []; - for (let i = ptr; i < ptr + 4 * len; i += 4) { - result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true))); - } - wasm.__externref_drop_slice(ptr, len); - return result; -} -/** - * @param {string} transaction - * @returns {string[]} - */ -module.exports.get_prevouts = function(transaction) { - const ptr0 = passStringToWasm0(transaction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.get_prevouts(ptr0, len0); - if (ret[3]) { - throw takeFromExternrefTable0(ret[2]); - } - var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); - return v2; -}; - -/** - * @param {string} transaction - * @returns {string} - */ -module.exports.get_opreturn = function(transaction) { - let deferred3_0; - let deferred3_1; - try { - const ptr0 = passStringToWasm0(transaction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.get_opreturn(ptr0, len0); - var ptr2 = ret[0]; - var len2 = ret[1]; - if (ret[3]) { - ptr2 = 0; len2 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred3_0 = ptr2; - deferred3_1 = len2; - return getStringFromWasm0(ptr2, len2); - } finally { - wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); - } -}; - -/** - * @param {Process} process - * @param {string} state_id - * @param {string} new_tip - * @returns {Process} - */ -module.exports.process_commit_new_state = function(process, state_id, new_tip) { - const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(new_tip, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.process_commit_new_state(process, ptr0, len0, ptr1, len1); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {string} new_tx_msg - * @param {number} block_height - * @param {OutPointMemberMap} members_list - * @returns {ApiReturn} - */ -module.exports.parse_new_tx = function(new_tx_msg, block_height, members_list) { - const ptr0 = passStringToWasm0(new_tx_msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertNum(block_height); - const ret = wasm.parse_new_tx(ptr0, len0, block_height, members_list); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {string} cipher_msg - * @param {OutPointMemberMap} members_list - * @param {OutPointProcessMap} processes - * @returns {ApiReturn} - */ -module.exports.parse_cipher = function(cipher_msg, members_list, processes) { - const ptr0 = passStringToWasm0(cipher_msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.parse_cipher(ptr0, len0, members_list, processes); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @returns {any} - */ -module.exports.get_outputs = function() { - const ret = wasm.get_outputs(); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @returns {bigint} - */ -module.exports.get_available_amount = function() { - const ret = wasm.get_available_amount(); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return BigInt.asUintN(64, ret[0]); -}; - -/** - * We send a transaction that pays at least one output to each address - * The goal can be to establish a shared_secret to be used as an encryption key for further communication - * or if the recipient is a relay it can be the init transaction for a new process - * @param {string[]} addresses - * @param {number} fee_rate - * @returns {ApiReturn} - */ -module.exports.create_transaction = function(addresses, fee_rate) { - const ptr0 = passArrayJsValueToWasm0(addresses, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - _assertNum(fee_rate); - const ret = wasm.create_transaction(ptr0, len0, fee_rate); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {TsUnsignedTransaction} partial_tx - * @returns {ApiReturn} - */ -module.exports.sign_transaction = function(partial_tx) { - const ret = wasm.sign_transaction(partial_tx); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {Pcd} private_data - * @param {Roles} roles - * @param {Pcd} public_data - * @param {string} relay_address - * @param {number} fee_rate - * @param {OutPointMemberMap} members_list - * @returns {ApiReturn} - */ -module.exports.create_new_process = function(private_data, roles, public_data, relay_address, fee_rate, members_list) { - const ptr0 = passStringToWasm0(relay_address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertNum(fee_rate); - const ret = wasm.create_new_process(private_data, roles, public_data, ptr0, len0, fee_rate, members_list); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {Process} process - * @param {Pcd} new_attributes - * @param {Roles} roles - * @param {Pcd} new_public_data - * @param {OutPointMemberMap} members_list - * @returns {ApiReturn} - */ -module.exports.update_process = function(process, new_attributes, roles, new_public_data, members_list) { - const ret = wasm.update_process(process, new_attributes, roles, new_public_data, members_list); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {string} process_id - * @param {string[]} state_ids_str - * @param {any} roles - * @param {OutPointMemberMap} members_list - * @returns {ApiReturn} - */ -module.exports.request_data = function(process_id, state_ids_str, roles, members_list) { - const ptr0 = passStringToWasm0(process_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArrayJsValueToWasm0(state_ids_str, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.request_data(ptr0, len0, ptr1, len1, roles, members_list); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {Process} process - * @param {string} state_id - * @param {OutPointMemberMap} members_list - * @returns {ApiReturn} - */ -module.exports.create_update_message = function(process, state_id, members_list) { - const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.create_update_message(process, ptr0, len0, members_list); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {Process} process - * @param {string} state_id - * @param {OutPointMemberMap} members_list - * @returns {ApiReturn} - */ -module.exports.validate_state = function(process, state_id, members_list) { - const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.validate_state(process, ptr0, len0, members_list); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {Process} process - * @param {string} state_id - * @param {OutPointMemberMap} members_list - * @returns {ApiReturn} - */ -module.exports.refuse_state = function(process, state_id, members_list) { - const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.refuse_state(process, ptr0, len0, members_list); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {Process} process - * @param {string} state_id - * @param {OutPointMemberMap} members_list - * @returns {ApiReturn} - */ -module.exports.evaluate_state = function(process, state_id, members_list) { - const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.evaluate_state(process, ptr0, len0, members_list); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {Process} process - * @param {string} state_id - * @param {OutPointMemberMap} members_list - * @returns {ApiReturn} - */ -module.exports.create_response_prd = function(process, state_id, members_list) { - const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.create_response_prd(process, ptr0, len0, members_list); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @returns {string} - */ -module.exports.create_faucet_msg = function() { - let deferred2_0; - let deferred2_1; - try { - const ret = wasm.create_faucet_msg(); - var ptr1 = ret[0]; - var len1 = ret[1]; - if (ret[3]) { - ptr1 = 0; len1 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } -}; - -/** - * @param {string} process_outpoint - * @returns {string[]} - */ -module.exports.get_storages = function(process_outpoint) { - const ptr0 = passStringToWasm0(process_outpoint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.get_storages(ptr0, len0); - if (ret[3]) { - throw takeFromExternrefTable0(ret[2]); - } - var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); - return v2; -}; - -/** - * @param {string} parent_roles - * @param {string} child_roles - */ -module.exports.is_child_role = function(parent_roles, child_roles) { - const ptr0 = passStringToWasm0(parent_roles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(child_roles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.is_child_role(ptr0, len0, ptr1, len1); - if (ret[1]) { - throw takeFromExternrefTable0(ret[0]); - } -}; - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1, 1) >>> 0; - getUint8ArrayMemory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} - -function getArrayU8FromWasm0(ptr, len) { - ptr = ptr >>> 0; - return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); -} -/** - * @param {Uint8Array} key - * @param {Uint8Array} data - * @returns {Uint8Array} - */ -module.exports.decrypt_data = function(key, data) { - const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.decrypt_data(ptr0, len0, ptr1, len1); - if (ret[3]) { - throw takeFromExternrefTable0(ret[2]); - } - var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); - wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); - return v3; -}; - -/** - * @param {any} data - * @returns {Pcd} - */ -module.exports.encode_binary = function(data) { - const ret = wasm.encode_binary(data); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {any} json_data - * @returns {Pcd} - */ -module.exports.encode_json = function(json_data) { - const ret = wasm.encode_json(json_data); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {Uint8Array} value - * @returns {any} - */ -module.exports.decode_value = function(value) { - const ptr0 = passArray8ToWasm0(value, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.decode_value(ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * @param {any} value - * @param {string} commited_in - * @param {string} label - * @returns {string} - */ -module.exports.hash_value = function(value, commited_in, label) { - let deferred4_0; - let deferred4_1; - try { - const ptr0 = passStringToWasm0(commited_in, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(label, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ret = wasm.hash_value(value, ptr0, len0, ptr1, len1); - var ptr3 = ret[0]; - var len3 = ret[1]; - if (ret[3]) { - ptr3 = 0; len3 = 0; - throw takeFromExternrefTable0(ret[2]); - } - deferred4_0 = ptr3; - deferred4_1 = len3; - return getStringFromWasm0(ptr3, len3); - } finally { - wasm.__wbindgen_free(deferred4_0, deferred4_1, 1); - } -}; - -/** - * Generate a merkle proof for a specific attribute in a process state. - * - * This function creates a merkle proof that proves the existence of a specific attribute - * in a given state of a process. The proof can be used to verify that the attribute - * was indeed part of the state without revealing the entire state. - * - * # Arguments - * * `process_state` - The process state object as a JavaScript value - * * `attribute_name` - The name of the attribute to generate a proof for - * - * # Returns - * A MerkleProofResult object containing: - * * `proof` - The merkle proof as a hex string - * * `root` - The merkle root (state_id) as a hex string - * * `attribute` - The attribute name that was proven - * * `attribute_index` - The index of the attribute in the merkle tree - * * `total_leaves_count` - The total number of leaves in the merkle tree - * - * # Errors - * * "Failed to deserialize process state" - If the process state cannot be deserialized from JsValue - * * "Attribute not found in state" - If the attribute doesn't exist in the state - * @param {any} process_state - * @param {string} attribute_name - * @returns {MerkleProofResult} - */ -module.exports.get_merkle_proof = function(process_state, attribute_name) { - const ptr0 = passStringToWasm0(attribute_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.get_merkle_proof(process_state, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -}; - -/** - * Validate a merkle proof for a specific attribute. - * - * This function verifies that a merkle proof is valid and proves the existence - * of a specific attribute in a given state. It checks that the proof correctly - * leads to the claimed root when combined with the attribute hash. - * - * # Arguments - * * `proof_result` - a JsValue expected to contain a MerkleProofResult with the proof and metadata - * * `hash` - The hash of the attribute data as a hex string (the leaf value) - * - * # Returns - * A boolean indicating whether the proof is valid - * - * # Errors - * * "serde_wasm_bindgen deserialization error" - If the proof is not a valid MerkleProofResult - * * "Invalid proof format" - If the proof cannot be parsed - * * "Invalid hash format" - If the hash is not a valid 32-byte hex string - * * "Invalid root format" - If the root is not a valid 32-byte hex string - * @param {any} proof_result - * @param {string} hash - * @returns {boolean} - */ -module.exports.validate_merkle_proof = function(proof_result, hash) { - const ptr0 = passStringToWasm0(hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.validate_merkle_proof(proof_result, ptr0, len0); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return ret[0] !== 0; -}; - -function __wbg_adapter_52(arg0, arg1) { - _assertNum(arg0); - _assertNum(arg1); - wasm._dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0dcb1618ebc342c1(arg0, arg1); -} - -function __wbg_adapter_55(arg0, arg1, arg2) { - _assertNum(arg0); - _assertNum(arg1); - wasm.closure667_externref_shim(arg0, arg1, arg2); -} - -function __wbg_adapter_227(arg0, arg1, arg2, arg3) { - _assertNum(arg0); - _assertNum(arg1); - wasm.closure1273_externref_shim(arg0, arg1, arg2, arg3); -} - -const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"]; - -const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"]; - -module.exports.__wbg_String_8f0eb39a4a4c2f66 = function() { return logError(function (arg0, arg1) { - const ret = String(arg1); - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -}, arguments) }; - -module.exports.__wbg_abort_410ec47a64ac6117 = function() { return logError(function (arg0, arg1) { - arg0.abort(arg1); -}, arguments) }; - -module.exports.__wbg_abort_775ef1d17fc65868 = function() { return logError(function (arg0) { - arg0.abort(); -}, arguments) }; - -module.exports.__wbg_append_8c7dd8d641a5f01b = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { - arg0.append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); -}, arguments) }; - -module.exports.__wbg_buffer_609cc3eee51ed158 = function() { return logError(function (arg0) { - const ret = arg0.buffer; - return ret; -}, arguments) }; - -module.exports.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) { - const ret = arg0.call(arg1); - return ret; -}, arguments) }; - -module.exports.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(function (arg0, arg1, arg2) { - const ret = arg0.call(arg1, arg2); - return ret; -}, arguments) }; - -module.exports.__wbg_clearTimeout_b1115618e821c3b2 = function() { return logError(function (arg0) { - const ret = clearTimeout(arg0); - return ret; -}, arguments) }; - -module.exports.__wbg_crypto_ed58b8e10a292839 = function() { return logError(function (arg0) { - const ret = arg0.crypto; - return ret; -}, arguments) }; - -module.exports.__wbg_debug_e17b51583ca6a632 = function() { return logError(function (arg0, arg1, arg2, arg3) { - console.debug(arg0, arg1, arg2, arg3); -}, arguments) }; - -module.exports.__wbg_done_769e5ede4b31c67b = function() { return logError(function (arg0) { - const ret = arg0.done; - _assertBoolean(ret); - return ret; -}, arguments) }; - -module.exports.__wbg_entries_3265d4158b33e5dc = function() { return logError(function (arg0) { - const ret = Object.entries(arg0); - return ret; -}, arguments) }; - -module.exports.__wbg_error_524f506f44df1645 = function() { return logError(function (arg0) { - console.error(arg0); -}, arguments) }; - -module.exports.__wbg_error_80de38b3f7cc3c3c = function() { return logError(function (arg0, arg1, arg2, arg3) { - console.error(arg0, arg1, arg2, arg3); -}, arguments) }; - -module.exports.__wbg_fetch_3afbdcc7ddbf16fe = function() { return logError(function (arg0) { - const ret = fetch(arg0); - return ret; -}, arguments) }; - -module.exports.__wbg_fetch_509096533071c657 = function() { return logError(function (arg0, arg1) { - const ret = arg0.fetch(arg1); - return ret; -}, arguments) }; - -module.exports.__wbg_getRandomValues_bcb4912f16000dc4 = function() { return handleError(function (arg0, arg1) { - arg0.getRandomValues(arg1); -}, arguments) }; - -module.exports.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(arg0, arg1); - return ret; -}, arguments) }; - -module.exports.__wbg_get_b9b93047fe3cf45b = function() { return logError(function (arg0, arg1) { - const ret = arg0[arg1 >>> 0]; - return ret; -}, arguments) }; - -module.exports.__wbg_getwithrefkey_1dc361bd10053bfe = function() { return logError(function (arg0, arg1) { - const ret = arg0[arg1]; - return ret; -}, arguments) }; - -module.exports.__wbg_has_a5ea9117f258a0ec = function() { return handleError(function (arg0, arg1) { - const ret = Reflect.has(arg0, arg1); - _assertBoolean(ret); - return ret; -}, arguments) }; - -module.exports.__wbg_headers_9cb51cfd2ac780a4 = function() { return logError(function (arg0) { - const ret = arg0.headers; - return ret; -}, arguments) }; - -module.exports.__wbg_info_033d8b8a0838f1d3 = function() { return logError(function (arg0, arg1, arg2, arg3) { - console.info(arg0, arg1, arg2, arg3); -}, arguments) }; - -module.exports.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function() { return logError(function (arg0) { - let result; - try { - result = arg0 instanceof ArrayBuffer; - } catch (_) { - result = false; - } - const ret = result; - _assertBoolean(ret); - return ret; -}, arguments) }; - -module.exports.__wbg_instanceof_Map_f3469ce2244d2430 = function() { return logError(function (arg0) { - let result; - try { - result = arg0 instanceof Map; - } catch (_) { - result = false; - } - const ret = result; - _assertBoolean(ret); - return ret; -}, arguments) }; - -module.exports.__wbg_instanceof_Response_f2cc20d9f7dfd644 = function() { return logError(function (arg0) { - let result; - try { - result = arg0 instanceof Response; - } catch (_) { - result = false; - } - const ret = result; - _assertBoolean(ret); - return ret; -}, arguments) }; - -module.exports.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function() { return logError(function (arg0) { - let result; - try { - result = arg0 instanceof Uint8Array; - } catch (_) { - result = false; - } - const ret = result; - _assertBoolean(ret); - return ret; -}, arguments) }; - -module.exports.__wbg_isArray_a1eab7e0d067391b = function() { return logError(function (arg0) { - const ret = Array.isArray(arg0); - _assertBoolean(ret); - return ret; -}, arguments) }; - -module.exports.__wbg_isSafeInteger_343e2beeeece1bb0 = function() { return logError(function (arg0) { - const ret = Number.isSafeInteger(arg0); - _assertBoolean(ret); - return ret; -}, arguments) }; - -module.exports.__wbg_iterator_9a24c88df860dc65 = function() { return logError(function () { - const ret = Symbol.iterator; - return ret; -}, arguments) }; - -module.exports.__wbg_length_a446193dc22c12f8 = function() { return logError(function (arg0) { - const ret = arg0.length; - _assertNum(ret); - return ret; -}, arguments) }; - -module.exports.__wbg_length_e2d2a49132c1b256 = function() { return logError(function (arg0) { - const ret = arg0.length; - _assertNum(ret); - return ret; -}, arguments) }; - -module.exports.__wbg_log_cad59bb680daec67 = function() { return logError(function (arg0, arg1, arg2, arg3) { - console.log(arg0, arg1, arg2, arg3); -}, arguments) }; - -module.exports.__wbg_msCrypto_0a36e2ec3a343d26 = function() { return logError(function (arg0) { - const ret = arg0.msCrypto; - return ret; -}, arguments) }; - -module.exports.__wbg_new_018dcc2d6c8c2f6a = function() { return handleError(function () { - const ret = new Headers(); - return ret; -}, arguments) }; - -module.exports.__wbg_new_23a2665fac83c611 = function() { return logError(function (arg0, arg1) { - try { - var state0 = {a: arg0, b: arg1}; - var cb0 = (arg0, arg1) => { - const a = state0.a; - state0.a = 0; - try { - return __wbg_adapter_227(a, state0.b, arg0, arg1); - } finally { - state0.a = a; - } - }; - const ret = new Promise(cb0); - return ret; - } finally { - state0.a = state0.b = 0; - } -}, arguments) }; - -module.exports.__wbg_new_405e22f390576ce2 = function() { return logError(function () { - const ret = new Object(); - return ret; -}, arguments) }; - -module.exports.__wbg_new_5e0be73521bc8c17 = function() { return logError(function () { - const ret = new Map(); - return ret; -}, arguments) }; - -module.exports.__wbg_new_78feb108b6472713 = function() { return logError(function () { - const ret = new Array(); - return ret; -}, arguments) }; - -module.exports.__wbg_new_a12002a7f91c75be = function() { return logError(function (arg0) { - const ret = new Uint8Array(arg0); - return ret; -}, arguments) }; - -module.exports.__wbg_new_e25e5aab09ff45db = function() { return handleError(function () { - const ret = new AbortController(); - return ret; -}, arguments) }; - -module.exports.__wbg_newnoargs_105ed471475aaf50 = function() { return logError(function (arg0, arg1) { - const ret = new Function(getStringFromWasm0(arg0, arg1)); - return ret; -}, arguments) }; - -module.exports.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function() { return logError(function (arg0, arg1, arg2) { - const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0); - return ret; -}, arguments) }; - -module.exports.__wbg_newwithlength_a381634e90c276d4 = function() { return logError(function (arg0) { - const ret = new Uint8Array(arg0 >>> 0); - return ret; -}, arguments) }; - -module.exports.__wbg_newwithstrandinit_06c535e0a867c635 = function() { return handleError(function (arg0, arg1, arg2) { - const ret = new Request(getStringFromWasm0(arg0, arg1), arg2); - return ret; -}, arguments) }; - -module.exports.__wbg_next_25feadfc0913fea9 = function() { return logError(function (arg0) { - const ret = arg0.next; - return ret; -}, arguments) }; - -module.exports.__wbg_next_6574e1a8a62d1055 = function() { return handleError(function (arg0) { - const ret = arg0.next(); - return ret; -}, arguments) }; - -module.exports.__wbg_node_02999533c4ea02e3 = function() { return logError(function (arg0) { - const ret = arg0.node; - return ret; -}, arguments) }; - -module.exports.__wbg_now_2c95c9de01293173 = function() { return logError(function (arg0) { - const ret = arg0.now(); - return ret; -}, arguments) }; - -module.exports.__wbg_parse_def2e24ef1252aff = function() { return handleError(function (arg0, arg1) { - const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); - return ret; -}, arguments) }; - -module.exports.__wbg_performance_7a3ffd0b17f663ad = function() { return logError(function (arg0) { - const ret = arg0.performance; - return ret; -}, arguments) }; - -module.exports.__wbg_process_5c1d670bc53614b8 = function() { return logError(function (arg0) { - const ret = arg0.process; - return ret; -}, arguments) }; - -module.exports.__wbg_queueMicrotask_97d92b4fcc8a61c5 = function() { return logError(function (arg0) { - queueMicrotask(arg0); -}, arguments) }; - -module.exports.__wbg_queueMicrotask_d3219def82552485 = function() { return logError(function (arg0) { - const ret = arg0.queueMicrotask; - return ret; -}, arguments) }; - -module.exports.__wbg_randomFillSync_ab2cfe79ebbf2740 = function() { return handleError(function (arg0, arg1) { - arg0.randomFillSync(arg1); -}, arguments) }; - -module.exports.__wbg_require_79b1e9274cde3c87 = function() { return handleError(function () { - const ret = module.require; - return ret; -}, arguments) }; - -module.exports.__wbg_resolve_4851785c9c5f573d = function() { return logError(function (arg0) { - const ret = Promise.resolve(arg0); - return ret; -}, arguments) }; - -module.exports.__wbg_setTimeout_ca12ead8b48245e2 = function() { return logError(function (arg0, arg1) { - const ret = setTimeout(arg0, arg1); - return ret; -}, arguments) }; - -module.exports.__wbg_set_37837023f3d740e8 = function() { return logError(function (arg0, arg1, arg2) { - arg0[arg1 >>> 0] = arg2; -}, arguments) }; - -module.exports.__wbg_set_3f1d0b984ed272ed = function() { return logError(function (arg0, arg1, arg2) { - arg0[arg1] = arg2; -}, arguments) }; - -module.exports.__wbg_set_65595bdd868b3009 = function() { return logError(function (arg0, arg1, arg2) { - arg0.set(arg1, arg2 >>> 0); -}, arguments) }; - -module.exports.__wbg_set_8fc6bf8a5b1071d1 = function() { return logError(function (arg0, arg1, arg2) { - const ret = arg0.set(arg1, arg2); - return ret; -}, arguments) }; - -module.exports.__wbg_set_bb8cecf6a62b9f46 = function() { return handleError(function (arg0, arg1, arg2) { - const ret = Reflect.set(arg0, arg1, arg2); - _assertBoolean(ret); - return ret; -}, arguments) }; - -module.exports.__wbg_setbody_5923b78a95eedf29 = function() { return logError(function (arg0, arg1) { - arg0.body = arg1; -}, arguments) }; - -module.exports.__wbg_setcredentials_c3a22f1cd105a2c6 = function() { return logError(function (arg0, arg1) { - arg0.credentials = __wbindgen_enum_RequestCredentials[arg1]; -}, arguments) }; - -module.exports.__wbg_setheaders_834c0bdb6a8949ad = function() { return logError(function (arg0, arg1) { - arg0.headers = arg1; -}, arguments) }; - -module.exports.__wbg_setmethod_3c5280fe5d890842 = function() { return logError(function (arg0, arg1, arg2) { - arg0.method = getStringFromWasm0(arg1, arg2); -}, arguments) }; - -module.exports.__wbg_setmode_5dc300b865044b65 = function() { return logError(function (arg0, arg1) { - arg0.mode = __wbindgen_enum_RequestMode[arg1]; -}, arguments) }; - -module.exports.__wbg_setsignal_75b21ef3a81de905 = function() { return logError(function (arg0, arg1) { - arg0.signal = arg1; -}, arguments) }; - -module.exports.__wbg_signal_aaf9ad74119f20a4 = function() { return logError(function (arg0) { - const ret = arg0.signal; - return ret; -}, arguments) }; - -module.exports.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() { return logError(function () { - const ret = typeof global === 'undefined' ? null : global; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -}, arguments) }; - -module.exports.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() { return logError(function () { - const ret = typeof globalThis === 'undefined' ? null : globalThis; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -}, arguments) }; - -module.exports.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() { return logError(function () { - const ret = typeof self === 'undefined' ? null : self; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -}, arguments) }; - -module.exports.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() { return logError(function () { - const ret = typeof window === 'undefined' ? null : window; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); -}, arguments) }; - -module.exports.__wbg_status_f6360336ca686bf0 = function() { return logError(function (arg0) { - const ret = arg0.status; - _assertNum(ret); - return ret; -}, arguments) }; - -module.exports.__wbg_stringify_f7ed6987935b4a24 = function() { return handleError(function (arg0) { - const ret = JSON.stringify(arg0); - return ret; -}, arguments) }; - -module.exports.__wbg_subarray_aa9065fa9dc5df96 = function() { return logError(function (arg0, arg1, arg2) { - const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0); - return ret; -}, arguments) }; - -module.exports.__wbg_text_7805bea50de2af49 = function() { return handleError(function (arg0) { - const ret = arg0.text(); - return ret; -}, arguments) }; - -module.exports.__wbg_then_44b73946d2fb3e7d = function() { return logError(function (arg0, arg1) { - const ret = arg0.then(arg1); - return ret; -}, arguments) }; - -module.exports.__wbg_then_48b406749878a531 = function() { return logError(function (arg0, arg1, arg2) { - const ret = arg0.then(arg1, arg2); - return ret; -}, arguments) }; - -module.exports.__wbg_url_ae10c34ca209681d = function() { return logError(function (arg0, arg1) { - const ret = arg1.url; - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -}, arguments) }; - -module.exports.__wbg_value_cd1ffa7b1ab794f1 = function() { return logError(function (arg0) { - const ret = arg0.value; - return ret; -}, arguments) }; - -module.exports.__wbg_versions_c71aa1626a93e0a1 = function() { return logError(function (arg0) { - const ret = arg0.versions; - return ret; -}, arguments) }; - -module.exports.__wbg_warn_aaf1f4664a035bd6 = function() { return logError(function (arg0, arg1, arg2, arg3) { - console.warn(arg0, arg1, arg2, arg3); -}, arguments) }; - -module.exports.__wbindgen_as_number = function(arg0) { - const ret = +arg0; - return ret; -}; - -module.exports.__wbindgen_bigint_from_i64 = function(arg0) { - const ret = arg0; - return ret; -}; - -module.exports.__wbindgen_bigint_from_u64 = function(arg0) { - const ret = BigInt.asUintN(64, arg0); - return ret; -}; - -module.exports.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) { - const v = arg1; - const ret = typeof(v) === 'bigint' ? v : undefined; - if (!isLikeNone(ret)) { - _assertBigInt(ret); - } - getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); -}; - -module.exports.__wbindgen_boolean_get = function(arg0) { - const v = arg0; - const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; - _assertNum(ret); - return ret; -}; - -module.exports.__wbindgen_cb_drop = function(arg0) { - const obj = arg0.original; - if (obj.cnt-- == 1) { - obj.a = 0; - return true; - } - const ret = false; - _assertBoolean(ret); - return ret; -}; - -module.exports.__wbindgen_closure_wrapper11341 = function() { return logError(function (arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 647, __wbg_adapter_52); - return ret; -}, arguments) }; - -module.exports.__wbindgen_closure_wrapper11582 = function() { return logError(function (arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 668, __wbg_adapter_55); - return ret; -}, arguments) }; - -module.exports.__wbindgen_debug_string = function(arg0, arg1) { - const ret = debugString(arg1); - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -}; - -module.exports.__wbindgen_error_new = function(arg0, arg1) { - const ret = new Error(getStringFromWasm0(arg0, arg1)); - return ret; -}; - -module.exports.__wbindgen_in = function(arg0, arg1) { - const ret = arg0 in arg1; - _assertBoolean(ret); - return ret; -}; - -module.exports.__wbindgen_init_externref_table = function() { - const table = wasm.__wbindgen_export_4; - const offset = table.grow(4); - table.set(0, undefined); - table.set(offset + 0, undefined); - table.set(offset + 1, null); - table.set(offset + 2, true); - table.set(offset + 3, false); - ; -}; - -module.exports.__wbindgen_is_bigint = function(arg0) { - const ret = typeof(arg0) === 'bigint'; - _assertBoolean(ret); - return ret; -}; - -module.exports.__wbindgen_is_function = function(arg0) { - const ret = typeof(arg0) === 'function'; - _assertBoolean(ret); - return ret; -}; - -module.exports.__wbindgen_is_object = function(arg0) { - const val = arg0; - const ret = typeof(val) === 'object' && val !== null; - _assertBoolean(ret); - return ret; -}; - -module.exports.__wbindgen_is_string = function(arg0) { - const ret = typeof(arg0) === 'string'; - _assertBoolean(ret); - return ret; -}; - -module.exports.__wbindgen_is_undefined = function(arg0) { - const ret = arg0 === undefined; - _assertBoolean(ret); - return ret; -}; - -module.exports.__wbindgen_jsval_eq = function(arg0, arg1) { - const ret = arg0 === arg1; - _assertBoolean(ret); - return ret; -}; - -module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) { - const ret = arg0 == arg1; - _assertBoolean(ret); - return ret; -}; - -module.exports.__wbindgen_memory = function() { - const ret = wasm.memory; - return ret; -}; - -module.exports.__wbindgen_number_get = function(arg0, arg1) { - const obj = arg1; - const ret = typeof(obj) === 'number' ? obj : undefined; - if (!isLikeNone(ret)) { - _assertNum(ret); - } - getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); -}; - -module.exports.__wbindgen_number_new = function(arg0) { - const ret = arg0; - return ret; -}; - -module.exports.__wbindgen_string_get = function(arg0, arg1) { - const obj = arg1; - const ret = typeof(obj) === 'string' ? obj : undefined; - var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -}; - -module.exports.__wbindgen_string_new = function(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return ret; -}; - -module.exports.__wbindgen_throw = function(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -}; - -const path = require('path').join(__dirname, 'sdk_client_bg.wasm'); -const bytes = require('fs').readFileSync(path); - -const wasmModule = new WebAssembly.Module(bytes); -const wasmInstance = new WebAssembly.Instance(wasmModule, imports); -wasm = wasmInstance.exports; -module.exports.__wasm = wasm; - +import * as wasm from "./sdk_client_bg.wasm"; +export * from "./sdk_client_bg.js"; +import { __wbg_set_wasm } from "./sdk_client_bg.js"; +__wbg_set_wasm(wasm); wasm.__wbindgen_start(); - diff --git a/pkg/sdk_client_bg.js b/pkg/sdk_client_bg.js new file mode 100644 index 0000000..7ed6bae --- /dev/null +++ b/pkg/sdk_client_bg.js @@ -0,0 +1,1402 @@ +let wasm; +export function __wbg_set_wasm(val) { + wasm = val; +} + + +let WASM_VECTOR_LEN = 0; + +let cachedUint8ArrayMemory0 = null; + +function getUint8ArrayMemory0() { + if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { + cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8ArrayMemory0; +} + +const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder; + +let cachedTextEncoder = new lTextEncoder('utf-8'); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); +} + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; +}); + +function passStringToWasm0(arg, malloc, realloc) { + + if (typeof(arg) !== 'string') throw new Error(`expected a string argument, found ${typeof(arg)}`); + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8ArrayMemory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = 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, 1) >>> 0; + const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + if (ret.read !== arg.length) throw new Error('failed to pass whole string'); + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +let cachedDataViewMemory0 = null; + +function getDataViewMemory0() { + if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { + cachedDataViewMemory0 = new DataView(wasm.memory.buffer); + } + return cachedDataViewMemory0; +} + +function logError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + let error = (function () { + try { + return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString(); + } catch(_) { + return ""; + } + }()); + console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error); + throw e; + } +} + +function addToExternrefTable0(obj) { + const idx = wasm.__externref_table_alloc(); + wasm.__wbindgen_export_4.set(idx, obj); + return idx; +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + const idx = addToExternrefTable0(e); + wasm.__wbindgen_exn_store(idx); + } +} + +function _assertBoolean(n) { + if (typeof(n) !== 'boolean') { + throw new Error(`expected a boolean argument, found ${typeof(n)}`); + } +} + +function _assertNum(n) { + if (typeof(n) !== 'number') throw new Error(`expected a number argument, found ${typeof(n)}`); +} + +const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; + +let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +function _assertBigInt(n) { + if (typeof(n) !== 'bigint') throw new Error(`expected a bigint argument, found ${typeof(n)}`); +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches && builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +export function setup() { + wasm.setup(); +} + +function takeFromExternrefTable0(idx) { + const value = wasm.__wbindgen_export_4.get(idx); + wasm.__externref_table_dealloc(idx); + return value; +} +/** + * @returns {string} + */ +export function get_address() { + let deferred2_0; + let deferred2_1; + try { + const ret = wasm.get_address(); + var ptr1 = ret[0]; + var len1 = ret[1]; + if (ret[3]) { + ptr1 = 0; len1 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } +} + +/** + * @returns {Member} + */ +export function get_member() { + const ret = wasm.get_member(); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {any} device + */ +export function restore_device(device) { + const ret = wasm.restore_device(device); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +/** + * @param {string} sp_wallet + * @returns {string} + */ +export function create_device_from_sp_wallet(sp_wallet) { + let deferred3_0; + let deferred3_1; + try { + const ptr0 = passStringToWasm0(sp_wallet, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.create_device_from_sp_wallet(ptr0, len0); + var ptr2 = ret[0]; + var len2 = ret[1]; + if (ret[3]) { + ptr2 = 0; len2 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred3_0 = ptr2; + deferred3_1 = len2; + return getStringFromWasm0(ptr2, len2); + } finally { + wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); + } +} + +/** + * @param {number} birthday + * @param {string} network_str + * @returns {string} + */ +export function create_new_device(birthday, network_str) { + let deferred3_0; + let deferred3_1; + try { + _assertNum(birthday); + const ptr0 = passStringToWasm0(network_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.create_new_device(birthday, ptr0, len0); + var ptr2 = ret[0]; + var len2 = ret[1]; + if (ret[3]) { + ptr2 = 0; len2 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred3_0 = ptr2; + deferred3_1 = len2; + return getStringFromWasm0(ptr2, len2); + } finally { + wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); + } +} + +/** + * @returns {boolean} + */ +export function is_paired() { + const ret = wasm.is_paired(); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return ret[0] !== 0; +} + +function passArrayJsValueToWasm0(array, malloc) { + const ptr = malloc(array.length * 4, 4) >>> 0; + for (let i = 0; i < array.length; i++) { + const add = addToExternrefTable0(array[i]); + getDataViewMemory0().setUint32(ptr + 4 * i, add, true); + } + WASM_VECTOR_LEN = array.length; + return ptr; +} +/** + * @param {string} process_id + * @param {string[]} sp_addresses + */ +export function pair_device(process_id, sp_addresses) { + const ptr0 = passStringToWasm0(process_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArrayJsValueToWasm0(sp_addresses, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.pair_device(ptr0, len0, ptr1, len1); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +export function unpair_device() { + const ret = wasm.unpair_device(); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +/** + * @returns {string} + */ +export function dump_wallet() { + let deferred2_0; + let deferred2_1; + try { + const ret = wasm.dump_wallet(); + var ptr1 = ret[0]; + var len1 = ret[1]; + if (ret[3]) { + ptr1 = 0; len1 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } +} + +export function reset_process_cache() { + const ret = wasm.reset_process_cache(); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +/** + * @returns {string} + */ +export function dump_process_cache() { + let deferred2_0; + let deferred2_1; + try { + const ret = wasm.dump_process_cache(); + var ptr1 = ret[0]; + var len1 = ret[1]; + if (ret[3]) { + ptr1 = 0; len1 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } +} + +/** + * @param {any} processes + */ +export function set_process_cache(processes) { + const ret = wasm.set_process_cache(processes); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +/** + * @param {string} process_id + * @param {string} process + */ +export function add_to_process_cache(process_id, process) { + const ptr0 = passStringToWasm0(process_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(process, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.add_to_process_cache(ptr0, len0, ptr1, len1); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +export function reset_shared_secrets() { + const ret = wasm.reset_shared_secrets(); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +/** + * @param {string} secrets + */ +export function set_shared_secrets(secrets) { + const ptr0 = passStringToWasm0(secrets, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.set_shared_secrets(ptr0, len0); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +/** + * @returns {string} + */ +export function get_pairing_process_id() { + let deferred2_0; + let deferred2_1; + try { + const ret = wasm.get_pairing_process_id(); + var ptr1 = ret[0]; + var len1 = ret[1]; + if (ret[3]) { + ptr1 = 0; len1 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } +} + +/** + * @returns {Device} + */ +export function dump_device() { + const ret = wasm.dump_device(); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @returns {Device} + */ +export function dump_neutered_device() { + const ret = wasm.dump_neutered_device(); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +export function reset_device() { + const ret = wasm.reset_device(); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +/** + * @param {string} transaction + * @returns {string} + */ +export function get_txid(transaction) { + let deferred3_0; + let deferred3_1; + try { + const ptr0 = passStringToWasm0(transaction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.get_txid(ptr0, len0); + var ptr2 = ret[0]; + var len2 = ret[1]; + if (ret[3]) { + ptr2 = 0; len2 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred3_0 = ptr2; + deferred3_1 = len2; + return getStringFromWasm0(ptr2, len2); + } finally { + wasm.__wbindgen_free(deferred3_0, deferred3_1, 1); + } +} + +/** + * @param {string} new_tx_msg + * @param {number} block_height + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +export function parse_new_tx(new_tx_msg, block_height, members_list) { + const ptr0 = passStringToWasm0(new_tx_msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertNum(block_height); + const ret = wasm.parse_new_tx(ptr0, len0, block_height, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {string} cipher_msg + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +export function parse_cipher(cipher_msg, members_list) { + const ptr0 = passStringToWasm0(cipher_msg, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.parse_cipher(ptr0, len0, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @returns {any} + */ +export function get_outputs() { + const ret = wasm.get_outputs(); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @returns {bigint} + */ +export function get_available_amount() { + const ret = wasm.get_available_amount(); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return BigInt.asUintN(64, ret[0]); +} + +/** + * We send a transaction that pays at least one output to each address + * The goal can be to establish a shared_secret to be used as an encryption key for further communication + * or if the recipient is a relay it can be the init transaction for a new process + * @param {string[]} addresses + * @param {number} fee_rate + * @returns {ApiReturn} + */ +export function create_transaction(addresses, fee_rate) { + const ptr0 = passArrayJsValueToWasm0(addresses, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + _assertNum(fee_rate); + const ret = wasm.create_transaction(ptr0, len0, fee_rate); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {TsUnsignedTransaction} partial_tx + * @returns {ApiReturn} + */ +export function sign_transaction(partial_tx) { + const ret = wasm.sign_transaction(partial_tx); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {Pcd} private_data + * @param {Roles} roles + * @param {Pcd} public_data + * @param {string} relay_address + * @param {number} fee_rate + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +export function create_new_process(private_data, roles, public_data, relay_address, fee_rate, members_list) { + const ptr0 = passStringToWasm0(relay_address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertNum(fee_rate); + const ret = wasm.create_new_process(private_data, roles, public_data, ptr0, len0, fee_rate, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {Process} process + * @param {Pcd} new_attributes + * @param {Roles} roles + * @param {Pcd} new_public_data + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +export function update_process(process, new_attributes, roles, new_public_data, members_list) { + const ret = wasm.update_process(process, new_attributes, roles, new_public_data, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {string} process_id + * @param {string[]} state_ids_str + * @param {any} roles + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +export function request_data(process_id, state_ids_str, roles, members_list) { + const ptr0 = passStringToWasm0(process_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArrayJsValueToWasm0(state_ids_str, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.request_data(ptr0, len0, ptr1, len1, roles, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {Process} process + * @param {string} state_id + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +export function create_update_message(process, state_id, members_list) { + const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.create_update_message(process, ptr0, len0, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {Process} process + * @param {string} state_id + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +export function validate_state(process, state_id, members_list) { + const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.validate_state(process, ptr0, len0, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {Process} process + * @param {string} state_id + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +export function refuse_state(process, state_id, members_list) { + const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.refuse_state(process, ptr0, len0, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {Process} process + * @param {string} state_id + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +export function evaluate_state(process, state_id, members_list) { + const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.evaluate_state(process, ptr0, len0, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {Process} process + * @param {string} state_id + * @param {OutPointMemberMap} members_list + * @returns {ApiReturn} + */ +export function create_response_prd(process, state_id, members_list) { + const ptr0 = passStringToWasm0(state_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.create_response_prd(process, ptr0, len0, members_list); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @returns {string} + */ +export function create_faucet_msg() { + let deferred2_0; + let deferred2_1; + try { + const ret = wasm.create_faucet_msg(); + var ptr1 = ret[0]; + var len1 = ret[1]; + if (ret[3]) { + ptr1 = 0; len1 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } +} + +function getArrayJsValueFromWasm0(ptr, len) { + ptr = ptr >>> 0; + const mem = getDataViewMemory0(); + const result = []; + for (let i = ptr; i < ptr + 4 * len; i += 4) { + result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true))); + } + wasm.__externref_drop_slice(ptr, len); + return result; +} +/** + * @param {string} process_outpoint + * @returns {string[]} + */ +export function get_storages(process_outpoint) { + const ptr0 = passStringToWasm0(process_outpoint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.get_storages(ptr0, len0); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); + } + var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 4, 4); + return v2; +} + +/** + * @param {string} parent_roles + * @param {string} child_roles + */ +export function is_child_role(parent_roles, child_roles) { + const ptr0 = passStringToWasm0(parent_roles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(child_roles, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.is_child_role(ptr0, len0, ptr1, len1); + if (ret[1]) { + throw takeFromExternrefTable0(ret[0]); + } +} + +function passArray8ToWasm0(arg, malloc) { + const ptr = malloc(arg.length * 1, 1) >>> 0; + getUint8ArrayMemory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); +} +/** + * @param {Uint8Array} key + * @param {Uint8Array} data + * @returns {Uint8Array} + */ +export function decrypt_data(key, data) { + const ptr0 = passArray8ToWasm0(key, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.decrypt_data(ptr0, len0, ptr1, len1); + if (ret[3]) { + throw takeFromExternrefTable0(ret[2]); + } + var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); + wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); + return v3; +} + +/** + * @param {any} data + * @returns {Pcd} + */ +export function encode_binary(data) { + const ret = wasm.encode_binary(data); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {any} json_data + * @returns {Pcd} + */ +export function encode_json(json_data) { + const ret = wasm.encode_json(json_data); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {Uint8Array} value + * @returns {any} + */ +export function decode_value(value) { + const ptr0 = passArray8ToWasm0(value, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.decode_value(ptr0, len0); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * @param {any} value + * @param {string} commited_in + * @param {string} label + * @returns {string} + */ +export function hash_value(value, commited_in, label) { + let deferred4_0; + let deferred4_1; + try { + const ptr0 = passStringToWasm0(commited_in, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(label, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ret = wasm.hash_value(value, ptr0, len0, ptr1, len1); + var ptr3 = ret[0]; + var len3 = ret[1]; + if (ret[3]) { + ptr3 = 0; len3 = 0; + throw takeFromExternrefTable0(ret[2]); + } + deferred4_0 = ptr3; + deferred4_1 = len3; + return getStringFromWasm0(ptr3, len3); + } finally { + wasm.__wbindgen_free(deferred4_0, deferred4_1, 1); + } +} + +/** + * Generate a merkle proof for a specific attribute in a process state. + * + * This function creates a merkle proof that proves the existence of a specific attribute + * in a given state of a process. The proof can be used to verify that the attribute + * was indeed part of the state without revealing the entire state. + * + * # Arguments + * * `process_state` - The process state object as a JavaScript value + * * `attribute_name` - The name of the attribute to generate a proof for + * + * # Returns + * A MerkleProofResult object containing: + * * `proof` - The merkle proof as a hex string + * * `root` - The merkle root (state_id) as a hex string + * * `attribute` - The attribute name that was proven + * * `attribute_index` - The index of the attribute in the merkle tree + * * `total_leaves_count` - The total number of leaves in the merkle tree + * + * # Errors + * * "Failed to deserialize process state" - If the process state cannot be deserialized from JsValue + * * "Attribute not found in state" - If the attribute doesn't exist in the state + * @param {any} process_state + * @param {string} attribute_name + * @returns {MerkleProofResult} + */ +export function get_merkle_proof(process_state, attribute_name) { + const ptr0 = passStringToWasm0(attribute_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.get_merkle_proof(process_state, ptr0, len0); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return takeFromExternrefTable0(ret[0]); +} + +/** + * Validate a merkle proof for a specific attribute. + * + * This function verifies that a merkle proof is valid and proves the existence + * of a specific attribute in a given state. It checks that the proof correctly + * leads to the claimed root when combined with the attribute hash. + * + * # Arguments + * * `proof_result` - a JsValue expected to contain a MerkleProofResult with the proof and metadata + * * `hash` - The hash of the attribute data as a hex string (the leaf value) + * + * # Returns + * A boolean indicating whether the proof is valid + * + * # Errors + * * "serde_wasm_bindgen deserialization error" - If the proof is not a valid MerkleProofResult + * * "Invalid proof format" - If the proof cannot be parsed + * * "Invalid hash format" - If the hash is not a valid 32-byte hex string + * * "Invalid root format" - If the root is not a valid 32-byte hex string + * @param {any} proof_result + * @param {string} hash + * @returns {boolean} + */ +export function validate_merkle_proof(proof_result, hash) { + const ptr0 = passStringToWasm0(hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.validate_merkle_proof(proof_result, ptr0, len0); + if (ret[2]) { + throw takeFromExternrefTable0(ret[1]); + } + return ret[0] !== 0; +} + +export function __wbg_String_8f0eb39a4a4c2f66() { return logError(function (arg0, arg1) { + const ret = String(arg1); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); +}, arguments) }; + +export function __wbg_buffer_609cc3eee51ed158() { return logError(function (arg0) { + const ret = arg0.buffer; + return ret; +}, arguments) }; + +export function __wbg_call_672a4d21634d4a24() { return handleError(function (arg0, arg1) { + const ret = arg0.call(arg1); + return ret; +}, arguments) }; + +export function __wbg_call_7cccdd69e0791ae2() { return handleError(function (arg0, arg1, arg2) { + const ret = arg0.call(arg1, arg2); + return ret; +}, arguments) }; + +export function __wbg_crypto_ed58b8e10a292839() { return logError(function (arg0) { + const ret = arg0.crypto; + return ret; +}, arguments) }; + +export function __wbg_debug_e17b51583ca6a632() { return logError(function (arg0, arg1, arg2, arg3) { + console.debug(arg0, arg1, arg2, arg3); +}, arguments) }; + +export function __wbg_done_769e5ede4b31c67b() { return logError(function (arg0) { + const ret = arg0.done; + _assertBoolean(ret); + return ret; +}, arguments) }; + +export function __wbg_entries_3265d4158b33e5dc() { return logError(function (arg0) { + const ret = Object.entries(arg0); + return ret; +}, arguments) }; + +export function __wbg_error_524f506f44df1645() { return logError(function (arg0) { + console.error(arg0); +}, arguments) }; + +export function __wbg_error_80de38b3f7cc3c3c() { return logError(function (arg0, arg1, arg2, arg3) { + console.error(arg0, arg1, arg2, arg3); +}, arguments) }; + +export function __wbg_getRandomValues_bcb4912f16000dc4() { return handleError(function (arg0, arg1) { + arg0.getRandomValues(arg1); +}, arguments) }; + +export function __wbg_get_67b2ba62fc30de12() { return handleError(function (arg0, arg1) { + const ret = Reflect.get(arg0, arg1); + return ret; +}, arguments) }; + +export function __wbg_get_b9b93047fe3cf45b() { return logError(function (arg0, arg1) { + const ret = arg0[arg1 >>> 0]; + return ret; +}, arguments) }; + +export function __wbg_getwithrefkey_1dc361bd10053bfe() { return logError(function (arg0, arg1) { + const ret = arg0[arg1]; + return ret; +}, arguments) }; + +export function __wbg_info_033d8b8a0838f1d3() { return logError(function (arg0, arg1, arg2, arg3) { + console.info(arg0, arg1, arg2, arg3); +}, arguments) }; + +export function __wbg_instanceof_ArrayBuffer_e14585432e3737fc() { return logError(function (arg0) { + let result; + try { + result = arg0 instanceof ArrayBuffer; + } catch (_) { + result = false; + } + const ret = result; + _assertBoolean(ret); + return ret; +}, arguments) }; + +export function __wbg_instanceof_Map_f3469ce2244d2430() { return logError(function (arg0) { + let result; + try { + result = arg0 instanceof Map; + } catch (_) { + result = false; + } + const ret = result; + _assertBoolean(ret); + return ret; +}, arguments) }; + +export function __wbg_instanceof_Uint8Array_17156bcf118086a9() { return logError(function (arg0) { + let result; + try { + result = arg0 instanceof Uint8Array; + } catch (_) { + result = false; + } + const ret = result; + _assertBoolean(ret); + return ret; +}, arguments) }; + +export function __wbg_isArray_a1eab7e0d067391b() { return logError(function (arg0) { + const ret = Array.isArray(arg0); + _assertBoolean(ret); + return ret; +}, arguments) }; + +export function __wbg_isSafeInteger_343e2beeeece1bb0() { return logError(function (arg0) { + const ret = Number.isSafeInteger(arg0); + _assertBoolean(ret); + return ret; +}, arguments) }; + +export function __wbg_iterator_9a24c88df860dc65() { return logError(function () { + const ret = Symbol.iterator; + return ret; +}, arguments) }; + +export function __wbg_length_a446193dc22c12f8() { return logError(function (arg0) { + const ret = arg0.length; + _assertNum(ret); + return ret; +}, arguments) }; + +export function __wbg_length_e2d2a49132c1b256() { return logError(function (arg0) { + const ret = arg0.length; + _assertNum(ret); + return ret; +}, arguments) }; + +export function __wbg_log_cad59bb680daec67() { return logError(function (arg0, arg1, arg2, arg3) { + console.log(arg0, arg1, arg2, arg3); +}, arguments) }; + +export function __wbg_msCrypto_0a36e2ec3a343d26() { return logError(function (arg0) { + const ret = arg0.msCrypto; + return ret; +}, arguments) }; + +export function __wbg_new_405e22f390576ce2() { return logError(function () { + const ret = new Object(); + return ret; +}, arguments) }; + +export function __wbg_new_5e0be73521bc8c17() { return logError(function () { + const ret = new Map(); + return ret; +}, arguments) }; + +export function __wbg_new_78feb108b6472713() { return logError(function () { + const ret = new Array(); + return ret; +}, arguments) }; + +export function __wbg_new_a12002a7f91c75be() { return logError(function (arg0) { + const ret = new Uint8Array(arg0); + return ret; +}, arguments) }; + +export function __wbg_newnoargs_105ed471475aaf50() { return logError(function (arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return ret; +}, arguments) }; + +export function __wbg_newwithbyteoffsetandlength_d97e637ebe145a9a() { return logError(function (arg0, arg1, arg2) { + const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0); + return ret; +}, arguments) }; + +export function __wbg_newwithlength_a381634e90c276d4() { return logError(function (arg0) { + const ret = new Uint8Array(arg0 >>> 0); + return ret; +}, arguments) }; + +export function __wbg_next_25feadfc0913fea9() { return logError(function (arg0) { + const ret = arg0.next; + return ret; +}, arguments) }; + +export function __wbg_next_6574e1a8a62d1055() { return handleError(function (arg0) { + const ret = arg0.next(); + return ret; +}, arguments) }; + +export function __wbg_node_02999533c4ea02e3() { return logError(function (arg0) { + const ret = arg0.node; + return ret; +}, arguments) }; + +export function __wbg_parse_def2e24ef1252aff() { return handleError(function (arg0, arg1) { + const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); + return ret; +}, arguments) }; + +export function __wbg_process_5c1d670bc53614b8() { return logError(function (arg0) { + const ret = arg0.process; + return ret; +}, arguments) }; + +export function __wbg_randomFillSync_ab2cfe79ebbf2740() { return handleError(function (arg0, arg1) { + arg0.randomFillSync(arg1); +}, arguments) }; + +export function __wbg_require_79b1e9274cde3c87() { return handleError(function () { + const ret = module.require; + return ret; +}, arguments) }; + +export function __wbg_set_37837023f3d740e8() { return logError(function (arg0, arg1, arg2) { + arg0[arg1 >>> 0] = arg2; +}, arguments) }; + +export function __wbg_set_3f1d0b984ed272ed() { return logError(function (arg0, arg1, arg2) { + arg0[arg1] = arg2; +}, arguments) }; + +export function __wbg_set_65595bdd868b3009() { return logError(function (arg0, arg1, arg2) { + arg0.set(arg1, arg2 >>> 0); +}, arguments) }; + +export function __wbg_set_8fc6bf8a5b1071d1() { return logError(function (arg0, arg1, arg2) { + const ret = arg0.set(arg1, arg2); + return ret; +}, arguments) }; + +export function __wbg_set_bb8cecf6a62b9f46() { return handleError(function (arg0, arg1, arg2) { + const ret = Reflect.set(arg0, arg1, arg2); + _assertBoolean(ret); + return ret; +}, arguments) }; + +export function __wbg_static_accessor_GLOBAL_88a902d13a557d07() { return logError(function () { + const ret = typeof global === 'undefined' ? null : global; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); +}, arguments) }; + +export function __wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0() { return logError(function () { + const ret = typeof globalThis === 'undefined' ? null : globalThis; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); +}, arguments) }; + +export function __wbg_static_accessor_SELF_37c5d418e4bf5819() { return logError(function () { + const ret = typeof self === 'undefined' ? null : self; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); +}, arguments) }; + +export function __wbg_static_accessor_WINDOW_5de37043a91a9c40() { return logError(function () { + const ret = typeof window === 'undefined' ? null : window; + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); +}, arguments) }; + +export function __wbg_stringify_f7ed6987935b4a24() { return handleError(function (arg0) { + const ret = JSON.stringify(arg0); + return ret; +}, arguments) }; + +export function __wbg_subarray_aa9065fa9dc5df96() { return logError(function (arg0, arg1, arg2) { + const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0); + return ret; +}, arguments) }; + +export function __wbg_value_cd1ffa7b1ab794f1() { return logError(function (arg0) { + const ret = arg0.value; + return ret; +}, arguments) }; + +export function __wbg_versions_c71aa1626a93e0a1() { return logError(function (arg0) { + const ret = arg0.versions; + return ret; +}, arguments) }; + +export function __wbg_warn_aaf1f4664a035bd6() { return logError(function (arg0, arg1, arg2, arg3) { + console.warn(arg0, arg1, arg2, arg3); +}, arguments) }; + +export function __wbindgen_as_number(arg0) { + const ret = +arg0; + return ret; +}; + +export function __wbindgen_bigint_from_i64(arg0) { + const ret = arg0; + return ret; +}; + +export function __wbindgen_bigint_from_u64(arg0) { + const ret = BigInt.asUintN(64, arg0); + return ret; +}; + +export function __wbindgen_bigint_get_as_i64(arg0, arg1) { + const v = arg1; + const ret = typeof(v) === 'bigint' ? v : undefined; + if (!isLikeNone(ret)) { + _assertBigInt(ret); + } + getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); +}; + +export function __wbindgen_boolean_get(arg0) { + const v = arg0; + const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; + _assertNum(ret); + return ret; +}; + +export function __wbindgen_debug_string(arg0, arg1) { + const ret = debugString(arg1); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); +}; + +export function __wbindgen_error_new(arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return ret; +}; + +export function __wbindgen_in(arg0, arg1) { + const ret = arg0 in arg1; + _assertBoolean(ret); + return ret; +}; + +export function __wbindgen_init_externref_table() { + const table = wasm.__wbindgen_export_4; + const offset = table.grow(4); + table.set(0, undefined); + table.set(offset + 0, undefined); + table.set(offset + 1, null); + table.set(offset + 2, true); + table.set(offset + 3, false); + ; +}; + +export function __wbindgen_is_bigint(arg0) { + const ret = typeof(arg0) === 'bigint'; + _assertBoolean(ret); + return ret; +}; + +export function __wbindgen_is_function(arg0) { + const ret = typeof(arg0) === 'function'; + _assertBoolean(ret); + return ret; +}; + +export function __wbindgen_is_object(arg0) { + const val = arg0; + const ret = typeof(val) === 'object' && val !== null; + _assertBoolean(ret); + return ret; +}; + +export function __wbindgen_is_string(arg0) { + const ret = typeof(arg0) === 'string'; + _assertBoolean(ret); + return ret; +}; + +export function __wbindgen_is_undefined(arg0) { + const ret = arg0 === undefined; + _assertBoolean(ret); + return ret; +}; + +export function __wbindgen_jsval_eq(arg0, arg1) { + const ret = arg0 === arg1; + _assertBoolean(ret); + return ret; +}; + +export function __wbindgen_jsval_loose_eq(arg0, arg1) { + const ret = arg0 == arg1; + _assertBoolean(ret); + return ret; +}; + +export function __wbindgen_memory() { + const ret = wasm.memory; + return ret; +}; + +export function __wbindgen_number_get(arg0, arg1) { + const obj = arg1; + const ret = typeof(obj) === 'number' ? obj : undefined; + if (!isLikeNone(ret)) { + _assertNum(ret); + } + getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); +}; + +export function __wbindgen_number_new(arg0) { + const ret = arg0; + return ret; +}; + +export function __wbindgen_string_get(arg0, arg1) { + const obj = arg1; + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); +}; + +export function __wbindgen_string_new(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return ret; +}; + +export function __wbindgen_throw(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); +}; + diff --git a/pkg/sdk_client_bg.wasm b/pkg/sdk_client_bg.wasm index 288c36e..e8c9c93 100644 Binary files a/pkg/sdk_client_bg.wasm and b/pkg/sdk_client_bg.wasm differ diff --git a/pkg/sdk_client_bg.wasm.d.ts b/pkg/sdk_client_bg.wasm.d.ts new file mode 100644 index 0000000..42f0e22 --- /dev/null +++ b/pkg/sdk_client_bg.wasm.d.ts @@ -0,0 +1,69 @@ +/* tslint:disable */ +/* eslint-disable */ +export const memory: WebAssembly.Memory; +export const setup: () => void; +export const get_address: () => [number, number, number, number]; +export const get_member: () => [number, number, number]; +export const restore_device: (a: any) => [number, number]; +export const create_device_from_sp_wallet: (a: number, b: number) => [number, number, number, number]; +export const create_new_device: (a: number, b: number, c: number) => [number, number, number, number]; +export const is_paired: () => [number, number, number]; +export const pair_device: (a: number, b: number, c: number, d: number) => [number, number]; +export const unpair_device: () => [number, number]; +export const dump_wallet: () => [number, number, number, number]; +export const reset_process_cache: () => [number, number]; +export const dump_process_cache: () => [number, number, number, number]; +export const set_process_cache: (a: any) => [number, number]; +export const add_to_process_cache: (a: number, b: number, c: number, d: number) => [number, number]; +export const reset_shared_secrets: () => [number, number]; +export const set_shared_secrets: (a: number, b: number) => [number, number]; +export const get_pairing_process_id: () => [number, number, number, number]; +export const dump_device: () => [number, number, number]; +export const dump_neutered_device: () => [number, number, number]; +export const reset_device: () => [number, number]; +export const get_txid: (a: number, b: number) => [number, number, number, number]; +export const parse_new_tx: (a: number, b: number, c: number, d: any) => [number, number, number]; +export const parse_cipher: (a: number, b: number, c: any) => [number, number, number]; +export const get_outputs: () => [number, number, number]; +export const get_available_amount: () => [bigint, number, number]; +export const create_transaction: (a: number, b: number, c: number) => [number, number, number]; +export const sign_transaction: (a: any) => [number, number, number]; +export const create_new_process: (a: any, b: any, c: any, d: number, e: number, f: number, g: any) => [number, number, number]; +export const update_process: (a: any, b: any, c: any, d: any, e: any) => [number, number, number]; +export const request_data: (a: number, b: number, c: number, d: number, e: any, f: any) => [number, number, number]; +export const create_update_message: (a: any, b: number, c: number, d: any) => [number, number, number]; +export const validate_state: (a: any, b: number, c: number, d: any) => [number, number, number]; +export const refuse_state: (a: any, b: number, c: number, d: any) => [number, number, number]; +export const evaluate_state: (a: any, b: number, c: number, d: any) => [number, number, number]; +export const create_response_prd: (a: any, b: number, c: number, d: any) => [number, number, number]; +export const create_faucet_msg: () => [number, number, number, number]; +export const get_storages: (a: number, b: number) => [number, number, number, number]; +export const is_child_role: (a: number, b: number, c: number, d: number) => [number, number]; +export const decrypt_data: (a: number, b: number, c: number, d: number) => [number, number, number, number]; +export const encode_binary: (a: any) => [number, number, number]; +export const encode_json: (a: any) => [number, number, number]; +export const decode_value: (a: number, b: number) => [number, number, number]; +export const hash_value: (a: any, b: number, c: number, d: number, e: number) => [number, number, number, number]; +export const get_merkle_proof: (a: any, b: number, c: number) => [number, number, number]; +export const validate_merkle_proof: (a: any, b: number, c: number) => [number, number, number]; +export const rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void; +export const rust_zstd_wasm_shim_malloc: (a: number) => number; +export const rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number; +export const rust_zstd_wasm_shim_calloc: (a: number, b: number) => number; +export const rust_zstd_wasm_shim_free: (a: number) => void; +export const rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number; +export const rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number; +export const rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number; +export const rustsecp256k1_v0_9_2_context_create: (a: number) => number; +export const rustsecp256k1_v0_9_2_context_destroy: (a: number) => void; +export const rustsecp256k1_v0_9_2_default_illegal_callback_fn: (a: number, b: number) => void; +export const rustsecp256k1_v0_9_2_default_error_callback_fn: (a: number, b: number) => void; +export const __wbindgen_malloc: (a: number, b: number) => number; +export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; +export const __wbindgen_exn_store: (a: number) => void; +export const __externref_table_alloc: () => number; +export const __wbindgen_export_4: WebAssembly.Table; +export const __externref_table_dealloc: (a: number) => void; +export const __wbindgen_free: (a: number, b: number, c: number) => void; +export const __externref_drop_slice: (a: number, b: number) => void; +export const __wbindgen_start: () => void;