thirdweb 5.45.2-nightly-b15aa4cdff3f3b233025da285780668a18fe29ab-20240813000336 → 5.46.0-nightly-814024ae249141ad1446ce7f21793b1d37b95d13-20240814000405

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 (107) hide show
  1. package/dist/cjs/contract/actions/get-compiler-metadata.js +37 -0
  2. package/dist/cjs/contract/actions/get-compiler-metadata.js.map +1 -0
  3. package/dist/cjs/exports/contract.js +3 -1
  4. package/dist/cjs/exports/contract.js.map +1 -1
  5. package/dist/cjs/exports/extensions/erc1155.js +3 -1
  6. package/dist/cjs/exports/extensions/erc1155.js.map +1 -1
  7. package/dist/cjs/exports/extensions/erc721.js +3 -1
  8. package/dist/cjs/exports/extensions/erc721.js.map +1 -1
  9. package/dist/cjs/extensions/erc1155/write/updateTokenURI.js +81 -0
  10. package/dist/cjs/extensions/erc1155/write/updateTokenURI.js.map +1 -0
  11. package/dist/cjs/extensions/erc721/write/updateTokenURI.js +81 -0
  12. package/dist/cjs/extensions/erc721/write/updateTokenURI.js.map +1 -0
  13. package/dist/cjs/utils/any-evm/deploy-metadata.js +2 -27
  14. package/dist/cjs/utils/any-evm/deploy-metadata.js.map +1 -1
  15. package/dist/cjs/version.js +1 -1
  16. package/dist/cjs/wallets/in-app/core/authentication/getLoginPath.js +16 -2
  17. package/dist/cjs/wallets/in-app/core/authentication/getLoginPath.js.map +1 -1
  18. package/dist/cjs/wallets/in-app/core/authentication/siwe.js +4 -5
  19. package/dist/cjs/wallets/in-app/core/authentication/siwe.js.map +1 -1
  20. package/dist/cjs/wallets/in-app/core/authentication/types.js.map +1 -1
  21. package/dist/cjs/wallets/in-app/native/auth/native-auth.js +3 -3
  22. package/dist/cjs/wallets/in-app/native/auth/native-auth.js.map +1 -1
  23. package/dist/cjs/wallets/in-app/native/native-connector.js +10 -10
  24. package/dist/cjs/wallets/in-app/native/native-connector.js.map +1 -1
  25. package/dist/cjs/wallets/in-app/web/in-app.js +15 -0
  26. package/dist/cjs/wallets/in-app/web/in-app.js.map +1 -1
  27. package/dist/cjs/wallets/in-app/web/lib/web-connector.js +5 -5
  28. package/dist/cjs/wallets/in-app/web/lib/web-connector.js.map +1 -1
  29. package/dist/cjs/wallets/types.js +8 -1
  30. package/dist/cjs/wallets/types.js.map +1 -1
  31. package/dist/esm/contract/actions/get-compiler-metadata.js +34 -0
  32. package/dist/esm/contract/actions/get-compiler-metadata.js.map +1 -0
  33. package/dist/esm/exports/contract.js +1 -0
  34. package/dist/esm/exports/contract.js.map +1 -1
  35. package/dist/esm/exports/extensions/erc1155.js +1 -0
  36. package/dist/esm/exports/extensions/erc1155.js.map +1 -1
  37. package/dist/esm/exports/extensions/erc721.js +1 -0
  38. package/dist/esm/exports/extensions/erc721.js.map +1 -1
  39. package/dist/esm/extensions/erc1155/write/updateTokenURI.js +77 -0
  40. package/dist/esm/extensions/erc1155/write/updateTokenURI.js.map +1 -0
  41. package/dist/esm/extensions/erc721/write/updateTokenURI.js +77 -0
  42. package/dist/esm/extensions/erc721/write/updateTokenURI.js.map +1 -0
  43. package/dist/esm/utils/any-evm/deploy-metadata.js +1 -26
  44. package/dist/esm/utils/any-evm/deploy-metadata.js.map +1 -1
  45. package/dist/esm/version.js +1 -1
  46. package/dist/esm/wallets/in-app/core/authentication/getLoginPath.js +16 -2
  47. package/dist/esm/wallets/in-app/core/authentication/getLoginPath.js.map +1 -1
  48. package/dist/esm/wallets/in-app/core/authentication/siwe.js +4 -5
  49. package/dist/esm/wallets/in-app/core/authentication/siwe.js.map +1 -1
  50. package/dist/esm/wallets/in-app/core/authentication/types.js.map +1 -1
  51. package/dist/esm/wallets/in-app/native/auth/native-auth.js +3 -3
  52. package/dist/esm/wallets/in-app/native/auth/native-auth.js.map +1 -1
  53. package/dist/esm/wallets/in-app/native/native-connector.js +10 -10
  54. package/dist/esm/wallets/in-app/native/native-connector.js.map +1 -1
  55. package/dist/esm/wallets/in-app/web/in-app.js +15 -0
  56. package/dist/esm/wallets/in-app/web/in-app.js.map +1 -1
  57. package/dist/esm/wallets/in-app/web/lib/web-connector.js +5 -5
  58. package/dist/esm/wallets/in-app/web/lib/web-connector.js.map +1 -1
  59. package/dist/esm/wallets/types.js +7 -0
  60. package/dist/esm/wallets/types.js.map +1 -1
  61. package/dist/types/contract/actions/get-compiler-metadata.d.ts +20 -0
  62. package/dist/types/contract/actions/get-compiler-metadata.d.ts.map +1 -0
  63. package/dist/types/exports/contract.d.ts +1 -0
  64. package/dist/types/exports/contract.d.ts.map +1 -1
  65. package/dist/types/exports/extensions/erc1155.d.ts +1 -0
  66. package/dist/types/exports/extensions/erc1155.d.ts.map +1 -1
  67. package/dist/types/exports/extensions/erc721.d.ts +1 -0
  68. package/dist/types/exports/extensions/erc721.d.ts.map +1 -1
  69. package/dist/types/extensions/erc1155/write/updateTokenURI.d.ts +37 -0
  70. package/dist/types/extensions/erc1155/write/updateTokenURI.d.ts.map +1 -0
  71. package/dist/types/extensions/erc721/write/updateTokenURI.d.ts +37 -0
  72. package/dist/types/extensions/erc721/write/updateTokenURI.d.ts.map +1 -0
  73. package/dist/types/react/core/utils/storage.d.ts +1 -1
  74. package/dist/types/react/core/utils/storage.d.ts.map +1 -1
  75. package/dist/types/utils/any-evm/deploy-metadata.d.ts.map +1 -1
  76. package/dist/types/version.d.ts +1 -1
  77. package/dist/types/wallets/in-app/core/authentication/getLoginPath.d.ts +1 -1
  78. package/dist/types/wallets/in-app/core/authentication/getLoginPath.d.ts.map +1 -1
  79. package/dist/types/wallets/in-app/core/authentication/siwe.d.ts +4 -3
  80. package/dist/types/wallets/in-app/core/authentication/siwe.d.ts.map +1 -1
  81. package/dist/types/wallets/in-app/core/authentication/types.d.ts +5 -4
  82. package/dist/types/wallets/in-app/core/authentication/types.d.ts.map +1 -1
  83. package/dist/types/wallets/in-app/native/auth/native-auth.d.ts +3 -2
  84. package/dist/types/wallets/in-app/native/auth/native-auth.d.ts.map +1 -1
  85. package/dist/types/wallets/in-app/native/native-connector.d.ts.map +1 -1
  86. package/dist/types/wallets/in-app/web/in-app.d.ts +15 -0
  87. package/dist/types/wallets/in-app/web/in-app.d.ts.map +1 -1
  88. package/dist/types/wallets/types.d.ts +2 -1
  89. package/dist/types/wallets/types.d.ts.map +1 -1
  90. package/package.json +2 -2
  91. package/src/contract/actions/get-compiler-metadata.ts +40 -0
  92. package/src/exports/contract.ts +2 -0
  93. package/src/exports/extensions/erc1155.ts +6 -0
  94. package/src/exports/extensions/erc721.ts +4 -0
  95. package/src/extensions/erc1155/write/updateTokenURI.ts +97 -0
  96. package/src/extensions/erc721/write/updateTokenURI.ts +97 -0
  97. package/src/extensions/prebuilts/deploy-split.test.ts +1 -1
  98. package/src/utils/any-evm/deploy-metadata.ts +1 -28
  99. package/src/version.ts +1 -1
  100. package/src/wallets/in-app/core/authentication/getLoginPath.ts +17 -3
  101. package/src/wallets/in-app/core/authentication/siwe.ts +8 -8
  102. package/src/wallets/in-app/core/authentication/types.ts +5 -4
  103. package/src/wallets/in-app/native/auth/native-auth.ts +6 -5
  104. package/src/wallets/in-app/native/native-connector.ts +15 -15
  105. package/src/wallets/in-app/web/in-app.ts +15 -0
  106. package/src/wallets/in-app/web/lib/web-connector.ts +5 -5
  107. package/src/wallets/types.ts +8 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thirdweb",
