thirdweb 5.47.0 → 5.47.1-nightly-574ff0295dcbb39f2ddd753c9e8a264498aae99e-20240819000344

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 (89) hide show
  1. package/dist/cjs/exports/extensions/lens.js +4 -1
  2. package/dist/cjs/exports/extensions/lens.js.map +1 -1
  3. package/dist/cjs/exports/utils.js +7 -5
  4. package/dist/cjs/exports/utils.js.map +1 -1
  5. package/dist/cjs/extensions/lens/read/getFullProfile.js.map +1 -1
  6. package/dist/cjs/extensions/lens/read/getHandleFromProfileId.js.map +1 -1
  7. package/dist/cjs/extensions/lens/read/getProfileMetadata.js.map +1 -1
  8. package/dist/cjs/extensions/lens/read/resolveAddress.js +74 -0
  9. package/dist/cjs/extensions/lens/read/resolveAddress.js.map +1 -0
  10. package/dist/cjs/extensions/vote/read/getProposalVoteCounts.js +4 -3
  11. package/dist/cjs/extensions/vote/read/getProposalVoteCounts.js.map +1 -1
  12. package/dist/cjs/react/core/hooks/transaction/useSendAndConfirmTransaction.js +16 -1
  13. package/dist/cjs/react/core/hooks/transaction/useSendAndConfirmTransaction.js.map +1 -1
  14. package/dist/cjs/react/native/hooks/transaction/useSendTransaction.js +11 -0
  15. package/dist/cjs/react/native/hooks/transaction/useSendTransaction.js.map +1 -1
  16. package/dist/cjs/react/web/ui/TransactionButton/index.js +22 -6
  17. package/dist/cjs/react/web/ui/TransactionButton/index.js.map +1 -1
  18. package/dist/cjs/transaction/actions/send-and-confirm-transaction.js +15 -0
  19. package/dist/cjs/transaction/actions/send-and-confirm-transaction.js.map +1 -1
  20. package/dist/cjs/transaction/actions/send-transaction.js +13 -0
  21. package/dist/cjs/transaction/actions/send-transaction.js.map +1 -1
  22. package/dist/cjs/version.js +1 -1
  23. package/dist/cjs/version.js.map +1 -1
  24. package/dist/esm/exports/extensions/lens.js +2 -0
  25. package/dist/esm/exports/extensions/lens.js.map +1 -1
  26. package/dist/esm/exports/utils.js +1 -0
  27. package/dist/esm/exports/utils.js.map +1 -1
  28. package/dist/esm/extensions/lens/read/getFullProfile.js.map +1 -1
  29. package/dist/esm/extensions/lens/read/getHandleFromProfileId.js.map +1 -1
  30. package/dist/esm/extensions/lens/read/getProfileMetadata.js.map +1 -1
  31. package/dist/esm/extensions/lens/read/resolveAddress.js +71 -0
  32. package/dist/esm/extensions/lens/read/resolveAddress.js.map +1 -0
  33. package/dist/esm/extensions/vote/read/getProposalVoteCounts.js +4 -3
  34. package/dist/esm/extensions/vote/read/getProposalVoteCounts.js.map +1 -1
  35. package/dist/esm/react/core/hooks/transaction/useSendAndConfirmTransaction.js +16 -1
  36. package/dist/esm/react/core/hooks/transaction/useSendAndConfirmTransaction.js.map +1 -1
  37. package/dist/esm/react/native/hooks/transaction/useSendTransaction.js +11 -0
  38. package/dist/esm/react/native/hooks/transaction/useSendTransaction.js.map +1 -1
  39. package/dist/esm/react/web/ui/TransactionButton/index.js +22 -6
  40. package/dist/esm/react/web/ui/TransactionButton/index.js.map +1 -1
  41. package/dist/esm/transaction/actions/send-and-confirm-transaction.js +15 -0
  42. package/dist/esm/transaction/actions/send-and-confirm-transaction.js.map +1 -1
  43. package/dist/esm/transaction/actions/send-transaction.js +13 -0
  44. package/dist/esm/transaction/actions/send-transaction.js.map +1 -1
  45. package/dist/esm/version.js +1 -1
  46. package/dist/esm/version.js.map +1 -1
  47. package/dist/types/exports/extensions/lens.d.ts +1 -0
  48. package/dist/types/exports/extensions/lens.d.ts.map +1 -1
  49. package/dist/types/exports/utils.d.ts +1 -0
  50. package/dist/types/exports/utils.d.ts.map +1 -1
  51. package/dist/types/extensions/lens/read/getFullProfile.d.ts +16 -4
  52. package/dist/types/extensions/lens/read/getFullProfile.d.ts.map +1 -1
  53. package/dist/types/extensions/lens/read/getHandleFromProfileId.d.ts +12 -3
  54. package/dist/types/extensions/lens/read/getHandleFromProfileId.d.ts.map +1 -1
  55. package/dist/types/extensions/lens/read/getProfileMetadata.d.ts +4 -2
  56. package/dist/types/extensions/lens/read/getProfileMetadata.d.ts.map +1 -1
  57. package/dist/types/extensions/lens/read/resolveAddress.d.ts +47 -0
  58. package/dist/types/extensions/lens/read/resolveAddress.d.ts.map +1 -0
  59. package/dist/types/extensions/vote/read/getAll.d.ts +1 -1
  60. package/dist/types/extensions/vote/read/getProposalVoteCounts.d.ts +4 -3
  61. package/dist/types/extensions/vote/read/getProposalVoteCounts.d.ts.map +1 -1
  62. package/dist/types/react/core/hooks/transaction/useSendAndConfirmTransaction.d.ts +25 -1
  63. package/dist/types/react/core/hooks/transaction/useSendAndConfirmTransaction.d.ts.map +1 -1
  64. package/dist/types/react/native/hooks/transaction/useSendTransaction.d.ts +11 -0
  65. package/dist/types/react/native/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  66. package/dist/types/react/web/ui/TransactionButton/index.d.ts +22 -6
  67. package/dist/types/react/web/ui/TransactionButton/index.d.ts.map +1 -1
  68. package/dist/types/transaction/actions/send-and-confirm-transaction.d.ts +15 -0
  69. package/dist/types/transaction/actions/send-and-confirm-transaction.d.ts.map +1 -1
  70. package/dist/types/transaction/actions/send-transaction.d.ts +13 -0
  71. package/dist/types/transaction/actions/send-transaction.d.ts.map +1 -1
  72. package/dist/types/version.d.ts +1 -1
  73. package/dist/types/version.d.ts.map +1 -1
  74. package/package.json +1 -1
  75. package/src/exports/extensions/lens.ts +6 -0
  76. package/src/exports/utils.ts +2 -0
  77. package/src/extensions/lens/read/getFullProfile.ts +16 -4
  78. package/src/extensions/lens/read/getHandleFromProfileId.ts +12 -3
  79. package/src/extensions/lens/read/getProfileMetadata.ts +4 -2
  80. package/src/extensions/lens/read/resolveAddress.test.ts +23 -0
  81. package/src/extensions/lens/read/resolveAddress.ts +121 -0
  82. package/src/extensions/vote/read/getAll.ts +1 -1
  83. package/src/extensions/vote/read/getProposalVoteCounts.ts +4 -3
  84. package/src/react/core/hooks/transaction/useSendAndConfirmTransaction.ts +30 -5
  85. package/src/react/native/hooks/transaction/useSendTransaction.tsx +11 -0
  86. package/src/react/web/ui/TransactionButton/index.tsx +22 -6
  87. package/src/transaction/actions/send-and-confirm-transaction.ts +15 -0
  88. package/src/transaction/actions/send-transaction.ts +13 -0
  89. package/src/version.ts +1 -1
