Fix new/old proxy detect (args length) (#3592)

This commit is contained in:
Jaco Greeff 2020-09-02 08:34:25 +02:00 committed by GitHub
parent b4c24a2abc
commit 7e2bc73ead
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -75,7 +75,7 @@ function Overview ({ className = '', onStatusChange }: Props): React.ReactElemen
const delegations = useCall<Voting[]>(api.query.democracy?.votingOf?.multi, [sortedAddresses]);
const proxies = useCall<[ProxyDefinition[], BN][]>(api.query.proxy?.proxies.multi, [sortedAddresses], {
transform: (result: [([AccountId, ProxyType] | ProxyDefinition)[], BN][]): [ProxyDefinition[], BN][] =>
api.tx.proxy.addProxy.meta.args.length === 4
api.tx.proxy.addProxy.meta.args.length === 3
? result as [ProxyDefinition[], BN][]
: (result as [[AccountId, ProxyType][], BN][]).map(([arr, bn]): [ProxyDefinition[], BN] =>
[arr.map(([delegate, proxyType]): ProxyDefinition => api.createType('ProxyDefinition', { delegate, proxyType })), bn]

View File

@ -54,7 +54,7 @@ export default function useProxies (address?: string | null): State {
api.query.proxy
.proxies<ITuple<[Vec<ITuple<[AccountId, ProxyType]> | ProxyDefinition>, BalanceOf]>>(address)
.then(([_proxies]): void => {
const proxies = api.tx.proxy.addProxy.meta.args.length === 4
const proxies = api.tx.proxy.addProxy.meta.args.length === 3
? (_proxies as ProxyDefinition[]).map(({ delay, delegate, proxyType }) =>
createProxy(allAccounts, delegate, proxyType, delay)
)

View File

@ -123,7 +123,7 @@ async function queryForProxy (api: ApiPromise, allAccounts: string[], address: s
if (isFunction(api.query.proxy?.proxies)) {
const { isProxied } = extractExternal(address);
const [_proxies] = await api.query.proxy.proxies<ITuple<[Vec<ITuple<[AccountId, ProxyType]> | ProxyDefinition>, BalanceOf]>>(address);
const proxies = api.tx.proxy.addProxy.meta.args.length === 4
const proxies = api.tx.proxy.addProxy.meta.args.length === 3
? (_proxies as ProxyDefinition[]).map(({ delegate, proxyType }): [string, ProxyType] => [delegate.toString(), proxyType])
: (_proxies as [AccountId, ProxyType][]).map(([delegate, proxyType]): [string, ProxyType] => [delegate.toString(), proxyType]);
const proxiesFilter = filterProxies(allAccounts, tx, proxies);