@abstraxn/signer-react 1.0.1 → 1.0.3
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/CHANGELOG.md +29 -0
- package/README.md +4 -0
- package/dist/src/hooks.d.ts +71 -41
- package/dist/src/hooks.js +299 -150
- package/dist/src/hooks.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.3] - 2026-01-29
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- `useGetGasPrice` hook to fetch gas price (maxFeePerGas, maxPriorityFeePerGas, gasPrice) from the chain
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- `useEstimateGas` now returns only `{ gasLimit }`; use `useGetGasPrice` for fees
|
|
15
|
+
- `useSignTxn` and `useSignAndSendTxn`: parameter renamed from `override` to `gas` with direct fields `gasLimit`, `gasPrice?`, `maxFeePerGas?`, `maxPriorityFeePerGas?`
|
|
16
|
+
|
|
17
|
+
## [1.0.2] - 2026-01-29
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- `useGetGasPrice` hook to fetch gas price (maxFeePerGas, maxPriorityFeePerGas, gasPrice) from the chain
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- `useEstimateGas` now returns only `{ gasLimit }`; use `useGetGasPrice` for fees
|
|
24
|
+
- `useSignTxn` and `useSignAndSendTxn`: parameter renamed from `override` to `gas` with direct fields `gasLimit`, `gasPrice?`, `maxFeePerGas?`, `maxPriorityFeePerGas?`
|
|
25
|
+
|
|
26
|
+
## [1.0.1] - 2026-01-28
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
- Added `useEstimateGas` hook for estimating gas costs for transactions
|
package/README.md
CHANGED
|
@@ -109,6 +109,10 @@ function HookConnectButton() {
|
|
|
109
109
|
- **@abstraxn/signer-core** - Core SDK (dependency)
|
|
110
110
|
- **@abstraxn/signer** - Backward compatible wrapper (deprecated)
|
|
111
111
|
|
|
112
|
+
## 📋 Changelog
|
|
113
|
+
|
|
114
|
+
See [CHANGELOG.md](./CHANGELOG.md) for a list of changes and version history.
|
|
115
|
+
|
|
112
116
|
## 📝 License
|
|
113
117
|
|
|
114
118
|
MIT
|
package/dist/src/hooks.d.ts
CHANGED
|
@@ -8366,14 +8366,14 @@ export declare function usePrepareRawTxn(provider: PublicClient): {
|
|
|
8366
8366
|
prepareRawTxn: ({ from, to, value, data, abi, functionName, args, }: {
|
|
8367
8367
|
from: Address;
|
|
8368
8368
|
to: Address;
|
|
8369
|
-
value?: string | number;
|
|
8369
|
+
value?: string | number | bigint;
|
|
8370
8370
|
data?: `0x${string}`;
|
|
8371
8371
|
abi?: Abi;
|
|
8372
8372
|
functionName?: string;
|
|
8373
8373
|
args?: any[];
|
|
8374
8374
|
}) => Promise<{
|
|
8375
8375
|
to: Address;
|
|
8376
|
-
value:
|
|
8376
|
+
value: string | bigint;
|
|
8377
8377
|
data: `0x${string}`;
|
|
8378
8378
|
}>;
|
|
8379
8379
|
};
|
|
@@ -8390,28 +8390,34 @@ export declare function usePrepareRawTxn(provider: PublicClient): {
|
|
|
8390
8390
|
* const { signTxn } = useSignTxn(publicClient);
|
|
8391
8391
|
*
|
|
8392
8392
|
* // Prepare transaction
|
|
8393
|
-
* const rawTx = await prepareRawTxn({
|
|
8394
|
-
*
|
|
8395
|
-
*
|
|
8396
|
-
*
|
|
8397
|
-
*
|
|
8398
|
-
*
|
|
8399
|
-
* // Sign transaction
|
|
8393
|
+
* const rawTx = await prepareRawTxn({ from: address!, to: '0x...', value: '0.001' });
|
|
8394
|
+
* const { estimateGas } = useEstimateGas(publicClient);
|
|
8395
|
+
* const { getGasPrice } = useGetGasPrice(publicClient);
|
|
8396
|
+
* const { gasLimit } = await estimateGas({ account: address!, to: rawTx.to, data: rawTx.data, value: rawTx.value });
|
|
8397
|
+
* const fees = await getGasPrice();
|
|
8400
8398
|
* const signedTx = await signTxn({
|
|
8401
8399
|
* from: address!,
|
|
8402
|
-
* ...rawTx,
|
|
8400
|
+
* ...rawTx,
|
|
8401
|
+
* gas: { gasLimit, maxFeePerGas: fees.maxFeePerGas!, maxPriorityFeePerGas: fees.maxPriorityFeePerGas! },
|
|
8403
8402
|
* });
|
|
8404
8403
|
* ```
|
|
8405
8404
|
*/
|
|
8406
8405
|
export declare function useSignTxn(provider: PublicClient): {
|
|
8407
|
-
signTxn: ({ from, to, value, data, chainId, }: {
|
|
8406
|
+
signTxn: ({ from, to, value, data, chainId, gas, }: {
|
|
8408
8407
|
from: Address;
|
|
8409
8408
|
to: Address;
|
|
8410
|
-
value:
|
|
8409
|
+
value: string | bigint;
|
|
8411
8410
|
data: `0x${string}`;
|
|
8412
8411
|
chainId?: number;
|
|
8412
|
+
/** Gas: optionally pass gasLimit + (maxFeePerGas & maxPriorityFeePerGas for EIP-1559) or (gasPrice for legacy). */
|
|
8413
|
+
gas?: {
|
|
8414
|
+
gasLimit?: bigint;
|
|
8415
|
+
gasPrice?: bigint;
|
|
8416
|
+
maxFeePerGas?: bigint;
|
|
8417
|
+
maxPriorityFeePerGas?: bigint;
|
|
8418
|
+
};
|
|
8413
8419
|
}) => Promise<{
|
|
8414
|
-
unsignedTransaction: `0x02${string}
|
|
8420
|
+
unsignedTransaction: `0x02${string}` | `0x01${string}` | `0x03${string}` | `0x04${string}` | import("viem").TransactionSerializedLegacy;
|
|
8415
8421
|
signedTransaction: string;
|
|
8416
8422
|
}>;
|
|
8417
8423
|
isConnected: boolean;
|
|
@@ -8430,31 +8436,36 @@ export declare function useSignTxn(provider: PublicClient): {
|
|
|
8430
8436
|
* const { signAndSendTxn } = useSignAndSendTxn(publicClient);
|
|
8431
8437
|
*
|
|
8432
8438
|
* // Prepare transaction
|
|
8433
|
-
* const rawTx = await prepareRawTxn({
|
|
8434
|
-
*
|
|
8435
|
-
*
|
|
8436
|
-
*
|
|
8437
|
-
*
|
|
8438
|
-
*
|
|
8439
|
-
* // Sign and send transaction
|
|
8439
|
+
* const rawTx = await prepareRawTxn({ from: address!, to: '0x...', value: '0.001' });
|
|
8440
|
+
* const { estimateGas } = useEstimateGas(publicClient);
|
|
8441
|
+
* const { getGasPrice } = useGetGasPrice(publicClient);
|
|
8442
|
+
* const { gasLimit } = await estimateGas({ account: address!, to: rawTx.to, data: rawTx.data, value: rawTx.value });
|
|
8443
|
+
* const fees = await getGasPrice();
|
|
8440
8444
|
* const result = await signAndSendTxn({
|
|
8441
8445
|
* from: address!,
|
|
8442
|
-
* ...rawTx,
|
|
8446
|
+
* ...rawTx,
|
|
8447
|
+
* gas: { gasLimit, maxFeePerGas: fees.maxFeePerGas!, maxPriorityFeePerGas: fees.maxPriorityFeePerGas! },
|
|
8443
8448
|
* });
|
|
8444
|
-
*
|
|
8445
8449
|
* console.log('Transaction hash:', result.hash);
|
|
8446
8450
|
* ```
|
|
8447
8451
|
*/
|
|
8448
8452
|
export declare function useSignAndSendTxn(provider: PublicClient): {
|
|
8449
|
-
signAndSendTxn: ({ from, to, value, data, chainId, }: {
|
|
8453
|
+
signAndSendTxn: ({ from, to, value, data, chainId, gas, }: {
|
|
8450
8454
|
from: Address;
|
|
8451
8455
|
to: Address;
|
|
8452
|
-
value:
|
|
8456
|
+
value: string | bigint;
|
|
8453
8457
|
data: `0x${string}`;
|
|
8454
8458
|
chainId?: number;
|
|
8459
|
+
/** Gas: optionally pass gasLimit + (maxFeePerGas & maxPriorityFeePerGas for EIP-1559) or (gasPrice for legacy). */
|
|
8460
|
+
gas?: {
|
|
8461
|
+
gasLimit?: bigint;
|
|
8462
|
+
gasPrice?: bigint;
|
|
8463
|
+
maxFeePerGas?: bigint;
|
|
8464
|
+
maxPriorityFeePerGas?: bigint;
|
|
8465
|
+
};
|
|
8455
8466
|
}) => Promise<{
|
|
8456
8467
|
hash: `0x${string}`;
|
|
8457
|
-
unsignedTransaction: `0x02${string}
|
|
8468
|
+
unsignedTransaction: `0x02${string}` | `0x01${string}` | `0x03${string}` | `0x04${string}` | import("viem").TransactionSerializedLegacy;
|
|
8458
8469
|
signedTransaction: string;
|
|
8459
8470
|
}>;
|
|
8460
8471
|
isConnected: boolean;
|
|
@@ -8495,33 +8506,52 @@ export declare function useWaitForTxnReceipt(provider: PublicClient): {
|
|
|
8495
8506
|
}) => Promise<TransactionReceipt>;
|
|
8496
8507
|
};
|
|
8497
8508
|
/**
|
|
8498
|
-
* Hook to estimate gas
|
|
8499
|
-
*
|
|
8509
|
+
* Hook to estimate gas for a transaction
|
|
8510
|
+
* Returns gasLimit to pass as gas.gasLimit to useSignTxn / useSignAndSendTxn (use useGetGasPrice for fees; no estimation inside those hooks).
|
|
8500
8511
|
*
|
|
8501
8512
|
* @param provider - PublicClient instance (can be created using usePublicClient hook)
|
|
8502
8513
|
* @returns Object with estimateGas function
|
|
8503
8514
|
*
|
|
8504
8515
|
* @example
|
|
8505
8516
|
* ```tsx
|
|
8506
|
-
* const { publicClient } = usePublicClient(
|
|
8507
|
-
* polygonAmoy,
|
|
8508
|
-
* 'https://rpc-amoy.polygon.technology'
|
|
8509
|
-
* );
|
|
8510
8517
|
* const { estimateGas } = useEstimateGas(publicClient);
|
|
8518
|
+
* const result = await estimateGas({
|
|
8519
|
+
* account: address!,
|
|
8520
|
+
* to: rawTx.to,
|
|
8521
|
+
* data: rawTx.data,
|
|
8522
|
+
* value: rawTx.value,
|
|
8523
|
+
* });
|
|
8524
|
+
* // gas: { gasLimit: result.gasLimit }
|
|
8525
|
+
* ```
|
|
8526
|
+
*/
|
|
8527
|
+
export declare function useEstimateGas(provider: PublicClient): {
|
|
8528
|
+
estimateGas: ({ account, to, data, value, }: {
|
|
8529
|
+
account: Address;
|
|
8530
|
+
to: Address;
|
|
8531
|
+
data?: `0x${string}`;
|
|
8532
|
+
value?: string | bigint;
|
|
8533
|
+
}) => Promise<{
|
|
8534
|
+
gasLimit: bigint;
|
|
8535
|
+
}>;
|
|
8536
|
+
};
|
|
8537
|
+
/**
|
|
8538
|
+
* Hook to get current gas price / EIP-1559 fees from the chain.
|
|
8539
|
+
* Use with useEstimateGas when you need gas limit and gas price for the gas param in useSignTxn / useSignAndSendTxn.
|
|
8511
8540
|
*
|
|
8512
|
-
*
|
|
8513
|
-
*
|
|
8541
|
+
* @param provider - PublicClient instance (can be created using usePublicClient hook)
|
|
8542
|
+
* @returns Object with getGasPrice function returning maxFeePerGas, maxPriorityFeePerGas, and/or gasPrice
|
|
8514
8543
|
*
|
|
8515
|
-
*
|
|
8516
|
-
*
|
|
8517
|
-
*
|
|
8518
|
-
*
|
|
8519
|
-
*
|
|
8520
|
-
* // }
|
|
8544
|
+
* @example
|
|
8545
|
+
* ```tsx
|
|
8546
|
+
* const { publicClient } = usePublicClient(...);
|
|
8547
|
+
* const { getGasPrice } = useGetGasPrice(publicClient);
|
|
8548
|
+
* const fees = await getGasPrice();
|
|
8549
|
+
* // EIP-1559: gas: { gasLimit, maxFeePerGas: fees.maxFeePerGas!, maxPriorityFeePerGas: fees.maxPriorityFeePerGas! }
|
|
8550
|
+
* // Legacy: gas: { gasLimit, gasPrice: fees.gasPrice! }
|
|
8521
8551
|
* ```
|
|
8522
8552
|
*/
|
|
8523
|
-
export declare function
|
|
8524
|
-
|
|
8553
|
+
export declare function useGetGasPrice(provider: PublicClient): {
|
|
8554
|
+
getGasPrice: () => Promise<{
|
|
8525
8555
|
gasPrice?: bigint;
|
|
8526
8556
|
maxFeePerGas?: bigint;
|
|
8527
8557
|
maxPriorityFeePerGas?: bigint;
|