Skip to content

Commit

Permalink
Merge branch 'main' into TOOL-3276
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsdls authored Feb 2, 2025
2 parents 08fe6e9 + b651bae commit 6e5b7ec
Show file tree
Hide file tree
Showing 26 changed files with 796 additions and 707 deletions.
7 changes: 7 additions & 0 deletions .changeset/cuddly-pumas-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@thirdweb-dev/service-utils": patch
"thirdweb": patch
"thirdweb-login": patch
---

updated dependencies
5 changes: 5 additions & 0 deletions .changeset/early-adults-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Skip factory entrypoint lookup for ZKsync chains
5 changes: 5 additions & 0 deletions .changeset/friendly-candles-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/service-utils": patch
---

[service-utils] Update to ESM for compression typrse
5 changes: 5 additions & 0 deletions .changeset/metal-icons-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Fix: Ecosystem smart wallets now properly trigger switch chain on their admin wallets
10 changes: 5 additions & 5 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
"@radix-ui/react-slot": "^1.1.1",
"@radix-ui/react-switch": "^1.1.2",
"@radix-ui/react-tooltip": "1.1.7",
"@sentry/nextjs": "8.52.0",
"@sentry/nextjs": "8.53.0",
"@shazow/whatsabi": "^0.19.0",
"@tanstack/react-query": "5.65.1",
"@tanstack/react-query": "5.66.0",
"@tanstack/react-table": "^8.20.6",
"@thirdweb-dev/service-utils": "workspace:*",
"@vercel/functions": "^1.6.0",
Expand Down Expand Up @@ -91,7 +91,7 @@
"remark-gfm": "^4.0.0",
"server-only": "^0.0.1",
"shiki": "1.27.0",
"sonner": "^1.7.3",
"sonner": "^1.7.4",
"spdx-correct": "^3.2.0",
"swagger-ui-react": "^5.18.3",
"tailwind-merge": "^2.6.0",
Expand All @@ -106,7 +106,7 @@
"@chromatic-com/storybook": "3.2.4",
"@next/bundle-analyzer": "15.1.6",
"@next/eslint-plugin-next": "15.1.6",
"@playwright/test": "1.50.0",
"@playwright/test": "1.50.1",
"@storybook/addon-essentials": "8.5.2",
"@storybook/addon-interactions": "8.5.2",
"@storybook/addon-links": "8.5.2",
Expand All @@ -117,7 +117,7 @@
"@storybook/react": "8.5.2",
"@storybook/test": "8.5.2",
"@types/color": "4.2.0",
"@types/node": "22.10.10",
"@types/node": "22.13.0",
"@types/papaparse": "^5.3.15",
"@types/pluralize": "^0.0.33",
"@types/qrcode": "^1.5.5",
Expand Down
2 changes: 1 addition & 1 deletion apps/login/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"devDependencies": {
"@eslint/eslintrc": "^3",
"@types/node": "22.10.10",
"@types/node": "22.13.0",
"@types/react": "19.0.8",
"@types/react-dom": "19.0.3",
"eslint": "^9",
Expand Down
2 changes: 1 addition & 1 deletion apps/login/test/script-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h1>Test Page</h1>

<!-- load the script -->
<script src="http://localhost:3000/twl.min.js" data-client-id="testfoo1234"></script>
<script src="http://localhost:3000/twl.js" data-client-id="testfoo1234"></script>


</body>
Expand Down
8 changes: 4 additions & 4 deletions apps/playground-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"fix": "eslint ./src --fix"
},
"dependencies": {
"@abstract-foundation/agw-client": "^1.3.0",
"@abstract-foundation/agw-react": "^1.4.3",
"@abstract-foundation/agw-client": "^1.4.0",
"@abstract-foundation/agw-react": "^1.5.0",
"@radix-ui/react-accordion": "^1.2.2",
"@radix-ui/react-checkbox": "^1.1.3",
"@radix-ui/react-dialog": "1.1.5",
Expand All @@ -29,7 +29,7 @@
"@radix-ui/react-switch": "^1.1.2",
"@radix-ui/react-tabs": "^1.1.2",
"@radix-ui/react-tooltip": "1.1.7",
"@tanstack/react-query": "5.65.1",
"@tanstack/react-query": "5.66.0",
"@thirdweb-dev/engine": "^0.0.18",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
Expand All @@ -48,7 +48,7 @@
"use-debounce": "^10.0.4"
},
"devDependencies": {
"@types/node": "22.10.10",
"@types/node": "22.13.0",
"@types/react": "19.0.8",
"@types/react-dom": "19.0.3",
"eslint": "8.57.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@radix-ui/react-select": "^2.1.5",
"@radix-ui/react-slot": "^1.1.1",
"@radix-ui/react-tabs": "^1.1.2",
"@tanstack/react-query": "5.65.1",
"@tanstack/react-query": "5.66.0",
"@tryghost/content-api": "^1.11.21",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
Expand Down Expand Up @@ -56,7 +56,7 @@
"@next/eslint-plugin-next": "15.1.6",
"@types/flexsearch": "^0.7.6",
"@types/mdx": "^2.0.13",
"@types/node": "22.10.10",
"@types/node": "22.13.0",
"@types/react": "19.0.8",
"@types/react-dom": "19.0.3",
"@types/react-html-parser": "^2.0.6",
Expand Down
6 changes: 3 additions & 3 deletions apps/wallet-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@radix-ui/react-label": "^2.1.1",
"@radix-ui/react-popover": "^1.1.5",
"@radix-ui/react-slot": "^1.1.1",
"@tanstack/react-query": "5.65.1",
"@tanstack/react-query": "5.66.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.0.4",
Expand All @@ -26,7 +26,7 @@
"react-dom": "19.0.0",
"react-hook-form": "7.54.2",
"server-only": "^0.0.1",
"sonner": "^1.7.3",
"sonner": "^1.7.4",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"thirdweb": "workspace:*",
Expand All @@ -35,7 +35,7 @@
},
"devDependencies": {
"@next/eslint-plugin-next": "15.1.6",
"@types/node": "22.10.10",
"@types/node": "22.13.0",
"@types/react": "19.0.8",
"@types/react-dom": "19.0.3",
"@typescript-eslint/eslint-plugin": "7.14.1",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.12",
"@manypkg/get-packages": "2.2.2",
"@types/node": "22.10.10",
"turbo": "2.3.4",
"@types/node": "22.13.0",
"turbo": "2.4.0",
"typescript": "5.7.3"
},
"pnpm": {
Expand Down
14 changes: 4 additions & 10 deletions packages/service-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@
},
"typesVersions": {
"*": {
"node": [
"./dist/types/node/index.d.ts"
],
"cf-worker": [
"./dist/types/cf-worker/index.d.ts"
]
"node": ["./dist/types/node/index.d.ts"],
"cf-worker": ["./dist/types/cf-worker/index.d.ts"]
}
},
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/pay",
Expand All @@ -40,9 +36,7 @@
"url": "https://github.com/thirdweb-dev/js/issues"
},
"author": "thirdweb eng <[email protected]>",
"files": [
"dist/"
],
"files": ["dist/"],
"sideEffects": false,
"dependencies": {
"aws4fetch": "1.0.20",
Expand All @@ -53,7 +47,7 @@
"devDependencies": {
"@cloudflare/workers-types": "4.20250129.0",
"@types/lz4js": "^0.2.1",
"@types/node": "22.10.10",
"@types/node": "22.13.0",
"typescript": "5.7.3",
"vitest": "3.0.4"
},
Expand Down
5 changes: 2 additions & 3 deletions packages/service-utils/src/cf-worker/usageV2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ServiceName } from "../core/services.js";
import { type UsageV2Event, getTopicName } from "../core/usageV2.js";
import type { UsageV2Event } from "../core/usageV2.js";

