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 16, 2024
1 parent eaa2198 commit c0ae547
Show file tree
Hide file tree
Showing 69 changed files with 802 additions and 855 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
4 changes: 2 additions & 2 deletions demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ <h2>Result</h2>
integrity="<%= htmlWebpackPlugin.options.bitcoinJsIntegrityHash %>"
crossorigin="anonymous"></script>
<!-- needed for WalletStore in Activate Btc demo -->
<script defer type="text/javascript"
<!-- <script defer type="text/javascript"
src="<%= htmlWebpackPlugin.options.cdnDomain %>/v<%= htmlWebpackPlugin.options.coreVersion %>/web-offline.js"
integrity="<%= htmlWebpackPlugin.options.coreIntegrityHash %>"
crossorigin="anonymous"></script>
crossorigin="anonymous"></script> -->

<!-- built files will be auto injected -->
</body>
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
4 changes: 2 additions & 2 deletions public/cashlink.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<script defer type="text/javascript" src="/browser-warning.js"
integrity="<%= htmlWebpackPlugin.options.browserWarningIntegrityHash %>"
crossorigin="anonymous"></script>
<script defer src="<%= htmlWebpackPlugin.options.cdnDomain %>/v<%= htmlWebpackPlugin.options.coreVersion %>/web-offline.js"
<!-- <script defer src="<%= htmlWebpackPlugin.options.cdnDomain %>/v<%= htmlWebpackPlugin.options.coreVersion %>/web-offline.js"
integrity="<%= htmlWebpackPlugin.options.coreIntegrityHash %>"
crossorigin="anonymous"></script>
crossorigin="anonymous"></script> -->
<title>Nimiq Cashlink</title>

<meta name="robots" content="noindex, follow">
Expand Down
4 changes: 2 additions & 2 deletions public/export.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="robots" content="noindex">
<script defer src="<%= htmlWebpackPlugin.options.cdnDomain %>/v<%= htmlWebpackPlugin.options.coreVersion %>/web-offline.js"
<!-- <script defer src="<%= htmlWebpackPlugin.options.cdnDomain %>/v<%= htmlWebpackPlugin.options.coreVersion %>/web-offline.js"
integrity="<%= htmlWebpackPlugin.options.coreIntegrityHash %>"
crossorigin="anonymous"></script>
crossorigin="anonymous"></script> -->
<title>Nimiq Hub Export</title>

<style>
Expand Down
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<script defer type="text/javascript" src="/browser-warning.js"
integrity="<%= htmlWebpackPlugin.options.browserWarningIntegrityHash %>"
crossorigin="anonymous"></script>
<script defer src="<%= htmlWebpackPlugin.options.cdnDomain %>/v<%= htmlWebpackPlugin.options.coreVersion %>/web-offline.js"
<!-- <script defer src="<%= htmlWebpackPlugin.options.cdnDomain %>/v<%= htmlWebpackPlugin.options.coreVersion %>/web-offline.js"
integrity="<%= htmlWebpackPlugin.options.coreIntegrityHash %>"
crossorigin="anonymous"></script>
crossorigin="anonymous"></script> -->
<title>Nimiq</title>
<meta name="robots" content="noindex">
<meta name="description" content="Nimiq Hub provides a unified interface for all Nimiq accounts, addresses, and contracts.">
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
27 changes: 18 additions & 9 deletions src/cashlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,21 @@ Vue.config.productionTip = false;
// see https://cli.vuejs.org/guide/mode-and-env.html#using-env-variables-in-client-side-code
setVueComponentsAssetPath(`${process.env.BASE_URL}js/`, `${process.env.BASE_URL}img/`);

startSentry(Vue);

setLanguage(detectLanguage()).then(() => {
const app = new Vue({
store,
i18n,
render: (h) => h(App),
}).$mount('#app');
});
async function main() {
// Load the main Nimiq WASM module and make it available globally.
// This must happen before creating the RpcApi instance, because it can try to recover state in its
// constructor, which in turn uses the RequestParser, which needs the Nimiq module.
window.Nimiq = await window.loadAlbatross();

startSentry(Vue);

setLanguage(detectLanguage()).then(() => {
const app = new Vue({
store,
i18n,
render: (h) => h(App),
}).$mount('#app');
});
}

main();
Loading

0 comments on commit c0ae547

Please sign in to comment.