diff --git a/.github/workflows/branch-release.yaml b/.github/workflows/branch-release.yaml new file mode 100644 index 0000000..141318c --- /dev/null +++ b/.github/workflows/branch-release.yaml @@ -0,0 +1,72 @@ +name: Branch Release + +on: + push: + branches: + - '**' + - '!main' + +jobs: + branch-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history to get the latest tag + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: latest + + - name: Cache pnpm modules + uses: actions/cache@v4 + with: + path: | + ~/.pnpm-store + node_modules + src/playground/node_modules + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm- + + - name: Install Dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm run build + + - name: Set Version from Branch + run: | + BRANCH_NAME=${GITHUB_REF#refs/heads/} + BRANCH_NAME=${BRANCH_NAME//\//-} # Replace slashes with dashes + SHORT_SHA=$(git rev-parse --short HEAD) + + # Get the latest version tag and increment patch + LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") + LATEST_VERSION=${LATEST_TAG#v} # Remove 'v' prefix + + # Split version into major.minor.patch + IFS='.' read -r major minor patch <<< "$LATEST_VERSION" + + # Increment patch version + patch=$((patch + 1)) + BASE_VERSION="${major}.${minor}.${patch}" + + VERSION="${BASE_VERSION}-${BRANCH_NAME}-${SHORT_SHA}" + pnpm version $VERSION --no-git-tag-version + + - name: Configure NPM Authentication + run: | + echo "@bitte-ai:registry=https://registry.npmjs.org/" > ~/.npmrc + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc + + - name: Publish with npm + run: npm publish --access public --tag beta + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index b512c09..76add87 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +dist \ No newline at end of file diff --git a/package.json b/package.json index a8e3927..c29ac8c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bitte-ai/wallet", - "version": "0.7.0", + "version": "0.7.2-beta", "description": "Bitte Wallet", "keywords": [ "bitte", @@ -15,15 +15,16 @@ "exports": { ".": { "types": "./dist/index.d.ts", + "require": "./dist/index.js", "import": "./dist/index.mjs", - "require": "./dist/index.js" + "default": "./dist/index.mjs" } }, "files": [ "dist" ], - "main": "dist/index.cjs.js", - "module": "dist/index.esm.js", + "main": "dist/index.js", + "module": "dist/index.mjs.js", "types": "dist/index.d.ts", "publishConfig": { "access": "public" @@ -31,12 +32,12 @@ "author": "Bitte Team", "license": "MIT", "dependencies": { - "@near-wallet-selector/core": "^8.9.16", - "@near-wallet-selector/wallet-utils": "^8.9.16", - "near-api-js": "^5.0.1" + "@near-wallet-selector/core": "^8.10.1", + "@near-wallet-selector/wallet-utils": "^8.10.1", + "near-api-js": "^5.1.1" }, "devDependencies": { "tsup": "^8.3.5", "typescript": "^5.7.3" } -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d1ebc04..2caa48d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,14 +9,14 @@ importers: .: dependencies: '@near-wallet-selector/core': - specifier: ^8.9.16 - version: 8.9.16(near-api-js@5.0.1) + specifier: ^8.10.1 + version: 8.10.1(near-api-js@5.1.1) '@near-wallet-selector/wallet-utils': - specifier: ^8.9.16 - version: 8.9.16(near-api-js@5.0.1) + specifier: ^8.10.1 + version: 8.10.1(near-api-js@5.1.1) near-api-js: - specifier: ^5.0.1 - version: 5.0.1 + specifier: ^5.1.1 + version: 5.1.1 devDependencies: tsup: specifier: ^8.3.5 @@ -199,60 +199,61 @@ packages: '@jridgewell/trace-mapping@0.3.25': resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} - '@near-js/accounts@1.3.1': - resolution: {integrity: sha512-LAUN5L31JKtuXD9xS6D98GLtjG8KL9z761RvTYH6FMAwTFiyPed2M65mKNThGj3Zq46vWRGML0rJ2rlnXvewrA==} + '@near-js/accounts@1.4.1': + resolution: {integrity: sha512-ni3QT9H3NdrbVVKyx56yvz93r89Dvpc/vgVtiIK2OdXjkK6jcj+UKMDRQ6F7rd9qJOInLkHZbVBtcR6j1CXLjw==} - '@near-js/crypto@1.4.1': - resolution: {integrity: sha512-hbricJD0H8nwu63Zw16UZQg3ms2W9NwDBsLt3OEtudTcu9q1MRrVZWc7ATjdmTvhkcgmouEFc6oLBsOxnmSLCA==} + '@near-js/crypto@1.4.2': + resolution: {integrity: sha512-GRfchsyfWvSAPA1gI9hYhw5FH94Ac1BUo+Cmp5rSJt/V0K3xVzCWgOQxvv4R3kDnWjaXJEuAmpEEnr4Bp3FWrA==} - '@near-js/keystores-browser@0.2.1': - resolution: {integrity: sha512-wF7UUDccnkVxdWqVgladupiXkrBmxNK9ilZg6zg9a11xtrDUpnjmWF4ON4tl1lJWF0XdTJmGdOrgOQZQDBQ79g==} + '@near-js/keystores-browser@0.2.2': + resolution: {integrity: sha512-Pxqm7WGtUu6zj32vGCy9JcEDpZDSB5CCaLQDTQdF3GQyL0flyRv2I/guLAgU5FLoYxU7dJAX9mslJhPW7P2Bfw==} - '@near-js/keystores-node@0.1.1': - resolution: {integrity: sha512-ht69dVB0IAX2RckOlBCCTxl7e8X29EYqgL4KE83Sg+cAwsQctAjVLpor5RbgJhg1iYY5BhIK5JgI0pTOJRAHxA==} + '@near-js/keystores-node@0.1.2': + resolution: {integrity: sha512-MWLvTszZOVziiasqIT/LYNhUyWqOJjDGlsthOsY6dTL4ZcXjjmhmzrbFydIIeQr+CcEl5wukTo68ORI9JrHl6g==} - '@near-js/keystores@0.2.1': - resolution: {integrity: sha512-KTeqSB+gx5LZNC9VGtHDe+aEiJts6e3nctMnnn/gqIgvW7KJ+BzcmTZZpxCmQLcy+s7hHSpzmyTVRkaCuYjCcQ==} + '@near-js/keystores@0.2.2': + resolution: {integrity: sha512-DLhi/3a4qJUY+wgphw2Jl4S+L0AKsUYm1mtU0WxKYV5OBwjOXvbGrXNfdkheYkfh3nHwrQgtjvtszX6LrRXLLw==} - '@near-js/providers@1.0.1': - resolution: {integrity: sha512-a1rU+JjTes/fdpnP/SLRQuWAK80os1DoHw2sszg/ccA9byTdI/CM6eKinrWJrO5i86IARfigOgjCJhrzPscvuQ==} + '@near-js/providers@1.0.3': + resolution: {integrity: sha512-VJMboL14R/+MGKnlhhE3UPXCGYvMd1PpvF9OqZ9yBbulV7QVSIdTMfY4U1NnDfmUC2S3/rhAEr+3rMrIcNS7Fg==} - '@near-js/signers@0.2.1': - resolution: {integrity: sha512-l1PnUy4e8NQe5AAHs7mEuWbbUt0rrsZLtcK1UlFaA16MKZmxXdHLMBfUmzyMA4bGzwkyUyGtIebkR+KjBfpEog==} + '@near-js/signers@0.2.2': + resolution: {integrity: sha512-M6ib+af9zXAPRCjH2RyIS0+RhCmd9gxzCeIkQ+I2A3zjgGiEDkBZbYso9aKj8Zh2lPKKSH7h+u8JGymMOSwgyw==} - '@near-js/transactions@1.3.1': - resolution: {integrity: sha512-kL9hxUqBr+tILQHFsh5T/bz3UkJrAq5tnyFqh0xf+7qGXZuRIPfuW/HMq4M6wFw0MGi/8ycmDT3yTQFH7PzZqw==} + '@near-js/transactions@1.3.3': + resolution: {integrity: sha512-1AXD+HuxlxYQmRTLQlkVmH+RAmV3HwkAT8dyZDu+I2fK/Ec9BQHXakOJUnOBws3ihF+akQhamIBS5T0EXX/Ylw==} '@near-js/types@0.3.1': resolution: {integrity: sha512-8qIA7ynAEAuVFNAQc0cqz2xRbfyJH3PaAG5J2MgPPhD18lu/tCGd6pzYg45hjhtiJJRFDRjh/FUWKS+ZiIIxUw==} - '@near-js/utils@1.0.1': - resolution: {integrity: sha512-MzCAspVJJLrURnSbq059s6cWon2/qbbBVl+Ib1yBOMTs/6EuJ7GRvuSmtmSB7l9Hjjmz8Imn1aB2q3RVYZSbrA==} + '@near-js/utils@1.1.0': + resolution: {integrity: sha512-5XWRq7xpu8Wud9pRXe2U347KXyi0mXofedUY2DQ9TaqiZUcMIaN9xj7DbCs2v6dws3pJyYrT1KWxeNp5fSaY3w==} - '@near-js/wallet-account@1.3.1': - resolution: {integrity: sha512-POOKarJnYsTK0zEXygm43ecGlraPl5qagQHl+By5bk0zQFgeKaoFIJK/n04xUoGBhZTBIVp1/q7q3O1pB57hqg==} + '@near-js/wallet-account@1.3.3': + resolution: {integrity: sha512-GDzg/Kz0GBYF7tQfyQQQZ3vviwV8yD+8F2lYDzsWJiqIln7R1ov0zaXN4Tii86TeS21KPn2hHAsVu3Y4txa8OQ==} - '@near-wallet-selector/core@8.9.16': - resolution: {integrity: sha512-Bq+bZvwpsYgs8g4mtDMEMUpHwD/+VlHY3hj5pLv6o6C/3Ym0/540/8ydd9VUhMsdpY0Dhv2SLamKiL6PJK6THA==} + '@near-wallet-selector/core@8.10.1': + resolution: {integrity: sha512-FHZNLIPF3Qvj2M8cwyeHFH0Gwq58q7ibw02r+TkekyzZgXESvd/kU/OcF11T4r3WG1OrHPiZay7XXeAwDc9Txw==} peerDependencies: near-api-js: ^4.0.0 || ^5.0.0 - '@near-wallet-selector/wallet-utils@8.9.16': - resolution: {integrity: sha512-/qIaazrYMZ240eCYpW4SV35Yspe2Ba/NY9Z3f5aodQBZSI9QvjzZxQkxux68JuPt4J2+c9oKKK4XvbFqYP/aSQ==} + '@near-wallet-selector/wallet-utils@8.10.1': + resolution: {integrity: sha512-1NxFCGo7bo+CiKOOS4yjSAwAfnjhYYXo3i1UCuu4MhHrQS+EvwMCxCadUKSNGXn1IC1TpKmWMVaENkv7gWKlZQ==} peerDependencies: near-api-js: ^4.0.0 || ^5.0.0 - '@noble/curves@1.2.0': - resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} - - '@noble/hashes@1.3.2': - resolution: {integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==} - engines: {node: '>= 16'} + '@noble/curves@1.8.1': + resolution: {integrity: sha512-warwspo+UYUPep0Q+vtdVB4Ugn8GGQj8iyB3gnRWsztmUHTI3S1nhdiWNsPUGL0vud7JlRRk1XEu7Lq1KGTnMQ==} + engines: {node: ^14.21.3 || >=16} '@noble/hashes@1.3.3': resolution: {integrity: sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==} engines: {node: '>= 16'} + '@noble/hashes@1.7.1': + resolution: {integrity: sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ==} + engines: {node: ^14.21.3 || >=16} + '@pkgjs/parseargs@0.11.0': resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} @@ -352,6 +353,9 @@ packages: cpu: [x64] os: [win32] + '@scure/base@1.2.4': + resolution: {integrity: sha512-5Yy9czTO47mqz+/J8GM6GIId4umdCk1wc1q8rKERQulIoc8VP9pzDcghv10Tl2E7R96ZUx/PhND3ESYUQX8NuQ==} + '@types/estree@1.0.6': resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==} @@ -380,11 +384,6 @@ packages: balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - base-x@2.0.6: - resolution: {integrity: sha512-UAmjxz9KbK+YIi66xej+pZVo/vxUOh49ubEvZW5egCbxhur05pBb+hwuireQwKO4nDpsNm64/jEei17LEpsr5g==} - engines: {node: '>=4.5.0'} - deprecated: use 3.0.0 instead, safe-buffer has been merged and release for compatability - bn.js@4.12.1: resolution: {integrity: sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg==} @@ -397,9 +396,6 @@ packages: brorand@1.1.0: resolution: {integrity: sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==} - bs58@4.0.0: - resolution: {integrity: sha512-/jcGuUuSebyxwLLfKrbKnCJttxRf9PM51EnHTwmFKBxl4z1SGkoAhrfd6uZKE0dcjQTfm6XzTP8DPr1tzE4KIw==} - bundle-require@5.1.0: resolution: {integrity: sha512-3WrrOuZiyaaZPWiEt4G3+IffISVC9HYlWueJEBWED4ZH4aIAC2PnkdnuRrR94M+w6yGWn4AglWtJtBI8YqvgoA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -471,8 +467,8 @@ packages: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} - exponential-backoff@3.1.1: - resolution: {integrity: sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==} + exponential-backoff@3.1.2: + resolution: {integrity: sha512-8QxYTVXUkuy7fIIoitQkPwGonB8F3Zj8eEO8Sqg9Zv/bkI7RJAzowee4gr81Hak/dUTpA2Z7VfQgoijjPNlUZA==} fdir@6.4.3: resolution: {integrity: sha512-PMXmW2y1hDDfTSRc9gaXIuCCRpuoz3Kaz8cUelp3smouvfT632ozg2vrT6lJsHKKOF59YLbOGfAWGUcKEfRMQw==} @@ -533,9 +529,6 @@ packages: isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - isomorphic-unfetch@3.1.0: - resolution: {integrity: sha512-geDJjpoZ8N0kWexiwkX8F9NkTsXhetLPVbZFQ+JTW239QNOwvB0gniuR1Wc6f0AMTn7/mFGyXvHTifrCp/GH8Q==} - jackspeak@3.4.3: resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==} @@ -595,11 +588,11 @@ packages: mz@2.7.0: resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==} - near-abi@0.1.1: - resolution: {integrity: sha512-RVDI8O+KVxRpC3KycJ1bpfVj9Zv+xvq9PlW1yIFl46GhrnLw83/72HqHGjGDjQ8DtltkcpSjY9X3YIGZ+1QyzQ==} + near-abi@0.2.0: + resolution: {integrity: sha512-kCwSf/3fraPU2zENK18sh+kKG4uKbEUEQdyWQkmW8ZofmLarObIz2+zAYjA1teDZLeMvEQew3UysnPDXgjneaA==} - near-api-js@5.0.1: - resolution: {integrity: sha512-ZSQYIQdekIvSRfOFuRj6MW11jtK5lsOaiWM2VB0nq7eROuuxwSSXHg+syjCXl3HNNZ3hzg0CNdp+5Za0X1ZtYg==} + near-api-js@5.1.1: + resolution: {integrity: sha512-h23BGSKxNv8ph+zU6snicstsVK1/CTXsQz4LuGGwoRE24Hj424nSe4+/1tzoiC285Ljf60kPAqRCmsfv9etF2g==} node-addon-api@5.1.0: resolution: {integrity: sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==} @@ -613,15 +606,6 @@ packages: encoding: optional: true - node-fetch@2.7.0: - resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} - engines: {node: 4.x || >=6.0.0} - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true - node-gyp-build@4.8.4: resolution: {integrity: sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==} hasBin: true @@ -696,9 +680,9 @@ packages: safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} - secp256k1@5.0.0: - resolution: {integrity: sha512-TKWX8xvoGHrxVdqbYeZM9w+izTF4b9z3NhSaDkdn81btvuh+ivbIMGT/zQvDtTFWhRlThpoz6LEYTr7n8A5GcA==} - engines: {node: '>=14.0.0'} + secp256k1@5.0.1: + resolution: {integrity: sha512-lDFs9AAIaWP9UCdtWrotXWWF9t8PWgQDcxqgAnpM9rMqxb3Oaq2J0thzPVSxBwdJgyQtkU/sYtFtbM1RSt/iYA==} + engines: {node: '>=18.0.0'} setprototypeof@1.1.1: resolution: {integrity: sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==} @@ -802,9 +786,6 @@ packages: engines: {node: '>=14.17'} hasBin: true - unfetch@4.2.0: - resolution: {integrity: sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA==} - webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} @@ -937,120 +918,118 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 - '@near-js/accounts@1.3.1': + '@near-js/accounts@1.4.1': dependencies: - '@near-js/crypto': 1.4.1 - '@near-js/providers': 1.0.1 - '@near-js/signers': 0.2.1 - '@near-js/transactions': 1.3.1 + '@near-js/crypto': 1.4.2 + '@near-js/providers': 1.0.3 + '@near-js/signers': 0.2.2 + '@near-js/transactions': 1.3.3 '@near-js/types': 0.3.1 - '@near-js/utils': 1.0.1 - '@noble/hashes': 1.3.3 + '@near-js/utils': 1.1.0 + '@noble/hashes': 1.7.1 borsh: 1.0.0 depd: 2.0.0 is-my-json-valid: 2.20.6 - isomorphic-unfetch: 3.1.0 lru_map: 0.4.1 - near-abi: 0.1.1 + near-abi: 0.2.0 transitivePeerDependencies: - encoding - '@near-js/crypto@1.4.1': + '@near-js/crypto@1.4.2': dependencies: '@near-js/types': 0.3.1 - '@near-js/utils': 1.0.1 - '@noble/curves': 1.2.0 + '@near-js/utils': 1.1.0 + '@noble/curves': 1.8.1 borsh: 1.0.0 randombytes: 2.1.0 - secp256k1: 5.0.0 + secp256k1: 5.0.1 - '@near-js/keystores-browser@0.2.1': + '@near-js/keystores-browser@0.2.2': dependencies: - '@near-js/crypto': 1.4.1 - '@near-js/keystores': 0.2.1 + '@near-js/crypto': 1.4.2 + '@near-js/keystores': 0.2.2 - '@near-js/keystores-node@0.1.1': + '@near-js/keystores-node@0.1.2': dependencies: - '@near-js/crypto': 1.4.1 - '@near-js/keystores': 0.2.1 + '@near-js/crypto': 1.4.2 + '@near-js/keystores': 0.2.2 - '@near-js/keystores@0.2.1': + '@near-js/keystores@0.2.2': dependencies: - '@near-js/crypto': 1.4.1 + '@near-js/crypto': 1.4.2 '@near-js/types': 0.3.1 - '@near-js/providers@1.0.1': + '@near-js/providers@1.0.3': dependencies: - '@near-js/transactions': 1.3.1 + '@near-js/transactions': 1.3.3 '@near-js/types': 0.3.1 - '@near-js/utils': 1.0.1 + '@near-js/utils': 1.1.0 borsh: 1.0.0 - exponential-backoff: 3.1.1 - isomorphic-unfetch: 3.1.0 + exponential-backoff: 3.1.2 optionalDependencies: node-fetch: 2.6.7 transitivePeerDependencies: - encoding - '@near-js/signers@0.2.1': + '@near-js/signers@0.2.2': dependencies: - '@near-js/crypto': 1.4.1 - '@near-js/keystores': 0.2.1 + '@near-js/crypto': 1.4.2 + '@near-js/keystores': 0.2.2 '@noble/hashes': 1.3.3 - '@near-js/transactions@1.3.1': + '@near-js/transactions@1.3.3': dependencies: - '@near-js/crypto': 1.4.1 - '@near-js/signers': 0.2.1 + '@near-js/crypto': 1.4.2 + '@near-js/signers': 0.2.2 '@near-js/types': 0.3.1 - '@near-js/utils': 1.0.1 - '@noble/hashes': 1.3.3 + '@near-js/utils': 1.1.0 + '@noble/hashes': 1.7.1 borsh: 1.0.0 '@near-js/types@0.3.1': {} - '@near-js/utils@1.0.1': + '@near-js/utils@1.1.0': dependencies: '@near-js/types': 0.3.1 - bs58: 4.0.0 + '@scure/base': 1.2.4 depd: 2.0.0 mustache: 4.0.0 - '@near-js/wallet-account@1.3.1': + '@near-js/wallet-account@1.3.3': dependencies: - '@near-js/accounts': 1.3.1 - '@near-js/crypto': 1.4.1 - '@near-js/keystores': 0.2.1 - '@near-js/providers': 1.0.1 - '@near-js/signers': 0.2.1 - '@near-js/transactions': 1.3.1 + '@near-js/accounts': 1.4.1 + '@near-js/crypto': 1.4.2 + '@near-js/keystores': 0.2.2 + '@near-js/providers': 1.0.3 + '@near-js/signers': 0.2.2 + '@near-js/transactions': 1.3.3 '@near-js/types': 0.3.1 - '@near-js/utils': 1.0.1 + '@near-js/utils': 1.1.0 borsh: 1.0.0 transitivePeerDependencies: - encoding - '@near-wallet-selector/core@8.9.16(near-api-js@5.0.1)': + '@near-wallet-selector/core@8.10.1(near-api-js@5.1.1)': dependencies: borsh: 1.0.0 events: 3.3.0 js-sha256: 0.9.0 - near-api-js: 5.0.1 + near-api-js: 5.1.1 rxjs: 7.8.1 - '@near-wallet-selector/wallet-utils@8.9.16(near-api-js@5.0.1)': + '@near-wallet-selector/wallet-utils@8.10.1(near-api-js@5.1.1)': dependencies: - '@near-wallet-selector/core': 8.9.16(near-api-js@5.0.1) - near-api-js: 5.0.1 + '@near-wallet-selector/core': 8.10.1(near-api-js@5.1.1) + near-api-js: 5.1.1 - '@noble/curves@1.2.0': + '@noble/curves@1.8.1': dependencies: - '@noble/hashes': 1.3.2 - - '@noble/hashes@1.3.2': {} + '@noble/hashes': 1.7.1 '@noble/hashes@1.3.3': {} + '@noble/hashes@1.7.1': {} + '@pkgjs/parseargs@0.11.0': optional: true @@ -1111,6 +1090,8 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.34.1': optional: true + '@scure/base@1.2.4': {} + '@types/estree@1.0.6': {} '@types/json-schema@7.0.15': {} @@ -1129,10 +1110,6 @@ snapshots: balanced-match@1.0.2: {} - base-x@2.0.6: - dependencies: - safe-buffer: 5.2.1 - bn.js@4.12.1: {} borsh@1.0.0: {} @@ -1143,10 +1120,6 @@ snapshots: brorand@1.1.0: {} - bs58@4.0.0: - dependencies: - base-x: 2.0.6 - bundle-require@5.1.0(esbuild@0.24.2): dependencies: esbuild: 0.24.2 @@ -1228,7 +1201,7 @@ snapshots: events@3.3.0: {} - exponential-backoff@3.1.1: {} + exponential-backoff@3.1.2: {} fdir@6.4.3(picomatch@4.0.2): optionalDependencies: @@ -1298,13 +1271,6 @@ snapshots: isexe@2.0.0: {} - isomorphic-unfetch@3.1.0: - dependencies: - node-fetch: 2.7.0 - unfetch: 4.2.0 - transitivePeerDependencies: - - encoding - jackspeak@3.4.3: dependencies: '@isaacs/cliui': 8.0.2 @@ -1349,28 +1315,28 @@ snapshots: object-assign: 4.1.1 thenify-all: 1.6.0 - near-abi@0.1.1: + near-abi@0.2.0: dependencies: '@types/json-schema': 7.0.15 - near-api-js@5.0.1: + near-api-js@5.1.1: dependencies: - '@near-js/accounts': 1.3.1 - '@near-js/crypto': 1.4.1 - '@near-js/keystores': 0.2.1 - '@near-js/keystores-browser': 0.2.1 - '@near-js/keystores-node': 0.1.1 - '@near-js/providers': 1.0.1 - '@near-js/signers': 0.2.1 - '@near-js/transactions': 1.3.1 + '@near-js/accounts': 1.4.1 + '@near-js/crypto': 1.4.2 + '@near-js/keystores': 0.2.2 + '@near-js/keystores-browser': 0.2.2 + '@near-js/keystores-node': 0.1.2 + '@near-js/providers': 1.0.3 + '@near-js/signers': 0.2.2 + '@near-js/transactions': 1.3.3 '@near-js/types': 0.3.1 - '@near-js/utils': 1.0.1 - '@near-js/wallet-account': 1.3.1 - '@noble/curves': 1.2.0 + '@near-js/utils': 1.1.0 + '@near-js/wallet-account': 1.3.3 + '@noble/curves': 1.8.1 borsh: 1.0.0 depd: 2.0.0 http-errors: 1.7.2 - near-abi: 0.1.1 + near-abi: 0.2.0 node-fetch: 2.6.7 transitivePeerDependencies: - encoding @@ -1381,10 +1347,6 @@ snapshots: dependencies: whatwg-url: 5.0.0 - node-fetch@2.7.0: - dependencies: - whatwg-url: 5.0.0 - node-gyp-build@4.8.4: {} object-assign@4.1.1: {} @@ -1449,7 +1411,7 @@ snapshots: safe-buffer@5.2.1: {} - secp256k1@5.0.0: + secp256k1@5.0.1: dependencies: elliptic: 6.6.1 node-addon-api: 5.1.0 @@ -1558,8 +1520,6 @@ snapshots: typescript@5.7.3: {} - unfetch@4.2.0: {} - webidl-conversions@3.0.1: {} webidl-conversions@4.0.2: {} diff --git a/src/bitte-wallet.ts b/src/bitte-wallet.ts index 772ef1b..bfd9211 100644 --- a/src/bitte-wallet.ts +++ b/src/bitte-wallet.ts @@ -5,12 +5,11 @@ import type { SignMessageParams, Transaction, } from "@near-wallet-selector/core"; - import { createAction } from "@near-wallet-selector/wallet-utils"; -import { connect, keyStores, providers, transactions } from "near-api-js"; -import type { PublicKey } from "near-api-js/lib/utils"; -import { KeyPair, serialize } from "near-api-js/lib/utils"; +import { createAction } from "@near-wallet-selector/wallet-utils"; +import { connect, keyStores, providers } from "near-api-js"; +import type { PublicKey } from "near-api-js/lib/utils/index.js"; +import { KeyPair } from "near-api-js/lib/utils/index.js"; import { WalletConfig, WalletMessage, WalletResponseData, WalletState } from "./types"; -import type { Transaction as WalletSelectorTransaction, Action as WalletSelectorAction } from "@near-wallet-selector/core"; // Constants @@ -21,13 +20,13 @@ const POLL_INTERVAL = 300; // State management const getInitialState = (): WalletState => ({ - signedAccountId: localStorage.getItem("signedAccountId") || "", - functionCallKey: JSON.parse(localStorage.getItem("functionCallKey") || "null"), + signedAccountId: localStorage.getItem("bitte:signedAccountId") || "", + functionCallKey: JSON.parse(localStorage.getItem("bitte:functionCallKey") || "null"), }); const saveState = (state: WalletState): void => { - localStorage.setItem("signedAccountId", state.signedAccountId); - localStorage.setItem("functionCallKey", JSON.stringify(state.functionCallKey)); + localStorage.setItem("bitte:signedAccountId", state.signedAccountId); + localStorage.setItem("bitte:functionCallKey", JSON.stringify(state.functionCallKey)); }; // Create wallet configuration @@ -153,26 +152,6 @@ const signMessage = async ( }); }; -const completeTransaction = async ( - config: WalletConfig, - state: WalletState, - { receiverId, actions }: { receiverId: string; actions: Array } -): Promise => { - // To create a transaction we need a recent block - const block = await config.provider.block({ finality: "final" }); - const blockHash = serialize.base_decode(block.header.hash); - - // create Transaction for the wallet - return transactions.createTransaction( - state.signedAccountId, - KeyPair.fromRandom("ed25519").getPublicKey(), - receiverId, - 0, - actions.map((a) => createAction(a)), - Uint8Array.from(blockHash) - ); -}; - const storedKeyCanSign = ( state: WalletState, receiverId: string, @@ -218,11 +197,10 @@ const signUsingKeyPair = async ( const requestSignTransactionsUrl = ( config: WalletConfig, - txs: Array + txs: Array ): string => { const newUrl = new URL(`${config.walletUrl}/sign-transaction`); - - const stringifiedParam = JSON.stringify(txs); + const stringifiedParam = JSON.stringify(txs, (_, v) => typeof v === 'bigint' ? v.toString() : v); const urlParam = encodeURIComponent(stringifiedParam); newUrl.searchParams.set('transactions_data', urlParam); @@ -238,14 +216,23 @@ const signAndSendTransactionsPopUp = async ( const url = requestSignTransactionsUrl(config, txs); const txsHashes = ( await handlePopupTransaction(config, url, (data) => data.transactionHashes) - )?.split(","); + )?.split(",").map(decodeURIComponent); + + + console.log(txsHashes, 'hashes') + if (!txsHashes) { throw new Error("No transaction hashes received"); } - return Promise.all( + + const res = Promise.all( txsHashes.map((hash) => config.provider.txStatus(hash, "unused")) ); + + console.log(res, 'res') + + return res }; @@ -267,10 +254,7 @@ const signAndSendTransaction = async ( } } - - const tx = await completeTransaction(config, state, { receiverId, actions }); - - const results = await signAndSendTransactionsPopUp(config, [tx as any]); + const results = await signAndSendTransactionsPopUp(config, [{ signerId: state.signedAccountId, receiverId, actions }]); return results[0]; };