From 85ac83ce4ff0c9eca1482a343ebf707335842b66 Mon Sep 17 00:00:00 2001 From: envin Date: Tue, 12 Mar 2024 20:50:07 +0100 Subject: [PATCH] feat(algorand): remove unsupported wallets --- .changeset/curvy-starfishes-draw.md | 5 +++ .../algoWalletModal/connectors/algo-signer.js | 45 ------------------- .../connectors/my-algo-wallet.js | 40 ----------------- src/lib/algoWalletModal/index.jsx | 44 ++---------------- src/store/wallets/algorand/index.js | 9 +--- 5 files changed, 11 insertions(+), 132 deletions(-) create mode 100644 .changeset/curvy-starfishes-draw.md delete mode 100644 src/lib/algoWalletModal/connectors/algo-signer.js delete mode 100644 src/lib/algoWalletModal/connectors/my-algo-wallet.js diff --git a/.changeset/curvy-starfishes-draw.md b/.changeset/curvy-starfishes-draw.md new file mode 100644 index 00000000..b5b1f16d --- /dev/null +++ b/.changeset/curvy-starfishes-draw.md @@ -0,0 +1,5 @@ +--- +'ptokens-dapp-v2': minor +--- + +Update Algorand explorer and supported wallets diff --git a/src/lib/algoWalletModal/connectors/algo-signer.js b/src/lib/algoWalletModal/connectors/algo-signer.js deleted file mode 100644 index f63097ed..00000000 --- a/src/lib/algoWalletModal/connectors/algo-signer.js +++ /dev/null @@ -1,45 +0,0 @@ -import { EventEmitter } from 'eventemitter3' -import algosdk from 'algosdk' - -class Provider extends EventEmitter { - constructor(_algoSigner) { - super() - this.algoSigner = _algoSigner - this.type = 'AlgoSigner' - } - - close() { - return - } - - signTxn(_txns) { - return this.algoSigner.signTxn( - _txns.map((_tx) => ({ txn: Buffer.from(algosdk.encodeUnsignedTransaction(_tx)).toString('base64') })) - ) - } - - sign(_tx) { - return this.algoSigner.sign(_tx) - } - - async getAccounts() { - return Object.values( - await this.algoSigner.accounts({ - ledger: 'MainNet', - }) - ).map(({ address }) => address) - } -} - -const ConnectToAlgoSigner = async () => { - if (typeof window.AlgoSigner === 'undefined') { - throw new Error('AlgoSigner not installed') - } - - await window.AlgoSigner.connect() - - const provider = new Provider(window.AlgoSigner) - return provider -} - -export default ConnectToAlgoSigner diff --git a/src/lib/algoWalletModal/connectors/my-algo-wallet.js b/src/lib/algoWalletModal/connectors/my-algo-wallet.js deleted file mode 100644 index 4994611d..00000000 --- a/src/lib/algoWalletModal/connectors/my-algo-wallet.js +++ /dev/null @@ -1,40 +0,0 @@ -import { EventEmitter } from 'eventemitter3' -import MyAlgoConnect from '@randlabs/myalgo-connect' - -class Provider extends EventEmitter { - constructor(myAlgoConnect, accountsSharedByUser) { - super() - this.myAlgoConnect = myAlgoConnect - this.accountsSharedByUser = accountsSharedByUser - this.type = 'MyAlgo' - } - - close() { - return - } - - signTxn(_txns) { - return this.myAlgoConnect.signTransaction(_txns.map((_tx) => _tx.toByte())) - } - - sign(_tx) { - return this.myAlgoConnect.signTransaction(_tx) - } - - async getAccounts() { - return this.accountsSharedByUser.map((_el) => _el.address) - } -} - -const ConnectToMyAlgoWallet = async () => { - const myAlgoConnect = new MyAlgoConnect() - try { - const accountsSharedByUser = await myAlgoConnect.connect() - const provider = new Provider(myAlgoConnect, accountsSharedByUser) - return provider - } catch (err) { - console.error(err) - } -} - -export default ConnectToMyAlgoWallet diff --git a/src/lib/algoWalletModal/index.jsx b/src/lib/algoWalletModal/index.jsx index a5a72cf0..7f313791 100644 --- a/src/lib/algoWalletModal/index.jsx +++ b/src/lib/algoWalletModal/index.jsx @@ -1,12 +1,11 @@ +import EventEmitter from 'eventemitter3' import * as React from 'react' import * as ReactDOM from 'react-dom' + import Modal from '../eosConnect/components/Modal' -import EventEmitter from 'eventemitter3' -import connectToWalletConnect from './connectors/wallet-connect' -import connectToAlgoSigner from './connectors/algo-signer' -import connectToMyAlgoWallet from './connectors/my-algo-wallet' -import connectToPeraWallet from './connectors/pera-wallet' + import connectToDeflyWallet from './connectors/defly-wallet' +import connectToPeraWallet from './connectors/pera-wallet' const INITIAL_STATE = { show: false } @@ -46,28 +45,6 @@ class AlgoWalletModal extends EventEmitter { setConfigs = ({ dappName, providerOptions: { algoSigner, walletConnect, myAlgoWallet } }) => { this.userOptions = [] - this.userOptions.push({ - name: 'AlgoSigner', - logo: './assets/jpeg/algosigner.jpeg', - description: 'Connect to AlgoSigner', - themeColors: this.themeColors, - onClick: async () => { - this._call.resolve(await connectToAlgoSigner()) - await this.toogleModal() - }, - }) - - this.userOptions.push({ - name: 'MyAlgoWallet', - logo: './assets/png/myalgo-logo.png', - description: 'Connect to MyAlgoWallet', - themeColors: this.themeColors, - onClick: async () => { - this._call.resolve(await connectToMyAlgoWallet(walletConnect)) - await this.toogleModal() - }, - }) - this.userOptions.push({ name: 'Pera Wallet', logo: './assets/png/pera-wallet-logo.png', @@ -90,19 +67,6 @@ class AlgoWalletModal extends EventEmitter { }, }) - if (walletConnect) { - this.userOptions.push({ - name: 'WalletConnect', - logo: './assets/svg/wallet-connect.svg', - description: 'Scan with WalletConnect to connect', - themeColors: this.themeColors, - onClick: async () => { - this._call.resolve(await connectToWalletConnect(walletConnect)) - await this.toogleModal() - }, - }) - } - this.renderModal() } diff --git a/src/store/wallets/algorand/index.js b/src/store/wallets/algorand/index.js index b4eab07b..4a45cfb9 100644 --- a/src/store/wallets/algorand/index.js +++ b/src/store/wallets/algorand/index.js @@ -3,9 +3,8 @@ import { WALLET_ALGORAND_DISCONNECTED, WALLET_ALGORAND_ACCOUNT_CHANGED, } from '../../../constants' - -import settings from '../../../settings' import AlgoWalletModal from '../../../lib/algoWalletModal' +import settings from '../../../settings' import { getWeb3ModalTheme } from '../../../theme/web3-modal' import { getTheme } from '../../pages/pages.selectors' import { getWalletProviderByBlockchain } from '../wallets.selectors' @@ -18,11 +17,7 @@ const connectWithAlgorandWallet = async (_dispatch) => { const algoWalletModal = new AlgoWalletModal({ dappName: settings.dappName, theme: getWeb3ModalTheme(getTheme()), - providerOptions: { - walletConnect: { - bridge: 'https://bridge.walletconnect.org', - }, - }, + providerOptions: {}, }) try {