File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
target_chains/starknet/sdk/js Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @pythnetwork/pyth-starknet-js" ,
3- "version" : " 0.1 .0" ,
3+ "version" : " 0.2 .0" ,
44 "description" : " Pyth Network Starknet Utilities" ,
55 "homepage" : " https://pyth.network" ,
66 "author" : {
Original file line number Diff line number Diff line change @@ -21,7 +21,9 @@ export class ByteBuffer {
2121 data : string [ ] = [ ] ;
2222
2323 /** Create a `ByteBuffer` from an array of `bytes31`.
24- * Use `ByteBuffer::fromHex` to create `ByteBuffer` from HEX representation of binary data.
24+ * - Use `ByteBuffer::fromBuffer` to create `ByteBuffer` from a `Buffer`.
25+ * - Use `ByteBuffer::fromBase64` to create `ByteBuffer` from Base64 representation of binary data.
26+ * - Use `ByteBuffer::fromHex` to create `ByteBuffer` from HEX representation of binary data.
2527 */
2628 constructor ( num_last_bytes : number , data : string [ ] ) {
2729 this . num_last_bytes = num_last_bytes ;
@@ -30,8 +32,16 @@ export class ByteBuffer {
3032
3133 /** Create a `ByteBuffer` from HEX representation of binary data. */
3234 public static fromHex ( hexData : string ) : ByteBuffer {
33- const buffer = Buffer . from ( hexData , "base64" ) ;
35+ return ByteBuffer . fromBuffer ( Buffer . from ( hexData , "hex" ) ) ;
36+ }
37+
38+ /** Create a `ByteBuffer` from Base64 representation of binary data. */
39+ public static fromBase64 ( hexData : string ) : ByteBuffer {
40+ return ByteBuffer . fromBuffer ( Buffer . from ( hexData , "base64" ) ) ;
41+ }
3442
43+ /** Create a `ByteBuffer` from a `Buffer`. */
44+ public static fromBuffer ( buffer : Buffer ) : ByteBuffer {
3545 let pos = 0 ;
3646 const data = [ ] ;
3747 while ( pos < buffer . length ) {
You can’t perform that action at this time.
0 commit comments