alloy_sol_types/abi/
encoder.rs

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
// Copyright 2015-2020 Parity Technologies
// Copyright 2023-2023 Alloy Contributors
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use crate::{
    abi::{Token, TokenSeq},
    utils, Word,
};
use alloc::vec::Vec;
use core::{mem, ptr};

/// An ABI encoder.
///
/// This is not intended for public consumption. It should be used only by the
/// token types. If you have found yourself here, you probably want to use the
/// high-level [`crate::SolType`] interface (or its dynamic equivalent) instead.
#[derive(Clone, Debug, Default)]
pub struct Encoder {
    buf: Vec<Word>,
    suffix_offset: Vec<usize>,
}

impl Encoder {
    /// Instantiate a new empty encoder.
    #[inline]
    pub const fn new() -> Self {
        Self { buf: Vec::new(), suffix_offset: Vec::new() }
    }

    /// Instantiate a new encoder with a given capacity in words.
    #[inline]
    pub fn with_capacity(size: usize) -> Self {
        Self {
            buf: Vec::with_capacity(size),
            // Note: this has to be non-zero even if it won't get used. The compiler will optimize
            // it out, but it won't for `Vec::new` (??).
            suffix_offset: Vec::with_capacity(4),
        }
    }

    /// Finish the encoding process, returning the encoded words.
    ///
    /// Use `into_bytes` instead to flatten the words into bytes.
    // https://github.com/rust-lang/rust-clippy/issues/4979
    #[allow(clippy::missing_const_for_fn)]
    #[inline]
    pub fn finish(self) -> Vec<Word> {
        self.buf
    }

    /// Finish the encoding process, returning the encoded bytes.
    #[inline]
    pub fn into_bytes(self) -> Vec<u8> {
        // TODO: remove once `Vec::into_flattened` is stabilized.
        // unsafe { mem::transmute::<Vec<_>, Vec<[u8; 32]>>(self.buf) }.into_flattened()

        // SAFETY: `#[repr(transparent)] FixedBytes<N>([u8; N])`
        crate::impl_core::into_flattened::<u8, 32>(unsafe {
            mem::transmute::<Vec<Word>, Vec<[u8; 32]>>(self.buf)
        })
    }

    /// Determine the current suffix offset.
    ///
    /// # Panics
    ///
    /// Panics if there is no current suffix offset.
    #[inline]
    #[cfg_attr(debug_assertions, track_caller)]
    pub fn suffix_offset(&self) -> usize {
        debug_assert!(!self.suffix_offset.is_empty());
        unsafe { *self.suffix_offset.last().unwrap_unchecked() }
    }

    /// Appends a suffix offset.
    #[inline]
    pub fn push_offset(&mut self, words: usize) {
        self.suffix_offset.push(words * 32);
    }

    /// Removes the last offset and returns it.
    #[inline]
    pub fn pop_offset(&mut self) -> Option<usize> {
        self.suffix_offset.pop()
    }

    /// Bump the suffix offset by a given number of words.
    #[inline]
    pub fn bump_offset(&mut self, words: usize) {
        if let Some(last) = self.suffix_offset.last_mut() {
            *last += words * 32;
        }
    }

    /// Append a word to the encoder.
    #[inline]
    pub fn append_word(&mut self, word: Word) {
        self.buf.push(word);
    }

    /// Append a pointer to the current suffix offset.
    ///
    /// # Panics
    ///
    /// Panics if there is no current suffix offset.
    #[inline]
    #[cfg_attr(debug_assertions, track_caller)]
    pub fn append_indirection(&mut self) {
        self.append_word(utils::pad_usize(self.suffix_offset()));
    }

    /// Append a sequence length.
    #[inline]
    pub fn append_seq_len(&mut self, len: usize) {
        self.append_word(utils::pad_usize(len));
    }

    /// Append a sequence of bytes as a packed sequence with a length prefix.
    #[inline]
    pub fn append_packed_seq(&mut self, bytes: &[u8]) {
        self.append_seq_len(bytes.len());
        self.append_bytes(bytes);
    }

    /// Shortcut for appending a token sequence.
    #[inline]
    pub fn append_head_tail<'a, T: TokenSeq<'a>>(&mut self, token: &T) {
        token.encode_sequence(self);
    }