/**
* Send events to Kafka.
Expand Down Expand Up @@ -29,8 +29,7 @@ export async function sendUsageV2Events(
? "https://u.thirdweb.com"
: "https://u.thirdweb-dev.com";

const topic = getTopicName(options.productName);
const resp = await fetch(`${baseUrl}/usage-v2/${topic}`, {
const resp = await fetch(`${baseUrl}/usage-v2/${options.productName}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
15 changes: 7 additions & 8 deletions packages/service-utils/src/node/usageV2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { randomUUID } from "node:crypto";
import { checkServerIdentity } from "node:tls";
import {
CompressionCodecs,
CompressionTypes,
Kafka,
type Producer,
Expand All @@ -10,10 +11,6 @@ import { compress, decompress } from "lz4js";
import type { ServiceName } from "../core/services.js";
import { type UsageV2Event, getTopicName } from "../core/usageV2.js";

// Import KafkaJS with CJS pattern (source: https://github.com/tulios/kafkajs/issues/1391)
import KafkaJS from "kafkajs";
const { CompressionCodecs } = KafkaJS;

/**
* Creates a UsageV2Producer which opens a persistent TCP connection.
* This class is thread-safe so your service should re-use one instance.
Expand Down Expand Up @@ -47,9 +44,9 @@ export class UsageV2Producer {
*/
productName: ServiceName;
/**
* The compression algorithm to use.
* Whether to compress the events.
*/
compression?: CompressionTypes;
shouldCompress?: boolean;

username: string;
password: string;
Expand All @@ -58,7 +55,7 @@ export class UsageV2Producer {
producerName,
environment,
productName,
compression = CompressionTypes.LZ4,
shouldCompress = true,
username,
password,
} = config;
Expand All @@ -82,7 +79,9 @@ export class UsageV2Producer {
});

