Adjust for shared default show/check address (#8747)

This commit is contained in:
Jaco 2023-01-10 12:56:41 +02:00 committed by GitHub
parent 81e186f81d
commit 14fb35975f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 10 deletions

View File

@ -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<PalletStakingExposure>(
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');

View File

@ -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<Props> {
const { t } = useTranslation();
@ -57,7 +56,7 @@ function PreimageCall ({ className = '', value }: Props): React.ReactElement<Pro
: (
<AddressMini
className='--tmp'
value={NULL_ADDR}
value={ZERO_ACCOUNT}
/>
)}
</td>

View File

@ -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<Result> = {
encodedCallLength: 0,
v1Weight: BN_ZERO,