Skip to content

Commit 62d18b5

Browse files
Expose getAuthToken from inApp and ecosystem wallets
1 parent 7562952 commit 62d18b5

File tree

7 files changed

+37
-21
lines changed

7 files changed

+37
-21
lines changed

.changeset/brown-ends-strive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Expose getAuthToken from inapp and ecosystem wallets

packages/thirdweb/src/wallets/in-app/core/wallet/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ import type {
1616
SingleStepAuthArgsType,
1717
} from "../authentication/types.js";
1818
import type { UserStatus } from "./enclave-wallet.js";
19+
import type { Wallet } from "../../../interfaces/wallet.js";
20+
21+
export type InAppWallet = Wallet<"inApp"> & {
22+
getAuthToken: () => string | null;
23+
};
24+
25+
export type EcosystemWallet = Wallet<EcosystemWalletId> & {
26+
getAuthToken: () => string | null;
27+
};
1928

2029
export type Ecosystem = {
2130
id: EcosystemWalletId;

packages/thirdweb/src/wallets/in-app/native/ecosystem.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { ThirdwebClient } from "../../../client/client.js";
2-
import type { Wallet } from "../../interfaces/wallet.js";
32
import type {
43
CreateWalletArgs,
54
EcosystemWalletId,
65
} from "../../wallet-types.js";
76
import { createInAppWallet } from "../core/wallet/in-app-core.js";
7+
import type { EcosystemWallet } from "../core/wallet/types.js";
88

99
/**
1010
* 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";
6363
*/
6464
export function ecosystemWallet(
6565
...args: CreateWalletArgs<EcosystemWalletId>
66-
): Wallet<EcosystemWalletId> {
66+
): EcosystemWallet {
6767
const [ecosystemId, createOptions] = args;
6868
const ecosystem = {
6969
id: ecosystemId,
@@ -87,5 +87,5 @@ export function ecosystemWallet(
8787
partnerId: createOptions?.partnerId,
8888
},
8989
ecosystem,
90-
}) as Wallet<EcosystemWalletId>;
90+
}) as EcosystemWallet;
9191
}

packages/thirdweb/src/wallets/in-app/native/in-app.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import type { ThirdwebClient } from "../../../client/client.js";
2-
import type { Wallet } from "../../interfaces/wallet.js";
32
import { createInAppWallet } from "../core/wallet/in-app-core.js";
4-
import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
3+
import type {
4+
InAppWallet,
5+
InAppWalletCreationOptions,
6+
} from "../core/wallet/types.js";
57

68
/**
79
* Creates an in-app wallet.
@@ -57,7 +59,7 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
5759
*/
5860
export function inAppWallet(
5961
createOptions?: InAppWalletCreationOptions,
60-
): Wallet<"inApp"> {
62+
): InAppWallet {
6163
return createInAppWallet({
6264
connectorFactory: async (client: ThirdwebClient) => {
6365
const { InAppNativeConnector } = await import("./native-connector.js");
@@ -68,5 +70,5 @@ export function inAppWallet(
6870
});
6971
},
7072
createOptions,
71-
}) as Wallet<"inApp">;
73+
}) as InAppWallet;
7274
}

packages/thirdweb/src/wallets/in-app/web/ecosystem.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
EcosystemWalletId,
66
} from "../../wallet-types.js";
77
import { createInAppWallet } from "../core/wallet/in-app-core.js";
8+
import type { EcosystemWallet } from "../core/wallet/types.js";
89

910
/**
1011
* 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 +54,7 @@ import { createInAppWallet } from "../core/wallet/in-app-core.js";
5354
*/
5455
export function ecosystemWallet(
5556
...args: CreateWalletArgs<EcosystemWalletId>
56-
): Wallet<EcosystemWalletId> {
57+
): EcosystemWallet {
5758
const [ecosystemId, createOptions] = args;
5859
const ecosystem = {
5960
id: ecosystemId,
@@ -76,5 +77,5 @@ export function ecosystemWallet(
7677
partnerId: ecosystem.partnerId,
7778
},
7879
ecosystem,
79-
}) as Wallet<EcosystemWalletId>;
80+
}) as EcosystemWallet;
8081
}

packages/thirdweb/src/wallets/in-app/web/in-app.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { ThirdwebClient } from "../../../client/client.js";
2-
import type { Wallet } from "../../interfaces/wallet.js";
32
import { createInAppWallet } from "../core/wallet/in-app-core.js";
4-
import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
3+
import type { InAppWallet, InAppWalletCreationOptions } from "../core/wallet/types.js";
54

65
/**
76
* 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 +301,7 @@ import type { InAppWalletCreationOptions } from "../core/wallet/types.js";
302301
*/
303302
export function inAppWallet(
304303
createOptions?: InAppWalletCreationOptions,
305-
): Wallet<"inApp"> {
304+
): InAppWallet {
306305
return createInAppWallet({
307306
connectorFactory: async (client: ThirdwebClient) => {
308307
const { InAppWebConnector } = await import("./lib/web-connector.js");
@@ -313,5 +312,5 @@ export function inAppWallet(
313312
});
314313
},
315314
createOptions,
316-
}) as Wallet<"inApp">;
315+
}) as InAppWallet;
317316
}

packages/thirdweb/src/wallets/in-app/web/lib/in-app-gateway.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe
2222
const clientIdFetch = getClientFetch(
2323
createThirdwebClient({
2424
clientId: TEST_CLIENT.clientId,
25-
}),
25+
})
2626
);
2727

2828
beforeAll(async () => {
@@ -38,7 +38,7 @@ describe
3838
strategy: "backend",
3939
walletSecret: "test-secret",
4040
});
41-
authToken = wallet.getAuthToken?.();
41+
authToken = wallet.getAuthToken();
4242
expect(authToken).toBeDefined();
4343
});
4444

@@ -59,7 +59,7 @@ describe
5959
],
6060
signingOptions: {
6161
from: account.address,
62-
type: "eoa",
62+
type: "EOA",
6363
},
6464
},
6565
bodySerializer: stringify,
@@ -69,17 +69,17 @@ describe
6969
},
7070
});
7171

72-
const signatureResult = signResult.data?.result?.results[0];
72+
const signatureResult = signResult.data?.result[0];
7373
if (signatureResult && "result" in signatureResult) {
7474
expect(signatureResult.result.signature).toEqual(rawSignature);
7575
} else {
7676
throw new Error(
77-
`Failed to sign message: ${stringify(signatureResult?.error) || "Unknown error"}`,
77+
`Failed to sign message: ${stringify(signatureResult?.error) || "Unknown error"}`
7878
);
7979
}
8080
});
8181

82-
it("should queue a 4337 transaction", async () => {
82+
it("should queue a 7702 transaction", async () => {
8383
const body = {
8484
executionOptions: {
8585
chainId: sepolia.id,
@@ -105,7 +105,7 @@ describe
105105
});
106106
if (result.error) {
107107
throw new Error(
108-
`Error sending transaction: ${stringify(result.error)}`,
108+
`Error sending transaction: ${stringify(result.error)}`
109109
);
110110
}
111111

@@ -120,7 +120,7 @@ describe
120120
transactionId: txId,
121121
});
122122

123-
console.log(tx);
123+
console.log(tx.transactionHash);
124124
expect(tx.transactionHash).toBeDefined();
125125
});
126126
});

0 commit comments

Comments
 (0)