From ffdd213f3e955f36943f6dc0fef9e97f115edf16 Mon Sep 17 00:00:00 2001 From: xiaoch05 Date: Wed, 27 Dec 2023 14:31:46 +0800 Subject: [PATCH] support guardV3 --- apollo/src/aggregation/aggregation.service.ts | 3 ++- apollo/src/guard/guard.service.ts | 27 +++++++++---------- apollo/src/xtoken/transfer.service.ts | 2 +- apollo/src/xtoken/xtoken.service.ts | 2 +- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/apollo/src/aggregation/aggregation.service.ts b/apollo/src/aggregation/aggregation.service.ts index be5887c6..d879f5fb 100644 --- a/apollo/src/aggregation/aggregation.service.ts +++ b/apollo/src/aggregation/aggregation.service.ts @@ -4,6 +4,7 @@ import { HistoryRecords, Lnv20RelayInfo, Lnv20RelayInfos } from '../graphql'; import { GuardService } from '../guard/guard.service'; // export lnbridge service configure import { TransferService } from '../lnbridgev20/transfer.service'; +import { last } from 'lodash'; @Injectable() export class AggregationService extends PrismaClient implements OnModuleInit { @@ -115,7 +116,7 @@ export class AggregationService extends PrismaClient implements OnModuleInit { record.fromChain, record.toChain, record.bridge, - BigInt(record.messageNonce).toString(), + BigInt(last(record.id.split('-'))).toString(), record.endTime.toString(), record.recvTokenAddress, record.recipient, diff --git a/apollo/src/guard/guard.service.ts b/apollo/src/guard/guard.service.ts index 8b76f302..a5c8e411 100644 --- a/apollo/src/guard/guard.service.ts +++ b/apollo/src/guard/guard.service.ts @@ -6,6 +6,7 @@ class GuardInfo { toChain: string; bridge: string; chainId: number; + depositor: string; contract: string; } @@ -14,18 +15,12 @@ export class GuardService { private readonly guardConfig: GuardInfo[] = [ { - fromChain: 'pangolin-dvm', - toChain: 'goerli', - bridge: 'helix-sub2ethv2(lock)', - chainId: 5, - contract: '0x8C986EC362A38cA4A6a3fd4188C5318c689A187d', - }, - { - fromChain: 'darwinia-dvm', - toChain: 'ethereum', - bridge: 'helix-sub2ethv2(lock)', - chainId: 1, - contract: '0x61B6B8c7C00aA7F060a2BEDeE6b11927CC9c3eF1', + fromChain: 'crab-dvm', + toChain: 'sepolia', + bridge: 'xtoken-crab-dvm', + chainId: 11155111, + depositor: '0xf22D0bb66b39745Ae6e3fEa3E5859d7f0b367Fd1', + contract: '0xcc357d5A8E5dBD52bC508E0FE491137d912F6bc8', }, ]; @@ -47,6 +42,7 @@ export class GuardService { return null; } const dataHash = this.generateDataHash( + info.depositor, transferId, timestamp, token, @@ -59,6 +55,7 @@ export class GuardService { } private generateDataHash( + depositor: string, transferId: string, timestamp: string, token: string, @@ -68,11 +65,11 @@ export class GuardService { contractAddress: string ): string { const claimSign = this.web3.eth.abi.encodeFunctionSignature( - 'claim(uint256,uint256,address,address,uint256,bytes[])' + 'claim(address,uint256,uint256,address,address,uint256,bytes[])' ); const param = this.web3.eth.abi.encodeParameters( - ['uint256', 'uint256', 'address', 'address', 'uint256'], - [transferId, timestamp, token, recipient, amount] + ['address', 'uint256', 'uint256', 'address', 'address', 'uint256'], + [depositor, transferId, timestamp, token, recipient, amount] ); const message = this.web3.eth.abi.encodeParameters(['bytes4', 'bytes'], [claimSign, param]); const structHash = this.web3.utils.keccak256(message); diff --git a/apollo/src/xtoken/transfer.service.ts b/apollo/src/xtoken/transfer.service.ts index c9d8dd71..43b41f0c 100644 --- a/apollo/src/xtoken/transfer.service.ts +++ b/apollo/src/xtoken/transfer.service.ts @@ -37,7 +37,7 @@ export class TransferService extends BaseTransferServiceT2 { { originalSymbol: 'CRAB', symbol: 'xCRAB', - address: '0xe8835bB0735fbfD5ECAC1e20835D5B7C39622ba3', + address: '0x9Da7E18441f26515CC713290BE846E726d41781d', protocolFee: 0, decimals: 18, }, diff --git a/apollo/src/xtoken/xtoken.service.ts b/apollo/src/xtoken/xtoken.service.ts index a8968488..0c764d12 100644 --- a/apollo/src/xtoken/xtoken.service.ts +++ b/apollo/src/xtoken/xtoken.service.ts @@ -159,7 +159,7 @@ export class xTokenService implements OnModuleInit { sendToken: sendTokenInfo.symbol, recvToken: recvTokenInfo.symbol, sendAmount: record.amount, - recvAmount: '0', + recvAmount: record.amount, startTime: Number(record.timestamp), endTime: endTime, result: result,