Skip to content

Commit

Permalink
feat(world): add types for v2 config resolvers (#2389)
Browse files Browse the repository at this point in the history
Co-authored-by: David Blass <[email protected]>
  • Loading branch information
alvrs and ssalbdivad authored Mar 11, 2024
1 parent 257a0af commit 711f6e2
Show file tree
Hide file tree
Showing 20 changed files with 1,600 additions and 533 deletions.
16 changes: 13 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
"plugin:@typescript-eslint/recommended",
],
"rules": {
"max-len": ["error", { "code": 180, "comments": 180 }]
}
"max-len": ["error", { "code": 180, "comments": 180 }],
"@typescript-eslint/ban-types": [
"error",
{
"extendDefaults": true,
"types": {
// don't throw an error for the empty object type ({})
"{}": false,
},
},
],
},
}
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"typescript.tsdk": "node_modules/typescript/lib"
}
2 changes: 1 addition & 1 deletion packages/store/ts/config/v2/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("resolveSchema", () => {
},
} as const;
attest<typeof expected>(resolved).type.toString.snap(
'{ regular: { type: "uint256"; internalType: "uint256"; }; user: { type: "address"; internalType: "CustomType"; }; }',
'{ readonly regular: { readonly type: "uint256"; readonly internalType: "uint256"; }; readonly user: { readonly type: "address"; readonly internalType: "CustomType"; }; }',
);
});

Expand Down
6 changes: 3 additions & 3 deletions packages/store/ts/config/v2/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export type SchemaInput<scope extends AbiTypeScope = AbiTypeScope> = {
};

export type resolveSchema<schema extends SchemaInput<scope>, scope extends AbiTypeScope> = evaluate<{
[key in keyof schema]: {
readonly [key in keyof schema]: {
/** the Solidity primitive ABI type */
type: scope["types"][schema[key]];
readonly type: scope["types"][schema[key]];
/** the user defined type or Solidity primitive ABI type */
internalType: schema[key];
readonly internalType: schema[key];
};
}>;

Expand Down
Loading

0 comments on commit 711f6e2

Please sign in to comment.