avail-rust-client 0.5.1

Avail Rust SDK client library
Documentation
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
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
//! Builders for transactions targeting specific Avail pallets.

use crate::{Client, SubmittableTransaction};
use avail_rust_core::{
	AccountId, AccountIdLike, ExtrinsicCall, H256, MultiAddress,
	avail::{
		self,
		multisig::types::Timepoint,
		nomination_pools::types::{BondExtraValue, ClaimPermission, ConfigOpAccount, PoolState},
		proxy::types::ProxyType,
		staking::types::{RewardDestination, ValidatorPrefs},
	},
	types::{
		HashString,
		metadata::{MultiAddressLike, StringOrBytes},
		substrate::Weight,
	},
};

/// Entry point for constructing pallet-specific transaction builders.
///
/// Each accessor clones the underlying [`Client`] and returns a lightweight helper that can compose
/// extrinsics without contacting the node. The returned builders produce [`SubmittableTransaction`]s
/// which must be signed—and optionally submitted—separately.
pub struct TransactionApi(pub(crate) Client);
impl TransactionApi {
	/// Returns helpers for composing `balances` pallet extrinsics.
	///
	/// # Returns
	/// Returns a [`Balances`] builder that clones this client.
	pub fn balances(&self) -> Balances {
		Balances(self.0.clone())
	}

	/// Returns helpers for composing data availability submissions.
	///
	/// # Returns
	/// Returns a [`DataAvailability`] builder that clones this client.
	pub fn data_availability(&self) -> DataAvailability {
		DataAvailability(self.0.clone())
	}

	/// Returns helpers for multisig transaction approval flows.
	///
	/// # Returns
	/// Returns a [`Multisig`] builder that clones this client.
	pub fn multisig(&self) -> Multisig {
		Multisig(self.0.clone())
	}

	/// Returns helpers for batching extrinsics via the utility pallet.
	///
	/// # Returns
	/// Returns a [`Utility`] builder that clones this client.
	pub fn utility(&self) -> Utility {
		Utility(self.0.clone())
	}

	/// Returns helpers for proxy management extrinsics.
	///
	/// # Returns
	/// Returns a [`Proxy`] builder that clones this client.
	pub fn proxy(&self) -> Proxy {
		Proxy(self.0.clone())
	}

	/// Returns helpers for staking-related extrinsics.
	///
	/// # Returns
	/// Returns a [`Staking`] builder that clones this client.
	pub fn staking(&self) -> Staking {
		Staking(self.0.clone())
	}

	/// Returns helpers for Vector message passing extrinsics.
	///
	/// # Returns
	/// Returns a [`Vector`] builder that clones this client.
	pub fn vector(&self) -> Vector {
		Vector(self.0.clone())
	}

	/// Returns helpers for system-level extrinsics.
	///
	/// # Returns
	/// Returns a [`System`] builder that clones this client.
	pub fn system(&self) -> System {
		System(self.0.clone())
	}

	/// Returns helpers for nomination pool extrinsics.
	///
	/// # Returns
	/// Returns a [`NominationPools`] builder that clones this client.
	pub fn nomination_pools(&self) -> NominationPools {
		NominationPools(self.0.clone())
	}

	/// Returns helpers for validator session key management.
	///
	/// # Returns
	/// Returns a [`Session`] builder that clones this client.
	pub fn session(&self) -> Session {
		Session(self.0.clone())
	}
}

/// Builds extrinsics for the `session` pallet.
///
/// The helper clones the underlying client; composing calls does not contact the node until the
/// resulting [`SubmittableTransaction`] is signed or submitted.
pub struct Session(Client);
impl Session {
	/// Updates the node's session keys with new authorities and proof data.
	///
	/// # Panics
	/// Panics when any supplied key fails to decode into an `H256` hash.
	///
	/// # Arguments
	/// * `babe` - BABE authority key encoded as a hash string.
	/// * `grandpa` - GRANDPA authority key encoded as a hash string.
	/// * `authority_discovery` - Authority discovery key encoded as a hash string.
	/// * `im_online` - Im-online session key encoded as a hash string.
	/// * `proof` - Proof bytes returned by the session key generator.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that sets the supplied session keys.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_key(
		&self,
		babe: impl Into<HashString>,
		grandpa: impl Into<HashString>,
		authority_discovery: impl Into<HashString>,
		im_online: impl Into<HashString>,
		proof: Vec<u8>,
	) -> SubmittableTransaction {
		let babe: HashString = babe.into();
		let babe: H256 = babe.try_into().expect("Invalid string for H256");

		let grandpa: HashString = grandpa.into();
		let grandpa: H256 = grandpa.try_into().expect("Invalid string for H256");

		let authority_discovery: HashString = authority_discovery.into();
		let authority_discovery: H256 = authority_discovery.try_into().expect("Invalid string for H256");

		let im_online: HashString = im_online.into();
		let im_online: H256 = im_online.try_into().expect("Invalid string for H256");

		let value = avail::session::tx::SetKeys { babe, grandpa, authority_discovery, im_online, proof };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Removes the stored session keys from on-chain storage.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that clears session keys for the signing account.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn purge_key(&self) -> SubmittableTransaction {
		let value = avail::session::tx::PurgeKeys {};
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}
}

