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 1
1
{
2
2
"name" : " @pythnetwork/pyth-starknet-js" ,
3
- "version" : " 0.1 .0" ,
3
+ "version" : " 0.2 .0" ,
4
4
"description" : " Pyth Network Starknet Utilities" ,
5
5
"homepage" : " https://pyth.network" ,
6
6
"author" : {
Original file line number Diff line number Diff line change @@ -21,7 +21,9 @@ export class ByteBuffer {
21
21
data : string [ ] = [ ] ;
22
22
23
23
/** 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.
25
27
*/
26
28
constructor ( num_last_bytes : number , data : string [ ] ) {
27
29
this . num_last_bytes = num_last_bytes ;
@@ -30,8 +32,16 @@ export class ByteBuffer {
30
32
31
33
/** Create a `ByteBuffer` from HEX representation of binary data. */
32
34
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
+ }
34
42
43
+ /** Create a `ByteBuffer` from a `Buffer`. */
44
+ public static fromBuffer ( buffer : Buffer ) : ByteBuffer {
35
45
let pos = 0 ;
36
46
const data = [ ] ;
37
47
while ( pos < buffer . length ) {
You can’t perform that action at this time.
0 commit comments