Skip to content

Commit

Permalink
feat: add Brave Wallet provider (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
josheleonard committed Aug 9, 2022
1 parent c468a10 commit 257ccba
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/use-solana/package.json
Expand Up @@ -34,6 +34,7 @@
"@saberhq/solana-contrib": "workspace:^",
"@saberhq/wallet-adapter-icons": "workspace:^",
"@solana/wallet-adapter-base": "^0.9.6",
"@solana/wallet-adapter-brave": "0.1.4",
"@solana/wallet-adapter-clover": "^0.4.5",
"@solana/wallet-adapter-coin98": "^0.5.5",
"@solana/wallet-adapter-exodus": "^0.1.1",
Expand Down
13 changes: 12 additions & 1 deletion packages/use-solana/src/providers.ts
@@ -1,4 +1,5 @@
import {
BRAVEWALLET,
CLOVER,
COIN98,
EXODUS,
Expand All @@ -14,6 +15,7 @@ import {
SOLLET,
} from "@saberhq/wallet-adapter-icons";
import type { WalletAdapterNetwork } from "@solana/wallet-adapter-base";
import { BraveWalletAdapter } from "@solana/wallet-adapter-brave";
import { CloverWalletAdapter } from "@solana/wallet-adapter-clover";
import { Coin98WalletAdapter } from "@solana/wallet-adapter-coin98";
import { ExodusWalletAdapter } from "@solana/wallet-adapter-exodus";
Expand All @@ -28,7 +30,7 @@ import {
SolletWalletAdapter,
} from "@solana/wallet-adapter-sollet";
import { SolongWalletAdapter } from "@solana/wallet-adapter-solong";
import type React from "react";
import type * as React from "react";

import type { WalletAdapterBuilder } from "./adapters";
import { LedgerWalletAdapter, SolanaWalletAdapter } from "./adapters";
Expand All @@ -37,6 +39,7 @@ import { SecretKeyAdapter } from "./adapters/secret-key";
import { SolflareAdapter } from "./adapters/solflare";

export enum DefaultWalletType {
BraveWallet = "BraveWallet",
Clover = "Clover",
Coin98 = "Coin98",
Exodus = "Exodus",
Expand Down Expand Up @@ -91,6 +94,14 @@ export const DEFAULT_WALLET_PROVIDERS: WalletProviderMap<

isInstalled: () => window.sollet !== undefined,
},
[DefaultWalletType.BraveWallet]: {
name: "Brave Wallet",
url: "https://www.brave.com/wallet",
icon: BRAVEWALLET,
makeAdapter: () => new SolanaWalletAdapter(new BraveWalletAdapter()),
isInstalled: () => window.braveSolana?.isBraveWallet === true,
isMobile: true,
},
[DefaultWalletType.Ledger]: {
name: "Ledger",
url: "https://www.ledger.com",
Expand Down
3 changes: 3 additions & 0 deletions packages/use-solana/src/typings/window.d.ts
Expand Up @@ -146,5 +146,8 @@ declare global {
huobiWallet?: {
isHuobiWallet?: boolean;
};
braveSolana?: {
isBraveWallet?: boolean;
};
}
}
74 changes: 74 additions & 0 deletions packages/wallet-adapter-icons/src/bravewallet.tsx
@@ -0,0 +1,74 @@
import * as React from "react";

export const BRAVEWALLET: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (
<svg
width="218"
height="256"
viewBox="0 0 218 300"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
{...props}
>
<defs>
<linearGradient
x1="0%"
y1="50.7055163%"
x2="100%"
y2="50.7055163%"
id="linearGradient-1"
>
<stop stopColor="#FF5500" offset="0%"></stop>
<stop stopColor="#FF5500" offset="40.9877232%"></stop>
<stop stopColor="#FF2000" offset="58.1981215%"></stop>
<stop stopColor="#FF2000" offset="100%"></stop>
</linearGradient>
<linearGradient
x1="2.1484375%"
y1="50.7055163%"
x2="100%"
y2="50.7055163%"
id="linearGradient-2"
>
<stop stopColor="#FF452A" offset="0%"></stop>
<stop stopColor="#FF2000" offset="100%"></stop>
</linearGradient>
<path
d="M170.272109,25.3359387 L147.968109,0.00010893617 L108.800109,0.00010893617 L69.6321088,0.00010893617 L47.3281088,25.3359387 C47.3281088,25.3359387 27.7441088,19.8891302 18.4961088,29.1487047 C18.4961088,29.1487047 44.6081088,26.7886026 53.5841088,41.4040238 C53.5841088,41.4040238 77.7921088,46.0338111 81.0561088,46.0338111 C84.3201088,46.0338111 91.3921088,43.3104068 97.9201088,41.1316834 C104.448109,38.95296 108.800109,38.9371643 108.800109,38.9371643 C108.800109,38.9371643 113.152109,38.95296 119.680109,41.1316834 C126.208109,43.3104068 133.280109,46.0338111 136.544109,46.0338111 C139.808109,46.0338111 164.016109,41.4040238 164.016109,41.4040238 C172.992109,26.7886026 199.104109,29.1487047 199.104109,29.1487047 C189.856109,19.8891302 170.272109,25.3359387 170.272109,25.3359387"
id="path-3"
></path>
</defs>
<g
id="starting-collection"
stroke="none"
strokeWidth="1"
fill="none"
fillRule="evenodd"
>
<g id="Build-Icons" transform="translate(-70.000000, -350.000000)">
<g id="build-icons/Stable" transform="translate(50.000000, 350.000000)">
<g id="Logo" transform="translate(20.114286, 0.000000)">
<path
d="M209.984109,61.2848749 L215.968109,46.5784919 C215.968109,46.5784919 208.352109,38.4082791 199.104109,29.1487047 C189.856109,19.8891302 170.272109,25.3359387 170.272109,25.3359387 L147.968109,0.00010893617 L108.800109,0.00010893617 L69.6321088,0.00010893617 L47.3281088,25.3359387 C47.3281088,25.3359387 27.7441088,19.8891302 18.4961088,29.1487047 C9.2481088,38.4082791 1.6321088,46.5784919 1.6321088,46.5784919 L7.6161088,61.2848749 L0.0001088,83.0721089 C0.0001088,83.0721089 22.3993088,168.017811 25.0241088,178.391258 C30.1921088,198.81679 33.7281088,206.714662 48.4161088,217.063598 C63.1041088,227.412534 89.7601088,245.387003 94.1121088,248.110407 C98.4641088,250.833811 103.904109,255.472858 108.800109,255.472858 C113.696109,255.472858 119.136109,250.833811 123.488109,248.110407 C127.840109,245.387003 154.496109,227.412534 169.184109,217.063598 C183.872109,206.714662 187.408109,198.81679 192.576109,178.391258 C195.200365,168.017811 217.600109,83.0721089 217.600109,83.0721089 L209.984109,61.2848749 Z"
id="Head"
fill="url(#linearGradient-1)"
></path>
<path
d="M164.016109,41.4040238 C164.016109,41.4040238 192.704493,76.1274281 192.704493,83.5487047 C192.704493,90.9699813 189.095597,92.9286536 185.467117,96.7866281 C181.838637,100.644603 165.991373,117.49376 163.956269,119.657232 C161.921165,121.821249 157.684493,125.101862 160.176557,131.006747 C162.668621,136.911632 166.344973,144.425505 162.256813,152.046679 C158.168109,159.667854 151.164109,164.754628 146.676109,163.913641 C142.188109,163.072109 131.648109,157.557215 127.772109,155.038066 C123.896109,152.518917 111.611501,142.374781 111.611501,138.493386 C111.611501,134.612534 124.310093,127.643888 126.655821,126.0605 C129.002637,124.477658 139.703117,118.349454 139.922349,115.944143 C140.141037,113.538288 140.057805,112.832926 136.899885,106.889369 C133.741965,100.945266 128.054989,93.0136238 129.001549,87.7362111 C129.948109,82.459343 139.119949,79.7152409 145.665357,77.2402111 C152.209677,74.765726 164.811437,70.0918196 166.385229,69.3652153 C167.960109,68.6380664 167.553197,67.945777 162.783949,67.4931472 C158.015789,67.0405174 144.483245,65.2419813 138.382285,66.9446536 C132.281325,68.647326 121.858285,71.2378281 121.013997,72.6115132 C120.169709,73.9851983 119.424973,74.0314962 120.292109,78.7702196 C121.158701,83.508943 125.622765,106.24719 126.055789,110.285998 C126.489357,114.324807 127.336909,116.994832 122.987629,117.990509 C118.637805,118.986186 111.316109,120.715003 108.800109,120.715003 C106.284109,120.715003 98.9618688,118.986186 94.6125888,117.990509 C90.2627648,116.994832 91.1103168,114.324807 91.5438848,110.285998 C91.9774528,106.24719 96.4409728,83.508943 97.3081088,78.7702196 C98.1747008,74.0314962 97.4299648,73.9851983 96.5862208,72.6115132 C95.7419328,71.2378281 85.3183488,68.647326 79.2173888,66.9446536 C73.1164288,65.2419813 59.5844288,67.0405174 54.8157248,67.4931472 C50.0470208,67.945777 49.6401088,68.6380664 51.2144448,69.3652153 C52.7887808,70.0918196 65.3905408,74.765726 71.9348608,77.2402111 C78.4797248,79.7152409 87.6521088,82.459343 88.5986688,87.7362111 C89.5452288,93.0136238 83.8577088,100.945266 80.7003328,106.889369 C77.5424128,112.832926 77.4586368,113.538288 77.6778688,115.944143 C77.8965568,118.349454 88.5975808,124.477658 90.9438528,126.0605 C93.2901248,127.643888 105.988173,134.612534 105.988173,138.493386 C105.988173,142.374781 93.7041088,152.518917 89.8281088,155.038066 C85.9521088,157.557215 75.4121088,163.072109 70.9241088,163.913641 C66.4361088,164.754628 59.4321088,159.667854 55.3434048,152.046679 C51.2552448,144.425505 54.9315968,136.911632 57.4231168,131.006747 C59.9151808,125.101862 55.6790528,121.821249 53.6434048,119.657232 C51.6088448,117.49376 35.7610368,100.644603 32.1325568,96.7866281 C28.5040768,92.9286536 24.8957248,90.9699813 24.8957248,83.5487047 C24.8957248,76.1274281 53.5841088,41.4040238 53.5841088,41.4040238 C53.5841088,41.4040238 77.7921088,46.0338111 81.0561088,46.0338111 C84.3201088,46.0338111 91.3921088,43.3104068 97.9201088,41.1316834 C104.448109,38.95296 108.800109,38.9371643 108.800109,38.9371643 C108.800109,38.9371643 113.152109,38.95296 119.680109,41.1316834 C126.208109,43.3104068 133.280109,46.0338111 136.544109,46.0338111 C139.808109,46.0338111 164.016109,41.4040238 164.016109,41.4040238 Z M142.509504,174.227935 C144.28512,175.341263 143.202016,177.439918 141.584704,178.584837 C139.966848,179.729757 118.228064,196.584361 116.118432,198.447169 C114.008256,200.310523 110.908,203.387425 108.8,203.387425 C106.692,203.387425 103.5912,200.310523 101.481568,198.447169 C99.371392,196.584361 77.633152,179.729757 76.015296,178.584837 C74.39744,177.439918 73.31488,175.341263 75.090496,174.227935 C76.866656,173.115152 82.422528,170.306233 90.08912,166.333876 C97.754624,162.362063 107.308896,158.985042 108.8,158.985042 C110.291104,158.985042 119.844832,162.362063 127.511424,166.333876 C135.177472,170.306233 140.733344,173.115152 142.509504,174.227935 Z"
id="Face"
fill="#FFFFFF"
></path>
<mask id="mask-4" fill="white">
<use xlinkHref="#path-3"></use>
</mask>
<use
id="Top-Head"
fill="url(#linearGradient-2)"
xlinkHref="#path-3"
></use>
</g>
</g>
</g>
</g>
</svg>
);
1 change: 1 addition & 0 deletions packages/wallet-adapter-icons/src/index.tsx
Expand Up @@ -5,6 +5,7 @@

import React from "react";

export * from "./bravewallet.js";
export * from "./coin98.js";
export * from "./mathwallet.js";

Expand Down
23 changes: 23 additions & 0 deletions yarn.lock
Expand Up @@ -2477,6 +2477,7 @@ __metadata:
"@saberhq/tsconfig": ^1.13.32
"@saberhq/wallet-adapter-icons": "workspace:^"
"@solana/wallet-adapter-base": ^0.9.6
"@solana/wallet-adapter-brave": 0.1.4
"@solana/wallet-adapter-clover": ^0.4.5
"@solana/wallet-adapter-coin98": ^0.5.5
"@solana/wallet-adapter-exodus": ^0.1.1
Expand Down Expand Up @@ -2634,6 +2635,28 @@ __metadata:
languageName: node
linkType: hard

"@solana/wallet-adapter-base@npm:^0.9.9":
version: 0.9.9
resolution: "@solana/wallet-adapter-base@npm:0.9.9"
dependencies:
eventemitter3: ^4.0.0
peerDependencies:
"@solana/web3.js": ^1.44.3
checksum: 3e69b0bf7e5dbc2447db65096904e1d5f7f8ba2ef3eca1b5018f6c7b48c744229870f0bb2096249078ee33a3de63c575e665502bb09e532221dbd732fa095654
languageName: node
linkType: hard

"@solana/wallet-adapter-brave@npm:0.1.4":
version: 0.1.4
resolution: "@solana/wallet-adapter-brave@npm:0.1.4"
dependencies:
"@solana/wallet-adapter-base": ^0.9.9
peerDependencies:
"@solana/web3.js": ^1.36.0
checksum: d8b8fcf8b8ecbb4e100c8f7af97392bdb9e0fbcf4a720fb7f1743e5b89c5088b99af6db8a59dfdcda0024f6791509361e0e3259aecfc6d8dbf13a6d0dd32c845
languageName: node
linkType: hard

"@solana/wallet-adapter-clover@npm:^0.4.5":
version: 0.4.5
resolution: "@solana/wallet-adapter-clover@npm:0.4.5"
Expand Down

0 comments on commit 257ccba

Please sign in to comment.