xrpl 3.1.0 → 4.0.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/README.md +3 -3
- package/build/xrpl-latest.js +36 -693
- package/build/xrpl-latest.js.map +1 -1
- package/dist/npm/Wallet/defaultFaucets.d.ts +1 -2
- package/dist/npm/Wallet/defaultFaucets.d.ts.map +1 -1
- package/dist/npm/Wallet/defaultFaucets.js +0 -5
- package/dist/npm/Wallet/defaultFaucets.js.map +1 -1
- package/dist/npm/Wallet/fundWallet.d.ts.map +1 -1
- package/dist/npm/Wallet/fundWallet.js +1 -5
- package/dist/npm/Wallet/fundWallet.js.map +1 -1
- package/dist/npm/client/RequestManager.d.ts +5 -4
- package/dist/npm/client/RequestManager.d.ts.map +1 -1
- package/dist/npm/client/RequestManager.js.map +1 -1
- package/dist/npm/client/connection.d.ts +2 -2
- package/dist/npm/client/connection.d.ts.map +1 -1
- package/dist/npm/client/connection.js.map +1 -1
- package/dist/npm/client/index.d.ts +4 -3
- package/dist/npm/client/index.d.ts.map +1 -1
- package/dist/npm/client/index.js +16 -4
- package/dist/npm/client/index.js.map +1 -1
- package/dist/npm/client/partialPayment.d.ts +2 -1
- package/dist/npm/client/partialPayment.d.ts.map +1 -1
- package/dist/npm/client/partialPayment.js +10 -3
- package/dist/npm/client/partialPayment.js.map +1 -1
- package/dist/npm/models/common/index.d.ts +5 -0
- package/dist/npm/models/common/index.d.ts.map +1 -1
- package/dist/npm/models/common/index.js +4 -0
- package/dist/npm/models/common/index.js.map +1 -1
- package/dist/npm/models/ledger/AMM.d.ts +2 -2
- package/dist/npm/models/ledger/AMM.d.ts.map +1 -1
- package/dist/npm/models/ledger/Amendments.d.ts +2 -2
- package/dist/npm/models/ledger/Amendments.d.ts.map +1 -1
- package/dist/npm/models/ledger/BaseLedgerEntry.d.ts +3 -3
- package/dist/npm/models/ledger/BaseLedgerEntry.d.ts.map +1 -1
- package/dist/npm/models/ledger/DirectoryNode.d.ts +2 -2
- package/dist/npm/models/ledger/DirectoryNode.d.ts.map +1 -1
- package/dist/npm/models/ledger/FeeSettings.d.ts +2 -2
- package/dist/npm/models/ledger/FeeSettings.d.ts.map +1 -1
- package/dist/npm/models/ledger/Ledger.d.ts +11 -2
- package/dist/npm/models/ledger/Ledger.d.ts.map +1 -1
- package/dist/npm/models/ledger/LedgerHashes.d.ts +2 -2
- package/dist/npm/models/ledger/LedgerHashes.d.ts.map +1 -1
- package/dist/npm/models/ledger/NegativeUNL.d.ts +2 -2
- package/dist/npm/models/ledger/NegativeUNL.d.ts.map +1 -1
- package/dist/npm/models/ledger/index.d.ts +2 -2
- package/dist/npm/models/ledger/index.d.ts.map +1 -1
- package/dist/npm/models/ledger/index.js.map +1 -1
- package/dist/npm/models/methods/accountInfo.d.ts +17 -4
- package/dist/npm/models/methods/accountInfo.d.ts.map +1 -1
- package/dist/npm/models/methods/accountTx.d.ts +11 -5
- package/dist/npm/models/methods/accountTx.d.ts.map +1 -1
- package/dist/npm/models/methods/feature.d.ts +28 -0
- package/dist/npm/models/methods/feature.d.ts.map +1 -0
- package/dist/npm/models/methods/feature.js +3 -0
- package/dist/npm/models/methods/feature.js.map +1 -0
- package/dist/npm/models/methods/index.d.ts +14 -11
- package/dist/npm/models/methods/index.d.ts.map +1 -1
- package/dist/npm/models/methods/ledger.d.ts +17 -5
- package/dist/npm/models/methods/ledger.d.ts.map +1 -1
- package/dist/npm/models/methods/nftsByIssuer.d.ts +19 -0
- package/dist/npm/models/methods/nftsByIssuer.d.ts.map +1 -0
- package/dist/npm/models/methods/nftsByIssuer.js +3 -0
- package/dist/npm/models/methods/nftsByIssuer.js.map +1 -0
- package/dist/npm/models/methods/submitMultisigned.d.ts +16 -5
- package/dist/npm/models/methods/submitMultisigned.d.ts.map +1 -1
- package/dist/npm/models/methods/tx.d.ts +20 -8
- package/dist/npm/models/methods/tx.d.ts.map +1 -1
- package/dist/npm/snippets/src/claimPayChannel.js +1 -1
- package/dist/npm/snippets/src/claimPayChannel.js.map +1 -1
- package/dist/npm/snippets/src/sendEscrow.js +1 -1
- package/dist/npm/snippets/src/sendEscrow.js.map +1 -1
- package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
- package/dist/npm/src/Wallet/defaultFaucets.d.ts +1 -2
- package/dist/npm/src/Wallet/defaultFaucets.d.ts.map +1 -1
- package/dist/npm/src/Wallet/defaultFaucets.js +0 -5
- package/dist/npm/src/Wallet/defaultFaucets.js.map +1 -1
- package/dist/npm/src/Wallet/fundWallet.d.ts.map +1 -1
- package/dist/npm/src/Wallet/fundWallet.js +1 -5
- package/dist/npm/src/Wallet/fundWallet.js.map +1 -1
- package/dist/npm/src/client/RequestManager.d.ts +5 -4
- package/dist/npm/src/client/RequestManager.d.ts.map +1 -1
- package/dist/npm/src/client/RequestManager.js.map +1 -1
- package/dist/npm/src/client/connection.d.ts +2 -2
- package/dist/npm/src/client/connection.d.ts.map +1 -1
- package/dist/npm/src/client/connection.js.map +1 -1
- package/dist/npm/src/client/index.d.ts +4 -3
- package/dist/npm/src/client/index.d.ts.map +1 -1
- package/dist/npm/src/client/index.js +16 -4
- package/dist/npm/src/client/index.js.map +1 -1
- package/dist/npm/src/client/partialPayment.d.ts +2 -1
- package/dist/npm/src/client/partialPayment.d.ts.map +1 -1
- package/dist/npm/src/client/partialPayment.js +10 -3
- package/dist/npm/src/client/partialPayment.js.map +1 -1
- package/dist/npm/src/models/common/index.d.ts +5 -0
- package/dist/npm/src/models/common/index.d.ts.map +1 -1
- package/dist/npm/src/models/common/index.js +4 -0
- package/dist/npm/src/models/common/index.js.map +1 -1
- package/dist/npm/src/models/ledger/AMM.d.ts +2 -2
- package/dist/npm/src/models/ledger/AMM.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/Amendments.d.ts +2 -2
- package/dist/npm/src/models/ledger/Amendments.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/BaseLedgerEntry.d.ts +3 -3
- package/dist/npm/src/models/ledger/BaseLedgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/DirectoryNode.d.ts +2 -2
- package/dist/npm/src/models/ledger/DirectoryNode.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/FeeSettings.d.ts +2 -2
- package/dist/npm/src/models/ledger/FeeSettings.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/Ledger.d.ts +11 -2
- package/dist/npm/src/models/ledger/Ledger.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/LedgerHashes.d.ts +2 -2
- package/dist/npm/src/models/ledger/LedgerHashes.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/NegativeUNL.d.ts +2 -2
- package/dist/npm/src/models/ledger/NegativeUNL.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/index.d.ts +2 -2
- package/dist/npm/src/models/ledger/index.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/index.js.map +1 -1
- package/dist/npm/src/models/methods/accountInfo.d.ts +17 -4
- package/dist/npm/src/models/methods/accountInfo.d.ts.map +1 -1
- package/dist/npm/src/models/methods/accountTx.d.ts +11 -5
- package/dist/npm/src/models/methods/accountTx.d.ts.map +1 -1
- package/dist/npm/src/models/methods/feature.d.ts +28 -0
- package/dist/npm/src/models/methods/feature.d.ts.map +1 -0
- package/dist/npm/src/models/methods/feature.js +3 -0
- package/dist/npm/src/models/methods/feature.js.map +1 -0
- package/dist/npm/src/models/methods/index.d.ts +14 -11
- package/dist/npm/src/models/methods/index.d.ts.map +1 -1
- package/dist/npm/src/models/methods/ledger.d.ts +17 -5
- package/dist/npm/src/models/methods/ledger.d.ts.map +1 -1
- package/dist/npm/src/models/methods/nftsByIssuer.d.ts +19 -0
- package/dist/npm/src/models/methods/nftsByIssuer.d.ts.map +1 -0
- package/dist/npm/src/models/methods/nftsByIssuer.js +3 -0
- package/dist/npm/src/models/methods/nftsByIssuer.js.map +1 -0
- package/dist/npm/src/models/methods/submitMultisigned.d.ts +16 -5
- package/dist/npm/src/models/methods/submitMultisigned.d.ts.map +1 -1
- package/dist/npm/src/models/methods/tx.d.ts +20 -8
- package/dist/npm/src/models/methods/tx.d.ts.map +1 -1
- package/dist/npm/src/sugar/autofill.d.ts +1 -1
- package/dist/npm/src/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/src/sugar/autofill.js +2 -4
- package/dist/npm/src/sugar/autofill.js.map +1 -1
- package/dist/npm/src/sugar/getFeeXrp.d.ts +1 -1
- package/dist/npm/src/sugar/getFeeXrp.d.ts.map +1 -1
- package/dist/npm/src/sugar/getFeeXrp.js +3 -2
- package/dist/npm/src/sugar/getFeeXrp.js.map +1 -1
- package/dist/npm/src/sugar/submit.d.ts.map +1 -1
- package/dist/npm/src/sugar/submit.js.map +1 -1
- package/dist/npm/src/utils/hashes/hashLedger.d.ts +4 -3
- package/dist/npm/src/utils/hashes/hashLedger.d.ts.map +1 -1
- package/dist/npm/src/utils/hashes/hashLedger.js.map +1 -1
- package/dist/npm/src/utils/index.d.ts +2 -1
- package/dist/npm/src/utils/index.d.ts.map +1 -1
- package/dist/npm/src/utils/index.js.map +1 -1
- package/dist/npm/sugar/autofill.d.ts +1 -1
- package/dist/npm/sugar/autofill.d.ts.map +1 -1
- package/dist/npm/sugar/autofill.js +2 -4
- package/dist/npm/sugar/autofill.js.map +1 -1
- package/dist/npm/sugar/getFeeXrp.d.ts +1 -1
- package/dist/npm/sugar/getFeeXrp.d.ts.map +1 -1
- package/dist/npm/sugar/getFeeXrp.js +3 -2
- package/dist/npm/sugar/getFeeXrp.js.map +1 -1
- package/dist/npm/sugar/submit.d.ts.map +1 -1
- package/dist/npm/sugar/submit.js.map +1 -1
- package/dist/npm/utils/hashes/hashLedger.d.ts +4 -3
- package/dist/npm/utils/hashes/hashLedger.d.ts.map +1 -1
- package/dist/npm/utils/hashes/hashLedger.js.map +1 -1
- package/dist/npm/utils/index.d.ts +2 -1
- package/dist/npm/utils/index.d.ts.map +1 -1
- package/dist/npm/utils/index.js.map +1 -1
- package/package.json +5 -6
- package/src/Wallet/defaultFaucets.ts +0 -6
- package/src/Wallet/fundWallet.ts +0 -1
- package/src/client/RequestManager.ts +17 -12
- package/src/client/connection.ts +7 -5
- package/src/client/index.ts +63 -16
- package/src/client/partialPayment.ts +34 -13
- package/src/models/common/index.ts +8 -0
- package/src/models/ledger/AMM.ts +2 -2
- package/src/models/ledger/Amendments.ts +2 -2
- package/src/models/ledger/BaseLedgerEntry.ts +9 -5
- package/src/models/ledger/DirectoryNode.ts +2 -2
- package/src/models/ledger/FeeSettings.ts +4 -2
- package/src/models/ledger/Ledger.ts +46 -9
- package/src/models/ledger/LedgerHashes.ts +2 -4
- package/src/models/ledger/NegativeUNL.ts +2 -2
- package/src/models/ledger/index.ts +2 -1
- package/src/models/methods/accountInfo.ts +58 -12
- package/src/models/methods/accountTx.ts +49 -8
- package/src/models/methods/feature.ts +68 -0
- package/src/models/methods/index.ts +67 -23
- package/src/models/methods/ledger.ts +41 -5
- package/src/models/methods/nftsByIssuer.ts +68 -0
- package/src/models/methods/submitMultisigned.ts +48 -16
- package/src/models/methods/tx.ts +74 -22
- package/src/sugar/autofill.ts +4 -10
- package/src/sugar/getFeeXrp.ts +6 -3
- package/src/sugar/submit.ts +5 -3
- package/src/utils/hashes/hashLedger.ts +8 -5
- package/src/utils/index.ts +2 -1
package/src/models/methods/tx.ts
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
import {
|
2
|
+
APIVersion,
|
3
|
+
DEFAULT_API_VERSION,
|
4
|
+
RIPPLED_API_V1,
|
5
|
+
RIPPLED_API_V2,
|
6
|
+
} from '../common'
|
1
7
|
import { Transaction, TransactionMetadata } from '../transactions'
|
2
8
|
import { BaseTransaction } from '../transactions/common'
|
3
9
|
|
@@ -41,6 +47,47 @@ export interface TxRequest extends BaseRequest {
|
|
41
47
|
max_ledger?: number
|
42
48
|
}
|
43
49
|
|
50
|
+
/**
|
51
|
+
* Common properties of transaction responses.
|
52
|
+
*
|
53
|
+
* @category Responses
|
54
|
+
*/
|
55
|
+
interface BaseTxResult<
|
56
|
+
Version extends APIVersion = typeof DEFAULT_API_VERSION,
|
57
|
+
T extends BaseTransaction = Transaction,
|
58
|
+
> {
|
59
|
+
/** The SHA-512 hash of the transaction. */
|
60
|
+
hash: string
|
61
|
+
/**
|
62
|
+
* The Concise Transaction Identifier of the transaction (16-byte hex string)
|
63
|
+
*/
|
64
|
+
ctid?: string
|
65
|
+
/** The ledger index of the ledger that includes this transaction. */
|
66
|
+
ledger_index?: number
|
67
|
+
/** Unique hashed string Transaction metadata blob, which describes the results of the transaction.
|
68
|
+
* Can be undefined if a transaction has not been validated yet. This field is omitted if binary
|
69
|
+
* binary format is not requested. */
|
70
|
+
meta_blob?: Version extends typeof RIPPLED_API_V2
|
71
|
+
? TransactionMetadata<T> | string
|
72
|
+
: never
|
73
|
+
/** Transaction metadata, which describes the results of the transaction.
|
74
|
+
* Can be undefined if a transaction has not been validated yet. */
|
75
|
+
meta?: TransactionMetadata<T> | string
|
76
|
+
/**
|
77
|
+
* If true, this data comes from a validated ledger version; if omitted or.
|
78
|
+
* Set to false, this data is not final.
|
79
|
+
*/
|
80
|
+
validated?: boolean
|
81
|
+
/**
|
82
|
+
* The time the transaction was closed, in seconds since the Ripple Epoch.
|
83
|
+
*/
|
84
|
+
close_time_iso?: string
|
85
|
+
/**
|
86
|
+
* This number measures the number of seconds since the "Ripple Epoch" of January 1, 2000 (00:00 UTC)
|
87
|
+
*/
|
88
|
+
date?: number
|
89
|
+
}
|
90
|
+
|
44
91
|
/**
|
45
92
|
* Response expected from a {@link TxRequest}.
|
46
93
|
*
|
@@ -48,28 +95,7 @@ export interface TxRequest extends BaseRequest {
|
|
48
95
|
*/
|
49
96
|
export interface TxResponse<T extends BaseTransaction = Transaction>
|
50
97
|
extends BaseResponse {
|
51
|
-
result: {
|
52
|
-
/** The SHA-512 hash of the transaction. */
|
53
|
-
hash: string
|
54
|
-
/**
|
55
|
-
* The Concise Transaction Identifier of the transaction (16-byte hex string)
|
56
|
-
*/
|
57
|
-
ctid?: string
|
58
|
-
/** The ledger index of the ledger that includes this transaction. */
|
59
|
-
ledger_index?: number
|
60
|
-
/** Transaction metadata, which describes the results of the transaction.
|
61
|
-
* Can be undefined if a transaction has not been validated yet. */
|
62
|
-
meta?: TransactionMetadata<T> | string
|
63
|
-
/**
|
64
|
-
* If true, this data comes from a validated ledger version; if omitted or.
|
65
|
-
* Set to false, this data is not final.
|
66
|
-
*/
|
67
|
-
validated?: boolean
|
68
|
-
/**
|
69
|
-
* This number measures the number of seconds since the "Ripple Epoch" of January 1, 2000 (00:00 UTC)
|
70
|
-
*/
|
71
|
-
date?: number
|
72
|
-
} & T
|
98
|
+
result: BaseTxResult<typeof RIPPLED_API_V2, T> & { tx_json: T }
|
73
99
|
/**
|
74
100
|
* If true, the server was able to search all of the specified ledger
|
75
101
|
* versions, and the transaction was in none of them. If false, the server did
|
@@ -78,3 +104,29 @@ export interface TxResponse<T extends BaseTransaction = Transaction>
|
|
78
104
|
*/
|
79
105
|
searched_all?: boolean
|
80
106
|
}
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Response expected from a {@link TxRequest} using API version 1.
|
110
|
+
*
|
111
|
+
* @category ResponsesV1
|
112
|
+
*/
|
113
|
+
export interface TxV1Response<T extends BaseTransaction = Transaction>
|
114
|
+
extends BaseResponse {
|
115
|
+
result: BaseTxResult<typeof RIPPLED_API_V1, T> & T
|
116
|
+
/**
|
117
|
+
* If true, the server was able to search all of the specified ledger
|
118
|
+
* versions, and the transaction was in none of them. If false, the server did
|
119
|
+
* not have all of the specified ledger versions available, so it is not sure.
|
120
|
+
* If one of them might contain the transaction.
|
121
|
+
*/
|
122
|
+
searched_all?: boolean
|
123
|
+
}
|
124
|
+
|
125
|
+
/**
|
126
|
+
* Type to map between the API version and the response type.
|
127
|
+
*
|
128
|
+
* @category Responses
|
129
|
+
*/
|
130
|
+
export type TxVersionResponseMap<
|
131
|
+
Version extends APIVersion = typeof DEFAULT_API_VERSION,
|
132
|
+
> = Version extends typeof RIPPLED_API_V1 ? TxV1Response : TxResponse
|
package/src/sugar/autofill.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import BigNumber from 'bignumber.js'
|
2
2
|
import { xAddressToClassicAddress, isValidXAddress } from 'ripple-address-codec'
|
3
3
|
|
4
|
-
import type
|
4
|
+
import { type Client } from '..'
|
5
5
|
import { ValidationError, XrplError } from '../errors'
|
6
6
|
import { AccountInfoRequest, AccountObjectsRequest } from '../models/methods'
|
7
7
|
import { Transaction } from '../models/transactions'
|
@@ -17,7 +17,6 @@ const LEDGER_OFFSET = 20
|
|
17
17
|
// Mainnet and testnet are exceptions. More context: https://github.com/XRPLF/rippled/pull/4370
|
18
18
|
const RESTRICTED_NETWORKS = 1024
|
19
19
|
const REQUIRED_NETWORKID_VERSION = '1.11.0'
|
20
|
-
const HOOKS_TESTNET_ID = 21338
|
21
20
|
|
22
21
|
/**
|
23
22
|
* Determines whether the source rippled version is not later than the target rippled version.
|
@@ -87,8 +86,7 @@ function isNotLaterRippledVersion(source: string, target: string): boolean {
|
|
87
86
|
|
88
87
|
/**
|
89
88
|
* Determine if the transaction required a networkID to be valid.
|
90
|
-
* Transaction needs networkID if later than restricted ID and
|
91
|
-
* or build version is >= 1.11.0
|
89
|
+
* Transaction needs networkID if later than restricted ID and build version is >= 1.11.0
|
92
90
|
*
|
93
91
|
* @param client -- The connected client.
|
94
92
|
* @returns True if required networkID, false otherwise.
|
@@ -99,12 +97,8 @@ export function txNeedsNetworkID(client: Client): boolean {
|
|
99
97
|
client.networkID > RESTRICTED_NETWORKS
|
100
98
|
) {
|
101
99
|
if (
|
102
|
-
|
103
|
-
|
104
|
-
REQUIRED_NETWORKID_VERSION,
|
105
|
-
client.buildVersion,
|
106
|
-
)) ||
|
107
|
-
client.networkID === HOOKS_TESTNET_ID
|
100
|
+
client.buildVersion &&
|
101
|
+
isNotLaterRippledVersion(REQUIRED_NETWORKID_VERSION, client.buildVersion)
|
108
102
|
) {
|
109
103
|
return true
|
110
104
|
}
|
package/src/sugar/getFeeXrp.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import BigNumber from 'bignumber.js'
|
2
2
|
|
3
|
-
import type
|
3
|
+
import { type Client } from '..'
|
4
4
|
import { XrplError } from '../errors'
|
5
5
|
|
6
6
|
const NUM_DECIMAL_PLACES = 6
|
@@ -20,8 +20,11 @@ export default async function getFeeXrp(
|
|
20
20
|
): Promise<string> {
|
21
21
|
const feeCushion = cushion ?? client.feeCushion
|
22
22
|
|
23
|
-
const serverInfo = (
|
24
|
-
.
|
23
|
+
const serverInfo = (
|
24
|
+
await client.request({
|
25
|
+
command: 'server_info',
|
26
|
+
})
|
27
|
+
).result.info
|
25
28
|
|
26
29
|
const baseFee = serverInfo.validated_ledger?.base_fee_xrp
|
27
30
|
|
package/src/sugar/submit.ts
CHANGED
@@ -10,7 +10,7 @@ import type {
|
|
10
10
|
} from '..'
|
11
11
|
import { ValidationError, XrplError } from '../errors'
|
12
12
|
import { Signer } from '../models/common'
|
13
|
-
import {
|
13
|
+
import { TxResponse } from '../models/methods'
|
14
14
|
import { BaseTransaction } from '../models/transactions/common'
|
15
15
|
|
16
16
|
/** Approximate time for a ledger to close, in milliseconds */
|
@@ -129,7 +129,7 @@ export async function waitForFinalTransactionOutcome<
|
|
129
129
|
}
|
130
130
|
|
131
131
|
const txResponse = await client
|
132
|
-
.request
|
132
|
+
.request({
|
133
133
|
command: 'tx',
|
134
134
|
transaction: txHash,
|
135
135
|
})
|
@@ -153,7 +153,9 @@ export async function waitForFinalTransactionOutcome<
|
|
153
153
|
})
|
154
154
|
|
155
155
|
if (txResponse.result.validated) {
|
156
|
-
|
156
|
+
// TODO: resolve the type assertion below
|
157
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we know that txResponse is of type TxResponse
|
158
|
+
return txResponse as TxResponse<T>
|
157
159
|
}
|
158
160
|
|
159
161
|
return waitForFinalTransactionOutcome<T>(
|
@@ -8,8 +8,9 @@ import BigNumber from 'bignumber.js'
|
|
8
8
|
import { decode, encode } from 'ripple-binary-codec'
|
9
9
|
|
10
10
|
import { ValidationError, XrplError } from '../../errors'
|
11
|
-
import
|
11
|
+
import { APIVersion } from '../../models'
|
12
12
|
import { LedgerEntry } from '../../models/ledger'
|
13
|
+
import { LedgerVersionMap } from '../../models/ledger/Ledger'
|
13
14
|
import { Transaction, TransactionMetadata } from '../../models/transactions'
|
14
15
|
|
15
16
|
import HashPrefix from './HashPrefix'
|
@@ -99,7 +100,9 @@ export function hashSignedTx(tx: Transaction | string): string {
|
|
99
100
|
* @returns The hash of the ledger.
|
100
101
|
* @category Utilities
|
101
102
|
*/
|
102
|
-
export function hashLedgerHeader(
|
103
|
+
export function hashLedgerHeader(
|
104
|
+
ledgerHeader: LedgerVersionMap<APIVersion>,
|
105
|
+
): string {
|
103
106
|
const prefix = HashPrefix.LEDGER.toString(HEX).toUpperCase()
|
104
107
|
|
105
108
|
const ledger =
|
@@ -158,7 +161,7 @@ export function hashStateTree(entries: LedgerEntry[]): string {
|
|
158
161
|
}
|
159
162
|
|
160
163
|
function computeTransactionHash(
|
161
|
-
ledger:
|
164
|
+
ledger: LedgerVersionMap<APIVersion>,
|
162
165
|
options: HashLedgerHeaderOptions,
|
163
166
|
): string {
|
164
167
|
const { transaction_hash } = ledger
|
@@ -188,7 +191,7 @@ function computeTransactionHash(
|
|
188
191
|
}
|
189
192
|
|
190
193
|
function computeStateHash(
|
191
|
-
ledger:
|
194
|
+
ledger: LedgerVersionMap<APIVersion>,
|
192
195
|
options: HashLedgerHeaderOptions,
|
193
196
|
): string {
|
194
197
|
const { account_hash } = ledger
|
@@ -222,7 +225,7 @@ function computeStateHash(
|
|
222
225
|
* @category Utilities
|
223
226
|
*/
|
224
227
|
function hashLedger(
|
225
|
-
ledger:
|
228
|
+
ledger: LedgerVersionMap<APIVersion>,
|
226
229
|
options: {
|
227
230
|
computeTreeHashes?: boolean
|
228
231
|
} = {},
|
package/src/utils/index.ts
CHANGED
@@ -23,6 +23,7 @@ import {
|
|
23
23
|
} from 'ripple-binary-codec'
|
24
24
|
import { verify as verifyKeypairSignature } from 'ripple-keypairs'
|
25
25
|
|
26
|
+
import type { APIVersion } from '../models'
|
26
27
|
import { LedgerEntry } from '../models/ledger'
|
27
28
|
import { Response } from '../models/methods'
|
28
29
|
import { PaymentChannelClaim } from '../models/transactions/paymentChannelClaim'
|
@@ -157,7 +158,7 @@ function isValidAddress(address: string): boolean {
|
|
157
158
|
* @returns Whether the response has more pages of data.
|
158
159
|
* @category Utilities
|
159
160
|
*/
|
160
|
-
function hasNextPage(response: Response): boolean {
|
161
|
+
function hasNextPage(response: Response<APIVersion>): boolean {
|
161
162
|
// eslint-disable-next-line @typescript-eslint/dot-notation -- only checking if it exists
|
162
163
|
return Boolean(response.result['marker'])
|
163
164
|
}
|