@storagehub-sdk/core 0.4.3 → 0.4.4

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.
@@ -26,7 +26,6 @@ export declare class StorageHubClient {
26
26
  private static readonly MAX_LOCATION_BYTES;
27
27
  private static readonly MAX_PEER_ID_BYTES;
28
28
  private static readonly DEFAULT_GAS_MULTIPLIER;
29
- private static readonly DEFAULT_GAS_PRICE;
30
29
  /**
31
30
  * Get write contract instance bound to the wallet client.
32
31
  *
@@ -53,13 +52,28 @@ export declare class StorageHubClient {
53
52
  private estimateGas;
54
53
  /**
55
54
  * Build transaction options with gas and fee settings.
56
- * Handles both legacy and EIP-1559 fee structures.
55
+ *
57
56
  *
58
57
  * Note: `chain: null` is set to ensure compatibility with wallet clients that don't
59
58
  * properly expose chain information (e.g., Reown's Social Login). This tells viem
60
59
  * to use the wallet's currently selected chain rather than trying to fetch chainId.
61
60
  */
62
61
  private buildTxOptions;
62
+ /**
63
+ * Builds EIP-1559 gas fee.
64
+ *
65
+ * Strategy:
66
+ * - Reads the `baseFeePerGas` from the latest block (EIP-1559 required).
67
+ * - Sets a congestion-aware tip (`maxPriorityFeePerGas`).
68
+ * - Computes `maxFeePerGas` as:
69
+ *
70
+ * maxFeePerGas = baseFeePerGas * 3 + maxPriorityFeePerGas
71
+ *
72
+ * The 3x multiplier provides protection against short-term base fee spikes
73
+ * while avoiding excessive overpayment during normal conditions.
74
+ *
75
+ */
76
+ private buildEip1559FeeOptions;
63
77
  /**
64
78
  * Validate string length in UTF-8 bytes and convert to hex.
65
79
  * @param str - Input string to validate and encode
@@ -24,16 +24,32 @@ export type StorageHubClientOptions = {
24
24
  filesystemContractAddress: Address;
25
25
  };
26
26
  /**
27
- * Optional EVM write overrides for SDK calls.
28
27
  *
29
- * Use these when you need to customize the transaction envelope or
30
- * sidestep under-estimation issues on Frontier/weight based pallets.
28
+ * Use this type to explicitly control transaction fees when submitting
29
+ * EIP-1559 transactions, especially under network congestion or when
30
+ * automatic fee estimation is unreliable.
31
31
  *
32
- * - If `gas` is not provided, the SDK will estimate gas for the function
33
- * and apply `gasMultiplier` (default 5) for headroom.
34
- * - You can provide legacy `gasPrice`, or EIP-1559 fees via
35
- * `maxFeePerGas` and `maxPriorityFeePerGas`.
32
+ * Notes:
33
+ * - These fields are mutually exclusive with legacy `gasPrice`.
34
+ * - The effective gas price paid is:
35
+ * `min(maxFeePerGas, baseFeePerGas + maxPriorityFeePerGas)`.
36
36
  */
37
+ export type Eip1559FeeOptions = {
38
+ /**
39
+ * Maximum total fee per gas unit (wei).
40
+ *
41
+ * Acts as an upper bound that protects against sudden base fee spikes
42
+ * between blocks.
43
+ */
44
+ maxFeePerGas: bigint;
45
+ /**
46
+ * Priority fee (tip) per gas unit (wei) paid to the block producer.
47
+ *
48
+ * Higher values increase the likelihood of faster inclusion under
49
+ * congestion.
50
+ */
51
+ maxPriorityFeePerGas: bigint;
52
+ };
37
53
  export type EvmWriteOptions = {
38
54
  /**
39
55
  * Explicit gas limit. If omitted, the SDK will estimate and multiply.
@@ -45,7 +61,10 @@ export type EvmWriteOptions = {
45
61
  */
46
62
  gasMultiplier?: number;
47
63
  /**
48
- * Legacy gas price (wei). If set, EIP-1559 fields are ignored by most clients.
64
+ * Legacy gas price (wei).
65
+ *
66
+ * @deprecated StorageHub SDK is moving to EIP-1559 only. This field is ignored by the SDK.
67
+ * Use `maxFeePerGas` and `maxPriorityFeePerGas` instead.
49
68
  */
50
69
  gasPrice?: bigint;
51
70
  /**