Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update wasm files from main branch with manually created for brc20 #3

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions bundler/wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
*
Expand All @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand All @@ -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.
Expand Down
44 changes: 28 additions & 16 deletions bundler/wasm_bg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -3434,17 +3440,20 @@ 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);
_assertClass(recipient, XfrPublicKey);
_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];
Expand All @@ -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];
Expand Down Expand Up @@ -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);
};
Expand All @@ -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);
};
Expand All @@ -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) };
Expand All @@ -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) };

Expand Down
Binary file modified bundler/wasm_bg.wasm
Binary file not shown.
32 changes: 16 additions & 16 deletions bundler/wasm_bg.wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
42 changes: 42 additions & 0 deletions demo.js
Original file line number Diff line number Diff line change
@@ -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));
12 changes: 8 additions & 4 deletions nodejs/wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
*
Expand All @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand All @@ -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.
Expand Down
Loading