diff --git a/.gitignore b/.gitignore index 3c3629e..cea4dfd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +dist/utils.* diff --git a/lib/utils.ts b/lib/utils.ts new file mode 100644 index 0000000..a3f2896 --- /dev/null +++ b/lib/utils.ts @@ -0,0 +1,24 @@ +import { uniqWith } from 'lodash'; +import { AbiEvent, AbiFunction, type Abi } from 'abitype'; + +export type NodeType = 'event' | 'function'; + +export type AbiNode = AbiEvent | AbiFunction; + +const stringifyInputTypes = (node: AbiNode) => + JSON.stringify(node.inputs.map(({ type }) => type)); + +// Some newer versions of the compiler add extra stuff that prevents a deep equal comparison +const nodesAreEqual = (nodeA: AbiNode, nodeB: AbiNode) => + nodeA.name === nodeB.name && + stringifyInputTypes(nodeA) === stringifyInputTypes(nodeB); + +export const joinAbis = (abiA: Abi, abiB: Abi, nodeType: NodeType) => { + return uniqWith( + (abiA as AbiNode[]).concat( + (abiB as AbiNode[]).filter(({ type }: { type: string }) => type === nodeType), + ), + nodesAreEqual, + ); +}; + diff --git a/package.json b/package.json index 020638a..e86bf89 100644 --- a/package.json +++ b/package.json @@ -7,23 +7,28 @@ "README.md" ], "exports": { + "./utils": "./dist/utils.js", "./*": "./dist/*.json" }, "main": "./dist/versions.json", "module": "./dist/versions.json", "license": "GPL-3.0-only", "engines": { - "node": "^16 || ^18 || ^20", - "npm": "^8 || ^9 || ^10" + "node": "^18 || ^20 || ^22", + "npm": "^10" }, "scripts": { - "build": "ts-node scripts/extract-contract-abis.ts", + "build": "ts-node scripts/extract-contract-abis.ts && tsc lib/utils.ts --skipLibCheck --declaration --outDir dist", "test": "node scripts/check-versions.mjs", "prepare": "husky install" }, + "dependencies": { + "abitype": "^1.0.7", + "lodash": "^4.17.21" + }, "devDependencies": { - "@commitlint/cli": "^19.3.0", - "@commitlint/config-conventional": "^19.2.2", + "@commitlint/cli": "^19.6.1", + "@commitlint/config-conventional": "^19.6.0", "@types/lodash": "^4.14.191", "@types/mkdirp": "^1.0.2", "@types/rimraf": "^3.0.2", @@ -39,12 +44,11 @@ "eslint-plugin-prettier": "^4.2.1", "fast-glob": "^3.2.11", "husky": "^8.0.3", - "lodash": "^4.17.21", "mkdirp": "^1.0.4", "prettier": "^2.8.0", "rimraf": "^3.0.2", "ts-node": "^10.9.1", - "typescript": "^4.9.3", + "typescript": "^5.7.2", "yargs": "^17.3.1" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fb693c3..e2f466b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,13 +4,21 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +dependencies: + abitype: + specifier: ^1.0.7 + version: 1.0.7(typescript@5.7.2) + lodash: + specifier: ^4.17.21 + version: 4.17.21 + devDependencies: '@commitlint/cli': - specifier: ^19.3.0 - version: 19.3.0(@types/node@18.13.0)(typescript@4.9.5) + specifier: ^19.6.1 + version: 19.6.1(@types/node@18.13.0)(typescript@5.7.2) '@commitlint/config-conventional': - specifier: ^19.2.2 - version: 19.2.2 + specifier: ^19.6.0 + version: 19.6.0 '@types/lodash': specifier: ^4.14.191 version: 4.14.191 @@ -25,10 +33,10 @@ devDependencies: version: 17.0.22 '@typescript-eslint/eslint-plugin': specifier: ^5.45.0 - version: 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@4.9.5) + version: 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@5.7.2) '@typescript-eslint/parser': specifier: ^5.45.0 - version: 5.51.0(eslint@8.34.0)(typescript@4.9.5) + version: 5.51.0(eslint@8.34.0)(typescript@5.7.2) eslint: specifier: ^8.28.0 version: 8.34.0 @@ -46,7 +54,7 @@ devDependencies: version: 2.27.5(@typescript-eslint/parser@5.51.0)(eslint@8.34.0) eslint-plugin-jest: specifier: ^26.1.1 - version: 26.9.0(@typescript-eslint/eslint-plugin@5.51.0)(eslint@8.34.0)(typescript@4.9.5) + version: 26.9.0(@typescript-eslint/eslint-plugin@5.51.0)(eslint@8.34.0)(typescript@5.7.2) eslint-plugin-prettier: specifier: ^4.2.1 version: 4.2.1(eslint-config-prettier@8.6.0)(eslint@8.34.0)(prettier@2.8.4) @@ -56,9 +64,6 @@ devDependencies: husky: specifier: ^8.0.3 version: 8.0.3 - lodash: - specifier: ^4.17.21 - version: 4.17.21 mkdirp: specifier: ^1.0.4 version: 1.0.4 @@ -70,10 +75,10 @@ devDependencies: version: 3.0.2 ts-node: specifier: ^10.9.1 - version: 10.9.1(@types/node@18.13.0)(typescript@4.9.5) + version: 10.9.1(@types/node@18.13.0)(typescript@5.7.2) typescript: - specifier: ^4.9.3 - version: 4.9.5 + specifier: ^5.7.2 + version: 5.7.2 yargs: specifier: ^17.3.1 version: 17.6.2 @@ -103,44 +108,44 @@ packages: picocolors: 1.0.1 dev: true - /@commitlint/cli@19.3.0(@types/node@18.13.0)(typescript@4.9.5): - resolution: {integrity: sha512-LgYWOwuDR7BSTQ9OLZ12m7F/qhNY+NpAyPBgo4YNMkACE7lGuUnuQq1yi9hz1KA4+3VqpOYl8H1rY/LYK43v7g==} + /@commitlint/cli@19.6.1(@types/node@18.13.0)(typescript@5.7.2): + resolution: {integrity: sha512-8hcyA6ZoHwWXC76BoC8qVOSr8xHy00LZhZpauiD0iO0VYbVhMnED0da85lTfIULxl7Lj4c6vZgF0Wu/ed1+jlQ==} engines: {node: '>=v18'} hasBin: true dependencies: - '@commitlint/format': 19.3.0 - '@commitlint/lint': 19.2.2 - '@commitlint/load': 19.2.0(@types/node@18.13.0)(typescript@4.9.5) - '@commitlint/read': 19.2.1 - '@commitlint/types': 19.0.3 - execa: 8.0.1 + '@commitlint/format': 19.5.0 + '@commitlint/lint': 19.6.0 + '@commitlint/load': 19.6.1(@types/node@18.13.0)(typescript@5.7.2) + '@commitlint/read': 19.5.0 + '@commitlint/types': 19.5.0 + tinyexec: 0.3.1 yargs: 17.6.2 transitivePeerDependencies: - '@types/node' - typescript dev: true - /@commitlint/config-conventional@19.2.2: - resolution: {integrity: sha512-mLXjsxUVLYEGgzbxbxicGPggDuyWNkf25Ht23owXIH+zV2pv1eJuzLK3t1gDY5Gp6pxdE60jZnWUY5cvgL3ufw==} + /@commitlint/config-conventional@19.6.0: + resolution: {integrity: sha512-DJT40iMnTYtBtUfw9ApbsLZFke1zKh6llITVJ+x9mtpHD08gsNXaIRqHTmwTZL3dNX5+WoyK7pCN/5zswvkBCQ==} engines: {node: '>=v18'} dependencies: - '@commitlint/types': 19.0.3 + '@commitlint/types': 19.5.0 conventional-changelog-conventionalcommits: 7.0.2 dev: true - /@commitlint/config-validator@19.0.3: - resolution: {integrity: sha512-2D3r4PKjoo59zBc2auodrSCaUnCSALCx54yveOFwwP/i2kfEAQrygwOleFWswLqK0UL/F9r07MFi5ev2ohyM4Q==} + /@commitlint/config-validator@19.5.0: + resolution: {integrity: sha512-CHtj92H5rdhKt17RmgALhfQt95VayrUo2tSqY9g2w+laAXyk7K/Ef6uPm9tn5qSIwSmrLjKaXK9eiNuxmQrDBw==} engines: {node: '>=v18'} dependencies: - '@commitlint/types': 19.0.3 + '@commitlint/types': 19.5.0 ajv: 8.17.1 dev: true - /@commitlint/ensure@19.0.3: - resolution: {integrity: sha512-SZEpa/VvBLoT+EFZVb91YWbmaZ/9rPH3ESrINOl0HD2kMYsjvl0tF7nMHh0EpTcv4+gTtZBAe1y/SS6/OhfZzQ==} + /@commitlint/ensure@19.5.0: + resolution: {integrity: sha512-Kv0pYZeMrdg48bHFEU5KKcccRfKmISSm9MvgIgkpI6m+ohFTB55qZlBW6eYqh/XDfRuIO0x4zSmvBjmOwWTwkg==} engines: {node: '>=v18'} dependencies: - '@commitlint/types': 19.0.3 + '@commitlint/types': 19.5.0 lodash.camelcase: 4.3.0 lodash.kebabcase: 4.1.1 lodash.snakecase: 4.1.1 @@ -148,48 +153,48 @@ packages: lodash.upperfirst: 4.3.1 dev: true - /@commitlint/execute-rule@19.0.0: - resolution: {integrity: sha512-mtsdpY1qyWgAO/iOK0L6gSGeR7GFcdW7tIjcNFxcWkfLDF5qVbPHKuGATFqRMsxcO8OUKNj0+3WOHB7EHm4Jdw==} + /@commitlint/execute-rule@19.5.0: + resolution: {integrity: sha512-aqyGgytXhl2ejlk+/rfgtwpPexYyri4t8/n4ku6rRJoRhGZpLFMqrZ+YaubeGysCP6oz4mMA34YSTaSOKEeNrg==} engines: {node: '>=v18'} dev: true - /@commitlint/format@19.3.0: - resolution: {integrity: sha512-luguk5/aF68HiF4H23ACAfk8qS8AHxl4LLN5oxPc24H+2+JRPsNr1OS3Gaea0CrH7PKhArBMKBz5RX9sA5NtTg==} + /@commitlint/format@19.5.0: + resolution: {integrity: sha512-yNy088miE52stCI3dhG/vvxFo9e4jFkU1Mj3xECfzp/bIS/JUay4491huAlVcffOoMK1cd296q0W92NlER6r3A==} engines: {node: '>=v18'} dependencies: - '@commitlint/types': 19.0.3 + '@commitlint/types': 19.5.0 chalk: 5.3.0 dev: true - /@commitlint/is-ignored@19.2.2: - resolution: {integrity: sha512-eNX54oXMVxncORywF4ZPFtJoBm3Tvp111tg1xf4zWXGfhBPKpfKG6R+G3G4v5CPlRROXpAOpQ3HMhA9n1Tck1g==} + /@commitlint/is-ignored@19.6.0: + resolution: {integrity: sha512-Ov6iBgxJQFR9koOupDPHvcHU9keFupDgtB3lObdEZDroiG4jj1rzky60fbQozFKVYRTUdrBGICHG0YVmRuAJmw==} engines: {node: '>=v18'} dependencies: - '@commitlint/types': 19.0.3 + '@commitlint/types': 19.5.0 semver: 7.6.2 dev: true - /@commitlint/lint@19.2.2: - resolution: {integrity: sha512-xrzMmz4JqwGyKQKTpFzlN0dx0TAiT7Ran1fqEBgEmEj+PU98crOFtysJgY+QdeSagx6EDRigQIXJVnfrI0ratA==} + /@commitlint/lint@19.6.0: + resolution: {integrity: sha512-LRo7zDkXtcIrpco9RnfhOKeg8PAnE3oDDoalnrVU/EVaKHYBWYL1DlRR7+3AWn0JiBqD8yKOfetVxJGdEtZ0tg==} engines: {node: '>=v18'} dependencies: - '@commitlint/is-ignored': 19.2.2 - '@commitlint/parse': 19.0.3 - '@commitlint/rules': 19.0.3 - '@commitlint/types': 19.0.3 + '@commitlint/is-ignored': 19.6.0 + '@commitlint/parse': 19.5.0 + '@commitlint/rules': 19.6.0 + '@commitlint/types': 19.5.0 dev: true - /@commitlint/load@19.2.0(@types/node@18.13.0)(typescript@4.9.5): - resolution: {integrity: sha512-XvxxLJTKqZojCxaBQ7u92qQLFMMZc4+p9qrIq/9kJDy8DOrEa7P1yx7Tjdc2u2JxIalqT4KOGraVgCE7eCYJyQ==} + /@commitlint/load@19.6.1(@types/node@18.13.0)(typescript@5.7.2): + resolution: {integrity: sha512-kE4mRKWWNju2QpsCWt428XBvUH55OET2N4QKQ0bF85qS/XbsRGG1MiTByDNlEVpEPceMkDr46LNH95DtRwcsfA==} engines: {node: '>=v18'} dependencies: - '@commitlint/config-validator': 19.0.3 - '@commitlint/execute-rule': 19.0.0 - '@commitlint/resolve-extends': 19.1.0 - '@commitlint/types': 19.0.3 + '@commitlint/config-validator': 19.5.0 + '@commitlint/execute-rule': 19.5.0 + '@commitlint/resolve-extends': 19.5.0 + '@commitlint/types': 19.5.0 chalk: 5.3.0 - cosmiconfig: 9.0.0(typescript@4.9.5) - cosmiconfig-typescript-loader: 5.0.0(@types/node@18.13.0)(cosmiconfig@9.0.0)(typescript@4.9.5) + cosmiconfig: 9.0.0(typescript@5.7.2) + cosmiconfig-typescript-loader: 6.1.0(@types/node@18.13.0)(cosmiconfig@9.0.0)(typescript@5.7.2) lodash.isplainobject: 4.0.6 lodash.merge: 4.6.2 lodash.uniq: 4.5.0 @@ -198,68 +203,67 @@ packages: - typescript dev: true - /@commitlint/message@19.0.0: - resolution: {integrity: sha512-c9czf6lU+9oF9gVVa2lmKaOARJvt4soRsVmbR7Njwp9FpbBgste5i7l/2l5o8MmbwGh4yE1snfnsy2qyA2r/Fw==} + /@commitlint/message@19.5.0: + resolution: {integrity: sha512-R7AM4YnbxN1Joj1tMfCyBryOC5aNJBdxadTZkuqtWi3Xj0kMdutq16XQwuoGbIzL2Pk62TALV1fZDCv36+JhTQ==} engines: {node: '>=v18'} dev: true - /@commitlint/parse@19.0.3: - resolution: {integrity: sha512-Il+tNyOb8VDxN3P6XoBBwWJtKKGzHlitEuXA5BP6ir/3loWlsSqDr5aecl6hZcC/spjq4pHqNh0qPlfeWu38QA==} + /@commitlint/parse@19.5.0: + resolution: {integrity: sha512-cZ/IxfAlfWYhAQV0TwcbdR1Oc0/r0Ik1GEessDJ3Lbuma/MRO8FRQX76eurcXtmhJC//rj52ZSZuXUg0oIX0Fw==} engines: {node: '>=v18'} dependencies: - '@commitlint/types': 19.0.3 + '@commitlint/types': 19.5.0 conventional-changelog-angular: 7.0.0 conventional-commits-parser: 5.0.0 dev: true - /@commitlint/read@19.2.1: - resolution: {integrity: sha512-qETc4+PL0EUv7Q36lJbPG+NJiBOGg7SSC7B5BsPWOmei+Dyif80ErfWQ0qXoW9oCh7GTpTNRoaVhiI8RbhuaNw==} + /@commitlint/read@19.5.0: + resolution: {integrity: sha512-TjS3HLPsLsxFPQj6jou8/CZFAmOP2y+6V4PGYt3ihbQKTY1Jnv0QG28WRKl/d1ha6zLODPZqsxLEov52dhR9BQ==} engines: {node: '>=v18'} dependencies: - '@commitlint/top-level': 19.0.0 - '@commitlint/types': 19.0.3 - execa: 8.0.1 + '@commitlint/top-level': 19.5.0 + '@commitlint/types': 19.5.0 git-raw-commits: 4.0.0 minimist: 1.2.8 + tinyexec: 0.3.1 dev: true - /@commitlint/resolve-extends@19.1.0: - resolution: {integrity: sha512-z2riI+8G3CET5CPgXJPlzftH+RiWYLMYv4C9tSLdLXdr6pBNimSKukYP9MS27ejmscqCTVA4almdLh0ODD2KYg==} + /@commitlint/resolve-extends@19.5.0: + resolution: {integrity: sha512-CU/GscZhCUsJwcKTJS9Ndh3AKGZTNFIOoQB2n8CmFnizE0VnEuJoum+COW+C1lNABEeqk6ssfc1Kkalm4bDklA==} engines: {node: '>=v18'} dependencies: - '@commitlint/config-validator': 19.0.3 - '@commitlint/types': 19.0.3 + '@commitlint/config-validator': 19.5.0 + '@commitlint/types': 19.5.0 global-directory: 4.0.1 import-meta-resolve: 4.1.0 lodash.mergewith: 4.6.2 resolve-from: 5.0.0 dev: true - /@commitlint/rules@19.0.3: - resolution: {integrity: sha512-TspKb9VB6svklxNCKKwxhELn7qhtY1rFF8ls58DcFd0F97XoG07xugPjjbVnLqmMkRjZDbDIwBKt9bddOfLaPw==} + /@commitlint/rules@19.6.0: + resolution: {integrity: sha512-1f2reW7lbrI0X0ozZMesS/WZxgPa4/wi56vFuJENBmed6mWq5KsheN/nxqnl/C23ioxpPO/PL6tXpiiFy5Bhjw==} engines: {node: '>=v18'} dependencies: - '@commitlint/ensure': 19.0.3 - '@commitlint/message': 19.0.0 - '@commitlint/to-lines': 19.0.0 - '@commitlint/types': 19.0.3 - execa: 8.0.1 + '@commitlint/ensure': 19.5.0 + '@commitlint/message': 19.5.0 + '@commitlint/to-lines': 19.5.0 + '@commitlint/types': 19.5.0 dev: true - /@commitlint/to-lines@19.0.0: - resolution: {integrity: sha512-vkxWo+VQU5wFhiP9Ub9Sre0FYe019JxFikrALVoD5UGa8/t3yOJEpEhxC5xKiENKKhUkTpEItMTRAjHw2SCpZw==} + /@commitlint/to-lines@19.5.0: + resolution: {integrity: sha512-R772oj3NHPkodOSRZ9bBVNq224DOxQtNef5Pl8l2M8ZnkkzQfeSTr4uxawV2Sd3ui05dUVzvLNnzenDBO1KBeQ==} engines: {node: '>=v18'} dev: true - /@commitlint/top-level@19.0.0: - resolution: {integrity: sha512-KKjShd6u1aMGNkCkaX4aG1jOGdn7f8ZI8TR1VEuNqUOjWTOdcDSsmglinglJ18JTjuBX5I1PtjrhQCRcixRVFQ==} + /@commitlint/top-level@19.5.0: + resolution: {integrity: sha512-IP1YLmGAk0yWrImPRRc578I3dDUI5A2UBJx9FbSOjxe9sTlzFiwVJ+zeMLgAtHMtGZsC8LUnzmW1qRemkFU4ng==} engines: {node: '>=v18'} dependencies: find-up: 7.0.0 dev: true - /@commitlint/types@19.0.3: - resolution: {integrity: sha512-tpyc+7i6bPG9mvaBbtKUeghfyZSDgWquIDfMgqYtTbmZ9Y9VzEm2je9EYcQ0aoz5o7NvGS+rcDec93yO08MHYA==} + /@commitlint/types@19.5.0: + resolution: {integrity: sha512-DSHae2obMSMkAtTBSOulg5X7/z+rGLxcXQIkg3OmWvY6wifojge5uVMydfhUvs7yQj+V7jNmRZ2Xzl8GJyqRgg==} engines: {node: '>=v18'} dependencies: '@types/conventional-commits-parser': 5.0.0 @@ -423,7 +427,7 @@ packages: '@types/yargs-parser': 21.0.0 dev: true - /@typescript-eslint/eslint-plugin@5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@4.9.5): + /@typescript-eslint/eslint-plugin@5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@5.7.2): resolution: {integrity: sha512-wcAwhEWm1RgNd7dxD/o+nnLW8oH+6RK1OGnmbmkj/GGoDPV1WWMVP0FXYQBivKHdwM1pwii3bt//RC62EriIUQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -434,10 +438,10 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@4.9.5) + '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@5.7.2) '@typescript-eslint/scope-manager': 5.51.0 - '@typescript-eslint/type-utils': 5.51.0(eslint@8.34.0)(typescript@4.9.5) - '@typescript-eslint/utils': 5.51.0(eslint@8.34.0)(typescript@4.9.5) + '@typescript-eslint/type-utils': 5.51.0(eslint@8.34.0)(typescript@5.7.2) + '@typescript-eslint/utils': 5.51.0(eslint@8.34.0)(typescript@5.7.2) debug: 4.3.4 eslint: 8.34.0 grapheme-splitter: 1.0.4 @@ -445,13 +449,13 @@ packages: natural-compare-lite: 1.4.0 regexpp: 3.2.0 semver: 7.3.8 - tsutils: 3.21.0(typescript@4.9.5) - typescript: 4.9.5 + tsutils: 3.21.0(typescript@5.7.2) + typescript: 5.7.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@5.51.0(eslint@8.34.0)(typescript@4.9.5): + /@typescript-eslint/parser@5.51.0(eslint@8.34.0)(typescript@5.7.2): resolution: {integrity: sha512-fEV0R9gGmfpDeRzJXn+fGQKcl0inIeYobmmUWijZh9zA7bxJ8clPhV9up2ZQzATxAiFAECqPQyMDB4o4B81AaA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -463,10 +467,10 @@ packages: dependencies: '@typescript-eslint/scope-manager': 5.51.0 '@typescript-eslint/types': 5.51.0 - '@typescript-eslint/typescript-estree': 5.51.0(typescript@4.9.5) + '@typescript-eslint/typescript-estree': 5.51.0(typescript@5.7.2) debug: 4.3.4 eslint: 8.34.0 - typescript: 4.9.5 + typescript: 5.7.2 transitivePeerDependencies: - supports-color dev: true @@ -479,7 +483,7 @@ packages: '@typescript-eslint/visitor-keys': 5.51.0 dev: true - /@typescript-eslint/type-utils@5.51.0(eslint@8.34.0)(typescript@4.9.5): + /@typescript-eslint/type-utils@5.51.0(eslint@8.34.0)(typescript@5.7.2): resolution: {integrity: sha512-QHC5KKyfV8sNSyHqfNa0UbTbJ6caB8uhcx2hYcWVvJAZYJRBo5HyyZfzMdRx8nvS+GyMg56fugMzzWnojREuQQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -489,12 +493,12 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 5.51.0(typescript@4.9.5) - '@typescript-eslint/utils': 5.51.0(eslint@8.34.0)(typescript@4.9.5) + '@typescript-eslint/typescript-estree': 5.51.0(typescript@5.7.2) + '@typescript-eslint/utils': 5.51.0(eslint@8.34.0)(typescript@5.7.2) debug: 4.3.4 eslint: 8.34.0 - tsutils: 3.21.0(typescript@4.9.5) - typescript: 4.9.5 + tsutils: 3.21.0(typescript@5.7.2) + typescript: 5.7.2 transitivePeerDependencies: - supports-color dev: true @@ -504,7 +508,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree@5.51.0(typescript@4.9.5): + /@typescript-eslint/typescript-estree@5.51.0(typescript@5.7.2): resolution: {integrity: sha512-TSkNupHvNRkoH9FMA3w7TazVFcBPveAAmb7Sz+kArY6sLT86PA5Vx80cKlYmd8m3Ha2SwofM1KwraF24lM9FvA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -519,13 +523,13 @@ packages: globby: 11.1.0 is-glob: 4.0.3 semver: 7.3.8 - tsutils: 3.21.0(typescript@4.9.5) - typescript: 4.9.5 + tsutils: 3.21.0(typescript@5.7.2) + typescript: 5.7.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils@5.51.0(eslint@8.34.0)(typescript@4.9.5): + /@typescript-eslint/utils@5.51.0(eslint@8.34.0)(typescript@5.7.2): resolution: {integrity: sha512-76qs+5KWcaatmwtwsDJvBk4H76RJQBFe+Gext0EfJdC3Vd2kpY2Pf//OHHzHp84Ciw0/rYoGTDnIAr3uWhhJYw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -535,7 +539,7 @@ packages: '@types/semver': 7.3.13 '@typescript-eslint/scope-manager': 5.51.0 '@typescript-eslint/types': 5.51.0 - '@typescript-eslint/typescript-estree': 5.51.0(typescript@4.9.5) + '@typescript-eslint/typescript-estree': 5.51.0(typescript@5.7.2) eslint: 8.34.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0(eslint@8.34.0) @@ -561,6 +565,20 @@ packages: through: 2.3.8 dev: true + /abitype@1.0.7(typescript@5.7.2): + resolution: {integrity: sha512-ZfYYSktDQUwc2eduYu8C4wOs+RDPmnRYMh7zNfzeMtGGgb0U+6tLGjixUic6mXf5xKKCcgT5Qp6cv39tOARVFw==} + peerDependencies: + typescript: '>=5.0.4' + zod: ^3 >=3.22.0 + peerDependenciesMeta: + typescript: + optional: true + zod: + optional: true + dependencies: + typescript: 5.7.2 + dev: false + /acorn-jsx@5.3.2(acorn@8.8.2): resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: @@ -792,21 +810,21 @@ packages: split2: 4.2.0 dev: true - /cosmiconfig-typescript-loader@5.0.0(@types/node@18.13.0)(cosmiconfig@9.0.0)(typescript@4.9.5): - resolution: {integrity: sha512-+8cK7jRAReYkMwMiG+bxhcNKiHJDM6bR9FD/nGBXOWdMLuYawjF5cGrtLilJ+LGd3ZjCXnJjR5DkfWPoIVlqJA==} - engines: {node: '>=v16'} + /cosmiconfig-typescript-loader@6.1.0(@types/node@18.13.0)(cosmiconfig@9.0.0)(typescript@5.7.2): + resolution: {integrity: sha512-tJ1w35ZRUiM5FeTzT7DtYWAFFv37ZLqSRkGi2oeCK1gPhvaWjkAtfXvLmvE1pRfxxp9aQo6ba/Pvg1dKj05D4g==} + engines: {node: '>=v18'} peerDependencies: '@types/node': '*' - cosmiconfig: '>=8.2' - typescript: '>=4' + cosmiconfig: '>=9' + typescript: '>=5' dependencies: '@types/node': 18.13.0 - cosmiconfig: 9.0.0(typescript@4.9.5) - jiti: 1.21.6 - typescript: 4.9.5 + cosmiconfig: 9.0.0(typescript@5.7.2) + jiti: 2.4.2 + typescript: 5.7.2 dev: true - /cosmiconfig@9.0.0(typescript@4.9.5): + /cosmiconfig@9.0.0(typescript@5.7.2): resolution: {integrity: sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==} engines: {node: '>=14'} peerDependencies: @@ -819,7 +837,7 @@ packages: import-fresh: 3.3.0 js-yaml: 4.1.0 parse-json: 5.2.0 - typescript: 4.9.5 + typescript: 5.7.2 dev: true /create-require@1.1.1: @@ -1056,7 +1074,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@4.9.5) + '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@5.7.2) debug: 3.2.7 eslint: 8.34.0 eslint-import-resolver-node: 0.3.7 @@ -1085,7 +1103,7 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@4.9.5) + '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@5.7.2) array-includes: 3.1.6 array.prototype.flat: 1.3.1 array.prototype.flatmap: 1.3.1 @@ -1108,7 +1126,7 @@ packages: - supports-color dev: true - /eslint-plugin-jest@26.9.0(@typescript-eslint/eslint-plugin@5.51.0)(eslint@8.34.0)(typescript@4.9.5): + /eslint-plugin-jest@26.9.0(@typescript-eslint/eslint-plugin@5.51.0)(eslint@8.34.0)(typescript@5.7.2): resolution: {integrity: sha512-TWJxWGp1J628gxh2KhaH1H1paEdgE2J61BBF1I59c6xWeL5+D1BzMxGDN/nXAfX+aSkR5u80K+XhskK6Gwq9ng==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1121,8 +1139,8 @@ packages: jest: optional: true dependencies: - '@typescript-eslint/eslint-plugin': 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@4.9.5) - '@typescript-eslint/utils': 5.51.0(eslint@8.34.0)(typescript@4.9.5) + '@typescript-eslint/eslint-plugin': 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@5.7.2) + '@typescript-eslint/utils': 5.51.0(eslint@8.34.0)(typescript@5.7.2) eslint: 8.34.0 transitivePeerDependencies: - supports-color @@ -1268,21 +1286,6 @@ packages: engines: {node: '>=0.10.0'} dev: true - /execa@8.0.1: - resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} - engines: {node: '>=16.17'} - dependencies: - cross-spawn: 7.0.3 - get-stream: 8.0.1 - human-signals: 5.0.0 - is-stream: 3.0.0 - merge-stream: 2.0.0 - npm-run-path: 5.3.0 - onetime: 6.0.0 - signal-exit: 4.1.0 - strip-final-newline: 3.0.0 - dev: true - /fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} dev: true @@ -1404,11 +1407,6 @@ packages: has-symbols: 1.0.3 dev: true - /get-stream@8.0.1: - resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} - engines: {node: '>=16'} - dev: true - /get-symbol-description@1.0.0: resolution: {integrity: sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==} engines: {node: '>= 0.4'} @@ -1539,11 +1537,6 @@ packages: function-bind: 1.1.1 dev: true - /human-signals@5.0.0: - resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} - engines: {node: '>=16.17.0'} - dev: true - /husky@8.0.3: resolution: {integrity: sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==} engines: {node: '>=14'} @@ -1699,11 +1692,6 @@ packages: call-bind: 1.0.2 dev: true - /is-stream@3.0.0: - resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dev: true - /is-string@1.0.7: resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} engines: {node: '>= 0.4'} @@ -1746,8 +1734,8 @@ packages: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true - /jiti@1.21.6: - resolution: {integrity: sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==} + /jiti@2.4.2: + resolution: {integrity: sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==} hasBin: true dev: true @@ -1858,7 +1846,7 @@ packages: /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} - dev: true + dev: false /lru-cache@6.0.0: resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} @@ -1876,10 +1864,6 @@ packages: engines: {node: '>=16.10'} dev: true - /merge-stream@2.0.0: - resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==} - dev: true - /merge2@1.4.1: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} engines: {node: '>= 8'} @@ -1893,11 +1877,6 @@ packages: picomatch: 2.3.1 dev: true - /mimic-fn@4.0.0: - resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} - engines: {node: '>=12'} - dev: true - /minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} dependencies: @@ -1926,13 +1905,6 @@ packages: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} dev: true - /npm-run-path@5.3.0: - resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - path-key: 4.0.0 - dev: true - /object-inspect@1.12.3: resolution: {integrity: sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==} dev: true @@ -1976,13 +1948,6 @@ packages: wrappy: 1.0.2 dev: true - /onetime@6.0.0: - resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} - engines: {node: '>=12'} - dependencies: - mimic-fn: 4.0.0 - dev: true - /optionator@0.9.1: resolution: {integrity: sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==} engines: {node: '>= 0.8.0'} @@ -2060,11 +2025,6 @@ packages: engines: {node: '>=8'} dev: true - /path-key@4.0.0: - resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} - engines: {node: '>=12'} - dev: true - /path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} dev: true @@ -2218,11 +2178,6 @@ packages: object-inspect: 1.12.3 dev: true - /signal-exit@4.1.0: - resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} - engines: {node: '>=14'} - dev: true - /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -2270,11 +2225,6 @@ packages: engines: {node: '>=4'} dev: true - /strip-final-newline@3.0.0: - resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} - engines: {node: '>=12'} - dev: true - /strip-json-comments@3.1.1: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} @@ -2312,6 +2262,10 @@ packages: resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} dev: true + /tinyexec@0.3.1: + resolution: {integrity: sha512-WiCJLEECkO18gwqIp6+hJg0//p23HXp4S+gGtAKu3mI2F2/sXC4FvHvXvB0zJVVaTPhx1/tOwdbRsa1sOBIKqQ==} + dev: true + /to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -2319,7 +2273,7 @@ packages: is-number: 7.0.0 dev: true - /ts-node@10.9.1(@types/node@18.13.0)(typescript@4.9.5): + /ts-node@10.9.1(@types/node@18.13.0)(typescript@5.7.2): resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true peerDependencies: @@ -2345,7 +2299,7 @@ packages: create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 4.9.5 + typescript: 5.7.2 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 dev: true @@ -2363,14 +2317,14 @@ packages: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: true - /tsutils@3.21.0(typescript@4.9.5): + /tsutils@3.21.0(typescript@5.7.2): resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' dependencies: tslib: 1.14.1 - typescript: 4.9.5 + typescript: 5.7.2 dev: true /type-check@0.4.0: @@ -2393,11 +2347,10 @@ packages: is-typed-array: 1.1.10 dev: true - /typescript@4.9.5: - resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} - engines: {node: '>=4.2.0'} + /typescript@5.7.2: + resolution: {integrity: sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==} + engines: {node: '>=14.17'} hasBin: true - dev: true /unbox-primitive@1.0.2: resolution: {integrity: sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==} diff --git a/scripts/extract-contract-abis.ts b/scripts/extract-contract-abis.ts index afcf20f..54e7d06 100644 --- a/scripts/extract-contract-abis.ts +++ b/scripts/extract-contract-abis.ts @@ -8,6 +8,8 @@ import fg from 'fast-glob'; import { sync as mkdirpSync } from 'mkdirp'; import _ from 'lodash'; +import { type AbiNode, type NodeType, joinAbis } from '../lib/utils'; + import { latest as LATEST_TAG } from '../dist/versions.json'; const DEPLOY_CONTRACTS = ['MetaTxToken', 'TokenAuthority']; @@ -24,26 +26,11 @@ const ARTIFACTS_DIR_TOKEN = resolvePath( const OUTPUT_DIR = resolvePath(__dirname, '../dist/versions'); -// Simplified ABI node for events or functions -type AbiNode = { - inputs: { name: string; type: string }[]; - name: string; - type: 'event' | 'function'; -}; - -const stringifyInputTypes = (node: AbiNode) => - JSON.stringify(node.inputs.map(({ type }) => type)); - // Capitalize the first letter of a string const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1); -// Some newer versions of the compiler add extra stuff that prevents a deep equal comparison -const nodesAreEqual = (nodeA: AbiNode, nodeB: AbiNode) => - nodeA.name === nodeB.name && - stringifyInputTypes(nodeA) === stringifyInputTypes(nodeB); - // This builds artificial ABIs that contain all nodes of a certain type across all versions of a versioned contract. Exact duplicates are discarded -const buildJoinedAbis = async (tag: string, nodeType: string) => { +const buildJoinedAbis = async (tag: string, nodeType: NodeType) => { const targetDir = tag === 'next' ? resolvePath(__dirname, `../dist/${nodeType}s/next`) @@ -59,13 +46,8 @@ const buildJoinedAbis = async (tag: string, nodeType: string) => { if (!nodeAbis[contractName]) { nodeAbis[contractName] = []; } - nodeAbis[contractName] = _.uniqWith( - nodeAbis[contractName].concat( - abi.filter(({ type }: { type: string }) => type === nodeType), - ), - nodesAreEqual, - ); - } catch(err) { + nodeAbis[contractName] = joinAbis(nodeAbis[contractName], abi, nodeType); + } catch (err) { console.error(err); // ignore } diff --git a/tsconfig.json b/tsconfig.json index 66e5206..5637621 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,9 +8,9 @@ "resolveJsonModule": true, "esModuleInterop": true, "strict": true, - "target": "es6", - "types": ["node", "jest"], - "rootDir": "./" + "target": "es2022", + "rootDir": "./", + "skipLibCheck": true }, "include": ["scripts/**/*"], "exclude": ["node_modules"]