Skip to content

Commit

Permalink
xtoken: crab<>darwinia
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoch05 committed Feb 28, 2024
1 parent edb1b7a commit ac97473
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 5 deletions.
5 changes: 5 additions & 0 deletions apollo/.env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ GNOSIS_LNV3_ENDPOINT=https://api.studio.thegraph.com/query/59403/lnv3-gnosis/v1.
MANTLE_LNV3_ENDPOINT=https://thegraph-g1.darwinia.network/helix/subgraphs/name/lnv3/mantle
SCROLL_LNV3_ENDPOINT=https://api.studio.thegraph.com/query/59403/lnv3-scroll/v1.0.0

XTOKEN_DARWINIA=https://thegraph.darwinia.network/helix/subgraphs/name/xtokentransfer/darwinia
XTOKEN_CRAB=https://thegraph.darwinia.network/helix/subgraphs/name/xtokentransfer/crab
XTOKEN_DISPATCH_DARWINIA=https://thegraph.darwinia.network/helix/subgraphs/name/xtokendispatch/darwinia
XTOKEN_DISPATCH_CRAB=https://thegraph.darwinia.network/helix/subgraphs/name/xtokendispatch/crab

CHAIN_TYPE=formal
21 changes: 18 additions & 3 deletions apollo/src/guard/guard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class GuardInfo {
toChain: string;
bridge: string;
chainId: number;
depositor: string;
depositor: string | null;
contract: string;
}

Expand All @@ -22,6 +22,14 @@ export class GuardService {
depositor: '0x371019523b25Ff4F26d977724f976566b08bf741',
contract: '0x3f200d3b6DA62bcA2F8a93F663b172A7f1AaE9ba',
},
{
fromChain: 'darwinia-dvm',
toChain: 'ethereum',
bridge: 'helix-sub2ethv2(lock)',
chainId: 1,
depositor: null,
contract: '0x61B6B8c7C00aA7F060a2BEDeE6b11927CC9c3eF1',
}
];

