9
9
use CBOR \TAg ;
10
10
use CBOR \StringStream ;
11
11
use CBOR \OtherObject ;
12
+ use CBOR \Tag \GenericTag ;
12
13
use Illuminate \Support \Str ;
13
14
use Merkeleon \PhpCryptocurrencyAddressValidation \Utils \Base58Decoder ;
14
15
use Throwable ;
@@ -25,10 +26,10 @@ public function __construct(array $options)
25
26
parent ::__construct ($ options );
26
27
27
28
$ otherObjectManager = new OtherObject \OtherObjectManager ();
28
- $ tagManager = new Tag \TagObjectManager ();
29
-
30
29
$ otherObjectManager ->add (OtherObject \SimpleObject::class);
31
- $ tagManager ->add (Tag \PositiveBigIntegerTag::class);
30
+
31
+ $ tagManager = new Tag \TagManager ();
32
+ $ tagManager ->add (Tag \UnsignedBigIntegerTag::class);
32
33
33
34
$ this ->decoder = new Decoder ($ tagManager , $ otherObjectManager );
34
35
}
@@ -54,24 +55,28 @@ public function check(string $address): bool
54
55
return false ;
55
56
}
56
57
57
- $ normalizedData = $ object ->getNormalizedData ();
58
+ /** @var array $normalizedData */
59
+ $ normalizedData = $ object ->normalize ();
58
60
59
61
if (count ($ normalizedData ) !== 2 ) {
60
62
return false ;
61
63
}
62
64
if (!is_numeric ($ normalizedData [1 ])) {
63
65
return false ;
64
66
}
65
- if (!$ normalizedData [0 ] instanceof ByteStringObject) {
67
+
68
+ if (!$ normalizedData [0 ] instanceof GenericTag) {
66
69
return false ;
67
70
}
68
71
69
- $ bs = $ normalizedData [0 ];
72
+ /** @var ByteStringObject $bs */
73
+ $ bs = $ normalizedData [0 ]->getValue ();
74
+
70
75
if (!in_array ($ bs ->getLength (), array_values ($ this ->options ), true )) {
71
76
return false ;
72
77
}
73
78
74
- $ crcCalculated = crc32 ($ normalizedData [ 0 ] ->getValue ());
79
+ $ crcCalculated = crc32 ($ bs ->getValue ());
75
80
$ validCrc = $ normalizedData [1 ];
76
81
77
82
return $ crcCalculated === (int )$ validCrc ;
0 commit comments