Skip to content

Commit

Permalink
[Blockchain Watcher] (UNICHAIN) Map unichain chain (#1806)
Browse files Browse the repository at this point in the history
* Map unichain chain

* Use 44 chain number

* Add custom varibale

---------

Co-authored-by: julian merlo <[email protected]>
  • Loading branch information
julianmerlo95 and julian merlo authored Oct 18, 2024
1 parent 2dce5b9 commit f89c8e8
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 45 deletions.
7 changes: 7 additions & 0 deletions blockchain-watcher/config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@
"__format": "json"
}
},
"unichain": {
"network": "UNICHAIN_NETWORK",
"rpcs": {
"__name": "UNICHAIN_RPCS",
"__format": "json"
}
},
"polygon-sepolia": {
"network": "POLYGON_SEPOLIA_NETWORK",
"rpcs": {
Expand Down
7 changes: 7 additions & 0 deletions blockchain-watcher/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@
"rpcs": ["https://testnet.snaxchain.io/"],
"timeout": 10000
},
"unichain": {
"name": "unichain",
"network": "testnet",
"chainId": 44,
"rpcs": ["https://sepolia.unichain.org"],
"timeout": 10000
},
"evmos": {
"name": "evmos",
"network": "testnet",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const EVM_CHAINS = new Map([
["xlayer", "evmRepo"],
["snaxchain", "evmRepo"],
["berachain", "evmRepo"],
["unichain", "evmRepo"],
]);

const POOL_STRATEGY = "healthy";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ describe("RepositoriesBuilder", () => {
expect(repos.getEvmBlockRepository("berachain")).toBeInstanceOf(
RateLimitedEvmJsonRPCBlockRepository
);
expect(repos.getEvmBlockRepository("unichain")).toBeInstanceOf(
RateLimitedEvmJsonRPCBlockRepository
);
expect(repos.getAlgorandRepository()).toBeInstanceOf(RateLimitedAlgorandJsonRPCBlockRepository);
expect(repos.getAptosRepository()).toBeInstanceOf(RateLimitedAptosJsonRPCBlockRepository);
expect(repos.getMetadataRepository()).toBeInstanceOf(FileMetadataRepository);
Expand Down
7 changes: 7 additions & 0 deletions blockchain-watcher/test/mocks/configMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ export const configMock = (): Config => {
rpcs: ["http://localhost"],
timeout: 10000,
},
unichain: {
name: "unichain",
network: "testnet",
chainId: 44,
rpcs: ["http://localhost"],
timeout: 10000,
},
evmos: {
name: "evmos",
network: "testnet",
Expand Down
3 changes: 2 additions & 1 deletion deploy/blockchain-watcher/env/production-mainnet.env
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ TERRA_RPCS='["https://terra-classic-rpc.publicnode.com:443"]'
TERRA2_RPCS='["https://terra-rpc.polkachu.com","https://rpc-terra-01.stakeflow.io","https://terra-rpc.publicnode.com:443"]'
OASIS_RPCS='["https://emerald.oasis.dev"]'
SNAXCHAIN_RPCS='["https://mainnet.snaxchain.io/"]'
BERACHAIN_RPCS=
BERACHAIN_RPCS=
UNICHAIN_RPCS=
3 changes: 2 additions & 1 deletion deploy/blockchain-watcher/env/production-testnet.env
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ ETHEREUM_RPCS=
TERRA_RPCS=
TERRA2_RPCS=
NEAR_RPCS=
BERACHAIN_RPCS=
BERACHAIN_RPCS=
UNICHAIN_RPCS=
3 changes: 2 additions & 1 deletion deploy/blockchain-watcher/env/staging-mainnet.env
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ TERRA_RPCS='["https://terra-classic-rpc.publicnode.com:443"]'
TERRA2_RPCS='["https://terra-rpc.polkachu.com","https://rpc-terra-01.stakeflow.io","https://terra-rpc.publicnode.com:443"]'
OASIS_RPCS='["https://emerald.oasis.dev"]'
SNAXCHAIN_RPCS='["https://mainnet.snaxchain.io/"]'
BERACHAIN_RPCS=
BERACHAIN_RPCS=
UNICHAIN_RPCS=
3 changes: 2 additions & 1 deletion deploy/blockchain-watcher/env/staging-testnet.env
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ ETHEREUM_RPCS=
TERRA_RPCS=
TERRA2_RPCS=
NEAR_RPCS=
BERACHAIN_RPCS=
BERACHAIN_RPCS=
UNICHAIN_RPCS=
80 changes: 39 additions & 41 deletions deploy/blockchain-watcher/workers/source-events-3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,45 @@ data:
}
}
]
},
{
"id": "poll-log-message-published-unichain-latest",
"chain": "unichain",
"source": {
"repository": "evmRepo",
"action": "PollEvm",
"config": {
"blockBatchSize": 100,
"commitment": "latest",
"interval": 5000,
"filters": [
{
"addresses": ["0xBB73cB66C26740F31d1FabDC6b7A46a038A300dd"],
"type": "Portal Token Bridge",
"topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
}
],
"chain": "unichain",
"chainId": 44
}
},
"handlers": [
{
"action": "HandleEvmLogs",
"target": "sns",
"mapper": "evmLogMessagePublishedMapper",
"config": {
"abis": [
{
"abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
"topic": "0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2",
"type": "Portal Token Bridge"
}
],
"metricName": "process_source_event"
}
}
]
}
]
mainnet-jobs.json: |-
Expand Down Expand Up @@ -363,47 +402,6 @@ data:
}
]
},
{
"id": "poll-log-message-published-terra-immediate",
"chain": "terra",
"source": {
"action": "PollCosmos",
"repository": "cosmosRepo",
"config": {
"blockBatchSize": 100,
"commitment": "immediate",
"environment": "mainnet",
"interval": 60000,
"filter": {
"addresses": [
"terra1dq03ugtd40zu9hcgdzrsq6z2z4hwhc9tqk2uy5"
]
},
"chain": "terra",
"chainId": 3
}
},
"handlers": [
{
"action": "HandleCosmosTransactions",
"target": "sns",
"mapper": "cosmosLogMessagePublishedMapper",
"config": {
"filter": {
"addresses": [
"terra1dq03ugtd40zu9hcgdzrsq6z2z4hwhc9tqk2uy5"
]
},
"metricName": "process_source_event",
"metricLabels": {
"job": "poll-log-message-published-terra",
"chain": "terra",
"commitment": "immediate"
}
}
}
]
},
{
"id": "poll-log-message-published-terra2-immediate",
"chain": "terra2",
Expand Down
35 changes: 35 additions & 0 deletions deploy/blockchain-watcher/workers/target-events-3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,41 @@ data:
}
}
]
},
{
"id": "poll-redeemed-transactions-unichain-latest",
"chain": "unichain",
"source": {
"action": "PollEvm",
"repository": "evmRepo",
"records": "GetEvmTransactions",
"config": {
"blockBatchSize": 100,
"commitment": "latest",
"environment": "testnet",
"interval": 15000,
"filters": [
{
"addresses": [],
"type": "Portal Token Bridge (Connect, Portico, Omniswap, tBTC, etc)",
"topics": ["0xcaf280c8cfeba144da67230d9b009c8f868a75bac9a528fa0474be1ba317c169"],
"strategy": "GetTransactionsByLogFiltersStrategy"
}
],
"chain": "unichain",
"chainId": 44
}
},
"handlers": [
{
"action": "HandleEvmTransactions",
"target": "sns",
"mapper": "evmRedeemedTransactionFoundMapper",
"config": {
"metricName": "process_vaa_event"
}
}
]
}
]
mainnet-jobs.json: |-
Expand Down

0 comments on commit f89c8e8

Please sign in to comment.