@altiuslabs/tx-sdk 0.1.18 → 0.1.20

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.18",
3
+ "version": "0.1.20",
4
4
  "description": "SDK for signing and sending Altius USD multi-token transactions",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/constants.js CHANGED
@@ -32,15 +32,10 @@ export const FEE_TOKEN_FACTORY_ADDRESS = '0xa17000000000000000000000000000000000
32
32
 
33
33
  /**
34
34
  * Fee Manager (Independent prefix)
35
- * Address: 0xFE0000000000000000000000000000000000000001
35
+ * Address: 0xFE00000000000000000000000000000000000001
36
36
  */
37
37
  export const FEE_MANAGER_ADDRESS = '0xFE00000000000000000000000000000000000001';
38
38
 
39
- /**
40
- * Fee token prefix (10 bytes) for validation
41
- */
42
- export const FEE_TOKEN_PREFIX = '0xa1700000';
43
-
44
39
  /**
45
40
  * Zero address
46
41
  */
@@ -87,6 +82,16 @@ export const FAUCET_AMOUNT_MICRO = BigInt(100_000_000);
87
82
  */
88
83
  export const FAUCET_AMOUNT_WEI = BigInt(100_000_000_000_000_000_000);
89
84
 
85
+ /**
86
+ * Default faucet amount in token units (100 USDA with 18 decimals)
87
+ */
88
+ export const DEFAULT_FAUCET_AMOUNT = BigInt(100_000_000_000_000_000_000);
89
+
90
+ /**
91
+ * Default faucet amount in microdollars
92
+ */
93
+ export const DEFAULT_FAUCET_AMOUNT_MICRO = 100_000_000;
94
+
90
95
  /**
91
96
  * Default transfer amount in microdollars (10 USDA)
92
97
  */
package/src/index.js CHANGED
@@ -26,7 +26,7 @@ export { NonceManager, create_nonce_manager } from './nonce.js';
26
26
  export { TxClient, TxClientBuilder, create_tx_client } from './client.js';
27
27
 
28
28
  // Utilities
29
- export { keccak256, pad_hex, num_to_hex, rlp_encode, transaction_hash, computeFeeTokenAddress, isReservedAddress } from './utils.js';
29
+ export { keccak256, pad_hex, num_to_hex, rlp_encode, transaction_hash, computeFeeTokenAddress, isReservedAddress, is_fee_token_prefix, is_valid_fee_token_address, is_index_reserved } from './utils.js';
30
30
 
31
31
  // Constants
32
32
  export * from './constants.js';
@@ -169,7 +169,7 @@ export class TxBuilder {
169
169
  max_fee_per_gas: this._max_fee_per_gas,
170
170
  max_fee_per_gas_usd_attodollars: this._max_fee_per_gas_usd_attodollars,
171
171
  fee_token: this._fee_token,
172
- fee_payer: this._fee_payer,
172
+ fee_payer: this._fee_payer || '0x0000000000000000000000000000000000000000',
173
173
  fee_payer_signature: this._fee_payer_signature,
174
174
  };
175
175
  }
@@ -220,6 +220,9 @@ export class TxBuilder {
220
220
 
221
221
  const tx = this.build();
222
222
 
223
+ // Use sender as fee_payer if not specified
224
+ const feePayer = tx.fee_payer || wallet.address;
225
+
223
226
  // Convert r, s to 32-byte buffers
224
227
  const rBuffer = Buffer.from(sig.r.slice(2), 'hex');
225
228
  const sBuffer = Buffer.from(sig.s.slice(2), 'hex');
@@ -238,7 +241,7 @@ export class TxBuilder {
238
241
  Buffer.from(tx.data.slice(2), 'hex') || Buffer.alloc(0), // data as buffer
239
242
  [], // empty access list
240
243
  Buffer.from(tx.fee_token.slice(2), 'hex'), // fee_token as buffer
241
- Buffer.from(tx.fee_payer.slice(2), 'hex'), // fee_payer as buffer
244
+ Buffer.from(feePayer.slice(2), 'hex'), // fee_payer as buffer
242
245
  BigInt(tx.max_fee_per_gas_usd_attodollars),
243
246
  Buffer.from(tx.fee_payer_signature?.slice(2) || '', 'hex') || Buffer.alloc(0),
244
247
  // Signature: y_parity (1 byte), r (32 bytes), s (32 bytes)
@@ -255,6 +258,7 @@ export class TxBuilder {
255
258
 
256
259
  return {
257
260
  ...tx,
261
+ fee_payer: feePayer,
258
262
  v: y_parity,
259
263
  r: sig.r,
260
264
  s: sig.s,
package/src/utils.js CHANGED
@@ -117,3 +117,31 @@ export function isReservedAddress(address, creator, salt) {
117
117
  const { index } = computeFeeTokenAddress(creator, salt);
118
118
  return index < 256n;
119
119
  }
120
+
121
+ /**
122
+ * Check if address has fee token prefix (0xa170...)
123
+ * @param {string} address - Address to check
124
+ * @returns {boolean} True if has fee token prefix
125
+ */
126
+ export function is_fee_token_prefix(address) {
127
+ const clean = address.startsWith('0x') ? address.slice(2) : address;
128
+ return clean.startsWith('a170');
129
+ }
130
+
131
+ /**
132
+ * Check if address is valid fee token (has prefix and not zero)
133
+ * @param {string} address - Address to check
134
+ * @returns {boolean} True if valid fee token address
135
+ */
136
+ export function is_valid_fee_token_address(address) {
137
+ return is_fee_token_prefix(address) && address !== '0x0000000000000000000000000000000000000000';
138
+ }
139
+
140
+ /**
141
+ * Check if index is reserved (index < 256)
142
+ * @param {bigint|number} index - Index to check
143
+ * @returns {boolean} True if reserved
144
+ */
145
+ export function is_index_reserved(index) {
146
+ return BigInt(index) < 256n;
147
+ }