Skip to content

Commit

Permalink
Merge branch 'albatross-testnet'
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed Nov 19, 2024
2 parents 7c642f5 + 34707f7 commit 8bbaa4a
Show file tree
Hide file tree
Showing 96 changed files with 3,993 additions and 2,041 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store
node_modules
dist
client/dist
!client/dist
client/build

# only yarn
Expand Down
2 changes: 2 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--install.ignore-engines true

8 changes: 8 additions & 0 deletions client/HubApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
SetupSwapRequest,
SetupSwapResult,
RefundSwapRequest,
SignStakingRequest,
} from './PublicRequestTypes';

export default class HubApi<
Expand Down Expand Up @@ -170,6 +171,13 @@ export default class HubApi<
return this._request(requestBehavior, RequestType.SIGN_TRANSACTION, [request]);
}

public signStaking<B extends BehaviorType = DB>(
request: Promise<SignStakingRequest> | SignStakingRequest,
requestBehavior: RequestBehavior<B> = this._defaultBehavior as any,
): Promise<B extends BehaviorType.REDIRECT ? void : SignedTransaction[]> {
return this._request(requestBehavior, RequestType.SIGN_STAKING, [request]);
}

public signMessage<B extends BehaviorType = DB>(
request: Promise<SignMessageRequest> | SignMessageRequest,
requestBehavior: RequestBehavior<B> = this._defaultBehavior as any,
Expand Down
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
28 changes: 20 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 All @@ -16,6 +17,7 @@ export enum RequestType {
CHECKOUT = 'checkout',
SIGN_MESSAGE = 'sign-message',
SIGN_TRANSACTION = 'sign-transaction',
SIGN_STAKING = 'sign-staking',
ONBOARD = 'onboard',
SIGNUP = 'signup',
LOGIN = 'login',
Expand Down Expand Up @@ -91,7 +93,7 @@ export interface ChooseAddressResult extends Address {
export interface SignTransactionRequest extends BasicRequest {
sender: string;
recipient: string;
recipientType?: Nimiq.Account.Type;
recipientType?: Nimiq.AccountType;
recipientLabel?: string;
value: number;
fee?: number;
Expand All @@ -100,13 +102,19 @@ export interface SignTransactionRequest extends BasicRequest {
validityStartHeight: number; // FIXME To be made optional when hub has its own network
}

export interface SignStakingRequest extends BasicRequest {
senderLabel?: string;
recipientLabel?: string;
transaction: Uint8Array | Uint8Array[];
}

export interface NimiqCheckoutRequest extends BasicRequest {
version?: 1;
shopLogoUrl?: string;
sender?: string;
forceSender?: boolean;
recipient: string;
recipientType?: Nimiq.Account.Type;
recipientType?: Nimiq.AccountType;
value: number;
fee?: number;
extraData?: Bytes;
Expand Down Expand Up @@ -220,6 +228,7 @@ export interface MultiCurrencyCheckoutRequest extends BasicRequest {
export type CheckoutRequest = NimiqCheckoutRequest | MultiCurrencyCheckoutRequest;

export interface SignedTransaction {
transaction: Uint8Array;
serializedTx: string; // HEX
hash: string; // HEX

Expand All @@ -228,9 +237,9 @@ export interface SignedTransaction {
signature: Uint8Array;

sender: string; // Userfriendly address
senderType: Nimiq.Account.Type;
senderType: Nimiq.AccountType;
recipient: string; // Userfriendly address
recipientType: Nimiq.Account.Type;
recipientType: Nimiq.AccountType;
value: number; // Luna
fee: number; // Luna
validityStartHeight: number;
Expand Down Expand Up @@ -466,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 Expand Up @@ -661,6 +670,7 @@ export interface SignedPolygonTransaction {
}

export type RpcRequest = SignTransactionRequest
| SignStakingRequest
| CreateCashlinkRequest
| ManageCashlinkRequest
| CheckoutRequest
Expand All @@ -678,6 +688,7 @@ export type RpcRequest = SignTransactionRequest
| RefundSwapRequest;

export type RpcResult = SignedTransaction
| SignedTransaction[]
| Account
| Account[]
| SimpleResult
Expand All @@ -700,6 +711,7 @@ export type ResultByRequestType<T> =
T extends RequestType.CHOOSE_ADDRESS ? ChooseAddressResult :
T extends RequestType.ADD_ADDRESS ? Address :
T extends RequestType.SIGN_TRANSACTION ? SignedTransaction :
T extends RequestType.SIGN_STAKING ? SignedTransaction[] :
T extends RequestType.CHECKOUT ? SignedTransaction | SimpleResult :
T extends RequestType.SIGN_MESSAGE ? SignedMessage :
T extends RequestType.LOGOUT | RequestType.CHANGE_PASSWORD ? SimpleResult :
Expand Down
Loading

0 comments on commit 8bbaa4a

Please sign in to comment.