Skip to content

Commit

Permalink
add opposite testcase & add version for query
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoch05 committed Jan 15, 2024
1 parent 5e0f04f commit fb51923
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 34 deletions.
2 changes: 2 additions & 0 deletions apollo/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ GOERLI_A2E_LN_ENDPOINT=http://localhost:8000/subgraphs/name/arbi2ethln/ethereum
ARBITRUM_A2E_LN_ENDPOINT=http://localhost:8000/subgraphs/name/arbi2ethln/arbitrum

LN_ETHEREUM_DEFAULT_ENDPOINT = https://api.studio.thegraph.com/query/61328/ln-default-sepolia/version/latest
LN_ETHEREUM_OPPOSITE_ENDPOINT = https://api.studio.thegraph.com/query/61328/ln-opposite-sepolia/version/latest
LN_ARBITRUM_DEFAULT_ENDPOINT = https://api.studio.thegraph.com/query/61328/ln-default-arbisepolia/version/latest
LN_ARBITRUM_OPPOSITE_ENDPOINT = https://api.studio.thegraph.com/query/61328/ln-opposite-arbisepolia/version/latest
LN_ZKSYNC_DEFAULT_ENDPOINT = https://api.studio.thegraph.com/query/61328/ln-default-zksepolia/version/latest

ETHEREUM_LNV3_ENDPOINT=https://api.studio.thegraph.com/query/61328/lnv3-sepolia/version/latest
Expand Down
4 changes: 2 additions & 2 deletions apollo/src/aggregation/aggregation.history.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ type Query {
checkLnBridgeExist(fromChainId: Int, toChainId: Int, fromToken: String, toToken: String): Boolean
queryGuardNeedSignature(fromChain: String, toChain: String, bridge: String, guardAddress: String, row: Int): HistoryRecords
queryRelayRecords(fromChain: String, toChain: String, bridge: String, relayer: String, row: Int): HistoryRecords
queryLnBridgeRelayInfos(fromChain: String, toChain: String, bridge: String, relayer: String, row: Int, page: Int): LnBridgeRelayInfos
sortedLnBridgeRelayInfos(fromChain: String, toChain: String, bridge: String, token: String, row: Int, amount: String, decimals: Int): SortedLnBridgeRelayInfos
queryLnBridgeRelayInfos(fromChain: String, toChain: String, version: String, bridge: String, relayer: String, row: Int, page: Int): LnBridgeRelayInfos
sortedLnBridgeRelayInfos(fromChain: String, toChain: String, version: String, bridge: String, token: String, row: Int, amount: String, decimals: Int): SortedLnBridgeRelayInfos
}

