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/integrate btc wallet #26

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion apps/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
"fmt": "prettier --write '**/*.{tsx,ts,json,css,scss,md}'"
},
"dependencies": {
"@oranjlabs/strike": "*",
"@dfinity/agent": "^1.3",
"@dfinity/auth-client": "^1.3",
"@dfinity/candid": "^1.3",
"@dfinity/identity": "^1.3",
"@dfinity/principal": "^1.3",
"@oranjlabs/strike": "*",
"@xstate/react": "^5.0.1",
"next": "^14.2.7",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
Binary file added apps/site/public/wallet/okx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/site/public/wallet/orange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/site/public/wallet/unisat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/site/public/wallet/wizz-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/site/public/wallet/wizz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/site/public/wallet/xverse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions apps/site/public/wallet/xverse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 48 additions & 1 deletion apps/site/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,58 @@
// Test Case
export const host =
process.env.NEXT_PUBLIC_DFX_NETWORK === 'ic'
? 'https://icp0.io'
: 'http://127.0.0.1:4943';
: 'https://icp0.io';

export const provider =
process.env.NEXT_PUBLIC_DFX_NETWORK === 'ic'
? 'https://identity.ic0.app'
: 'http://rdmx6-jaaaa-aaaaa-aaadq-cai.localhost:4943';

export const ICP_BLINK_PREFIX = /^(icp-action:|icp:)/;

export interface Wallet {
id: string;
name: string;
lightLogo: string;
darkLogo: string;
link: string;
}

export const btcWallets: Wallet[] = [
{
id: 'XverseProviders.BitcoinProvider',
name: 'Xverse',
lightLogo: '/wallet/xverse.svg',
darkLogo: '/wallet/xverse.svg',
link: 'https://chromewebstore.google.com/detail/xverse-wallet/idnnbdplmphpflfnlkomgpfbpcgelopg?hl=en',
},
{
id: 'unisat',
name: 'Unisat',
lightLogo: '/wallet/unisat.png',
darkLogo: '/wallet/unisat.png',
link: 'https://chromewebstore.google.com/detail/unisat-wallet/ppbibelpcjmhbdihakflkdcoccbgbkpo?hl=en',
},
{
id: 'wizz',
name: 'Wizz',
lightLogo: '/wallet/wizz-black.png',
darkLogo: '/wallet/wizz-black.png',
link: 'https://chromewebstore.google.com/detail/wizz-wallet/ghlmndacnhlaekppcllcpcjjjomjkjpg?hl=en',
},
{
id: 'okxwallet.bitcoin',
name: 'OKX',
lightLogo: '/wallet/okx.png',
darkLogo: '/wallet/okx.png',
link: 'https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge?hl=en',
},
{
id: 'OrangecryptoProviders.BitcoinProvider',
name: 'Orange',
lightLogo: '/wallet/orange.png',
darkLogo: '/wallet/orange.png',
link: 'https://chromewebstore.google.com/detail/glmhbknppefdmpemdmjnjlinpbclokhn',
},
];
56 changes: 44 additions & 12 deletions apps/site/src/provider/ConnectProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,59 @@
'use client';

import { Connect2ICProvider } from '@oranjlabs/icp-wallet-adapter-react';
import { createClient, InternetIdentity } from '@oranjlabs/icp-wallet-adapter';
import {
createClient,
BTCWalletConnector,
InternetIdentity,
} from '@oranjlabs/icp-wallet-adapter';
import '@oranjlabs/strike/index.css';
import '@oranjlabs/icp-wallet-adapter-react/index.css';

import { host, provider } from '../config';
import {
siwbMachine,
createActor as createSIWBActor,
} from '@oranjbase/ic-siwb-js';
import { useMachine } from '@xstate/react';
import { host, provider, btcWallets } from '../config';

const isServer = typeof window === 'undefined';
const config = { host, providerUrl: provider };

const providers = isServer ? [] : [new InternetIdentity(config)];

const client = createClient({
providers,
globalProviderConfig: {
host,
},
const actor = createSIWBActor('aw5qc-miaaa-aaaak-amupq-cai', {
agentOptions: { host },
});

export default function ConnectProvider({
children,
}: {
children: React.ReactNode;
}) {
const [snapshot, send, actorRef] = useMachine(siwbMachine, {
input: { anonymousActor: actor },
inspect: (e) => console.debug(e),
});

const config = {
host,
providerUrl: provider,
send,
siwbActorRef: actorRef,
};

const providers = isServer
? []
: [
new InternetIdentity(config),
new BTCWalletConnector({ ...config, btcWallet: btcWallets[0] }),
new BTCWalletConnector({ ...config, btcWallet: btcWallets[1] }),
new BTCWalletConnector({ ...config, btcWallet: btcWallets[2] }),
new BTCWalletConnector({ ...config, btcWallet: btcWallets[3] }),
new BTCWalletConnector({ ...config, btcWallet: btcWallets[4] }),
];

const client = createClient({
providers,
globalProviderConfig: {
host,
},
});

return <Connect2ICProvider client={client}>{children}</Connect2ICProvider>;
}
33 changes: 25 additions & 8 deletions apps/site/src/views/home/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,32 @@ export default function Header() {
STRIKE
</span>
</a>
<div className="sm:flex hidden flex-row gap-[8px] font-medium items-center text-[14px] leading-[24px]">
<ExtensionIcon width={20} height={20} />
<a
href="https://chromewebstore.google.com/detail/strike-by-oranj/iomlailejogiahpdlmckpjdkipgpfccm "
target="_blank"
>
Get Chrome Extension
</a>
<div className="sm:flex hidden flex flex-row gap-[16px]">
<div className="flex flex-row gap-[8px] font-medium items-center text-[14px] leading-[24px]">
<ExtensionIcon width={20} height={20} />
<a
href="https://chromewebstore.google.com/detail/strike-by-oranj/iomlailejogiahpdlmckpjdkipgpfccm "
target="_blank"
>
Get Chrome Extension
</a>
</div>
<ConnectButton
style={{
borderRadius: 12,
padding: `8px 12px`,
borderColor: '#2B5ACC',
backgroundColor: '#3670FF',
fontWeight: 600,
fontSize: 14,
borderWidth: 1,
borderStyle: 'solid',
display: 'flex',
justifyContent: 'center',
}}
/>
</div>

{menuVisible ? (
<CrossIcon
width={24}
Expand Down
Loading
Loading