/// Builds extrinsics for the `nomination_pools` pallet.
///
/// Many helpers accept `MultiAddressLike` values and will panic if those cannot be converted into
/// on-chain account identifiers. Constructing the [`SubmittableTransaction`] itself does not hit the
/// network; signing or submitting it will.
pub struct NominationPools(Client);
impl NominationPools {
	/// Contributes additional stake from the pool's bonded account.
	///
	/// # Arguments
	/// * `value` - Amount to bond, expressed as a [`BondExtraValue`].
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that bonds the extra amount for the pool.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn bond_extra(&self, value: BondExtraValue) -> SubmittableTransaction {
		let value = avail::nomination_pools::tx::BondExtra { value };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Bonds additional stake on behalf of another member.
	///
	/// # Panics
	/// Panics if `member` cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `member` - Account that receives the increased bonded amount.
	/// * `value` - Amount to bond, expressed as a [`BondExtraValue`].
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that bonds extra stake for the specified member.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn bond_extra_other(
		&self,
		member: impl Into<MultiAddressLike>,
		value: BondExtraValue,
	) -> SubmittableTransaction {
		let member: MultiAddressLike = member.into();
		let member: MultiAddress = member.try_into().expect("Malformed string is passed for AccountId");

		let value = avail::nomination_pools::tx::BondExtraOther { member, value };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Requests the pool to chill its nominations.
	///
	/// # Arguments
	/// * `pool_id` - Identifier of the pool that should chill.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that issues the `chill` request.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn chill(&self, pool_id: u32) -> SubmittableTransaction {
		let value = avail::nomination_pools::tx::Chill { pool_id };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Claims pending commission for the given pool.
	///
	/// # Arguments
	/// * `pool_id` - Identifier of the pool that should pay out commission.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that claims the commission.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn claim_commission(&self, pool_id: u32) -> SubmittableTransaction {
		let value = avail::nomination_pools::tx::ClaimCommission { pool_id };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Claims a pending payout for the caller.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that claims unpaid rewards for the signer.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn claim_payout(&self) -> SubmittableTransaction {
		let value = avail::nomination_pools::tx::ClaimPayout {};
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Claims a pending payout for another pool member.
	///
	/// # Panics
	/// Panics if `owner` cannot be converted into an `AccountId`.
	///
	/// # Arguments
	/// * `owner` - Account that receives the payout.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that claims unpaid rewards on behalf of `owner`.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn claim_payout_other(&self, owner: impl Into<AccountIdLike>) -> SubmittableTransaction {
		let owner: AccountIdLike = owner.into();
		let owner: AccountId = owner.try_into().expect("Malformed string is passed for AccountId");

		let value = avail::nomination_pools::tx::ClaimPayoutOther { owner };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Creates a new nomination pool with freshly provided roles.
	///
	/// # Panics
	/// Panics if any of `root`, `nominator`, or `bouncer` cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `amount` - Initial bonded amount for the pool.
	/// * `root` - Root account controlling pool administration.
	/// * `nominator` - Account authorised to nominate validators.
	/// * `bouncer` - Account that manages membership access.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that creates the pool with the supplied roles.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn create(
		&self,
		amount: u128,
		root: impl Into<MultiAddressLike>,
		nominator: impl Into<MultiAddressLike>,
		bouncer: impl Into<MultiAddressLike>,
	) -> SubmittableTransaction {
		let root: MultiAddressLike = root.into();
		let root: MultiAddress = root.try_into().expect("Malformed string is passed for AccountId");
		let nominator: MultiAddressLike = nominator.into();
		let nominator: MultiAddress = nominator.try_into().expect("Malformed string is passed for AccountId");
		let bouncer: MultiAddressLike = bouncer.into();
		let bouncer: MultiAddress = bouncer.try_into().expect("Malformed string is passed for AccountId");

		let value = avail::nomination_pools::tx::Create { amount, root, nominator, bouncer };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Creates a new nomination pool using a specific pool identifier.
	///
	/// # Panics
	/// Panics if any of `root`, `nominator`, or `bouncer` cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `amount` - Initial bonded amount for the pool.
	/// * `root` - Root account controlling pool administration.
	/// * `nominator` - Account authorised to nominate validators.
	/// * `bouncer` - Account that manages membership access.
	/// * `pool_id` - Identifier to assign to the new pool.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that creates the pool with an explicit identifier.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn create_with_pool_id(
		&self,
		amount: u128,
		root: impl Into<MultiAddressLike>,
		nominator: impl Into<MultiAddressLike>,
		bouncer: impl Into<MultiAddressLike>,
		pool_id: u32,
	) -> SubmittableTransaction {
		let root: MultiAddressLike = root.into();
		let root: MultiAddress = root.try_into().expect("Malformed string is passed for AccountId");
		let nominator: MultiAddressLike = nominator.into();
		let nominator: MultiAddress = nominator.try_into().expect("Malformed string is passed for AccountId");
		let bouncer: MultiAddressLike = bouncer.into();
		let bouncer: MultiAddress = bouncer.try_into().expect("Malformed string is passed for AccountId");

		let value = avail::nomination_pools::tx::CreateWithPoolId { amount, root, nominator, bouncer, pool_id };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Joins an existing pool by contributing the requested amount.
	///
	/// # Arguments
	/// * `amount` - Amount of stake contributed by the caller.
	/// * `pool_id` - Identifier of the pool to join.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that adds the caller to the pool.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn join(&self, amount: u128, pool_id: u32) -> SubmittableTransaction {
		let value = avail::nomination_pools::tx::Join { amount, pool_id };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Sets nominations for the pool to a new validator set.
	///
	/// # Panics
	/// Panics if any validator identifier cannot be converted into an `AccountId`.
	///
	/// # Arguments
	/// * `pool_id` - Identifier of the pool whose nominations are updated.
	/// * `validators` - Validators that the pool should nominate.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that updates the pool's nominations.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn nominate(&self, pool_id: u32, validators: Vec<impl Into<AccountIdLike>>) -> SubmittableTransaction {
		let validators: Vec<AccountIdLike> = validators.into_iter().map(|x| x.into()).collect();
		let validators: Result<Vec<AccountId>, _> = validators.into_iter().map(AccountId::try_from).collect();
		let validators = validators.expect("Malformed string is passed for AccountId");

		let value = avail::nomination_pools::tx::Nominate { pool_id, validators };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Updates who is allowed to claim rewards for the pool.
	///
	/// # Arguments
	/// * `permission` - Claim policy applied to the pool.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that adjusts the pool's claim permission.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_claim_permission(&self, permission: ClaimPermission) -> SubmittableTransaction {
		let value = avail::nomination_pools::tx::SetClaimPermission { permission };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Updates the commission settings for the pool, optionally setting a payee.
	///
	/// # Panics
	/// Panics if the payee provided in `new_commission` cannot be converted into an `AccountId`.
	///
	/// # Arguments
	/// * `pool_id` - Identifier of the pool whose commission is updated.
	/// * `new_commission` - Optional tuple of `(commission, payee)` describing the new rate and payee.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that updates commission settings.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_commission(&self, pool_id: u32, new_commission: Option<(u32, AccountIdLike)>) -> SubmittableTransaction {
		let new_commission =
			new_commission.map(|x| (x.0, AccountId::try_from(x.1).expect("Malformed string is passed for AccountId")));
		let value = avail::nomination_pools::tx::SetCommission { pool_id, new_commission };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Configures how frequently pool commission may change.
	///
	/// # Arguments
	/// * `pool_id` - Identifier of the pool being updated.
	/// * `max_increase` - Maximum commission increase allowed per change.
	/// * `min_delay` - Minimum number of eras between commission updates.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that applies the new change rate.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_commission_change_rate(
		&self,
		pool_id: u32,
		max_increase: u32,
		min_delay: u32,
	) -> SubmittableTransaction {
		let value = avail::nomination_pools::tx::SetCommissionChangeRate { pool_id, max_increase, min_delay };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Caps commission at the provided maximum percentage.
	///
	/// # Arguments
	/// * `pool_id` - Identifier of the pool being updated.
	/// * `max_commission` - Maximum commission percentage allowed.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that stores the new commission cap.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_commission_max(&self, pool_id: u32, max_commission: u32) -> SubmittableTransaction {
		let value = avail::nomination_pools::tx::SetCommissionMax { pool_id, max_commission };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Updates pool metadata stored on chain.
	///
	/// # Arguments
	/// * `pool_id` - Identifier of the pool being updated.
	/// * `metadata` - Metadata payload encoded as bytes or string.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that writes the metadata to storage.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_metadata<'a>(&self, pool_id: u32, metadata: impl Into<StringOrBytes<'a>>) -> SubmittableTransaction {
		let metadata: StringOrBytes = metadata.into();
		let metadata: Vec<u8> = metadata.into();
		let value = avail::nomination_pools::tx::SetMetadata { pool_id, metadata };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Transitions the pool into a new lifecycle state.
	///
	/// # Arguments
	/// * `pool_id` - Identifier of the pool being updated.
	/// * `state` - New lifecycle state to apply.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that updates the pool state.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_state(&self, pool_id: u32, state: PoolState) -> SubmittableTransaction {
		let value = avail::nomination_pools::tx::SetState { pool_id, state };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Starts the unbonding process for the specified member account.
	///
	/// # Panics
	/// Panics if `member_account` cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `member_account` - Account leaving the pool.
	/// * `unbonding_points` - Amount of stake to unbond, expressed in pool points.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that schedules the unbonding.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn unbond(
		&self,
		member_account: impl Into<MultiAddressLike>,
		unbonding_points: u128,
	) -> SubmittableTransaction {
		let member_account: MultiAddressLike = member_account.into();
		let member_account: MultiAddress = member_account
			.try_into()
			.expect("Malformed string is passed for AccountId");

		let value = avail::nomination_pools::tx::Unbond { member_account, unbonding_points };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Updates the pool's root, nominator, and bouncer roles.
	///
	/// # Arguments
	/// * `pool_id` - Identifier of the pool being updated.
	/// * `new_root` - Operation describing how to update the root account.
	/// * `new_nominator` - Operation describing how to update the nominator account.
	/// * `new_bouncer` - Operation describing how to update the bouncer account.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that applies the new role assignments.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn update_roles(
		&self,
		pool_id: u32,
		new_root: ConfigOpAccount,
		new_nominator: ConfigOpAccount,
		new_bouncer: ConfigOpAccount,
	) -> SubmittableTransaction {
		let value = avail::nomination_pools::tx::UpdateRoles { pool_id, new_root, new_nominator, new_bouncer };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Withdraws fully unbonded funds for the given member account.
	///
	/// # Panics
	/// Panics if `member_account` cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `member_account` - Account withdrawing previously unbonded funds.
	/// * `num_slashing_spans` - Number of slashing spans to consider when finalising the withdrawal.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that withdraws the unbonded amount.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn withdraw_unbonded(
		&self,
		member_account: impl Into<MultiAddressLike>,
		num_slashing_spans: u32,
	) -> SubmittableTransaction {
		let member_account: MultiAddressLike = member_account.into();
		let member_account: MultiAddress = member_account
			.try_into()
			.expect("Malformed string is passed for AccountId");

		let value = avail::nomination_pools::tx::WithdrawUnbonded { member_account, num_slashing_spans };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}
}

/// Builds extrinsics for the `staking` pallet.
///
/// Methods that accept `AccountIdLike` or `MultiAddressLike` parameters will panic if the provided
/// value cannot be converted into the expected on-chain representation.
pub struct Staking(Client);
impl Staking {
	/// Bonds funds from the controller with the provided reward destination.
	///
	/// # Arguments
	/// * `value` - Amount of stake to bond.
	/// * `payee` - Destination where rewards should be paid.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that bonds the specified amount.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn bond(&self, value: u128, payee: RewardDestination) -> SubmittableTransaction {
		let value = avail::staking::tx::Bond { value, payee };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Adds additional stake on top of an existing bond.
	///
	/// # Arguments
	/// * `value` - Additional stake to add to the bonded balance.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that increases the bonded amount.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn bond_extra(&self, value: u128) -> SubmittableTransaction {
		let value = avail::staking::tx::BondExtra { value };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Starts unbonding the given amount of funds.
	///
	/// # Arguments
	/// * `value` - Amount of stake to unbond.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that schedules the unbonding.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn unbond(&self, value: u128) -> SubmittableTransaction {
		let value = avail::staking::tx::Unbond { value };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Re-bonds a portion of funds that are currently unbonding.
	///
	/// # Arguments
	/// * `value` - Amount of stake to re-bond.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that re-bonds the requested amount.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn rebond(&self, value: u128) -> SubmittableTransaction {
		let value = avail::staking::tx::Rebond { value };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Advertises validator preferences for the caller.
	///
	/// # Arguments
	/// * `commission` - Desired commission percentage.
	/// * `blocked` - Flag indicating whether new nominations are rejected.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that publishes the validator preferences.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn validate(&self, commission: u32, blocked: bool) -> SubmittableTransaction {
		let value = avail::staking::tx::Validate { prefs: ValidatorPrefs { commission, blocked } };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Nominates a new set of validator targets.
	///
	/// # Panics
	/// Panics if any provided target cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `targets` - Validators to nominate.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that updates the nomination targets.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn nominate(&self, targets: Vec<impl Into<MultiAddressLike>>) -> SubmittableTransaction {
		let targets: Vec<MultiAddressLike> = targets.into_iter().map(|x| x.into()).collect();
		let targets: Result<Vec<MultiAddress>, _> = targets.into_iter().map(MultiAddress::try_from).collect();
		let targets = targets.expect("Malformed string is passed for AccountId");

		let value = avail::staking::tx::Nominate { targets };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Pays out staking rewards for the given validator and era.
	///
	/// # Panics
	/// Panics if `validator_stash` cannot be converted into an `AccountId`.
	///
	/// # Arguments
	/// * `validator_stash` - Stash account whose rewards are claimed.
	/// * `era` - Era for which rewards are paid out.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that triggers the payout.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn payout_stakers(&self, validator_stash: impl Into<AccountIdLike>, era: u32) -> SubmittableTransaction {
		let validator_stash: AccountIdLike = validator_stash.into();
		let validator_stash = AccountId::try_from(validator_stash).expect("Malformed string is passed for AccountId");

		let value = avail::staking::tx::PayoutStakers { validator_stash, era };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Switches the controller account for the stash.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that sets a new controller (based on the signature).
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_controller(&self) -> SubmittableTransaction {
		let value = avail::staking::tx::SetController {};
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Updates the staking reward destination.
	///
	/// # Arguments
	/// * `payee` - Destination where new rewards should be deposited.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that updates the reward destination.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_payee(&self, payee: RewardDestination) -> SubmittableTransaction {
		let value = avail::staking::tx::SetPayee { payee };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Stops nominating for the caller.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that chills the caller's nominations.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn chill(&self) -> SubmittableTransaction {
		let value = avail::staking::tx::Chill {};
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Issues a chill for another stash account.
	///
	/// # Panics
	/// Panics if `stash` cannot be converted into an `AccountId`.
	///
	/// # Arguments
	/// * `stash` - Stash account to chill.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that chills the specified stash.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn chill_other(&self, stash: impl Into<AccountIdLike>) -> SubmittableTransaction {
		let stash: AccountIdLike = stash.into();
		let stash = AccountId::try_from(stash).expect("Malformed string is passed for AccountId");

		let value = avail::staking::tx::ChillOther { stash };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Withdraws funds that have completed the unbonding period.
	///
	/// # Arguments
	/// * `num_slashing_spans` - Number of slashing spans to consider when finalising the withdrawal.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that withdraws matured unbonded funds.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn withdraw_unbonded(&self, num_slashing_spans: u32) -> SubmittableTransaction {
		let value = avail::staking::tx::WithdrawUnbonded { num_slashing_spans };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Removes a stash that no longer has bonded funds.
	///
	/// # Panics
	/// Panics if `stash` cannot be converted into an `AccountId`.
	///
	/// # Arguments
	/// * `stash` - Stash account to reap.
	/// * `num_slashing_spans` - Number of slashing spans considered during reaping.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that reaps the empty stash.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn reap_stash(&self, stash: impl Into<AccountIdLike>, num_slashing_spans: u32) -> SubmittableTransaction {
		let stash: AccountIdLike = stash.into();
		let stash = AccountId::try_from(stash).expect("Malformed string is passed for AccountId");

		let value = avail::staking::tx::ReapStash { stash, num_slashing_spans };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Removes the provided nominees from the caller's nomination list.
	///
	/// # Panics
	/// Panics if any identifier in `who` cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `who` - Nominees to remove.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that removes the specified nominees.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn kick(&self, who: Vec<impl Into<MultiAddressLike>>) -> SubmittableTransaction {
		let who: Vec<MultiAddressLike> = who.into_iter().map(|x| x.into()).collect();
		let who: Result<Vec<MultiAddress>, _> = who.into_iter().map(MultiAddress::try_from).collect();
		let who = who.expect("Malformed string is passed for AccountId");

		let value = avail::staking::tx::Kick { who };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Forces the commission for the given validator to the chain minimum.
	///
	/// # Panics
	/// Panics if `validator_stash` cannot be converted into an `AccountId`.
	///
	/// # Arguments
	/// * `validator_stash` - Stash account whose commission is being forced.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that enforces the minimum commission.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn force_apply_min_commission(&self, validator_stash: impl Into<AccountIdLike>) -> SubmittableTransaction {
		let validator_stash: AccountIdLike = validator_stash.into();
		let validator_stash = AccountId::try_from(validator_stash).expect("Malformed string is passed for AccountId");

		let value = avail::staking::tx::ForceApplyMinCommission { validator_stash };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Pays out staking rewards for a subset of nominators.
	///
	/// # Panics
	/// Panics if `validator_stash` cannot be converted into an `AccountId`.
	///
	/// # Arguments
	/// * `validator_stash` - Stash account whose rewards are being claimed.
	/// * `era` - Era for which rewards are paid.
	/// * `page` - Page index selecting which nominators to payout.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that triggers the paged payout.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn payout_stakers_by_page(
		&self,
		validator_stash: impl Into<AccountIdLike>,
		era: u32,
		page: u32,
	) -> SubmittableTransaction {
		let validator_stash: AccountIdLike = validator_stash.into();
		let validator_stash = AccountId::try_from(validator_stash).expect("Malformed string is passed for AccountId");

		let value = avail::staking::tx::PayoutStakersByPage { validator_stash, era, page };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}
}

/// Builds extrinsics for the `balances` pallet.
///
/// All helpers expect account identifiers that can be converted into `MultiAddress` values and will
/// panic if the conversion fails.
pub struct Balances(Client);
impl Balances {
	/// Transfers funds allowing the sender's account to be removed if depleted.
	///
	/// # Panics
	/// Panics if `dest` cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `dest` - Destination account receiving the transfer.
	/// * `amount` - Amount to transfer.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that performs the transfer.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn transfer_allow_death(&self, dest: impl Into<MultiAddressLike>, amount: u128) -> SubmittableTransaction {
		let dest: MultiAddressLike = dest.into();
		let dest: MultiAddress = dest.try_into().expect("Malformed string is passed for AccountId");

		let value = avail::balances::tx::TransferAllowDeath { dest, value: amount };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Transfers funds while keeping the sender's account alive.
	///
	/// # Panics
	/// Panics if `dest` cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `dest` - Destination account receiving the transfer.
	/// * `amount` - Amount to transfer.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that performs the keep-alive transfer.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn transfer_keep_alive(&self, dest: impl Into<MultiAddressLike>, amount: u128) -> SubmittableTransaction {
		let dest: MultiAddressLike = dest.into();
		let dest: MultiAddress = dest.try_into().expect("Malformed string is passed for AccountId");

		let value = avail::balances::tx::TransferKeepAlive { dest, value: amount };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Transfers the entire free balance to the destination.
	///
	/// # Panics
	/// Panics if `dest` cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `dest` - Destination account receiving the transfer.
	/// * `keep_alive` - When `true`, leaves the minimum balance to keep the account alive.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that transfers the full balance.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn transfer_all(&self, dest: impl Into<MultiAddressLike>, keep_alive: bool) -> SubmittableTransaction {
		let dest: MultiAddressLike = dest.into();
		let dest: MultiAddress = dest.try_into().expect("Malformed string is passed for AccountId");

		let value = avail::balances::tx::TransferAll { dest, keep_alive };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}
}

/// Builds extrinsics for the `multisig` pallet.
///
/// Helper methods convert `AccountIdLike` and `HashString` inputs into on-chain representations and
/// panic if the conversion fails; they also sort the provided signatories to match runtime
/// expectations.
pub struct Multisig(Client);
impl Multisig {
	/// Approves a multisig call by reference to its hash.
	///
	/// # Panics
	/// Panics if any signatory identifier fails to convert into an `AccountId` or if `call_hash`
	/// cannot be converted into `H256`.
	///
	/// # Arguments
	/// * `threshold` - Total number of approvals required to execute the call.
	/// * `other_signatories` - Remaining signatories excluding the caller.
	/// * `maybe_timepoint` - Optional timepoint identifying the in-progress multisig.
	/// * `call_hash` - Hash of the call being approved.
	/// * `max_weight` - Execution weight budget for the call.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that records the approval.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn approve_as_multi(
		&self,
		threshold: u16,
		other_signatories: Vec<impl Into<AccountIdLike>>,
		maybe_timepoint: Option<Timepoint>,
		call_hash: impl Into<HashString>,
		max_weight: Weight,
	) -> SubmittableTransaction {
		fn inner(
			client: Client,
			threshold: u16,
			other_signatories: Vec<AccountIdLike>,
			maybe_timepoint: Option<Timepoint>,
			call_hash: HashString,
			max_weight: Weight,
		) -> SubmittableTransaction {
			let other_signatories: Result<Vec<AccountId>, _> =
				other_signatories.into_iter().map(|x| x.try_into()).collect();
			let mut other_signatories = other_signatories.expect("Malformed string is passed for AccountId");
			other_signatories.sort();

			let call_hash: H256 = call_hash.try_into().expect("Malformed string is passed for H256");

			let value = avail::multisig::tx::ApproveAsMulti {
				threshold,
				other_signatories,
				maybe_timepoint,
				call_hash,
				max_weight,
			};
			SubmittableTransaction::from_encodable(client, value)
		}

		let other_signatories: Vec<AccountIdLike> = other_signatories.into_iter().map(|x| x.into()).collect();
		let call_hash: HashString = call_hash.into();
		inner(self.0.clone(), threshold, other_signatories, maybe_timepoint, call_hash, max_weight)
	}

