diff --git a/.gitignore b/.gitignore index 10bea97..b8ead06 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,7 @@ static/dist /coverage junit.xml dist + +/core +/types +/handlers diff --git a/package.json b/package.json index a8947e0..475bc74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ubiquibot/permit-generation", - "version": "1.0.2", + "version": "1.2.0", "description": "ECR20 / ECR721 permit generation for automated payments.", "author": "Ubiquity DAO", "license": "MIT", @@ -64,7 +64,7 @@ "lint-staged": "^15.2.2", "npm-run-all": "^4.1.5", "prettier": "^3.2.5", - "rollup": "4.14.0", + "rollup": "4.14.3", "rollup-plugin-dts-bundle-generator": "1.4.0", "rollup-plugin-typescript2": "0.36.0", "ts-jest": "29.1.2", @@ -87,11 +87,13 @@ ] }, "files": [ - "dist/*", + "types/*", + "handlers/*", + "core/*", "README.md", "package.json" ], - "module": "dist/index.esm.js", - "main": "dist/index.js", - "typings": "dist/index.d.ts" + "module": "core/index.esm.js", + "main": "core/index.js", + "typings": "types/index.d.ts" } diff --git a/rollup.config.mjs b/rollup.config.mjs index 6fb6356..cab7056 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -6,11 +6,56 @@ import commonjs from "@rollup/plugin-commonjs"; import json from "@rollup/plugin-json"; import terser from "@rollup/plugin-terser"; -export default { - input: "src/index.ts", - output: { - dir: "dist", - format: "cjs", +const config = [ + { + input: "src/types/index.ts", + output: { + dir: "types", + format: "cjs", + }, + plugins: [ + nodeResolve({ browser: true }), + commonjs(), + typescript(), + yaml(), + json(), + generateDtsBundle(), + terser(), + ], }, - plugins: [nodeResolve(), commonjs(), typescript(), yaml(), json(), generateDtsBundle(), terser()], -}; + { + input: "src/handlers/index.ts", + output: { + dir: "handlers", + format: "cjs", + }, + plugins: [ + nodeResolve({ browser: true }), + commonjs(), + typescript(), + yaml(), + json(), + generateDtsBundle(), + terser(), + ], + }, + { + input: "src/index.ts", + output: { + dir: "core", + format: "esm", + preserveModules: true, + }, + plugins: [ + nodeResolve(), + commonjs(), + typescript(), + yaml(), + json(), + generateDtsBundle(), + terser(), + ], + }, +]; + +export default config; diff --git a/tests/encode-decode.test.ts b/tests/encode-decode.test.ts index afc0798..fd11d3d 100644 --- a/tests/encode-decode.test.ts +++ b/tests/encode-decode.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from "@jest/globals"; -import { decodePermits, encodePermits, Permit, TokenType } from "../src"; +import { decodePermits, encodePermits } from "../src/handlers/encode-decode"; +import { Permit, TokenType } from "../src/types"; describe("Encoding / Decoding tests", () => { it("Should properly encode and decode a list of permits", () => { diff --git a/tests/generate-payout-permit.test.ts b/tests/generate-payout-permit.test.ts index ab7c95e..0d25260 100644 --- a/tests/generate-payout-permit.test.ts +++ b/tests/generate-payout-permit.test.ts @@ -1,7 +1,6 @@ // import { generateErc20PermitSignature } from "../src/handlers/generate-erc20-permit"; -import { generateErc20PermitSignature } from "../src"; +import { generateErc20PermitSignature, generatePayoutPermit } from "../src"; // import { generateErc721PermitSignature } from "../src/handlers/generate-erc721-permit"; -import { generatePayoutPermit } from "../src"; import { Context } from "../src/types/context"; import { cypherText, mockContext, SPENDER } from "./constants"; import { describe, expect, it, beforeEach, afterEach, jest } from "@jest/globals"; diff --git a/yarn.lock b/yarn.lock index 332742f..c2c864c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2067,80 +2067,85 @@ estree-walker "^2.0.2" picomatch "^2.3.1" -"@rollup/rollup-android-arm-eabi@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.14.0.tgz#57936f50d0335e2e7bfac496d209606fa516add4" - integrity sha512-jwXtxYbRt1V+CdQSy6Z+uZti7JF5irRKF8hlKfEnF/xJpcNGuuiZMBvuoYM+x9sr9iWGnzrlM0+9hvQ1kgkf1w== - -"@rollup/rollup-android-arm64@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.14.0.tgz#81bba83b37382a2d0e30ceced06c8d3d85138054" - integrity sha512-fI9nduZhCccjzlsA/OuAwtFGWocxA4gqXGTLvOyiF8d+8o0fZUeSztixkYjcGq1fGZY3Tkq4yRvHPFxU+jdZ9Q== - -"@rollup/rollup-darwin-arm64@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.14.0.tgz#a371bd723a5c4c4a33376da72abfc3938066842b" - integrity sha512-BcnSPRM76/cD2gQC+rQNGBN6GStBs2pl/FpweW8JYuz5J/IEa0Fr4AtrPv766DB/6b2MZ/AfSIOSGw3nEIP8SA== - -"@rollup/rollup-darwin-x64@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.14.0.tgz#8baf2fda277c9729125017c65651296282412886" - integrity sha512-LDyFB9GRolGN7XI6955aFeI3wCdCUszFWumWU0deHA8VpR3nWRrjG6GtGjBrQxQKFevnUTHKCfPR4IvrW3kCgQ== - -"@rollup/rollup-linux-arm-gnueabihf@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.14.0.tgz#822830a8f7388d5b81d04c69415408d3bab1079b" - integrity sha512-ygrGVhQP47mRh0AAD0zl6QqCbNsf0eTo+vgwkY6LunBcg0f2Jv365GXlDUECIyoXp1kKwL5WW6rsO429DBY/bA== - -"@rollup/rollup-linux-arm64-gnu@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.14.0.tgz#e20fbe1bd4414c7119f9e0bba8ad17a6666c8365" - integrity sha512-x+uJ6MAYRlHGe9wi4HQjxpaKHPM3d3JjqqCkeC5gpnnI6OWovLdXTpfa8trjxPLnWKyBsSi5kne+146GAxFt4A== - -"@rollup/rollup-linux-arm64-musl@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.14.0.tgz#13f475596a62e1924f13fe1c8cf2c40e09a99b47" - integrity sha512-nrRw8ZTQKg6+Lttwqo6a2VxR9tOroa2m91XbdQ2sUUzHoedXlsyvY1fN4xWdqz8PKmf4orDwejxXHjh7YBGUCA== - -"@rollup/rollup-linux-powerpc64le-gnu@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.14.0.tgz#6a431c441420d1c510a205e08c6673355a0a2ea9" - integrity sha512-xV0d5jDb4aFu84XKr+lcUJ9y3qpIWhttO3Qev97z8DKLXR62LC3cXT/bMZXrjLF9X+P5oSmJTzAhqwUbY96PnA== - -"@rollup/rollup-linux-riscv64-gnu@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.14.0.tgz#53d9448962c3f9ed7a1672269655476ea2d67567" - integrity sha512-SDDhBQwZX6LPRoPYjAZWyL27LbcBo7WdBFWJi5PI9RPCzU8ijzkQn7tt8NXiXRiFMJCVpkuMkBf4OxSxVMizAw== - -"@rollup/rollup-linux-s390x-gnu@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.14.0.tgz#95f0c133b324da3e7e5c7d12855e0eb71d21a946" - integrity sha512-RxB/qez8zIDshNJDufYlTT0ZTVut5eCpAZ3bdXDU9yTxBzui3KhbGjROK2OYTTor7alM7XBhssgoO3CZ0XD3qA== - -"@rollup/rollup-linux-x64-gnu@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.14.0.tgz#820ada75c68ead1acc486e41238ca0d8f8531478" - integrity sha512-C6y6z2eCNCfhZxT9u+jAM2Fup89ZjiG5pIzZIDycs1IwESviLxwkQcFRGLjnDrP+PT+v5i4YFvlcfAs+LnreXg== - -"@rollup/rollup-linux-x64-musl@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.14.0.tgz#ca74f22e125efbe94c1148d989ef93329b464443" - integrity sha512-i0QwbHYfnOMYsBEyjxcwGu5SMIi9sImDVjDg087hpzXqhBSosxkE7gyIYFHgfFl4mr7RrXksIBZ4DoLoP4FhJg== - -"@rollup/rollup-win32-arm64-msvc@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.14.0.tgz#269023332297051d037a9593dcba92c10fef726b" - integrity sha512-Fq52EYb0riNHLBTAcL0cun+rRwyZ10S9vKzhGKKgeD+XbwunszSY0rVMco5KbOsTlwovP2rTOkiII/fQ4ih/zQ== - -"@rollup/rollup-win32-ia32-msvc@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.14.0.tgz#d7701438daf964011fd7ca33e3f13f3ff5129e7b" - integrity sha512-e/PBHxPdJ00O9p5Ui43+vixSgVf4NlLsmV6QneGERJ3lnjIua/kim6PRFe3iDueT1rQcgSkYP8ZBBXa/h4iPvw== - -"@rollup/rollup-win32-x64-msvc@4.14.0": - version "4.14.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.0.tgz#0bb7ac3cd1c3292db1f39afdabfd03ccea3a3d34" - integrity sha512-aGg7iToJjdklmxlUlJh/PaPNa4PmqHfyRMLunbL3eaMO0gp656+q1zOKkpJ/CVe9CryJv6tAN1HDoR8cNGzkag== +"@rollup/rollup-android-arm-eabi@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.14.3.tgz#bddf05c3387d02fac04b6b86b3a779337edfed75" + integrity sha512-X9alQ3XM6I9IlSlmC8ddAvMSyG1WuHk5oUnXGw+yUBs3BFoTizmG1La/Gr8fVJvDWAq+zlYTZ9DBgrlKRVY06g== + +"@rollup/rollup-android-arm64@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.14.3.tgz#b26bd09de58704c0a45e3375b76796f6eda825e4" + integrity sha512-eQK5JIi+POhFpzk+LnjKIy4Ks+pwJ+NXmPxOCSvOKSNRPONzKuUvWE+P9JxGZVxrtzm6BAYMaL50FFuPe0oWMQ== + +"@rollup/rollup-darwin-arm64@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.14.3.tgz#c5f3fd1aa285b6d33dda6e3f3ca395f8c37fd5ca" + integrity sha512-Od4vE6f6CTT53yM1jgcLqNfItTsLt5zE46fdPaEmeFHvPs5SjZYlLpHrSiHEKR1+HdRfxuzXHjDOIxQyC3ptBA== + +"@rollup/rollup-darwin-x64@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.14.3.tgz#8e4673734d7dc9d68f6d48e81246055cda0e840f" + integrity sha512-0IMAO21axJeNIrvS9lSe/PGthc8ZUS+zC53O0VhF5gMxfmcKAP4ESkKOCwEi6u2asUrt4mQv2rjY8QseIEb1aw== + +"@rollup/rollup-linux-arm-gnueabihf@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.14.3.tgz#53ed38eb13b58ababdb55a7f66f0538a7f85dcba" + integrity sha512-ge2DC7tHRHa3caVEoSbPRJpq7azhG+xYsd6u2MEnJ6XzPSzQsTKyXvh6iWjXRf7Rt9ykIUWHtl0Uz3T6yXPpKw== + +"@rollup/rollup-linux-arm-musleabihf@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.14.3.tgz#0706ee38330e267a5c9326956820f009cfb21fcd" + integrity sha512-ljcuiDI4V3ySuc7eSk4lQ9wU8J8r8KrOUvB2U+TtK0TiW6OFDmJ+DdIjjwZHIw9CNxzbmXY39wwpzYuFDwNXuw== + +"@rollup/rollup-linux-arm64-gnu@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.14.3.tgz#426fce7b8b242ac5abd48a10a5020f5a468c6cb4" + integrity sha512-Eci2us9VTHm1eSyn5/eEpaC7eP/mp5n46gTRB3Aar3BgSvDQGJZuicyq6TsH4HngNBgVqC5sDYxOzTExSU+NjA== + +"@rollup/rollup-linux-arm64-musl@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.14.3.tgz#65bf944530d759b50d7ffd00dfbdf4125a43406f" + integrity sha512-UrBoMLCq4E92/LCqlh+blpqMz5h1tJttPIniwUgOFJyjWI1qrtrDhhpHPuFxULlUmjFHfloWdixtDhSxJt5iKw== + +"@rollup/rollup-linux-powerpc64le-gnu@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.14.3.tgz#494ba3b31095e9a45df9c3f646d21400fb631a95" + integrity sha512-5aRjvsS8q1nWN8AoRfrq5+9IflC3P1leMoy4r2WjXyFqf3qcqsxRCfxtZIV58tCxd+Yv7WELPcO9mY9aeQyAmw== + +"@rollup/rollup-linux-riscv64-gnu@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.14.3.tgz#8b88ed0a40724cce04aa15374ebe5ba4092d679f" + integrity sha512-sk/Qh1j2/RJSX7FhEpJn8n0ndxy/uf0kI/9Zc4b1ELhqULVdTfN6HL31CDaTChiBAOgLcsJ1sgVZjWv8XNEsAQ== + +"@rollup/rollup-linux-s390x-gnu@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.14.3.tgz#09c9e5ec57a0f6ec3551272c860bb9a04b96d70f" + integrity sha512-jOO/PEaDitOmY9TgkxF/TQIjXySQe5KVYB57H/8LRP/ux0ZoO8cSHCX17asMSv3ruwslXW/TLBcxyaUzGRHcqg== + +"@rollup/rollup-linux-x64-gnu@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.14.3.tgz#197f27fd481ad9c861021d5cbbf21793922a631c" + integrity sha512-8ybV4Xjy59xLMyWo3GCfEGqtKV5M5gCSrZlxkPGvEPCGDLNla7v48S662HSGwRd6/2cSneMQWiv+QzcttLrrOA== + +"@rollup/rollup-linux-x64-musl@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.14.3.tgz#5cc0522f4942f2df625e9bfb6fb02c6580ffbce6" + integrity sha512-s+xf1I46trOY10OqAtZ5Rm6lzHre/UiLA1J2uOhCFXWkbZrJRkYBPO6FhvGfHmdtQ3Bx793MNa7LvoWFAm93bg== + +"@rollup/rollup-win32-arm64-msvc@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.14.3.tgz#a648122389d23a7543b261fba082e65fefefe4f6" + integrity sha512-+4h2WrGOYsOumDQ5S2sYNyhVfrue+9tc9XcLWLh+Kw3UOxAvrfOrSMFon60KspcDdytkNDh7K2Vs6eMaYImAZg== + +"@rollup/rollup-win32-ia32-msvc@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.14.3.tgz#34727b5c7953c35fc6e1ae4f770ad3a2025f8e03" + integrity sha512-T1l7y/bCeL/kUwh9OD4PQT4aM7Bq43vX05htPJJ46RTI4r5KNt6qJRzAfNfM+OYMNEVBWQzR2Gyk+FXLZfogGw== + +"@rollup/rollup-win32-x64-msvc@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.3.tgz#5b2fb4d8cd44c05deef8a7b0e6deb9ccb8939d18" + integrity sha512-/BypzV0H1y1HzgYpxqRaXGBRqfodgoBBCcsrujT6QRcakDQdfU+Lq9PENPh5jB4I44YWq+0C2eHsHya+nZY1sA== "@sinclair/typebox@^0.27.8": version "0.27.8" @@ -6316,28 +6321,29 @@ rollup-plugin-typescript2@0.36.0: semver "^7.5.4" tslib "^2.6.2" -rollup@4.14.0: - version "4.14.0" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.14.0.tgz#c3e2cd479f1b2358b65c1f810fa05b51603d7be8" - integrity sha512-Qe7w62TyawbDzB4yt32R0+AbIo6m1/sqO7UPzFS8Z/ksL5mrfhA0v4CavfdmFav3D+ub4QeAgsGEe84DoWe/nQ== +rollup@4.14.3: + version "4.14.3" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.14.3.tgz#bcbb7784b35826d3164346fa6d5aac95190d8ba9" + integrity sha512-ag5tTQKYsj1bhrFC9+OEWqb5O6VYgtQDO9hPDBMmIbePwhfSr+ExlcU741t8Dhw5DkPCQf6noz0jb36D6W9/hw== dependencies: "@types/estree" "1.0.5" optionalDependencies: - "@rollup/rollup-android-arm-eabi" "4.14.0" - "@rollup/rollup-android-arm64" "4.14.0" - "@rollup/rollup-darwin-arm64" "4.14.0" - "@rollup/rollup-darwin-x64" "4.14.0" - "@rollup/rollup-linux-arm-gnueabihf" "4.14.0" - "@rollup/rollup-linux-arm64-gnu" "4.14.0" - "@rollup/rollup-linux-arm64-musl" "4.14.0" - "@rollup/rollup-linux-powerpc64le-gnu" "4.14.0" - "@rollup/rollup-linux-riscv64-gnu" "4.14.0" - "@rollup/rollup-linux-s390x-gnu" "4.14.0" - "@rollup/rollup-linux-x64-gnu" "4.14.0" - "@rollup/rollup-linux-x64-musl" "4.14.0" - "@rollup/rollup-win32-arm64-msvc" "4.14.0" - "@rollup/rollup-win32-ia32-msvc" "4.14.0" - "@rollup/rollup-win32-x64-msvc" "4.14.0" + "@rollup/rollup-android-arm-eabi" "4.14.3" + "@rollup/rollup-android-arm64" "4.14.3" + "@rollup/rollup-darwin-arm64" "4.14.3" + "@rollup/rollup-darwin-x64" "4.14.3" + "@rollup/rollup-linux-arm-gnueabihf" "4.14.3" + "@rollup/rollup-linux-arm-musleabihf" "4.14.3" + "@rollup/rollup-linux-arm64-gnu" "4.14.3" + "@rollup/rollup-linux-arm64-musl" "4.14.3" + "@rollup/rollup-linux-powerpc64le-gnu" "4.14.3" + "@rollup/rollup-linux-riscv64-gnu" "4.14.3" + "@rollup/rollup-linux-s390x-gnu" "4.14.3" + "@rollup/rollup-linux-x64-gnu" "4.14.3" + "@rollup/rollup-linux-x64-musl" "4.14.3" + "@rollup/rollup-win32-arm64-msvc" "4.14.3" + "@rollup/rollup-win32-ia32-msvc" "4.14.3" + "@rollup/rollup-win32-x64-msvc" "4.14.3" fsevents "~2.3.2" rollup@^2.75.5: