From 4d768949250c15fed9b7b42414a3f33debf211ee Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 17 Apr 2024 13:19:52 +0900 Subject: [PATCH 1/5] chore: changed esm to cjs and remove preserve modules --- rollup.config.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rollup.config.mjs b/rollup.config.mjs index cab7056..04394a8 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -43,8 +43,7 @@ const config = [ input: "src/index.ts", output: { dir: "core", - format: "esm", - preserveModules: true, + format: "cjs", }, plugins: [ nodeResolve(), From a6cb1a8ca7faed16c370c03c93de39d7ec0068ae Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 17 Apr 2024 13:22:48 +0900 Subject: [PATCH 2/5] v1.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 475bc74..5a1af99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ubiquibot/permit-generation", - "version": "1.2.0", + "version": "1.2.1", "description": "ECR20 / ECR721 permit generation for automated payments.", "author": "Ubiquity DAO", "license": "MIT", From ddde7c1e8cc116d1aa18a7b56500676009649c66 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 17 Apr 2024 16:53:20 +0900 Subject: [PATCH 3/5] chore: moved code generation to dist folder --- .gitignore | 4 --- package.json | 26 ++++++++++++++--- rollup.config.mjs | 9 ++++-- yarn.lock | 72 +++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 94 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index b8ead06..10bea97 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,3 @@ static/dist /coverage junit.xml dist - -/core -/types -/handlers diff --git a/package.json b/package.json index 5a1af99..1355c2e 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "npm-run-all": "^4.1.5", "prettier": "^3.2.5", "rollup": "4.14.3", + "rollup-plugin-delete": "2.0.0", "rollup-plugin-dts-bundle-generator": "1.4.0", "rollup-plugin-typescript2": "0.36.0", "ts-jest": "29.1.2", @@ -87,13 +88,30 @@ ] }, "files": [ - "types/*", - "handlers/*", - "core/*", + "dist/types/*", + "dist/handlers/*", + "dist/core/*", "README.md", "package.json" ], "module": "core/index.esm.js", "main": "core/index.js", - "typings": "types/index.d.ts" + "typings": "types/index.d.ts", + "exports": { + "./core": { + "require": "./dist/core/index.js", + "import": "./dist/core/index.js", + "types": "./dist/core/index.d.ts" + }, + "./types": { + "require": "./dist/types/index.js", + "import": "./dist/types/index.js", + "types": "./dist/types/index.d.ts" + }, + "./handlers": { + "require": "./dist/handlers/index.js", + "import": "./dist/handlers/index.js", + "types": "./dist/handlers/index.d.ts" + } + } } diff --git a/rollup.config.mjs b/rollup.config.mjs index 04394a8..1e47c78 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -5,15 +5,18 @@ import nodeResolve from "@rollup/plugin-node-resolve"; import commonjs from "@rollup/plugin-commonjs"; import json from "@rollup/plugin-json"; import terser from "@rollup/plugin-terser"; +import del from "rollup-plugin-delete"; +/** @type {import("rollup").RollupOptions[]} */ const config = [ { input: "src/types/index.ts", output: { - dir: "types", + dir: "dist/types", format: "cjs", }, plugins: [ + del({ targets: ["dist/*"] }), nodeResolve({ browser: true }), commonjs(), typescript(), @@ -26,7 +29,7 @@ const config = [ { input: "src/handlers/index.ts", output: { - dir: "handlers", + dir: "dist/handlers", format: "cjs", }, plugins: [ @@ -42,7 +45,7 @@ const config = [ { input: "src/index.ts", output: { - dir: "core", + dir: "dist/core", format: "cjs", }, plugins: [ diff --git a/yarn.lock b/yarn.lock index c2c864c..aa0e986 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2295,6 +2295,14 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== +"@types/glob@^7.1.1": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb" + integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA== + dependencies: + "@types/minimatch" "*" + "@types/node" "*" + "@types/graceful-fs@^4.1.3": version "4.1.9" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4" @@ -2331,6 +2339,11 @@ resolved "https://registry.yarnpkg.com/@types/libsodium-wrappers/-/libsodium-wrappers-0.7.13.tgz#769c4ea01de96bb297207586a70777ebf066dcb4" integrity sha512-KeAKtlObirLJk/na6jHBFEdTDjDfFS6Vcr0eG2FjiHKn3Nw8axJFfIu0Y9TpwaauRldQBj/pZm/MHtK76r6OWg== +"@types/minimatch@*": + version "5.1.2" + resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-5.1.2.tgz#07508b45797cb81ec3f273011b054cd0755eddca" + integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA== + "@types/minimist@^1.2.0": version "1.2.5" resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.5.tgz#ec10755e871497bcd83efe927e43ec46e8c0747e" @@ -3407,6 +3420,20 @@ define-properties@^1.1.3, define-properties@^1.2.0, define-properties@^1.2.1: has-property-descriptors "^1.0.0" object-keys "^1.1.1" +del@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/del/-/del-5.1.0.tgz#d9487c94e367410e6eff2925ee58c0c84a75b3a7" + integrity sha512-wH9xOVHnczo9jN2IW68BabcecVPxacIA3g/7z6vhSU/4stOKQzeCRK0yD0A24WiAAUJmmVpWqrERcTxnLo3AnA== + dependencies: + globby "^10.0.1" + graceful-fs "^4.2.2" + is-glob "^4.0.1" + is-path-cwd "^2.2.0" + is-path-inside "^3.0.1" + p-map "^3.0.0" + rimraf "^3.0.0" + slash "^3.0.0" + deprecation@^2.0.0: version "2.3.1" resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" @@ -3885,7 +3912,7 @@ fast-equals@^5.0.1: resolved "https://registry.yarnpkg.com/fast-equals/-/fast-equals-5.0.1.tgz#a4eefe3c5d1c0d021aeed0bc10ba5e0c12ee405d" integrity sha512-WF1Wi8PwwSY7/6Kx0vKXtw8RwuSGoM1bvDaJbu7MxDlR1vovZjIAKrnzyrThgAjm6JDTu0fVgWXDlMGspodfoQ== -fast-glob@3.3.2, fast-glob@^3.2.9, fast-glob@^3.3.2: +fast-glob@3.3.2, fast-glob@^3.0.3, fast-glob@^3.2.9, fast-glob@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow== @@ -4227,6 +4254,20 @@ globalthis@^1.0.3: dependencies: define-properties "^1.1.3" +globby@^10.0.1: + version "10.0.2" + resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.2.tgz#277593e745acaa4646c3ab411289ec47a0392543" + integrity sha512-7dUi7RvCoT/xast/o/dLN53oqND4yk0nsHkhRgn9w65C4PofCLOoJ39iSOg+qVDdWQPIEj+eszMHQ+aLVwwQSg== + dependencies: + "@types/glob" "^7.1.1" + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.0.3" + glob "^7.1.3" + ignore "^5.1.1" + merge2 "^1.2.3" + slash "^3.0.0" + globby@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" @@ -4246,7 +4287,7 @@ gopd@^1.0.1: dependencies: get-intrinsic "^1.1.3" -graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.11, graceful-fs@^4.2.6, graceful-fs@^4.2.9: +graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.11, graceful-fs@^4.2.2, graceful-fs@^4.2.6, graceful-fs@^4.2.9: version "4.2.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== @@ -4378,7 +4419,7 @@ identity-function@^1.0.0: resolved "https://registry.yarnpkg.com/identity-function/-/identity-function-1.0.0.tgz#bea1159f0985239be3ca348edf40ce2f0dd2c21d" integrity sha512-kNrgUK0qI+9qLTBidsH85HjDLpZfrrS0ElquKKe/fJFdB3D7VeKdXXEvOPDUHSHOzdZKCAAaQIWWyp0l2yq6pw== -ignore@^5.1.8, ignore@^5.2.0, ignore@^5.2.4: +ignore@^5.1.1, ignore@^5.1.8, ignore@^5.2.0, ignore@^5.2.4: version "5.3.1" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef" integrity sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw== @@ -4581,7 +4622,12 @@ is-obj@^2.0.0: resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-2.0.0.tgz#473fb05d973705e3fd9620545018ca8e22ef4982" integrity sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w== -is-path-inside@^3.0.3: +is-path-cwd@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-2.2.0.tgz#67d43b82664a7b5191fd9119127eb300048a9fdb" + integrity sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ== + +is-path-inside@^3.0.1, is-path-inside@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== @@ -5555,7 +5601,7 @@ merge-stream@^2.0.0: resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== -merge2@^1.3.0, merge2@^1.4.1: +merge2@^1.2.3, merge2@^1.3.0, merge2@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== @@ -5879,6 +5925,13 @@ p-locate@^5.0.0: dependencies: p-limit "^3.0.2" +p-map@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-map/-/p-map-3.0.0.tgz#d704d9af8a2ba684e2600d9a215983d4141a979d" + integrity sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ== + dependencies: + aggregate-error "^3.0.0" + p-map@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b" @@ -6288,7 +6341,7 @@ rfdc@^1.3.0: resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.1.tgz#2b6d4df52dffe8bb346992a10ea9451f24373a8f" integrity sha512-r5a3l5HzYlIC68TpmYKlxWjmOP6wiPJ1vWv2HeLhNsRZMrCkxeqxiHlQ21oXmQ4F3SiryXBHhAD7JZqvOJjFmg== -rimraf@^3.0.2: +rimraf@^3.0.0, rimraf@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== @@ -6302,6 +6355,13 @@ rimraf@^5.0.5: dependencies: glob "^10.3.7" +rollup-plugin-delete@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-delete/-/rollup-plugin-delete-2.0.0.tgz#262acf80660d48c3b167fb0baabd0c3ab985c153" + integrity sha512-/VpLMtDy+8wwRlDANuYmDa9ss/knGsAgrDhM+tEwB1npHwNu4DYNmDfUL55csse/GHs9Q+SMT/rw9uiaZ3pnzA== + dependencies: + del "^5.1.0" + rollup-plugin-dts-bundle-generator@1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/rollup-plugin-dts-bundle-generator/-/rollup-plugin-dts-bundle-generator-1.4.0.tgz#533fd3a003094a1c46a93628f3c824bd4e69fd79" From 1feff62bc87e406f4d5224b75925f478efa693e1 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Wed, 17 Apr 2024 17:11:24 +0900 Subject: [PATCH 4/5] chore: bump package.json version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1355c2e..bb53ca3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ubiquibot/permit-generation", - "version": "1.2.1", + "version": "1.2.2", "description": "ECR20 / ECR721 permit generation for automated payments.", "author": "Ubiquity DAO", "license": "MIT", From a94aad8be07cffa7810bbcfa92cd3f3687fe5491 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Thu, 18 Apr 2024 13:02:14 +0900 Subject: [PATCH 5/5] chore: fixed naming convention to match camelCase and made name more explicit --- src/handlers/encode-decode.ts | 6 +++--- src/handlers/generate-erc20-permit.ts | 10 +++++----- src/handlers/generate-erc721-permit.ts | 10 +++++----- src/handlers/generate-payout-permit.ts | 8 ++++---- src/types/permits.ts | 6 +++--- tests/encode-decode.test.ts | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/handlers/encode-decode.ts b/src/handlers/encode-decode.ts index fad6ec4..4367025 100644 --- a/src/handlers/encode-decode.ts +++ b/src/handlers/encode-decode.ts @@ -1,10 +1,10 @@ -import { Permit, TokenType } from "../types"; +import { PermitReward, TokenType } from "../types"; import { RewardPermit } from "./permit-type"; /** * Returns a base64 encoded string containing all the permit data */ -export function encodePermits(permits: Permit[]) { +export function encodePermits(permits: PermitReward[]) { const permitsDto = permits .map((permit) => { if (permit.tokenType === TokenType.ERC20) { @@ -66,7 +66,7 @@ export function encodePermits(permits: Permit[]) { export function decodePermits(base64: string) { const decoded = atob(base64); const objs: Array = JSON.parse(decoded); - const result: Permit[] = []; + const result: PermitReward[] = []; for (const obj of objs) { const tokenType = obj.type === "erc20-permit" ? TokenType.ERC20 : TokenType.ERC721; if (tokenType === TokenType.ERC721) { diff --git a/src/handlers/generate-erc20-permit.ts b/src/handlers/generate-erc20-permit.ts index e88ee9f..3c4beff 100644 --- a/src/handlers/generate-erc20-permit.ts +++ b/src/handlers/generate-erc20-permit.ts @@ -1,7 +1,7 @@ import { PERMIT2_ADDRESS, PermitTransferFrom, SignatureTransfer } from "@uniswap/permit2-sdk"; import { ethers, keccak256, MaxInt256, parseUnits, toUtf8Bytes } from "ethers"; import { Context, Logger } from "../types/context"; -import { Permit, TokenType } from "../types"; +import { PermitReward, TokenType } from "../types"; import { decryptKeys } from "../utils/keys"; import { getPayoutConfigByNetworkId } from "../utils/payoutConfigByNetworkId"; @@ -14,9 +14,9 @@ export interface Payload { userId: number; } -export async function generateErc20PermitSignature(payload: Payload, username: string, amount: number): Promise; -export async function generateErc20PermitSignature(context: Context, username: string, amount: number): Promise; -export async function generateErc20PermitSignature(contextOrPayload: Context | Payload, username: string, amount: number): Promise { +export async function generateErc20PermitSignature(payload: Payload, username: string, amount: number): Promise; +export async function generateErc20PermitSignature(context: Context, username: string, amount: number): Promise; +export async function generateErc20PermitSignature(contextOrPayload: Context | Payload, username: string, amount: number): Promise { let _logger: Logger; const _username = username; let _walletAddress: string | null | undefined; @@ -119,7 +119,7 @@ export async function generateErc20PermitSignature(contextOrPayload: Context | P throw new Error(errorMessage); }); - const erc20Permit: Permit = { + const erc20Permit: PermitReward = { tokenType: TokenType.ERC20, tokenAddress: permitTransferFromData.permitted.token, beneficiary: permitTransferFromData.spender, diff --git a/src/handlers/generate-erc721-permit.ts b/src/handlers/generate-erc721-permit.ts index 2ec3499..4564a21 100644 --- a/src/handlers/generate-erc721-permit.ts +++ b/src/handlers/generate-erc721-permit.ts @@ -1,7 +1,7 @@ import { MaxUint256 } from "@uniswap/permit2-sdk"; import { ethers, keccak256, toUtf8Bytes } from "ethers"; import { Context, Logger } from "../types/context"; -import { Permit, TokenType } from "../types"; +import { PermitReward, TokenType } from "../types"; import { isIssueEvent } from "../types/typeguards"; import { getPayoutConfigByNetworkId } from "../utils/payoutConfigByNetworkId"; @@ -38,13 +38,13 @@ export interface PermitPayload { userId: number; } -export async function generateErc721PermitSignature(permitPayload: PermitPayload, username: string, contributionType: string): Promise; -export async function generateErc721PermitSignature(context: Context, username: string, contributionType: string): Promise; +export async function generateErc721PermitSignature(permitPayload: PermitPayload, username: string, contributionType: string): Promise; +export async function generateErc721PermitSignature(context: Context, username: string, contributionType: string): Promise; export async function generateErc721PermitSignature( contextOrPermitPayload: Context | PermitPayload, username: string, contributionType: string -): Promise { +): Promise { let _logger: Logger; let _nftContractAddress: string; let _evmNetworkId: number; @@ -153,7 +153,7 @@ export async function generateErc721PermitSignature( throw new Error(`Failed to sign typed data: ${error}`); }); - const erc721Permit: Permit = { + const erc721Permit: PermitReward = { tokenType: TokenType.ERC721, tokenAddress: _nftContractAddress, beneficiary: _walletAddress, diff --git a/src/handlers/generate-payout-permit.ts b/src/handlers/generate-payout-permit.ts index 61a5e24..666a067 100644 --- a/src/handlers/generate-payout-permit.ts +++ b/src/handlers/generate-payout-permit.ts @@ -1,4 +1,4 @@ -import { Permit } from "../types"; +import { PermitReward } from "../types"; import { Context } from "../types/context"; import { generateErc20PermitSignature } from "./generate-erc20-permit"; import { generateErc721PermitSignature } from "./generate-erc721-permit"; @@ -10,13 +10,13 @@ import { PermitRequest } from "../types/plugin-input"; * @param permitRequests * @returns A Promise that resolves to the generated permit transaction data or an error message. */ -export async function generatePayoutPermit(context: Context, permitRequests: PermitRequest[]): Promise { - const permits: Permit[] = []; +export async function generatePayoutPermit(context: Context, permitRequests: PermitRequest[]): Promise { + const permits: PermitReward[] = []; for (const permitRequest of permitRequests) { const { type, amount, username, contributionType } = permitRequest; - let permit: Permit; + let permit: PermitReward; switch (type) { case "ERC20": permit = await generateErc20PermitSignature(context, username, amount); diff --git a/src/types/permits.ts b/src/types/permits.ts index 1eb8be2..708d29c 100644 --- a/src/types/permits.ts +++ b/src/types/permits.ts @@ -16,13 +16,13 @@ interface CommonFields { networkId: number; } -interface ERC20Permit extends CommonFields { +interface Erc20PermitReward extends CommonFields { tokenType: TokenType.ERC20; amount: BigNumberish; erc721Request?: never; } -interface ERC721Permit extends CommonFields { +interface Erc721PermitReward extends CommonFields { tokenType: TokenType.ERC721; amount: "0" | "1"; erc721Request?: { @@ -38,4 +38,4 @@ interface ERC721Permit extends CommonFields { }; } -export type Permit = ERC20Permit | ERC721Permit; +export type PermitReward = Erc20PermitReward | Erc721PermitReward; diff --git a/tests/encode-decode.test.ts b/tests/encode-decode.test.ts index fd11d3d..f16010e 100644 --- a/tests/encode-decode.test.ts +++ b/tests/encode-decode.test.ts @@ -1,10 +1,10 @@ import { describe, expect, it } from "@jest/globals"; import { decodePermits, encodePermits } from "../src/handlers/encode-decode"; -import { Permit, TokenType } from "../src/types"; +import { PermitReward, TokenType } from "../src/types"; describe("Encoding / Decoding tests", () => { it("Should properly encode and decode a list of permits", () => { - const permitErc20: Permit = { + const permitErc20: PermitReward = { beneficiary: "ubiquity", deadline: "1", networkId: 100, @@ -15,7 +15,7 @@ describe("Encoding / Decoding tests", () => { tokenType: TokenType.ERC20, amount: 100, }; - const permitErc721: Permit = { + const permitErc721: PermitReward = { beneficiary: "ubiquity2", deadline: "2", networkId: 101,