thirdweb 5.53.0-nightly-9d84aff26615b6a553ac002e7f51a0ed5172eb5d-20240909000344 → 5.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/cjs/chains/chain-definitions/assetchain-testnet.js +25 -0
  2. package/dist/cjs/chains/chain-definitions/assetchain-testnet.js.map +1 -0
  3. package/dist/cjs/exports/react.native.js +4 -1
  4. package/dist/cjs/exports/react.native.js.map +1 -1
  5. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +4 -2
  6. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  7. package/dist/cjs/social/profiles.js.map +1 -1
  8. package/dist/cjs/utils/bytecode/resolveImplementation.js +17 -10
  9. package/dist/cjs/utils/bytecode/resolveImplementation.js.map +1 -1
  10. package/dist/cjs/version.js +1 -1
  11. package/dist/cjs/version.js.map +1 -1
  12. package/dist/cjs/wallets/coinbase/coinbaseMobileSDK.js +52 -24
  13. package/dist/cjs/wallets/coinbase/coinbaseMobileSDK.js.map +1 -1
  14. package/dist/cjs/wallets/coinbase/coinbaseWebSDK.js.map +1 -1
  15. package/dist/cjs/wallets/coinbase/utils.js +1 -1
  16. package/dist/cjs/wallets/coinbase/utils.js.map +1 -1
  17. package/dist/esm/chains/chain-definitions/assetchain-testnet.js +22 -0
  18. package/dist/esm/chains/chain-definitions/assetchain-testnet.js.map +1 -0
  19. package/dist/esm/exports/react.native.js +2 -0
  20. package/dist/esm/exports/react.native.js.map +1 -1
  21. package/dist/esm/exports/social.js +0 -1
  22. package/dist/esm/exports/social.js.map +1 -1
  23. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +4 -2
  24. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  25. package/dist/esm/social/profiles.js.map +1 -1
  26. package/dist/esm/utils/bytecode/resolveImplementation.js +17 -10
  27. package/dist/esm/utils/bytecode/resolveImplementation.js.map +1 -1
  28. package/dist/esm/version.js +1 -1
  29. package/dist/esm/version.js.map +1 -1
  30. package/dist/esm/wallets/coinbase/coinbaseMobileSDK.js +50 -22
  31. package/dist/esm/wallets/coinbase/coinbaseMobileSDK.js.map +1 -1
  32. package/dist/esm/wallets/coinbase/coinbaseWebSDK.js.map +1 -1
  33. package/dist/esm/wallets/coinbase/utils.js +1 -1
  34. package/dist/esm/wallets/coinbase/utils.js.map +1 -1
  35. package/dist/types/chains/chain-definitions/assetchain-testnet.d.ts +7 -0
  36. package/dist/types/chains/chain-definitions/assetchain-testnet.d.ts.map +1 -0
  37. package/dist/types/exports/react.d.ts +1 -0
  38. package/dist/types/exports/react.d.ts.map +1 -1
  39. package/dist/types/exports/react.native.d.ts +2 -0
  40. package/dist/types/exports/react.native.d.ts.map +1 -1
  41. package/dist/types/exports/social.d.ts +1 -1
  42. package/dist/types/exports/social.d.ts.map +1 -1
  43. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  44. package/dist/types/react/core/social/useSocialProfiles.d.ts +1 -1
  45. package/dist/types/react/core/social/useSocialProfiles.d.ts.map +1 -1
  46. package/dist/types/react/core/utils/wallet.d.ts +1 -1
  47. package/dist/types/social/profiles.d.ts +2 -2
  48. package/dist/types/social/profiles.d.ts.map +1 -1
  49. package/dist/types/social/types.d.ts +2 -2
  50. package/dist/types/social/types.d.ts.map +1 -1
  51. package/dist/types/version.d.ts +1 -1
  52. package/dist/types/version.d.ts.map +1 -1
  53. package/dist/types/wallets/coinbase/coinbaseMobileSDK.d.ts +2 -3
  54. package/dist/types/wallets/coinbase/coinbaseMobileSDK.d.ts.map +1 -1
  55. package/dist/types/wallets/coinbase/coinbaseWebSDK.d.ts.map +1 -1
  56. package/package.json +14 -1
  57. package/src/chains/chain-definitions/assetchain-testnet.ts +22 -0
  58. package/src/event/actions/get-events.test.ts +13 -0
  59. package/src/exports/react.native.ts +9 -0
  60. package/src/exports/react.ts +6 -0
  61. package/src/exports/social.ts +6 -1
  62. package/src/extensions/modules/ClaimableERC1155/claimableERC1155.test.ts +1 -1
  63. package/src/extensions/modules/ClaimableERC20/claimableERC20.test.ts +1 -1
  64. package/src/extensions/modules/ClaimableERC721/claimableERC721.test.ts +1 -1
  65. package/src/extensions/modules/OpenEditionMetadataERC721/openEditionERC721.test.ts +1 -1
  66. package/src/extensions/prebuilts/deploy-modular-core.test.ts +1 -1
  67. package/src/react/core/hooks/transaction/useSendTransaction.ts +4 -2
  68. package/src/social/profiles.ts +3 -3
  69. package/src/social/types.ts +2 -2
  70. package/src/utils/bytecode/resolveImplementation.test.ts +9 -0
  71. package/src/utils/bytecode/resolveImplementation.ts +21 -13
  72. package/src/version.ts +1 -1
  73. package/src/wallets/coinbase/coinbaseMobileSDK.ts +66 -35
  74. package/src/wallets/coinbase/coinbaseWebSDK.ts +0 -1
  75. package/src/wallets/coinbase/utils.ts +1 -1
