Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Nightly Wallet support #659

Merged
merged 15 commits into from Aug 10, 2022
1 change: 1 addition & 0 deletions .size-limit.json
Expand Up @@ -30,6 +30,7 @@
"bn.js",
"@ledgerhq/hw-transport",
"@ledgerhq/hw-transport-webusb",
"@nightlylabs/wallet-solana-adapter",
"@solana/wallet-adapter-base",
"@solana/wallet-adapter-clover",
"@solana/wallet-adapter-coin98",
Expand Down
1 change: 1 addition & 0 deletions packages/use-solana/package.json
Expand Up @@ -31,6 +31,7 @@
"dependencies": {
"@ledgerhq/hw-transport": "^6.27.1",
"@ledgerhq/hw-transport-webusb": "^6.27.1",
"@nightlylabs/wallet-solana-adapter": "^0.0.4",
"@saberhq/solana-contrib": "workspace:^",
"@saberhq/wallet-adapter-icons": "workspace:^",
"@solana/wallet-adapter-base": "^0.9.6",
Expand Down
10 changes: 10 additions & 0 deletions packages/use-solana/src/providers.ts
@@ -1,3 +1,4 @@
import { NightlyWalletAdapter } from "@nightlylabs/wallet-solana-adapter";
import {
BRAVEWALLET,
CLOVER,
Expand All @@ -9,6 +10,7 @@ import {
LEDGER,
MAGNIFYING_GLASS,
MATHWALLET,
NIGHTLY,
PHANTOM,
SLOPE,
SOLFLARE,
Expand Down Expand Up @@ -47,6 +49,7 @@ export enum DefaultWalletType {
Huobi = "Huobi",
Ledger = "Ledger",
MathWallet = "MathWallet",
Nightly = "Nightly",
Phantom = "Phantom",
ReadOnly = "ReadOnly",
SecretKey = "SecretKey",
Expand Down Expand Up @@ -216,6 +219,13 @@ export const DEFAULT_WALLET_PROVIDERS: WalletProviderMap<
isInstalled: () =>
!!process.env.LOCAL_PUBKEY || !!process.env.REACT_APP_LOCAL_PUBKEY,
},
[DefaultWalletType.Nightly]: {
name: "Nightly",
url: "https://nightly.app",
icon: NIGHTLY,
makeAdapter: () => new SolanaWalletAdapter(new NightlyWalletAdapter()),
isInstalled: () => typeof window?.nightly?.solana !== "undefined",
},
};

export interface WalletProviderInfo {
Expand Down
12 changes: 12 additions & 0 deletions packages/use-solana/src/typings/window.d.ts
Expand Up @@ -74,6 +74,15 @@ export interface MathWalletProvider {
isMathWallet: true;
isPhantom: undefined;
}

export interface NightlyProvider {
publicKey: PublicKey;
connect(onDisconnect?: () => void): Promise<PublicKey>;
disconnect(): Promise<void>;
signTransaction(tx: Transaction): Promise<Transaction>;
signAllTransactions(txs: Transaction[]): Promise<Transaction[]>;
}

declare global {
interface Window {
solana?:
Expand Down Expand Up @@ -146,6 +155,9 @@ declare global {
huobiWallet?: {
isHuobiWallet?: boolean;
};
nightly?: {
solana?: NightlyProvider
};
braveSolana?: {
isBraveWallet?: boolean;
};
Expand Down
40 changes: 40 additions & 0 deletions packages/wallet-adapter-icons/src/index.tsx
Expand Up @@ -377,3 +377,43 @@ export const HUOBI: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (
</defs>
</svg>
);

export const NIGHTLY: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (
<svg
width="96"
height="96"
viewBox="0 0 96 96"
fill="none"
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<path
d="M48 96C74.5097 96 96 74.5097 96 48C96 21.4903 74.5097 0 48 0C21.4903 0 0 21.4903 0 48C0 74.5097 21.4903 96 48 96Z"
fill="#6D73F8"
/>
<path
d="M48 85.6356C48 85.6356 52.4533 85.6356 55.44 82.5867C58.9155 79.2801 57.3511 75.4312 62.2755 71.4312C66.9866 67.6445 72.9244 70.3379 72.9244 70.3379C77.0222 62.1245 74.7911 52.569 74.7911 52.569C81.7688 34.2579 75.9644 21.1557 74.4444 17.3601C69.4488 24.3379 63.1911 29.1734 55.7955 32.409C53.2266 31.7068 50.5955 31.3334 48 31.3601C45.4133 31.3334 42.7733 31.7068 40.2044 32.409C32.8177 29.1645 26.5511 24.3379 21.5555 17.3601C20.0355 21.1557 14.2311 34.2579 21.2089 52.569C21.2089 52.569 18.9778 62.1245 23.0755 70.3379C23.0755 70.3379 29.0133 67.6445 33.7244 71.4312C38.6577 75.4312 37.0844 79.2801 40.56 82.5867C43.5466 85.6356 48 85.6356 48 85.6356Z"
fill="white"
/>
<path
d="M42.4799 65.298C42.2933 59.218 36.3021 57.2624 32.2133 59.8224C32.2133 59.8224 32.8533 62.4358 35.8399 63.7513C38.2755 64.8269 39.3244 63.3869 42.4799 65.298Z"
fill="#7B81F9"
/>
<path
d="M22.4977 23.0935C20.0888 31.5468 21.1288 42.2402 24.9333 50.0269C28.8266 47.2713 32.9155 43.0135 35.0933 38.5069C29.9644 34.7113 25.6622 31.1024 22.4977 23.0935Z"
fill="#7B81F9"
/>
<path
d="M53.5199 65.298C53.7066 59.218 59.6977 57.2624 63.7866 59.8224C63.7866 59.8224 63.1466 62.4358 60.1599 63.7513C57.7243 64.8269 56.6755 63.3869 53.5199 65.298Z"
fill="#7B81F9"
/>
<path
d="M73.5022 23.0935C75.9111 31.5468 74.8711 42.2402 71.0666 50.0269C67.1733 47.2713 63.0844 43.0135 60.9066 38.5069C66.0355 34.7113 70.3377 31.1024 73.5022 23.0935Z"
fill="#7B81F9"
/>
<path
d="M47.9999 85.3069C50.1404 85.3069 51.8755 83.7787 51.8755 81.8936C51.8755 80.0084 50.1404 78.4802 47.9999 78.4802C45.8595 78.4802 44.1244 80.0084 44.1244 81.8936C44.1244 83.7787 45.8595 85.3069 47.9999 85.3069Z"
fill="#7B81F9"
/>
</svg>
);