diff --git a/packages/snap/package.json b/packages/snap/package.json index ef32cc8..69db832 100644 --- a/packages/snap/package.json +++ b/packages/snap/package.json @@ -61,7 +61,8 @@ "rimraf": "^3.0.2", "through2": "^4.0.2", "ts-jest": "^29.1.0", - "typescript": "^4.7.4" + "typescript": "^4.7.4", + "@polkadot/apps-config":"latest" }, "packageManager": "yarn@3.2.1", "engines": { diff --git a/packages/snap/src/chains.ts b/packages/snap/src/chains.ts index 7d2bd86..179f0e9 100644 --- a/packages/snap/src/chains.ts +++ b/packages/snap/src/chains.ts @@ -19,7 +19,25 @@ const westend = { website: 'https://polkadot.network', }; -selectableNetworks.push(westend as Network); +const westendAssetHub = { + decimals: [12], + displayName: 'Westend Asset Hub', + genesisHash: [ + '0x67f9723393ef76214df0118c34bbbd3dbebc8ed46a10973a8c969d48fe7598c9', + ], + hasLedgerSupport: false, + icon: 'polkadot', + isIgnored: false, + isTestnet: true, + network: 'westmint', + prefix: 42, + slip44: 354, + standardAccount: '*25519', + symbols: ['WND'], + website: 'https://polkadot.network', +}; + +selectableNetworks.push(westend as Network, westendAssetHub as Network); export const getChain = (genesisOrChainName: string): Network => { const chain = selectableNetworks.find( diff --git a/packages/snap/src/rpc/showConfirmTx.ts b/packages/snap/src/rpc/showConfirmTx.ts index 98dbe13..f78a563 100644 --- a/packages/snap/src/rpc/showConfirmTx.ts +++ b/packages/snap/src/rpc/showConfirmTx.ts @@ -17,6 +17,9 @@ import getLogo from '../util/getLogo'; import { Decoded, getDecoded } from './decodeTxMethod'; const FLOATING_POINT_DIGIT = 4; +const EMPTY_LOGO = ` + +`; export function fixFloatingPoint( _number: number | string, @@ -75,20 +78,27 @@ const transactionContent = ( decoded: Decoded, ) => { const headingText = `Transaction Approval Request from ${origin}`; - const decodedArgs = decoded.args; + const decodedArgs = decoded?.args; const { args, callIndex } = api.createType('Call', payload.method); const { method, section } = api.registry.findMetaCall(callIndex); const action = `${section}_${method}`; + let chainLogoSvg = EMPTY_LOGO; const dataURI = getLogo(payload.genesisHash); - const svgString = atob(dataURI.replace(/data:image\/svg\+xml;base64,/, '')); + const maybeSvgString = atob( + dataURI.replace(/data:image\/svg\+xml;base64,/, ''), + ); + const indexOfFirstSvgTag = maybeSvgString.indexOf('