From d65d99af1083342ad3f5c79fa518729688b28bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s?= Date: Mon, 20 May 2024 06:42:46 -0400 Subject: [PATCH] fix: explorer urls when adding networks (#200) ## Description Fix adding explorer urls when adding networks into metamask ## Related Issue Or Context Closes: #187 ## How Has This Been Tested? Testing details. ## Types of changes - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation ## Checklist: - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have ensured that all acceptance criteria (or expected behavior) from issue are met - [ ] I have updated the documentation locally and in sygma-docs. - [ ] I have added tests to cover my changes. - [ ] I have ensured that all the checks are passing and green, I've signed the CLA bot Co-authored-by: Saad Ahmed <48211799+saadjhk@users.noreply.github.com> --- packages/widget/src/constants.ts | 2 +- packages/widget/src/controllers/wallet-manager/manager.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/widget/src/constants.ts b/packages/widget/src/constants.ts index 76a2706b..d5b85000 100644 --- a/packages/widget/src/constants.ts +++ b/packages/widget/src/constants.ts @@ -6,7 +6,7 @@ export const DEFAULT_ETH_DECIMALS = 18; export const MAINNET_EXPLORER_URL = 'https://scan.buildwithsygma.com/transfer/'; export const TESTNET_EXPLORER_URL = 'https://scan.test.buildwithsygma.com/transfer/'; -export const CHAIN_ID_URL = 'https://chainid.network/chains_mini.json'; +export const CHAIN_ID_URL = 'https://chainid.network/chains.json'; type WsUrl = `ws://${string}` | `wss://${string}`; export const SUBSTRATE_RPCS: { diff --git a/packages/widget/src/controllers/wallet-manager/manager.ts b/packages/widget/src/controllers/wallet-manager/manager.ts index 514f3cc8..430818eb 100644 --- a/packages/widget/src/controllers/wallet-manager/manager.ts +++ b/packages/widget/src/controllers/wallet-manager/manager.ts @@ -22,6 +22,7 @@ type ChainData = { name: string; rpc: string[]; nativeCurrency: { name: string; symbol: string; decimals: number }; + explorers: Array<{ name: string; standard: string; url: string }>; }; type ChainDataResponse = Array; @@ -282,7 +283,8 @@ export class WalletController implements ReactiveController { chainId, name, nativeCurrency: { name: tokenName, symbol, decimals }, - rpc + rpc, + explorers } = chainData; try { await provider.request({ @@ -296,7 +298,8 @@ export class WalletController implements ReactiveController { name: tokenName, symbol: symbol, decimals: decimals - } + }, + blockExplorerUrls: explorers.map((explorer) => explorer.url) } ] });