Skip to content
Merged
Show file tree
Hide file tree
Changes from 141 commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
4d4d8cd
Remove dead code from `react` package
MananTank Feb 15, 2023
589c7f8
Bunch of changes
MananTank Feb 15, 2023
b9cf6cb
export provider from react/evm/index
Feb 16, 2023
a85fa31
temp testing for device wallet
MananTank Feb 16, 2023
79d4296
Merge branch 'main' into connect-wallet-v2
Feb 16, 2023
919aeb2
Lots of improvements
MananTank Feb 16, 2023
fcae2b2
Merge branch 'connect-wallet-v2' of github.com:thirdweb-dev/js into c…
Feb 16, 2023
6c04ae8
FIx coordinatorStorage key
MananTank Feb 16, 2023
2108000
Use AsyncStorage interface in Device Wallet
MananTank Feb 16, 2023
33120ee
Merge branch 'connect-wallet-v2' of github.com:thirdweb-dev/js into c…
Feb 16, 2023
4b4ef5d
Merge branch 'main' into connect-wallet-v2
Feb 17, 2023
c54c6a9
RN provider using core provider
Feb 17, 2023
84758a4
working solution device-wallet rn
Feb 18, 2023
a7551c7
working solution device rn and autoconnect
Feb 18, 2023
81e190f
merge main
Feb 18, 2023
42ccc92
new <ConnectWallet/>
MananTank Feb 20, 2023
0a8769f
Hotlink DX
MananTank Feb 20, 2023
dcf2bcf
remove types in hotlink mode
MananTank Feb 20, 2023
d1cd067
Merge branch 'main' into connect-wallet-v2-ike
Feb 20, 2023
662cff8
merge
Feb 20, 2023
6790ead
pull
Feb 20, 2023
b2f31bb
clean
Feb 20, 2023
85691e2
update exports
Feb 20, 2023
3d8b2d4
merge
Feb 20, 2023
9cb7f1e
coinbase wallet, connect wallet info etc
MananTank Feb 20, 2023
9283bfe
Merge branch 'main' into connect-wallet-v2
joaquim-verges Feb 21, 2023
63790cc
Refactor a bunch of stuff
MananTank Feb 21, 2023
8c34466
hotlink: fix types position change on hotlink-revert
MananTank Feb 21, 2023
ad70131
v1
Feb 21, 2023
62c6751
hotlink: update instructors
MananTank Feb 21, 2023
05066ad
merge
Feb 21, 2023
8f3d0f4
wc v2
Feb 21, 2023
533df42
* core: Make wallet.connector public
MananTank Feb 22, 2023
e663e73
wc v2 working without autoconnect
Feb 22, 2023
384466d
merge
Feb 22, 2023
82ac73a
cleanup
Feb 22, 2023
c4470ef
react: add search in NetworkSelector
MananTank Feb 22, 2023
86d93fa
wallet connect v1
Feb 23, 2023
ce64a3b
Connect to active chain, simplified coinbase connect
MananTank Feb 23, 2023
f759304
wc v1 connector
Feb 23, 2023
445b5fe
merge
Feb 23, 2023
e0bfd36
core: Wallet Connect v1, disconnect listener
MananTank Feb 23, 2023
2a147de
adding patch for wc/legacy-provider
Feb 23, 2023
ea638b2
merge
Feb 23, 2023
d7216d5
Merge branch 'main' into connect-wallet-v2
MananTank Feb 23, 2023
f5b9fb0
logs
Feb 23, 2023
68175f8
format wallet-connect-v1/index.ts
MananTank Feb 24, 2023
411287c
format wallet-connect-v1.ts
MananTank Feb 24, 2023
7ccd9fd
- Added ConnectWallet component (need to figure out icons)
Feb 24, 2023
6c38a17
Added walletsMedata and ConnectWallet component
Feb 26, 2023
8a47293
Merge branch 'main' into connect-wallet-v2
jnsdls Feb 26, 2023
ee658d8
added listeners
Feb 27, 2023
192bce9
merge main
Feb 27, 2023
e620908
merge
Feb 27, 2023
21ed641
Working QR code for metamask and other changes
MananTank Feb 27, 2023
a796094
react: fix connect wallet issues on device wallet and coinbase
MananTank Feb 27, 2023
3ddc1c1
react: add Get Started with Metamask screen
MananTank Feb 27, 2023
553ecdb
merge;
Feb 27, 2023
8a2a2f8
react: add coinbase scan and get started screens
MananTank Feb 27, 2023
4a60fc1
Merge branch 'main' into connect-wallet-v2
MananTank Feb 28, 2023
69c116b
Fix unmet peer deps error in wallets package
MananTank Feb 28, 2023
f9a0366
- Created useActiveChain hook
Feb 28, 2023
2641531
- Created useActiveChain hook
Feb 28, 2023
8b05c66
Merge branch 'connect-wallet-v2' into connect-wallet-v2-ike
Feb 28, 2023
cd85af1
remove emit
Feb 28, 2023
b430c30
react: reduce size of wallet icon in QR
MananTank Feb 28, 2023
4c715b6
wallets: don't add Buffer polyfill on server env
MananTank Feb 28, 2023
4a25fd3
react-core: Fix the wrong native currency on non-default chains
MananTank Feb 28, 2023
4f6fc47
core: remove additional exports
MananTank Feb 28, 2023
ce046b0
react-core: working web3button
MananTank Feb 28, 2023
c017ad0
react: remove dead code
MananTank Feb 28, 2023
117e730
react: make web3button theme optional
MananTank Feb 28, 2023
ec4fd64
wallets: remove getClient() usage in WC connector
MananTank Feb 28, 2023
82ff82f
react: add customizations to ConnectWallet
MananTank Feb 28, 2023
b433fab
merge
Feb 28, 2023
1aacb70
works in next.js
MananTank Feb 28, 2023
9628065
Merge branch 'main' into connect-wallet-v2
joaquim-verges Mar 1, 2023
6359b0b
saving wcv1 session
Mar 1, 2023
8391904
Merge branch 'connect-wallet-v2' into connect-wallet-v2-ike
Mar 1, 2023
affb5c0
log
Mar 1, 2023
9af4549
Merge branch 'main' into connect-wallet-v2
joaquim-verges Mar 1, 2023
c371a2c
Merge branch 'connect-wallet-v2' into connect-wallet-v2-ike
Mar 1, 2023
1f7b03b
set events in correct places
Mar 1, 2023
abffb61
react: allow configuring the dropdown position of ConnectWallet
MananTank Mar 1, 2023
6b719fe
react: disable network switching if only one network supported
MananTank Mar 1, 2023
48d105c
react: fix web3button loading state
MananTank Mar 1, 2023
b4ba996
FIx network mismatch issue, remove desiredChainId
MananTank Mar 1, 2023
dbf78f4
Fix wrong wallet name metamask scan screen
MananTank Mar 1, 2023
b7d839f
replace useConnectionStatus with useConnectingToWallet
MananTank Mar 1, 2023
b7afc59
react: Connect Wallet fixes
MananTank Mar 1, 2023
4a5f525
react: open the metamask app on mobile
MananTank Mar 1, 2023
1fa9011
react: UI adjustments for mobile devices
MananTank Mar 1, 2023
6a34efd
small fixes
Mar 2, 2023
a86edae
Merge branch 'connect-wallet-v2-ike' into connect-wallet-v2
Mar 2, 2023
78d9b9d
react: mobile UI improvements
MananTank Mar 2, 2023
ce84144
Merge branch 'main' into connect-wallet-v2
MananTank Mar 2, 2023
20c266c
react: ConnectWallet files restructure
MananTank Mar 2, 2023
1851180
minor ui improvements
Mar 2, 2023
783a333
switch chain
Mar 2, 2023
5d7d6c2
Merge branch 'connect-wallet-v2' of github.com:thirdweb-dev/js into c…
Mar 2, 2023
760abfc
react: new install app/extension screens
MananTank Mar 2, 2023
d0bdc1c
react: Add Export and Copy button
MananTank Mar 2, 2023
9a7c8cb
merge
Mar 2, 2023
f1c1568
Merge branch 'connect-wallet-v2' of github.com:thirdweb-dev/js into c…
Mar 2, 2023
ac2cce8
coinbase
Mar 3, 2023
4478e93
Merge branch 'connect-wallet-v2' into connect-wallet-v2-ike
Mar 3, 2023
92428c1
added coinbase wallet mobile
Mar 3, 2023
42bbfe3
Merge branch 'main' into connect-wallet-v2-ike
Mar 3, 2023
05c72ea
Merge branch 'main' into connect-wallet-v2
jnsdls Mar 3, 2023
e8e0233
Merge branch 'connect-wallet-v2' of github.com:thirdweb-dev/js into c…
Mar 3, 2023
6acaa8b
revert chagne
Mar 3, 2023
b6ef45b
merge
Mar 3, 2023
3455adc
build
Mar 3, 2023
4833150
dependencies
Mar 3, 2023
5c58481
wallets: fix deps
MananTank Mar 3, 2023
ce0afeb
temporarily remove coinbaseWalletMobile to make a build
MananTank Mar 3, 2023
d6ebc68
last used chainId
Mar 3, 2023
5988a94
update patch
Mar 3, 2023
f13f2b9
move coinbase-wallet-mobile out of wallets
Mar 3, 2023
9f773e6
react, core: Wallet Separation refactor
MananTank Mar 3, 2023
664477c
remove logs. fixed shims. added switch-chain events
Mar 3, 2023
8a429cc
merge
Mar 3, 2023
36686db
merge move coinbase-mobile out
Mar 3, 2023
b79ab34
Merge branch 'main' into connect-wallet-v2
joaquim-verges Mar 5, 2023
f47d307
core: fix disconnect on chain switch issue in metamask
MananTank Mar 6, 2023
091df16
core: fix type error
MananTank Mar 6, 2023
7249413
react: proper wallet options type
MananTank Mar 6, 2023
5052fed
Merge branch 'connect-wallet-v2' of github.com:thirdweb-dev/js into c…
Mar 6, 2023
27704b7
Fix react-qr-code lazy import error
MananTank Mar 6, 2023
c1cc7af
first
Mar 6, 2023
f1d9c8b
react: web3button - show original action if disabled
MananTank Mar 6, 2023
cab64a6
first
Mar 6, 2023
08e2d20
Merge branch 'connect-wallet-v2' of github.com:thirdweb-dev/js into c…
Mar 6, 2023
044b70c
wip
Mar 6, 2023
c8705e3
random
Mar 6, 2023
8f23705
RN wallets classes
Mar 6, 2023
6ce559b
Merge branch 'connect-wallet-v2-type-wip' into connect-wallet-v2
Mar 6, 2023
be10b9a
remove unused function
Mar 6, 2023
c5cebd3
fix lint
Mar 6, 2023
91688d8
fix lint
Mar 6, 2023
805eb29
switch chain for device wallet, fix wallet.addListener
MananTank Mar 7, 2023
9f0e884
handle empty array
Mar 8, 2023
11b3bff
Merge branch 'main' into connect-wallet-v2
jnsdls Mar 8, 2023
4716431
Merge branch 'main' into connect-wallet-v2
MananTank Mar 8, 2023
822305b
[RN] light theme
Mar 8, 2023
bcd28aa
Merge branch 'connect-wallet-v2' of github.com:thirdweb-dev/js into c…
Mar 8, 2023
21036c4
move listeners after provider creation
Mar 8, 2023
fd89b36
listeners
Mar 8, 2023
90f030c
remove wagmi and wagmi related hooks from react-native. switch asyncs…
Mar 9, 2023
dd5c27f
working wallet.addListener
MananTank Mar 9, 2023
f71d50f
Fix auto connect issue when using WC1 connector
MananTank Mar 9, 2023
3d17099
dynamically import WC1 connector in metamask wallet
MananTank Mar 9, 2023
0841a56
react: show tooltip when can't switch network
MananTank Mar 9, 2023
3729c69
core: add timeout for auto connect
MananTank Mar 9, 2023
9cfed81
remove logs
Mar 9, 2023
b442267
Merge branch 'connect-wallet-v2' of github.com:thirdweb-dev/js into c…
Mar 9, 2023
81f7c5c
react: export useActiveChain
MananTank Mar 9, 2023
6bc9065
pass custom walletId per wallet
Mar 9, 2023
2a2b4ae
pass custom walletId per wallet
Mar 9, 2023
2073809
Merge branch 'connect-wallet-v2' of github.com:thirdweb-dev/js into c…
Mar 9, 2023
4755994
stop using wagmi chain object
Mar 9, 2023
02d3b22
- Remove wagmi/core as a dependency in react-native
Mar 10, 2023
2a4209b
add changeset
Mar 10, 2023
cf06040
react: minor UI updates
MananTank Mar 10, 2023
a598922
react-core: remove duplicate export
MananTank Mar 10, 2023
3275c4d
react-native: remove duplicate field from package.json
MananTank Mar 10, 2023
88f2017
refactor exports
MananTank Mar 10, 2023
4aa1ab4
core: remove useWalletSigner()
MananTank Mar 10, 2023
a8fbe72
core: remove useActiveChainId() hook
MananTank Mar 10, 2023
1c24140
allow updating chains in connectors and wallets
MananTank Mar 10, 2023
3bb9a6c
Merge branch 'main' into connect-wallet-v2
MananTank Mar 10, 2023
6ce6e19
remove unused function
Mar 10, 2023
bce6590
Merge branch 'connect-wallet-v2' of github.com:thirdweb-dev/js into c…
Mar 10, 2023
a226acf
copied wcv1 legacyprovider code to be able to patch it to store the s…
Mar 10, 2023
e649559
set paper as dependency and fix version
Mar 10, 2023
48d404b
add wallets changeset
Mar 10, 2023
71597ea
merge main;
Mar 10, 2023
f3f1f16
fix lint
Mar 10, 2023
802306f
removeListeners to avoid multiple calls
Mar 10, 2023
ffa1d9d
minor bump to all packages involved
Mar 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
"release": "node ./scripts/pre-release.mjs && changeset publish",
"version-packages:nightly": "changeset version --snapshot nightly",
"release:nightly": "node ./scripts/pre-release.mjs && changeset publish --tag nightly",
"push": "turbo run push --filter=./packages/*"
"push": "turbo run push --filter=./packages/*",
"hotlink-init": "node ./scripts/hotlink/hotlink-init.mjs",
"hotlink-revert": "node ./scripts/hotlink/hotlink-revert.mjs",
"postinstall": "patch-package"
},
"packageManager": "[email protected]",
"dependencies": {
Expand All @@ -39,6 +42,7 @@
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
"eslint": "^8.21.0",
"mocha": "^10.2.0",
"patch-package": "^6.5.1",
"postinstall-postinstall": "^2.1.0",
"prettier": "^2.7.1",
"turbo": "^1.8.3",
Expand Down
10 changes: 5 additions & 5 deletions packages/auth/src/evm/evm.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Chain } from "@wagmi/core";

