diff --git a/wasm/index.ts b/wasm/index.ts index a7f54ee4b95..5e0aeec052a 100644 --- a/wasm/index.ts +++ b/wasm/index.ts @@ -10,4 +10,4 @@ import * as KeyStore from "./src/keystore"; declare function load(): Promise; export const initWasm: typeof load = Loader; -export { TW, WalletCore, KeyStore }; +export { TW, WalletCore, KeyStore}; diff --git a/wasm/package-lock.json b/wasm/package-lock.json index 94e227042c2..985c31be826 100644 --- a/wasm/package-lock.json +++ b/wasm/package-lock.json @@ -1,11 +1,11 @@ { - "name": "@trustwallet/wallet-core", + "name": "craminiumlab-wallet-core", "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "@trustwallet/wallet-core", + "name": "craminiumlab-wallet-core", "version": "1.0.0", "license": "MIT", "dependencies": { diff --git a/wasm/package.json b/wasm/package.json index 996f10ac35e..2c3c4e6b666 100644 --- a/wasm/package.json +++ b/wasm/package.json @@ -1,6 +1,6 @@ { - "name": "@trustwallet/wallet-core", - "version": "1.0.0", + "name": "craminiumlab-wallet-core", + "version": "1.0.3", "description": "wallet core wasm and protobuf models", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/wasm/tests/Blockchain/Aptos.test.ts b/wasm/tests/Blockchain/Aptos.test.ts index 98ccaf9ce27..f2815fa0fb9 100644 --- a/wasm/tests/Blockchain/Aptos.test.ts +++ b/wasm/tests/Blockchain/Aptos.test.ts @@ -10,7 +10,7 @@ import Long = require("long"); describe("Aptos", () => { it("test sign aptos", () => { - const { PrivateKey, HexCoding, AnySigner, AnyAddress, CoinType } = globalThis.core; + const { PrivateKey, HexCoding, AnySigner, CoinType, TransactionCompiler } = globalThis.core; const txDataInput = TW.Aptos.Proto.SigningInput.create({ chainId: 33, sender: "0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30", @@ -29,10 +29,16 @@ describe("Aptos", () => { ).data(), }); const input = TW.Aptos.Proto.SigningInput.encode(txDataInput).finish(); + console.log('Aptos input:', input.length) + console.log(TransactionCompiler) + const hash = TransactionCompiler.preImageHashes(CoinType.aptos, input) + console.log('hash:', hash) + console.log('type:', CoinType.aptos.value) const outputData = AnySigner.sign(input, CoinType.aptos); const output = TW.Aptos.Proto.SigningOutput.decode(outputData); assert.equal(HexCoding.encode(output.encoded), "0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f3063000000000000000200000000000000000000000000000000000000000000000000000000000000010d6170746f735f6163636f756e74087472616e7366657200022007968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f3008e803000000000000fe4d3200000000006400000000000000c2276ada00000000210020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c405707246db31e2335edc4316a7a656a11691d1d1647f6e864d1ab12f43428aaaf806cf02120d0b608cdd89c5c904af7b137432aacdd60cc53f9fad7bd33578e01") assert.equal(HexCoding.encode(output.authenticator!.signature), "0x5707246db31e2335edc4316a7a656a11691d1d1647f6e864d1ab12f43428aaaf806cf02120d0b608cdd89c5c904af7b137432aacdd60cc53f9fad7bd33578e01") assert.equal(HexCoding.encode(output.rawTxn), "0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f3063000000000000000200000000000000000000000000000000000000000000000000000000000000010d6170746f735f6163636f756e74087472616e7366657200022007968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f3008e803000000000000fe4d3200000000006400000000000000c2276ada0000000021") + console.log(globalThis.walletCore) }); }); diff --git a/wasm/tests/Blockchain/Cosmos.test.ts b/wasm/tests/Blockchain/Cosmos.test.ts new file mode 100644 index 00000000000..fa7fda4e862 --- /dev/null +++ b/wasm/tests/Blockchain/Cosmos.test.ts @@ -0,0 +1,3 @@ +import {TW} from "../../dist"; +import {assert} from "chai"; +import Long = require("long"); \ No newline at end of file diff --git a/wasm/tsconfig.json b/wasm/tsconfig.json index bcca79e9e1b..f85054d77f3 100644 --- a/wasm/tsconfig.json +++ b/wasm/tsconfig.json @@ -20,4 +20,4 @@ "node_modules", "./tests/**/*.ts" ], -} +} \ No newline at end of file diff --git a/wasmjs/dist/src/index.js b/wasmjs/dist/src/index.js new file mode 100644 index 00000000000..d1eee748ae8 --- /dev/null +++ b/wasmjs/dist/src/index.js @@ -0,0 +1,191 @@ +import * as Core from "craminiumlab-wallet-core"; +import { TW } from "craminiumlab-wallet-core"; +import { initWasm } from "craminiumlab-wallet-core"; +import Long from "long"; +export { initWasm }; +export class WalletCoreWrapper { + constructor(core, _tw = TW) { + const { CoinType, HexCoding, AnySigner, TransactionCompiler, DataVector, PrivateKey } = core; + this.CoinType = CoinType; + this.HexCoding = HexCoding; + this.AnySigner = AnySigner; + this.TransactionCompiler = TransactionCompiler; + this.DataVector = DataVector; + this.PrivateKey = PrivateKey; + this.TW = _tw; + } + static async init() { + const core = await Core.initWasm(); + return new WalletCoreWrapper(core); + } + encodeHex(data) { + return this.HexCoding.encode(data); + } + createWithData(hexStr) { + const data = this.HexCoding.decode(hexStr); + const privateKey = this.PrivateKey.createWithData(data); + return privateKey.data(); + } + anySign(input, coin) { + return this.AnySigner.sign(input, coin); + } + preImageHashes(coin, txInput) { + const result = this.TransactionCompiler.preImageHashes(coin, txInput); + console.log('RESULT', result, result.length); + return result; + } + compileWithSignatures(coinType, txInputData, signatures, publicKeys) { + const sigs = signatures.map((s) => this.HexCoding.decode(s)); + const pubs = publicKeys.map((p) => this.HexCoding.decode(p)); + const sigVec = this.makeDataVector(sigs); + const pubVec = this.makeDataVector(pubs); + return this.TransactionCompiler.compileWithSignatures(coinType, txInputData, sigVec, pubVec); + } + makeDataVector(items) { + const vec = this.DataVector.create(); + items.forEach((i) => vec.add(i)); + return vec; + } + buildAptosUnsignedTx(jsonStr) { + const req = JSON.parse(jsonStr); + const input = { + chainId: req.chainId, + sender: req.sender, + sequenceNumber: Long.fromString(String(req.sequenceNumber)), + expirationTimestampSecs: Long.fromString(String(req.ttl)), + gasUnitPrice: Long.fromString(String(req.gasUnitPrice)), + maxGasAmount: Long.fromString(String(req.maxGasAmount)), + transfer: this.TW.Aptos.Proto.TransferMessage.create({ + to: req.toAddress, + amount: Long.fromString(String(req.amount)), + }), + }; + return this.TW.Aptos.Proto.SigningInput.encode(input).finish(); + } + buildAptosUnsignedMessage(txInput) { + const preimage = this.preImageHashes(this.CoinType.aptos, txInput); + const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage); + return out.data; + } + buildCardanoUnsignedTx(jsonStr) { + const req = JSON.parse(jsonStr); + const transfer = this.TW.Cardano.Proto.Transfer.create({ + toAddress: req.toAddress, + changeAddress: req.changeAddress, + amount: req.amount, + useMaxAmount: false, + }); + const utxos = req.utxos.map((utxo) => this.TW.Cardano.Proto.TxInput.create({ + outPoint: this.TW.Cardano.Proto.OutPoint.create({ + txHash: utxo.tx_hash, + outputIndex: utxo.output_index, + }), + address: utxo.address, + amount: utxo.amount, + tokenAmount: null + })); + const input = { + transferMessage: transfer, + utxos: utxos, + ttl: new Long(req.ttl), + }; + return this.TW.Cardano.Proto.SigningInput.encode(input).finish(); + } + buildCardanoUnsignedMessage(txInput) { + const preimage = this.preImageHashes(this.CoinType.cardano, txInput); + const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage); + return out.dataHash; + } + buildCosmosUnsignedTx(jsonStr) { + const req = JSON.parse(jsonStr); + console.log(req); + const message = this.TW.Cosmos.Proto.Message.create({ + sendCoinsMessage: this.TW.Cosmos.Proto.Message.Send.create({ + fromAddress: req.fromAddress, + toAddress: req.toAddress, + amounts: [ + this.TW.Cosmos.Proto.Amount.create({ + denom: req.denom, + amount: req.amount, + }), + ] + }) + }); + const input = { + chainId: req.chainId, + accountNumber: req.accountNumber, + sequence: req.sequence, + messages: [message], + memo: req.memo, + publicKey: this.HexCoding.decode(req.publicKey), + fee: this.TW.Cosmos.Proto.Fee.create({ + gas: req.gas, + amounts: [ + this.TW.Cosmos.Proto.Amount.create({ + denom: req.gasDenom, + amount: req.gasAmount, + }) + ] + }) + }; + return this.TW.Cosmos.Proto.SigningInput.encode(input).finish(); + } + buildCosmosUnsignedMessage(txInput) { + const preimage = this.preImageHashes(this.CoinType.cosmos, txInput); + const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage); + return out.dataHash; + } + buildNearUnsignedTx(jsonStr) { + const req = JSON.parse(jsonStr); + console.log(req); + const action = this.TW.NEAR.Proto.Action.create({ + transfer: this.TW.NEAR.Proto.Transfer.create({ + deposit: this.HexCoding.decode(req.transferAmount) + }) + }); + const input = { + signerId: req.signerId, + nonce: Long.fromString(String(req.nonce)), + receiverId: req.receiverId, + blockHash: this.HexCoding.decode(req.blockHash), + actions: [action], + publicKey: this.HexCoding.decode(req.publicKey), + }; + console.log(input); + return this.TW.NEAR.Proto.SigningInput.encode(input).finish(); + } + buildNearUnsignedMessage(txInput) { + const preimage = this.preImageHashes(this.CoinType.near, txInput); + const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage); + return out.dataHash; + } + buildStellarUnsignedTx(jsonStr) { + const req = JSON.parse(jsonStr); + console.log(req); + const opPayment = TW.Stellar.Proto.OperationPayment.create({ + destination: req.destination, + amount: Long.fromString(String(req.amount)), + }); + const memoText = this.TW.Stellar.Proto.MemoText.create({ + text: req.memoText + }); + const input = { + fee: req.fee, + account: req.account, + passphrase: 'Public Global Stellar Network ; September 2015', + sequence: Long.fromString(String(req.sequence)), + opPayment: opPayment, + memoText: memoText + }; + console.log(input); + return this.TW.Stellar.Proto.SigningInput.encode(input).finish(); + } + buildStellarUnsignedMessage(txInput) { + const preimage = this.preImageHashes(this.CoinType.stellar, txInput); + const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage); + return out.dataHash; + } + marshalInput(input) { + return input.finish(); + } +} diff --git a/wasmjs/dist/test/tw.test.js b/wasmjs/dist/test/tw.test.js new file mode 100644 index 00000000000..cdd6d6cc794 --- /dev/null +++ b/wasmjs/dist/test/tw.test.js @@ -0,0 +1,121 @@ +import { describe, it, expect, beforeAll } from 'vitest'; +import { WalletCoreWrapper, initWasm } from "../src"; +import Long from "long"; +let wallet; +beforeAll(async () => { + const core = await initWasm(); + wallet = await new WalletCoreWrapper(core); +}); +describe("Aptos", () => { + it("compile signature", async () => { + const jsonString = JSON.stringify({ + chainId: 33, + sender: "0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30", + sequenceNumber: 99, + ttl: 3664390082, + maxGasAmount: 3296766, + gasUnitPrice: 100, + toAddress: "0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30", + amount: 1000 + }); + const inputBytes = wallet.buildAptosUnsignedTx(jsonString); + const preimageHash = wallet.preImageHashes(wallet.CoinType.aptos, inputBytes); + expect(preimageHash.length).toBeGreaterThan(0); + let sigHash = wallet.buildAptosUnsignedMessage(inputBytes); + console.log('sigHash raw:', (sigHash)); + const sigHex = '5707246db31e2335edc4316a7a656a11691d1d1647f6e864d1ab12f43428aaaf806cf02120d0b608cdd89c5c904af7b137432aacdd60cc53f9fad7bd33578e01'; + const pubHex = 'ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c'; + const signingOutput = wallet.compileWithSignatures(wallet.CoinType.aptos, inputBytes, [sigHex], [pubHex]); + const decoded = wallet.TW.Aptos.Proto.SigningOutput.decode(signingOutput); + expect(decoded.encoded.length).toBeGreaterThan(0); + }); + it("test sign aptos", async () => { + const txInput = wallet.TW.Aptos.Proto.SigningInput.create({ + chainId: 33, + sender: "0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30", + transfer: wallet.TW.Aptos.Proto.TransferMessage.create({ + amount: new Long(1000), + to: "0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30" + }), + sequenceNumber: new Long(99), + expirationTimestampSecs: new Long(3664390082), + gasUnitPrice: new Long(100), + maxGasAmount: new Long(3296766), + privateKey: wallet.createWithData("0x5d996aa76b3212142792d9130796cd2e11e3c445a93118c08414df4f66bc60ec") + }); + const inputBytes = wallet.TW.Aptos.Proto.SigningInput.encode(txInput).finish(); + const signed = wallet.anySign(inputBytes, wallet.CoinType.aptos); + const decoded = wallet.TW.Aptos.Proto.SigningOutput.decode(signed); + expect(wallet.encodeHex(decoded.encoded)).to.equal("0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f3063000000000000000200000000000000000000000000000000000000000000000000000000000000010d6170746f735f6163636f756e74087472616e7366657200022007968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f3008e803000000000000fe4d3200000000006400000000000000c2276ada00000000210020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c405707246db31e2335edc4316a7a656a11691d1d1647f6e864d1ab12f43428aaaf806cf02120d0b608cdd89c5c904af7b137432aacdd60cc53f9fad7bd33578e01"); + }); +}); +describe("Cardano", () => { + it("compile signature", async () => { + const jsonString = '{\"address\":\"\",\"toAddress\":\"addr1q90uh2eawrdc9vaemftgd50l28yrh9lqxtjjh4z6dnn0u7ggasexxdyyk9f05atygnjlccsjsggtc87hhqjna32fpv5qeq96ls\",\"changeAddress\":\"addr1qx55ymlqemndq8gluv40v58pu76a2tp4mzjnyx8n6zrp2vtzrs43a0057y0edkn8lh9su8vh5lnhs4npv6l9tuvncv8swc7t08\",\"amount\":3000000,\"ttl\":190000000,\"utxos\":[{\"tx_hash\":\"gxblAH1h+5BlLKu0EUGXKji1vGCVTWAs+ENHaqP2f2M=\",\"output_index\":0,\"address\":\"Ae2tdPwUPEZ6vkqxSjJxaQYmDxHf5DTnxtZ67pFLJGTb9LTnCGkDP6ca3f8\",\"amount\":2500000},{\"tx_hash\":\"4pOSxZyQP++5BXMFh9IsrovaML2Nmu7D7KCCrndnWUY=\",\"output_index\":0,\"address\":\"Ae2tdPwUPEZ6vkqxSjJxaQYmDxHf5DTnxtZ67pFLJGTb9LTnCGkDP6ca3f8\",\"amount\":1700000}]}'; + const inputBytes = wallet.buildCardanoUnsignedTx(jsonString); + const preimageHash = wallet.preImageHashes(wallet.CoinType.cardano, inputBytes); + expect(preimageHash.length).toBeGreaterThan(0); + let sigHash = wallet.buildCardanoUnsignedMessage(inputBytes); + console.log('sigHash raw:', (sigHash)); + const sigHex = '6a23ab9267867fbf021c1cb2232bc83d2cdd663d651d22d59b6cddbca5cb106d4db99da50672f69a2309ca8a329a3f9576438afe4538b013de4591a6dfcd4d09'; + const pubHex = 'd163c8c4f0be7c22cd3a1152abb013c855ea614b92201497a568c5d93ceeb41ea7f484aa383806735c46fd769c679ee41f8952952036a6e2338ada940b8a91f40b5aaa6103dc10842894a1eeefc5447b9bcb9bcf227d77e57be195d17bc03263d46f19d0fbf75afb0b9a24e31d533f4fd74cee3b56e162568e8defe37123afc4'; + const signingOutput = wallet.compileWithSignatures(wallet.CoinType.cardano, inputBytes, [sigHex], [pubHex]); + const decoded = wallet.TW.Cardano.Proto.SigningOutput.decode(signingOutput); + expect(decoded.encoded.length).toBeGreaterThan(0); + const txencoded = wallet.encodeHex(decoded.encoded); + expect(txencoded).to.equal("0x83a400828258208316e5007d61fb90652cabb41141972a38b5bc60954d602cf843476aa3f67f6300825820e29392c59c903fefb905730587d22cae8bda30bd8d9aeec3eca082ae77675946000182825839015fcbab3d70db82b3b9da5686d1ff51c83b97e032e52bd45a6ce6fe7908ec32633484b152fa756444e5fc62128210bc1fd7b8253ec5490b281a002dc6c082583901a9426fe0cee6d01d1fe32af650e1e7b5d52c35d8a53218f3d0861531621c2b1ebdf4f11f96da67fdcb0e1d97a7e778566166be55f193c30f1a000f9ec1021a0002b0bf031a0b532b80a20081825820d163c8c4f0be7c22cd3a1152abb013c855ea614b92201497a568c5d93ceeb41e58406a23ab9267867fbf021c1cb2232bc83d2cdd663d651d22d59b6cddbca5cb106d4db99da50672f69a2309ca8a329a3f9576438afe4538b013de4591a6dfcd4d090281845820d163c8c4f0be7c22cd3a1152abb013c855ea614b92201497a568c5d93ceeb41e58406a23ab9267867fbf021c1cb2232bc83d2cdd663d651d22d59b6cddbca5cb106d4db99da50672f69a2309ca8a329a3f9576438afe4538b013de4591a6dfcd4d095820a7f484aa383806735c46fd769c679ee41f8952952036a6e2338ada940b8a91f441a0f6"); + }); +}); +describe("Cosmos", () => { + it("compile signature", async () => { + const jsonString = "{\"chainId\":\"cosmoshub-4\",\"fromAddress\":\"cosmos1mky69cn8ektwy0845vec9upsdphktxt03gkwlx\",\"toAddress\":\"cosmos18s0hdnsllgcclweu9aymw4ngktr2k0rkygdzdp\",\"amount\":\"400000\",\"denom\":\"uatom\",\"memo\":\"\",\"gas\":200000,\"gasAmount\":\"1000\",\"gasDenom\":\"uatom\",\"publicKey\":\"02ecef5ce437a302c67f95468de4b31f36e911f467d7e6a52b41c1e13e1d563649\",\"accountNumber\":546179,\"sequence\":0}"; + const inputBytes = wallet.buildCosmosUnsignedTx(jsonString); + console.log('Inputbytes:', inputBytes); + const preimageHash = wallet.preImageHashes(wallet.CoinType.cosmos, inputBytes); + expect(preimageHash.length).toBeGreaterThan(0); + let sigHash = wallet.buildCosmosUnsignedMessage(inputBytes); + console.log('sigHash raw:', wallet.encodeHex(sigHash)); + const sigHex = 'afbd513a776f4fdf470ef7f9675f21ae9d630fc4d635d8dbaa0dc0a716434cd07e02510765d4673dfa880825bae8e67cb367396ff6b976fc6b19a31fc95e8097'; + const pubHex = '02ecef5ce437a302c67f95468de4b31f36e911f467d7e6a52b41c1e13e1d563649'; + const signingOutput = wallet.compileWithSignatures(wallet.CoinType.cosmos, inputBytes, [sigHex], [pubHex]); + const decoded = wallet.TW.Cosmos.Proto.SigningOutput.decode(signingOutput); + console.log(decoded); + expect(decoded.json.length).toBeGreaterThan(0); + }); +}); +describe("NEAR", () => { + it("compile signature", async () => { + const jsonStr = "{\"signerId\":\"test.near\",\"nonce\":1,\"receiverId\":\"whatever.near\",\"blockHash\":\"0fa473fd26901df296be6adc4cc4df34d040efa2435224b6986910e630c2fef6\",\"publicKey\":\"917b3d268d4b58f7fec1b150bd68d69be3ee5d4cc39855e341538465bb77860d\",\"transferAmount\":\"01000000000000000000000000000000\"}"; + const inputBytes = wallet.buildNearUnsignedTx(jsonStr); + console.log('Inputbytes:', inputBytes.length); + console.log('Inputbytes:', wallet.encodeHex(inputBytes)); + const preimageHash = wallet.preImageHashes(wallet.CoinType.near, inputBytes); + expect(preimageHash.length).toBeGreaterThan(0); + console.log('preimageHash raw:', wallet.encodeHex(preimageHash)); + let sigHash = wallet.buildNearUnsignedMessage(inputBytes); + console.log('sigHash raw:', wallet.encodeHex(sigHash)); + const sigHex = '969a83332186ee9755e4839325525806e189a3d2d2bb4b4760e94443e97e1c4f22deeef0059a8e9713100eda6e19144da7e8a0ef7e539b20708ba1d8d021bd01'; + const pubHex = '917b3d268d4b58f7fec1b150bd68d69be3ee5d4cc39855e341538465bb77860d'; + const signingOutput = wallet.compileWithSignatures(wallet.CoinType.near, inputBytes, [sigHex], [pubHex]); + const decoded = wallet.TW.NEAR.Proto.SigningOutput.decode(signingOutput); + expect(decoded.signedTransaction.length).toBeGreaterThan(0); + }); +}); +describe("Stellar", () => { + it("compile signature", async () => { + const jsonStr = "{\"signerId\":\"test.near\",\"nonce\":1,\"receiverId\":\"whatever.near\",\"blockHash\":\"0fa473fd26901df296be6adc4cc4df34d040efa2435224b6986910e630c2fef6\",\"publicKey\":\"917b3d268d4b58f7fec1b150bd68d69be3ee5d4cc39855e341538465bb77860d\",\"transferAmount\":\"01000000000000000000000000000000\"}"; + const inputBytes = wallet.buildNearUnsignedTx(jsonStr); + console.log('Inputbytes:', inputBytes.length); + console.log('Inputbytes:', wallet.encodeHex(inputBytes)); + const preimageHash = wallet.preImageHashes(wallet.CoinType.near, inputBytes); + expect(preimageHash.length).toBeGreaterThan(0); + console.log('preimageHash raw:', wallet.encodeHex(preimageHash)); + let sigHash = wallet.buildNearUnsignedMessage(inputBytes); + console.log('sigHash raw:', wallet.encodeHex(sigHash)); + const sigHex = '969a83332186ee9755e4839325525806e189a3d2d2bb4b4760e94443e97e1c4f22deeef0059a8e9713100eda6e19144da7e8a0ef7e539b20708ba1d8d021bd01'; + const pubHex = '917b3d268d4b58f7fec1b150bd68d69be3ee5d4cc39855e341538465bb77860d'; + const signingOutput = wallet.compileWithSignatures(wallet.CoinType.near, inputBytes, [sigHex], [pubHex]); + const decoded = wallet.TW.NEAR.Proto.SigningOutput.decode(signingOutput); + expect(decoded.signedTransaction.length).toBeGreaterThan(0); + }); +}); diff --git a/wasmjs/package-lock.json b/wasmjs/package-lock.json new file mode 100644 index 00000000000..ed2438b59fc --- /dev/null +++ b/wasmjs/package-lock.json @@ -0,0 +1,2251 @@ +{ + "name": "craminiumlab-wasmjs", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "craminiumlab-wasmjs", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "craminiumlab-wallet-core": "^1.0.2", + "long": "^5.3.2", + "protobufjs": "^7.5.3" + }, + "devDependencies": { + "@types/chai": "^5.2.2", + "@types/webextension-polyfill": "^0.12.3", + "chai": "^5.2.1", + "ts-node": "^10.9.2", + "tsx": "^4.20.3", + "typescript": "^5.8.3", + "vite": "^5.4.19", + "vitest": "^1.6.1" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.6", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@jest/schemas": { + "version": "29.6.3", + "dev": true, + "license": "MIT", + "dependencies": { + "@sinclair/typebox": "^0.27.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.4", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@protobufjs/aspromise": { + "version": "1.1.2", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/base64": { + "version": "1.1.2", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/codegen": { + "version": "2.0.4", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/eventemitter": { + "version": "1.1.0", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/fetch": { + "version": "1.1.0", + "license": "BSD-3-Clause", + "dependencies": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "node_modules/@protobufjs/float": { + "version": "1.0.2", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/inquire": { + "version": "1.1.0", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/path": { + "version": "1.1.2", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/pool": { + "version": "1.1.0", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/utf8": { + "version": "1.1.0", + "license": "BSD-3-Clause" + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.44.2", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.44.2", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@sinclair/typebox": { + "version": "0.27.8", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/chai": { + "version": "5.2.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.8", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "24.0.12", + "license": "MIT", + "dependencies": { + "undici-types": "~7.8.0" + } + }, + "node_modules/@types/webextension-polyfill": { + "version": "0.12.3", + "dev": true, + "license": "MIT" + }, + "node_modules/@vitest/expect": { + "version": "1.6.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "1.6.1", + "@vitest/utils": "1.6.1", + "chai": "^4.3.10" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/expect/node_modules/assertion-error": { + "version": "1.1.0", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/@vitest/expect/node_modules/chai": { + "version": "4.5.0", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", + "pathval": "^1.1.1", + "type-detect": "^4.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@vitest/expect/node_modules/check-error": { + "version": "1.0.3", + "dev": true, + "license": "MIT", + "dependencies": { + "get-func-name": "^2.0.2" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@vitest/expect/node_modules/deep-eql": { + "version": "4.1.4", + "dev": true, + "license": "MIT", + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@vitest/expect/node_modules/loupe": { + "version": "2.3.7", + "dev": true, + "license": "MIT", + "dependencies": { + "get-func-name": "^2.0.1" + } + }, + "node_modules/@vitest/expect/node_modules/pathval": { + "version": "1.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/@vitest/runner": { + "version": "1.6.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "1.6.1", + "p-limit": "^5.0.0", + "pathe": "^1.1.1" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner/node_modules/p-limit": { + "version": "5.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^1.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@vitest/runner/node_modules/yocto-queue": { + "version": "1.2.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@vitest/snapshot": { + "version": "1.6.1", + "dev": true, + "license": "MIT", + "dependencies": { + "magic-string": "^0.30.5", + "pathe": "^1.1.1", + "pretty-format": "^29.7.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "1.6.1", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyspy": "^2.2.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "1.6.1", + "dev": true, + "license": "MIT", + "dependencies": { + "diff-sequences": "^29.6.3", + "estree-walker": "^3.0.3", + "loupe": "^2.3.7", + "pretty-format": "^29.7.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils/node_modules/loupe": { + "version": "2.3.7", + "dev": true, + "license": "MIT", + "dependencies": { + "get-func-name": "^2.0.1" + } + }, + "node_modules/acorn": { + "version": "8.15.0", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.4", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "dev": true, + "license": "MIT" + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/chai": { + "version": "5.2.1", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/check-error": { + "version": "2.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 16" + } + }, + "node_modules/confbox": { + "version": "0.1.8", + "dev": true, + "license": "MIT" + }, + "node_modules/craminiumlab-wallet-core": { + "version": "1.0.2", + "license": "MIT", + "dependencies": { + "protobufjs": ">=6.11.3" + } + }, + "node_modules/create-require": { + "version": "1.1.1", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.4.1", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-eql": { + "version": "5.0.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/diff-sequences": { + "version": "29.6.3", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/esbuild": { + "version": "0.25.6", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.6", + "@esbuild/android-arm": "0.25.6", + "@esbuild/android-arm64": "0.25.6", + "@esbuild/android-x64": "0.25.6", + "@esbuild/darwin-arm64": "0.25.6", + "@esbuild/darwin-x64": "0.25.6", + "@esbuild/freebsd-arm64": "0.25.6", + "@esbuild/freebsd-x64": "0.25.6", + "@esbuild/linux-arm": "0.25.6", + "@esbuild/linux-arm64": "0.25.6", + "@esbuild/linux-ia32": "0.25.6", + "@esbuild/linux-loong64": "0.25.6", + "@esbuild/linux-mips64el": "0.25.6", + "@esbuild/linux-ppc64": "0.25.6", + "@esbuild/linux-riscv64": "0.25.6", + "@esbuild/linux-s390x": "0.25.6", + "@esbuild/linux-x64": "0.25.6", + "@esbuild/netbsd-arm64": "0.25.6", + "@esbuild/netbsd-x64": "0.25.6", + "@esbuild/openbsd-arm64": "0.25.6", + "@esbuild/openbsd-x64": "0.25.6", + "@esbuild/openharmony-arm64": "0.25.6", + "@esbuild/sunos-x64": "0.25.6", + "@esbuild/win32-arm64": "0.25.6", + "@esbuild/win32-ia32": "0.25.6", + "@esbuild/win32-x64": "0.25.6" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/execa": { + "version": "8.0.1", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^8.0.1", + "human-signals": "^5.0.0", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^4.1.0", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": ">=16.17" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/get-func-name": { + "version": "2.0.2", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/get-stream": { + "version": "8.0.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/get-tsconfig": { + "version": "4.10.1", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/human-signals": { + "version": "5.0.0", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=16.17.0" + } + }, + "node_modules/is-stream": { + "version": "3.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "dev": true, + "license": "ISC" + }, + "node_modules/js-tokens": { + "version": "9.0.1", + "dev": true, + "license": "MIT" + }, + "node_modules/local-pkg": { + "version": "0.5.1", + "dev": true, + "license": "MIT", + "dependencies": { + "mlly": "^1.7.3", + "pkg-types": "^1.2.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/long": { + "version": "5.3.2", + "license": "Apache-2.0" + }, + "node_modules/loupe": { + "version": "3.1.4", + "dev": true, + "license": "MIT" + }, + "node_modules/magic-string": { + "version": "0.30.17", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "dev": true, + "license": "ISC" + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "dev": true, + "license": "MIT" + }, + "node_modules/mimic-fn": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mlly": { + "version": "1.7.4", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.14.0", + "pathe": "^2.0.1", + "pkg-types": "^1.3.0", + "ufo": "^1.5.4" + } + }, + "node_modules/mlly/node_modules/pathe": { + "version": "2.0.3", + "dev": true, + "license": "MIT" + }, + "node_modules/ms": { + "version": "2.1.3", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.11", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/npm-run-path": { + "version": "5.3.0", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/npm-run-path/node_modules/path-key": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/onetime": { + "version": "6.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "mimic-fn": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/pathe": { + "version": "1.1.2", + "dev": true, + "license": "MIT" + }, + "node_modules/pathval": { + "version": "2.0.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.16" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "dev": true, + "license": "ISC" + }, + "node_modules/pkg-types": { + "version": "1.3.1", + "dev": true, + "license": "MIT", + "dependencies": { + "confbox": "^0.1.8", + "mlly": "^1.7.4", + "pathe": "^2.0.1" + } + }, + "node_modules/pkg-types/node_modules/pathe": { + "version": "2.0.3", + "dev": true, + "license": "MIT" + }, + "node_modules/postcss": { + "version": "8.5.6", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/pretty-format": { + "version": "29.7.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@jest/schemas": "^29.6.3", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/protobufjs": { + "version": "7.5.3", + "hasInstallScript": true, + "license": "BSD-3-Clause", + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/node": ">=13.7.0", + "long": "^5.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/react-is": { + "version": "18.3.1", + "dev": true, + "license": "MIT" + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/rollup": { + "version": "4.44.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.8" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.44.2", + "@rollup/rollup-android-arm64": "4.44.2", + "@rollup/rollup-darwin-arm64": "4.44.2", + "@rollup/rollup-darwin-x64": "4.44.2", + "@rollup/rollup-freebsd-arm64": "4.44.2", + "@rollup/rollup-freebsd-x64": "4.44.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.44.2", + "@rollup/rollup-linux-arm-musleabihf": "4.44.2", + "@rollup/rollup-linux-arm64-gnu": "4.44.2", + "@rollup/rollup-linux-arm64-musl": "4.44.2", + "@rollup/rollup-linux-loongarch64-gnu": "4.44.2", + "@rollup/rollup-linux-powerpc64le-gnu": "4.44.2", + "@rollup/rollup-linux-riscv64-gnu": "4.44.2", + "@rollup/rollup-linux-riscv64-musl": "4.44.2", + "@rollup/rollup-linux-s390x-gnu": "4.44.2", + "@rollup/rollup-linux-x64-gnu": "4.44.2", + "@rollup/rollup-linux-x64-musl": "4.44.2", + "@rollup/rollup-win32-arm64-msvc": "4.44.2", + "@rollup/rollup-win32-ia32-msvc": "4.44.2", + "@rollup/rollup-win32-x64-msvc": "4.44.2", + "fsevents": "~2.3.2" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "dev": true, + "license": "ISC" + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "3.9.0", + "dev": true, + "license": "MIT" + }, + "node_modules/strip-final-newline": { + "version": "3.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/strip-literal": { + "version": "2.1.1", + "dev": true, + "license": "MIT", + "dependencies": { + "js-tokens": "^9.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/tinybench": { + "version": "2.9.0", + "dev": true, + "license": "MIT" + }, + "node_modules/tinypool": { + "version": "0.8.4", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "2.2.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/ts-node": { + "version": "10.9.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/tsx": { + "version": "4.20.3", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.25.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/type-detect": { + "version": "4.1.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/typescript": { + "version": "5.8.3", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/ufo": { + "version": "1.6.1", + "dev": true, + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "7.8.0", + "license": "MIT" + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "dev": true, + "license": "MIT" + }, + "node_modules/vite": { + "version": "5.4.19", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.21.3", + "postcss": "^8.4.43", + "rollup": "^4.20.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || >=20.0.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vite-node": { + "version": "1.6.1", + "dev": true, + "license": "MIT", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.3.4", + "pathe": "^1.1.1", + "picocolors": "^1.0.0", + "vite": "^5.0.0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-x64": { + "version": "0.21.5", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/esbuild": { + "version": "0.21.5", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" + } + }, + "node_modules/vitest": { + "version": "1.6.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/expect": "1.6.1", + "@vitest/runner": "1.6.1", + "@vitest/snapshot": "1.6.1", + "@vitest/spy": "1.6.1", + "@vitest/utils": "1.6.1", + "acorn-walk": "^8.3.2", + "chai": "^4.3.10", + "debug": "^4.3.4", + "execa": "^8.0.1", + "local-pkg": "^0.5.0", + "magic-string": "^0.30.5", + "pathe": "^1.1.1", + "picocolors": "^1.0.0", + "std-env": "^3.5.0", + "strip-literal": "^2.0.0", + "tinybench": "^2.5.1", + "tinypool": "^0.8.3", + "vite": "^5.0.0", + "vite-node": "1.6.1", + "why-is-node-running": "^2.2.2" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/node": "^18.0.0 || >=20.0.0", + "@vitest/browser": "1.6.1", + "@vitest/ui": "1.6.1", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, + "node_modules/vitest/node_modules/assertion-error": { + "version": "1.1.0", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/vitest/node_modules/chai": { + "version": "4.5.0", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", + "pathval": "^1.1.1", + "type-detect": "^4.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/vitest/node_modules/check-error": { + "version": "1.0.3", + "dev": true, + "license": "MIT", + "dependencies": { + "get-func-name": "^2.0.2" + }, + "engines": { + "node": "*" + } + }, + "node_modules/vitest/node_modules/deep-eql": { + "version": "4.1.4", + "dev": true, + "license": "MIT", + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/vitest/node_modules/loupe": { + "version": "2.3.7", + "dev": true, + "license": "MIT", + "dependencies": { + "get-func-name": "^2.0.1" + } + }, + "node_modules/vitest/node_modules/pathval": { + "version": "1.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/which": { + "version": "2.0.2", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yn": { + "version": "3.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + } + }, + "dependencies": { + "@cspotcode/source-map-support": { + "version": "0.8.1", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "0.3.9" + } + }, + "@esbuild/linux-x64": { + "version": "0.25.6", + "dev": true, + "optional": true + }, + "@jest/schemas": { + "version": "29.6.3", + "dev": true, + "requires": { + "@sinclair/typebox": "^0.27.8" + } + }, + "@jridgewell/resolve-uri": { + "version": "3.1.2", + "dev": true + }, + "@jridgewell/sourcemap-codec": { + "version": "1.5.4", + "dev": true + }, + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "@protobufjs/aspromise": { + "version": "1.1.2" + }, + "@protobufjs/base64": { + "version": "1.1.2" + }, + "@protobufjs/codegen": { + "version": "2.0.4" + }, + "@protobufjs/eventemitter": { + "version": "1.1.0" + }, + "@protobufjs/fetch": { + "version": "1.1.0", + "requires": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "@protobufjs/float": { + "version": "1.0.2" + }, + "@protobufjs/inquire": { + "version": "1.1.0" + }, + "@protobufjs/path": { + "version": "1.1.2" + }, + "@protobufjs/pool": { + "version": "1.1.0" + }, + "@protobufjs/utf8": { + "version": "1.1.0" + }, + "@rollup/rollup-linux-x64-gnu": { + "version": "4.44.2", + "dev": true, + "optional": true + }, + "@rollup/rollup-linux-x64-musl": { + "version": "4.44.2", + "dev": true, + "optional": true + }, + "@sinclair/typebox": { + "version": "0.27.8", + "dev": true + }, + "@tsconfig/node10": { + "version": "1.0.11", + "dev": true + }, + "@tsconfig/node12": { + "version": "1.0.11", + "dev": true + }, + "@tsconfig/node14": { + "version": "1.0.3", + "dev": true + }, + "@tsconfig/node16": { + "version": "1.0.4", + "dev": true + }, + "@types/chai": { + "version": "5.2.2", + "dev": true, + "requires": { + "@types/deep-eql": "*" + } + }, + "@types/deep-eql": { + "version": "4.0.2", + "dev": true + }, + "@types/estree": { + "version": "1.0.8", + "dev": true + }, + "@types/node": { + "version": "24.0.12", + "requires": { + "undici-types": "~7.8.0" + } + }, + "@types/webextension-polyfill": { + "version": "0.12.3", + "dev": true + }, + "@vitest/expect": { + "version": "1.6.1", + "dev": true, + "requires": { + "@vitest/spy": "1.6.1", + "@vitest/utils": "1.6.1", + "chai": "^4.3.10" + }, + "dependencies": { + "assertion-error": { + "version": "1.1.0", + "dev": true + }, + "chai": { + "version": "4.5.0", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", + "pathval": "^1.1.1", + "type-detect": "^4.1.0" + } + }, + "check-error": { + "version": "1.0.3", + "dev": true, + "requires": { + "get-func-name": "^2.0.2" + } + }, + "deep-eql": { + "version": "4.1.4", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "loupe": { + "version": "2.3.7", + "dev": true, + "requires": { + "get-func-name": "^2.0.1" + } + }, + "pathval": { + "version": "1.1.1", + "dev": true + } + } + }, + "@vitest/runner": { + "version": "1.6.1", + "dev": true, + "requires": { + "@vitest/utils": "1.6.1", + "p-limit": "^5.0.0", + "pathe": "^1.1.1" + }, + "dependencies": { + "p-limit": { + "version": "5.0.0", + "dev": true, + "requires": { + "yocto-queue": "^1.0.0" + } + }, + "yocto-queue": { + "version": "1.2.1", + "dev": true + } + } + }, + "@vitest/snapshot": { + "version": "1.6.1", + "dev": true, + "requires": { + "magic-string": "^0.30.5", + "pathe": "^1.1.1", + "pretty-format": "^29.7.0" + } + }, + "@vitest/spy": { + "version": "1.6.1", + "dev": true, + "requires": { + "tinyspy": "^2.2.0" + } + }, + "@vitest/utils": { + "version": "1.6.1", + "dev": true, + "requires": { + "diff-sequences": "^29.6.3", + "estree-walker": "^3.0.3", + "loupe": "^2.3.7", + "pretty-format": "^29.7.0" + }, + "dependencies": { + "loupe": { + "version": "2.3.7", + "dev": true, + "requires": { + "get-func-name": "^2.0.1" + } + } + } + }, + "acorn": { + "version": "8.15.0", + "dev": true + }, + "acorn-walk": { + "version": "8.3.4", + "dev": true, + "requires": { + "acorn": "^8.11.0" + } + }, + "arg": { + "version": "4.1.3", + "dev": true + }, + "assertion-error": { + "version": "2.0.1", + "dev": true + }, + "cac": { + "version": "6.7.14", + "dev": true + }, + "chai": { + "version": "5.2.1", + "dev": true, + "requires": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + } + }, + "check-error": { + "version": "2.1.1", + "dev": true + }, + "confbox": { + "version": "0.1.8", + "dev": true + }, + "craminiumlab-wallet-core": { + "version": "1.0.2", + "requires": { + "protobufjs": ">=6.11.3" + } + }, + "create-require": { + "version": "1.1.1", + "dev": true + }, + "cross-spawn": { + "version": "7.0.6", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "debug": { + "version": "4.4.1", + "dev": true, + "requires": { + "ms": "^2.1.3" + } + }, + "deep-eql": { + "version": "5.0.2", + "dev": true + }, + "diff-sequences": { + "version": "29.6.3", + "dev": true + }, + "esbuild": { + "version": "0.25.6", + "dev": true, + "requires": { + "@esbuild/aix-ppc64": "0.25.6", + "@esbuild/android-arm": "0.25.6", + "@esbuild/android-arm64": "0.25.6", + "@esbuild/android-x64": "0.25.6", + "@esbuild/darwin-arm64": "0.25.6", + "@esbuild/darwin-x64": "0.25.6", + "@esbuild/freebsd-arm64": "0.25.6", + "@esbuild/freebsd-x64": "0.25.6", + "@esbuild/linux-arm": "0.25.6", + "@esbuild/linux-arm64": "0.25.6", + "@esbuild/linux-ia32": "0.25.6", + "@esbuild/linux-loong64": "0.25.6", + "@esbuild/linux-mips64el": "0.25.6", + "@esbuild/linux-ppc64": "0.25.6", + "@esbuild/linux-riscv64": "0.25.6", + "@esbuild/linux-s390x": "0.25.6", + "@esbuild/linux-x64": "0.25.6", + "@esbuild/netbsd-arm64": "0.25.6", + "@esbuild/netbsd-x64": "0.25.6", + "@esbuild/openbsd-arm64": "0.25.6", + "@esbuild/openbsd-x64": "0.25.6", + "@esbuild/openharmony-arm64": "0.25.6", + "@esbuild/sunos-x64": "0.25.6", + "@esbuild/win32-arm64": "0.25.6", + "@esbuild/win32-ia32": "0.25.6", + "@esbuild/win32-x64": "0.25.6" + } + }, + "estree-walker": { + "version": "3.0.3", + "dev": true, + "requires": { + "@types/estree": "^1.0.0" + } + }, + "execa": { + "version": "8.0.1", + "dev": true, + "requires": { + "cross-spawn": "^7.0.3", + "get-stream": "^8.0.1", + "human-signals": "^5.0.0", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^4.1.0", + "strip-final-newline": "^3.0.0" + } + }, + "get-func-name": { + "version": "2.0.2", + "dev": true + }, + "get-stream": { + "version": "8.0.1", + "dev": true + }, + "get-tsconfig": { + "version": "4.10.1", + "dev": true, + "requires": { + "resolve-pkg-maps": "^1.0.0" + } + }, + "human-signals": { + "version": "5.0.0", + "dev": true + }, + "is-stream": { + "version": "3.0.0", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "dev": true + }, + "js-tokens": { + "version": "9.0.1", + "dev": true + }, + "local-pkg": { + "version": "0.5.1", + "dev": true, + "requires": { + "mlly": "^1.7.3", + "pkg-types": "^1.2.1" + } + }, + "long": { + "version": "5.3.2" + }, + "loupe": { + "version": "3.1.4", + "dev": true + }, + "magic-string": { + "version": "0.30.17", + "dev": true, + "requires": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "make-error": { + "version": "1.3.6", + "dev": true + }, + "merge-stream": { + "version": "2.0.0", + "dev": true + }, + "mimic-fn": { + "version": "4.0.0", + "dev": true + }, + "mlly": { + "version": "1.7.4", + "dev": true, + "requires": { + "acorn": "^8.14.0", + "pathe": "^2.0.1", + "pkg-types": "^1.3.0", + "ufo": "^1.5.4" + }, + "dependencies": { + "pathe": { + "version": "2.0.3", + "dev": true + } + } + }, + "ms": { + "version": "2.1.3", + "dev": true + }, + "nanoid": { + "version": "3.3.11", + "dev": true + }, + "npm-run-path": { + "version": "5.3.0", + "dev": true, + "requires": { + "path-key": "^4.0.0" + }, + "dependencies": { + "path-key": { + "version": "4.0.0", + "dev": true + } + } + }, + "onetime": { + "version": "6.0.0", + "dev": true, + "requires": { + "mimic-fn": "^4.0.0" + } + }, + "path-key": { + "version": "3.1.1", + "dev": true + }, + "pathe": { + "version": "1.1.2", + "dev": true + }, + "pathval": { + "version": "2.0.1", + "dev": true + }, + "picocolors": { + "version": "1.1.1", + "dev": true + }, + "pkg-types": { + "version": "1.3.1", + "dev": true, + "requires": { + "confbox": "^0.1.8", + "mlly": "^1.7.4", + "pathe": "^2.0.1" + }, + "dependencies": { + "pathe": { + "version": "2.0.3", + "dev": true + } + } + }, + "postcss": { + "version": "8.5.6", + "dev": true, + "requires": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + } + }, + "pretty-format": { + "version": "29.7.0", + "dev": true, + "requires": { + "@jest/schemas": "^29.6.3", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "5.2.0", + "dev": true + } + } + }, + "protobufjs": { + "version": "7.5.3", + "requires": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/node": ">=13.7.0", + "long": "^5.0.0" + } + }, + "react-is": { + "version": "18.3.1", + "dev": true + }, + "resolve-pkg-maps": { + "version": "1.0.0", + "dev": true + }, + "rollup": { + "version": "4.44.2", + "dev": true, + "requires": { + "@rollup/rollup-android-arm-eabi": "4.44.2", + "@rollup/rollup-android-arm64": "4.44.2", + "@rollup/rollup-darwin-arm64": "4.44.2", + "@rollup/rollup-darwin-x64": "4.44.2", + "@rollup/rollup-freebsd-arm64": "4.44.2", + "@rollup/rollup-freebsd-x64": "4.44.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.44.2", + "@rollup/rollup-linux-arm-musleabihf": "4.44.2", + "@rollup/rollup-linux-arm64-gnu": "4.44.2", + "@rollup/rollup-linux-arm64-musl": "4.44.2", + "@rollup/rollup-linux-loongarch64-gnu": "4.44.2", + "@rollup/rollup-linux-powerpc64le-gnu": "4.44.2", + "@rollup/rollup-linux-riscv64-gnu": "4.44.2", + "@rollup/rollup-linux-riscv64-musl": "4.44.2", + "@rollup/rollup-linux-s390x-gnu": "4.44.2", + "@rollup/rollup-linux-x64-gnu": "4.44.2", + "@rollup/rollup-linux-x64-musl": "4.44.2", + "@rollup/rollup-win32-arm64-msvc": "4.44.2", + "@rollup/rollup-win32-ia32-msvc": "4.44.2", + "@rollup/rollup-win32-x64-msvc": "4.44.2", + "@types/estree": "1.0.8", + "fsevents": "~2.3.2" + } + }, + "shebang-command": { + "version": "2.0.0", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "dev": true + }, + "siginfo": { + "version": "2.0.0", + "dev": true + }, + "signal-exit": { + "version": "4.1.0", + "dev": true + }, + "source-map-js": { + "version": "1.2.1", + "dev": true + }, + "stackback": { + "version": "0.0.2", + "dev": true + }, + "std-env": { + "version": "3.9.0", + "dev": true + }, + "strip-final-newline": { + "version": "3.0.0", + "dev": true + }, + "strip-literal": { + "version": "2.1.1", + "dev": true, + "requires": { + "js-tokens": "^9.0.1" + } + }, + "tinybench": { + "version": "2.9.0", + "dev": true + }, + "tinypool": { + "version": "0.8.4", + "dev": true + }, + "tinyspy": { + "version": "2.2.1", + "dev": true + }, + "ts-node": { + "version": "10.9.2", + "dev": true, + "requires": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "dependencies": { + "diff": { + "version": "4.0.2", + "dev": true + } + } + }, + "tsx": { + "version": "4.20.3", + "dev": true, + "requires": { + "esbuild": "~0.25.0", + "fsevents": "~2.3.3", + "get-tsconfig": "^4.7.5" + } + }, + "type-detect": { + "version": "4.1.0", + "dev": true + }, + "typescript": { + "version": "5.8.3", + "dev": true + }, + "ufo": { + "version": "1.6.1", + "dev": true + }, + "undici-types": { + "version": "7.8.0" + }, + "v8-compile-cache-lib": { + "version": "3.0.1", + "dev": true + }, + "vite": { + "version": "5.4.19", + "dev": true, + "requires": { + "esbuild": "^0.21.3", + "fsevents": "~2.3.3", + "postcss": "^8.4.43", + "rollup": "^4.20.0" + }, + "dependencies": { + "@esbuild/linux-x64": { + "version": "0.21.5", + "dev": true, + "optional": true + }, + "esbuild": { + "version": "0.21.5", + "dev": true, + "requires": { + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" + } + } + } + }, + "vite-node": { + "version": "1.6.1", + "dev": true, + "requires": { + "cac": "^6.7.14", + "debug": "^4.3.4", + "pathe": "^1.1.1", + "picocolors": "^1.0.0", + "vite": "^5.0.0" + } + }, + "vitest": { + "version": "1.6.1", + "dev": true, + "requires": { + "@vitest/expect": "1.6.1", + "@vitest/runner": "1.6.1", + "@vitest/snapshot": "1.6.1", + "@vitest/spy": "1.6.1", + "@vitest/utils": "1.6.1", + "acorn-walk": "^8.3.2", + "chai": "^4.3.10", + "debug": "^4.3.4", + "execa": "^8.0.1", + "local-pkg": "^0.5.0", + "magic-string": "^0.30.5", + "pathe": "^1.1.1", + "picocolors": "^1.0.0", + "std-env": "^3.5.0", + "strip-literal": "^2.0.0", + "tinybench": "^2.5.1", + "tinypool": "^0.8.3", + "vite": "^5.0.0", + "vite-node": "1.6.1", + "why-is-node-running": "^2.2.2" + }, + "dependencies": { + "assertion-error": { + "version": "1.1.0", + "dev": true + }, + "chai": { + "version": "4.5.0", + "dev": true, + "requires": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", + "pathval": "^1.1.1", + "type-detect": "^4.1.0" + } + }, + "check-error": { + "version": "1.0.3", + "dev": true, + "requires": { + "get-func-name": "^2.0.2" + } + }, + "deep-eql": { + "version": "4.1.4", + "dev": true, + "requires": { + "type-detect": "^4.0.0" + } + }, + "loupe": { + "version": "2.3.7", + "dev": true, + "requires": { + "get-func-name": "^2.0.1" + } + }, + "pathval": { + "version": "1.1.1", + "dev": true + } + } + }, + "which": { + "version": "2.0.2", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "why-is-node-running": { + "version": "2.3.0", + "dev": true, + "requires": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + } + }, + "yn": { + "version": "3.1.1", + "dev": true + } + } +} diff --git a/wasmjs/package.json b/wasmjs/package.json new file mode 100644 index 00000000000..653d969d461 --- /dev/null +++ b/wasmjs/package.json @@ -0,0 +1,32 @@ +{ + "name": "craminiumlab-wasmjs", + "version": "1.0.0", + "description": "", + "main": "src/index.ts", + "type": "module", + "scripts": { + "build": "tsc", + "test": "vitest" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@types/chai": "^5.2.2", + "@types/webextension-polyfill": "^0.12.3", + "chai": "^5.2.1", + "ts-node": "^10.9.2", + "tsx": "^4.20.3", + "typescript": "^5.8.3", + "vite": "^5.4.19", + "vitest": "^1.6.1" + }, + "dependencies": { + "craminiumlab-wallet-core": "^1.0.2", + "long": "^5.3.2", + "protobufjs": "^7.5.3" + }, + "files": [ + "dist" + ] +} diff --git a/wasmjs/public/wallet-core.js b/wasmjs/public/wallet-core.js new file mode 100644 index 00000000000..da74489513f --- /dev/null +++ b/wasmjs/public/wallet-core.js @@ -0,0 +1,178 @@ + +var Module = (() => { + var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; + if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; + return ( +function(Module = {}) { + +var g;g||(g=typeof Module !== 'undefined' ? Module : {});var aa,ba;g.ready=new Promise(function(a,b){aa=a;ba=b}); +["_setThrew","_fflush","___getTypeName","__embind_initialize_bindings","onRuntimeInitialized"].forEach(a=>{Object.getOwnPropertyDescriptor(g.ready,a)||Object.defineProperty(g.ready,a,{get:()=>n("You are getting "+a+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js"),set:()=>n("You are setting "+a+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")})}); +var ca=Object.assign({},g),da="./this.program",ea=(a,b)=>{throw b;},fa="object"==typeof window,ha="function"==typeof importScripts,w="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,ia=!fa&&!w&&!ha;if(g.ENVIRONMENT)throw Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");var x="",ja,ka,la; +if(w){if("undefined"==typeof process||!process.release||"node"!==process.release.name)throw Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");var ma=process.versions.node,na=ma.split(".").slice(0,3);na=1E4*na[0]+100*na[1]+1*na[2];if(101900>na)throw Error("This emscripten-generated code requires node v10.19.19.0 (detected v"+ma+")");var fs=require("fs"),oa=require("path"); +x=ha?oa.dirname(x)+"/":__dirname+"/";ja=(a,b)=>{a=pa(a)?new URL(a):oa.normalize(a);return fs.readFileSync(a,b?void 0:"utf8")};la=a=>{a=ja(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a};ka=(a,b,c)=>{a=pa(a)?new URL(a):oa.normalize(a);fs.readFile(a,function(d,e){d?c(d):b(e.buffer)})};1process.versions.node.split(".")[0])process.on("unhandledRejection",function(a){throw a;});ea=(a,b)=>{process.exitCode=a;throw b;};g.inspect=function(){return"[Emscripten Module object]"}}else if(ia){if("object"==typeof process&&"function"===typeof require||"object"==typeof window||"function"==typeof importScripts)throw Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)"); +"undefined"!=typeof read&&(ja=function(a){return read(a)});la=function(a){if("function"==typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");assert("object"==typeof a);return a};ka=function(a,b){setTimeout(()=>b(la(a)),0)};"undefined"==typeof clearTimeout&&(globalThis.clearTimeout=()=>{});"function"==typeof quit&&(ea=(a,b)=>{setTimeout(()=>{if(!(b instanceof qa)){let c=b;b&&"object"==typeof b&&b.stack&&(c=[b,b.stack]);y("exiting due to exception: "+c)}quit(a)});throw b;});"undefined"!= +typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print)}else if(fa||ha){ha?x=self.location.href:"undefined"!=typeof document&&document.currentScript&&(x=document.currentScript.src);_scriptDir&&(x=_scriptDir);0!==x.indexOf("blob:")?x=x.substr(0,x.replace(/[?#].*/,"").lastIndexOf("/")+1):x="";if("object"!=typeof window&&"function"!=typeof importScripts)throw Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)"); +ja=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText};ha&&(la=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});ka=(a,b,c)=>{var d=new XMLHttpRequest;d.open("GET",a,!0);d.responseType="arraybuffer";d.onload=()=>{200==d.status||0==d.status&&d.response?b(d.response):c()};d.onerror=c;d.send(null)}}else throw Error("environment detection error"); +var ra=g.print||console.log.bind(console),y=g.printErr||console.warn.bind(console);Object.assign(g,ca);ca=null;Object.getOwnPropertyDescriptor(g,"fetchSettings")&&n("`Module.fetchSettings` was supplied but `fetchSettings` not included in INCOMING_MODULE_JS_API");z("arguments","arguments_");g.thisProgram&&(da=g.thisProgram);z("thisProgram","thisProgram");g.quit&&(ea=g.quit);z("quit","quit_");assert("undefined"==typeof g.memoryInitializerPrefixURL,"Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"); +assert("undefined"==typeof g.pthreadMainPrefixURL,"Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead");assert("undefined"==typeof g.cdInitializerPrefixURL,"Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead");assert("undefined"==typeof g.filePackagePrefixURL,"Module.filePackagePrefixURL option was removed, use Module.locateFile instead");assert("undefined"==typeof g.read,"Module.read option was removed (modify read_ in JS)"); +assert("undefined"==typeof g.readAsync,"Module.readAsync option was removed (modify readAsync in JS)");assert("undefined"==typeof g.readBinary,"Module.readBinary option was removed (modify readBinary in JS)");assert("undefined"==typeof g.setWindowTitle,"Module.setWindowTitle option was removed (modify setWindowTitle in JS)");assert("undefined"==typeof g.TOTAL_MEMORY,"Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY");z("read","read_");z("readAsync","readAsync");z("readBinary","readBinary"); +z("setWindowTitle","setWindowTitle");assert(!ia,"shell environment detected but not enabled at build time. Add 'shell' to `-sENVIRONMENT` to enable.");var sa;g.wasmBinary&&(sa=g.wasmBinary);z("wasmBinary","wasmBinary");var noExitRuntime=g.noExitRuntime||!0;z("noExitRuntime","noExitRuntime");"object"!=typeof WebAssembly&&n("no native wasm support detected");var ta,ua=!1,va;function assert(a,b){a||n("Assertion failed"+(b?": "+b:""))}var wa="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0; +function xa(a,b,c){var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16e?d+=String.fromCharCode(e):(e-=65536,d+=String.fromCharCode(55296| +e>>10,56320|e&1023))}}else d+=String.fromCharCode(e)}return d}function A(a,b){assert("number"==typeof a);return a?xa(C,a,b):""} +function Aa(a,b,c,d){if(!(0=k){var l=a.charCodeAt(++f);k=65536+((k&1023)<<10)|l&1023}if(127>=k){if(c>=d)break;b[c++]=k}else{if(2047>=k){if(c+1>=d)break;b[c++]=192|k>>6}else{if(65535>=k){if(c+2>=d)break;b[c++]=224|k>>12}else{if(c+3>=d)break;1114111>18;b[c++]=128|k>>12&63}b[c++]=128|k>>6&63}b[c++]=128|k&63}}b[c]=0;return c-e}function Ba(a,b,c){assert("number"==typeof c,"stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!");Aa(a,C,b,c)}function Ca(a){for(var b=0,c=0;c=d?b++:2047>=d?b+=2:55296<=d&&57343>=d?(b+=4,++c):b+=3}return b}var D,C,E,Da,F,G,Ea,Fa; +function Ga(){var a=ta.buffer;g.HEAP8=D=new Int8Array(a);g.HEAP16=E=new Int16Array(a);g.HEAP32=F=new Int32Array(a);g.HEAPU8=C=new Uint8Array(a);g.HEAPU16=Da=new Uint16Array(a);g.HEAPU32=G=new Uint32Array(a);g.HEAPF32=Ea=new Float32Array(a);g.HEAPF64=Fa=new Float64Array(a)}assert(!g.STACK_SIZE,"STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"); +assert("undefined"!=typeof Int32Array&&"undefined"!==typeof Float64Array&&void 0!=Int32Array.prototype.subarray&&void 0!=Int32Array.prototype.set,"JS engine does not provide full typed array support");assert(!g.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally");assert(!g.INITIAL_MEMORY,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically");var Ha; +function Ia(){var a=Ja();assert(0==(a&3));0==a&&(a+=4);G[a>>2]=34821223;G[a+4>>2]=2310721022;G[0]=1668509029}function Ka(){if(!ua){var a=Ja();0==a&&(a+=4);var b=G[a>>2],c=G[a+4>>2];34821223==b&&2310721022==c||n("Stack overflow! Stack cookie has been overwritten at "+za(a)+", expected hex dwords 0x89BACDFE and 0x2135467, but received "+za(c)+" "+za(b));1668509029!==G[0]&&n("Runtime error: The application has corrupted its heap memory area (address zero)!")}}var La=new Int16Array(1),Ma=new Int8Array(La.buffer); +La[0]=25459;if(115!==Ma[0]||99!==Ma[1])throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)";var Na=[],Oa=[],Pa=[],Qa=!1;function Ra(){var a=g.preRun.shift();Na.unshift(a)}assert(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");assert(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"); +assert(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");assert(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");var J=0,K=null,Sa=null,Ta={}; +function Ua(){J++;g.monitorRunDependencies&&g.monitorRunDependencies(J);assert(!Ta["wasm-instantiate"]);Ta["wasm-instantiate"]=1;null===K&&"undefined"!=typeof setInterval&&(K=setInterval(function(){if(ua)clearInterval(K),K=null;else{var a=!1,b;for(b in Ta)a||(a=!0,y("still waiting on run dependencies:")),y("dependency: "+b);a&&y("(end of list)")}},1E4))}function n(a){if(g.onAbort)g.onAbort(a);a="Aborted("+a+")";y(a);ua=!0;va=1;a=new WebAssembly.RuntimeError(a);ba(a);throw a;} +function Va(a){return a.startsWith("data:application/octet-stream;base64,")}function pa(a){return a.startsWith("file://")}function L(a){return function(){var b=g.asm;assert(Qa,"native function `"+a+"` called before runtime initialization");b[a]||assert(b[a],"exported native function `"+a+"` not found");return b[a].apply(null,arguments)}}var M;M="wallet-core.wasm";if(!Va(M)){var Wa=M;M=g.locateFile?g.locateFile(Wa,x):x+Wa} +function Xa(a){try{if(a==M&&sa)return new Uint8Array(sa);if(la)return la(a);throw"both async and sync fetching of the wasm failed";}catch(b){n(b)}} +function Ya(a){if(!sa&&(fa||ha)){if("function"==typeof fetch&&!pa(a))return fetch(a,{credentials:"same-origin"}).then(function(b){if(!b.ok)throw"failed to load wasm binary file at '"+a+"'";return b.arrayBuffer()}).catch(function(){return Xa(a)});if(ka)return new Promise(function(b,c){ka(a,function(d){b(new Uint8Array(d))},c)})}return Promise.resolve().then(function(){return Xa(a)})} +function Za(a,b,c){return Ya(a).then(function(d){return WebAssembly.instantiate(d,b)}).then(function(d){return d}).then(c,function(d){y("failed to asynchronously prepare wasm: "+d);pa(M)&&y("warning: Loading from a file URI ("+M+") is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing");n(d)})} +function $a(a,b){var c=M;return sa||"function"!=typeof WebAssembly.instantiateStreaming||Va(c)||pa(c)||w||"function"!=typeof fetch?Za(c,a,b):fetch(c,{credentials:"same-origin"}).then(function(d){return WebAssembly.instantiateStreaming(d,a).then(b,function(e){y("wasm streaming compile failed: "+e);y("falling back to ArrayBuffer instantiation");return Za(c,a,b)})})}var ab,bb; +function z(a,b){Object.getOwnPropertyDescriptor(g,a)||Object.defineProperty(g,a,{configurable:!0,get:function(){n("Module."+a+" has been replaced with plain "+b+" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)")}})} +function cb(a){return"FS_createPath"===a||"FS_createDataFile"===a||"FS_createPreloadedFile"===a||"FS_unlink"===a||"addRunDependency"===a||"FS_createLazyFile"===a||"FS_createDevice"===a||"removeRunDependency"===a}(function(a,b){"undefined"!==typeof globalThis&&Object.defineProperty(globalThis,a,{configurable:!0,get:function(){ya("`"+a+"` is not longer defined by emscripten. "+b)}})})("buffer","Please use HEAP8.buffer or wasmMemory.buffer"); +function db(a){Object.getOwnPropertyDescriptor(g,a)||Object.defineProperty(g,a,{configurable:!0,get:function(){var b="'"+a+"' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)";cb(a)&&(b+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you");n(b)}})} +var eb={2181428:()=>{if(void 0===g.fa)try{var a="object"===typeof window?window:self,b="undefined"!==typeof a.crypto?a.crypto:a.msCrypto;a=function(){var d=new Uint32Array(1);b.getRandomValues(d);return d[0]>>>0};a();g.fa=a}catch(d){try{var c=require("crypto");a=function(){var e=c.randomBytes(4);return(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0};a();g.fa=a}catch(e){throw"No secure random number generator found";}}},2182150:()=>g.fa()}; +function qa(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}function fb(a){for(;0=hb.length&&(hb.length=a+1),hb[a]=b=Ha.get(a));assert(Ha.get(a)==b,"JavaScript-side Wasm function table mirror is out of date!");return b} +function jb(a){this.l=a-24;this.Oa=function(b){G[this.l+4>>2]=b};this.Ja=function(b){G[this.l+8>>2]=b};this.Ka=function(){F[this.l>>2]=0};this.Ea=function(){D[this.l+12>>0]=0};this.La=function(){D[this.l+13>>0]=0};this.I=function(b,c){this.Da();this.Oa(b);this.Ja(c);this.Ka();this.Ea();this.La()};this.Da=function(){G[this.l+16>>2]=0}} +var kb=0,lb=(a,b)=>{for(var c=0,d=a.length-1;0<=d;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a},mb=a=>{var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=lb(a.split("/").filter(d=>!!d),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a},nb=a=>{var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b},ob= +a=>{if("/"===a)return"/";a=mb(a);a=a.replace(/\/$/,"");var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)}; +function pb(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var a=new Uint8Array(1);return()=>{crypto.getRandomValues(a);return a[0]}}if(w)try{var b=require("crypto");return()=>b.randomBytes(1)[0]}catch(c){}return()=>n("no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: function(array) { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };")} +function qb(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!=typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=lb(a.split("/").filter(d=>!!d),!b).join("/");return(b?"/":"")+a||"."}function rb(a,b){var c=Array(Ca(a)+1);a=Aa(a,c,0,c.length);b&&(c.length=a);return c}var sb=[];function tb(a,b){sb[a]={input:[],output:[],T:b};ub(a,vb)} +var vb={open:function(a){var b=sb[a.node.rdev];if(!b)throw new N(43);a.tty=b;a.seekable=!1},close:function(a){a.tty.T.fsync(a.tty)},fsync:function(a){a.tty.T.fsync(a.tty)},read:function(a,b,c,d){if(!a.tty||!a.tty.T.ra)throw new N(60);for(var e=0,f=0;f=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)), +c=a.i,a.i=new Uint8Array(b),0=a.node.s)return 0;a=Math.min(a.node.s- +e,d);assert(0<=a);if(8b)throw new N(28);return b},ma:function(a,b,c){O.pa(a.node,b+c);a.node.s=Math.max(a.node.s,b+c)},$:function(a,b,c,d,e){if(32768!==(a.node.mode&61440))throw new N(43);a=a.node.i;if(e&2||a.buffer!==D.buffer){if(0{a=qb(a);if(!a)return{path:"",node:null};b=Object.assign({qa:!0,ja:0},b);if(8!!k);for(var c=Gb,d="/",e=0;e{for(var b;;){if(a=== +a.parent)return a=a.J.ta,b?"/"!==a[a.length-1]?a+"/"+b:a+b:a;b=b?a.name+"/"+b:a.name;a=a.parent}},Ob=(a,b)=>{for(var c=0,d=0;d>>0)%Kb.length},Bb=(a,b)=>{var c;if(c=(c=Pb(a,"x"))?c:a.j.lookup?0:2)throw new N(c,a);for(c=Kb[Ob(a.id,b)];c;c=c.Na){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.j.lookup(a,b)},zb=(a,b,c,d)=>{assert("object"==typeof a);a=new Qb(a,b,c,d);b=Ob(a.parent.id,a.name);a.Na=Kb[b];return Kb[b]=a},Rb={r:0,"r+":2,w:577, +"w+":578,a:1089,"a+":1090},Sb=a=>{var b=["r","w","rw"][a&3];a&512&&(b+="w");return b},Pb=(a,b)=>{if(Lb)return 0;if(!b.includes("r")||a.mode&292){if(b.includes("w")&&!(a.mode&146)||b.includes("x")&&!(a.mode&73))return 2}else return 2;return 0},Tb=(a,b)=>{try{return Bb(a,b),20}catch(c){}return Pb(a,"wx")},Ub=(a=0)=>{for(;4096>=a;a++)if(!Ib[a])return a;throw new N(33);},Wb=(a,b)=>{Vb||(Vb=function(){this.I={}},Vb.prototype={},Object.defineProperties(Vb.prototype,{object:{get:function(){return this.node}, +set:function(c){this.node=c}},flags:{get:function(){return this.I.flags},set:function(c){this.I.flags=c}},position:{get:function(){return this.I.position},set:function(c){this.I.position=c}}}));a=Object.assign(new Vb,a);b=Ub(b);a.fd=b;return Ib[b]=a},yb={open:a=>{a.h=Hb[a.node.rdev].h;a.h.open&&a.h.open(a)},L:()=>{throw new N(70);}},ub=(a,b)=>{Hb[a]={h:b}},Xb=(a,b)=>{if("string"==typeof a)throw a;var c="/"===b,d=!b;if(c&&Gb)throw new N(10);if(!c&&!d){var e=P(b,{qa:!1});b=e.path;e=e.node;if(e.aa)throw new N(10); +if(16384!==(e.mode&61440))throw new N(54);}b={type:a,gb:{},ta:b,Ma:[]};a=a.J(b);a.J=b;b.root=a;c?Gb=a:e&&(e.aa=b,e.J&&e.J.Ma.push(b))},Q=(a,b,c)=>{var d=P(a,{parent:!0}).node;a=ob(a);if(!a||"."===a||".."===a)throw new N(28);var e=Tb(d,a);if(e)throw new N(e);if(!d.j.Z)throw new N(63);return d.j.Z(d,a,b,c)},Yb=(a,b,c)=>{"undefined"==typeof c&&(c=b,b=438);Q(a,b|8192,c)},Zb=(a,b)=>{if(!qb(a))throw new N(44);var c=P(b,{parent:!0}).node;if(!c)throw new N(44);b=ob(b);var d=Tb(c,b);if(d)throw new N(d);if(!c.j.symlink)throw new N(63); +c.j.symlink(c,b,a)},Mb=a=>{a=P(a).node;if(!a)throw new N(44);if(!a.j.readlink)throw new N(28);return qb(Nb(a.parent),a.j.readlink(a))},ac=(a,b,c)=>{if(""===a)throw new N(44);if("string"==typeof b){var d=Rb[b];if("undefined"==typeof d)throw Error("Unknown file open mode: "+b);b=d}c=b&64?("undefined"==typeof c?438:c)&4095|32768:0;if("object"==typeof a)var e=a;else{a=mb(a);try{e=P(a,{W:!(b&131072)}).node}catch(f){}}d=!1;if(b&64)if(e){if(b&128)throw new N(20);}else e=Q(a,c,0),d=!0;if(!e)throw new N(44); +8192===(e.mode&61440)&&(b&=-513);if(b&65536&&16384!==(e.mode&61440))throw new N(54);if(!d&&(c=e?40960===(e.mode&61440)?32:16384===(e.mode&61440)&&("r"!==Sb(b)||b&512)?31:Pb(e,Sb(b)):44))throw new N(c);if(b&512&&!d){c=e;c="string"==typeof c?P(c,{W:!0}).node:c;if(!c.j.G)throw new N(63);if(16384===(c.mode&61440))throw new N(31);if(32768!==(c.mode&61440))throw new N(28);if(d=Pb(c,"w"))throw new N(d);c.j.G(c,{size:0,timestamp:Date.now()})}b&=-131713;e=Wb({node:e,path:Nb(e),flags:b,seekable:!0,position:0, +h:e.h,cb:[],error:!1});e.h.open&&e.h.open(e);!g.logReadFiles||b&1||($b||($b={}),a in $b||($b[a]=1));return e},bc=(a,b,c)=>{if(null===a.fd)throw new N(8);if(!a.seekable||!a.h.L)throw new N(70);if(0!=c&&1!=c&&2!=c)throw new N(28);a.position=a.h.L(a,b,c);a.cb=[]},cc=()=>{N||(N=function(a,b){this.name="ErrnoError";this.node=b;this.Xa=function(c){this.A=c;for(var d in Eb)if(Eb[d]===c){this.code=d;break}};this.Xa(a);this.message=Db[a];this.stack&&(Object.defineProperty(this,"stack",{value:Error().stack, +writable:!0}),this.stack=Fb(this.stack))},N.prototype=Error(),N.prototype.constructor=N,[44].forEach(a=>{Ab[a]=new N(a);Ab[a].stack=""}))},dc,ec=(a,b)=>{var c=0;a&&(c|=365);b&&(c|=146);return c},gc=(a,b,c)=>{a=mb("/dev/"+a);var d=ec(!!b,!!c);fc||(fc=64);var e=fc++<<8|0;ub(e,{open:f=>{f.seekable=!1},close:()=>{c&&c.buffer&&c.buffer.length&&c(10)},read:(f,k,l,p)=>{for(var m=0,q=0;q{for(var m=0;m>2]}function S(a){a=Ib[a];if(!a)throw new N(8);return a}function jc(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var kc=void 0; +function T(a){for(var b="";C[a];)b+=kc[C[a++]];return b}var lc={},mc={},nc={};function oc(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}function pc(a,b){a=oc(a);return{[a]:function(){return b.apply(this,arguments)}}[a]} +function qc(a){var b=Error,c=pc(a,function(d){this.name=a;this.message=d;d=Error(d).stack;void 0!==d&&(this.stack=this.toString()+"\n"+d.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c}var rc=void 0;function U(a){throw new rc(a);}var sc=void 0;function tc(a){throw new sc(a);} +function uc(a,b,c){function d(l){l=c(l);l.length!==a.length&&tc("Mismatched type converter count");for(var p=0;p{mc.hasOwnProperty(l)?e[p]=mc[l]:(f.push(l),lc.hasOwnProperty(l)||(lc[l]=[]),lc[l].push(()=>{e[p]=mc[l];++k;k===f.length&&d(e)}))});0===f.length&&d(e)} +function V(a,b,c={}){if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var d=b.name;a||U('type "'+d+'" must have a positive integer typeid pointer');if(mc.hasOwnProperty(a)){if(c.Fa)return;U("Cannot register type '"+d+"' twice")}mc[a]=b;delete nc[a];lc.hasOwnProperty(a)&&(b=lc[a],delete lc[a],b.forEach(e=>e()))}function vc(a){U(a.g.o.m.name+" instance already deleted")}var wc=!1;function xc(){} +function yc(a){--a.count.value;0===a.count.value&&(a.v?a.B.M(a.v):a.o.m.M(a.l))}function zc(a,b,c){if(b===c)return a;if(void 0===c.C)return null;a=zc(a,b,c.C);return null===a?null:c.Aa(a)}var Ac={},Bc=[];function Cc(){for(;Bc.length;){var a=Bc.pop();a.g.R=!1;a["delete"]()}}var Dc=void 0,Ec={};function Fc(a,b){for(void 0===b&&U("ptr should not be undefined");a.C;)b=a.V(b),a=a.C;return Ec[b]} +function Gc(a,b){b.o&&b.l||tc("makeClassHandle requires ptr and ptrType");!!b.B!==!!b.v&&tc("Both smartPtrType and smartPtr must be specified");b.count={value:1};return Hc(Object.create(a,{g:{value:b}}))} +function Ic(a){function b(){return this.Y?Gc(this.m.S,{o:this.Sa,l:c,B:this,v:a}):Gc(this.m.S,{o:this,l:a})}var c=this.Ca(a);if(!c)return this.oa(a),null;var d=Fc(this.m,c);if(void 0!==d){if(0===d.g.count.value)return d.g.l=c,d.g.v=a,d.clone();d=d.clone();this.oa(a);return d}d=this.m.Ba(c);d=Ac[d];if(!d)return b.call(this);d=this.X?d.ya:d.pointerType;var e=zc(c,this.m,d.m);return null===e?b.call(this):this.Y?Gc(d.m.S,{o:d,l:e,B:this,v:a}):Gc(d.m.S,{o:d,l:e})} +function Hc(a){if("undefined"===typeof FinalizationRegistry)return Hc=b=>b,a;wc=new FinalizationRegistry(b=>{console.warn(b.sa.stack.replace(/^Error: /,""));yc(b.g)});Hc=b=>{var c=b.g;if(c.v){var d={g:c};d.sa=Error("Embind found a leaked C++ instance "+c.o.m.name+" <"+za(c.l)+">.\nWe'll free it automatically in this case, but this functionality is not reliable across various environments.\nMake sure to invoke .delete() manually once you're done with the instance instead.\nOriginally allocated");"captureStackTrace"in +Error&&Error.captureStackTrace(d.sa,Ic);wc.register(b,d,b)}return b};xc=b=>{wc.unregister(b)};return Hc(a)}function W(){}function Jc(a,b,c){if(void 0===a[b].u){var d=a[b];a[b]=function(){a[b].u.hasOwnProperty(arguments.length)||U("Function '"+c+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+a[b].u+")!");return a[b].u[arguments.length].apply(this,arguments)};a[b].u=[];a[b].u[d.P]=d}} +function Kc(a,b,c){g.hasOwnProperty(a)?((void 0===c||void 0!==g[a].u&&void 0!==g[a].u[c])&&U("Cannot register public name '"+a+"' twice"),Jc(g,a,a),g.hasOwnProperty(c)&&U("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),g[a].u[c]=b):(g[a]=b,void 0!==c&&(g[a].fb=c))}function Lc(a,b,c,d,e,f,k,l){this.name=a;this.constructor=b;this.S=c;this.M=d;this.C=e;this.Ba=f;this.V=k;this.Aa=l;this.Ta=[]} +function Mc(a,b,c){for(;b!==c;)b.V||U("Expected null or instance of "+c.name+", got an instance of "+b.name),a=b.V(a),b=b.C;return a}function Nc(a,b){if(null===b)return this.ha&&U("null is not a valid "+this.name),0;b.g||U('Cannot pass "'+Oc(b)+'" as a '+this.name);b.g.l||U("Cannot pass deleted object as a pointer of type "+this.name);return Mc(b.g.l,b.g.o.m,this.m)} +function Pc(a,b){if(null===b){this.ha&&U("null is not a valid "+this.name);if(this.Y){var c=this.Ua();null!==a&&a.push(this.M,c);return c}return 0}b.g||U('Cannot pass "'+Oc(b)+'" as a '+this.name);b.g.l||U("Cannot pass deleted object as a pointer of type "+this.name);!this.X&&b.g.o.X&&U("Cannot convert argument of type "+(b.g.B?b.g.B.name:b.g.o.name)+" to parameter type "+this.name);c=Mc(b.g.l,b.g.o.m,this.m);if(this.Y)switch(void 0===b.g.v&&U("Passing raw pointer to smart pointer is illegal"),this.Ya){case 0:b.g.B=== +this?c=b.g.v:U("Cannot convert argument of type "+(b.g.B?b.g.B.name:b.g.o.name)+" to parameter type "+this.name);break;case 1:c=b.g.v;break;case 2:if(b.g.B===this)c=b.g.v;else{var d=b.clone();c=this.Va(c,Qc(function(){d["delete"]()}));null!==a&&a.push(this.M,c)}break;default:U("Unsupporting sharing policy")}return c} +function Rc(a,b){if(null===b)return this.ha&&U("null is not a valid "+this.name),0;b.g||U('Cannot pass "'+Oc(b)+'" as a '+this.name);b.g.l||U("Cannot pass deleted object as a pointer of type "+this.name);b.g.o.X&&U("Cannot convert argument of type "+b.g.o.name+" to parameter type "+this.name);return Mc(b.g.l,b.g.o.m,this.m)}function Sc(a){return this.fromWireType(F[a>>2])} +function X(a,b,c,d){this.name=a;this.m=b;this.ha=c;this.X=d;this.Y=!1;this.M=this.Va=this.Ua=this.va=this.Ya=this.Sa=void 0;void 0!==b.C?this.toWireType=Pc:(this.toWireType=d?Nc:Rc,this.D=null)}function Tc(a,b,c){g.hasOwnProperty(a)||tc("Replacing nonexistant public symbol");void 0!==g[a].u&&void 0!==c?g[a].u[c]=b:(g[a]=b,g[a].P=c)} +function Uc(a,b){assert(a.includes("j")||a.includes("p"),"getDynCaller should only be called with i64 sigs");var c=[];return function(){c.length=0;Object.assign(c,arguments);if(a.includes("j")){assert("dynCall_"+a in g,"bad function pointer type - dynCall function not found for sig '"+a+"'");c&&c.length?assert(c.length===a.substring(1).replace(/j/g,"--").length):assert(1==a.length);var d=g["dynCall_"+a];d=c&&c.length?d.apply(null,[b].concat(c)):d.call(null,b)}else assert(ib(b),"missing table entry in dynCall: "+ +b),d=ib(b).apply(null,c);return d}}function Vc(a,b){a=T(a);var c=a.includes("j")?Uc(a,b):ib(b);"function"!=typeof c&&U("unknown function pointer with signature "+a+": "+b);return c}var Wc=void 0;function Xc(a){a=Yc(a);var b=T(a);Y(a);return b}function Zc(a,b){function c(f){e[f]||mc[f]||(nc[f]?nc[f].forEach(c):(d.push(f),e[f]=!0))}var d=[],e={};b.forEach(c);throw new Wc(a+": "+d.map(Xc).join([", "]));} +function $c(a,b,c,d,e,f){var k=b.length;2>k&&U("argTypes array size mismatch! Must at least get return value and 'this' types!");assert(!f,"Async bindings are only supported with JSPI.");var l=null!==b[1]&&null!==c,p=!1;for(c=1;c>2]);return c}var dd=[],Z=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function ed(a){4{a||U("Cannot use deleted val. handle = "+a);return Z[a].value},Qc=a=>{switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=dd.length?dd.pop():Z.length;Z[b]={ka:1,value:a};return b}}; +function gd(a,b,c){switch(b){case 0:return function(d){return this.fromWireType((c?D:C)[d])};case 1:return function(d){return this.fromWireType((c?E:Da)[d>>1])};case 2:return function(d){return this.fromWireType((c?F:G)[d>>2])};default:throw new TypeError("Unknown integer type: "+a);}}function hd(a,b){var c=mc[a];void 0===c&&U(b+" has unknown type "+Xc(a));return c}function Oc(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a} +function jd(a,b){switch(b){case 2:return function(c){return this.fromWireType(Ea[c>>2])};case 3:return function(c){return this.fromWireType(Fa[c>>3])};default:throw new TypeError("Unknown float type: "+a);}} +function kd(a,b,c){switch(b){case 0:return c?function(d){return D[d]}:function(d){return C[d]};case 1:return c?function(d){return E[d>>1]}:function(d){return Da[d>>1]};case 2:return c?function(d){return F[d>>2]}:function(d){return G[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var ld="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0; +function md(a,b){assert(0==a%2,"Pointer passed to UTF16ToString must be aligned to two bytes!");var c=a>>1;for(var d=c+b/2;!(c>=d)&&Da[c];)++c;c<<=1;if(32=b/2);++d){var e=E[a+2*d>>1];if(0==e)break;c+=String.fromCharCode(e)}return c} +function nd(a,b,c){assert(0==b%2,"Pointer passed to stringToUTF16 must be aligned to two bytes!");assert("number"==typeof c,"stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!");void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var d=b;c=c<2*a.length?c/2:a.length;for(var e=0;e>1]=a.charCodeAt(e),b+=2;E[b>>1]=0;return b-d}function od(a){return 2*a.length} +function pd(a,b){assert(0==a%4,"Pointer passed to UTF32ToString must be aligned to four bytes!");for(var c=0,d="";!(c>=b/4);){var e=F[a+4*c>>2];if(0==e)break;++c;65536<=e?(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023)):d+=String.fromCharCode(e)}return d} +function qd(a,b,c){assert(0==b%4,"Pointer passed to stringToUTF32 must be aligned to four bytes!");assert("number"==typeof c,"stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!");void 0===c&&(c=2147483647);if(4>c)return 0;var d=b;c=d+c-4;for(var e=0;e=f){var k=a.charCodeAt(++e);f=65536+((f&1023)<<10)|k&1023}F[b>>2]=f;b+=4;if(b+4>c)break}F[b>>2]=0;return b-d} +function rd(a){for(var b=0,c=0;c=d&&++c;b+=4}return b}var sd={};function td(a){var b=sd[a];return void 0===b?T(a):b}var ud=[]; +function vd(){function a(b){b.$$$embind_global$$$=b;var c="object"==typeof $$$embind_global$$$&&b.$$$embind_global$$$==b;c||delete b.$$$embind_global$$$;return c}if("object"==typeof globalThis)return globalThis;if("object"==typeof $$$embind_global$$$)return $$$embind_global$$$;"object"==typeof global&&a(global)?$$$embind_global$$$=global:"object"==typeof self&&a(self)&&($$$embind_global$$$=self);if("object"==typeof $$$embind_global$$$)return $$$embind_global$$$;throw Error("unable to get global object."); +}function wd(a){var b=ud.length;ud.push(a);return b}function xd(a,b){for(var c=Array(a),d=0;d>2],"parameter "+d);return c}var yd=[];function zd(a){var b=Array(a+1);return function(c,d,e){b[0]=c;for(var f=0;f>2],"parameter "+f);b[f+1]=k.readValueFromPointer(e);e+=k.argPackAdvance}c=new (c.bind.apply(c,b));return Qc(c)}}var Ad={},Bd={}; +function Cd(a){a instanceof qa||"unwind"==a||(Ka(),a instanceof WebAssembly.RuntimeError&&0>=Dd()&&y("Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 65536)"),ea(1,a))} +function Ed(a){if(ua)y("user callback triggered after runtime exited or application aborted. Ignoring.");else try{if(a(),!noExitRuntime)try{va=a=va;Fd();if(noExitRuntime){var b="program exited (with status: "+a+"), but keepRuntimeAlive() is set (counter=0) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)";ba(b);y(b)}va=a;if(!noExitRuntime){if(g.onExit)g.onExit(a); +ua=!0}ea(a,new qa(a))}catch(c){Cd(c)}}catch(c){Cd(c)}}var Gd;Gd=w?()=>{var a=process.hrtime();return 1E3*a[0]+a[1]/1E6}:()=>performance.now();function Hd(a){var b=Ca(a)+1,c=Id(b);c&&Aa(a,D,c,b);return c}var Jd=[],Kd={}; +function Ld(){if(!Md){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:da||"./this.program"},b;for(b in Kd)void 0===Kd[b]?delete a[b]:a[b]=Kd[b];var c=[];for(b in a)c.push(b+"="+a[b]);Md=c}return Md}var Md;function Nd(a,b){Nd.ua||(Nd.ua=pb());for(var c=0;c>0]=Nd.ua();return 0}function Od(a){return 0===a%4&&(0!==a%100||0===a%400)} +var Pd=[31,29,31,30,31,30,31,31,30,31,30,31],Qd=[31,28,31,30,31,30,31,31,30,31,30,31];function Rd(a,b){assert(0<=a.length,"writeArrayToMemory array must have a length (should be an array or typed array)");D.set(a,b)} +function Sd(a,b,c,d){function e(h,r,u){for(h="number"==typeof h?h.toString():h||"";h.lengthH?-1:0B-h.getDate())r-=B-h.getDate()+1,h.setDate(1),11>u?h.setMonth(u+1):(h.setMonth(0),h.setFullYear(h.getFullYear()+1));else{h.setDate(h.getDate()+r);break}}u=new Date(h.getFullYear()+1,0,4);r=l(new Date(h.getFullYear(),0, +4));u=l(u);return 0>=k(r,h)?0>=k(u,h)?h.getFullYear()+1:h.getFullYear():h.getFullYear()-1}var m=F[d+40>>2];d={ab:F[d>>2],$a:F[d+4>>2],da:F[d+8>>2],la:F[d+12>>2],ea:F[d+16>>2],O:F[d+20>>2],H:F[d+24>>2],N:F[d+28>>2],ib:F[d+32>>2],Za:F[d+36>>2],bb:m?A(m):""};c=A(c);m={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d", +"%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var q in m)c=c.replace(new RegExp(q,"g"),m[q]);var t="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),v="January February March April May June July August September October November December".split(" ");m={"%a":function(h){return t[h.H].substring(0,3)},"%A":function(h){return t[h.H]},"%b":function(h){return v[h.ea].substring(0,3)},"%B":function(h){return v[h.ea]}, +"%C":function(h){return f((h.O+1900)/100|0,2)},"%d":function(h){return f(h.la,2)},"%e":function(h){return e(h.la,2," ")},"%g":function(h){return p(h).toString().substring(2)},"%G":function(h){return p(h)},"%H":function(h){return f(h.da,2)},"%I":function(h){h=h.da;0==h?h=12:12h.da?"AM":"PM"},"%S":function(h){return f(h.ab,2)},"%t":function(){return"\t"},"%u":function(h){return h.H||7},"%U":function(h){return f(Math.floor((h.N+7-h.H)/7),2)},"%V":function(h){var r=Math.floor((h.N+7-(h.H+6)%7)/7);2>=(h.H+371-h.N-2)%7&&r++;if(r)53==r&&(u=(h.H+371-h.N)%7,4==u||3==u&&Od(h.O)||(r=1));else{r=52;var u=(h.H+7-h.N-1)%7;(4==u||5==u&&Od(h.O%400-1))&&r++}return f(r,2)},"%w":function(h){return h.H},"%W":function(h){return f(Math.floor((h.N+7-(h.H+6)%7)/7),2)},"%y":function(h){return(h.O+ +1900).toString().substring(2)},"%Y":function(h){return h.O+1900},"%z":function(h){h=h.Za;var r=0<=h;h=Math.abs(h)/60;return(r?"+":"-")+String("0000"+(h/60*100+h%60)).slice(-4)},"%Z":function(h){return h.bb},"%%":function(){return"%"}};c=c.replace(/%%/g,"\x00\x00");for(q in m)c.includes(q)&&(c=c.replace(new RegExp(q,"g"),m[q](d)));c=c.replace(/\0\0/g,"%");q=rb(c,!1);if(q.length>b)return 0;Rd(q,a);return q.length-1} +function Qb(a,b,c,d){a||(a=this);this.parent=a;this.J=a.J;this.aa=null;this.id=Jb++;this.name=b;this.mode=c;this.j={};this.h={};this.rdev=d}Object.defineProperties(Qb.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}}});cc();Kb=Array(4096);Xb(O,"/");Q("/tmp",16895,0);Q("/home",16895,0);Q("/home/web_user",16895,0); +(()=>{Q("/dev",16895,0);ub(259,{read:()=>0,write:(b,c,d,e)=>e});Yb("/dev/null",259);tb(1280,wb);tb(1536,xb);Yb("/dev/tty",1280);Yb("/dev/tty1",1536);var a=pb();gc("random",a);gc("urandom",a);Q("/dev/shm",16895,0);Q("/dev/shm/tmp",16895,0)})(); +(()=>{Q("/proc",16895,0);var a=Q("/proc/self",16895,0);Q("/proc/self/fd",16895,0);Xb({J:()=>{var b=zb(a,"fd",16895,73);b.j={lookup:(c,d)=>{var e=Ib[+d];if(!e)throw new N(8);c={parent:null,J:{ta:"fake"},j:{readlink:()=>e.path}};return c.parent=c}};return b}},"/proc/self/fd")})(); +Eb={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115, +ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14, +EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135};for(var Td=Array(256),Ud=0;256>Ud;++Ud)Td[Ud]=String.fromCharCode(Ud);kc=Td;rc=g.BindingError=qc("BindingError"); +sc=g.InternalError=qc("InternalError");W.prototype.isAliasOf=function(a){if(!(this instanceof W&&a instanceof W))return!1;var b=this.g.o.m,c=this.g.l,d=a.g.o.m;for(a=a.g.l;b.C;)c=b.V(c),b=b.C;for(;d.C;)a=d.V(a),d=d.C;return b===d&&c===a}; +W.prototype.clone=function(){this.g.l||vc(this);if(this.g.U)return this.g.count.value+=1,this;var a=Hc,b=Object,c=b.create,d=Object.getPrototypeOf(this),e=this.g;a=a(c.call(b,d,{g:{value:{count:e.count,R:e.R,U:e.U,l:e.l,o:e.o,v:e.v,B:e.B}}}));a.g.count.value+=1;a.g.R=!1;return a};W.prototype["delete"]=function(){this.g.l||vc(this);this.g.R&&!this.g.U&&U("Object already scheduled for deletion");xc(this);yc(this.g);this.g.U||(this.g.v=void 0,this.g.l=void 0)};W.prototype.isDeleted=function(){return!this.g.l}; +W.prototype.deleteLater=function(){this.g.l||vc(this);this.g.R&&!this.g.U&&U("Object already scheduled for deletion");Bc.push(this);1===Bc.length&&Dc&&Dc(Cc);this.g.R=!0;return this};g.getInheritedInstanceCount=function(){return Object.keys(Ec).length};g.getLiveInheritedInstances=function(){var a=[],b;for(b in Ec)Ec.hasOwnProperty(b)&&a.push(Ec[b]);return a};g.flushPendingDeletes=Cc;g.setDelayFunction=function(a){Dc=a;Bc.length&&Dc&&Dc(Cc)};X.prototype.Ca=function(a){this.va&&(a=this.va(a));return a}; +X.prototype.oa=function(a){this.M&&this.M(a)};X.prototype.argPackAdvance=8;X.prototype.readValueFromPointer=Sc;X.prototype.deleteObject=function(a){if(null!==a)a["delete"]()};X.prototype.fromWireType=Ic;Wc=g.UnboundTypeError=qc("UnboundTypeError");g.count_emval_handles=function(){for(var a=0,b=5;be?-28:Wb(d, +e).fd;case 1:case 2:return 0;case 3:return d.flags;case 4:return e=ic(),d.flags|=e,0;case 5:return e=ic(),E[e+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return F[Vd()>>2]=28,-1;default:return-28}}catch(f){if("undefined"==typeof R||"ErrnoError"!==f.name)throw f;return-f.A}},__syscall_getcwd:function(a,b){try{if(0===b)return-28;var c=Ca("/")+1;if(b>2]=0;case 21520:return d.tty?-28:-59;case 21531:a=e=ic();if(!d.h.Ga)throw new N(59);return d.h.Ga(d,b,a);case 21523:return d.tty?0:-59;case 21524:return d.tty?0:-59;default:return-28}}catch(f){if("undefined"==typeof R||"ErrnoError"!==f.name)throw f;return-f.A}},__syscall_openat:function(a, +b,c,d){hc=d;try{b=A(b);var e=b;if("/"===e.charAt(0))b=e;else{var f=-100===a?"/":S(a).path;if(0==e.length)throw new N(44);b=mb(f+"/"+e)}var k=d?ic():0;return ac(b,c,k).fd}catch(l){if("undefined"==typeof R||"ErrnoError"!==l.name)throw l;return-l.A}},_embind_register_bigint:function(){},_embind_register_bool:function(a,b,c,d,e){var f=jc(c);b=T(b);V(a,{name:b,fromWireType:function(k){return!!k},toWireType:function(k,l){return l?d:e},argPackAdvance:8,readValueFromPointer:function(k){if(1===c)var l=D;else if(2=== +c)l=E;else if(4===c)l=F;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(l[k>>f])},D:null})},_embind_register_class:function(a,b,c,d,e,f,k,l,p,m,q,t,v){q=T(q);f=Vc(e,f);l&&(l=Vc(k,l));m&&(m=Vc(p,m));v=Vc(t,v);var h=oc(q);Kc(h,function(){Zc("Cannot construct "+q+" due to unbound types",[d])});uc([a,b,c],d?[d]:[],function(r){r=r[0];if(d){var u=r.m;var B=u.S}else B=W.prototype;r=pc(h,function(){if(Object.getPrototypeOf(this)!==H)throw new rc("Use 'new' to construct "+ +q);if(void 0===I.I)throw new rc(q+" has no accessible constructor");var bd=I.I[arguments.length];if(void 0===bd)throw new rc("Tried to invoke ctor of "+q+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(I.I).toString()+") parameters instead!");return bd.apply(this,arguments)});var H=Object.create(B,{constructor:{value:r}});r.prototype=H;var I=new Lc(q,r,H,v,u,f,l,m);u=new X(q,I,!0,!1);B=new X(q+"*",I,!1,!1);var cd=new X(q+" const*",I,!1,!0);Ac[a]={pointerType:B, +ya:cd};Tc(h,r);return[u,B,cd]})},_embind_register_class_class_function:function(a,b,c,d,e,f,k,l){var p=ad(c,d);b=T(b);f=Vc(e,f);uc([],[a],function(m){function q(){Zc("Cannot call "+t+" due to unbound types",p)}m=m[0];var t=m.name+"."+b;b.startsWith("@@")&&(b=Symbol[b.substring(2)]);var v=m.m.constructor;void 0===v[b]?(q.P=c-1,v[b]=q):(Jc(v,b,t),v[b].u[c-1]=q);uc([],p,function(h){h=[h[0],null].concat(h.slice(1));h=$c(t,h,null,f,k,l);void 0===v[b].u?(h.P=c-1,v[b]=h):v[b].u[c-1]=h;return[]});return[]})}, +_embind_register_class_function:function(a,b,c,d,e,f,k,l,p){var m=ad(c,d);b=T(b);f=Vc(e,f);uc([],[a],function(q){function t(){Zc("Cannot call "+v+" due to unbound types",m)}q=q[0];var v=q.name+"."+b;b.startsWith("@@")&&(b=Symbol[b.substring(2)]);l&&q.m.Ta.push(b);var h=q.m.S,r=h[b];void 0===r||void 0===r.u&&r.className!==q.name&&r.P===c-2?(t.P=c-2,t.className=q.name,h[b]=t):(Jc(h,b,v),h[b].u[c-2]=t);uc([],m,function(u){u=$c(v,u,q,f,k,p);void 0===h[b].u?(u.P=c-2,h[b]=u):h[b].u[c-2]=u;return[]});return[]})}, +_embind_register_emval:function(a,b){b=T(b);V(a,{name:b,fromWireType:function(c){var d=fd(c);ed(c);return d},toWireType:function(c,d){return Qc(d)},argPackAdvance:8,readValueFromPointer:Sc,D:null})},_embind_register_enum:function(a,b,c,d){function e(){}c=jc(c);b=T(b);e.values={};V(a,{name:b,constructor:e,fromWireType:function(f){return this.constructor.values[f]},toWireType:function(f,k){return k.value},argPackAdvance:8,readValueFromPointer:gd(b,c,d),D:null});Kc(b,e)},_embind_register_enum_value:function(a, +b,c){var d=hd(a,"enum");b=T(b);a=d.constructor;d=Object.create(d.constructor.prototype,{value:{value:c},constructor:{value:pc(d.name+"_"+b,function(){})}});a.values[c]=d;a[b]=d},_embind_register_float:function(a,b,c){c=jc(c);b=T(b);V(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,e){if("number"!=typeof e&&"boolean"!=typeof e)throw new TypeError('Cannot convert "'+Oc(e)+'" to '+this.name);return e},argPackAdvance:8,readValueFromPointer:jd(b,c),D:null})},_embind_register_function:function(a, +b,c,d,e,f,k){var l=ad(b,c);a=T(a);e=Vc(d,e);Kc(a,function(){Zc("Cannot call "+a+" due to unbound types",l)},b-1);uc([],l,function(p){p=[p[0],null].concat(p.slice(1));Tc(a,$c(a,p,null,e,f,k),b-1);return[]})},_embind_register_integer:function(a,b,c,d,e){b=T(b);-1===e&&(e=4294967295);var f=jc(c),k=m=>m;if(0===d){var l=32-8*c;k=m=>m<>>l}var p=(m,q)=>{if("number"!=typeof m&&"boolean"!=typeof m)throw new TypeError('Cannot convert "'+Oc(m)+'" to '+q);if(me)throw new TypeError('Passing a number "'+ +Oc(m)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+d+", "+e+"]!");};c=b.includes("unsigned")?function(m,q){p(q,this.name);return q>>>0}:function(m,q){p(q,this.name);return q};V(a,{name:b,fromWireType:k,toWireType:c,argPackAdvance:8,readValueFromPointer:kd(b,f,0!==d),D:null})},_embind_register_memory_view:function(a,b,c){function d(f){f>>=2;var k=G;return new e(k.buffer,k[f+1],k[f])}var e=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array, +Float32Array,Float64Array][b];c=T(c);V(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{Fa:!0})},_embind_register_std_string:function(a,b){b=T(b);var c="std::string"===b;V(a,{name:b,fromWireType:function(d){var e=G[d>>2],f=d+4;if(c)for(var k=f,l=0;l<=e;++l){var p=f+l;if(l==e||0==C[p]){k=A(k,p-k);if(void 0===m)var m=k;else m+=String.fromCharCode(0),m+=k;k=p+1}}else{m=Array(e);for(l=0;l>2]=f;if(c&&k)Ba(e,p,f+1);else if(k)for(k=0;kDa;var l=1}else 4===b&&(d=pd,e=qd,f=rd,k=()=>G,l=2);V(a,{name:c,fromWireType:function(p){for(var m=G[p>>2],q=k(),t,v=p+4,h=0;h<=m;++h){var r=p+4+h*b;if(h==m||0==q[r>>l])v=d(v,r-v),void 0===t?t=v:(t+=String.fromCharCode(0),t+=v),v=r+b}Y(p);return t},toWireType:function(p,m){"string"!=typeof m&&U("Cannot pass non-string to C++ string type "+c);var q=f(m),t=Id(4+q+b);G[t>>2]=q>>l; +e(m,t+4,q+b);null!==p&&p.push(Y,t);return t},argPackAdvance:8,readValueFromPointer:Sc,D:function(p){Y(p)}})},_embind_register_void:function(a,b){b=T(b);V(a,{Ia:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},_emscripten_get_now_is_monotonic:function(){return!0},_emval_call_void_method:function(a,b,c,d){a=ud[a];b=fd(b);c=td(c);a(b,c,null,d)},_emval_decref:ed,_emval_get_global:function(a){if(0===a)return Qc(vd());a=td(a);return Qc(vd()[a])},_emval_get_method_caller:function(a, +b){var c=xd(a,b),d=c[0];b=d.name+"_$"+c.slice(1).map(function(k){return k.name}).join("_")+"$";var e=yd[b];if(void 0!==e)return e;var f=Array(a-1);e=wd((k,l,p,m)=>{for(var q=0,t=0;t>2]+4294967296*F[a+4>>2]));F[b>>2]=a.getUTCSeconds();F[b+4>>2]=a.getUTCMinutes();F[b+8>>2]=a.getUTCHours();F[b+12>>2]=a.getUTCDate();F[b+16>>2]=a.getUTCMonth();F[b+20>>2]=a.getUTCFullYear()-1900;F[b+24>>2]=a.getUTCDay();F[b+28>>2]=(a.getTime()-Date.UTC(a.getUTCFullYear(),0,1,0,0,0,0))/864E5|0},_mmap_js:function(a,b,c,d,e,f,k){try{var l=S(d);if(0!==(b&2)&&0===(c&2)&&2!==(l.flags&2097155))throw new N(2); +if(1===(l.flags&2097155))throw new N(2);if(!l.h.$)throw new N(43);var p=l.h.$(l,a,e,b,c);var m=p.l;F[f>>2]=p.wa;G[k>>2]=m;return 0}catch(q){if("undefined"==typeof R||"ErrnoError"!==q.name)throw q;return-q.A}},_munmap_js:function(a,b,c,d,e,f){try{var k=S(e);if(c&2){if(32768!==(k.node.mode&61440))throw new N(43);if(!(d&2)){var l=C.slice(a,a+b);k.h.ba&&k.h.ba(k,l,f,b,d)}}}catch(p){if("undefined"==typeof R||"ErrnoError"!==p.name)throw p;return-p.A}},_setitimer_js:function(a,b){Bd[a]&&(clearTimeout(Bd[a].id), +delete Bd[a]);if(!b)return 0;var c=setTimeout(()=>{assert(a in Bd);delete Bd[a];Ed(()=>Wd(a,Gd()))},b);Bd[a]={id:c,hb:b};return 0},_tzset_js:function(a,b,c){function d(p){return(p=p.toTimeString().match(/\(([A-Za-z ]+)\)$/))?p[1]:"GMT"}var e=(new Date).getFullYear(),f=new Date(e,0,1),k=new Date(e,6,1);e=f.getTimezoneOffset();var l=k.getTimezoneOffset();G[a>>2]=60*Math.max(e,l);F[b>>2]=Number(e!=l);a=d(f);b=d(k);a=Hd(a);b=Hd(b);l>2]=a,G[c+4>>2]=b):(G[c>>2]=b,G[c+4>>2]=a)},abort:function(){n("native code called abort()")}, +emscripten_asm_const_int:function(a,b,c){assert(Array.isArray(Jd));assert(0==c%16);Jd.length=0;var d;for(c>>=2;d=C[b++];){var e=String.fromCharCode(d),f=["d","f","i"];assert(f.includes(e),"Invalid character "+d+'("'+e+'") in readEmAsmArgs! Use only ['+f+'], and do not specify "v" for void return argument.');c+=105!=d&c;Jd.push(105==d?F[c]:Fa[c++>>1]);++c}eb.hasOwnProperty(a)||n("No EM_ASM constant found at address "+a);return eb[a].apply(null,Jd)},emscripten_date_now:function(){return Date.now()}, +emscripten_get_now:Gd,emscripten_memcpy_big:function(a,b,c){C.copyWithin(a,b,b+c)},emscripten_resize_heap:function(a){var b=C.length;a>>>=0;assert(a>b);if(2147483648=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);var e=Math;d=Math.max(a,d);e=e.min.call(e,2147483648,d+(65536-d%65536)%65536);a:{d=e;var f=ta.buffer;try{ta.grow(d-f.byteLength+65535>>>16);Ga();var k=1;break a}catch(l){y("emscripten_realloc_buffer: Attempted to grow heap from "+ +f.byteLength+" bytes to "+d+" bytes, but got error: "+l)}k=void 0}if(k)return!0}y("Failed to grow the heap from "+b+" bytes to "+e+" bytes, not enough memory!");return!1},environ_get:function(a,b){var c=0;Ld().forEach(function(d,e){var f=b+c;e=G[a+4*e>>2]=f;for(f=0;f>0]=d.charCodeAt(f);D[e>>0]=0;c+=d.length+1});return 0},environ_sizes_get:function(a,b){var c=Ld();G[a>>2]=c.length;var d=0;c.forEach(function(e){d+=e.length+1});G[b>> +2]=d;return 0},fd_close:function(a){try{var b=S(a);if(null===b.fd)throw new N(8);b.ga&&(b.ga=null);try{b.h.close&&b.h.close(b)}catch(c){throw c;}finally{Ib[b.fd]=null}b.fd=null;return 0}catch(c){if("undefined"==typeof R||"ErrnoError"!==c.name)throw c;return c.A}},fd_read:function(a,b,c,d){try{a:{var e=S(a);a=b;for(var f,k=b=0;k>2],p=G[a+4>>2];a+=8;var m=e,q=l,t=p,v=f,h=D;if(0>t||0>v)throw new N(28);if(null===m.fd)throw new N(8);if(1===(m.flags&2097155))throw new N(8);if(16384=== +(m.node.mode&61440))throw new N(31);if(!m.h.read)throw new N(28);var r="undefined"!=typeof v;if(!r)v=m.position;else if(!m.seekable)throw new N(70);var u=m.h.read(m,h,q,t,v);r||(m.position+=u);var B=u;if(0>B){var H=-1;break a}b+=B;if(B>2]=H;return 0}catch(I){if("undefined"==typeof R||"ErrnoError"!==I.name)throw I;return I.A}},fd_seek:function(a,b,c,d,e){try{assert(b==b>>>0||b==(b|0));assert(c===(c|0));var f=c+2097152>>>0<4194305-!!b?(b>>>0)+4294967296* +c:NaN;if(isNaN(f))return 61;var k=S(a);bc(k,f,d);bb=[k.position>>>0,(ab=k.position,1<=+Math.abs(ab)?0>>0:~~+Math.ceil((ab-+(~~ab>>>0))/4294967296)>>>0:0)];F[e>>2]=bb[0];F[e+4>>2]=bb[1];k.ga&&0===f&&0===d&&(k.ga=null);return 0}catch(l){if("undefined"==typeof R||"ErrnoError"!==l.name)throw l;return l.A}},fd_write:function(a,b,c,d){try{a:{var e=S(a);a=b;for(var f,k=b=0;k>2],p=G[a+4>>2];a+=8;var m=e,q=l,t=p,v=f,h=D;if(0>t||0>v)throw new N(28); +if(null===m.fd)throw new N(8);if(0===(m.flags&2097155))throw new N(8);if(16384===(m.node.mode&61440))throw new N(31);if(!m.h.write)throw new N(28);m.seekable&&m.flags&1024&&bc(m,0,2);var r="undefined"!=typeof v;if(!r)v=m.position;else if(!m.seekable)throw new N(70);var u=m.h.write(m,h,q,t,v,void 0);r||(m.position+=u);var B=u;if(0>B){var H=-1;break a}b+=B;"undefined"!==typeof f&&(f+=B)}H=b}G[d>>2]=H;return 0}catch(I){if("undefined"==typeof R||"ErrnoError"!==I.name)throw I;return I.A}},getentropy:Nd, +strftime_l:function(a,b,c,d){return Sd(a,b,c,d)}}; +(function(){function a(d){d=d.exports;g.asm=d;ta=g.asm.memory;assert(ta,"memory not found in wasm exports");Ga();Ha=g.asm.__indirect_function_table;assert(Ha,"table not found in wasm exports");Oa.unshift(g.asm.__wasm_call_ctors);J--;g.monitorRunDependencies&&g.monitorRunDependencies(J);assert(Ta["wasm-instantiate"]);delete Ta["wasm-instantiate"];if(0==J&&(null!==K&&(clearInterval(K),K=null),Sa)){var e=Sa;Sa=null;e()}return d}var b={env:Xd,wasi_snapshot_preview1:Xd};Ua();var c=g;if(g.instantiateWasm)try{return g.instantiateWasm(b, +a)}catch(d){y("Module.instantiateWasm callback failed with error: "+d),ba(d)}$a(b,function(d){assert(g===c,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?");c=null;a(d.instance)}).catch(ba);return{}})();var Id=L("malloc"),Vd=L("__errno_location"),Y=L("free"),Yd=g._fflush=L("fflush"),Yc=g.___getTypeName=L("__getTypeName");g.__embind_initialize_bindings=L("_embind_initialize_bindings");var Cb=L("emscripten_builtin_memalign"),Wd=L("_emscripten_timeout"); +g._setThrew=L("setThrew");function Zd(){return(Zd=g.asm.emscripten_stack_init).apply(null,arguments)}function Ja(){return(Ja=g.asm.emscripten_stack_get_end).apply(null,arguments)}function Dd(){return(Dd=g.asm.emscripten_stack_get_current).apply(null,arguments)}g.dynCall_iiiiij=L("dynCall_iiiiij");g.dynCall_iiiij=L("dynCall_iiiij");g.dynCall_jii=L("dynCall_jii");g.dynCall_ji=L("dynCall_ji");g.dynCall_iiji=L("dynCall_iiji");g.dynCall_iiiji=L("dynCall_iiiji");g.dynCall_jiii=L("dynCall_jiii"); +g.dynCall_jiiii=L("dynCall_jiiii");g.dynCall_iiij=L("dynCall_iiij");g.dynCall_jijjj=L("dynCall_jijjj");g.dynCall_jij=L("dynCall_jij");g.dynCall_viijii=L("dynCall_viijii");g.dynCall_viiiijijji=L("dynCall_viiiijijji");g.dynCall_iijj=L("dynCall_iijj");g.dynCall_vijj=L("dynCall_vijj");g.dynCall_jj=L("dynCall_jj");g.dynCall_viji=L("dynCall_viji");g.dynCall_jiji=L("dynCall_jiji");g.dynCall_iiiiijj=L("dynCall_iiiiijj");g.dynCall_iiiiiijj=L("dynCall_iiiiiijj"); +"stringToNewUTF8 inetPton4 inetNtop4 inetPton6 inetNtop6 readSockaddr writeSockaddr getHostByName traverseStack convertPCtoSourceLocation runMainThreadEmAsm jstoi_q jstoi_s listenOnce autoResumeAudioContext runtimeKeepalivePush runtimeKeepalivePop safeSetTimeout asmjsMangle HandleAllocator getNativeTypeSize STACK_SIZE STACK_ALIGN POINTER_SIZE ASSERTIONS writeI53ToI64 writeI53ToI64Clamped writeI53ToI64Signaling writeI53ToU64Clamped writeI53ToU64Signaling readI53FromU64 convertI32PairToI53 convertU32PairToI53 getCFunc ccall cwrap uleb128Encode sigToWasmTypes generateFuncType convertJsFunctionToWasm getEmptyTableSlot updateTableMap getFunctionAddress addFunction removeFunction reallyNegative unSign strLen reSign formatString intArrayToString AsciiToString stringToAscii allocateUTF8OnStack writeStringToMemory getSocketFromFD getSocketAddress registerKeyEventCallback maybeCStringToJsString findEventTarget findCanvasEventTarget getBoundingClientRect fillMouseEventData registerMouseEventCallback registerWheelEventCallback registerUiEventCallback registerFocusEventCallback fillDeviceOrientationEventData registerDeviceOrientationEventCallback fillDeviceMotionEventData registerDeviceMotionEventCallback screenOrientation fillOrientationChangeEventData registerOrientationChangeEventCallback fillFullscreenChangeEventData registerFullscreenChangeEventCallback JSEvents_requestFullscreen JSEvents_resizeCanvasForFullscreen registerRestoreOldStyle hideEverythingExceptGivenElement restoreHiddenElements setLetterbox softFullscreenResizeWebGLRenderTarget doRequestFullscreen fillPointerlockChangeEventData registerPointerlockChangeEventCallback registerPointerlockErrorEventCallback requestPointerLock fillVisibilityChangeEventData registerVisibilityChangeEventCallback registerTouchEventCallback fillGamepadEventData registerGamepadEventCallback registerBeforeUnloadEventCallback fillBatteryEventData battery registerBatteryEventCallback setCanvasElementSize getCanvasElementSize jsStackTrace stackTrace checkWasiClock createDyncallWrapper setImmediateWrapped clearImmediateWrapped polyfillSetImmediate getPromise makePromise makePromiseCallback exception_addRef exception_decRef setMainLoop _setNetworkCallback registerInheritedInstance unregisterInheritedInstance validateThis".split(" ").forEach(function(a){"undefined"===typeof globalThis|| +Object.getOwnPropertyDescriptor(globalThis,a)||Object.defineProperty(globalThis,a,{configurable:!0,get:function(){var b="`"+a+"` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line",c=a;c.startsWith("_")||(c="$"+a);b+=" (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE="+c+")";cb(a)&&(b+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you");ya(b)}});db(a)});"run UTF8ArrayToString UTF8ToString stringToUTF8Array stringToUTF8 lengthBytesUTF8 addOnPreRun addOnInit addOnPreMain addOnExit addOnPostRun addRunDependency removeRunDependency FS_createFolder FS_createPath FS_createDataFile FS_createPreloadedFile FS_createLazyFile FS_createLink FS_createDevice FS_unlink out err callMain abort keepRuntimeAlive wasmMemory stackAlloc stackSave stackRestore getTempRet0 setTempRet0 writeStackCookie checkStackCookie ptrToString zeroMemory exitJS getHeapMax emscripten_realloc_buffer ENV ERRNO_CODES ERRNO_MESSAGES setErrNo DNS Protocols Sockets getRandomDevice timers warnOnce UNWIND_CACHE readEmAsmArgsArray readEmAsmArgs runEmAsmFunction getExecutableName dynCallLegacy getDynCaller dynCall handleException callUserCallback maybeExit asyncLoad alignMemory mmapAlloc readI53FromI64 convertI32PairToI53Checked freeTableIndexes functionsInTableMap setValue getValue PATH PATH_FS intArrayFromString UTF16Decoder UTF16ToString stringToUTF16 lengthBytesUTF16 UTF32ToString stringToUTF32 lengthBytesUTF32 allocateUTF8 writeArrayToMemory writeAsciiToMemory SYSCALLS JSEvents specialHTMLTargets currentFullscreenStrategy restoreOldWindowedStyle demangle demangleAll ExitStatus getEnvStrings doReadv doWritev promiseMap uncaughtExceptionCount exceptionLast exceptionCaught ExceptionInfo Browser wget FS MEMFS TTY PIPEFS SOCKFS InternalError BindingError UnboundTypeError PureVirtualError init_embind throwInternalError throwBindingError throwUnboundTypeError ensureOverloadTable exposePublicSymbol replacePublicSymbol extendError createNamedFunction embindRepr registeredInstances getBasestPointer getInheritedInstance getInheritedInstanceCount getLiveInheritedInstances registeredTypes awaitingDependencies typeDependencies registeredPointers registerType whenDependentTypesAreResolved embind_charCodes embind_init_charCodes readLatin1String getTypeName heap32VectorToArray requireRegisteredType getShiftFromSize integerReadValueFromPointer enumReadValueFromPointer floatReadValueFromPointer simpleReadValueFromPointer runDestructors new_ craftInvokerFunction embind__requireFunction tupleRegistrations structRegistrations genericPointerToWireType constNoSmartPtrRawPointerToWireType nonConstNoSmartPtrRawPointerToWireType init_RegisteredPointer RegisteredPointer RegisteredPointer_getPointee RegisteredPointer_destructor RegisteredPointer_deleteObject RegisteredPointer_fromWireType runDestructor releaseClassHandle finalizationRegistry detachFinalizer_deps detachFinalizer attachFinalizer makeClassHandle init_ClassHandle ClassHandle ClassHandle_isAliasOf throwInstanceAlreadyDeleted ClassHandle_clone ClassHandle_delete deletionQueue ClassHandle_isDeleted ClassHandle_deleteLater flushPendingDeletes delayFunction setDelayFunction RegisteredClass shallowCopyInternalPointer downcastPointer upcastPointer char_0 char_9 makeLegalFunctionName emval_handle_array emval_free_list emval_symbols init_emval count_emval_handles get_first_emval getStringOrSymbol Emval emval_newers craftEmvalAllocator emval_get_global emval_lookupTypes emval_allocateDestructors emval_methodCallers emval_addMethodCaller emval_registeredMethods".split(" ").forEach(db); +var $d;Sa=function ae(){$d||be();$d||(Sa=ae)}; +function be(){function a(){if(!$d&&($d=!0,g.calledRun=!0,!ua)){assert(!Qa);Qa=!0;Ka();if(!g.noFSInit&&!dc){assert(!dc,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)");dc=!0;cc();g.stdin=g.stdin;g.stdout=g.stdout;g.stderr=g.stderr;g.stdin?gc("stdin",g.stdin):Zb("/dev/tty","/dev/stdin");g.stdout?gc("stdout",null,g.stdout):Zb("/dev/tty","/dev/stdout");g.stderr?gc("stderr",null, +g.stderr):Zb("/dev/tty1","/dev/stderr");var b=ac("/dev/stdin",0),c=ac("/dev/stdout",1),d=ac("/dev/stderr",1);assert(0===b.fd,"invalid handle for stdin ("+b.fd+")");assert(1===c.fd,"invalid handle for stdout ("+c.fd+")");assert(2===d.fd,"invalid handle for stderr ("+d.fd+")")}Lb=!1;fb(Oa);aa(g);if(g.onRuntimeInitialized)g.onRuntimeInitialized();assert(!g._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');Ka();if(g.postRun)for("function"== +typeof g.postRun&&(g.postRun=[g.postRun]);g.postRun.length;)b=g.postRun.shift(),Pa.unshift(b);fb(Pa)}}if(!(0{c=!0};try{Yd(0),["stdout","stderr"].forEach(function(d){d="/dev/"+d;try{var e=P(d,{W:!0});d=e.path}catch(k){}var f={Ha:!1,exists:!1,error:0,name:null,path:null,object:null,Pa:!1,Ra:null,Qa:null};try{e=P(d,{parent:!0}),f.Pa=!0,f.Ra=e.path,f.Qa=e.node,f.name=ob(d),e=P(d,{W:!0}),f.exists=!0,f.path=e.path,f.object=e.node,f.name=e.node.name,f.Ha="/"===e.path}catch(k){f.error=k.A}f&&(e=sb[f.object.rdev])&&e.output&&e.output.length&&(c=!0)})}catch(d){}ra=a;y=b;c&& +ya("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the FAQ), or make sure to emit a newline when you printf etc.")}if(g.preInit)for("function"==typeof g.preInit&&(g.preInit=[g.preInit]);0 { + const core = await Core.initWasm(); + return new WalletCoreWrapper(core); + } + + encodeHex(data: Uint8Array): string { + return this.HexCoding.encode(data); + } + + createWithData(hexStr: string): Uint8Array { + const data = this.HexCoding.decode(hexStr); + const privateKey = this.PrivateKey.createWithData(data); + return privateKey.data(); + } + + anySign(input: Uint8Array, coin: InstanceType): Uint8Array { + return this.AnySigner.sign(input, coin); + } + + preImageHashes(coin: InstanceType, txInput: Uint8Array): Uint8Array { + const result = this.TransactionCompiler.preImageHashes(coin, txInput); + return result + } + + compileWithSignatures( + coinType: InstanceType, + txInputData: Uint8Array, + signatures: string[], + publicKeys: string[] + ): Uint8Array { + const sigs = signatures.map((s) => this.HexCoding.decode(s)); + const pubs = publicKeys.map((p) => this.HexCoding.decode(p)); + const sigVec = this.makeDataVector(sigs); + const pubVec = this.makeDataVector(pubs); + + return this.TransactionCompiler.compileWithSignatures( + coinType, + txInputData, + sigVec, + pubVec + ); + } + + makeDataVector(items: Uint8Array[]): ReturnType { + const vec = this.DataVector.create(); + items.forEach((i) => vec.add(i)); + return vec; + } + + buildAptosUnsignedTx(jsonStr: string): Uint8Array { + const req = JSON.parse(jsonStr); + const input = { + chainId: req.chainId, + sender: req.sender, + sequenceNumber: Long.fromString(String(req.sequenceNumber)), + expirationTimestampSecs: Long.fromString(String(req.ttl)), + gasUnitPrice: Long.fromString(String(req.gasUnitPrice)), + maxGasAmount: Long.fromString(String(req.maxGasAmount)), + transfer: this.TW.Aptos.Proto.TransferMessage.create({ + to: req.toAddress, + amount: Long.fromString(String(req.amount)), + }), + }; + return this.TW.Aptos.Proto.SigningInput.encode(input).finish(); + } + + buildAptosUnsignedMessage(txInput: Uint8Array): Uint8Array { + const preimage = this.preImageHashes(this.CoinType.aptos, txInput); + const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage) + return out.data + } + + buildCardanoUnsignedTx(jsonStr: string): Uint8Array { + const req = JSON.parse(jsonStr); + + const transfer = this.TW.Cardano.Proto.Transfer.create({ + toAddress: req.toAddress, + changeAddress: req.changeAddress, + amount: req.amount, + useMaxAmount: false, + }); + + const utxos = req.utxos.map((utxo: any) => + this.TW.Cardano.Proto.TxInput.create({ + outPoint: this.TW.Cardano.Proto.OutPoint.create({ + txHash: utxo.tx_hash, + outputIndex: utxo.output_index, + }), + address: utxo.address, + amount: utxo.amount, + tokenAmount: null + }) + ); + + const input = { + transferMessage: transfer, + utxos: utxos, + ttl: new Long(req.ttl), + }; + return this.TW.Cardano.Proto.SigningInput.encode(input).finish(); + } + + buildCardanoUnsignedMessage(txInput: Uint8Array): Uint8Array { + const preimage = this.preImageHashes(this.CoinType.cardano, txInput); + const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage) + return out.dataHash + } + + buildCosmosUnsignedTx(jsonStr: string): Uint8Array { + const req = JSON.parse(jsonStr); + + const message = this.TW.Cosmos.Proto.Message.create({ + sendCoinsMessage: this.TW.Cosmos.Proto.Message.Send.create({ + fromAddress: req.fromAddress, + toAddress: req.toAddress, + amounts: [ + this.TW.Cosmos.Proto.Amount.create({ + denom: req.denom, + amount: req.amount, + }), + ] + }) + }); + + const input = { + chainId: req.chainId, + accountNumber: req.accountNumber, + sequence: req.sequence, + messages: [message], + memo: req.memo, + publicKey: this.HexCoding.decode(req.publicKey), + fee: this.TW.Cosmos.Proto.Fee.create({ + gas: req.gas, + amounts: [ + this.TW.Cosmos.Proto.Amount.create({ + denom: req.gasDenom, + amount: req.gasAmount, + }) + ] + }) + }; + return this.TW.Cosmos.Proto.SigningInput.encode(input).finish(); + } + + buildCosmosUnsignedMessage(txInput: Uint8Array): Uint8Array { + const preimage = this.preImageHashes(this.CoinType.cosmos, txInput); + const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage) + return out.dataHash + } + + buildNearUnsignedTx(jsonStr: string): Uint8Array { + const req = JSON.parse(jsonStr); + + const action = this.TW.NEAR.Proto.Action.create({ + transfer: this.TW.NEAR.Proto.Transfer.create({ + deposit: this.HexCoding.decode(req.transferAmount) + }) + }) + + const input = { + signerId: req.signerId, + nonce: Long.fromString(String(req.nonce)), + receiverId: req.receiverId, + blockHash: this.HexCoding.decode(req.blockHash), + actions: [action], + publicKey: this.HexCoding.decode(req.publicKey), + }; + return this.TW.NEAR.Proto.SigningInput.encode(input).finish(); + } + + buildNearUnsignedMessage(txInput: Uint8Array): Uint8Array { + const preimage = this.preImageHashes(this.CoinType.near, txInput); + const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage) + return out.dataHash + } + + buildStellarUnsignedTx(jsonStr: string): Uint8Array { + const req = JSON.parse(jsonStr); + + const opPayment = TW.Stellar.Proto.OperationPayment.create({ + destination: req.destination, + amount: Long.fromString(String(req.amount)), + }) + const memoText = this.TW.Stellar.Proto.MemoText.create({ + text: req.memoText + }) + const input = { + fee : req.fee, + account: req.account, + passphrase: 'Public Global Stellar Network ; September 2015', + sequence: Long.fromString(String(req.sequence)), + opPayment: opPayment, + memoText: memoText + }; + return this.TW.Stellar.Proto.SigningInput.encode(input).finish(); + } + + buildStellarUnsignedMessage(txInput: Uint8Array): Uint8Array { + const preimage = this.preImageHashes(this.CoinType.stellar, txInput); + const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage) + return out.dataHash + } + + marshalInput(input: protobuf.Writer): Uint8Array { + return input.finish(); + } + + +} \ No newline at end of file diff --git a/wasmjs/test/tw.test.ts b/wasmjs/test/tw.test.ts new file mode 100644 index 00000000000..82ee8c45013 --- /dev/null +++ b/wasmjs/test/tw.test.ts @@ -0,0 +1,191 @@ +import { describe, it, expect, beforeAll } from 'vitest'; +import { WalletCoreWrapper, initWasm } from "../src"; +import Long from "long"; + +let wallet: WalletCoreWrapper; + +beforeAll(async () => { + const core = await initWasm(); + wallet = await new WalletCoreWrapper(core); +}); + +describe("Aptos", () => { + it("compile signature", async () => { + const jsonString = JSON.stringify({ + chainId: 33, + sender: "0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30", + sequenceNumber: 99, + ttl: 3664390082, + maxGasAmount: 3296766, + gasUnitPrice: 100, + toAddress: "0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30", + amount: 1000 + }); + + const inputBytes = wallet.buildAptosUnsignedTx(jsonString); + + const preimageHash = wallet.preImageHashes(wallet.CoinType.aptos, inputBytes); + expect(preimageHash.length).toBeGreaterThan(0); + + let sigHash = wallet.buildAptosUnsignedMessage(inputBytes) + console.log('sigHash raw:', (sigHash)) + + const sigHex = '5707246db31e2335edc4316a7a656a11691d1d1647f6e864d1ab12f43428aaaf806cf02120d0b608cdd89c5c904af7b137432aacdd60cc53f9fad7bd33578e01'; + const pubHex = 'ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c'; + + const signingOutput = wallet.compileWithSignatures( + wallet.CoinType.aptos, + inputBytes, + [sigHex], + [pubHex] + ); + const decoded = wallet.TW.Aptos.Proto.SigningOutput.decode(signingOutput); + expect(decoded.encoded.length).toBeGreaterThan(0); + }); + + it("test sign aptos", async () => { + const txInput = wallet.TW.Aptos.Proto.SigningInput.create({ + chainId: 33, + sender: "0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30", + transfer: wallet.TW.Aptos.Proto.TransferMessage.create({ + amount: new Long(1000), + to: "0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f30" + }), + sequenceNumber: new Long(99), + expirationTimestampSecs: new Long(3664390082), + gasUnitPrice: new Long(100), + maxGasAmount: new Long(3296766), + privateKey: wallet.createWithData("0x5d996aa76b3212142792d9130796cd2e11e3c445a93118c08414df4f66bc60ec") + }); + + const inputBytes = wallet.TW.Aptos.Proto.SigningInput.encode(txInput).finish(); + const signed = wallet.anySign(inputBytes, wallet.CoinType.aptos); + const decoded = wallet.TW.Aptos.Proto.SigningOutput.decode(signed); + + expect(wallet.encodeHex(decoded.encoded)).to.equal( + "0x07968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f3063000000000000000200000000000000000000000000000000000000000000000000000000000000010d6170746f735f6163636f756e74087472616e7366657200022007968dab936c1bad187c60ce4082f307d030d780e91e694ae03aef16aba73f3008e803000000000000fe4d3200000000006400000000000000c2276ada00000000210020ea526ba1710343d953461ff68641f1b7df5f23b9042ffa2d2a798d3adb3f3d6c405707246db31e2335edc4316a7a656a11691d1d1647f6e864d1ab12f43428aaaf806cf02120d0b608cdd89c5c904af7b137432aacdd60cc53f9fad7bd33578e01" + ); + }); +}); + +describe("Cardano", () => { + it("compile signature", async () => { + const jsonString = '{\"address\":\"\",\"toAddress\":\"addr1q90uh2eawrdc9vaemftgd50l28yrh9lqxtjjh4z6dnn0u7ggasexxdyyk9f05atygnjlccsjsggtc87hhqjna32fpv5qeq96ls\",\"changeAddress\":\"addr1qx55ymlqemndq8gluv40v58pu76a2tp4mzjnyx8n6zrp2vtzrs43a0057y0edkn8lh9su8vh5lnhs4npv6l9tuvncv8swc7t08\",\"amount\":3000000,\"ttl\":190000000,\"utxos\":[{\"tx_hash\":\"gxblAH1h+5BlLKu0EUGXKji1vGCVTWAs+ENHaqP2f2M=\",\"output_index\":0,\"address\":\"Ae2tdPwUPEZ6vkqxSjJxaQYmDxHf5DTnxtZ67pFLJGTb9LTnCGkDP6ca3f8\",\"amount\":2500000},{\"tx_hash\":\"4pOSxZyQP++5BXMFh9IsrovaML2Nmu7D7KCCrndnWUY=\",\"output_index\":0,\"address\":\"Ae2tdPwUPEZ6vkqxSjJxaQYmDxHf5DTnxtZ67pFLJGTb9LTnCGkDP6ca3f8\",\"amount\":1700000}]}'; + const inputBytes = wallet.buildCardanoUnsignedTx(jsonString); + + const preimageHash = wallet.preImageHashes(wallet.CoinType.cardano, inputBytes); + expect(preimageHash.length).toBeGreaterThan(0); + + let sigHash = wallet.buildCardanoUnsignedMessage(inputBytes) + console.log('sigHash raw:', (sigHash)) + + const sigHex = '6a23ab9267867fbf021c1cb2232bc83d2cdd663d651d22d59b6cddbca5cb106d4db99da50672f69a2309ca8a329a3f9576438afe4538b013de4591a6dfcd4d09'; + const pubHex = 'd163c8c4f0be7c22cd3a1152abb013c855ea614b92201497a568c5d93ceeb41ea7f484aa383806735c46fd769c679ee41f8952952036a6e2338ada940b8a91f40b5aaa6103dc10842894a1eeefc5447b9bcb9bcf227d77e57be195d17bc03263d46f19d0fbf75afb0b9a24e31d533f4fd74cee3b56e162568e8defe37123afc4'; + + const signingOutput = wallet.compileWithSignatures( + wallet.CoinType.cardano, + inputBytes, + [sigHex], + [pubHex] + ); + const decoded = wallet.TW.Cardano.Proto.SigningOutput.decode(signingOutput); + expect(decoded.encoded.length).toBeGreaterThan(0); + const txencoded = wallet.encodeHex(decoded.encoded) + expect(txencoded).to.equal("0x83a400828258208316e5007d61fb90652cabb41141972a38b5bc60954d602cf843476aa3f67f6300825820e29392c59c903fefb905730587d22cae8bda30bd8d9aeec3eca082ae77675946000182825839015fcbab3d70db82b3b9da5686d1ff51c83b97e032e52bd45a6ce6fe7908ec32633484b152fa756444e5fc62128210bc1fd7b8253ec5490b281a002dc6c082583901a9426fe0cee6d01d1fe32af650e1e7b5d52c35d8a53218f3d0861531621c2b1ebdf4f11f96da67fdcb0e1d97a7e778566166be55f193c30f1a000f9ec1021a0002b0bf031a0b532b80a20081825820d163c8c4f0be7c22cd3a1152abb013c855ea614b92201497a568c5d93ceeb41e58406a23ab9267867fbf021c1cb2232bc83d2cdd663d651d22d59b6cddbca5cb106d4db99da50672f69a2309ca8a329a3f9576438afe4538b013de4591a6dfcd4d090281845820d163c8c4f0be7c22cd3a1152abb013c855ea614b92201497a568c5d93ceeb41e58406a23ab9267867fbf021c1cb2232bc83d2cdd663d651d22d59b6cddbca5cb106d4db99da50672f69a2309ca8a329a3f9576438afe4538b013de4591a6dfcd4d095820a7f484aa383806735c46fd769c679ee41f8952952036a6e2338ada940b8a91f441a0f6") + }) +}) + +describe("Cosmos", () => { + it("compile signature", async () => { + const jsonString = "{\"chainId\":\"cosmoshub-4\",\"fromAddress\":\"cosmos1mky69cn8ektwy0845vec9upsdphktxt03gkwlx\",\"toAddress\":\"cosmos18s0hdnsllgcclweu9aymw4ngktr2k0rkygdzdp\",\"amount\":\"400000\",\"denom\":\"uatom\",\"memo\":\"\",\"gas\":200000,\"gasAmount\":\"1000\",\"gasDenom\":\"uatom\",\"publicKey\":\"02ecef5ce437a302c67f95468de4b31f36e911f467d7e6a52b41c1e13e1d563649\",\"accountNumber\":546179,\"sequence\":0}"; + + const inputBytes = wallet.buildCosmosUnsignedTx(jsonString); + console.log('Inputbytes:', inputBytes) + + const preimageHash = wallet.preImageHashes(wallet.CoinType.cosmos, inputBytes); + expect(preimageHash.length).toBeGreaterThan(0); + + let sigHash = wallet.buildCosmosUnsignedMessage(inputBytes) + console.log('sigHash raw:', wallet.encodeHex(sigHash)) + + const sigHex = 'afbd513a776f4fdf470ef7f9675f21ae9d630fc4d635d8dbaa0dc0a716434cd07e02510765d4673dfa880825bae8e67cb367396ff6b976fc6b19a31fc95e8097'; + const pubHex = '02ecef5ce437a302c67f95468de4b31f36e911f467d7e6a52b41c1e13e1d563649'; + + const signingOutput = wallet.compileWithSignatures( + wallet.CoinType.cosmos, + inputBytes, + [sigHex], + [pubHex] + ); + const decoded = wallet.TW.Cosmos.Proto.SigningOutput.decode(signingOutput); + console.log(decoded) + expect(decoded.json.length).toBeGreaterThan(0); + }) +}) + +describe("NEAR", () => { + it("compile signature", async () => { + const jsonStr = "{\"signerId\":\"test.near\",\"nonce\":1,\"receiverId\":\"whatever.near\",\"blockHash\":\"0fa473fd26901df296be6adc4cc4df34d040efa2435224b6986910e630c2fef6\",\"publicKey\":\"917b3d268d4b58f7fec1b150bd68d69be3ee5d4cc39855e341538465bb77860d\",\"transferAmount\":\"01000000000000000000000000000000\"}"; + + const inputBytes = wallet.buildNearUnsignedTx(jsonStr); + + const preimageHash = wallet.preImageHashes(wallet.CoinType.near, inputBytes); + expect(preimageHash.length).toBeGreaterThan(0); + + let sigHash = wallet.buildNearUnsignedMessage(inputBytes) + + const sigHex = '969a83332186ee9755e4839325525806e189a3d2d2bb4b4760e94443e97e1c4f22deeef0059a8e9713100eda6e19144da7e8a0ef7e539b20708ba1d8d021bd01'; + const pubHex = '917b3d268d4b58f7fec1b150bd68d69be3ee5d4cc39855e341538465bb77860d'; + + const signingOutput = wallet.compileWithSignatures( + wallet.CoinType.near, + inputBytes, + [sigHex], + [pubHex] + ); + const decoded = wallet.TW.NEAR.Proto.SigningOutput.decode(signingOutput); + expect(decoded.signedTransaction.length).toBeGreaterThan(0); + }) +}) + +describe("Stellar", () => { + it("compile signature", async () => { + const obj = { + account: "GAE2SZV4VLGBAPRYRFV2VY7YYLYGYIP5I7OU7BSP6DJT7GAZ35OKFDYI", + fee: 1000, + sequence: 2, + destination: "GDCYBNRRPIHLHG7X7TKPUPAZ7WVUXCN3VO7WCCK64RIFV5XM5V5K4A52", + memoText: "Hello, world!", + amount: 10000000, + estimationMode: 8 + }; + const jsonStr = JSON.stringify(obj) + + const inputBytes = wallet.buildStellarUnsignedTx(jsonStr); + console.log('Inputbytes:', inputBytes.length) + console.log('Inputbytes:', wallet.encodeHex(inputBytes)) + + const preimageHash = wallet.preImageHashes(wallet.CoinType.stellar, inputBytes); + expect(preimageHash.length).toBeGreaterThan(0); + console.log('preimageHash raw:', wallet.encodeHex(preimageHash)) + + let sigHash = wallet.buildStellarUnsignedMessage(inputBytes) + console.log('sigHash raw:', wallet.encodeHex(sigHash)) + + const sigHex = '5042574491827aaccbce1e2964c05098caba06194beb35e595aabfec9f788516a833f755f18144f4a2eedb3123d180f44e7c16037d00857c5c5b7033ebac2c01'; + const pubHex = '09a966bcaacc103e38896baae3f8c2f06c21fd47dd4f864ff0d33f9819df5ca2'; + + const signingOutput = wallet.compileWithSignatures( + wallet.CoinType.stellar, + inputBytes, + [sigHex], + [pubHex] + ); + const decoded = wallet.TW.Stellar.Proto.SigningOutput.decode(signingOutput); + console.log(decoded) + expect(decoded.signature.length).toBeGreaterThan(0); + + const expectedRawTx = "AAAAAAmpZryqzBA+OIlrquP4wvBsIf1H3U+GT/DTP5gZ31yiAAAD6AAAAAAAAAACAAAAAAAAAAEAAAANSGVsbG8sIHdvcmxkIQAAAAAAAAEAAAAAAAAAAQAAAADFgLYxeg6zm/f81Po8Gf2rS4m7q79hCV7kUFr27O16rgAAAAAAAAAAAJiWgAAAAAAAAAABGd9cogAAAEBQQldEkYJ6rMvOHilkwFCYyroGGUvrNeWVqr/sn3iFFqgz91XxgUT0ou7bMSPRgPROfBYDfQCFfFxbcDPrrCwB" + expect(expectedRawTx).to.equal(decoded.signature) + }) +}) \ No newline at end of file diff --git a/wasmjs/tsconfig.json b/wasmjs/tsconfig.json new file mode 100644 index 00000000000..35147c5d66c --- /dev/null +++ b/wasmjs/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "ESNext", + "moduleResolution": "Bundler", // or "NodeNext" + "esModuleInterop": true, + "strict": true, + "skipLibCheck": true, + "outDir": "dist", + }, + "include": ["src", "test"] +} diff --git a/wrapper/go-wrapper/core/coin.go b/wrapper/go-wrapper/core/coin.go index 4cb9b46f90b..d6f11b62df9 100644 --- a/wrapper/go-wrapper/core/coin.go +++ b/wrapper/go-wrapper/core/coin.go @@ -11,18 +11,19 @@ import "github.com/Cramiumlabs/wallet-core/wrapper/go-wrapper/types" type CoinType uint32 const ( - CoinTypeBitcoin CoinType = C.TWCoinTypeBitcoin - CoinTypeBinance CoinType = C.TWCoinTypeBinance - CoinTypeEthereum CoinType = C.TWCoinTypeEthereum - CoinTypeTron CoinType = C.TWCoinTypeTron - CoinTypeCardano CoinType = C.TWCoinTypeCardano - CoinTypeLitecoin CoinType = C.TWCoinTypeLitecoin - CoinTypeDogecoin CoinType = C.TWCoinTypeDogecoin - CoinTypeCosmos CoinType = C.TWCoinTypeCosmos - CoinTypeAptos CoinType = C.TWCoinTypeAptos - CoinTypeNEAR CoinType = C.TWCoinTypeNEAR - CoinTypeICP CoinType = C.TWCoinTypeInternetComputer - CoinTypeStellar CoinType = C.TWCoinTypeStellar + CoinTypeBitcoin CoinType = C.TWCoinTypeBitcoin + CoinTypeBinance CoinType = C.TWCoinTypeBinance + CoinTypeEthereum CoinType = C.TWCoinTypeEthereum + CoinTypeTron CoinType = C.TWCoinTypeTron + CoinTypeCardano CoinType = C.TWCoinTypeCardano + CoinTypeLitecoin CoinType = C.TWCoinTypeLitecoin + CoinTypeDogecoin CoinType = C.TWCoinTypeDogecoin + CoinTypeCosmos CoinType = C.TWCoinTypeCosmos + CoinTypeAptos CoinType = C.TWCoinTypeAptos + CoinTypeNEAR CoinType = C.TWCoinTypeNEAR + CoinTypeICP CoinType = C.TWCoinTypeInternetComputer + CoinTypeStellar CoinType = C.TWCoinTypeStellar + CoinTypeBitcoinCash CoinType = C.TWCoinTypeBitcoinCash ) func (c CoinType) GetName() string { diff --git a/wrapper/go-wrapper/main.go b/wrapper/go-wrapper/main.go index 55948ab8a10..16b71d64021 100644 --- a/wrapper/go-wrapper/main.go +++ b/wrapper/go-wrapper/main.go @@ -57,6 +57,7 @@ func main() { sample.TestAptos() sample.TestICP() sample.TestStellar() + sample.TestBitcoinCash() } func createEthTransaction(ew *core.Wallet) string { diff --git a/wrapper/go-wrapper/sample/bitcoincash.go b/wrapper/go-wrapper/sample/bitcoincash.go new file mode 100644 index 00000000000..77ca8a1a212 --- /dev/null +++ b/wrapper/go-wrapper/sample/bitcoincash.go @@ -0,0 +1,76 @@ +package sample + +import ( + "encoding/hex" + "errors" + "fmt" + + "github.com/Cramiumlabs/wallet-core/wrapper/go-wrapper/core" + "github.com/Cramiumlabs/wallet-core/wrapper/go-wrapper/protos/bitcoin" + "google.golang.org/protobuf/proto" +) + +func TestBitcoinCash() { + // https://blockchair.com/bitcoin-cash/transaction/96ee20002b34e468f9d3c5ee54f6a8ddaa61c118889c4f35395c2cd93ba5bbb4 + + Address := "bitcoincash:qzhlrcrcne07x94h99thved2pgzdtv8ccujjy73xya" + input := &bitcoin.SigningInput{ + HashType: uint32(core.BitcoinSigHashTypeAll), + Amount: 600, + ByteFee: 1, + ToAddress: "1Bp9U1ogV3A14FMvKbRJms7ctyso4Z4Tcx", + ChangeAddress: "1FQc5LdgGHMHEN9nwkjmz6tWkxhPpxBvBU", + } + + utxoHash, err := hex.DecodeString("e28c2b955293159898e34c6840d99bf4d390e2ee1c6f606939f18ee1e2000d05") + if err != nil { + panic(err) + } + fmt.Println("utxoHash", utxoHash) + + lockScript := core.BitcoinScriptLockScriptForAddress(Address, core.CoinType(core.CoinTypeBitcoinCash)) + fmt.Println("lockScript", hex.EncodeToString(lockScript)) + + input.Utxo = make([]*bitcoin.UnspentTransaction, 1) + utxo := &bitcoin.UnspentTransaction{ + OutPoint: &bitcoin.OutPoint{ + Hash: utxoHash, + Index: 2, + Sequence: 4294967295, + }, + Amount: 5151, + Script: lockScript, + } + input.Utxo[0] = utxo + + txInputData, err := proto.Marshal(input) + if err != nil { + panic(err) + } + msgForSign := core.PreImageHashes(core.CoinTypeBitcoinCash, txInputData) + if msgForSign == nil || len(msgForSign) == 0 { + panic(err) + } + + var preSigningOutput bitcoin.PreSigningOutput + proto.Unmarshal(msgForSign, &preSigningOutput) + fmt.Println("preSigningOutput:", hex.EncodeToString(preSigningOutput.HashPublicKeys[0].DataHash)) + if len(preSigningOutput.HashPublicKeys) == 0 || len(preSigningOutput.HashPublicKeys[0].DataHash) == 0 { + panic(fmt.Errorf("Invalid transaction input: no data for signing")) + } + + signature, _ := hex.DecodeString("304402204c8506e96808b672fce2a0c2ee958f9fa1e9b39fbb62741efb9857e77daa94f102202f560e3c05d215e6b397b5dd49df289bbdbbb7d80faea31bc37f20f6aa92b88d") + pubkey, _ := hex.DecodeString("038eab72ec78e639d02758e7860cdec018b49498c307791f785aa3019622f4ea5b") + + txOutput := core.CompileWithSignatures(core.CoinType(core.CoinTypeBitcoinCash), txInputData, [][]byte{signature}, [][]byte{pubkey}) + + var output bitcoin.SigningOutput + proto.Unmarshal(txOutput, &output) + fmt.Println("input", input) + fmt.Println("Output:", hex.EncodeToString(output.Encoded)) + + valid := core.PublicKeyVerifyAsDER(pubkey, core.PublicKeyTypeSECP256k1, signature, preSigningOutput.HashPublicKeys[0].DataHash) + if !valid { + panic(errors.New("verification failed")) + } +}