3
- "version": "5.45.2-nightly-b15aa4cdff3f3b233025da285780668a18fe29ab-20240813000336",
3
+ "version": "5.46.0-nightly-814024ae249141ad1446ce7f21793b1d37b95d13-20240814000405",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/thirdweb-dev/js.git#main"
@@ -297,7 +297,7 @@
297
297
  "expo-web-browser": "13.0.3",
298
298
  "happy-dom": "^14.12.0",
299
299
  "msw": "^2.3.4",
300
- "react-native": "0.74.2",
300
+ "react-native": "0.74.5",
301
301
  "react-native-aes-gcm-crypto": "0.2.2",
302
302
  "react-native-quick-crypto": "0.7.0-rc.6",
303
303
  "react-native-svg": "15.3.0",
@@ -0,0 +1,40 @@
1
+ import type { ThirdwebContract } from "../contract.js";
2
+ import { formatCompilerMetadata } from "./compiler-metadata.js";
3
+
4
+ /**
5
+ * Down the compiled metadata from thirdweb contract api and format it
6
+ * @param metadata The (json) data returned from https://contract.thirdweb.com/metadata/<chainId>/<contractAddress>
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { getCompilerMetadata, getContract } from "thirdweb/contracts";
11
+ *
12
+ * const contract = getContract({
13
+ * address: "0x...",
14
+ * chain: ethereum,
15
+ * client: "",
16
+ * });
17
+ * const metadata = await getCompilerMetadata(contract);
18
+ * ```
19
+ * @returns
20
+ */
21
+ export async function getCompilerMetadata(contract: ThirdwebContract) {
22
+ const { address, chain } = contract;
23
+ const response = await fetch(
24
+ `https://contract.thirdweb.com/metadata/${chain.id}/${address}`,
25
+ {
26
+ method: "GET",
27
+ headers: {
28
+ "Content-Type": "application/json",
29
+ },
30
+ },
31
+ );
32
+ if (!response.ok) {
33
+ const errorMsg = await response.json();
34
+ throw new Error(
35
+ errorMsg.message || errorMsg.error || "Failed to get compiler metadata",
36
+ );
37
+ }
38
+ const data = await response.json();
39
+ return formatCompilerMetadata(data);
40
+ }
@@ -34,3 +34,5 @@ export {
34
34
  type PrepareDirectDeployTransactionOptions,
35
35
  } from "../contract/deployment/deploy-with-abi.js";