@@ -13,6 +13,17 @@ import { type SendTransactionConfig } from "../../../core/hooks/transaction/useS
13
13
  * sendTx(tx);
14
14
  * ```
15
15
  *
16
+ * ### Gasless usage with [thirdweb Engine](https://portal.thirdweb.com/engine)
17
+ * ```tsx
18
+ * import { useSendTransaction } from "thirdweb/react";
19
+ * const mutation = useSendTransaction({
20
+ * gasless: {
21
+ * provider: "engine",
22
+ * relayerUrl: "https://thirdweb.engine-***.thirdweb.com/relayer/***",
23
+ * relayerForwarderAddress: "0x...",
24
+ * }
25
+ * });
26
+ * ```
16
27
  * @transaction
17
28
  */
18
29
  export declare function useSendTransaction(config?: SendTransactionConfig): import("@tanstack/react-query").UseMutationResult<{
@@ -1 +1 @@
1
- {"version":3,"file":"useSendTransaction.d.ts","sourceRoot":"","sources":["../../../../../../src/react/native/hooks/transaction/useSendTransaction.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,uDAAuD,CAAC;AAI/D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,GAAE,qBAA0B;;;;;wFAQpE"}
1
+ {"version":3,"file":"useSendTransaction.d.ts","sourceRoot":"","sources":["../../../../../../src/react/native/hooks/transaction/useSendTransaction.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,uDAAuD,CAAC;AAI/D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,GAAE,qBAA0B;;;;;wFAQpE"}
@@ -5,6 +5,8 @@ import { type TransactionButtonProps } from "../../../core/hooks/transaction/tra
5
5
  * @param props - The props for this component.
6
6
  * Refer to [TransactionButtonProps](https://portal.thirdweb.com/references/typescript/v5/TransactionButtonProps) for details.
7
7
  * @example
8
+ *
9
+ * ### Basic usage
8
10
  * ```tsx
