@@ -8,9 +8,8 @@ import { PricingMode } from './PricingMode';
8
8
import { TransactionTarget } from './TransactionTarget' ;
9
9
import { TransactionEntryPoint } from './TransactionEntryPoint' ;
10
10
import { TransactionScheduling } from './TransactionScheduling' ;
11
- import { PublicKey } from './keypair' ;
11
+ import { PublicKey , PrivateKey } from './keypair' ;
12
12
import { HexBytes } from './HexBytes' ;
13
- import { PrivateKey } from './keypair/PrivateKey' ;
14
13
import { Args } from './Args' ;
15
14
import { deserializeArgs , serializeArgs } from './SerializationUtils' ;
16
15
import { byteHash } from './ByteConverters' ;
@@ -101,7 +100,7 @@ export class Approval {
101
100
}
102
101
103
102
/**
104
- * Represents a TransactionV1 object, including its header, body , and approvals.
103
+ * Represents a TransactionV1 object, including its hash, payload , and approvals.
105
104
*/
106
105
@jsonObject
107
106
export class TransactionV1 {
@@ -272,11 +271,21 @@ export class TransactionV1 {
272
271
}
273
272
274
273
/**
275
- * Represents the header of a transaction, including details like chain name, timestamp,
276
- * time-to-live (TTL), initiator address, and pricing mode.
274
+ * A wrapper for a TransactionV1 or Deploy.
277
275
*/
278
276
@jsonObject
279
- export class TransactionHeader {
277
+ export class Transaction {
278
+ /**
279
+ * The hash of the transaction.
280
+ */
281
+ @jsonMember ( {
282
+ name : 'hash' ,
283
+ constructor : Hash ,
284
+ deserializer : json => Hash . fromJSON ( json ) ,
285
+ serializer : value => value . toJSON ( )
286
+ } )
287
+ public hash : Hash ;
288
+
280
289
/**
281
290
* The name of the blockchain chain associated with this transaction.
282
291
*/
@@ -322,35 +331,6 @@ export class TransactionHeader {
322
331
@jsonMember ( { name : 'pricing_mode' , constructor : PricingMode } )
323
332
public pricingMode : PricingMode ;
324
333
325
- /**
326
- * Creates a new `TransactionHeader` instance with the given properties.
327
- * @param chainName The name of the blockchain chain.
328
- * @param timestamp The timestamp of the transaction.
329
- * @param ttl The TTL (Time-To-Live) for the transaction.
330
- * @param initiatorAddr The address of the transaction initiator.
331
- * @param pricingMode The pricing mode for the transaction.
332
- */
333
- constructor (
334
- chainName : string ,
335
- timestamp : Timestamp ,
336
- ttl : Duration ,
337
- initiatorAddr : InitiatorAddr ,
338
- pricingMode : PricingMode
339
- ) {
340
- this . chainName = chainName ;
341
- this . timestamp = timestamp ;
342
- this . ttl = ttl ;
343
- this . initiatorAddr = initiatorAddr ;
344
- this . pricingMode = pricingMode ;
345
- }
346
- }
347
-
348
- /**
349
- * Represents the body of a transaction, containing the arguments, target,
350
- * entry point, scheduling information, and transaction category.
351
- */
352
- @jsonObject
353
- export class TransactionBody {
354
334
/**
355
335
* The arguments for the transaction, which can be a map of values required by the entry point.
356
336
*/
@@ -395,62 +375,11 @@ export class TransactionBody {
395
375
396
376
/**
397
377
* The category of the transaction, indicating its type (e.g., minting, auction).
378
+ * Using TransactionCategory as enum
398
379
*/
399
380
@jsonMember ( { name : 'transaction_category' , constructor : Number } )
400
381
public category ?: number ;
401
382
402
- /**
403
- * Constructs a `TransactionBody` with the given arguments, target, entry point, scheduling, and category.
404
- * @param args The arguments for the transaction.
405
- * @param target The target of the transaction (e.g., a contract or account).
406
- * @param entryPoint The entry point to specify the method or action of the transaction.
407
- * @param scheduling The scheduling information for the transaction's execution.
408
- * @param category The category/type of the transaction (e.g., mint, auction).
409
- */
410
- constructor (
411
- args : Args ,
412
- target : TransactionTarget ,
413
- entryPoint : TransactionEntryPoint ,
414
- scheduling : TransactionScheduling ,
415
- category ?: number
416
- ) {
417
- this . args = args ;
418
- this . target = target ;
419
- this . entryPoint = entryPoint ;
420
- this . scheduling = scheduling ;
421
- this . category = category ;
422
- }
423
- }
424
-
425
- /**
426
- * Represents a transaction in the system, containing information such as its hash,
427
- * header, body, approvals, and optionally its associated deployment and transaction details.
428
- */
429
- @jsonObject
430
- export class Transaction {
431
- /**
432
- * The hash of the transaction.
433
- */
434
- @jsonMember ( {
435
- name : 'hash' ,
436
- constructor : Hash ,
437
- deserializer : json => Hash . fromJSON ( json ) ,
438
- serializer : value => value . toJSON ( )
439
- } )
440
- public hash : Hash ;
441
-
442
- /**
443
- * The header of the transaction, which includes metadata about the transaction.
444
- */
445
- @jsonMember ( { name : 'header' , constructor : TransactionHeader } )
446
- public header : TransactionHeader ;
447
-
448
- /**
449
- * The body of the transaction, containing details such as the target, entry point, and arguments.
450
- */
451
- @jsonMember ( { name : 'body' , constructor : TransactionBody } )
452
- public body : TransactionBody ;
453
-
454
383
/**
455
384
* The list of approvals for this transaction.
456
385
*/
@@ -472,24 +401,49 @@ export class Transaction {
472
401
/**
473
402
* Creates a new `Transaction` instance with the specified values.
474
403
* @param hash The hash of the transaction.
475
- * @param header The header of the transaction.
476
- * @param body The body of the transaction.
404
+ * @param chainName The blockchain chain name associated with this transaction.
405
+ * @param timestamp The timestamp of transaction creation.
406
+ * @param ttl The time-to-live duration of the transaction.
407
+ * @param initiatorAddr The address of the transaction initiator.
408
+ * @param pricingMode The pricing mode for this transaction.
409
+ * @param args The arguments for the transaction.
410
+ * @param target The target of the transaction.
411
+ * @param entryPoint The entry point of the transaction.
412
+ * @param scheduling The scheduling information for the transaction.
477
413
* @param approvals The list of approvals for this transaction.
414
+ * @param category The category of the transaction, indicating its type (e.g., minting, auction).
478
415
* @param originTransactionV1 The original TransactionV1, if applicable.
479
416
* @param originDeployV1 The original deploy, if applicable.
480
417
*/
481
418
constructor (
482
419
hash : Hash ,
483
- header : TransactionHeader ,
484
- body : TransactionBody ,
420
+ chainName : string ,
421
+ timestamp : Timestamp ,
422
+ ttl : Duration ,
423
+ initiatorAddr : InitiatorAddr ,
424
+ pricingMode : PricingMode ,
425
+ args : Args ,
426
+ target : TransactionTarget ,
427
+ entryPoint : TransactionEntryPoint ,
428
+ scheduling : TransactionScheduling ,
485
429
approvals : Approval [ ] ,
430
+ category ?: TransactionCategory ,
486
431
originTransactionV1 ?: TransactionV1 ,
487
432
originDeployV1 ?: Deploy
488
433
) {
489
434
this . hash = hash ;
490
- this . header = header ;
491
- this . body = body ;
435
+ this . chainName = chainName ;
436
+ this . timestamp = timestamp ;
437
+ this . ttl = ttl ;
438
+ this . initiatorAddr = initiatorAddr ;
439
+ this . pricingMode = pricingMode ;
440
+ this . args = args ;
441
+ this . target = target ;
442
+ this . entryPoint = entryPoint ;
443
+ this . scheduling = scheduling ;
492
444
this . approvals = approvals ;
445
+ this . category = category ;
446
+
493
447
this . originDeployV1 = originDeployV1 ;
494
448
this . originTransactionV1 = originTransactionV1 ;
495
449
}
@@ -518,21 +472,19 @@ export class Transaction {
518
472
static fromTransactionV1 ( v1 : TransactionV1 ) : Transaction {
519
473
return new Transaction (
520
474
v1 . hash ,
521
- new TransactionHeader (
522
- v1 . payload . chainName ,
523
- v1 . payload . timestamp ,
524
- v1 . payload . ttl ,
525
- v1 . payload . initiatorAddr ,
526
- v1 . payload . pricingMode
527
- ) ,
528
- new TransactionBody (
529
- v1 . payload . fields . args ,
530
- v1 . payload . fields . target ,
531
- v1 . payload . fields . entryPoint ,
532
- v1 . payload . fields . scheduling
533
- ) ,
475
+ v1 . payload . chainName ,
476
+ v1 . payload . timestamp ,
477
+ v1 . payload . ttl ,
478
+ v1 . payload . initiatorAddr ,
479
+ v1 . payload . pricingMode ,
480
+ v1 . payload . fields . args ,
481
+ v1 . payload . fields . target ,
482
+ v1 . payload . fields . entryPoint ,
483
+ v1 . payload . fields . scheduling ,
534
484
v1 . approvals ,
535
- v1
485
+ undefined ,
486
+ v1 , // originTransactionV1
487
+ undefined // originDeployV1 is not applicable for this method
536
488
) ;
537
489
}
538
490
}
0 commit comments