Skip to content

Commit

Permalink
Update everything to @nimiq/core@next
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed Nov 15, 2024
1 parent eaa2198 commit 31929a5
Show file tree
Hide file tree
Showing 64 changed files with 789 additions and 836 deletions.
3 changes: 2 additions & 1 deletion client/PublicPaymentOptions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type * as Nimiq from '@nimiq/core';
import { PaymentOptions, Currency, PaymentType } from './PublicRequestTypes';

export interface NimiqSpecifics {
Expand All @@ -9,7 +10,7 @@ export interface NimiqSpecifics {
sender?: string;
forceSender?: boolean;
recipient?: string;
recipientType?: Nimiq.Account.Type;
recipientType?: Nimiq.AccountType;
}

export type NimiqDirectPaymentOptions = PaymentOptions<Currency.NIM, PaymentType.DIRECT>;
Expand Down
17 changes: 9 additions & 8 deletions client/PublicRequestTypes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type * as Nimiq from '@nimiq/core';
import type { RelayRequest } from '@opengsn/common/dist/EIP712/RelayRequest';

import {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion client/dist/src/PublicPaymentOptions.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type * as Nimiq from '@nimiq/core';
import { PaymentOptions, Currency, PaymentType } from './PublicRequestTypes';
export interface NimiqSpecifics {
fee?: number | string;
Expand All @@ -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<Currency.NIM, PaymentType.DIRECT>;
export interface BitcoinSpecifics {
Expand Down
17 changes: 9 additions & 8 deletions client/dist/src/PublicRequestTypes.d.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion client/types/Nimiq.d.ts

This file was deleted.

3 changes: 0 additions & 3 deletions client/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Import @nimiq/core-web types from relative path within user's node_modules
/// <reference path="../../core-web/namespace.d.ts" />

export { default } from '../dist/src/HubApi';

// export public request types, RequestBehavior types and Account types for convenience of the HupApi user
Expand Down
30 changes: 25 additions & 5 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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==
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions docs/api-methods/10_checkout.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions docs/api-methods/40_sign-transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 1 addition & 5 deletions src/CashlinkApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/CheckoutCardNimiq.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 31929a5

Please sign in to comment.