diff --git a/packages/contracts-core/src/ERC1155.ts b/packages/contracts-core/src/ERC1155.ts index 26bed15..b8c8273 100644 --- a/packages/contracts-core/src/ERC1155.ts +++ b/packages/contracts-core/src/ERC1155.ts @@ -11,12 +11,7 @@ import { BaseContract } from './base'; import { callMethod } from './utils'; class ERC1155 extends BaseContract { - constructor( - address: string, - provider: JsonRpcProvider, - abi = abis.ERC1155, - account?: string | null - ) { + constructor(address: string, provider: JsonRpcProvider, abi = abis.ERC1155, account?: string | null) { super(address, provider, abi, account); } diff --git a/packages/contracts-core/src/KiltProofs.ts b/packages/contracts-core/src/KiltProofs.ts index da21f2a..4f9b45d 100644 --- a/packages/contracts-core/src/KiltProofs.ts +++ b/packages/contracts-core/src/KiltProofs.ts @@ -27,14 +27,9 @@ class KiltProofs extends BaseContract { callback?: (exists: boolean) => void ): Promise | Promise<() => void> { if (callback) { - return this.web3Query.one( - this.multicallContract.single_proof_exists(who, requestHash), - callback - ); + return this.web3Query.one(this.multicallContract.single_proof_exists(who, requestHash), callback); } else { - return this.web3Query.one( - this.multicallContract.single_proof_exists(who, requestHash) - ); + return this.web3Query.one(this.multicallContract.single_proof_exists(who, requestHash)); } } diff --git a/packages/contracts-core/src/Poap.ts b/packages/contracts-core/src/Poap.ts index 1c9e4d2..9e5f39d 100644 --- a/packages/contracts-core/src/Poap.ts +++ b/packages/contracts-core/src/Poap.ts @@ -2,11 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import type { BigNumber, BigNumberish } from '@ethersproject/bignumber'; -import type { - JsonRpcProvider, - TransactionReceipt, - TransactionResponse -} from '@ethersproject/providers'; +import type { JsonRpcProvider, TransactionReceipt, TransactionResponse } from '@ethersproject/providers'; import * as abis from './abis'; import { ERC1155 } from './ERC1155'; diff --git a/packages/contracts-core/src/SimpleAggregator.ts b/packages/contracts-core/src/SimpleAggregator.ts index 626c956..e86bde0 100644 --- a/packages/contracts-core/src/SimpleAggregator.ts +++ b/packages/contracts-core/src/SimpleAggregator.ts @@ -13,11 +13,7 @@ class SimpleAggregator extends BaseContract { } public isFinished(cOwner: string, requestHash: BytesLike): Promise; - public isFinished( - cOwner: string, - requestHash: BytesLike, - callback: (exists: boolean) => void - ): Promise<() => void>; + public isFinished(cOwner: string, requestHash: BytesLike, callback: (exists: boolean) => void): Promise<() => void>; public isFinished( cOwner: string, @@ -25,10 +21,7 @@ class SimpleAggregator extends BaseContract { callback?: (exists: boolean) => void ): Promise | Promise<() => void> { if (callback) { - return this.web3Query.one( - this.multicallContract.isFinished(cOwner, requestHash), - callback - ); + return this.web3Query.one(this.multicallContract.isFinished(cOwner, requestHash), callback); } else { return this.web3Query.one(this.multicallContract.isFinished(cOwner, requestHash)); } diff --git a/packages/contracts-core/src/utils.ts b/packages/contracts-core/src/utils.ts index ceeff2c..63fe5f4 100644 --- a/packages/contracts-core/src/utils.ts +++ b/packages/contracts-core/src/utils.ts @@ -53,12 +53,7 @@ export function getProviderOrSigner( // account is optional // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types -export function getContract( - address: string, - ABI: any, - library: JsonRpcProvider, - account?: string | null -): Contract { +export function getContract(address: string, ABI: any, library: JsonRpcProvider, account?: string | null): Contract { if (!isAddress(address) || address === AddressZero) { throw Error(`Invalid 'address' parameter '${address}'.`); } @@ -92,11 +87,7 @@ export async function getGasEstimate( .catch((error: any) => { console.debug('Call threw error', error); - return new CallError( - methodName, - 'Call threw error', - error?.error?.data?.message || 'Unknown error' - ); + return new CallError(methodName, 'Call threw error', error?.error?.data?.message || 'Unknown error'); }); }); @@ -126,8 +117,8 @@ export async function callMethod( // if the user rejected the tx, pass this along if ( [ - -32700, -32600, -32601, -32602, -32603, -32000, -32001, -32002, -32003, -32004, -32005, - -32006, 4001, 4100, 4200, 4900, 4901 + -32700, -32600, -32601, -32602, -32603, -32000, -32001, -32002, -32003, -32004, -32005, -32006, 4001, 4100, + 4200, 4900, 4901 ].includes(error?.code) ) { throw new RpcError(error.code); @@ -142,11 +133,6 @@ export async function callMethod( export function getRequestHash(requestDetails: RequestDetails) { return keccak256( ['bytes32', 'uint128[]', 'bytes32', 'bytes32'], - [ - requestDetails.cType, - requestDetails.fieldNames, - requestDetails.programHash, - requestDetails.attester - ] + [requestDetails.cType, requestDetails.fieldNames, requestDetails.programHash, requestDetails.attester] ); } diff --git a/packages/credential-core/src/vc/encryptDecrypt.spec.ts b/packages/credential-core/src/vc/encryptDecrypt.spec.ts index db3b51e..afdfd10 100644 --- a/packages/credential-core/src/vc/encryptDecrypt.spec.ts +++ b/packages/credential-core/src/vc/encryptDecrypt.spec.ts @@ -29,12 +29,9 @@ describe('encrypt and decrypt', () => { '0x887a133dfbc4741d71fcb882443f7260c3405f5a46c62a24ec3327ab1b72fad1' ], claimNonceMap: { - '0xa7c77ad182242fb339b5c2298a5261b0a422689bb6114b2450c21b0d01e41ce8': - '8d583499-4dd0-4438-ad0e-91427f2c6213', - '0x73cf049941ed8805d3d1bf8a553f9004b91f28bfb45dd00ba22a9b8869fe2e67': - '4b270eb2-7b62-4173-b46d-c95af345d704', - '0x42db520aad41fb03d1aebd0afe4828e52c147000f93c1aa3331ccf8ff567cdbb': - 'c87ac94c-5be7-4b60-8973-9b9849807f63' + '0xa7c77ad182242fb339b5c2298a5261b0a422689bb6114b2450c21b0d01e41ce8': '8d583499-4dd0-4438-ad0e-91427f2c6213', + '0x73cf049941ed8805d3d1bf8a553f9004b91f28bfb45dd00ba22a9b8869fe2e67': '4b270eb2-7b62-4173-b46d-c95af345d704', + '0x42db520aad41fb03d1aebd0afe4828e52c147000f93c1aa3331ccf8ff567cdbb': 'c87ac94c-5be7-4b60-8973-9b9849807f63' }, legitimations: [], delegationId: null, @@ -53,9 +50,7 @@ describe('encrypt and decrypt', () => { const decrypted = vcDecrypt(encrypted, '1234'); expect(decrypted).toEqual(kiltVC); - expect(() => vcDecrypt(encrypted, '123')).toThrow( - 'Unable to decrypt using the supplied passphrase' - ); + expect(() => vcDecrypt(encrypted, '123')).toThrow('Unable to decrypt using the supplied passphrase'); }); it('encrypt zkid vc and descrypt', () => { @@ -92,8 +87,7 @@ describe('encrypt and decrypt', () => { created: 1669915042670, verificationMethod: 'did:zk:0xdC6BF231a4f18074288C07C3f31f2eD170E368aD#key-0', proofPurpose: 'assertionMethod', - proofValue: - 'zHghh8GGTZpQsMfbkaotA2XyKFT8QFY87sBbGGrQPtuyeBj86rMZK95LJ3WF9J7BHiffabpHsDbd64xoXc5AmLMskk' + proofValue: 'zHghh8GGTZpQsMfbkaotA2XyKFT8QFY87sBbGGrQPtuyeBj86rMZK95LJ3WF9J7BHiffabpHsDbd64xoXc5AmLMskk' } ] }; @@ -103,8 +97,6 @@ describe('encrypt and decrypt', () => { const decrypted = vcDecrypt(encrypted, '1234'); expect(decrypted).toEqual(zkidVC); - expect(() => vcDecrypt(encrypted, '123')).toThrow( - 'Unable to decrypt using the supplied passphrase' - ); + expect(() => vcDecrypt(encrypted, '123')).toThrow('Unable to decrypt using the supplied passphrase'); }); }); diff --git a/packages/did-keyring/src/DidManager.ts b/packages/did-keyring/src/DidManager.ts index 79b4180..dea08c7 100644 --- a/packages/did-keyring/src/DidManager.ts +++ b/packages/did-keyring/src/DidManager.ts @@ -32,11 +32,7 @@ export class DidManager extends DidBase { this.kilt.on('remove', () => onRemove); } - public override addDidFromMnemonic( - mnemonic: string, - password: string, - type: 'zk' | 'kilt' = 'zk' - ): string { + public override addDidFromMnemonic(mnemonic: string, password: string, type: 'zk' | 'kilt' = 'zk'): string { if (type === 'zk') { return this.zk.addDidFromMnemonic(mnemonic, password); } else { @@ -44,11 +40,7 @@ export class DidManager extends DidBase { } } - public override addDidFromJson( - json: ZkidDidKeys$Json | KiltDidKeys$Json, - newPass: string, - oldPass: string - ): string { + public override addDidFromJson(json: ZkidDidKeys$Json | KiltDidKeys$Json, newPass: string, oldPass: string): string { if (isZkDidKeys$Json(json)) { return this.zk.addDidFromJson(json, newPass, oldPass); } diff --git a/packages/did-keyring/src/kilt/Keyring.ts b/packages/did-keyring/src/kilt/Keyring.ts index 418f196..553fafd 100644 --- a/packages/did-keyring/src/kilt/Keyring.ts +++ b/packages/did-keyring/src/kilt/Keyring.ts @@ -39,9 +39,7 @@ export class Keyring extends PolkadotKeyring implements KiltKeystore { data, peerPublicKey, publicKey - }: RequestData & { peerPublicKey: Uint8Array }): Promise< - ResponseData & { nonce: Uint8Array } - > { + }: RequestData & { peerPublicKey: Uint8Array }): Promise & { nonce: Uint8Array }> { const pair = this.getPair(publicKey); const nonce = randomAsU8a(24); diff --git a/packages/did-keyring/src/kilt/KiltDid.ts b/packages/did-keyring/src/kilt/KiltDid.ts index 0b9ea71..d842f57 100644 --- a/packages/did-keyring/src/kilt/KiltDid.ts +++ b/packages/did-keyring/src/kilt/KiltDid.ts @@ -26,16 +26,12 @@ export class KiltDid extends DidBase { * @returns a [[LightDidDetails]] object */ public override addDidFromMnemonic(mnemonic: string, password: string): DidUri { - const pairs = [ - this.keyring.addFromUri(mnemonic, {}, 'sr25519'), - this.keyring.addFromUri(mnemonic, {}, 'ed25519') - ]; + const pairs = [this.keyring.addFromUri(mnemonic, {}, 'sr25519'), this.keyring.addFromUri(mnemonic, {}, 'ed25519')]; const didDetails = LightDidDetails.fromDetails({ authenticationKey: { publicKey: pairs[0].publicKey, - type: - pairs[0].type === 'sr25519' ? VerificationKeyType.Sr25519 : VerificationKeyType.Ed25519 + type: pairs[0].type === 'sr25519' ? VerificationKeyType.Sr25519 : VerificationKeyType.Ed25519 }, encryptionKey: { publicKey: pairs[1].publicKey, @@ -60,8 +56,7 @@ export class KiltDid extends DidBase { const didDetails = LightDidDetails.fromDetails({ authenticationKey: { publicKey: pairs[0].publicKey, - type: - pairs[0].type === 'sr25519' ? VerificationKeyType.Sr25519 : VerificationKeyType.Ed25519 + type: pairs[0].type === 'sr25519' ? VerificationKeyType.Sr25519 : VerificationKeyType.Ed25519 }, encryptionKey: { publicKey: pairs[1].publicKey, diff --git a/packages/did-keyring/src/kilt/types.ts b/packages/did-keyring/src/kilt/types.ts index c9e3800..28821ec 100644 --- a/packages/did-keyring/src/kilt/types.ts +++ b/packages/did-keyring/src/kilt/types.ts @@ -1,12 +1,7 @@ // Copyright 2021-2023 zcloak authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { - DidUri, - EncryptionAlgorithms, - Keystore, - SigningAlgorithms -} from '@kiltprotocol/types'; +import type { DidUri, EncryptionAlgorithms, Keystore, SigningAlgorithms } from '@kiltprotocol/types'; import type { KeyringPair$Json } from '@polkadot/keyring/types'; export type KiltKeystore = Keystore; diff --git a/packages/did-keyring/src/types.ts b/packages/did-keyring/src/types.ts index f6b6081..7bd14ad 100644 --- a/packages/did-keyring/src/types.ts +++ b/packages/did-keyring/src/types.ts @@ -1,12 +1,7 @@ // Copyright 2021-2023 zcloak authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { - DidUri, - EncryptionAlgorithms, - Keystore, - SigningAlgorithms -} from '@kiltprotocol/types'; +import type { DidUri, EncryptionAlgorithms, Keystore, SigningAlgorithms } from '@kiltprotocol/types'; import type { KeyringPair$Json as KiltKeyringPair$Json } from '@polkadot/keyring/types'; import type { DidKeys$Json } from '@zcloak/did/keys/types'; diff --git a/packages/react-wallet/src/AbstractWallet.ts b/packages/react-wallet/src/AbstractWallet.ts index 5dcbb36..7eee2b7 100644 --- a/packages/react-wallet/src/AbstractWallet.ts +++ b/packages/react-wallet/src/AbstractWallet.ts @@ -34,8 +34,5 @@ export abstract class AbstractWallet extends Events { public abstract disconnect(): Promise; - public abstract switchNetwork( - chainId: number, - params?: AddEthereumChainParameter - ): Promise; + public abstract switchNetwork(chainId: number, params?: AddEthereumChainParameter): Promise; } diff --git a/packages/react-wallet/src/WalletProvider.tsx b/packages/react-wallet/src/WalletProvider.tsx index e7cad81..9aa409a 100644 --- a/packages/react-wallet/src/WalletProvider.tsx +++ b/packages/react-wallet/src/WalletProvider.tsx @@ -30,10 +30,7 @@ interface Props { const WalletContext = createContext({} as WalletState); -export const WalletProvider: React.FC> = ({ - children, - supportedChainId -}) => { +export const WalletProvider: React.FC> = ({ children, supportedChainId }) => { const [state, setState] = useState({}); const wallet = useRef(); @@ -45,10 +42,7 @@ export const WalletProvider: React.FC> = ({ setState((state) => ({ ...state, - account: - _wallet.accounts && _wallet.accounts.length > 0 - ? getAddress(_wallet.accounts[0]) - : undefined, + account: _wallet.accounts && _wallet.accounts.length > 0 ? getAddress(_wallet.accounts[0]) : undefined, chainId: _wallet.chainId, provider: _wallet.provider })); diff --git a/packages/react-wallet/src/switchNetwork.ts b/packages/react-wallet/src/switchNetwork.ts index 0366461..963f64c 100644 --- a/packages/react-wallet/src/switchNetwork.ts +++ b/packages/react-wallet/src/switchNetwork.ts @@ -37,10 +37,7 @@ export async function switchNetwork( } } -export async function addNetwork( - externalProvider: any, - params: AddEthereumChainParameter -): Promise { +export async function addNetwork(externalProvider: any, params: AddEthereumChainParameter): Promise { await externalProvider?.request?.({ method: 'wallet_addEthereumChain', params: [ diff --git a/packages/service/src/Api.ts b/packages/service/src/Api.ts index 9299fcd..c9d30c4 100644 --- a/packages/service/src/Api.ts +++ b/packages/service/src/Api.ts @@ -56,12 +56,9 @@ export class CredentialApi extends Request { } getAttestationStatus(params: { senderKeyId: string }) { - return this.get>( - '/admin-attester/attestation-status', - { - params - } - ); + return this.get>('/admin-attester/attestation-status', { + params + }); } getAttestation(params: { senderKeyId: string; receiverKeyId: string }) { @@ -115,12 +112,7 @@ export class CredentialApi extends Request { return this.post>('/message', { body }); } - getMessages(params: { - receiverKeyId?: string; - senderKeyId?: string; - start_id?: string; - size?: number; - }) { + getMessages(params: { receiverKeyId?: string; senderKeyId?: string; start_id?: string; size?: number }) { return this.get>('/message', { params }); } } diff --git a/packages/ui-did-keyring/src/KiltDid.ts b/packages/ui-did-keyring/src/KiltDid.ts index ef97b9f..acda145 100644 --- a/packages/ui-did-keyring/src/KiltDid.ts +++ b/packages/ui-did-keyring/src/KiltDid.ts @@ -49,10 +49,7 @@ export class KiltDid extends KiltDidSuper { super.remove(didUrl); } - public override addDid( - didUriOrDetails: DidUri | LightDidDetails, - password?: string | undefined - ): LightDidDetails { + public override addDid(didUriOrDetails: DidUri | LightDidDetails, password?: string | undefined): LightDidDetails { const didDetails = super.addDid(didUriOrDetails, password); this.#store.set(kiltDidKey(didDetails.uri), didDetails.uri); diff --git a/packages/ui-did-keyring/src/defaults.ts b/packages/ui-did-keyring/src/defaults.ts index 1fb8ecf..4b37277 100644 --- a/packages/ui-did-keyring/src/defaults.ts +++ b/packages/ui-did-keyring/src/defaults.ts @@ -32,13 +32,4 @@ const zkPairKeyRegex = new RegExp(`^${ZK_PAIR_PREFIX}0x[0-9a-f]*`, ''); const zkDidKey = (didUri: DidUrl): string => didUri; const zkDidRegex = new RegExp(`^${ZK_DID_PREFIX}0x[0-9A-Fa-f]*`, ''); -export { - kiltPairKey, - kiltPairKeyRegex, - kiltDidKey, - kiltDidRegex, - zkPairKey, - zkPairKeyRegex, - zkDidKey, - zkDidRegex -}; +export { kiltPairKey, kiltPairKeyRegex, kiltDidKey, kiltDidRegex, zkPairKey, zkPairKeyRegex, zkDidKey, zkDidRegex }; diff --git a/packages/web3-query/src/Web3Query.ts b/packages/web3-query/src/Web3Query.ts index 20dfc7d..5f5f885 100644 --- a/packages/web3-query/src/Web3Query.ts +++ b/packages/web3-query/src/Web3Query.ts @@ -67,10 +67,7 @@ export class Web3Query { } public async all(calls: ContractCall[]): Promise; - public async all( - calls: ContractCall[], - callback: (results: T) => void - ): Promise<() => void>; + public async all(calls: ContractCall[], callback: (results: T) => void): Promise<() => void>; public async all( calls: ContractCall[], @@ -99,15 +96,9 @@ export class Web3Query { } public async one(call: ContractCall): Promise; - public async one( - call: ContractCall, - callback: (results: TOne) => void - ): Promise<() => void>; - - public async one( - call: ContractCall, - callback?: (results: TOne) => void - ): Promise void)> { + public async one(call: ContractCall, callback: (results: TOne) => void): Promise<() => void>; + + public async one(call: ContractCall, callback?: (results: TOne) => void): Promise void)> { const [result] = await all<[TOne]>([call], await getAddress(this._provider), this._provider); if (callback) { diff --git a/packages/web3-query/src/contract.ts b/packages/web3-query/src/contract.ts index dd9ab42..b1d984e 100644 --- a/packages/web3-query/src/contract.ts +++ b/packages/web3-query/src/contract.ts @@ -25,12 +25,8 @@ export class Contract { this._abi = toFragment(abi); - this._functions = this._abi - .filter((x) => x.type === 'function') - .map((x) => FunctionFragment.from(x)); - const callFunctions = this._functions.filter( - (x) => x.stateMutability === 'pure' || x.stateMutability === 'view' - ); + this._functions = this._abi.filter((x) => x.type === 'function').map((x) => FunctionFragment.from(x)); + const callFunctions = this._functions.filter((x) => x.stateMutability === 'pure' || x.stateMutability === 'view'); for (const callFunction of callFunctions) { const { name } = callFunction;