diff --git a/bundler/wasm.d.ts b/bundler/wasm.d.ts index 13b0affe..427a4a7d 100644 --- a/bundler/wasm.d.ts +++ b/bundler/wasm.d.ts @@ -951,9 +951,10 @@ export class TransactionBuilder { * @param am: amount to pay * @param kp: owner's XfrKeyPair * @param {XfrKeyPair} kp +* @param {string | undefined} memo * @returns {TransactionBuilder} */ - add_fee_relative_auto(kp: XfrKeyPair): TransactionBuilder; + add_fee_relative_auto(kp: XfrKeyPair, memo?: string): TransactionBuilder; /** * Use this func to get the necessary infomations for generating `Relative Inputs` * @@ -966,9 +967,10 @@ export class TransactionBuilder { * As the last operation of any transaction, * add a static fee to the transaction. * @param {FeeInputs} inputs +* @param {string | undefined} memo * @returns {TransactionBuilder} */ - add_fee(inputs: FeeInputs): TransactionBuilder; + add_fee(inputs: FeeInputs, memo?: string): TransactionBuilder; /** * A simple fee checker for mainnet v1.0. * @@ -1214,9 +1216,10 @@ export class TransferOperationBuilder { * @param {string} code * @param {boolean} conf_amount * @param {boolean} conf_type +* @param {string | undefined} memo * @returns {TransferOperationBuilder} */ - add_output_with_tracing(amount: bigint, recipient: XfrPublicKey, tracing_policies: TracingPolicies, code: string, conf_amount: boolean, conf_type: boolean): TransferOperationBuilder; + add_output_with_tracing(amount: bigint, recipient: XfrPublicKey, tracing_policies: TracingPolicies, code: string, conf_amount: boolean, conf_type: boolean, memo?: string): TransferOperationBuilder; /** * Wraps around TransferOperationBuilder to add an output to a transfer operation builder. * @@ -1231,9 +1234,10 @@ export class TransferOperationBuilder { * @param {string} code * @param {boolean} conf_amount * @param {boolean} conf_type +* @param {string | undefined} memo * @returns {TransferOperationBuilder} */ - add_output_no_tracing(amount: bigint, recipient: XfrPublicKey, code: string, conf_amount: boolean, conf_type: boolean): TransferOperationBuilder; + add_output_no_tracing(amount: bigint, recipient: XfrPublicKey, code: string, conf_amount: boolean, conf_type: boolean, memo?: string): TransferOperationBuilder; /** * Wraps around TransferOperationBuilder to ensure the transfer inputs and outputs are balanced. * This function will add change outputs for all unspent portions of input records. diff --git a/bundler/wasm_bg.js b/bundler/wasm_bg.js index e9900329..eb565aae 100644 --- a/bundler/wasm_bg.js +++ b/bundler/wasm_bg.js @@ -2762,15 +2762,18 @@ export class TransactionBuilder { * @param am: amount to pay * @param kp: owner's XfrKeyPair * @param {XfrKeyPair} kp + * @param {string | undefined} memo * @returns {TransactionBuilder} */ - add_fee_relative_auto(kp) { + add_fee_relative_auto(kp, memo) { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertClass(kp, XfrKeyPair); var ptr0 = kp.__destroy_into_raw(); - wasm.transactionbuilder_add_fee_relative_auto(retptr, ptr, ptr0); + var ptr1 = isLikeNone(memo) ? 0 : passStringToWasm0(memo, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.transactionbuilder_add_fee_relative_auto(retptr, ptr, ptr0, ptr1, len1); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; @@ -2806,15 +2809,18 @@ export class TransactionBuilder { * As the last operation of any transaction, * add a static fee to the transaction. * @param {FeeInputs} inputs + * @param {string | undefined} memo * @returns {TransactionBuilder} */ - add_fee(inputs) { + add_fee(inputs, memo) { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertClass(inputs, FeeInputs); var ptr0 = inputs.__destroy_into_raw(); - wasm.transactionbuilder_add_fee(retptr, ptr, ptr0); + var ptr1 = isLikeNone(memo) ? 0 : passStringToWasm0(memo, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.transactionbuilder_add_fee(retptr, ptr, ptr0, ptr1, len1); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; @@ -3434,9 +3440,10 @@ export class TransferOperationBuilder { * @param {string} code * @param {boolean} conf_amount * @param {boolean} conf_type + * @param {string | undefined} memo * @returns {TransferOperationBuilder} */ - add_output_with_tracing(amount, recipient, tracing_policies, code, conf_amount, conf_type) { + add_output_with_tracing(amount, recipient, tracing_policies, code, conf_amount, conf_type, memo) { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); @@ -3444,7 +3451,9 @@ export class TransferOperationBuilder { _assertClass(tracing_policies, TracingPolicies); const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; - wasm.transferoperationbuilder_add_output_with_tracing(retptr, ptr, amount, recipient.ptr, tracing_policies.ptr, ptr0, len0, conf_amount, conf_type); + var ptr1 = isLikeNone(memo) ? 0 : passStringToWasm0(memo, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.transferoperationbuilder_add_output_with_tracing(retptr, ptr, amount, recipient.ptr, tracing_policies.ptr, ptr0, len0, conf_amount, conf_type, ptr1, len1); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; @@ -3470,16 +3479,19 @@ export class TransferOperationBuilder { * @param {string} code * @param {boolean} conf_amount * @param {boolean} conf_type + * @param {string | undefined} memo * @returns {TransferOperationBuilder} */ - add_output_no_tracing(amount, recipient, code, conf_amount, conf_type) { + add_output_no_tracing(amount, recipient, code, conf_amount, conf_type, memo) { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertClass(recipient, XfrPublicKey); const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; - wasm.transferoperationbuilder_add_output_no_tracing(retptr, ptr, amount, recipient.ptr, ptr0, len0, conf_amount, conf_type); + var ptr1 = isLikeNone(memo) ? 0 : passStringToWasm0(memo, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.transferoperationbuilder_add_output_no_tracing(retptr, ptr, amount, recipient.ptr, ptr0, len0, conf_amount, conf_type, ptr1, len1); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; @@ -3838,7 +3850,7 @@ export function __wbindgen_object_clone_ref(arg0) { return addHeapObject(ret); }; -export function __wbg_crypto_58f13aa23ffcb166(arg0) { +export function __wbg_crypto_d05b68a3572bb8ca(arg0) { const ret = getObject(arg0).crypto; return addHeapObject(ret); }; @@ -3849,17 +3861,17 @@ export function __wbindgen_is_object(arg0) { return ret; }; -export function __wbg_process_5b786e71d465a513(arg0) { +export function __wbg_process_b02b3570280d0366(arg0) { const ret = getObject(arg0).process; return addHeapObject(ret); }; -export function __wbg_versions_c2ab80650590b6a2(arg0) { +export function __wbg_versions_c1cb42213cedf0f5(arg0) { const ret = getObject(arg0).versions; return addHeapObject(ret); }; -export function __wbg_node_523d7bd03ef69fba(arg0) { +export function __wbg_node_43b1089f407e4ec2(arg0) { const ret = getObject(arg0).node; return addHeapObject(ret); }; @@ -3869,12 +3881,12 @@ export function __wbindgen_is_string(arg0) { return ret; }; -export function __wbg_msCrypto_abcb1295e768d1f2(arg0) { +export function __wbg_msCrypto_10fc94afee92bd76(arg0) { const ret = getObject(arg0).msCrypto; return addHeapObject(ret); }; -export function __wbg_require_2784e593a4674877() { return handleError(function () { +export function __wbg_require_9a7e0f667ead4995() { return handleError(function () { const ret = module.require; return addHeapObject(ret); }, arguments) }; @@ -3884,11 +3896,11 @@ export function __wbindgen_is_function(arg0) { return ret; }; -export function __wbg_randomFillSync_a0d98aa11c81fe89() { return handleError(function (arg0, arg1) { +export function __wbg_randomFillSync_b70ccbdf4926a99d() { return handleError(function (arg0, arg1) { getObject(arg0).randomFillSync(takeObject(arg1)); }, arguments) }; -export function __wbg_getRandomValues_504510b5564925af() { return handleError(function (arg0, arg1) { +export function __wbg_getRandomValues_7e42b4fb8779dc6d() { return handleError(function (arg0, arg1) { getObject(arg0).getRandomValues(getObject(arg1)); }, arguments) }; diff --git a/bundler/wasm_bg.wasm b/bundler/wasm_bg.wasm index 9a95689e..50a7a7d2 100644 Binary files a/bundler/wasm_bg.wasm and b/bundler/wasm_bg.wasm differ diff --git a/bundler/wasm_bg.wasm.d.ts b/bundler/wasm_bg.wasm.d.ts index 68d73814..2d2a48fa 100644 --- a/bundler/wasm_bg.wasm.d.ts +++ b/bundler/wasm_bg.wasm.d.ts @@ -12,9 +12,9 @@ export function __wbg_feeinputs_free(a: number): void; export function feeinputs_new(): number; export function feeinputs_append(a: number, b: number, c: number, d: number, e: number, f: number): void; export function feeinputs_append2(a: number, b: number, c: number, d: number, e: number, f: number): number; -export function transactionbuilder_add_fee_relative_auto(a: number, b: number, c: number): void; +export function transactionbuilder_add_fee_relative_auto(a: number, b: number, c: number, d: number, e: number): void; export function transactionbuilder_get_relative_outputs(a: number, b: number): void; -export function transactionbuilder_add_fee(a: number, b: number, c: number): void; +export function transactionbuilder_add_fee(a: number, b: number, c: number, d: number, e: number): void; export function transactionbuilder_check_fee(a: number): number; export function transactionbuilder_new(a: number): number; export function transactionbuilder_add_operation_create_asset(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; @@ -43,8 +43,8 @@ export function __wbg_transferoperationbuilder_free(a: number): void; export function transferoperationbuilder_new(): number; export function transferoperationbuilder_add_input_with_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; export function transferoperationbuilder_add_input_no_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; -export function transferoperationbuilder_add_output_with_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number): void; -export function transferoperationbuilder_add_output_no_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; +export function transferoperationbuilder_add_output_with_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number): void; +export function transferoperationbuilder_add_output_no_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): void; export function transferoperationbuilder_balance(a: number, b: number): void; export function transferoperationbuilder_create(a: number, b: number): void; export function transferoperationbuilder_sign(a: number, b: number, c: number): void; @@ -85,13 +85,13 @@ export function restore_keypair_from_mnemonic_default(a: number, b: number, c: n export function restore_keypair_from_mnemonic_bip44(a: number, b: number, c: number, d: number, e: number, f: number): void; export function restore_keypair_from_mnemonic_bip49(a: number, b: number, c: number, d: number, e: number, f: number): void; export function fra_get_asset_code(a: number): void; +export function fra_get_minimal_fee(): number; export function fra_get_dest_pubkey(): number; export function get_coinbase_address(a: number): void; -export function get_delegation_target_address(a: number): void; -export function get_coinbase_principal_address(a: number): void; -export function fra_get_minimal_fee(): number; export function get_delegation_min_amount(): number; export function get_delegation_max_amount(): number; +export function get_delegation_target_address(a: number): void; +export function get_coinbase_principal_address(a: number): void; export function __wbg_publicparams_free(a: number): void; export function publicparams_new(): number; export function __wbg_txoref_free(a: number): void; @@ -149,22 +149,22 @@ export function assetrules_set_decimals(a: number, b: number, c: number): void; export function __wbg_credentialsignature_free(a: number): void; export function __wbg_xpublickey_free(a: number): void; export function __wbg_xsecretkey_free(a: number): void; -export function __wbg_blsg2_free(a: number): void; export function __wbg_blsscalar_free(a: number): void; -export function __wbg_blsg1_free(a: number): void; +export function __wbg_blsg2_free(a: number): void; export function __wbg_secp256k1g1_free(a: number): void; -export function __wbg_jubjubscalar_free(a: number): void; +export function __wbg_zorroscalar_free(a: number): void; export function __wbg_zorrog1_free(a: number): void; export function __wbg_ed25519scalar_free(a: number): void; +export function __wbg_blsgt_free(a: number): void; +export function __wbg_ed25519point_free(a: number): void; +export function __wbg_blsg1_free(a: number): void; export function __wbg_zorrofq_free(a: number): void; -export function __wbg_secq256k1g1_free(a: number): void; -export function __wbg_zorroscalar_free(a: number): void; -export function __wbg_secq256k1scalar_free(a: number): void; export function __wbg_secp256k1scalar_free(a: number): void; export function __wbg_blsfq_free(a: number): void; -export function __wbg_blsgt_free(a: number): void; -export function __wbg_ed25519point_free(a: number): void; -export function ring_core_0_17_6_bn_mul_mont(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function __wbg_secq256k1scalar_free(a: number): void; +export function __wbg_secq256k1g1_free(a: number): void; +export function __wbg_jubjubscalar_free(a: number): void; +export function ring_core_0_17_8_bn_mul_mont(a: number, b: number, c: number, d: number, e: number, f: number): void; export function __wbg_credissuersecretkey_free(a: number): void; export function __wbg_credissuerpublickey_free(a: number): void; export function __wbg_creduserpublickey_free(a: number): void; diff --git a/demo.js b/demo.js new file mode 100644 index 00000000..3e480f37 --- /dev/null +++ b/demo.js @@ -0,0 +1,42 @@ +// Call 'wasm-pack build --target nodejs' to build from this directory for this command to work +const wasm = require('./wasm.js'); +const axios = require('axios'); + +let kp_sender = wasm.restore_keypair_from_mnemonic_default("zoo nerve assault talk depend approve mercy surge bicycle ridge dismiss satoshi boring opera next fat cinnamon valley office actor above spray alcohol giant"); +//console.log("sender:", wasm.public_key_to_base64(kp_sender.pub_key)); +let kp_reveicer = wasm.new_keypair(); +//console.log("reveicer:",wasm.keypair_to_str(kp_reveicer)); + +let utxo = JSON.parse('{"id":null,"record":{"amount":{"NonConfidential":"47489623119996"},"asset_type":{"NonConfidential":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},"public_key":"HZnxwPI5PD_xpQX1NqKTHXqPdHXVXtGe7yQ0JI3MVTs="}}'); +let fee_pub_key = wasm.public_key_from_base64("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="); +let transfer_op = wasm.TransferOperationBuilder.new() + .add_input_no_tracing(wasm.TxoRef.absolute(57314n), wasm.ClientAssetRecord.from_json(utxo), null, kp_sender, 1000n) + .add_output_no_tracing(10000n, fee_pub_key, wasm.fra_get_asset_code(), false, false, null) + //.add_output_no_tracing(1n, kp_reveicer.pub_key, wasm.fra_get_asset_code(), false, false, '{"p":"brc-20","op":"deploy","tick":"ordi","max":"21000000","lim":"1000"}') + //.add_output_no_tracing(1n, kp_reveicer.pub_key, wasm.fra_get_asset_code(), false, false, '{"p":"brc-20","op":"mint","tick":"ordi","amt":"1000"}') + .add_output_no_tracing(1n, kp_reveicer.pub_key, wasm.fra_get_asset_code(), false, false, '{"p":"brc-20","op":"transfer","tick":"ordi","amt":"1000"}') + .add_output_no_tracing(47489623109995n, kp_sender.pub_key, wasm.fra_get_asset_code(), false, false, null) + .create() + .sign(kp_sender) + .transaction(); + +let seq_id = 19121n; +let asset_rules = wasm.AssetRules.new(); +let tx =wasm.TransactionBuilder.new(seq_id).add_transfer_operation(transfer_op) + .sign(kp_sender) + .transaction(); +//console.log(tx) + +const stringToHex = (str) => { + let hex = ''; + for (let i = 0; i < str.length; i++) { + const charCode = str.charCodeAt(i); + const hexValue = charCode.toString(16); + + // Pad with zeros to ensure two-digit representation + hex += hexValue.padStart(2, '0'); + } + return hex; +}; + +console.log(stringToHex(tx)); diff --git a/nodejs/wasm.d.ts b/nodejs/wasm.d.ts index 13b0affe..427a4a7d 100644 --- a/nodejs/wasm.d.ts +++ b/nodejs/wasm.d.ts @@ -951,9 +951,10 @@ export class TransactionBuilder { * @param am: amount to pay * @param kp: owner's XfrKeyPair * @param {XfrKeyPair} kp +* @param {string | undefined} memo * @returns {TransactionBuilder} */ - add_fee_relative_auto(kp: XfrKeyPair): TransactionBuilder; + add_fee_relative_auto(kp: XfrKeyPair, memo?: string): TransactionBuilder; /** * Use this func to get the necessary infomations for generating `Relative Inputs` * @@ -966,9 +967,10 @@ export class TransactionBuilder { * As the last operation of any transaction, * add a static fee to the transaction. * @param {FeeInputs} inputs +* @param {string | undefined} memo * @returns {TransactionBuilder} */ - add_fee(inputs: FeeInputs): TransactionBuilder; + add_fee(inputs: FeeInputs, memo?: string): TransactionBuilder; /** * A simple fee checker for mainnet v1.0. * @@ -1214,9 +1216,10 @@ export class TransferOperationBuilder { * @param {string} code * @param {boolean} conf_amount * @param {boolean} conf_type +* @param {string | undefined} memo * @returns {TransferOperationBuilder} */ - add_output_with_tracing(amount: bigint, recipient: XfrPublicKey, tracing_policies: TracingPolicies, code: string, conf_amount: boolean, conf_type: boolean): TransferOperationBuilder; + add_output_with_tracing(amount: bigint, recipient: XfrPublicKey, tracing_policies: TracingPolicies, code: string, conf_amount: boolean, conf_type: boolean, memo?: string): TransferOperationBuilder; /** * Wraps around TransferOperationBuilder to add an output to a transfer operation builder. * @@ -1231,9 +1234,10 @@ export class TransferOperationBuilder { * @param {string} code * @param {boolean} conf_amount * @param {boolean} conf_type +* @param {string | undefined} memo * @returns {TransferOperationBuilder} */ - add_output_no_tracing(amount: bigint, recipient: XfrPublicKey, code: string, conf_amount: boolean, conf_type: boolean): TransferOperationBuilder; + add_output_no_tracing(amount: bigint, recipient: XfrPublicKey, code: string, conf_amount: boolean, conf_type: boolean, memo?: string): TransferOperationBuilder; /** * Wraps around TransferOperationBuilder to ensure the transfer inputs and outputs are balanced. * This function will add change outputs for all unspent portions of input records. diff --git a/nodejs/wasm.js b/nodejs/wasm.js index fc76159d..3a06823b 100644 --- a/nodejs/wasm.js +++ b/nodejs/wasm.js @@ -2794,15 +2794,18 @@ class TransactionBuilder { * @param am: amount to pay * @param kp: owner's XfrKeyPair * @param {XfrKeyPair} kp + * @param {string | undefined} memo * @returns {TransactionBuilder} */ - add_fee_relative_auto(kp) { + add_fee_relative_auto(kp, memo) { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertClass(kp, XfrKeyPair); var ptr0 = kp.__destroy_into_raw(); - wasm.transactionbuilder_add_fee_relative_auto(retptr, ptr, ptr0); + var ptr1 = isLikeNone(memo) ? 0 : passStringToWasm0(memo, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.transactionbuilder_add_fee_relative_auto(retptr, ptr, ptr0, ptr1, len1); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; @@ -2838,15 +2841,18 @@ class TransactionBuilder { * As the last operation of any transaction, * add a static fee to the transaction. * @param {FeeInputs} inputs + * @param {string | undefined} memo * @returns {TransactionBuilder} */ - add_fee(inputs) { + add_fee(inputs, memo) { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertClass(inputs, FeeInputs); var ptr0 = inputs.__destroy_into_raw(); - wasm.transactionbuilder_add_fee(retptr, ptr, ptr0); + var ptr1 = isLikeNone(memo) ? 0 : passStringToWasm0(memo, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.transactionbuilder_add_fee(retptr, ptr, ptr0, ptr1, len1); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; @@ -3467,9 +3473,10 @@ class TransferOperationBuilder { * @param {string} code * @param {boolean} conf_amount * @param {boolean} conf_type + * @param {string | undefined} memo * @returns {TransferOperationBuilder} */ - add_output_with_tracing(amount, recipient, tracing_policies, code, conf_amount, conf_type) { + add_output_with_tracing(amount, recipient, tracing_policies, code, conf_amount, conf_type, memo) { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); @@ -3477,7 +3484,9 @@ class TransferOperationBuilder { _assertClass(tracing_policies, TracingPolicies); const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; - wasm.transferoperationbuilder_add_output_with_tracing(retptr, ptr, amount, recipient.ptr, tracing_policies.ptr, ptr0, len0, conf_amount, conf_type); + var ptr1 = isLikeNone(memo) ? 0 : passStringToWasm0(memo, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.transferoperationbuilder_add_output_with_tracing(retptr, ptr, amount, recipient.ptr, tracing_policies.ptr, ptr0, len0, conf_amount, conf_type, ptr1, len1); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; @@ -3503,16 +3512,19 @@ class TransferOperationBuilder { * @param {string} code * @param {boolean} conf_amount * @param {boolean} conf_type + * @param {string | undefined} memo * @returns {TransferOperationBuilder} */ - add_output_no_tracing(amount, recipient, code, conf_amount, conf_type) { + add_output_no_tracing(amount, recipient, code, conf_amount, conf_type, memo) { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertClass(recipient, XfrPublicKey); const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; - wasm.transferoperationbuilder_add_output_no_tracing(retptr, ptr, amount, recipient.ptr, ptr0, len0, conf_amount, conf_type); + var ptr1 = isLikeNone(memo) ? 0 : passStringToWasm0(memo, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.transferoperationbuilder_add_output_no_tracing(retptr, ptr, amount, recipient.ptr, ptr0, len0, conf_amount, conf_type, ptr1, len1); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; @@ -3880,7 +3892,7 @@ module.exports.__wbindgen_object_clone_ref = function(arg0) { return addHeapObject(ret); }; -module.exports.__wbg_crypto_58f13aa23ffcb166 = function(arg0) { +module.exports.__wbg_crypto_d05b68a3572bb8ca = function(arg0) { const ret = getObject(arg0).crypto; return addHeapObject(ret); }; @@ -3891,17 +3903,17 @@ module.exports.__wbindgen_is_object = function(arg0) { return ret; }; -module.exports.__wbg_process_5b786e71d465a513 = function(arg0) { +module.exports.__wbg_process_b02b3570280d0366 = function(arg0) { const ret = getObject(arg0).process; return addHeapObject(ret); }; -module.exports.__wbg_versions_c2ab80650590b6a2 = function(arg0) { +module.exports.__wbg_versions_c1cb42213cedf0f5 = function(arg0) { const ret = getObject(arg0).versions; return addHeapObject(ret); }; -module.exports.__wbg_node_523d7bd03ef69fba = function(arg0) { +module.exports.__wbg_node_43b1089f407e4ec2 = function(arg0) { const ret = getObject(arg0).node; return addHeapObject(ret); }; @@ -3911,12 +3923,12 @@ module.exports.__wbindgen_is_string = function(arg0) { return ret; }; -module.exports.__wbg_msCrypto_abcb1295e768d1f2 = function(arg0) { +module.exports.__wbg_msCrypto_10fc94afee92bd76 = function(arg0) { const ret = getObject(arg0).msCrypto; return addHeapObject(ret); }; -module.exports.__wbg_require_2784e593a4674877 = function() { return handleError(function () { +module.exports.__wbg_require_9a7e0f667ead4995 = function() { return handleError(function () { const ret = module.require; return addHeapObject(ret); }, arguments) }; @@ -3926,11 +3938,11 @@ module.exports.__wbindgen_is_function = function(arg0) { return ret; }; -module.exports.__wbg_randomFillSync_a0d98aa11c81fe89 = function() { return handleError(function (arg0, arg1) { +module.exports.__wbg_randomFillSync_b70ccbdf4926a99d = function() { return handleError(function (arg0, arg1) { getObject(arg0).randomFillSync(takeObject(arg1)); }, arguments) }; -module.exports.__wbg_getRandomValues_504510b5564925af = function() { return handleError(function (arg0, arg1) { +module.exports.__wbg_getRandomValues_7e42b4fb8779dc6d = function() { return handleError(function (arg0, arg1) { getObject(arg0).getRandomValues(getObject(arg1)); }, arguments) }; diff --git a/nodejs/wasm_bg.wasm b/nodejs/wasm_bg.wasm index 2fa9ac98..2b39d762 100644 Binary files a/nodejs/wasm_bg.wasm and b/nodejs/wasm_bg.wasm differ diff --git a/nodejs/wasm_bg.wasm.d.ts b/nodejs/wasm_bg.wasm.d.ts index 68d73814..2d2a48fa 100644 --- a/nodejs/wasm_bg.wasm.d.ts +++ b/nodejs/wasm_bg.wasm.d.ts @@ -12,9 +12,9 @@ export function __wbg_feeinputs_free(a: number): void; export function feeinputs_new(): number; export function feeinputs_append(a: number, b: number, c: number, d: number, e: number, f: number): void; export function feeinputs_append2(a: number, b: number, c: number, d: number, e: number, f: number): number; -export function transactionbuilder_add_fee_relative_auto(a: number, b: number, c: number): void; +export function transactionbuilder_add_fee_relative_auto(a: number, b: number, c: number, d: number, e: number): void; export function transactionbuilder_get_relative_outputs(a: number, b: number): void; -export function transactionbuilder_add_fee(a: number, b: number, c: number): void; +export function transactionbuilder_add_fee(a: number, b: number, c: number, d: number, e: number): void; export function transactionbuilder_check_fee(a: number): number; export function transactionbuilder_new(a: number): number; export function transactionbuilder_add_operation_create_asset(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; @@ -43,8 +43,8 @@ export function __wbg_transferoperationbuilder_free(a: number): void; export function transferoperationbuilder_new(): number; export function transferoperationbuilder_add_input_with_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; export function transferoperationbuilder_add_input_no_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; -export function transferoperationbuilder_add_output_with_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number): void; -export function transferoperationbuilder_add_output_no_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; +export function transferoperationbuilder_add_output_with_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number): void; +export function transferoperationbuilder_add_output_no_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): void; export function transferoperationbuilder_balance(a: number, b: number): void; export function transferoperationbuilder_create(a: number, b: number): void; export function transferoperationbuilder_sign(a: number, b: number, c: number): void; @@ -85,13 +85,13 @@ export function restore_keypair_from_mnemonic_default(a: number, b: number, c: n export function restore_keypair_from_mnemonic_bip44(a: number, b: number, c: number, d: number, e: number, f: number): void; export function restore_keypair_from_mnemonic_bip49(a: number, b: number, c: number, d: number, e: number, f: number): void; export function fra_get_asset_code(a: number): void; +export function fra_get_minimal_fee(): number; export function fra_get_dest_pubkey(): number; export function get_coinbase_address(a: number): void; -export function get_delegation_target_address(a: number): void; -export function get_coinbase_principal_address(a: number): void; -export function fra_get_minimal_fee(): number; export function get_delegation_min_amount(): number; export function get_delegation_max_amount(): number; +export function get_delegation_target_address(a: number): void; +export function get_coinbase_principal_address(a: number): void; export function __wbg_publicparams_free(a: number): void; export function publicparams_new(): number; export function __wbg_txoref_free(a: number): void; @@ -149,22 +149,22 @@ export function assetrules_set_decimals(a: number, b: number, c: number): void; export function __wbg_credentialsignature_free(a: number): void; export function __wbg_xpublickey_free(a: number): void; export function __wbg_xsecretkey_free(a: number): void; -export function __wbg_blsg2_free(a: number): void; export function __wbg_blsscalar_free(a: number): void; -export function __wbg_blsg1_free(a: number): void; +export function __wbg_blsg2_free(a: number): void; export function __wbg_secp256k1g1_free(a: number): void; -export function __wbg_jubjubscalar_free(a: number): void; +export function __wbg_zorroscalar_free(a: number): void; export function __wbg_zorrog1_free(a: number): void; export function __wbg_ed25519scalar_free(a: number): void; +export function __wbg_blsgt_free(a: number): void; +export function __wbg_ed25519point_free(a: number): void; +export function __wbg_blsg1_free(a: number): void; export function __wbg_zorrofq_free(a: number): void; -export function __wbg_secq256k1g1_free(a: number): void; -export function __wbg_zorroscalar_free(a: number): void; -export function __wbg_secq256k1scalar_free(a: number): void; export function __wbg_secp256k1scalar_free(a: number): void; export function __wbg_blsfq_free(a: number): void; -export function __wbg_blsgt_free(a: number): void; -export function __wbg_ed25519point_free(a: number): void; -export function ring_core_0_17_6_bn_mul_mont(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function __wbg_secq256k1scalar_free(a: number): void; +export function __wbg_secq256k1g1_free(a: number): void; +export function __wbg_jubjubscalar_free(a: number): void; +export function ring_core_0_17_8_bn_mul_mont(a: number, b: number, c: number, d: number, e: number, f: number): void; export function __wbg_credissuersecretkey_free(a: number): void; export function __wbg_credissuerpublickey_free(a: number): void; export function __wbg_creduserpublickey_free(a: number): void; diff --git a/send_tx.rs b/send_tx.rs new file mode 100644 index 00000000..64168012 --- /dev/null +++ b/send_tx.rs @@ -0,0 +1,25 @@ +use sha2::{Digest, Sha256}; + +fn main() { + let tx = "7b22626f6479223a7b226e6f5f7265706c61795f746f6b656e223a5b5b3131302c3230372c33332c3138362c3235342c3134372c3138362c3133375d2c31393132315d2c226f7065726174696f6e73223a5b7b225472616e736665724173736574223a7b22626f6479223a7b22696e70757473223a5b7b224162736f6c757465223a35373331347d5d2c22706f6c6963696573223a7b2276616c6964223a747275652c22696e707574735f74726163696e675f706f6c6963696573223a5b5b5d5d2c22696e707574735f7369675f636f6d6d69746d656e7473223a5b6e756c6c5d2c226f7574707574735f74726163696e675f706f6c6963696573223a5b5b5d2c5b5d2c5b5d5d2c226f7574707574735f7369675f636f6d6d69746d656e7473223a5b6e756c6c2c6e756c6c2c6e756c6c5d7d2c226f757470757473223a5b7b226964223a6e756c6c2c227265636f7264223a7b22616d6f756e74223a7b224e6f6e436f6e666964656e7469616c223a223130303030227d2c2261737365745f74797065223a7b224e6f6e436f6e666964656e7469616c223a5b302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c305d7d2c227075626c69635f6b6579223a22414141414141414141414141414141414141414141414141414141414141414141414141414141414141413d227d7d2c7b226964223a6e756c6c2c227265636f7264223a7b22616d6f756e74223a7b224e6f6e436f6e666964656e7469616c223a2231227d2c2261737365745f74797065223a7b224e6f6e436f6e666964656e7469616c223a5b302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c305d7d2c227075626c69635f6b6579223a226c30517567744e554b47443533574b6646364271364548457550775a63526e45766e5f5047343852336a673d227d2c226d656d6f223a227b5c22705c223a5c226272632d32305c222c5c226f705c223a5c227472616e736665725c222c5c227469636b5c223a5c226f7264695c222c5c22616d745c223a5c22313030305c227d227d2c7b226964223a6e756c6c2c227265636f7264223a7b22616d6f756e74223a7b224e6f6e436f6e666964656e7469616c223a223437343839363233313039393935227d2c2261737365745f74797065223a7b224e6f6e436f6e666964656e7469616c223a5b302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c305d7d2c227075626c69635f6b6579223a22485a6e787750493550445f78705158314e714b54485871506448585658744765377951304a49334d5654733d227d7d5d2c227472616e73666572223a7b22696e70757473223a5b7b22616d6f756e74223a7b224e6f6e436f6e666964656e7469616c223a223437343839363233313139393936227d2c2261737365745f74797065223a7b224e6f6e436f6e666964656e7469616c223a5b302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c305d7d2c227075626c69635f6b6579223a22485a6e787750493550445f78705158314e714b54485871506448585658744765377951304a49334d5654733d227d5d2c226f757470757473223a5b7b22616d6f756e74223a7b224e6f6e436f6e666964656e7469616c223a223130303030227d2c2261737365745f74797065223a7b224e6f6e436f6e666964656e7469616c223a5b302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c305d7d2c227075626c69635f6b6579223a22414141414141414141414141414141414141414141414141414141414141414141414141414141414141413d227d2c7b22616d6f756e74223a7b224e6f6e436f6e666964656e7469616c223a2231227d2c2261737365745f74797065223a7b224e6f6e436f6e666964656e7469616c223a5b302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c305d7d2c227075626c69635f6b6579223a226c30517567744e554b47443533574b6646364271364548457550775a63526e45766e5f5047343852336a673d227d2c7b22616d6f756e74223a7b224e6f6e436f6e666964656e7469616c223a223437343839363233313039393935227d2c2261737365745f74797065223a7b224e6f6e436f6e666964656e7469616c223a5b302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c302c305d7d2c227075626c69635f6b6579223a22485a6e787750493550445f78705158314e714b54485871506448585658744765377951304a49334d5654733d227d5d2c2270726f6f6673223a7b2261737365745f747970655f616e645f616d6f756e745f70726f6f66223a224e6f50726f6f66222c2261737365745f74726163696e675f70726f6f66223a7b2261737365745f747970655f616e645f616d6f756e745f70726f6f6673223a5b5d2c22696e707574735f6964656e746974795f70726f6f6673223a5b5b5d5d2c226f7574707574735f6964656e746974795f70726f6f6673223a5b5b5d2c5b5d2c5b5d5d7d7d2c2261737365745f74726163696e675f6d656d6f73223a5b5b5d2c5b5d2c5b5d2c5b5d5d2c226f776e6572735f6d656d6f73223a5b6e756c6c2c6e756c6c2c6e756c6c5d7d2c227472616e736665725f74797065223a225374616e64617264227d2c22626f64795f7369676e617475726573223a5b7b2261646472657373223a7b226b6579223a22485a6e787750493550445f78705158314e714b54485871506448585658744765377951304a49334d5654733d227d2c227369676e6174757265223a22594e2d473466437258334b5938614d464a78734e6a654b6135527266396c79584861453975773876583877455f557575706633736a6b67477530347573334e574f6d6f4167733042317a32624a31636f7356396344513d3d227d5d7d7d5d7d2c227075626b65795f7369676e5f6d6170223a7b22485a6e787750493550445f78705158314e714b54485871506448585658744765377951304a49334d5654733d223a2261556f7775334b7462634d446b4539592d4b6673646859617467596852613367475833774464505a595337394847634a6d617a6d567134337669384d6561584e4c446944333268324165716f4c506a31554c713742773d3d227d7d"; + let tx_bytes = hex::decode(tx.strip_prefix("0x").unwrap_or(tx)).unwrap(); + let url = "https://prod-testnet.prod.findora.org:26657"; + let txn_b64 = base64::encode_config(&tx_bytes, base64::URL_SAFE); + + let json_rpc = + format!( + "{{\"jsonrpc\":\"2.0\",\"id\":\"anything\",\"method\":\"broadcast_tx_sync\",\"params\": {{\"tx\": \"{}\"}}}}", + &txn_b64 + ); + + attohttpc::post(url) + .header(attohttpc::header::CONTENT_TYPE, "application/json") + .text(json_rpc) + .send() + .and_then(|v| v.error_for_status()) + .map(|v| println!("{:?}", v)) + .unwrap(); + + let tx_hash = Sha256::digest(tx_bytes); + println!("{}", hex::encode(tx_hash)); +} diff --git a/web/wasm.d.ts b/web/wasm.d.ts index d25c7959..3b4e50ca 100644 --- a/web/wasm.d.ts +++ b/web/wasm.d.ts @@ -951,9 +951,10 @@ export class TransactionBuilder { * @param am: amount to pay * @param kp: owner's XfrKeyPair * @param {XfrKeyPair} kp +* @param {string | undefined} memo * @returns {TransactionBuilder} */ - add_fee_relative_auto(kp: XfrKeyPair): TransactionBuilder; + add_fee_relative_auto(kp: XfrKeyPair, memo?: string): TransactionBuilder; /** * Use this func to get the necessary infomations for generating `Relative Inputs` * @@ -966,9 +967,10 @@ export class TransactionBuilder { * As the last operation of any transaction, * add a static fee to the transaction. * @param {FeeInputs} inputs +* @param {string | undefined} memo * @returns {TransactionBuilder} */ - add_fee(inputs: FeeInputs): TransactionBuilder; + add_fee(inputs: FeeInputs, memo?: string): TransactionBuilder; /** * A simple fee checker for mainnet v1.0. * @@ -1214,9 +1216,10 @@ export class TransferOperationBuilder { * @param {string} code * @param {boolean} conf_amount * @param {boolean} conf_type +* @param {string | undefined} memo * @returns {TransferOperationBuilder} */ - add_output_with_tracing(amount: bigint, recipient: XfrPublicKey, tracing_policies: TracingPolicies, code: string, conf_amount: boolean, conf_type: boolean): TransferOperationBuilder; + add_output_with_tracing(amount: bigint, recipient: XfrPublicKey, tracing_policies: TracingPolicies, code: string, conf_amount: boolean, conf_type: boolean, memo?: string): TransferOperationBuilder; /** * Wraps around TransferOperationBuilder to add an output to a transfer operation builder. * @@ -1231,9 +1234,10 @@ export class TransferOperationBuilder { * @param {string} code * @param {boolean} conf_amount * @param {boolean} conf_type +* @param {string | undefined} memo * @returns {TransferOperationBuilder} */ - add_output_no_tracing(amount: bigint, recipient: XfrPublicKey, code: string, conf_amount: boolean, conf_type: boolean): TransferOperationBuilder; + add_output_no_tracing(amount: bigint, recipient: XfrPublicKey, code: string, conf_amount: boolean, conf_type: boolean, memo?: string): TransferOperationBuilder; /** * Wraps around TransferOperationBuilder to ensure the transfer inputs and outputs are balanced. * This function will add change outputs for all unspent portions of input records. @@ -1360,9 +1364,9 @@ export interface InitOutput { readonly feeinputs_new: () => number; readonly feeinputs_append: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly feeinputs_append2: (a: number, b: number, c: number, d: number, e: number, f: number) => number; - readonly transactionbuilder_add_fee_relative_auto: (a: number, b: number, c: number) => void; + readonly transactionbuilder_add_fee_relative_auto: (a: number, b: number, c: number, d: number, e: number) => void; readonly transactionbuilder_get_relative_outputs: (a: number, b: number) => void; - readonly transactionbuilder_add_fee: (a: number, b: number, c: number) => void; + readonly transactionbuilder_add_fee: (a: number, b: number, c: number, d: number, e: number) => void; readonly transactionbuilder_check_fee: (a: number) => number; readonly transactionbuilder_new: (a: number) => number; readonly transactionbuilder_add_operation_create_asset: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void; @@ -1391,8 +1395,8 @@ export interface InitOutput { readonly transferoperationbuilder_new: () => number; readonly transferoperationbuilder_add_input_with_tracing: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void; readonly transferoperationbuilder_add_input_no_tracing: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void; - readonly transferoperationbuilder_add_output_with_tracing: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void; - readonly transferoperationbuilder_add_output_no_tracing: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void; + readonly transferoperationbuilder_add_output_with_tracing: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void; + readonly transferoperationbuilder_add_output_no_tracing: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void; readonly transferoperationbuilder_balance: (a: number, b: number) => void; readonly transferoperationbuilder_create: (a: number, b: number) => void; readonly transferoperationbuilder_sign: (a: number, b: number, c: number) => void; @@ -1433,13 +1437,13 @@ export interface InitOutput { readonly restore_keypair_from_mnemonic_bip44: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly restore_keypair_from_mnemonic_bip49: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly fra_get_asset_code: (a: number) => void; + readonly fra_get_minimal_fee: () => number; readonly fra_get_dest_pubkey: () => number; readonly get_coinbase_address: (a: number) => void; - readonly get_delegation_target_address: (a: number) => void; - readonly get_coinbase_principal_address: (a: number) => void; - readonly fra_get_minimal_fee: () => number; readonly get_delegation_min_amount: () => number; readonly get_delegation_max_amount: () => number; + readonly get_delegation_target_address: (a: number) => void; + readonly get_coinbase_principal_address: (a: number) => void; readonly __wbg_publicparams_free: (a: number) => void; readonly publicparams_new: () => number; readonly __wbg_txoref_free: (a: number) => void; @@ -1497,22 +1501,22 @@ export interface InitOutput { readonly __wbg_credentialsignature_free: (a: number) => void; readonly __wbg_xpublickey_free: (a: number) => void; readonly __wbg_xsecretkey_free: (a: number) => void; - readonly __wbg_blsg2_free: (a: number) => void; readonly __wbg_blsscalar_free: (a: number) => void; - readonly __wbg_blsg1_free: (a: number) => void; + readonly __wbg_blsg2_free: (a: number) => void; readonly __wbg_secp256k1g1_free: (a: number) => void; - readonly __wbg_jubjubscalar_free: (a: number) => void; + readonly __wbg_zorroscalar_free: (a: number) => void; readonly __wbg_zorrog1_free: (a: number) => void; readonly __wbg_ed25519scalar_free: (a: number) => void; + readonly __wbg_blsgt_free: (a: number) => void; + readonly __wbg_ed25519point_free: (a: number) => void; + readonly __wbg_blsg1_free: (a: number) => void; readonly __wbg_zorrofq_free: (a: number) => void; - readonly __wbg_secq256k1g1_free: (a: number) => void; - readonly __wbg_zorroscalar_free: (a: number) => void; - readonly __wbg_secq256k1scalar_free: (a: number) => void; readonly __wbg_secp256k1scalar_free: (a: number) => void; readonly __wbg_blsfq_free: (a: number) => void; - readonly __wbg_blsgt_free: (a: number) => void; - readonly __wbg_ed25519point_free: (a: number) => void; - readonly ring_core_0_17_6_bn_mul_mont: (a: number, b: number, c: number, d: number, e: number, f: number) => void; + readonly __wbg_secq256k1scalar_free: (a: number) => void; + readonly __wbg_secq256k1g1_free: (a: number) => void; + readonly __wbg_jubjubscalar_free: (a: number) => void; + readonly ring_core_0_17_8_bn_mul_mont: (a: number, b: number, c: number, d: number, e: number, f: number) => void; readonly __wbg_credissuersecretkey_free: (a: number) => void; readonly __wbg_credissuerpublickey_free: (a: number) => void; readonly __wbg_creduserpublickey_free: (a: number) => void; diff --git a/web/wasm.js b/web/wasm.js index b5ef9f12..3905b26c 100644 --- a/web/wasm.js +++ b/web/wasm.js @@ -2754,15 +2754,18 @@ export class TransactionBuilder { * @param am: amount to pay * @param kp: owner's XfrKeyPair * @param {XfrKeyPair} kp + * @param {string | undefined} memo * @returns {TransactionBuilder} */ - add_fee_relative_auto(kp) { + add_fee_relative_auto(kp, memo) { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertClass(kp, XfrKeyPair); var ptr0 = kp.__destroy_into_raw(); - wasm.transactionbuilder_add_fee_relative_auto(retptr, ptr, ptr0); + var ptr1 = isLikeNone(memo) ? 0 : passStringToWasm0(memo, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.transactionbuilder_add_fee_relative_auto(retptr, ptr, ptr0, ptr1, len1); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; @@ -2798,15 +2801,18 @@ export class TransactionBuilder { * As the last operation of any transaction, * add a static fee to the transaction. * @param {FeeInputs} inputs + * @param {string | undefined} memo * @returns {TransactionBuilder} */ - add_fee(inputs) { + add_fee(inputs, memo) { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertClass(inputs, FeeInputs); var ptr0 = inputs.__destroy_into_raw(); - wasm.transactionbuilder_add_fee(retptr, ptr, ptr0); + var ptr1 = isLikeNone(memo) ? 0 : passStringToWasm0(memo, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.transactionbuilder_add_fee(retptr, ptr, ptr0, ptr1, len1); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; @@ -3426,9 +3432,10 @@ export class TransferOperationBuilder { * @param {string} code * @param {boolean} conf_amount * @param {boolean} conf_type + * @param {string | undefined} memo * @returns {TransferOperationBuilder} */ - add_output_with_tracing(amount, recipient, tracing_policies, code, conf_amount, conf_type) { + add_output_with_tracing(amount, recipient, tracing_policies, code, conf_amount, conf_type, memo) { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); @@ -3436,7 +3443,9 @@ export class TransferOperationBuilder { _assertClass(tracing_policies, TracingPolicies); const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; - wasm.transferoperationbuilder_add_output_with_tracing(retptr, ptr, amount, recipient.ptr, tracing_policies.ptr, ptr0, len0, conf_amount, conf_type); + var ptr1 = isLikeNone(memo) ? 0 : passStringToWasm0(memo, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.transferoperationbuilder_add_output_with_tracing(retptr, ptr, amount, recipient.ptr, tracing_policies.ptr, ptr0, len0, conf_amount, conf_type, ptr1, len1); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; @@ -3462,16 +3471,19 @@ export class TransferOperationBuilder { * @param {string} code * @param {boolean} conf_amount * @param {boolean} conf_type + * @param {string | undefined} memo * @returns {TransferOperationBuilder} */ - add_output_no_tracing(amount, recipient, code, conf_amount, conf_type) { + add_output_no_tracing(amount, recipient, code, conf_amount, conf_type, memo) { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertClass(recipient, XfrPublicKey); const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; - wasm.transferoperationbuilder_add_output_no_tracing(retptr, ptr, amount, recipient.ptr, ptr0, len0, conf_amount, conf_type); + var ptr1 = isLikeNone(memo) ? 0 : passStringToWasm0(memo, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.transferoperationbuilder_add_output_no_tracing(retptr, ptr, amount, recipient.ptr, ptr0, len0, conf_amount, conf_type, ptr1, len1); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var r2 = getInt32Memory0()[retptr / 4 + 2]; @@ -3858,7 +3870,7 @@ function getImports() { const ret = getObject(arg0); return addHeapObject(ret); }; - imports.wbg.__wbg_crypto_58f13aa23ffcb166 = function(arg0) { + imports.wbg.__wbg_crypto_d05b68a3572bb8ca = function(arg0) { const ret = getObject(arg0).crypto; return addHeapObject(ret); }; @@ -3867,15 +3879,15 @@ function getImports() { const ret = typeof(val) === 'object' && val !== null; return ret; }; - imports.wbg.__wbg_process_5b786e71d465a513 = function(arg0) { + imports.wbg.__wbg_process_b02b3570280d0366 = function(arg0) { const ret = getObject(arg0).process; return addHeapObject(ret); }; - imports.wbg.__wbg_versions_c2ab80650590b6a2 = function(arg0) { + imports.wbg.__wbg_versions_c1cb42213cedf0f5 = function(arg0) { const ret = getObject(arg0).versions; return addHeapObject(ret); }; - imports.wbg.__wbg_node_523d7bd03ef69fba = function(arg0) { + imports.wbg.__wbg_node_43b1089f407e4ec2 = function(arg0) { const ret = getObject(arg0).node; return addHeapObject(ret); }; @@ -3883,11 +3895,11 @@ function getImports() { const ret = typeof(getObject(arg0)) === 'string'; return ret; }; - imports.wbg.__wbg_msCrypto_abcb1295e768d1f2 = function(arg0) { + imports.wbg.__wbg_msCrypto_10fc94afee92bd76 = function(arg0) { const ret = getObject(arg0).msCrypto; return addHeapObject(ret); }; - imports.wbg.__wbg_require_2784e593a4674877 = function() { return handleError(function () { + imports.wbg.__wbg_require_9a7e0f667ead4995 = function() { return handleError(function () { const ret = module.require; return addHeapObject(ret); }, arguments) }; @@ -3895,10 +3907,10 @@ function getImports() { const ret = typeof(getObject(arg0)) === 'function'; return ret; }; - imports.wbg.__wbg_randomFillSync_a0d98aa11c81fe89 = function() { return handleError(function (arg0, arg1) { + imports.wbg.__wbg_randomFillSync_b70ccbdf4926a99d = function() { return handleError(function (arg0, arg1) { getObject(arg0).randomFillSync(takeObject(arg1)); }, arguments) }; - imports.wbg.__wbg_getRandomValues_504510b5564925af = function() { return handleError(function (arg0, arg1) { + imports.wbg.__wbg_getRandomValues_7e42b4fb8779dc6d = function() { return handleError(function (arg0, arg1) { getObject(arg0).getRandomValues(getObject(arg1)); }, arguments) }; imports.wbg.__wbg_self_7eede1f4488bf346 = function() { return handleError(function () { diff --git a/web/wasm_bg.wasm b/web/wasm_bg.wasm index 2c1ebb28..ca8eb599 100644 Binary files a/web/wasm_bg.wasm and b/web/wasm_bg.wasm differ diff --git a/web/wasm_bg.wasm.d.ts b/web/wasm_bg.wasm.d.ts index 68d73814..2d2a48fa 100644 --- a/web/wasm_bg.wasm.d.ts +++ b/web/wasm_bg.wasm.d.ts @@ -12,9 +12,9 @@ export function __wbg_feeinputs_free(a: number): void; export function feeinputs_new(): number; export function feeinputs_append(a: number, b: number, c: number, d: number, e: number, f: number): void; export function feeinputs_append2(a: number, b: number, c: number, d: number, e: number, f: number): number; -export function transactionbuilder_add_fee_relative_auto(a: number, b: number, c: number): void; +export function transactionbuilder_add_fee_relative_auto(a: number, b: number, c: number, d: number, e: number): void; export function transactionbuilder_get_relative_outputs(a: number, b: number): void; -export function transactionbuilder_add_fee(a: number, b: number, c: number): void; +export function transactionbuilder_add_fee(a: number, b: number, c: number, d: number, e: number): void; export function transactionbuilder_check_fee(a: number): number; export function transactionbuilder_new(a: number): number; export function transactionbuilder_add_operation_create_asset(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; @@ -43,8 +43,8 @@ export function __wbg_transferoperationbuilder_free(a: number): void; export function transferoperationbuilder_new(): number; export function transferoperationbuilder_add_input_with_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; export function transferoperationbuilder_add_input_no_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void; -export function transferoperationbuilder_add_output_with_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number): void; -export function transferoperationbuilder_add_output_no_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): void; +export function transferoperationbuilder_add_output_with_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number): void; +export function transferoperationbuilder_add_output_no_tracing(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): void; export function transferoperationbuilder_balance(a: number, b: number): void; export function transferoperationbuilder_create(a: number, b: number): void; export function transferoperationbuilder_sign(a: number, b: number, c: number): void; @@ -85,13 +85,13 @@ export function restore_keypair_from_mnemonic_default(a: number, b: number, c: n export function restore_keypair_from_mnemonic_bip44(a: number, b: number, c: number, d: number, e: number, f: number): void; export function restore_keypair_from_mnemonic_bip49(a: number, b: number, c: number, d: number, e: number, f: number): void; export function fra_get_asset_code(a: number): void; +export function fra_get_minimal_fee(): number; export function fra_get_dest_pubkey(): number; export function get_coinbase_address(a: number): void; -export function get_delegation_target_address(a: number): void; -export function get_coinbase_principal_address(a: number): void; -export function fra_get_minimal_fee(): number; export function get_delegation_min_amount(): number; export function get_delegation_max_amount(): number; +export function get_delegation_target_address(a: number): void; +export function get_coinbase_principal_address(a: number): void; export function __wbg_publicparams_free(a: number): void; export function publicparams_new(): number; export function __wbg_txoref_free(a: number): void; @@ -149,22 +149,22 @@ export function assetrules_set_decimals(a: number, b: number, c: number): void; export function __wbg_credentialsignature_free(a: number): void; export function __wbg_xpublickey_free(a: number): void; export function __wbg_xsecretkey_free(a: number): void; -export function __wbg_blsg2_free(a: number): void; export function __wbg_blsscalar_free(a: number): void; -export function __wbg_blsg1_free(a: number): void; +export function __wbg_blsg2_free(a: number): void; export function __wbg_secp256k1g1_free(a: number): void; -export function __wbg_jubjubscalar_free(a: number): void; +export function __wbg_zorroscalar_free(a: number): void; export function __wbg_zorrog1_free(a: number): void; export function __wbg_ed25519scalar_free(a: number): void; +export function __wbg_blsgt_free(a: number): void; +export function __wbg_ed25519point_free(a: number): void; +export function __wbg_blsg1_free(a: number): void; export function __wbg_zorrofq_free(a: number): void; -export function __wbg_secq256k1g1_free(a: number): void; -export function __wbg_zorroscalar_free(a: number): void; -export function __wbg_secq256k1scalar_free(a: number): void; export function __wbg_secp256k1scalar_free(a: number): void; export function __wbg_blsfq_free(a: number): void; -export function __wbg_blsgt_free(a: number): void; -export function __wbg_ed25519point_free(a: number): void; -export function ring_core_0_17_6_bn_mul_mont(a: number, b: number, c: number, d: number, e: number, f: number): void; +export function __wbg_secq256k1scalar_free(a: number): void; +export function __wbg_secq256k1g1_free(a: number): void; +export function __wbg_jubjubscalar_free(a: number): void; +export function ring_core_0_17_8_bn_mul_mont(a: number, b: number, c: number, d: number, e: number, f: number): void; export function __wbg_credissuersecretkey_free(a: number): void; export function __wbg_credissuerpublickey_free(a: number): void; export function __wbg_creduserpublickey_free(a: number): void;