11import { quality , binary , HashPrefix } from './coretypes'
22import { decodeLedgerData } from './ledger-hashes'
3- import { ClaimObject } from './binary'
3+ import { ClaimObject , BatchObject } from './binary'
44import { JsonObject } from './types/serialized-type'
55import {
66 XrplDefinitionsBase ,
@@ -15,6 +15,7 @@ const {
1515 signingData,
1616 signingClaimData,
1717 multiSigningData,
18+ signingBatchData,
1819 binaryToJSON,
1920 serializeObject,
2021} = binary
@@ -71,12 +72,10 @@ function encodeForSigning(
7172}
7273
7374/**
74- * Encode a transaction and prepare for signing with a claim
75+ * Encode a payment channel claim for signing.
7576 *
76- * @param json JSON object representing the transaction
77- * @param signer string representing the account to sign the transaction with
78- * @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
79- * @returns a hex string of the encoded transaction
77+ * @param json JSON object representing the claim.
78+ * @returns a hex string of the encoded claim.
8079 */
8180function encodeForSigningClaim ( json : object ) : string {
8281 if ( typeof json !== 'object' ) {
@@ -86,12 +85,12 @@ function encodeForSigningClaim(json: object): string {
8685}
8786
8887/**
89- * Encode a transaction and prepare for multi-signing
88+ * Encode a transaction and prepare for multi-signing.
9089 *
91- * @param json JSON object representing the transaction
92- * @param signer string representing the account to sign the transaction with
90+ * @param json JSON object representing the transaction.
91+ * @param signer string representing the account to sign the transaction with.
9392 * @param definitions Custom rippled types to use instead of the default. Used for sidechains and amendments.
94- * @returns a hex string of the encoded transaction
93+ * @returns a hex string of the encoded transaction.
9594 */
9695function encodeForMultisigning (
9796 json : object ,
@@ -110,6 +109,19 @@ function encodeForMultisigning(
110109 )
111110}
112111
112+ /**
113+ * Encode a Batch transaction for signing.
114+ *
115+ * @param json JSON object representing the transaction.
116+ * @returns a hex string of the encoded transaction.
117+ */
118+ function encodeForSigningBatch ( json : object ) : string {
119+ if ( typeof json !== 'object' ) {
120+ throw new Error ( 'Need an object to encode a Batch transaction' )
121+ }
122+ return bytesToHex ( signingBatchData ( json as BatchObject ) )
123+ }
124+
113125/**
114126 * Encode a quality value
115127 *
@@ -142,6 +154,7 @@ export {
142154 encodeForSigning ,
143155 encodeForSigningClaim ,
144156 encodeForMultisigning ,
157+ encodeForSigningBatch ,
145158 encodeQuality ,
146159 decodeQuality ,
147160 decodeLedgerData ,
0 commit comments