diff --git a/.changeset/brown-ends-strive.md b/.changeset/brown-ends-strive.md new file mode 100644 index 00000000000..9e4bdf50766 --- /dev/null +++ b/.changeset/brown-ends-strive.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Expose getAuthToken from inapp and ecosystem wallets diff --git a/packages/thirdweb/src/wallets/in-app/core/wallet/types.ts b/packages/thirdweb/src/wallets/in-app/core/wallet/types.ts index 98c5906a49e..75f5d4330f0 100644 --- a/packages/thirdweb/src/wallets/in-app/core/wallet/types.ts +++ b/packages/thirdweb/src/wallets/in-app/core/wallet/types.ts @@ -3,6 +3,7 @@ import type { ThirdwebClient } from "../../../../client/client.js"; import type { SupportedSmsCountry } from "../../../../react/web/wallets/in-app/supported-sms-countries.js"; import type { AsyncStorage } from "../../../../utils/storage/AsyncStorage.js"; import type { Prettify } from "../../../../utils/type-utils.js"; +import type { Wallet } from "../../../interfaces/wallet.js"; import type { SmartWalletOptions } from "../../../smart/types.js"; import type { AuthOption, @@ -17,6 +18,14 @@ import type { } from "../authentication/types.js"; import type { UserStatus } from "./enclave-wallet.js"; +export type InAppWallet = Wallet<"inApp"> & { + getAuthToken: () => string | null; +}; + +export type EcosystemWallet = Wallet & { + getAuthToken: () => string | null; +}; + export type Ecosystem = { id: EcosystemWalletId; partnerId?: string; diff --git a/packages/thirdweb/src/wallets/in-app/native/ecosystem.ts b/packages/thirdweb/src/wallets/in-app/native/ecosystem.ts index a69b04dfca2..902655e3ff5 100644 --- a/packages/thirdweb/src/wallets/in-app/native/ecosystem.ts +++ b/packages/thirdweb/src/wallets/in-app/native/ecosystem.ts @@ -1,10 +1,10 @@ import type { ThirdwebClient } from "../../../client/client.js"; -import type { Wallet } from "../../interfaces/wallet.js"; import type { CreateWalletArgs, EcosystemWalletId, } from "../../wallet-types.js"; import { createInAppWallet } from "../core/wallet/in-app-core.js"; +import type { EcosystemWallet } from "../core/wallet/types.js"; /** * Creates an [Ecosystem Wallet](https://portal.thirdweb.com/connect/ecosystems/overview) based on various authentication methods. @@ -63,7 +63,7 @@ import { createInAppWallet } from "../core/wallet/in-app-core.js"; */ export function ecosystemWallet( ...args: CreateWalletArgs -): Wallet { +): EcosystemWallet { const [ecosystemId, createOptions] = args; const ecosystem = { id: ecosystemId, @@ -87,5 +87,5 @@ export function ecosystemWallet( partnerId: createOptions?.partnerId, }, ecosystem, - }) as Wallet; + }) as EcosystemWallet; } diff --git a/packages/thirdweb/src/wallets/in-app/native/in-app.ts b/packages/thirdweb/src/wallets/in-app/native/in-app.ts index 80aba848d44..de4b5212677 100644 --- a/packages/thirdweb/src/wallets/in-app/native/in-app.ts +++ b/packages/thirdweb/src/wallets/in-app/native/in-app.ts @@ -1,7 +1,9 @@ import type { ThirdwebClient } from "../../../client/client.js"; -import type { Wallet } from "../../interfaces/wallet.js"; import { createInAppWallet } from "../core/wallet/in-app-core.js"; -import type { InAppWalletCreationOptions } from "../core/wallet/types.js"; +import type { + InAppWallet, + InAppWalletCreationOptions, +} from "../core/wallet/types.js"; /** * Creates an in-app wallet. @@ -57,7 +59,7 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js"; */ export function inAppWallet( createOptions?: InAppWalletCreationOptions, -): Wallet<"inApp"> { +): InAppWallet { return createInAppWallet({ connectorFactory: async (client: ThirdwebClient) => { const { InAppNativeConnector } = await import("./native-connector.js"); @@ -68,5 +70,5 @@ export function inAppWallet( }); }, createOptions, - }) as Wallet<"inApp">; + }) as InAppWallet; } diff --git a/packages/thirdweb/src/wallets/in-app/web/ecosystem.ts b/packages/thirdweb/src/wallets/in-app/web/ecosystem.ts index 97a95d76b1b..c1040e93de0 100644 --- a/packages/thirdweb/src/wallets/in-app/web/ecosystem.ts +++ b/packages/thirdweb/src/wallets/in-app/web/ecosystem.ts @@ -1,10 +1,10 @@ import type { ThirdwebClient } from "../../../client/client.js"; -import type { Wallet } from "../../interfaces/wallet.js"; import type { CreateWalletArgs, EcosystemWalletId, } from "../../wallet-types.js"; import { createInAppWallet } from "../core/wallet/in-app-core.js"; +import type { EcosystemWallet } from "../core/wallet/types.js"; /** * Creates an [Ecosystem Wallet](https://portal.thirdweb.com/connect/wallet/overview) based on various authentication methods. Full list of available authentication methods [here](/connect/wallet/sign-in-methods/configure). @@ -53,7 +53,7 @@ import { createInAppWallet } from "../core/wallet/in-app-core.js"; */ export function ecosystemWallet( ...args: CreateWalletArgs -): Wallet { +): EcosystemWallet { const [ecosystemId, createOptions] = args; const ecosystem = { id: ecosystemId, @@ -76,5 +76,5 @@ export function ecosystemWallet( partnerId: ecosystem.partnerId, }, ecosystem, - }) as Wallet; + }) as EcosystemWallet; } diff --git a/packages/thirdweb/src/wallets/in-app/web/in-app.ts b/packages/thirdweb/src/wallets/in-app/web/in-app.ts index 81462ba3690..7e06b0eb5e8 100644 --- a/packages/thirdweb/src/wallets/in-app/web/in-app.ts +++ b/packages/thirdweb/src/wallets/in-app/web/in-app.ts @@ -1,7 +1,9 @@ import type { ThirdwebClient } from "../../../client/client.js"; -import type { Wallet } from "../../interfaces/wallet.js"; import { createInAppWallet } from "../core/wallet/in-app-core.js"; -import type { InAppWalletCreationOptions } from "../core/wallet/types.js"; +import type { + InAppWallet, + InAppWalletCreationOptions, +} from "../core/wallet/types.js"; /** * Creates an app scoped wallet for users based on various authentication methods. Full list of available authentication methods [here](https://portal.thirdweb.com/connect/wallet/sign-in-methods/configure). @@ -302,7 +304,7 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js"; */ export function inAppWallet( createOptions?: InAppWalletCreationOptions, -): Wallet<"inApp"> { +): InAppWallet { return createInAppWallet({ connectorFactory: async (client: ThirdwebClient) => { const { InAppWebConnector } = await import("./lib/web-connector.js"); @@ -313,5 +315,5 @@ export function inAppWallet( }); }, createOptions, - }) as Wallet<"inApp">; + }) as InAppWallet; } diff --git a/packages/thirdweb/src/wallets/in-app/web/lib/in-app-gateway.test.ts b/packages/thirdweb/src/wallets/in-app/web/lib/in-app-gateway.test.ts index e48111df520..54b22a490c6 100644 --- a/packages/thirdweb/src/wallets/in-app/web/lib/in-app-gateway.test.ts +++ b/packages/thirdweb/src/wallets/in-app/web/lib/in-app-gateway.test.ts @@ -38,7 +38,7 @@ describe strategy: "backend", walletSecret: "test-secret", }); - authToken = wallet.getAuthToken?.(); + authToken = wallet.getAuthToken(); expect(authToken).toBeDefined(); }); @@ -59,7 +59,7 @@ describe ], signingOptions: { from: account.address, - type: "eoa", + type: "EOA", }, }, bodySerializer: stringify, @@ -69,7 +69,7 @@ describe }, }); - const signatureResult = signResult.data?.result?.results[0]; + const signatureResult = signResult.data?.result[0]; if (signatureResult && "result" in signatureResult) { expect(signatureResult.result.signature).toEqual(rawSignature); } else { @@ -79,7 +79,7 @@ describe } }); - it("should queue a 4337 transaction", async () => { + it("should queue a 7702 transaction", async () => { const body = { executionOptions: { chainId: sepolia.id, @@ -120,7 +120,7 @@ describe transactionId: txId, }); - console.log(tx); + console.log(tx.transactionHash); expect(tx.transactionHash).toBeDefined(); }); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a748ca46f7a..ce04f37bf54 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1054,6 +1054,8 @@ importers: specifier: 5.8.3 version: 5.8.3 + packages/api: {} + packages/engine: dependencies: '@hey-api/client-fetch':