From 1e2fc9e5887aa40d1bc8eb1a5769aab9d1c594e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Petruni=C4=87?= Date: Fri, 19 Jan 2024 14:35:38 +0100 Subject: [PATCH] chore: reorganize monorepo, improved linting, testing and ci (#58) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description - merged controller packages into widget package - added better linting - removed unnecessary typescript compiling - improved ci (added testing) - configured release-please No code logic changes in this PR ## Related Issue Or Context Closes: # ## How Has This Been Tested? Testing details. ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation ## Checklist: - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have ensured that all acceptance criteria (or expected behavior) from issue are met - [ ] I have updated the documentation locally and in sygma-docs. - [ ] I have added tests to cover my changes. - [ ] I have ensured that all the checks are passing and green, I've signed the CLA bot --------- Signed-off-by: Marin Petrunic Co-authored-by: Filip Štoković <59089574+sztok7@users.noreply.github.com> Co-authored-by: Filip Štoković --- .eslintrc.json | 59 +- .github/workflows/build-react.yml | 30 - .github/workflows/build-sdk-manager.yml | 31 - .github/workflows/build-wallet-manager.yml | 30 - .github/workflows/build-widget.yml | 30 - .github/workflows/{widget.yml => cd.yml} | 55 +- .github/workflows/ci.yml | 27 + .github/workflows/react-widget.yml | 63 - .github/workflows/sdk-manager.yml | 62 - .github/workflows/wallet-manager.yml | 62 - .gitignore | 4 +- .release-please-manifest.json | 3 + .yarnrc.yml | 4 +- package.json | 39 +- packages/react/.eslintrc.json | 6 + packages/react/package.json | 2 +- packages/sdk-manager/.gitignore | 25 - packages/sdk-manager/.npmignore | 5 - packages/sdk-manager/CHANGELOG.md | 24 - packages/sdk-manager/package.json | 30 - packages/sdk-manager/tsconfig.json | 9 - packages/sdk-manager/vite.config.ts | 30 - packages/wallet-manager/.gitignore | 25 - packages/wallet-manager/.npmignore | 5 - packages/wallet-manager/CHANGELOG.md | 121 - packages/wallet-manager/README.md | 49 - packages/wallet-manager/package.json | 36 - packages/wallet-manager/tsconfig.json | 10 - packages/wallet-manager/vite.config.ts | 8 - packages/widget/.eslintrc.json | 12 + packages/widget/package.json | 41 +- .../amount-selector/amount-selector.ts | 24 +- .../components/base-selector/base-selector.ts | 18 +- .../network-selector/network-selector.ts | 11 +- .../src/components/widget-app/widget-app.ts | 71 +- .../src/components/widget-app/widget-mixin.ts | 27 +- .../src/components/widget-app/widget-view.ts | 19 +- packages/widget/src/controllers/index.ts | 2 + .../controllers/sdk-manager}/SdkManager.ts | 26 +- .../sdk-manager}/SdkManagerContextProvider.ts | 23 +- .../src/controllers/sdk-manager}/index.ts | 0 .../sdk-manager}/types/SdkManagerState.ts | 10 +- .../sdk-manager}/types/SdkManagerStatus.ts | 0 .../controllers/sdk-manager}/types/index.ts | 0 .../wallet-manager}/WalletManagerContext.ts | 13 +- .../WalletManagerController.ts | 55 +- .../src/controllers/wallet-manager}/index.ts | 0 .../wallet-manager}/interfaces/index.ts | 10 +- .../src/controllers/wallet-manager}/types.ts | 4 +- .../wallet-manager}/utils/index.ts | 2 +- .../wallet-manager}/wallets/Evm/Evm.ts | 55 +- .../wallet-manager}/wallets/Evm/index.ts | 0 .../wallets/Substrate/Substrate.ts | 3 +- .../wallets/Substrate/index.ts | 0 .../wallet-manager}/wallets/index.ts | 0 packages/widget/src/interfaces/index.ts | 5 +- packages/widget/src/utils/index.ts | 10 +- packages/widget/src/widget.ts | 7 +- .../wallet-manager}/EvmWallet.test.ts | 4 +- .../wallet-manager}/Substrate.test.ts | 3 +- .../WalletManagerController.test.ts | 21 +- packages/widget/tsconfig.build.json | 4 + packages/widget/tsconfig.json | 2 +- packages/widget/vite.config.ts | 10 +- release-please-config.json | 19 + yarn.lock | 2535 +++++++++-------- 66 files changed, 1723 insertions(+), 2207 deletions(-) delete mode 100644 .github/workflows/build-react.yml delete mode 100644 .github/workflows/build-sdk-manager.yml delete mode 100644 .github/workflows/build-wallet-manager.yml delete mode 100644 .github/workflows/build-widget.yml rename .github/workflows/{widget.yml => cd.yml} (52%) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/react-widget.yml delete mode 100644 .github/workflows/sdk-manager.yml delete mode 100644 .github/workflows/wallet-manager.yml create mode 100644 .release-please-manifest.json create mode 100644 packages/react/.eslintrc.json delete mode 100644 packages/sdk-manager/.gitignore delete mode 100644 packages/sdk-manager/.npmignore delete mode 100644 packages/sdk-manager/CHANGELOG.md delete mode 100644 packages/sdk-manager/package.json delete mode 100644 packages/sdk-manager/tsconfig.json delete mode 100644 packages/sdk-manager/vite.config.ts delete mode 100644 packages/wallet-manager/.gitignore delete mode 100644 packages/wallet-manager/.npmignore delete mode 100644 packages/wallet-manager/CHANGELOG.md delete mode 100644 packages/wallet-manager/README.md delete mode 100644 packages/wallet-manager/package.json delete mode 100644 packages/wallet-manager/tsconfig.json delete mode 100644 packages/wallet-manager/vite.config.ts create mode 100644 packages/widget/.eslintrc.json create mode 100644 packages/widget/src/controllers/index.ts rename packages/{sdk-manager/src => widget/src/controllers/sdk-manager}/SdkManager.ts (82%) rename packages/{sdk-manager/src => widget/src/controllers/sdk-manager}/SdkManagerContextProvider.ts (81%) rename packages/{sdk-manager/src => widget/src/controllers/sdk-manager}/index.ts (100%) rename packages/{sdk-manager/src => widget/src/controllers/sdk-manager}/types/SdkManagerState.ts (75%) rename packages/{sdk-manager/src => widget/src/controllers/sdk-manager}/types/SdkManagerStatus.ts (100%) rename packages/{sdk-manager/src => widget/src/controllers/sdk-manager}/types/index.ts (100%) rename packages/{wallet-manager/src => widget/src/controllers/wallet-manager}/WalletManagerContext.ts (87%) rename packages/{wallet-manager/src => widget/src/controllers/wallet-manager}/WalletManagerController.ts (70%) rename packages/{wallet-manager/src => widget/src/controllers/wallet-manager}/index.ts (100%) rename packages/{wallet-manager/src => widget/src/controllers/wallet-manager}/interfaces/index.ts (80%) rename packages/{wallet-manager/src => widget/src/controllers/wallet-manager}/types.ts (82%) rename packages/{wallet-manager/src => widget/src/controllers/wallet-manager}/utils/index.ts (88%) rename packages/{wallet-manager/src => widget/src/controllers/wallet-manager}/wallets/Evm/Evm.ts (69%) rename packages/{wallet-manager/src => widget/src/controllers/wallet-manager}/wallets/Evm/index.ts (100%) rename packages/{wallet-manager/src => widget/src/controllers/wallet-manager}/wallets/Substrate/Substrate.ts (93%) rename packages/{wallet-manager/src => widget/src/controllers/wallet-manager}/wallets/Substrate/index.ts (100%) rename packages/{wallet-manager/src => widget/src/controllers/wallet-manager}/wallets/index.ts (100%) rename packages/{wallet-manager/src/test => widget/tests/unit/controllers/wallet-manager}/EvmWallet.test.ts (85%) rename packages/{wallet-manager/src/test => widget/tests/unit/controllers/wallet-manager}/Substrate.test.ts (87%) rename packages/{wallet-manager/src/test => widget/tests/unit/controllers/wallet-manager}/WalletManagerController.test.ts (78%) create mode 100644 packages/widget/tsconfig.build.json create mode 100644 release-please-config.json diff --git a/.eslintrc.json b/.eslintrc.json index ca66489a..85071cb0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,55 +1,10 @@ { - "extends": [ - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:import/typescript", - "plugin:lit/recommended", - "plugin:wc/recommended", - "plugin:prettier/recommended" - ], - "parserOptions": { - "sourceType": "module", - "ecmaVersion": "latest" - }, - "env": { - "browser": true - }, - "rules": { - "@typescript-eslint/explicit-function-return-type": "off", - "import/extensions": "off", - "import/no-import-module-exports": "off", - "import/no-unresolved": "off", - "import/prefer-default-export": "off", - "lit/no-template-map": "off", - "lit/prefer-static-styles": "off", - "class-methods-use-this": [ - "error", - { - "exceptMethods": ["render", "update"] - } - ], - "no-console": ["warn", { "allow": ["warn"] }], - "no-param-reassign": "off", - "no-plusplus": "off", - "no-underscore-dangle": "off", - "prefer-destructuring": "off" - }, - "plugins": ["@typescript-eslint", "wc", "prettier"], + "root": true, + "extends": "@chainsafe", "parser": "@typescript-eslint/parser", - "overrides": [ - { - "files": ["src/@types/*.d.ts"], - "rules": { - "@typescript-eslint/no-explicit-any": "off" - } - }, - { - "files": ["scripts/*.js"], - "rules": { - "import/no-extraneous-dependencies": "off", - "no-console": "off", - "no-restricted-syntax": "off" - } - } - ] + "parserOptions": { + "project": ["'./packages/*/tsconfig.json'", "'./examples/*/tsconfig.json'"], + "ecmaVersion": 2020, + "sourceType": "module" + } } \ No newline at end of file diff --git a/.github/workflows/build-react.yml b/.github/workflows/build-react.yml deleted file mode 100644 index 6771018f..00000000 --- a/.github/workflows/build-react.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: "Lint and build React" - -on: - pull_request: - types: [opened, synchronize, reopened] - paths: - - 'packages/react/**' - - '!packages/widget/**' - - '!packages/sdk-manager/**' - - '!packages/wallet-manager/**' - -jobs: - check: - runs-on: ubuntu-latest - strategy: - matrix: - os: [ubuntu-latest] - node: [18] - fail-fast: true - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - cache: 'yarn' # cache node modules - node-version: ${{ matrix.node }} - - run: corepack enable - - run: yarn set version stable - - run: yarn install --immutable # install dependencies - - run: yarn run lint:react-widget # lint code - - run: yarn run build:all # build react diff --git a/.github/workflows/build-sdk-manager.yml b/.github/workflows/build-sdk-manager.yml deleted file mode 100644 index 9ba1761b..00000000 --- a/.github/workflows/build-sdk-manager.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: "Lint and build SDK Manager" - -on: - pull_request: - types: [opened, synchronize, reopened] - paths: - - 'packages/sdk-manager/**' - - '!packages/widget/**' - - '!packages/wallet-manager/**' - - '!packages/react/**' - -jobs: - check: - runs-on: ubuntu-latest - strategy: - matrix: - os: [ubuntu-latest] - node: [18] - fail-fast: true - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - cache: 'yarn' # cache node modules - node-version: ${{ matrix.node }} - - run: corepack enable - - run: yarn set version stable - - run: yarn - - run: yarn run lint:sdk-manager # lint code - - run: yarn run build:wallet-manager # build wallet-manager - - run: yarn run build:sdk-manager # build sdk-manager diff --git a/.github/workflows/build-wallet-manager.yml b/.github/workflows/build-wallet-manager.yml deleted file mode 100644 index 741bc46d..00000000 --- a/.github/workflows/build-wallet-manager.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: "Lint and build Wallet Manager" - -on: - pull_request: - types: [opened, synchronize, reopened] - paths: - - 'packages/wallet-manager/**' - - '!packages/sdk-manager/**' - - '!packages/widget/**' - - '!packages/react/**' - -jobs: - check: - runs-on: ubuntu-latest - strategy: - matrix: - os: [ubuntu-latest] - node: [18] - fail-fast: true - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - cache: 'yarn' # cache node modules - node-version: ${{ matrix.node }} - - run: corepack enable - - run: yarn set version stable - - run: yarn - - run: yarn run lint:wallet-manager # lint code - - run: yarn run build:wallet-manager # build wallet diff --git a/.github/workflows/build-widget.yml b/.github/workflows/build-widget.yml deleted file mode 100644 index 2313d1c3..00000000 --- a/.github/workflows/build-widget.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: "Lint and build Widget" - -on: - pull_request: - types: [opened, synchronize, reopened] - paths: - - 'packages/widget/**' - - '!packages/sdk-manager/**' - - '!packages/wallet-manager/**' - - '!packages/react/**' - -jobs: - check: - runs-on: ubuntu-latest - strategy: - matrix: - os: [ubuntu-latest] - node: [18] - fail-fast: true - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - cache: 'yarn' # cache node modules - node-version: ${{ matrix.node }} - - run: corepack enable - - run: yarn set version stable - - run: yarn install --immutable - - run: yarn run lint:widget # lint code - - run: yarn run build:all # build widget diff --git a/.github/workflows/widget.yml b/.github/workflows/cd.yml similarity index 52% rename from .github/workflows/widget.yml rename to .github/workflows/cd.yml index d9f8755a..430414fb 100644 --- a/.github/workflows/widget.yml +++ b/.github/workflows/cd.yml @@ -1,62 +1,57 @@ -name: Publish Widget to NPM +name: Publish packages to NPM on: push: branches: - main - paths: - - 'packages/widget/**' - - '!packages/sdk-manager/**' - - '!packages/wallet-manager/**' jobs: maybe-release: name: release runs-on: ubuntu-latest + # add check if ci is successfull if: github.event_name == 'push' && github.ref == 'refs/heads/main' steps: - # you should probably do this after your regular CI checks passes - - uses: google-github-actions/release-please-action@v3 # it will analyze commits and create PR with new version and updated CHANGELOG:md file. On merging it will create github release page with changelog + - uses: google-github-actions/release-please-action@v3 id: release with: - release-type: node + command: manifest token: ${{secrets.RELEASE_TOKEN}} - path: packages/widget - monorepo-tags: true default-branch: main - package-name: '@buildwithsygma/widget' + release-type: node + monorepo-tags: true changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false},{"type":"revert","hidden":true}]' - - uses: actions/checkout@v3 - # these if statements ensure that a publication only occurs when - # a new release is created: + - uses: actions/checkout@v4 if: ${{ steps.release.outputs.releases_created }} - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 + if: ${{ steps.release.outputs.releases_created }} with: - cache: 'yarn' node-version: 18 - registry-url: 'https://registry.npmjs.org' - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - if: ${{ steps.release.outputs.releases_created }} - - name: Enable corepack - run: corepack enable + - run: corepack enable if: ${{ steps.release.outputs.releases_created }} - - - name: Install yarn - run: yarn set version stable + + - uses: actions/setup-node@v4 + with: + cache: 'yarn' + node-version: 18 + registry-url: 'https://registry.npmjs.org' if: ${{ steps.release.outputs.releases_created }} - name: Install dependencies - run: yarn install + run: yarn install --immutable if: ${{ steps.release.outputs.releases_created }} - name: Build all packages - run: yarn build:all + run: yarn build if: ${{ steps.release.outputs.releases_created }} - - run: npm publish --workspace=@buildwithsygma/sygmaprotocol-widget --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + if: ${{ steps.release.outputs.releases_created }} + run: | + echo npmAuthToken: "$NODE_AUTH_TOKEN" >> ./.yarnrc.yml + + - run: yarn workspaces foreach -v --exclude root --no-private npm publish --tolerate-republish --access public if: ${{ steps.release.outputs.releases_created }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..85797156 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: "ci / test" + +on: + push: + branches: + - main # runs on push to master, add more branches if you use them + pull_request: + branches: + - '**' # runs on update to pull request on any branch + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - run: corepack enable + - uses: actions/setup-node@v4 + with: + node-version: 18 + cache: yarn + - run: yarn install --immutable + - run: yarn run lint + - run: yarn run build + - run: yarn run test:unit diff --git a/.github/workflows/react-widget.yml b/.github/workflows/react-widget.yml deleted file mode 100644 index c8344282..00000000 --- a/.github/workflows/react-widget.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Publish React Widget to NPM - -on: - push: - branches: - - main - paths: - - 'packages/react/**' - - '!packages/widget/**' - - '!packages/sdk-manager/**' - - '!packages/wallet-manager/**' -jobs: - maybe-release: - name: release - runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - steps: - # you should probably do this after your regular CI checks passes - - uses: google-github-actions/release-please-action@v3 # it will analyze commits and create PR with new version and updated CHANGELOG:md file. On merging it will create github release page with changelog - id: release - with: - release-type: node - token: ${{secrets.RELEASE_TOKEN}} - path: packages/react - monorepo-tags: true - default-branch: main - package-name: '@buildwithsygma/react-widget' - changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false},{"type":"revert","hidden":true}]' - - - uses: actions/checkout@v3 - # these if statements ensure that a publication only occurs when - # a new release is created: - if: ${{ steps.release.outputs.releases_created }} - - - uses: actions/setup-node@v3 - with: - cache: 'yarn' - node-version: 18 - registry-url: 'https://registry.npmjs.org' - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - if: ${{ steps.release.outputs.releases_created }} - - - name: Enable corepack - run: corepack enable - if: ${{ steps.release.outputs.releases_created }} - - - name: Install yarn - run: yarn set version stable - if: ${{ steps.release.outputs.releases_created }} - - - name: Install dependencies - run: yarn install - if: ${{ steps.release.outputs.releases_created }} - - - name: Build all packages - run: yarn build:all - if: ${{ steps.release.outputs.releases_created }} - - - run: npm publish --workspace=@buildwithsygma/sygmaprotocol-react-widget --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - if: ${{ steps.release.outputs.releases_created }} diff --git a/.github/workflows/sdk-manager.yml b/.github/workflows/sdk-manager.yml deleted file mode 100644 index 27a6f497..00000000 --- a/.github/workflows/sdk-manager.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Publish SDK Manager to NPM - -on: - push: - branches: - - main - paths: - - 'packages/sdk-manager/**' - - '!packages/wallet-manager/**' - - '!packages/widget/**' -jobs: - maybe-release: - name: release - runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - steps: - # you should probably do this after your regular CI checks passes - - uses: google-github-actions/release-please-action@v3 # it will analyze commits and create PR with new version and updated CHANGELOG:md file. On merging it will create github release page with changelog - id: release - with: - release-type: node - token: ${{secrets.RELEASE_TOKEN}} - path: packages/sdk-manager - monorepo-tags: true - default-branch: main - package-name: '@buildwithsygma/sygmaprotocol-sdk-manager' - changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false},{"type":"revert","hidden":true}]' - - - uses: actions/checkout@v3 - # these if statements ensure that a publication only occurs when - # a new release is created: - if: ${{ steps.release.outputs.releases_created }} - - - uses: actions/setup-node@v3 - with: - cache: 'yarn' - node-version: 18 - registry-url: 'https://registry.npmjs.org' - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - if: ${{ steps.release.outputs.releases_created }} - - - name: Enable corepack - run: corepack enable - if: ${{ steps.release.outputs.releases_created }} - - - name: Install yarn - run: yarn set version stable - if: ${{ steps.release.outputs.releases_created }} - - - name: Install dependencies - run: yarn install - if: ${{ steps.release.outputs.releases_created }} - - - name: Build all packages - run: yarn build:all - if: ${{ steps.release.outputs.releases_created }} - - - run: npm publish --workspace=@buildwithsygma/sygmaprotocol-sdk-manager --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - if: ${{ steps.release.outputs.releases_created }} diff --git a/.github/workflows/wallet-manager.yml b/.github/workflows/wallet-manager.yml deleted file mode 100644 index d782c10a..00000000 --- a/.github/workflows/wallet-manager.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Publish Wallet Manager to NPM - -on: - push: - branches: - - main - paths: - - 'packages/wallet-manager/**' - - '!packages/widget/**' - - '!packages/sdk-manager/**' -jobs: - maybe-release: - name: release - runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - steps: - # you should probably do this after your regular CI checks passes - - uses: google-github-actions/release-please-action@v3 # it will analyze commits and create PR with new version and updated CHANGELOG:md file. On merging it will create github release page with changelog - id: release - with: - release-type: node - token: ${{secrets.RELEASE_TOKEN}} - path: packages/wallet-manager - monorepo-tags: true - default-branch: main - package-name: '@buildwithsygma/sygmaprotocol-wallet-manager' - changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false},{"type":"revert","hidden":true}]' - - - uses: actions/checkout@v3 - # these if statements ensure that a publication only occurs when - # a new release is created: - if: ${{ steps.release.outputs.releases_created }} - - - uses: actions/setup-node@v3 - with: - cache: 'yarn' - node-version: 18 - registry-url: 'https://registry.npmjs.org' - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - if: ${{ steps.release.outputs.releases_created }} - - - name: Enable corepack - run: corepack enable - if: ${{ steps.release.outputs.releases_created }} - - - name: Install yarn - run: yarn set version stable - if: ${{ steps.release.outputs.releases_created }} - - - name: Install dependencies - run: yarn install - if: ${{ steps.release.outputs.releases_created }} - - - name: Build all packages - run: yarn build:all - if: ${{ steps.release.outputs.releases_created }} - - - run: npm publish --workspace=@buildwithsygma/sygmaprotocol-wallet-manager --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - if: ${{ steps.release.outputs.releases_created }} diff --git a/.gitignore b/.gitignore index 813e586a..5279781a 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,8 @@ # production /build +packages/wallet-manager/build +packages/sdk-manager/build # misc .DS_Store @@ -46,4 +48,4 @@ public/sygma-runtime-config* .vscode /dist -/examples \ No newline at end of file +/examples diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..364dd255 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + "packages/widget": "0.1.0" +} \ No newline at end of file diff --git a/.yarnrc.yml b/.yarnrc.yml index d00f6b19..f3818cf1 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -4,6 +4,4 @@ enableGlobalCache: true nodeLinker: node-modules -yarnPath: .yarn/releases/yarn-4.0.1.cjs - -checksumBehavior: update +yarnPath: .yarn/releases/yarn-4.0.1.cjs \ No newline at end of file diff --git a/package.json b/package.json index 51a61ee2..9efdd42f 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@buildwithsygma/sygma-widget", + "name": "root", "description": "Sygma Widget Monorepo", "version": "1.0.0", "main": "index.js", @@ -19,30 +19,29 @@ "node": ">=16.0.0" }, "devDependencies": { - "@babel/core": "^7.22.20", - "@typescript-eslint/eslint-plugin": "^6.6.0", - "@typescript-eslint/parser": "^6.6.0", + "@chainsafe/eslint-config": "^2.1.1", "eslint": "^8.48.0", - "eslint-config-prettier": "^9.0.0", - "eslint-plugin-import": "^2.28.1", "eslint-plugin-lit": "^1.9.1", - "eslint-plugin-prettier": "^5.0.0", - "eslint-plugin-wc": "^2.0.2", - "prettier": "^3.0.3", "typescript": "^5.2.2" }, "packageManager": "yarn@4.0.1", "scripts": { - "build:wallet-manager": "yarn workspace @buildwithsygma/sygmaprotocol-wallet-manager clean && yarn workspace @buildwithsygma/sygmaprotocol-wallet-manager build", - "build:sdk-manager": "yarn workspace @buildwithsygma/sygmaprotocol-sdk-manager clean && yarn workspace @buildwithsygma/sygmaprotocol-sdk-manager build", - "build:widget": "yarn workspace @buildwithsygma/sygmaprotocol-widget clean && yarn workspace @buildwithsygma/sygmaprotocol-widget build", - "build:react-widget": "yarn workspace @buildwithsygma/sygmaprotocol-react-widget clean && yarn workspace @buildwithsygma/sygmaprotocol-react-widget build", - "build:all": "yarn build:wallet-manager && yarn build:sdk-manager && yarn build:widget && yarn build:react-widget", - "lint:wallet-manager": "yarn workspace @buildwithsygma/sygmaprotocol-wallet-manager lint && yarn workspace @buildwithsygma/sygmaprotocol-wallet-manager lint:fix", - "lint:sdk-manager": "yarn workspace @buildwithsygma/sygmaprotocol-sdk-manager lint && yarn workspace @buildwithsygma/sygmaprotocol-sdk-manager lint:fix", - "lint:widget": "yarn workspace @buildwithsygma/sygmaprotocol-widget lint && yarn workspace @buildwithsygma/sygmaprotocol-widget lint:fix", - "lint:react-widget": "yarn workspace @buildwithsygma/sygmaprotocol-react-widget lint && yarn workspace @buildwithsygma/sygmaprotocol-react-widget lint:fix", - "lint:all": "yarn lint:wallet-manager && yarn lint:sdk-manager && yarn lint:widget && yarn lint:react-widget", - "clean:all": "yarn workspace @buildwithsygma/sygmaprotocol-wallet-manager clean && yarn workspace @buildwithsygma/sygmaprotocol-sdk-manager clean && yarn workspace @buildwithsygma/sygmaprotocol-widget clean && yarn workspace @buildwithsygma/sygmaprotocol-react-widget clean" + "demo": "yarn workspace @buildwithsygma/sygmaprotocol-widget run dev", + "clean": "yarn workspaces foreach --all -pt run clean", + "build": "yarn workspaces foreach --all -pt run build", + "lint": "yarn workspaces foreach --all -pt run lint", + "test:unit": "yarn workspaces foreach --all -pt run test:unit", + "build:widget": "yarn workspace @buildwithsygma/sygmaprotocol-widget build", + "build:react-widget": "yarn workspace @buildwithsygma/sygmaprotocol-react-widget build", + "lint:widget": "yarn workspace @buildwithsygma/sygmaprotocol-widget lint", + "lint:react-widget": "yarn workspace @buildwithsygma/sygmaprotocol-react-widget lint" + }, + "resolutions": { + "@polkadot/api": "10.7.2", + "@polkadot/util": "12.5.1", + "@polkadot/util-crypto": "12.5.1", + "@polkadot/wasm-bridge": "7.2.2", + "@polkadot/keyring": "12.5.1", + "@polkadot/wasm-crypto": "7.2.2" } } diff --git a/packages/react/.eslintrc.json b/packages/react/.eslintrc.json new file mode 100644 index 00000000..8a8dc6d1 --- /dev/null +++ b/packages/react/.eslintrc.json @@ -0,0 +1,6 @@ +{ + "extends": "../../.eslintrc.json", + "parserOptions": { + "project": "./tsconfig.json" + } +} \ No newline at end of file diff --git a/packages/react/package.json b/packages/react/package.json index 749b7801..d8b83364 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,7 +1,7 @@ { "name": "@buildwithsygma/sygmaprotocol-react-widget", "description": "Sygma Protocol Widget", - "version": "1.0.0", + "version": "0.1.0", "main": "build/index.js", "module": "build/index.js", "license": "LGPL-3.0-or-later", diff --git a/packages/sdk-manager/.gitignore b/packages/sdk-manager/.gitignore deleted file mode 100644 index 5d7b14bf..00000000 --- a/packages/sdk-manager/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local -build - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/packages/sdk-manager/.npmignore b/packages/sdk-manager/.npmignore deleted file mode 100644 index 9500451d..00000000 --- a/packages/sdk-manager/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -tsconfig.json -.DS_Store -node_modules/** -src/** -./vite.config.ts \ No newline at end of file diff --git a/packages/sdk-manager/CHANGELOG.md b/packages/sdk-manager/CHANGELOG.md deleted file mode 100644 index bfe78ebf..00000000 --- a/packages/sdk-manager/CHANGELOG.md +++ /dev/null @@ -1,24 +0,0 @@ -# Changelog - -## 0.0.1 (2023-12-14) - - -### Features - -* EmvWallet class base implementation ([74c9649](https://github.com/sygmaprotocol/sygma-widget/commit/74c96492dba784524891dfa04ca3314c69a36370)) -* SDK Manager package ([#25](https://github.com/sygmaprotocol/sygma-widget/issues/25)) ([f9a8793](https://github.com/sygmaprotocol/sygma-widget/commit/f9a87932f5ffe7961c551e644ff20e2293fa4816)) - - -### Bug Fixes - -* fix sygma namespace ([f9ab963](https://github.com/sygmaprotocol/sygma-widget/commit/f9ab9637ea2b797086cee6c0a12b046e3cb2e14c)) - - -### Miscellaneous - -* folder structure for the packages ([c41a2bc](https://github.com/sygmaprotocol/sygma-widget/commit/c41a2bcc1647114bdc944f0677e6802fd908e76f)) -* **main:** release 0.0.1 ([8cff038](https://github.com/sygmaprotocol/sygma-widget/commit/8cff038e5ec68039a2b3ff0301f9d7d4b63d9f61)) -* **main:** release wallet-manager 0.1.0 ([076ffa3](https://github.com/sygmaprotocol/sygma-widget/commit/076ffa31ef8a5d49129ab11beba084e2086e5ec5)) -* scripts and adding some stuff to gitignores ([c60f73e](https://github.com/sygmaprotocol/sygma-widget/commit/c60f73ebc6c402fdd4a390236cf2cf2c61741ec9)) -* setup for modern yarn and pipelines to check building phase ([3ffdae4](https://github.com/sygmaprotocol/sygma-widget/commit/3ffdae46e876b65e160f8ead0eab0aa51796e2f0)) -* setup pipelines ([#9](https://github.com/sygmaprotocol/sygma-widget/issues/9)) ([576b4c5](https://github.com/sygmaprotocol/sygma-widget/commit/576b4c59592e83a6c64a7159d0ef5e3f7b812b63)) diff --git a/packages/sdk-manager/package.json b/packages/sdk-manager/package.json deleted file mode 100644 index ff30ebdf..00000000 --- a/packages/sdk-manager/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "@buildwithsygma/sygmaprotocol-sdk-manager", - "description": "Sygma Protocol Widget", - "version": "0.0.1", - "main": "build/index.js", - "module": "build/index.js", - "license": "LGPL-3.0-or-later", - "type": "module", - "types": "./build/index.d.ts", - "scripts": { - "build": "tsc --build --clean && tsc --build ./tsconfig.json", - "dev": "tsc --build --clean && tsc --build ./tsconfig.json --watch", - "clean": "rm -rf ./build", - "lint": "eslint 'src/**/*.ts'", - "lint:fix": "yarn run lint --fix" - }, - "author": "Sygmaprotocol Product Team", - "dependencies": { - "@buildwithsygma/sygma-sdk-core": "2.4.0", - "@ethersproject/contracts": "^5.7.0", - "@ethersproject/transactions": "^5.7.0", - "@lit/context": "1.0.0", - "@polkadot/api": "10.7.2", - "lit": "3.0.0" - }, - "devDependencies": { - "@polkadot/types": "10.7.2", - "typescript": "^5.2.2" - } -} diff --git a/packages/sdk-manager/tsconfig.json b/packages/sdk-manager/tsconfig.json deleted file mode 100644 index 6bcac6f7..00000000 --- a/packages/sdk-manager/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "rootDir": "./src", - "outDir": "build", - "declaration": true - }, - "include": ["./src/**/*"] -} diff --git a/packages/sdk-manager/vite.config.ts b/packages/sdk-manager/vite.config.ts deleted file mode 100644 index 0f492924..00000000 --- a/packages/sdk-manager/vite.config.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { PluginOption, defineConfig } from 'vite'; -import { resolve } from 'path'; -import { visualizer } from "rollup-plugin-visualizer"; - -// https://vitejs.dev/config/ -export default defineConfig({ - base: '/', - build: { - outDir: 'build', - lib: { - entry: 'src/index.ts', - formats: ['es'] - }, - manifest: true, - rollupOptions: { - input: { - main: resolve(__dirname, 'index.html') - }, - plugins: [ - visualizer({ - template: 'sunburst', // or sunburst - open: false, - gzipSize: true, - brotliSize: true, - filename: 'bundle/analyse.html' // will be saved in project's root - }) as PluginOption - ] - } - } -}); diff --git a/packages/wallet-manager/.gitignore b/packages/wallet-manager/.gitignore deleted file mode 100644 index 5d7b14bf..00000000 --- a/packages/wallet-manager/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* -lerna-debug.log* - -node_modules -dist -dist-ssr -*.local -build - -# Editor directories and files -.vscode/* -!.vscode/extensions.json -.idea -.DS_Store -*.suo -*.ntvs* -*.njsproj -*.sln -*.sw? diff --git a/packages/wallet-manager/.npmignore b/packages/wallet-manager/.npmignore deleted file mode 100644 index 9500451d..00000000 --- a/packages/wallet-manager/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -tsconfig.json -.DS_Store -node_modules/** -src/** -./vite.config.ts \ No newline at end of file diff --git a/packages/wallet-manager/CHANGELOG.md b/packages/wallet-manager/CHANGELOG.md deleted file mode 100644 index 61e29cf5..00000000 --- a/packages/wallet-manager/CHANGELOG.md +++ /dev/null @@ -1,121 +0,0 @@ -# Changelog - -## [0.1.0](https://github.com/sygmaprotocol/sygma-widget/compare/sygmaprotocol-wallet-manager-v0.0.1...sygmaprotocol-wallet-manager-v0.1.0) (2023-12-14) - - -### Features - -* SDK Manager package ([#25](https://github.com/sygmaprotocol/sygma-widget/issues/25)) ([f9a8793](https://github.com/sygmaprotocol/sygma-widget/commit/f9a87932f5ffe7961c551e644ff20e2293fa4816)) - -## 0.0.1 (2023-12-01) - - -### Features - -* base implementation for context provider ([8c9b14b](https://github.com/sygmaprotocol/sygma-widget/commit/8c9b14b8b4926bdb31c3fa089786ffce527be6b5)) -* base implementation for reactive controller of wallet manager ([08e7d70](https://github.com/sygmaprotocol/sygma-widget/commit/08e7d70d01b775599aa8d6020c250063d108bf9a)) -* basic implementation for wallet classes ([fe0dc5d](https://github.com/sygmaprotocol/sygma-widget/commit/fe0dc5d43255085eb1274aa10ea7fc27385fe4a8)) -* EmvWallet class base implementation ([74c9649](https://github.com/sygmaprotocol/sygma-widget/commit/74c96492dba784524891dfa04ca3314c69a36370)) -* init of providers ([e41ebd4](https://github.com/sygmaprotocol/sygma-widget/commit/e41ebd44e8167f66f5f5b11123b9584cbd27456e)) -* public methods to react to change of account and network ([c90ab38](https://github.com/sygmaprotocol/sygma-widget/commit/c90ab380eed82d0b25170dc1021a9951b27660a3)) -* small adition to readme + fix test ([3f09616](https://github.com/sygmaprotocol/sygma-widget/commit/3f09616bb0eaa6bd193f128ae0411ae580853bc0)) -* substrate wallet class base implementation and some fixes for Evm wallet ([e6caa8d](https://github.com/sygmaprotocol/sygma-widget/commit/e6caa8d4dfdea40fe61f71162740f266ad350be4)) -* wallet package readme ([6607153](https://github.com/sygmaprotocol/sygma-widget/commit/6607153da5fde66dfd4ccc9ca684a8a12ef0b0ea)) - - -### Bug Fixes - -* fix readme ([3694e83](https://github.com/sygmaprotocol/sygma-widget/commit/3694e83f24ab329d78f0c13306374d699b1c21b5)) -* fix sygma namespace ([f9ab963](https://github.com/sygmaprotocol/sygma-widget/commit/f9ab9637ea2b797086cee6c0a12b046e3cb2e14c)) - - -### Miscellaneous - -* addressing comments on pr review ([b099ce9](https://github.com/sygmaprotocol/sygma-widget/commit/b099ce9d9582c9a4649c290759874fff91e80798)) -* basic tests for the reactive controller ([8697e81](https://github.com/sygmaprotocol/sygma-widget/commit/8697e81ff38560cb32172bafaa5f10b8509d7de1)) -* change method names ([d002ac2](https://github.com/sygmaprotocol/sygma-widget/commit/d002ac2b97a1b47481bb26763724ba8b34e9d72c)) -* change name of the context provider ([c3ab7da](https://github.com/sygmaprotocol/sygma-widget/commit/c3ab7da80b4449a87e2c65828eef6c94252e3015)) -* changes to version ([964c39d](https://github.com/sygmaprotocol/sygma-widget/commit/964c39dc7e85033d44c64ad1dd562f0152964d85)) -* changing to removeAllListeners ([fba19a5](https://github.com/sygmaprotocol/sygma-widget/commit/fba19a544657cf93376edf3ff18c5306fd80a309)) -* default parameter for network value ([7b90cae](https://github.com/sygmaprotocol/sygma-widget/commit/7b90caed4962e77bdec05d0a47dba060c1b82b3d)) -* ethers and lit context as peer dependencies ([797c073](https://github.com/sygmaprotocol/sygma-widget/commit/797c07323e433947d89d2efba7d6123e017bbd38)) -* ethers as peer dependency and update on lock file ([98d0120](https://github.com/sygmaprotocol/sygma-widget/commit/98d012096952fc49e4e1c03cdb3b93d6c270dc9c)) -* fixating dependencies ([2c5ad0a](https://github.com/sygmaprotocol/sygma-widget/commit/2c5ad0a993785ef1526fb70c2b0615148444ae99)) -* fixing and adding some more basic tests ([ab3e13f](https://github.com/sygmaprotocol/sygma-widget/commit/ab3e13fd913e77655f33bf89d58b025ca9c7e6dc)) -* folder structure for the packages ([c41a2bc](https://github.com/sygmaprotocol/sygma-widget/commit/c41a2bcc1647114bdc944f0677e6802fd908e76f)) -* handling error when connection to provider is rejected and some docs improvements ([d295070](https://github.com/sygmaprotocol/sygma-widget/commit/d295070b89013e71f3318d57d10c1db1ab18e229)) -* init wallet manager on connectedCallback and not the constructor ([47302b8](https://github.com/sygmaprotocol/sygma-widget/commit/47302b808683f31d8bd4b9bd2f22ee37e4c61cac)) -* lit context back to dependency definition ([95b496d](https://github.com/sygmaprotocol/sygma-widget/commit/95b496dadacbf56e64d746f6cc0395be78272e32)) -* **main:** release 0.0.1 ([8cff038](https://github.com/sygmaprotocol/sygma-widget/commit/8cff038e5ec68039a2b3ff0301f9d7d4b63d9f61)) -* **main:** release wallet-manager 0.1.0 ([4c0e739](https://github.com/sygmaprotocol/sygma-widget/commit/4c0e739fc615de2f9db6ac02fb8e1588b11ba974)) -* **main:** release wallet-manager 0.1.0 ([076ffa3](https://github.com/sygmaprotocol/sygma-widget/commit/076ffa31ef8a5d49129ab11beba084e2086e5ec5)) -* **main:** release wallet-manager 1.0.0 ([179d343](https://github.com/sygmaprotocol/sygma-widget/commit/179d3432616e590cd170a7064633943cf4eeab76)) -* moving synthetic event creator as util function and removing it from context ([1386eb8](https://github.com/sygmaprotocol/sygma-widget/commit/1386eb883b80fb5627cadd8227383152841ff0b8)) -* pr review ([a4cfef5](https://github.com/sygmaprotocol/sygma-widget/commit/a4cfef54b2e125efe1ef5067ca56ca329fe8b403)) -* pr review last comments ([3fdf418](https://github.com/sygmaprotocol/sygma-widget/commit/3fdf41892a217dd596caf8e76051640e6218ac6a)) -* PR review, changes on constructor implementation ([244bc78](https://github.com/sygmaprotocol/sygma-widget/commit/244bc78fe97038b84fd569db408708afaec91e78)) -* readme addition ([295af80](https://github.com/sygmaprotocol/sygma-widget/commit/295af80321858a2db48dcba1ab3e0267ce522f13)) -* removing js docs comments, adding yarn folder to the gitignore ([40592ce](https://github.com/sygmaprotocol/sygma-widget/commit/40592ce955e3f9162e644329f3bb62e0f0e51362)) -* removing static methods to instantiate evm wallet class ([556c825](https://github.com/sygmaprotocol/sygma-widget/commit/556c825b80c4dd6abfcf33c9423837ba83cc5084)) -* rename networks property to network ([9405bd5](https://github.com/sygmaprotocol/sygma-widget/commit/9405bd5b207d1e99fa6cb1ae11de9768b97fe913)) -* scripts and adding some stuff to gitignores ([c60f73e](https://github.com/sygmaprotocol/sygma-widget/commit/c60f73ebc6c402fdd4a390236cf2cf2c61741ec9)) -* setup for modern yarn and pipelines to check building phase ([3ffdae4](https://github.com/sygmaprotocol/sygma-widget/commit/3ffdae46e876b65e160f8ead0eab0aa51796e2f0)) -* setup pipelines ([#9](https://github.com/sygmaprotocol/sygma-widget/issues/9)) ([576b4c5](https://github.com/sygmaprotocol/sygma-widget/commit/576b4c59592e83a6c64a7159d0ef5e3f7b812b63)) -* update Evm base class ([5149995](https://github.com/sygmaprotocol/sygma-widget/commit/5149995b2a27a1a8c62468d3186a823675d74520)) -* update on tsconfig and lock file ([fa18c10](https://github.com/sygmaprotocol/sygma-widget/commit/fa18c10a277326028bea743ca8473c3d01023b83)) -* update package and lock file with vitest ([94fd2b0](https://github.com/sygmaprotocol/sygma-widget/commit/94fd2b0e5d26970c0bcdba5993f8a5baeed40edf)) -* update tests ([43666c3](https://github.com/sygmaprotocol/sygma-widget/commit/43666c301f7b2215932c6653195ba5959bbba22b)) - -## [0.1.0](https://github.com/sygmaprotocol/sygma-widget/compare/wallet-manager-v1.0.0...wallet-manager-v0.1.0) (2023-11-29) - - -### Features - -* base implementation for context provider ([8c9b14b](https://github.com/sygmaprotocol/sygma-widget/commit/8c9b14b8b4926bdb31c3fa089786ffce527be6b5)) -* base implementation for reactive controller of wallet manager ([08e7d70](https://github.com/sygmaprotocol/sygma-widget/commit/08e7d70d01b775599aa8d6020c250063d108bf9a)) -* basic implementation for wallet classes ([fe0dc5d](https://github.com/sygmaprotocol/sygma-widget/commit/fe0dc5d43255085eb1274aa10ea7fc27385fe4a8)) -* EmvWallet class base implementation ([74c9649](https://github.com/sygmaprotocol/sygma-widget/commit/74c96492dba784524891dfa04ca3314c69a36370)) -* init of providers ([e41ebd4](https://github.com/sygmaprotocol/sygma-widget/commit/e41ebd44e8167f66f5f5b11123b9584cbd27456e)) -* public methods to react to change of account and network ([c90ab38](https://github.com/sygmaprotocol/sygma-widget/commit/c90ab380eed82d0b25170dc1021a9951b27660a3)) -* substrate wallet class base implementation and some fixes for Evm wallet ([e6caa8d](https://github.com/sygmaprotocol/sygma-widget/commit/e6caa8d4dfdea40fe61f71162740f266ad350be4)) -* wallet package readme ([6607153](https://github.com/sygmaprotocol/sygma-widget/commit/6607153da5fde66dfd4ccc9ca684a8a12ef0b0ea)) - - -### Bug Fixes - -* fix sygma namespace ([f9ab963](https://github.com/sygmaprotocol/sygma-widget/commit/f9ab9637ea2b797086cee6c0a12b046e3cb2e14c)) - - -### Miscellaneous - -* addressing comments on pr review ([b099ce9](https://github.com/sygmaprotocol/sygma-widget/commit/b099ce9d9582c9a4649c290759874fff91e80798)) -* basic tests for the reactive controller ([8697e81](https://github.com/sygmaprotocol/sygma-widget/commit/8697e81ff38560cb32172bafaa5f10b8509d7de1)) -* change method names ([d002ac2](https://github.com/sygmaprotocol/sygma-widget/commit/d002ac2b97a1b47481bb26763724ba8b34e9d72c)) -* change name of the context provider ([c3ab7da](https://github.com/sygmaprotocol/sygma-widget/commit/c3ab7da80b4449a87e2c65828eef6c94252e3015)) -* changes to version ([964c39d](https://github.com/sygmaprotocol/sygma-widget/commit/964c39dc7e85033d44c64ad1dd562f0152964d85)) -* changing to removeAllListeners ([fba19a5](https://github.com/sygmaprotocol/sygma-widget/commit/fba19a544657cf93376edf3ff18c5306fd80a309)) -* default parameter for network value ([7b90cae](https://github.com/sygmaprotocol/sygma-widget/commit/7b90caed4962e77bdec05d0a47dba060c1b82b3d)) -* ethers and lit context as peer dependencies ([797c073](https://github.com/sygmaprotocol/sygma-widget/commit/797c07323e433947d89d2efba7d6123e017bbd38)) -* ethers as peer dependency and update on lock file ([98d0120](https://github.com/sygmaprotocol/sygma-widget/commit/98d012096952fc49e4e1c03cdb3b93d6c270dc9c)) -* fixating dependencies ([2c5ad0a](https://github.com/sygmaprotocol/sygma-widget/commit/2c5ad0a993785ef1526fb70c2b0615148444ae99)) -* fixing and adding some more basic tests ([ab3e13f](https://github.com/sygmaprotocol/sygma-widget/commit/ab3e13fd913e77655f33bf89d58b025ca9c7e6dc)) -* folder structure for the packages ([c41a2bc](https://github.com/sygmaprotocol/sygma-widget/commit/c41a2bcc1647114bdc944f0677e6802fd908e76f)) -* handling error when connection to provider is rejected and some docs improvements ([d295070](https://github.com/sygmaprotocol/sygma-widget/commit/d295070b89013e71f3318d57d10c1db1ab18e229)) -* init wallet manager on connectedCallback and not the constructor ([47302b8](https://github.com/sygmaprotocol/sygma-widget/commit/47302b808683f31d8bd4b9bd2f22ee37e4c61cac)) -* lit context back to dependency definition ([95b496d](https://github.com/sygmaprotocol/sygma-widget/commit/95b496dadacbf56e64d746f6cc0395be78272e32)) -* **main:** release wallet-manager 0.1.0 ([076ffa3](https://github.com/sygmaprotocol/sygma-widget/commit/076ffa31ef8a5d49129ab11beba084e2086e5ec5)) -* **main:** release wallet-manager 1.0.0 ([179d343](https://github.com/sygmaprotocol/sygma-widget/commit/179d3432616e590cd170a7064633943cf4eeab76)) -* moving synthetic event creator as util function and removing it from context ([1386eb8](https://github.com/sygmaprotocol/sygma-widget/commit/1386eb883b80fb5627cadd8227383152841ff0b8)) -* pr review ([a4cfef5](https://github.com/sygmaprotocol/sygma-widget/commit/a4cfef54b2e125efe1ef5067ca56ca329fe8b403)) -* pr review last comments ([3fdf418](https://github.com/sygmaprotocol/sygma-widget/commit/3fdf41892a217dd596caf8e76051640e6218ac6a)) -* PR review, changes on constructor implementation ([244bc78](https://github.com/sygmaprotocol/sygma-widget/commit/244bc78fe97038b84fd569db408708afaec91e78)) -* removing js docs comments, adding yarn folder to the gitignore ([40592ce](https://github.com/sygmaprotocol/sygma-widget/commit/40592ce955e3f9162e644329f3bb62e0f0e51362)) -* removing static methods to instantiate evm wallet class ([556c825](https://github.com/sygmaprotocol/sygma-widget/commit/556c825b80c4dd6abfcf33c9423837ba83cc5084)) -* rename networks property to network ([9405bd5](https://github.com/sygmaprotocol/sygma-widget/commit/9405bd5b207d1e99fa6cb1ae11de9768b97fe913)) -* scripts and adding some stuff to gitignores ([c60f73e](https://github.com/sygmaprotocol/sygma-widget/commit/c60f73ebc6c402fdd4a390236cf2cf2c61741ec9)) -* setup for modern yarn and pipelines to check building phase ([3ffdae4](https://github.com/sygmaprotocol/sygma-widget/commit/3ffdae46e876b65e160f8ead0eab0aa51796e2f0)) -* setup pipelines ([#9](https://github.com/sygmaprotocol/sygma-widget/issues/9)) ([576b4c5](https://github.com/sygmaprotocol/sygma-widget/commit/576b4c59592e83a6c64a7159d0ef5e3f7b812b63)) -* update Evm base class ([5149995](https://github.com/sygmaprotocol/sygma-widget/commit/5149995b2a27a1a8c62468d3186a823675d74520)) -* update on tsconfig and lock file ([fa18c10](https://github.com/sygmaprotocol/sygma-widget/commit/fa18c10a277326028bea743ca8473c3d01023b83)) -* update package and lock file with vitest ([94fd2b0](https://github.com/sygmaprotocol/sygma-widget/commit/94fd2b0e5d26970c0bcdba5993f8a5baeed40edf)) -* update tests ([43666c3](https://github.com/sygmaprotocol/sygma-widget/commit/43666c301f7b2215932c6653195ba5959bbba22b)) diff --git a/packages/wallet-manager/README.md b/packages/wallet-manager/README.md deleted file mode 100644 index 805e4723..00000000 --- a/packages/wallet-manager/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# SygmaProtocol Wallet Manager Package - -## Install - -```bash -yarn install @buildwithsygma/sygmaprotocol-wallet-manager -``` - -## Usage - -On lit component - -```bash - # Passing a web3Provider and an apiPromise - - - - - # Passing a wssConnectionUrl - - - -``` - -## Develop - -```bash -# Run this on the root of the monorepo -yarn install - -# cd to the package -cd ./packages/wallet-manager - -# start watch mode -yarn dev -``` - -## Build the package - -```bash -yarn lint -# if needed lint fix -yarn lint:fix - -yarn build -``` \ No newline at end of file diff --git a/packages/wallet-manager/package.json b/packages/wallet-manager/package.json deleted file mode 100644 index 75a0e164..00000000 --- a/packages/wallet-manager/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "@buildwithsygma/sygmaprotocol-wallet-manager", - "description": "Sygma Protocol Widget", - "version": "0.1.0", - "main": "build/index.js", - "module": "build/index.js", - "license": "LGPL-3.0-or-later", - "type": "module", - "types": "./build/index.d.ts", - "scripts": { - "build": "tsc --build --clean && tsc --build ./tsconfig.json", - "dev": "tsc --build --clean && tsc --build ./tsconfig.json --watch", - "clean": "rm -rf ./build", - "lint": "eslint 'src/**/*.ts'", - "lint:fix": "yarn run lint --fix", - "test": "vitest --config ./vite.config.ts" - }, - "author": "Sygmaprotocol Product Team", - "devDependencies": { - "@polkadot/types": "10.7.2", - "jsdom": "^22.1.0", - "typescript": "^5.2.2", - "vitest": "^0.34.5" - }, - "dependencies": { - "@ethersproject/abstract-signer": "5.7.0", - "@lit/context": "1.0.0", - "@polkadot/api": "10.7.2", - "@polkadot/extension-dapp": "0.46.5", - "lit": "3.0.0" - }, - "peerDependencies": { - "ethers": "*", - "events": "*" - } -} diff --git a/packages/wallet-manager/tsconfig.json b/packages/wallet-manager/tsconfig.json deleted file mode 100644 index c446ac7d..00000000 --- a/packages/wallet-manager/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "rootDir": "./src", - "outDir": "build", - "declaration": true - }, - "include": ["./src/**/*"], - "exclude": ["./src/**/*.test.ts"] -} diff --git a/packages/wallet-manager/vite.config.ts b/packages/wallet-manager/vite.config.ts deleted file mode 100644 index 2a9bf5d4..00000000 --- a/packages/wallet-manager/vite.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { defineConfig } from 'vitest/config'; - -export default defineConfig({ - test: { - environment: 'jsdom', - exclude: ['**/node_modules/**', '**/dist/**', '**/build/**'] - } -}); diff --git a/packages/widget/.eslintrc.json b/packages/widget/.eslintrc.json new file mode 100644 index 00000000..dda67430 --- /dev/null +++ b/packages/widget/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "plugins": [ + "lit" + ], + "extends": [ + "../../.eslintrc.json", + "plugin:lit/recommended" + ], + "parserOptions": { + "project": "./tsconfig.json" + } + } \ No newline at end of file diff --git a/packages/widget/package.json b/packages/widget/package.json index c7791763..250aa70a 100644 --- a/packages/widget/package.json +++ b/packages/widget/package.json @@ -1,41 +1,48 @@ { "name": "@buildwithsygma/sygmaprotocol-widget", "description": "Sygma Protocol Widget", - "version": "1.0.0", + "version": "0.1.0", "main": "build/index.js", "module": "build/index.js", "license": "LGPL-3.0-or-later", "type": "module", "scripts": { - "start": "npm run dev", + "start": "yarn run dev", "dev": "vite", - "build": "tsc && vite build", - "serve": "tsc && vite preview", + "build": "yarn run lint:types && yarn run clean && vite build", + "serve": "vite preview", "clean": "rm -rf ./build", - "lint": "eslint 'src/**/*.ts'", - "lint:fix": "yarn run lint --fix" + "lint": "yarn run lint:types && yarn run lint:code && yarn run lint:lit", + "lint:types": "tsc -p ./tsconfig.build.json --noEmit", + "lint:code": "eslint '{src,tests}/**/*.ts'", + "lint:lit": "lit-analyzer", + "test": "yarn run test:unit", + "test:unit": "vitest --run --config ./vite.config.ts" }, "author": "Sygmaprotocol Product Team", "dependencies": { - "@buildwithsygma/sygma-sdk-core": "2.6.0", - "@buildwithsygma/sygmaprotocol-sdk-manager": "*", - "@buildwithsygma/sygmaprotocol-wallet-manager": "*", - "@lit/context": "1.0.0", - "@lit/reactive-element": "2.0.0", + "@buildwithsygma/sygma-sdk-core": "^2.6.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/contracts": "^5.7.0", + "@ethersproject/providers": "^5.7.2", + "@ethersproject/transactions": "^5.7.0", + "@lit/context": "^1.1.0", + "@lit/reactive-element": "^2.0.3", + "@polkadot/api": "^10.11.2", + "@polkadot/extension-dapp": "^0.46.6", "ethers": "5.7.2", "events": "^3.3.0", "lit": "3.0.0" }, "devDependencies": { - "@types/node": "20.8.4", "eslint": "^8.48.0", - "eslint-config-prettier": "^9.0.0", - "eslint-plugin-import": "^2.28.1", "eslint-plugin-lit": "^1.9.1", - "eslint-plugin-prettier": "^5.0.0", - "eslint-plugin-wc": "^2.0.2", + "jsdom": "^23.2.0", + "lit-analyzer": "^2.0.3", "rollup-plugin-visualizer": "^5.9.2", "typescript": "5.2.2", - "vite": "4.4.11" + "vite": "4.4.11", + "vite-plugin-clean": "^1.0.0", + "vitest": "^1.2.1" } } diff --git a/packages/widget/src/components/amount-selector/amount-selector.ts b/packages/widget/src/components/amount-selector/amount-selector.ts index 544d00b2..5d80cb20 100644 --- a/packages/widget/src/components/amount-selector/amount-selector.ts +++ b/packages/widget/src/components/amount-selector/amount-selector.ts @@ -1,10 +1,12 @@ -import { Resource } from '@buildwithsygma/sygma-sdk-core'; +import type { Resource } from '@buildwithsygma/sygma-sdk-core'; +import type { HTMLTemplateResult } from 'lit'; import { LitElement, html } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; -import { styles } from './styles'; -import { when } from 'lit/directives/when.js'; import { ifDefined } from 'lit/directives/if-defined.js'; -import { Ref, createRef, ref } from 'lit/directives/ref.js'; +import type { Ref } from 'lit/directives/ref.js'; +import { createRef, ref } from 'lit/directives/ref.js'; +import { when } from 'lit/directives/when.js'; +import { styles } from './styles'; @customElement('amount-selector') export default class AmountSelector extends LitElement { @@ -32,7 +34,7 @@ export default class AmountSelector extends LitElement { selectedNetworkChainId?: number; @property({ - type: Number + type: String }) tokenBalance?: string; @@ -48,7 +50,7 @@ export default class AmountSelector extends LitElement { inputRef: Ref = createRef(); - handleAmountChange(event: Event): void { + handleAmountChange = (event: Event): void => { const { value } = event.target as HTMLInputElement; this.selectedAmount = Number.parseFloat(value); @@ -60,9 +62,9 @@ export default class AmountSelector extends LitElement { composed: true }) ); - } + }; - useMaxBalance() { + useMaxBalance = (): void => { this.selectedAmount = Number.parseFloat(this.tokenBalance!); (this.inputRef.value as HTMLInputElement).value = `${this.selectedAmount}`; @@ -71,9 +73,9 @@ export default class AmountSelector extends LitElement { }); this.inputRef.value?.dispatchEvent(event); - } + }; - renderBalance() { + renderBalance(): HTMLTemplateResult { return html`
${`${Number.parseFloat(this.tokenBalance!).toFixed(4)}`} @@ -82,7 +84,7 @@ export default class AmountSelector extends LitElement { `; } - render() { + render(): HTMLTemplateResult { return html`
diff --git a/packages/widget/src/components/base-selector/base-selector.ts b/packages/widget/src/components/base-selector/base-selector.ts index 3ee5f83b..eb2e3010 100644 --- a/packages/widget/src/components/base-selector/base-selector.ts +++ b/packages/widget/src/components/base-selector/base-selector.ts @@ -1,15 +1,16 @@ -import { Domain, Resource } from '@buildwithsygma/sygma-sdk-core'; +import type { Domain, Resource } from '@buildwithsygma/sygma-sdk-core'; +import type { HTMLTemplateResult } from 'lit'; import { LitElement, html } from 'lit'; import { customElement, property } from 'lit/decorators.js'; +import { ifDefined } from 'lit/directives/if-defined.js'; import { map } from 'lit/directives/map.js'; import { when } from 'lit/directives/when.js'; -import { styles } from './styles'; import { capitalize, renderNetworkIcon, renderNoNetworkIcon } from '../../utils'; -import { ifDefined } from 'lit/directives/if-defined.js'; +import { styles } from './styles'; @customElement('base-selector') export default class BaseSelector extends LitElement { @@ -50,8 +51,7 @@ export default class BaseSelector extends LitElement { }) homechain?: Domain; - // eslint-disable-next-line class-methods-use-this - onChange(event: Event): void { + onChange = (event: Event): void => { const { value } = event.target as HTMLInputElement; if (this.typeSelector === 'network') { dispatchEvent( @@ -70,9 +70,9 @@ export default class BaseSelector extends LitElement { }) ); } - } + }; - renderEntries() { + renderEntries(): Generator | HTMLTemplateResult { if (this.entries) { return map(this.entries, (entry: Domain | Resource, index: number) => { if (index === 0) { @@ -105,7 +105,7 @@ export default class BaseSelector extends LitElement { `; } - render() { + render(): HTMLTemplateResult { return html`
${when( @@ -115,12 +115,14 @@ export default class BaseSelector extends LitElement { console.log( !!(this.selectedNetworkChainId && this.entries?.length) ); + return when( !!( this.selectedNetworkChainId && (this.entries?.length || this.homechain) ), () => renderNetworkIcon(this.selectedNetworkChainId as number), + () => renderNoNetworkIcon() ); } diff --git a/packages/widget/src/components/network-selector/network-selector.ts b/packages/widget/src/components/network-selector/network-selector.ts index b8402b71..ab86663c 100644 --- a/packages/widget/src/components/network-selector/network-selector.ts +++ b/packages/widget/src/components/network-selector/network-selector.ts @@ -1,11 +1,12 @@ -import { LitElement, html } from 'lit'; -import { customElement, property } from 'lit/decorators.js'; -import { +import type { EthereumConfig, SubstrateConfig } from '@buildwithsygma/sygma-sdk-core'; -import { styles } from './styles'; +import type { HTMLTemplateResult } from 'lit'; +import { LitElement, html } from 'lit'; +import { customElement, property } from 'lit/decorators.js'; import '../base-selector'; +import { styles } from './styles'; const directions = { from: 'From', @@ -54,7 +55,7 @@ export default class NetworkSelector extends LitElement { }) disabled = false; - render() { + render(): HTMLTemplateResult { return html`