@@ -6,46 +6,199 @@ import {
66 TransactionType ,
77} from '@bitgo/sdk-core' ;
88
9+ /**
10+ * Extended transaction explanation for IOTA transactions.
11+ * Includes IOTA-specific fields like sender and optional sponsor.
12+ *
13+ * @example
14+ * ```typescript
15+ * const explanation: TransactionExplanation = {
16+ * type: TransactionType.Send,
17+ * sender: '0x1234...',
18+ * sponsor: '0x5678...', // Optional gas sponsor
19+ * outputAmount: '1000000',
20+ * outputs: [...],
21+ * fee: { fee: '5000' }
22+ * };
23+ * ```
24+ */
925export interface TransactionExplanation extends BaseTransactionExplanation {
26+ /** The type of transaction (e.g., Send, Receive) */
1027 type : BitGoTransactionType ;
28+
29+ /** The address initiating the transaction */
1130 sender : string ;
31+
32+ /**
33+ * Optional gas sponsor address.
34+ * When present, this address pays for the transaction's gas fees
35+ * instead of the sender.
36+ */
1237 sponsor ?: string ;
1338}
1439
40+ /**
41+ * Represents an IOTA object (coin or NFT) used as transaction input.
42+ * Objects in IOTA are versioned and content-addressable.
43+ *
44+ * @example
45+ * ```typescript
46+ * const coinObject: TransactionObjectInput = {
47+ * objectId: '0x1234...', // Unique object identifier
48+ * version: '42', // Object version number
49+ * digest: 'ABC123...' // Content hash
50+ * };
51+ * ```
52+ */
1553export type TransactionObjectInput = {
54+ /** Unique identifier for the object (64-character hex string) */
1655 objectId : string ;
56+
57+ /** Version number of the object (as string) */
1758 version : string ;
59+
60+ /** Base58-encoded digest of the object's content */
1861 digest : string ;
1962} ;
2063
64+ /**
65+ * Gas configuration for IOTA transactions.
66+ * All fields are optional to support both simulation and real transactions.
67+ *
68+ * @example
69+ * ```typescript
70+ * const gasData: GasData = {
71+ * gasBudget: 5000000, // Maximum gas units to spend
72+ * gasPrice: 1000, // Price per gas unit
73+ * gasPaymentObjects: [coinObject1, coinObject2] // Coins to pay gas
74+ * };
75+ * ```
76+ */
2177export type GasData = {
78+ /**
79+ * Maximum amount of gas units this transaction can consume.
80+ * Measured in gas units.
81+ */
2282 gasBudget ?: number ;
83+
84+ /**
85+ * Price per gas unit in MIST (smallest IOTA unit).
86+ * Total fee = gasBudget * gasPrice
87+ */
2388 gasPrice ?: number ;
89+
90+ /**
91+ * Array of coin objects used to pay for gas.
92+ * These objects will be consumed to cover the transaction fee.
93+ */
2494 gasPaymentObjects ?: TransactionObjectInput [ ] ;
2595} ;
2696
2797/**
28- * The transaction data returned from the toJson() function of a transaction
98+ * Base transaction data returned from the toJson() function.
99+ * Contains common fields present in all IOTA transactions.
100+ *
101+ * @example
102+ * ```typescript
103+ * const txData: TxData = {
104+ * type: TransactionType.Send,
105+ * sender: '0x1234...',
106+ * gasBudget: 5000000,
107+ * gasPrice: 1000,
108+ * gasPaymentObjects: [...],
109+ * gasSponsor: '0x5678...' // Optional
110+ * };
111+ * ```
29112 */
30113export interface TxData {
114+ /** Transaction ID (digest), available after transaction is built */
31115 id ?: string ;
116+
117+ /** Address of the transaction sender */
32118 sender : string ;
119+
120+ /** Maximum gas units allocated for this transaction */
33121 gasBudget ?: number ;
122+
123+ /** Price per gas unit in MIST */
34124 gasPrice ?: number ;
125+
126+ /** Coin objects used to pay for gas */
35127 gasPaymentObjects ?: TransactionObjectInput [ ] ;
128+
129+ /**
130+ * Optional address that sponsors (pays for) the gas.
131+ * If not provided, the sender pays for gas.
132+ */
36133 gasSponsor ?: string ;
134+
135+ /** Type of the transaction */
37136 type : TransactionType ;
38137}
39138
139+ /**
140+ * Transfer transaction data with recipient information.
141+ * Extends TxData with transfer-specific fields.
142+ *
143+ * @example
144+ * ```typescript
145+ * const transferData: TransferTxData = {
146+ * type: TransactionType.Send,
147+ * sender: '0x1234...',
148+ * recipients: [
149+ * { address: '0xabcd...', amount: '1000000' },
150+ * { address: '0xef01...', amount: '2000000' }
151+ * ],
152+ * paymentObjects: [coinObject],
153+ * gasBudget: 5000000,
154+ * gasPrice: 1000,
155+ * gasPaymentObjects: [gasObject]
156+ * };
157+ * ```
158+ */
40159export interface TransferTxData extends TxData {
160+ /**
161+ * Array of recipients and the amounts they receive.
162+ * Each recipient must have a valid IOTA address and amount.
163+ */
41164 recipients : TransactionRecipient [ ] ;
165+
166+ /**
167+ * Optional coin objects used as payment sources.
168+ * These are split and transferred to recipients.
169+ * If not provided, gas objects are used for payment.
170+ */
42171 paymentObjects ?: TransactionObjectInput [ ] ;
43172}
44173
174+ /**
175+ * Options for explaining an IOTA transaction.
176+ *
177+ * @example
178+ * ```typescript
179+ * const explanation = await iota.explainTransaction({
180+ * txHex: '0x1234...' // Raw transaction hex
181+ * });
182+ * ```
183+ */
45184export interface ExplainTransactionOptions {
185+ /** Raw transaction data in hexadecimal format */
46186 txHex : string ;
47187}
48188
189+ /**
190+ * Options for parsing an IOTA transaction.
191+ * Extends base parsing options with IOTA-specific requirements.
192+ *
193+ * @example
194+ * ```typescript
195+ * const parsed = await iota.parseTransaction({
196+ * txHex: '0x1234...' // Raw transaction hex
197+ * });
198+ * // Returns: { inputs: [...], outputs: [...], fee: BigNumber }
199+ * ```
200+ */
49201export interface IotaParseTransactionOptions extends BaseParseTransactionOptions {
202+ /** Raw transaction data in hexadecimal format */
50203 txHex : string ;
51204}
0 commit comments