From 08defebc8e3eccfd75149d66f02670da7dc568dd Mon Sep 17 00:00:00 2001 From: David Mohl Date: Tue, 29 Mar 2022 20:43:09 +0900 Subject: [PATCH 01/13] Add Saifu wallet --- packages/starter/react-ui-starter/src/App.tsx | 5 + packages/wallets/saifu/.gitignore | 1 + packages/wallets/saifu/.prettierignore | 1 + packages/wallets/saifu/LICENSE | 202 +++++++++++++ packages/wallets/saifu/README.md | 3 + packages/wallets/saifu/package.json | 33 +++ packages/wallets/saifu/src/adapter.ts | 270 ++++++++++++++++++ packages/wallets/saifu/src/index.ts | 1 + packages/wallets/saifu/tsconfig.cjs.json | 10 + packages/wallets/saifu/tsconfig.json | 9 + packages/wallets/wallets/package.json | 4 +- packages/wallets/wallets/src/adapters.ts | 49 ++++ packages/wallets/wallets/src/index.ts | 4 + 13 files changed, 591 insertions(+), 1 deletion(-) create mode 100644 packages/wallets/saifu/.gitignore create mode 100644 packages/wallets/saifu/.prettierignore create mode 100644 packages/wallets/saifu/LICENSE create mode 100644 packages/wallets/saifu/README.md create mode 100644 packages/wallets/saifu/package.json create mode 100644 packages/wallets/saifu/src/adapter.ts create mode 100644 packages/wallets/saifu/src/index.ts create mode 100644 packages/wallets/saifu/tsconfig.cjs.json create mode 100644 packages/wallets/saifu/tsconfig.json create mode 100644 packages/wallets/wallets/src/adapters.ts diff --git a/packages/starter/react-ui-starter/src/App.tsx b/packages/starter/react-ui-starter/src/App.tsx index 1afead7d8..178a8b7a7 100644 --- a/packages/starter/react-ui-starter/src/App.tsx +++ b/packages/starter/react-ui-starter/src/App.tsx @@ -8,6 +8,7 @@ import { SlopeWalletAdapter, SolflareWalletAdapter, TorusWalletAdapter, + SaifuWalletAdapter, } from '@solana/wallet-adapter-wallets'; import { clusterApiUrl } from '@solana/web3.js'; import React, { FC, ReactNode, useMemo } from 'react'; @@ -41,6 +42,10 @@ const Context: FC<{ children: ReactNode }> = ({ children }) => { new SlopeWalletAdapter(), new SolflareWalletAdapter({ network }), new TorusWalletAdapter(), + new LedgerWalletAdapter(), + new SolletWalletAdapter({ network }), + new SolletExtensionWalletAdapter({ network }), + new SaifuWalletAdapter(), ], [network] ); diff --git a/packages/wallets/saifu/.gitignore b/packages/wallets/saifu/.gitignore new file mode 100644 index 000000000..a65b41774 --- /dev/null +++ b/packages/wallets/saifu/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/wallets/saifu/.prettierignore b/packages/wallets/saifu/.prettierignore new file mode 100644 index 000000000..a65b41774 --- /dev/null +++ b/packages/wallets/saifu/.prettierignore @@ -0,0 +1 @@ +lib diff --git a/packages/wallets/saifu/LICENSE b/packages/wallets/saifu/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/packages/wallets/saifu/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/wallets/saifu/README.md b/packages/wallets/saifu/README.md new file mode 100644 index 000000000..d69a8c0b8 --- /dev/null +++ b/packages/wallets/saifu/README.md @@ -0,0 +1,3 @@ +# `@solana/wallet-adapter-saifu` + +Wallet adapter for integrating https://saifuwallet.com/ diff --git a/packages/wallets/saifu/package.json b/packages/wallets/saifu/package.json new file mode 100644 index 000000000..e41fd8b22 --- /dev/null +++ b/packages/wallets/saifu/package.json @@ -0,0 +1,33 @@ +{ + "name": "@solana/wallet-adapter-saifu", + "version": "0.1.0", + "author": "Solana Maintainers ", + "repository": "https://github.com/solana-labs/wallet-adapter", + "license": "Apache-2.0", + "type": "module", + "sideEffects": false, + "main": "lib/cjs/index.js", + "module": "lib/esm/index.mjs", + "types": "lib/types/index.d.ts", + "exports": { + "import": "./lib/esm/index.mjs", + "require": "./lib/cjs/index.js" + }, + "files": [ + "lib", + "src", + "LICENSE" + ], + "publishConfig": { + "access": "public" + }, + "scripts": { + "clean": "shx rm -rf lib/*", + "build": "yarn clean && tsc -p tsconfig.json && tsc-esm -p tsconfig.json && tsc -p tsconfig.cjs.json", + "postbuild": "echo '{\"type\":\"commonjs\"}' | npx json > lib/cjs/package.json && echo '{\"type\":\"module\"} ' | npx json > lib/esm/package.json" + }, + "dependencies": { + "@solana/wallet-adapter-base": "^0.9.4", + "@solana/web3.js": "^1.36.0" + } +} diff --git a/packages/wallets/saifu/src/adapter.ts b/packages/wallets/saifu/src/adapter.ts new file mode 100644 index 000000000..5f2143455 --- /dev/null +++ b/packages/wallets/saifu/src/adapter.ts @@ -0,0 +1,270 @@ +import { + BaseMessageSignerWalletAdapter, + EventEmitter, + scopePollingDetectionStrategy, + SendTransactionOptions, + WalletAccountError, + WalletConnectionError, + WalletDisconnectedError, + WalletDisconnectionError, + WalletError, + WalletName, + WalletNotConnectedError, + WalletNotReadyError, + WalletPublicKeyError, + WalletReadyState, + WalletSignTransactionError, + WalletWindowClosedError, +} from '@solana/wallet-adapter-base'; +import { Connection, PublicKey, SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; + +interface SaifuWalletEvents { + connect(...args: unknown[]): unknown; + disconnect(...args: unknown[]): unknown; +} + +interface SaifuWallet extends EventEmitter { + isSaifu?: 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; + _handleDisconnect(...args: unknown[]): unknown; +} + +interface SolanaWindow extends Window { + solana?: SaifuWallet; + saifu?: SaifuWallet; +} + +declare const window: SolanaWindow; + +export interface SaifuWalletAdapterConfig {} + +export const SaifuWalletName = 'Saifu' as WalletName; + +export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { + name = SaifuWalletName; + url = 'https://saifuwallet.com'; + icon = + 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iNTQxcHgiIGhlaWdodD0iNTQxcHgiIHZpZXdCb3g9IjAgMCA1NDEgNTQxIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPHRpdGxlPkFydGJvYXJkIENvcHkgOTwvdGl0bGU+CiAgICA8ZGVmcz4KICAgICAgICA8bGluZWFyR3JhZGllbnQgeDE9IjEuNzk5ODcyMTYlIiB5MT0iMCUiIHgyPSI5OC4zOTcxMDUxJSIgeTI9Ijk3Ljk5MDI5MSUiIGlkPSJsaW5lYXJHcmFkaWVudC0xIj4KICAgICAgICAgICAgPHN0b3Agc3RvcC1jb2xvcj0iI0ZCOTIzQyIgb2Zmc2V0PSIwJSI+PC9zdG9wPgogICAgICAgICAgICA8c3RvcCBzdG9wLWNvbG9yPSIjRUM0ODk5IiBvZmZzZXQ9IjEwMCUiPjwvc3RvcD4KICAgICAgICA8L2xpbmVhckdyYWRpZW50PgogICAgPC9kZWZzPgogICAgPGcgaWQ9IkFydGJvYXJkLUNvcHktOSIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPHBhdGggZD0iTTIzMi4yNzAwNDQsLTcuODU2NzI5NzFlLTE1IEwzMDcuNzI5OTU2LDcuODU2Nz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A3MDYxIDIzNi41OTcyNDIsMzE4LjkxNDY5IDIyOS45OTcyMzYsMzE5Ljk2MDI4NCBDMjIzLjM5NzIzLDMyMS4wMDU4NDYgMjEyLjUxOTc4OCwzMjIuMzM3NjY0IDIwNS44MjUxNDcsMzIyLjkxOTg0OCBDMTk5LjEzMDUwNiwzMjMuNTAyMDYyIDE3OS4xMDU0OTcsMzIzLjkyNjY4NCAxNjEuMzI1MTQ3LDMyMy44NjM0MjEgWiIgaWQ9IlNoYXBlIj48L3BhdGg+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4='; + + private _connecting: boolean; + private _wallet: SaifuWallet | null; + private _publicKey: PublicKey | null; + private _readyState: WalletReadyState = + typeof window === 'undefined' || typeof document === 'undefined' + ? WalletReadyState.Unsupported + : WalletReadyState.NotDetected; + + constructor(config: SaifuWalletAdapterConfig = {}) { + super(); + this._connecting = false; + this._wallet = null; + this._publicKey = null; + + if (this._readyState !== WalletReadyState.Unsupported) { + scopePollingDetectionStrategy(() => { + if (window.solana?.isSaifu || window.saifu) { + this._readyState = WalletReadyState.Installed; + this.emit('readyStateChange', this._readyState); + return true; + } + return false; + }); + } + } + + get publicKey(): PublicKey | null { + return this._publicKey; + } + + get connecting(): boolean { + return this._connecting; + } + + get connected(): boolean { + return !!this._wallet?.isConnected; + } + + get readyState(): WalletReadyState { + return this._readyState; + } + + async connect(): Promise { + try { + if (this.connected || this.connecting) return; + if (this._readyState !== WalletReadyState.Installed) throw new WalletNotReadyError(); + + this._connecting = true; + + const wallet = window.saifu || window.solana; + + // just bail + if (!wallet) { + throw new WalletNotReadyError(); + } + + if (!wallet.isConnected) { + const handleDisconnect = wallet._handleDisconnect; + try { + await new Promise((resolve, reject) => { + const connect = () => { + wallet.off('connect', connect); + resolve(); + }; + + wallet._handleDisconnect = (...args: unknown[]) => { + wallet.off('connect', connect); + reject(new WalletWindowClosedError()); + return handleDisconnect.apply(wallet, args); + }; + + wallet.on('connect', connect); + + wallet.connect().catch((reason: any) => { + wallet.off('connect', connect); + reject(reason); + }); + }); + } catch (error: any) { + if (error instanceof WalletError) throw error; + throw new WalletConnectionError(error?.message, error); + } finally { + wallet._handleDisconnect = handleDisconnect; + } + } + + 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 sendTransaction( + transaction: Transaction, + connection: Connection, + options?: SendTransactionOptions + ): Promise { + try { + const wallet = this._wallet; + if (wallet && 'signAndSendTransaction' in wallet && !options?.signers) { + transaction.feePayer = transaction.feePayer || this.publicKey || undefined; + transaction.recentBlockhash = + transaction.recentBlockhash || (await connection.getRecentBlockhash('finalized')).blockhash; + + const { signature } = await wallet.signAndSendTransaction(transaction, options); + return signature; + } + } catch (error: any) { + this.emit('error', error); + throw error; + } + + return await super.sendTransaction(transaction, connection, options); + } + + async signTransaction(transaction: Transaction): Promise { + try { + const wallet = this._wallet; + if (!wallet) throw new WalletNotConnectedError(); + + try { + return (await wallet.signTransaction(transaction)) || transaction; + } catch (error: any) { + throw new WalletSignTransactionError(error?.message, error); + } + } catch (error: any) { + this.emit('error', error); + throw error; + } + } + + async signAllTransactions(transactions: Transaction[]): Promise { + try { + const wallet = this._wallet; + if (!wallet) throw new WalletNotConnectedError(); + + try { + return (await wallet.signAllTransactions(transactions)) || 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 WalletSignTransactionError(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'); + } + }; +} diff --git a/packages/wallets/saifu/src/index.ts b/packages/wallets/saifu/src/index.ts new file mode 100644 index 000000000..7e77e9fc2 --- /dev/null +++ b/packages/wallets/saifu/src/index.ts @@ -0,0 +1 @@ +export * from './adapter'; diff --git a/packages/wallets/saifu/tsconfig.cjs.json b/packages/wallets/saifu/tsconfig.cjs.json new file mode 100644 index 000000000..443b583a0 --- /dev/null +++ b/packages/wallets/saifu/tsconfig.cjs.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "outDir": "lib/cjs", + "declarationDir": null, + "declaration": false + } +} diff --git a/packages/wallets/saifu/tsconfig.json b/packages/wallets/saifu/tsconfig.json new file mode 100644 index 000000000..ea51e41c4 --- /dev/null +++ b/packages/wallets/saifu/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../../tsconfig.json", + "include": ["src"], + "compilerOptions": { + "outDir": "lib/esm", + "declarationDir": "lib/types", + "noEmit": false + } +} diff --git a/packages/wallets/wallets/package.json b/packages/wallets/wallets/package.json index 6685da2a7..a4a32c3a8 100644 --- a/packages/wallets/wallets/package.json +++ b/packages/wallets/wallets/package.json @@ -49,6 +49,8 @@ "@solana/wallet-adapter-sollet": "^0.11.0", "@solana/wallet-adapter-solong": "^0.9.2", "@solana/wallet-adapter-tokenpocket": "^0.4.2", - "@solana/wallet-adapter-torus": "^0.11.12" + "@solana/wallet-adapter-torus": "^0.11.12", + "@solana/wallet-adapter-walletconnect": "^0.1.0", + "@solana/wallet-adapter-saifu": "^0.1.0" } } diff --git a/packages/wallets/wallets/src/adapters.ts b/packages/wallets/wallets/src/adapters.ts new file mode 100644 index 000000000..8855728ab --- /dev/null +++ b/packages/wallets/wallets/src/adapters.ts @@ -0,0 +1,49 @@ +import { Adapter, WalletAdapterNetwork } from '@solana/wallet-adapter-base'; +import { BitKeepWalletAdapter } from '@solana/wallet-adapter-bitkeep'; +import { BitpieWalletAdapter } from '@solana/wallet-adapter-bitpie'; +import { BloctoWalletAdapter } from '@solana/wallet-adapter-blocto'; +import { CloverWalletAdapter } from '@solana/wallet-adapter-clover'; +import { Coin98WalletAdapter } from '@solana/wallet-adapter-coin98'; +import { CoinhubWalletAdapter } from '@solana/wallet-adapter-coinhub'; +import { GlowWalletAdapter } from '@solana/wallet-adapter-glow'; +import { HuobiWalletAdapter } from '@solana/wallet-adapter-huobi'; +import { LedgerWalletAdapter } from '@solana/wallet-adapter-ledger'; +import { MathWalletAdapter } from '@solana/wallet-adapter-mathwallet'; +import { PhantomWalletAdapter } from '@solana/wallet-adapter-phantom'; +import { SafePalWalletAdapter } from '@solana/wallet-adapter-safepal'; +import { SlopeWalletAdapter } from '@solana/wallet-adapter-slope'; +import { SolflareWalletAdapter } from '@solana/wallet-adapter-solflare'; +import { SolletExtensionWalletAdapter, SolletWalletAdapter } from '@solana/wallet-adapter-sollet'; +import { SolongWalletAdapter } from '@solana/wallet-adapter-solong'; +import { TokenPocketWalletAdapter } from '@solana/wallet-adapter-tokenpocket'; +import { TorusWalletAdapter } from '@solana/wallet-adapter-torus'; +import { SaifuWalletAdapter } from '@solana/wallet-adapter-saifu'; + +export interface WalletsConfig { + network?: WalletAdapterNetwork; +} + +export function getWalletAdapters({ network = WalletAdapterNetwork.Mainnet }: WalletsConfig = {}): Adapter[] { + return [ + new PhantomWalletAdapter(), + new GlowWalletAdapter(), + new SlopeWalletAdapter(), + new SolflareWalletAdapter({ network }), + new SolletExtensionWalletAdapter({ network }), + new BitKeepWalletAdapter(), + new BitpieWalletAdapter(), + new CloverWalletAdapter(), + new Coin98WalletAdapter(), + new CoinhubWalletAdapter(), + new HuobiWalletAdapter(), + new MathWalletAdapter(), + new SafePalWalletAdapter(), + new SolongWalletAdapter(), + new TokenPocketWalletAdapter(), + new TorusWalletAdapter(), + new LedgerWalletAdapter(), + new SolletWalletAdapter({ network }), + new BloctoWalletAdapter({ network }), + new SaifuWalletAdapter(), + ]; +} diff --git a/packages/wallets/wallets/src/index.ts b/packages/wallets/wallets/src/index.ts index 0718263b8..ab5ef7e21 100644 --- a/packages/wallets/wallets/src/index.ts +++ b/packages/wallets/wallets/src/index.ts @@ -19,3 +19,7 @@ export * from '@solana/wallet-adapter-sollet'; export * from '@solana/wallet-adapter-solong'; export * from '@solana/wallet-adapter-tokenpocket'; export * from '@solana/wallet-adapter-torus'; +export * from '@solana/wallet-adapter-walletconnect'; +export * from '@solana/wallet-adapter-saifu'; + +export * from './adapters'; From 50fc102b88bdfc5fa85b1fea00ecb549e5af95c0 Mon Sep 17 00:00:00 2001 From: David Mohl Date: Tue, 29 Mar 2022 20:46:31 +0900 Subject: [PATCH 02/13] Add Saifu to README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 036171abd..67fdb7d3e 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ import { SolletExtensionWalletAdapter, SolletWalletAdapter, TorusWalletAdapter, + SaifuWalletAdapter } from '@solana/wallet-adapter-wallets'; import { WalletModalProvider, @@ -83,6 +84,7 @@ export const Wallet: FC = () => { new GlowWalletAdapter(), new SlopeWalletAdapter(), new SolflareWalletAdapter({ network }), + new SaifuWalletAdapter(), new TorusWalletAdapter(), ], [network] @@ -172,6 +174,7 @@ You can use the [wallets](https://github.com/solana-labs/wallet-adapter/tree/mas | [nightly](https://github.com/solana-labs/wallet-adapter/tree/master/packages/wallets/nightly) | Adapter for [Nightly](https://nightly.app) | [`@solana/wallet-adapter-nightly`](https://npmjs.com/package/@solana/wallet-adapter-nightly) | | [phantom](https://github.com/solana-labs/wallet-adapter/tree/master/packages/wallets/phantom) | Adapter for [Phantom](https://phantom.app) | [`@solana/wallet-adapter-phantom`](https://npmjs.com/package/@solana/wallet-adapter-phantom) | | [safepal](https://github.com/solana-labs/wallet-adapter/tree/master/packages/wallets/safepal) | Adapter for [SafePal](https://safepal.io) | [`@solana/wallet-adapter-safepal`](https://npmjs.com/package/@solana/wallet-adapter-safepal) | +| [saifu](https://github.com/solana-labs/wallet-adapter/tree/master/packages/wallets/saifu) | Adapter for [Saifu](https://saifuwallet.com/) | [`@solana/wallet-adapter-saifu`](https://npmjs.com/package/@solana/wallet-adapter-safepal) | | [slope](https://github.com/solana-labs/wallet-adapter/tree/master/packages/wallets/slope) | Adapter for [Slope](https://slope.finance) | [`@solana/wallet-adapter-slope`](https://npmjs.com/package/@solana/wallet-adapter-slope) | | [solflare](https://github.com/solana-labs/wallet-adapter/tree/master/packages/wallets/solflare) | Adapter for [Solflare](https://solflare.com) | [`@solana/wallet-adapter-solflare`](https://npmjs.com/package/@solana/wallet-adapter-solflare) | | [sollet](https://github.com/solana-labs/wallet-adapter/tree/master/packages/wallets/sollet) | Adapter for [Sollet](https://www.sollet.io) | [`@solana/wallet-adapter-sollet`](https://npmjs.com/package/@solana/wallet-adapter-sollet) | From 5f72d82b9abe533f797b9358a5c2559d710e4678 Mon Sep 17 00:00:00 2001 From: David Mohl Date: Tue, 14 Jun 2022 16:22:06 +0900 Subject: [PATCH 03/13] Remove stuff that got deleted in upstream --- packages/starter/react-ui-starter/src/App.tsx | 3 -- packages/wallets/wallets/src/adapters.ts | 49 ------------------- packages/wallets/wallets/src/index.ts | 2 - 3 files changed, 54 deletions(-) delete mode 100644 packages/wallets/wallets/src/adapters.ts diff --git a/packages/starter/react-ui-starter/src/App.tsx b/packages/starter/react-ui-starter/src/App.tsx index 178a8b7a7..4b739e61a 100644 --- a/packages/starter/react-ui-starter/src/App.tsx +++ b/packages/starter/react-ui-starter/src/App.tsx @@ -42,9 +42,6 @@ const Context: FC<{ children: ReactNode }> = ({ children }) => { new SlopeWalletAdapter(), new SolflareWalletAdapter({ network }), new TorusWalletAdapter(), - new LedgerWalletAdapter(), - new SolletWalletAdapter({ network }), - new SolletExtensionWalletAdapter({ network }), new SaifuWalletAdapter(), ], [network] diff --git a/packages/wallets/wallets/src/adapters.ts b/packages/wallets/wallets/src/adapters.ts deleted file mode 100644 index 8855728ab..000000000 --- a/packages/wallets/wallets/src/adapters.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { Adapter, WalletAdapterNetwork } from '@solana/wallet-adapter-base'; -import { BitKeepWalletAdapter } from '@solana/wallet-adapter-bitkeep'; -import { BitpieWalletAdapter } from '@solana/wallet-adapter-bitpie'; -import { BloctoWalletAdapter } from '@solana/wallet-adapter-blocto'; -import { CloverWalletAdapter } from '@solana/wallet-adapter-clover'; -import { Coin98WalletAdapter } from '@solana/wallet-adapter-coin98'; -import { CoinhubWalletAdapter } from '@solana/wallet-adapter-coinhub'; -import { GlowWalletAdapter } from '@solana/wallet-adapter-glow'; -import { HuobiWalletAdapter } from '@solana/wallet-adapter-huobi'; -import { LedgerWalletAdapter } from '@solana/wallet-adapter-ledger'; -import { MathWalletAdapter } from '@solana/wallet-adapter-mathwallet'; -import { PhantomWalletAdapter } from '@solana/wallet-adapter-phantom'; -import { SafePalWalletAdapter } from '@solana/wallet-adapter-safepal'; -import { SlopeWalletAdapter } from '@solana/wallet-adapter-slope'; -import { SolflareWalletAdapter } from '@solana/wallet-adapter-solflare'; -import { SolletExtensionWalletAdapter, SolletWalletAdapter } from '@solana/wallet-adapter-sollet'; -import { SolongWalletAdapter } from '@solana/wallet-adapter-solong'; -import { TokenPocketWalletAdapter } from '@solana/wallet-adapter-tokenpocket'; -import { TorusWalletAdapter } from '@solana/wallet-adapter-torus'; -import { SaifuWalletAdapter } from '@solana/wallet-adapter-saifu'; - -export interface WalletsConfig { - network?: WalletAdapterNetwork; -} - -export function getWalletAdapters({ network = WalletAdapterNetwork.Mainnet }: WalletsConfig = {}): Adapter[] { - return [ - new PhantomWalletAdapter(), - new GlowWalletAdapter(), - new SlopeWalletAdapter(), - new SolflareWalletAdapter({ network }), - new SolletExtensionWalletAdapter({ network }), - new BitKeepWalletAdapter(), - new BitpieWalletAdapter(), - new CloverWalletAdapter(), - new Coin98WalletAdapter(), - new CoinhubWalletAdapter(), - new HuobiWalletAdapter(), - new MathWalletAdapter(), - new SafePalWalletAdapter(), - new SolongWalletAdapter(), - new TokenPocketWalletAdapter(), - new TorusWalletAdapter(), - new LedgerWalletAdapter(), - new SolletWalletAdapter({ network }), - new BloctoWalletAdapter({ network }), - new SaifuWalletAdapter(), - ]; -} diff --git a/packages/wallets/wallets/src/index.ts b/packages/wallets/wallets/src/index.ts index ab5ef7e21..836dc581b 100644 --- a/packages/wallets/wallets/src/index.ts +++ b/packages/wallets/wallets/src/index.ts @@ -21,5 +21,3 @@ export * from '@solana/wallet-adapter-tokenpocket'; export * from '@solana/wallet-adapter-torus'; export * from '@solana/wallet-adapter-walletconnect'; export * from '@solana/wallet-adapter-saifu'; - -export * from './adapters'; From 4f63fd2f65d33e79776b1c6a4990d8fb4e276e84 Mon Sep 17 00:00:00 2001 From: David Mohl Date: Thu, 23 Jun 2022 14:24:20 +0900 Subject: [PATCH 04/13] Remove saifu from default README --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 67fdb7d3e..89be588d6 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,6 @@ import { SolletExtensionWalletAdapter, SolletWalletAdapter, TorusWalletAdapter, - SaifuWalletAdapter } from '@solana/wallet-adapter-wallets'; import { WalletModalProvider, @@ -84,7 +83,6 @@ export const Wallet: FC = () => { new GlowWalletAdapter(), new SlopeWalletAdapter(), new SolflareWalletAdapter({ network }), - new SaifuWalletAdapter(), new TorusWalletAdapter(), ], [network] From 2dcd6b58a0263f7d399b6152b1195a1238a41f9e Mon Sep 17 00:00:00 2001 From: David Mohl Date: Thu, 23 Jun 2022 14:24:27 +0900 Subject: [PATCH 05/13] Update package.json with peerDependencies --- packages/wallets/saifu/package.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/wallets/saifu/package.json b/packages/wallets/saifu/package.json index e41fd8b22..0b83899f8 100644 --- a/packages/wallets/saifu/package.json +++ b/packages/wallets/saifu/package.json @@ -26,8 +26,14 @@ "build": "yarn clean && tsc -p tsconfig.json && tsc-esm -p tsconfig.json && tsc -p tsconfig.cjs.json", "postbuild": "echo '{\"type\":\"commonjs\"}' | npx json > lib/cjs/package.json && echo '{\"type\":\"module\"} ' | npx json > lib/esm/package.json" }, + "peerDependencies": { + "@solana/web3.js": "^1.36.0" + }, "dependencies": { "@solana/wallet-adapter-base": "^0.9.4", + "@solflare-wallet/sdk": "^1.0.11" + }, + "devDependencies": { "@solana/web3.js": "^1.36.0" } } From bcfb68f58baa9b15173a121ab6cef27ec7133ef7 Mon Sep 17 00:00:00 2001 From: David Mohl Date: Thu, 23 Jun 2022 14:25:59 +0900 Subject: [PATCH 06/13] Slim down adapter - Remove sendTransaction - Remove window.solana ref - Make window.saifu not optional --- packages/wallets/saifu/src/adapter.ts | 71 ++++----------------------- 1 file changed, 9 insertions(+), 62 deletions(-) diff --git a/packages/wallets/saifu/src/adapter.ts b/packages/wallets/saifu/src/adapter.ts index 5f2143455..5cd28574e 100644 --- a/packages/wallets/saifu/src/adapter.ts +++ b/packages/wallets/saifu/src/adapter.ts @@ -2,21 +2,18 @@ import { BaseMessageSignerWalletAdapter, EventEmitter, scopePollingDetectionStrategy, - SendTransactionOptions, WalletAccountError, WalletConnectionError, WalletDisconnectedError, WalletDisconnectionError, - WalletError, WalletName, WalletNotConnectedError, WalletNotReadyError, WalletPublicKeyError, WalletReadyState, WalletSignTransactionError, - WalletWindowClosedError, } from '@solana/wallet-adapter-base'; -import { Connection, PublicKey, SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; +import {PublicKey, SendOptions, Transaction, TransactionSignature} from '@solana/web3.js'; interface SaifuWalletEvents { connect(...args: unknown[]): unknown; @@ -40,13 +37,13 @@ interface SaifuWallet extends EventEmitter { } interface SolanaWindow extends Window { - solana?: SaifuWallet; - saifu?: SaifuWallet; + saifu: SaifuWallet; } declare const window: SolanaWindow; -export interface SaifuWalletAdapterConfig {} +export interface SaifuWalletAdapterConfig { +} export const SaifuWalletName = 'Saifu' as WalletName; @@ -72,7 +69,7 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { if (this._readyState !== WalletReadyState.Unsupported) { scopePollingDetectionStrategy(() => { - if (window.solana?.isSaifu || window.saifu) { + if (window.saifu) { this._readyState = WalletReadyState.Installed; this.emit('readyStateChange', this._readyState); return true; @@ -105,40 +102,13 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { this._connecting = true; - const wallet = window.saifu || window.solana; - - // just bail - if (!wallet) { - throw new WalletNotReadyError(); - } + const wallet = window.saifu; - if (!wallet.isConnected) { - const handleDisconnect = wallet._handleDisconnect; + if (!wallet?.isConnected) { try { - await new Promise((resolve, reject) => { - const connect = () => { - wallet.off('connect', connect); - resolve(); - }; - - wallet._handleDisconnect = (...args: unknown[]) => { - wallet.off('connect', connect); - reject(new WalletWindowClosedError()); - return handleDisconnect.apply(wallet, args); - }; - - wallet.on('connect', connect); - - wallet.connect().catch((reason: any) => { - wallet.off('connect', connect); - reject(reason); - }); - }); + await wallet.connect() } catch (error: any) { - if (error instanceof WalletError) throw error; throw new WalletConnectionError(error?.message, error); - } finally { - wallet._handleDisconnect = handleDisconnect; } } @@ -183,29 +153,6 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { this.emit('disconnect'); } - async sendTransaction( - transaction: Transaction, - connection: Connection, - options?: SendTransactionOptions - ): Promise { - try { - const wallet = this._wallet; - if (wallet && 'signAndSendTransaction' in wallet && !options?.signers) { - transaction.feePayer = transaction.feePayer || this.publicKey || undefined; - transaction.recentBlockhash = - transaction.recentBlockhash || (await connection.getRecentBlockhash('finalized')).blockhash; - - const { signature } = await wallet.signAndSendTransaction(transaction, options); - return signature; - } - } catch (error: any) { - this.emit('error', error); - throw error; - } - - return await super.sendTransaction(transaction, connection, options); - } - async signTransaction(transaction: Transaction): Promise { try { const wallet = this._wallet; @@ -244,7 +191,7 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { if (!wallet) throw new WalletNotConnectedError(); try { - const { signature } = await wallet.signMessage(message); + const {signature} = await wallet.signMessage(message); return signature; } catch (error: any) { throw new WalletSignTransactionError(error?.message, error); From b1c3f5ea3c1f85ca0351fd413a0e6e015570f47d Mon Sep 17 00:00:00 2001 From: David Mohl Date: Thu, 23 Jun 2022 14:26:28 +0900 Subject: [PATCH 07/13] Remove saifu from react-ui-starter --- packages/starter/react-ui-starter/src/App.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/starter/react-ui-starter/src/App.tsx b/packages/starter/react-ui-starter/src/App.tsx index 4b739e61a..1afead7d8 100644 --- a/packages/starter/react-ui-starter/src/App.tsx +++ b/packages/starter/react-ui-starter/src/App.tsx @@ -8,7 +8,6 @@ import { SlopeWalletAdapter, SolflareWalletAdapter, TorusWalletAdapter, - SaifuWalletAdapter, } from '@solana/wallet-adapter-wallets'; import { clusterApiUrl } from '@solana/web3.js'; import React, { FC, ReactNode, useMemo } from 'react'; @@ -42,7 +41,6 @@ const Context: FC<{ children: ReactNode }> = ({ children }) => { new SlopeWalletAdapter(), new SolflareWalletAdapter({ network }), new TorusWalletAdapter(), - new SaifuWalletAdapter(), ], [network] ); From 1c0351a62c12977aec629abbac557a1856b4c419 Mon Sep 17 00:00:00 2001 From: David Mohl Date: Thu, 23 Jun 2022 16:04:49 +0900 Subject: [PATCH 08/13] Re-add 'connect' event binding --- packages/wallets/saifu/src/adapter.ts | 32 ++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/wallets/saifu/src/adapter.ts b/packages/wallets/saifu/src/adapter.ts index 5cd28574e..d3abf2bd6 100644 --- a/packages/wallets/saifu/src/adapter.ts +++ b/packages/wallets/saifu/src/adapter.ts @@ -6,12 +6,14 @@ import { WalletConnectionError, WalletDisconnectedError, WalletDisconnectionError, + WalletError, WalletName, WalletNotConnectedError, WalletNotReadyError, WalletPublicKeyError, WalletReadyState, WalletSignTransactionError, + WalletWindowClosedError, } from '@solana/wallet-adapter-base'; import {PublicKey, SendOptions, Transaction, TransactionSignature} from '@solana/web3.js'; @@ -106,8 +108,36 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { if (!wallet?.isConnected) { try { - await wallet.connect() + // connection flow: + // 1. Bind 'connect' for post auth + // 2. Call wallet.connect() + // 3. Wallet with authorize the user and emit 'connect' + // 4. 'connect' will resolve the full promise + await new Promise((resolve, reject) => { + + // connect will get called post auth + // resolving this promise will unblock the outer part + // so this should happen last + const connect = () => { + wallet.off('connect', connect); + resolve(); + }; + + wallet._handleDisconnect = (...args: unknown[]) => { + wallet.off('connect', connect); + reject(new WalletWindowClosedError()); + }; + + // saifu will emit 'connect' once connection has been established + wallet.on('connect', connect); + + wallet.connect().catch((reason: any) => { + wallet.off('connect', connect); + reject(reason); + }); + }); } catch (error: any) { + if (error instanceof WalletError) throw error; throw new WalletConnectionError(error?.message, error); } } From 57957e6ec63ae7316857bd83204fae700d7f2b79 Mon Sep 17 00:00:00 2001 From: David Mohl Date: Sat, 25 Jun 2022 10:55:08 +0900 Subject: [PATCH 09/13] Remove wallet._handleDisconnect override --- packages/wallets/saifu/src/adapter.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/wallets/saifu/src/adapter.ts b/packages/wallets/saifu/src/adapter.ts index d3abf2bd6..430529ae3 100644 --- a/packages/wallets/saifu/src/adapter.ts +++ b/packages/wallets/saifu/src/adapter.ts @@ -123,11 +123,6 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { resolve(); }; - wallet._handleDisconnect = (...args: unknown[]) => { - wallet.off('connect', connect); - reject(new WalletWindowClosedError()); - }; - // saifu will emit 'connect' once connection has been established wallet.on('connect', connect); From 937a66310391bc90d5624560f10e1a865e1dfcf6 Mon Sep 17 00:00:00 2001 From: David Mohl Date: Sat, 25 Jun 2022 11:19:03 +0900 Subject: [PATCH 10/13] Re-add sendTransaction Will fallback to parent behavior when not present in object yet --- packages/wallets/saifu/src/adapter.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/wallets/saifu/src/adapter.ts b/packages/wallets/saifu/src/adapter.ts index 430529ae3..21f4457ef 100644 --- a/packages/wallets/saifu/src/adapter.ts +++ b/packages/wallets/saifu/src/adapter.ts @@ -2,6 +2,7 @@ import { BaseMessageSignerWalletAdapter, EventEmitter, scopePollingDetectionStrategy, + SendTransactionOptions, WalletAccountError, WalletConnectionError, WalletDisconnectedError, @@ -15,7 +16,7 @@ import { WalletSignTransactionError, WalletWindowClosedError, } from '@solana/wallet-adapter-base'; -import {PublicKey, SendOptions, Transaction, TransactionSignature} from '@solana/web3.js'; +import {Connection, PublicKey, SendOptions, Transaction, TransactionSignature} from '@solana/web3.js'; interface SaifuWalletEvents { connect(...args: unknown[]): unknown; @@ -178,6 +179,28 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { this.emit('disconnect'); } + async sendTransaction( + transaction: Transaction, + connection: Connection, + options: SendTransactionOptions = {} + ): Promise { + try { + const wallet = this._wallet; + if (!wallet) throw new WalletNotConnectedError(); + + // fallback to parent if not implemented yet + if (!('signAndSendTransaction' in wallet)) { + return super.sendTransaction(transaction, connection, options); + } + + const { signature } = await wallet.signAndSendTransaction(transaction, options); + return signature; + } catch (error: any) { + this.emit('error', error); + throw error; + } + } + async signTransaction(transaction: Transaction): Promise { try { const wallet = this._wallet; From b7f3c077a7739bc57e3bf425585312b48b527716 Mon Sep 17 00:00:00 2001 From: David Mohl Date: Tue, 28 Jun 2022 11:17:03 +0900 Subject: [PATCH 11/13] Fix nits - formatting, order, whitespace --- packages/wallets/saifu/package.json | 3 +-- packages/wallets/saifu/src/adapter.ts | 17 ++++++----------- packages/wallets/wallets/package.json | 4 ++-- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/packages/wallets/saifu/package.json b/packages/wallets/saifu/package.json index 0b83899f8..7c9464e66 100644 --- a/packages/wallets/saifu/package.json +++ b/packages/wallets/saifu/package.json @@ -30,8 +30,7 @@ "@solana/web3.js": "^1.36.0" }, "dependencies": { - "@solana/wallet-adapter-base": "^0.9.4", - "@solflare-wallet/sdk": "^1.0.11" + "@solana/wallet-adapter-base": "^0.9.4" }, "devDependencies": { "@solana/web3.js": "^1.36.0" diff --git a/packages/wallets/saifu/src/adapter.ts b/packages/wallets/saifu/src/adapter.ts index 21f4457ef..f4e6ea156 100644 --- a/packages/wallets/saifu/src/adapter.ts +++ b/packages/wallets/saifu/src/adapter.ts @@ -16,7 +16,7 @@ import { WalletSignTransactionError, WalletWindowClosedError, } from '@solana/wallet-adapter-base'; -import {Connection, PublicKey, SendOptions, Transaction, TransactionSignature} from '@solana/web3.js'; +import { Connection, PublicKey, SendOptions, Transaction, TransactionSignature } from '@solana/web3.js'; interface SaifuWalletEvents { connect(...args: unknown[]): unknown; @@ -29,14 +29,13 @@ interface SaifuWallet extends EventEmitter { isConnected: boolean; signTransaction(transaction: Transaction): Promise; signAllTransactions(transactions: Transaction[]): Promise; - signAndSendTransaction( + signAndSendTransaction?( transaction: Transaction, options?: SendOptions ): Promise<{ signature: TransactionSignature }>; signMessage(message: Uint8Array): Promise<{ signature: Uint8Array }>; connect(): Promise; disconnect(): Promise; - _handleDisconnect(...args: unknown[]): unknown; } interface SolanaWindow extends Window { @@ -45,16 +44,14 @@ interface SolanaWindow extends Window { declare const window: SolanaWindow; -export interface SaifuWalletAdapterConfig { -} +export interface SaifuWalletAdapterConfig {} export const SaifuWalletName = 'Saifu' as WalletName; export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { name = SaifuWalletName; url = 'https://saifuwallet.com';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OS45OTcyMzYsMzE5Ljk2MDI4NCBDMjIzLjM5NzIzLDMyMS4wMDU4NDYgMjEyLjUxOTc4OCwzMjIuMzM3NjY0IDIwNS44MjUxNDcsMzIyLjkxOTg0OCBDMTk5LjEzMDUwNiwzMjMuNTAyMDYyIDE3OS4xMDU0OTcsMzIzLjkyNjY4NCAxNjEuMzI1MTQ3LDMyMy44NjM0MjEgWiIgaWQ9IlNoYXBlIj48L3BhdGg+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4='; private _connecting: boolean; private _wallet: SaifuWallet | null; @@ -115,7 +112,6 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { // 3. Wallet with authorize the user and emit 'connect' // 4. 'connect' will resolve the full promise await new Promise((resolve, reject) => { - // connect will get called post auth // resolving this promise will unblock the outer part // so this should happen last @@ -133,7 +129,6 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { }); }); } catch (error: any) { - if (error instanceof WalletError) throw error; throw new WalletConnectionError(error?.message, error); } } @@ -189,7 +184,7 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { if (!wallet) throw new WalletNotConnectedError(); // fallback to parent if not implemented yet - if (!('signAndSendTransaction' in wallet)) { + if (!wallet.signAndSendTransaction) { return super.sendTransaction(transaction, connection, options); } @@ -239,7 +234,7 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { if (!wallet) throw new WalletNotConnectedError(); try { - const {signature} = await wallet.signMessage(message); + const { signature } = await wallet.signMessage(message); return signature; } catch (error: any) { throw new WalletSignTransactionError(error?.message, error); diff --git a/packages/wallets/wallets/package.json b/packages/wallets/wallets/package.json index a4a32c3a8..54c4391a0 100644 --- a/packages/wallets/wallets/package.json +++ b/packages/wallets/wallets/package.json @@ -44,13 +44,13 @@ "@solana/wallet-adapter-nightly": "^0.1.0", "@solana/wallet-adapter-phantom": "^0.9.2", "@solana/wallet-adapter-safepal": "^0.5.2", + "@solana/wallet-adapter-saifu": "^0.1.0", "@solana/wallet-adapter-slope": "^0.5.2", "@solana/wallet-adapter-solflare": "^0.6.3", "@solana/wallet-adapter-sollet": "^0.11.0", "@solana/wallet-adapter-solong": "^0.9.2", "@solana/wallet-adapter-tokenpocket": "^0.4.2", "@solana/wallet-adapter-torus": "^0.11.12", - "@solana/wallet-adapter-walletconnect": "^0.1.0", - "@solana/wallet-adapter-saifu": "^0.1.0" + "@solana/wallet-adapter-walletconnect": "^0.1.0" } } From 8a797b573eca499a5fe14e40ba1dee9c0cd5731c Mon Sep 17 00:00:00 2001 From: David Mohl Date: Tue, 28 Jun 2022 12:58:19 +0900 Subject: [PATCH 12/13] Remove event-based logic in favor of promise-only --- packages/wallets/saifu/src/adapter.ts | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/packages/wallets/saifu/src/adapter.ts b/packages/wallets/saifu/src/adapter.ts index f4e6ea156..918d55703 100644 --- a/packages/wallets/saifu/src/adapter.ts +++ b/packages/wallets/saifu/src/adapter.ts @@ -106,28 +106,7 @@ export class SaifuWalletAdapter extends BaseMessageSignerWalletAdapter { if (!wallet?.isConnected) { try { - // connection flow: - // 1. Bind 'connect' for post auth - // 2. Call wallet.connect() - // 3. Wallet with authorize the user and emit 'connect' - // 4. 'connect' will resolve the full promise - await new Promise((resolve, reject) => { - // connect will get called post auth - // resolving this promise will unblock the outer part - // so this should happen last - const connect = () => { - wallet.off('connect', connect); - resolve(); - }; - - // saifu will emit 'connect' once connection has been established - wallet.on('connect', connect); - - wallet.connect().catch((reason: any) => { - wallet.off('connect', connect); - reject(reason); - }); - }); + await wallet.connect(); } catch (error: any) { throw new WalletConnectionError(error?.message, error); } From 38e49132507b33a923fce9332eb4af22c7719ee0 Mon Sep 17 00:00:00 2001 From: David Mohl Date: Tue, 28 Jun 2022 13:03:35 +0900 Subject: [PATCH 13/13] Clean up rebase conflicts --- packages/wallets/wallets/package.json | 3 +-- packages/wallets/wallets/src/index.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/wallets/wallets/package.json b/packages/wallets/wallets/package.json index 54c4391a0..b6587b61f 100644 --- a/packages/wallets/wallets/package.json +++ b/packages/wallets/wallets/package.json @@ -50,7 +50,6 @@ "@solana/wallet-adapter-sollet": "^0.11.0", "@solana/wallet-adapter-solong": "^0.9.2", "@solana/wallet-adapter-tokenpocket": "^0.4.2", - "@solana/wallet-adapter-torus": "^0.11.12", - "@solana/wallet-adapter-walletconnect": "^0.1.0" + "@solana/wallet-adapter-torus": "^0.11.12" } } diff --git a/packages/wallets/wallets/src/index.ts b/packages/wallets/wallets/src/index.ts index 836dc581b..2aa64977c 100644 --- a/packages/wallets/wallets/src/index.ts +++ b/packages/wallets/wallets/src/index.ts @@ -13,11 +13,10 @@ export * from '@solana/wallet-adapter-mathwallet'; export * from '@solana/wallet-adapter-nightly'; export * from '@solana/wallet-adapter-phantom'; export * from '@solana/wallet-adapter-safepal'; +export * from '@solana/wallet-adapter-saifu'; export * from '@solana/wallet-adapter-slope'; export * from '@solana/wallet-adapter-solflare'; export * from '@solana/wallet-adapter-sollet'; export * from '@solana/wallet-adapter-solong'; export * from '@solana/wallet-adapter-tokenpocket'; export * from '@solana/wallet-adapter-torus'; -export * from '@solana/wallet-adapter-walletconnect'; -export * from '@solana/wallet-adapter-saifu';