Skip to content

Commit

Permalink
Merge branch 'master' into thegreataxios/config/update-skale
Browse files Browse the repository at this point in the history
  • Loading branch information
0xngmi authored Jun 18, 2024
2 parents 88f27ba + c729ff8 commit 3c886a1
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 6 deletions.
8 changes: 8 additions & 0 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ functions:
- http:
path: largetransactions/{chain}
method: get
lastBlocks:
handler: src/handlers/getLastBlocks.default
timeout: 120
memorySize: 2000
events:
- http:
path: lastblocks
method: get
runAdapter:
handler: src/handlers/runAdapter.default
timeout: 900
Expand Down
4 changes: 4 additions & 0 deletions src/adapters/across/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const contracts = {
linea: {
spokePoolv2p5: "0x7E63A5f1a8F0B4d0934B2f2327DAED3F6bb2ee75",
},
mode: {
spokePoolv2p5: "0x3baD7AD0728f9917d1Bf08af5782dCbD516cDd96",
},
} as const;

type SupportedChains = keyof typeof contracts;
Expand Down Expand Up @@ -221,6 +224,7 @@ const adapter: BridgeAdapter = {
"zksync era": constructParams("era"),
base: constructParams("base"),
linea: constructParams("linea"),
mode: constructParams("mode"),
};

export default adapter;
18 changes: 15 additions & 3 deletions src/adapters/orbiter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ const eoaAddressNative = [
"0x80c67432656d59144ceff962e8faf8926599bcf8", // native
"0xe4edb277e41dc89ab076a1f049f4a3efa700bce8", // native
"0xee73323912a4e3772b74ed0ca1595a152b0ef282", // native
"0xe01a40a0894970fc4c2b06f36f5eb94e73ea502d", //merlin
"0xe01a40a0894970fc4c2b06f36f5eb94e73ea502d", // merlin
'0x41d3d33156ae7c62c094aae2995003ae63f587b3',
'0xd7aa9ba6caac7b0436c91396f22ca5a7f31664fc',
'0x0a88bc5c32b684d467b43c06d9e0899efeaf59df',
'0x1c84daa159cf68667a54beb412cdb8b2c193fb32',
'0x8086061cf07c03559fbb4aa58f191f9c4a5df2b2',
'0x732efacd14b0355999aebb133585787921aba3a9',
];

const nativeTokens: Record<string, string> = {
Expand Down Expand Up @@ -115,12 +121,18 @@ const adapter: BridgeAdapter = {
polygon: constructParams("polygon"),
scroll: constructParams("scroll"),
// mode: constructParams("mode"), no etherscan
// manta: constructParams("manta"),
manta: constructParams("manta"),
"arbitrum nova": constructParams("arbitrum_nova"),
"polygon zkevm": constructParams("polygon_zkevm"),
"zksync era": constructParams("era"),
merlin: constructParams("merlin"),
zklink: constructParams("zklink"),
btr: constructParams("btr"),
bitlayer: constructParams("btr"),
'x layer': constructParams("xlayer"),
opbnb: constructParams("opbnb"),
bsc: constructParams("bsc"),
mantle: constructParams("mantle"),
bouncebit: constructParams("bouncebit-mainnet"),
zkfair: constructParams("zkfair"),
};
export default adapter;
14 changes: 11 additions & 3 deletions src/data/bridgeNetworkData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1104,18 +1104,26 @@ export default [
"Blast",
"Arbitrum Nova",
"Scroll",
// "Manta",
"Manta",
// "Mode",
"zkSync Era",
"Polygon zkEVM",
"Merlin",
"BTR",
"ZKLink",
"Bitlayer",
"ZkLink",
"X Layer",
"BSC",
"Bouncebit",
"Mantle",
"Zkfair",
"opBNB"
],
chainMapping: {
"arbitrum nova": "arbitrum_nova",
"zksync era": "era",
"polygon zkevm": "polygon_zkevm",
"btr": "bitlayer",
"xlayer": "X Layer",
},
},
{
Expand Down
32 changes: 32 additions & 0 deletions src/handlers/getLastBlocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import wrap, { wrapScheduledLambda } from "../utils/wrap";
import bridgeNetworks from "../data/bridgeNetworkData";
import { runAdapterToCurrentBlock } from "../utils/adapter";
import { sql } from "../utils/db";
import { successResponse } from "../utils/lambda-response";

const handler = async () => {
const lastRecordedBlocks = (
await sql`SELECT jsonb_object_agg(bridge_id::text, subresult) as result
FROM (
SELECT bridge_id, jsonb_build_object('startBlock', MIN(tx_block), 'endBlock', MAX(tx_block)) as subresult
FROM bridges.transactions
GROUP BY bridge_id
) subquery;
`
)[0].result;

const bridgeConfig = await sql`SELECT * FROM bridges.config`;

const bridgeConfigById = bridgeConfig.reduce((acc: any, config: any) => {
acc[config.id] = config;
return acc;
}, {});

const lastBlocksByName = Object.keys(lastRecordedBlocks).reduce((acc: any, bridgeId: any) => {
acc[`${bridgeConfigById[bridgeId].bridge_name}-${bridgeConfigById[bridgeId].chain}`] = lastRecordedBlocks[bridgeId];
return acc;
}, {});
return successResponse(lastBlocksByName);
};

export default wrap(handler);
16 changes: 16 additions & 0 deletions src/utils/normalizeChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,18 @@ export const chainCoingeckoIds = {
cmcId: "30746",
categories: ["EVM"],
},
"X Layer": {
geckoId: "x-layer",
symbol: null,
cmcId: null,
categories: ["EVM"],
},
"opBNB": {
geckoId: null,
symbol: null,
cmcId: null,
categories: ["EVM", "Rollup"],
},
} as {
[chain: string]: {
geckoId: string | null;
Expand Down Expand Up @@ -1190,6 +1202,10 @@ export function getChainDisplayName(normalizedChain: string, useNewChainNames: b
return "BounceBit"
case "europa":
return "SKALE Europa"
case "xlayer":
return "X Layer"
case "opbnb":
return "opBNB"
default:
return normalizedChain.slice(0, 1).toUpperCase() + normalizedChain.slice(1); // Capitalize first letter
}
Expand Down

0 comments on commit 3c886a1

Please sign in to comment.