Skip to content

Commit

Permalink
remove deposit and call logic from deposit handler
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Nov 12, 2024
1 parent e47cc0e commit de54f0f
Showing 1 changed file with 5 additions and 35 deletions.
40 changes: 5 additions & 35 deletions packages/localnet/src/handleOnEVMDeposited.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,41 +52,11 @@ export const handleOnEVMDeposited = async ({

const zrc20 = foreignCoin.zrc20_contract_address;
try {
const context = {
origin: ethers.ZeroAddress,
sender,
chainID: chainID,
};

// If message is not empty, execute depositAndCall
if (message !== "0x") {
log(
"ZetaChain",
`Universal contract ${receiver} executing onCall (context: ${JSON.stringify(
context
)}), zrc20: ${zrc20}, amount: ${amount}, message: ${message})`
);

const tx = await protocolContracts.gatewayZEVM
.connect(fungibleModuleSigner)
.depositAndCall(context, zrc20, amount, receiver, message, deployOpts);

await tx.wait();
const logs = await provider.getLogs({
address: receiver,
fromBlock: "latest",
});

logs.forEach((data) => {
log("ZetaChain", `Event from onCall: ${JSON.stringify(data)}`);
});
} else {
const tx = await protocolContracts.gatewayZEVM
.connect(fungibleModuleSigner)
.deposit(zrc20, amount, receiver, deployOpts);
await tx.wait();
log("ZetaChain", `Deposited ${amount} of ${zrc20} tokens to ${receiver}`);
}
const tx = await protocolContracts.gatewayZEVM
.connect(fungibleModuleSigner)
.deposit(zrc20, amount, receiver, deployOpts);
await tx.wait();
log("ZetaChain", `Deposited ${amount} of ${zrc20} tokens to ${receiver}`);
} catch (err) {
logErr("ZetaChain", `Error depositing: ${err}`);
const revertOptions = args[5];
Expand Down

0 comments on commit de54f0f

Please sign in to comment.