Skip to content

Commit

Permalink
fix: handle deposit from EVM, update protocol contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Sep 1, 2024
1 parent 89d26e3 commit 50177d4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"typescript": "^5.5.4"
},
"dependencies": {
"@zetachain/protocol-contracts": "10.0.0-rc9",
"@zetachain/protocol-contracts": "10.0.0-rc10",
"ansis": "^3.3.2",
"concurrently": "^8.2.2",
"ethers": "^6.13.2",
Expand Down
24 changes: 14 additions & 10 deletions packages/localnet/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ export const initLocalnet = async (port: number) => {

// event Withdrawn(address indexed sender, uint256 indexed chainId, bytes receiver, address zrc20, uint256 value, uint256 gasfee, uint256 protocolFlatFee, bytes message, uint256 gasLimit, RevertOptions revertOptions);
protocolContracts.gatewayZEVM.on("Withdrawn", async (...args: Array<any>) => {
console.log("Worker: Withdrawn event on GatewayZEVM.");
console.log("Worker: Calling ReceiverEVM through GatewayEVM...");
try {
const receiver = args[2];
const message = args[7];
Expand Down Expand Up @@ -345,13 +343,13 @@ export const initLocalnet = async (port: number) => {
const receiver = args[1];
const amount = args[2];
const message = args[4];
if (message != "0x") {
const context = {
origin: protocolContracts.gatewayZEVM.target,
sender: await fungibleModuleSigner.getAddress(),
chainID: 1,
};
const zrc20 = protocolContracts.zrc20Eth.target;
const context = {
origin: protocolContracts.gatewayZEVM.target,
sender: await fungibleModuleSigner.getAddress(),
chainID: 1,
};
const zrc20 = protocolContracts.zrc20Eth.target;
if (message !== "0x") {
log(
"ZetaChain",
`Universal contract ${receiver} executing onCrossChainCall (context: ${JSON.stringify(
Expand Down Expand Up @@ -381,9 +379,15 @@ export const initLocalnet = async (port: number) => {
`Event from onCrossChainCall: ${JSON.stringify(data)}`
);
});
} else {
const depositTx = await protocolContracts.gatewayZEVM
.connect(fungibleModuleSigner)
.deposit(zrc20, amount, receiver, deployOpts);

await depositTx.wait();
}
} catch (e: any) {
logErr("ZetaChain", `Error executing onCrossChainCall: ${e}`);
logErr("ZetaChain", `Error depositing: ${e}`);
const revertOptions = args[5];
await handleOnRevertEVM(revertOptions, e);
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -772,10 +772,10 @@
"@typescript-eslint/types" "8.0.1"
eslint-visitor-keys "^3.4.3"

"@zetachain/[email protected]rc9":
version "10.0.0-rc9"
resolved "https://registry.yarnpkg.com/@zetachain/protocol-contracts/-/protocol-contracts-10.0.0-rc9.tgz#edee08ded7ac1d200ba20f595fe916e9c3a66203"
integrity sha512-oAmsbpjCglGEL8oQVk+UKYBIdo9ZVP2kIUGnIw0O1FakbBH4+eWjCJjD/bZ8q0HxzEWjpu91tFRsdc3w2q5aqg==
"@zetachain/[email protected]rc10":
version "10.0.0-rc10"
resolved "https://registry.yarnpkg.com/@zetachain/protocol-contracts/-/protocol-contracts-10.0.0-rc10.tgz#e3c21b493904ec743c9026627b2f809009fec7a2"
integrity sha512-kOH7Lk0os3xt9N/FCdeaLUMyonfez97q69Jy2YFwddjv9jpqaxwLXWj2hvdIFc21inKZ7HIjmDDcj9/n8gITKg==
dependencies:
"@openzeppelin/contracts" "^5.0.2"
"@openzeppelin/contracts-upgradeable" "^5.0.2"
Expand Down

0 comments on commit 50177d4

Please sign in to comment.