Comparing version 2.0.16 to 2.0.17
@@ -116,10 +116,22 @@ import { writeFileSync } from 'fs'; | ||
export type Mutations = keyof Contract['mutations'] | ||
const BaseMutation = { | ||
contractName: '{{CONTRACT_NAME}}' as const, | ||
deployAddress, | ||
getAbi: () => abi, | ||
function getMutation<M extends Mutations>(functionName: M) { | ||
return { | ||
contractName: '{{CONTRACT_NAME}}' as const, | ||
functionName, | ||
deployAddress, | ||
argsType: undefined as ExtractArgs<Contract['mutations'][M]> | undefined, | ||
getAbi: () => abi, | ||
} | ||
} | ||
export const mutation = { | ||
${writeMethods.map((m) => `\t\t${m}: {...BaseMutation, functionName: '${m}', argsType: undefined as ExtractArgs<Contract['mutations']['${m}']> | undefined},`).join('\n')} | ||
export const mutation: { | ||
[K in Mutations]: { | ||
contractName: '{{CONTRACT_NAME}}' | ||
deployAddress: Address | undefined | ||
getAbi: () => typeof abi | ||
functionName: K | ||
argsType: ExtractArgs<Contract['mutations'][K]> | undefined | ||
} | ||
} = { | ||
${writeMethods.map((m) => `\t\t${m}: getMutation('${m}'),`).join('\n')} | ||
} | ||
@@ -126,0 +138,0 @@ ` |
@@ -19,2 +19,11 @@ const typeMap = { | ||
}; | ||
export function extractParamsList(funcs) { | ||
const sortedFuncs = funcs.sort((a, b) => (b.inputs?.length || 0) - (a.inputs?.length || 0)); | ||
const baseFunc = sortedFuncs[0]; | ||
return (baseFunc.inputs?.map((input, i) => ({ | ||
name: input.name.replace('_', ''), | ||
type: getSolidityToTsType(input), | ||
isOptional: sortedFuncs.some((f) => (f.inputs?.length || 0) < i + 1), | ||
})) || []); | ||
} | ||
function generateContractTypes(abi) { | ||
@@ -51,10 +60,6 @@ const functions = abi.filter((item) => item.type === 'function'); | ||
function generateOverloadedType(name, funcs) { | ||
const sortedFuncs = funcs.sort((a, b) => (b.inputs?.length || 0) - (a.inputs?.length || 0)); | ||
const baseFunc = sortedFuncs[0]; | ||
const params = baseFunc.inputs | ||
?.map((input, i) => { | ||
const isOptional = sortedFuncs.some((f) => (f.inputs?.length || 0) < i + 1); | ||
return `${input.name.replace('_', '')}${isOptional ? '?' : ''}: ${getSolidityToTsType(input)}`; | ||
}) | ||
.join(', ') || ''; | ||
const params = extractParamsList(funcs) | ||
.map(({ name, type, isOptional }) => `${name}${isOptional ? '?' : ''}: ${type}`) | ||
.join(', '); | ||
const baseFunc = funcs[0]; | ||
const output = baseFunc.outputs && baseFunc.outputs.length === 1 | ||
@@ -61,0 +66,0 @@ ? getSolidityToTsType(baseFunc.outputs[0]) |
{ | ||
"name": "dappql", | ||
"version": "2.0.16", | ||
"version": "2.0.17", | ||
"description": "wagmi extension to easily query smart-contracts", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
14480
354
1