Skip to content

Commit

Permalink
fix: use signer.getAddress instead of signer.address (#161)
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
fadeev and coderabbitai[bot] authored Jul 12, 2024
1 parent 1cfaebb commit 0113af5
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion packages/client/src/deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export const deposit = async function (
} catch (e) {
throw new Error("Amount cannot be parsed.");
}
const balance = await contract.balanceOf(signer.address);
const signerAddress = await signer.getAddress();
const balance = await contract.balanceOf(signerAddress);
if (balance.lt(value)) {
throw new Error("Insufficient token balance.");
}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/sendZeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const sendZeta = async function (
await approveTx.wait();

const destinationChainId = this.getChains()[destination]?.chain_id;
const destinationAddress = recipient ? recipient : signer.address;
const destinationAddress = recipient;

return await connectorContract.send({
destinationAddress,
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const withdraw = async function (
recipient,
}: {
amount: string;
recipient?: string;
recipient: string;
zrc20: string;
}
) {
Expand All @@ -51,6 +51,6 @@ export const withdraw = async function (

await (await gasContract.connect(signer).approve(zrc20, gasFee)).wait();

const to = recipient ? recipient : signer.address;
const to = recipient;
return await targetContract.connect(signer).withdraw(to, value);
};
7 changes: 4 additions & 3 deletions packages/tasks/src/deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
Array.isArray(msg) &&
msg.length === 2 &&
Array.isArray(msg[0]) &&
msg[0].every((item: string) => typeof item === "string") &&
msg[1].every((item: string) => typeof item === "string")
msg[0].every((item: string) => typeof item === "string")
) {
message = JSON.parse(args.message);
} else {
Expand Down Expand Up @@ -107,14 +106,16 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
)?.symbol;
}

const signerAddress = await signer.getAddress();

if (args.json) {
const tx = await client.deposit(data);
console.log(JSON.stringify(tx, null, 2));
} else {
console.log(`
Networks: ${chain} → zeta_testnet
Amount sent: ${amount} ${symbol || ""}
Sender: ${signer.address}
Sender: ${signerAddress}
Recipient: ${args.recipient}`);
if (message) {
console.log(`Message: ${args.message}`);
Expand Down
5 changes: 3 additions & 2 deletions packages/tasks/src/sendZETA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const main = async (args: any, hre: any) => {
}

const { amount, destination } = args;
const recipient = args.recipient || signer.address;
const signerAddress = await signer.getAddress();
const recipient = args.recipient || signerAddress;
const chain = hre.network.name;

const data: any = {
Expand All @@ -57,7 +58,7 @@ Cross-chain fee: ${fee} ZETA
Amount received: ${(parseFloat(amount) - parseFloat(fee)).toFixed(
18
)} ZETA (estimated)
From address: ${signer.address}
From address: ${signerAddress}
To address: ${recipient}
`);

Expand Down
4 changes: 3 additions & 1 deletion packages/tasks/src/withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {

const client = new ZetaChainClient({ network: "testnet", signer });

const recipient = args.recipient || signer.address;
const signerAddress = await signer.getAddress();

const recipient = args.recipient || signerAddress;
const amount = args.amount;
const zrc20 = args.zrc20;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const _abi = [
] as const;

const _bytecode =
"0x60566050600b82828239805160001a6073146043577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220db9c0f1b135916f15772ca92fae45f42347adcdba0acca9f1f72dea8794c690664736f6c63430008070033";
"0x60566050600b82828239805160001a6073146043577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea2646970667358221220766c094da1789d965b537afc578d9d0e9a34b2290ca8a52d0bb141f2642765b964736f6c63430008070033";

type BytesHelperLibConstructorParams =
| [signer?: Signer]
Expand Down
2 changes: 1 addition & 1 deletion typechain-types/factories/contracts/TestZRC20__factory.ts

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 0113af5

Please sign in to comment.