const arbitrum: Chain = {
id: 42_161,
id: 42161,
name: "Arbitrum One",
network: "arbitrum",
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
Expand Down Expand Up @@ -34,7 +34,7 @@ const arbitrum: Chain = {
};

const arbitrumGoerli: Chain = {
id: 421_613,
id: 421613,
name: "Arbitrum Goerli",
network: "arbitrum-goerli",
nativeCurrency: {
Expand Down Expand Up @@ -72,7 +72,7 @@ const arbitrumGoerli: Chain = {
};

const avalanche: Chain = {
id: 43_114,
id: 43114,
name: "Avalanche",
network: "avalanche",
nativeCurrency: {
Expand All @@ -97,7 +97,7 @@ const avalanche: Chain = {
};

const avalancheFuji: Chain = {
id: 43_113,
id: 43113,
name: "Avalanche Fuji",
network: "avalanche-fuji",
nativeCurrency: {
Expand Down Expand Up @@ -427,7 +427,7 @@ const polygon: Chain = {
};

const polygonMumbai: Chain = {
id: 80_001,
id: 80001,
name: "Polygon Mumbai",
network: "maticmum",
nativeCurrency: { name: "MATIC", symbol: "MATIC", decimals: 18 },
Expand Down
31 changes: 31 additions & 0 deletions packages/chains/chains/1967.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export default {
"name": "Eleanor",
"title": "Metatime Testnet Eleanor",
"chain": "MTC",
"rpc": [
"https://eleanor.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
"https://rpc.metatime.com/eleanor",
"wss://ws.metatime.com/eleanor"
],
"faucets": [
"https://faucet.metatime.com/eleanor"
],
"nativeCurrency": {
"name": "Eleanor Metacoin",
"symbol": "MTC",
"decimals": 18
},
"infoURL": "https://eleanor.metatime.com",
"shortName": "mtc",
"chainId": 1967,
"networkId": 1967,
"explorers": [
{
"name": "metaexplorer-eleanor",
"url": "https://explorer.metatime.com/eleanor",
"standard": "EIP3091"
}
],
"testnet": true,
"slug": "eleanor"
} as const;
8 changes: 5 additions & 3 deletions packages/react-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@
"typescript": "^4.7.4"
},
"dependencies": {
"@thirdweb-dev/chains": "*",
"@thirdweb-dev/wallets": "*",
"@tanstack/react-query": "^4.0.10",
"tiny-invariant": "^1.2.0",
"@thirdweb-dev/auth": "*"
"@thirdweb-dev/auth": "*",
"@thirdweb-dev/chains": "*",
"@wagmi/core": "^0.9.6",
"tiny-invariant": "^1.2.0"
},
"peerDependencies": {
"@solana/wallet-adapter-react": "^0.15.19",
Expand Down
2 changes: 2 additions & 0 deletions packages/react-core/src/core/constants/wc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const TW_WC_PROJECT_ID = "145769e410f16970a79ff77b2d89a1e0";
export const WC_RELAY_URL = "wss://relay.walletconnect.com";
125 changes: 125 additions & 0 deletions packages/react-core/src/core/hooks/wallet-hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { useThirdwebWallet } from "../providers/thirdweb-wallet-provider";
import invariant from "tiny-invariant";

/**
* @returns the current active wallet instance
*/
export function useActiveWallet() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's rename this to useWallet()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

const context = useThirdwebWallet();
invariant(
context,
"useActiveWallet() hook must be used within a <ThirdwebProvider/>",
);
return context.activeWallet;
}

/**
*
* @returns `supportedWallets` configured in the `<ThirdwebProvider/>`
*/
export function useWallets() {
const context = useThirdwebWallet();
invariant(
context,
"useWallets() hook must be used within a <ThirdwebProvider/>",
);
return context.wallets;
}

/**
*
* @returns a method to connect to a wallet class
*/
export function useConnect() {
const context = useThirdwebWallet();
invariant(
context,
"useConnect() hook must be used within a <ThirdwebProvider/>",
);
return context.connect;
}

/**
*
* @returns a method to disconnect from the current active wallet
*/
export function useDisconnect() {
const context = useThirdwebWallet();
invariant(
context,
"useDisconnect() hook must be used within a <ThirdwebProvider/>",
);
return context.disconnect;
}

/**
*
* @returns the connection status of the wallet
*
* It can be one of the following:
* 1. `unknown` - when wallet connection status is not yet known
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what causes unknown? just a loading state? can we make it loading in that case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status starts out with unknown - because when the app is loading, we just don't know status

Here are two possible scenarios when app is loading:

  1. if wallet was previously connected + autoconnect enabled, the status goes from unknown => connecting => connected
  2. if no wallet was connected before or autoconnect is not enabled, the status goes from unknown => disconnected

We can make it loading instead of unknown but it sounds a bit similar to connecting - it feels like we are trying to "connect" but we are not. Let me know what you think, I'm fine with either

* 2. `connecting` - when wallet is connecting
* 3. `connected` - when wallet is connected
* 4. `disconnected` - when wallet is disconnected
*
*/
export function useConnectionStatus() {
const context = useThirdwebWallet();
invariant(
context,
"useConnectionStatus() must be used within a <ThirdwebProvider/>",
);
return context.connectionStatus;
}

/**
*
* @returns a method to create an instance of given wallet class
*/
export function useCreateWalletInstance() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a public API? what is it used for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be a public API, user can use it to create a wallet instance.

This abstracts away the complexity of creating a wallet instance ( Wallet constructor takes a bunch of things as argument )

const createInstance = useCreateWalletInstance();

// when we need to create an instance, we do:
const metamask = createInstance(MetamaskWallet)

// MetamaskWallet is a class
// metamask is wallet instance

const context = useThirdwebWallet();
invariant(
context,
"useCreateWalletInstance() must be used within a <ThirdwebProvider/>",
);
return context.createWalletInstance;
}

/**
*
* @returns a method to connect the wallet to network/chain with given chainId
*/
export function useSwitchChain() {
const context = useThirdwebWallet();
invariant(
context,
"useSwitchChain() must be used within a <ThirdwebProvider/>",
);
return context.switchChain;
}

/**
*
* @returns a method to get the chainId of currently connected network/chain
*/
export function useActiveChainId() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have it available can we instead return the chain object? useActiveChain() in that case?

Copy link
Member Author

@MananTank MananTank Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have a useActiveChain hook also

we also have useChainId which works inside both ThirdwebProvider and ThirdwebSDKProvider - while useActiveChainId only works inside ThirdwebProvider - so removing it in favor of useChainId

so I'm deleting the useActiveChainId()

But we still need to keep both useActiveChain() and useChainId() because if wallet is connected to a chain that is not in the list of supportedChains - useChainId() will still return a chainId but useActiveChain() returns undefined

const context = useThirdwebWallet();
invariant(
context,
"useActiveChainId() must be used within a <ThirdwebProvider/>",
);
return context.activeChainId;
}

/**
*
* @returns the signer of the connected wallet
*/
export function useWalletSigner() {
const context = useThirdwebWallet();
invariant(
context,
"useWalletSigner() must be used within a <ThirdwebProvider/>",
);
return context.signer;
}
3 changes: 3 additions & 0 deletions packages/react-core/src/core/providers/theme-context.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { createContext } from "react";

export const ThirdwebThemeContext = createContext<"light" | "dark">("dark");
Loading