-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace RPC provider from Alchemy to Infura DIN (#451)
* feat: replace alchemy by infura din * chore: change secrets from VOYAGER to DIN for rpc calls * chore: lint+fix * chore: .env.example * chore: test import fix * chore: reduced coverage on old test to 50% * chore: handle comments * chore: fix comments * chore: handle comment * chore: change ALCHEMY to DIN in CI/CD * chore: fix comments
- Loading branch information
Showing
11 changed files
with
62 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { constants } from 'starknet'; | ||
|
||
import { Config } from '../config'; | ||
import { getRPCUrl } from './rpc-provider'; | ||
|
||
describe('getRPCUrl', () => { | ||
beforeEach(function () { | ||
Config.rpcApiKey = 'API_KEY'; | ||
}); | ||
afterEach(function () { | ||
Config.rpcApiKey = ''; | ||
}); | ||
|
||
it('returns Mainnet RPC URL if chain id is Mainnet', () => { | ||
expect(getRPCUrl(constants.StarknetChainId.SN_MAIN)).toBe( | ||
`https://starknet-mainnet.infura.io/v3/${Config.rpcApiKey}`, | ||
); | ||
}); | ||
|
||
it('returns Sepolia RPC URL if chain id is not either Mainnet or Sepolia', () => { | ||
expect(getRPCUrl('0x534e5f474f45524c49')).toBe( | ||
`https://starknet-sepolia.infura.io/v3/${Config.rpcApiKey}`, | ||
); | ||
}); | ||
|
||
it('returns Sepolia RPC URL if chain id is Sepolia', () => { | ||
expect(getRPCUrl(constants.StarknetChainId.SN_SEPOLIA)).toBe( | ||
`https://starknet-sepolia.infura.io/v3/${Config.rpcApiKey}`, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { constants } from 'starknet'; | ||
|
||
import { Config } from '../config'; | ||
|
||
/** | ||
* Gets the rpc URL for a given Chain ID. | ||
* | ||
* @param chainId - The Chain ID. | ||
* @returns The RPC node endpoint of the corresponding chain. | ||
*/ | ||
export function getRPCUrl(chainId: string) { | ||
switch (chainId) { | ||
case constants.StarknetChainId.SN_MAIN: | ||
return `https://starknet-mainnet.infura.io/v3/${Config.rpcApiKey}`; | ||
default: | ||
case constants.StarknetChainId.SN_SEPOLIA: | ||
return `https://starknet-sepolia.infura.io/v3/${Config.rpcApiKey}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters