Skip to content

Commit

Permalink
WIP: Update everything to @nimiq/core@next
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed Nov 14, 2024
1 parent b2f19d5 commit 98af2c8
Show file tree
Hide file tree
Showing 59 changed files with 698 additions and 792 deletions.
2 changes: 1 addition & 1 deletion client/PublicPaymentOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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
16 changes: 8 additions & 8 deletions client/PublicRequestTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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 +113,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 +236,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 @@ -460,19 +460,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
2 changes: 1 addition & 1 deletion client/dist/src/PublicPaymentOptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,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
14 changes: 7 additions & 7 deletions client/dist/src/PublicRequestTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export declare enum AccountType {
BIP39 = 2,
LEDGER = 3
}
export {
export {
/** @deprecated Use AccountType instead */
AccountType as WalletType, };
export interface BasicRequest {
Expand Down Expand Up @@ -72,7 +72,7 @@ export interface ChooseAddressResult extends Address {
export interface SignTransactionRequest extends BasicRequest {
sender: string;
recipient: string;
recipientType?: Nimiq.Account.Type | 3;
recipientType?: Nimiq.AccountType | 3;
recipientLabel?: string;
value: number;
fee?: number;
Expand All @@ -91,7 +91,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 +190,9 @@ export interface SignedTransaction {
signerPublicKey: Uint8Array;
signature: Uint8Array;
sender: string;
senderType: Nimiq.Account.Type | 3;
senderType: Nimiq.AccountType | 3;
recipient: string;
recipientType: Nimiq.Account.Type | 3;
recipientType: Nimiq.AccountType | 3;
value: number;
fee: number;
validityStartHeight: number;
Expand Down Expand Up @@ -375,7 +375,7 @@ export interface Address {
label: string;
}
export interface VestingContract {
type: Nimiq.Account.Type.VESTING;
type: Nimiq.AccountType.VESTING;
address: string;
label: string;
owner: string;
Expand All @@ -385,7 +385,7 @@ export interface VestingContract {
totalAmount: number;
}
export interface HashedTimeLockedContract {
type: Nimiq.Account.Type.HTLC;
type: Nimiq.AccountType.HTLC;
address: string;
label: string;
sender: string;
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
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"@nimiq/fastspot-api": "^1.8.0",
"@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&239c43cc712da603ce744eeede76f3b9d56d16b2",
"@nimiq/ledger-api": "^3.0.0",
"@nimiq/network-client": "^0.6.2",
"@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,10 +392,10 @@ 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,
recipientType: this.paymentOptions.protocolSpecific.recipientType as any, // TODO: Remove when Keyguard Client is updated
// recipientLabel: '', // Checkout is using the shopOrigin instead
value: this.paymentOptions.amount,
fee: this.paymentOptions.fee,
Expand Down
Loading

0 comments on commit 98af2c8

Please sign in to comment.