@shapeshiftoss/types 1.0.1 → 1.2.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/dist/{types.d.ts → base.d.ts} +30 -158
- package/dist/{types.js → base.js} +1 -12
- package/dist/chain-adapters/bitcoin.d.ts +56 -0
- package/dist/chain-adapters/bitcoin.js +2 -0
- package/dist/chain-adapters/ethereum.d.ts +32 -0
- package/dist/chain-adapters/ethereum.js +2 -0
- package/dist/chain-adapters/index.assert.d.ts +0 -0
- package/dist/chain-adapters/index.assert.js +16 -0
- package/dist/chain-adapters/index.d.ts +143 -0
- package/dist/{types.assert.js → chain-adapters/index.js} +17 -14
- package/dist/index.d.ts +3 -1
- package/dist/index.js +16 -1
- package/dist/utility.d.ts +24 -0
- package/dist/utility.js +7 -0
- package/package.json +2 -2
- package/dist/types.assert.d.ts +0 -1
|
@@ -1,4 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HDWallet } from '@shapeshiftoss/hdwallet-core';
|
|
2
|
+
import { ethereum, SignTxInput } from './chain-adapters';
|
|
3
|
+
/** Common */
|
|
4
|
+
export declare type BIP32Params = {
|
|
5
|
+
purpose: number;
|
|
6
|
+
coinType: number;
|
|
7
|
+
accountNumber: number;
|
|
8
|
+
isChange?: boolean;
|
|
9
|
+
index?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare enum ContractTypes {
|
|
12
|
+
ERC20 = "ERC20",
|
|
13
|
+
ERC721 = "ERC721",
|
|
14
|
+
OTHER = "OTHER",
|
|
15
|
+
NONE = "NONE"
|
|
16
|
+
}
|
|
17
|
+
export declare enum ChainTypes {
|
|
18
|
+
Ethereum = "ethereum",
|
|
19
|
+
Bitcoin = "bitcoin"
|
|
20
|
+
}
|
|
21
|
+
export declare enum NetworkTypes {
|
|
22
|
+
MAINNET = "MAINNET",
|
|
23
|
+
TESTNET = "TESTNET",
|
|
24
|
+
ETH_ROPSTEN = "ETH_ROPSTEN",
|
|
25
|
+
ETH_RINKEBY = "ETH_RINKEBY"
|
|
26
|
+
}
|
|
2
27
|
declare type AbstractAsset = {
|
|
3
28
|
chain: ChainTypes;
|
|
4
29
|
network: NetworkTypes;
|
|
@@ -24,22 +49,6 @@ export declare type BaseAsset = AbstractAsset & {
|
|
|
24
49
|
tokens?: TokenAsset[];
|
|
25
50
|
};
|
|
26
51
|
export declare type Asset = AbstractAsset & Partial<TokenAssetFields>;
|
|
27
|
-
export declare enum ContractTypes {
|
|
28
|
-
ERC20 = "ERC20",
|
|
29
|
-
ERC721 = "ERC721",
|
|
30
|
-
OTHER = "OTHER",
|
|
31
|
-
NONE = "NONE"
|
|
32
|
-
}
|
|
33
|
-
export declare enum ChainTypes {
|
|
34
|
-
Ethereum = "ethereum",
|
|
35
|
-
Bitcoin = "bitcoin"
|
|
36
|
-
}
|
|
37
|
-
export declare enum NetworkTypes {
|
|
38
|
-
MAINNET = "MAINNET",
|
|
39
|
-
TESTNET = "TESTNET",
|
|
40
|
-
ETH_ROPSTEN = "ETH_ROPSTEN",
|
|
41
|
-
ETH_RINKEBY = "ETH_RINKEBY"
|
|
42
|
-
}
|
|
43
52
|
export declare type MarketData = {
|
|
44
53
|
price: string;
|
|
45
54
|
marketCap: string;
|
|
@@ -67,22 +76,12 @@ export declare type MarketDataArgs = {
|
|
|
67
76
|
chain: ChainTypes;
|
|
68
77
|
tokenId?: string;
|
|
69
78
|
};
|
|
70
|
-
export declare type MarketDataType = (args: MarketDataArgs) => Promise<MarketData
|
|
71
|
-
export declare type PriceHistoryType = (args: PriceHistoryArgs) => Promise<HistoryData[]
|
|
79
|
+
export declare type MarketDataType = (args: MarketDataArgs) => Promise<MarketData>;
|
|
80
|
+
export declare type PriceHistoryType = (args: PriceHistoryArgs) => Promise<HistoryData[]>;
|
|
72
81
|
export declare enum SwapperType {
|
|
73
82
|
Zrx = "0x",
|
|
74
83
|
Thorchain = "Thorchain"
|
|
75
84
|
}
|
|
76
|
-
export declare type FeeData = {
|
|
77
|
-
fee?: string;
|
|
78
|
-
gas?: string;
|
|
79
|
-
estimatedGas?: string;
|
|
80
|
-
gasPrice?: string;
|
|
81
|
-
approvalFee?: string;
|
|
82
|
-
protocolFee?: string;
|
|
83
|
-
minimumProtocolFee?: string;
|
|
84
|
-
receiveNetworkFee?: string;
|
|
85
|
-
};
|
|
86
85
|
export declare type SwapSource = {
|
|
87
86
|
name: string;
|
|
88
87
|
proportion: string;
|
|
@@ -115,12 +114,6 @@ export declare type ThorVaultInfo = {
|
|
|
115
114
|
vaultAddress: string;
|
|
116
115
|
timestamp: string;
|
|
117
116
|
};
|
|
118
|
-
export declare type SignTx = ETHSignTx | BTCSignTx;
|
|
119
|
-
declare type ChainTxTypeInner = {
|
|
120
|
-
[ChainTypes.Ethereum]: ETHSignTx;
|
|
121
|
-
[ChainTypes.Bitcoin]: BTCSignTx;
|
|
122
|
-
};
|
|
123
|
-
export declare type ChainTxType<T> = T extends keyof ChainTxTypeInner ? ChainTxTypeInner[T] : never;
|
|
124
117
|
export declare type BuildThorTradeOutput = SignTxInput<unknown> & ThorVaultInfo;
|
|
125
118
|
export declare type Quote = {
|
|
126
119
|
success: boolean;
|
|
@@ -139,9 +132,9 @@ export declare type Quote = {
|
|
|
139
132
|
maximum?: string | null;
|
|
140
133
|
guaranteedPrice?: string;
|
|
141
134
|
slipScore?: string;
|
|
142
|
-
txData?: string
|
|
135
|
+
txData?: string;
|
|
143
136
|
value?: string;
|
|
144
|
-
feeData?:
|
|
137
|
+
feeData?: ethereum.QuoteFeeData;
|
|
145
138
|
allowanceContract?: string;
|
|
146
139
|
allowanceGrantRequired?: boolean;
|
|
147
140
|
slippage?: string;
|
|
@@ -183,125 +176,4 @@ export declare type ApprovalNeededOutput = {
|
|
|
183
176
|
gas?: string;
|
|
184
177
|
gasPrice?: string;
|
|
185
178
|
};
|
|
186
|
-
declare type TransactionBase<T extends ChainTypes> = {
|
|
187
|
-
network: NetworkTypes;
|
|
188
|
-
chain: T;
|
|
189
|
-
symbol: string;
|
|
190
|
-
txid: string;
|
|
191
|
-
status: string;
|
|
192
|
-
from: string;
|
|
193
|
-
to: string;
|
|
194
|
-
blockHash: string;
|
|
195
|
-
blockHeight: number;
|
|
196
|
-
confirmations: number;
|
|
197
|
-
timestamp: number;
|
|
198
|
-
value: string;
|
|
199
|
-
fee: string;
|
|
200
|
-
};
|
|
201
|
-
declare type EthereumSpecificFields = {
|
|
202
|
-
nonce: string;
|
|
203
|
-
};
|
|
204
|
-
declare type BitcoinSpecificFields = {
|
|
205
|
-
opReturn: string;
|
|
206
|
-
};
|
|
207
|
-
declare type ChainFieldMap = {
|
|
208
|
-
[ChainTypes.Ethereum]: EthereumSpecificFields;
|
|
209
|
-
[ChainTypes.Bitcoin]: BitcoinSpecificFields;
|
|
210
|
-
};
|
|
211
|
-
declare type ChainSpecificFields<T extends ChainTypes> = T extends keyof ChainFieldMap ? ChainFieldMap[T] : never;
|
|
212
|
-
export declare type Transaction<T extends ChainTypes = ChainTypes> = TransactionBase<T> & {
|
|
213
|
-
details: ChainSpecificFields<T> & Record<string, undefined>;
|
|
214
|
-
};
|
|
215
|
-
export declare type TxHistoryResponse<T extends ChainTypes> = {
|
|
216
|
-
page: number;
|
|
217
|
-
totalPages: number;
|
|
218
|
-
txs: number;
|
|
219
|
-
transactions: Transaction<T>[];
|
|
220
|
-
};
|
|
221
|
-
export declare type Token = {
|
|
222
|
-
type: string;
|
|
223
|
-
name: string;
|
|
224
|
-
path?: string;
|
|
225
|
-
contract?: string;
|
|
226
|
-
transfers: number;
|
|
227
|
-
symbol?: string;
|
|
228
|
-
decimals?: number;
|
|
229
|
-
balance?: string;
|
|
230
|
-
totalReceived?: string;
|
|
231
|
-
totalSent?: string;
|
|
232
|
-
};
|
|
233
|
-
export declare type BalanceResponse = {
|
|
234
|
-
network: NetworkTypes;
|
|
235
|
-
symbol: string;
|
|
236
|
-
address: string;
|
|
237
|
-
balance: string;
|
|
238
|
-
unconfirmedBalance: string;
|
|
239
|
-
unconfirmedTxs: number;
|
|
240
|
-
txs: number;
|
|
241
|
-
tokens: Token[];
|
|
242
|
-
};
|
|
243
|
-
export declare type BroadcastTxResponse = {
|
|
244
|
-
network: NetworkTypes;
|
|
245
|
-
txid: string;
|
|
246
|
-
};
|
|
247
|
-
export declare type BuildSendTxInput = {
|
|
248
|
-
to: string;
|
|
249
|
-
value: string;
|
|
250
|
-
wallet: HDWallet;
|
|
251
|
-
path: string;
|
|
252
|
-
/*** In base units */
|
|
253
|
-
fee?: string;
|
|
254
|
-
/*** Optional param for eth txs indicating what ERC20 is being sent */
|
|
255
|
-
erc20ContractAddress?: string;
|
|
256
|
-
limit?: string;
|
|
257
|
-
};
|
|
258
|
-
export declare type SignTxInput<TxType> = {
|
|
259
|
-
txToSign: TxType;
|
|
260
|
-
wallet: HDWallet;
|
|
261
|
-
};
|
|
262
|
-
export declare type GetAddressInput = {
|
|
263
|
-
wallet: HDWallet;
|
|
264
|
-
path: string;
|
|
265
|
-
};
|
|
266
|
-
export declare type GetFeeDataInput = {
|
|
267
|
-
contractAddress?: string;
|
|
268
|
-
from: string;
|
|
269
|
-
to: string;
|
|
270
|
-
value: string;
|
|
271
|
-
};
|
|
272
|
-
export declare enum FeeDataKey {
|
|
273
|
-
Slow = "slow",
|
|
274
|
-
Average = "average",
|
|
275
|
-
Fast = "fast"
|
|
276
|
-
}
|
|
277
|
-
export declare type FeeDataType = {
|
|
278
|
-
feeUnitPrice: string;
|
|
279
|
-
networkFee: string;
|
|
280
|
-
feeUnits: string;
|
|
281
|
-
};
|
|
282
|
-
export declare type FeeDataEstimate = {
|
|
283
|
-
[FeeDataKey.Slow]: FeeDataType;
|
|
284
|
-
[FeeDataKey.Average]: FeeDataType;
|
|
285
|
-
[FeeDataKey.Fast]: FeeDataType;
|
|
286
|
-
};
|
|
287
|
-
export declare enum ValidAddressResultType {
|
|
288
|
-
Valid = "valid",
|
|
289
|
-
Invalid = "invalid"
|
|
290
|
-
}
|
|
291
|
-
export declare type ValidAddressResult = {
|
|
292
|
-
/**
|
|
293
|
-
* Is this Address valid
|
|
294
|
-
*/
|
|
295
|
-
valid: boolean;
|
|
296
|
-
/**
|
|
297
|
-
* Result type of valid address
|
|
298
|
-
*/
|
|
299
|
-
result: ValidAddressResultType;
|
|
300
|
-
};
|
|
301
|
-
export declare type FeeEstimateInput = {
|
|
302
|
-
to: string;
|
|
303
|
-
from: string;
|
|
304
|
-
data: string;
|
|
305
|
-
value: string;
|
|
306
|
-
};
|
|
307
179
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SwapperType = exports.HistoryTimeframe = exports.NetworkTypes = exports.ChainTypes = exports.ContractTypes = void 0;
|
|
4
4
|
var ContractTypes;
|
|
5
5
|
(function (ContractTypes) {
|
|
6
6
|
ContractTypes["ERC20"] = "ERC20";
|
|
@@ -35,14 +35,3 @@ var SwapperType;
|
|
|
35
35
|
SwapperType["Zrx"] = "0x";
|
|
36
36
|
SwapperType["Thorchain"] = "Thorchain";
|
|
37
37
|
})(SwapperType = exports.SwapperType || (exports.SwapperType = {}));
|
|
38
|
-
var FeeDataKey;
|
|
39
|
-
(function (FeeDataKey) {
|
|
40
|
-
FeeDataKey["Slow"] = "slow";
|
|
41
|
-
FeeDataKey["Average"] = "average";
|
|
42
|
-
FeeDataKey["Fast"] = "fast";
|
|
43
|
-
})(FeeDataKey = exports.FeeDataKey || (exports.FeeDataKey = {}));
|
|
44
|
-
var ValidAddressResultType;
|
|
45
|
-
(function (ValidAddressResultType) {
|
|
46
|
-
ValidAddressResultType["Valid"] = "valid";
|
|
47
|
-
ValidAddressResultType["Invalid"] = "invalid";
|
|
48
|
-
})(ValidAddressResultType = exports.ValidAddressResultType || (exports.ValidAddressResultType = {}));
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { BTCInputScriptType } from '@shapeshiftoss/hdwallet-core';
|
|
2
|
+
import { GetAddressInputBase } from '.';
|
|
3
|
+
export declare type Account = {
|
|
4
|
+
nextChangeAddressIndex?: number;
|
|
5
|
+
nextReceiveAddressIndex?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare type GetAddressInput = GetAddressInputBase & {
|
|
8
|
+
scriptType: BTCInputScriptType;
|
|
9
|
+
};
|
|
10
|
+
export declare type TransactionSpecific = {
|
|
11
|
+
opReturnData?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare type Recipient = {
|
|
14
|
+
value: number;
|
|
15
|
+
address?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare type ScriptSig = {
|
|
18
|
+
hex: string;
|
|
19
|
+
asm: string;
|
|
20
|
+
};
|
|
21
|
+
export declare type Vin = {
|
|
22
|
+
txinwitness?: string;
|
|
23
|
+
scriptSig?: ScriptSig;
|
|
24
|
+
coinbase?: string;
|
|
25
|
+
sequence?: number;
|
|
26
|
+
vout?: number;
|
|
27
|
+
txid?: string;
|
|
28
|
+
};
|
|
29
|
+
export declare type Vout = {
|
|
30
|
+
scriptPubKey?: ScriptPubKey;
|
|
31
|
+
n?: number;
|
|
32
|
+
value?: string | number;
|
|
33
|
+
};
|
|
34
|
+
export declare type ScriptPubKey = {
|
|
35
|
+
addresses: Array<string>;
|
|
36
|
+
type: string;
|
|
37
|
+
reqSigs: number;
|
|
38
|
+
hex: string;
|
|
39
|
+
asm: string;
|
|
40
|
+
};
|
|
41
|
+
export declare type NodeTransaction = {
|
|
42
|
+
txid: string;
|
|
43
|
+
hash: string;
|
|
44
|
+
version: number;
|
|
45
|
+
size: number;
|
|
46
|
+
vsize: number;
|
|
47
|
+
weight: number;
|
|
48
|
+
locktime: number;
|
|
49
|
+
vin: Array<Vin>;
|
|
50
|
+
vout: Array<Vout>;
|
|
51
|
+
hex: string;
|
|
52
|
+
blockhash: string;
|
|
53
|
+
confirmations: number;
|
|
54
|
+
time: number;
|
|
55
|
+
blocktime: number;
|
|
56
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ContractTypes } from '../base';
|
|
2
|
+
export declare type Account = {
|
|
3
|
+
nonce: number;
|
|
4
|
+
tokens?: Array<TokenWithBalance>;
|
|
5
|
+
};
|
|
6
|
+
export declare type Token = {
|
|
7
|
+
contract: string;
|
|
8
|
+
precision: number;
|
|
9
|
+
name: string;
|
|
10
|
+
symbol: string;
|
|
11
|
+
contractType: ContractTypes;
|
|
12
|
+
};
|
|
13
|
+
export declare type TokenWithBalance = Token & {
|
|
14
|
+
balance: string;
|
|
15
|
+
};
|
|
16
|
+
export declare type TxTransfer = {
|
|
17
|
+
token?: Token;
|
|
18
|
+
};
|
|
19
|
+
export declare type FeeData = {
|
|
20
|
+
feePerTx: string;
|
|
21
|
+
feeLimit: string;
|
|
22
|
+
};
|
|
23
|
+
export declare type QuoteFeeData = {
|
|
24
|
+
fee?: string;
|
|
25
|
+
gas?: string;
|
|
26
|
+
estimatedGas?: string;
|
|
27
|
+
gasPrice?: string;
|
|
28
|
+
approvalFee?: string;
|
|
29
|
+
protocolFee?: string;
|
|
30
|
+
minimumProtocolFee?: string;
|
|
31
|
+
receiveNetworkFee?: string;
|
|
32
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import * as ta from 'type-assertions'
|
|
3
|
+
// import { ChainTypes } from '../base'
|
|
4
|
+
// unit tests for types
|
|
5
|
+
// a generic transaction should have details.nonce of string | undefined
|
|
6
|
+
// ta.assert<ta.Equal<Transaction['details']['nonce'], string | undefined>>()
|
|
7
|
+
// // a generic transaction should have details.opReturn of string | undefined
|
|
8
|
+
// ta.assert<ta.Equal<Transaction['details']['opReturn'], string | undefined>>()
|
|
9
|
+
// // an ethereum transaction should have details.nonce of string
|
|
10
|
+
// ta.assert<ta.Equal<Transaction<ChainTypes.Ethereum>['details']['nonce'], string>>()
|
|
11
|
+
// // an ethereum transaction should have details.opReturn of undefined
|
|
12
|
+
// ta.assert<ta.Equal<Transaction<ChainTypes.Ethereum>['details']['opReturn'], undefined>>()
|
|
13
|
+
// // a bitcoin transaction should have details.nonce of undefined
|
|
14
|
+
// ta.assert<ta.Equal<Transaction<ChainTypes.Bitcoin>['details']['nonce'], undefined>>()
|
|
15
|
+
// // a bitcoin transaction should have details.opReturn of string
|
|
16
|
+
// ta.assert<ta.Equal<Transaction<ChainTypes.Bitcoin>['details']['opReturn'], string>>()
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { HDWallet, BTCInputScriptType, BTCSignTx, ETHSignTx } from '@shapeshiftoss/hdwallet-core';
|
|
2
|
+
import { BIP32Params, ChainTypes, NetworkTypes } from '../base';
|
|
3
|
+
import { ChainSpecific } from '../utility';
|
|
4
|
+
import * as ethereum from './ethereum';
|
|
5
|
+
import * as bitcoin from './bitcoin';
|
|
6
|
+
export { bitcoin, ethereum };
|
|
7
|
+
declare type ChainSpecificAccount<T> = ChainSpecific<T, {
|
|
8
|
+
[ChainTypes.Ethereum]: ethereum.Account;
|
|
9
|
+
[ChainTypes.Bitcoin]: bitcoin.Account;
|
|
10
|
+
}>;
|
|
11
|
+
export declare type Account<T extends ChainTypes> = {
|
|
12
|
+
balance: string;
|
|
13
|
+
pubkey: string;
|
|
14
|
+
symbol: string;
|
|
15
|
+
chain: T;
|
|
16
|
+
network: NetworkTypes;
|
|
17
|
+
} & ChainSpecificAccount<T>;
|
|
18
|
+
declare type ChainSpecificTransaction<T> = ChainSpecific<T, {
|
|
19
|
+
[ChainTypes.Bitcoin]: bitcoin.TransactionSpecific;
|
|
20
|
+
}>;
|
|
21
|
+
export declare type Transaction<T extends ChainTypes> = {
|
|
22
|
+
network: NetworkTypes;
|
|
23
|
+
chain: T;
|
|
24
|
+
symbol: string;
|
|
25
|
+
txid: string;
|
|
26
|
+
status: string;
|
|
27
|
+
from: string;
|
|
28
|
+
to?: string;
|
|
29
|
+
blockHash?: string;
|
|
30
|
+
blockHeight?: number;
|
|
31
|
+
confirmations?: number;
|
|
32
|
+
timestamp?: number;
|
|
33
|
+
value: string;
|
|
34
|
+
fee: string;
|
|
35
|
+
} & ChainSpecificTransaction<T>;
|
|
36
|
+
export declare enum FeeDataKey {
|
|
37
|
+
Slow = "slow",
|
|
38
|
+
Average = "average",
|
|
39
|
+
Fast = "fast"
|
|
40
|
+
}
|
|
41
|
+
declare type ChainSpecificFeeData<T> = ChainSpecific<T, {
|
|
42
|
+
[ChainTypes.Ethereum]: ethereum.FeeData;
|
|
43
|
+
}>;
|
|
44
|
+
export declare type FeeData<T extends ChainTypes> = {
|
|
45
|
+
feePerUnit: string;
|
|
46
|
+
} & ChainSpecificFeeData<T>;
|
|
47
|
+
export declare type FeeDataEstimate<T extends ChainTypes> = {
|
|
48
|
+
[FeeDataKey.Slow]: FeeData<T>;
|
|
49
|
+
[FeeDataKey.Average]: FeeData<T>;
|
|
50
|
+
[FeeDataKey.Fast]: FeeData<T>;
|
|
51
|
+
};
|
|
52
|
+
export declare type SubscribeTxsInput = {
|
|
53
|
+
addresses: Array<string>;
|
|
54
|
+
};
|
|
55
|
+
export declare type SubscribeTxsMessage<T extends ChainTypes> = {
|
|
56
|
+
address: string;
|
|
57
|
+
blockHash?: string;
|
|
58
|
+
blockHeight: number;
|
|
59
|
+
blockTime: number;
|
|
60
|
+
chain: T;
|
|
61
|
+
confirmations: number;
|
|
62
|
+
network: NetworkTypes;
|
|
63
|
+
txid: string;
|
|
64
|
+
} & TxTransfer<T>;
|
|
65
|
+
declare type ChainSpecificTxTransfer<T> = ChainSpecific<T, {
|
|
66
|
+
[ChainTypes.Ethereum]: ethereum.TxTransfer;
|
|
67
|
+
}>;
|
|
68
|
+
export declare type TxTransfer<T extends ChainTypes> = {
|
|
69
|
+
asset: string;
|
|
70
|
+
type: 'send' | 'receive' | 'fee';
|
|
71
|
+
value: string;
|
|
72
|
+
} & ChainSpecificTxTransfer<T>;
|
|
73
|
+
export declare type SubscribeError = {
|
|
74
|
+
message: string;
|
|
75
|
+
};
|
|
76
|
+
export declare type TxHistoryResponse<T extends ChainTypes> = {
|
|
77
|
+
page: number;
|
|
78
|
+
totalPages: number;
|
|
79
|
+
txs: number;
|
|
80
|
+
transactions: Array<Transaction<T>>;
|
|
81
|
+
};
|
|
82
|
+
declare type ChainTxTypeInner = {
|
|
83
|
+
[ChainTypes.Ethereum]: ETHSignTx;
|
|
84
|
+
[ChainTypes.Bitcoin]: BTCSignTx;
|
|
85
|
+
};
|
|
86
|
+
export declare type ChainTxType<T> = T extends keyof ChainTxTypeInner ? ChainTxTypeInner[T] : never;
|
|
87
|
+
export declare type BuildSendTxInput = {
|
|
88
|
+
to?: string;
|
|
89
|
+
value?: string;
|
|
90
|
+
wallet: HDWallet;
|
|
91
|
+
/** In base units **/
|
|
92
|
+
fee?: string;
|
|
93
|
+
/** Optional param for eth txs indicating what ERC20 is being sent **/
|
|
94
|
+
erc20ContractAddress?: string;
|
|
95
|
+
recipients?: Array<bitcoin.Recipient>;
|
|
96
|
+
opReturnData?: string;
|
|
97
|
+
scriptType?: BTCInputScriptType;
|
|
98
|
+
gasLimit?: string;
|
|
99
|
+
bip32Params?: BIP32Params;
|
|
100
|
+
feeSpeed?: FeeDataKey;
|
|
101
|
+
};
|
|
102
|
+
export declare type SignTxInput<TxType> = {
|
|
103
|
+
txToSign: TxType;
|
|
104
|
+
wallet: HDWallet;
|
|
105
|
+
};
|
|
106
|
+
export interface TxHistoryInput {
|
|
107
|
+
readonly pubkey: string;
|
|
108
|
+
readonly page?: number;
|
|
109
|
+
readonly pageSize?: number;
|
|
110
|
+
readonly contract?: string;
|
|
111
|
+
}
|
|
112
|
+
export declare type GetAddressInputBase = {
|
|
113
|
+
wallet: HDWallet;
|
|
114
|
+
bip32Params?: BIP32Params;
|
|
115
|
+
};
|
|
116
|
+
export declare type GetAddressInput = GetAddressInputBase | bitcoin.GetAddressInput;
|
|
117
|
+
export declare type GetFeeDataInput = {
|
|
118
|
+
contractAddress?: string;
|
|
119
|
+
from: string;
|
|
120
|
+
to: string;
|
|
121
|
+
value: string;
|
|
122
|
+
};
|
|
123
|
+
export declare enum ValidAddressResultType {
|
|
124
|
+
Valid = "valid",
|
|
125
|
+
Invalid = "invalid"
|
|
126
|
+
}
|
|
127
|
+
export declare type ValidAddressResult = {
|
|
128
|
+
/** Is this Address valid */
|
|
129
|
+
valid: boolean;
|
|
130
|
+
/** Result type of valid address */
|
|
131
|
+
result: ValidAddressResultType;
|
|
132
|
+
};
|
|
133
|
+
export declare type ZrxFeeResult = {
|
|
134
|
+
fast: number;
|
|
135
|
+
instant: number;
|
|
136
|
+
low: number;
|
|
137
|
+
source: 'ETH_GAS_STATION' | 'ETHERSCAN' | 'ETHERCHAIN' | 'GAS_NOW' | 'MY_CRYPTO' | 'UP_VEST' | 'GETH_PENDING' | 'MEDIAN' | 'AVERAGE';
|
|
138
|
+
standard: number;
|
|
139
|
+
timestamp: number;
|
|
140
|
+
};
|
|
141
|
+
export declare type ZrxGasApiResponse = {
|
|
142
|
+
result: ZrxFeeResult[];
|
|
143
|
+
};
|
|
@@ -19,17 +19,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
exports.ValidAddressResultType = exports.FeeDataKey = exports.ethereum = exports.bitcoin = void 0;
|
|
23
|
+
const base_1 = require("../base");
|
|
24
|
+
const ethereum = __importStar(require("./ethereum"));
|
|
25
|
+
exports.ethereum = ethereum;
|
|
26
|
+
const bitcoin = __importStar(require("./bitcoin"));
|
|
27
|
+
exports.bitcoin = bitcoin;
|
|
28
|
+
var FeeDataKey;
|
|
29
|
+
(function (FeeDataKey) {
|
|
30
|
+
FeeDataKey["Slow"] = "slow";
|
|
31
|
+
FeeDataKey["Average"] = "average";
|
|
32
|
+
FeeDataKey["Fast"] = "fast";
|
|
33
|
+
})(FeeDataKey = exports.FeeDataKey || (exports.FeeDataKey = {}));
|
|
34
|
+
var ValidAddressResultType;
|
|
35
|
+
(function (ValidAddressResultType) {
|
|
36
|
+
ValidAddressResultType["Valid"] = "valid";
|
|
37
|
+
ValidAddressResultType["Invalid"] = "invalid";
|
|
38
|
+
})(ValidAddressResultType = exports.ValidAddressResultType || (exports.ValidAddressResultType = {}));
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,8 +6,23 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
6
6
|
if (k2 === undefined) k2 = k;
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
9
21
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
22
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
23
|
};
|
|
12
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
|
|
25
|
+
exports.chainAdapters = void 0;
|
|
26
|
+
const chainAdapters = __importStar(require("./chain-adapters"));
|
|
27
|
+
exports.chainAdapters = chainAdapters;
|
|
28
|
+
__exportStar(require("./base"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Further reading on ideas behind these utility types
|
|
3
|
+
*
|
|
4
|
+
* See: https://stackoverflow.com/questions/55904032/how-to-get-optional-property-from-union
|
|
5
|
+
*/
|
|
6
|
+
/** Get specific type for key(K) in union(T) */
|
|
7
|
+
declare type ValueOfUnion<T, K> = T extends unknown ? (K extends keyof T ? T[K] : undefined) : never;
|
|
8
|
+
/** Get all keys in union(T) as union */
|
|
9
|
+
declare type KeysOfUnion<T> = T extends unknown ? keyof T : never;
|
|
10
|
+
/**
|
|
11
|
+
* Create mapping of all keys in union(T) with proper type values
|
|
12
|
+
*
|
|
13
|
+
* _note: `| keyof T` index is simply to tell typescript that T is definitely a sub type of KeysOfUnion_
|
|
14
|
+
*/
|
|
15
|
+
declare type UnionMapping<T> = {
|
|
16
|
+
[K in KeysOfUnion<T> | keyof T]: ValueOfUnion<T, K>;
|
|
17
|
+
};
|
|
18
|
+
/** Pick out the elements we know for sure and make everything else optional */
|
|
19
|
+
declare type UnionMerge<T> = Pick<UnionMapping<T>, keyof T> & Partial<UnionMapping<T>>;
|
|
20
|
+
/** Adds all possible values of union(T) as a nested object under a `chainSpecific` key */
|
|
21
|
+
export declare type ChainSpecific<T, M> = UnionMerge<T extends unknown ? (T extends keyof M ? {
|
|
22
|
+
chainSpecific: M[T];
|
|
23
|
+
} : undefined) : never>;
|
|
24
|
+
export {};
|
package/dist/utility.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshiftoss/types",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Common types shared across packages",
|
|
5
5
|
"repository": "https://github.com/shapeshift/lib",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
"type-check": "tsc --project ./tsconfig.json --noEmit"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@shapeshiftoss/hdwallet-core": "^1.
|
|
23
|
+
"@shapeshiftoss/hdwallet-core": "^1.17.0"
|
|
24
24
|
}
|
|
25
25
|
}
|
package/dist/types.assert.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|