Skip to content

Commit

Permalink
fix: lint (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteZhang1024 authored Nov 27, 2024
1 parent 4a72cc9 commit 5ccce07
Show file tree
Hide file tree
Showing 20 changed files with 538 additions and 45 deletions.
8 changes: 8 additions & 0 deletions packages/errors/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


fast-safe-stringify@^2.0.6:
version "2.1.1"
resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz#c406a83b6e70d9e35ce3b30a81141df30aeba884"
integrity sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==
12 changes: 8 additions & 4 deletions packages/example/components/ApiActuator/ApiPayload.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useCallback, useEffect, useMemo, useState } from 'react';
import React, { FC, useCallback, useEffect, useState } from 'react';
import { useWallet } from '../connect/WalletContext';
import { IApiExecutor, useApiExecutor } from './useApiExecutor';
import { IEthereumProvider } from '../chains/ethereum/types';
Expand Down Expand Up @@ -96,6 +96,11 @@ export type IApiExecuteProps = {
timeout?: number;
} & IApiExecutor;

interface IExecuteResult {
result: string | undefined;
error?: string | undefined;
}

function ApiExecute({
allowCallWithoutProvider,
onExecute,
Expand Down Expand Up @@ -130,10 +135,9 @@ function ApiExecute({
handleSetValidateResult('');

try {
// @ts-expect-error
const { result, error } = await Promise.race([
execute(request),
new Promise((_, rej) => setTimeout(() => rej(`call timeout ${timeout}ms`), timeout)),
new Promise<IExecuteResult>((_, rej) => setTimeout(() => rej(`call timeout ${timeout}ms`), timeout)),
]);
if (error) {
handleSetResult(`Error: ${error}`);
Expand All @@ -143,7 +147,7 @@ function ApiExecute({
} catch (error) {
console.log('execute error', error);

handleSetResult(`Error: ${error}`);
handleSetResult(`Error: ${typeof error === 'string' ? error : JSON.stringify(error)}`);
}
setLoading(false);
}, [execute, request, handleSetResult]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const tryFormatCompactJson = (json: string) => {
const hasArray = /\[.*?\]/.test(json);
const obj = JSON.parse(json);
if (hasArray) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return perfectJson(obj, {
// @ts-expect-error
singleLine: ({ value }) => Array.isArray(value) && value.length > 10,
Expand Down
6 changes: 4 additions & 2 deletions packages/example/components/chains/alephium/example.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument */

import { dapps } from './dapps.config';
import { ApiPayload, ApiGroup } from '../../ApiActuator';
import DappList from '../../DAppList';
Expand Down Expand Up @@ -34,6 +35,7 @@ export function Example() {
const balance = useBalance();
const { toast } = useToast();

// eslint-disable-next-line @typescript-eslint/no-inferrable-types
const getTokenTransferFrom = (chainId: string | undefined, approve: boolean = false) => {
const tokens: {
name: string;
Expand Down Expand Up @@ -237,7 +239,7 @@ export function Example() {
});
}

return signed.toString();
return Promise.resolve(signed.toString());
}}
/>
</ApiGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function Example() {
}, [accounts]);

const getAccountInfo = () => {
// eslint-disable-next-line no-unsafe-optional-chaining
const [namespace, reference, address] = account?.split(':');
return {
namespace,
Expand Down
6 changes: 3 additions & 3 deletions packages/example/components/chains/aptos/example.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-return */
import { dapps } from './dapps.config';
import ConnectButton from '../../../components/connect/ConnectButton';
import { useEffect, useRef } from 'react';
Expand All @@ -11,7 +11,6 @@ import { useWallet } from '../../../components/connect/WalletContext';
import type { IKnownWallet } from '../../../components/connect/types';
import DappList from '../../../components/DAppList';
import params from './params';
import { SignMessagePayload } from '@onekeyfe/onekey-aptos-provider/dist/types';
import nacl from 'tweetnacl';
import { stripHexPrefix } from 'ethereumjs-util';
import { toast } from '../../ui/use-toast';
Expand Down Expand Up @@ -39,6 +38,7 @@ export default function Example() {
return Promise.reject('Wallet not found');
}

// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const provider = get(window, providerDetail.inject) as IProviderApi | undefined;

if (!provider) {
Expand Down Expand Up @@ -176,7 +176,7 @@ export default function Example() {
description="signMessage"
presupposeParams={params.signMessage}
onExecute={async (request: string) => {
const obj = JSON.parse(request) as SignMessagePayload;
const obj = JSON.parse(request);
const res = await provider?.signMessage(obj);
return JSON.stringify(res);
}}
Expand Down
2 changes: 1 addition & 1 deletion packages/example/components/chains/btc/example.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-return */
import { dapps } from './dapps.config';
import ConnectButton from '../../../components/connect/ConnectButton';
import { useEffect, useRef } from 'react';
Expand Down
4 changes: 2 additions & 2 deletions packages/example/components/chains/btcBabylon/example.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-return */
import { dapps } from './dapps.config';
import ConnectButton from '../../connect/ConnectButton';
import { useEffect, useRef } from 'react';
Expand Down Expand Up @@ -274,7 +274,7 @@ export default function BTCExample() {
return res;
}}
onValidate={async (request: string, response: string) => {
return Verifier.verifySignature(account.address, request, response);
return Promise.resolve(Verifier.verifySignature(account.address, request, response));
}}
/>
</ApiGroup>
Expand Down
5 changes: 3 additions & 2 deletions packages/example/components/chains/cardano/example.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/no-unused-vars, */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/require-await, @typescript-eslint/restrict-template-expressions */
import { dapps } from './dapps.config';
import ConnectButton from '../../../components/connect/ConnectButton';
import { useEffect, useRef, useState } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/example/components/chains/conflux/example.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-unsafe-optional-chaining */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-return */
import { dapps } from './dapps.config';
import ConnectButton from '../../../components/connect/ConnectButton';
import { useEffect, useRef } from 'react';
Expand Down
5 changes: 2 additions & 3 deletions packages/example/components/chains/cosmos/example.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-return */
import { dapps } from './dapps.config';
import ConnectButton from '../../../components/connect/ConnectButton';
import { useCallback, useEffect, useRef, useState } from 'react';
Expand Down
6 changes: 3 additions & 3 deletions packages/example/components/chains/ethereum/example.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-inferrable-types */
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-return */
import { dapps } from './dapps.config';
import ConnectButton from '../../../components/connect/ConnectButton';
import { useEffect, useRef } from 'react';
Expand Down
3 changes: 2 additions & 1 deletion packages/example/components/chains/scdo/example.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-return, no-unsafe-optional-chaining */
import { dapps } from './dapps.config';
import ConnectButton from '../../../components/connect/ConnectButton';
import { useRef } from 'react';
Expand Down Expand Up @@ -52,6 +52,7 @@ export default function Example() {
};
};

// eslint-disable-next-line @typescript-eslint/no-inferrable-types
const getTokenTransferFrom = (chainId: string | undefined, approve: boolean = false) => {
const tokens: {
name: string;
Expand Down
1 change: 1 addition & 0 deletions packages/example/components/chains/scdo/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */
import { defaultAbiCoder } from '@ethersproject/abi';

export function encodeTokenTransferPayload({ address, amount }: { address: string; amount: string }) {
Expand Down
2 changes: 1 addition & 1 deletion packages/example/components/chains/solana/example.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-return */
import { dapps } from './dapps.config';
import ConnectButton from '../../../components/connect/ConnectButton';
import { useEffect, useMemo, useRef } from 'react';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-unsafe-optional-chaining */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-return */
require('@solana/wallet-adapter-react-ui/styles.css');
import { dapps } from './dapps.config';
import { useEffect, useMemo } from 'react';
Expand Down
6 changes: 4 additions & 2 deletions packages/example/components/chains/ton/TonProofDemoApi.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import {
Account,
ConnectAdditionalRequest,
Expand All @@ -18,7 +19,7 @@ class TonProofDemoApiService {
this.accessToken = localStorage.getItem(this.localStorageKey);

if (!this.accessToken) {
this.generatePayload();
void this.generatePayload();
}
}

Expand Down Expand Up @@ -76,13 +77,14 @@ class TonProofDemoApiService {
})
).json();

// eslint-disable-next-line @typescript-eslint/ban-types
return response as {};
}

reset() {
this.accessToken = null;
localStorage.removeItem(this.localStorageKey);
this.generatePayload();
void this.generatePayload();
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/example/components/chains/ton/example.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-return */
import { dapps } from './dapps.config';
import { ApiPayload, ApiGroup } from '../../ApiActuator';
import DappList from '../../../components/DAppList';
Expand Down Expand Up @@ -91,7 +91,7 @@ export function Example() {
allowCallWithoutProvider={true}
onExecute={async (request: string) => {
void tonConnectUI.openModal();
return 'success';
return Promise.resolve('success');
}}
onValidate={async (request: string, response: string) => {
if (wallet.connectItems?.tonProof && 'proof' in wallet.connectItems.tonProof) {
Expand Down
3 changes: 1 addition & 2 deletions packages/example/components/chains/tron/example.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return */
/* eslint-disable no-unsafe-optional-chaining */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { dapps } from './dapps.config';
import ConnectButton from '../../../components/connect/ConnectButton';
import { use, useEffect, useRef, useState } from 'react';
Expand Down
Loading

0 comments on commit 5ccce07

Please sign in to comment.