@gloxx/gloxx-wasm 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -0
- package/gloxx_wasm.d.ts +75 -0
- package/gloxx_wasm.js +920 -0
- package/gloxx_wasm_bg.wasm +0 -0
- package/package.json +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @gloxx/wasm
|
|
2
|
+
|
|
3
|
+
WebAssembly (Wasm) bindings for the Gloxx Network, providing high-performance cryptographic operations and wallet management for browser-based environments.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package brings the security and performance of the Gloxx Rust implementation to the web. It allows developers to build client-side applications that can:
|
|
8
|
+
- Create and manage user wallets.
|
|
9
|
+
- Construct valid Gloxx transactions.
|
|
10
|
+
- Cryptographically sign transactions and messages.
|
|
11
|
+
|
|
12
|
+
All of this is done in a secure, client-side context without relying on centralized servers for sensitive operations.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @gloxx/wasm
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start: Creating and Signing a Transaction
|
|
21
|
+
|
|
22
|
+
Since this package is built with `--target web`, you must initialize the Wasm module before using any functions.
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
import init, {
|
|
26
|
+
generate_wallet,
|
|
27
|
+
create_transaction,
|
|
28
|
+
sign_transaction
|
|
29
|
+
} from '@gloxx/wasm';
|
|
30
|
+
|
|
31
|
+
async function main() {
|
|
32
|
+
// 1. Load the Wasm binary
|
|
33
|
+
await init();
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
// 2. Create a new wallet
|
|
37
|
+
const senderWallet = generate_wallet();
|
|
38
|
+
console.log(`Sender Address: ${senderWallet.address}`);
|
|
39
|
+
|
|
40
|
+
// 3. Define transaction details
|
|
41
|
+
const recipientAddress = "glx1...recipient_address..."; // Replace with a real address
|
|
42
|
+
const amount = 100; // The amount to send
|
|
43
|
+
const nonce = 0; // The sender's current nonce
|
|
44
|
+
|
|
45
|
+
// 4. Create the transaction object
|
|
46
|
+
// This object is a JsValue, an opaque handle to the Rust struct.
|
|
47
|
+
// It is not a plain JavaScript object.
|
|
48
|
+
const unsignedTx = create_transaction(
|
|
49
|
+
senderWallet.address,
|
|
50
|
+
senderWallet.public_key,
|
|
51
|
+
recipientAddress,
|
|
52
|
+
amount,
|
|
53
|
+
nonce
|
|
54
|
+
);
|
|
55
|
+
console.log("Successfully created transaction object.");
|
|
56
|
+
|
|
57
|
+
// 5. Sign the transaction object using the sender's private key
|
|
58
|
+
const signature = sign_transaction(unsignedTx, senderWallet.private_key);
|
|
59
|
+
console.log(`Transaction Signature: ${signature}`);
|
|
60
|
+
|
|
61
|
+
// The `unsignedTx` object and the `signature` can now be broadcast
|
|
62
|
+
// to a Gloxx network node using a library like fetch or axios.
|
|
63
|
+
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error("Gloxx Wasm Error:", error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
main();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## API Reference
|
|
73
|
+
|
|
74
|
+
All functions return a `Promise` if using an async bundler or require an `await init()` call first.
|
|
75
|
+
|
|
76
|
+
### Wallet Management
|
|
77
|
+
|
|
78
|
+
- `generate_wallet()`: Generates a new random wallet.
|
|
79
|
+
- **Returns:** `JsWallet` object: `{ address, mnemonic, private_key, public_key }`.
|
|
80
|
+
|
|
81
|
+
- `import_wallet(phrase, passphrase?)`: Recovers a wallet from a mnemonic phrase.
|
|
82
|
+
- **Parameters:**
|
|
83
|
+
- `phrase` (string): The 12-24 word recovery phrase.
|
|
84
|
+
- `passphrase` (optional string): An optional BIP39 passphrase.
|
|
85
|
+
- **Returns:** `JsWallet` object.
|
|
86
|
+
|
|
87
|
+
### Transaction Workflow
|
|
88
|
+
|
|
89
|
+
- `create_transaction(sender_address, public_key_hex, recipient_address, amount, nonce)`: Constructs an unsigned transaction.
|
|
90
|
+
- **Parameters:**
|
|
91
|
+
- `sender_address` (string): The sender's `glx1...` address.
|
|
92
|
+
- `public_key_hex` (string): The sender's public key, hex-encoded.
|
|
93
|
+
- `recipient_address` (string): The recipient's `glx1...` address.
|
|
94
|
+
- `amount` (number): The amount of the transfer.
|
|
95
|
+
- `nonce` (number): The sender's current transaction count.
|
|
96
|
+
- **Returns:** `JsValue` - An opaque handle to the Rust transaction object. Pass this directly to `sign_transaction`.
|
|
97
|
+
|
|
98
|
+
- `sign_transaction(transaction_js, private_key_hex)`: Signs a transaction object created by `create_transaction`.
|
|
99
|
+
- **Parameters:**
|
|
100
|
+
- `transaction_js` (JsValue): The object returned from `create_transaction`.
|
|
101
|
+
- `private_key_hex` (string): The sender's private key, hex-encoded.
|
|
102
|
+
- **Returns:** (string) The resulting signature, hex-encoded.
|
|
103
|
+
|
|
104
|
+
### Other Cryptographic Functions
|
|
105
|
+
|
|
106
|
+
- `sign_message(message, private_key_hex)`: Signs a generic message (string or `Uint8Array`).
|
|
107
|
+
- `verify_signature(message, signature_hex, public_key_hex)`: Validates a signature against a public key. Returns `true` if valid.
|
|
108
|
+
- `encrypt_keystore(private_key_hex, address, password)`: Encrypts the private key, returning a JSON string for secure storage (e.g., in `localStorage`).
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT
|
|
113
|
+
|
|
114
|
+
© 2025 Gloxx Network
|
package/gloxx_wasm.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class JsWallet {
|
|
5
|
+
private constructor();
|
|
6
|
+
free(): void;
|
|
7
|
+
[Symbol.dispose](): void;
|
|
8
|
+
address: string;
|
|
9
|
+
mnemonic: string;
|
|
10
|
+
private_key: string;
|
|
11
|
+
public_key: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function create_transaction(sender_address: string, public_key_hex: string, recipient_address: string, amount: bigint, nonce: bigint): any;
|
|
15
|
+
|
|
16
|
+
export function encrypt_keystore(private_key_hex: string, address: string, password: string): string;
|
|
17
|
+
|
|
18
|
+
export function generate_wallet(): JsWallet;
|
|
19
|
+
|
|
20
|
+
export function import_wallet(phrase: string, passphrase?: string | null): JsWallet;
|
|
21
|
+
|
|
22
|
+
export function sign_message(message: any, private_key_hex: string): string;
|
|
23
|
+
|
|
24
|
+
export function sign_transaction(transaction_js: any, private_key_hex: string): string;
|
|
25
|
+
|
|
26
|
+
export function verify_signature(message: any, signature_hex: string, public_key_hex: string): boolean;
|
|
27
|
+
|
|
28
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
29
|
+
|
|
30
|
+
export interface InitOutput {
|
|
31
|
+
readonly memory: WebAssembly.Memory;
|
|
32
|
+
readonly __wbg_get_jswallet_address: (a: number, b: number) => void;
|
|
33
|
+
readonly __wbg_get_jswallet_mnemonic: (a: number, b: number) => void;
|
|
34
|
+
readonly __wbg_get_jswallet_private_key: (a: number, b: number) => void;
|
|
35
|
+
readonly __wbg_get_jswallet_public_key: (a: number, b: number) => void;
|
|
36
|
+
readonly __wbg_jswallet_free: (a: number, b: number) => void;
|
|
37
|
+
readonly __wbg_set_jswallet_address: (a: number, b: number, c: number) => void;
|
|
38
|
+
readonly __wbg_set_jswallet_mnemonic: (a: number, b: number, c: number) => void;
|
|
39
|
+
readonly __wbg_set_jswallet_private_key: (a: number, b: number, c: number) => void;
|
|
40
|
+
readonly __wbg_set_jswallet_public_key: (a: number, b: number, c: number) => void;
|
|
41
|
+
readonly create_transaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint, i: bigint) => void;
|
|
42
|
+
readonly encrypt_keystore: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
43
|
+
readonly generate_wallet: (a: number) => void;
|
|
44
|
+
readonly import_wallet: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
45
|
+
readonly sign_message: (a: number, b: number, c: number, d: number) => void;
|
|
46
|
+
readonly sign_transaction: (a: number, b: number, c: number, d: number) => void;
|
|
47
|
+
readonly verify_signature: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
48
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
49
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
50
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
51
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
52
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
59
|
+
* a precompiled `WebAssembly.Module`.
|
|
60
|
+
*
|
|
61
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
62
|
+
*
|
|
63
|
+
* @returns {InitOutput}
|
|
64
|
+
*/
|
|
65
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
69
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
70
|
+
*
|
|
71
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
72
|
+
*
|
|
73
|
+
* @returns {Promise<InitOutput>}
|
|
74
|
+
*/
|
|
75
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/gloxx_wasm.js
ADDED
|
@@ -0,0 +1,920 @@
|
|
|
1
|
+
/* @ts-self-types="./gloxx_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
export class JsWallet {
|
|
4
|
+
static __wrap(ptr) {
|
|
5
|
+
ptr = ptr >>> 0;
|
|
6
|
+
const obj = Object.create(JsWallet.prototype);
|
|
7
|
+
obj.__wbg_ptr = ptr;
|
|
8
|
+
JsWalletFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
9
|
+
return obj;
|
|
10
|
+
}
|
|
11
|
+
__destroy_into_raw() {
|
|
12
|
+
const ptr = this.__wbg_ptr;
|
|
13
|
+
this.__wbg_ptr = 0;
|
|
14
|
+
JsWalletFinalization.unregister(this);
|
|
15
|
+
return ptr;
|
|
16
|
+
}
|
|
17
|
+
free() {
|
|
18
|
+
const ptr = this.__destroy_into_raw();
|
|
19
|
+
wasm.__wbg_jswallet_free(ptr, 0);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @returns {string}
|
|
23
|
+
*/
|
|
24
|
+
get address() {
|
|
25
|
+
let deferred1_0;
|
|
26
|
+
let deferred1_1;
|
|
27
|
+
try {
|
|
28
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
29
|
+
wasm.__wbg_get_jswallet_address(retptr, this.__wbg_ptr);
|
|
30
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
31
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
32
|
+
deferred1_0 = r0;
|
|
33
|
+
deferred1_1 = r1;
|
|
34
|
+
return getStringFromWasm0(r0, r1);
|
|
35
|
+
} finally {
|
|
36
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
37
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @returns {string}
|
|
42
|
+
*/
|
|
43
|
+
get mnemonic() {
|
|
44
|
+
let deferred1_0;
|
|
45
|
+
let deferred1_1;
|
|
46
|
+
try {
|
|
47
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
48
|
+
wasm.__wbg_get_jswallet_mnemonic(retptr, this.__wbg_ptr);
|
|
49
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
50
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
51
|
+
deferred1_0 = r0;
|
|
52
|
+
deferred1_1 = r1;
|
|
53
|
+
return getStringFromWasm0(r0, r1);
|
|
54
|
+
} finally {
|
|
55
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
56
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @returns {string}
|
|
61
|
+
*/
|
|
62
|
+
get private_key() {
|
|
63
|
+
let deferred1_0;
|
|
64
|
+
let deferred1_1;
|
|
65
|
+
try {
|
|
66
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
67
|
+
wasm.__wbg_get_jswallet_private_key(retptr, this.__wbg_ptr);
|
|
68
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
69
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
70
|
+
deferred1_0 = r0;
|
|
71
|
+
deferred1_1 = r1;
|
|
72
|
+
return getStringFromWasm0(r0, r1);
|
|
73
|
+
} finally {
|
|
74
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
75
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @returns {string}
|
|
80
|
+
*/
|
|
81
|
+
get public_key() {
|
|
82
|
+
let deferred1_0;
|
|
83
|
+
let deferred1_1;
|
|
84
|
+
try {
|
|
85
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
86
|
+
wasm.__wbg_get_jswallet_public_key(retptr, this.__wbg_ptr);
|
|
87
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
88
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
89
|
+
deferred1_0 = r0;
|
|
90
|
+
deferred1_1 = r1;
|
|
91
|
+
return getStringFromWasm0(r0, r1);
|
|
92
|
+
} finally {
|
|
93
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
94
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @param {string} arg0
|
|
99
|
+
*/
|
|
100
|
+
set address(arg0) {
|
|
101
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
102
|
+
const len0 = WASM_VECTOR_LEN;
|
|
103
|
+
wasm.__wbg_set_jswallet_address(this.__wbg_ptr, ptr0, len0);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @param {string} arg0
|
|
107
|
+
*/
|
|
108
|
+
set mnemonic(arg0) {
|
|
109
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
110
|
+
const len0 = WASM_VECTOR_LEN;
|
|
111
|
+
wasm.__wbg_set_jswallet_mnemonic(this.__wbg_ptr, ptr0, len0);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @param {string} arg0
|
|
115
|
+
*/
|
|
116
|
+
set private_key(arg0) {
|
|
117
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
118
|
+
const len0 = WASM_VECTOR_LEN;
|
|
119
|
+
wasm.__wbg_set_jswallet_private_key(this.__wbg_ptr, ptr0, len0);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @param {string} arg0
|
|
123
|
+
*/
|
|
124
|
+
set public_key(arg0) {
|
|
125
|
+
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
126
|
+
const len0 = WASM_VECTOR_LEN;
|
|
127
|
+
wasm.__wbg_set_jswallet_public_key(this.__wbg_ptr, ptr0, len0);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (Symbol.dispose) JsWallet.prototype[Symbol.dispose] = JsWallet.prototype.free;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @param {string} sender_address
|
|
134
|
+
* @param {string} public_key_hex
|
|
135
|
+
* @param {string} recipient_address
|
|
136
|
+
* @param {bigint} amount
|
|
137
|
+
* @param {bigint} nonce
|
|
138
|
+
* @returns {any}
|
|
139
|
+
*/
|
|
140
|
+
export function create_transaction(sender_address, public_key_hex, recipient_address, amount, nonce) {
|
|
141
|
+
try {
|
|
142
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
143
|
+
const ptr0 = passStringToWasm0(sender_address, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
144
|
+
const len0 = WASM_VECTOR_LEN;
|
|
145
|
+
const ptr1 = passStringToWasm0(public_key_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
146
|
+
const len1 = WASM_VECTOR_LEN;
|
|
147
|
+
const ptr2 = passStringToWasm0(recipient_address, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
148
|
+
const len2 = WASM_VECTOR_LEN;
|
|
149
|
+
wasm.create_transaction(retptr, ptr0, len0, ptr1, len1, ptr2, len2, amount, nonce);
|
|
150
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
151
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
152
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
153
|
+
if (r2) {
|
|
154
|
+
throw takeObject(r1);
|
|
155
|
+
}
|
|
156
|
+
return takeObject(r0);
|
|
157
|
+
} finally {
|
|
158
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @param {string} private_key_hex
|
|
164
|
+
* @param {string} address
|
|
165
|
+
* @param {string} password
|
|
166
|
+
* @returns {string}
|
|
167
|
+
*/
|
|
168
|
+
export function encrypt_keystore(private_key_hex, address, password) {
|
|
169
|
+
let deferred5_0;
|
|
170
|
+
let deferred5_1;
|
|
171
|
+
try {
|
|
172
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
173
|
+
const ptr0 = passStringToWasm0(private_key_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
174
|
+
const len0 = WASM_VECTOR_LEN;
|
|
175
|
+
const ptr1 = passStringToWasm0(address, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
176
|
+
const len1 = WASM_VECTOR_LEN;
|
|
177
|
+
const ptr2 = passStringToWasm0(password, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
178
|
+
const len2 = WASM_VECTOR_LEN;
|
|
179
|
+
wasm.encrypt_keystore(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
180
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
181
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
182
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
183
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
184
|
+
var ptr4 = r0;
|
|
185
|
+
var len4 = r1;
|
|
186
|
+
if (r3) {
|
|
187
|
+
ptr4 = 0; len4 = 0;
|
|
188
|
+
throw takeObject(r2);
|
|
189
|
+
}
|
|
190
|
+
deferred5_0 = ptr4;
|
|
191
|
+
deferred5_1 = len4;
|
|
192
|
+
return getStringFromWasm0(ptr4, len4);
|
|
193
|
+
} finally {
|
|
194
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
195
|
+
wasm.__wbindgen_export4(deferred5_0, deferred5_1, 1);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @returns {JsWallet}
|
|
201
|
+
*/
|
|
202
|
+
export function generate_wallet() {
|
|
203
|
+
try {
|
|
204
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
205
|
+
wasm.generate_wallet(retptr);
|
|
206
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
207
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
208
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
209
|
+
if (r2) {
|
|
210
|
+
throw takeObject(r1);
|
|
211
|
+
}
|
|
212
|
+
return JsWallet.__wrap(r0);
|
|
213
|
+
} finally {
|
|
214
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @param {string} phrase
|
|
220
|
+
* @param {string | null} [passphrase]
|
|
221
|
+
* @returns {JsWallet}
|
|
222
|
+
*/
|
|
223
|
+
export function import_wallet(phrase, passphrase) {
|
|
224
|
+
try {
|
|
225
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
226
|
+
const ptr0 = passStringToWasm0(phrase, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
227
|
+
const len0 = WASM_VECTOR_LEN;
|
|
228
|
+
var ptr1 = isLikeNone(passphrase) ? 0 : passStringToWasm0(passphrase, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
229
|
+
var len1 = WASM_VECTOR_LEN;
|
|
230
|
+
wasm.import_wallet(retptr, ptr0, len0, ptr1, len1);
|
|
231
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
232
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
233
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
234
|
+
if (r2) {
|
|
235
|
+
throw takeObject(r1);
|
|
236
|
+
}
|
|
237
|
+
return JsWallet.__wrap(r0);
|
|
238
|
+
} finally {
|
|
239
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* @param {any} message
|
|
245
|
+
* @param {string} private_key_hex
|
|
246
|
+
* @returns {string}
|
|
247
|
+
*/
|
|
248
|
+
export function sign_message(message, private_key_hex) {
|
|
249
|
+
let deferred3_0;
|
|
250
|
+
let deferred3_1;
|
|
251
|
+
try {
|
|
252
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
253
|
+
const ptr0 = passStringToWasm0(private_key_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
254
|
+
const len0 = WASM_VECTOR_LEN;
|
|
255
|
+
wasm.sign_message(retptr, addHeapObject(message), ptr0, len0);
|
|
256
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
257
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
258
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
259
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
260
|
+
var ptr2 = r0;
|
|
261
|
+
var len2 = r1;
|
|
262
|
+
if (r3) {
|
|
263
|
+
ptr2 = 0; len2 = 0;
|
|
264
|
+
throw takeObject(r2);
|
|
265
|
+
}
|
|
266
|
+
deferred3_0 = ptr2;
|
|
267
|
+
deferred3_1 = len2;
|
|
268
|
+
return getStringFromWasm0(ptr2, len2);
|
|
269
|
+
} finally {
|
|
270
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
271
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @param {any} transaction_js
|
|
277
|
+
* @param {string} private_key_hex
|
|
278
|
+
* @returns {string}
|
|
279
|
+
*/
|
|
280
|
+
export function sign_transaction(transaction_js, private_key_hex) {
|
|
281
|
+
let deferred3_0;
|
|
282
|
+
let deferred3_1;
|
|
283
|
+
try {
|
|
284
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
285
|
+
const ptr0 = passStringToWasm0(private_key_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
286
|
+
const len0 = WASM_VECTOR_LEN;
|
|
287
|
+
wasm.sign_transaction(retptr, addHeapObject(transaction_js), ptr0, len0);
|
|
288
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
289
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
290
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
291
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
292
|
+
var ptr2 = r0;
|
|
293
|
+
var len2 = r1;
|
|
294
|
+
if (r3) {
|
|
295
|
+
ptr2 = 0; len2 = 0;
|
|
296
|
+
throw takeObject(r2);
|
|
297
|
+
}
|
|
298
|
+
deferred3_0 = ptr2;
|
|
299
|
+
deferred3_1 = len2;
|
|
300
|
+
return getStringFromWasm0(ptr2, len2);
|
|
301
|
+
} finally {
|
|
302
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
303
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @param {any} message
|
|
309
|
+
* @param {string} signature_hex
|
|
310
|
+
* @param {string} public_key_hex
|
|
311
|
+
* @returns {boolean}
|
|
312
|
+
*/
|
|
313
|
+
export function verify_signature(message, signature_hex, public_key_hex) {
|
|
314
|
+
try {
|
|
315
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
316
|
+
const ptr0 = passStringToWasm0(signature_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
317
|
+
const len0 = WASM_VECTOR_LEN;
|
|
318
|
+
const ptr1 = passStringToWasm0(public_key_hex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
319
|
+
const len1 = WASM_VECTOR_LEN;
|
|
320
|
+
wasm.verify_signature(retptr, addHeapObject(message), ptr0, len0, ptr1, len1);
|
|
321
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
322
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
323
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
324
|
+
if (r2) {
|
|
325
|
+
throw takeObject(r1);
|
|
326
|
+
}
|
|
327
|
+
return r0 !== 0;
|
|
328
|
+
} finally {
|
|
329
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function __wbg_get_imports() {
|
|
334
|
+
const import0 = {
|
|
335
|
+
__proto__: null,
|
|
336
|
+
__wbg_Error_2e59b1b37a9a34c3: function(arg0, arg1) {
|
|
337
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
338
|
+
return addHeapObject(ret);
|
|
339
|
+
},
|
|
340
|
+
__wbg_Number_e6ffdb596c888833: function(arg0) {
|
|
341
|
+
const ret = Number(getObject(arg0));
|
|
342
|
+
return ret;
|
|
343
|
+
},
|
|
344
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
345
|
+
const ret = String(getObject(arg1));
|
|
346
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
347
|
+
const len1 = WASM_VECTOR_LEN;
|
|
348
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
349
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
350
|
+
},
|
|
351
|
+
__wbg___wbindgen_bigint_get_as_i64_2c5082002e4826e2: function(arg0, arg1) {
|
|
352
|
+
const v = getObject(arg1);
|
|
353
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
354
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
355
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
356
|
+
},
|
|
357
|
+
__wbg___wbindgen_boolean_get_a86c216575a75c30: function(arg0) {
|
|
358
|
+
const v = getObject(arg0);
|
|
359
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
360
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
361
|
+
},
|
|
362
|
+
__wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
|
|
363
|
+
const ret = debugString(getObject(arg1));
|
|
364
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
365
|
+
const len1 = WASM_VECTOR_LEN;
|
|
366
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
367
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
368
|
+
},
|
|
369
|
+
__wbg___wbindgen_in_4bd7a57e54337366: function(arg0, arg1) {
|
|
370
|
+
const ret = getObject(arg0) in getObject(arg1);
|
|
371
|
+
return ret;
|
|
372
|
+
},
|
|
373
|
+
__wbg___wbindgen_is_bigint_6c98f7e945dacdde: function(arg0) {
|
|
374
|
+
const ret = typeof(getObject(arg0)) === 'bigint';
|
|
375
|
+
return ret;
|
|
376
|
+
},
|
|
377
|
+
__wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
|
|
378
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
379
|
+
return ret;
|
|
380
|
+
},
|
|
381
|
+
__wbg___wbindgen_is_object_40c5a80572e8f9d3: function(arg0) {
|
|
382
|
+
const val = getObject(arg0);
|
|
383
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
384
|
+
return ret;
|
|
385
|
+
},
|
|
386
|
+
__wbg___wbindgen_is_string_b29b5c5a8065ba1a: function(arg0) {
|
|
387
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
388
|
+
return ret;
|
|
389
|
+
},
|
|
390
|
+
__wbg___wbindgen_is_undefined_c0cca72b82b86f4d: function(arg0) {
|
|
391
|
+
const ret = getObject(arg0) === undefined;
|
|
392
|
+
return ret;
|
|
393
|
+
},
|
|
394
|
+
__wbg___wbindgen_jsval_eq_7d430e744a913d26: function(arg0, arg1) {
|
|
395
|
+
const ret = getObject(arg0) === getObject(arg1);
|
|
396
|
+
return ret;
|
|
397
|
+
},
|
|
398
|
+
__wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944: function(arg0, arg1) {
|
|
399
|
+
const ret = getObject(arg0) == getObject(arg1);
|
|
400
|
+
return ret;
|
|
401
|
+
},
|
|
402
|
+
__wbg___wbindgen_number_get_7579aab02a8a620c: function(arg0, arg1) {
|
|
403
|
+
const obj = getObject(arg1);
|
|
404
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
405
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
406
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
407
|
+
},
|
|
408
|
+
__wbg___wbindgen_shr_9b967ee87cdd7385: function(arg0, arg1) {
|
|
409
|
+
const ret = getObject(arg0) >> getObject(arg1);
|
|
410
|
+
return addHeapObject(ret);
|
|
411
|
+
},
|
|
412
|
+
__wbg___wbindgen_string_get_914df97fcfa788f2: function(arg0, arg1) {
|
|
413
|
+
const obj = getObject(arg1);
|
|
414
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
415
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
416
|
+
var len1 = WASM_VECTOR_LEN;
|
|
417
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
418
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
419
|
+
},
|
|
420
|
+
__wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
|
|
421
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
422
|
+
},
|
|
423
|
+
__wbg_call_7f2987183bb62793: function() { return handleError(function (arg0, arg1) {
|
|
424
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
425
|
+
return addHeapObject(ret);
|
|
426
|
+
}, arguments); },
|
|
427
|
+
__wbg_call_d578befcc3145dee: function() { return handleError(function (arg0, arg1, arg2) {
|
|
428
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
429
|
+
return addHeapObject(ret);
|
|
430
|
+
}, arguments); },
|
|
431
|
+
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
|
432
|
+
const ret = getObject(arg0).crypto;
|
|
433
|
+
return addHeapObject(ret);
|
|
434
|
+
},
|
|
435
|
+
__wbg_done_547d467e97529006: function(arg0) {
|
|
436
|
+
const ret = getObject(arg0).done;
|
|
437
|
+
return ret;
|
|
438
|
+
},
|
|
439
|
+
__wbg_entries_616b1a459b85be0b: function(arg0) {
|
|
440
|
+
const ret = Object.entries(getObject(arg0));
|
|
441
|
+
return addHeapObject(ret);
|
|
442
|
+
},
|
|
443
|
+
__wbg_from_741da0f916ab74aa: function(arg0) {
|
|
444
|
+
const ret = Array.from(getObject(arg0));
|
|
445
|
+
return addHeapObject(ret);
|
|
446
|
+
},
|
|
447
|
+
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
|
448
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
449
|
+
}, arguments); },
|
|
450
|
+
__wbg_get_4848e350b40afc16: function(arg0, arg1) {
|
|
451
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
452
|
+
return addHeapObject(ret);
|
|
453
|
+
},
|
|
454
|
+
__wbg_get_ed0642c4b9d31ddf: function() { return handleError(function (arg0, arg1) {
|
|
455
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
456
|
+
return addHeapObject(ret);
|
|
457
|
+
}, arguments); },
|
|
458
|
+
__wbg_get_unchecked_7d7babe32e9e6a54: function(arg0, arg1) {
|
|
459
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
460
|
+
return addHeapObject(ret);
|
|
461
|
+
},
|
|
462
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
463
|
+
const ret = getObject(arg0)[getObject(arg1)];
|
|
464
|
+
return addHeapObject(ret);
|
|
465
|
+
},
|
|
466
|
+
__wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a: function(arg0) {
|
|
467
|
+
let result;
|
|
468
|
+
try {
|
|
469
|
+
result = getObject(arg0) instanceof ArrayBuffer;
|
|
470
|
+
} catch (_) {
|
|
471
|
+
result = false;
|
|
472
|
+
}
|
|
473
|
+
const ret = result;
|
|
474
|
+
return ret;
|
|
475
|
+
},
|
|
476
|
+
__wbg_instanceof_Uint8Array_4b8da683deb25d72: function(arg0) {
|
|
477
|
+
let result;
|
|
478
|
+
try {
|
|
479
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
480
|
+
} catch (_) {
|
|
481
|
+
result = false;
|
|
482
|
+
}
|
|
483
|
+
const ret = result;
|
|
484
|
+
return ret;
|
|
485
|
+
},
|
|
486
|
+
__wbg_isArray_db61795ad004c139: function(arg0) {
|
|
487
|
+
const ret = Array.isArray(getObject(arg0));
|
|
488
|
+
return ret;
|
|
489
|
+
},
|
|
490
|
+
__wbg_isSafeInteger_ea83862ba994770c: function(arg0) {
|
|
491
|
+
const ret = Number.isSafeInteger(getObject(arg0));
|
|
492
|
+
return ret;
|
|
493
|
+
},
|
|
494
|
+
__wbg_iterator_de403ef31815a3e6: function() {
|
|
495
|
+
const ret = Symbol.iterator;
|
|
496
|
+
return addHeapObject(ret);
|
|
497
|
+
},
|
|
498
|
+
__wbg_length_0c32cb8543c8e4c8: function(arg0) {
|
|
499
|
+
const ret = getObject(arg0).length;
|
|
500
|
+
return ret;
|
|
501
|
+
},
|
|
502
|
+
__wbg_length_6e821edde497a532: function(arg0) {
|
|
503
|
+
const ret = getObject(arg0).length;
|
|
504
|
+
return ret;
|
|
505
|
+
},
|
|
506
|
+
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
|
507
|
+
const ret = getObject(arg0).msCrypto;
|
|
508
|
+
return addHeapObject(ret);
|
|
509
|
+
},
|
|
510
|
+
__wbg_new_4f9fafbb3909af72: function() {
|
|
511
|
+
const ret = new Object();
|
|
512
|
+
return addHeapObject(ret);
|
|
513
|
+
},
|
|
514
|
+
__wbg_new_a560378ea1240b14: function(arg0) {
|
|
515
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
516
|
+
return addHeapObject(ret);
|
|
517
|
+
},
|
|
518
|
+
__wbg_new_f3c9df4f38f3f798: function() {
|
|
519
|
+
const ret = new Array();
|
|
520
|
+
return addHeapObject(ret);
|
|
521
|
+
},
|
|
522
|
+
__wbg_new_with_length_9cedd08484b73942: function(arg0) {
|
|
523
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
524
|
+
return addHeapObject(ret);
|
|
525
|
+
},
|
|
526
|
+
__wbg_next_01132ed6134b8ef5: function(arg0) {
|
|
527
|
+
const ret = getObject(arg0).next;
|
|
528
|
+
return addHeapObject(ret);
|
|
529
|
+
},
|
|
530
|
+
__wbg_next_b3713ec761a9dbfd: function() { return handleError(function (arg0) {
|
|
531
|
+
const ret = getObject(arg0).next();
|
|
532
|
+
return addHeapObject(ret);
|
|
533
|
+
}, arguments); },
|
|
534
|
+
__wbg_node_84ea875411254db1: function(arg0) {
|
|
535
|
+
const ret = getObject(arg0).node;
|
|
536
|
+
return addHeapObject(ret);
|
|
537
|
+
},
|
|
538
|
+
__wbg_now_88621c9c9a4f3ffc: function() {
|
|
539
|
+
const ret = Date.now();
|
|
540
|
+
return ret;
|
|
541
|
+
},
|
|
542
|
+
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
|
543
|
+
const ret = getObject(arg0).process;
|
|
544
|
+
return addHeapObject(ret);
|
|
545
|
+
},
|
|
546
|
+
__wbg_prototypesetcall_3e05eb9545565046: function(arg0, arg1, arg2) {
|
|
547
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
548
|
+
},
|
|
549
|
+
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
|
550
|
+
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
551
|
+
}, arguments); },
|
|
552
|
+
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
|
553
|
+
const ret = module.require;
|
|
554
|
+
return addHeapObject(ret);
|
|
555
|
+
}, arguments); },
|
|
556
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
557
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
558
|
+
},
|
|
559
|
+
__wbg_set_6c60b2e8ad0e9383: function(arg0, arg1, arg2) {
|
|
560
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
561
|
+
},
|
|
562
|
+
__wbg_static_accessor_GLOBAL_THIS_a1248013d790bf5f: function() {
|
|
563
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
564
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
565
|
+
},
|
|
566
|
+
__wbg_static_accessor_GLOBAL_f2e0f995a21329ff: function() {
|
|
567
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
568
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
569
|
+
},
|
|
570
|
+
__wbg_static_accessor_SELF_24f78b6d23f286ea: function() {
|
|
571
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
572
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
573
|
+
},
|
|
574
|
+
__wbg_static_accessor_WINDOW_59fd959c540fe405: function() {
|
|
575
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
576
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
577
|
+
},
|
|
578
|
+
__wbg_subarray_0f98d3fb634508ad: function(arg0, arg1, arg2) {
|
|
579
|
+
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
580
|
+
return addHeapObject(ret);
|
|
581
|
+
},
|
|
582
|
+
__wbg_value_7f6052747ccf940f: function(arg0) {
|
|
583
|
+
const ret = getObject(arg0).value;
|
|
584
|
+
return addHeapObject(ret);
|
|
585
|
+
},
|
|
586
|
+
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
|
587
|
+
const ret = getObject(arg0).versions;
|
|
588
|
+
return addHeapObject(ret);
|
|
589
|
+
},
|
|
590
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
591
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
592
|
+
const ret = arg0;
|
|
593
|
+
return addHeapObject(ret);
|
|
594
|
+
},
|
|
595
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
596
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
597
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
598
|
+
return addHeapObject(ret);
|
|
599
|
+
},
|
|
600
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
601
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
602
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
603
|
+
return addHeapObject(ret);
|
|
604
|
+
},
|
|
605
|
+
__wbindgen_cast_0000000000000004: function(arg0, arg1) {
|
|
606
|
+
// Cast intrinsic for `U128 -> Externref`.
|
|
607
|
+
const ret = (BigInt.asUintN(64, arg0) | (BigInt.asUintN(64, arg1) << BigInt(64)));
|
|
608
|
+
return addHeapObject(ret);
|
|
609
|
+
},
|
|
610
|
+
__wbindgen_cast_0000000000000005: function(arg0) {
|
|
611
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
612
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
613
|
+
return addHeapObject(ret);
|
|
614
|
+
},
|
|
615
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
616
|
+
const ret = getObject(arg0);
|
|
617
|
+
return addHeapObject(ret);
|
|
618
|
+
},
|
|
619
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
620
|
+
takeObject(arg0);
|
|
621
|
+
},
|
|
622
|
+
};
|
|
623
|
+
return {
|
|
624
|
+
__proto__: null,
|
|
625
|
+
"./gloxx_wasm_bg.js": import0,
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
const JsWalletFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
630
|
+
? { register: () => {}, unregister: () => {} }
|
|
631
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_jswallet_free(ptr >>> 0, 1));
|
|
632
|
+
|
|
633
|
+
function addHeapObject(obj) {
|
|
634
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
635
|
+
const idx = heap_next;
|
|
636
|
+
heap_next = heap[idx];
|
|
637
|
+
|
|
638
|
+
heap[idx] = obj;
|
|
639
|
+
return idx;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function debugString(val) {
|
|
643
|
+
// primitive types
|
|
644
|
+
const type = typeof val;
|
|
645
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
646
|
+
return `${val}`;
|
|
647
|
+
}
|
|
648
|
+
if (type == 'string') {
|
|
649
|
+
return `"${val}"`;
|
|
650
|
+
}
|
|
651
|
+
if (type == 'symbol') {
|
|
652
|
+
const description = val.description;
|
|
653
|
+
if (description == null) {
|
|
654
|
+
return 'Symbol';
|
|
655
|
+
} else {
|
|
656
|
+
return `Symbol(${description})`;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
if (type == 'function') {
|
|
660
|
+
const name = val.name;
|
|
661
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
662
|
+
return `Function(${name})`;
|
|
663
|
+
} else {
|
|
664
|
+
return 'Function';
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
// objects
|
|
668
|
+
if (Array.isArray(val)) {
|
|
669
|
+
const length = val.length;
|
|
670
|
+
let debug = '[';
|
|
671
|
+
if (length > 0) {
|
|
672
|
+
debug += debugString(val[0]);
|
|
673
|
+
}
|
|
674
|
+
for(let i = 1; i < length; i++) {
|
|
675
|
+
debug += ', ' + debugString(val[i]);
|
|
676
|
+
}
|
|
677
|
+
debug += ']';
|
|
678
|
+
return debug;
|
|
679
|
+
}
|
|
680
|
+
// Test for built-in
|
|
681
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
682
|
+
let className;
|
|
683
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
684
|
+
className = builtInMatches[1];
|
|
685
|
+
} else {
|
|
686
|
+
// Failed to match the standard '[object ClassName]'
|
|
687
|
+
return toString.call(val);
|
|
688
|
+
}
|
|
689
|
+
if (className == 'Object') {
|
|
690
|
+
// we're a user defined class or Object
|
|
691
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
692
|
+
// easier than looping through ownProperties of `val`.
|
|
693
|
+
try {
|
|
694
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
695
|
+
} catch (_) {
|
|
696
|
+
return 'Object';
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
// errors
|
|
700
|
+
if (val instanceof Error) {
|
|
701
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
702
|
+
}
|
|
703
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
704
|
+
return className;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
function dropObject(idx) {
|
|
708
|
+
if (idx < 1028) return;
|
|
709
|
+
heap[idx] = heap_next;
|
|
710
|
+
heap_next = idx;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
714
|
+
ptr = ptr >>> 0;
|
|
715
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
let cachedDataViewMemory0 = null;
|
|
719
|
+
function getDataViewMemory0() {
|
|
720
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
721
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
722
|
+
}
|
|
723
|
+
return cachedDataViewMemory0;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
function getStringFromWasm0(ptr, len) {
|
|
727
|
+
ptr = ptr >>> 0;
|
|
728
|
+
return decodeText(ptr, len);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
let cachedUint8ArrayMemory0 = null;
|
|
732
|
+
function getUint8ArrayMemory0() {
|
|
733
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
734
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
735
|
+
}
|
|
736
|
+
return cachedUint8ArrayMemory0;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
function getObject(idx) { return heap[idx]; }
|
|
740
|
+
|
|
741
|
+
function handleError(f, args) {
|
|
742
|
+
try {
|
|
743
|
+
return f.apply(this, args);
|
|
744
|
+
} catch (e) {
|
|
745
|
+
wasm.__wbindgen_export3(addHeapObject(e));
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
let heap = new Array(1024).fill(undefined);
|
|
750
|
+
heap.push(undefined, null, true, false);
|
|
751
|
+
|
|
752
|
+
let heap_next = heap.length;
|
|
753
|
+
|
|
754
|
+
function isLikeNone(x) {
|
|
755
|
+
return x === undefined || x === null;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
759
|
+
if (realloc === undefined) {
|
|
760
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
761
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
762
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
763
|
+
WASM_VECTOR_LEN = buf.length;
|
|
764
|
+
return ptr;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
let len = arg.length;
|
|
768
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
769
|
+
|
|
770
|
+
const mem = getUint8ArrayMemory0();
|
|
771
|
+
|
|
772
|
+
let offset = 0;
|
|
773
|
+
|
|
774
|
+
for (; offset < len; offset++) {
|
|
775
|
+
const code = arg.charCodeAt(offset);
|
|
776
|
+
if (code > 0x7F) break;
|
|
777
|
+
mem[ptr + offset] = code;
|
|
778
|
+
}
|
|
779
|
+
if (offset !== len) {
|
|
780
|
+
if (offset !== 0) {
|
|
781
|
+
arg = arg.slice(offset);
|
|
782
|
+
}
|
|
783
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
784
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
785
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
786
|
+
|
|
787
|
+
offset += ret.written;
|
|
788
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
WASM_VECTOR_LEN = offset;
|
|
792
|
+
return ptr;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
function takeObject(idx) {
|
|
796
|
+
const ret = getObject(idx);
|
|
797
|
+
dropObject(idx);
|
|
798
|
+
return ret;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
802
|
+
cachedTextDecoder.decode();
|
|
803
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
804
|
+
let numBytesDecoded = 0;
|
|
805
|
+
function decodeText(ptr, len) {
|
|
806
|
+
numBytesDecoded += len;
|
|
807
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
808
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
809
|
+
cachedTextDecoder.decode();
|
|
810
|
+
numBytesDecoded = len;
|
|
811
|
+
}
|
|
812
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
const cachedTextEncoder = new TextEncoder();
|
|
816
|
+
|
|
817
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
818
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
819
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
820
|
+
view.set(buf);
|
|
821
|
+
return {
|
|
822
|
+
read: arg.length,
|
|
823
|
+
written: buf.length
|
|
824
|
+
};
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
let WASM_VECTOR_LEN = 0;
|
|
829
|
+
|
|
830
|
+
let wasmModule, wasm;
|
|
831
|
+
function __wbg_finalize_init(instance, module) {
|
|
832
|
+
wasm = instance.exports;
|
|
833
|
+
wasmModule = module;
|
|
834
|
+
cachedDataViewMemory0 = null;
|
|
835
|
+
cachedUint8ArrayMemory0 = null;
|
|
836
|
+
return wasm;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
async function __wbg_load(module, imports) {
|
|
840
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
841
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
842
|
+
try {
|
|
843
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
844
|
+
} catch (e) {
|
|
845
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
846
|
+
|
|
847
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
848
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
849
|
+
|
|
850
|
+
} else { throw e; }
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
const bytes = await module.arrayBuffer();
|
|
855
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
856
|
+
} else {
|
|
857
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
858
|
+
|
|
859
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
860
|
+
return { instance, module };
|
|
861
|
+
} else {
|
|
862
|
+
return instance;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
function expectedResponseType(type) {
|
|
867
|
+
switch (type) {
|
|
868
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
869
|
+
}
|
|
870
|
+
return false;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
function initSync(module) {
|
|
875
|
+
if (wasm !== undefined) return wasm;
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
if (module !== undefined) {
|
|
879
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
880
|
+
({module} = module)
|
|
881
|
+
} else {
|
|
882
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
const imports = __wbg_get_imports();
|
|
887
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
888
|
+
module = new WebAssembly.Module(module);
|
|
889
|
+
}
|
|
890
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
891
|
+
return __wbg_finalize_init(instance, module);
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
async function __wbg_init(module_or_path) {
|
|
895
|
+
if (wasm !== undefined) return wasm;
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
if (module_or_path !== undefined) {
|
|
899
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
900
|
+
({module_or_path} = module_or_path)
|
|
901
|
+
} else {
|
|
902
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
if (module_or_path === undefined) {
|
|
907
|
+
module_or_path = new URL('gloxx_wasm_bg.wasm', import.meta.url);
|
|
908
|
+
}
|
|
909
|
+
const imports = __wbg_get_imports();
|
|
910
|
+
|
|
911
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
912
|
+
module_or_path = fetch(module_or_path);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
916
|
+
|
|
917
|
+
return __wbg_finalize_init(instance, module);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gloxx/gloxx-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Gloxx Team"
|
|
6
|
+
],
|
|
7
|
+
"version": "0.1.1",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/Gloxx-Labs/gloxx-network"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"gloxx_wasm_bg.wasm",
|
|
15
|
+
"gloxx_wasm.js",
|
|
16
|
+
"gloxx_wasm.d.ts"
|
|
17
|
+
],
|
|
18
|
+
"main": "gloxx_wasm.js",
|
|
19
|
+
"types": "gloxx_wasm.d.ts",
|
|
20
|
+
"sideEffects": [
|
|
21
|
+
"./snippets/*"
|
|
22
|
+
]
|
|
23
|
+
}
|