9
11
  * <TransactionButton
10
12
  * transaction={() => {}}
@@ -14,7 +16,8 @@ import { type TransactionButtonProps } from "../../../core/hooks/transaction/tra
14
16
  * Confirm Transaction
15
17
  * </TransactionButton>
16
18
  * ```
17
- * Customize the styling by passing the `unstyled` prop and your inline styles and/or classes:
19
+ *
20
+ * ### Customize the styling by passing the `unstyled` prop and your inline styles and/or classes:
18
21
  * ```tsx
19
22
  * <TransactionButton
20
23
  * transaction={() => {}}
@@ -25,7 +28,7 @@ import { type TransactionButtonProps } from "../../../core/hooks/transaction/tra
25
28
  * </TransactionButton>
26
29
  * ```
27
30
  *
28
- * Handle errors
31
+ * ### Handle errors
29
32
  * ```tsx
30
33
  * <TransactionButton
31
34
  * transaction={() => ...}
@@ -38,7 +41,7 @@ import { type TransactionButtonProps } from "../../../core/hooks/transaction/tra
38
41
  * </TransactionButton>
39
42
  * ```
40
43
  *
41
- * Alert when a transaction is sent
44
+ * ### Alert when a transaction is sent
42
45
  * ```tsx
43
46
  * <TransactionButton
44
47
  * transaction={() => ...}
@@ -51,7 +54,7 @@ import { type TransactionButtonProps } from "../../../core/hooks/transaction/tra
51
54
  * </TransactionButton>
52
55
  * ```
53
56
  *
54
- * Alert when a transaction is completed
57
+ * ### Alert when a transaction is completed
55
58
  * ```tsx
56
59
  * <TransactionButton
57
60
  * transaction={() => ...}
@@ -65,7 +68,7 @@ import { type TransactionButtonProps } from "../../../core/hooks/transaction/tra
65
68
  * </TransactionButton>
66
69
  * ```
67
70
  *
68
- * The onClick prop, if provided, will be called before the transaction is sent.
71
+ * ### The onClick prop, if provided, will be called before the transaction is sent.
69
72
  * ```tsx
70
73
  * <TransactionButton
71
74
  * onClick={() => alert("Transaction is about to be sent")}
@@ -75,7 +78,7 @@ import { type TransactionButtonProps } from "../../../core/hooks/transaction/tra
75
78
  * </TransactionButton>
76
79
  * ```
77
80
  *
78
- * Attach custom Pay metadata
81
+ * ### Attach custom Pay metadata
79
82
  * ```tsx
80
83
  * <TransactionButton
81
84
  * payModal={{
@@ -89,6 +92,19 @@ import { type TransactionButtonProps } from "../../../core/hooks/transaction/tra
89
92
  * ...
90
93
  * </TransactionButton>
91
94
  * ```
95
+ *
96
+ * ### Gasless usage with [thirdweb Engine](https://portal.thirdweb.com/engine)
97
+ * ```tsx
98
+ * <TransactionButton
99
+ * gasless={{
100
+ * provider: "engine",
101
+ * relayerUrl: "https://thirdweb.engine-***.thirdweb.com/relayer/***",
102
+ * relayerForwarderAddress: "0x...",
103
+ * }}
104
+ * >
105
+ * ...
106
+ * </TransactionButton>
107
+ * ```
92
108
  * @component
93
109
  */
94
110
  export declare function TransactionButton(props: TransactionButtonProps): import("react/jsx-runtime.js").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/react/web/ui/TransactionButton/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,6DAA6D,CAAC;AAMrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,8CAkE9D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/react/web/ui/TransactionButton/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,6DAA6D,CAAC;AAMrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2GG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,8CAkE9D"}
@@ -7,6 +7,8 @@ import { type SendTransactionOptions } from "./send-transaction.js";
7
7
  * @throws An error if the wallet is not connected.
8
8
  * @transaction
9
9
  * @example
10
+ *
11
+ * ### Basic usage
10
12
  * ```ts
11
13
  * import { sendAndConfirmTransaction } from "thirdweb";
12
14
  *
@@ -15,6 +17,19 @@ import { type SendTransactionOptions } from "./send-transaction.js";
15
17
  * transaction
16
18
  * });
