-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestDataFactory.kt
864 lines (811 loc) · 32.4 KB
/
TestDataFactory.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
@file:Suppress("LongParameterList", "LargeClass")
package com.wavesenterprise.sdk.node.test.data
import com.wavesenterprise.sdk.node.domain.Address
import com.wavesenterprise.sdk.node.domain.Amount
import com.wavesenterprise.sdk.node.domain.AssetId
import com.wavesenterprise.sdk.node.domain.Attachment
import com.wavesenterprise.sdk.node.domain.ChainId
import com.wavesenterprise.sdk.node.domain.DataEntry
import com.wavesenterprise.sdk.node.domain.DataKey
import com.wavesenterprise.sdk.node.domain.DataSize
import com.wavesenterprise.sdk.node.domain.DataValue
import com.wavesenterprise.sdk.node.domain.DataValue.IntegerDataValue
import com.wavesenterprise.sdk.node.domain.Decimals
import com.wavesenterprise.sdk.node.domain.Fee
import com.wavesenterprise.sdk.node.domain.FeeAssetId
import com.wavesenterprise.sdk.node.domain.FileName
import com.wavesenterprise.sdk.node.domain.Hash
import com.wavesenterprise.sdk.node.domain.Height
import com.wavesenterprise.sdk.node.domain.IssueTxDescription
import com.wavesenterprise.sdk.node.domain.IssueTxName
import com.wavesenterprise.sdk.node.domain.OpType
import com.wavesenterprise.sdk.node.domain.Password
import com.wavesenterprise.sdk.node.domain.PermissionOp
import com.wavesenterprise.sdk.node.domain.PolicyDescription
import com.wavesenterprise.sdk.node.domain.PolicyId
import com.wavesenterprise.sdk.node.domain.PolicyName
import com.wavesenterprise.sdk.node.domain.PublicKey
import com.wavesenterprise.sdk.node.domain.Quantity
import com.wavesenterprise.sdk.node.domain.Reissuable
import com.wavesenterprise.sdk.node.domain.Role
import com.wavesenterprise.sdk.node.domain.Script
import com.wavesenterprise.sdk.node.domain.Signature
import com.wavesenterprise.sdk.node.domain.Timestamp
import com.wavesenterprise.sdk.node.domain.TxId
import com.wavesenterprise.sdk.node.domain.TxType
import com.wavesenterprise.sdk.node.domain.TxVersion
import com.wavesenterprise.sdk.node.domain.ValidationProof
import com.wavesenterprise.sdk.node.domain.address.Message
import com.wavesenterprise.sdk.node.domain.address.SignMessageRequest
import com.wavesenterprise.sdk.node.domain.address.SignMessageResponse
import com.wavesenterprise.sdk.node.domain.address.VerifyMessageSignatureRequest
import com.wavesenterprise.sdk.node.domain.address.VerifyMessageSignatureResponse
import com.wavesenterprise.sdk.node.domain.atomic.AtomicBadge
import com.wavesenterprise.sdk.node.domain.contract.CallContractTransaction
import com.wavesenterprise.sdk.node.domain.contract.ContractId
import com.wavesenterprise.sdk.node.domain.contract.ContractId.Companion.contractId
import com.wavesenterprise.sdk.node.domain.contract.ContractImage
import com.wavesenterprise.sdk.node.domain.contract.ContractImageHash
import com.wavesenterprise.sdk.node.domain.contract.ContractInfo
import com.wavesenterprise.sdk.node.domain.contract.ContractName
import com.wavesenterprise.sdk.node.domain.contract.ContractTransaction
import com.wavesenterprise.sdk.node.domain.contract.ContractTxStatus
import com.wavesenterprise.sdk.node.domain.contract.ContractVersion
import com.wavesenterprise.sdk.node.domain.contract.CreateContractTransaction
import com.wavesenterprise.sdk.node.domain.contract.TxStatus
import com.wavesenterprise.sdk.node.domain.privacy.Data
import com.wavesenterprise.sdk.node.domain.privacy.DataAuthor
import com.wavesenterprise.sdk.node.domain.privacy.DataComment
import com.wavesenterprise.sdk.node.domain.privacy.PolicyItemFileInfo
import com.wavesenterprise.sdk.node.domain.privacy.PolicyItemInfoResponse
import com.wavesenterprise.sdk.node.domain.privacy.PolicyItemRequest
import com.wavesenterprise.sdk.node.domain.privacy.SendDataRequest
import com.wavesenterprise.sdk.node.domain.sign.AtomicSignRequest
import com.wavesenterprise.sdk.node.domain.sign.CreateContractSignRequest
import com.wavesenterprise.sdk.node.domain.sign.CreatePolicySignRequest
import com.wavesenterprise.sdk.node.domain.sign.UpdatePolicySignRequest
import com.wavesenterprise.sdk.node.domain.tx.AtomicInnerTx
import com.wavesenterprise.sdk.node.domain.tx.AtomicTx
import com.wavesenterprise.sdk.node.domain.tx.BurnTx
import com.wavesenterprise.sdk.node.domain.tx.CallContractTx
import com.wavesenterprise.sdk.node.domain.tx.CreateContractTx
import com.wavesenterprise.sdk.node.domain.tx.CreatePolicyTx
import com.wavesenterprise.sdk.node.domain.tx.DisableContractTx
import com.wavesenterprise.sdk.node.domain.tx.ExecutableTx
import com.wavesenterprise.sdk.node.domain.tx.ExecutedContractTx
import com.wavesenterprise.sdk.node.domain.tx.GenesisTx
import com.wavesenterprise.sdk.node.domain.tx.IssueTx
import com.wavesenterprise.sdk.node.domain.tx.LeaseTx
import com.wavesenterprise.sdk.node.domain.tx.PermitTx
import com.wavesenterprise.sdk.node.domain.tx.PolicyDataHashTx
import com.wavesenterprise.sdk.node.domain.tx.ReissueTx
import com.wavesenterprise.sdk.node.domain.tx.TransferTx
import com.wavesenterprise.sdk.node.domain.tx.Tx
import com.wavesenterprise.sdk.node.domain.tx.TxInfo
import com.wavesenterprise.sdk.node.domain.tx.UpdateContractTx
import com.wavesenterprise.sdk.node.domain.tx.UpdatePolicyTx
import com.wavesenterprise.sdk.node.test.data.Util.Companion.randomBytesFromUUID
import com.wavesenterprise.sdk.node.test.data.Util.Companion.randomStringBase58
import java.time.Instant
import java.util.UUID
class TestDataFactory private constructor() {
companion object {
@JvmStatic
fun address(bytes: ByteArray = randomBytesFromUUID()) = Address(bytes)
@JvmStatic
fun txId(bytes: ByteArray = randomBytesFromUUID()) = TxId(bytes)
@JvmStatic
fun password(password: String = "password") = Password(password)
@JvmStatic
fun policyId(txId: TxId = txId()) = PolicyId(txId)
@JvmStatic
fun dataHash(stringBase58: String = randomStringBase58()) = Hash.fromStringBase58(stringBase58)
@JvmStatic
fun data(bytes: ByteArray = randomBytesFromUUID()) = Data(bytes)
@JvmStatic
fun fee(value: Long = 0) = Fee(value)
@JvmStatic
fun publicKey(bytes: ByteArray = randomBytesFromUUID()) = PublicKey(bytes)
@JvmStatic
fun message(value: String = "message") = Message(value)
@JvmStatic
fun signature(bytes: ByteArray = randomBytesFromUUID()) = Signature(bytes)
@JvmStatic
fun dataKey(value: String = "dataKey") = DataKey(value)
@JvmStatic
fun dataEntry(
key: DataKey = dataKey(),
value: DataValue = IntegerDataValue(0L),
) = DataEntry(
key = key,
value = value,
)
@JvmStatic
fun contractTransaction(
sender: Address,
type: TxType = TxType.CALL_CONTRACT,
): ContractTransaction =
when (type) {
TxType.CALL_CONTRACT -> CallContractTransaction(
id = txId(),
sender = sender,
contractId = ContractId(txId()),
params = emptyList(),
fee = Fee(0),
type = type,
version = TxVersion.fromInt(0),
proof = Signature(randomBytesFromUUID()),
timestamp = Timestamp.fromUtcTimestamp(Instant.now().toEpochMilli()),
contractVersion = ContractVersion(0),
feeAssetId = AssetId(randomBytesFromUUID()),
senderPublicKey = PublicKey(randomBytesFromUUID()),
)
TxType.CREATE_CONTRACT -> CreateContractTransaction(
id = txId(),
sender = sender,
contractId = ContractId(txId()),
params = emptyList(),
fee = Fee(0),
type = type,
version = TxVersion.fromInt(0),
proof = Signature(randomBytesFromUUID()),
timestamp = Timestamp.fromUtcTimestamp(Instant.now().toEpochMilli()),
feeAssetId = AssetId(randomBytesFromUUID()),
senderPublicKey = PublicKey(randomBytesFromUUID()),
contractName = ContractName("test-contract-${UUID.randomUUID()}"),
image = ContractImage("image"),
imageHash = ContractImageHash("imageHash"),
)
else -> throw IllegalArgumentException(
"Only CALL_CONTRACT and CREATE_CONTRACT are allowed as transaction type",
)
}
@JvmStatic
fun callContractTx(
id: TxId = txId(),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
contractId: ContractId = ContractId(TxId(randomBytesFromUUID())),
params: List<DataEntry> = emptyList(),
fee: Fee = Fee(1L),
version: TxVersion = TxVersion(1),
proofs: List<Signature>? = null,
timestamp: Timestamp = Timestamp(1L),
feeAssetId: FeeAssetId? = null,
contractVersion: ContractVersion = ContractVersion(1),
atomicBadge: AtomicBadge? = null,
senderAddress: Address = Address(randomBytesFromUUID()),
) = CallContractTx(
id = id,
senderPublicKey = senderPublicKey,
contractId = contractId,
params = params,
fee = fee,
version = version,
proofs = proofs,
timestamp = timestamp,
feeAssetId = feeAssetId,
contractVersion = contractVersion,
atomicBadge = atomicBadge,
senderAddress = senderAddress,
)
@JvmStatic
fun createContractTx(
id: TxId = txId(),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
params: List<DataEntry> = emptyList(),
fee: Fee = Fee(1L),
version: TxVersion = TxVersion(1),
proofs: List<Signature>? = null,
timestamp: Timestamp = Timestamp(1L),
feeAssetId: FeeAssetId? = null,
image: ContractImage = ContractImage("ContractImage"),
imageHash: ContractImageHash = ContractImageHash("ContractImageHash"),
contractName: ContractName = ContractName("ContractName"),
atomicBadge: AtomicBadge? = null,
senderAddress: Address = Address(randomBytesFromUUID()),
) = CreateContractTx(
id = id,
senderPublicKey = senderPublicKey,
params = params,
fee = fee,
version = version,
proofs = proofs,
timestamp = timestamp,
feeAssetId = feeAssetId,
image = image,
imageHash = imageHash,
contractName = contractName,
atomicBadge = atomicBadge,
senderAddress = senderAddress,
)
@JvmStatic
fun updateContractTx(
id: TxId = txId(),
contractId: ContractId = ContractId(TxId(randomBytesFromUUID())),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
fee: Fee = Fee(1L),
version: TxVersion = TxVersion(1),
proofs: List<Signature>? = null,
timestamp: Timestamp = Timestamp(1L),
feeAssetId: FeeAssetId? = null,
image: ContractImage = ContractImage("ContractImage"),
imageHash: ContractImageHash = ContractImageHash("ContractImageHash"),
atomicBadge: AtomicBadge? = null,
senderAddress: Address = Address(randomBytesFromUUID()),
) = UpdateContractTx(
id = id,
contractId = contractId,
senderPublicKey = senderPublicKey,
fee = fee,
version = version,
proofs = proofs,
timestamp = timestamp,
feeAssetId = feeAssetId,
image = image,
imageHash = imageHash,
atomicBadge = atomicBadge,
senderAddress = senderAddress,
)
@JvmStatic
fun disableContractTx(
id: TxId = txId(),
contractId: ContractId = ContractId(TxId(randomBytesFromUUID())),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
fee: Fee = Fee(1L),
version: TxVersion = TxVersion(1),
proofs: List<Signature>? = null,
timestamp: Timestamp = Timestamp(1L),
feeAssetId: FeeAssetId? = null,
atomicBadge: AtomicBadge? = null,
senderAddress: Address = Address(randomBytesFromUUID()),
) = DisableContractTx(
id = id,
contractId = contractId,
senderPublicKey = senderPublicKey,
fee = fee,
version = version,
proofs = proofs,
timestamp = timestamp,
feeAssetId = feeAssetId,
atomicBadge = atomicBadge,
senderAddress = senderAddress,
)
@JvmStatic
fun createContractSignRequest(
senderAddress: Address = Address.fromBase58("3M3ybNZvLG7o7rnM4F7ViRPnDTfVggdfmRX"),
) = CreateContractSignRequest(
version = TxVersion(2),
// sender specific
senderAddress = senderAddress,
// only for signature by node
password = Password("bla"),
// ---------------
// fee specific
fee = Fee(0),
feeAssetId = FeeAssetId.fromBase58("GQNK5zxqt1a6cYxnYfG4Svk6HvEjwBdeq61vP2FnNSSp"),
// ---------------
// contract specific
contractName = ContractName("bla"),
image = ContractImage("image"),
imageHash = ContractImageHash("ContractImageHash"),
params = listOf(),
// -----------------
)
@JvmStatic
fun policyDataHashTx(
id: TxId = txId(),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
fee: Fee = Fee(1L),
version: TxVersion = TxVersion(1),
proofs: List<Signature>? = null,
timestamp: Timestamp = Timestamp(1L),
feeAssetId: FeeAssetId? = null,
atomicBadge: AtomicBadge? = null,
senderAddress: Address = Address(randomBytesFromUUID()),
dataHash: Hash = Hash.fromStringBase58(randomStringBase58()),
policyId: PolicyId = PolicyId.fromByteArray(randomBytesFromUUID()),
) = PolicyDataHashTx(
id = id,
senderPublicKey = senderPublicKey,
dataHash = dataHash,
policyId = policyId,
timestamp = timestamp,
fee = fee,
feeAssetId = feeAssetId,
atomicBadge = atomicBadge,
proofs = proofs,
senderAddress = senderAddress,
version = version,
)
@JvmStatic
fun updatePolicyTx(
id: TxId = txId(),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
fee: Fee = Fee(1L),
version: TxVersion = TxVersion(1),
proofs: List<Signature>? = null,
timestamp: Timestamp = Timestamp(1L),
feeAssetId: FeeAssetId? = null,
atomicBadge: AtomicBadge? = null,
senderAddress: Address = Address(randomBytesFromUUID()),
policyId: PolicyId = PolicyId.fromByteArray(randomBytesFromUUID()),
owners: List<Address> = listOf(),
opType: OpType = OpType.ADD,
recipients: List<Address> = listOf(),
) = UpdatePolicyTx(
id = id,
senderPublicKey = senderPublicKey,
policyId = policyId,
owners = owners,
opType = opType,
recipients = recipients,
timestamp = timestamp,
fee = fee,
feeAssetId = feeAssetId,
atomicBadge = atomicBadge,
proofs = proofs,
senderAddress = senderAddress,
version = version,
)
@JvmStatic
fun createPolicyTx(
id: TxId = txId(),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
fee: Fee = Fee(1L),
description: PolicyDescription = PolicyDescription("PolicyDescription"),
policyName: PolicyName = PolicyName("PolicyName"),
version: TxVersion = TxVersion(1),
proofs: List<Signature>? = null,
timestamp: Timestamp = Timestamp(1L),
feeAssetId: FeeAssetId? = null,
atomicBadge: AtomicBadge? = null,
senderAddress: Address = Address(randomBytesFromUUID()),
owners: List<Address> = listOf(),
recipients: List<Address> = listOf(),
) = CreatePolicyTx(
id = id,
senderPublicKey = senderPublicKey,
owners = owners,
recipients = recipients,
description = description,
policyName = policyName,
timestamp = timestamp,
fee = fee,
feeAssetId = feeAssetId,
atomicBadge = atomicBadge,
proofs = proofs,
senderAddress = senderAddress,
version = version,
)
@JvmStatic
fun atomicTx(
id: TxId = TxId(randomBytesFromUUID()),
txs: List<AtomicInnerTx> = listOf(),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
fee: Fee = Fee(1L),
version: TxVersion = TxVersion(1),
proofs: List<Signature>? = null,
timestamp: Timestamp = Timestamp(1L),
senderAddress: Address = Address(randomBytesFromUUID()),
) = AtomicTx(
id = id,
senderPublicKey = senderPublicKey,
txs = txs,
timestamp = timestamp,
fee = fee,
proofs = proofs,
senderAddress = senderAddress,
version = version,
)
@JvmStatic
fun genesisTx(
id: TxId = TxId(randomBytesFromUUID()),
recipient: Address = Address(randomBytesFromUUID()),
fee: Fee = Fee(1L),
version: TxVersion = TxVersion(1),
signature: Signature = Signature(randomBytesFromUUID()),
amount: Amount = Amount(1L),
timestamp: Timestamp = Timestamp(1L),
) = GenesisTx(
id = id,
recipient = recipient,
amount = amount,
fee = fee,
timestamp = timestamp,
signature = signature,
version = version,
)
@JvmStatic
fun executedContractTx(
id: TxId = txId(),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
tx: ExecutableTx = callContractTx(),
resultsHash: Hash = Hash(randomBytesFromUUID()),
results: List<DataEntry> = listOf(),
validationProofs: List<ValidationProof> = listOf(),
version: TxVersion = TxVersion(1),
proofs: List<Signature> = listOf(),
timestamp: Timestamp = Timestamp(1L),
atomicBadge: AtomicBadge? = null,
senderAddress: Address = Address(randomBytesFromUUID()),
) = ExecutedContractTx(
id = id,
senderPublicKey = senderPublicKey,
tx = tx,
results = results,
resultsHash = resultsHash,
validationProofs = validationProofs,
timestamp = timestamp,
atomicBadge = atomicBadge,
proofs = proofs,
senderAddress = senderAddress,
version = version,
)
@JvmStatic
fun issueTx(
id: TxId = txId(),
chainId: ChainId = ChainId(Byte.MIN_VALUE),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
name: IssueTxName = IssueTxName(randomBytesFromUUID()),
description: IssueTxDescription = IssueTxDescription(randomBytesFromUUID()),
quantity: Quantity = Quantity(1),
decimals: Decimals = Decimals(Byte.MIN_VALUE),
reissuable: Reissuable = Reissuable(false),
fee: Fee = Fee(1),
timestamp: Timestamp = Timestamp(1),
script: Script? = null,
proofs: List<Signature>? = null,
senderAddress: Address = address(),
version: TxVersion = TxVersion(1),
) = IssueTx(
id = id,
chainId = chainId,
senderPublicKey = senderPublicKey,
name = name,
description = description,
quantity = quantity,
timestamp = timestamp,
decimals = decimals,
reissuable = reissuable,
script = script,
fee = fee,
proofs = proofs,
senderAddress = senderAddress,
version = version,
)
@JvmStatic
fun transferTx(
id: TxId = txId(),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
assetId: AssetId? = null,
feeAssetId: FeeAssetId? = null,
timestamp: Timestamp = Timestamp(1),
amount: Amount = Amount(1),
fee: Fee = Fee(0),
recipient: Address = address(),
attachment: Attachment? = null,
atomicBadge: AtomicBadge? = null,
proofs: List<Signature>? = null,
senderAddress: Address = address(),
version: TxVersion = TxVersion(1),
) = TransferTx(
id = id,
senderPublicKey = senderPublicKey,
assetId = assetId,
feeAssetId = feeAssetId,
timestamp = timestamp,
amount = amount,
fee = fee,
recipient = recipient,
attachment = attachment,
atomicBadge = atomicBadge,
proofs = proofs,
senderAddress = senderAddress,
version = version,
)
@JvmStatic
fun reissueTx(
id: TxId = txId(),
chainId: ChainId = ChainId(Byte.MIN_VALUE),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
assetId: AssetId? = null,
quantity: Quantity = Quantity(1),
reissuable: Reissuable = Reissuable(false),
fee: Fee = Fee(0),
timestamp: Timestamp = Timestamp(1),
proofs: List<Signature>? = null,
senderAddress: Address = address(),
version: TxVersion = TxVersion(1),
) = ReissueTx(
id = id,
chainId = chainId,
senderPublicKey = senderPublicKey,
assetId = assetId,
quantity = quantity,
reissuable = reissuable,
fee = fee,
timestamp = timestamp,
proofs = proofs,
senderAddress = senderAddress,
version = version,
)
@JvmStatic
fun burnTx(
id: TxId = txId(),
chainId: ChainId = ChainId(Byte.MIN_VALUE),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
assetId: AssetId? = null,
amount: Amount = Amount(1),
fee: Fee = Fee(0),
timestamp: Timestamp = Timestamp(1),
proofs: List<Signature>? = null,
senderAddress: Address = address(),
version: TxVersion = TxVersion(1),
) = BurnTx(
id = id,
chainId = chainId,
senderPublicKey = senderPublicKey,
assetId = assetId,
amount = amount,
fee = fee,
timestamp = timestamp,
proofs = proofs,
senderAddress = senderAddress,
version = version,
)
@JvmStatic
fun leaseTx(
id: TxId = txId(),
assetId: AssetId? = null,
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
recipient: Address = address(),
amount: Amount = Amount(1),
fee: Fee = Fee(0),
timestamp: Timestamp = Timestamp(1),
proofs: List<Signature>? = null,
senderAddress: Address = address(),
version: TxVersion = TxVersion(1),
) = LeaseTx(
id = id,
assetId = assetId,
senderPublicKey = senderPublicKey,
recipient = recipient,
amount = amount,
fee = fee,
timestamp = timestamp,
proofs = proofs,
senderAddress = senderAddress,
version = version,
)
@JvmStatic
fun permitTx(
id: TxId = txId(),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
target: Address = Address(randomBytesFromUUID()),
version: TxVersion = TxVersion(1),
proofs: List<Signature> = listOf(),
timestamp: Timestamp = Timestamp(1L),
fee: Fee = Fee(0),
permissionOp: PermissionOp = permissionOp(),
senderAddress: Address = Address(randomBytesFromUUID()),
) = PermitTx(
id = id,
senderPublicKey = senderPublicKey,
target = target,
timestamp = timestamp,
fee = fee,
permissionOp = permissionOp,
proofs = proofs,
senderAddress = senderAddress,
version = version,
)
@JvmStatic
fun permissionOp(
opType: OpType = OpType.ADD,
role: Role = Role.SENDER,
timestamp: Timestamp = Timestamp(1),
dueTimestamp: Timestamp = Timestamp(1),
) = PermissionOp(
opType = opType,
role = role,
timestamp = timestamp,
dueTimestamp = dueTimestamp,
)
@JvmStatic
fun policyItemFileInfo(
filename: FileName = FileName("FileName"),
size: DataSize = DataSize(1L),
timestamp: Timestamp = Timestamp(1L),
author: DataAuthor = DataAuthor("DataAuthor"),
comment: DataComment = DataComment("DataComment"),
) = PolicyItemFileInfo(
filename = filename,
size = size,
timestamp = timestamp,
author = author,
comment = comment,
)
@JvmStatic
fun policyItemInfoResponse(
senderAddress: Address = Address(randomBytesFromUUID()),
policyId: PolicyId = PolicyId.fromByteArray(randomBytesFromUUID()),
info: PolicyItemFileInfo = policyItemFileInfo(),
dataHash: Hash = Hash.fromStringBase58(randomStringBase58()),
) = PolicyItemInfoResponse(
senderAddress = senderAddress,
policyId = policyId,
info = info,
dataHash = dataHash,
)
@JvmStatic
fun txInfo(
height: Height = Height(1L),
tx: Tx = createContractTx(),
) = TxInfo(
height = height,
tx = tx,
)
@JvmStatic
fun contractTxStatus(
senderAddress: Address = Address(randomBytesFromUUID()),
senderPublicKey: PublicKey = PublicKey(randomBytesFromUUID()),
txId: TxId = TxId(randomBytesFromUUID()),
code: Int? = null,
message: String = "Message",
timestamp: Timestamp = Timestamp(1),
signature: Signature = Signature(randomBytesFromUUID()),
status: TxStatus = TxStatus.SUCCESS,
) = ContractTxStatus(
senderAddress = senderAddress,
senderPublicKey = senderPublicKey,
txId = txId,
code = code,
message = message,
timestamp = timestamp,
signature = signature,
status = status,
)
@JvmStatic
fun sendDataRequest(
senderAddress: Address = address(),
policyId: PolicyId = policyId(),
dataHash: Hash = dataHash(),
data: Data = data(),
info: PolicyItemFileInfo = policyItemFileInfo(),
fee: Fee = fee(),
feeAssetId: FeeAssetId? = null,
atomicBadge: AtomicBadge? = null,
password: Password = password("password"),
broadcastTx: Boolean = true,
) = SendDataRequest(
senderAddress = senderAddress,
policyId = policyId,
dataHash = dataHash,
data = data,
info = info,
fee = fee,
feeAssetId = feeAssetId,
atomicBadge = atomicBadge,
password = password,
broadcastTx = broadcastTx,
)
@JvmStatic
fun policyItemRequest(
policyId: PolicyId = policyId(),
dataHash: Hash = dataHash(),
) = PolicyItemRequest(
policyId = policyId,
dataHash = dataHash,
)
@JvmStatic
fun createPolicySignRequest(
version: TxVersion = TxVersion(2),
senderAddress: Address = address(),
password: Password = password(),
fee: Fee = fee(),
feeAssetId: FeeAssetId? = null,
policyName: PolicyName = PolicyName("test-policy"),
recipients: List<Address> = listOf(),
owners: List<Address> = listOf(),
description: PolicyDescription = PolicyDescription("test"),
atomicBadge: AtomicBadge? = null,
) = CreatePolicySignRequest(
version = version,
senderAddress = senderAddress,
password = password,
fee = fee,
feeAssetId = feeAssetId,
policyName = policyName,
recipients = recipients,
owners = owners,
description = description,
atomicBadge = atomicBadge,
)
@JvmStatic
fun updatePolicySignRequest(
policyId: PolicyId = policyId(),
opType: OpType = OpType.ADD,
version: TxVersion = TxVersion(2),
senderAddress: Address = address(),
password: Password = password(),
fee: Fee = fee(),
feeAssetId: FeeAssetId? = null,
recipients: List<Address> = listOf(),
owners: List<Address> = listOf(),
atomicBadge: AtomicBadge? = null,
) = UpdatePolicySignRequest(
policyId = policyId,
opType = opType,
version = version,
senderAddress = senderAddress,
password = password,
fee = fee,
feeAssetId = feeAssetId,
recipients = recipients,
owners = owners,
atomicBadge = atomicBadge,
)
@JvmStatic
fun atomicSignRequest(
version: TxVersion? = TxVersion(2),
senderAddress: Address = address(),
password: Password? = password(),
fee: Fee = fee(),
txs: List<AtomicInnerTx> = listOf(),
) = AtomicSignRequest(
version = version,
senderAddress = senderAddress,
password = password,
fee = fee,
txs = txs,
)
@JvmStatic
fun contractInfo(
id: ContractId = txId().contractId,
image: ContractImage = ContractImage("test-image:0.0.1"),
imageHash: ContractImageHash = ContractImageHash("hash"),
version: ContractVersion = ContractVersion(1),
active: Boolean = true,
) = ContractInfo(
id = id,
image = image,
imageHash = imageHash,
version = version,
active = active,
)
@JvmStatic
fun signMessageRequest(
message: Message = message(),
password: Password = password(),
) = SignMessageRequest(
message = message,
password = password,
)
@JvmStatic
fun signMessageResponse(
message: Message = message(),
publicKey: PublicKey = publicKey(),
signature: Signature = signature(),
) = SignMessageResponse(
message = message,
publicKey = publicKey,
signature = signature,
)
@JvmStatic
fun verifyMessageSignatureRequest(
message: Message = message(),
publicKey: PublicKey = publicKey(),
signature: Signature = signature(),
) = VerifyMessageSignatureRequest(
message = message,
publicKey = publicKey,
signature = signature,
)
@JvmStatic
fun verifyMessageSignatureResponse(
valid: Boolean = true,
) = VerifyMessageSignatureResponse(
valid = valid,
)
}
}