@@ -1,7 +1,7 @@
1
1
  import type { ThirdwebClient } from "../client/client.js";
2
2
  import { getThirdwebBaseUrl } from "../utils/domains.js";
3
3
  import { getClientFetch } from "../utils/fetch.js";
4
- import type { SocialProfiles } from "./types.js";
4
+ import type { SocialProfile } from "./types.js";
5
5
 
6
6
  /**
7
7
  * Fetches the wallet's available social profiles.
@@ -23,7 +23,7 @@ import type { SocialProfiles } from "./types.js";
23
23
  export async function getSocialProfiles(args: {
24
24
  address: string;
25
25
  client: ThirdwebClient;
26
- }): Promise<SocialProfiles> {
26
+ }): Promise<SocialProfile[]> {
27
27
  const { address, client } = args;
28
28
 
29
29
  const clientFetch = getClientFetch(client);
@@ -42,5 +42,5 @@ export async function getSocialProfiles(args: {
42
42
  }
43
43
  }
44
44
 
45
- return (await response.json()).data as SocialProfiles;
45
+ return (await response.json()).data as SocialProfile[];
46
46
  }
@@ -34,10 +34,10 @@ export type EnsProfile = {
34
34
  telegram?: string;
35
35
  };
36
36
 
37
- export type SocialProfiles = {
37
+ export type SocialProfile = {
38
38
  type: "farcaster" | "lens" | "ens";
39
39
  name?: string;
40
40
  avatar?: string;
41
41
  bio?: string;
42
42
  metadata?: FarcasterProfile | LensProfile | EnsProfile;
43
- }[];
43
+ };
@@ -8,6 +8,8 @@ import {
8
8
  import { ANVIL_CHAIN } from "../../../test/src/chains.js";
9
9
  import { TEST_CLIENT } from "../../../test/src/test-clients.js";
10
10
  import {
11
+ BASE_USDC_IMPLEMENTATION,
12
+ BASE_USDC_PROXY_CONTRACT,
11
13
  NFT_DROP_CONTRACT,
12
14
  NFT_DROP_IMPLEMENTATION,
13
15
  POLYGON_USDT_IMPLEMENTATION,
@@ -31,6 +33,13 @@ describe("Resolve implementation", async () => {
31
33
  );
32
34
  });
33
35
 
36
+ it("should extract implementation address for base USDC proxy contract", async () => {
37
+ const resolved = resolveImplementation(BASE_USDC_PROXY_CONTRACT);
38
+ expect((await resolved).address).to.equal(
39
+ BASE_USDC_IMPLEMENTATION.toLowerCase(),
40
+ );
41
+ });
42
+
34
43
  it("should extract implementation address for ERC1967 proxy contract", async () => {
35
44
  const implementationAddress = await deployContract({
36
45
  client: TEST_CLIENT,
@@ -120,24 +120,32 @@ async function getImplementationFromStorageSlot(
120
120
  });
121
121
 
122
122
  try {
123
- let proxyStorage = "";
124
-
125
- proxyStorage = await eth_getStorageAt(rpcRequest, {
126
- address: contract.address,
127
- position:
128
- "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc",
129
- });
130
-
131
- if (proxyStorage === ZERO_BYTES32 && contract.chain.id === 137) {
132
- proxyStorage = await eth_getStorageAt(rpcRequest, {
123
+ const proxyStoragePromises = [
124
+ eth_getStorageAt(rpcRequest, {
125
+ address: contract.address,
126
+ position:
127
+ "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc",
128
+ }),
129
+ eth_getStorageAt(rpcRequest, {
133
130
  address: contract.address,
134
131
  position:
135
132
  // keccak256("matic.network.proxy.implementation") - used in polygon USDT proxy: https://polygonscan.com/address/0xc2132d05d31c914a87c6611c10748aeb04b58e8f#code
136
133
  "0xbaab7dbf64751104133af04abc7d9979f0fda3b059a322a8333f533d3f32bf7f",
137
- });
138
- }
134
+ }),
135
+ eth_getStorageAt(rpcRequest, {
136
+ address: contract.address,
137
+ position:
138
+ // keccak256("org.zeppelinos.proxy.implementation") - e.g. base USDC proxy: https://basescan.org/address/0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913#code
139
+ "0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3",
140
+ }),
141
+ ];
139
142
 
140
- return `0x${proxyStorage.slice(-40)}`;
143
+ const proxyStorages = await Promise.all(proxyStoragePromises);
144
+ const proxyStorage = proxyStorages.find(
145
+ (storage) => storage !== ZERO_BYTES32,
146
+ );
147
+
148
+ return proxyStorage ? `0x${proxyStorage.slice(-40)}` : AddressZero;
141
149
  } catch {
142
150
  return undefined;
143
151
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.53.0-nightly-9d84aff26615b6a553ac002e7f51a0ed5172eb5d-20240909000344";
1
+ export const version = "5.53.0";
@@ -1,9 +1,5 @@
1
- import { configure, handleResponse } from "@coinbase/wallet-mobile-sdk";
2
1
  import type { ProviderInterface } from "@coinbase/wallet-sdk";
3
- import { Linking } from "react-native";
4
- import type { Chain } from "../../chains/types.js";
5
- import type { COINBASE } from "../constants.js";
6
- import type { CreateWalletArgs } from "../wallet-types.js";
2
+ import type { CoinbaseWalletCreationOptions } from "./coinbaseWebSDK.js";
7
3
 
8
4
  let _provider: ProviderInterface | undefined;
9
5
 
@@ -11,44 +7,78 @@ let _provider: ProviderInterface | undefined;
11
7
  * @internal
12
8
  */
