@xchainjs/xchain-doge 0.7.9 → 0.7.11
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/lib/blockcypher-api.d.ts +8 -0
- package/lib/client.d.ts +47 -32
- package/lib/const.d.ts +18 -8
- package/lib/index.d.ts +17 -0
- package/lib/index.esm.js +163 -85
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +163 -85
- package/lib/index.js.map +1 -1
- package/lib/utils.d.ts +24 -14
- package/package.json +9 -9
package/lib/blockcypher-api.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { Network } from '@xchainjs/xchain-client';
|
|
2
|
+
/**
|
|
3
|
+
* Function to get the URL for sending a transaction based on the network and Blockcypher URL.
|
|
4
|
+
* Throws an error if the network is 'testnet' since the testnet URL is not available for Blockcypher.
|
|
5
|
+
* @param {object} params Object containing the Blockcypher URL and network type.
|
|
6
|
+
* @param {string} params.blockcypherUrl The Blockcypher URL.
|
|
7
|
+
* @param {Network} params.network The network type (Mainnet, Testnet, or Stagenet).
|
|
8
|
+
* @returns {string} The URL for sending a transaction.
|
|
9
|
+
*/
|
|
2
10
|
export declare const getSendTxUrl: ({ blockcypherUrl, network }: {
|
|
3
11
|
blockcypherUrl: string;
|
|
4
12
|
network: Network;
|
package/lib/client.d.ts
CHANGED
|
@@ -4,29 +4,39 @@ import { Address } from '@xchainjs/xchain-util';
|
|
|
4
4
|
import { Client as UTXOClient, UTXO, UtxoClientParams } from '@xchainjs/xchain-utxo';
|
|
5
5
|
import * as Dogecoin from 'bitcoinjs-lib';
|
|
6
6
|
import { LedgerTxInfo, LedgerTxInfoParams } from './types/ledger';
|
|
7
|
+
/**
|
|
8
|
+
* Default parameters for Dogecoin UTXO client.
|
|
9
|
+
* Contains default values for network, phrase, explorer providers, data providers, root derivation paths, and fee bounds.
|
|
10
|
+
*/
|
|
7
11
|
export declare const defaultDogeParams: UtxoClientParams;
|
|
8
12
|
/**
|
|
9
|
-
* Custom Dogecoin client
|
|
13
|
+
* Custom Dogecoin client extending UTXOClient.
|
|
14
|
+
* Implements methods for Dogecoin-specific functionality.
|
|
10
15
|
*/
|
|
11
16
|
declare class Client extends UTXOClient {
|
|
12
17
|
/**
|
|
13
|
-
* Constructor
|
|
14
|
-
*
|
|
15
|
-
* Pass strict null as nodeAuth to disable auth for node json rpc
|
|
18
|
+
* Constructor for initializing the Dogecoin client.
|
|
19
|
+
* Initializes the client with the provided parameters.
|
|
16
20
|
*
|
|
17
|
-
* @param {DogecoinClientParams} params
|
|
21
|
+
* @param {DogecoinClientParams} params Parameters for initializing the Dogecoin client.
|
|
18
22
|
*/
|
|
19
23
|
constructor(params?: UtxoClientParams);
|
|
20
24
|
/**
|
|
21
|
-
*
|
|
25
|
+
* Get the Dogecoin address.
|
|
26
|
+
*
|
|
27
|
+
* Generates a Dogecoin address using the provided phrase and index.
|
|
28
|
+
* @param {number} index The index of the address to retrieve. Default is 0.
|
|
29
|
+
* @returns {Address} The Dogecoin address.
|
|
30
|
+
* @throws {"index must be greater than zero"} Thrown if the index is less than zero.
|
|
31
|
+
* @throws {"Phrase must be provided"} Thrown if the phrase is not provided.
|
|
32
|
+
* @throws {"Address not defined"} Thrown if failed to create the address from the phrase.
|
|
22
33
|
*/
|
|
23
34
|
getAddress(index?: number): Address;
|
|
24
35
|
/**
|
|
25
36
|
* Get the current address.
|
|
26
|
-
*
|
|
37
|
+
* Asynchronous version of getAddress method.
|
|
27
38
|
* Generates a network-specific key-pair by first converting the buffer to a Wallet-Import-Format (WIF)
|
|
28
39
|
* The address is then decoded into type P2WPKH and returned.
|
|
29
|
-
*
|
|
30
40
|
* @returns {Address} The current address.
|
|
31
41
|
*
|
|
32
42
|
* @throws {"Phrase must be provided"} Thrown if phrase has not been set before.
|
|
@@ -34,8 +44,9 @@ declare class Client extends UTXOClient {
|
|
|
34
44
|
*/
|
|
35
45
|
getAddressAsync(index?: number): Promise<string>;
|
|
36
46
|
/**
|
|
47
|
+
* Get Dogecoin asset information.
|
|
37
48
|
*
|
|
38
|
-
* @returns
|
|
49
|
+
* @returns {AssetInfo} Dogecoin asset information.
|
|
39
50
|
*/
|
|
40
51
|
getAssetInfo(): AssetInfo;
|
|
41
52
|
/**
|
|
@@ -53,25 +64,27 @@ declare class Client extends UTXOClient {
|
|
|
53
64
|
/**
|
|
54
65
|
* Validate the given address.
|
|
55
66
|
*
|
|
56
|
-
* @param {Address} address
|
|
57
|
-
* @returns {boolean} `true`
|
|
67
|
+
* @param {Address} address The Dogecoin address to validate.
|
|
68
|
+
* @returns {boolean} `true` if the address is valid, otherwise `false`.
|
|
58
69
|
*/
|
|
59
70
|
validateAddress(address: string): boolean;
|
|
60
71
|
/**
|
|
61
|
-
*
|
|
72
|
+
* Asynchronously transfers Dogecoin.
|
|
62
73
|
*
|
|
63
|
-
*
|
|
64
|
-
* @
|
|
74
|
+
* Builds, signs, and broadcasts a Dogecoin transaction with the specified parameters.
|
|
75
|
+
* @param {TxParams & { feeRate?: FeeRate }} params The transfer parameters including transaction details and optional fee rate.
|
|
76
|
+
* @returns {TxHash} A promise that resolves to the transaction hash once the transfer is completed.
|
|
65
77
|
*/
|
|
66
78
|
transfer(params: TxParams & {
|
|
67
79
|
feeRate?: FeeRate;
|
|
68
80
|
}): Promise<TxHash>;
|
|
69
81
|
/**
|
|
70
|
-
*
|
|
82
|
+
* Builds a Dogecoin transaction (PSBT).
|
|
71
83
|
*
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
74
|
-
* @
|
|
84
|
+
* Builds a Partially Signed Bitcoin Transaction (PSBT) with the specified parameters.
|
|
85
|
+
* @param {BuildParams} params The transaction build options including sender, recipient, amount, memo, and fee rate.
|
|
86
|
+
* @returns {Transaction} A promise that resolves to the built PSBT and the unspent transaction outputs (UTXOs) used in the transaction.
|
|
87
|
+
* @deprecated This method is deprecated. Use the `transfer` method instead.
|
|
75
88
|
*/
|
|
76
89
|
buildTx: ({ amount, recipient, memo, feeRate, sender, }: TxParams & {
|
|
77
90
|
feeRate: FeeRate;
|
|
@@ -81,18 +94,20 @@ declare class Client extends UTXOClient {
|
|
|
81
94
|
utxos: UTXO[];
|
|
82
95
|
}>;
|
|
83
96
|
/**
|
|
84
|
-
*
|
|
97
|
+
* Asynchronously creates transaction information for ledger sign.
|
|
98
|
+
*
|
|
99
|
+
* Builds a transaction (PSBT) and prepares necessary information for ledger signing.
|
|
85
100
|
*
|
|
86
|
-
* @param {LedgerTxInfoParams} params The transaction
|
|
87
|
-
* @returns {LedgerTxInfo}
|
|
88
|
-
* @deprecated
|
|
101
|
+
* @param {LedgerTxInfoParams} params The parameters for creating transaction information.
|
|
102
|
+
* @returns {LedgerTxInfo} A promise that resolves to the transaction information used for ledger sign.
|
|
89
103
|
*/
|
|
90
104
|
createTxInfo(params: LedgerTxInfoParams): Promise<LedgerTxInfo>;
|
|
91
105
|
/**
|
|
92
|
-
*
|
|
106
|
+
* Asynchronously prepares a transaction for transfer.
|
|
93
107
|
*
|
|
94
|
-
*
|
|
95
|
-
* @
|
|
108
|
+
* Builds a transaction (PSBT) with the specified transfer options.
|
|
109
|
+
* @param {TxParams & { sender: Address; feeRate: FeeRate; spendPendingUTXO?: boolean }} params The transfer options including sender address, fee rate, and optional flag for spending pending UTXOs.
|
|
110
|
+
* @returns {Promise<PreparedTx>} A promise that resolves to the raw unsigned transaction (PSBT).
|
|
96
111
|
*/
|
|
97
112
|
prepareTx({ sender, memo, amount, recipient, feeRate, }: TxParams & {
|
|
98
113
|
sender: Address;
|
|
@@ -100,19 +115,19 @@ declare class Client extends UTXOClient {
|
|
|
100
115
|
spendPendingUTXO?: boolean;
|
|
101
116
|
}): Promise<PreparedTx>;
|
|
102
117
|
/**
|
|
103
|
-
*
|
|
118
|
+
* Compiles the memo into a buffer for inclusion in a Dogecoin transaction.
|
|
104
119
|
*
|
|
105
120
|
* @param {string} memo The memo to be compiled.
|
|
106
|
-
* @returns {Buffer} The compiled memo.
|
|
121
|
+
* @returns {Buffer} The compiled memo as a buffer.
|
|
107
122
|
*/
|
|
108
123
|
protected compileMemo(memo: string): Buffer;
|
|
109
124
|
/**
|
|
110
|
-
*
|
|
125
|
+
* Calculates the transaction fee based on the provided UTXOs, fee rate, and optional data.
|
|
111
126
|
*
|
|
112
|
-
* @param {UTXO[]} inputs The UTXOs.
|
|
113
|
-
* @param {FeeRate} feeRate The fee rate.
|
|
114
|
-
* @param {Buffer} data The compiled memo (
|
|
115
|
-
* @returns {number} The fee
|
|
127
|
+
* @param {UTXO[]} inputs The unspent transaction outputs (UTXOs) used as inputs.
|
|
128
|
+
* @param {FeeRate} feeRate The fee rate for the transaction.
|
|
129
|
+
* @param {Buffer | null} data The compiled memo (optional).
|
|
130
|
+
* @returns {number} The calculated transaction fee.
|
|
116
131
|
*/
|
|
117
132
|
protected getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data?: Buffer | null): number;
|
|
118
133
|
}
|
package/lib/const.d.ts
CHANGED
|
@@ -2,24 +2,34 @@ import { ExplorerProvider } from '@xchainjs/xchain-client';
|
|
|
2
2
|
import { Asset } from '@xchainjs/xchain-util';
|
|
3
3
|
import { BlockcypherProvider, SochainProvider, UtxoOnlineDataProviders } from '@xchainjs/xchain-utxo-providers';
|
|
4
4
|
/**
|
|
5
|
-
* Minimum transaction fee
|
|
6
|
-
* 100000 satoshi/kB
|
|
5
|
+
* Minimum transaction fee for Dogecoin transactions.
|
|
6
|
+
* Defined as 100000 satoshi/kB.
|
|
7
7
|
* @see https://github.com/dogecoin/dogecoin/blob/master/src/validation.h#L58
|
|
8
8
|
*/
|
|
9
9
|
export declare const MIN_TX_FEE = 100000;
|
|
10
|
+
/**
|
|
11
|
+
* Decimal places for Dogecoin.
|
|
12
|
+
*/
|
|
10
13
|
export declare const DOGE_DECIMAL = 8;
|
|
14
|
+
/**
|
|
15
|
+
* Lower fee bound for Dogecoin transactions.
|
|
16
|
+
* Referenced from Dogecoin fee recommendation documentation.
|
|
17
|
+
* @see https://github.com/dogecoin/dogecoin/blob/master/doc/fee-recommendation.md
|
|
18
|
+
*/
|
|
11
19
|
export declare const LOWER_FEE_BOUND = 100;
|
|
20
|
+
/**
|
|
21
|
+
* Upper fee bound for Dogecoin transactions.
|
|
22
|
+
* Referenced from Dogecoin fee recommendation documentation.
|
|
23
|
+
* @see https://github.com/dogecoin/dogecoin/blob/master/doc/fee-recommendation.md
|
|
24
|
+
*/
|
|
12
25
|
export declare const UPPER_FEE_BOUND = 20000000;
|
|
13
26
|
/**
|
|
14
|
-
* Chain identifier for Dogecoin
|
|
15
|
-
*
|
|
27
|
+
* Chain identifier for Dogecoin.
|
|
16
28
|
*/
|
|
17
29
|
export declare const DOGEChain: "DOGE";
|
|
18
30
|
/**
|
|
19
|
-
* Base
|
|
20
|
-
*
|
|
21
|
-
* Based on definition in Thorchain `common`
|
|
22
|
-
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24
|
|
31
|
+
* Base asset object for Dogecoin.
|
|
32
|
+
* Represents the Dogecoin asset in various contexts.
|
|
23
33
|
*/
|
|
24
34
|
export declare const AssetDOGE: Asset;
|
|
25
35
|
export declare const blockstreamExplorerProviders: {
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Export all types defined in the 'types.ts' file.
|
|
3
|
+
*/
|
|
1
4
|
export * from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Export the Dogecoin client implementation defined in the 'client.ts' file.
|
|
7
|
+
*/
|
|
2
8
|
export * from './client';
|
|
9
|
+
/**
|
|
10
|
+
* Export all constants defined in the 'const.ts' file.
|
|
11
|
+
*/
|
|
3
12
|
export * from './const';
|
|
13
|
+
/**
|
|
14
|
+
* Export utility functions for validating Dogecoin addresses and getting address prefixes
|
|
15
|
+
* from the 'utils.ts' file.
|
|
16
|
+
*/
|
|
4
17
|
export { validateAddress, getPrefix } from './utils';
|
|
18
|
+
/**
|
|
19
|
+
* Export a function for getting the transaction send URL from the Blockcypher API
|
|
20
|
+
* from the 'blockcypher-api.ts' file.
|
|
21
|
+
*/
|
|
5
22
|
export { getSendTxUrl } from './blockcypher-api';
|