Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
24ebb79
allow wallet config, fix gnosis safe
MananTank Mar 27, 2023
d343958
remove console log
MananTank Mar 27, 2023
20a4bf9
Fix icon size issue with reset css
MananTank Mar 27, 2023
89a0743
export wallet classes
MananTank Mar 27, 2023
6d5138a
allow getting email from paper wallet
MananTank Mar 27, 2023
1f203c7
remove unnecessary try-catch
MananTank Mar 27, 2023
45a84be
remove unnecessary comments
MananTank Mar 27, 2023
9fe0630
Merge branch 'main' into allow-wallet-config
MananTank Mar 27, 2023
555d23f
Merge branch 'main' into allow-wallet-config
MananTank Mar 27, 2023
10bd90b
add changeset
MananTank Mar 27, 2023
8271dd3
merge
Mar 27, 2023
92d26a9
merge
Mar 27, 2023
c76fd4f
Merge branch 'main' into allow-wallet-config
iketw Mar 27, 2023
4653b96
Merge branch 'main' into allow-wallet-config
Mar 27, 2023
bd07a54
Merge branch 'allow-wallet-config' of github.com:thirdweb-dev/js into…
Mar 27, 2023
646dc4a
react-native fixes
Mar 27, 2023
2c05798
Merge branch 'main' into allow-wallet-config
Mar 27, 2023
89629b4
descriptive console.error
Mar 27, 2023
b245c50
fix bug in wcv2, optionalChains are not optional
Mar 28, 2023
b37c673
[RN] coinbase-wallet allow passing callbackURL
Mar 28, 2023
74f8928
Remove duplicate prop
MananTank Mar 28, 2023
063cd33
use react-query in usePaperWalletUserEmail()
MananTank Mar 28, 2023
337e678
Merge branch 'main' into allow-wallet-config
MananTank Mar 28, 2023
2f9750e
Update Paper SDK version
MananTank Mar 28, 2023
66bd21c
wallets: fix build error after updating paper sdk version
MananTank Mar 28, 2023
10366f5
auth: export PrivateKeyWallet
MananTank Mar 28, 2023
53d6247
- [RN] add listener for coinbase wallet
Mar 29, 2023
2f4e1e5
changeset
Mar 29, 2023
44b6282
Merge branch 'main' into allow-wallet-config
Mar 29, 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
Prev Previous commit
Next Next commit
react-native fixes
  • Loading branch information