    /// Append a sequence of bytes, padding to the next word.
    #[inline(always)]
    fn append_bytes(&mut self, bytes: &[u8]) {
        if bytes.is_empty() {
            return;
        }

        let n_words = utils::words_for(bytes);
        self.buf.reserve(n_words);
        unsafe {
            // set length before copying
            // this is fine because we reserved above and we don't panic below
            let len = self.buf.len();
            self.buf.set_len(len + n_words);

            // copy
            let cnt = bytes.len();
            let dst = self.buf.as_mut_ptr().add(len).cast::<u8>();
            ptr::copy_nonoverlapping(bytes.as_ptr(), dst, cnt);

            // set remaining bytes to zero if necessary
            let rem = cnt % 32;
            if rem != 0 {
                let pad = 32 - rem;
                ptr::write_bytes(dst.add(cnt), 0, pad);
            }
        }
    }
}

/// ABI-encodes a single token.
///
/// You are probably looking for
/// [`SolValue::abi_encode`](crate::SolValue::abi_encode) if
/// you are not intending to use raw tokens.
///
/// See the [`abi`](super) module for more information.
#[inline(always)]
pub fn encode<'a, T: Token<'a>>(token: &T) -> Vec<u8> {
    encode_sequence::<(T,)>(tuple_from_ref(token))
}

/// ABI-encodes a tuple as ABI function params, suitable for passing to a
/// function.
///
/// You are probably looking for
/// [`SolValue::abi_encode_params`](crate::SolValue::abi_encode_params) if
/// you are not intending to use raw tokens.
///
/// See the [`abi`](super) module for more information.
#[inline(always)]
pub fn encode_params<'a, T: TokenSeq<'a>>(token: &T) -> Vec<u8> {
    let encode = const {
        if T::IS_TUPLE {
            encode_sequence
        } else {
            encode
        }
    };
    encode(token)
}

/// ABI-encodes a token sequence.
///
/// You are probably looking for
/// [`SolValue::abi_encode_sequence`](crate::SolValue::abi_encode_sequence) if
/// you are not intending to use raw tokens.
///
/// See the [`abi`](super) module for more information.
#[inline]
pub fn encode_sequence<'a, T: TokenSeq<'a>>(token: &T) -> Vec<u8> {
    let mut enc = Encoder::with_capacity(token.total_words());
    enc.append_head_tail(token);
    enc.into_bytes()
}

/// Converts a reference to `T` into a reference to a tuple of length 1 (without
/// copying).
///
/// Same as [`core::array::from_ref`].
#[inline(always)]
const fn tuple_from_ref<T>(s: &T) -> &(T,) {
    // SAFETY: Converting `&T` to `&(T,)` is sound.
    unsafe { &*(s as *const T).cast::<(T,)>() }
}

#[cfg(test)]
mod tests {
    use crate::{sol_data, SolType};
    use alloc::{borrow::ToOwned, string::ToString, vec::Vec};
    use alloy_primitives::{address, bytes, hex, Address, U256};
    use alloy_sol_macro::sol;

