const getBalanceClick = async () => {
//Call getBalance method
const balanceObj = await getBalance(clientId);
console.log("balanceObj", balanceObj);
console.log("balance", balanceObj?.balance);
setBalance(balanceObj?.balance || 0);
};
const getBalanceWasmClick = async () => {
//Call getBalance method on Wasm
const balanceObj = await getBalanceWasm(clientId);
console.log("balanceObj", balanceObj);
console.log("balance", balanceObj?.zcn);
setBalance(balanceObj?.zcn || 0);
};
const createWalletClick = async () => {
console.log("calling createWallet");
const wallet = await createWallet();
console.log("Wallet", wallet);
setClientId(wallet.keys.walletId);
setPublicKey(wallet.keys.publicKey);
setPrivateKey(wallet.keys.privateKey);
};
const recoverWalletClick = async () => {
console.log("calling recoverWallet");
const wallet = await recoverWallet(mnemonic);
console.log("Wallet", wallet);
setClientId(wallet.keys.walletId);
setPublicKey(wallet.keys.publicKey);
setPrivateKey(wallet.keys.privateKey);
};
const getFaucetTokenClick = async () => {
console.log("calling getFaucetToken");
await getFaucetToken();
};
const sendTransactionClick = async () => {
console.log("calling sendTransaction");
const fromWallet = {
id: clientId,
public_key: publicKey,
secretKey: privateKey,
};
await sendTransaction(fromWallet, sendTo, parseInt(sendAmount), "");
};
const setWalletClick = async () => {
console.log("calling set wallet");
//Call setWallet method
await setWallet(clientId, privateKey, publicKey, mnemonic);
};
const getUSDRateClick = async () => {
console.log("getUSDRate");
const rate = await getUSDRate("zcn");
console.log("getUSDRate completed", rate);
setOutput(rate);
};
const isWalletIDClick = async () => {
console.log("isWalletID");
const output = await isWalletID(clientId);
//const output = await isWalletID("abc");
console.log("isWalletID completed", output);
setOutput("" + output);
};
const getPublicEncryptionKeyClick = async () => {
console.log("getPublicEncryptionKey");
const key = await getPublicEncryptionKey(mnemonic);
console.log("getPublicEncryptionKey completed", key);
setEncryptKey(key);
};
const initBridgeClick = async () => {
const ethereumAddress = "0x5B9eb7E72247c45F6c4B8424FB2002151c57c54d",
bridgeAddress = "0x2405e40161ea6da91AE0e95061e7A8462b4D5eEa",
authorizersAddress = "0xB132C20A02AD7C38d88805F0e3fFDdfb54224C58",
wzcnAddress = "0x10140fbca3a468A1c35F132D75659eF0EB5d95DB",
ethereumNodeURL =
"https://goerli.infura.io/v3/6141be73a15d47748af0dc14f53d57d7",
gasLimit = 300000,
value = 0,
consensusThreshold = 75.0;
console.log(
"initBridgeClick",
ethereumAddress,
bridgeAddress,
authorizersAddress,
wzcnAddress,
ethereumNodeURL,
gasLimit,
value,
consensusThreshold
);
//Call initBridge method
await initBridge(
ethereumAddress,
bridgeAddress,
authorizersAddress,
wzcnAddress,
ethereumNodeURL,
gasLimit,
value,
consensusThreshold
);
};
const burnZCNClick = async () => {
const amount = 1000;
console.log("burnZCNClick", amount);
const hash = await burnZCN(amount);
setTxHash(hash);
return hash;
};
const mintZCNClick = async () => {
const burnTrxHash = txHash,
timeout = 100;
console.log("mintZCNClick", burnTrxHash, timeout);
const hash = await mintZCN(burnTrxHash, timeout);
return hash;
};
const getMintWZCNPayloadClick = async () => {
const burnTrxHash = txHash;
console.log("getMintWZCNPayloadClick", burnTrxHash);
const result = await getMintWZCNPayload(burnTrxHash);
return result;
};