17
19
  * ```
20
+ *
21
+ * ### Gasless usage with [thirdweb Engine](https://portal.thirdweb.com/engine)
22
+ * ```ts
23
+ * const transactionReceipt = await sendAndConfirmTransaction({
24
+ * account,
25
+ * transaction,
26
+ * gasless: {
27
+ * provider: "engine",
28
+ * relayerUrl: "https://thirdweb.engine-***.thirdweb.com/relayer/***",
29
+ * relayerForwarderAddress: "0x...",
30
+ * }
31
+ * });
32
+ * ```
18
33
  */
19
34
  export declare function sendAndConfirmTransaction(options: SendTransactionOptions): Promise<TransactionReceipt>;
20
35
  //# sourceMappingURL=send-and-confirm-transaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"send-and-confirm-transaction.d.ts","sourceRoot":"","sources":["../../../../src/transaction/actions/send-and-confirm-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,uBAAuB,CAAC;AAG/B;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,kBAAkB,CAAC,CAG7B"}
1
+ {"version":3,"file":"send-and-confirm-transaction.d.ts","sourceRoot":"","sources":["../../../../src/transaction/actions/send-and-confirm-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,uBAAuB,CAAC;AAG/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,kBAAkB,CAAC,CAG7B"}
@@ -93,6 +93,19 @@ export type SendTransactionOptions = {
93
93
  * transaction,
94
94
  * });
95
95
  * ```
96
+ *
97
+ * ### Gasless usage with [thirdweb Engine](https://portal.thirdweb.com/engine)
98
+ * ```ts
99
+ * const { transactionHash } = await sendTransaction({
100
+ * account,
101
+ * transaction,
102
+ * gasless: {
103
+ * provider: "engine",
104
+ * relayerUrl: "https://thirdweb.engine-***.thirdweb.com/relayer/***",
105
+ * relayerForwarderAddress: "0x...",
106
+ * }
107
+ * });
108
+ * ```
96
109
  */
97
110
  export declare function sendTransaction(options: SendTransactionOptions): Promise<WaitForReceiptOptions>;
98
111
  //# sourceMappingURL=send-transaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"send-transaction.d.ts","sourceRoot":"","sources":["../../../../src/transaction/actions/send-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,OAAO,CAAC;IAGjB,WAAW,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAkChC"}
