@altiuslabs/tx-sdk 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/utils.js +4 -45
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altiuslabs/tx-sdk",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "SDK for signing and sending Altius USD multi-token transactions",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -19,9 +19,9 @@
19
19
  "signer"
20
20
  ],
21
21
  "dependencies": {
22
+ "ethereumjs-util": "^7.1.5",
22
23
  "js-sha3": "^0.9.3",
23
- "noble-secp256k1": "^1.2.14",
24
- "rlp": "^3.0.0"
24
+ "noble-secp256k1": "^1.2.14"
25
25
  },
26
26
  "author": "",
27
27
  "license": "MIT"
package/src/utils.js CHANGED
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import sha3 from 'js-sha3';
6
- import RLP from 'rlp';
6
+ import { rlp as RLP } from 'ethereumjs-util';
7
7
 
8
8
  /**
9
9
  * Compute keccak256 hash
@@ -38,55 +38,14 @@ export function num_to_hex(num, bytes = 32) {
38
38
  return pad_hex('0x' + hex, bytes);
39
39
  }
40
40
 
41
- /**
42
- * Convert a value to RLP-compatible Buffer
43
- * @param {any} value - Value to convert
44
- * @returns {Buffer} RLP-compatible buffer
45
- */
46
- function toRlpBytes(value) {
47
- if (Buffer.isBuffer(value)) {
48
- return value;
49
- }
50
- if (typeof value === 'string') {
51
- // Hex string
52
- if (value.startsWith('0x')) {
53
- return Buffer.from(value.slice(2), 'hex');
54
- }
55
- return Buffer.from(value);
56
- }
57
- if (typeof value === 'number' || typeof value === 'bigint') {
58
- // Convert number/bigint to big-endian bytes
59
- const bigIntValue = BigInt(value);
60
- if (bigIntValue === 0n) {
61
- return Buffer.from([]);
62
- }
63
- const hex = bigIntValue.toString(16);
64
- // RLP encodes integers as big-endian without leading zeros (except for zero itself)
65
- return Buffer.from(hex, 'hex');
66
- }
67
- if (Array.isArray(value)) {
68
- // For empty arrays, return empty buffer
69
- if (value.length === 0) {
70
- return Buffer.from([]);
71
- }
72
- // Recursively encode array items
73
- const encodedItems = value.map(item => toRlpBytes(item));
74
- return Buffer.concat(encodedItems);
75
- }
76
- // Default: stringify
77
- return Buffer.from(String(value));
78
- }
79
-
80
41
  /**
81
42
  * RLP encoding (for 0x7a transactions)
82
- * @param {Array} items - Array of items to encode
43
+ * @param {Array} items - Array of items to encode (numbers, bigints, strings, Buffers, arrays)
83
44
  * @returns {string} RLP encoded data as 0x-prefixed hex
84
45
  */
85
46
  export function rlp_encode(items) {
86
- // Convert all items to RLP-compatible buffers first
87
- const buffers = items.map(item => toRlpBytes(item));
88
- const encoded = RLP.encode(buffers);
89
- return '0x' + Buffer.from(encoded).toString('hex');
47
+ const encoded = RLP.encode(items);
48
+ return '0x' + encoded.toString('hex');
90
49
  }
91
50
 
92
51
  /**