13
9
  export async function getCoinbaseMobileProvider(
14
- options?: CreateWalletArgs<typeof COINBASE>[1],
10
+ options?: CoinbaseWalletCreationOptions,
15
11
  ): Promise<ProviderInterface> {
16
12
  if (!_provider) {
17
- const callbackURL = new URL(
18
- options?.mobileConfig?.callbackURL || "https://thirdweb.com/wsegue",
19
- );
20
- const mobileProvider: ProviderInterface = (await initMobileProvider({
21
- chain: options?.chains ? options.chains[0] : undefined,
22
- ...options?.mobileConfig,
23
- })) as unknown as ProviderInterface;
24
- _provider = mobileProvider;
25
- Linking.addEventListener("url", ({ url }) => {
26
- const incomingUrl = new URL(url);
27
- if (
28
- callbackURL &&
29
- incomingUrl.host === callbackURL.host &&
30
- incomingUrl.protocol === callbackURL.protocol &&
31
- incomingUrl.hostname === callbackURL.hostname
32
- ) {
13
+ // if explicitly set to smart wallet only, use the smart wallet provider
14
+ const useSmartWallet = options?.walletConfig?.options === "smartWalletOnly";
15
+ let mobileProvider: ProviderInterface;
16
+ if (useSmartWallet) {
17
+ mobileProvider = (await initSmartWalletProvider(
18
+ options,
19
+ )) as unknown as ProviderInterface;
20
+ const ExpoLinking = await import("expo-linking");
21
+ const { handleResponse } = await import("@mobile-wallet-protocol/client");
22
+ ExpoLinking.addEventListener("url", ({ url }) => {
23
+ handleResponse(url);
24
+ });
25
+ } else {
26
+ // otherwise, use the coinbase app provider
27
+ // TODO: remove this path once the new @mobile-wallet-protocol/client supports it
28
+ mobileProvider = (await initCoinbaseAppProvider(
29
+ options,
30
+ )) as unknown as ProviderInterface;
31
+ const ExpoLinking = await import("expo-linking");
32
+ const { handleResponse } = await import("@coinbase/wallet-mobile-sdk");
33
+ ExpoLinking.addEventListener("url", ({ url }) => {
33
34
  // @ts-expect-error - Passing a URL object to handleResponse crashes the function
34
35
  handleResponse(url);
35
- }
36
- });
36
+ });
37
+ }
38
+ _provider = mobileProvider;
37
39
  return mobileProvider;
38
40
  }
39
41
  return _provider;
40
42
  }
