From ef77f728d6515d1b8d812e7745d17f5b63dd18cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren?= Date: Thu, 14 Nov 2024 20:42:59 -0600 Subject: [PATCH] Update everything to @nimiq/core@next --- client/package.json | 2 +- client/src/Observable.ts | 2 +- client/src/PublicRequest.ts | 9 +- client/yarn.lock | 30 +++++- demos/DerivePolygonAddress.html | 4 +- demos/Export.html | 6 +- demos/LanguagePicker.html | 2 +- demos/LoginFile.html | 2 +- demos/PasswordInput.html | 2 +- demos/RemoveKey.html | 4 +- demos/SignTransaction.html | 4 +- demos/setup.html | 2 +- karma.conf.coverage.js | 5 +- karma.conf.js | 5 +- package.json | 2 +- serve.js | 3 +- src/common.js | 51 ++------- src/commonPoW.js | 36 +++++++ src/components/DownloadLoginFile.js | 3 +- src/components/FileImporter.js | 3 +- src/components/PasswordBox.js | 4 +- src/components/PasswordInput.js | 4 +- src/components/PasswordSetterBox.js | 4 +- src/components/ProgressIndicator.js | 4 +- src/components/QrVideoScanner.js | 4 +- src/components/RecoveryWords.js | 3 +- src/components/RecoveryWordsInputField.js | 3 +- src/components/SwapFeesTooltip.js | 4 +- src/components/TabWidthSelector.js | 4 +- src/components/Timer.js | 4 +- src/components/ValidateWords.js | 3 +- src/config/config.local.js | 1 + src/config/config.mainnet.js | 1 + src/config/config.testnet.js | 1 + src/lib/AlbatrossWasm.mjs | 6 +- src/lib/Constants.js | 1 + src/lib/I18n.js | 4 +- src/lib/Key.js | 10 +- src/lib/KeyStore.js | 2 +- src/lib/NonPartitionedSessionStorage.js | 2 +- src/lib/Observable.js | 77 ++++++++++++++ src/lib/RequestParser.js | 100 +++++++++++------- src/lib/bitcoin/BitcoinKey.js | 4 +- src/lib/polygon/PolygonKey.js | 4 +- src/lib/swap/CryptoUtils.js | 7 +- src/lib/swap/HtlcUtils.js | 10 +- .../swap/OasisSettlementInstructionUtils.js | 2 +- src/request/TopLevelApi.js | 4 +- src/request/change-password/index.html | 4 +- src/request/create/Create.js | 2 +- src/request/create/IdenticonSelector.js | 3 +- src/request/create/index.html | 3 +- src/request/derive-address/index.html | 3 +- src/request/derive-btc-xpub/index.html | 3 +- src/request/derive-polygon-address/index.html | 3 +- src/request/export/ExportFile.js | 3 +- src/request/export/ExportWords.js | 6 +- src/request/export/index.html | 2 + src/request/iframe/index.html | 2 +- src/request/import/ImportFile.js | 1 + src/request/import/ImportWords.js | 3 +- src/request/import/index.html | 2 + src/request/remove-key/index.html | 2 + src/request/sign-btc-transaction/index.html | 3 +- src/request/sign-message/SignMessageApi.js | 2 +- src/request/sign-message/index.html | 3 +- .../sign-polygon-transaction/index.html | 3 +- src/request/sign-staking/SignStaking.js | 12 +-- src/request/sign-staking/SignStakingApi.js | 7 +- src/request/sign-staking/index.html | 2 +- src/request/sign-staking/index.js | 4 +- src/request/sign-swap/SignSwap.js | 8 +- src/request/sign-swap/SignSwapApi.js | 17 +-- src/request/sign-swap/index.html | 3 +- .../sign-transaction/SignTransaction.js | 28 ++--- src/request/sign-transaction/index.html | 2 +- src/request/sign-transaction/index.js | 4 +- src/request/swap-iframe/SwapIFrameApi.js | 44 +++++--- src/request/swap-iframe/index.html | 2 +- tests/DummyData.spec.js | 4 +- tests/lib/AccountStore.spec.js | 2 +- tests/lib/Key.spec.js | 18 ++-- tests/lib/KeyStore.spec.js | 12 +-- tests/lib/RequestParser.spec.js | 18 ++-- tests/lib/Utf8Tools.spec.js | 2 +- tools/build.sh | 13 +-- tools/dependencyValidator.js | 8 +- types/Albatross.d.ts | 8 -- types/Keyguard.d.ts | 14 +-- types/Nimiq.d.ts | 10 +- types/NimiqPoW.d.ts | 8 ++ 91 files changed, 464 insertions(+), 293 deletions(-) create mode 100644 src/commonPoW.js create mode 100644 src/lib/Observable.js delete mode 100644 types/Albatross.d.ts create mode 100644 types/NimiqPoW.d.ts diff --git a/client/package.json b/client/package.json index e03cf8c94..72dfcd6bf 100644 --- a/client/package.json +++ b/client/package.json @@ -26,7 +26,7 @@ }, "homepage": "https://github.com/nimiq/keyguard/client#readme", "dependencies": { - "@nimiq/core-web": "1.6.3", + "@nimiq/albatross-wasm": "npm:@nimiq/core@next", "@nimiq/rpc": "^0.3.0", "@opengsn/common": "^2.2.5" }, diff --git a/client/src/Observable.ts b/client/src/Observable.ts index 975291340..19c5f024c 100644 --- a/client/src/Observable.ts +++ b/client/src/Observable.ts @@ -12,7 +12,7 @@ export default class Observable { this._listeners = new Map(); } - public on(type: string, callback: (arg: T) => any): number { + public on(type: string, callback: (...args: any[]) => any): number { if (!this._listeners.has(type)) { this._listeners.set(type, [callback]); return 0; diff --git a/client/src/PublicRequest.ts b/client/src/PublicRequest.ts index e1091e846..ec69ffda6 100644 --- a/client/src/PublicRequest.ts +++ b/client/src/PublicRequest.ts @@ -1,4 +1,4 @@ -import * as Nimiq from '@nimiq/core-web'; +import * as Nimiq from '@nimiq/albatross-wasm'; import { ForwardRequest as OpenGsnForwardRequest } from '@opengsn/common/dist/EIP712/ForwardRequest'; import { RelayData as OpenGsnRelayData } from '@opengsn/common/dist/EIP712/RelayData'; import { KeyguardCommand } from './KeyguardCommand'; @@ -43,13 +43,14 @@ export type TransactionInfo = { keyPath: string, senderLabel?: string, sender: Uint8Array, - senderType: Nimiq.Account.Type | 3, + senderType: Nimiq.AccountType, + senderData?: Uint8Array, recipient: Uint8Array, - recipientType?: Nimiq.Account.Type, + recipientType?: Nimiq.AccountType, + recipientData?: Uint8Array, value: number, fee: number, validityStartHeight: number, - data?: Uint8Array, flags?: number, }; diff --git a/client/yarn.lock b/client/yarn.lock index abe19845e..3ffc33ae3 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -211,10 +211,13 @@ "@ethersproject/properties" "^5.7.0" "@ethersproject/strings" "^5.7.0" -"@nimiq/core-web@1.6.3": - version "1.6.3" - resolved "https://registry.yarnpkg.com/@nimiq/core-web/-/core-web-1.6.3.tgz#b4a8f8c5d289850b20cb4009766af5b1cafd6e20" - integrity sha512-D6RrJi2cRU81odNpmwczhUBvOQ47+/Db1svrTkH/G4xNd72lr9MS5nMdfpUz+rBRnSprljrzW2mdUtZ6W9bPaA== +"@nimiq/albatross-wasm@npm:@nimiq/core@next": + version "2.0.0-next.rc.4" + resolved "https://registry.yarnpkg.com/@nimiq/core/-/core-2.0.0-next.rc.4.tgz#a353f4507f2f10e3be741f920cff921c9474dea7" + integrity sha512-qSBy/Mg0rbqAstEnrgzGhqeQpmQdOjCZPWmBV5uFxAMAAYl9nrABaXWQXo3Jvemvx5VQE9pz5/ma3I8Z0ROy1g== + dependencies: + comlink "^4.4.1" + websocket "^1.0.34" "@nimiq/rpc@^0.3.0": version "0.3.0" @@ -850,6 +853,11 @@ combined-stream@^1.0.6, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" +comlink@^4.4.1: + version "4.4.2" + resolved "https://registry.yarnpkg.com/comlink/-/comlink-4.4.2.tgz#cbbcd82742fbebc06489c28a183eedc5c60a2bca" + integrity sha512-OxGdvBmJuNKSCMO4NTl1L47VRp6xn2wG4F/2hYzB6tiCb709otOxtEYCSvK80PtjODfXXZu8ds+Nw5kVCjqd2g== + commander@^2.12.1: version "2.17.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" @@ -1149,7 +1157,7 @@ es-errors@^1.3.0: resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== -es5-ext@^0.10.35, es5-ext@^0.10.50, es5-ext@^0.10.62, es5-ext@~0.10.14: +es5-ext@^0.10.35, es5-ext@^0.10.50, es5-ext@^0.10.62, es5-ext@^0.10.63, es5-ext@~0.10.14: version "0.10.64" resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.64.tgz#12e4ffb48f1ba2ea777f1fcdd1918ef73ea21714" integrity sha512-p2snDhiLaXe6dahss1LddxqEm+SkuDvV8dnIQG0MWjyHpcMNfXKPE+/Cc0y+PhxJX3A4xGNeFCj5oc0BUh6deg== @@ -3447,6 +3455,18 @@ websocket@^1.0.32: utf-8-validate "^5.0.2" yaeti "^0.0.6" +websocket@^1.0.34: + version "1.0.35" + resolved "https://registry.yarnpkg.com/websocket/-/websocket-1.0.35.tgz#374197207d7d4cc4c36cbf8a1bb886ee52a07885" + integrity sha512-/REy6amwPZl44DDzvRCkaI1q1bIiQB0mEFQLUrhz3z2EK91cp3n72rAjUlrTP0zV22HJIUOVHQGPxhFRjxjt+Q== + dependencies: + bufferutil "^4.0.1" + debug "^2.2.0" + es5-ext "^0.10.63" + typedarray-to-buffer "^3.1.5" + utf-8-validate "^5.0.2" + yaeti "^0.0.6" + whatwg-url@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" diff --git a/demos/DerivePolygonAddress.html b/demos/DerivePolygonAddress.html index 3af079f29..6bab1377b 100644 --- a/demos/DerivePolygonAddress.html +++ b/demos/DerivePolygonAddress.html @@ -4,7 +4,7 @@ Derive Polygon Address | Keyguard Demo - + @@ -33,7 +33,7 @@ const secret = Nimiq.Entropy.generate(); const key = new Key(secret); - const password = Nimiq.BufferUtils.fromAscii('1234567890'); + const password = Nimiq.BufferUtils.fromUtf8('1234567890'); const id = await KeyStore.instance.put(key, password); const request = { diff --git a/demos/Export.html b/demos/Export.html index 8c86e418b..2749bac32 100644 --- a/demos/Export.html +++ b/demos/Export.html @@ -6,7 +6,7 @@ - + @@ -30,7 +30,7 @@ document.querySelector('.bip39').addEventListener('click', async () => { const entropy = Nimiq.Entropy.generate(); const key = new Key(entropy); - const password = Nimiq.BufferUtils.fromAscii('1234567890'); + const password = Nimiq.BufferUtils.fromUtf8('1234567890'); const id = await KeyStore.instance.put(key, password); const exportRequest = { @@ -44,7 +44,7 @@ document.querySelector('.legacy').addEventListener('click', async () => { const secret = Nimiq.PrivateKey.generate(); const key = new Key(secret); - const password = Nimiq.BufferUtils.fromAscii('1234567890'); + const password = Nimiq.BufferUtils.fromUtf8('1234567890'); const id = await KeyStore.instance.put(key, password); const exportRequest = { diff --git a/demos/LanguagePicker.html b/demos/LanguagePicker.html index 20dc80f5a..959a5c72e 100644 --- a/demos/LanguagePicker.html +++ b/demos/LanguagePicker.html @@ -5,7 +5,7 @@ i18n Test | Keyguard Demo - +