	/// Executes a multisig call with full call data.
	///
	/// # Panics
	/// Panics if any signatory identifier fails to convert into an `AccountId`.
	///
	/// # Arguments
	/// * `threshold` - Total number of approvals required to execute the call.
	/// * `other_signatories` - Remaining signatories excluding the caller.
	/// * `maybe_timepoint` - Optional timepoint identifying the in-progress multisig.
	/// * `call` - Call payload to execute once approvals are satisfied.
	/// * `max_weight` - Execution weight budget for the call.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that submits the multisig call.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn as_multi(
		&self,
		threshold: u16,
		other_signatories: Vec<impl Into<AccountIdLike>>,
		maybe_timepoint: Option<Timepoint>,
		call: impl Into<ExtrinsicCall>,
		max_weight: Weight,
	) -> SubmittableTransaction {
		fn inner(
			client: Client,
			threshold: u16,
			other_signatories: Vec<AccountIdLike>,
			maybe_timepoint: Option<Timepoint>,
			call: ExtrinsicCall,
			max_weight: Weight,
		) -> SubmittableTransaction {
			let other_signatories: Result<Vec<AccountId>, _> =
				other_signatories.into_iter().map(|x| x.try_into()).collect();
			let mut other_signatories = other_signatories.expect("Malformed string is passed for AccountId");
			other_signatories.sort();

			let value = avail::multisig::tx::AsMulti {
				threshold,
				other_signatories,
				maybe_timepoint,
				call,
				max_weight,
			};
			SubmittableTransaction::from_encodable(client, value)
		}

		let other_signatories: Vec<AccountIdLike> = other_signatories.into_iter().map(|x| x.into()).collect();
		inner(self.0.clone(), threshold, other_signatories, maybe_timepoint, call.into(), max_weight)
	}

	/// Executes a multisig call with a threshold of one.
	///
	/// # Panics
	/// Panics if any signatory identifier fails to convert into an `AccountId`.
	///
	/// # Arguments
	/// * `other_signatories` - Remaining signatories excluding the caller; used to derive the multisig account.
	/// * `call` - Call payload to execute.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that executes the call with a threshold of one.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn as_multi_threshold_1(
		&self,
		other_signatories: Vec<impl Into<AccountIdLike>>,
		call: impl Into<ExtrinsicCall>,
	) -> SubmittableTransaction {
		fn inner(client: Client, other_signatories: Vec<AccountIdLike>, call: ExtrinsicCall) -> SubmittableTransaction {
			let other_signatories: Result<Vec<AccountId>, _> =
				other_signatories.into_iter().map(|x| x.try_into()).collect();
			let mut other_signatories = other_signatories.expect("Malformed string is passed for AccountId");
			other_signatories.sort();

			let value = avail::multisig::tx::AsMultiThreshold1 { other_signatories, call };
			SubmittableTransaction::from_encodable(client, value)
		}

		let other_signatories: Vec<AccountIdLike> = other_signatories.into_iter().map(|x| x.into()).collect();
		inner(self.0.clone(), other_signatories, call.into())
	}

	/// Cancels a previously scheduled multisig call.
	///
	/// # Panics
	/// Panics if any signatory identifier fails to convert into an `AccountId` or if `call_hash`
	/// cannot be converted into `H256`.
	///
	/// # Arguments
	/// * `threshold` - Total number of approvals required by the multisig.
	/// * `other_signatories` - Remaining signatories excluding the caller.
	/// * `timepoint` - Timepoint returned when the call was created.
	/// * `call_hash` - Hash of the call being cancelled.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that cancels the multisig operation.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn cancel_as_multi(
		&self,
		threshold: u16,
		other_signatories: Vec<impl Into<AccountIdLike>>,
		timepoint: Timepoint,
		call_hash: impl Into<HashString>,
	) -> SubmittableTransaction {
		fn inner(
			client: Client,
			threshold: u16,
			other_signatories: Vec<AccountIdLike>,
			timepoint: Timepoint,
			call_hash: HashString,
		) -> SubmittableTransaction {
			let other_signatories: Result<Vec<AccountId>, _> =
				other_signatories.into_iter().map(|x| x.try_into()).collect();
			let mut other_signatories = other_signatories.expect("Malformed string is passed for AccountId");
			other_signatories.sort();

			let call_hash: H256 = call_hash.try_into().expect("Malformed string is passed for H256");

			let value = avail::multisig::tx::CancelAsMulti { threshold, other_signatories, timepoint, call_hash };
			SubmittableTransaction::from_encodable(client, value)
		}

		let other_signatories: Vec<AccountIdLike> = other_signatories.into_iter().map(|x| x.into()).collect();
		let call_hash: HashString = call_hash.into();
		inner(self.0.clone(), threshold, other_signatories, timepoint, call_hash)
	}
}