41
43
 
42
- async function initMobileProvider(args: {
43
- chain?: Chain;
44
- callbackURL?: string;
45
- hostURL?: string;
46
- hostPackageName?: string;
47
- }) {
44
+ async function initSmartWalletProvider(
45
+ options?: CoinbaseWalletCreationOptions,
46
+ ) {
47
+ const { EIP1193Provider, Wallets } = await import(
48
+ "@mobile-wallet-protocol/client"
49
+ );
50
+ const appDeeplinkUrl = options?.mobileConfig?.callbackURL;
51
+ if (!appDeeplinkUrl) {
52
+ throw new Error(
53
+ "callbackURL is required. Set it when creating the coinbase wallet. Ex: createWallet('com.coinbase.wallet', { mobileConfig: { callbackUrl: 'https://example.com' }}",
54
+ );
55
+ }
56
+ const sdk = new EIP1193Provider({
57
+ metadata: {
58
+ appName: options?.appMetadata?.name || "thirdweb powered app",
59
+ appChainIds: options?.chains?.map((c) => c.id),
60
+ appDeeplinkUrl,
61
+ appLogoUrl: options?.appMetadata?.logoUrl,
62
+ },
63
+ wallet: Wallets.CoinbaseSmartWallet, // TODO support both smart and EOA once the SDK supports it
64
+ });
65
+ return sdk;
66
+ }
67
+
68
+ async function initCoinbaseAppProvider(
69
+ options?: CoinbaseWalletCreationOptions,
70
+ ) {
71
+ const appDeeplinkUrl = options?.mobileConfig?.callbackURL;
72
+ if (!appDeeplinkUrl) {
73
+ throw new Error(
74
+ "callbackURL is required. Set it when creating the coinbase wallet. Ex: createWallet('com.coinbase.wallet', { mobileConfig: { callbackUrl: 'https://example.com' }}",
75
+ );
76
+ }
77
+ const { configure } = await import("@coinbase/wallet-mobile-sdk");
48
78
  configure({
49
- callbackURL: new URL(args.callbackURL || "https://thirdweb.com/wsegue"),
50
- hostURL: new URL(args.hostURL || "https://wallet.coinbase.com/wsegue"),
51
- hostPackageName: args.hostPackageName || "org.toshi",
79
+ callbackURL: new URL(appDeeplinkUrl),
80
+ hostURL: new URL("https://wallet.coinbase.com/wsegue"),
81
+ hostPackageName: "org.toshi",
52
82
  });
53
83
  let CoinbaseWalletMobileSDK = (
54
84
  await import(
@@ -67,8 +97,9 @@ async function initMobileProvider(args: {
67
97
  }
68
98
  ).default;
69
99
  }
100
+ const chain = options.chains?.[0];
70
101
  return new CoinbaseWalletMobileSDK({
71
- jsonRpcUrl: args.chain?.rpc,
72
- chainId: args.chain?.id,
102
+ jsonRpcUrl: chain?.rpc,
103
+ chainId: chain?.id,
73
104
  });
74
105
  }
@@ -295,7 +295,6 @@ function createAccount(provider: ProviderInterface, _address: string) {
295
295
  },
296
296
  ],
297
297
  })) as Hex;
298
-
299
298
  return {
300
299
  transactionHash,
301
300
  };
@@ -2,5 +2,5 @@ import type { ProviderInterface } from "@coinbase/wallet-sdk";
2
2
 
3
3
  export async function showCoinbasePopup(provider: ProviderInterface) {
4
4
  // biome-ignore lint/suspicious/noExplicitAny: based on the latest CB SDK - scary but works
5
- await (provider as any)?.communicator?.waitForPopupLoaded();
5
+ await (provider as any)?.communicator?.waitForPopupLoaded?.();
6
6
  }