1
+ {"version":3,"file":"send-transaction.d.ts","sourceRoot":"","sources":["../../../../src/transaction/actions/send-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,OAAO,CAAC;IAGjB,WAAW,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmGG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAkChC"}
@@ -1,2 +1,2 @@
1
- export declare const version = "5.47.0";
1
+ export declare const version = "5.47.1-nightly-574ff0295dcbb39f2ddd753c9e8a264498aae99e-20240819000344";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,2EAA2E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thirdweb",
3
- "version": "5.47.0",
3
+ "version": "5.47.1-nightly-574ff0295dcbb39f2ddd753c9e8a264498aae99e-20240819000344",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/thirdweb-dev/js.git#main"
@@ -119,6 +119,8 @@ export {
119
119
  /**
120
120
  * Custom extension
121
121
  */
122
+
123
+ // Read
122
124
  export {
123
125
  getHandleFromProfileId,
124
126
  type GetHandleFromProfileIdParams,
@@ -133,6 +135,10 @@ export {
133
135
  type GetFullProfileParams,
134
136
  type FullProfileResponse,
135
137
  } from "../../extensions/lens/read/getFullProfile.js";
138
+ export {
139
+ resolveAddress,
140
+ type ResolveLensAddressParams,
141
+ } from "../../extensions/lens/read/resolveAddress.js";
136
142
 
137
143
  /**
138
144
  * Contract addresses
@@ -131,6 +131,8 @@ export {
131
131
  type AddressInput,
132
132
  } from "../utils/address.js";
133
133
 
134
+ export { isBytes } from "viem";
135
+
134
136
  // ------------------------------------------------
135
137
  // abi
136
138
  // ------------------------------------------------
@@ -2,7 +2,6 @@ import { polygon } from "../../../chains/chain-definitions/polygon.js";
2
2
  import type { Chain } from "../../../chains/types.js";
3
3
  import type { ThirdwebClient } from "../../../client/client.js";
4
4
  import { getContract } from "../../../contract/contract.js";
5
- import type { Hex } from "../../../utils/encoding/hex.js";
6
5
  import { getProfile } from "../__generated__/LensHub/read/getProfile.js";
7
6
  import { getDefaultHandle } from "../__generated__/TokenHandleRegistry/read/getDefaultHandle.js";
8
7
  import {
@@ -19,10 +18,23 @@ export type GetFullProfileParams = {
19
18
  profileId: bigint;
20
19
  client: ThirdwebClient;
21
20
  includeJoinDate?: boolean;
21
+ /**
22
+ * Override variables for Lens smart contracts
23
+ * Make sure all of them have to be on the same network
24
+ */
22
25
  overrides?: {
23
- lensHubAddress?: Hex;
24
- lensHandleAddress?: Hex;
25
- tokenHandleRegistryAddress?: Hex;
26
+ /**
27
+ * Contract address for the LensHub contract
28
+ */
29
+ lensHubAddress?: string;
30
+ /**
31
+ * Contract address for the LensHandle contract
32
+ */
33
+ lensHandleAddress?: string;
34
+ /**
35
+ * Contract address for the TokenHandleRegistry contract
36
+ */
37
+ tokenHandleRegistryAddress?: string;
26
38
  chain?: Chain;
27
39
  };
28
40
  };
@@ -2,7 +2,6 @@ import { polygon } from "../../../chains/chain-definitions/polygon.js";
2
2
  import type { Chain } from "../../../chains/types.js";
3
3
  import type { ThirdwebClient } from "../../../client/client.js";
4
4
  import { getContract } from "../../../contract/contract.js";
5
- import type { Hex } from "../../../utils/encoding/hex.js";
6
5
  import { getHandle } from "../__generated__/LensHandle/read/getHandle.js";
7
6
  import { getDefaultHandle } from "../__generated__/TokenHandleRegistry/read/getDefaultHandle.js";
8
7
  import {
@@ -16,9 +15,19 @@ import {
16
15
  export type GetHandleFromProfileIdParams = {
17
16
  profileId: bigint;
18
17
  client: ThirdwebClient;
18
+ /**
19
+ * Override variables for LensHandle contract and TokenHandleRegistry contract
20
+ * Make sure both of them have to be on the same network
21
+ */
19
22
  overrides?: {
20
- lensHandleAddress?: Hex;
21
- tokenHandleRegistryAddress?: Hex;
23
+ /**
24
+ * Contract address for the LensHandle contract
25
+ */
26
+ lensHandleAddress?: string;
27
+ /**
28
+ * Contract address for the TokenHandleRegistry contract
29
+ */
30
+ tokenHandleRegistryAddress?: string;
22
31
  chain?: Chain;
23
32
  };
24
33
  };
@@ -2,7 +2,6 @@ import { polygon } from "../../../chains/chain-definitions/polygon.js";
2
2
  import type { Chain } from "../../../chains/types.js";
3
3
  import type { ThirdwebClient } from "../../../client/client.js";
4
4
  import { getContract } from "../../../contract/contract.js";
5
- import type { Hex } from "../../../utils/encoding/hex.js";
6
5
  import { getProfile } from "../__generated__/LensHub/read/getProfile.js";
7
6
  import { LENS_HUB_ADDRESS } from "../consts.js";
8
7
  import type { LensProfileSchema } from "./type.js";
@@ -14,7 +13,10 @@ export type GetProfileMetadataParams = {
14
13
  profileId: bigint;
15
14
  client: ThirdwebClient;
16
15
  overrides?: {
17
- lensHubAddress?: Hex;
16
+ /**
17
+ * Contract address for the LensHub contract
18
+ */
19
+ lensHubAddress?: string;
18
20
  chain?: Chain;
19
21
  };
20
22
  };
@@ -0,0 +1,23 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { TEST_CLIENT } from "~test/test-clients.js";
3
+ import { isAddress } from "../../../utils/address.js";
4
+ import { resolveAddress } from "./resolveAddress.js";
5
+
6
+ describe("resolve lens address", () => {
7
+ it("should resolve to correct address", async () => {
8
+ const address = await resolveAddress({
9
+ client: TEST_CLIENT,
10
+ name: "captain_jack",
11
+ });
12
+ // "captain_jack" is a valid localname so it should definitely resolve to a valid address
13
+ expect(isAddress(address)).toBe(true);
14
+ });
15
+
16
+ it("should throw if passed an invalid lens handle", async () => {
17
+ await expect(() =>
18
+ resolveAddress({ client: TEST_CLIENT, name: "vitalik.eth" }),
19
+ ).rejects.toThrowError(
20
+ "Could not fetch the wallet address for lens handle: vitalik.eth",
21
+ );
22
+ });
23
+ });
@@ -0,0 +1,121 @@
1
+ import type { Chain } from "../../../chains/types.js";
2
+ import type { ThirdwebClient } from "../../../client/client.js";
3
+ import { ZERO_ADDRESS } from "../../../constants/addresses.js";
4
+ import { getAddress, isAddress } from "../../../utils/address.js";
5
+ import { withCache } from "../../../utils/promise/withCache.js";
6
+
7
+ /**
8
+ * @extension LENS
9
+ */
10
+ export type ResolveLensAddressParams = {
11
+ /**
12
+ * Either a full lens handle, or a lens localName
13
+ * Examples:
14
+ * 1. Full handle: "lens/vitalik"
15
+ * 2. Just local name: "vitalik"
16
+ */
17
+ name: string;
18
+ /**
19
+ * a [`ThirdwebClient`](https://portal.thirdweb.com/references/typescript/v5/ThirdwebClient)
20
+ */
21
+ client: ThirdwebClient;
22
+ /**
23
+ * Override parameters for Lens contract, defaults to LensHandle contract on Polygon
24
+ */
25
+ overrides?: {
26
+ /**
27
+ * The contract address of the [`LensHandle contract`](https://www.lens.xyz/docs/resources/smart-contracts)
28
+ */
29
+ lensHandleContractAddress?: string;
30
+ /**
31
+ * The chain which `lensHandleContractAddress` is deployed on
32
+ */
33
+ chain?: Chain;
34
+ };
35
+ };
36
+
37
+ /**
38
+ * Take in a Lens handle or local-name and return the wallet address behind that handle/local-name.
39
+ * For example, "lens/vitalik" is a handle, with "lens" being the namespace and "vitalik" being the local name
40
+ * @extension LENS
41
+ * @example
42
+ * ```ts
43
+ * import { resolveAddress } from "thirdweb/extensions/lens";
44
+ *
45
+ * const walletAddress = await resolveAddress({
46
+ * name: "vitalik",
47
+ * client,
48
+ * });
49
+ * ```
50
+ */
51
+ export async function resolveAddress(
52
+ options: ResolveLensAddressParams,
53
+ ): Promise<string> {
54
+ const { name, overrides, client } = options;
55
+ if (isAddress(name)) {
56
+ return getAddress(name);
57
+ }
58
+ return withCache(
59
+ async (): Promise<string> => {
60
+ const [
61
+ { getContract },
62
+ { getTokenId },
63
+ { ownerOf },
64
+ { polygon },
65
+ { LENS_HANDLE_ADDRESS },
66
+ ] = await Promise.all([
67
+ import("../../../contract/contract.js"),
68
+ import("../__generated__/LensHandle/read/getTokenId.js"),
69
+ import("../../erc721/__generated__/IERC721A/read/ownerOf.js"),
70
+ import("../../../chains/chain-definitions/polygon.js"),
71
+ import("../consts.js"),
72
+ ]);
73
+ const contract = getContract({
74
+ address: overrides?.lensHandleContractAddress || LENS_HANDLE_ADDRESS,
75
+ chain: overrides?.chain || polygon,
76
+ client,
77
+ });
78
+ /**
79
+ * For better UX, we accept both handle and local name
80
+ * The difference: handle = <namespace>/<local-name>
81
+ * For example, "lens/vitalik" is a handle, with "lens" being the namespace and "vitalik" being the local name
82
+ * Currently there's only 1 namespace called "lens" but we should make sure the code can scale when there are more
83
+ *
84
+ * Since lens does not allow "/" in the name,
85
+ * if the string contains "/", it is either invalid, or it definitely contains the namespace
86
+ * In that case we remove the possible namespace because the `getTokenId` method only accepts localName
87
+ */
88
+ const isPossibleHandle = name.includes("/");
89
+ const localName = isPossibleHandle ? name.split("/")[1] : name;
90
+ if (!localName) {
91
+ throw new Error(`missing local name from ${name}`);
92
+ }
93
+ const tokenId = await getTokenId({ contract, localName });
94
+ if (!tokenId) {
95
+ throw new Error(
96
+ `Could not retrieve tokenId from localName: ${localName}`,
97
+ );
98
+ }
99
+
100
+ /**
101
+ * Another thing to note is that even if you enter an invalid localName,
102
+ * `getTokenId` still returns you a tokenId - so never rely on the result alone.
103
+ * Check if the tokenId truly exists using `exists` or in this case, `ownerOf`
104
+ */
105
+ const address = await ownerOf({ contract, tokenId }).catch(
106
+ () => ZERO_ADDRESS,
107
+ );
108
+ if (address === ZERO_ADDRESS) {
109
+ throw new Error(
110
+ `Could not fetch the wallet address for lens handle: ${name}`,
111
+ );
112
+ }
113
+ return address;
114
+ },
115
+ {
116
+ cacheKey: `lens:addr:${name}`,
117
+ // 1min cache
118
+ cacheTime: 60 * 1000,
119
+ },
120
+ );
121
+ }
@@ -42,7 +42,7 @@ export type ProposalItem = {
42
42
  */
43
43
  stateLabel: string | undefined;
44
44
  /**
45
- * The current vote info. See type ProposalVoteInfo for more context
45
+ * The current vote info. See type [`ProposalVoteInfo`](https://portal.thirdweb.com/references/typescript/v5/ProposalItem) for more context
46
46
  */
47
47
  votes: ProposalVoteInfo;
48
48
  /**
@@ -12,6 +12,7 @@ export type ProposalVoteInfo = { [K in keyof typeof VoteType]: bigint };
12
12
  * Get the info about Against, For and Abstain votes of a proposal
13
13
  * @param options
14
14
  * @returns the object containing the info about Against, For and Abstain votes of a proposal
15
+ * Note: the count is displayed in "wei"
15
16
  * @extension VOTE
16
17
  * @example
17
18
  * ```ts
@@ -21,9 +22,9 @@ export type ProposalVoteInfo = { [K in keyof typeof VoteType]: bigint };
21
22
  *
22
23
  * // Example result
23
24
  * {
24
- * against: 12n, // 12 users voted against the proposal
25
- * for: 104n, // 104 users support the proposal
26
- * abstain: 3n, // 3 users voted abstain on this proposal
25
+ * for: 12000000000000000000n, // 12 tokens (with a decimals of 18) were used to vote "for"
26
+ * against: 7000000000000000000n, // 7 tokens (with a decimals of 18) were used to vote "against"
27
+ * abstain: 0n, // no user has voted abstain on this proposal
27
28
  * }
28
29
  * ```
29
30
  */
@@ -1,9 +1,21 @@
1
1
  import { type UseMutationResult, useMutation } from "@tanstack/react-query";
2
+ import type { GaslessOptions } from "../../../../transaction/actions/gasless/types.js";
2
3
  import { sendAndConfirmTransaction } from "../../../../transaction/actions/send-and-confirm-transaction.js";
3
4
  import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
4
5
  import type { TransactionReceipt } from "../../../../transaction/types.js";
5
6
  import { useActiveAccount } from "../wallets/useActiveAccount.js";
6
7
 
8
+ /**
9
+ * Configuration for the `useSendTransaction` hook.
10
+ */
11
+ export type SendAndConfirmTransactionConfig = {
12
+ /**
13
+ * Configuration for gasless transactions.
14
+ * Refer to [`GaslessOptions`](https://portal.thirdweb.com/references/typescript/v5/GaslessOptions) for more details.
15
+ */
16
+ gasless?: GaslessOptions;
17
+ };
18
+
7
19
  /**
8
20
  * A hook to send a transaction.
9
21
  * @returns A mutation object to send a transaction.
@@ -15,14 +27,26 @@ import { useActiveAccount } from "../wallets/useActiveAccount.js";
15
27
  * // later
16
28
  * sendAndConfirmTx(tx);
17
29
  * ```
30
+ *
31
+ *
32
+ * ### Gasless usage with [thirdweb Engine](https://portal.thirdweb.com/engine)
33
+ * ```tsx
34
+ * import { useSendAndConfirmTransaction } from "thirdweb/react";
35
+ * const mutation = useSendAndConfirmTransaction({
36
+ * gasless: {
37
+ * provider: "engine",
38
+ * relayerUrl: "https://thirdweb.engine-***.thirdweb.com/relayer/***",
39
+ * relayerForwarderAddress: "0x...",
40
+ * }
41
+ * });
42
+ * ```
18
43
  * @transaction
19
44
  */
20
- export function useSendAndConfirmTransaction(): UseMutationResult<
21
- TransactionReceipt,
22
- Error,
23
- PreparedTransaction
24
- > {
45
+ export function useSendAndConfirmTransaction(
46
+ config: SendAndConfirmTransactionConfig = {},
47
+ ): UseMutationResult<TransactionReceipt, Error, PreparedTransaction> {
25
48
  const account = useActiveAccount();
49
+ const { gasless } = config;
26
50
  return useMutation({
27
51
  mutationFn: async (transaction) => {
28
52
  if (!account) {
@@ -31,6 +55,7 @@ export function useSendAndConfirmTransaction(): UseMutationResult<
31
55
  return await sendAndConfirmTransaction({
32
56
  transaction,
33
57
  account,
58
+ gasless,
34
59
  });
35
60
  },
36
61
  });
@@ -19,6 +19,17 @@ import { useSwitchActiveWalletChain } from "../../../core/hooks/wallets/useSwitc
19
19
  * sendTx(tx);
20
20
  * ```
21
21
  *
22
+ * ### Gasless usage with [thirdweb Engine](https://portal.thirdweb.com/engine)
23
+ * ```tsx
24
+ * import { useSendTransaction } from "thirdweb/react";
25
+ * const mutation = useSendTransaction({
26
+ * gasless: {
27
+ * provider: "engine",
28
+ * relayerUrl: "https://thirdweb.engine-***.thirdweb.com/relayer/***",
29
+ * relayerForwarderAddress: "0x...",
30
+ * }
31
+ * });
32
+ * ```
22
33
  * @transaction
23
34
  */
24
35
  export function useSendTransaction(config: SendTransactionConfig = {}) {
@@ -15,6 +15,8 @@ import { Button } from "../components/buttons.js";
15
15
  * @param props - The props for this component.
16
16
  * Refer to [TransactionButtonProps](https://portal.thirdweb.com/references/typescript/v5/TransactionButtonProps) for details.
17
17
  * @example
18
+ *
19
+ * ### Basic usage
18
20
  * ```tsx
19
21
  * <TransactionButton
20
22
  * transaction={() => {}}
@@ -24,7 +26,8 @@ import { Button } from "../components/buttons.js";
24
26
  * Confirm Transaction
25
27
  * </TransactionButton>
26
28
  * ```
27
- * Customize the styling by passing the `unstyled` prop and your inline styles and/or classes:
29
+ *
30
+ * ### Customize the styling by passing the `unstyled` prop and your inline styles and/or classes:
28
31
  * ```tsx
29
32
  * <TransactionButton
30
33
  * transaction={() => {}}
@@ -35,7 +38,7 @@ import { Button } from "../components/buttons.js";
35
38
  * </TransactionButton>
36
39
  * ```
37
40
  *
38
- * Handle errors
41
+ * ### Handle errors
39
42
  * ```tsx
40
43
  * <TransactionButton
41
44
  * transaction={() => ...}
@@ -48,7 +51,7 @@ import { Button } from "../components/buttons.js";
48
51
  * </TransactionButton>
49
52
  * ```
50
53
  *
51
- * Alert when a transaction is sent
54
+ * ### Alert when a transaction is sent
52
55
  * ```tsx
53
56
  * <TransactionButton
54
57
  * transaction={() => ...}
@@ -61,7 +64,7 @@ import { Button } from "../components/buttons.js";
61
64
  * </TransactionButton>
62
65
  * ```
63
66
  *
64
- * Alert when a transaction is completed
67
+ * ### Alert when a transaction is completed
65
68
  * ```tsx
66
69
  * <TransactionButton
67
70
  * transaction={() => ...}
@@ -75,7 +78,7 @@ import { Button } from "../components/buttons.js";
75
78
  * </TransactionButton>
76
79
  * ```
77
80
  *
78
- * The onClick prop, if provided, will be called before the transaction is sent.
81
+ * ### The onClick prop, if provided, will be called before the transaction is sent.
79
82
  * ```tsx
80
83
  * <TransactionButton
81
84
  * onClick={() => alert("Transaction is about to be sent")}
@@ -85,7 +88,7 @@ import { Button } from "../components/buttons.js";
85
88
  * </TransactionButton>
86
89
  * ```
87
90
  *
88
- * Attach custom Pay metadata
91
+ * ### Attach custom Pay metadata
89
92
  * ```tsx
90
93
  * <TransactionButton
91
94
  * payModal={{
@@ -99,6 +102,19 @@ import { Button } from "../components/buttons.js";
99
102
  * ...
100
103
  * </TransactionButton>
101
104
  * ```
105
+ *
106
+ * ### Gasless usage with [thirdweb Engine](https://portal.thirdweb.com/engine)
107
+ * ```tsx
108
+ * <TransactionButton
109
+ * gasless={{
110
+ * provider: "engine",
111
+ * relayerUrl: "https://thirdweb.engine-***.thirdweb.com/relayer/***",
112
+ * relayerForwarderAddress: "0x...",
113
+ * }}
114
+ * >
115
+ * ...
116
+ * </TransactionButton>
117
+ * ```
102
118
  * @component
103
119
  */
104
120
  export function TransactionButton(props: TransactionButtonProps) {