Skip to content

Commit

Permalink
Networks: Add sonic
Browse files Browse the repository at this point in the history
  • Loading branch information
PatricioHenderson committed Jan 21, 2025
1 parent b73cd14 commit 46e7416
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,20 @@ jobs:
VERSION_LABEL: ${{ github.sha }}
run: yarn deploy:polygon

deploy-sonic:
name: Deploy Sonic
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- name: Deploy Sonic
env:
GRAPH_KEY: ${{ secrets.GRAPH_STUDIO_KEY }}
VERSION_LABEL: ${{ github.sha }}
run: yarn deploy:sonic

deploy-zkevm:
name: Deploy zkEVM
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"build:mainnet": "NETWORK=mainnet ./scripts/build.sh",
"build:optimism": "NETWORK=optimism ./scripts/build.sh",
"build:polygon": "NETWORK=polygon ./scripts/build.sh",
"build:sonic": "NETWORK=sonic ./scripts/build.sh",
"build:zkevm": "NETWORK=zkevm ./scripts/build.sh",
"deploy:arbitrum": "NETWORK=arbitrum ./scripts/deploy.sh",
"deploy:aurora": "NETWORK=aurora ./scripts/deploy.sh",
Expand All @@ -26,6 +27,7 @@
"deploy:mainnet": "NETWORK=mainnet ./scripts/deploy.sh",
"deploy:optimism": "NETWORK=optimism ./scripts/deploy.sh",
"deploy:polygon": "NETWORK=polygon ./scripts/deploy.sh",
"deploy:sonic": "NETWORK=sonic ./scripts/build.sh",
"deploy:zkevm": "NETWORK=zkevm ./scripts/deploy.sh"
},
"dependencies": {
Expand Down
13 changes: 11 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ relayer_3_polygon=0x9E0A538749A486bbF127F8848a6f2CF4e1e92DbD
feeController_polygon=0x88586bfc840b99680c8cc753a36b51999608b1f6
block_polygon=49350048

# Sonic
registry_sonic=0x1675BF3F75046aCd131caD845eb8FF3Bed49a643
deployer_sonic=0x849B7B1102B0dcf6eC10f98b81C8D1c38f7cbf24
relayer_1_sonic=0xD7252C026c3cA28D73B4DeeF62FE6ADe86eC17A9
relayer_2_sonic=0x54FC6E302043aAF56154e8B4A7F01645eDAdA906
relayer_3_sonic=0x9E0A538749A486bbF127F8848a6f2CF4e1e92DbD
feeController_sonic=0x88586bfc840b99680c8cc753a36b51999608b1f6
block_sonic=1988191

# zkEVM
registry_zkevm=0x1675BF3F75046aCd131caD845eb8FF3Bed49a643
deployer_zkevm=0x849B7B1102B0dcf6eC10f98b81C8D1c38f7cbf24
Expand All @@ -103,9 +112,9 @@ feeController_zkevm=0x88586bfc840b99680c8cc753a36b51999608b1f6
block_zkevm=6788022

# Validate network
networks=(arbitrum aurora avalanche base bsc fantom gnosis mainnet optimism polygon zkevm)
networks=(arbitrum aurora avalanche base bsc fantom gnosis mainnet optimism polygon sonic zkevm)
if [[ -z $NETWORK || ! " ${networks[@]} " =~ " ${NETWORK} " ]]; then
echo 'Please make sure the network provided is either: arbitrum, aurora, avalanche, base, bsc, fantom, gnosis, mainnet, optimism, polygon, or zkevm.'
echo 'Please make sure the network provided is either: arbitrum, aurora, avalanche, base, bsc, fantom, gnosis, mainnet, optimism, polygon, sonic, or zkevm.'
exit 1
fi

Expand Down
7 changes: 6 additions & 1 deletion src/Networks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BigInt, dataSource } from '@graphprotocol/graph-ts'

export function isEthNetwork(): boolean {
return isMainnet() || isArbitrum() || isOptimism() || isBase() || isZkEvm() || isAurora()
return isMainnet() || isArbitrum() || isOptimism() || isBase() || isZkEvm() || isAurora() || isSonic()
}

export function isMainnet(): boolean {
Expand Down Expand Up @@ -48,6 +48,10 @@ export function isAurora(): boolean {
return dataSource.network() == 'aurora'
}

export function isSonic(): boolean {
return dataSource.network() == 'sonic'
}

export function getNetworkId(): BigInt {
if (isMainnet()) return BigInt.fromI32(1)
if (isArbitrum()) return BigInt.fromI32(42161)
Expand All @@ -60,5 +64,6 @@ export function getNetworkId(): BigInt {
if (isZkEvm()) return BigInt.fromI32(1101)
if (isBase()) return BigInt.fromI32(8453)
if (isAurora()) return BigInt.fromI32(1313161554)
if (isSonic()) return BigInt.fromI32(146)
return BigInt.fromI32(0)
}

0 comments on commit 46e7416

Please sign in to comment.