Skip to content

Commit

Permalink
Resolved linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
andresceballosm committed Jul 31, 2024
1 parent b731bf2 commit 37b0b86
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
6 changes: 3 additions & 3 deletions examples/taco/nodejs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);

Expand Down Expand Up @@ -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(),
);

Expand All @@ -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();

Expand Down
42 changes: 25 additions & 17 deletions packages/taco/src/conditions/base/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -87,28 +92,31 @@ const functionAbiSchema = z
},
);

function toJsonAbiFormat(humanReadableAbi: string): any {
function toJsonAbiFormat(humanReadableAbi: string) {
const abiWithoutFunctionKeyword = humanReadableAbi.replace(
/^function\s+/,
'',
);
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<typeof functionAbiSchema>;
Expand Down
2 changes: 1 addition & 1 deletion packages/taco/src/conditions/context/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class WalletAuthenticationProvider {
public async getOrCreateWalletSignature(): Promise<TypedSignature> {
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}`;
Expand Down
4 changes: 1 addition & 3 deletions packages/taco/test/conditions/base/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
);
Expand Down

0 comments on commit 37b0b86

Please sign in to comment.