ikethirdweb committed Mar 27, 2023
commit 646dc4a8ec0778d0c2b809acd380de2836f14d46
4 changes: 2 additions & 2 deletions packages/react-core/src/core/types/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export type WalletOptions = {

export type WalletInstance = InstanceType<typeof AbstractBrowserWallet>;

export type WalletClass<INS extends WalletInstance = WalletInstance> = {
export type WalletClass<I extends WalletInstance = WalletInstance> = {
id: string;
new (options: WalletOptions): INS;
new (options: WalletOptions): I;
meta: (typeof AbstractBrowserWallet)["meta"];
};

Expand Down
1 change: 1 addition & 0 deletions packages/react-native/src/evm/components/Web3Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export const Web3Button = <TAction extends ActionFn>({
content = "Switch Network";
} else if (
actionMutation.isLoading ||
!contract ||
connectionStatus === "connecting" ||
connectionStatus === "unknown"
) {
Expand Down
10 changes: 4 additions & 6 deletions packages/react-native/src/evm/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
export { CoinbaseWallet } from "./wallets/wallets/coinbase-wallet";
export {
MetaMaskWallet,
RainbowWallet,
TrustWallet,
} from "./wallets/wallets/all";
export { CoinbaseWallet, coinbaseWallet } from "./wallets/wallets/coinbase-wallet";
export { MetaMaskWallet, metamaskWallet } from "./wallets/wallets/metamask-wallet";
export { RainbowWallet, rainbowWallet } from "./wallets/wallets/rainbow-wallet";
export { TrustWallet, trustWallet } from "./wallets/wallets/trust-wallet";

export { ConnectWallet } from "./components/ConnectWallet";
export { Web3Button } from "./components/Web3Button";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@thirdweb-dev/react-core";
import { PropsWithChildren } from "react";
import type { Chain, defaultChains } from "@thirdweb-dev/chains";
import { metamaskWallet } from "../wallets/wallets/all";
import { metamaskWallet } from "../wallets/wallets/metamask-wallet";

const DEFAULT_WALLETS = [metamaskWallet(), coinbaseWallet()];

Expand Down
190 changes: 0 additions & 190 deletions packages/react-native/src/evm/wallets/wallets/all.ts

This file was deleted.

67 changes: 67 additions & 0 deletions packages/react-native/src/evm/wallets/wallets/metamask-wallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { WalletOptions, WalletConnectV1Options, WalletConnectV1 } from "@thirdweb-dev/wallets";
import { formatDisplayUri } from "../../utils/uri";
import { Linking } from "react-native";
import {
WalletOptions as WalletOptionsRC,
Wallet,
ExtraCoreWalletOptions
} from "@thirdweb-dev/react-core";
import { createAsyncLocalStorage } from "../../../core/AsyncStorage";

type WC1Options = Omit<
WalletOptions<WalletConnectV1Options>,
"qrcode" | "walletStorage"
> &
ExtraCoreWalletOptions;

export class MetaMaskWallet extends WalletConnectV1 {
static id = "metamask" as const;
static meta = {
id: "metamask",
name: "MetaMask",
iconURL:
"https://registry.walletconnect.org/v2/logo/md/5195e9db-94d8-4579-6f11-ef553be95100",
links: {
native: "metamask:",
universal: "https://metamask.app.link",
},
};

constructor(options: WC1Options) {
const storage = createAsyncLocalStorage("metamask");
super({
...options,
walletId: "metamask",
walletStorage: storage,
qrcode: false,
});

this.on("open_wallet", this._onWCOpenWallet);

this.on("disconnect", () => {
this.removeListener("open_wallet", this._onWCOpenWallet);
});
}

_onWCOpenWallet(uri?: string) {
const links = MetaMaskWallet.meta.links;

if (uri) {
const fullUrl = formatDisplayUri(uri, links);

Linking.openURL(fullUrl);
} else {
const fullUrl = formatDisplayUri("", links);

Linking.openURL(fullUrl);
}
}
}

export const metamaskWallet = () => {
return {
id: MetaMaskWallet.id,
meta: MetaMaskWallet.meta,
create: (options: WalletOptionsRC) => new MetaMaskWallet(options),
} satisfies Wallet;
};
66 changes: 66 additions & 0 deletions packages/react-native/src/evm/wallets/wallets/rainbow-wallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { WalletOptions, WalletConnectV1Options, WalletConnectV1 } from "@thirdweb-dev/wallets";
import { formatDisplayUri } from "../../utils/uri";
import { Linking } from "react-native";
import {
WalletOptions as WalletOptionsRC,
Wallet,
ExtraCoreWalletOptions
} from "@thirdweb-dev/react-core";
import { createAsyncLocalStorage } from "../../../core/AsyncStorage";

type WC1Options = Omit<
WalletOptions<WalletConnectV1Options>,
"qrcode" | "walletStorage"
> &
ExtraCoreWalletOptions;

export class RainbowWallet extends WalletConnectV1 {
static id = "rainbow" as const;
static meta = {
id: "rainbow",
name: "Rainbow",
iconURL:
"https://registry.walletconnect.org/v2/logo/md/7a33d7f1-3d12-4b5c-f3ee-5cd83cb1b500",
links: {
native: "rainbow:",
universal: "https://rnbwapp.com",
},
};

constructor(options: WC1Options) {
const storage = createAsyncLocalStorage("rainbow");
super({
...options,
walletId: "rainbow",
walletStorage: storage,
qrcode: false,
});
this.on("open_wallet", this._onWCOpenWallet);

this.on("disconnect", () => {
this.removeListener("open_wallet", this._onWCOpenWallet);
});
}

_onWCOpenWallet(uri?: string) {
const links = RainbowWallet.meta.links;

if (uri) {
const fullUrl = formatDisplayUri(uri, links);

Linking.openURL(fullUrl);
} else {
const fullUrl = formatDisplayUri("", links);

Linking.openURL(fullUrl);
}
}
}

export const rainbowWallet = () => {
return {
id: RainbowWallet.id,
meta: RainbowWallet.meta,
create: (options: WalletOptionsRC) => new RainbowWallet(options),
} satisfies Wallet;
};
Loading