Skip to content

Commit

Permalink
Merge pull request #21 from nobitex/debug/proper_struct_order_for_mint
Browse files Browse the repository at this point in the history
[DEBUG] fix struct order for mint funciton
  • Loading branch information
toolabi authored Mar 10, 2024
2 parents ae9505a + f1a286b commit 005a795
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions commands/mint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@

import json


class MintContext:
src_burn_addr: str
dst_addr: str
encrypted: bool
priv_fee_payer: str

def __init__(self, src_burn_addr: str, dst_addr: str, encrypted: bool, priv_fee_payer: str):
def __init__(
self, src_burn_addr: str, dst_addr: str, encrypted: bool, priv_fee_payer: str
):
self.src_burn_addr = src_burn_addr
self.dst_addr = dst_addr
self.encrypted = encrypted
Expand Down Expand Up @@ -43,37 +46,43 @@ def mint_cmd(network: Network, context: MintContext):
proof = w3.eth.get_proof(burn_addr.address, [], block_number)

(prefix, state_root, postfix) = get_block_splited_information(block)
(layers, root_proof, mid_proofs, last_proof) = get_proof_of_burn(burn_addr, coin.salt.val, context.encrypted, block, proof)
(layers, root_proof, mid_proofs, last_proof) = get_proof_of_burn(
burn_addr, coin.salt.val, context.encrypted, block, proof
)

target = context.dst_addr

contract_feed = [
block_number,
coin.get_value(),
nullifier,
layers,
root_proof,
mid_proofs,
last_proof,
context.encrypted,
target,
prefix,
state_root,
layers,
mid_proofs,
prefix,
postfix,
]

contract = w3.eth.contract(address=network.burnth_contract_addr, abi=json.load(open("abis/Burnth.abi")))
contract = w3.eth.contract(
address=network.burnth_contract_addr, abi=json.load(open("abis/Burnth.abi"))
)
address = w3.eth.account.from_key(context.priv_fee_payer).address
nonce = w3.eth.get_transaction_count(address)
gas_price = w3.eth.gas_price

txn = contract.functions.mint(contract_feed).build_transaction({
'chainId': network.chain_id,
'gas': 7000000,
"maxFeePerGas": gas_price,
"maxPriorityFeePerGas": gas_price // 2,
'nonce': nonce,
})
txn = contract.functions.mint(contract_feed).build_transaction(
{
"chainId": network.chain_id,
"gas": 7000000,
"maxFeePerGas": gas_price,
"maxPriorityFeePerGas": gas_price // 2,
"nonce": nonce,
}
)

signed = w3.eth.account.sign_transaction(txn, context.priv_fee_payer)
tx_hash = w3.eth.send_raw_transaction(signed.rawTransaction)
Expand Down

0 comments on commit 005a795

Please sign in to comment.