/// Builds extrinsics for the `data_availability` pallet.
pub struct DataAvailability(Client);
impl DataAvailability {
	/// Registers a new application key for data availability submissions.
	///
	/// # Arguments
	/// * `key` - Application key bytes or string accepted by the runtime.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that registers the application key.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn create_application_key<'a>(&self, key: impl Into<StringOrBytes<'a>>) -> SubmittableTransaction {
		let key: Vec<u8> = Into::<StringOrBytes>::into(key).into();
		let value = avail::data_availability::tx::CreateApplicationKey { key };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Submits application data for availability guarantees.
	///
	/// # Arguments
	/// * `data` - Data payload to submit.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that submits the data for availability.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn submit_data<'a>(&self, data: impl Into<StringOrBytes<'a>>) -> SubmittableTransaction {
		let data: Vec<u8> = Into::<StringOrBytes>::into(data).into();
		let value = avail::data_availability::tx::SubmitData { data };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	#[cfg(feature = "next")]
	/// Submits metadata describing an out-of-band blob.
	///
	/// # Arguments
	/// * `blob_hash` - Hash identifying the blob payload.
	/// * `size` - Size of the blob in bytes.
	/// * `commitments` - Commitment bytes used for verification.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] ready to be signed and submitted.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn submit_blob_metadata(&self, blob_hash: H256, size: u64, commitments: Vec<u8>) -> SubmittableTransaction {
		let value = avail::data_availability::tx::SubmitBlobMetadata { blob_hash, size, commitments };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}
}

