File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 2626 "require" : {
2727 "php" : " ^8.1.0" ,
2828 "guzzlehttp/guzzle" : " ^7.4" ,
29- "brick/math" : " ^0.10.2|^0.11|^0.12"
29+ "brick/math" : " ^0.10.2|^0.11|^0.12" ,
30+ "hardcastle/xrpl_php" : " ^0.8|^0.9"
3031 },
3132 "require-dev" : {
3233 "phpunit/phpunit" : " ^10.1" ,
Original file line number Diff line number Diff line change @@ -113,4 +113,15 @@ public static function ieee754FloatFromBytes(array $bytes): float|null|bool
113113
114114 }
115115
116+ /**
117+ * Test: makeMptID(4369311,'rGepNyxjJbtN75Zb4fgkjQsnv3UUcbp45E') should output: 0042AB9FAB8A5036CE4DB80D47016F557F9BFC9523985BF1
118+ * @return string
119+ */
120+ public static function makeMptID (int $ sequence , string $ issuer ): string {
121+ $ sequence = pack ('N ' , $ sequence ); // 'N' = unsigned long (32-bit big endian)
122+ $ codec = new \Hardcastle \XRPL_PHP \Core \RippleAddressCodec \AddressCodec ();
123+ $ accountID = $ codec ->decodeAccountId ($ issuer )->toUtf8 ();
124+ return \strtoupper (\bin2hex ($ sequence . $ accountID )); //Return as hex string
125+ }
126+
116127}
Original file line number Diff line number Diff line change @@ -37,4 +37,11 @@ public function testConvertCurrencyToSymbolLP()
3737 {
3838 $ this ->assertEquals ('LP 03B20F3A7D26D33C6DA3503E5CCE3E67B102D4D2 ' ,Util::currencyToSymbol ('03B20F3A7D26D33C6DA3503E5CCE3E67B102D4D2 ' ));
3939 }
40+
41+ public function testMakeMptId () {
42+ $ sequence = 4369311 ;
43+ $ issuer = 'rGepNyxjJbtN75Zb4fgkjQsnv3UUcbp45E ' ;
44+ $ this ->assertEquals ('0042AB9FAB8A5036CE4DB80D47016F557F9BFC9523985BF1 ' ,Util::makeMptID ($ sequence ,$ issuer ));
45+
46+ }
4047}
You can’t perform that action at this time.
0 commit comments