diff --git a/examples/taco/nodejs/src/index.ts b/examples/taco/nodejs/src/index.ts index 01b5db7b3..ae086ade0 100644 --- a/examples/taco/nodejs/src/index.ts +++ b/examples/taco/nodejs/src/index.ts @@ -50,7 +50,7 @@ console.log('Chain ID:', chainId); const encryptToBytes = async (messageString: string) => { const encryptorSigner = new ethers.Wallet(encryptorPrivateKey); console.log( - 'Encryptor signer\'s address:', + "Encryptor signer's address:", await encryptorSigner.getAddress(), ); @@ -98,7 +98,7 @@ const encryptToBytes = async (messageString: string) => { const decryptFromBytes = async (encryptedBytes: Uint8Array) => { const consumerSigner = new ethers.Wallet(consumerPrivateKey); console.log( - '\nConsumer signer\'s address:', + "\nConsumer signer's address:", await consumerSigner.getAddress(), ); @@ -117,7 +117,7 @@ const runExample = async () => { // Make sure the provider is connected to the correct network const network = await provider.getNetwork(); if (network.chainId !== chainId) { - throw (`Please connect your provider to an appropriate network ${chainId}`); + throw `Please connect your provider to an appropriate network ${chainId}`; } await initialize(); diff --git a/packages/taco/src/conditions/base/contract.ts b/packages/taco/src/conditions/base/contract.ts index b2295d0aa..20d9b0458 100644 --- a/packages/taco/src/conditions/base/contract.ts +++ b/packages/taco/src/conditions/base/contract.ts @@ -15,12 +15,18 @@ const EthBaseTypes: [string, ...string[]] = [ 'string', 'address', 'address payable', - ...Array.from({ length: 32 }, (_v, i) => `bytes${i + 1}`), // bytes1 through bytes32 + ...Array.from({ length: 32 }, (_v, i) => `bytes${i + 1}`), 'bytes', - ...Array.from({ length: 32 }, (_v, i) => `uint${8 * (i + 1)}`), // uint8 through uint256 - ...Array.from({ length: 32 }, (_v, i) => `int${8 * (i + 1)}`), // int8 through int256 + ...Array.from({ length: 32 }, (_v, i) => `uint${8 * (i + 1)}`), + ...Array.from({ length: 32 }, (_v, i) => `int${8 * (i + 1)}`), ]; +type AbiVariable = { + name: string; + type: string; + internalType: string; +}; + const functionAbiVariableSchema = z .object({ name: z.string(), @@ -59,7 +65,6 @@ const functionAbiSchema = z (functionAbi) => { let asInterface; try { - // `stringify` here because ethers.utils.Interface doesn't accept a Zod schema asInterface = new ethers.utils.Interface(JSON.stringify([functionAbi])); } catch (e) { return false; @@ -87,7 +92,7 @@ const functionAbiSchema = z }, ); -function toJsonAbiFormat(humanReadableAbi: string): any { +function toJsonAbiFormat(humanReadableAbi: string) { const abiWithoutFunctionKeyword = humanReadableAbi.replace( /^function\s+/, '', @@ -95,20 +100,23 @@ function toJsonAbiFormat(humanReadableAbi: string): any { const fragment = ethers.utils.FunctionFragment.from( abiWithoutFunctionKeyword, ); - const { constant, payable, ...jsonAbi } = JSON.parse( - fragment.format(ethers.utils.FormatTypes.json), - ); + const jsonAbi = JSON.parse(fragment.format(ethers.utils.FormatTypes.json)); - jsonAbi.inputs = jsonAbi.inputs.map((input: any) => ({ - ...input, - internalType: input.type, - })); - jsonAbi.outputs = jsonAbi.outputs.map((output: any) => ({ - ...output, - internalType: output.type, - })); + const filteredJsonAbi = { + name: jsonAbi.name, + type: jsonAbi.type, + stateMutability: jsonAbi.stateMutability, + inputs: jsonAbi.inputs.map((input: AbiVariable) => ({ + ...input, + internalType: input.type, + })), + outputs: jsonAbi.outputs.map((output: AbiVariable) => ({ + ...output, + internalType: output.type, + })), + }; - return jsonAbi; + return filteredJsonAbi; } export type FunctionAbiProps = z.infer; diff --git a/packages/taco/src/conditions/context/providers.ts b/packages/taco/src/conditions/context/providers.ts index 70dcc68b5..f912aaf19 100644 --- a/packages/taco/src/conditions/context/providers.ts +++ b/packages/taco/src/conditions/context/providers.ts @@ -27,7 +27,7 @@ export class WalletAuthenticationProvider { public async getOrCreateWalletSignature(): Promise { console.warn( 'DeprecationWarning: The EIP712 authentication is deprecated and will be replaced ' + - 'by EIP4361 authentication in the next release.' + 'by EIP4361 authentication in the next release.', ); const address = await this.signer.getAddress(); const storageKey = `wallet-signature-${address}`; diff --git a/packages/taco/test/conditions/base/contract.test.ts b/packages/taco/test/conditions/base/contract.test.ts index c8bbf6478..57c35c47c 100644 --- a/packages/taco/test/conditions/base/contract.test.ts +++ b/packages/taco/test/conditions/base/contract.test.ts @@ -347,9 +347,7 @@ describe('supports custom function abi', () => { }); const invalidHumanReadableAbi = 'function invalidAbi'; - expect(() => - humanReadableAbiSchema.parse(humanReadableAbi), - ).not.toThrow(); + expect(() => humanReadableAbiSchema.parse(humanReadableAbi)).not.toThrow(); expect(() => humanReadableAbiSchema.parse(invalidHumanReadableAbi)).toThrow( 'Invalid Human-Readable ABI format', );