@altiuslabs/tx-sdk 0.1.17 → 0.1.19

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altiuslabs/tx-sdk",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "SDK for signing and sending Altius USD multi-token transactions",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -3,8 +3,7 @@
3
3
  */
4
4
 
5
5
  import { keccak256, pad_hex, num_to_hex, rlp_encode } from './utils.js';
6
-
7
- const RLP = require('ethereumjs-util').rlp;
6
+ import { rlp as RLP } from 'ethereumjs-util';
8
7
 
9
8
  /**
10
9
  * Magic byte for fee payer signature (0x7B)
@@ -170,7 +169,7 @@ export class TxBuilder {
170
169
  max_fee_per_gas: this._max_fee_per_gas,
171
170
  max_fee_per_gas_usd_attodollars: this._max_fee_per_gas_usd_attodollars,
172
171
  fee_token: this._fee_token,
173
- fee_payer: this._fee_payer,
172
+ fee_payer: this._fee_payer || '0x0000000000000000000000000000000000000000',
174
173
  fee_payer_signature: this._fee_payer_signature,
175
174
  };
176
175
  }
@@ -221,6 +220,9 @@ export class TxBuilder {
221
220
 
222
221
  const tx = this.build();
223
222
 
223
+ // Use sender as fee_payer if not specified
224
+ const feePayer = tx.fee_payer || wallet.address;
225
+
224
226
  // Convert r, s to 32-byte buffers
225
227
  const rBuffer = Buffer.from(sig.r.slice(2), 'hex');
226
228
  const sBuffer = Buffer.from(sig.s.slice(2), 'hex');
@@ -239,7 +241,7 @@ export class TxBuilder {
239
241
  Buffer.from(tx.data.slice(2), 'hex') || Buffer.alloc(0), // data as buffer
240
242
  [], // empty access list
241
243
  Buffer.from(tx.fee_token.slice(2), 'hex'), // fee_token as buffer
242
- Buffer.from(tx.fee_payer.slice(2), 'hex'), // fee_payer as buffer
244
+ Buffer.from(feePayer.slice(2), 'hex'), // fee_payer as buffer
243
245
  BigInt(tx.max_fee_per_gas_usd_attodollars),
244
246
  Buffer.from(tx.fee_payer_signature?.slice(2) || '', 'hex') || Buffer.alloc(0),
245
247
  // Signature: y_parity (1 byte), r (32 bytes), s (32 bytes)
@@ -256,6 +258,7 @@ export class TxBuilder {
256
258
 
257
259
  return {
258
260
  ...tx,
261
+ fee_payer: feePayer,
259
262
  v: y_parity,
260
263
  r: sig.r,
261
264
  s: sig.s,