From ed237e308cc46164dbf515fbd82e148726d2bfd8 Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Fri, 16 Jun 2023 12:00:30 +0200 Subject: [PATCH 01/14] upgrade capi to beta 47 --- package.json | 2 +- pnpm-lock.yaml | 184 +++++++++++++++++++++++-------------------------- 2 files changed, 87 insertions(+), 99 deletions(-) diff --git a/package.json b/package.json index c1986da..a5c2db3 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "@headlessui/react": "^1.7.15", "@preact/signals": "^1.1.3", "@talisman-connect/wallets": "^1.1.3", - "capi": "0.1.0-beta.42", + "capi": "0.1.0-beta.47", "dotenv": "^16.1.4", "preact": "^10.15.1", "react-hook-form": "^7.44.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 27504b6..1855d2a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,7 +14,7 @@ importers: dependencies: '@capi/westend': specifier: https://capi.dev/a416a0563f132155/westend.tar - version: '@capi.dev/a416a0563f132155/westend.tar(capi@0.1.0-beta.42)' + version: '@capi.dev/a416a0563f132155/westend.tar(capi@0.1.0-beta.47)' '@headlessui/react': specifier: ^1.7.15 version: 1.7.15(react-dom@18.2.0)(react@18.2.0) @@ -25,8 +25,8 @@ importers: specifier: ^1.1.3 version: 1.1.3(@polkadot/util-crypto@8.7.1)(@polkadot/util@8.7.1) capi: - specifier: 0.1.0-beta.42 - version: 0.1.0-beta.42 + specifier: 0.1.0-beta.47 + version: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dotenv: specifier: ^16.1.4 version: 16.1.4 @@ -1207,7 +1207,6 @@ packages: engines: {node: '>=12'} dependencies: '@jridgewell/trace-mapping': 0.3.9 - dev: true /@deno/shim-deno-test@0.4.0: resolution: {integrity: sha512-oYWcD7CpERZy/TXMTM9Tgh1HD/POHlbY9WpzmAk+5H8DohcxG415Qws8yLGlim3EaKBT2v3lJv01x4G0BosnaQ==} @@ -1443,7 +1442,6 @@ packages: /@jridgewell/resolve-uri@3.1.1: resolution: {integrity: sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==} engines: {node: '>=6.0.0'} - dev: true /@jridgewell/set-array@1.1.2: resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==} @@ -1456,7 +1454,6 @@ packages: /@jridgewell/sourcemap-codec@1.4.15: resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} - dev: true /@jridgewell/trace-mapping@0.3.18: resolution: {integrity: sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==} @@ -1470,7 +1467,6 @@ packages: dependencies: '@jridgewell/resolve-uri': 3.1.1 '@jridgewell/sourcemap-codec': 1.4.15 - dev: true /@noble/ed25519@2.0.0: resolution: {integrity: sha512-/extjhkwFupyopDrt80OMWKdLgP429qLZj+z6sYJz90rF2Iz0gjZh2ArMKPImUl13Kx+0EXI2hN9T/KJV0/Zng==} @@ -1985,16 +1981,6 @@ packages: - supports-color dev: false - /@substrate/smoldot-light@0.7.6: - resolution: {integrity: sha512-bpoUYfKtAn8BMzVY88F34CivU/uymKKvmqY3sQ2oSV5h71Cj6jREOknSgVVVwPk8BpUYlp8paYFbtuR4cQpVOA==} - dependencies: - pako: 2.1.0 - ws: 8.13.0 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - dev: false - /@substrate/ss58-registry@1.40.0: resolution: {integrity: sha512-QuU2nBql3J4KCnOWtWDw4n1K4JU0T79j54ZZvm/9nhsX6AIar13FyhsaBfs6QkJ2ixTQAnd7TocJIoJRWbqMZA==} dev: false @@ -2045,19 +2031,15 @@ packages: /@tsconfig/node10@1.0.9: resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==} - dev: true /@tsconfig/node12@1.0.11: resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} - dev: true /@tsconfig/node14@1.0.3: resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} - dev: true /@tsconfig/node16@1.0.3: resolution: {integrity: sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==} - dev: true /@types/aws-lambda@8.10.115: resolution: {integrity: sha512-kCZuFXKLV3y8NjSoaD5+qKTpRWvPz3uh3W/u1uwlw3Mg+MtaStg1NWgjAwUXo/VJDb6n6KF1ljykFNlNwEJ53Q==} @@ -2177,13 +2159,11 @@ packages: /acorn-walk@8.2.0: resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==} engines: {node: '>=0.4.0'} - dev: true /acorn@8.8.2: resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} engines: {node: '>=0.4.0'} hasBin: true - dev: true /ansi-styles@3.2.1: resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} @@ -2205,7 +2185,6 @@ packages: /arg@4.1.3: resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} - dev: true /arg@5.0.2: resolution: {integrity: sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==} @@ -2370,32 +2349,37 @@ packages: resolution: {integrity: sha512-uv7/gXuHi10Whlj0pp5q/tsK/32J2QSqVRKQhs2j8VsDCjgyruAh/eEXHF822VqO9yT6iZKw3nRwZRSPBE9OQg==} dev: true - /capi@0.1.0-beta.42: - resolution: {integrity: sha512-P14h5HrxoECV13eZy4Zy5oGaK+PxEXDqBofwSTUgMpofV+xGBLous3HpCg1AkkTqTfm1QwkxZ6hyvq0Ze0JYmA==} + /capi@0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3): + resolution: {integrity: sha512-hvTu8cih0zQ1vUCF4kajc+eH5kwP5dlyWlT+mHqSnTzer1KJ+VHyxgFZ/pHCxg9GEmesunYyNsYUXMroZVW9oA==} hasBin: true dependencies: - '@capi/contracts-dev': '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/contracts-dev.tar(capi@0.1.0-beta.42)' - '@capi/polkadot': '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/polkadot.tar(capi@0.1.0-beta.42)' - '@capi/polkadot-dev': '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/polkadot-dev.tar(capi@0.1.0-beta.42)' - '@capi/rococo-dev': '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev.tar(capi@0.1.0-beta.42)' - '@capi/rococo-dev-contracts': '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-contracts.tar(capi@0.1.0-beta.42)' - '@capi/rococo-dev-westmint': '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-westmint.tar(capi@0.1.0-beta.42)' - '@capi/rococo-dev-xcm': '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-xcm.tar(capi@0.1.0-beta.42)' - '@capi/rococo-dev-xcm-statemine': '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-xcm-statemine.tar(capi@0.1.0-beta.42)' - '@capi/rococo-dev-xcm-trappist': '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-xcm-trappist.tar(capi@0.1.0-beta.42)' - '@capi/statemint': '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/statemint.tar(capi@0.1.0-beta.42)' - '@capi/westend': '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/westend.tar(capi@0.1.0-beta.42)' - '@capi/westend-dev': '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/westend-dev.tar(capi@0.1.0-beta.42)' + '@capi/contracts-dev': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/contracts-dev.tar(capi@0.1.0-beta.47)' + '@capi/polkadot': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot.tar(capi@0.1.0-beta.47)' + '@capi/polkadot-dev': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot-dev.tar(capi@0.1.0-beta.47)' + '@capi/rococo-dev': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev.tar(capi@0.1.0-beta.47)' + '@capi/rococo-dev-contracts': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-contracts.tar(capi@0.1.0-beta.47)' + '@capi/rococo-dev-westmint': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-westmint.tar(capi@0.1.0-beta.47)' + '@capi/rococo-dev-xcm': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm.tar(capi@0.1.0-beta.47)' + '@capi/rococo-dev-xcm-statemine': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-statemine.tar(capi@0.1.0-beta.47)' + '@capi/rococo-dev-xcm-trappist': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-trappist.tar(capi@0.1.0-beta.47)' + '@capi/statemint': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/statemint.tar(capi@0.1.0-beta.47)' + '@capi/westend': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend.tar(capi@0.1.0-beta.47)' + '@capi/westend-dev': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend-dev.tar(capi@0.1.0-beta.47)' '@deno/shim-deno': 0.14.0 '@noble/ed25519': 2.0.0 - '@substrate/smoldot-light': 0.7.6 isomorphic-ws: 5.0.0(ws@8.13.0) scale-codec: 0.11.2 + smoldot: 1.0.6 + ts-node: 10.9.1(@types/node@20.3.1)(typescript@5.1.3) tslib: 2.5.0 - wat-the-crypto: 0.0.2 + wat-the-crypto: 0.0.3 ws: 8.13.0 transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' - bufferutil + - typescript - utf-8-validate dev: false @@ -2495,7 +2479,6 @@ packages: /create-require@1.1.1: resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} - dev: true /cssesc@3.0.0: resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==} @@ -2566,7 +2549,6 @@ packages: /diff@4.0.2: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} - dev: true /dlv@1.1.3: resolution: {integrity: sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==} @@ -3070,7 +3052,6 @@ packages: /make-error@1.3.6: resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} - dev: true /media-typer@0.3.0: resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==} @@ -3705,6 +3686,16 @@ packages: semver: 7.0.0 dev: false + /smoldot@1.0.6: + resolution: {integrity: sha512-eooOKiJJax2frJOFi9gROemQFAJqVa975KZnDeImfFXe2b+odI4IYf0I4NI0c1vOdcM7xUWBOxYeAIVQQILa7w==} + dependencies: + pako: 2.1.0 + ws: 8.13.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: false + /source-map-js@1.0.2: resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} engines: {node: '>=0.10.0'} @@ -3857,7 +3848,6 @@ packages: typescript: 5.1.3 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 - dev: true /tsconfck@2.1.1(typescript@5.1.3): resolution: {integrity: sha512-ZPCkJBKASZBmBUNqGHmRhdhM8pJYDdOXp4nRgj/O0JwUwsMq50lCDRQP/M5GBNAA0elPrq4gAeu4dkaVCuKWww==} @@ -3999,7 +3989,6 @@ packages: /v8-compile-cache-lib@3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} - dev: true /vary@1.1.2: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} @@ -4055,8 +4044,8 @@ packages: optionalDependencies: fsevents: 2.3.2 - /wat-the-crypto@0.0.2: - resolution: {integrity: sha512-LfIvUR5LjijsyZ8ZhVxrkeM4l3sYZ2W6EW4SO7s6dlQijQbK6z1q45sp0ijRWyI8Tc7WGmJVtJcoNZ+g13mo/g==} + /wat-the-crypto@0.0.3: + resolution: {integrity: sha512-Ob4HtNrDNUnk20CKZKBPaawn5R8wGqFhv1+RH/v3ypFyi0GnB1YE0xwrvW1JQwzoUHmcQh26tiO4seF4Qvy3Kw==} dev: false /webidl-conversions@3.0.1: @@ -4147,145 +4136,144 @@ packages: /yn@3.1.1: resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} engines: {node: '>=6'} - dev: true /zod@3.21.4: resolution: {integrity: sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==} dev: false - '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/contracts-dev.tar(capi@0.1.0-beta.42)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/contracts-dev.tar} - id: '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/contracts-dev.tar' + '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/contracts-dev.tar(capi@0.1.0-beta.47)': + resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/contracts-dev.tar} + id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/contracts-dev.tar' name: contracts-dev version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.42 + capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/polkadot-dev.tar(capi@0.1.0-beta.42)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/polkadot-dev.tar} - id: '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/polkadot-dev.tar' + '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot-dev.tar(capi@0.1.0-beta.47)': + resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot-dev.tar} + id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot-dev.tar' name: polkadot-dev version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.42 + capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/polkadot.tar(capi@0.1.0-beta.42)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/polkadot.tar} - id: '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/polkadot.tar' + '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot.tar(capi@0.1.0-beta.47)': + resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot.tar} + id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot.tar' name: polkadot version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.42 + capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-contracts.tar(capi@0.1.0-beta.42)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-contracts.tar} - id: '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-contracts.tar' + '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-contracts.tar(capi@0.1.0-beta.47)': + resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-contracts.tar} + id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-contracts.tar' name: rococo-dev-contracts version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.42 + capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-westmint.tar(capi@0.1.0-beta.42)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-westmint.tar} - id: '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-westmint.tar' + '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-westmint.tar(capi@0.1.0-beta.47)': + resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-westmint.tar} + id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-westmint.tar' name: rococo-dev-westmint version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.42 + capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-xcm-statemine.tar(capi@0.1.0-beta.42)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-xcm-statemine.tar} - id: '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-xcm-statemine.tar' + '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-statemine.tar(capi@0.1.0-beta.47)': + resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-statemine.tar} + id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-statemine.tar' name: rococo-dev-xcm-statemine version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.42 + capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-xcm-trappist.tar(capi@0.1.0-beta.42)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-xcm-trappist.tar} - id: '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-xcm-trappist.tar' + '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-trappist.tar(capi@0.1.0-beta.47)': + resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-trappist.tar} + id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-trappist.tar' name: rococo-dev-xcm-trappist version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.42 + capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-xcm.tar(capi@0.1.0-beta.42)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-xcm.tar} - id: '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev-xcm.tar' + '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm.tar(capi@0.1.0-beta.47)': + resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm.tar} + id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm.tar' name: rococo-dev-xcm version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.42 + capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev.tar(capi@0.1.0-beta.42)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev.tar} - id: '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/rococo-dev.tar' + '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev.tar(capi@0.1.0-beta.47)': + resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev.tar} + id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev.tar' name: rococo-dev version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.42 + capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/statemint.tar(capi@0.1.0-beta.42)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/statemint.tar} - id: '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/statemint.tar' + '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/statemint.tar(capi@0.1.0-beta.47)': + resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/statemint.tar} + id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/statemint.tar' name: statemint version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.42 + capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/westend-dev.tar(capi@0.1.0-beta.42)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/westend-dev.tar} - id: '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/westend-dev.tar' + '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend-dev.tar(capi@0.1.0-beta.47)': + resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend-dev.tar} + id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend-dev.tar' name: westend-dev version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.42 + capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/westend.tar(capi@0.1.0-beta.42)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/westend.tar} - id: '@capi.dev/@v0.1.0-beta.42/371568ef82e78f0c/westend.tar' + '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend.tar(capi@0.1.0-beta.47)': + resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend.tar} + id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend.tar' name: westend version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.42 + capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/a416a0563f132155/westend.tar(capi@0.1.0-beta.42)': + '@capi.dev/a416a0563f132155/westend.tar(capi@0.1.0-beta.47)': resolution: {tarball: https://capi.dev/a416a0563f132155/westend.tar} id: '@capi.dev/a416a0563f132155/westend.tar' name: westend @@ -4293,5 +4281,5 @@ packages: peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.42 + capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) dev: false From b988a9dce2098f2d74a3489bb9312ebf5810f66e Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Fri, 16 Jun 2023 14:02:38 +0200 Subject: [PATCH 02/14] update import of `net` --- nets.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nets.ts b/nets.ts index 05a9c15..e81c2e4 100644 --- a/nets.ts +++ b/nets.ts @@ -1,4 +1,4 @@ -import { net } from "capi" +import { net } from "capi/nets" export const westend = net.ws({ url: "wss://westend-rpc.polkadot.io/", From 886845d90faaa3d567ec7b761ce7515af7c30514 Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Fri, 16 Jun 2023 14:02:50 +0200 Subject: [PATCH 03/14] import from `unstable` pattern --- www/src/components/wizards/multisig/Members.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/src/components/wizards/multisig/Members.tsx b/www/src/components/wizards/multisig/Members.tsx index 10ea9dc..f29916d 100644 --- a/www/src/components/wizards/multisig/Members.tsx +++ b/www/src/components/wizards/multisig/Members.tsx @@ -2,11 +2,11 @@ import { MultiAddress, Westend, westend } from "@capi/westend" import { zodResolver } from "@hookform/resolvers/zod/dist/zod.js" import { Rune, ss58 } from "capi" import { MultisigRune } from "capi/patterns/multisig" +import { signature } from "capi/patterns/signature/polkadot" import { filterPureCreatedEvents, replaceDelegateCalls, -} from "capi/patterns/proxy" -import { signature } from "capi/patterns/signature/polkadot" +} from "capi/patterns/unstable/proxy" import { Controller, useForm } from "react-hook-form" import { accounts, From 82e8364f38e0e224682a6dd4b55701b9fd11b3b4 Mon Sep 17 00:00:00 2001 From: tjjfvi Date: Fri, 16 Jun 2023 10:00:15 -0400 Subject: [PATCH 04/14] fix nets.ts check --- tsconfig.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 2efb15d..78465f0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,8 @@ { "extends": "./tsconfig.base.json", - "files": [], + "compilerOptions": { + "noEmit": true + }, + "files": ["nets.ts"], "references": [{ "path": "www" }, { "path": "server" }, { "path": "common" }] } From 4d27a3bb6d4291b12f1ae841e9a1d952155b12a0 Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Mon, 19 Jun 2023 12:01:49 +0200 Subject: [PATCH 05/14] adds new required parameter `Scope` --- server/main.ts | 81 ++++++++++--------- server/scripts/send-transfer.ts | 37 +++++---- www/src/components/Setup.tsx | 5 +- www/src/components/wizards/multisig/Fund.tsx | 16 ++-- .../components/wizards/multisig/Members.tsx | 11 +-- .../components/wizards/transaction/New.tsx | 5 +- .../components/wizards/transaction/Sign.tsx | 3 +- .../components/wizards/transaction/signals.ts | 3 +- www/src/hooks/useAccountInfo.ts | 3 +- www/src/hooks/useProposals.ts | 10 ++- www/src/signals/scope.ts | 6 ++ www/src/util/balance.ts | 9 ++- www/src/util/chain-constants.ts | 10 ++- www/src/util/local-storage.ts | 5 +- www/src/util/transaction.ts | 3 +- 15 files changed, 123 insertions(+), 84 deletions(-) create mode 100644 www/src/signals/scope.ts diff --git a/server/main.ts b/server/main.ts index 89180c9..26b6b8f 100644 --- a/server/main.ts +++ b/server/main.ts @@ -1,5 +1,5 @@ import { westend } from "@capi/westend" -import { SignedExtrinsicRune } from "capi" +import { Scope, SignedExtrinsicRune } from "capi" import { $input, $result, Submit } from "common" import express from "express" import * as http from "http" @@ -42,19 +42,23 @@ wsServer.on("connection", (ws, _req) => { channels[decoded.channel] = new Set() } channels[decoded.channel]?.add(ws) - ws.send($result.encode({ - type: "subscribe", - channel: decoded.channel, - result: "ok", - })) + ws.send( + $result.encode({ + type: "subscribe", + channel: decoded.channel, + result: "ok", + }), + ) break case "unsubscribe": if (channels[decoded.channel]?.delete(ws)) { - ws.send($result.encode({ - type: "unsubscribe", - channel: decoded.channel, - result: "ok", - })) + ws.send( + $result.encode({ + type: "unsubscribe", + channel: decoded.channel, + result: "ok", + }), + ) } break case "submit": @@ -79,19 +83,18 @@ async function handleSubmit(ws: ws.WebSocket, submit: Submit): Promise { channels[submit.channel]?.forEach((ws) => ws.send(data)) } - await SignedExtrinsicRune.fromHex( - westend, - submit.signedExtrinsic, - ) + await SignedExtrinsicRune.fromHex(westend, submit.signedExtrinsic) .sent() .dbgStatus("tx status") .transactionStatuses((txStatus) => { if (typeof txStatus === "string") { - send($result.encode({ - type: "submit", - channel: submit.channel, - result: { status: txStatus }, - })) + send( + $result.encode({ + type: "submit", + channel: submit.channel, + result: { status: txStatus }, + }), + ) } else { const status = Object.keys(txStatus)[0]! switch (status) { @@ -104,32 +107,38 @@ async function handleSubmit(ws: ws.WebSocket, submit: Submit): Promise { case "usurped": case "dropped": case "invalid": - send($result.encode({ - type: "submit", - channel: submit.channel, - result: { status }, - })) + send( + $result.encode({ + type: "submit", + channel: submit.channel, + result: { status }, + }), + ) break case "finalized": const hash: string = txStatus["finalized"]! as string - send($result.encode({ - type: "submit", - channel: submit.channel, - result: { status, hash }, - })) + send( + $result.encode({ + type: "submit", + channel: submit.channel, + result: { status, hash }, + }), + ) break } } return false }) - .run() + .run(new Scope()) } catch (err) { - ws.send($result.encode({ - type: "submit", - channel: submit.channel, - result: { status: "failed" }, - })) + ws.send( + $result.encode({ + type: "submit", + channel: submit.channel, + result: { status: "failed" }, + }), + ) handleError(err) } } diff --git a/server/scripts/send-transfer.ts b/server/scripts/send-transfer.ts index d2ac7a5..24df4b7 100644 --- a/server/scripts/send-transfer.ts +++ b/server/scripts/send-transfer.ts @@ -1,5 +1,5 @@ import { westend } from "@capi/westend" -import { hex, Sr25519 } from "capi" +import { hex, Scope, Sr25519 } from "capi" import { signature } from "capi/patterns/signature/polkadot" import { $input, $result } from "common" import * as crypto from "crypto" @@ -16,28 +16,31 @@ const sender = Sr25519.fromSecret(secret) const recipient = Sr25519.fromSecret(crypto.getRandomValues(new Uint8Array(64))) -const signedExtrinsic = await westend.Balances - .transfer({ - value: 12345n, - dest: recipient.address, - }) +const signedExtrinsic = await westend.Balances.transfer({ + value: 12345n, + dest: recipient.address, +}) .signed(signature({ sender })) .hex() - .run() + .run(new Scope()) const ws = new WebSocket(endpoint) ws.on("open", () => { - ws.send($input.encode({ - type: "subscribe", - channel: "multisig-xyz", - })) - - ws.send($input.encode({ - type: "submit", - channel: "multisig-xyz", - signedExtrinsic, - })) + ws.send( + $input.encode({ + type: "subscribe", + channel: "multisig-xyz", + }), + ) + + ws.send( + $input.encode({ + type: "submit", + channel: "multisig-xyz", + signedExtrinsic, + }), + ) }) ws.on("message", (message) => { diff --git a/www/src/components/Setup.tsx b/www/src/components/Setup.tsx index 429cf8b..14c4cae 100644 --- a/www/src/components/Setup.tsx +++ b/www/src/components/Setup.tsx @@ -9,6 +9,7 @@ import { Link } from "react-router-dom" import { useAccountInfo } from "../hooks/useAccountInfo.js" import { useProposals } from "../hooks/useProposals.js" import { accounts, defaultAccount, defaultSender } from "../signals/accounts.js" +import { scope } from "../signals/scope.js" import { formatBalance } from "../util/balance.js" import { toMultiAddressIdRune, toMultisigRune } from "../util/capi-helpers.js" import { AccountId } from "./AccountId.js" @@ -44,7 +45,7 @@ export function Setup({ setup }: Props) { .dbgStatus("Ratify") .finalized() - return ratifyCall.run() + return ratifyCall.run(scope.value) }, onSuccess: (result) => { console.log({ result }) @@ -69,7 +70,7 @@ export function Setup({ setup }: Props) { .dbgStatus("Cancel") .finalized() - return cancelCall.run() + return cancelCall.run(scope.value) }, onSuccess: (result) => { console.log({ result }) diff --git a/www/src/components/wizards/multisig/Fund.tsx b/www/src/components/wizards/multisig/Fund.tsx index baef683..458554e 100644 --- a/www/src/components/wizards/multisig/Fund.tsx +++ b/www/src/components/wizards/multisig/Fund.tsx @@ -3,6 +3,7 @@ import { zodResolver } from "@hookform/resolvers/zod/dist/zod.js" import { signature } from "capi/patterns/signature/polkadot" import { Controller, useForm } from "react-hook-form" import { defaultSender } from "../../../signals/accounts.js" +import { scope } from "../../../signals/scope.js" import { toMultiAddressIdRune } from "../../../util/capi-helpers.js" import { BalanceInput } from "../../BalanceInput.js" import { Button } from "../../Button.js" @@ -23,7 +24,9 @@ export function MultisigFund() { resolver: zodResolver(multisigFundSchema), mode: "onChange", }) - const { value: { fundingAmount, stash } } = wizardData + const { + value: { fundingAmount, stash }, + } = wizardData const onSubmit = async (formDataNew: MultisigFundEntity) => { try { @@ -32,17 +35,16 @@ export function MultisigFund() { if (!sender || !stash) return - const fundStashCall = westend.Balances - .transfer({ - value: BigInt(fundingAmount), // TODO properly scale the amount - dest: toMultiAddressIdRune(stash), - }) + const fundStashCall = westend.Balances.transfer({ + value: BigInt(fundingAmount), // TODO properly scale the amount + dest: toMultiAddressIdRune(stash), + }) .signed(signature({ sender })) .sent() .dbgStatus("Transfer:") .finalized() - await fundStashCall.run() + await fundStashCall.run(scope.value) updateWizardData({ ...formDataNew }) goNext() } catch (exception) { diff --git a/www/src/components/wizards/multisig/Members.tsx b/www/src/components/wizards/multisig/Members.tsx index f29916d..b4f05fb 100644 --- a/www/src/components/wizards/multisig/Members.tsx +++ b/www/src/components/wizards/multisig/Members.tsx @@ -13,6 +13,7 @@ import { defaultAccount, defaultSender, } from "../../../signals/accounts.js" +import { scope } from "../../../signals/scope.js" import { formatBalance } from "../../../util/balance.js" import { toPubKey } from "../../../util/capi-helpers.js" import { @@ -82,8 +83,8 @@ export function MultisigMembers() { ) const multisigAddress = ss58.encode( - await westend.addressPrefix().run(), - await multisig.accountId.run(), + await westend.addressPrefix().run(scope.value), + await multisig.accountId.run(scope.value), ) // TODO can we check if stash already created? previously? @@ -102,9 +103,9 @@ export function MultisigMembers() { .map((events: { pure: unknown }[]) => events.map(({ pure }) => pure)) .access(0) - const stashBytes = (await createStashCall.run()) as Uint8Array + const stashBytes = (await createStashCall.run(scope.value)) as Uint8Array const stashAddress = ss58.encode( - await westend.addressPrefix().run(), + await westend.addressPrefix().run(scope.value), stashBytes, ) console.info("New Stash created at:", stashAddress) @@ -126,7 +127,7 @@ export function MultisigMembers() { .dbgStatus("Replacing Proxy Delegates:") .finalized() - await replaceDelegates.run() + await replaceDelegates.run(scope.value) // TODO save to database instead of localStorage storeSetup(members.map((m) => m?.address) as string[], { diff --git a/www/src/components/wizards/transaction/New.tsx b/www/src/components/wizards/transaction/New.tsx index 1ee8da5..2fae0b0 100644 --- a/www/src/components/wizards/transaction/New.tsx +++ b/www/src/components/wizards/transaction/New.tsx @@ -4,6 +4,7 @@ import { useEffect } from "preact/hooks" import { Controller, SubmitHandler, useForm } from "react-hook-form" import { useSearchParams } from "react-router-dom" import { defaultAccount } from "../../../signals/accounts.js" +import { scope } from "../../../signals/scope.js" import { setups } from "../../../signals/setups.js" import { formatBalance } from "../../../util/balance.js" import { AccountId } from "../../AccountId.js" @@ -35,8 +36,8 @@ export function TransactionNew() { const onSubmit: SubmitHandler = async (formDataNew) => { if (!call.value) return - const callHash = hex.encode(await call.value.callHash.run()) - const callData = hex.encode(await call.value.callData.run()) + const callHash = hex.encode(await call.value.callHash.run(scope.value)) + const callData = hex.encode(await call.value.callData.run(scope.value)) const selectedSetup = setups.peek().find((s) => s.multisig === formDataNew.from?.address ) diff --git a/www/src/components/wizards/transaction/Sign.tsx b/www/src/components/wizards/transaction/Sign.tsx index 9a6ef9f..5be3ade 100644 --- a/www/src/components/wizards/transaction/Sign.tsx +++ b/www/src/components/wizards/transaction/Sign.tsx @@ -8,6 +8,7 @@ import { import { useState } from "preact/hooks" import { useNavigate } from "react-router-dom" +import { scope } from "../../../signals/scope.js" import { toBalance } from "../../../util/balance.js" import { storeCall } from "../../../util/local-storage.js" import { AccountId } from "../../AccountId.js" @@ -50,7 +51,7 @@ export function TransactionSign() { .finalized() ratifyCall - .run() + .run(scope.value) .then(() => storeCall(call)) .then(() => { setSubmitting(false) diff --git a/www/src/components/wizards/transaction/signals.ts b/www/src/components/wizards/transaction/signals.ts index b566425..eb8b987 100644 --- a/www/src/components/wizards/transaction/signals.ts +++ b/www/src/components/wizards/transaction/signals.ts @@ -1,6 +1,7 @@ import { MultiAddress, Westend, westend } from "@capi/westend" import { effect, Signal, signal } from "@preact/signals" import { ExtrinsicRune, ss58 } from "capi" +import { scope } from "../../../signals/scope.js" import { toBalance } from "../../../util/balance.js" import { transactionData } from "./formData.js" @@ -19,7 +20,7 @@ effect(() => { effect(() => { call.value ?.estimate() - .run() + .run(scope.value) .then((estimate: bigint) => { fee.value = estimate }) diff --git a/www/src/hooks/useAccountInfo.ts b/www/src/hooks/useAccountInfo.ts index 8672c3b..2891a3d 100644 --- a/www/src/hooks/useAccountInfo.ts +++ b/www/src/hooks/useAccountInfo.ts @@ -1,5 +1,6 @@ import { westend } from "@capi/westend" import { useQuery } from "@tanstack/react-query" +import { scope } from "../signals/scope.js" import { toPubKey } from "../util/capi-helpers.js" export function useAccountInfo(address: string) { @@ -7,7 +8,7 @@ export function useAccountInfo(address: string) { queryKey: ["AccountInfo", address], queryFn: async () => { const accountInfo = await westend.System.Account.value(toPubKey(address)) - .run() + .run(scope.value) if (!accountInfo) return 0n return accountInfo.data.free }, diff --git a/www/src/hooks/useProposals.ts b/www/src/hooks/useProposals.ts index 93768c8..6621381 100644 --- a/www/src/hooks/useProposals.ts +++ b/www/src/hooks/useProposals.ts @@ -3,6 +3,7 @@ import { useQuery } from "@tanstack/react-query" import { hex } from "capi" import { Setup } from "common" import { useMemo } from "preact/hooks" +import { scope } from "../signals/scope.js" import { toAddress, toMultisigRune } from "../util/capi-helpers.js" import { getCall } from "../util/local-storage.js" @@ -20,7 +21,7 @@ export function useProposals(setup: Setup) { queryKey: ["proposals", setup.id], queryFn: async () => { const proposals: Array> = await multisig.proposals(5) - .run() + .run(scope.value) return Promise.all( proposals.map(async ([, callHashBytes]) => { @@ -30,9 +31,10 @@ export function useProposals(setup: Setup) { callHash, call: getCall(callHash), approvals: - (await multisig.proposal(callHashBytes!).run())?.approvals.map(( - approvalBytes, - ) => toAddress(approvalBytes)) ?? [], + (await multisig.proposal(callHashBytes!).run(scope.value)) + ?.approvals.map( + (approvalBytes) => toAddress(approvalBytes), + ) ?? [], } as Proposal }), ) diff --git a/www/src/signals/scope.ts b/www/src/signals/scope.ts new file mode 100644 index 0000000..b511798 --- /dev/null +++ b/www/src/signals/scope.ts @@ -0,0 +1,6 @@ +import { Signal, signal } from "@preact/signals" +import { Scope } from "capi" + +const scope: Signal = signal(new Scope()) + +export { scope } diff --git a/www/src/util/balance.ts b/www/src/util/balance.ts index 420d99d..e5e2f83 100644 --- a/www/src/util/balance.ts +++ b/www/src/util/balance.ts @@ -1,5 +1,6 @@ import { westend } from "@capi/westend" import { ss58 } from "capi" +import { scope } from "../signals/scope.js" export function formatBalance( balance: bigint, @@ -27,7 +28,9 @@ export function formatBalance( export async function getBalance(address: string) { const addressPubKey = ss58.decode(address)[1] - const balance = await westend.System.Account.value(addressPubKey).run() + const balance = await westend.System.Account.value(addressPubKey).run( + scope.value, + ) if (!balance) throw new Error("Could not retrieve balance") @@ -41,6 +44,8 @@ export function toBalance(value: number, tokenDecimals = 12): bigint { const [integer = "0", _ = "0"] = String(value).split(".") const decimal = _.substring(0, tokenDecimals) - return BigInt(integer) * 10n ** BigInt(tokenDecimals) + return ( + BigInt(integer) * 10n ** BigInt(tokenDecimals) + BigInt(decimal) * 10n ** BigInt(tokenDecimals - decimal.length) + ) } diff --git a/www/src/util/chain-constants.ts b/www/src/util/chain-constants.ts index 3314a10..7388e03 100644 --- a/www/src/util/chain-constants.ts +++ b/www/src/util/chain-constants.ts @@ -1,18 +1,20 @@ import { westend } from "@capi/westend" +import { scope } from "../signals/scope.js" async function getExistentialDeposit() { return await westend.pallet("Balances").constant("ExistentialDeposit").decoded - .run() + .run(scope.value) } async function getProxyDepositBase() { - return await westend.pallet("Proxy").constant("ProxyDepositBase").decoded - .run() + return await westend.pallet("Proxy").constant("ProxyDepositBase").decoded.run( + scope.value, + ) } async function getProxyDepositFactor() { return await westend.pallet("Proxy").constant("ProxyDepositFactor").decoded - .run() + .run(scope.value) } export const PROXY_DEPOSIT_BASE = await getProxyDepositBase() diff --git a/www/src/util/local-storage.ts b/www/src/util/local-storage.ts index 871c75e..d8d518c 100644 --- a/www/src/util/local-storage.ts +++ b/www/src/util/local-storage.ts @@ -2,6 +2,7 @@ import { $runtimeCall, Westend } from "@capi/westend" import { Wallet, WalletAccount } from "@talisman-connect/wallets" import { ExtrinsicRune, hex, Rune } from "capi" import { isSetup, Setup } from "common" +import { scope } from "../signals/scope.js" export function retrieveStored(key: "defaultAccount"): WalletAccount | undefined export function retrieveStored(key: "defaultExtension"): Wallet | undefined @@ -52,7 +53,9 @@ export async function storeCall(call: ExtrinsicRune) { const collection = await Rune.array([ call.callHash.access(), call.callData.access(), - ]).run() + ]).run( + scope.value, + ) const [hash, data] = collection.map((value) => "0x" + hex.encode(value)) if (!hash || !data) throw new Error("Could not store call") diff --git a/www/src/util/transaction.ts b/www/src/util/transaction.ts index 1fac310..38b61a4 100644 --- a/www/src/util/transaction.ts +++ b/www/src/util/transaction.ts @@ -1,5 +1,6 @@ import { MultiAddress, westend } from "@capi/westend" import { ss58 } from "capi" +import { scope } from "../signals/scope.js" import { isValidAddress } from "./address.js" export async function estimateFee(address: string, value: bigint) { @@ -10,6 +11,6 @@ export async function estimateFee(address: string, value: bigint) { dest: MultiAddress.Id(addressPubKey), }) .estimate() - .run() + .run(scope.value) return fee } From ccd1c4643b8c4d64b16a41287e785361da286eaa Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Mon, 19 Jun 2023 12:16:14 +0200 Subject: [PATCH 06/14] adds required types --- www/src/signals/accounts.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/www/src/signals/accounts.ts b/www/src/signals/accounts.ts index aa0909d..f4b86e8 100644 --- a/www/src/signals/accounts.ts +++ b/www/src/signals/accounts.ts @@ -1,6 +1,13 @@ -import { westend } from "@capi/westend" -import { computed, effect, signal } from "@preact/signals" +import { Westend, westend } from "@capi/westend" +import { + computed, + effect, + ReadonlySignal, + Signal, + signal, +} from "@preact/signals" import { getWalletBySource, WalletAccount } from "@talisman-connect/wallets" +import { ExtrinsicSender, ValueRune } from "capi" import { pjsSender } from "capi/patterns/compat/pjs_sender" import { retrieveStored } from "../util/local-storage.js" import { retry } from "../util/retry.js" @@ -9,12 +16,14 @@ interface InjectedWindow extends Window { injectedWeb3: unknown } -const accounts = signal([]) +const accounts: Signal = signal([]) const storedAccount = retrieveStored("defaultAccount") const storedExtension = retrieveStored("defaultExtension") const defaultAccount = signal(storedAccount) const defaultExtension = signal(storedExtension) -const defaultSender = computed(() => { +const defaultSender: ReadonlySignal< + ValueRune, never> | undefined +> = computed(() => { const { signer } = defaultExtension.value || {} const { address: userAddress } = defaultAccount.value || {} if (!signer || !userAddress) return From 169a968da7f25f983e6fbf0e6c957be5017f80bd Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Mon, 19 Jun 2023 12:16:56 +0200 Subject: [PATCH 07/14] removes reference to other typescript project from root ts file which is only for `nets.ts`, this caused build issues as they reference each other and don't allow changes --- tsconfig.json | 3 +-- www/tsconfig.json | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 78465f0..f02e7fd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,5 @@ "compilerOptions": { "noEmit": true }, - "files": ["nets.ts"], - "references": [{ "path": "www" }, { "path": "server" }, { "path": "common" }] + "files": ["nets.ts"] } diff --git a/www/tsconfig.json b/www/tsconfig.json index 28e712b..1e7eb93 100644 --- a/www/tsconfig.json +++ b/www/tsconfig.json @@ -8,8 +8,5 @@ "pages": ["src/pages"], "signals": ["src/signals"] }, - "references": [ - { "path": "../common" }, - { "path": "../server" } - ] + "references": [{ "path": "../common" }, { "path": "../server" }] } From da02aee4fd8fd73c94510d4c8fd019d07f7e1d82 Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Mon, 19 Jun 2023 12:38:18 +0200 Subject: [PATCH 08/14] setting `nets.ts` to files breaks tsconfig in modules. Let's fix this later somehow different :space_invader: --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index f02e7fd..f00d3fd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,5 +3,6 @@ "compilerOptions": { "noEmit": true }, - "files": ["nets.ts"] + "files": [], + "references": [{ "path": "www" }, { "path": "server" }, { "path": "common" }] } From 392319eca571fd10804787c94e3eb00f33c4efff Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Mon, 19 Jun 2023 17:00:09 +0200 Subject: [PATCH 09/14] creating scope as simple var --- www/src/components/Setup.tsx | 2 +- www/src/components/wizards/multisig/Fund.tsx | 2 +- www/src/components/wizards/multisig/Members.tsx | 2 +- www/src/components/wizards/transaction/New.tsx | 2 +- www/src/components/wizards/transaction/Sign.tsx | 2 +- www/src/components/wizards/transaction/signals.ts | 2 +- www/src/hooks/useAccountInfo.ts | 2 +- www/src/hooks/useProposals.ts | 2 +- www/src/signals/scope.ts | 6 ------ www/src/util/balance.ts | 2 +- www/src/util/chain-constants.ts | 2 +- www/src/util/local-storage.ts | 2 +- www/src/util/scope.ts | 5 +++++ www/src/util/transaction.ts | 2 +- 14 files changed, 17 insertions(+), 18 deletions(-) delete mode 100644 www/src/signals/scope.ts create mode 100644 www/src/util/scope.ts diff --git a/www/src/components/Setup.tsx b/www/src/components/Setup.tsx index 14c4cae..42a3079 100644 --- a/www/src/components/Setup.tsx +++ b/www/src/components/Setup.tsx @@ -9,9 +9,9 @@ import { Link } from "react-router-dom" import { useAccountInfo } from "../hooks/useAccountInfo.js" import { useProposals } from "../hooks/useProposals.js" import { accounts, defaultAccount, defaultSender } from "../signals/accounts.js" -import { scope } from "../signals/scope.js" import { formatBalance } from "../util/balance.js" import { toMultiAddressIdRune, toMultisigRune } from "../util/capi-helpers.js" +import { scope } from "../util/scope.js" import { AccountId } from "./AccountId.js" import { Button } from "./Button.js" import { CenteredCard } from "./CenteredCard.js" diff --git a/www/src/components/wizards/multisig/Fund.tsx b/www/src/components/wizards/multisig/Fund.tsx index 458554e..477772e 100644 --- a/www/src/components/wizards/multisig/Fund.tsx +++ b/www/src/components/wizards/multisig/Fund.tsx @@ -3,8 +3,8 @@ import { zodResolver } from "@hookform/resolvers/zod/dist/zod.js" import { signature } from "capi/patterns/signature/polkadot" import { Controller, useForm } from "react-hook-form" import { defaultSender } from "../../../signals/accounts.js" -import { scope } from "../../../signals/scope.js" import { toMultiAddressIdRune } from "../../../util/capi-helpers.js" +import { scope } from "../../../util/scope.js" import { BalanceInput } from "../../BalanceInput.js" import { Button } from "../../Button.js" import { goNext } from "../Wizard.js" diff --git a/www/src/components/wizards/multisig/Members.tsx b/www/src/components/wizards/multisig/Members.tsx index b4f05fb..0412cc0 100644 --- a/www/src/components/wizards/multisig/Members.tsx +++ b/www/src/components/wizards/multisig/Members.tsx @@ -13,7 +13,6 @@ import { defaultAccount, defaultSender, } from "../../../signals/accounts.js" -import { scope } from "../../../signals/scope.js" import { formatBalance } from "../../../util/balance.js" import { toPubKey } from "../../../util/capi-helpers.js" import { @@ -21,6 +20,7 @@ import { PROXY_DEPOSIT_FACTOR, } from "../../../util/chain-constants.js" import { storeSetup } from "../../../util/local-storage.js" +import { scope } from "../../../util/scope.js" import { AccountSelect } from "../../AccountSelect.js" import { Button } from "../../Button.js" import { IconChevronLeft } from "../../icons/IconChevronLeft.js" diff --git a/www/src/components/wizards/transaction/New.tsx b/www/src/components/wizards/transaction/New.tsx index 2fae0b0..ed4494a 100644 --- a/www/src/components/wizards/transaction/New.tsx +++ b/www/src/components/wizards/transaction/New.tsx @@ -4,9 +4,9 @@ import { useEffect } from "preact/hooks" import { Controller, SubmitHandler, useForm } from "react-hook-form" import { useSearchParams } from "react-router-dom" import { defaultAccount } from "../../../signals/accounts.js" -import { scope } from "../../../signals/scope.js" import { setups } from "../../../signals/setups.js" import { formatBalance } from "../../../util/balance.js" +import { scope } from "../../../util/scope.js" import { AccountId } from "../../AccountId.js" import { AccountSelect } from "../../AccountSelect.js" import { AddressInput } from "../../AddressInput.js" diff --git a/www/src/components/wizards/transaction/Sign.tsx b/www/src/components/wizards/transaction/Sign.tsx index 5be3ade..9bf0290 100644 --- a/www/src/components/wizards/transaction/Sign.tsx +++ b/www/src/components/wizards/transaction/Sign.tsx @@ -8,9 +8,9 @@ import { import { useState } from "preact/hooks" import { useNavigate } from "react-router-dom" -import { scope } from "../../../signals/scope.js" import { toBalance } from "../../../util/balance.js" import { storeCall } from "../../../util/local-storage.js" +import { scope } from "../../../util/scope.js" import { AccountId } from "../../AccountId.js" import { Button } from "../../Button.js" import { IconTrash } from "../../icons/IconTrash.js" diff --git a/www/src/components/wizards/transaction/signals.ts b/www/src/components/wizards/transaction/signals.ts index eb8b987..19c55c6 100644 --- a/www/src/components/wizards/transaction/signals.ts +++ b/www/src/components/wizards/transaction/signals.ts @@ -1,8 +1,8 @@ import { MultiAddress, Westend, westend } from "@capi/westend" import { effect, Signal, signal } from "@preact/signals" import { ExtrinsicRune, ss58 } from "capi" -import { scope } from "../../../signals/scope.js" import { toBalance } from "../../../util/balance.js" +import { scope } from "../../../util/scope.js" import { transactionData } from "./formData.js" export const call = signal | undefined>(undefined) diff --git a/www/src/hooks/useAccountInfo.ts b/www/src/hooks/useAccountInfo.ts index 2891a3d..7e0d512 100644 --- a/www/src/hooks/useAccountInfo.ts +++ b/www/src/hooks/useAccountInfo.ts @@ -1,7 +1,7 @@ import { westend } from "@capi/westend" import { useQuery } from "@tanstack/react-query" -import { scope } from "../signals/scope.js" import { toPubKey } from "../util/capi-helpers.js" +import { scope } from "../util/scope.js" export function useAccountInfo(address: string) { return useQuery({ diff --git a/www/src/hooks/useProposals.ts b/www/src/hooks/useProposals.ts index 6621381..52c4a61 100644 --- a/www/src/hooks/useProposals.ts +++ b/www/src/hooks/useProposals.ts @@ -3,9 +3,9 @@ import { useQuery } from "@tanstack/react-query" import { hex } from "capi" import { Setup } from "common" import { useMemo } from "preact/hooks" -import { scope } from "../signals/scope.js" import { toAddress, toMultisigRune } from "../util/capi-helpers.js" import { getCall } from "../util/local-storage.js" +import { scope } from "../util/scope.js" type Proposal = { callHash: string diff --git a/www/src/signals/scope.ts b/www/src/signals/scope.ts deleted file mode 100644 index b511798..0000000 --- a/www/src/signals/scope.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Signal, signal } from "@preact/signals" -import { Scope } from "capi" - -const scope: Signal = signal(new Scope()) - -export { scope } diff --git a/www/src/util/balance.ts b/www/src/util/balance.ts index e5e2f83..bfd4dcf 100644 --- a/www/src/util/balance.ts +++ b/www/src/util/balance.ts @@ -1,6 +1,6 @@ import { westend } from "@capi/westend" import { ss58 } from "capi" -import { scope } from "../signals/scope.js" +import { scope } from "./scope.js" export function formatBalance( balance: bigint, diff --git a/www/src/util/chain-constants.ts b/www/src/util/chain-constants.ts index 7388e03..a3929d1 100644 --- a/www/src/util/chain-constants.ts +++ b/www/src/util/chain-constants.ts @@ -1,5 +1,5 @@ import { westend } from "@capi/westend" -import { scope } from "../signals/scope.js" +import { scope } from "./scope.js" async function getExistentialDeposit() { return await westend.pallet("Balances").constant("ExistentialDeposit").decoded diff --git a/www/src/util/local-storage.ts b/www/src/util/local-storage.ts index d8d518c..7bfe492 100644 --- a/www/src/util/local-storage.ts +++ b/www/src/util/local-storage.ts @@ -2,7 +2,7 @@ import { $runtimeCall, Westend } from "@capi/westend" import { Wallet, WalletAccount } from "@talisman-connect/wallets" import { ExtrinsicRune, hex, Rune } from "capi" import { isSetup, Setup } from "common" -import { scope } from "../signals/scope.js" +import { scope } from "./scope.js" export function retrieveStored(key: "defaultAccount"): WalletAccount | undefined export function retrieveStored(key: "defaultExtension"): Wallet | undefined diff --git a/www/src/util/scope.ts b/www/src/util/scope.ts new file mode 100644 index 0000000..a99756c --- /dev/null +++ b/www/src/util/scope.ts @@ -0,0 +1,5 @@ +import { Scope } from "capi" + +const scope = new Scope() + +export { scope } diff --git a/www/src/util/transaction.ts b/www/src/util/transaction.ts index 38b61a4..9d53b3f 100644 --- a/www/src/util/transaction.ts +++ b/www/src/util/transaction.ts @@ -1,7 +1,7 @@ import { MultiAddress, westend } from "@capi/westend" import { ss58 } from "capi" -import { scope } from "../signals/scope.js" import { isValidAddress } from "./address.js" +import { scope } from "./scope.js" export async function estimateFee(address: string, value: bigint) { if (!address || !isValidAddress(address)) throw new Error("Invalid address") From a4585fb832b1115e3d6df07d9c7fab040b585a43 Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Mon, 19 Jun 2023 17:03:12 +0200 Subject: [PATCH 10/14] use scope as is not as signal --- www/src/components/Setup.tsx | 151 ++++++++++-------- www/src/components/wizards/multisig/Fund.tsx | 50 +++--- .../components/wizards/multisig/Members.tsx | 139 +++++++++------- .../components/wizards/transaction/New.tsx | 4 +- .../components/wizards/transaction/Sign.tsx | 2 +- .../components/wizards/transaction/signals.ts | 2 +- www/src/hooks/useAccountInfo.ts | 2 +- www/src/hooks/useProposals.ts | 8 +- www/src/util/balance.ts | 4 +- www/src/util/chain-constants.ts | 6 +- www/src/util/local-storage.ts | 4 +- www/src/util/transaction.ts | 2 +- 12 files changed, 197 insertions(+), 177 deletions(-) diff --git a/www/src/components/Setup.tsx b/www/src/components/Setup.tsx index 797ed00..f5f4823 100644 --- a/www/src/components/Setup.tsx +++ b/www/src/components/Setup.tsx @@ -1,44 +1,44 @@ -import { Setup as SetupType } from "common"; - -import { RuntimeCall } from "@capi/westend"; -import { useMutation } from "@tanstack/react-query"; -import { hex } from "capi"; -import { signature } from "capi/patterns/signature/polkadot"; -import { useMemo } from "preact/hooks"; -import { Link } from "react-router-dom"; -import { useAccountInfo } from "../hooks/useAccountInfo.js"; -import { useProposals } from "../hooks/useProposals.js"; -import { accounts, defaultAccount, defaultSender } from "../signals/accounts.js"; -import { formatBalance } from "../util/balance.js"; -import { toMultiAddressIdRune, toMultisigRune } from "../util/capi-helpers.js"; -import { filterEvents, handleException } from "../util/events.js"; -import { scope } from "../util/scope.js"; -import { AccountId } from "./AccountId.js"; -import { Button } from "./Button.js"; -import { CenteredCard } from "./CenteredCard.js"; -import { IconBell } from "./icons/IconBell.js"; -import { IconPlus } from "./icons/IconPlus.js"; -import { IconTrash } from "./icons/IconTrash.js"; -import { Identicon } from "./identicon/Identicon.js"; +import { Setup as SetupType } from "common" + +import { RuntimeCall } from "@capi/westend" +import { useMutation } from "@tanstack/react-query" +import { hex } from "capi" +import { signature } from "capi/patterns/signature/polkadot" +import { useMemo } from "preact/hooks" +import { Link } from "react-router-dom" +import { useAccountInfo } from "../hooks/useAccountInfo.js" +import { useProposals } from "../hooks/useProposals.js" +import { accounts, defaultAccount, defaultSender } from "../signals/accounts.js" +import { formatBalance } from "../util/balance.js" +import { toMultiAddressIdRune, toMultisigRune } from "../util/capi-helpers.js" +import { filterEvents, handleException } from "../util/events.js" +import { scope } from "../util/scope.js" +import { AccountId } from "./AccountId.js" +import { Button } from "./Button.js" +import { CenteredCard } from "./CenteredCard.js" +import { IconBell } from "./icons/IconBell.js" +import { IconPlus } from "./icons/IconPlus.js" +import { IconTrash } from "./icons/IconTrash.js" +import { Identicon } from "./identicon/Identicon.js" interface Props { - setup: SetupType; + setup: SetupType } export function Setup({ setup }: Props) { - const multisig = useMemo(() => toMultisigRune(setup), [setup]); - const { data: balance } = useAccountInfo(setup.stash); - const { data: proposals, refetch: refetchProposals } = useProposals(setup); + const multisig = useMemo(() => toMultisigRune(setup), [setup]) + const { data: balance } = useAccountInfo(setup.stash) + const { data: proposals, refetch: refetchProposals } = useProposals(setup) const { mutate: ratify, isLoading: isRatifying } = useMutation({ mutationFn: async (call: RuntimeCall) => { - const sender = defaultSender.value; - const account = defaultAccount.value; + const sender = defaultSender.value + const account = defaultAccount.value if (!setup || !sender || !account) { - throw new Error("Missing setup, sender or account"); + throw new Error("Missing setup, sender or account") } - const user = toMultiAddressIdRune(account.address); + const user = toMultiAddressIdRune(account.address) const ratifyCall = multisig .ratify(user, call) .signed(signature({ sender })) @@ -46,26 +46,26 @@ export function Setup({ setup }: Props) { .dbgStatus("Ratify") .inBlockEvents() .unhandleFailed() - .pipe(filterEvents); + .pipe(filterEvents) - return ratifyCall.run(scope); + return ratifyCall.run(scope) }, onSuccess: (result) => { - console.log({ result }); - refetchProposals(); + console.log({ result }) + refetchProposals() }, onError: (error) => console.error(error), - }); + }) const { mutate: cancel, isLoading: isCanceling } = useMutation({ mutationFn: async (callHash: string) => { - const sender = defaultSender.value; - const account = defaultAccount.value; + const sender = defaultSender.value + const account = defaultAccount.value if (!setup || !sender || !account) { - throw new Error("Missing setup, sender or account"); + throw new Error("Missing setup, sender or account") } - const user = toMultiAddressIdRune(account.address); + const user = toMultiAddressIdRune(account.address) const cancelCall = multisig .cancel(user, hex.decode(callHash)) .signed(signature({ sender })) @@ -73,18 +73,18 @@ export function Setup({ setup }: Props) { .dbgStatus("Cancel") .inBlockEvents() .unhandleFailed() - .pipe(filterEvents); + .pipe(filterEvents) - return cancelCall.run(scope); + return cancelCall.run(scope) }, onSuccess: (result) => { - console.log({ result }); - refetchProposals(); + console.log({ result }) + refetchProposals() }, onError: (error: any) => { - handleException(error); + handleException(error) }, - }); + }) return ( @@ -109,7 +109,9 @@ export function Setup({ setup }: Props) {
Multisig {setup.threshold}/{setup.members.length}
-
{`Balance: ${balance ? formatBalance(balance) : "N/A"} DOT`}
+
+ {`Balance: ${balance ? formatBalance(balance) : "N/A"} DOT`} +
0 && "bg-green-500 text-white rounded-sm" + proposals && proposals.length > 0 + && "bg-green-500 text-white rounded-sm" }`} > 0 ? "white" : undefined} + fill={proposals && proposals.length > 0 + ? "white" + : undefined} />
- {proposals && proposals?.length > 0 ? `${proposals?.length} ` : "No "} Pending - Transactions + {proposals && proposals?.length > 0 + ? `${proposals?.length} ` + : "No "} Pending Transactions
@@ -143,17 +149,15 @@ export function Setup({ setup }: Props) { a.address === member[0])?.name || - "Member " + (index + 1) - } + name={accounts.value.find((a) => a.address === member[0])?.name + || "Member " + (index + 1)} /> ))} - {proposals && - proposals.map(({ callHash, call, approvals }) => ( + {proposals + && proposals.map(({ callHash, call, approvals }) => ( <>
@@ -165,20 +169,25 @@ export function Setup({ setup }: Props) {
{callHash}
- {!approvals.includes(defaultAccount.value?.address!) ? ( - - ) : ( - - )} + {!approvals.includes(defaultAccount.value?.address!) + ? ( + + ) + : ( + + )}
@@ -200,5 +209,5 @@ export function Setup({ setup }: Props) {
- ); + ) } diff --git a/www/src/components/wizards/multisig/Fund.tsx b/www/src/components/wizards/multisig/Fund.tsx index d9ce232..d077953 100644 --- a/www/src/components/wizards/multisig/Fund.tsx +++ b/www/src/components/wizards/multisig/Fund.tsx @@ -1,21 +1,21 @@ -import { westend } from "@capi/westend"; -import { zodResolver } from "@hookform/resolvers/zod/dist/zod.js"; -import { signature } from "capi/patterns/signature/polkadot"; -import { Controller, useForm } from "react-hook-form"; -import { defaultSender } from "../../../signals/accounts.js"; -import { toBalance } from "../../../util/balance.js"; -import { toMultiAddressIdRune } from "../../../util/capi-helpers.js"; -import { filterEvents, handleException } from "../../../util/events.js"; -import { scope } from "../../../util/scope.js"; -import { BalanceInput } from "../../BalanceInput.js"; -import { Button } from "../../Button.js"; -import { goNext } from "../Wizard.js"; +import { westend } from "@capi/westend" +import { zodResolver } from "@hookform/resolvers/zod/dist/zod.js" +import { signature } from "capi/patterns/signature/polkadot" +import { Controller, useForm } from "react-hook-form" +import { defaultSender } from "../../../signals/accounts.js" +import { toBalance } from "../../../util/balance.js" +import { toMultiAddressIdRune } from "../../../util/capi-helpers.js" +import { filterEvents, handleException } from "../../../util/events.js" +import { scope } from "../../../util/scope.js" +import { BalanceInput } from "../../BalanceInput.js" +import { Button } from "../../Button.js" +import { goNext } from "../Wizard.js" import { MultisigFundEntity, multisigFundSchema, updateWizardData, wizardData, -} from "./wizardData.js"; +} from "./wizardData.js" export function MultisigFund() { const { @@ -25,17 +25,17 @@ export function MultisigFund() { } = useForm({ resolver: zodResolver(multisigFundSchema), mode: "onChange", - }); + }) const { value: { fundingAmount, stash }, - } = wizardData; + } = wizardData const onSubmit = async (formDataNew: MultisigFundEntity) => { try { - const sender = defaultSender.value; - const { fundingAmount } = formDataNew; + const sender = defaultSender.value + const { fundingAmount } = formDataNew - if (!sender || !stash) return; + if (!sender || !stash) return const fundStashCall = westend.Balances.transfer({ value: toBalance(fundingAmount), @@ -46,15 +46,15 @@ export function MultisigFund() { .dbgStatus("Transfer:") .inBlockEvents() .unhandleFailed() - .pipe(filterEvents); + .pipe(filterEvents) - await fundStashCall.run(scope); - updateWizardData({ ...formDataNew }); - goNext(); + await fundStashCall.run(scope) + updateWizardData({ ...formDataNew }) + goNext() } catch (exception: any) { - handleException(exception); + handleException(exception) } - }; + } return (
@@ -85,5 +85,5 @@ export function MultisigFund() {
- ); + ) } diff --git a/www/src/components/wizards/multisig/Members.tsx b/www/src/components/wizards/multisig/Members.tsx index 6a33ef3..0454fa3 100644 --- a/www/src/components/wizards/multisig/Members.tsx +++ b/www/src/components/wizards/multisig/Members.tsx @@ -1,37 +1,48 @@ -import { MultiAddress, Westend, westend } from "@capi/westend"; -import { zodResolver } from "@hookform/resolvers/zod/dist/zod.js"; -import { Rune, ss58 } from "capi"; -import { MultisigRune } from "capi/patterns/multisig"; -import { signature } from "capi/patterns/signature/polkadot"; -import { filterPureCreatedEvents, replaceDelegateCalls } from "capi/patterns/unstable/proxy"; -import { Controller, useForm } from "react-hook-form"; -import { accounts, defaultAccount, defaultSender } from "../../../signals/accounts.js"; -import { formatBalance } from "../../../util/balance.js"; -import { toPubKey } from "../../../util/capi-helpers.js"; -import { PROXY_DEPOSIT_BASE, PROXY_DEPOSIT_FACTOR } from "../../../util/chain-constants.js"; -import { filterEvents, handleException } from "../../../util/events.js"; -import { storeSetup } from "../../../util/local-storage.js"; -import { scope } from "../../../util/scope.js"; -import { AccountSelect } from "../../AccountSelect.js"; -import { Button } from "../../Button.js"; -import { InputError } from "../../InputError.js"; -import { Row, SumTable } from "../../SumTable.js"; -import { IconChevronLeft } from "../../icons/IconChevronLeft.js"; -import { goNext, goPrev } from "../Wizard.js"; +import { MultiAddress, Westend, westend } from "@capi/westend" +import { zodResolver } from "@hookform/resolvers/zod/dist/zod.js" +import { Rune, ss58 } from "capi" +import { MultisigRune } from "capi/patterns/multisig" +import { signature } from "capi/patterns/signature/polkadot" +import { + filterPureCreatedEvents, + replaceDelegateCalls, +} from "capi/patterns/unstable/proxy" +import { Controller, useForm } from "react-hook-form" +import { + accounts, + defaultAccount, + defaultSender, +} from "../../../signals/accounts.js" +import { formatBalance } from "../../../util/balance.js" +import { toPubKey } from "../../../util/capi-helpers.js" +import { + PROXY_DEPOSIT_BASE, + PROXY_DEPOSIT_FACTOR, +} from "../../../util/chain-constants.js" +import { filterEvents, handleException } from "../../../util/events.js" +import { storeSetup } from "../../../util/local-storage.js" +import { scope } from "../../../util/scope.js" +import { AccountSelect } from "../../AccountSelect.js" +import { Button } from "../../Button.js" +import { IconChevronLeft } from "../../icons/IconChevronLeft.js" +import { InputError } from "../../InputError.js" +import { Row, SumTable } from "../../SumTable.js" +import { goNext, goPrev } from "../Wizard.js" import { MultisigMemberEntity, multisigMemberSchema, updateWizardData, wizardData, -} from "./wizardData.js"; +} from "./wizardData.js" const multisigCreationFees: Row[] = [ { name: "Proxy fee", value: formatBalance(PROXY_DEPOSIT_BASE + PROXY_DEPOSIT_FACTOR), - info: "Amount reserved for the creation of a PureProxy that holds the multisig funds. The multisig account acts as AnyProxy for this account.", + info: + "Amount reserved for the creation of a PureProxy that holds the multisig funds. The multisig account acts as AnyProxy for this account.", }, -]; +] export function MultisigMembers() { const { @@ -42,37 +53,40 @@ export function MultisigMembers() { } = useForm({ resolver: zodResolver(multisigMemberSchema), mode: "onChange", - }); + }) const onBack = (formDataNew: MultisigMemberEntity) => { - updateWizardData(formDataNew); - goPrev(); - }; + updateWizardData(formDataNew) + goPrev() + } const onErrorBack = () => { - const formDataWithErrors = getValues(); - updateWizardData(formDataWithErrors); - goPrev(); - }; + const formDataWithErrors = getValues() + updateWizardData(formDataWithErrors) + goPrev() + } const onSubmit = async (formDataNew: MultisigMemberEntity) => { try { - if (!defaultSender.value || !defaultAccount.value) return; + if (!defaultSender.value || !defaultAccount.value) return - const { threshold } = wizardData.value; - const { members } = formDataNew; + const { threshold } = wizardData.value + const { members } = formDataNew - const signatories = members.map((member) => toPubKey(member!.address)); + const signatories = members.map((member) => toPubKey(member!.address)) - const multisig: MultisigRune = MultisigRune.from(westend, { - signatories, - threshold, - }); + const multisig: MultisigRune = MultisigRune.from( + westend, + { + signatories, + threshold, + }, + ) const multisigAddress = ss58.encode( await westend.addressPrefix().run(scope), - await multisig.accountId.run(scope) - ); + await multisig.accountId.run(scope), + ) // TODO can we check if stash already created? previously? const createStashCall = westend.Proxy.createPure({ @@ -88,13 +102,16 @@ export function MultisigMembers() { .pipe(filterPureCreatedEvents) // TODO typing is broken in capi .map((events: { pure: unknown }[]) => events.map(({ pure }) => pure)) - .access(0); + .access(0) - const stashBytes = (await createStashCall.run(scope)) as Uint8Array; - const stashAddress = ss58.encode(await westend.addressPrefix().run(scope), stashBytes); - console.info("New Stash created at:", stashAddress); + const stashBytes = (await createStashCall.run(scope)) as Uint8Array + const stashAddress = ss58.encode( + await westend.addressPrefix().run(scope), + stashBytes, + ) + console.info("New Stash created at:", stashAddress) - const [_, userAddressBytes] = ss58.decode(defaultAccount.value.address); + const [_, userAddressBytes] = ss58.decode(defaultAccount.value.address) // TODO can we somehow check if the delegation has already been done? const replaceDelegates = westend.Utility.batchAll({ calls: Rune.array( @@ -102,8 +119,8 @@ export function MultisigMembers() { westend, MultiAddress.Id(stashBytes), // effected account MultiAddress.Id(userAddressBytes), // from - multisig.address // to - ) + multisig.address, // to + ), ), }) .signed(signature({ sender: defaultSender.value })) @@ -111,9 +128,9 @@ export function MultisigMembers() { .dbgStatus("Replacing Proxy Delegates:") .inBlockEvents() .unhandleFailed() - .pipe(filterEvents); + .pipe(filterEvents) - await replaceDelegates.run(scope); + await replaceDelegates.run(scope) // TODO save to database instead of localStorage storeSetup(members.map((m) => m?.address) as string[], { @@ -126,19 +143,19 @@ export function MultisigMembers() { multisig: multisigAddress, stash: stashAddress, history: [], - }); + }) updateWizardData({ ...formDataNew, address: multisigAddress, stash: stashAddress, - }); + }) - goNext(); + goNext() } catch (exception) { - handleException(exception); + handleException(exception) } - }; + } return (
@@ -153,18 +170,18 @@ export function MultisigMembers() { control={control} name={`members.${i}`} defaultValue={member} - render={({ field }) => } + render={({ field }) => ( + + )} /> {errors.members && } - ); + ) })} {errors.members && } - {multisigCreationFees.map((fee) => ( - - ))} + {multisigCreationFees.map((fee) => )}
@@ -181,5 +198,5 @@ export function MultisigMembers() {
- ); + ) } diff --git a/www/src/components/wizards/transaction/New.tsx b/www/src/components/wizards/transaction/New.tsx index ed4494a..15b3522 100644 --- a/www/src/components/wizards/transaction/New.tsx +++ b/www/src/components/wizards/transaction/New.tsx @@ -36,8 +36,8 @@ export function TransactionNew() { const onSubmit: SubmitHandler = async (formDataNew) => { if (!call.value) return - const callHash = hex.encode(await call.value.callHash.run(scope.value)) - const callData = hex.encode(await call.value.callData.run(scope.value)) + const callHash = hex.encode(await call.value.callHash.run(scope)) + const callData = hex.encode(await call.value.callData.run(scope)) const selectedSetup = setups.peek().find((s) => s.multisig === formDataNew.from?.address ) diff --git a/www/src/components/wizards/transaction/Sign.tsx b/www/src/components/wizards/transaction/Sign.tsx index 3c1223b..e97cc89 100644 --- a/www/src/components/wizards/transaction/Sign.tsx +++ b/www/src/components/wizards/transaction/Sign.tsx @@ -54,7 +54,7 @@ export function TransactionSign() { .pipe(filterEvents) ratifyCall - .run(scope.value) + .run(scope) .then(() => storeCall(call)) .then(() => { setSubmitting(false) diff --git a/www/src/components/wizards/transaction/signals.ts b/www/src/components/wizards/transaction/signals.ts index 19c55c6..ac63a4a 100644 --- a/www/src/components/wizards/transaction/signals.ts +++ b/www/src/components/wizards/transaction/signals.ts @@ -20,7 +20,7 @@ effect(() => { effect(() => { call.value ?.estimate() - .run(scope.value) + .run(scope) .then((estimate: bigint) => { fee.value = estimate }) diff --git a/www/src/hooks/useAccountInfo.ts b/www/src/hooks/useAccountInfo.ts index 7e0d512..cff8043 100644 --- a/www/src/hooks/useAccountInfo.ts +++ b/www/src/hooks/useAccountInfo.ts @@ -8,7 +8,7 @@ export function useAccountInfo(address: string) { queryKey: ["AccountInfo", address], queryFn: async () => { const accountInfo = await westend.System.Account.value(toPubKey(address)) - .run(scope.value) + .run(scope) if (!accountInfo) return 0n return accountInfo.data.free }, diff --git a/www/src/hooks/useProposals.ts b/www/src/hooks/useProposals.ts index 52c4a61..666a277 100644 --- a/www/src/hooks/useProposals.ts +++ b/www/src/hooks/useProposals.ts @@ -21,7 +21,7 @@ export function useProposals(setup: Setup) { queryKey: ["proposals", setup.id], queryFn: async () => { const proposals: Array> = await multisig.proposals(5) - .run(scope.value) + .run(scope) return Promise.all( proposals.map(async ([, callHashBytes]) => { @@ -31,10 +31,8 @@ export function useProposals(setup: Setup) { callHash, call: getCall(callHash), approvals: - (await multisig.proposal(callHashBytes!).run(scope.value)) - ?.approvals.map( - (approvalBytes) => toAddress(approvalBytes), - ) ?? [], + (await multisig.proposal(callHashBytes!).run(scope))?.approvals + .map((approvalBytes) => toAddress(approvalBytes)) ?? [], } as Proposal }), ) diff --git a/www/src/util/balance.ts b/www/src/util/balance.ts index bfd4dcf..f4ccebd 100644 --- a/www/src/util/balance.ts +++ b/www/src/util/balance.ts @@ -28,9 +28,7 @@ export function formatBalance( export async function getBalance(address: string) { const addressPubKey = ss58.decode(address)[1] - const balance = await westend.System.Account.value(addressPubKey).run( - scope.value, - ) + const balance = await westend.System.Account.value(addressPubKey).run(scope) if (!balance) throw new Error("Could not retrieve balance") diff --git a/www/src/util/chain-constants.ts b/www/src/util/chain-constants.ts index a3929d1..1728755 100644 --- a/www/src/util/chain-constants.ts +++ b/www/src/util/chain-constants.ts @@ -3,18 +3,18 @@ import { scope } from "./scope.js" async function getExistentialDeposit() { return await westend.pallet("Balances").constant("ExistentialDeposit").decoded - .run(scope.value) + .run(scope) } async function getProxyDepositBase() { return await westend.pallet("Proxy").constant("ProxyDepositBase").decoded.run( - scope.value, + scope, ) } async function getProxyDepositFactor() { return await westend.pallet("Proxy").constant("ProxyDepositFactor").decoded - .run(scope.value) + .run(scope) } export const PROXY_DEPOSIT_BASE = await getProxyDepositBase() diff --git a/www/src/util/local-storage.ts b/www/src/util/local-storage.ts index 7bfe492..c9d10fe 100644 --- a/www/src/util/local-storage.ts +++ b/www/src/util/local-storage.ts @@ -53,9 +53,7 @@ export async function storeCall(call: ExtrinsicRune) { const collection = await Rune.array([ call.callHash.access(), call.callData.access(), - ]).run( - scope.value, - ) + ]).run(scope) const [hash, data] = collection.map((value) => "0x" + hex.encode(value)) if (!hash || !data) throw new Error("Could not store call") diff --git a/www/src/util/transaction.ts b/www/src/util/transaction.ts index 9d53b3f..d522f48 100644 --- a/www/src/util/transaction.ts +++ b/www/src/util/transaction.ts @@ -11,6 +11,6 @@ export async function estimateFee(address: string, value: bigint) { dest: MultiAddress.Id(addressPubKey), }) .estimate() - .run(scope.value) + .run(scope) return fee } From 016b901f3aad5f72fa30d181c6faa2eec7e8165c Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Mon, 19 Jun 2023 17:04:36 +0200 Subject: [PATCH 11/14] removes old example scripts --- server/scripts/README.md | 1 - server/scripts/create-user.ts | 10 ------- server/scripts/send-transfer.ts | 48 --------------------------------- 3 files changed, 59 deletions(-) delete mode 100644 server/scripts/README.md delete mode 100644 server/scripts/create-user.ts delete mode 100644 server/scripts/send-transfer.ts diff --git a/server/scripts/README.md b/server/scripts/README.md deleted file mode 100644 index c481d9f..0000000 --- a/server/scripts/README.md +++ /dev/null @@ -1 +0,0 @@ -Utility scripts for testing diff --git a/server/scripts/create-user.ts b/server/scripts/create-user.ts deleted file mode 100644 index d551e99..0000000 --- a/server/scripts/create-user.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { westend } from "@capi/westend" -import { hex, Sr25519, ss58 } from "capi" -import * as crypto from "crypto" - -const secret = crypto.getRandomValues(new Uint8Array(64)) -const kp = Sr25519.fromSecret(secret) -const address = ss58.encode(westend.System.SS58Prefix, kp.publicKey) - -console.log("secret:", hex.encode(secret)) -console.log("address:", address) diff --git a/server/scripts/send-transfer.ts b/server/scripts/send-transfer.ts deleted file mode 100644 index 24df4b7..0000000 --- a/server/scripts/send-transfer.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { westend } from "@capi/westend" -import { hex, Scope, Sr25519 } from "capi" -import { signature } from "capi/patterns/signature/polkadot" -import { $input, $result } from "common" -import * as crypto from "crypto" -import WebSocket from "ws" - -const args = process.argv.slice(2) -if (args.length < 2) { - throw new Error("secret key and endpoint are required") -} -const secret = hex.decode(args[0]!) -const endpoint = args[1]! - -const sender = Sr25519.fromSecret(secret) - -const recipient = Sr25519.fromSecret(crypto.getRandomValues(new Uint8Array(64))) - -const signedExtrinsic = await westend.Balances.transfer({ - value: 12345n, - dest: recipient.address, -}) - .signed(signature({ sender })) - .hex() - .run(new Scope()) - -const ws = new WebSocket(endpoint) - -ws.on("open", () => { - ws.send( - $input.encode({ - type: "subscribe", - channel: "multisig-xyz", - }), - ) - - ws.send( - $input.encode({ - type: "submit", - channel: "multisig-xyz", - signedExtrinsic, - }), - ) -}) - -ws.on("message", (message) => { - console.log($result.decode(Uint8Array.from(message as Buffer))) -}) From e1a141d1357f213e40f62cff5396151e528546ca Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Wed, 5 Jul 2023 09:47:29 +0200 Subject: [PATCH 12/14] bump capi to gamma.1 and adapt code accordingly --- nets.ts | 1 - package.json | 4 +- pnpm-lock.yaml | 163 ++++++++++-------- server/main.ts | 4 +- www/src/components/Setup.tsx | 6 +- www/src/components/wizards/multisig/Fund.tsx | 4 +- .../components/wizards/multisig/Members.tsx | 12 +- .../components/wizards/multisig/Summary.tsx | 23 ++- .../components/wizards/transaction/New.tsx | 6 +- .../components/wizards/transaction/Sign.tsx | 4 +- .../components/wizards/transaction/signals.ts | 4 +- www/src/hooks/useAccountInfo.ts | 3 +- www/src/hooks/useProposals.ts | 8 +- www/src/util/balance.ts | 3 +- www/src/util/chain-constants.ts | 10 +- www/src/util/local-storage.ts | 3 +- www/src/util/scope.ts | 5 - www/src/util/transaction.ts | 3 +- 18 files changed, 131 insertions(+), 135 deletions(-) delete mode 100644 www/src/util/scope.ts diff --git a/nets.ts b/nets.ts index e81c2e4..1ab4841 100644 --- a/nets.ts +++ b/nets.ts @@ -2,5 +2,4 @@ import { net } from "capi/nets" export const westend = net.ws({ url: "wss://westend-rpc.polkadot.io/", - version: "v0.9.42", }) diff --git a/package.json b/package.json index a5c2db3..8ac3e86 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "@headlessui/react": "^1.7.15", "@preact/signals": "^1.1.3", "@talisman-connect/wallets": "^1.1.3", - "capi": "0.1.0-beta.47", + "capi": "0.1.0-gamma.1", "dotenv": "^16.1.4", "preact": "^10.15.1", "react-hook-form": "^7.44.3", @@ -41,6 +41,6 @@ "start:docker": "sudo docker-compose up --build --abort-on-container-exit", "start:docker:db": "docker-compose up --build --abort-on-container-exit dynamodb", "clean:docker": "docker-compose down --rmi all", - "sync": "capi sync node --runtime-config package.json --server https://capi.dev" + "sync": "capi sync node --server https://capi.dev" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 61fc919..02633c8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,7 +14,7 @@ importers: dependencies: '@capi/westend': specifier: https://capi.dev/a416a0563f132155/westend.tar - version: '@capi.dev/a416a0563f132155/westend.tar(capi@0.1.0-beta.47)' + version: '@capi.dev/a416a0563f132155/westend.tar(capi@0.1.0-gamma.1)' '@headlessui/react': specifier: ^1.7.15 version: 1.7.15(react-dom@18.2.0)(react@18.2.0) @@ -25,8 +25,8 @@ importers: specifier: ^1.1.3 version: 1.1.3(@polkadot/util-crypto@8.7.1)(@polkadot/util@8.7.1) capi: - specifier: 0.1.0-beta.47 - version: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + specifier: 0.1.0-gamma.1 + version: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dotenv: specifier: ^16.1.4 version: 16.1.4 @@ -1218,8 +1218,8 @@ packages: resolution: {integrity: sha512-oYWcD7CpERZy/TXMTM9Tgh1HD/POHlbY9WpzmAk+5H8DohcxG415Qws8yLGlim3EaKBT2v3lJv01x4G0BosnaQ==} dev: false - /@deno/shim-deno@0.14.0: - resolution: {integrity: sha512-cDUScUb8NI8mKN5qQ+/+sL7Z0bcBdRrzx7DZ6pOvSTyhWweNdRZ1ZtYsdOB5IfhNawdYJ9phQdtbXDuAOvbrIg==} + /@deno/shim-deno@0.16.1: + resolution: {integrity: sha512-s9v0kzF5bm/o9TgdwvsraHx6QNllYrXXmKzgOG2lh4LFXnVMr2gpjK/c/ve6EflQn1MqImcWmVD8HAv5ahuuZQ==} dependencies: '@deno/shim-deno-test': 0.4.0 which: 2.0.2 @@ -1474,10 +1474,6 @@ packages: '@jridgewell/resolve-uri': 3.1.1 '@jridgewell/sourcemap-codec': 1.4.15 - /@noble/ed25519@2.0.0: - resolution: {integrity: sha512-/extjhkwFupyopDrt80OMWKdLgP429qLZj+z6sYJz90rF2Iz0gjZh2ArMKPImUl13Kx+0EXI2hN9T/KJV0/Zng==} - dev: false - /@noble/hashes@1.0.0: resolution: {integrity: sha512-DZVbtY62kc3kkBtMHqwCOfXrT/hnoORy5BJ4+HU1IR59X0KWAOqsfzQPcUl/lQLlG7qXbe/fZ3r/emxtAl+sqg==} dev: false @@ -2359,26 +2355,26 @@ packages: resolution: {integrity: sha512-uv7/gXuHi10Whlj0pp5q/tsK/32J2QSqVRKQhs2j8VsDCjgyruAh/eEXHF822VqO9yT6iZKw3nRwZRSPBE9OQg==} dev: true - /capi@0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3): - resolution: {integrity: sha512-hvTu8cih0zQ1vUCF4kajc+eH5kwP5dlyWlT+mHqSnTzer1KJ+VHyxgFZ/pHCxg9GEmesunYyNsYUXMroZVW9oA==} + /capi@0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3): + resolution: {integrity: sha512-d1NiNc/h4ttMQ/O5MbMRjn1QmmxvXKUxbk5yuuABV/N+sdd17m1KKWfvxMCHqERWIahzPR+a8DTYb3cBwCVbnw==} hasBin: true dependencies: - '@capi/contracts-dev': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/contracts-dev.tar(capi@0.1.0-beta.47)' - '@capi/polkadot': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot.tar(capi@0.1.0-beta.47)' - '@capi/polkadot-dev': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot-dev.tar(capi@0.1.0-beta.47)' - '@capi/rococo-dev': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev.tar(capi@0.1.0-beta.47)' - '@capi/rococo-dev-contracts': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-contracts.tar(capi@0.1.0-beta.47)' - '@capi/rococo-dev-westmint': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-westmint.tar(capi@0.1.0-beta.47)' - '@capi/rococo-dev-xcm': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm.tar(capi@0.1.0-beta.47)' - '@capi/rococo-dev-xcm-statemine': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-statemine.tar(capi@0.1.0-beta.47)' - '@capi/rococo-dev-xcm-trappist': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-trappist.tar(capi@0.1.0-beta.47)' - '@capi/statemint': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/statemint.tar(capi@0.1.0-beta.47)' - '@capi/westend': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend.tar(capi@0.1.0-beta.47)' - '@capi/westend-dev': '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend-dev.tar(capi@0.1.0-beta.47)' - '@deno/shim-deno': 0.14.0 - '@noble/ed25519': 2.0.0 + '@capi/collectives': '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/collectives.tar(capi@0.1.0-gamma.1)' + '@capi/contracts-dev': '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/contracts-dev.tar(capi@0.1.0-gamma.1)' + '@capi/polkadot': '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/polkadot.tar(capi@0.1.0-gamma.1)' + '@capi/polkadot-dev': '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/polkadot-dev.tar(capi@0.1.0-gamma.1)' + '@capi/rococo-dev': '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev.tar(capi@0.1.0-gamma.1)' + '@capi/rococo-dev-contracts': '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-contracts.tar(capi@0.1.0-gamma.1)' + '@capi/rococo-dev-westmint': '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-westmint.tar(capi@0.1.0-gamma.1)' + '@capi/rococo-dev-xcm': '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-xcm.tar(capi@0.1.0-gamma.1)' + '@capi/rococo-dev-xcm-statemine': '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-xcm-statemine.tar(capi@0.1.0-gamma.1)' + '@capi/rococo-dev-xcm-trappist': '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-xcm-trappist.tar(capi@0.1.0-gamma.1)' + '@capi/statemint': '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/statemint.tar(capi@0.1.0-gamma.1)' + '@capi/westend': '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/westend.tar(capi@0.1.0-gamma.1)' + '@capi/westend-dev': '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/westend-dev.tar(capi@0.1.0-gamma.1)' + '@deno/shim-deno': 0.16.1 isomorphic-ws: 5.0.0(ws@8.13.0) - scale-codec: 0.11.2 + scale-codec: 0.12.2 smoldot: 1.0.6 ts-node: 10.9.1(@types/node@20.3.1)(typescript@5.1.3) tslib: 2.5.0 @@ -3629,6 +3625,10 @@ packages: resolution: {integrity: sha512-foVDx4QomwIgCssCbsLEfKIzalDZIbJ3FFyAml9hxN1GHb/Ppd/9SDgTeSabuc6uRwoSnFNRrSjA8Uxykk4+VA==} dev: false + /scale-codec@0.12.2: + resolution: {integrity: sha512-HCZIusTOu8JNTYQZjwyZqG958LjiFZA56Osr4AGXw8h9/QabKiSufdflAdHUoNrdx0iHjSpwGqj+qAEtpmma5w==} + dev: false + /scheduler@0.23.0: resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==} dependencies: @@ -4156,139 +4156,150 @@ packages: resolution: {integrity: sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==} dev: false - '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/contracts-dev.tar(capi@0.1.0-beta.47)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/contracts-dev.tar} - id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/contracts-dev.tar' + '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/collectives.tar(capi@0.1.0-gamma.1)': + resolution: {tarball: https://capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/collectives.tar} + id: '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/collectives.tar' + name: collectives + version: 0.0.0-TODO + peerDependencies: + capi: '*' + dependencies: + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) + dev: false + + '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/contracts-dev.tar(capi@0.1.0-gamma.1)': + resolution: {tarball: https://capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/contracts-dev.tar} + id: '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/contracts-dev.tar' name: contracts-dev version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot-dev.tar(capi@0.1.0-beta.47)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot-dev.tar} - id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot-dev.tar' + '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/polkadot-dev.tar(capi@0.1.0-gamma.1)': + resolution: {tarball: https://capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/polkadot-dev.tar} + id: '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/polkadot-dev.tar' name: polkadot-dev version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot.tar(capi@0.1.0-beta.47)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot.tar} - id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/polkadot.tar' + '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/polkadot.tar(capi@0.1.0-gamma.1)': + resolution: {tarball: https://capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/polkadot.tar} + id: '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/polkadot.tar' name: polkadot version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-contracts.tar(capi@0.1.0-beta.47)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-contracts.tar} - id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-contracts.tar' + '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-contracts.tar(capi@0.1.0-gamma.1)': + resolution: {tarball: https://capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-contracts.tar} + id: '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-contracts.tar' name: rococo-dev-contracts version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-westmint.tar(capi@0.1.0-beta.47)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-westmint.tar} - id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-westmint.tar' + '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-westmint.tar(capi@0.1.0-gamma.1)': + resolution: {tarball: https://capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-westmint.tar} + id: '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-westmint.tar' name: rococo-dev-westmint version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-statemine.tar(capi@0.1.0-beta.47)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-statemine.tar} - id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-statemine.tar' + '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-xcm-statemine.tar(capi@0.1.0-gamma.1)': + resolution: {tarball: https://capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-xcm-statemine.tar} + id: '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-xcm-statemine.tar' name: rococo-dev-xcm-statemine version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-trappist.tar(capi@0.1.0-beta.47)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-trappist.tar} - id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm-trappist.tar' + '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-xcm-trappist.tar(capi@0.1.0-gamma.1)': + resolution: {tarball: https://capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-xcm-trappist.tar} + id: '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-xcm-trappist.tar' name: rococo-dev-xcm-trappist version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm.tar(capi@0.1.0-beta.47)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm.tar} - id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev-xcm.tar' + '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-xcm.tar(capi@0.1.0-gamma.1)': + resolution: {tarball: https://capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-xcm.tar} + id: '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev-xcm.tar' name: rococo-dev-xcm version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev.tar(capi@0.1.0-beta.47)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev.tar} - id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/rococo-dev.tar' + '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev.tar(capi@0.1.0-gamma.1)': + resolution: {tarball: https://capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev.tar} + id: '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/rococo-dev.tar' name: rococo-dev version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/statemint.tar(capi@0.1.0-beta.47)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/statemint.tar} - id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/statemint.tar' + '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/statemint.tar(capi@0.1.0-gamma.1)': + resolution: {tarball: https://capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/statemint.tar} + id: '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/statemint.tar' name: statemint version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend-dev.tar(capi@0.1.0-beta.47)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend-dev.tar} - id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend-dev.tar' + '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/westend-dev.tar(capi@0.1.0-gamma.1)': + resolution: {tarball: https://capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/westend-dev.tar} + id: '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/westend-dev.tar' name: westend-dev version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend.tar(capi@0.1.0-beta.47)': - resolution: {tarball: https://capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend.tar} - id: '@capi.dev/@v0.1.0-beta.47/d5de72ca4087cd41/westend.tar' + '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/westend.tar(capi@0.1.0-gamma.1)': + resolution: {tarball: https://capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/westend.tar} + id: '@capi.dev/@v0.1.0-gamma.1/ed956cd5bde67584/westend.tar' name: westend version: 0.0.0-TODO peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dev: false - '@capi.dev/a416a0563f132155/westend.tar(capi@0.1.0-beta.47)': + '@capi.dev/a416a0563f132155/westend.tar(capi@0.1.0-gamma.1)': resolution: {tarball: https://capi.dev/a416a0563f132155/westend.tar} id: '@capi.dev/a416a0563f132155/westend.tar' name: westend @@ -4296,5 +4307,5 @@ packages: peerDependencies: capi: '*' dependencies: - capi: 0.1.0-beta.47(@types/node@20.3.1)(typescript@5.1.3) + capi: 0.1.0-gamma.1(@types/node@20.3.1)(typescript@5.1.3) dev: false diff --git a/server/main.ts b/server/main.ts index 26b6b8f..3fe88b1 100644 --- a/server/main.ts +++ b/server/main.ts @@ -1,5 +1,5 @@ import { westend } from "@capi/westend" -import { Scope, SignedExtrinsicRune } from "capi" +import { SignedExtrinsicRune } from "capi" import { $input, $result, Submit } from "common" import express from "express" import * as http from "http" @@ -130,7 +130,7 @@ async function handleSubmit(ws: ws.WebSocket, submit: Submit): Promise { return false }) - .run(new Scope()) + .run() } catch (err) { ws.send( $result.encode({ diff --git a/www/src/components/Setup.tsx b/www/src/components/Setup.tsx index f5f4823..d317c7a 100644 --- a/www/src/components/Setup.tsx +++ b/www/src/components/Setup.tsx @@ -12,7 +12,7 @@ import { accounts, defaultAccount, defaultSender } from "../signals/accounts.js" import { formatBalance } from "../util/balance.js" import { toMultiAddressIdRune, toMultisigRune } from "../util/capi-helpers.js" import { filterEvents, handleException } from "../util/events.js" -import { scope } from "../util/scope.js" + import { AccountId } from "./AccountId.js" import { Button } from "./Button.js" import { CenteredCard } from "./CenteredCard.js" @@ -48,7 +48,7 @@ export function Setup({ setup }: Props) { .unhandleFailed() .pipe(filterEvents) - return ratifyCall.run(scope) + return ratifyCall.run() }, onSuccess: (result) => { console.log({ result }) @@ -75,7 +75,7 @@ export function Setup({ setup }: Props) { .unhandleFailed() .pipe(filterEvents) - return cancelCall.run(scope) + return cancelCall.run() }, onSuccess: (result) => { console.log({ result }) diff --git a/www/src/components/wizards/multisig/Fund.tsx b/www/src/components/wizards/multisig/Fund.tsx index d077953..858b8c0 100644 --- a/www/src/components/wizards/multisig/Fund.tsx +++ b/www/src/components/wizards/multisig/Fund.tsx @@ -6,7 +6,7 @@ import { defaultSender } from "../../../signals/accounts.js" import { toBalance } from "../../../util/balance.js" import { toMultiAddressIdRune } from "../../../util/capi-helpers.js" import { filterEvents, handleException } from "../../../util/events.js" -import { scope } from "../../../util/scope.js" + import { BalanceInput } from "../../BalanceInput.js" import { Button } from "../../Button.js" import { goNext } from "../Wizard.js" @@ -48,7 +48,7 @@ export function MultisigFund() { .unhandleFailed() .pipe(filterEvents) - await fundStashCall.run(scope) + await fundStashCall.run() updateWizardData({ ...formDataNew }) goNext() } catch (exception: any) { diff --git a/www/src/components/wizards/multisig/Members.tsx b/www/src/components/wizards/multisig/Members.tsx index 0454fa3..06d1fdd 100644 --- a/www/src/components/wizards/multisig/Members.tsx +++ b/www/src/components/wizards/multisig/Members.tsx @@ -21,7 +21,7 @@ import { } from "../../../util/chain-constants.js" import { filterEvents, handleException } from "../../../util/events.js" import { storeSetup } from "../../../util/local-storage.js" -import { scope } from "../../../util/scope.js" + import { AccountSelect } from "../../AccountSelect.js" import { Button } from "../../Button.js" import { IconChevronLeft } from "../../icons/IconChevronLeft.js" @@ -84,8 +84,8 @@ export function MultisigMembers() { ) const multisigAddress = ss58.encode( - await westend.addressPrefix().run(scope), - await multisig.accountId.run(scope), + await westend.addressPrefix().run(), + await multisig.accountId.run(), ) // TODO can we check if stash already created? previously? @@ -104,9 +104,9 @@ export function MultisigMembers() { .map((events: { pure: unknown }[]) => events.map(({ pure }) => pure)) .access(0) - const stashBytes = (await createStashCall.run(scope)) as Uint8Array + const stashBytes = (await createStashCall.run()) as Uint8Array const stashAddress = ss58.encode( - await westend.addressPrefix().run(scope), + await westend.addressPrefix().run(), stashBytes, ) console.info("New Stash created at:", stashAddress) @@ -130,7 +130,7 @@ export function MultisigMembers() { .unhandleFailed() .pipe(filterEvents) - await replaceDelegates.run(scope) + await replaceDelegates.run() // TODO save to database instead of localStorage storeSetup(members.map((m) => m?.address) as string[], { diff --git a/www/src/components/wizards/multisig/Summary.tsx b/www/src/components/wizards/multisig/Summary.tsx index c3a296e..04446bb 100644 --- a/www/src/components/wizards/multisig/Summary.tsx +++ b/www/src/components/wizards/multisig/Summary.tsx @@ -3,7 +3,9 @@ import { Button } from "../../Button.js" import { wizardData } from "./wizardData.js" export function MultisigSummary() { - const { value: { name, fundingAmount, members } } = wizardData + const { + value: { name, fundingAmount, members }, + } = wizardData return (
@@ -12,30 +14,25 @@ export function MultisigSummary() {
         
Multisig name: - - {name} - + {name}
-
+
Multisig members:
    - {members.map((v, i)=>
  • {v?.address}
  • )} + {members.map((v, i) => ( +
  • {v?.address}
  • + ))}
Multisig fund: - - {fundingAmount} - + {fundingAmount}

- diff --git a/www/src/components/wizards/transaction/New.tsx b/www/src/components/wizards/transaction/New.tsx index 15b3522..45123b1 100644 --- a/www/src/components/wizards/transaction/New.tsx +++ b/www/src/components/wizards/transaction/New.tsx @@ -6,7 +6,7 @@ import { useSearchParams } from "react-router-dom" import { defaultAccount } from "../../../signals/accounts.js" import { setups } from "../../../signals/setups.js" import { formatBalance } from "../../../util/balance.js" -import { scope } from "../../../util/scope.js" + import { AccountId } from "../../AccountId.js" import { AccountSelect } from "../../AccountSelect.js" import { AddressInput } from "../../AddressInput.js" @@ -36,8 +36,8 @@ export function TransactionNew() { const onSubmit: SubmitHandler = async (formDataNew) => { if (!call.value) return - const callHash = hex.encode(await call.value.callHash.run(scope)) - const callData = hex.encode(await call.value.callData.run(scope)) + const callHash = hex.encode(await call.value.callHash.run()) + const callData = hex.encode(await call.value.callData.run()) const selectedSetup = setups.peek().find((s) => s.multisig === formDataNew.from?.address ) diff --git a/www/src/components/wizards/transaction/Sign.tsx b/www/src/components/wizards/transaction/Sign.tsx index e97cc89..fa18b8d 100644 --- a/www/src/components/wizards/transaction/Sign.tsx +++ b/www/src/components/wizards/transaction/Sign.tsx @@ -11,7 +11,7 @@ import { useNavigate } from "react-router-dom" import { toBalance } from "../../../util/balance.js" import { filterEvents, handleException } from "../../../util/events.js" import { storeCall } from "../../../util/local-storage.js" -import { scope } from "../../../util/scope.js" + import { AccountId } from "../../AccountId.js" import { Button } from "../../Button.js" import { IconTrash } from "../../icons/IconTrash.js" @@ -54,7 +54,7 @@ export function TransactionSign() { .pipe(filterEvents) ratifyCall - .run(scope) + .run() .then(() => storeCall(call)) .then(() => { setSubmitting(false) diff --git a/www/src/components/wizards/transaction/signals.ts b/www/src/components/wizards/transaction/signals.ts index ac63a4a..32541e2 100644 --- a/www/src/components/wizards/transaction/signals.ts +++ b/www/src/components/wizards/transaction/signals.ts @@ -2,7 +2,7 @@ import { MultiAddress, Westend, westend } from "@capi/westend" import { effect, Signal, signal } from "@preact/signals" import { ExtrinsicRune, ss58 } from "capi" import { toBalance } from "../../../util/balance.js" -import { scope } from "../../../util/scope.js" + import { transactionData } from "./formData.js" export const call = signal | undefined>(undefined) @@ -20,7 +20,7 @@ effect(() => { effect(() => { call.value ?.estimate() - .run(scope) + .run() .then((estimate: bigint) => { fee.value = estimate }) diff --git a/www/src/hooks/useAccountInfo.ts b/www/src/hooks/useAccountInfo.ts index cff8043..8672c3b 100644 --- a/www/src/hooks/useAccountInfo.ts +++ b/www/src/hooks/useAccountInfo.ts @@ -1,14 +1,13 @@ import { westend } from "@capi/westend" import { useQuery } from "@tanstack/react-query" import { toPubKey } from "../util/capi-helpers.js" -import { scope } from "../util/scope.js" export function useAccountInfo(address: string) { return useQuery({ queryKey: ["AccountInfo", address], queryFn: async () => { const accountInfo = await westend.System.Account.value(toPubKey(address)) - .run(scope) + .run() if (!accountInfo) return 0n return accountInfo.data.free }, diff --git a/www/src/hooks/useProposals.ts b/www/src/hooks/useProposals.ts index 666a277..93768c8 100644 --- a/www/src/hooks/useProposals.ts +++ b/www/src/hooks/useProposals.ts @@ -5,7 +5,6 @@ import { Setup } from "common" import { useMemo } from "preact/hooks" import { toAddress, toMultisigRune } from "../util/capi-helpers.js" import { getCall } from "../util/local-storage.js" -import { scope } from "../util/scope.js" type Proposal = { callHash: string @@ -21,7 +20,7 @@ export function useProposals(setup: Setup) { queryKey: ["proposals", setup.id], queryFn: async () => { const proposals: Array> = await multisig.proposals(5) - .run(scope) + .run() return Promise.all( proposals.map(async ([, callHashBytes]) => { @@ -31,8 +30,9 @@ export function useProposals(setup: Setup) { callHash, call: getCall(callHash), approvals: - (await multisig.proposal(callHashBytes!).run(scope))?.approvals - .map((approvalBytes) => toAddress(approvalBytes)) ?? [], + (await multisig.proposal(callHashBytes!).run())?.approvals.map(( + approvalBytes, + ) => toAddress(approvalBytes)) ?? [], } as Proposal }), ) diff --git a/www/src/util/balance.ts b/www/src/util/balance.ts index f4ccebd..76005cc 100644 --- a/www/src/util/balance.ts +++ b/www/src/util/balance.ts @@ -1,6 +1,5 @@ import { westend } from "@capi/westend" import { ss58 } from "capi" -import { scope } from "./scope.js" export function formatBalance( balance: bigint, @@ -28,7 +27,7 @@ export function formatBalance( export async function getBalance(address: string) { const addressPubKey = ss58.decode(address)[1] - const balance = await westend.System.Account.value(addressPubKey).run(scope) + const balance = await westend.System.Account.value(addressPubKey).run() if (!balance) throw new Error("Could not retrieve balance") diff --git a/www/src/util/chain-constants.ts b/www/src/util/chain-constants.ts index 1728755..3314a10 100644 --- a/www/src/util/chain-constants.ts +++ b/www/src/util/chain-constants.ts @@ -1,20 +1,18 @@ import { westend } from "@capi/westend" -import { scope } from "./scope.js" async function getExistentialDeposit() { return await westend.pallet("Balances").constant("ExistentialDeposit").decoded - .run(scope) + .run() } async function getProxyDepositBase() { - return await westend.pallet("Proxy").constant("ProxyDepositBase").decoded.run( - scope, - ) + return await westend.pallet("Proxy").constant("ProxyDepositBase").decoded + .run() } async function getProxyDepositFactor() { return await westend.pallet("Proxy").constant("ProxyDepositFactor").decoded - .run(scope) + .run() } export const PROXY_DEPOSIT_BASE = await getProxyDepositBase() diff --git a/www/src/util/local-storage.ts b/www/src/util/local-storage.ts index c9d10fe..871c75e 100644 --- a/www/src/util/local-storage.ts +++ b/www/src/util/local-storage.ts @@ -2,7 +2,6 @@ import { $runtimeCall, Westend } from "@capi/westend" import { Wallet, WalletAccount } from "@talisman-connect/wallets" import { ExtrinsicRune, hex, Rune } from "capi" import { isSetup, Setup } from "common" -import { scope } from "./scope.js" export function retrieveStored(key: "defaultAccount"): WalletAccount | undefined export function retrieveStored(key: "defaultExtension"): Wallet | undefined @@ -53,7 +52,7 @@ export async function storeCall(call: ExtrinsicRune) { const collection = await Rune.array([ call.callHash.access(), call.callData.access(), - ]).run(scope) + ]).run() const [hash, data] = collection.map((value) => "0x" + hex.encode(value)) if (!hash || !data) throw new Error("Could not store call") diff --git a/www/src/util/scope.ts b/www/src/util/scope.ts deleted file mode 100644 index a99756c..0000000 --- a/www/src/util/scope.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Scope } from "capi" - -const scope = new Scope() - -export { scope } diff --git a/www/src/util/transaction.ts b/www/src/util/transaction.ts index d522f48..1fac310 100644 --- a/www/src/util/transaction.ts +++ b/www/src/util/transaction.ts @@ -1,7 +1,6 @@ import { MultiAddress, westend } from "@capi/westend" import { ss58 } from "capi" import { isValidAddress } from "./address.js" -import { scope } from "./scope.js" export async function estimateFee(address: string, value: bigint) { if (!address || !isValidAddress(address)) throw new Error("Invalid address") @@ -11,6 +10,6 @@ export async function estimateFee(address: string, value: bigint) { dest: MultiAddress.Id(addressPubKey), }) .estimate() - .run(scope) + .run() return fee } From c0a922bbdd36843291f5463273e461b64c10565f Mon Sep 17 00:00:00 2001 From: peetzweg/ <839848+peetzweg@users.noreply.github.com> Date: Wed, 5 Jul 2023 15:23:10 +0200 Subject: [PATCH 13/14] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8ac3e86..150e3ec 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,6 @@ "start:docker": "sudo docker-compose up --build --abort-on-container-exit", "start:docker:db": "docker-compose up --build --abort-on-container-exit dynamodb", "clean:docker": "docker-compose down --rmi all", - "sync": "capi sync node --server https://capi.dev" + "sync": "capi sync node" } } From 30976d5eabd61f39a33556272e2a2acd48aefd21 Mon Sep 17 00:00:00 2001 From: peetzweg/ Date: Thu, 6 Jul 2023 10:04:03 +0200 Subject: [PATCH 14/14] use new import path --- www/src/api/replaceDelegatesCall.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/src/api/replaceDelegatesCall.ts b/www/src/api/replaceDelegatesCall.ts index c464f7e..ebc1806 100644 --- a/www/src/api/replaceDelegatesCall.ts +++ b/www/src/api/replaceDelegatesCall.ts @@ -1,7 +1,7 @@ import { MultiAddress, westend } from "@capi/westend" import { Rune, RunicArgs, ss58 } from "capi" -import { replaceDelegateCalls } from "capi/patterns/proxy" import { signature } from "capi/patterns/signature/polkadot" +import { replaceDelegateCalls } from "capi/patterns/unstable/proxy" import { PROXY_DEPOSIT_BASE, PROXY_DEPOSIT_FACTOR,