@ledgerhq/types-live 6.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +743 -0
- package/lib/account.d.ts +198 -0
- package/lib/account.d.ts.map +1 -0
- package/lib/account.js +3 -0
- package/lib/account.js.map +1 -0
- package/lib/bridge.d.ts +91 -0
- package/lib/bridge.d.ts.map +1 -0
- package/lib/bridge.js +3 -0
- package/lib/bridge.js.map +1 -0
- package/lib/derivation.d.ts +5 -0
- package/lib/derivation.d.ts.map +1 -0
- package/lib/derivation.js +3 -0
- package/lib/derivation.js.map +1 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/nft.d.ts +44 -0
- package/lib/nft.d.ts.map +1 -0
- package/lib/nft.js +3 -0
- package/lib/nft.js.map +1 -0
- package/lib/operation.d.ts +59 -0
- package/lib/operation.d.ts.map +1 -0
- package/lib/operation.js +3 -0
- package/lib/operation.js.map +1 -0
- package/lib/pagination.d.ts +18 -0
- package/lib/pagination.d.ts.map +1 -0
- package/lib/pagination.js +3 -0
- package/lib/pagination.js.map +1 -0
- package/lib/portfolio.d.ts +98 -0
- package/lib/portfolio.d.ts.map +1 -0
- package/lib/portfolio.js +3 -0
- package/lib/portfolio.js.map +1 -0
- package/lib/swap.d.ts +28 -0
- package/lib/swap.d.ts.map +1 -0
- package/lib/swap.js +3 -0
- package/lib/swap.js.map +1 -0
- package/lib/transaction.d.ts +157 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +3 -0
- package/lib/transaction.js.map +1 -0
- package/lib-es/account.d.ts +198 -0
- package/lib-es/account.d.ts.map +1 -0
- package/lib-es/account.js +2 -0
- package/lib-es/account.js.map +1 -0
- package/lib-es/bridge.d.ts +91 -0
- package/lib-es/bridge.d.ts.map +1 -0
- package/lib-es/bridge.js +2 -0
- package/lib-es/bridge.js.map +1 -0
- package/lib-es/derivation.d.ts +5 -0
- package/lib-es/derivation.d.ts.map +1 -0
- package/lib-es/derivation.js +2 -0
- package/lib-es/derivation.js.map +1 -0
- package/lib-es/index.d.ts +9 -0
- package/lib-es/index.d.ts.map +1 -0
- package/lib-es/index.js +9 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/nft.d.ts +44 -0
- package/lib-es/nft.d.ts.map +1 -0
- package/lib-es/nft.js +2 -0
- package/lib-es/nft.js.map +1 -0
- package/lib-es/operation.d.ts +59 -0
- package/lib-es/operation.d.ts.map +1 -0
- package/lib-es/operation.js +2 -0
- package/lib-es/operation.js.map +1 -0
- package/lib-es/pagination.d.ts +18 -0
- package/lib-es/pagination.d.ts.map +1 -0
- package/lib-es/pagination.js +2 -0
- package/lib-es/pagination.js.map +1 -0
- package/lib-es/portfolio.d.ts +98 -0
- package/lib-es/portfolio.d.ts.map +1 -0
- package/lib-es/portfolio.js +2 -0
- package/lib-es/portfolio.js.map +1 -0
- package/lib-es/swap.d.ts +28 -0
- package/lib-es/swap.d.ts.map +1 -0
- package/lib-es/swap.js +2 -0
- package/lib-es/swap.js.map +1 -0
- package/lib-es/transaction.d.ts +157 -0
- package/lib-es/transaction.d.ts.map +1 -0
- package/lib-es/transaction.js +2 -0
- package/lib-es/transaction.js.map +1 -0
- package/package.json +35 -0
- package/src/account.ts +295 -0
- package/src/bridge.ts +149 -0
- package/src/derivation.ts +4 -0
- package/src/index.ts +8 -0
- package/src/nft.ts +53 -0
- package/src/operation.ts +130 -0
- package/src/pagination.ts +21 -0
- package/src/portfolio.ts +118 -0
- package/src/swap.ts +29 -0
- package/src/transaction.ts +188 -0
- package/tsconfig.json +7 -0
package/src/portfolio.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { BigNumber } from "bignumber.js";
|
|
2
|
+
import type { AccountLike, AccountLikeArray } from "./account";
|
|
3
|
+
import type {
|
|
4
|
+
CryptoCurrency,
|
|
5
|
+
TokenCurrency,
|
|
6
|
+
} from "@ledgerhq/types-cryptoassets";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export type BalanceHistoryData = {
|
|
12
|
+
date: Date;
|
|
13
|
+
value: BigNumber;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
export type BalanceHistory = BalanceHistoryData[];
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
export type BalanceHistoryRaw = Array<[string, string]>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
export type BalanceHistoryWithCountervalue = Array<{
|
|
28
|
+
date: Date;
|
|
29
|
+
value: BigNumber;
|
|
30
|
+
countervalue: BigNumber;
|
|
31
|
+
}>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
export type ValueChange = {
|
|
37
|
+
percentage: BigNumber | null | undefined;
|
|
38
|
+
// value from 0 to 1. not defined if not meaningful
|
|
39
|
+
value: BigNumber; // delta of change
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
export type AccountPortfolio = {
|
|
46
|
+
history: BalanceHistoryWithCountervalue;
|
|
47
|
+
countervalueAvailable: boolean;
|
|
48
|
+
countervalueReceiveSum: BigNumber;
|
|
49
|
+
countervalueSendSum: BigNumber;
|
|
50
|
+
cryptoChange: ValueChange;
|
|
51
|
+
// how much the account changes. value is in the account currency
|
|
52
|
+
countervalueChange: ValueChange; // calculates the ROI. value in the countervalue unit.
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
export type CurrencyPortfolio = {
|
|
59
|
+
history: BalanceHistoryWithCountervalue;
|
|
60
|
+
countervalueAvailable: boolean;
|
|
61
|
+
histories: BalanceHistoryWithCountervalue[];
|
|
62
|
+
accounts: AccountLikeArray;
|
|
63
|
+
cryptoChange: ValueChange;
|
|
64
|
+
// how much the account changes. value is in the account currency
|
|
65
|
+
countervalueChange: ValueChange; // calculates the ROI. value in the countervalue unit.
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
export type Portfolio = {
|
|
72
|
+
balanceHistory: BalanceHistory;
|
|
73
|
+
balanceAvailable: boolean;
|
|
74
|
+
availableAccounts: AccountLike[];
|
|
75
|
+
unavailableCurrencies: (CryptoCurrency | TokenCurrency)[];
|
|
76
|
+
accounts: AccountLike[];
|
|
77
|
+
range: PortfolioRange;
|
|
78
|
+
histories: BalanceHistoryWithCountervalue[];
|
|
79
|
+
countervalueReceiveSum: BigNumber;
|
|
80
|
+
countervalueSendSum: BigNumber;
|
|
81
|
+
countervalueChange: ValueChange; // calculates the ROI. value in the countervalue unit.
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
*/
|
|
87
|
+
export type PortfolioRangeConfig = {
|
|
88
|
+
count: number;
|
|
89
|
+
granularityId: "HOUR" | "DAY" | "WEEK";
|
|
90
|
+
// only supported here atm
|
|
91
|
+
startOf: (arg0: Date) => Date;
|
|
92
|
+
increment: number;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
*/
|
|
98
|
+
export type PortfolioRange = "year" | "month" | "week" | "day";
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
*/
|
|
103
|
+
export type AssetsDistribution = {
|
|
104
|
+
// false if no distribution can be done (sum is zero)
|
|
105
|
+
isAvailable: boolean;
|
|
106
|
+
// a sorted list of assets with data
|
|
107
|
+
list: Array<{
|
|
108
|
+
currency: CryptoCurrency | TokenCurrency;
|
|
109
|
+
distribution: number;
|
|
110
|
+
// % of the total (normalized in 0-1)
|
|
111
|
+
amount: BigNumber;
|
|
112
|
+
countervalue: BigNumber; // countervalue of the amount that was calculated based of the rate provided
|
|
113
|
+
}>;
|
|
114
|
+
// number of accounts to show first (before the see all)
|
|
115
|
+
showFirst: number;
|
|
116
|
+
// sum of all countervalues
|
|
117
|
+
sum: BigNumber;
|
|
118
|
+
};
|
package/src/swap.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export type SwapOperation = {
|
|
7
|
+
provider: string;
|
|
8
|
+
swapId: string;
|
|
9
|
+
status: string;
|
|
10
|
+
receiverAccountId: string;
|
|
11
|
+
tokenId?: string;
|
|
12
|
+
operationId: string;
|
|
13
|
+
fromAmount: BigNumber;
|
|
14
|
+
toAmount: BigNumber;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
export type SwapOperationRaw = {
|
|
21
|
+
provider: string;
|
|
22
|
+
swapId: string;
|
|
23
|
+
status: string;
|
|
24
|
+
receiverAccountId: string;
|
|
25
|
+
tokenId?: string;
|
|
26
|
+
operationId: string;
|
|
27
|
+
fromAmount: string;
|
|
28
|
+
toAmount: string;
|
|
29
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { BigNumber } from "bignumber.js";
|
|
2
|
+
import type { Operation, OperationRaw } from "./operation";
|
|
3
|
+
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export type BitcoinInput = {
|
|
9
|
+
address: string | null | undefined;
|
|
10
|
+
value: BigNumber | null | undefined;
|
|
11
|
+
previousTxHash: string | null | undefined;
|
|
12
|
+
previousOutputIndex: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
export type BitcoinInputRaw = [
|
|
19
|
+
string | null | undefined,
|
|
20
|
+
string | null | undefined,
|
|
21
|
+
string | null | undefined,
|
|
22
|
+
number
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
export type BitcoinOutput = {
|
|
29
|
+
hash: string;
|
|
30
|
+
outputIndex: number;
|
|
31
|
+
blockHeight: number | null | undefined;
|
|
32
|
+
address: string | null | undefined;
|
|
33
|
+
path: string | null | undefined; // DEPRECATED - used only by legacy libcore implementation
|
|
34
|
+
value: BigNumber;
|
|
35
|
+
rbf: boolean;
|
|
36
|
+
isChange: boolean;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
export type BitcoinOutputRaw = [
|
|
43
|
+
string,
|
|
44
|
+
number,
|
|
45
|
+
number | null | undefined,
|
|
46
|
+
string | null | undefined,
|
|
47
|
+
string | null | undefined,
|
|
48
|
+
string,
|
|
49
|
+
number, // rbf 0/1 for compression
|
|
50
|
+
number
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
export type SignedOperation = {
|
|
57
|
+
// prepared version of Operation before it's even broadcasted
|
|
58
|
+
// .id/.hash is potentially not settled yet
|
|
59
|
+
operation: Operation;
|
|
60
|
+
// usually the device signature hex OR anything that is needed to broadcast (can be an inline JSON)
|
|
61
|
+
signature: string;
|
|
62
|
+
// sometimes a coin needs the raw object (it must be serializable)
|
|
63
|
+
signatureRaw?: Record<string, any>;
|
|
64
|
+
// date calculated as expiring
|
|
65
|
+
expirationDate: Date | null | undefined;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
export type SignedOperationRaw = {
|
|
72
|
+
operation: OperationRaw;
|
|
73
|
+
signature: string;
|
|
74
|
+
signatureRaw?: Record<string, any>;
|
|
75
|
+
expirationDate: string | null | undefined;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
81
|
+
export type SignOperationEvent = // Used when lot of exchange is needed with the device to visually express a progress
|
|
82
|
+
// It can be used before and/or after the signature
|
|
83
|
+
// only used if it can takes >1s to show a visual progress to user (typically UTXO streaming)
|
|
84
|
+
| {
|
|
85
|
+
type: "device-streaming";
|
|
86
|
+
progress: number;
|
|
87
|
+
index: number;
|
|
88
|
+
total: number;
|
|
89
|
+
} // optional
|
|
90
|
+
// REQUIRED Indicates that a signature is now appearing and awaited on the device to confirm
|
|
91
|
+
| {
|
|
92
|
+
type: "device-signature-requested";
|
|
93
|
+
} // REQUIRED Indicates user have confirmed the transaction
|
|
94
|
+
| {
|
|
95
|
+
type: "device-signature-granted";
|
|
96
|
+
} // REQUIRED payload of the resulting signed operation
|
|
97
|
+
| {
|
|
98
|
+
type: "signed";
|
|
99
|
+
signedOperation: SignedOperation;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
*/
|
|
105
|
+
export type SignOperationEventRaw =
|
|
106
|
+
| {
|
|
107
|
+
type: "device-streaming";
|
|
108
|
+
progress: number;
|
|
109
|
+
index: number;
|
|
110
|
+
total: number;
|
|
111
|
+
}
|
|
112
|
+
| {
|
|
113
|
+
type: "device-signature-requested";
|
|
114
|
+
}
|
|
115
|
+
| {
|
|
116
|
+
type: "device-signature-granted";
|
|
117
|
+
}
|
|
118
|
+
| {
|
|
119
|
+
type: "signed";
|
|
120
|
+
signedOperation: SignedOperationRaw;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Transaction is a generic object that holds all state for all transactions
|
|
124
|
+
* there are generic fields and coin specific fields. That's why almost all fields are optionals
|
|
125
|
+
*/
|
|
126
|
+
export type TransactionCommon = {
|
|
127
|
+
amount: BigNumber;
|
|
128
|
+
recipient: string;
|
|
129
|
+
useAllAmount?: boolean;
|
|
130
|
+
subAccountId?: string | null | undefined;
|
|
131
|
+
feesStrategy?: "slow" | "medium" | "fast" | "custom" | null;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
*
|
|
136
|
+
*/
|
|
137
|
+
export type TransactionCommonRaw = {
|
|
138
|
+
amount: string;
|
|
139
|
+
recipient: string;
|
|
140
|
+
useAllAmount?: boolean;
|
|
141
|
+
subAccountId?: string | null | undefined;
|
|
142
|
+
feesStrategy?: "slow" | "medium" | "fast" | "custom" | null;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* User can have 3 differents choice for their fee
|
|
147
|
+
* Most of the time mid is low * 1.25 and high is low * 1.5
|
|
148
|
+
* They are some exception as eth that got his own meter
|
|
149
|
+
*/
|
|
150
|
+
export type FeeStrategy = {
|
|
151
|
+
amount: BigNumber;
|
|
152
|
+
displayedAmount?: BigNumber;
|
|
153
|
+
label: string;
|
|
154
|
+
unit?: Unit;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* TransactionStatus is a view of Transaction with general info to be used on the UI and status info.
|
|
158
|
+
*/
|
|
159
|
+
export type TransactionStatus = {
|
|
160
|
+
// potential error for each (user) field of the transaction
|
|
161
|
+
errors: Record<string, Error>;
|
|
162
|
+
// potential warning for each (user) field for a transaction
|
|
163
|
+
warnings: Record<string, Error>;
|
|
164
|
+
// estimated total fees the tx is going to cost. (in the mainAccount currency)
|
|
165
|
+
estimatedFees: BigNumber;
|
|
166
|
+
// actual amount that the recipient will receive (in account currency)
|
|
167
|
+
amount: BigNumber;
|
|
168
|
+
// total amount that the sender will spend (in account currency)
|
|
169
|
+
totalSpent: BigNumber;
|
|
170
|
+
// should the recipient be non editable
|
|
171
|
+
recipientIsReadOnly?: boolean;
|
|
172
|
+
txInputs?: BitcoinInput[];
|
|
173
|
+
txOutputs?: BitcoinOutput[];
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
*
|
|
177
|
+
*/
|
|
178
|
+
export type TransactionStatusRaw = {
|
|
179
|
+
errors: Record<string, string>;
|
|
180
|
+
warnings: Record<string, string>;
|
|
181
|
+
estimatedFees: string;
|
|
182
|
+
amount: string;
|
|
183
|
+
totalSpent: string;
|
|
184
|
+
useAllAmount?: boolean;
|
|
185
|
+
recipientIsReadOnly?: boolean;
|
|
186
|
+
txInputs?: BitcoinInputRaw[];
|
|
187
|
+
txOutputs?: BitcoinOutputRaw[];
|
|
188
|
+
};
|