/// Builds extrinsics for the `utility` pallet.
pub struct Utility(Client);
impl Utility {
	/// Dispatches a set of calls sequentially, aborting on failure.
	///
	/// # Arguments
	/// * `calls` - Calls executed in sequence.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that batches the supplied calls.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn batch(&self, calls: Vec<impl Into<ExtrinsicCall>>) -> SubmittableTransaction {
		let mut batch = avail::utility::tx::Batch::new();
		batch.add_calls(calls.into_iter().map(|x| x.into()).collect());
		SubmittableTransaction::from_encodable(self.0.clone(), batch)
	}

	/// Dispatches a set of calls and reverts the whole batch if any fail.
	///
	/// # Arguments
	/// * `calls` - Calls executed atomically; any failure rolls back the batch.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that executes the all-or-nothing batch.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn batch_all(&self, calls: Vec<impl Into<ExtrinsicCall>>) -> SubmittableTransaction {
		let mut batch = avail::utility::tx::BatchAll::new();
		batch.add_calls(calls.into_iter().map(|x| x.into()).collect());
		SubmittableTransaction::from_encodable(self.0.clone(), batch)
	}

	/// Dispatches a set of calls while ignoring failures.
	///
	/// # Arguments
	/// * `calls` - Calls executed sequentially; individual failures are ignored.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that executes the tolerant batch.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn force_batch(&self, calls: Vec<impl Into<ExtrinsicCall>>) -> SubmittableTransaction {
		let mut batch = avail::utility::tx::ForceBatch::new();
		batch.add_calls(calls.into_iter().map(|x| x.into()).collect());
		SubmittableTransaction::from_encodable(self.0.clone(), batch)
	}
}

