Skip to content

Commit

Permalink
merge in main
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsdls committed Oct 9, 2023
2 parents bb4fec5 + 125c836 commit 5f038e0
Show file tree
Hide file tree
Showing 100 changed files with 3,064 additions and 308 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"hotlink-revert": "node ./scripts/hotlink/hotlink-revert.mjs",
"explain:major": "node ./scripts/changeset-explain-major.mjs"
},
"packageManager": "pnpm@8.6.12",
"packageManager": "pnpm@8.9.0",
"dependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
Expand Down
21 changes: 21 additions & 0 deletions packages/auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# @thirdweb-dev/auth

## 3.2.48

### Patch Changes

- Updated dependencies []:
- @thirdweb-dev/wallets@1.3.5

## 3.2.47

### Patch Changes

- Updated dependencies [[`9bd01de5`](https://github.com/thirdweb-dev/js/commit/9bd01de5f9c388e758fba9af7899dc4a9c5a0101)]:
- @thirdweb-dev/wallets@1.3.4

## 3.2.46

### Patch Changes

- Updated dependencies [[`6d3d76cf`](https://github.com/thirdweb-dev/js/commit/6d3d76cff8018015faa191a1f8bd4f34506a6650), [`04f2f7b8`](https://github.com/thirdweb-dev/js/commit/04f2f7b8ff5f19345d868fc515a24ccd6ffd0ab9)]:
- @thirdweb-dev/wallets@1.3.3

## 3.2.45

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/auth",
"version": "3.2.45",
"version": "3.2.48",
"main": "dist/thirdweb-dev-auth.cjs.js",
"module": "dist/thirdweb-dev-auth.esm.js",
"browser": {
Expand Down
28 changes: 28 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# thirdweb

## 0.12.10

### Patch Changes

- 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)]:
- @thirdweb-dev/sdk@3.10.67
- @thirdweb-dev/wallets@1.3.5
- @thirdweb-dev/auth@3.2.48

## 0.12.9

### Patch Changes

- Updated dependencies [[`9bd01de5`](https://github.com/thirdweb-dev/js/commit/9bd01de5f9c388e758fba9af7899dc4a9c5a0101), [`f35fbec1`](https://github.com/thirdweb-dev/js/commit/f35fbec1be14332d06e73b5f44f66975ef311d6c)]:
- @thirdweb-dev/wallets@1.3.4
- @thirdweb-dev/sdk@3.10.66
- @thirdweb-dev/auth@3.2.47

## 0.12.8

### Patch Changes

- 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)]:
- @thirdweb-dev/wallets@1.3.3
- @thirdweb-dev/storage@1.2.11
- @thirdweb-dev/sdk@3.10.65
- @thirdweb-dev/auth@3.2.46

## 0.12.7

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "thirdweb",
"main": "dist/cli/index.js",
"version": "0.12.7",
"version": "0.12.10",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/cli",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"license": "Apache-2.0",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/contracts-js",
"dependencies": {
"@thirdweb-dev/contracts": "3.10.0"
"@thirdweb-dev/contracts": "3.10.1-0"
},
"devDependencies": {
"@babel/preset-env": "^7.22.9",
Expand Down
70 changes: 70 additions & 0 deletions packages/react-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,75 @@
# @thirdweb-dev/react-core

## 3.16.5

### Patch Changes

- 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)]:
- @thirdweb-dev/sdk@3.10.67
- @thirdweb-dev/wallets@1.3.5
- @thirdweb-dev/auth@3.2.48

## 3.16.4

### Patch Changes

- [#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

- [#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.

```
const smartWallet = useWallet("smartWallet"); // returns a SmartWallet instance
const embeddedWallet = useWallet("embeddedWallet"); // returns a EmbeddedWallet instance
```

- [#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

```
const Component = () => {
const {
mutate: createSessionKey,
isLoading,
error,
} = useCreateSessionKey();
if (error) {
console.error("failed to create session key", error);
}
return (
<button
disabled={isLoading}
onClick={() => createSessionKey(
"0x...",
{
approvedCallTargets: ["0x..."], // the addresses of contracts that the session key can call
nativeTokenLimitPerTransaction: 0.1, // the maximum amount of native token (in ETH) that the session key can spend per transaction
startDate: new Date(), // the date when the session key becomes active
expirationDate = new Date(Date.now() + 24 * 60 * 60 * 1000); // the date when the session key expires
}
)}
>
Create Session Key
</button>
);
};
```

- Updated dependencies [[`9bd01de5`](https://github.com/thirdweb-dev/js/commit/9bd01de5f9c388e758fba9af7899dc4a9c5a0101), [`f35fbec1`](https://github.com/thirdweb-dev/js/commit/f35fbec1be14332d06e73b5f44f66975ef311d6c)]:
- @thirdweb-dev/wallets@1.3.4
- @thirdweb-dev/sdk@3.10.66
- @thirdweb-dev/auth@3.2.47

## 3.16.3

### Patch Changes

- 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)]:
- @thirdweb-dev/wallets@1.3.3
- @thirdweb-dev/storage@1.2.11
- @thirdweb-dev/sdk@3.10.65
- @thirdweb-dev/auth@3.2.46

## 3.16.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react-core",
"version": "3.16.2",
"version": "3.16.5",
"repository": "https://github.com/thirdweb-dev/js/tree/main/packages/react-core",
"author": "thirdweb eng <[email protected]>",
"license": "Apache-2.0",
Expand Down
62 changes: 60 additions & 2 deletions packages/react-core/src/core/hooks/wallet-hooks.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,74 @@
import { useWalletContext } from "../providers/thirdweb-wallet-provider";
import invariant from "tiny-invariant";
import type {
BloctoWallet,
CoinbaseWallet,
EmbeddedWallet,
FrameWallet,
LocalWallet,
MagicLink,
MetaMaskWallet,
PaperWallet,
PhantomWallet,
RainbowWallet,
SafeWallet,
SmartWallet,
TrustWallet,
WalletConnect,
walletIds,
} from "@thirdweb-dev/wallets";
import { WalletInstance } from "../types/wallet";

export type WalletId = (typeof walletIds)[keyof typeof walletIds];

type WalletIdToWalletTypeMap = {
metamask: MetaMaskWallet;
coinbase: CoinbaseWallet;
rainbowWallet: RainbowWallet;
blocto: BloctoWallet;
frame: FrameWallet;
localWallet: LocalWallet;
magicLink: MagicLink;
paper: PaperWallet;
smartWallet: SmartWallet;
safe: SafeWallet;
trust: TrustWallet;
embeddedWallet: EmbeddedWallet;
walletConnect: WalletConnect;
phantom: PhantomWallet;
walletConnectV1: WalletConnect;
};

/**
* @returns the current active wallet instance
*/
export function useWallet() {
export function useWallet<T extends WalletId>(
walletId: T,
): WalletIdToWalletTypeMap[T] | undefined;
export function useWallet(): WalletInstance | undefined;
export function useWallet<T extends WalletId>(walletId?: T) {
const context = useWalletContext();
invariant(
context,
"useWallet() hook must be used within a <ThirdwebProvider/>",
);
return context.activeWallet;

const activeWallet = context.activeWallet;

if (!activeWallet) {
return undefined;
}

// if walletId is provided, return the wallet instance only if it matches the walletId
if (walletId) {
if (activeWallet.walletId === walletId) {
return activeWallet as WalletIdToWalletTypeMap[T];
} else {
return undefined;
}
}

return activeWallet;
}

/**
Expand Down
Loading

0 comments on commit 5f038e0

Please sign in to comment.