diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..2e1f07e --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,19 @@ +name: Publish Package to npmjs +on: + release: + types: [published] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + # Setup .npmrc file to publish to npm + - uses: actions/setup-node@v3 + with: + node-version: "16.x" + registry-url: "https://registry.npmjs.org" + - run: yarn install --frozen-lockfile + - run: yarn build + - run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index ee59a01..1a4e8a4 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ build/Release # Dependency directory node_modules +lib \ No newline at end of file diff --git a/package.json b/package.json index aad6d82..d6a6c17 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,20 @@ { - "name": "wizard-sdk", + "name": "@trustwallet/wizard-sdk", "version": "0.0.1", "description": "typescript sdk to visualize EIP-712 various protocols, simulate and decode transactions", - "main": "index.js", + "main": "lib/index.js", "repository": "git@github.com:trustwallet/wizard-sdk.git", "author": "Abdou <118254027+a6-dou@users.noreply.github.com>", "license": "BSD", + "keywords": [ + "web3", + "EIP-712", + "Simulation" + ], "scripts": { "test": "jest", - "coverage": "jest --coverage" + "coverage": "jest --coverage", + "build": "tsc --project ./tsconfig.build.json" }, "devDependencies": { "@types/jest": "^29.5.0", @@ -23,5 +29,12 @@ "@typescript-eslint/parser": "^5.55.0", "eslint": "^8.36.0", "ethers": "^6.1.0" - } + }, + "files": [ + "lib/", + "LICENSE", + "README.md", + "node_module", + "package.json" + ] } diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..f0e1e96 --- /dev/null +++ b/src/index.ts @@ -0,0 +1 @@ +export * as visualizer from "./visualizer"; diff --git a/src/types/index.ts b/src/types/index.ts index db588e3..f1ee47e 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -45,7 +45,7 @@ export type Result = { liveness?: Liveness; assetIn: AssetInOut[]; assetOut: AssetInOut[]; - approval?: Approval[]; + approval: Approval[]; }; export type Protocol = { diff --git a/src/visualizer/blur-io/index.ts b/src/visualizer/blur-io/index.ts index ceae8d6..fcc6c0a 100644 --- a/src/visualizer/blur-io/index.ts +++ b/src/visualizer/blur-io/index.ts @@ -78,6 +78,7 @@ export const visualize = (message: BlurIoOrder, domain: Domain): Result => { from: Number(message.listingTime) * 1000, to: Number(message.expirationTime) * 1000, }, + approval: [], }; }; diff --git a/src/visualizer/index.ts b/src/visualizer/index.ts index 47964bb..ece5194 100644 --- a/src/visualizer/index.ts +++ b/src/visualizer/index.ts @@ -1,4 +1,3 @@ - import { Domain, PermitMessage, Result } from "../types"; import { SeaPortPayload } from "../types/seaport"; diff --git a/src/visualizer/looksrare/index.ts b/src/visualizer/looksrare/index.ts index 9b5682e..cbae3fd 100644 --- a/src/visualizer/looksrare/index.ts +++ b/src/visualizer/looksrare/index.ts @@ -76,6 +76,7 @@ export const visualize = ( from: Number(message.startTime) * 1000, to: Number(message.endTime) * 1000, }, + approval: [], }; }; diff --git a/src/visualizer/seaport/index.ts b/src/visualizer/seaport/index.ts index b821a85..58c93e8 100644 --- a/src/visualizer/seaport/index.ts +++ b/src/visualizer/seaport/index.ts @@ -126,6 +126,7 @@ export const visualize = (message: SeaPortPayload, domain: Domain): Result => { }, assetIn, assetOut, + approval: [], }; }; diff --git a/test/visualizer/blur-io/index.test.ts b/test/visualizer/blur-io/index.test.ts index a597883..8dc6c44 100644 --- a/test/visualizer/blur-io/index.test.ts +++ b/test/visualizer/blur-io/index.test.ts @@ -42,6 +42,7 @@ describe("blur.io", () => { amounts: ["1"], }, ], + approval: [], liveness: { from: 1677736151000, to: 1678340951000 }, }); }); @@ -66,6 +67,7 @@ describe("blur.io", () => { amounts: ["800000000000000000"], }, ], + approval: [], liveness: { from: 1677736151000, to: 1678340951000 }, }); }); @@ -89,6 +91,7 @@ describe("blur.io", () => { amounts: ["10000000000000000"], }, ], + approval: [], liveness: { from: 1678461048000, to: 1709997048000 }, }); }); @@ -116,6 +119,7 @@ describe("blur.io", () => { amounts: ["800000000000000000"], }, ], + approval: [], liveness: { from: 1677736151000, to: 1678340951000 }, }); }); diff --git a/test/visualizer/looksrare/index.test.ts b/test/visualizer/looksrare/index.test.ts index da755a0..c8f5b35 100644 --- a/test/visualizer/looksrare/index.test.ts +++ b/test/visualizer/looksrare/index.test.ts @@ -60,6 +60,7 @@ describe("looksrare", () => { amounts: ["1"], }, ], + approval: [], liveness: { from: 1677588653000, to: 1680266940000 }, }); }); @@ -86,6 +87,7 @@ describe("looksrare", () => { amounts: ["1000000000000000"], }, ], + approval: [], liveness: { from: 1677588943000, to: 1677675336000 }, }); }); @@ -113,6 +115,7 @@ describe("looksrare", () => { amounts: ["1000000000000000"], }, ], + approval: [], liveness: { from: 1677588943000, to: 1677675336000 }, }); }); @@ -144,6 +147,7 @@ describe("looksrare", () => { amounts: ["1"], }, ], + approval: [], liveness: { from: 1677588653000, to: 1680266940000 }, }); }); diff --git a/test/visualizer/seaport/index.test.ts b/test/visualizer/seaport/index.test.ts index dfea6d4..25d86ab 100644 --- a/test/visualizer/seaport/index.test.ts +++ b/test/visualizer/seaport/index.test.ts @@ -68,6 +68,7 @@ describe("visualizer", () => { amounts: ["50", "100"], }, ], + approval: [], }); }); @@ -95,6 +96,7 @@ describe("visualizer", () => { amounts: ["50", "100"], }, ], + approval: [], }); }); @@ -124,6 +126,7 @@ describe("visualizer", () => { amounts: ["1"], }, ], + approval: [], }); }); @@ -153,6 +156,7 @@ describe("visualizer", () => { amounts: ["50", "100"], }, ], + approval: [], }); }); @@ -177,6 +181,7 @@ describe("visualizer", () => { amounts: ["4000000000000000"], }, ], + approval: [], }); }); @@ -207,6 +212,7 @@ describe("visualizer", () => { amounts: ["100000000000000000"], }, ], + approval: [], }); }); @@ -236,6 +242,7 @@ describe("visualizer", () => { from: 1677592745000, to: 1678197528000, }, + approval: [], }); }); @@ -269,6 +276,7 @@ describe("visualizer", () => { from: 1677130860000, to: 1677303660000, }, + approval: [], }); }); @@ -296,6 +304,7 @@ describe("visualizer", () => { from: 1677130860000, to: 1677303660000, }, + approval: [], }); }); @@ -323,6 +332,7 @@ describe("visualizer", () => { from: 1677130860000, to: 1677303660000, }, + approval: [], }); }); @@ -350,6 +360,7 @@ describe("visualizer", () => { from: 1680010140000, to: 1680269340000, }, + approval: [], }); }); }); diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..64f86c6 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] +} diff --git a/tsconfig.json b/tsconfig.json index 696e3be..7578c70 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -49,13 +49,13 @@ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, + "declarationMap": true /* Create sourcemaps for d.ts files. */, // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + "sourceMap": true /* Create source map files for emitted JavaScript files. */, // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ + "outDir": "./lib" /* Specify an output folder for all emitted files. */, // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */