Skip to content

Commit bfd2f8c

Browse files
authored
Merge pull request #298 from oasisprotocol/ml/backport/oasis-web3-gateway
Use Oasis Web3 gateway
2 parents f968c4d + 2d85513 commit bfd2f8c

File tree

4 files changed

+11
-114
lines changed

4 files changed

+11
-114
lines changed

.changelog/298.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Backport update Web3 gateway

home/src/constants/wagmi-config.ts

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
11
import { getDefaultConfig } from '@rainbow-me/rainbowkit'
2-
import { defineChain } from 'viem'
3-
import { sapphireTestnet } from 'viem/chains'
4-
5-
export const SAPPHIRE_1RPC_CHAIN_CONFIG = defineChain({
6-
id: 23294,
7-
name: 'Oasis Sapphire',
8-
network: 'sapphire',
9-
nativeCurrency: { name: 'Sapphire Rose', symbol: 'ROSE', decimals: 18 },
10-
rpcUrls: {
11-
default: {
12-
http: ['https://1rpc.io/oasis/sapphire'],
13-
},
14-
},
15-
blockExplorers: {
16-
default: {
17-
name: 'Oasis Explorer',
18-
url: 'https://explorer.oasis.io/mainnet/sapphire',
19-
},
20-
},
21-
contracts: {
22-
multicall3: {
23-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
24-
blockCreated: 734531,
25-
},
26-
},
27-
})
2+
import { sapphire, sapphireTestnet } from 'viem/chains'
283

294
const { VITE_WALLET_CONNECT_PROJECT_ID, PROD } = import.meta.env
305

@@ -37,7 +12,7 @@ declare module 'wagmi' {
3712
export const wagmiConfig: ReturnType<typeof getDefaultConfig> = getDefaultConfig({
3813
appName: 'ROSE Stake',
3914
projectId: VITE_WALLET_CONNECT_PROJECT_ID,
40-
chains: [PROD ? SAPPHIRE_1RPC_CHAIN_CONFIG : sapphireTestnet],
15+
chains: [PROD ? sapphire : sapphireTestnet],
4116
ssr: false,
4217
batch: {
4318
multicall: false,

stake/src/constants/config.ts

Lines changed: 4 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,9 @@
1-
import { Chain, defineChain } from 'viem'
2-
3-
export const SAPPHIRE_CHAIN_CONFIG = defineChain({
4-
id: 23294,
5-
name: 'Oasis Sapphire',
6-
network: 'sapphire',
7-
nativeCurrency: { name: 'Sapphire Rose', symbol: 'ROSE', decimals: 18 },
8-
rpcUrls: {
9-
default: {
10-
http: ['https://sapphire.oasis.io'],
11-
webSocket: ['wss://sapphire.oasis.io/ws'],
12-
},
13-
},
14-
blockExplorers: {
15-
default: {
16-
name: 'Oasis Explorer',
17-
url: 'https://explorer.oasis.io/mainnet/sapphire',
18-
},
19-
},
20-
contracts: {
21-
multicall3: {
22-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
23-
blockCreated: 734531,
24-
},
25-
},
26-
})
27-
28-
export const SAPPHIRE_1RPC_CHAIN_CONFIG = defineChain({
29-
id: 23294,
30-
name: 'Oasis Sapphire',
31-
network: 'sapphire',
32-
nativeCurrency: { name: 'Sapphire Rose', symbol: 'ROSE', decimals: 18 },
33-
rpcUrls: {
34-
default: {
35-
http: ['https://1rpc.io/oasis/sapphire'],
36-
},
37-
},
38-
blockExplorers: {
39-
default: {
40-
name: 'Oasis Explorer',
41-
url: 'https://explorer.oasis.io/mainnet/sapphire',
42-
},
43-
},
44-
contracts: {
45-
multicall3: {
46-
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
47-
blockCreated: 734531,
48-
},
49-
},
50-
})
51-
52-
export const SAPPHIRE_TESTNET_CHAIN_CONFIG = defineChain({
53-
id: 23295,
54-
name: 'Oasis Sapphire Testnet',
55-
network: 'sapphire-testnet',
56-
nativeCurrency: { name: 'Sapphire Test Rose', symbol: 'TEST', decimals: 18 },
57-
rpcUrls: {
58-
default: {
59-
http: ['https://testnet.sapphire.oasis.dev'],
60-
webSocket: ['wss://testnet.sapphire.oasis.dev/ws'],
61-
},
62-
},
63-
blockExplorers: {
64-
default: {
65-
name: 'Oasis Explorer',
66-
url: 'https://explorer.oasis.io/testnet/sapphire',
67-
},
68-
},
69-
testnet: true,
70-
})
1+
import { Chain } from 'viem'
2+
import { sapphire, sapphireTestnet } from 'viem/chains'
713

724
export const SUPPORTED_CHAIN_IDS: Record<number, Chain> = {
73-
[23294]: SAPPHIRE_1RPC_CHAIN_CONFIG,
74-
[23295]: SAPPHIRE_TESTNET_CHAIN_CONFIG,
5+
[23294]: sapphire,
6+
[23295]: sapphireTestnet,
757
}
768

779
export const NEXUS_BASE_URL_CONFIG: Map<number, string> = new Map([

stake/src/providers/Web3Provider.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
11
import { FC, PropsWithChildren, useEffect, useState } from 'react'
2-
import {
3-
GAS_LIMIT_STAKE,
4-
GAS_LIMIT_UNSTAKE,
5-
SAPPHIRE_1RPC_CHAIN_CONFIG,
6-
SAPPHIRE_CHAIN_CONFIG,
7-
SAPPHIRE_TESTNET_CHAIN_CONFIG,
8-
SUPPORTED_CHAIN_IDS,
9-
} from '../constants/config'
2+
import { GAS_LIMIT_STAKE, GAS_LIMIT_UNSTAKE, SUPPORTED_CHAIN_IDS } from '../constants/config'
103
import { Web3Context, Web3ProviderContext, Web3ProviderState } from './Web3Context'
114
import { consensusDelegate, consensusUndelegate } from '@oasisprotocol/rose-app-subcall'
125
import { useAccount, usePublicClient } from 'wagmi'
136
import { TransactionRequestLegacy, createPublicClient, http, PublicClient } from 'viem'
7+
import { sapphire, sapphireTestnet } from 'viem/chains'
148

159
const { PROD } = import.meta.env
1610

17-
/* eslint-disable indent */
1811
const clients: PublicClient[] = PROD
19-
? [
20-
createPublicClient({ chain: SAPPHIRE_1RPC_CHAIN_CONFIG, transport: http() }),
21-
createPublicClient({ chain: SAPPHIRE_CHAIN_CONFIG, transport: http() }),
22-
]
23-
: [createPublicClient({ chain: SAPPHIRE_TESTNET_CHAIN_CONFIG, transport: http() })]
24-
/* eslint-enable indent */
12+
? [createPublicClient({ chain: sapphire, transport: http() })]
13+
: [createPublicClient({ chain: sapphireTestnet, transport: http() })]
2514

2615
const web3ProviderInitialState: Web3ProviderState = {
2716
explorerBaseUrl: null,

0 commit comments

Comments
 (0)