this.topic = getTopicName(productName);
this.compression = compression;
this.compression = shouldCompress
? CompressionTypes.LZ4
: CompressionTypes.None;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/thirdweb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
"@radix-ui/react-focus-scope": "1.1.1",
"@radix-ui/react-icons": "1.3.2",
"@radix-ui/react-tooltip": "1.1.7",
"@tanstack/react-query": "5.65.1",
"@tanstack/react-query": "5.66.0",
"@walletconnect/ethereum-provider": "2.17.5",
"@walletconnect/sign-client": "2.17.5",
"abitype": "1.0.8",
Expand Down Expand Up @@ -361,7 +361,7 @@
"ethers6": "npm:ethers@6",
"expo-linking": "7.0.3",
"expo-web-browser": "14.0.1",
"happy-dom": "16.7.3",
"happy-dom": "16.8.1",
"knip": "5.43.6",
"msw": "2.7.0",
"prettier": "3.3.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ export const ZKSYNC_WETH: Record<number, string> = {
[11124]: "0x9EDCde0257F2386Ce177C3a7FCdd97787F0D841d",
[37111]: "0xaA91D645D7a6C1aeaa5988e0547267B77d33fe16",
[555271]: "0xb0b8b267d44c64BA6dD1Daf442949887c85199f6",
[2741]: "0x3439153EB7AF838Ad19d56E1571FBD09333C2809",
};
3 changes: 1 addition & 2 deletions packages/thirdweb/src/wallets/eip5792/get-capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { isCoinbaseSDKWallet } from "../coinbase/coinbase-web.js";
import { isInAppWallet } from "../in-app/core/wallet/index.js";
import { getInjectedProvider } from "../injected/index.js";
import type { Wallet } from "../interfaces/wallet.js";
import { isSmartWallet } from "../smart/index.js";
import { isWalletConnect } from "../wallet-connect/controller.js";
import type { WalletId } from "../wallet-types.js";
import type { WalletCapabilities, WalletCapabilitiesRecord } from "./types.js";
Expand Down Expand Up @@ -47,7 +46,7 @@ export async function getCapabilities<const ID extends WalletId = WalletId>({
};
}

if (isSmartWallet(wallet)) {
if (wallet.id === "smart") {
const { smartWalletGetCapabilities } = await import(
"../smart/lib/smart-wallet-capabilities.js"
);
Expand Down
43 changes: 43 additions & 0 deletions packages/thirdweb/src/wallets/manager/connection-manager.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
import { TEST_ACCOUNT_A } from "../../../test/src/test-wallets.js";
import { baseSepolia } from "../../chains/chain-definitions/base-sepolia.js";
import { sepolia } from "../../chains/chain-definitions/sepolia.js";
import type { ThirdwebClient } from "../../client/client.js";
import type { AsyncStorage } from "../../utils/storage/AsyncStorage.js";
import { inAppWallet } from "../in-app/web/in-app.js";
import type { Account, Wallet } from "../interfaces/wallet.js";
import { smartWallet } from "../smart/smart-wallet.js";
import type { SmartWalletOptions } from "../smart/types.js";
import {
createConnectionManager,
Expand Down Expand Up @@ -157,6 +160,46 @@ describe.runIf(process.env.TW_SECRET_KEY)("Connection Manager", () => {
expect(wallet.switchChain).toHaveBeenCalledWith(newChain);
});

it("should switch admin wallet for smart wallet if available", async () => {
const manager = createConnectionManager(storage);
const adminAccount = TEST_ACCOUNT_A;
const adminWallet = inAppWallet();
adminWallet.getAccount = () => adminAccount;

const _wallet = smartWallet({
chain: baseSepolia,
sponsorGas: true,
});
await _wallet.connect({
client,
personalAccount: adminAccount,
});

await manager.handleConnection(adminWallet, { client });
await manager.handleConnection(_wallet, { client });

const newChain = {
id: 2,
name: "New Chain",
rpc: "https://rpc.example.com",
};

// Mock storage and wallet setup
storage.getItem = vi.fn().mockResolvedValue("inApp");
adminWallet.id = "inApp";
_wallet.switchChain = vi.fn();
adminWallet.switchChain = vi.fn();

// Add wallets to connected wallets store
manager.addConnectedWallet(adminWallet);
manager.addConnectedWallet(_wallet);

await manager.switchActiveWalletChain(newChain);

expect(_wallet.switchChain).toHaveBeenCalledWith(newChain);
expect(adminWallet.switchChain).toHaveBeenCalledWith(newChain);
});

it("should define chains", async () => {
const manager = createConnectionManager(storage);
await manager.handleConnection(wallet, { client });
Expand Down
Loading

0 comments on commit 6e5b7ec

Please sign in to comment.