type Mutation {
Expand Down
6 changes: 4 additions & 2 deletions apollo/src/aggregation/aggregation.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,15 @@ export class AggregationResolver {
async queryLnBridgeRelayInfos(
@Args('fromChain') fromChain: string,
@Args('toChain') toChain: string,
@Args('version') version: string,
@Args('bridge') bridge: string,
@Args('relayer') relayer: string,
@Args('row') row: number,
@Args('page') page: number
) {
const skip = row * page || 0;
const take = row || 10;
const baseFilters = { fromChain, toChain, bridge, relayer };
const baseFilters = { fromChain, toChain, bridge, relayer, version };

const where = {
...baseFilters,
Expand All @@ -276,6 +277,7 @@ export class AggregationResolver {
async sortedLnBridgeRelayInfos(
@Args('fromChain') fromChain: string,
@Args('toChain') toChain: string,
@Args('version') version: string,
@Args('bridge') bridge: string,
@Args('token') token: string,
@Args('row') row: number,
Expand All @@ -284,7 +286,7 @@ export class AggregationResolver {
) {
const take = row || 128;
const sendToken = token?.toLowerCase();
const baseFilters = { fromChain, toChain, sendToken, bridge };
const baseFilters = { fromChain, toChain, sendToken, bridge, version };

const where = {
...baseFilters,
Expand Down
4 changes: 2 additions & 2 deletions apollo/src/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export abstract class IQuery {

abstract queryRelayRecords(fromChain?: Nullable<string>, toChain?: Nullable<string>, bridge?: Nullable<string>, relayer?: Nullable<string>, row?: Nullable<number>): Nullable<HistoryRecords> | Promise<Nullable<HistoryRecords>>;

abstract queryLnBridgeRelayInfos(fromChain?: Nullable<string>, toChain?: Nullable<string>, bridge?: Nullable<string>, relayer?: Nullable<string>, row?: Nullable<number>, page?: Nullable<number>): Nullable<LnBridgeRelayInfos> | Promise<Nullable<LnBridgeRelayInfos>>;
abstract queryLnBridgeRelayInfos(fromChain?: Nullable<string>, toChain?: Nullable<string>, version?: Nullable<string>, bridge?: Nullable<string>, relayer?: Nullable<string>, row?: Nullable<number>, page?: Nullable<number>): Nullable<LnBridgeRelayInfos> | Promise<Nullable<LnBridgeRelayInfos>>;

abstract sortedLnBridgeRelayInfos(fromChain?: Nullable<string>, toChain?: Nullable<string>, bridge?: Nullable<string>, token?: Nullable<string>, row?: Nullable<number>, amount?: Nullable<string>, decimals?: Nullable<number>): Nullable<SortedLnBridgeRelayInfos> | Promise<Nullable<SortedLnBridgeRelayInfos>>;
abstract sortedLnBridgeRelayInfos(fromChain?: Nullable<string>, toChain?: Nullable<string>, version?: Nullable<string>, bridge?: Nullable<string>, token?: Nullable<string>, row?: Nullable<number>, amount?: Nullable<string>, decimals?: Nullable<number>): Nullable<SortedLnBridgeRelayInfos> | Promise<Nullable<SortedLnBridgeRelayInfos>>;
}

export class HistoryRecord {
Expand Down
2 changes: 1 addition & 1 deletion apollo/src/lnbridgev20/lnbridgev20.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ export class Lnbridgev20Service implements OnModuleInit {
);
const sourcePartner = this.findPartnerByChainId(record.remoteChainId);
if (sourcePartner === null) {
this.logger.warn(`can't find partner chain id ${record.remoteChainId}`);
this.logger.warn(`can't find partner chain source:${transfer.chainId} remote:${record.remoteChainId}`);
latestNonce += 1;
this.fetchCache[index].latestRelayerInfoTargetNonce = latestNonce;
return;
Expand Down
20 changes: 10 additions & 10 deletions apollo/src/lnbridgev20/transfer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ export class TransferService extends BaseTransferServiceT3 {
chainId: 11155111,
chainName: 'sepolia',
defaultEndpoint: this.lnEthereumDefaultEndpoint,
oppositeEndpoint: null,
oppositeEndpoint: this.lnEthereumOppositeEndpoint,
tokens: [
{
fromSymbol: 'USDC',
Expand All @@ -623,7 +623,7 @@ export class TransferService extends BaseTransferServiceT3 {
toAddress: '0x8A87497488073307E1a17e8A12475a94Afcb413f',
protocolFee: 100000000,
decimals: 18,
bridgeType: 'default',
bridgeType: 'opposite',
channel: 'layerzero',
},
{
Expand All @@ -648,7 +648,7 @@ export class TransferService extends BaseTransferServiceT3 {
toAddress: '0x3b8Bb7348D4F581e67E2498574F73e4B9Fc51855',
protocolFee: 100000000,
decimals: 18,
bridgeType: 'default',
bridgeType: 'opposite',
channel: 'layerzero',
},
{
Expand All @@ -673,7 +673,7 @@ export class TransferService extends BaseTransferServiceT3 {
toAddress: '0x0000000000000000000000000000000000000000',
protocolFee: 1000000000000000,
decimals: 18,
bridgeType: 'default',
bridgeType: 'opposite',
channel: 'layerzero',
},
{
Expand All @@ -693,7 +693,7 @@ export class TransferService extends BaseTransferServiceT3 {
chainId: 421614,
chainName: 'arbitrum-sepolia',
defaultEndpoint: this.lnArbitrumDefaultEndpoint,
oppositeEndpoint: null,
oppositeEndpoint: this.lnArbitrumOppositeEndpoint,
tokens: [
{
fromSymbol: 'USDC',
Expand All @@ -706,7 +706,7 @@ export class TransferService extends BaseTransferServiceT3 {
toAddress: '0x0ac58Df0cc3542beC4cDa71B16D06C3cCc39f405',
protocolFee: 100000000000000000000,
decimals: 18,
bridgeType: 'default',
bridgeType: 'opposite',
channel: 'layerzero',
},
{
Expand All @@ -717,7 +717,7 @@ export class TransferService extends BaseTransferServiceT3 {
decimals: 6,
bridgeType: 'default',
channel: 'layerzero',
},
}
],
},
{
Expand All @@ -731,7 +731,7 @@ export class TransferService extends BaseTransferServiceT3 {
toAddress: '0x876A4f6eCF13EEb101F9E75FCeF58f19Ff383eEB',
protocolFee: 100000000000000000000,
decimals: 18,
bridgeType: 'default',
bridgeType: 'opposite',
channel: 'layerzero',
},
{
Expand All @@ -756,7 +756,7 @@ export class TransferService extends BaseTransferServiceT3 {
toAddress: '0x0000000000000000000000000000000000000000',
protocolFee: 1000000000000000,
decimals: 18,
bridgeType: 'default',
bridgeType: 'opposite',
channel: 'layerzero',
},
{
Expand Down Expand Up @@ -854,7 +854,7 @@ export class TransferService extends BaseTransferServiceT3 {
],
},
],
},
}
];

readonly isTest = this.configService.get<string>('CHAIN_TYPE') === 'test';
Expand Down
6 changes: 3 additions & 3 deletions subgraph/ln-default-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"scripts": {
"codegen": "graph codegen",
"build": "graph build",
"build-sepolia": "sh generate.sh sepolia 0x7e101911E5FB461d78FBde3992f76F3Bf8BbA829 4607131 && graph codegen && graph build",
"build-arbisepolia": "sh generate.sh arbitrum-sepolia 0x7e101911E5FB461d78FBde3992f76F3Bf8BbA829 639445 && graph codegen && graph build",
"build-zksepolia": "sh generate.sh zksync-era-sepolia 0xbd8434d7d330329364590822ca2D2Fae630C1424 77153 && graph codegen && graph build",
"build-sepolia": "sh generate.sh sepolia 0x8429D7Dfd91D6F970ba89fFC005e67D15f1E4739 5088292 && graph codegen && graph build",
"build-arbisepolia": "sh generate.sh arbitrum-sepolia 0x8429D7Dfd91D6F970ba89fFC005e67D15f1E4739 7187613 && graph codegen && graph build",
"build-zksepolia": "sh generate.sh zksync-era-sepolia 0xBe23e871318E49C747CB909AC65aCCFAEAac3a37 97433 && graph codegen && graph build",
"build-ethereum": "sh generate.sh mainnet 0x94C614DAeFDbf151E1BB53d6A201ae5fF56A9337 18411160 && graph codegen && graph build",
"build-arbitrum": "sh generate.sh arbitrum-one 0x94C614DAeFDbf151E1BB53d6A201ae5fF56A9337 143123443 && graph codegen && graph build",
"build-mantle": "sh generate.sh mantle 0x94C614DAeFDbf151E1BB53d6A201ae5fF56A9337 17119189 && graph codegen && graph build",
Expand Down
8 changes: 3 additions & 5 deletions subgraph/ln-opposite-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
"scripts": {
"codegen": "graph codegen",
"build": "graph build",
"build-goerli": "sh generate.sh goerli 0x4C538EfA6e3f9Dfb939AA4F0B224577DA665923a 9844813 && graph codegen && graph build",
"build-arbigoerli": "sh generate.sh arbitrum-goerli 0x4C538EfA6e3f9Dfb939AA4F0B224577DA665923a 46913317 && graph codegen && graph build",
"build-lineagoerli": "sh generate.sh lineagoerli 0x4C538EfA6e3f9Dfb939AA4F0B224577DA665923a 1698144 && graph codegen && graph build",
"build-mantlegoerli": "sh generate.sh mantlegoerli 0x4C538EfA6e3f9Dfb939AA4F0B224577DA665923a 23363565 && graph codegen && graph build",
"build-sepolia": "sh generate.sh sepolia 0xbA96d83E2A04c4E50F2D6D7eCA03D70bA2426e5f 5088301 && graph codegen && graph build",
"build-arbisepolia": "sh generate.sh arbitrum-sepolia 0xbA96d83E2A04c4E50F2D6D7eCA03D70bA2426e5f 7188705 && graph codegen && graph build",
"build-ethereum": "sh generate.sh mainnet 0x48d769d5C7ff75703cDd1543A1a2ed9bC9044A23 18381361 && graph codegen && graph build",
"build-arbitrum": "sh generate.sh arbitrum-one 0x48d769d5C7ff75703cDd1543A1a2ed9bC9044A23 141864870 && graph codegen && graph build",
"create-remote-dev": "graph create --access-token $KEY --node https://thegraph-g2.darwinia.network/helix/deploy/ lnopposite/$NETWORK",
Expand All @@ -16,7 +14,7 @@
"deploy-remote-pro": "graph deploy --access-token $KEY --node https://thegraph.darwinia.network/helix/deploy/ --ipfs https://ipfs.network.thegraph.com lnopposite/$NETWORK"
},
"dependencies": {
"@graphprotocol/graph-cli": "0.31.1",
"@graphprotocol/graph-cli": "0.64.1",
"@graphprotocol/graph-ts": "0.30.0"
}
}
18 changes: 9 additions & 9 deletions subgraph/ln-opposite-bridge/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@
graphql-import-node "^0.0.5"
js-yaml "^4.1.0"

"@graphprotocol/graph-cli@0.31.1":
version "0.58.0"
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-cli/-/graph-cli-0.58.0.tgz#60af39fbf96296353dab862ea9f55026639f9851"
integrity sha512-EbdL5LZFmIMAuItQXv7LXgd7cqYQ3BdIJR2jxNr+LRL0juBAxmEz6zVvYnIUmgXoa5SB5rxE9ZT6pfe+fhbD6Q==
"@graphprotocol/graph-cli@0.64.1":
version "0.64.1"
resolved "https://registry.yarnpkg.com/@graphprotocol/graph-cli/-/graph-cli-0.64.1.tgz#c644d7b387b8959e637b94896721251d45008e16"
integrity sha512-BUjWLiEvZUPxuJ/PpARXMBeVLBGjJ/AKP+Orqzlb09b/6HAyQwYpDsaz5R9rW05LYPRqMikuCmktY727rbIFuA==
dependencies:
"@float-capital/float-subgraph-uncrashable" "^0.0.0-alpha.4"
"@oclif/core" "2.8.6"
Expand All @@ -242,7 +242,7 @@
ipfs-http-client "55.0.0"
jayson "4.0.0"
js-yaml "3.14.1"
prettier "1.19.1"
prettier "3.0.3"
request "2.88.2"
semver "7.4.0"
sync-request "6.1.0"
Expand Down Expand Up @@ -2861,10 +2861,10 @@ pluralize@^8.0.0:
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-8.0.0.tgz#1a6fa16a38d12a1901e0320fa017051c539ce3b1"
integrity sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==

prettier@1.19.1:
version "1.19.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
prettier@3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.3.tgz#432a51f7ba422d1469096c0fdc28e235db8f9643"
integrity sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==

process-nextick-args@~2.0.0:
version "2.0.1"
Expand Down

0 comments on commit fb51923

Please sign in to comment.