recoverPubkey(
Expand Down Expand Up @@ -64,10 +72,17 @@ export class GuardService {
chainId: number,
contractAddress: string
): string {
const claimSign = this.web3.eth.abi.encodeFunctionSignature(
const claimSign = depositor === null ?
this.web3.eth.abi.encodeFunctionSignature(
'claim(uint256,uint256,address,address,uint256,bytes[])'
) : this.web3.eth.abi.encodeFunctionSignature(
'claim(address,uint256,uint256,address,address,uint256,bytes[])'
);
const param = this.web3.eth.abi.encodeParameters(
const param = depositor === null ?
this.web3.eth.abi.encodeParameters(
['uint256', 'uint256', 'address', 'address', 'uint256'],
[transferId, timestamp, token, recipient, amount]
) : this.web3.eth.abi.encodeParameters(
['address', 'uint256', 'uint256', 'address', 'address', 'uint256'],
[depositor, transferId, timestamp, token, recipient, amount]
);
Expand Down
65 changes: 63 additions & 2 deletions apollo/src/xtoken/transfer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,71 @@ import { AddressTokenMap } from '../base/AddressToken';
@Injectable()
export class TransferService extends BaseTransferServiceT2 {
private readonly darwainiaUrl = this.configService.get<string>('XTOKEN_DARWINIA');
private readonly crabUrl = this.configService.get<string>('XTOKEN_CRAB');
private readonly ethereumUrl = this.configService.get<string>('XTOKEN_ETHEREUM');
private readonly darwiniaDispatchSubgraph = this.configService.get<string>('XTOKEN_DISPATCH_DARWINIA');
private readonly crabDispatchSubgraph = this.configService.get<string>('XTOKEN_DISPATCH_CRAB');
private readonly ethereumDispatchSubgraph = this.configService.get<string>('XTOKEN_DISPATCH_ETHEREUM');

formalChainTransfers: PartnerT2[] = [];
formalChainTransfers: PartnerT2[] = [
{
chainId: 46,
chain: 'darwinia-dvm',
url: this.darwainiaUrl,
bridge: 'xtokenbridge',
symbols: [
{
key: 'RING',
symbol: 'RING',
address: '0x0000000000000000000000000000000000000000',
protocolFee: 0,
decimals: 18,
},
{
key: 'CRAB',
symbol: 'xWCRAB',
address: '0x656567Eb75b765FC320783cc6EDd86bD854b2305',
protocolFee: 0,
decimals: 18,
}
],
channels: [
{
chain: 'crab-dvm',
channel: 'msgport'
}
]
},
{
chainId: 44,
chain: 'crab-dvm',
url: this.crabUrl,
bridge: 'xtokenbridge',
symbols: [
{
key: 'RING',
symbol: 'xWRING',
address: '0x273131F7CB50ac002BDd08cA721988731F7e1092',
protocolFee: 0,
decimals: 18,
},
{
key: 'CRAB',
symbol: 'CRAB',
address: '0x0000000000000000000000000000000000000000',
protocolFee: 0,
decimals: 18,
}
],
channels: [
{
chain: 'darwinia-dvm',
channel: 'msgport'
}
]

}
];

testChainTransfers: PartnerT2[] = [
{
Expand Down Expand Up @@ -60,8 +120,9 @@ export class TransferService extends BaseTransferServiceT2 {
dispatchEndPoints = {
'pangolin-dvm': this.darwiniaDispatchSubgraph,
sepolia: this.ethereumDispatchSubgraph,
darwinia: this.darwiniaDispatchSubgraph,
'darwinia-dvm': this.darwiniaDispatchSubgraph,
ethereum: this.ethereumDispatchSubgraph,
'crab-dvm': this.crabDispatchSubgraph,
};
addressToTokenInfo: { [key: string]: AddressTokenMap } = {};

Expand Down
2 changes: 2 additions & 0 deletions subgraph/xtoken/messageDispatcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"build": "graph build",
"build-pangolin": "sh generate.sh dispatch pangolin 2298283 0x0000000005d961F950adA391C1511c92bbc64D9F 0xf7F461728DC89de5EF6615715678b5f5b12bb98A && graph codegen && graph build",
"build-sepolia": "sh generate.sh dispatch sepolia 5229494 0x0000000005d961F950adA391C1511c92bbc64D9F 0xf7F461728DC89de5EF6615715678b5f5b12bb98A && sh generate.sh guard sepolia 0x3f200d3b6DA62bcA2F8a93F663b172A7f1AaE9ba 5229494 && graph codegen && graph build",
"build-darwinia": "sh generate.sh dispatch darwinia2 2013793 0x0000000005d961F950adA391C1511c92bbc64D9F 0x65Be094765731F394bc6d9DF53bDF3376F1Fc8B0 && graph codegen && graph build",
"build-crab": "sh generate.sh dispatch crab2 2239020 0x0000000005d961F950adA391C1511c92bbc64D9F 0x65Be094765731F394bc6d9DF53bDF3376F1Fc8B0 && graph codegen && graph build",
"create-remote-dev": "graph create --access-token ${KEY} --node https://thegraph-g2.darwinia.network/helix/deploy/ xtokendispatch/${NETWORK}",
"deploy-remote-dev": "graph deploy --access-token $KEY --node https://thegraph-g2.darwinia.network/helix/deploy/ --ipfs https://ipfs.network.thegraph.com xtokendispatch/$NETWORK",
"create-remote-pro": "graph create --access-token ${KEY} --node https://thegraph.darwinia.network/helix/deploy/ xtokendispatch/${NETWORK}",
Expand Down
2 changes: 2 additions & 0 deletions subgraph/xtoken/transfer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"build": "graph build",
"build-pangolin": "sh generate.sh init && sh generate.sh backing pangolin 0x94eAb0CB67AB7edaf9A280aCa097F70e4BD780ac 2298437 && graph codegen && graph build",
"build-sepolia": "sh generate.sh init && sh generate.sh issuing sepolia 0x371019523b25Ff4F26d977724f976566b08bf741 5230232 && graph codegen && graph build",
"build-darwinia": "sh generate.sh init && sh generate.sh backing darwinia2 0xFd626a860F4d4bDB94aF200c218ce62c9647c8b2 2020384 && sh generate.sh issuing darwinia2 0xf16d9682c4883415aee6e78eb0d6ae3507014e42 2020389 && graph codegen && graph build",
"build-crab": "sh generate.sh init && sh generate.sh backing crab2 0xFd626a860F4d4bDB94aF200c218ce62c9647c8b2 2239742 && sh generate.sh issuing crab2 0xf16d9682c4883415aee6e78eb0d6ae3507014e42 2239808 && graph codegen && graph build",
"create-remote-dev": "graph create --access-token ${KEY} --node https://thegraph-g2.darwinia.network/helix/deploy/ xtokentransfer/${NETWORK}",
"deploy-remote-dev": "graph deploy --access-token $KEY --node https://thegraph-g2.darwinia.network/helix/deploy/ --ipfs https://ipfs.network.thegraph.com xtokentransfer/$NETWORK",
"create-remote-pro": "graph create --access-token ${KEY} --node https://thegraph.darwinia.network/helix/deploy/ xtokentransfer/${NETWORK}",
Expand Down

0 comments on commit ac97473

Please sign in to comment.