/// Builds extrinsics for the `proxy` pallet.
///
/// Methods converting `MultiAddressLike` parameters will panic if the provided values cannot be
/// decoded into `MultiAddress` instances.
pub struct Proxy(Client);
impl Proxy {
	/// Dispatches a call through an existing proxy relationship.
	///
	/// # Panics
	/// Panics if `id` cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `id` - Proxy account that will dispatch the call.
	/// * `force_proxy_type` - Optional proxy type override.
	/// * `call` - Call to execute through the proxy.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that executes the proxied call.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn proxy(
		&self,
		id: impl Into<MultiAddressLike>,
		force_proxy_type: Option<ProxyType>,
		call: impl Into<ExtrinsicCall>,
	) -> SubmittableTransaction {
		let id: MultiAddressLike = id.into();
		let id: MultiAddress = id.try_into().expect("Malformed string is passed for AccountId");

		let value = avail::proxy::tx::Proxy { id, force_proxy_type, call: call.into() };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Registers a new proxy delegate for the caller.
	///
	/// # Panics
	/// Panics if `id` cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `id` - Delegate account that gains proxy rights.
	/// * `proxy_type` - Proxy type applied to the delegate.
	/// * `delay` - Number of blocks the proxy must wait before first use.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that adds the proxy.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn add_proxy(
		&self,
		id: impl Into<MultiAddressLike>,
		proxy_type: ProxyType,
		delay: u32,
	) -> SubmittableTransaction {
		let id: MultiAddressLike = id.into();
		let id: MultiAddress = id.try_into().expect("Malformed string is passed for AccountId");

		let value = avail::proxy::tx::AddProxy { id, proxy_type, delay };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Removes a specific proxy delegate.
	///
	/// # Panics
	/// Panics if `delegate` cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `delegate` - Delegate being removed.
	/// * `proxy_type` - Proxy type to revoke.
	/// * `delay` - Expected delay recorded for the delegate.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that removes the proxy.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn remove_proxy(
		&self,
		delegate: impl Into<MultiAddressLike>,
		proxy_type: ProxyType,
		delay: u32,
	) -> SubmittableTransaction {
		let delegate: MultiAddressLike = delegate.into();
		let delegate: MultiAddress = delegate.try_into().expect("Malformed string is passed for AccountId");

		let value = avail::proxy::tx::RemoveProxy { delegate, proxy_type, delay };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Removes all proxies belonging to the caller.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that clears the caller's proxies.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn remove_proxies(&self) -> SubmittableTransaction {
		let value = avail::proxy::tx::RemoveProxies {};
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Creates a pure proxy account with the requested parameters.
	///
	/// # Arguments
	/// * `proxy_type` - Proxy type to associate with the pure proxy.
	/// * `delay` - Number of blocks the proxy must wait before use.
	/// * `index` - Index differentiating multiple pure proxies.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that spawns the pure proxy.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn create_pure(&self, proxy_type: ProxyType, delay: u32, index: u16) -> SubmittableTransaction {
		let value = avail::proxy::tx::CreatePure { proxy_type, delay, index };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Kills a pure proxy that was previously spawned by the provided account.
	///
	/// # Panics
	/// Panics if `spawner` cannot be converted into a `MultiAddress`.
	///
	/// # Arguments
	/// * `spawner` - Account that originally spawned the pure proxy.
	/// * `proxy_type` - Proxy type associated with the pure proxy.
	/// * `index` - Index of the pure proxy to kill.
	/// * `height` - Block height recorded at spawn time.
	/// * `ext_index` - Extrinsic index recorded at spawn time.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that destroys the pure proxy.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn kill_pure(
		&self,
		spawner: impl Into<MultiAddressLike>,
		proxy_type: ProxyType,
		index: u16,
		height: u32,
		ext_index: u32,
	) -> SubmittableTransaction {
		let spawner: MultiAddressLike = spawner.into();
		let spawner: MultiAddress = spawner.try_into().expect("Malformed string is passed for AccountId");

		let value = avail::proxy::tx::KillPure { spawner, proxy_type, index, height, ext_index };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}
}

