Skip to content

Commit 5f038e0

Browse files
committed
merge in main
2 parents bb4fec5 + 125c836 commit 5f038e0

File tree

100 files changed

+3064
-308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+3064
-308
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"hotlink-revert": "node ./scripts/hotlink/hotlink-revert.mjs",
3434
"explain:major": "node ./scripts/changeset-explain-major.mjs"
3535
},
36-
"packageManager": "pnpm@8.6.12",
36+
"packageManager": "pnpm@8.9.0",
3737
"dependencies": {
3838
"@changesets/changelog-github": "^0.4.8",
3939
"@changesets/cli": "^2.26.2",

packages/auth/CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# @thirdweb-dev/auth
22

3+
## 3.2.48
4+
5+
### Patch Changes
6+
7+
- Updated dependencies []:
8+
- @thirdweb-dev/wallets@1.3.5
9+
10+
## 3.2.47
11+
12+
### Patch Changes
13+
14+
- Updated dependencies [[`9bd01de5`](https://github.com/thirdweb-dev/js/commit/9bd01de5f9c388e758fba9af7899dc4a9c5a0101)]:
15+
- @thirdweb-dev/wallets@1.3.4
16+
17+
## 3.2.46
18+
19+
### Patch Changes
20+
21+
- Updated dependencies [[`6d3d76cf`](https://github.com/thirdweb-dev/js/commit/6d3d76cff8018015faa191a1f8bd4f34506a6650), [`04f2f7b8`](https://github.com/thirdweb-dev/js/commit/04f2f7b8ff5f19345d868fc515a24ccd6ffd0ab9)]:
22+
- @thirdweb-dev/wallets@1.3.3
23+
324
## 3.2.45
425

526
### Patch Changes

packages/auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@thirdweb-dev/auth",
3-
"version": "3.2.45",
3+
"version": "3.2.48",
44
"main": "dist/thirdweb-dev-auth.cjs.js",
55
"module": "dist/thirdweb-dev-auth.esm.js",
66
"browser": {

packages/cli/CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# thirdweb
22

3+
## 0.12.10
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [[`ec36b13a`](https://github.com/thirdweb-dev/js/commit/ec36b13a30e0071548df0b7a6eb5299e2e65e4f9), [`6abb8459`](https://github.com/thirdweb-dev/js/commit/6abb8459712e387b6d8b2edf7eb16fb906c05dae), [`a6c36724`](https://github.com/thirdweb-dev/js/commit/a6c36724eb930ee0abbce876bb7847c859c6fb48)]:
8+
- @thirdweb-dev/sdk@3.10.67
9+
- @thirdweb-dev/wallets@1.3.5
10+
- @thirdweb-dev/auth@3.2.48
11+
12+
## 0.12.9
13+
14+
### Patch Changes
15+
16+
- Updated dependencies [[`9bd01de5`](https://github.com/thirdweb-dev/js/commit/9bd01de5f9c388e758fba9af7899dc4a9c5a0101), [`f35fbec1`](https://github.com/thirdweb-dev/js/commit/f35fbec1be14332d06e73b5f44f66975ef311d6c)]:
17+
- @thirdweb-dev/wallets@1.3.4
18+
- @thirdweb-dev/sdk@3.10.66
19+
- @thirdweb-dev/auth@3.2.47
20+
21+
## 0.12.8
22+
23+
### Patch Changes
24+
25+
- Updated dependencies [[`6d3d76cf`](https://github.com/thirdweb-dev/js/commit/6d3d76cff8018015faa191a1f8bd4f34506a6650), [`04f2f7b8`](https://github.com/thirdweb-dev/js/commit/04f2f7b8ff5f19345d868fc515a24ccd6ffd0ab9), [`15fe4779`](https://github.com/thirdweb-dev/js/commit/15fe4779f4b99e51afe214ac3ebb31f611089787)]:
26+
- @thirdweb-dev/wallets@1.3.3
27+
- @thirdweb-dev/storage@1.2.11
28+
- @thirdweb-dev/sdk@3.10.65
29+
- @thirdweb-dev/auth@3.2.46
30+
331
## 0.12.7
432

533
### Patch Changes

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "thirdweb",
33
"main": "dist/cli/index.js",
4-
"version": "0.12.7",
4+
"version": "0.12.10",
55
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
66
"author": "thirdweb eng <[email protected]>",
77
"license": "Apache-2.0",

packages/contracts-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"license": "Apache-2.0",
1111
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/contracts-js",
1212
"dependencies": {
13-
"@thirdweb-dev/contracts": "3.10.0"
13+
"@thirdweb-dev/contracts": "3.10.1-0"
1414
},
1515
"devDependencies": {
1616
"@babel/preset-env": "^7.22.9",

packages/react-core/CHANGELOG.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,75 @@
11
# @thirdweb-dev/react-core
22

3+
## 3.16.5
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [[`ec36b13a`](https://github.com/thirdweb-dev/js/commit/ec36b13a30e0071548df0b7a6eb5299e2e65e4f9), [`6abb8459`](https://github.com/thirdweb-dev/js/commit/6abb8459712e387b6d8b2edf7eb16fb906c05dae), [`a6c36724`](https://github.com/thirdweb-dev/js/commit/a6c36724eb930ee0abbce876bb7847c859c6fb48)]:
8+
- @thirdweb-dev/sdk@3.10.67
9+
- @thirdweb-dev/wallets@1.3.5
10+
- @thirdweb-dev/auth@3.2.48
11+
12+
## 3.16.4
13+
14+
### Patch Changes
15+
16+
- [#1719](https://github.com/thirdweb-dev/js/pull/1719) [`93127047`](https://github.com/thirdweb-dev/js/commit/931270479ef227556a1077357a8c000b08de6e8d) Thanks [@MananTank](https://github.com/MananTank)! - Type refactor for useWallet hook
17+
18+
- [#1716](https://github.com/thirdweb-dev/js/pull/1716) [`d3c8626a`](https://github.com/thirdweb-dev/js/commit/d3c8626a5a8def882c1592b236048ebe88e85d49) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Better `useWallet()` API to obtain specific wallet instances.
19+
20+
```
21+
const smartWallet = useWallet("smartWallet"); // returns a SmartWallet instance
22+
const embeddedWallet = useWallet("embeddedWallet"); // returns a EmbeddedWallet instance
23+
```
24+
25+
- [#1712](https://github.com/thirdweb-dev/js/pull/1712) [`9bd01de5`](https://github.com/thirdweb-dev/js/commit/9bd01de5f9c388e758fba9af7899dc4a9c5a0101) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Add `useCreateSessionKey` and `useRevokeSessionKey` hooks
26+
27+
```
28+
const Component = () => {
29+
const {
30+
mutate: createSessionKey,
31+
isLoading,
32+
error,
33+
} = useCreateSessionKey();
34+
35+
if (error) {
36+
console.error("failed to create session key", error);
37+
}
38+
39+
return (
40+
<button
41+
disabled={isLoading}
42+
onClick={() => createSessionKey(
43+
"0x...",
44+
{
45+
approvedCallTargets: ["0x..."], // the addresses of contracts that the session key can call
46+
nativeTokenLimitPerTransaction: 0.1, // the maximum amount of native token (in ETH) that the session key can spend per transaction
47+
startDate: new Date(), // the date when the session key becomes active
48+
expirationDate = new Date(Date.now() + 24 * 60 * 60 * 1000); // the date when the session key expires
49+
}
50+
)}
51+
>
52+
Create Session Key
53+
</button>
54+
);
55+
};
56+
```
57+
58+
- Updated dependencies [[`9bd01de5`](https://github.com/thirdweb-dev/js/commit/9bd01de5f9c388e758fba9af7899dc4a9c5a0101), [`f35fbec1`](https://github.com/thirdweb-dev/js/commit/f35fbec1be14332d06e73b5f44f66975ef311d6c)]:
59+
- @thirdweb-dev/wallets@1.3.4
60+
- @thirdweb-dev/sdk@3.10.66
61+
- @thirdweb-dev/auth@3.2.47
62+
63+
## 3.16.3
64+
65+
### Patch Changes
66+
67+
- Updated dependencies [[`6d3d76cf`](https://github.com/thirdweb-dev/js/commit/6d3d76cff8018015faa191a1f8bd4f34506a6650), [`04f2f7b8`](https://github.com/thirdweb-dev/js/commit/04f2f7b8ff5f19345d868fc515a24ccd6ffd0ab9), [`15fe4779`](https://github.com/thirdweb-dev/js/commit/15fe4779f4b99e51afe214ac3ebb31f611089787)]:
68+
- @thirdweb-dev/wallets@1.3.3
69+
- @thirdweb-dev/storage@1.2.11
70+
- @thirdweb-dev/sdk@3.10.65
71+
- @thirdweb-dev/auth@3.2.46
72+
373
## 3.16.2
474

575
### Patch Changes

packages/react-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@thirdweb-dev/react-core",
3-
"version": "3.16.2",
3+
"version": "3.16.5",
44
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
55
"author": "thirdweb eng <[email protected]>",
66
"license": "Apache-2.0",

packages/react-core/src/core/hooks/wallet-hooks.ts

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,74 @@
11
import { useWalletContext } from "../providers/thirdweb-wallet-provider";
22
import invariant from "tiny-invariant";
3+
import type {
4+
BloctoWallet,
5+
CoinbaseWallet,
6+
EmbeddedWallet,
7+
FrameWallet,
8+
LocalWallet,
9+
MagicLink,
10+
MetaMaskWallet,
11+
PaperWallet,
12+
PhantomWallet,
13+
RainbowWallet,
14+
SafeWallet,
15+
SmartWallet,
16+
TrustWallet,
17+
WalletConnect,
18+
walletIds,
19+
} from "@thirdweb-dev/wallets";
20+
import { WalletInstance } from "../types/wallet";
21+
22+
export type WalletId = (typeof walletIds)[keyof typeof walletIds];
23+
24+
type WalletIdToWalletTypeMap = {
25+
metamask: MetaMaskWallet;
26+
coinbase: CoinbaseWallet;
27+
rainbowWallet: RainbowWallet;
28+
blocto: BloctoWallet;
29+
frame: FrameWallet;
30+
localWallet: LocalWallet;
31+
magicLink: MagicLink;
32+
paper: PaperWallet;
33+
smartWallet: SmartWallet;
34+
safe: SafeWallet;
35+
trust: TrustWallet;
36+
embeddedWallet: EmbeddedWallet;
37+
walletConnect: WalletConnect;
38+
phantom: PhantomWallet;
39+
walletConnectV1: WalletConnect;
40+
};
341

442
/**
543
* @returns the current active wallet instance
644
*/
7-
export function useWallet() {
45+
export function useWallet<T extends WalletId>(
46+
walletId: T,
47+
): WalletIdToWalletTypeMap[T] | undefined;
48+
export function useWallet(): WalletInstance | undefined;
49+
export function useWallet<T extends WalletId>(walletId?: T) {
850
const context = useWalletContext();
951
invariant(
1052
context,
1153
"useWallet() hook must be used within a <ThirdwebProvider/>",
1254
);
13-
return context.activeWallet;
55+
56+
const activeWallet = context.activeWallet;
57+
58+
if (!activeWallet) {
59+
return undefined;
60+
}
61+
62+
// if walletId is provided, return the wallet instance only if it matches the walletId
63+
if (walletId) {
64+
if (activeWallet.walletId === walletId) {
65+
return activeWallet as WalletIdToWalletTypeMap[T];
66+
} else {
67+
return undefined;
68+
}
69+
}
70+
71+
return activeWallet;
1472
}
1573

1674
/**

0 commit comments

Comments
 (0)