mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
add moonriver support (#900)
* add moonriver * bump ocean.js to v0.19.2 * fix network display * maybe fix that damn git+ssh problem * specific detection for moonriver in Web3Provider too * fix code comment link * fix network switch button for Moonriver * compute success message tweak Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
This commit is contained in:
parent
32688892bc
commit
6598071f81
@ -10,10 +10,10 @@ module.exports = {
|
|||||||
|
|
||||||
// List of chainIds which metadata cache queries will return by default.
|
// List of chainIds which metadata cache queries will return by default.
|
||||||
// This preselects the Chains user preferences.
|
// This preselects the Chains user preferences.
|
||||||
chainIds: [1, 137, 56],
|
chainIds: [1, 137, 56, 1285],
|
||||||
|
|
||||||
// List of all supported chainIds. Used to populate the Chains user preferences list.
|
// List of all supported chainIds. Used to populate the Chains user preferences list.
|
||||||
chainIdsSupported: [1, 3, 4, 137, 80001, 1287, 56, 2021000],
|
chainIdsSupported: [1, 3, 4, 137, 80001, 1287, 56, 2021000, 1285],
|
||||||
|
|
||||||
rbacUrl: process.env.GATSBY_RBAC_URL,
|
rbacUrl: process.env.GATSBY_RBAC_URL,
|
||||||
|
|
||||||
|
15277
package-lock.json
generated
15277
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -28,7 +28,7 @@
|
|||||||
"@coingecko/cryptoformat": "^0.4.4",
|
"@coingecko/cryptoformat": "^0.4.4",
|
||||||
"@loadable/component": "^5.15.0",
|
"@loadable/component": "^5.15.0",
|
||||||
"@oceanprotocol/art": "^3.2.0",
|
"@oceanprotocol/art": "^3.2.0",
|
||||||
"@oceanprotocol/lib": "^0.19.0",
|
"@oceanprotocol/lib": "^0.19.2",
|
||||||
"@oceanprotocol/typographies": "^0.1.0",
|
"@oceanprotocol/typographies": "^0.1.0",
|
||||||
"@portis/web3": "^4.1.0",
|
"@portis/web3": "^4.1.0",
|
||||||
"@sindresorhus/slugify": "^2.1.0",
|
"@sindresorhus/slugify": "^2.1.0",
|
||||||
|
@ -23,9 +23,14 @@ export function filterNetworksByType(
|
|||||||
// HEADS UP! Only networkData.network === 'mainnet' is consistent
|
// HEADS UP! Only networkData.network === 'mainnet' is consistent
|
||||||
// while not every test network in the network data has 'testnet'
|
// while not every test network in the network data has 'testnet'
|
||||||
// in its place. So for the 'testnet' case filter for all non-'mainnet'.
|
// in its place. So for the 'testnet' case filter for all non-'mainnet'.
|
||||||
|
//
|
||||||
|
// HEADS UP NO. 2! We hack in mainnet detection for moonriver as their
|
||||||
|
// network data uses the `network` key wrong over in
|
||||||
|
// https://github.com/ethereum-lists/chains/blob/master/_data/chains/eip155-1285.json
|
||||||
|
//
|
||||||
return type === 'mainnet'
|
return type === 'mainnet'
|
||||||
? networkData.network === type
|
? networkData.network === type || networkData.network === 'moonriver'
|
||||||
: networkData.network !== 'mainnet'
|
: networkData.network !== 'mainnet' && networkData.network !== 'moonriver'
|
||||||
})
|
})
|
||||||
return finalNetworks
|
return finalNetworks
|
||||||
}
|
}
|
||||||
|
@ -465,10 +465,7 @@ export default function Compute({
|
|||||||
|
|
||||||
<footer className={styles.feedback}>
|
<footer className={styles.feedback}>
|
||||||
{isPublished && (
|
{isPublished && (
|
||||||
<SuccessConfetti
|
<SuccessConfetti success="Your job started successfully! Watch the progress below or on your profile." />
|
||||||
success="Your job started successfully! Watch the progress on the history page."
|
|
||||||
action={<SuccessAction />}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</footer>
|
</footer>
|
||||||
{accountId && (
|
{accountId && (
|
||||||
|
@ -258,7 +258,9 @@ function Web3Provider({ children }: { children: ReactNode }): ReactElement {
|
|||||||
setNetworkDisplayName(networkDisplayName)
|
setNetworkDisplayName(networkDisplayName)
|
||||||
|
|
||||||
// Figure out if we're on a chain's testnet, or not
|
// Figure out if we're on a chain's testnet, or not
|
||||||
setIsTestnet(networkData?.network !== 'mainnet')
|
setIsTestnet(
|
||||||
|
networkData?.network !== 'mainnet' && networkData.network !== 'moonriver'
|
||||||
|
)
|
||||||
|
|
||||||
Logger.log(`[web3] Network display name set to: ${networkDisplayName}`)
|
Logger.log(`[web3] Network display name set to: ${networkDisplayName}`)
|
||||||
}, [networkId, networksList])
|
}, [networkId, networksList])
|
||||||
|
@ -56,11 +56,14 @@ export function getNetworkDisplayName(
|
|||||||
let displayName
|
let displayName
|
||||||
|
|
||||||
switch (networkId) {
|
switch (networkId) {
|
||||||
|
case 137:
|
||||||
|
displayName = 'Polygon'
|
||||||
|
break
|
||||||
case 1287:
|
case 1287:
|
||||||
displayName = 'Moonbase Alpha'
|
displayName = 'Moonbase Alpha'
|
||||||
break
|
break
|
||||||
case 137:
|
case 1285:
|
||||||
displayName = 'Polygon'
|
displayName = 'Moonriver'
|
||||||
break
|
break
|
||||||
case 80001:
|
case 80001:
|
||||||
displayName = 'Polygon Mumbai'
|
displayName = 'Polygon Mumbai'
|
||||||
@ -94,24 +97,31 @@ export async function addCustomNetwork(
|
|||||||
web3Provider: any,
|
web3Provider: any,
|
||||||
network: EthereumListsChain
|
network: EthereumListsChain
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const newNewtworkData = {
|
// Always add explorer URL from ocean.js first, as it's null sometimes
|
||||||
|
// in network data
|
||||||
|
const blockExplorerUrls = [
|
||||||
|
getOceanConfig(network.networkId).explorerUri,
|
||||||
|
network.explorers && network.explorers[0].url
|
||||||
|
]
|
||||||
|
|
||||||
|
const newNetworkData = {
|
||||||
chainId: `0x${network.chainId.toString(16)}`,
|
chainId: `0x${network.chainId.toString(16)}`,
|
||||||
chainName: getNetworkDisplayName(network, network.chainId),
|
chainName: getNetworkDisplayName(network, network.chainId),
|
||||||
nativeCurrency: network.nativeCurrency,
|
nativeCurrency: network.nativeCurrency,
|
||||||
rpcUrls: network.rpc,
|
rpcUrls: network.rpc,
|
||||||
blockExplorerUrls: [network.explorers[0].url]
|
blockExplorerUrls
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await web3Provider.request({
|
await web3Provider.request({
|
||||||
method: 'wallet_switchEthereumChain',
|
method: 'wallet_switchEthereumChain',
|
||||||
params: [{ chainId: newNewtworkData.chainId }]
|
params: [{ chainId: newNetworkData.chainId }]
|
||||||
})
|
})
|
||||||
} catch (switchError) {
|
} catch (switchError) {
|
||||||
if (switchError.code === 4902) {
|
if (switchError.code === 4902) {
|
||||||
await web3Provider.request(
|
await web3Provider.request(
|
||||||
{
|
{
|
||||||
method: 'wallet_addEthereumChain',
|
method: 'wallet_addEthereumChain',
|
||||||
params: [newNewtworkData]
|
params: [newNetworkData]
|
||||||
},
|
},
|
||||||
(err: string, added: any) => {
|
(err: string, added: any) => {
|
||||||
if (err || 'error' in added) {
|
if (err || 'error' in added) {
|
||||||
|
Loading…
Reference in New Issue
Block a user