/// Builds extrinsics for the `vector` pallet.
///
/// Several helpers convert hash-like parameters into `H256` values and will panic if the provided
/// data cannot be parsed.
pub struct Vector(Client);
impl Vector {
	/// Submits a fulfillment proof for a pending cross-chain call.
	///
	/// # Arguments
	/// * `function_id` - Identifier of the function being fulfilled.
	/// * `input` - Encoded input payload.
	/// * `output` - Encoded output payload.
	/// * `proof` - Proof bytes attesting to the fulfillment.
	/// * `slot` - Slot in which the message was queued.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that fulfills the cross-chain call.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn batch(
		&self,
		function_id: H256,
		input: Vec<u8>,
		output: Vec<u8>,
		proof: Vec<u8>,
		slot: u64,
	) -> SubmittableTransaction {
		let value = avail::vector::tx::FulfillCall { function_id, input, output, proof, slot };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Executes a vector addressed message with witness data.
	///
	/// # Arguments
	/// * `slot` - Slot to execute.
	/// * `addr_message` - Addressed message payload.
	/// * `account_proof` - Proof for the account tree.
	/// * `storage_proof` - Proof for the storage entries.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that executes the message.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn execute(
		&self,
		slot: u64,
		addr_message: avail::vector::types::AddressedMessage,
		account_proof: Vec<Vec<u8>>,
		storage_proof: Vec<Vec<u8>>,
	) -> SubmittableTransaction {
		let value = avail::vector::tx::Execute { slot, addr_message, account_proof, storage_proof };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Toggles whether a source chain is frozen.
	///
	/// # Arguments
	/// * `source_chain_id` - Identifier of the source chain.
	/// * `frozen` - Boolean indicating the desired freeze state.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that updates the frozen state.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn source_chain_froze(&self, source_chain_id: u32, frozen: bool) -> SubmittableTransaction {
		let value = avail::vector::tx::SourceChainFroze { source_chain_id, frozen };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Sends a vector message to the specified domain.
	///
	/// # Panics
	/// Panics if `to` cannot be converted into an `H256`.
	///
	/// # Arguments
	/// * `message` - Message payload to send.
	/// * `to` - Destination address encoded as a hash string.
	/// * `domain` - Destination domain identifier.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that enqueues the message.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn send_message(
		&self,
		message: avail::vector::types::Message,
		to: impl Into<HashString>,
		domain: u32,
	) -> SubmittableTransaction {
		let to: HashString = to.into();
		let to: H256 = to.try_into().expect("Malformed string is passed for H256");

		let value = avail::vector::tx::SendMessage { message, to, domain };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Marks previous outbound messages as failed by index.
	///
	/// # Arguments
	/// * `failed_txs` - Indices of failed outbound messages.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that records the failure.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn failed_send_message_txs(&self, failed_txs: Vec<u32>) -> SubmittableTransaction {
		let value = avail::vector::tx::FailedSendMessageTxs { failed_txs };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Updates the Poseidon hash commitment for a sync period.
	///
	/// # Arguments
	/// * `period` - Period identifier.
	/// * `poseidon_hash` - Poseidon hash commitment bytes.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that stores the commitment.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_poseidon_hash(&self, period: u64, poseidon_hash: Vec<u8>) -> SubmittableTransaction {
		let value = avail::vector::tx::SetPoseidonHash { period: period.into(), poseidon_hash };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Registers the broadcaster for a specific domain.
	///
	/// # Arguments
	/// * `broadcaster_domain` - Domain where the broadcaster operates.
	/// * `broadcaster` - Broadcaster identifier.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that sets the broadcaster.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_broadcaster(&self, broadcaster_domain: u32, broadcaster: H256) -> SubmittableTransaction {
		let value = avail::vector::tx::SetBroadcaster { broadcaster_domain: broadcaster_domain.into(), broadcaster };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Overwrites the set of domains allowed to send messages.
	///
	/// # Arguments
	/// * `value` - Domains permitted to send messages.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that updates the whitelist.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_whitelisted_domains(&self, value: Vec<u32>) -> SubmittableTransaction {
		let value = avail::vector::tx::SetWhitelistedDomains { value };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Updates the vector configuration parameters.
	///
	/// # Arguments
	/// * `value` - Configuration structure applied to the pallet.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that stores the configuration.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_configuration(&self, value: avail::vector::types::Configuration) -> SubmittableTransaction {
		let value = avail::vector::tx::SetConfiguration { value };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Updates the function identifiers used by the pallet.
	///
	/// # Arguments
	/// * `value` - Optional tuple containing new function identifiers.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that records the identifiers.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_function_ids(&self, value: Option<(H256, H256)>) -> SubmittableTransaction {
		let value = avail::vector::tx::SetFunctionIds { value };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Sets the verification key for the step circuit.
	///
	/// # Arguments
	/// * `value` - Optional verification key bytes.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that updates the verification key.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_step_verification_key(&self, value: Option<Vec<u8>>) -> SubmittableTransaction {
		let value = avail::vector::tx::SetStepVerificationKey { value };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Updates the updater account hash.
	///
	/// # Arguments
	/// * `updater` - New updater hash.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that stores the updater hash.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_updater(&self, updater: H256) -> SubmittableTransaction {
		let value = avail::vector::tx::SetUpdater { updater };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Submits a zero-knowledge proof fulfilling a pending message.
	///
	/// # Arguments
	/// * `proof` - Proof bytes attesting to message fulfillment.
	/// * `public_values` - Public inputs used during verification.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that fulfills the message.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn fulfill(&self, proof: Vec<u8>, public_values: Vec<u8>) -> SubmittableTransaction {
		let value = avail::vector::tx::Fulfill { proof, public_values };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Sets the verification key for SP1 proofs.
	///
	/// # Arguments
	/// * `sp1_vk` - SP1 verification key hash.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that stores the key.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_sp1_verification_key(&self, sp1_vk: H256) -> SubmittableTransaction {
		let value = avail::vector::tx::SetSp1VerificationKey { sp1_vk };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Updates the sync committee hash for the provided period.
	///
	/// # Arguments
	/// * `period` - Period identifier.
	/// * `hash` - New sync committee hash.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that stores the sync committee hash.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_sync_committee_hash(&self, period: u64, hash: H256) -> SubmittableTransaction {
		let value = avail::vector::tx::SetSyncCommitteeHash { period, hash };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Enables or disables mock execution mode.
	///
	/// # Arguments
	/// * `value` - `true` to enable mock mode, `false` to disable.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that toggles mock mode.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn enable_mock(&self, value: bool) -> SubmittableTransaction {
		let value = avail::vector::tx::EnableMock { value };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Fulfills a message when running in mock mode.
	///
	/// # Arguments
	/// * `public_values` - Mock public values consumed by the fulfillment.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that fulfills the message in mock mode.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn mock_fulfill(&self, public_values: Vec<u8>) -> SubmittableTransaction {
		let value = avail::vector::tx::MockFulfill { public_values };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}
}