36
36
  export { prepareAutoFactoryDeployTransaction } from "../contract/deployment/deploy-via-autofactory.js";
37
+
38
+ export { getCompilerMetadata } from "../contract/actions/get-compiler-metadata.js";
@@ -99,6 +99,12 @@ export {
99
99
  updateMetadata,
100
100
  type UpdateMetadataParams,
101
101
  } from "../../extensions/erc1155/drops/write/updateMetadata.js";
102
+
103
+ export {
104
+ updateTokenURI,
105
+ type UpdateTokenURIParams,
106
+ } from "../../extensions/erc1155/write/updateTokenURI.js";
107
+
102
108
  export {
103
109
  getClaimConditionById,
104
110
  type GetClaimConditionByIdParams,
@@ -167,3 +167,7 @@ export {
167
167
  updateMetadata,
168
168
  type UpdateMetadataParams,
169
169
  } from "../../extensions/erc721/drops/write/updateMetadata.js";
170
+ export {
171
+ updateTokenURI,
172
+ type UpdateTokenURIParams,
173
+ } from "../../extensions/erc721/write/updateTokenURI.js";
@@ -0,0 +1,97 @@
1
+ import { upload } from "../../../storage/upload.js";
2
+ import type { BaseTransactionOptions } from "../../../transaction/types.js";
3
+ import type { NFTInput } from "../../../utils/nft/parseNft.js";
4
+ import {
5
+ type SetTokenURIParams,
6
+ setTokenURI,
7
+ } from "../../erc1155/__generated__/INFTMetadata/write/setTokenURI.js";
8
+
9
+ /**
10
+ * @extension ERC1155
11
+ */
12
+ export type UpdateTokenURIParams = {
13
+ tokenId: bigint;
14
+ newMetadata: NFTInput;
15
+ };
16
+
17
+ /**
18
+ * This function is an abstracted layer of the [`setTokenURI` extension](https://portal.thirdweb.com/references/typescript/v5/erc1155/setTokenURI),
19
+ * which means it uses `setTokenURI` under the hood.
20
+ * While the `setTokenURI` method only takes in a uri string, this extension takes in a user-friendly [`NFTInput`](https://portal.thirdweb.com/references/typescript/v5/NFTInput),
21
+ * upload that content to IPFS and pass the IPFS URI (of said `NFTInput`) to the underlying `setTokenURI` method.
22
+ *
23
+ * This extension does not validate the NFTInput so make sure you are passing the proper content that you want to update.
24
+ *
25
+ * @extension ERC1155
26
+ * @returns the prepared transaction from `setTokenURI`
27
+ * @example
28
+ * ```ts
29
+ * import { updateTokenURI } from "thirdweb/extensions/erc1155";
30
+ *
31
+ * const transaction = updateTokenURI({
32
+ * tokenId: 0n,
33
+ * nft: {
34
+ * name: "new name",
35
+ * description: "new description",
36
+ * image: "https://image-host.com/new-image.png",
37
+ * },
38
+ * });
39
+ * ```
40
+ */
41
+ export function updateTokenURI(
42
+ options: BaseTransactionOptions<UpdateTokenURIParams>,
43
+ ) {
44
+ const { contract } = options;
45
+ return setTokenURI({
46
+ contract,
47
+ asyncParams: async () => getUpdateTokenParams(options),
48
+ });
49
+ }
50
+
51
+ export async function getUpdateTokenParams(
52
+ options: BaseTransactionOptions<UpdateTokenURIParams>,
53
+ ): Promise<SetTokenURIParams> {
54
+ const { tokenId, newMetadata } = options;
55
+ const batch: Promise<string>[] = [
56
+ // image URI resolution
57
+ (async () => {
58
+ if (!newMetadata.image) {
59
+ return "";
60
+ }
61
+ if (typeof newMetadata.image === "string") {
62
+ return newMetadata.image;
63
+ }
64
+ return await upload({
65
+ client: options.contract.client,
66
+ files: [newMetadata.image],
67
+ });
68
+ })(),
69
+ // animation URI resolution
70
+ (async () => {
71
+ if (!newMetadata.animation_url) {
72
+ return "";
73
+ }
74
+ if (typeof newMetadata.animation_url === "string") {
75
+ return newMetadata.animation_url;
76
+ }
77
+ return await upload({
78
+ client: options.contract.client,
79
+ files: [newMetadata.animation_url],
80
+ });
81
+ })(),
82
+ ];
83
+
84
+ const [imageURI, animationURI] = await Promise.all(batch);
85
+ if (newMetadata.image && imageURI) {
86
+ newMetadata.image = imageURI;
87
+ }
88
+ if (newMetadata.animation_url && animationURI) {
89
+ newMetadata.animation_url = animationURI;
90
+ }
91
+
92
+ const uri = await upload({
93
+ client: options.contract.client,
94
+ files: [newMetadata],
95
+ });
96
+ return { tokenId, uri };
97
+ }
@@ -0,0 +1,97 @@
1
+ import { upload } from "../../../storage/upload.js";
2
+ import type { BaseTransactionOptions } from "../../../transaction/types.js";
3
+ import type { NFTInput } from "../../../utils/nft/parseNft.js";
4
+ import {
5
+ type SetTokenURIParams,
6
+ setTokenURI,
7
+ } from "../../erc721/__generated__/INFTMetadata/write/setTokenURI.js";
8
+
9
+ /**
10
+ * @extension ERC721
11
+ */
12
+ export type UpdateTokenURIParams = {
13
+ tokenId: bigint;
14
+ newMetadata: NFTInput;
15
+ };
16
+
17
+ /**
18
+ * This function is an abstracted layer of the [`setTokenURI` extension](https://portal.thirdweb.com/references/typescript/v5/erc721/setTokenURI),
19
+ * which means it uses `setTokenURI` under the hood.
20
+ * While the `setTokenURI` method only takes in a uri string, this extension takes in a user-friendly [`NFTInput`](https://portal.thirdweb.com/references/typescript/v5/NFTInput),
21
+ * upload that content to IPFS and pass the IPFS URI (of said `NFTInput`) to the underlying `setTokenURI` method.
22
+ *
23
+ * This extension does not validate the NFTInput so make sure you are passing the proper content that you want to update.
24
+ *
25
+ * @extension ERC721
26
+ * @returns the prepared transaction from `setTokenURI`
27
+ * @example
28
+ * ```ts
29
+ * import { updateTokenURI } from "thirdweb/extensions/erc721";
30
+ *
31
+ * const transaction = updateTokenURI({
32
+ * tokenId: 0n,
33
+ * nft: {
34
+ * name: "new name",
35
+ * description: "new description",
36
+ * image: "https://image-host.com/new-image.png",
37
+ * },
38
+ * });
39
+ * ```
40
+ */
41
+ export function updateTokenURI(
42
+ options: BaseTransactionOptions<UpdateTokenURIParams>,
43
+ ) {
44
+ const { contract } = options;
45
+ return setTokenURI({
46
+ contract,
47
+ asyncParams: async () => getUpdateTokenParams(options),
48
+ });
49
+ }
50
+
51
+ export async function getUpdateTokenParams(
52
+ options: BaseTransactionOptions<UpdateTokenURIParams>,
53
+ ): Promise<SetTokenURIParams> {
54
+ const { tokenId, newMetadata } = options;
55
+ const batch: Promise<string>[] = [
56
+ // image URI resolution
57
+ (async () => {
58
+ if (!newMetadata.image) {
59
+ return "";
60
+ }
61
+ if (typeof newMetadata.image === "string") {
62
+ return newMetadata.image;
63
+ }
64
+ return await upload({
65
+ client: options.contract.client,
66
+ files: [newMetadata.image],
67
+ });
68
+ })(),
69
+ // animation URI resolution
70
+ (async () => {
71
+ if (!newMetadata.animation_url) {
72
+ return "";
73
+ }
74
+ if (typeof newMetadata.animation_url === "string") {
75
+ return newMetadata.animation_url;
76
+ }
77
+ return await upload({
78
+ client: options.contract.client,
79
+ files: [newMetadata.animation_url],
80
+ });
81
+ })(),
82
+ ];
83
+
84
+ const [imageURI, animationURI] = await Promise.all(batch);
85
+ if (newMetadata.image && imageURI) {
86
+ newMetadata.image = imageURI;
87
+ }
88
+ if (newMetadata.animation_url && animationURI) {
89
+ newMetadata.animation_url = animationURI;
90
+ }
91
+
92
+ const uri = await upload({
93
+ client: options.contract.client,
94
+ files: [newMetadata],
95
+ });
96
+ return { tokenId, uri };
97
+ }
@@ -5,7 +5,7 @@ import { TEST_ACCOUNT_A } from "~test/test-wallets.js";
5
5
  import { isAddress } from "../../utils/address.js";
6
6
  import { deploySplitContract } from "./deploy-split.js";
7
7
 
8
- describe("deploy-split contract", () => {
8
+ describe.runIf(process.env.TW_SECRET_KEY)("deploy-split contract", () => {
9
9
  it("should deploy Split contract", async () => {
10
10
  const address = await deploySplitContract({
11
11
  account: TEST_ACCOUNT_A,
@@ -1,5 +1,6 @@
1
1
  import type { Abi } from "abitype";
2
2
  import type { ThirdwebClient } from "../../client/client.js";
3
+ import { formatCompilerMetadata } from "../../contract/actions/compiler-metadata.js";
3
4
  import { download } from "../../storage/download.js";
4
5
  import type { Hex } from "../encoding/hex.js";
5
6
  import type { Prettify } from "../type-utils.js";
@@ -89,34 +90,6 @@ async function fetchAndParseCompilerMetadata(
89
90
  return formatCompilerMetadata(metadata);
90
91
  }
91
92
 
92
- // biome-ignore lint/suspicious/noExplicitAny: TODO: fix later
93
- function formatCompilerMetadata(metadata: any): ParsedCompilerMetadata {
94
- const abi = metadata.output.abi;
95
- const compilationTarget = metadata.settings.compilationTarget;
96
- const targets = Object.keys(compilationTarget);
97
- const name = compilationTarget[targets[0] as keyof typeof compilationTarget];
98
- const info = {
99
- title: metadata.output.devdoc.title,
100
- author: metadata.output.devdoc.author,
101
- details: metadata.output.devdoc.detail,
102
- notice: metadata.output.userdoc.notice,
103
- };
104
- const licenses: string[] = [
105
- ...new Set(
106
- // biome-ignore lint/suspicious/noExplicitAny: TODO: fix later
107
- Object.entries(metadata.sources).map(([, src]) => (src as any).license),
108
- ),
109
- ];
110
- return {
111
- name,
112
- abi,
113
- metadata,
114
- info,
115
- licenses,
116
- isPartialAbi: metadata.isPartialAbi,
117
- };
118
- }
119
-
120
93
  // types
121
94
 
122
95
  type RawCompilerMetadata = {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.45.2-nightly-b15aa4cdff3f3b233025da285780668a18fe29ab-20240813000336";
1
+ export const version = "5.46.0-nightly-814024ae249141ad1446ce7f21793b1d37b95d13-20240814000405";
@@ -1,8 +1,20 @@
1
1
  import type { ThirdwebClient } from "../../../../client/client.js";
2
2
  import { getThirdwebBaseUrl } from "../../../../utils/domains.js";
3
- import type { AuthOption } from "../../../../wallets/types.js";
3
+ import { type AuthOption, authOptions } from "../../../../wallets/types.js";
4
4
  import type { Ecosystem } from "../../web/types.js";
5
5
 
6
+ const getLoginOptionRoute = (option: AuthOption) => {
7
+ if (!authOptions.includes(option)) {
8
+ throw new Error(`Unknown auth option ${option}`);
9
+ }
10
+ switch (option) {
11
+ case "wallet":
12
+ return "siwe";
13
+ default:
14
+ return option;
15
+ }
16
+ };
17
+
6
18
  export const getLoginUrl = ({
7
19
  authOption,
8
20
  client,
@@ -16,7 +28,8 @@ export const getLoginUrl = ({
16
28
  mode?: "popup" | "redirect" | "mobile";
17
29
  redirectUrl?: string;
18
30
  }) => {
19
- let baseUrl = `${getThirdwebBaseUrl("inAppWallet")}/api/2024-05-05/login/${authOption}?clientId=${client.clientId}`;
31
+ const route = getLoginOptionRoute(authOption);
32
+ let baseUrl = `${getThirdwebBaseUrl("inAppWallet")}/api/2024-05-05/login/${route}?clientId=${client.clientId}`;
20
33
  if (ecosystem?.partnerId) {
21
34
  baseUrl = `${baseUrl}&ecosystemId=${ecosystem.id}&ecosystemPartnerId=${ecosystem.partnerId}`;
22
35
  } else if (ecosystem) {
@@ -49,7 +62,8 @@ export const getLoginCallbackUrl = ({
49
62
  client: ThirdwebClient;
50
63
  ecosystem?: Ecosystem;
51
64
  }): string => {
52
- let baseUrl = `${getThirdwebBaseUrl("inAppWallet")}/api/2024-05-05/login/${authOption}/callback?clientId=${client.clientId}`;
65
+ const route = getLoginOptionRoute(authOption);
66
+ let baseUrl = `${getThirdwebBaseUrl("inAppWallet")}/api/2024-05-05/login/${route}/callback?clientId=${client.clientId}`;
53
67
  if (ecosystem?.partnerId) {
54
68
  baseUrl = `${baseUrl}&ecosystemId=${ecosystem.id}&ecosystemPartnerId=${ecosystem.partnerId}`;
55
69
  } else if (ecosystem) {
@@ -1,9 +1,9 @@
1
1
  import { signLoginPayload } from "../../../../auth/core/sign-login-payload.js";
2
2
  import type { LoginPayload } from "../../../../auth/core/types.js";
3
+ import type { Chain } from "../../../../chains/types.js";
3
4
  import type { ThirdwebClient } from "../../../../client/client.js";
4
5
  import { getClientFetch } from "../../../../utils/fetch.js";
5
- import type { InjectedSupportedWalletIds } from "../../../../wallets/__generated__/wallet-ids.js";
6
- import { createWallet } from "../../../../wallets/create-wallet.js";
6
+ import type { Wallet } from "../../../interfaces/wallet.js";
7
7
  import type { Ecosystem } from "../../web/types.js";
8
8
  import { getLoginCallbackUrl, getLoginUrl } from "./getLoginPath.js";
9
9
  import type { AuthStoredTokenWithCookieReturnType } from "./types.js";
@@ -12,23 +12,23 @@ import type { AuthStoredTokenWithCookieReturnType } from "./types.js";
12
12
  * @internal
13
13
  */
14
14
  export async function siweAuthenticate(args: {
15
- walletId: InjectedSupportedWalletIds;
16
- chainId: number;
15
+ wallet: Wallet;
16
+ chain: Chain;
17
17
  client: ThirdwebClient;
18
18
  ecosystem?: Ecosystem;
19
19
  }): Promise<AuthStoredTokenWithCookieReturnType> {
20
- const wallet = createWallet(args.walletId);
20
+ const { wallet, chain } = args;
21
21
  const account = await wallet.connect({ client: args.client });
22
22
  const clientFetch = getClientFetch(args.client, args.ecosystem);
23
23
 
24
24
  const payload = await (async () => {
25
25
  const path = getLoginUrl({
26
- authOption: "siwe",
26
+ authOption: "wallet",
27
27
  client: args.client,
28
28
  ecosystem: args.ecosystem,
29
29
  });
30
30
  const res = await clientFetch(
31
- `${path}&address=${account.address}&chainId=${args.chainId}`,
31
+ `${path}&address=${account.address}&chainId=${chain.id}`,
32
32
  );
33
33
 
34
34
  if (!res.ok) throw new Error("Failed to generate SIWE login payload");
@@ -39,7 +39,7 @@ export async function siweAuthenticate(args: {
39
39
 
40
40
  const authResult = await (async () => {
41
41
  const path = getLoginCallbackUrl({
42
- authOption: "siwe",
42
+ authOption: "wallet",
43
43
  client: args.client,
44
44
  ecosystem: args.ecosystem,
45
45
  });
@@ -1,8 +1,9 @@
1
1
  import type { AuthType } from "@passwordless-id/webauthn/dist/esm/types.js";
2
+ import type { Chain } from "../../../../chains/types.js";
2
3
  import type { ThirdwebClient } from "../../../../client/client.js";
3
4
  import type { Address } from "../../../../utils/address.js";
4
- import type { InjectedSupportedWalletIds } from "../../../../wallets/__generated__/wallet-ids.js";
5
5
  import type { Account } from "../../../interfaces/wallet.js";
6
+ import type { Wallet } from "../../../interfaces/wallet.js";
6
7
  import type { AuthOption, SocialAuthOption } from "../../../types.js";
7
8
  import type { Ecosystem } from "../../web/types.js";
8
9
 
@@ -42,9 +43,9 @@ export type SingleStepAuthArgsType =
42
43
  authenticatorType?: AuthType;
43
44
  }
44
45
  | {
45
- strategy: "siwe";
46
- walletId: InjectedSupportedWalletIds;
47
- chainId: number;
46
+ strategy: "wallet";
47
+ wallet: Wallet;
48
+ chain: Chain;
48
49
  };
49
50
 
50
51
  export type AuthArgsType = (MultiStepAuthArgsType | SingleStepAuthArgsType) & {
@@ -1,6 +1,7 @@
1
1
  import * as WebBrowser from "expo-web-browser";
2
+ import type { Chain } from "../../../../chains/types.js";
2
3
  import type { ThirdwebClient } from "../../../../client/client.js";
3
- import type { InjectedSupportedWalletIds } from "../../../../wallets/__generated__/wallet-ids.js";
4
+ import type { Wallet } from "../../../interfaces/wallet.js";
4
5
  import { getLoginUrl } from "../../core/authentication/getLoginPath.js";
5
6
  import { siweAuthenticate } from "../../core/authentication/siwe.js";
6
7
  import type {
@@ -125,15 +126,15 @@ export async function socialLogin(
125
126
 
126
127
  export async function siweLogin(
127
128
  client: ThirdwebClient,
128
- walletId: InjectedSupportedWalletIds,
129
- chainId: number,
129
+ wallet: Wallet,
130
+ chain: Chain,
130
131
  ecosystem?: Ecosystem,
131
132
  ): Promise<AuthStoredTokenWithCookieReturnType> {
132
133
  const { storedToken } = await siweAuthenticate({
133
134
  client,
134
135
  ecosystem,
135
- walletId,
136
- chainId,
136
+ wallet,
137
+ chain,
137
138
  });
138
139
  try {
139
140
  const toStoreToken: AuthStoredTokenWithCookieReturnType["storedToken"] = {
@@ -1,6 +1,6 @@
1
+ import type { Chain } from "../../../chains/types.js";
1
2
  import type { ThirdwebClient } from "../../../client/client.js";
2
- import type { InjectedSupportedWalletIds } from "../../../wallets/__generated__/wallet-ids.js";
3
- import type { Account } from "../../interfaces/wallet.js";
3
+ import type { Account, Wallet } from "../../interfaces/wallet.js";
4
4
  import { siweAuthenticate } from "../core/authentication/siwe.js";
5
5
  import {
6
6
  type AuthArgsType,
@@ -91,11 +91,11 @@ export class InAppNativeConnector implements InAppConnector {
91
91
  case "phone": {
92
92
  return verifyOtp(params);
93
93
  }
94
- case "siwe": {
94
+ case "wallet": {
95
95
  return siweAuthenticate({
96
96
  client: this.options.client,
97
- walletId: params.walletId,
98
- chainId: params.chainId,
97
+ wallet: params.wallet,
98
+ chain: params.chain,
99
99
  });
100
100
  }
101
101
  case "google":
@@ -145,10 +145,10 @@ export class InAppNativeConnector implements InAppConnector {
145
145
  redirectUrl,
146
146
  });
147
147
  }
148
- case "siwe": {
148
+ case "wallet": {
149
149
  return this.siweLogin({
150
- walletId: params.walletId,
151
- chainId: params.chainId,
150
+ wallet: params.wallet,
151
+ chain: params.chain,
152
152
  });
153
153
  }
154
154
  case "jwt": {
@@ -230,14 +230,14 @@ export class InAppNativeConnector implements InAppConnector {
230
230
  }
231
231
 
232
232
  private async siweLogin(options: {
233
- walletId: InjectedSupportedWalletIds;
234
- chainId: number;
233
+ wallet: Wallet;
234
+ chain: Chain;
235
235
  }): Promise<AuthLoginReturnType> {
236
236
  try {
237
237
  const { storedToken } = await siweLogin(
238
238
  this.options.client,
239
- options.walletId,
240
- options.chainId,
239
+ options.wallet,
240
+ options.chain,
241
241
  );
242
242
  const account = await this.getAccount();
243
243
  return {
@@ -250,15 +250,15 @@ export class InAppNativeConnector implements InAppConnector {
250
250
  };
251
251
  } catch (error) {
252
252
  console.error(
253
- `Error while signing in with: ${options.walletId}. ${error}`,
253
+ `Error while signing in with: ${options.wallet.id}. ${error}`,
254
254
  );
255
255
  if (error instanceof Error) {
256
256
  throw new Error(
257
- `Error signing in with ${options.walletId}: ${error.message}`,
257
+ `Error signing in with ${options.wallet.id}: ${error.message}`,
258
258
  );
259
259
  }
260
260
  throw new Error(
261
- `An unknown error occurred signing in with ${options.walletId}`,
261
+ `An unknown error occurred signing in with ${options.wallet.id}`,
262
262
  );
263
263
  }
264
264
  }
@@ -63,6 +63,21 @@ import { createInAppWallet } from "../core/wallet/in-app-core.js";
63
63
  * });
64
64
  * ```
65
65
  *
66
+ * ### Login with SIWE
67
+ * ```ts
68
+ * import { inAppWallet, createWallet } from "thirdweb/wallets";
69
+ *
70
+ * const rabby = createWallet("io.rabby");
71
+ * const inAppWallet = inAppWallet();
72
+ *
73
+ * const account = await inAppWallet.connect({
74
+ * strategy: "wallet",
75
+ * chain: mainnet,
76
+ * wallet: rabby,
77
+ * client: MY_CLIENT
78
+ * });
79
+ * ```
80
+ *
66
81
  * ### Login with phone number
67
82
  * ```ts
68
83
  * import { inAppWallet, preAuthenticate } from "thirdweb/wallets/in-app";
@@ -222,12 +222,12 @@ export class InAppWebConnector implements InAppConnector {
222
222
  openedWindow: args.openedWindow,
223
223
  });
224
224
  }
225
- case "siwe": {
225
+ case "wallet": {
226
226
  return siweAuthenticate({
227
- client: this.wallet.client,
228
227
  ecosystem: this.wallet.ecosystem,
229
- walletId: args.walletId,
230
- chainId: args.chainId,
228
+ client: this.wallet.client,
229
+ wallet: args.wallet,
230
+ chain: args.chain,
231
231
  });
232
232
  }
233
233
  }
@@ -280,7 +280,7 @@ export class InAppWebConnector implements InAppConnector {
280
280
  }
281
281
  case "phone":
282
282
  case "email":
283
- case "siwe":
283
+ case "wallet":
284
284
  case "apple":
285
285
  case "facebook":
286
286
  case "google":
@@ -29,12 +29,14 @@ export const socialAuthOptions = [
29
29
  ] as const;
30
30
  export type SocialAuthOption = (typeof socialAuthOptions)[number];
31
31
 
32
- export type AuthOption =
33
- | "email"
34
- | "phone"
35
- | "passkey"
36
- | "siwe"
37
- | SocialAuthOption;
32
+ export const authOptions = [
33
+ ...socialAuthOptions,
34
+ "email",
35
+ "phone",
36
+ "passkey",
37
+ "wallet",
38
+ ] as const;
39
+ export type AuthOption = (typeof authOptions)[number];
38
40
 
39
41
  export type DisconnectFn = () => Promise<void>;
40
42
  export type SwitchChainFn = (chain: Chain) => Promise<void>;