Skip to content

Commit

Permalink
feat: Upgrade packages to support polygon amoy testnet (#1759)
Browse files Browse the repository at this point in the history
* feat: upgrade decentraland-gatsby package

* feat: upgrade @dcl/schemas package

* feat: upgrade decentraland-dapps package

* feat: upgrade dcl-catalyst-client package

* feat: Update references from goerli to sepolia

* feat: Add polygon amoy support
  • Loading branch information
cyaiox authored Apr 24, 2024
1 parent 5406e8f commit a0ed1bb
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 272 deletions.
488 changes: 255 additions & 233 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"homepage": "https://github.com/decentraland/governance#readme",
"dependencies": {
"@dcl/feature-flags": "^1.2.0",
"@dcl/schemas": "^10.2.0",
"@dcl/schemas": "^11.5.0",
"@dcl/ui-env": "1.3.0",
"@jparnaudo/react-crypto-icons": "^1.0.5",
"@otterspace-xyz/contracts": "^2.7.3",
Expand All @@ -74,9 +74,9 @@
"cssnano": "^6.0.1",
"dayjs": "^1.11.9",
"dayjs-precise-range": "^1.0.1",
"dcl-catalyst-client": "^21.5.5",
"decentraland-dapps": "^19.3.4",
"decentraland-gatsby": "^5.110.0",
"dcl-catalyst-client": "^21.7.0",
"decentraland-dapps": "^19.6.0",
"decentraland-gatsby": "^5.111.0",
"decentraland-ui": "^5.14.0",
"discord.js": "^14.7.1",
"dompurify": "^2.3.3",
Expand Down Expand Up @@ -188,7 +188,7 @@
"*.{js,jsx,ts,tsx,css,json}": "prettier --write"
},
"overrides": {
"@dcl/schemas": "^10.2.0",
"@dcl/schemas": "^11.5.0",
"decentraland-connect": "5.2.4"
}
}
9 changes: 3 additions & 6 deletions src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,17 @@ export default function Layout({ children }: LayoutProps) {
return { ETHEREUM, MATIC }
}

