Skip to content

Commit

Permalink
polkadot-js#9901 - Fix issue with Contracts tab for polkadot-v1.0.0 b…
Browse files Browse the repository at this point in the history
…ased chain
  • Loading branch information
vampik33 committed Oct 15, 2023
1 parent d6973b2 commit 0e9ec32
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/page-contracts/src/Codes/Code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface Props {
function Code ({ className, code, onShowDeploy }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const optCode = useCall<Option<Codec>>(api.query.contracts.codeStorage, [code.json.codeHash]);
const optCode = useCall<Option<Codec>>(api.query.contracts.pristineCode, [code.json.codeHash]);
const [isForgetOpen, toggleIsForgetOpen] = useToggle();
const { contractAbi } = useAbi([code.json.abi, code.contractAbi], code.json.codeHash, true);

Expand Down
6 changes: 3 additions & 3 deletions packages/page-contracts/src/Codes/ValidateCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ interface Props {
function ValidateCode ({ codeHash, onChange }: Props): React.ReactElement<Props> | null {
const { api } = useApi();
const { t } = useTranslation();
const codeStorage = useCall<Option<PrefabWasmModule>>((api.query.contracts || api.query.contract).codeStorage, [codeHash]);
const pristineCode = useCall<Option<PrefabWasmModule>>((api.query.contracts || api.query.contract).pristineCode, [codeHash]);
const [isValidHex, isValid] = useMemo(
(): [boolean, boolean] => {
const isValidHex = !!codeHash && isHex(codeHash) && codeHash.length === 66;
const isStored = !!codeStorage && codeStorage.isSome;
const isStored = !!pristineCode && pristineCode.isSome;
const isValid = isValidHex && isStored;

onChange(isValid);
Expand All @@ -36,7 +36,7 @@ function ValidateCode ({ codeHash, onChange }: Props): React.ReactElement<Props>
isValid
];
},
[codeHash, codeStorage, onChange]
[codeHash, pristineCode, onChange]
);

if (isValid || !isValidHex) {
Expand Down
2 changes: 1 addition & 1 deletion packages/page-contracts/src/Contracts/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function Summary ({ trigger }: Props): React.ReactElement<Props> {
}, [api, accountCounter]);

useEffect((): void => {
api.query.contracts.codeStorage
api.query.contracts.pristineCode
.keys()
.then((arr) => setNumHashes(arr.length))
.catch(console.error);
Expand Down

0 comments on commit 0e9ec32

Please sign in to comment.