diff --git a/packages/apps-routing/src/staking.ts b/packages/apps-routing/src/staking.ts index 01d4560132..463076dd55 100644 --- a/packages/apps-routing/src/staking.ts +++ b/packages/apps-routing/src/staking.ts @@ -7,20 +7,19 @@ import type { PalletStakingExposure } from '@polkadot/types/lookup'; import type { Route } from './types'; import Component from '@polkadot/app-staking'; +import { ZERO_ACCOUNT } from '@polkadot/react-hooks/useWeight'; import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey'; import { assert, BN_ONE } from '@polkadot/util'; -const TEST_ADDR = '1ufRSF5gx9Q8hrYoj7KwpzQzDNqLJdbKrFwC6okxa5gtBRd'; - function needsApiCheck (api: ApiPromise): boolean { try { // we need a known Exposure type const { others: [{ value, who }], own, total } = api.registry.createType( unwrapStorageType(api.registry, api.query.staking.erasStakers.creator.meta.type), - { others: [{ value: BN_ONE, who: TEST_ADDR }], own: BN_ONE, total: BN_ONE } + { others: [{ value: BN_ONE, who: ZERO_ACCOUNT }], own: BN_ONE, total: BN_ONE } ); - assert(total.eq(BN_ONE) && own.eq(BN_ONE) && who.eq(TEST_ADDR) && value.eq(BN_ONE), 'Needs a known Exposure type'); + assert(total && own && value && who && total.eq(BN_ONE) && own.eq(BN_ONE) && value.eq(BN_ONE), 'Needs a known Exposure type'); } catch { console.warn('Unable to create known-shape Exposure type, disabling staking route'); @@ -29,7 +28,7 @@ function needsApiCheck (api: ApiPromise): boolean { try { // we need to be able to bond - api.tx.staking.bond(TEST_ADDR, BN_ONE, { Account: TEST_ADDR }); + api.tx.staking.bond(ZERO_ACCOUNT, BN_ONE, { Account: ZERO_ACCOUNT }); } catch { console.warn('Unable to create staking bond transaction, disabling staking route'); diff --git a/packages/page-preimages/src/Preimages/Call.tsx b/packages/page-preimages/src/Preimages/Call.tsx index 77f4d43c81..8c1c77b0d7 100644 --- a/packages/page-preimages/src/Preimages/Call.tsx +++ b/packages/page-preimages/src/Preimages/Call.tsx @@ -6,6 +6,7 @@ import type { Preimage } from '../types'; import React from 'react'; import { AddressMini, CallExpander, MarkError, MarkWarning } from '@polkadot/react-components'; +import { ZERO_ACCOUNT } from '@polkadot/react-hooks/useWeight'; import { useTranslation } from '../translate'; @@ -15,8 +16,6 @@ interface Props { value?: Preimage; } -const NULL_ADDR = '0x1234567812345678123456781234567812345678123456781234567812345678'; - function PreimageCall ({ className = '', value }: Props): React.ReactElement { const { t } = useTranslation(); @@ -57,7 +56,7 @@ function PreimageCall ({ className = '', value }: Props): React.ReactElement )} diff --git a/packages/react-hooks/src/useWeight.ts b/packages/react-hooks/src/useWeight.ts index 9cc0e99ea1..f30eeeec13 100644 --- a/packages/react-hooks/src/useWeight.ts +++ b/packages/react-hooks/src/useWeight.ts @@ -32,8 +32,9 @@ interface Result { weight: BN | V2WeightConstruct; } -// a random address that we are using for our queries -const ZERO_ACCOUNT = '5CAUdnwecHGxxyr5vABevAfZ34Fi4AaraDRMwfDQXQ52PXqg'; +// this is 32 bytes in length, it allows construction for both AccountId32 & AccountId20 +export const ZERO_ACCOUNT = '0x9876543210abcdef9876543210abcdef9876543210abcdef9876543210abcdef'; + const EMPTY_STATE: Partial = { encodedCallLength: 0, v1Weight: BN_ZERO,