Skip to content

Commit

Permalink
Merge pull request #85 from eco-stake/improve-keplr-mobile-integration
Browse files Browse the repository at this point in the history
Improve Keplr mobile integration
  • Loading branch information
tombeynon authored Feb 13, 2024
2 parents 2410d9e + f5a23df commit 8058012
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
28 changes: 14 additions & 14 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,20 @@ class App extends React.Component {
new KeplrSignerProvider(window.keplr),
new LeapSignerProvider(window.leap),
new CosmostationSignerProvider(window.cosmostation?.providers?.keplr, window.cosmostation?.cosmos),
new KeplrMobileSignerProvider({
connectModal: {
open: (uri, callback) => {
this.setState({
connectWallet: true,
qrCodeUri: uri || this.state.qrCodeUri,
qrCodeCallback: callback || this.state.qrCodeCallback
})
},
close: () => {
this.setState({ connectWallet: false })
}
}
}),
// new KeplrMobileSignerProvider({
// connectModal: {
// open: (uri, callback) => {
// this.setState({
// connectWallet: true,
// qrCodeUri: uri || this.state.qrCodeUri,
// qrCodeCallback: callback || this.state.qrCodeCallback
// })
// },
// close: () => {
// this.setState({ connectWallet: false })
// }
// }
// }),
// new FalconSignerProvider(window.falcon)
]
this.signerConnectors = {}
Expand Down
18 changes: 17 additions & 1 deletion src/utils/KeplrSignerProvider.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import _ from 'lodash'
import SignerProvider from "./SignerProvider.mjs"
import {
isMobile,
} from "@walletconnect/browser-utils";

export default class KeplrSignerProvider extends SignerProvider {
name = 'keplr'
label = 'Keplr Extension'
label = 'Keplr Wallet'
keychangeEvent = 'keplr_keystorechange'

async connect(network) {
if(this.provider){
return super.connect(network)
}else if(isMobile()){
window.location.href = 'keplrwallet://';
throw new Error('Please use the in-app browser to access REStake.')
}
}

available() {
return !!this.provider || isMobile()
}

enable(network){
this.setOptions({
sign: { preferNoSetFee: true }
Expand Down

0 comments on commit 8058012

Please sign in to comment.