thirdweb 5.35.0-nightly-aadbd33e9d696bd7dd77561fa3f3a0a0fa7747f5-20240716082511 → 5.35.0

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.
Files changed (74) hide show
  1. package/dist/cjs/exports/wallets/smart.js +4 -1
  2. package/dist/cjs/exports/wallets/smart.js.map +1 -1
  3. package/dist/cjs/pay/buyWithFiat/getPostOnRampQuote.js +2 -5
  4. package/dist/cjs/pay/buyWithFiat/getPostOnRampQuote.js.map +1 -1
  5. package/dist/cjs/pay/buyWithFiat/getStatus.js.map +1 -1
  6. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +8 -10
  7. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  8. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js +1 -1
  9. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js.map +1 -1
  10. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +1 -6
  11. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +1 -1
  12. package/dist/cjs/version.js +1 -1
  13. package/dist/cjs/version.js.map +1 -1
  14. package/dist/cjs/wallets/smart/lib/bundler.js +32 -7
  15. package/dist/cjs/wallets/smart/lib/bundler.js.map +1 -1
  16. package/dist/cjs/wallets/smart/lib/paymaster.js +16 -2
  17. package/dist/cjs/wallets/smart/lib/paymaster.js.map +1 -1
  18. package/dist/cjs/wallets/smart/lib/userop.js +4 -1
  19. package/dist/cjs/wallets/smart/lib/userop.js.map +1 -1
  20. package/dist/cjs/wallets/smart/types.js +41 -0
  21. package/dist/cjs/wallets/smart/types.js.map +1 -1
  22. package/dist/esm/exports/wallets/smart.js +2 -1
  23. package/dist/esm/exports/wallets/smart.js.map +1 -1
  24. package/dist/esm/pay/buyWithFiat/getPostOnRampQuote.js +2 -5
  25. package/dist/esm/pay/buyWithFiat/getPostOnRampQuote.js.map +1 -1
  26. package/dist/esm/pay/buyWithFiat/getStatus.js.map +1 -1
  27. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +8 -10
  28. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  29. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js +1 -1
  30. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js.map +1 -1
  31. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +1 -6
  32. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +1 -1
  33. package/dist/esm/version.js +1 -1
  34. package/dist/esm/version.js.map +1 -1
  35. package/dist/esm/wallets/smart/lib/bundler.js +31 -7
  36. package/dist/esm/wallets/smart/lib/bundler.js.map +1 -1
  37. package/dist/esm/wallets/smart/lib/paymaster.js +16 -2
  38. package/dist/esm/wallets/smart/lib/paymaster.js.map +1 -1
  39. package/dist/esm/wallets/smart/lib/userop.js +4 -1
  40. package/dist/esm/wallets/smart/lib/userop.js.map +1 -1
  41. package/dist/esm/wallets/smart/types.js +40 -1
  42. package/dist/esm/wallets/smart/types.js.map +1 -1
  43. package/dist/types/exports/wallets/smart.d.ts +2 -1
  44. package/dist/types/exports/wallets/smart.d.ts.map +1 -1
  45. package/dist/types/pay/buyWithFiat/getPostOnRampQuote.d.ts.map +1 -1
  46. package/dist/types/pay/buyWithFiat/getStatus.d.ts +8 -1
  47. package/dist/types/pay/buyWithFiat/getStatus.d.ts.map +1 -1
  48. package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts +6 -0
  49. package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts.map +1 -1
  50. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.d.ts +0 -2
  51. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.d.ts.map +1 -1
  52. package/dist/types/version.d.ts +1 -1
  53. package/dist/types/version.d.ts.map +1 -1
  54. package/dist/types/wallets/smart/lib/bundler.d.ts +20 -1
  55. package/dist/types/wallets/smart/lib/bundler.d.ts.map +1 -1
  56. package/dist/types/wallets/smart/lib/paymaster.d.ts +16 -2
  57. package/dist/types/wallets/smart/lib/paymaster.d.ts.map +1 -1
  58. package/dist/types/wallets/smart/lib/userop.d.ts +4 -1
  59. package/dist/types/wallets/smart/lib/userop.d.ts.map +1 -1
  60. package/dist/types/wallets/smart/types.d.ts +14 -0
  61. package/dist/types/wallets/smart/types.d.ts.map +1 -1
  62. package/package.json +1 -1
  63. package/src/exports/wallets/smart.ts +3 -0
  64. package/src/pay/buyWithFiat/getPostOnRampQuote.ts +2 -5
  65. package/src/pay/buyWithFiat/getStatus.ts +8 -1
  66. package/src/react/core/hooks/connection/ConnectButtonProps.ts +7 -0
  67. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +15 -17
  68. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.tsx +0 -2
  69. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.tsx +0 -23
  70. package/src/version.ts +1 -1
  71. package/src/wallets/smart/lib/bundler.ts +47 -13
  72. package/src/wallets/smart/lib/paymaster.ts +16 -2
  73. package/src/wallets/smart/lib/userop.ts +4 -1
  74. package/src/wallets/smart/types.ts +60 -0
