thirdweb 5.63.2 → 5.64.0-nightly-cdb907f175f7472d1fb3dea6547d946514564085-20241023000322
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/dist/cjs/exports/extensions/erc1155.js +3 -1
- package/dist/cjs/exports/extensions/erc1155.js.map +1 -1
- package/dist/cjs/extensions/erc1155/write/mintAdditionalSupplyToBatch.js +48 -0
- package/dist/cjs/extensions/erc1155/write/mintAdditionalSupplyToBatch.js.map +1 -0
- package/dist/cjs/extensions/erc1155/write/mintToBatch.js +9 -17
- package/dist/cjs/extensions/erc1155/write/mintToBatch.js.map +1 -1
- package/dist/cjs/react/core/utils/walletIcon.js +4 -0
- package/dist/cjs/react/core/utils/walletIcon.js.map +1 -1
- package/dist/cjs/react/native/ui/components/WalletImage.js +2 -0
- package/dist/cjs/react/native/ui/components/WalletImage.js.map +1 -1
- package/dist/cjs/react/native/ui/connect/InAppWalletUI.js +1 -0
- package/dist/cjs/react/native/ui/connect/InAppWalletUI.js.map +1 -1
- package/dist/cjs/react/native/ui/icons/svgs.js +5 -1
- package/dist/cjs/react/native/ui/icons/svgs.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js +3 -1
- package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/cjs/react/web/wallets/shared/oauthSignIn.js +1 -0
- package/dist/cjs/react/web/wallets/shared/oauthSignIn.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-auth-options.js +3 -3
- package/dist/cjs/wallets/ecosystem/get-ecosystem-wallet-auth-options.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js +3 -3
- package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/wallet/index.js +50 -2
- package/dist/cjs/wallets/in-app/core/wallet/index.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/web-connector.js +2 -0
- package/dist/cjs/wallets/in-app/web/lib/web-connector.js.map +1 -1
- package/dist/cjs/wallets/smart/index.js +30 -2
- package/dist/cjs/wallets/smart/index.js.map +1 -1
- package/dist/cjs/wallets/smart/smart-wallet.js +3 -6
- package/dist/cjs/wallets/smart/smart-wallet.js.map +1 -1
- package/dist/cjs/wallets/types.js +1 -0
- package/dist/cjs/wallets/types.js.map +1 -1
- package/dist/esm/exports/extensions/erc1155.js +1 -0
- package/dist/esm/exports/extensions/erc1155.js.map +1 -1
- package/dist/esm/extensions/erc1155/write/mintAdditionalSupplyToBatch.js +45 -0
- package/dist/esm/extensions/erc1155/write/mintAdditionalSupplyToBatch.js.map +1 -0
- package/dist/esm/extensions/erc1155/write/mintToBatch.js +9 -17
- package/dist/esm/extensions/erc1155/write/mintToBatch.js.map +1 -1
- package/dist/esm/react/core/utils/walletIcon.js +4 -0
- package/dist/esm/react/core/utils/walletIcon.js.map +1 -1
- package/dist/esm/react/native/ui/components/WalletImage.js +3 -1
- package/dist/esm/react/native/ui/components/WalletImage.js.map +1 -1
- package/dist/esm/react/native/ui/connect/InAppWalletUI.js +2 -1
- package/dist/esm/react/native/ui/connect/InAppWalletUI.js.map +1 -1
- package/dist/esm/react/native/ui/icons/svgs.js +4 -0
- package/dist/esm/react/native/ui/icons/svgs.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js +4 -2
- package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
- package/dist/esm/react/web/wallets/shared/oauthSignIn.js +1 -0
- package/dist/esm/react/web/wallets/shared/oauthSignIn.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-auth-options.js +2 -2
- package/dist/esm/wallets/ecosystem/get-ecosystem-wallet-auth-options.js.map +1 -1
- package/dist/esm/wallets/in-app/core/wallet/in-app-core.js +3 -3
- package/dist/esm/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
- package/dist/esm/wallets/in-app/core/wallet/index.js +50 -2
- package/dist/esm/wallets/in-app/core/wallet/index.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/web-connector.js +2 -0
- package/dist/esm/wallets/in-app/web/lib/web-connector.js.map +1 -1
- package/dist/esm/wallets/smart/index.js +30 -2
- package/dist/esm/wallets/smart/index.js.map +1 -1
- package/dist/esm/wallets/smart/smart-wallet.js +3 -6
- package/dist/esm/wallets/smart/smart-wallet.js.map +1 -1
- package/dist/esm/wallets/types.js +1 -0
- package/dist/esm/wallets/types.js.map +1 -1
- package/dist/types/exports/extensions/erc1155.d.ts +1 -0
- package/dist/types/exports/extensions/erc1155.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/write/mintAdditionalSupplyToBatch.d.ts +31 -0
- package/dist/types/extensions/erc1155/write/mintAdditionalSupplyToBatch.d.ts.map +1 -0
- package/dist/types/extensions/erc1155/write/mintToBatch.d.ts.map +1 -1
- package/dist/types/react/core/utils/walletIcon.d.ts +2 -1
- package/dist/types/react/core/utils/walletIcon.d.ts.map +1 -1
- package/dist/types/react/native/ui/components/WalletImage.d.ts.map +1 -1
- package/dist/types/react/native/ui/connect/InAppWalletUI.d.ts.map +1 -1
- package/dist/types/react/native/ui/icons/svgs.d.ts +1 -0
- package/dist/types/react/native/ui/icons/svgs.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/ConnectWalletSocialOptions.d.ts.map +1 -1
- package/dist/types/react/web/wallets/shared/oauthSignIn.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/ecosystem/get-ecosystem-wallet-auth-options.d.ts +11 -1
- package/dist/types/wallets/ecosystem/get-ecosystem-wallet-auth-options.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/authentication/types.d.ts +1 -1
- package/dist/types/wallets/in-app/core/authentication/types.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/wallet/in-app-core.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/wallet/index.d.ts +3 -2
- package/dist/types/wallets/in-app/core/wallet/index.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/web-connector.d.ts.map +1 -1
- package/dist/types/wallets/smart/index.d.ts.map +1 -1
- package/dist/types/wallets/smart/smart-wallet.d.ts +3 -6
- package/dist/types/wallets/smart/smart-wallet.d.ts.map +1 -1
- package/dist/types/wallets/types.d.ts +2 -2
- package/dist/types/wallets/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/exports/extensions/erc1155.ts +5 -0
- package/src/extensions/erc1155/write/mintAdditionalSupplyToBatch.test.ts +90 -0
- package/src/extensions/erc1155/write/mintAdditionalSupplyToBatch.ts +58 -0
- package/src/extensions/erc1155/write/mintToBatch.test.ts +57 -54
- package/src/extensions/erc1155/write/mintToBatch.ts +15 -24
- package/src/extensions/unstoppable-domains/read/resolveName.test.ts +9 -0
- package/src/react/core/utils/walletIcon.ts +5 -0
- package/src/react/native/ui/components/WalletImage.tsx +3 -0
- package/src/react/native/ui/connect/InAppWalletUI.tsx +2 -0
- package/src/react/native/ui/icons/svgs.ts +5 -0
- package/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +4 -2
- package/src/react/web/wallets/shared/oauthSignIn.ts +1 -0
- package/src/version.ts +1 -1
- package/src/wallets/ecosystem/get-ecosystem-wallet-auth-options.ts +14 -3
- package/src/wallets/in-app/core/authentication/types.ts +1 -0
- package/src/wallets/in-app/core/wallet/in-app-core.ts +3 -0
- package/src/wallets/in-app/core/wallet/index.ts +59 -0
- package/src/wallets/in-app/web/lib/web-connector.ts +2 -0
- package/src/wallets/smart/index.ts +40 -2
- package/src/wallets/smart/smart-wallet-integration-v07.test.ts +2 -4
- package/src/wallets/smart/smart-wallet.ts +3 -6
- package/src/wallets/types.ts +1 -0
@@ -13,62 +13,65 @@ const chain = ANVIL_CHAIN;
|
|
13
13
|
const client = TEST_CLIENT;
|
14
14
|
const account = TEST_ACCOUNT_C;
|
15
15
|
|
16
|
-
describe(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
address: await deployERC1155Contract({
|
16
|
+
describe.runIf(process.env.TW_SECRET_KEY)(
|
17
|
+
"ERC1155 Edition: mintToBatch",
|
18
|
+
() => {
|
19
|
+
it("should mint multiple tokens in one tx", async () => {
|
20
|
+
const contract = getContract({
|
22
21
|
chain,
|
23
22
|
client,
|
23
|
+
address: await deployERC1155Contract({
|
24
|
+
chain,
|
25
|
+
client,
|
26
|
+
account,
|
27
|
+
type: "TokenERC1155",
|
28
|
+
params: {
|
29
|
+
name: "edition",
|
30
|
+
contractURI: TEST_CONTRACT_URI,
|
31
|
+
},
|
32
|
+
}),
|
33
|
+
});
|
34
|
+
|
35
|
+
await sendAndConfirmTransaction({
|
24
36
|
account,
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
37
|
+
transaction: mintToBatch({
|
38
|
+
contract,
|
39
|
+
to: account.address,
|
40
|
+
nfts: [
|
41
|
+
{ metadata: { name: "token 0" }, supply: 1n },
|
42
|
+
{ metadata: { name: "token 1" }, supply: 2n },
|
43
|
+
{ metadata: { name: "token 2" }, supply: 3n },
|
44
|
+
],
|
45
|
+
}),
|
46
|
+
});
|
32
47
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
48
|
+
const nfts = await getNFTs({ contract });
|
49
|
+
expect(nfts).toStrictEqual([
|
50
|
+
{
|
51
|
+
metadata: { name: "token 0" },
|
52
|
+
owner: null,
|
53
|
+
id: 0n,
|
54
|
+
tokenURI: "ipfs://QmPZ6LpGqMuFbHKTXrNW1NRNLHf1nrxS4dtoFqdZZTKvPX/0",
|
55
|
+
type: "ERC1155",
|
56
|
+
supply: 1n,
|
57
|
+
},
|
58
|
+
{
|
59
|
+
metadata: { name: "token 1" },
|
60
|
+
owner: null,
|
61
|
+
id: 1n,
|
62
|
+
tokenURI: "ipfs://QmRFPyc3yEYxR4pQxwyTQWTine51TxWCoD6nzJWR3eX45b/0",
|
63
|
+
type: "ERC1155",
|
64
|
+
supply: 2n,
|
65
|
+
},
|
66
|
+
{
|
67
|
+
metadata: { name: "token 2" },
|
68
|
+
owner: null,
|
69
|
+
id: 2n,
|
70
|
+
tokenURI: "ipfs://QmesQiRLHCgqWZM2GFCs7Nb7rr2S72hU1BVQc7xiTyKZtT/0",
|
71
|
+
type: "ERC1155",
|
72
|
+
supply: 3n,
|
73
|
+
},
|
74
|
+
]);
|
44
75
|
});
|
45
|
-
|
46
|
-
|
47
|
-
expect(nfts).toStrictEqual([
|
48
|
-
{
|
49
|
-
metadata: { name: "token 0" },
|
50
|
-
owner: null,
|
51
|
-
id: 0n,
|
52
|
-
tokenURI: "ipfs://QmPZ6LpGqMuFbHKTXrNW1NRNLHf1nrxS4dtoFqdZZTKvPX/0",
|
53
|
-
type: "ERC1155",
|
54
|
-
supply: 1n,
|
55
|
-
},
|
56
|
-
{
|
57
|
-
metadata: { name: "token 1" },
|
58
|
-
owner: null,
|
59
|
-
id: 1n,
|
60
|
-
tokenURI: "ipfs://QmRFPyc3yEYxR4pQxwyTQWTine51TxWCoD6nzJWR3eX45b/0",
|
61
|
-
type: "ERC1155",
|
62
|
-
supply: 2n,
|
63
|
-
},
|
64
|
-
{
|
65
|
-
metadata: { name: "token 2" },
|
66
|
-
owner: null,
|
67
|
-
id: 2n,
|
68
|
-
tokenURI: "ipfs://QmesQiRLHCgqWZM2GFCs7Nb7rr2S72hU1BVQc7xiTyKZtT/0",
|
69
|
-
type: "ERC1155",
|
70
|
-
supply: 3n,
|
71
|
-
},
|
72
|
-
]);
|
73
|
-
});
|
74
|
-
});
|
76
|
+
},
|
77
|
+
);
|
@@ -83,33 +83,24 @@ export function mintToBatch(
|
|
83
83
|
return multicall({
|
84
84
|
contract: options.contract,
|
85
85
|
asyncParams: async () => {
|
86
|
-
const
|
87
|
-
options.nfts.map((
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
86
|
+
const data = await Promise.all(
|
87
|
+
options.nfts.map(async (nft) => {
|
88
|
+
const uri =
|
89
|
+
typeof nft.metadata === "string"
|
90
|
+
? nft.metadata
|
91
|
+
: await upload({
|
92
|
+
client: options.contract.client,
|
93
|
+
files: [nft.metadata],
|
94
|
+
});
|
95
|
+
return encodeMintTo({
|
96
|
+
to: options.to,
|
97
|
+
// maxUint256 is used to indicate that this is a NEW token!
|
98
|
+
tokenId: maxUint256,
|
99
|
+
uri,
|
100
|
+
amount: nft.supply,
|
94
101
|
});
|
95
102
|
}),
|
96
103
|
);
|
97
|
-
|
98
|
-
const data = uris.map((uri, index) => {
|
99
|
-
const item = options.nfts[index];
|
100
|
-
if (!item) {
|
101
|
-
// Should not happen
|
102
|
-
throw new Error("Index mismatch");
|
103
|
-
}
|
104
|
-
return encodeMintTo({
|
105
|
-
to: options.to,
|
106
|
-
// maxUint256 is used to indicate that this is a NEW token!
|
107
|
-
tokenId: maxUint256,
|
108
|
-
uri,
|
109
|
-
amount: item.supply,
|
110
|
-
});
|
111
|
-
});
|
112
|
-
|
113
104
|
return { data };
|
114
105
|
},
|
115
106
|
overrides: options.overrides,
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
2
2
|
import { TEST_CLIENT } from "~test/test-clients.js";
|
3
|
+
import { TEST_ACCOUNT_D } from "~test/test-wallets.js";
|
3
4
|
import { resolveName } from "./resolveName.js";
|
4
5
|
|
5
6
|
// Double check: https://unstoppabledomains.com/d/thirdwebsdk.unstoppable
|
@@ -13,4 +14,12 @@ describe("Unstoppable Domain: resolve name", () => {
|
|
13
14
|
}),
|
14
15
|
).toBe("thirdwebsdk.unstoppable");
|
15
16
|
});
|
17
|
+
|
18
|
+
it("should throw error on addresses that dont own any UD", async () => {
|
19
|
+
await expect(() =>
|
20
|
+
resolveName({ client: TEST_CLIENT, address: TEST_ACCOUNT_D.address }),
|
21
|
+
).rejects.toThrowError(
|
22
|
+
`Failed to retrieve domain for address: ${TEST_ACCOUNT_D.address}. Make sure you have set the Reverse Resolution address for your domain at https://unstoppabledomains.com/manage?page=reverseResolution&domain=your-domain`,
|
23
|
+
);
|
24
|
+
});
|
16
25
|
});
|
@@ -17,6 +17,8 @@ const telegramIconUri =
|
|
17
17
|
"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTAwMHB4IiBoZWlnaHQ9IjEwMDBweCIgdmlld0JveD0iMCAwIDEwMDAgMTAwMCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDwhLS0gR2VuZXJhdG9yOiBTa2V0Y2ggNTMuMiAoNzI2NDMpIC0gaHR0cHM6Ly9za2V0Y2hhcHAuY29tIC0tPgogICAgPHRpdGxlPkFydGJvYXJkPC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGRlZnM+CiAgICAgICAgPGxpbmVhckdyYWRpZW50IHgxPSI1MCUiIHkxPSIwJSIgeDI9IjUwJSIgeTI9Ijk5LjI1ODM0MDQlIiBpZD0ibGluZWFyR3JhZGllbnQtMSI+CiAgICAgICAgICAgIDxzdG9wIHN0b3AtY29sb3I9IiMyQUFCRUUiIG9mZnNldD0iMCUiPjwvc3RvcD4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iIzIyOUVEOSIgb2Zmc2V0PSIxMDAlIj48L3N0b3A+CiAgICAgICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDwvZG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Ny4zMTEgMTQ1LjMzNUgxNzcuMzE1Wk0xNTUuMzIzIDE3MC43NkwxNDguMTI0IDE2MC41MThMOTAuODQxNyA3OS4wMjJIMTE1LjUwM0wxNjEuNzMxIDE0NC43OTJMMTY4LjkzIDE1NS4wMzRMMjI5LjAyIDI0MC41MjVIMjA0LjM1OUwxNTUuMzIzIDE3MC43NjRWMTcwLjc2WiIgZmlsbD0id2hpdGUiLz4KPC9zdmc+Cg==";
|
22
24
|
export const emailIcon =
|
@@ -43,6 +45,7 @@ export const socialIcons = {
|
|
43
45
|
farcaster: farcasterIconUri,
|
44
46
|
telegram: telegramIconUri,
|
45
47
|
twitch: twitchIconUri,
|
48
|
+
github: githubIconUri,
|
46
49
|
};
|
47
50
|
|
48
51
|
// TODO: this should return actual <svg> elements so they can be themed
|
@@ -74,6 +77,8 @@ export function getWalletIcon(provider: string) {
|
|
74
77
|
return telegramIconUri;
|
75
78
|
case "twitch":
|
76
79
|
return twitchIconUri;
|
80
|
+
case "github":
|
81
|
+
return githubIconUri;
|
77
82
|
case "guest":
|
78
83
|
return guestIcon;
|
79
84
|
default:
|
@@ -13,6 +13,7 @@ import {
|
|
13
13
|
EMAIL_ICON,
|
14
14
|
FACEBOOK_ICON,
|
15
15
|
FARCASTER_ICON,
|
16
|
+
GITHUB_ICON,
|
16
17
|
GOOGLE_ICON,
|
17
18
|
GUEST_ICON,
|
18
19
|
LINE_ICON,
|
@@ -103,6 +104,8 @@ export function getAuthProviderImage(authProvider: string | null): string {
|
|
103
104
|
return FARCASTER_ICON;
|
104
105
|
case "telegram":
|
105
106
|
return TELEGRAM_ICON;
|
107
|
+
case "github":
|
108
|
+
return GITHUB_ICON;
|
106
109
|
case "twitch":
|
107
110
|
return TWITCH_ICON;
|
108
111
|
case "guest":
|
@@ -34,6 +34,7 @@ import {
|
|
34
34
|
DISCORD_ICON,
|
35
35
|
FACEBOOK_ICON,
|
36
36
|
FARCASTER_ICON,
|
37
|
+
GITHUB_ICON,
|
37
38
|
GOOGLE_ICON,
|
38
39
|
LINE_ICON,
|
39
40
|
TELEGRAM_ICON,
|
@@ -62,6 +63,7 @@ const socialIcons = {
|
|
62
63
|
x: X_ICON,
|
63
64
|
farcaster: FARCASTER_ICON,
|
64
65
|
telegram: TELEGRAM_ICON,
|
66
|
+
github: GITHUB_ICON,
|
65
67
|
twitch: TWITCH_ICON,
|
66
68
|
};
|
67
69
|
|
@@ -71,6 +71,11 @@ export const TELEGRAM_ICON = `<svg width={width} height={height} viewBox="0 0 10
|
|
71
71
|
</g>
|
72
72
|
</svg>`;
|
73
73
|
|
74
|
+
export const GITHUB_ICON = `<svg width="106" height="106" viewBox="0 0 106 106" fill="none" xmlns="http://www.w3.org/2000/svg">
|
75
|
+
<circle cx="53" cy="53" r="53" fill="white"/>
|
76
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M52.854 4C25.839 4 4 26 4 53.217C4 74.973 17.993 93.389 37.405 99.907C39.832 100.397 40.721 98.848 40.721 97.545C40.721 96.404 40.641 92.493 40.641 88.418C27.051 91.352 24.221 82.551 24.221 82.551C22.037 76.847 18.801 75.381 18.801 75.381C14.353 72.366 19.125 72.366 19.125 72.366C24.059 72.692 26.648 77.418 26.648 77.418C31.015 84.914 38.052 82.796 40.883 81.492C41.287 78.314 42.582 76.114 43.957 74.892C33.118 73.751 21.714 69.514 21.714 50.609C21.714 45.231 23.654 40.831 26.728 37.409C26.243 36.187 24.544 31.134 27.214 24.371C27.214 24.371 31.339 23.067 40.64 29.423C44.6221 28.3457 48.7288 27.7976 52.854 27.793C56.979 27.793 61.184 28.364 65.067 29.423C74.369 23.067 78.494 24.371 78.494 24.371C81.164 31.134 79.464 36.187 78.979 37.409C82.134 40.831 83.994 45.231 83.994 50.609C83.994 69.514 72.59 73.669 61.67 74.892C63.45 76.44 64.986 79.373 64.986 84.018C64.986 90.618 64.906 95.915 64.906 97.544C64.906 98.848 65.796 100.397 68.222 99.908C87.634 93.388 101.627 74.973 101.627 53.217C101.707 26 79.788 4 52.854 4Z" fill="#24292F"/>
|
77
|
+
</svg>`;
|
78
|
+
|
74
79
|
export const TWITCH_ICON = `<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
75
80
|
viewBox="0 0 2400 2800" style="enable-background:new 0 0 2400 2800;" xml:space="preserve">
|
76
81
|
<style type="text/css">
|
@@ -5,7 +5,7 @@ import { useMemo, useState } from "react";
|
|
5
5
|
import type { Chain } from "../../../../chains/types.js";
|
6
6
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
7
7
|
import { webLocalStorage } from "../../../../utils/storage/webStorage.js";
|
8
|
-
import {
|
8
|
+
import { getEcosystemOptions } from "../../../../wallets/ecosystem/get-ecosystem-wallet-auth-options.js";
|
9
9
|
import { isEcosystemWallet } from "../../../../wallets/ecosystem/is-ecosystem-wallet.js";
|
10
10
|
import type { Profile } from "../../../../wallets/in-app/core/authentication/types.js";
|
11
11
|
import { linkProfile } from "../../../../wallets/in-app/web/lib/auth/index.js";
|
@@ -114,6 +114,7 @@ export const ConnectWalletSocialOptions = (
|
|
114
114
|
coinbase: "Coinbase",
|
115
115
|
farcaster: "Farcaster",
|
116
116
|
telegram: "Telegram",
|
117
|
+
github: "GitHub",
|
117
118
|
twitch: "Twitch",
|
118
119
|
};
|
119
120
|
|
@@ -121,7 +122,8 @@ export const ConnectWalletSocialOptions = (
|
|
121
122
|
queryKey: ["auth-options", wallet.id],
|
122
123
|
queryFn: async () => {
|
123
124
|
if (isEcosystemWallet(wallet)) {
|
124
|
-
|
125
|
+
const options = await getEcosystemOptions(wallet.id);
|
126
|
+
return options?.authOptions ?? null;
|
125
127
|
}
|
126
128
|
return null;
|
127
129
|
},
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.
|
1
|
+
export const version = "5.64.0-nightly-cdb907f175f7472d1fb3dea6547d946514564085-20241023000322";
|
@@ -2,15 +2,26 @@ import { getThirdwebBaseUrl } from "../../utils/domains.js";
|
|
2
2
|
import type { AuthOption } from "../types.js";
|
3
3
|
import type { EcosystemWalletId } from "../wallet-types.js";
|
4
4
|
|
5
|
+
export type EcosystemOptions = {
|
6
|
+
authOptions: AuthOption[];
|
7
|
+
smartAccountOptions: SmartAccountOptions;
|
8
|
+
};
|
9
|
+
|
10
|
+
type SmartAccountOptions = {
|
11
|
+
chainIds: number[];
|
12
|
+
sponsorGas: boolean;
|
13
|
+
accountFactoryAddress: string;
|
14
|
+
};
|
15
|
+
|
5
16
|
/**
|
6
17
|
* Retrieves the specified auth options for a given ecosystem wallet, if any.
|
7
18
|
* @param walletId The ecosystem wallet ID.
|
8
19
|
* @returns {AuthOption[] | undefined} The auth options for the ecosystem wallet.
|
9
20
|
* @internal
|
10
21
|
*/
|
11
|
-
export async function
|
22
|
+
export async function getEcosystemOptions(
|
12
23
|
walletId: EcosystemWalletId,
|
13
|
-
): Promise<
|
24
|
+
): Promise<EcosystemOptions | null> {
|
14
25
|
const res = await fetch(
|
15
26
|
`${getThirdwebBaseUrl("inAppWallet")}/api/2024-05-05/ecosystem-wallet`,
|
16
27
|
{
|
@@ -29,5 +40,5 @@ export async function getEcosystemWalletAuthOptions(
|
|
29
40
|
);
|
30
41
|
}
|
31
42
|
|
32
|
-
return data
|
43
|
+
return data ?? null;
|
33
44
|
}
|
@@ -70,6 +70,7 @@ export function createInAppWallet(args: {
|
|
70
70
|
options,
|
71
71
|
createOptions,
|
72
72
|
connector,
|
73
|
+
ecosystem,
|
73
74
|
);
|
74
75
|
|
75
76
|
// set the states
|
@@ -96,6 +97,7 @@ export function createInAppWallet(args: {
|
|
96
97
|
options,
|
97
98
|
createOptions,
|
98
99
|
connector,
|
100
|
+
ecosystem,
|
99
101
|
);
|
100
102
|
// set the states
|
101
103
|
client = options.client;
|
@@ -142,6 +144,7 @@ export function createInAppWallet(args: {
|
|
142
144
|
},
|
143
145
|
createOptions,
|
144
146
|
connector,
|
147
|
+
ecosystem,
|
145
148
|
);
|
146
149
|
account = connectedAccount;
|
147
150
|
chain = connectedChain;
|
@@ -1,10 +1,12 @@
|
|
1
1
|
import { ethereum } from "../../../../chains/chain-definitions/ethereum.js";
|
2
2
|
import type { Chain } from "../../../../chains/types.js";
|
3
|
+
import { getCachedChain } from "../../../../chains/utils.js";
|
3
4
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
4
5
|
import {
|
5
6
|
type SocialAuthOption,
|
6
7
|
socialAuthOptions,
|
7
8
|
} from "../../../../wallets/types.js";
|
9
|
+
import { getEcosystemOptions } from "../../../ecosystem/get-ecosystem-wallet-auth-options.js";
|
8
10
|
import type { Account, Wallet } from "../../../interfaces/wallet.js";
|
9
11
|
import type { EcosystemWalletId, WalletId } from "../../../wallet-types.js";
|
10
12
|
import type {
|
@@ -13,6 +15,7 @@ import type {
|
|
13
15
|
WalletConnectionOption,
|
14
16
|
} from "../../../wallet-types.js";
|
15
17
|
import type { InAppConnector } from "../interfaces/connector.js";
|
18
|
+
import type { Ecosystem } from "./types.js";
|
16
19
|
|
17
20
|
/**
|
18
21
|
* Checks if the provided wallet is an in-app wallet.
|
@@ -37,6 +40,7 @@ export async function connectInAppWallet(
|
|
37
40
|
| CreateWalletArgs<"inApp">[1]
|
38
41
|
| CreateWalletArgs<EcosystemWalletId>[1],
|
39
42
|
connector: InAppConnector,
|
43
|
+
ecosystem: Ecosystem | undefined,
|
40
44
|
): Promise<[Account, Chain]> {
|
41
45
|
if (
|
42
46
|
// if auth mode is not specified, the default is popup
|
@@ -73,6 +77,33 @@ export async function connectInAppWallet(
|
|
73
77
|
});
|
74
78
|
}
|
75
79
|
|
80
|
+
if (ecosystem) {
|
81
|
+
const ecosystemOptions = await getEcosystemOptions(ecosystem.id);
|
82
|
+
const smartAccountOptions = ecosystemOptions?.smartAccountOptions;
|
83
|
+
if (smartAccountOptions) {
|
84
|
+
const allowedChains = smartAccountOptions.chainIds;
|
85
|
+
const firstAllowedChain = allowedChains[0];
|
86
|
+
if (!firstAllowedChain) {
|
87
|
+
throw new Error(
|
88
|
+
"At least one chain must be allowed for ecosystem smart account",
|
89
|
+
);
|
90
|
+
}
|
91
|
+
const preferredChain =
|
92
|
+
options.chain && allowedChains.includes(options.chain.id)
|
93
|
+
? options.chain
|
94
|
+
: getCachedChain(firstAllowedChain);
|
95
|
+
return convertToSmartAccount({
|
96
|
+
client: options.client,
|
97
|
+
authAccount,
|
98
|
+
smartAccountOptions: {
|
99
|
+
chain: preferredChain,
|
100
|
+
sponsorGas: smartAccountOptions.sponsorGas,
|
101
|
+
factoryAddress: smartAccountOptions.accountFactoryAddress,
|
102
|
+
},
|
103
|
+
});
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
76
107
|
return [authAccount, options.chain || ethereum] as const;
|
77
108
|
}
|
78
109
|
|
@@ -87,6 +118,7 @@ export async function autoConnectInAppWallet(
|
|
87
118
|
| CreateWalletArgs<"inApp">[1]
|
88
119
|
| CreateWalletArgs<EcosystemWalletId>[1],
|
89
120
|
connector: InAppConnector,
|
121
|
+
ecosystem: Ecosystem | undefined,
|
90
122
|
): Promise<[Account, Chain]> {
|
91
123
|
if (options.authResult && connector.loginWithAuthToken) {
|
92
124
|
await connector.loginWithAuthToken(options.authResult);
|
@@ -112,6 +144,33 @@ export async function autoConnectInAppWallet(
|
|
112
144
|
});
|
113
145
|
}
|
114
146
|
|
147
|
+
if (ecosystem) {
|
148
|
+
const ecosystemOptions = await getEcosystemOptions(ecosystem.id);
|
149
|
+
const smartAccountOptions = ecosystemOptions?.smartAccountOptions;
|
150
|
+
if (smartAccountOptions) {
|
151
|
+
const allowedChains = smartAccountOptions.chainIds;
|
152
|
+
const firstAllowedChain = allowedChains[0];
|
153
|
+
if (!firstAllowedChain) {
|
154
|
+
throw new Error(
|
155
|
+
"At least one chain must be allowed for ecosystem smart account",
|
156
|
+
);
|
157
|
+
}
|
158
|
+
const preferredChain =
|
159
|
+
options.chain && allowedChains.includes(options.chain.id)
|
160
|
+
? options.chain
|
161
|
+
: getCachedChain(firstAllowedChain);
|
162
|
+
return convertToSmartAccount({
|
163
|
+
client: options.client,
|
164
|
+
authAccount,
|
165
|
+
smartAccountOptions: {
|
166
|
+
chain: preferredChain,
|
167
|
+
sponsorGas: smartAccountOptions.sponsorGas,
|
168
|
+
factoryAddress: smartAccountOptions.accountFactoryAddress,
|
169
|
+
},
|
170
|
+
});
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
115
174
|
return [authAccount, options.chain || ethereum] as const;
|
116
175
|
}
|
117
176
|
|
@@ -318,6 +318,7 @@ export class InAppWebConnector implements InAppConnector {
|
|
318
318
|
case "facebook":
|
319
319
|
case "google":
|
320
320
|
case "telegram":
|
321
|
+
case "github":
|
321
322
|
case "twitch":
|
322
323
|
case "farcaster":
|
323
324
|
case "line":
|
@@ -390,6 +391,7 @@ export class InAppWebConnector implements InAppConnector {
|
|
390
391
|
case "google":
|
391
392
|
case "farcaster":
|
392
393
|
case "telegram":
|
394
|
+
case "github":
|
393
395
|
case "line":
|
394
396
|
case "x":
|
395
397
|
case "guest":
|
@@ -8,6 +8,7 @@ import {
|
|
8
8
|
} from "viem";
|
9
9
|
import type { Chain } from "../../chains/types.js";
|
10
10
|
import { getCachedChain } from "../../chains/utils.js";
|
11
|
+
import type { ThirdwebClient } from "../../client/client.js";
|
11
12
|
import { type ThirdwebContract, getContract } from "../../contract/contract.js";
|
12
13
|
import { allowance } from "../../extensions/erc20/__generated__/IERC20/read/allowance.js";
|
13
14
|
import { approve } from "../../extensions/erc20/write/approve.js";
|
@@ -18,6 +19,7 @@ import {
|
|
18
19
|
signEip712Transaction,
|
19
20
|
} from "../../transaction/actions/zksync/send-eip712-transaction.js";
|
20
21
|
import type { PreparedTransaction } from "../../transaction/prepare-transaction.js";
|
22
|
+
import { readContract } from "../../transaction/read-contract.js";
|
21
23
|
import { getAddress } from "../../utils/address.js";
|
22
24
|
import { isZkSyncChain } from "../../utils/any-evm/zksync/isZkSyncChain.js";
|
23
25
|
import { concatHex } from "../../utils/encoding/helpers/concat-hex.js";
|
@@ -97,10 +99,26 @@ export async function connectSmartWallet(
|
|
97
99
|
}
|
98
100
|
|
99
101
|
const options = creationOptions;
|
102
|
+
const chain = connectChain ?? options.chain;
|
103
|
+
|
104
|
+
// if factory is passed, but no entrypoint, try to resolve entrypoint from factory
|
105
|
+
if (options.factoryAddress && !options.overrides?.entrypointAddress) {
|
106
|
+
const entrypointAddress = await getEntrypointFromFactory(
|
107
|
+
options.factoryAddress,
|
108
|
+
client,
|
109
|
+
chain,
|
110
|
+
);
|
111
|
+
if (entrypointAddress) {
|
112
|
+
options.overrides = {
|
113
|
+
...options.overrides,
|
114
|
+
entrypointAddress,
|
115
|
+
};
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
100
119
|
const factoryAddress =
|
101
120
|
options.factoryAddress ??
|
102
|
-
getDefaultAccountFactory(
|
103
|
-
const chain = connectChain ?? options.chain;
|
121
|
+
getDefaultAccountFactory(options.overrides?.entrypointAddress);
|
104
122
|
const sponsorGas =
|
105
123
|
"gasless" in options ? options.gasless : options.sponsorGas;
|
106
124
|
|
@@ -638,3 +656,23 @@ async function confirmContractDeployment(args: {
|
|
638
656
|
isDeployed = await isContractDeployed(accountContract);
|
639
657
|
}
|
640
658
|
}
|
659
|
+
async function getEntrypointFromFactory(
|
660
|
+
factoryAddress: string,
|
661
|
+
client: ThirdwebClient,
|
662
|
+
chain: Chain,
|
663
|
+
) {
|
664
|
+
const factoryContract = getContract({
|
665
|
+
address: factoryAddress,
|
666
|
+
client,
|
667
|
+
chain,
|
668
|
+
});
|
669
|
+
try {
|
670
|
+
const entrypointAddress = await readContract({
|
671
|
+
contract: factoryContract,
|
672
|
+
method: "function entrypoint() public view returns (address)",
|
673
|
+
});
|
674
|
+
return entrypointAddress;
|
675
|
+
} catch {
|
676
|
+
return undefined;
|
677
|
+
}
|
678
|
+
}
|
@@ -23,7 +23,7 @@ import { isContractDeployed } from "../../utils/bytecode/is-contract-deployed.js
|
|
23
23
|
import { sleep } from "../../utils/sleep.js";
|
24
24
|
import type { Account, Wallet } from "../interfaces/wallet.js";
|
25
25
|
import { generateAccount } from "../utils/generateAccount.js";
|
26
|
-
import {
|
26
|
+
import { DEFAULT_ACCOUNT_FACTORY_V0_7 } from "./lib/constants.js";
|
27
27
|
import { smartWallet } from "./smart-wallet.js";
|
28
28
|
|
29
29
|
let wallet: Wallet;
|
@@ -54,9 +54,7 @@ describe.runIf(process.env.TW_SECRET_KEY).sequential(
|
|
54
54
|
wallet = smartWallet({
|
55
55
|
chain,
|
56
56
|
gasless: true,
|
57
|
-
|
58
|
-
entrypointAddress: ENTRYPOINT_ADDRESS_v0_7,
|
59
|
-
},
|
57
|
+
factoryAddress: DEFAULT_ACCOUNT_FACTORY_V0_7,
|
60
58
|
});
|
61
59
|
smartAccount = await wallet.connect({
|
62
60
|
client: TEST_CLIENT,
|
@@ -85,21 +85,18 @@ import { getDefaultAccountFactory } from "./lib/constants.js";
|
|
85
85
|
*
|
86
86
|
* ## Using v0.7 Entrypoint
|
87
87
|
*
|
88
|
-
* Both v0.6 (default) and v0.7 ERC4337 Entrypoints are supported. To use the v0.7 Entrypoint,
|
88
|
+
* Both v0.6 (default) and v0.7 ERC4337 Entrypoints are supported. To use the v0.7 Entrypoint, simply pass in a compatible account factory.
|
89
89
|
*
|
90
90
|
* You can use the predeployed `DEFAULT_ACCOUNT_FACTORY_V0_7` or deploy your own [AccountFactory v0.7](https://thirdweb.com/thirdweb.eth/AccountFactory_0_7).
|
91
91
|
*
|
92
92
|
* ```ts
|
93
|
-
* import { smartWallet, DEFAULT_ACCOUNT_FACTORY_V0_7
|
93
|
+
* import { smartWallet, DEFAULT_ACCOUNT_FACTORY_V0_7 } from "thirdweb/wallets/smart";
|
94
94
|
* import { sepolia } from "thirdweb/chains";
|
95
95
|
*
|
96
96
|
* const wallet = smartWallet({
|
97
97
|
* chain: sepolia,
|
98
98
|
* sponsorGas: true, // enable sponsored transactions
|
99
|
-
* factoryAddress: DEFAULT_ACCOUNT_FACTORY_V0_7,
|
100
|
-
* overrides: {
|
101
|
-
* entrypointAddress: ENTRYPOINT_ADDRESS_v0_7
|
102
|
-
* }
|
99
|
+
* factoryAddress: DEFAULT_ACCOUNT_FACTORY_V0_7, // 0.7 factory address
|
103
100
|
* });
|
104
101
|
* ```
|
105
102
|
*
|