@gearbox-protocol/sdk 14.10.0 → 14.10.1

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.
@@ -40,7 +40,8 @@ async function claimFromFaucet(opts) {
40
40
  role,
41
41
  amount,
42
42
  logger,
43
- gasMultiplier = 10n
43
+ gasMultiplier = 10n,
44
+ sync = false
44
45
  } = opts;
45
46
  let amnt = "default amount";
46
47
  let args;
@@ -81,7 +82,8 @@ async function claimFromFaucet(opts) {
81
82
  functionName: "claim",
82
83
  args
83
84
  });
84
- const hash = await wallet.writeContract({
85
+ logger?.debug({ gas }, "estimated claim tx gas");
86
+ const { request } = await publicClient.simulateContract({
85
87
  account: claimer,
86
88
  address: faucet,
87
89
  abi: faucetAbi,
@@ -90,15 +92,23 @@ async function claimFromFaucet(opts) {
90
92
  chain: wallet.chain,
91
93
  gas: gas * gasMultiplier
92
94
  });
93
- const receipt = await publicClient.waitForTransactionReceipt({
94
- hash
95
- });
95
+ logger?.debug({ request }, "simulated claim tx request");
96
+ let receipt;
97
+ if (sync) {
98
+ receipt = await wallet.writeContractSync(request);
99
+ } else {
100
+ const hash = await wallet.writeContract(request);
101
+ logger?.debug({ hash }, "claim tx hash");
102
+ receipt = await publicClient.waitForTransactionReceipt({ hash });
103
+ }
96
104
  if (receipt.status === "reverted") {
97
105
  throw new Error(
98
- `${usr} failed to claimed ${amnt} from faucet, tx: ${hash}`
106
+ `${usr} failed to claimed ${amnt} from faucet, tx: ${receipt.transactionHash}`
99
107
  );
100
108
  }
101
- logger?.debug(`${usr} claimed ${amnt} from faucet, tx: ${hash}`);
109
+ logger?.debug(
110
+ `${usr} claimed ${amnt} from faucet, tx: ${receipt.transactionHash}`
111
+ );
102
112
  }
103
113
  // Annotate the CommonJS export names for ESM import in node:
104
114
  0 && (module.exports = {
@@ -19,7 +19,8 @@ async function claimFromFaucet(opts) {
19
19
  role,
20
20
  amount,
21
21
  logger,
22
- gasMultiplier = 10n
22
+ gasMultiplier = 10n,
23
+ sync = false
23
24
  } = opts;
24
25
  let amnt = "default amount";
25
26
  let args;
@@ -60,7 +61,8 @@ async function claimFromFaucet(opts) {
60
61
  functionName: "claim",
61
62
  args
62
63
  });
63
- const hash = await wallet.writeContract({
64
+ logger?.debug({ gas }, "estimated claim tx gas");
65
+ const { request } = await publicClient.simulateContract({
64
66
  account: claimer,
65
67
  address: faucet,
66
68
  abi: faucetAbi,
@@ -69,15 +71,23 @@ async function claimFromFaucet(opts) {
69
71
  chain: wallet.chain,
70
72
  gas: gas * gasMultiplier
71
73
  });
72
- const receipt = await publicClient.waitForTransactionReceipt({
73
- hash
74
- });
74
+ logger?.debug({ request }, "simulated claim tx request");
75
+ let receipt;
76
+ if (sync) {
77
+ receipt = await wallet.writeContractSync(request);
78
+ } else {
79
+ const hash = await wallet.writeContract(request);
80
+ logger?.debug({ hash }, "claim tx hash");
81
+ receipt = await publicClient.waitForTransactionReceipt({ hash });
82
+ }
75
83
  if (receipt.status === "reverted") {
76
84
  throw new Error(
77
- `${usr} failed to claimed ${amnt} from faucet, tx: ${hash}`
85
+ `${usr} failed to claimed ${amnt} from faucet, tx: ${receipt.transactionHash}`
78
86
  );
79
87
  }
80
- logger?.debug(`${usr} claimed ${amnt} from faucet, tx: ${hash}`);
88
+ logger?.debug(
89
+ `${usr} claimed ${amnt} from faucet, tx: ${receipt.transactionHash}`
90
+ );
81
91
  }
82
92
  export {
83
93
  claimFromFaucet
@@ -21,6 +21,7 @@ interface ClaimFromFaucetOptions {
21
21
  amount?: TokenClaim[] | bigint | ((minAmountUSD: bigint) => bigint);
22
22
  gasMultiplier?: bigint;
23
23
  logger?: ILogger;
24
+ sync?: boolean;
24
25
  }
25
26
  export declare function claimFromFaucet(opts: ClaimFromFaucetOptions): Promise<void>;
26
27
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "14.10.0",
3
+ "version": "14.10.1",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {