@xchainjs/xchain-doge 0.5.8 → 0.5.10
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/README.md +50 -0
- package/lib/client.d.ts +25 -74
- package/lib/const.d.ts +17 -0
- package/lib/index.d.ts +1 -2
- package/lib/index.esm.js +58743 -63165
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +58749 -63172
- package/lib/index.js.map +1 -1
- package/lib/types/common.d.ts +0 -6
- package/lib/types/ledger.d.ts +1 -2
- package/lib/utils.d.ts +1 -49
- package/package.json +5 -3
- package/lib/ledger.d.ts +0 -8
- package/lib/node-api.d.ts +0 -17
- package/lib/sochain-api.d.ts +0 -67
package/README.md
CHANGED
|
@@ -39,3 +39,53 @@ This package uses the following service providers:
|
|
|
39
39
|
Sochain API rate limits: https://sochain.com/api#rate-limits (300 requests/minute)
|
|
40
40
|
|
|
41
41
|
BlockCypher API rate limits: https://api.blockcypher.com/v1/doge/main (5 requests/second)
|
|
42
|
+
|
|
43
|
+
### UtxoOnlineDataProviders
|
|
44
|
+
|
|
45
|
+
## default providers
|
|
46
|
+
|
|
47
|
+
Creating a no-arg DOGE Client will default to the following settings:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
const defaultDogeParams: UtxoClientParams = {
|
|
51
|
+
network: Network.Mainnet,
|
|
52
|
+
phrase: '',
|
|
53
|
+
explorerProviders: blockstreamExplorerProviders,
|
|
54
|
+
dataProviders: [blockcypherDataProviders],
|
|
55
|
+
rootDerivationPaths: {
|
|
56
|
+
[Network.Mainnet]: `m/44'/3'/0'/0/`,
|
|
57
|
+
[Network.Stagenet]: `m/44'/3'/0'/0/`,
|
|
58
|
+
[Network.Testnet]: `m/44'/1'/0'/0/`,
|
|
59
|
+
},
|
|
60
|
+
feeBounds: {
|
|
61
|
+
lower: LOWER_FEE_BOUND,
|
|
62
|
+
upper: UPPER_FEE_BOUND,
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Note: BlockCypher is the default online data provider (to fetch realtime utxos, balances, etc)
|
|
68
|
+
|
|
69
|
+
## Overriding providers
|
|
70
|
+
|
|
71
|
+
You can specify own array of providers, whoch will be executed in array-order, to provide automated failover to the subsequent providers if calls to the first providers fail
|
|
72
|
+
|
|
73
|
+
### example sochain v3, blockcypher backup
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { Client, defaultDogeParams, AssetDOGE, SochainDataProviders, BlockcypherDataProviders } from '@xchainjs/xchain-doge'
|
|
77
|
+
import { SochainNetwork, SochainProvider } from '@xchainjs/xchain-utxo-providers'
|
|
78
|
+
import { Network, UtxoClientParams } from '@xchainjs/xchain-client'
|
|
79
|
+
|
|
80
|
+
// override with your API key
|
|
81
|
+
SochainDataProviders[Network.Mainnet].apiKey = 'YOU_SOCHAIN_API_KEY'
|
|
82
|
+
|
|
83
|
+
//overridde the default init params with your onfig
|
|
84
|
+
const initParams: UtxoClientParams = {
|
|
85
|
+
...defaultDogeParams,
|
|
86
|
+
dataProviders: [SochainDataProviders, BlockcypherDataProviders]// use sochain first and blockcypher as fallback
|
|
87
|
+
phrase: process.env.YOURPHRASE,
|
|
88
|
+
}
|
|
89
|
+
const DOGEClient = new Client(sochainParams)
|
|
90
|
+
|
|
91
|
+
```
|
package/lib/client.d.ts
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fee, FeeRate, TxHash, TxParams, UTXO, UTXOClient, UtxoClientParams } from '@xchainjs/xchain-client';
|
|
2
2
|
import { Address } from '@xchainjs/xchain-util';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
sochainApiKey: string;
|
|
7
|
-
};
|
|
3
|
+
import * as Dogecoin from 'bitcoinjs-lib';
|
|
4
|
+
import { LedgerTxInfo, LedgerTxInfoParams } from './types/ledger';
|
|
5
|
+
export declare const defaultDogeParams: UtxoClientParams;
|
|
8
6
|
/**
|
|
9
7
|
* Custom Dogecoin client
|
|
10
8
|
*/
|
|
11
9
|
declare class Client extends UTXOClient {
|
|
12
|
-
private sochainUrl;
|
|
13
|
-
private blockcypherUrl;
|
|
14
|
-
private sochainApiKey;
|
|
15
10
|
/**
|
|
16
11
|
* Constructor
|
|
17
12
|
* Client is initialised with network type
|
|
@@ -19,41 +14,7 @@ declare class Client extends UTXOClient {
|
|
|
19
14
|
*
|
|
20
15
|
* @param {DogecoinClientParams} params
|
|
21
16
|
*/
|
|
22
|
-
constructor(
|
|
23
|
-
/**
|
|
24
|
-
* Set/Update the sochain url.
|
|
25
|
-
*
|
|
26
|
-
* @param {string} url The new sochain url.
|
|
27
|
-
* @returns {void}
|
|
28
|
-
*/
|
|
29
|
-
setSochainUrl(url: string): void;
|
|
30
|
-
/**
|
|
31
|
-
* Set/Update the blockcypher url.
|
|
32
|
-
*
|
|
33
|
-
* @param {string} url The new blockcypher url.
|
|
34
|
-
* @returns {void}
|
|
35
|
-
*/
|
|
36
|
-
setBlockcypherUrl(url: string): void;
|
|
37
|
-
/**
|
|
38
|
-
* Get the explorer url.
|
|
39
|
-
*
|
|
40
|
-
* @returns {string} The explorer url based on the network.
|
|
41
|
-
*/
|
|
42
|
-
getExplorerUrl(): string;
|
|
43
|
-
/**
|
|
44
|
-
* Get the explorer url for the given address.
|
|
45
|
-
*
|
|
46
|
-
* @param {Address} address
|
|
47
|
-
* @returns {string} The explorer url for the given address based on the network.
|
|
48
|
-
*/
|
|
49
|
-
getExplorerAddressUrl(address: Address): string;
|
|
50
|
-
/**
|
|
51
|
-
* Get the explorer url for the given transaction id.
|
|
52
|
-
*
|
|
53
|
-
* @param {string} txID The transaction id
|
|
54
|
-
* @returns {string} The explorer url for the given transaction id based on the network.
|
|
55
|
-
*/
|
|
56
|
-
getExplorerTxUrl(txID: string): string;
|
|
17
|
+
constructor(params?: UtxoClientParams);
|
|
57
18
|
/**
|
|
58
19
|
* Get the current address.
|
|
59
20
|
*
|
|
@@ -85,36 +46,6 @@ declare class Client extends UTXOClient {
|
|
|
85
46
|
* @returns {boolean} `true` or `false`
|
|
86
47
|
*/
|
|
87
48
|
validateAddress(address: string): boolean;
|
|
88
|
-
/**
|
|
89
|
-
* Get the Doge balance of a given address.
|
|
90
|
-
*
|
|
91
|
-
* @param {Address} address By default, it will return the balance of the current wallet. (optional)
|
|
92
|
-
* @returns {Balance[]} The Doge balance of the address.
|
|
93
|
-
*/
|
|
94
|
-
getBalance(address: Address): Promise<Balance[]>;
|
|
95
|
-
/**
|
|
96
|
-
* helper function tto limit adding to an array
|
|
97
|
-
*
|
|
98
|
-
* @param arr array to be added to
|
|
99
|
-
* @param toAdd elements to add
|
|
100
|
-
* @param limit do not add more than this limit
|
|
101
|
-
*/
|
|
102
|
-
private addArrayUpToLimit;
|
|
103
|
-
/**
|
|
104
|
-
* Get transaction history of a given address with pagination options.
|
|
105
|
-
* By default it will return the transaction history of the current wallet.
|
|
106
|
-
*
|
|
107
|
-
* @param {TxHistoryParams} params The options to get transaction history. (optional)
|
|
108
|
-
* @returns {TxsPage} The transaction history.
|
|
109
|
-
*/
|
|
110
|
-
getTransactions(params?: TxHistoryParams): Promise<TxsPage>;
|
|
111
|
-
/**
|
|
112
|
-
* Get the transaction details of a given transaction id.
|
|
113
|
-
*
|
|
114
|
-
* @param {string} txId The transaction id.
|
|
115
|
-
* @returns {Tx} The transaction details of the given transaction id.
|
|
116
|
-
*/
|
|
117
|
-
getTransactionData(txId: string): Promise<Tx>;
|
|
118
49
|
protected getSuggestedFeeRate(): Promise<FeeRate>;
|
|
119
50
|
protected calcFee(feeRate: FeeRate, memo?: string): Promise<Fee>;
|
|
120
51
|
/**
|
|
@@ -126,5 +57,25 @@ declare class Client extends UTXOClient {
|
|
|
126
57
|
transfer(params: TxParams & {
|
|
127
58
|
feeRate?: FeeRate;
|
|
128
59
|
}): Promise<TxHash>;
|
|
60
|
+
/**
|
|
61
|
+
* Build transcation.
|
|
62
|
+
*
|
|
63
|
+
* @param {BuildParams} params The transaction build options.
|
|
64
|
+
* @returns {Transaction}
|
|
65
|
+
*/
|
|
66
|
+
buildTx: ({ amount, recipient, memo, feeRate, sender, }: TxParams & {
|
|
67
|
+
feeRate: FeeRate;
|
|
68
|
+
sender: Address;
|
|
69
|
+
}) => Promise<{
|
|
70
|
+
psbt: Dogecoin.Psbt;
|
|
71
|
+
utxos: UTXO[];
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Create transaction info.
|
|
75
|
+
*
|
|
76
|
+
* @param {LedgerTxInfoParams} params The transaction build options.
|
|
77
|
+
* @returns {LedgerTxInfo} The transaction info used for ledger sign.
|
|
78
|
+
*/
|
|
79
|
+
createTxInfo(params: LedgerTxInfoParams): Promise<LedgerTxInfo>;
|
|
129
80
|
}
|
|
130
81
|
export { Client };
|
package/lib/const.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { ExplorerProvider } from '@xchainjs/xchain-client';
|
|
1
2
|
import { Asset } from '@xchainjs/xchain-util';
|
|
3
|
+
import { BlockcypherProvider, SochainProvider } from '@xchainjs/xchain-utxo-providers';
|
|
2
4
|
/**
|
|
3
5
|
* Minimum transaction fee
|
|
4
6
|
* 100000 satoshi/kB (similar to current `minrelaytxfee`)
|
|
@@ -20,3 +22,18 @@ export declare const DOGEChain: "DOGE";
|
|
|
20
22
|
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
|
|
21
23
|
*/
|
|
22
24
|
export declare const AssetDOGE: Asset;
|
|
25
|
+
export declare const blockstreamExplorerProviders: {
|
|
26
|
+
testnet: ExplorerProvider;
|
|
27
|
+
stagenet: ExplorerProvider;
|
|
28
|
+
mainnet: ExplorerProvider;
|
|
29
|
+
};
|
|
30
|
+
export declare const sochainDataProviders: {
|
|
31
|
+
testnet: SochainProvider;
|
|
32
|
+
stagenet: SochainProvider;
|
|
33
|
+
mainnet: SochainProvider;
|
|
34
|
+
};
|
|
35
|
+
export declare const blockcypherDataProviders: {
|
|
36
|
+
testnet: undefined;
|
|
37
|
+
stagenet: BlockcypherProvider;
|
|
38
|
+
mainnet: BlockcypherProvider;
|
|
39
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './types';
|
|
2
2
|
export * from './client';
|
|
3
3
|
export * from './const';
|
|
4
|
-
export {
|
|
4
|
+
export { getDefaultFees, getDefaultFeesWithRates, validateAddress, calcFee, getPrefix } from './utils';
|
|
5
5
|
export { getSendTxUrl } from './blockcypher-api';
|
|
6
|
-
export { createTxInfo } from './ledger';
|