case ChainId.ETHEREUM_SEPOLIA:
case ChainId.ETHEREUM_GOERLI:
case ChainId.ETHEREUM_RINKEBY:
case ChainId.ETHEREUM_ROPSTEN: {
case ChainId.ETHEREUM_SEPOLIA: {
const [ETHEREUM, MATIC] = await Promise.all([
fetchManaBalance(user, chainId),
fetchManaBalance(user, ChainId.MATIC_MUMBAI),
fetchManaBalance(user, ChainId.MATIC_AMOY),
])

return { ETHEREUM, MATIC }
}

case ChainId.MATIC_MAINNET:
case ChainId.MATIC_MUMBAI: {
case ChainId.MATIC_AMOY: {
const MATIC = await fetchManaBalance(user, chainId)
return { MATIC }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ function AccountsConnectModal({ open, onClose, account }: Props) {
}, [openDiscordChannel])

const [user, userState] = useAuthContext()
const chainId = userState.chainId || ChainId.ETHEREUM_GOERLI
const chainId = userState.chainId || ChainId.ETHEREUM_SEPOLIA
const env = getPushNotificationsEnv(chainId)
const [pushState, setPushState] = useState<'subscribing' | 'success' | 'error' | null>(null)

Expand Down
2 changes: 1 addition & 1 deletion src/components/Notifications/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function Notifications() {
const t = useFormatMessage()
const [user, userState] = useAuthContext()
const [isOpen, setOpen] = useState(false)
const chainId = userState.chainId || ChainId.ETHEREUM_GOERLI
const chainId = userState.chainId || ChainId.ETHEREUM_SEPOLIA
const queryClient = useQueryClient()
const lastNotificationQueryKey = `lastNotificationId#${user}`
const [isNewFeatureDismissed, setIsNewFeatureDismissed] = useState(
Expand Down
2 changes: 1 addition & 1 deletion src/components/Notifications/NotificationsFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function NotificationsFeed({
}

useClickOutside('.NotificationsFeed', isOpen, handleOnClose)
const chainId = userState.chainId || ChainId.ETHEREUM_GOERLI
const chainId = userState.chainId || ChainId.ETHEREUM_SEPOLIA
const env = getPushNotificationsEnv(chainId)

const handleSubscribeUserToChannel = async () => {
Expand Down
21 changes: 4 additions & 17 deletions src/front/context/useAuth.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,7 @@ import { ErrorClient } from '../../clients/ErrorClient'
import identify from './auth/identify'
import { setCurrentIdentity } from './auth/storage'

export const chains = [
ChainId.ETHEREUM_MAINNET,
ChainId.ETHEREUM_ROPSTEN,
ChainId.ETHEREUM_GOERLI,
ChainId.ETHEREUM_KOVAN,
ChainId.ETHEREUM_RINKEBY,
ChainId.ETHEREUM_SEPOLIA,
ChainId.MATIC_MAINNET,
ChainId.MATIC_MUMBAI,
]
export const chains = [ChainId.ETHEREUM_MAINNET, ChainId.ETHEREUM_SEPOLIA, ChainId.MATIC_MAINNET, ChainId.MATIC_AMOY]

export enum AuthEvent {
Connect = 'Connect',
Expand Down Expand Up @@ -228,7 +219,7 @@ export function getAddEthereumChainParameters(chainId: ChainId): AddEthereumChai
rpcUrls: ['https://rpc-mainnet.maticvigil.com/'],
blockExplorerUrls: ['https://polygonscan.com/'],
}
case ChainId.MATIC_MUMBAI:
case ChainId.MATIC_AMOY:
return {
chainId: hexChainId,
chainName,
Expand All @@ -237,14 +228,10 @@ export function getAddEthereumChainParameters(chainId: ChainId): AddEthereumChai
symbol: 'MATIC',
decimals: 18,
},
rpcUrls: ['https://rpc-mumbai.maticvigil.com/'],
blockExplorerUrls: ['https://mumbai.polygonscan.com/'],
rpcUrls: ['https://rpc.decentraland.org/amoy'],
blockExplorerUrls: ['https://oklink.com/amoy'],
}
case ChainId.ETHEREUM_MAINNET:
case ChainId.ETHEREUM_ROPSTEN:
case ChainId.ETHEREUM_RINKEBY:
case ChainId.ETHEREUM_KOVAN:
case ChainId.ETHEREUM_GOERLI:
case ChainId.ETHEREUM_SEPOLIA:
default:
return {
Expand Down
2 changes: 0 additions & 2 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ export function getEnvironmentChainId() {
switch (chainId) {
case ChainId.ETHEREUM_MAINNET.valueOf():
return ChainId.ETHEREUM_MAINNET
case ChainId.ETHEREUM_GOERLI:
return ChainId.ETHEREUM_GOERLI
case ChainId.ETHEREUM_SEPOLIA:
return ChainId.ETHEREUM_SEPOLIA
default:
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/usePushSubscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { FIVE_MINUTES_MS } from './constants'

export default function usePushSubscriptions() {
const [user, userState] = useAuthContext()
const chainId = userState.chainId || ChainId.ETHEREUM_GOERLI
const chainId = userState.chainId || ChainId.ETHEREUM_SEPOLIA
const env = getPushNotificationsEnv(chainId)

const { data: subscriptions, isLoading: isLoadingPushSubscriptions } = useQuery({
Expand Down
7 changes: 3 additions & 4 deletions src/utils/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export { default as RegisterABI } from './abi/Register.abi.json'
// MANA
export const MANA: Record<number, string | null | undefined> = {
[ChainId.ETHEREUM_MAINNET]: '0x0f5d2fb29fb7d3cfee444a200298f468908cc942',
[ChainId.ETHEREUM_RINKEBY]: '0x28BcE5263f5d7F4EB7e8C6d5d78275CA455BAc63',
[ChainId.ETHEREUM_GOERLI]: '0xe7fDae84ACaba2A5Ba817B6E6D8A2d415DBFEdbe',
[ChainId.ETHEREUM_SEPOLIA]: '0xfa04d2e2ba9aec166c93dfeeba7427b2303befa9',
}

export const wMANA: Record<number, string | null | undefined> = {
Expand All @@ -18,10 +17,10 @@ export const wMANA: Record<number, string | null | undefined> = {

export const LAND: Record<number, string | null | undefined> = {
[ChainId.ETHEREUM_MAINNET]: '0xf87e31492faf9a91b02ee0deaad50d51d56d5d4d',
[ChainId.ETHEREUM_GOERLI]: '0x25b6B4bac4aDB582a0ABd475439dA6730777Fbf7',
[ChainId.ETHEREUM_SEPOLIA]: '0x42f4ba48791e2de32f5fbf553441c2672864bb33',
}

export const ESTATE: Record<number, string | null | undefined> = {
[ChainId.ETHEREUM_MAINNET]: '0x959e104e1a4db6317fa58f8295f586e1a978c297',
[ChainId.ETHEREUM_GOERLI]: '0xC9A46712E6913c24d15b46fF12221a79c4e251DC',
[ChainId.ETHEREUM_SEPOLIA]: '0x369a7fbe718c870c79f99fb423882e8dd8b20486',
}
2 changes: 1 addition & 1 deletion src/utils/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getPushNotificationsEnv(chainId: ChainId) {
switch (chainId) {
case ChainId.ETHEREUM_MAINNET:
return ENV.PROD
case ChainId.ETHEREUM_GOERLI:
case ChainId.ETHEREUM_SEPOLIA:
default:
return ENV.STAGING
}
Expand Down

0 comments on commit a0ed1bb

Please sign in to comment.