    #[test]
    fn encode_address() {
        let address = Address::from([0x11u8; 20]);
        let expected = hex!("0000000000000000000000001111111111111111111111111111111111111111");
        let encoded = sol_data::Address::abi_encode(&address);
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), sol_data::Address::abi_encoded_size(&address));
    }

    #[test]
    fn encode_dynamic_array_of_addresses() {
        type MyTy = sol_data::Array<sol_data::Address>;
        let data = vec![Address::from([0x11u8; 20]), Address::from([0x22u8; 20])];
        let encoded = MyTy::abi_encode(&data);
        let expected = hex!(
            "
			0000000000000000000000000000000000000000000000000000000000000020
			0000000000000000000000000000000000000000000000000000000000000002
			0000000000000000000000001111111111111111111111111111111111111111
			0000000000000000000000002222222222222222222222222222222222222222
		"
        );
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_fixed_array_of_addresses() {
        type MyTy = sol_data::FixedArray<sol_data::Address, 2>;

        let addresses = [Address::from([0x11u8; 20]), Address::from([0x22u8; 20])];

        let encoded = MyTy::abi_encode(&addresses);
        let encoded_params = MyTy::abi_encode_params(&addresses);
        let expected = hex!(
            "
    		0000000000000000000000001111111111111111111111111111111111111111
    		0000000000000000000000002222222222222222222222222222222222222222
    	"
        );
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&addresses));
    }

    #[test]
    fn encode_two_addresses() {
        type MyTy = (sol_data::Address, sol_data::Address);
        let addresses = (Address::from([0x11u8; 20]), Address::from([0x22u8; 20]));

        let encoded = MyTy::abi_encode_sequence(&addresses);
        let encoded_params = MyTy::abi_encode_params(&addresses);
        let expected = hex!(
            "
    		0000000000000000000000001111111111111111111111111111111111111111
    		0000000000000000000000002222222222222222222222222222222222222222
    	"
        );
        assert_eq!(encoded, expected);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&addresses));
    }

    #[test]
    fn encode_fixed_array_of_dynamic_array_of_addresses() {
        type MyTy = sol_data::FixedArray<sol_data::Array<sol_data::Address>, 2>;
        let data = [
            vec![Address::from([0x11u8; 20]), Address::from([0x22u8; 20])],
            vec![Address::from([0x33u8; 20]), Address::from([0x44u8; 20])],
        ];

        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000040
    		00000000000000000000000000000000000000000000000000000000000000a0
    		0000000000000000000000000000000000000000000000000000000000000002
    		0000000000000000000000001111111111111111111111111111111111111111
    		0000000000000000000000002222222222222222222222222222222222222222
    		0000000000000000000000000000000000000000000000000000000000000002
    		0000000000000000000000003333333333333333333333333333333333333333
    		0000000000000000000000004444444444444444444444444444444444444444
    	"
        );
        let encoded = MyTy::abi_encode(&data);
        assert_eq!(encoded, expected);
        let encoded_params = MyTy::abi_encode_params(&data);
        assert_eq!(encoded_params, expected);

        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_dynamic_array_of_fixed_array_of_addresses() {
        type TwoAddrs = sol_data::FixedArray<sol_data::Address, 2>;
        type MyTy = sol_data::Array<TwoAddrs>;

        let data = vec![
            [Address::from([0x11u8; 20]), Address::from([0x22u8; 20])],
            [Address::from([0x33u8; 20]), Address::from([0x44u8; 20])],
        ];

        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000002
    		0000000000000000000000001111111111111111111111111111111111111111
    		0000000000000000000000002222222222222222222222222222222222222222
    		0000000000000000000000003333333333333333333333333333333333333333
    		0000000000000000000000004444444444444444444444444444444444444444
    	"
        );
        // a DynSeq at top level ALWAYS has extra indirection
        let encoded = MyTy::abi_encode(&data);
        assert_eq!(encoded, expected);
        let encoded_params = MyTy::abi_encode_params(&data);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_dynamic_array_of_dynamic_arrays() {
        type MyTy = sol_data::Array<sol_data::Array<sol_data::Address>>;

        let data = vec![vec![Address::from([0x11u8; 20])], vec![Address::from([0x22u8; 20])]];

        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000002
    		0000000000000000000000000000000000000000000000000000000000000040
    		0000000000000000000000000000000000000000000000000000000000000080
    		0000000000000000000000000000000000000000000000000000000000000001
    		0000000000000000000000001111111111111111111111111111111111111111
    		0000000000000000000000000000000000000000000000000000000000000001
    		0000000000000000000000002222222222222222222222222222222222222222
    	"
        );
        // a DynSeq at top level ALWAYS has extra indirection
        let encoded = MyTy::abi_encode(&data);
        assert_eq!(encoded, expected);
        let encoded_params = MyTy::abi_encode_params(&data);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_dynamic_array_of_dynamic_arrays2() {
        type MyTy = sol_data::Array<sol_data::Array<sol_data::Address>>;

        let data = vec![
            vec![Address::from([0x11u8; 20]), Address::from([0x22u8; 20])],
            vec![Address::from([0x33u8; 20]), Address::from([0x44u8; 20])],
        ];
        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000002
    		0000000000000000000000000000000000000000000000000000000000000040
    		00000000000000000000000000000000000000000000000000000000000000a0
    		0000000000000000000000000000000000000000000000000000000000000002
    		0000000000000000000000001111111111111111111111111111111111111111
    		0000000000000000000000002222222222222222222222222222222222222222
    		0000000000000000000000000000000000000000000000000000000000000002
    		0000000000000000000000003333333333333333333333333333333333333333
    		0000000000000000000000004444444444444444444444444444444444444444
    	"
        );
        // a DynSeq at top level ALWAYS has extra indirection
        let encoded = MyTy::abi_encode(&data);
        assert_eq!(encoded, expected);
        let encoded_params = MyTy::abi_encode_params(&data);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_fixed_array_of_fixed_arrays() {
        type MyTy = sol_data::FixedArray<sol_data::FixedArray<sol_data::Address, 2>, 2>;

        let fixed = [
            [Address::from([0x11u8; 20]), Address::from([0x22u8; 20])],
            [Address::from([0x33u8; 20]), Address::from([0x44u8; 20])],
        ];

        let encoded = MyTy::abi_encode_sequence(&fixed);
        let encoded_params = MyTy::abi_encode_params(&fixed);
        let expected = hex!(
            "
    		0000000000000000000000001111111111111111111111111111111111111111
    		0000000000000000000000002222222222222222222222222222222222222222
    		0000000000000000000000003333333333333333333333333333333333333333
    		0000000000000000000000004444444444444444444444444444444444444444
    	"
        );
        // a non-dynamic FixedSeq at top level NEVER has extra indirection
        assert_eq!(encoded, expected);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&fixed));
    }

    #[test]
    fn encode_fixed_array_of_static_tuples_followed_by_dynamic_type() {
        type Tup = (sol_data::Uint<256>, sol_data::Uint<256>, sol_data::Address);
        type Fixed = sol_data::FixedArray<Tup, 2>;
        type MyTy = (Fixed, sol_data::String);

        let data = (
            [
                (U256::from(93523141), U256::from(352332135), Address::from([0x44u8; 20])),
                (U256::from(12411), U256::from(451), Address::from([0x22u8; 20])),
            ],
            "gavofyork".to_string(),
        );

        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000005930cc5
    		0000000000000000000000000000000000000000000000000000000015002967
    		0000000000000000000000004444444444444444444444444444444444444444
    		000000000000000000000000000000000000000000000000000000000000307b
    		00000000000000000000000000000000000000000000000000000000000001c3
    		0000000000000000000000002222222222222222222222222222222222222222
    		00000000000000000000000000000000000000000000000000000000000000e0
    		0000000000000000000000000000000000000000000000000000000000000009
    		6761766f66796f726b0000000000000000000000000000000000000000000000
    	"
        );

        let encoded = MyTy::abi_encode(&data);
        let encoded_params = MyTy::abi_encode_params(&data);
        assert_ne!(encoded, expected);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_empty_array() {
        type MyTy0 = sol_data::Array<sol_data::Address>;

        let data: Vec<Address> = vec![];

        // Empty arrays
        let encoded = MyTy0::abi_encode_params(&data);
        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000000
    	    "
        );

        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), MyTy0::abi_encoded_size(&data));

        type MyTy = (sol_data::Array<sol_data::Address>, sol_data::Array<sol_data::Address>);
        let data: (Vec<Address>, Vec<Address>) = (vec![], vec![]);

        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000040
    		0000000000000000000000000000000000000000000000000000000000000060
    		0000000000000000000000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000000
    	    "
        );

        // Empty arrays
        let encoded = MyTy::abi_encode(&data);
        assert_ne!(encoded, expected);

        let encoded_params = MyTy::abi_encode_params(&data);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded_params.len() + 32, encoded.len());
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));

        type MyTy2 = (
            sol_data::Array<sol_data::Array<sol_data::Address>>,
            sol_data::Array<sol_data::Array<sol_data::Address>>,
        );

        let data: (Vec<Vec<Address>>, Vec<Vec<Address>>) = (vec![vec![]], vec![vec![]]);

        // Nested empty arrays
        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000040
    		00000000000000000000000000000000000000000000000000000000000000a0
    		0000000000000000000000000000000000000000000000000000000000000001
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000001
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000000
    	"
        );
        // A Dynamic FixedSeq may be a top-level sequence to `encode` or may
        // itself be an item in a top-level sequence. Which is to say, it could
        // be (as `abi_encode(T)` or `abi_encode((T,))`). This test was `abi_encode(T)`
        let encoded = MyTy2::abi_encode(&data);
        assert_ne!(encoded, expected);
        let encoded_params = MyTy2::abi_encode_params(&data);

        assert_eq!(encoded_params, expected);
        assert_eq!(encoded_params.len() + 32, encoded.len());
        assert_eq!(encoded.len(), MyTy2::abi_encoded_size(&data));
    }

    #[test]
    fn encode_empty_bytes() {
        let bytes = Vec::<u8>::new();

        let encoded = sol_data::Bytes::abi_encode(&bytes);
        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000000
    	"
        );
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), sol_data::Bytes::abi_encoded_size(&bytes));
    }

    #[test]
    fn encode_bytes() {
        let bytes = vec![0x12, 0x34];

        let encoded = sol_data::Bytes::abi_encode(&bytes);
        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000002
    		1234000000000000000000000000000000000000000000000000000000000000
    	"
        );
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), sol_data::Bytes::abi_encoded_size(&bytes));
    }

    #[test]
    fn encode_fixed_bytes() {
        let encoded = sol_data::FixedBytes::<2>::abi_encode(&[0x12, 0x34]);
        let expected = hex!("1234000000000000000000000000000000000000000000000000000000000000");
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), sol_data::FixedBytes::<2>::abi_encoded_size(&[0x12, 0x34]));
    }

    #[test]
    fn encode_empty_string() {
        let s = "";
        let encoded = sol_data::String::abi_encode(s);
        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000000
    	"
        );
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), sol_data::String::abi_encoded_size(&s));
    }

    #[test]
    fn encode_string() {
        let s = "gavofyork".to_string();
        let encoded = sol_data::String::abi_encode(&s);
        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000009
    		6761766f66796f726b0000000000000000000000000000000000000000000000
    	"
        );
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), sol_data::String::abi_encoded_size(&s));
    }

    #[test]
    fn encode_bytes2() {
        let bytes = hex!("10000000000000000000000000000000000000000000000000000000000002").to_vec();
        let encoded = sol_data::Bytes::abi_encode(&bytes);
        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		000000000000000000000000000000000000000000000000000000000000001f
    		1000000000000000000000000000000000000000000000000000000000000200
    	"
        );
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), sol_data::Bytes::abi_encoded_size(&bytes));
    }

    #[test]
    fn encode_bytes3() {
        let bytes = hex!(
            "
    		1000000000000000000000000000000000000000000000000000000000000000
    		1000000000000000000000000000000000000000000000000000000000000000
    	"
        );
        let encoded = sol_data::Bytes::abi_encode(&bytes);
        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000040
    		1000000000000000000000000000000000000000000000000000000000000000
    		1000000000000000000000000000000000000000000000000000000000000000
    	"
        );
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), sol_data::Bytes::abi_encoded_size(&bytes));
    }

    #[test]
    fn encode_two_bytes() {
        type MyTy = (sol_data::Bytes, sol_data::Bytes);

        let bytes = (
            hex!("10000000000000000000000000000000000000000000000000000000000002").to_vec(),
            hex!("0010000000000000000000000000000000000000000000000000000000000002").to_vec(),
        );
        let encoded = MyTy::abi_encode(&bytes);
        let encoded_params = MyTy::abi_encode_params(&bytes);
        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000040
    		0000000000000000000000000000000000000000000000000000000000000080
    		000000000000000000000000000000000000000000000000000000000000001f
    		1000000000000000000000000000000000000000000000000000000000000200
    		0000000000000000000000000000000000000000000000000000000000000020
    		0010000000000000000000000000000000000000000000000000000000000002
    	"
        );
        // A Dynamic FixedSeq may be a top-level sequence to `encode` or may
        // itself be an item in a top-level sequence. Which is to say, it could
        // be (as `abi_encode(T)` or `abi_encode((T,))`). This test was `abi_encode(T)`
        assert_ne!(encoded, expected);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded_params.len() + 32, encoded.len());
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&bytes));
    }

    #[test]
    fn encode_uint() {
        let uint = 4;
        let encoded = sol_data::Uint::<8>::abi_encode(&uint);
        let expected = hex!("0000000000000000000000000000000000000000000000000000000000000004");
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), sol_data::Uint::<8>::abi_encoded_size(&uint));
    }

    #[test]
    fn encode_int() {
        let int = 4;
        let encoded = sol_data::Int::<8>::abi_encode(&int);
        let expected = hex!("0000000000000000000000000000000000000000000000000000000000000004");
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), sol_data::Int::<8>::abi_encoded_size(&int));
    }

    #[test]
    fn encode_bool() {
        let encoded = sol_data::Bool::abi_encode(&true);
        let expected = hex!("0000000000000000000000000000000000000000000000000000000000000001");
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), sol_data::Bool::abi_encoded_size(&true));
    }

    #[test]
    fn encode_bool2() {
        let encoded = sol_data::Bool::abi_encode(&false);
        let expected = hex!("0000000000000000000000000000000000000000000000000000000000000000");
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len(), sol_data::Bool::abi_encoded_size(&false));
    }

    #[test]
    fn comprehensive_test() {
        type MyTy = (sol_data::Uint<8>, sol_data::Bytes, sol_data::Uint<8>, sol_data::Bytes);

        let bytes = hex!(
            "
    		131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b
    		131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b
    	"
        );

        let data = (5, bytes, 3, bytes);

        let encoded = MyTy::abi_encode(&data);
        let encoded_params = MyTy::abi_encode_params(&data);

        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000005
    		0000000000000000000000000000000000000000000000000000000000000080
    		0000000000000000000000000000000000000000000000000000000000000003
    		00000000000000000000000000000000000000000000000000000000000000e0
    		0000000000000000000000000000000000000000000000000000000000000040
    		131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b
    		131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b
    		0000000000000000000000000000000000000000000000000000000000000040
    		131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b
    		131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b
    	"
        );
        // A Dynamic FixedSeq may be a top-level sequence to `encode` or may
        // itself be an item in a top-level sequence. Which is to say, it could
        // be (as `abi_encode(T)` or `abi_encode((T,))`). This test was `abi_encode(T)`
        assert_ne!(encoded, expected);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded_params.len() + 32, encoded.len());
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn comprehensive_test2() {
        type MyTy = (
            sol_data::Bool,
            sol_data::String,
            sol_data::Uint<8>,
            sol_data::Uint<8>,
            sol_data::Uint<8>,
            sol_data::Array<sol_data::Uint<8>>,
        );

        let data = (true, "gavofyork".to_string(), 2, 3, 4, vec![5, 6, 7]);

        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000001
    		00000000000000000000000000000000000000000000000000000000000000c0
    		0000000000000000000000000000000000000000000000000000000000000002
    		0000000000000000000000000000000000000000000000000000000000000003
    		0000000000000000000000000000000000000000000000000000000000000004
    		0000000000000000000000000000000000000000000000000000000000000100
    		0000000000000000000000000000000000000000000000000000000000000009
    		6761766f66796f726b0000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000003
    		0000000000000000000000000000000000000000000000000000000000000005
    		0000000000000000000000000000000000000000000000000000000000000006
    		0000000000000000000000000000000000000000000000000000000000000007
    	"
        );
        // A Dynamic FixedSeq may be a top-level sequence to `encode` or may
        // itself be an item in a top-level sequence. Which is to say, it could
        // be (as `abi_encode(T)` or `abi_encode((T,))`). This test was `abi_encode(T)`
        let encoded = MyTy::abi_encode(&data);
        assert_ne!(encoded, expected);
        let encoded_params = MyTy::abi_encode_params(&data);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded_params.len() + 32, encoded.len());
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_dynamic_array_of_bytes() {
        type MyTy = sol_data::Array<sol_data::Bytes>;
        let data = vec![hex!(
            "019c80031b20d5e69c8093a571162299032018d913930d93ab320ae5ea44a4218a274f00d607"
        )
        .to_vec()];

        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000001
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000026
    		019c80031b20d5e69c8093a571162299032018d913930d93ab320ae5ea44a421
    		8a274f00d6070000000000000000000000000000000000000000000000000000
    	"
        );
        // a DynSeq at top level ALWAYS has extra indirection
        let encoded = MyTy::abi_encode(&data);
        assert_eq!(encoded, expected);
        let encoded_params = MyTy::abi_encode_params(&data);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_dynamic_array_of_bytes2() {
        type MyTy = sol_data::Array<sol_data::Bytes>;

        let data = vec![
            hex!("4444444444444444444444444444444444444444444444444444444444444444444444444444")
                .to_vec(),
            hex!("6666666666666666666666666666666666666666666666666666666666666666666666666666")
                .to_vec(),
        ];

        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000002
    		0000000000000000000000000000000000000000000000000000000000000040
    		00000000000000000000000000000000000000000000000000000000000000a0
    		0000000000000000000000000000000000000000000000000000000000000026
    		4444444444444444444444444444444444444444444444444444444444444444
    		4444444444440000000000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000026
    		6666666666666666666666666666666666666666666666666666666666666666
    		6666666666660000000000000000000000000000000000000000000000000000
    	"
        );
        // a DynSeq at top level ALWAYS has extra indirection
        let encoded = MyTy::abi_encode(&data);
        assert_eq!(encoded, expected);
        let encoded_params = MyTy::abi_encode_params(&data);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_static_tuple_of_addresses() {
        type MyTy = (sol_data::Address, sol_data::Address);
        let data = (Address::from([0x11u8; 20]), Address::from([0x22u8; 20]));

        let encoded = MyTy::abi_encode_sequence(&data);
        let encoded_params = MyTy::abi_encode_params(&data);

        let expected = hex!(
            "
    		0000000000000000000000001111111111111111111111111111111111111111
    		0000000000000000000000002222222222222222222222222222222222222222
    	"
        );
        assert_eq!(encoded, expected);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_dynamic_tuple() {
        type MyTy = (sol_data::String, sol_data::String);
        let data = ("gavofyork".to_string(), "gavofyork".to_string());

        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000040
    		0000000000000000000000000000000000000000000000000000000000000080
    		0000000000000000000000000000000000000000000000000000000000000009
    		6761766f66796f726b0000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000009
    		6761766f66796f726b0000000000000000000000000000000000000000000000
    	"
        );
        // a dynamic FixedSeq at top level should start with indirection
        // when not param encoded.
        let encoded = MyTy::abi_encode(&data);
        assert_eq!(encoded, expected);
        let encoded_params = MyTy::abi_encode_params(&data);
        assert_ne!(encoded_params, expected);
        assert_eq!(encoded_params.len() + 32, encoded.len());
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_dynamic_tuple_of_bytes2() {
        type MyTy = (sol_data::Bytes, sol_data::Bytes);

        let data = (
            hex!("4444444444444444444444444444444444444444444444444444444444444444444444444444")
                .to_vec(),
            hex!("6666666666666666666666666666666666666666666666666666666666666666666666666666")
                .to_vec(),
        );

        let encoded = MyTy::abi_encode(&data);
        let encoded_params = MyTy::abi_encode_params(&data);

        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000040
    		00000000000000000000000000000000000000000000000000000000000000a0
    		0000000000000000000000000000000000000000000000000000000000000026
    		4444444444444444444444444444444444444444444444444444444444444444
    		4444444444440000000000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000026
    		6666666666666666666666666666666666666666666666666666666666666666
    		6666666666660000000000000000000000000000000000000000000000000000
    	"
        );
        // a dynamic FixedSeq at top level should start with indirection
        // when not param encoded.
        assert_eq!(encoded, expected);
        assert_ne!(encoded_params, expected);
        assert_eq!(encoded_params.len() + 32, encoded.len());
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_complex_tuple() {
        type MyTy = (sol_data::Uint<256>, sol_data::String, sol_data::Address, sol_data::Address);

        let data = (
            U256::from_be_bytes::<32>([0x11u8; 32]),
            "gavofyork".to_owned(),
            Address::from([0x11u8; 20]),
            Address::from([0x22u8; 20]),
        );

        let expected = hex!(
            "
            0000000000000000000000000000000000000000000000000000000000000020
            1111111111111111111111111111111111111111111111111111111111111111
            0000000000000000000000000000000000000000000000000000000000000080
            0000000000000000000000001111111111111111111111111111111111111111
    		0000000000000000000000002222222222222222222222222222222222222222
    		0000000000000000000000000000000000000000000000000000000000000009
    		6761766f66796f726b0000000000000000000000000000000000000000000000
    	"
        );
        // a dynamic FixedSeq at top level should start with indirection
        // when not param encoded.
        let encoded = MyTy::abi_encode(&data);
        assert_eq!(encoded, expected);
        let encoded_params = MyTy::abi_encode_params(&data);
        assert_ne!(encoded_params, expected);
        assert_eq!(encoded_params.len() + 32, encoded.len());
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_nested_tuple() {
        type MyTy = (
            sol_data::String,
            sol_data::Bool,
            sol_data::String,
            (sol_data::String, sol_data::String, (sol_data::String, sol_data::String)),
        );

        let data = (
            "test".to_string(),
            true,
            "cyborg".to_string(),
            ("night".to_string(), "day".to_string(), ("weee".to_string(), "funtests".to_string())),
        );

        let encoded = MyTy::abi_encode(&data);
        let encoded_params = MyTy::abi_encode_sequence(&data);

        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000080
    		0000000000000000000000000000000000000000000000000000000000000001
    		00000000000000000000000000000000000000000000000000000000000000c0
    		0000000000000000000000000000000000000000000000000000000000000100
    		0000000000000000000000000000000000000000000000000000000000000004
    		7465737400000000000000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000006
    		6379626f72670000000000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000060
    		00000000000000000000000000000000000000000000000000000000000000a0
    		00000000000000000000000000000000000000000000000000000000000000e0
    		0000000000000000000000000000000000000000000000000000000000000005
    		6e69676874000000000000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000003
    		6461790000000000000000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000040
    		0000000000000000000000000000000000000000000000000000000000000080
    		0000000000000000000000000000000000000000000000000000000000000004
    		7765656500000000000000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000008
    		66756e7465737473000000000000000000000000000000000000000000000000
    	"
        );
        // a dynamic FixedSeq at top level should start with indirection
        // when not param encoded
        assert_eq!(encoded, expected);
        assert_ne!(encoded_params, expected);
        assert_eq!(encoded_params.len() + 32, encoded.len());
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_params_containing_dynamic_tuple() {
        type MyTy = (
            sol_data::Address,
            (sol_data::Bool, sol_data::String, sol_data::String),
            sol_data::Address,
            sol_data::Address,
            sol_data::Bool,
        );
        let data = (
            Address::from([0x22u8; 20]),
            (true, "spaceship".to_owned(), "cyborg".to_owned()),
            Address::from([0x33u8; 20]),
            Address::from([0x44u8; 20]),
            false,
        );

        let encoded_single = MyTy::abi_encode(&data);
        let encoded = MyTy::abi_encode_sequence(&data);

        let expected = hex!(
            "
    		0000000000000000000000002222222222222222222222222222222222222222
    		00000000000000000000000000000000000000000000000000000000000000a0
    		0000000000000000000000003333333333333333333333333333333333333333
    		0000000000000000000000004444444444444444444444444444444444444444
    		0000000000000000000000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000001
    		0000000000000000000000000000000000000000000000000000000000000060
    		00000000000000000000000000000000000000000000000000000000000000a0
    		0000000000000000000000000000000000000000000000000000000000000009
    		7370616365736869700000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000006
    		6379626f72670000000000000000000000000000000000000000000000000000
    	"
        );
        // A Dynamic FixedSeq may be a top-level sequence to `encode` or may
        // itself be an item in a top-level sequence. Which is to say, it could
        // be (as `abi_encode(T)` or `abi_encode((T,))`). This test was `abi_encode(T)`
        assert_ne!(encoded_single, expected);
        assert_eq!(encoded, expected);
        assert_eq!(encoded.len() + 32, encoded_single.len());
        assert_eq!(encoded_single.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_params_containing_static_tuple() {
        type MyTy = (
            sol_data::Address,
            (sol_data::Address, sol_data::Bool, sol_data::Bool),
            sol_data::Address,
            sol_data::Address,
        );

        let data = (
            Address::from([0x11u8; 20]),
            (Address::from([0x22u8; 20]), true, false),
            Address::from([0x33u8; 20]),
            Address::from([0x44u8; 20]),
        );

        let encoded = MyTy::abi_encode_sequence(&data);
        let encoded_params = MyTy::abi_encode_params(&data);

        let expected = hex!(
            "
    		0000000000000000000000001111111111111111111111111111111111111111
    		0000000000000000000000002222222222222222222222222222222222222222
    		0000000000000000000000000000000000000000000000000000000000000001
    		0000000000000000000000000000000000000000000000000000000000000000
    		0000000000000000000000003333333333333333333333333333333333333333
    		0000000000000000000000004444444444444444444444444444444444444444
    	"
        );

        // a static FixedSeq should NEVER indirect
        assert_eq!(encoded, expected);
        assert_eq!(encoded_params, expected);
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    #[test]
    fn encode_dynamic_tuple_with_nested_static_tuples() {
        type MyTy = (((sol_data::Bool, sol_data::Uint<16>),), sol_data::Array<sol_data::Uint<16>>);

        let data = (((false, 0x777),), vec![0x42, 0x1337]);

        let encoded = MyTy::abi_encode(&data);
        let encoded_params = MyTy::abi_encode_params(&data);

        let expected = hex!(
            "
    		0000000000000000000000000000000000000000000000000000000000000020
    		0000000000000000000000000000000000000000000000000000000000000000
    		0000000000000000000000000000000000000000000000000000000000000777
    		0000000000000000000000000000000000000000000000000000000000000060
    		0000000000000000000000000000000000000000000000000000000000000002
    		0000000000000000000000000000000000000000000000000000000000000042
    		0000000000000000000000000000000000000000000000000000000000001337
    	"
        );
        // a dynamic FixedSeq at top level should start with indirection
        // when not param encoded
        assert_eq!(encoded, expected);
        assert_ne!(encoded_params, expected);
        assert_eq!(encoded_params.len() + 32, encoded.len());
        assert_eq!(encoded.len(), MyTy::abi_encoded_size(&data));
    }

    // https://github.com/foundry-rs/foundry/issues/7280
    #[test]
    fn encode_empty_bytes_array_in_tuple() {
        type MyTy = sol! { (bytes, address, bytes[]) };

        let data = (
            Vec::from(bytes!("09736b79736b79736b79026f7300")),
            address!("B7b54cd129e6D8B24e6AE652a473449B273eE3E4"),
            Vec::<Vec<u8>>::new(),
        );

        let encoded_params = MyTy::abi_encode_params(&data);

        let expected = hex!(
            "
            0000000000000000000000000000000000000000000000000000000000000060
            000000000000000000000000B7b54cd129e6D8B24e6AE652a473449B273eE3E4
            00000000000000000000000000000000000000000000000000000000000000a0
            000000000000000000000000000000000000000000000000000000000000000e
            09736b79736b79736b79026f7300000000000000000000000000000000000000
            0000000000000000000000000000000000000000000000000000000000000000
    	"
        );
        assert_eq!(encoded_params, expected);
    }
}