From 6419dc0464e3c495162ca256a1406981e8a07818 Mon Sep 17 00:00:00 2001 From: "Justin (HoangVD2)" Date: Wed, 13 Mar 2024 09:00:49 +0700 Subject: [PATCH 1/3] revert: solana adapt --- .../solana-adapter-xdefi-integration.md | 343 ------------------ 1 file changed, 343 deletions(-) diff --git a/developers/solana-adapter-xdefi-integration.md b/developers/solana-adapter-xdefi-integration.md index 52acccd48..a8056ffd3 100644 --- a/developers/solana-adapter-xdefi-integration.md +++ b/developers/solana-adapter-xdefi-integration.md @@ -1,344 +1 @@ # Solana Adapter XDEFI Integration - -First, your app need to install dependencies for Solana Adapter and XDEFI. These imports include event emitters, error types, transaction-related types, and the PublicKey class. - -- `@solana/wallet-adapter-base` -- `@solana/web3.js` - -Then import dependencies and declare the `XDEFIWallet` and `XDEFIWalletWindow` interfaces: - -```typescript -import type { EventEmitter, WalletName } from "@solana/wallet-adapter-base"; -import { - BaseMessageSignerWalletAdapter, - scopePollingDetectionStrategy, - WalletAccountError, - WalletConnectionError, - WalletDisconnectedError, - WalletDisconnectionError, - WalletNotConnectedError, - WalletNotReadyError, - WalletPublicKeyError, - WalletReadyState, - WalletSignMessageError, - WalletSignTransactionError, -} from "@solana/wallet-adapter-base"; -import type { - SendOptions, - Transaction, - TransactionSignature, -} from "@solana/web3.js"; -import { PublicKey } from "@solana/web3.js"; - -interface XDEFIWalletEvents { - connect(...args: unknown[]): unknown; - disconnect(...args: unknown[]): unknown; -} - -interface XDEFIWallet extends EventEmitter { - isXDEFI?: boolean; - publicKey?: { toBytes(): Uint8Array }; - isConnected: boolean; - signTransaction(transaction: Transaction): Promise; - signAllTransactions(transactions: Transaction[]): Promise; - signAndSendTransaction( - transaction: Transaction, - options?: SendOptions, - ): Promise<{ signature: TransactionSignature }>; - signMessage(message: Uint8Array): Promise<{ signature: Uint8Array }>; - connect(): Promise; - disconnect(): Promise; -} - -interface XDEFIWalletWindow extends Window { - xfi?: { - solana?: XDEFIWallet; - }; -} -``` - -Next, constructor a new class that extends `BaseMessageSignerWalletAdapter` and implements the `XDEFIWallet` interface: - -```typescript -declare const window: XDEFIWalletWindow; - -export interface XDEFIWalletAdapterConfig {} - -export const XDEFIWalletName = "XDEFI" as WalletName<"XDEFI">; - -export class XDEFIWalletAdapter extends BaseMessageSignerWalletAdapter { - name = XDEFIWalletName; - url = "https://xdefi.io"; - icon = - "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE0LjI2MjggMTMuNDAxM0MxMi40MjI4IDE0LjUzMDcgOS45NTk5NyAxNS4xMTI0IDcuNDY1NjkgMTQuOTg4MUM1LjM2ODU1IDE0Ljg4NjUgMy42NDg1NSAxNC4xNDExIDIuNjA4NTUgMTIuOTE1N0MxLjY5NDI2IDExLjgyMDEgMS4zMzk5OCAxMC4zNzQ1IDEuNTc5OTggOC43MTE0M0MxLjY2MTMyIDguMTU4NzQgMS44MjgwMiA3LjYyMTY2IDIuMDc0MjYgNy4xMTg5NkwyLjEwODU1IDcuMDQ4MzdDMi45NzE4IDUuNDA1OTUgNC4yNTI5MyA0LjAxMzk3IDUuODI1ODQgMy4wMDk0MkM3LjM5ODc1IDIuMDA0ODYgOS4yMDkyNCAxLjQyMjM2IDExLjA3OTEgMS4zMTkyNEMxMi45NDkgMS4yMTYxMSAxNC44MTM4IDEuNTk1OTIgMTYuNDkwMSAyLjQyMTI4QzE4LjE2NjMgMy4yNDY2NSAxOS41OTYyIDQuNDg5MTIgMjAuNjM5IDYuMDI2NDFDMjEuNjgxOSA3LjU2MzcxIDIyLjMwMTcgOS4zNDI4NSAyMi40Mzc0IDExLjE4ODdDMjIuNTczMiAxMy4wMzQ2IDIyLjIyMDMgMTQuODgzNiAyMS40MTM0IDE2LjU1MzhDMjAuNjA2NSAxOC4yMjQgMTkuMzcz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allet: XDEFIWallet | null; - private _publicKey: PublicKey | null; - private _readyState: WalletReadyState = - typeof window === "undefined" || typeof document === "undefined" - ? WalletReadyState.Unsupported - : WalletReadyState.NotDetected; - - constructor(config: XDEFIWalletAdapterConfig = {}) { - super(); - this._connecting = false; - this._wallet = null; - this._publicKey = null; - - if (this._readyState !== WalletReadyState.Unsupported) { - scopePollingDetectionStrategy(() => { - if (window.xfi?.solana?.isXDEFI) { - this._readyState = WalletReadyState.Installed; - this.emit("readyStateChange", this._readyState); - return true; - } - return false; - }); - } - } - // Define the `connect`, `disconnect`, `signTransaction`, `signAllTransactions`, `signAndSendTransaction`, and `signMessage` methods like other wallet adapters. -} -``` - -Be sure to handle the `connect` and `disconnect` methods to update the `publicKey` and `isConnected` properties of the wallet adapter. - -### Example - -Here is an example of a Solana Adapter for XDEFI integration: - -```typescript -import type { EventEmitter, WalletName } from "@solana/wallet-adapter-base"; -import { - BaseMessageSignerWalletAdapter, - scopePollingDetectionStrategy, - WalletAccountError, - WalletConnectionError, - WalletDisconnectedError, - WalletDisconnectionError, - WalletNotConnectedError, - WalletNotReadyError, - WalletPublicKeyError, - WalletReadyState, - WalletSignMessageError, - WalletSignTransactionError, -} from "@solana/wallet-adapter-base"; -import type { - SendOptions, - Transaction, - TransactionSignature, -} from "@solana/web3.js"; -import { PublicKey } from "@solana/web3.js"; - -interface XDEFIWalletEvents { - connect(...args: unknown[]): unknown; - disconnect(...args: unknown[]): unknown; -} - -interface XDEFIWallet extends EventEmitter { - isXDEFI?: boolean; - publicKey?: { toBytes(): Uint8Array }; - isConnected: boolean; - signTransaction(transaction: Transaction): Promise; - signAllTransactions(transactions: Transaction[]): Promise; - signAndSendTransaction( - transaction: Transaction, - options?: SendOptions, - ): Promise<{ signature: TransactionSignature }>; - signMessage(message: Uint8Array): Promise<{ signature: Uint8Array }>; - connect(): Promise; - disconnect(): Promise; -} - -interface XDEFIWalletWindow extends Window { - xfi?: { - solana?: XDEFIWallet; - }; -} - -declare const window: XDEFIWalletWindow; - -export interface XDEFIWalletAdapterConfig {} - -export const XDEFIWalletName = "XDEFI" as WalletName<"XDEFI">; - -export class XDEFIWalletAdapter extends BaseMessageSignerWalletAdapter { - name = XDEFIWalletName; - url = "https://xdefi.io"; - icon = - "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE0LjI2MjggMTMuNDAxM0MxMi40MjI4IDE0LjUzMDcgOS45NTk5NyAxNS4xMTI0IDcuNDY1NjkgMTQuOTg4MUM1LjM2ODU1IDE0Ljg4NjUgMy42NDg1NSAxNC4xNDExIDIuNjA4NTUgMTIuOTE1N0MxLjY5NDI2IDExLjgyMDEgMS4zMzk5OCAxMC4zNzQ1IDEuNTc5OTggOC43MTE0M0MxLjY2MTMyIDguMTU4NzQgMS44MjgwMiA3LjYyMTY2IDIuMDc0MjYgNy4xMTg5NkwyLjEwODU1IDcuMDQ4MzdDMi45NzE4IDUuNDA1OTUgNC4yNTI5MyA0LjAxMzk3IDUuODI1ODQgMy4wMDk0MkM3LjM5ODc1IDIuMDA0ODYgOS4yMDkyNCAxLjQyMjM2IDExLjA3OTEgMS4zMTkyNEMxMi45NDkgMS4yMTYxMSAxNC44MTM4IDEuNTk1OTIgMTYuNDkwMSAyLjQyMTI4QzE4LjE2NjMgMy4yNDY2NSAxOS41OTYyIDQuNDg5MTIgMjAuNjM5IDYuMDI2NDFDMjEuNjgxOSA3LjU2MzcxIDIyLjMwMTcgOS4zNDI4NSAyMi40Mzc0IDExLjE4ODdDMjIuNTczMiAxMy4wMzQ2IDIyLjIyMDMgMTQuODgzNiAyMS40MTM0IDE2LjU1MzhDMjAuNjA2NSAxOC4yMjQgMTkuMzczNSAxOS42NTc3IDE3LjgzNTYgMjAuNzE0QzE2LjI5NzggMjEuNzcw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DAxIDE2LjYyNTdMMC40MjI4NTYgMTcuMTMzOUwwLjg0Mjg1NiAxNi42MzQyTDAgMTcuNjMzN0MwLjA5MTQyODYgMTcuNzA5OSAyLjE1NzE0IDE5LjM1ODkgNy4wMDg1NyAxOS4zNTg5QzcuNDA1NzEgMTkuMzU4OSA3LjgyMjg2IDE5LjM1ODkgOC4yNTcxNCAxOS4zMjVDMTMuODM3MSAxOS4wMTcyIDE2LjkwMjkgMTYuNjExNiAxNy45NzE0IDE1LjU4MzhMMTYuNzggMTQuODc1MVoiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik0xOS4wMiAxNi4yMTkyQzE4LjMxMjEgMTcuMTM4NyAxNy40NDA4IDE3LjkyMzMgMTYuNDQ4NiAxOC41MzQ1QzEyLjk1MTUgMjAuNzY1IDguNTAyODkgMjEuMDUzIDUuMzg4NiAyMC44OTc4TDUuMzIyODkgMjIuMTk5NEM1Ljg0NTc1IDIyLjIyNDggNi4zNDg2MSAyMi4yMzYxIDYuODM3MTggMjIuMjM2MUMxNS42MiAyMi4yMzYxIDE5LjE2ODYgMTguMjgzMiAyMC4xNiAxNi44NzE0TDE5LjAxNzIgMTYuMjA3OSIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTE4LjY4NTcgMTEuMjkyMkMxOS4yNjggMTEuMjkyMiAxOS43NCAxMC44MjU3IDE5Ljc0IDEwLjI1MDNDMTkuNzQgOS42NzQ4OSAxOS4yNjggOS4yMDg0MiAxOC42ODU3IDkuMjA4NDJDMTguMTAzNCA5LjIwODQyIDE3LjYzMTQgOS42NzQ4OSAxNy42MzE0IDEwLjI1MDNDMTcuNjMxNCAxMC44MjU3IDE4LjEwMzQgMTEuMjkyMiAxOC42ODU3IDExLjI5MjJaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K"; - readonly supportedTransactionVersions = null; - - private _connecting: boolean; - private _wallet: XDEFIWallet | null; - private _publicKey: PublicKey | null; - private _readyState: WalletReadyState = - typeof window === "undefined" || typeof document === "undefined" - ? WalletReadyState.Unsupported - : WalletReadyState.NotDetected; - - constructor(config: XDEFIWalletAdapterConfig = {}) { - super(); - this._connecting = false; - this._wallet = null; - this._publicKey = null; - - if (this._readyState !== WalletReadyState.Unsupported) { - scopePollingDetectionStrategy(() => { - if (window.xfi?.solana?.isXDEFI) { - this._readyState = WalletReadyState.Installed; - this.emit("readyStateChange", this._readyState); - return true; - } - return false; - }); - } - } - - get publicKey() { - return this._publicKey; - } - - get connecting() { - return this._connecting; - } - - get connected() { - return !!this._wallet?.isConnected; - } - - get readyState() { - return this._readyState; - } - - async connect(): Promise { - try { - if (this.connected || this.connecting) return; - if (this._readyState !== WalletReadyState.Installed) - throw new WalletNotReadyError(); - - this._connecting = true; - - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const wallet = window.xfi!.solana!; - - if (!wallet.isConnected) { - try { - await wallet.connect(); - } catch (error: any) { - throw new WalletConnectionError(error?.message, error); - } - } - - if (!wallet.publicKey) throw new WalletAccountError(); - - let publicKey: PublicKey; - try { - publicKey = new PublicKey(wallet.publicKey.toBytes()); - } catch (error: any) { - throw new WalletPublicKeyError(error?.message, error); - } - - wallet.on("disconnect", this._disconnected); - - this._wallet = wallet; - this._publicKey = publicKey; - - this.emit("connect", publicKey); - } catch (error: any) { - this.emit("error", error); - throw error; - } finally { - this._connecting = false; - } - } - - async disconnect(): Promise { - const wallet = this._wallet; - if (wallet) { - wallet.off("disconnect", this._disconnected); - - this._wallet = null; - this._publicKey = null; - - try { - await wallet.disconnect(); - } catch (error: any) { - this.emit("error", new WalletDisconnectionError(error?.message, error)); - } - } - - this.emit("disconnect"); - } - - async signTransaction(transaction: T): Promise { - try { - const wallet = this._wallet; - if (!wallet) throw new WalletNotConnectedError(); - - try { - return ( - ((await wallet.signTransaction(transaction)) as T) || transaction - ); - } catch (error: any) { - throw new WalletSignTransactionError(error?.message, error); - } - } catch (error: any) { - this.emit("error", error); - throw error; - } - } - - async signAllTransactions( - transactions: T[], - ): Promise { - try { - const wallet = this._wallet; - if (!wallet) throw new WalletNotConnectedError(); - - try { - return ( - ((await wallet.signAllTransactions(transactions)) as T[]) || - transactions - ); - } catch (error: any) { - throw new WalletSignTransactionError(error?.message, error); - } - } catch (error: any) { - this.emit("error", error); - throw error; - } - } - - async signMessage(message: Uint8Array): Promise { - try { - const wallet = this._wallet; - if (!wallet) throw new WalletNotConnectedError(); - - try { - const { signature } = await wallet.signMessage(message); - return signature; - } catch (error: any) { - throw new WalletSignMessageError(error?.message, error); - } - } catch (error: any) { - this.emit("error", error); - throw error; - } - } - - private _disconnected = () => { - const wallet = this._wallet; - if (wallet) { - wallet.off("disconnect", this._disconnected); - - this._wallet = null; - this._publicKey = null; - - this.emit("error", new WalletDisconnectedError()); - this.emit("disconnect"); - } - }; -} -``` From 53aae361b27e05513f88f85bed4c945bedf477f9 Mon Sep 17 00:00:00 2001 From: "Justin (HoangVD2)" Date: Wed, 13 Mar 2024 09:03:38 +0700 Subject: [PATCH 2/3] fix: update rainbow kit --- developers/rainbowkit-xdefi-integration.md | 51 ++++++++-------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/developers/rainbowkit-xdefi-integration.md b/developers/rainbowkit-xdefi-integration.md index 15f9fb89a..70e1e171a 100644 --- a/developers/rainbowkit-xdefi-integration.md +++ b/developers/rainbowkit-xdefi-integration.md @@ -1,5 +1,7 @@ # RainbowKit XDEFI Integration +### Built-in XDEFI Wallet + You can import individual wallets from `'@rainbow-me/rainbowkit/wallets'` along with the `connectorsForWallets` function to build your own list of wallets with their necessary connectors. This way you have full control over which wallets to display, and in which order. For example, you can choose to only show Rainbow along with generic fallback wallets. @@ -7,15 +9,15 @@ For example, you can choose to only show Rainbow along with generic fallback wal ```javascript import { connectorsForWallets } from "@rainbow-me/rainbowkit"; import { - rainbowWallet, - walletConnectWallet, + xdefiWallet, + // other wallets } from "@rainbow-me/rainbowkit/wallets"; const connectors = connectorsForWallets( [ { groupName: "Recommended", - wallets: [rainbowWallet, walletConnectWallet], + wallets: [xdefiWallet], }, ], { @@ -51,42 +53,28 @@ const App = () => ( ); ``` -### Built-in XDEFI Wallets - -First, you need to install the `@rainbow-me/rainbowkit/wallets` package and then import the dApp: - -```javascript -import { xdefiWallet } from "@rainbow-me/rainbowkit/wallets"; -``` - ### Examples -Here are examples: Show Rainbow, MetaMask, Coinbase and XDEFI along with generic fallback wallets. +Here are examples: Show XDEFI Wallet along with generic fallback wallets. ```javascript -import { connectorsForWallets } from '@rainbow-me/rainbowkit'; +import { connectorsForWallets } from "@rainbow-me/rainbowkit"; import { - rainbowWallet, - xdefiWallet - metaMaskWallet, - coinbaseWallet, - walletConnectWallet, -} from '@rainbow-me/rainbowkit/wallets'; + xdefiWallet, + // other wallets +} from "@rainbow-me/rainbowkit/wallets"; const connectors = connectorsForWallets( [ { - groupName: 'Suggested', + groupName: "Suggested", wallets: [ - rainbowWallet, xdefiWallet, - metaMaskWallet, - coinbaseWallet, - walletConnectWallet, + // other wallets ], }, ], - { appName: 'RainbowKit App', projectId: 'YOUR_PROJECT_ID' }, + { appName: "RainbowKit App", projectId: "YOUR_PROJECT_ID" }, ); ``` @@ -94,27 +82,26 @@ const connectors = connectorsForWallets( You also can use the `groupName` key to name different wallet groups. This is useful if you want to communicate to your users which wallets you recommend, as well as other possible wallets. -Recommend Rainbow and MetaMask, but also offer Coinbase along with generic fallback wallets. +Recommend XDEFI Wallet along with other wallets in a separate group ```javascript import { connectorsForWallets } from "@rainbow-me/rainbowkit"; import { - rainbowWallet, xdefiWallet, - metaMaskWallet, - coinbaseWallet, - walletConnectWallet, + // other wallets } from "@rainbow-me/rainbowkit/wallets"; const connectors = connectorsForWallets( [ { groupName: "Recommended", - wallets: [rainbowWallet, metaMaskWallet], + wallets: [xdefiWallet], }, { groupName: "Others", - wallets: [xdefiWallet, coinbaseWallet, walletConnectWallet], + wallets: [ + // other wallets + ], }, ], { appName: "RainbowKit App", projectId: "YOUR_PROJECT_ID" }, From 0bc7296b65ee4c5182fcff728785c9cab48323fa Mon Sep 17 00:00:00 2001 From: "Justin (HoangVD2)" Date: Wed, 13 Mar 2024 14:15:52 +0700 Subject: [PATCH 3/3] fix: revert Solana Adapter XDEFI Integration --- .../solana-adapter-xdefi-integration.md | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/developers/solana-adapter-xdefi-integration.md b/developers/solana-adapter-xdefi-integration.md index a8056ffd3..435dcc7a0 100644 --- a/developers/solana-adapter-xdefi-integration.md +++ b/developers/solana-adapter-xdefi-integration.md @@ -1 +1,65 @@ # Solana Adapter XDEFI Integration + +# Extension Wallet Solana Integration + +[[toc]] + +## Using Solana Adapter + +### Solana Adapter not installed + +Install the latest wallets package: + +```bash +npm install @solana/wallet-adapter-xdefi@latest +``` + +Once installed, you can add XDEFI Wallet by making adding this part of code: + +```js:line-numbers {0} +import { XDEFIWalletAdapter } from `@solana/wallet-adapter-xdefi`; +import { /* ... other adapters ... */ } from `@solana/wallet-adapter-wallets`; + +const wallets = useMemo( + () => [ + new XDEFIWalletAdapter(), + // ... other adapters ... + ], + [] +); + + +``` + +### Solana Adapter already installed + +Install the latest wallets package: + +```bash +npm install @solana/wallet-adapter-wallets@latest +``` + +Once installed, you can add XDEFI Wallet by making 2 changes: + +```js:line-numbers {0} +import { + XDEFIWalletAdapter, // [!code ++] + /* ... other adapters ... */ +} from `@solana/wallet-adapter-wallets`; + +const wallets = useMemo( + () => [ + new XDEFIWalletAdapter(), // [!code ++] + // ... other adapters ... + ], + [] +); + + +``` + +## Using XDEFI Provider + +## Using XDEFI SDK + +TBD