@@ -5,12 +5,14 @@ import type { TransactionReceipt } from "../../../transaction/types.js";
5
5
  import { type Hex, hexToBigInt } from "../../../utils/encoding/hex.js";
6
6
  import { getClientFetch } from "../../../utils/fetch.js";
7
7
  import { stringify } from "../../../utils/json.js";
8
- import type {
9
- BundlerOptions,
10
- EstimationResult,
11
- GasPriceResult,
12
- PmTransactionData,
13
- UserOperation,
8
+ import {
9
+ type BundlerOptions,
10
+ type EstimationResult,
11
+ type GasPriceResult,
12
+ type PmTransactionData,
13
+ type UserOperation,
14
+ type UserOperationReceipt,
15
+ formatUserOperationReceipt,
14
16
  } from "../types.js";
15
17
  import {
16
18
  DEBUG,
@@ -136,14 +138,12 @@ export async function getUserOpReceipt(
136
138
  userOpHash: Hex;
137
139
  },
138
140
  ): Promise<TransactionReceipt | undefined> {
139
- const res = await sendBundlerRequest({
140
- options: args,
141
- operation: "eth_getUserOperationReceipt",
142
- params: [args.userOpHash],
143
- });
141
+ const res = await getUserOpReceiptRaw(args);
142
+
144
143
  if (!res) {
145
144
  return undefined;
146
145
  }
146
+
147
147
  if (res.success === false) {
148
148
  // parse revert reason
149
149
  const logs = parseEventLogs({
@@ -152,20 +152,54 @@ export async function getUserOpReceipt(
152
152
  });
153
153
  const revertReason = logs[0]?.args?.revertReason;
154
154
  if (!revertReason) {
155
- throw new Error(`UserOp failed at txHash: ${res.transactionHash}`);
155
+ throw new Error(
156
+ `UserOp failed at txHash: ${res.receipt.transactionHash}`,
157
+ );
156
158
  }
157
159
  const revertMsg = decodeErrorResult({
158
160
  data: revertReason,
159
161
  });
160
162
  throw new Error(
161
163
  `UserOp failed with reason: '${revertMsg.args.join(",")}' at txHash: ${
162
- res.transactionHash
164
+ res.receipt.transactionHash
163
165
  }`,
164
166
  );
165
167
  }
166
168
  return res.receipt;
167
169
  }
168
170
 
171
+ /**
172
+ * Get the receipt of a user operation.
173
+ * @param args - The options for getting the receipt of a user operation.
174
+ * @returns The raw receipt of the user operation.
175
+ * @example
176
+ * ```ts
177
+ * import { getUserOpReceiptRaw } from "thirdweb/wallets/smart";
178
+ *
179
+ * const receipt = await getUserOpReceiptRaw({
180
+ * client,
181
+ * chain,
182
+ * userOpHash,
183
+ * });
184
+ * ```
185
+ * @walletUtils
186
+ */
187
+ export async function getUserOpReceiptRaw(
188
+ args: BundlerOptions & {
189
+ userOpHash: Hex;
190
+ },
191
+ ): Promise<UserOperationReceipt | undefined> {
192
+ const res = await sendBundlerRequest({
193
+ options: args,
194
+ operation: "eth_getUserOperationReceipt",
195
+ params: [args.userOpHash],
196
+ });
197
+ if (!res) {
198
+ return undefined;
199
+ }
200
+ return formatUserOperationReceipt(res as UserOperationReceipt);
201
+ }
202
+
169
203
  /**
170
204
  * @internal
171
205
  */
@@ -11,8 +11,22 @@ import {
11
11
  import { hexlifyUserOp } from "./utils.js";
12
12
 
13
13
  /**
14
- * TODO Docs
15
- * @internal
14
+ * Get paymaster and data details for a user operation.
15
+ * @param args - The userOp and options
16
+ * @returns - The paymaster and data details for the user operation.
17
+ * @example
18
+ * ```ts
19
+ * import { getPaymasterAndData } from "thirdweb/wallets/smart";
20
+ *
21
+ * const userOp = createUnsignedUserOp(...);
22
+ *
23
+ * const paymasterAndData = await getPaymasterAndData({
24
+ * userOp,
25
+ * client,
26
+ * chain,
27
+ * });
28
+ * ```
29
+ * @walletUtils
16
30
  */
17
31
  export async function getPaymasterAndData(args: {
18
32
  userOp: UserOperation;
@@ -81,7 +81,9 @@ export async function waitForUserOpReceipt(
81
81
  *
82
82
  * const userOp = await createUnsignedUserOp({
83
83
  * transaction,
84
+ * factoryContract,
84
85
  * accountContract,
86
+ * adminAddress,
85
87
  * sponsorGas,
86
88
  * overrides,
87
89
  * });
@@ -246,7 +248,8 @@ export async function createUnsignedUserOp(args: {
246
248
  *
247
249
  * const signedUserOp = await signUserOp({
248
250
  * userOp,
249
- * options,
251
+ * chain,
252
+ * adminAccount,
250
253
  * });
251
254
  * ```
252
255
  * @walletUtils
@@ -3,6 +3,7 @@ import type { Chain } from "../../chains/types.js";
3
3
  import type { ThirdwebClient } from "../../client/client.js";
4
4
  import type { ThirdwebContract } from "../../contract/contract.js";
5
5
  import type { PreparedTransaction } from "../../transaction/prepare-transaction.js";
6
+ import type { TransactionReceipt } from "../../transaction/types.js";
6
7
  import type { Hex } from "../../utils/encoding/hex.js";
7
8
  import type { Prettify } from "../../utils/type-utils.js";
8
9
  import type { Account, SendTransactionOption } from "../interfaces/wallet.js";
@@ -119,3 +120,62 @@ export type PmTransactionData = {
119
120
  paymaster: Address;
120
121
  paymasterInput: Hex;
121
122
  };
123
+
124
+ export type UserOperationReceipt = {
125
+ receipt: TransactionReceipt;
126
+ logs: TransactionReceipt["logs"];
127
+ userOpHash: Hex;
128
+ entryPoint: Address;
129
+ sender: Address;
130
+ nonce: bigint;
131
+ paymaster: Address;
132
+ actualGasUsed: bigint;
133
+ actualGasCost: bigint;
134
+ success: boolean;
135
+ };
136
+
137
+ export function formatUserOperationReceipt(
138
+ userOpReceiptRaw: UserOperationReceipt,
139
+ ) {
140
+ const { receipt: transactionReceipt } = userOpReceiptRaw;
141
+
142
+ const receipt = {
143
+ ...transactionReceipt,
144
+ transactionHash: transactionReceipt.transactionHash,
145
+ blockNumber: transactionReceipt.blockNumber
146
+ ? BigInt(transactionReceipt.blockNumber)
147
+ : null,
148
+ contractAddress: transactionReceipt.contractAddress
149
+ ? transactionReceipt.contractAddress
150
+ : null,
151
+ cumulativeGasUsed: transactionReceipt.cumulativeGasUsed
152
+ ? BigInt(transactionReceipt.cumulativeGasUsed)
153
+ : null,
154
+ effectiveGasPrice: transactionReceipt.effectiveGasPrice
155
+ ? BigInt(transactionReceipt.effectiveGasPrice)
156
+ : null,
157
+ gasUsed: transactionReceipt.gasUsed
158
+ ? BigInt(transactionReceipt.gasUsed)
159
+ : null,
160
+ logs: transactionReceipt.logs,
161
+ to: transactionReceipt.to ? transactionReceipt.to : null,
162
+ transactionIndex: transactionReceipt.transactionIndex,
163
+ status: transactionReceipt.status,
164
+ type: transactionReceipt.type,
165
+ } as TransactionReceipt;
166
+
167
+ if (transactionReceipt.blobGasPrice)
168
+ receipt.blobGasPrice = BigInt(transactionReceipt.blobGasPrice);
169
+ if (transactionReceipt.blobGasUsed)
170
+ receipt.blobGasUsed = BigInt(transactionReceipt.blobGasUsed);
171
+
172
+ const userOpReceipt = {
173
+ ...userOpReceiptRaw,
174
+ receipt,
175
+ userOpHash: userOpReceiptRaw.userOpHash,
176
+ actualGasCost: BigInt(userOpReceiptRaw.actualGasCost),
177
+ actualGasUsed: BigInt(userOpReceiptRaw.actualGasUsed),
178
+ nonce: BigInt(userOpReceiptRaw.nonce),
179
+ } as UserOperationReceipt;
180
+ return userOpReceipt;
181
+ }