diff --git a/client/PublicPaymentOptions.ts b/client/PublicPaymentOptions.ts index d9b7bae2f..985459587 100644 --- a/client/PublicPaymentOptions.ts +++ b/client/PublicPaymentOptions.ts @@ -1,3 +1,4 @@ +import type * as Nimiq from '@nimiq/core'; import { PaymentOptions, Currency, PaymentType } from './PublicRequestTypes'; export interface NimiqSpecifics { @@ -9,7 +10,7 @@ export interface NimiqSpecifics { sender?: string; forceSender?: boolean; recipient?: string; - recipientType?: Nimiq.Account.Type; + recipientType?: Nimiq.AccountType; } export type NimiqDirectPaymentOptions = PaymentOptions; diff --git a/client/PublicRequestTypes.ts b/client/PublicRequestTypes.ts index b09c83632..40b67882c 100644 --- a/client/PublicRequestTypes.ts +++ b/client/PublicRequestTypes.ts @@ -1,3 +1,4 @@ +import type * as Nimiq from '@nimiq/core'; import type { RelayRequest } from '@opengsn/common/dist/EIP712/RelayRequest'; import { @@ -92,7 +93,7 @@ export interface ChooseAddressResult extends Address { export interface SignTransactionRequest extends BasicRequest { sender: string; recipient: string; - recipientType?: Nimiq.Account.Type | 3; + recipientType?: Nimiq.AccountType; recipientLabel?: string; value: number; fee?: number; @@ -113,7 +114,7 @@ export interface NimiqCheckoutRequest extends BasicRequest { sender?: string; forceSender?: boolean; recipient: string; - recipientType?: Nimiq.Account.Type; + recipientType?: Nimiq.AccountType; value: number; fee?: number; extraData?: Bytes; @@ -236,9 +237,9 @@ export interface SignedTransaction { signature: Uint8Array; sender: string; // Userfriendly address - senderType: Nimiq.Account.Type | 3; + senderType: Nimiq.AccountType; recipient: string; // Userfriendly address - recipientType: Nimiq.Account.Type | 3; + recipientType: Nimiq.AccountType; value: number; // Luna fee: number; // Luna validityStartHeight: number; @@ -474,19 +475,19 @@ export interface Address { } export interface VestingContract { - type: Nimiq.Account.Type.VESTING; + type: Nimiq.AccountType.Vesting; address: string; // Userfriendly address label: string; owner: string; // Userfriendly address - start: number; + startTime: number; stepAmount: number; - stepBlocks: number; + timeStep: number; totalAmount: number; } export interface HashedTimeLockedContract { - type: Nimiq.Account.Type.HTLC; + type: Nimiq.AccountType.HTLC; address: string; // Userfriendly address label: string; diff --git a/client/dist/src/PublicPaymentOptions.d.ts b/client/dist/src/PublicPaymentOptions.d.ts index ac0204eea..7f3072712 100644 --- a/client/dist/src/PublicPaymentOptions.d.ts +++ b/client/dist/src/PublicPaymentOptions.d.ts @@ -1,3 +1,4 @@ +import type * as Nimiq from '@nimiq/core'; import { PaymentOptions, Currency, PaymentType } from './PublicRequestTypes'; export interface NimiqSpecifics { fee?: number | string; @@ -8,7 +9,7 @@ export interface NimiqSpecifics { sender?: string; forceSender?: boolean; recipient?: string; - recipientType?: Nimiq.Account.Type; + recipientType?: Nimiq.AccountType; } export declare type NimiqDirectPaymentOptions = PaymentOptions; export interface BitcoinSpecifics { diff --git a/client/dist/src/PublicRequestTypes.d.ts b/client/dist/src/PublicRequestTypes.d.ts index efecc630e..bd0e76ce2 100644 --- a/client/dist/src/PublicRequestTypes.d.ts +++ b/client/dist/src/PublicRequestTypes.d.ts @@ -1,3 +1,4 @@ +import type * as Nimiq from '@nimiq/core'; import type { RelayRequest } from '@opengsn/common/dist/EIP712/RelayRequest'; import { NimiqSpecifics, NimiqDirectPaymentOptions, BitcoinSpecifics, BitcoinDirectPaymentOptions, EtherSpecifics, EtherDirectPaymentOptions } from './PublicPaymentOptions'; export declare enum RequestType { @@ -72,7 +73,7 @@ export interface ChooseAddressResult extends Address { export interface SignTransactionRequest extends BasicRequest { sender: string; recipient: string; - recipientType?: Nimiq.Account.Type | 3; + recipientType?: Nimiq.AccountType; recipientLabel?: string; value: number; fee?: number; @@ -91,7 +92,7 @@ export interface NimiqCheckoutRequest extends BasicRequest { sender?: string; forceSender?: boolean; recipient: string; - recipientType?: Nimiq.Account.Type; + recipientType?: Nimiq.AccountType; value: number; fee?: number; extraData?: Bytes; @@ -190,9 +191,9 @@ export interface SignedTransaction { signerPublicKey: Uint8Array; signature: Uint8Array; sender: string; - senderType: Nimiq.Account.Type | 3; + senderType: Nimiq.AccountType; recipient: string; - recipientType: Nimiq.Account.Type | 3; + recipientType: Nimiq.AccountType; value: number; fee: number; validityStartHeight: number; @@ -388,17 +389,17 @@ export interface Address { label: string; } export interface VestingContract { - type: Nimiq.Account.Type.VESTING; + type: Nimiq.AccountType.Vesting; address: string; label: string; owner: string; - start: number; + startTime: number; stepAmount: number; - stepBlocks: number; + timeStep: number; totalAmount: number; } export interface HashedTimeLockedContract { - type: Nimiq.Account.Type.HTLC; + type: Nimiq.AccountType.HTLC; address: string; label: string; sender: string; diff --git a/client/package.json b/client/package.json index c8369aac8..ed0de144d 100644 --- a/client/package.json +++ b/client/package.json @@ -9,7 +9,7 @@ "private": false, "types": "types/index.d.ts", "dependencies": { - "@nimiq/core-web": "^1.6.3", + "@nimiq/core": "next", "@nimiq/fastspot-api": "^1.10.2", "@nimiq/rpc": "^0.4.0", "@nimiq/utils": "^0.5.0", diff --git a/client/types/Nimiq.d.ts b/client/types/Nimiq.d.ts deleted file mode 100644 index e39adbc88..000000000 --- a/client/types/Nimiq.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/client/types/index.d.ts b/client/types/index.d.ts index 85c7b7ca3..34807e6db 100644 --- a/client/types/index.d.ts +++ b/client/types/index.d.ts @@ -1,6 +1,3 @@ -// Import @nimiq/core-web types from relative path within user's node_modules -/// - export { default } from '../dist/src/HubApi'; // export public request types, RequestBehavior types and Account types for convenience of the HupApi user diff --git a/client/yarn.lock b/client/yarn.lock index e91c69385..f362bb16a 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -227,10 +227,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/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/fastspot-api@^1.10.2": version "1.10.2" @@ -991,6 +994,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, commander@^2.19.0: version "2.20.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422" @@ -1322,7 +1330,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== @@ -4223,6 +4231,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/docs/api-methods/10_checkout.md b/docs/api-methods/10_checkout.md index 153e20ed0..edd70d378 100644 --- a/docs/api-methods/10_checkout.md +++ b/docs/api-methods/10_checkout.md @@ -77,7 +77,7 @@ const signedTransaction = await hubApi.checkout(options); | `forceSender` | boolean | no | Whether to force the submitted sender address. If this option is `true`, an exception is thrown when either the sender address does not exist or does not have sufficient balance. When `false` (default), the user will be shown the address selector instead. (Only relevant in connection with the `sender` option.) | | `validityDuration` | number | no | The duration (in number of blocks) that the signed transaction should be valid for. The maximum and default is 120. | | `flags` | number | no | A [`Nimiq.Transaction.Flag`](https://nimiq-network.github.io/developer-reference/chapters/transactions.html#extended-transaction), only required if the transaction should create a contract. | -| `recipientType` | number | no | The [`Nimiq.Account.Type`](https://nimiq-network.github.io/developer-reference/chapters/accounts-and-contracts.html#contracts) of the recipient. Only required if the transaction should create a contract. | +| `recipientType` | number | no | The [`Nimiq.AccountType`](https://nimiq-network.github.io/developer-reference/chapters/accounts-and-contracts.html#contracts) of the recipient. Only required if the transaction should create a contract. | ## Result @@ -93,10 +93,10 @@ interface SignedTransaction { signature: Uint8Array; // Serialized signature of the signer sender: string; // Human-readable address of sender - senderType: Nimiq.Account.Type; // 0, 1, 2 - see recipientType above + senderType: Nimiq.AccountType; // 0, 1, 2, 3 - see recipientType above recipient: string; // Human-readable address of recipient - recipientType: Nimiq.Account.Type; // 0, 1, 2 - see above + recipientType: Nimiq.AccountType; // 0, 1, 2, 3 - see above value: number; fee: number; diff --git a/docs/api-methods/40_sign-transaction.md b/docs/api-methods/40_sign-transaction.md index a586b68ff..fe93a589f 100644 --- a/docs/api-methods/40_sign-transaction.md +++ b/docs/api-methods/40_sign-transaction.md @@ -102,7 +102,7 @@ const signedTransaction = await hubApi.signTransaction(options); | `fee` | number | no | Transaction fee in luna. Default: 0 | | `extraData` | string or Uint8Array | no | Extra data that should be sent with the transaction. | | `flags` | number | no | A [`Nimiq.Transaction.Flag`](https://nimiq-network.github.io/developer-reference/chapters/transactions.html#extended-transaction), only required if the transaction should create a contract. | -| `recipientType` | number | no | The [`Nimiq.Account.Type`](https://nimiq-network.github.io/developer-reference/chapters/accounts-and-contracts.html#contracts) of the recipient. Only required if the transaction should create a contract. | +| `recipientType` | number | no | The [`Nimiq.AccountType`](https://nimiq-network.github.io/developer-reference/chapters/accounts-and-contracts.html#contracts) of the recipient. Only required if the transaction should create a contract. | ## Result @@ -118,10 +118,10 @@ interface SignedTransaction { signature: Uint8Array; // Serialized signature of the signer sender: string; // Human-readable address of sender - senderType: Nimiq.Account.Type; // 0, 1, 2 - see recipientType above + senderType: Nimiq.AccountType; // 0, 1, 2, 3 - see recipientType above recipient: string; // Human-readable address of recipient - recipientType: Nimiq.Account.Type; // 0, 1, 2 - see above + recipientType: Nimiq.AccountType; // 0, 1, 2, 3 - see above value: number; fee: number; diff --git a/package.json b/package.json index 4712fa0cb..7108cb07d 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,8 @@ "@nimiq/electrum-client": "https://github.com/nimiq/electrum-client#build", "@nimiq/fastspot-api": "^1.10.2", "@nimiq/iqons": "^1.5.2", - "@nimiq/keyguard-client": "https://gitpkg.vercel.app/nimiq/keyguard?scripts.postinstall=cd%20client%20%26%26%20.%2Fbuild-gitpkg.sh&3eca28cc8a269da7722c3f8615c24595115ee251", - "@nimiq/ledger-api": "^3.0.0", - "@nimiq/network-client": "^0.6.2", + "@nimiq/keyguard-client": "https://gitpkg.vercel.app/nimiq/keyguard?scripts.postinstall=cd%20client%20%26%26%20.%2Fbuild-gitpkg.sh&80eebcc939ee110bb2bafe2d7ef9b988fea7344a", + "@nimiq/ledger-api": "github:nimiq/ledger-api#a7179c2d207c1deaeb2ab777ce6ad994e59f9c5f", "@nimiq/oasis-api": "^1.1.1", "@nimiq/rpc": "^0.4.1", "@nimiq/style": "^0.8.2", diff --git a/src/CashlinkApp.vue b/src/CashlinkApp.vue index 8f145f662..89bd7736e 100644 --- a/src/CashlinkApp.vue +++ b/src/CashlinkApp.vue @@ -21,7 +21,6 @@ import { Component, Vue } from 'vue-property-decorator'; import { LoadingSpinner } from '@nimiq/vue-components'; import CashlinkReceive from './views/CashlinkReceive.vue'; import { CashlinkTheme } from '../client/PublicRequestTypes'; -import { loadNimiq } from './lib/Helpers'; import '@nimiq/style/nimiq-style.min.css'; import '@nimiq/vue-components/dist/NimiqVueComponents.css'; @@ -32,10 +31,7 @@ export default class CashlinkApp extends Vue { private isDarkTheme = false; public async created() { - await Promise.all([ - this.$store.dispatch('initWallets'), - loadNimiq(), - ]); + await this.$store.dispatch('initWallets'); this.loading = false; } diff --git a/src/components/CheckoutCardNimiq.vue b/src/components/CheckoutCardNimiq.vue index cb3374d72..41e3b244a 100644 --- a/src/components/CheckoutCardNimiq.vue +++ b/src/components/CheckoutCardNimiq.vue @@ -247,10 +247,10 @@ class CheckoutCardNimiq const balance = balances.get(accountOrContract.userFriendlyAddress); if (balance === undefined) continue; - if ('type' in accountOrContract && accountOrContract.type === Nimiq.Account.Type.VESTING) { + if ('type' in accountOrContract && accountOrContract.type === Nimiq.AccountType.Vesting) { // Calculate available amount for vesting contract accountOrContract.balance = (accountOrContract as VestingContractInfo) - .calculateAvailableAmount(this.height, balance); + .calculateAvailableAmount(balance); } else { accountOrContract.balance = balance; } @@ -392,15 +392,15 @@ class CheckoutCardNimiq keyLabel: senderAccount.labelForKeyguard, sender: (senderContract || signer).address.serialize(), - senderType: senderContract ? senderContract.type : Nimiq.Account.Type.BASIC, + senderType: senderContract ? senderContract.type : Nimiq.AccountType.Basic, senderLabel: (senderContract || signer).label, recipient: this.paymentOptions.protocolSpecific.recipient!.serialize(), recipientType: this.paymentOptions.protocolSpecific.recipientType, + recipientData: this.paymentOptions.protocolSpecific.extraData, // recipientLabel: '', // Checkout is using the shopOrigin instead value: this.paymentOptions.amount, fee: this.paymentOptions.fee, validityStartHeight, - data: this.paymentOptions.protocolSpecific.extraData, flags: this.paymentOptions.protocolSpecific.flags, fiatAmount: this.request.fiatAmount, diff --git a/src/components/Network.vue b/src/components/Network.vue index a12bcad09..395982f99 100644 --- a/src/components/Network.vue +++ b/src/components/Network.vue @@ -2,37 +2,38 @@