Skip to content

Commit 0647861

Browse files
authored
chore: update devtools, eslint fixes, format code (use-ink#500)
1 parent 7e5e797 commit 0647861

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1489
-1723
lines changed

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"indent": "off",
8484
"no-console": ["error", { "allow": ["warn", "error"] }],
8585
"react/display-name": "off",
86-
"react/jsx-sort-props":"warn",
86+
"react/jsx-sort-props": "warn",
8787
"react/prop-types": "off",
8888
"react/react-in-jsx-scope": "off"
8989
}

cypress/e2e/extension.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ describe('Signer extension flow on live networks', () => {
2626
cy.contains('No signer extension found.').should('be.visible');
2727
cy.contains('New to Substrate?').should('be.visible');
2828
cy.contains(
29-
'Install the a compatible wallet like Polkadot.js Extension to create and manage Substrate accounts.'
29+
'Install the a compatible wallet like Polkadot.js Extension to create and manage Substrate accounts.',
3030
).should('be.visible');
3131
cy.contains(
32-
'If the extension is installed and you are seeing this, make sure it allows Contracts UI to use your accounts for signing.'
32+
'If the extension is installed and you are seeing this, make sure it allows Contracts UI to use your accounts for signing.',
3333
).should('be.visible');
3434
});
3535
});
@@ -45,10 +45,10 @@ describe('Signer extension flow on live networks', () => {
4545
cy.get('[data-cy="error-card"]').within(() => {
4646
cy.contains('No accounts found.').should('be.visible');
4747
cy.contains(
48-
'1. Follow this guide to create your first account in the Polkadot.js extension.'
48+
'1. Follow this guide to create your first account in the Polkadot.js extension.',
4949
).should('be.visible');
5050
cy.contains(
51-
'2. Drip some funds into your account via the faucets of our supported networks.'
51+
'2. Drip some funds into your account via the faucets of our supported networks.',
5252
).should('be.visible');
5353
});
5454
});

cypress/e2e/instantiateDryRun.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('Instantiate dry run', () => {
2121
cy.contains('ContractTrapped').should('be.visible');
2222
cy.contains('Contract trapped during execution.').should('be.visible');
2323
cy.contains(
24-
"panicked at 'assertion failed: 0 < requirement && requirement <= owners && owners <= MAX_OWNERS"
24+
"panicked at 'assertion failed: 0 < requirement && requirement <= owners && owners <= MAX_OWNERS",
2525
).should('be.visible');
2626
});
2727
});

cypress/support/component-index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<head>
44
<meta charset="utf-8" />

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<head>
44
<meta charset="utf-8" />

package.json

