Skip to content

Commit

Permalink
Merge pull request #6302 from connext/fix-linea-pmfr
Browse files Browse the repository at this point in the history
Fix: linea pmfr
  • Loading branch information
wanglonghong authored Jul 10, 2024
2 parents cd7fd95 + d482937 commit c322003
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 83 deletions.
10 changes: 8 additions & 2 deletions packages/agents/chain-abstraction/test/libs/shared/quote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,14 @@ describe("Libs:quote", () => {
});
axiosGetStub.resolves({ data: { toAmount: "990000000000000" } });
let initCoreSDKStub: SinonStub;
initCoreSDKStub = stub(MockableFns, "initCoreSDK");
initCoreSDKStub.resolves({ sdkBase: { calculateAmountReceived: { amountReceived: "100" } } });
initCoreSDKStub = stub(HelperFns, "initCoreSDK");
initCoreSDKStub.resolves({
sdkBase: {
calculateAmountReceived: () => {
return { amountReceived: "100" };
},
},
});
stub(HelperFns, "DestinationSwapperPerDomain").value({
"1886350457": {
type: Swapper.UniV3,
Expand Down
2 changes: 1 addition & 1 deletion packages/agents/lighthouse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@connext/nxtp-txservice": "workspace:*",
"@connext/nxtp-utils": "workspace:*",
"@connext/smart-contracts": "workspace:*",
"@consensys/linea-sdk": "0.1.6",
"@consensys/linea-sdk": "0.3.0",
"@eth-optimism/sdk": "3.3.2",
"@mantleio/sdk": "1.0.0",
"@sinclair/typebox": "0.25.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ export const getProcessFromLineaRootArgs = async ({
messageStatus,
});
} else if (messageStatus === "CLAIMABLE") {
return [messages[0].calldata, messages[0].messageNonce];
return [messages[0].calldata, BigNumber.from(messages[0].messageNonce)];
} else {
throw new NoRootAvailable(spokeChainId, hubChainId, requestContext, methodContext, {
error: `Linea Unknown message status`,
hash: sendHash,
});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const getPropagateParams = async (
const gasLimit = BigNumber.from("120000");
const margin = BigNumber.from(1);

const _fee = gasPrice.mul(gasLimit).mul(margin).toString();
const _fee = BigNumber.from(gasPrice).mul(gasLimit).mul(margin).toString();

logger.info("Got propagate params for Linea", requestContext, methodContext, {
gasPrice: gasPrice.toString(),
Expand Down
2 changes: 1 addition & 1 deletion packages/deployments/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@arbitrum/sdk": "3.1.11",
"@certusone/wormhole-sdk": "0.9.21",
"@connext/nxtp-utils": "workspace:*",
"@consensys/linea-sdk": "0.1.6",
"@consensys/linea-sdk": "0.3.0",
"@gelatonetwork/relay-context": "2.1.0",
"@mantleio/sdk": "1.0.0",
"@matterlabs/hardhat-zksync-deploy": "0.6.3",
Expand Down
26 changes: 12 additions & 14 deletions packages/deployments/contracts/tasks/connector/claimLinea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default task("claim-linea", "Claim messages on both of L1 and L2")
const deployer = Wallet.fromMnemonic(process.env.MAINNET_MNEMONIC ?? process.env.MNEMONIC!);

const env = mustGetEnv(_env);
const networkType = _networkType ?? ProtocolNetwork.TESTNET;
const networkType = _networkType ?? ProtocolNetwork.MAINNET;
console.log("networkType: ", networkType);
console.log("env:", env);
console.log("transaction hash", hash);
Expand All @@ -47,17 +47,18 @@ export default task("claim-linea", "Claim messages on both of L1 and L2")
});

// get L1/L2 contract
const originContract = chainId == hub.chain ? sdk.getL1Contract() : sdk.getL2Contract();
const originContract = chainId == hub.chain ? sdk.getL2Contract() : sdk.getL1Contract();

// get Message Status
const messages = await originContract.getMessagesByTransactionHash(hash);
console.log("messages: ", messages);

if (!messages?.length) {
throw new Error(`${hash} has no message sent`);
}
console.log("message: ", messages[0]);

const destContract = chainId == hub.chain ? sdk.getL2Contract() : sdk.getL1Contract();
const destContract = chainId == hub.chain ? sdk.getL1Contract() : sdk.getL2Contract();

// returns on-chain message status by message hash
const messageStatus = await destContract.getMessageStatus(messages[0].messageHash);
Expand All @@ -67,17 +68,14 @@ export default task("claim-linea", "Claim messages on both of L1 and L2")
console.log("message already claimed!! skipping...");
} else if (messageStatus === "CLAIMABLE") {
console.log("Claimable message status. ");
let claimMessage = await destContract.claim(
{
// claims message by message
...messages[0],
feeRecipient: deployer.address, // address that will receive fees. by default it is the message sender
},
{
gasPrice: utils.parseUnits("3", "gwei"),
},
);
console.log(claimMessage);
let claimMessage = await destContract.claim({
// claims message by message
...messages[0],
feeRecipient: deployer.address, // address that will receive fees. by default it is the message sender
});
console.log("claim:", claimMessage.hash);
const ret = await claimMessage.wait();
console.log("claim receipt:", ret);
} else {
console.log("unknown message status. skipping...");
}
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"src/**/*"
],
"dependencies": {
"@maticnetwork/maticjs": "3.6.6",
"@maticnetwork/maticjs": "3.8.2",
"@maticnetwork/maticjs-web3": "1.0.4",
"@sinclair/typebox": "0.25.21",
"ajv": "8.12.0",
Expand Down
Loading

0 comments on commit c322003

Please sign in to comment.