Skip to content

Commit 0a210bf

Browse files
committed
fix: build errors and add warning banner
1 parent 426b6fd commit 0a210bf

18 files changed

+57
-51
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
"@types/bcryptjs": "^2.4.6",
6969
"@types/big.js": "^6.2.2",
7070
"@types/node": "^22.5.0",
71-
"@types/react-dom": "^18.3.0",
71+
"@types/react": "^19.1.2",
72+
"@types/react-dom": "^19.1.2",
7273
"@typescript-eslint/eslint-plugin": "^8.2.0",
7374
"@typescript-eslint/parser": "^8.2.0",
7475
"@vitejs/plugin-react": "^4.3.1",

src/lib/util.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright 2022-2024 use-ink/contracts-ui authors & contributors
22
// SPDX-License-Identifier: GPL-3.0-only
33

4-
import { decodeAddress, encodeAddress } from '@polkadot/keyring';
5-
import { hexToU8a, isHex } from '@polkadot/util';
64
import { keyring } from '@polkadot/ui-keyring';
75
import format from 'date-fns/format';
86
import parseISO from 'date-fns/parseISO';
@@ -74,7 +72,8 @@ export function isUndefined(value: unknown): value is undefined {
7472

7573
export function isValidAddress(address: string | Uint8Array | null | undefined) {
7674
try {
77-
// encodeAddress(isHex(address) ? hexToU8a(address) : decodeAddress(address));
75+
// TODO: check isValidAddress
76+
console.log(address);
7877
return true;
7978
} catch (error) {
8079
return false;

src/services/chain/contract.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2022-2024 use-ink/contracts-ui authors & contributors
22
// SPDX-License-Identifier: GPL-3.0-only
33

4-
import { BlueprintPromise, CodePromise, ContractPromise } from '@polkadot/api-contract';
4+
import { BlueprintPromise, CodePromise } from '@polkadot/api-contract';
55
import { isValidAddress, isValidCodeHash, isNumber } from 'lib/util';
66
import { transformUserInput } from 'lib/callOptions';
77
import {
@@ -11,11 +11,7 @@ import {
1111
InstantiateData,
1212
SubmittableExtrinsic,
1313
} from 'types';
14-
import { stringToU8a, compactAddLength, u8aToU8a, hexToU8a } from '@polkadot/util';
15-
import { ISubmittableResult } from '@polkadot/types/types';
16-
import { BlueprintSubmittableResult, Contract } from '@polkadot/api-contract/base';
17-
import { contractsAbi } from '@polkadot/types/interfaces/definitions';
18-
import { fromEthAddress, isEthDerived, toEthAddress } from 'ui/hooks';
14+
import { u8aToU8a } from '@polkadot/util';
1915

2016
export function createInstantiateTx(
2117
api: ApiPromise,
@@ -30,6 +26,7 @@ export function createInstantiateTx(
3026
storageDepositLimit,
3127
}: Omit<InstantiateData, 'name'>,
3228
): SubmittableExtrinsic<'promise'> {
29+
//@ts-ignore TODO: need to update type in @polkadot/api-contracts
3330
const wasm = u8aToU8a(metadata?.json.source.contract_binary);
3431
const isValid = codeHash || !!wasm;
3532

src/ui/components/common/HeaderButtons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface Props {
1414
contract: UIContract;
1515
}
1616

17-
export function HeaderButtons({ contract: { address, dotAddress, codeHash } }: Props) {
17+
export function HeaderButtons({ contract: { address, codeHash } }: Props) {
1818
const { api } = useApi();
1919
const { db } = useDatabase();
2020
const [isOnChain, setIsOnChain] = useState(true);

src/ui/components/contract/ContractRow.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { ContractDocument } from 'types';
99
import { useApi } from 'ui/contexts';
1010
import { displayDate, truncate } from 'lib/util';
1111
import { getContractInfo } from 'services/chain';
12-
import { fromEthAddress, toEthAddress } from 'ui/hooks';
1312

1413
interface Props {
1514
contract: ContractDocument;

src/ui/components/contract/Interact.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
SubmittableResult,
2222
UIContract,
2323
} from 'types';
24-
import { Text } from '@polkadot/types';
2524
import { AccountSelect } from 'ui/components/account';
2625
import { Button, Buttons, Dropdown } from 'ui/components/common';
2726
import { ArgumentForm, Form, FormField, OptionsForm } from 'ui/components/form';
@@ -166,7 +165,7 @@ export const InteractTab = ({
166165
setNextResultId(nextResultId + 1);
167166
};
168167

169-
const newId = useRef<number>();
168+
const newId = useRef<number>(0);
170169

171170
const call = () => {
172171
if (!outcome || !message || !accountId) throw new Error('Unable to call contract.');

src/ui/components/contract/OutcomeItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ export function OutcomeItem({
1313
displayValue: string;
1414
copyValue?: string;
1515
id?: string;
16-
}): JSX.Element {
16+
}): React.ReactElement {
1717
return (
1818
<div className="event-log mb-4">
1919
<div className="mb-1 leading-5">{title}</div>
2020
<div
21-
className="return-value relative break-all rounded-sm bg-gray-200 p-2 text-xs text-gray-600 dark:bg-elevation-1 dark:text-gray-400"
21+
className="return-value relative break-all rounded-sm bg-gray-200 p-2 text-xs text-gray-600 dark:bg-elevation-1 dark:text-gray-400"
2222
data-cy="output"
2323
>
2424
<pre className="whitespace-pre-wrap">
2525
<code>{displayValue}</code>
2626
</pre>
2727
<CopyButton
2828
className="absolute bottom-2 right-2"
29-
id={title ? title.toLowerCase().replace(/\s+/g, '-') : id ?? ''}
29+
id={title ? title.toLowerCase().replace(/\s+/g, '-') : (id ?? '')}
3030
value={copyValue}
3131
/>
3232
</div>

src/ui/components/form/InputBn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function getMinMax(type: string): [bigint, bigint] {
3535
}
3636
}
3737

38-
export function InputBn({ onChange, typeDef: { type } }: Props): JSX.Element {
38+
export function InputBn({ onChange, typeDef: { type } }: Props): React.ReactElement {
3939
const [displayValue, setDisplayValue] = useState('0');
4040
const [min, max] = getMinMax(type);
4141

src/ui/components/instantiate/Step2.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,11 @@ import {
2222
useToggle,
2323
useStorageDepositLimit,
2424
useBalance,
25-
create2,
26-
toEthAddress,
27-
create1,
2825
} from 'ui/hooks';
2926
import { AbiMessage, Balance, OrFalsy } from 'types';
30-
import {
31-
decodeStorageDeposit,
32-
getGasLimit,
33-
getStorageDepositLimit,
34-
transformUserInput,
35-
} from 'lib/callOptions';
27+
import { decodeStorageDeposit, getGasLimit, getStorageDepositLimit } from 'lib/callOptions';
3628
import { BN_ZERO } from 'lib/bn';
3729
import { hasRevertFlag } from 'lib/hasRevertFlag';
38-
import { hexToU8a, stringToU8a } from '@polkadot/util';
39-
import { decodeAddress } from '@polkadot/keyring';
4030

4131
function validateSalt(value: OrFalsy<string>) {
4232
if (!!value && value.length === 66) {
@@ -73,6 +63,7 @@ export function Step2() {
7363
}, [metadata, setConstructorIndex]);
7464

7565
const [isUsingSalt, toggleIsUsingSalt] = useToggle(true);
66+
//@ts-ignore TODO: need to update type in @polkadot/api-contracts
7667
const code = metadata?.json.source.contract_binary;
7768

7869
const params: Parameters<typeof api.call.reviveApi.instantiate> = useMemo(() => {
@@ -98,6 +89,7 @@ export function Step2() {
9889
storageDepositLimit.isActive,
9990
storageDepositLimit.value,
10091
codeHashUrlParam,
92+
//@ts-ignore TODO: need to update type in @polkadot/api-contracts
10193
metadata?.json.source.contract_binary,
10294
inputData,
10395
isUsingSalt,
@@ -122,7 +114,6 @@ export function Step2() {
122114
instantiateResult = {
123115
Ok: {
124116
result: { flags: convertedFlags, data: okResult.result.data },
125-
accountId: okResult.accountId,
126117
},
127118
};
128119
} else {
@@ -159,7 +150,8 @@ export function Step2() {
159150
setData({
160151
...data,
161152
constructorIndex,
162-
salt: params[6] || null,
153+
// salt: params[6] || null,
154+
salt: (params[6] as string | Uint8Array | null) || null,
163155
value: deployConstructor?.isPayable ? (params[1] as Balance) : undefined,
164156
argValues,
165157
storageDepositLimit: getStorageDepositLimit(

src/ui/components/instantiate/Step3.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import { printBN } from 'lib/bn';
99
import { createInstantiateTx } from 'services/chain';
1010
import { SubmittableResult } from 'types';
1111
import { useApi, useInstantiate, useTransactions } from 'ui/contexts';
12-
import { create2, toEthAddress, useNewContract } from 'ui/hooks';
13-
import { hexToU8a, stringToU8a } from '@polkadot/util';
12+
import { useNewContract } from 'ui/hooks';
1413
import { transformUserInput } from 'lib/callOptions';
15-
import { decodeAddress } from '@polkadot/keyring';
1614

1715
export function Step3() {
1816
const { codeHash: codeHashUrlParam } = useParams<{ codeHash: string }>();
@@ -31,9 +29,9 @@ export function Step3() {
3129
const isValid = (result: SubmittableResult) => !result.isError && !result.dispatchError;
3230

3331
if (data.accountId) {
34-
const constructor = metadata.findConstructor(constructorIndex);
35-
const transformed = transformUserInput(api.registry, constructor.args, data.argValues);
36-
const inputData = constructor.toU8a(transformed).slice(1); // exclude the first byte (the length byte)
32+
const constructor = metadata?.findConstructor(constructorIndex);
33+
const transformed = transformUserInput(api.registry, constructor?.args || [], data.argValues);
34+
const inputData = constructor?.toU8a(transformed).slice(1); // exclude the first byte (the length byte)
3735

3836
const tx = createInstantiateTx(api, data);
3937

@@ -43,11 +41,13 @@ export function Step3() {
4341
accountId: data.accountId,
4442
onSuccess: result => {
4543
// Pass the contract data and extrinsic to onSuccess
44+
// @ts-ignore: TODO: solve type issue
4645
return onSuccess({
4746
...result,
4847
contractData: {
49-
salt: salt, // Using codeHash as salt for demonstration
50-
data: inputData, // The contract initialization data
48+
salt: salt?.toString() || '', // Using codeHash as salt for demonstration
49+
data: inputData || new Uint8Array(),
50+
// @ts-ignore TODO
5151
code: metadata?.json.source.contract_binary,
5252
},
5353
});

src/ui/contexts/DatabaseContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const INITIAL = {} as unknown as DbState;
1414

1515
export function DatabaseContextProvider({
1616
children,
17-
}: React.HTMLAttributes<HTMLDivElement>): JSX.Element | null {
17+
}: React.HTMLAttributes<HTMLDivElement>): React.ReactElement | null {
1818
const { genesisHash } = useApi();
1919
const [state, setState] = useState<DbState>(INITIAL);
2020

src/ui/hooks/useNewContract.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import { useNavigate } from 'react-router';
55
import type { BlueprintSubmittableResult } from 'types';
66
import { useApi, useDatabase, useInstantiate } from 'ui/contexts';
7-
import { BigNumberish, ethers, RlpStructuredDataish, toBeHex, toUtf8String } from 'ethers';
7+
import { BigNumberish, ethers } from 'ethers';
88
import { ApiTypes } from '@polkadot/api/types';
99
import { hexToU8a, stringToU8a, u8aToHex } from '@polkadot/util';
1010
import { keccak256 } from 'ethers';
11-
import { decodeAddress, encodeAddress } from '@polkadot/keyring';
11+
import { decodeAddress } from '@polkadot/keyring';
1212

1313
interface ExtendedBlueprintSubmittableResult<T extends ApiTypes>
1414
extends BlueprintSubmittableResult<T> {

src/ui/hooks/useStoredContract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function useStoredContract(address: string): UIContract | undefined {
3737
displayName: document.name,
3838
tx: contract.tx,
3939
codeHash: document.codeHash,
40-
address: contract.address,
40+
address: contract.address.toString(),
4141
dotAddress: document.dotAddress,
4242
date: document.date,
4343
id: document.id,

src/ui/layout/RootLayout.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ export function RootLayout({ accessory, heading, help, children, aside }: PagePr
1212
aside && 'grid grid-cols-[1fr_400px] gap-10',
1313
)}
1414
>
15+
<div className="col-span-2 mb-6 max-h-[100px] bg-yellow-400 p-4 text-center text-lg font-semibold text-black">
16+
NOTE: This is an ALPHA version for the ink! v6 Alpha release. If you run into issues, please
17+
open an issue at{' '}
18+
<a className="text-purple-700" href="https://github.com/use-ink/contracts-ui">
19+
https://github.com/use-ink/contracts-ui
20+
</a>
21+
</div>
1522
<main>
1623
<header className="mb-10 space-y-1 border-b border-gray-200 pb-6 dark:border-gray-800">
1724
{accessory && <div className="float-right">{accessory}</div>}

src/ui/layout/sidebar/NavLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { NavLink as NavLinkBase, NavLinkProps } from 'react-router-dom';
55

66
interface Props extends NavLinkProps {
7-
icon: (_: React.ComponentProps<'svg'>) => JSX.Element;
7+
icon: (_: React.ComponentProps<'svg'>) => React.ReactElement;
88
}
99

1010
export function NavLink({ children, icon: Icon, ...props }: Props): React.ReactElement<Props> {

src/ui/layout/sidebar/QuickLinks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function QuickLinks() {
1616
<div className="section your-contracts">
1717
<div className="header text-gray-400">Your Contracts</div>
1818
{contracts && contracts.length > 0 ? (
19-
contracts.map(({ name, address, dotAddress }) => {
19+
contracts.map(({ name, address }) => {
2020
return (
2121
<NavLink icon={DocumentTextIcon} key={address} to={`/contract/${address}`}>
2222
{name}

src/ui/pages/AddressLookup.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { useApi, useDatabase } from 'ui/contexts';
2121
import { useNonEmptyString } from 'ui/hooks/useNonEmptyString';
2222
import { useStoredMetadata } from 'ui/hooks/useStoredMetadata';
2323
import { RootLayout } from 'ui/layout';
24+
import { fromEthAddress } from 'ui/hooks';
2425

2526
export function AddressLookup() {
2627
const [searchString, setSearchString] = useState('');
@@ -192,6 +193,7 @@ export function AddressLookup() {
192193
const document = {
193194
abi: metadata.json,
194195
address,
196+
dotAddress: fromEthAddress(address),
195197
codeHash: metadata.info.source.wasmHash.toHex(),
196198
date: new Date().toISOString(),
197199
name,

yarn.lock

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,12 +2419,12 @@ __metadata:
24192419
languageName: node
24202420
linkType: hard
24212421

2422-
"@types/react-dom@npm:^18.3.0":
2423-
version: 18.3.6
2424-
resolution: "@types/react-dom@npm:18.3.6"
2422+
"@types/react-dom@npm:^19.1.2":
2423+
version: 19.1.2
2424+
resolution: "@types/react-dom@npm:19.1.2"
24252425
peerDependencies:
2426-
"@types/react": ^18.0.0
2427-
checksum: 03434d70eb3213413514303c684fe56672a0e5ac6629be92a34d521f926f9e9eb89dcabf9ff485df485a11244e0f4b47dbb6168f7a6a0b664518c9bafb25711d
2426+
"@types/react": ^19.0.0
2427+
checksum: 62a5c398e87b5a42f34497152c67367db70d5e348a05fc4bd78c119fc8d4367c02833c022b2f5dba4df33ae65b7ff76409847722ce6b8f9ea5d31983832688da
24282428
languageName: node
24292429
linkType: hard
24302430

@@ -2437,6 +2437,15 @@ __metadata:
24372437
languageName: node
24382438
linkType: hard
24392439

2440+
"@types/react@npm:^19.1.2":
2441+
version: 19.1.2
2442+
resolution: "@types/react@npm:19.1.2"
2443+
dependencies:
2444+
csstype: ^3.0.2
2445+
checksum: 5a911a2c84be0c9451bb8a7c75c907af1f52afbb4d51b0d62e7516a9b0b1e63c3c1cdc35b79bfc6e66176c76cfff9d43023a781cd3dc59e2744715ced7d7e7c4
2446+
languageName: node
2447+
linkType: hard
2448+
24402449
"@types/sinonjs__fake-timers@npm:8.1.1":
24412450
version: 8.1.1
24422451
resolution: "@types/sinonjs__fake-timers@npm:8.1.1"
@@ -3867,7 +3876,8 @@ __metadata:
38673876
"@types/bcryptjs": ^2.4.6
38683877
"@types/big.js": ^6.2.2
38693878
"@types/node": ^22.5.0
3870-
"@types/react-dom": ^18.3.0
3879+
"@types/react": ^19.1.2
3880+
"@types/react-dom": ^19.1.2
38713881
"@typescript-eslint/eslint-plugin": ^8.2.0
38723882
"@typescript-eslint/parser": ^8.2.0
38733883
"@vitejs/plugin-react": ^4.3.1

0 commit comments

Comments
 (0)