defining default values in makeTransaction function signature

This commit is contained in:
RcleydsonR 2022-11-22 08:35:24 -03:00
parent 15e5fed07b
commit 7256d59b49
2 changed files with 9 additions and 7 deletions

View File

@ -1,14 +1,14 @@
<script setup lang="ts">
import { storeToRefs } from "pinia";
import { useEtherStore } from "../store/ether";
import ethers from "../utils/ethers";
import blockchain from "../utils/blockchain";
const etherStore = useEtherStore();
const { walletAddress, balance } = storeToRefs(etherStore);
const connectMetaMask = () => {
ethers.connectProvider();
blockchain.connectProvider();
};
const formatWalletAddress = (): string => {
@ -22,7 +22,7 @@ const formatWalletAddress = (): string => {
};
const formatWalletBalance = (): string => {
const formattedBalance = ethers.formatEther(balance.value);
const formattedBalance = blockchain.formatEther(balance.value);
const fixed = formattedBalance.substring(0, 8);
return fixed;

View File

@ -42,7 +42,10 @@ const connectProvider = async () => {
});
};
const makeTransaction = async () => {
const makeTransaction = async (
receiverAccountAddress = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
ammount = "100.0"
) => {
const etherStore = useEtherStore();
const provider = getProvider();
if (!provider) return;
@ -50,10 +53,9 @@ const makeTransaction = async () => {
const signer = provider.getSigner();
const contract = new ethers.Contract(addresses.token, mockToken.abi, signer);
const fixedAccount1Address = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8";
const tx = await contract.transfer(
fixedAccount1Address,
ethers.utils.parseEther("100.0")
receiverAccountAddress,
ethers.utils.parseEther(ammount)
);
await tx.wait();