/// Builds extrinsics for the `system` pallet.
pub struct System(Client);
impl System {
	/// Emits a remark event containing arbitrary bytes.
	///
	/// # Arguments
	/// * `remark` - Payload recorded on chain.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that emits the remark.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn remark(&self, remark: Vec<u8>) -> SubmittableTransaction {
		let value = avail::system::tx::Remark { remark };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Replaces the runtime code with a new version.
	///
	/// # Arguments
	/// * `code` - WASM runtime bytecode.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that schedules the code upgrade.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_code(&self, code: Vec<u8>) -> SubmittableTransaction {
		let value = avail::system::tx::SetCode { code };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Replaces the runtime code without performing standard checks.
	///
	/// # Arguments
	/// * `code` - WASM runtime bytecode.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that forces the code upgrade.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn set_code_without_checks(&self, code: Vec<u8>) -> SubmittableTransaction {
		let value = avail::system::tx::SetCodeWithoutChecks { code };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}

	/// Emits a remark while guaranteeing an event is produced.
	///
	/// # Arguments
	/// * `remark` - Payload recorded on chain.
	///
	/// # Returns
	/// Returns a [`SubmittableTransaction`] that emits the remark alongside an event.
	///
	/// # Errors
	/// Does not perform network calls; transaction construction never fails.
	pub fn remark_with_event(&self, remark: Vec<u8>) -> SubmittableTransaction {
		let value = avail::system::tx::RemarkWithEvent { remark };
		SubmittableTransaction::from_encodable(self.0.clone(), value)
	}
}