+17-17
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"scripts": {
99
"start": "vite",
1010
"build": "tsc && vite build",
11-
"lint": "yarn eslint --fix .",
11+
"lint": "echo 'linting...'; yarn eslint --fix .; echo 'linting complete!'",
1212
"format": "yarn prettier --write .",
1313
"clean": "rm -rf dist",
1414
"test": "yarn cypress run",
@@ -52,48 +52,48 @@
5252
"react-select": "^5.7.3",
5353
"react-tooltip": "^5.14.0",
5454
"remark-gfm": "^3.0.1",
55-
"tailwind-merge": "^1.13.1",
55+
"tailwind-merge": "^1.14.0",
5656
"yup": "^1.2.0"
5757
},
5858
"devDependencies": {
59-
"@cypress/code-coverage": "^3.10.7",
59+
"@cypress/code-coverage": "^3.11.0",
6060
"@cypress/snapshot": "^2.1.7",
6161
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
6262
"@istanbuljs/nyc-config-typescript": "^1.0.2",
6363
"@nabla/vite-plugin-eslint": "^1.5.0",
64-
"@tailwindcss/forms": "^0.5.3",
64+
"@tailwindcss/forms": "^0.5.4",
6565
"@types/bcryptjs": "^2.4.2",
6666
"@types/big.js": "^6.1.6",
67-
"@types/node": "^20.3.1",
68-
"@types/react-dom": "^18.2.4",
69-
"@typescript-eslint/eslint-plugin": "^5.59.11",
70-
"@typescript-eslint/parser": "^5.59.11",
67+
"@types/node": "^20.4.5",
68+
"@types/react-dom": "^18.2.7",
69+
"@typescript-eslint/eslint-plugin": "^6.1.0",
70+
"@typescript-eslint/parser": "^6.1.0",
7171
"@vitejs/plugin-react": "^4.0.3",
7272
"autoprefixer": "^10.4.14",
7373
"cross-env": "^7.0.3",
74-
"cypress": "^12.14.0",
74+
"cypress": "^12.17.2",
7575
"cypress-file-upload": "^5.0.8",
76-
"eslint": "^8.42.0",
76+
"eslint": "^8.45.0",
7777
"eslint-config-prettier": "^8.8.0",
7878
"eslint-import-resolver-typescript": "^3.5.5",
7979
"eslint-plugin-header": "^3.1.1",
8080
"eslint-plugin-import": "^2.27.5",
81-
"eslint-plugin-react": "^7.32.2",
81+
"eslint-plugin-react": "^7.33.0",
8282
"eslint-plugin-react-hooks": "^4.6.0",
8383
"husky": "^8.0.3",
8484
"istanbul-lib-coverage": "^3.2.0",
8585
"lint-staged": ">=13.2.2",
8686
"nyc": "^15.1.0",
87-
"postcss": "^8.4.24",
87+
"postcss": "^8.4.27",
8888
"postcss-import": "^15.1.0",
89-
"prettier": "^2.8.8",
90-
"prettier-plugin-tailwindcss": "^0.2.8",
89+
"prettier": "^3.0.0",
90+
"prettier-plugin-tailwindcss": "^0.4.1",
9191
"source-map-support": "^0.5.21",
92-
"tailwindcss": "^3.3.2",
92+
"tailwindcss": "^3.3.3",
9393
"ts-node": "^10.9.1",
94-
"typescript": "^5.1.3",
94+
"typescript": "^5.1.6",
9595
"vite": "^4.4.6",
96-
"vite-plugin-istanbul": "^4.1.0",
96+
"vite-plugin-istanbul": "^5.0.0",
9797
"vite-tsconfig-paths": "^4.2.0"
9898
},
9999
"browserslist": [

snapshots.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
__version: '12.8.1',
2+
__version: '12.17.2',
33
'Storage Types Contract': {
44
UnsignedIntegers: {
55
1: "<code>{\n i128ValueMax: '170,141,183,460,469,231,731,687,303,715,884,105,727',\n i128ValueMin: '-170,141,183,460,469,231,731,687,303,715,884,105,728',\n i16ValueMax: '-32,769',\n i16ValueMin: '-32,768',\n i32ValueMax: '2,147,483,647',\n i32ValueMin: '-2,147,483,648',\n i64ValueMax: '9,223,372,036,854,775,807',\n i64ValueMin: '-9,223,372,036,854,775,808',\n i8ValueMax: '-129',\n i8ValueMin: '-128',\n }</code>",

src/helpers/callOptions.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { randomAsU8a } from './util';
66
import { UIStorageDeposit, ContractCallOutcome, BN, WeightV2, AbiParam, Registry } from 'types';
77

88
export function decodeStorageDeposit(
9-
storageDeposit: ContractCallOutcome['storageDeposit']
9+
storageDeposit: ContractCallOutcome['storageDeposit'],
1010
): UIStorageDeposit {
1111
if (storageDeposit.isCharge) {
1212
return { value: storageDeposit.asCharge, type: 'charge' };
@@ -30,7 +30,7 @@ export function getStorageDepositLimit(
3030
switchOn: boolean,
3131
userInput: BN,
3232
registry: Registry,
33-
dryRunValue?: UIStorageDeposit
33+
dryRunValue?: UIStorageDeposit,
3434
) {
3535
return switchOn
3636
? registry.createType('Balance', userInput)
@@ -43,7 +43,7 @@ export function getGasLimit(
4343
switchOn: boolean,
4444
refTimeLimit: BN,
4545
proofSizeLimit: BN,
46-
registry: Registry
46+
registry: Registry,
4747
): WeightV2 | null {
4848
return switchOn
4949
? registry.createType('WeightV2', {
@@ -56,7 +56,7 @@ export function getGasLimit(
5656
export function transformUserInput(
5757
registry: Registry,
5858
messageArgs: AbiParam[],
59-
values?: Record<string, unknown>
59+
values?: Record<string, unknown>,
6060
): unknown[] {
6161
return messageArgs.map(({ name, type: { type } }) => {
6262
const value = values ? values[name] : null;

src/helpers/contract.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function createInstantiateTx(
2323
metadata,
2424
salt,
2525
storageDepositLimit,
26-
}: Omit<InstantiateData, 'name'>
26+
}: Omit<InstantiateData, 'name'>,
2727
): SubmittableExtrinsic<'promise'> {
2828
const wasm = metadata?.info.source.wasm;
2929
const isValid = codeHash || !!wasm;

src/helpers/initValue.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ export function getInitValue(registry: Registry, accounts: Account[], def: TypeD
163163
error && console.error(`params: initValue: ${error}`);
164164
console.warn(
165165
`params: initValue: No default value for type ${type} from ${JSON.stringify(
166-
def
167-
)}, using defaults`
166+
def,
167+
)}, using defaults`,
168168
);
169169
}
170170

src/helpers/output.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function stringify(o: unknown) {
3939
function decodeReturnValue(
4040
returnType: TypeDef | null | undefined,
4141
data: Bytes,
42-
registry: Registry
42+
registry: Registry,
4343
): AnyJson {
4444
const returnTypeName = getReturnTypeName(returnType);
4545
let r: AnyJson = 'Decoding error';
@@ -81,7 +81,7 @@ function getOkText(outcome: AnyJson, returnValue: AnyJson) {
8181
export function getDecodedOutput(
8282
{ result }: Pick<ContractExecResult, 'result' | 'debugMessage'>,
8383
{ returnType }: AbiMessage,
84-
registry: Registry
84+
registry: Registry,
8585
): {
8686
decodedOutput: string;
8787
isError: boolean;

src/types/ui/contexts.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,17 @@ export interface InstantiateState {
6161

6262
export type InstantiateProps = InstantiateState;
6363

64-
export enum TxStatus {
65-
Error = 'error',
66-
Success = 'success',
67-
Processing = 'processing',
68-
Queued = 'queued',
69-
}
64+
// avoid enums https://www.youtube.com/watch?v=jjMbPt_H3RQ
65+
export const TxStatusMap = {
66+
Error: 'error',
67+
Success: 'success',
68+
Processing: 'processing',
69+
Queued: 'queued',
70+
} as const;
71+
72+
type ObjectValues<T> = T[keyof T];
73+
74+
export type TxStatus = ObjectValues<typeof TxStatusMap>;
7075
export interface TxOptions {
7176
extrinsic: SubmittableExtrinsic<'promise'>;
7277
accountId: string;

src/ui/components/common/CopyButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function CopyButton({ className, iconClassName, value, id }: Props) {
2626
setShowTooltip(false);
2727
}, 1000);
2828
},
29-
[value]
29+
[value],
3030
);
3131

3232
return (

src/ui/components/common/Dropdown.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { classes, isValidAddress } from 'helpers';
1919
import type { DropdownOption, DropdownProps } from 'types';
2020

2121
function isGroupedOptions<T>(
22-
options: ReactSelectProps<DropdownOption<T>, false>['options']
22+
options: ReactSelectProps<DropdownOption<T>, false>['options'],
2323
): options is GroupBase<DropdownOption<T>>[] {
2424
try {
2525
return !!options && (options as GroupBase<DropdownOption<T>>[])[0].options !== undefined;
@@ -60,7 +60,7 @@ function DropdownIndicator<T>(props: DropdownIndicatorProps<DropdownOption<T>, f
6060

6161
function getOption<T>(
6262
options: OptionsOrGroups<DropdownOption<T>, GroupBase<DropdownOption<T>>>,
63-
val: T
63+
val: T,
6464
) {
6565
if (isGroupedOptions(options)) {
6666
return options
@@ -87,7 +87,7 @@ export function Dropdown<T>({
8787
(option: DropdownOption<T> | null): void => {
8888
option && _onChange(option.value);
8989
},
90-
[_onChange]
90+
[_onChange],
9191
);
9292

9393
const value = useMemo(() => getOption(options, _value), [options, _value]);

src/ui/components/common/HeaderButtons.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function HeaderButtons({ contract: { address, codeHash } }: Props) {
5050
</Link>
5151
) : (
5252
<p className="mr-3 flex items-center font-semibold text-red-400">{`Not found at ${truncate(
53-
address
53+
address,
5454
)}`}</p>
5555
)}
5656
<button

src/ui/components/common/Spinner.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function Spinner({
2525
`border-${color}`,
2626
`dark:border-${darkColor}`,
2727
'animate-spin rounded-full border-solid',
28-
className
28+
className,
2929
)}
3030
data-cy="spinner"
3131
style={{ borderTopColor: 'transparent' }}

src/ui/components/common/Switch.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function Switch({ children, className, onChange, value }: Props) {
2020
className={classes(
2121
value ? 'bg-green-500' : 'bg-gray-700',
2222
'relative inline-flex w-8 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75',
23-
className
23+
className,
2424
)}
2525
data-cy="switch-button"
2626
onChange={onChange}
@@ -30,7 +30,7 @@ export function Switch({ children, className, onChange, value }: Props) {
3030
aria-hidden="true"
3131
className={classes(
3232
value ? 'translate-x-3.5' : 'translate-x-0',
33-
'pointer-events-none inline-block h-3.5 w-3.5 transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out'
33+
'pointer-events-none inline-block h-3.5 w-3.5 transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out',
3434
)}
3535
/>
3636
</HUISwitch>

src/ui/components/contract/DryRunResult.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function DryRunResult({
5050
<div
5151
className={classes(
5252
result.isErr || isError ? 'text-red-500' : 'text-green-500',
53-
'mb-2 font-mono text-sm'
53+
'mb-2 font-mono text-sm',
5454
)}
5555
>
5656
{prediction}

src/ui/components/contract/Interact.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export const InteractTab = ({
153153
isActive,
154154
userInput,
155155
api.registry,
156-
predictedStorageDeposit
156+
predictedStorageDeposit,
157157
),
158158
value: message.isPayable ? (params[2] as Balance) : undefined,
159159
};
@@ -162,7 +162,7 @@ export const InteractTab = ({
162162

163163
const extrinsic = tx[message.method](
164164
options,
165-
...transformUserInput(registry, message.args, argValues)
165+
...transformUserInput(registry, message.args, argValues),
166166
);
167167

168168
newId.current = queue({

src/ui/components/contract/TransactionResult.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function Events({ events }: { events: EventRecord[] }) {
1818
{events.map(({ event }) =>
1919
event.method === 'ContractEmitted' ? null : (
2020
<div key={event.method}>{`${event.section}::${event.method}`}</div>
21-
)
21+
),
2222
)}
2323
</div>
2424
);

src/ui/components/form/ArgumentForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface Props extends React.HTMLAttributes<HTMLFormElement> {
1818
export function ArgumentForm({ args, argValues, registry, setArgValues, className }: Props) {
1919
const components = useMemo(
2020
() => args.map(arg => ({ arg, Component: findComponent(registry, arg.type) })),
21-
[args, registry]
21+
[args, registry],
2222
);
2323
return (
2424
<Form className="argument-form">

src/ui/components/form/Enum.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function Enum(props: Props) {
2525
(value: unknown): void => {
2626
_onChange({ [variants[variantIndex].name as string]: value });
2727
},
28-
[_onChange, variants, variantIndex]
28+
[_onChange, variants, variantIndex],
2929
);
3030

3131
const setVariantIndex = useCallback(
@@ -38,7 +38,7 @@ export function Enum(props: Props) {
3838
});
3939
}
4040
},
41-
[registry, accounts, _onChange, variants]
41+
[registry, accounts, _onChange, variants],
4242
);
4343

4444
return (

src/ui/components/form/Input.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function Input({
3535
className={classes(
3636
'w-full rounded border-gray-200 bg-white text-sm dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300',
3737
isDisabled && 'dark:text-gray-500',
38-
className
38+
className,
3939
)}
4040
onChange={onChange}
4141
onFocus={onFocus}

src/ui/components/form/InputBn.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function InputBn({ onChange, typeDef: { type } }: Props): JSX.Element {
5050
}
5151
}
5252
},
53-
[max, min, onChange]
53+
[max, min, onChange],
5454
);
5555

5656
return (

src/ui/components/form/InputBytes.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function InputBytes({ onChange, className, length }: Props): React.ReactE
5252
// TODO shouldn't this unset the value in error and invalid case to prevent form submission?
5353
}
5454
},
55-
[onChange, validate]
55+
[onChange, validate],
5656
);
5757

5858
return (

0 commit comments

Comments
 (0)