Skip to content

Commit ca0c096

Browse files
committed
fix: Fix outdated files
1 parent 582b944 commit ca0c096

File tree

2 files changed

+38
-21
lines changed

2 files changed

+38
-21
lines changed

packages/extension-web-ui/src/hooks/transaction/confirmation/useMetadata.ts

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,47 @@ export default function useMetadata (genesisHash?: string | null, isPartial?: bo
3333
setLoadingChain(true);
3434

3535
if (genesisHash) {
36-
const getChainByMetaStore = () => {
37-
getMetadata(genesisHash, isPartial)
38-
.then(setChain)
39-
.catch((error): void => {
40-
console.error(error);
41-
setChain(null);
42-
})
43-
.finally(() => {
44-
setLoadingChain(false);
45-
});
36+
const getChainByMetaStore = async () => {
37+
try {
38+
const chain = await getMetadata(genesisHash, isPartial);
39+
40+
return chain;
41+
} catch (error) {
42+
console.error(error);
43+
44+
return null;
45+
}
4646
};
4747

48-
getMetadataRaw(chainInfo, genesisHash)
49-
.then((chain) => {
50-
if (chain) {
51-
setChain(chain);
48+
const fetchData = async () => {
49+
try {
50+
const chainFromRaw = await getMetadataRaw(chainInfo, genesisHash);
51+
const chainFromMetaStore = await getChainByMetaStore();
52+
53+
if (chainFromRaw && chainFromMetaStore) {
54+
if (chainFromRaw.specVersion >= chainFromMetaStore.specVersion) {
55+
setChain(chainFromRaw);
56+
} else {
57+
setChain(chainFromMetaStore);
58+
}
59+
5260
setLoadingChain(false);
5361
} else {
54-
getChainByMetaStore();
62+
setChain(chainFromRaw || chainFromMetaStore || null);
63+
setLoadingChain(false);
5564
}
56-
})
57-
.catch((e) => {
58-
console.error(e);
59-
getChainByMetaStore();
60-
});
65+
} catch (error) {
66+
console.error(error);
67+
setChain(null);
68+
setLoadingChain(false);
69+
}
70+
};
71+
72+
fetchData().catch((error) => {
73+
console.error(error);
74+
setChain(null);
75+
setLoadingChain(false);
76+
});
6177
} else {
6278
setLoadingChain(false);
6379
setChain(null);

packages/extension-web-ui/src/hooks/transaction/confirmation/useParseSubstrateRequestPayload.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { useEffect, useMemo, useState } from 'react';
1212
import { TypeRegistry } from '@polkadot/types';
1313
import { ExtrinsicPayload } from '@polkadot/types/interfaces';
1414
import { SignerPayloadJSON } from '@polkadot/types/types';
15+
import { HexString } from '@polkadot/util/types';
1516

1617
import { useGetChainInfoByGenesisHash } from '../../chain';
1718

@@ -79,7 +80,7 @@ const useParseSubstrateRequestPayload = (chain: Chain | null, request?: RequestS
7980

8081
if (metadataHash) {
8182
_payload.mode = 1;
82-
_payload.metadataHash = `0x${metadataHash}`;
83+
_payload.metadataHash = metadataHash as HexString;
8384
}
8485

8586
return _registry.createType('ExtrinsicPayload', _payload, { version: _payload.version });

0 commit comments

Comments
 (0)