Skip to content

Commit

Permalink
Merge pull request #229 from NethermindEth/sepolia_support
Browse files Browse the repository at this point in the history
add sepolia support
  • Loading branch information
rjnrohit authored Jan 23, 2024
2 parents 3b5825a + 816eae7 commit d81a694
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 35 deletions.
2 changes: 1 addition & 1 deletion plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.12.0",
"starknet": "5.19.5",
"starknet": "5.26.1",
"starknet-abi-forms": "^0.1.5",
"vite-plugin-svgr": "^4.2.0",
"web-vitals": "^2.1.4",
Expand Down
95 changes: 69 additions & 26 deletions plugin/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion plugin/src/components/BackgroundNotices/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import './style.css'
const Notices = [
'The starknet Remix Plugin is in Alpha',
'Cairo contracts and Scarb workspaces are compiled on a server hosted by Nethermind',
'Declaration of contracts with some wallets will be supported when they update to the latest starknet.js version'
'Declaration of contracts with some wallets will be supported when they update to the latest starknet.js version',
'Sepolia support is experimental'
]

const BackgroundNotices: React.FC = () => {
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/components/ManualAccount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ const ManualAccount: React.FC = () => {
</div>
)}

{selectedAccount != null && networkName === 'goerli' && (
{selectedAccount != null && (networkName === 'goerli' || networkName === 'sepolia') && (
<button
className="btn btn-primary w-100-btn"
onClick={() => {
Expand All @@ -417,7 +417,7 @@ const ManualAccount: React.FC = () => {
})
setTimeout(() => {
window?.open(
'https://faucet.goerli.starknet.io/',
`https://faucet.${networkName}.starknet.io/`,
'_blank',
'noopener noreferrer'
)
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/components/starknet/starknet-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { goerli, mainnet } from '@starknet-react/chains'
import { sepolia, goerli, mainnet } from '@starknet-react/chains'
import {
StarknetConfig,
publicProvider,
Expand All @@ -23,7 +23,7 @@ export function StarknetProvider ({ children }: { children: React.ReactNode }):

return (
<StarknetConfig
chains={[mainnet, goerli]}
chains={[mainnet, goerli, sepolia]}
provider={publicProvider()}
connectors={connectors}
>
Expand Down
8 changes: 8 additions & 0 deletions plugin/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,49 @@ const devnetUrl = 'http://127.0.0.1:5050'

type Network =
| 'goerli'
| 'sepolia'
| 'mainnet'

const networks = [
{ name: 'Testnet', value: 'goerli' },
{ name: 'Sepolia', value: 'sepolia' },
{ name: 'Mainnet', value: 'mainnet' }
]

const networkExplorerUrls = {
voyager: {
goerli: 'https://goerli.voyager.online',
sepolia: 'https://sepolia.voyager.online',
mainnet: 'https://voyager.online'
},
starkscan: {
goerli: 'https://testnet.starkscan.co',
sepolia: 'https://sepolia.starkscan.co',
mainnet: 'https://starkscan.co'
}
}

const networkEquivalents = new Map([
['goerli', constants.StarknetChainId.SN_GOERLI],
['sepolia', constants.StarknetChainId.SN_SEPOLIA],
['mainnet', constants.StarknetChainId.SN_MAIN]
])

const networkEquivalentsRev = new Map([
[constants.StarknetChainId.SN_GOERLI, 'goerli'],
[constants.StarknetChainId.SN_SEPOLIA, 'sepolia'],
[constants.StarknetChainId.SN_MAIN, 'mainnet']
])

const networkNameEquivalents = new Map([
['goerli', constants.NetworkName.SN_GOERLI],
['sepolia', constants.NetworkName.SN_SEPOLIA],
['mainnet', constants.NetworkName.SN_MAIN]
])

const networkNameEquivalentsRev = new Map([
[constants.NetworkName.SN_GOERLI, 'goerli'],
[constants.NetworkName.SN_SEPOLIA, 'sepolia'],
[constants.NetworkName.SN_MAIN, 'mainnet']
])

Expand Down
4 changes: 4 additions & 0 deletions plugin/src/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const getProvider = (network: string): RpcProvider => {
return new RpcProvider({
nodeUrl: 'https://rpc.starknet-testnet.lava.build'
})
case 'sepolia':
return new RpcProvider({
nodeUrl: 'https://free-rpc.nethermind.io/sepolia-juno'
})
case devnetUrl:
return new RpcProvider({
// TODO: Let user chose port eventually.
Expand Down
7 changes: 5 additions & 2 deletions plugin/src/utils/starknet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { BigNumber } from 'ethers'

import { type ParameterMetadata, ParameterType } from './types/contracts'

export enum StarknetChainId {
enum StarknetChainId {
SN_MAIN = '0x534e5f4d41494e',
SN_GOERLI = '0x534e5f474f45524c49'
SN_GOERLI = '0x534e5f474f45524c49',
SN_SEPOLIA = '0x534e5f5345504f4c4941'
}

export function getChainName (chainId: string): string {
Expand All @@ -14,6 +15,8 @@ export function getChainName (chainId: string): string {
return 'mainnet'
case StarknetChainId.SN_GOERLI:
return 'goerli'
case StarknetChainId.SN_SEPOLIA:
return 'sepolia'
default:
return 'unknown'
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/utils/types/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { type BigNumberish } from 'ethers'
enum StarknetChainId {
SN_MAIN = '0x534e5f4d41494e',
SN_GOERLI = '0x534e5f474f45524c49',
SN_GOERLI2 = '0x534e5f474f45524c4932',
SN_SEPOLIA = '0x534e5f5345504f4c4941'
}

interface DevnetAccount {
Expand Down

0 comments on commit d81a694

Please sign in to comment.