Skip to content

Commit

Permalink
Bugfix/rainbowkit buffer (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
nigeon authored Sep 18, 2023
1 parent 449d926 commit 32b86e3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
7 changes: 5 additions & 2 deletions packages/rainbowkit-wallets/src/lib/oAuthWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ import localStorageWallet from './localStorageWallet'
*/
export class oAuthWallet extends localStorageWallet {
private oAuthServiceUrl: string
private oAuthServiceProvider: string
private data: any
private cancel: boolean = false

constructor(oAuthServiceUrl: string) {
constructor(oAuthServiceUrl: string, oAuthServiceProvider: string) {
super()
this.oAuthServiceUrl = oAuthServiceUrl
this.oAuthServiceProvider = oAuthServiceProvider
}

async create(): Promise<ethers.Wallet> {
// Open the login popup
this.openLoginPopup(this.oAuthServiceUrl)
const url = this.oAuthServiceUrl + (this.oAuthServiceProvider ? `?provider=${this.oAuthServiceProvider}` : '')
this.openLoginPopup(url)

// Create the event listener to receive the seed from the popup
window.addEventListener('message', this.handlePopupMessage.bind(this))
Expand Down
4 changes: 2 additions & 2 deletions packages/rainbowkit-wallets/src/oAuthWallet.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { oAuthConnector } from './wagmi/oAuthConnector'

export const oAuthWallet = ({ chains, name, options }: any) => ({
export const oAuthWallet = ({ chains, name, iconUrl, options }: any) => ({
id: 'oAuth',
name: name || 'OAuth',
iconUrl: 'https://i.ibb.co/Mh7LXsn/social-login-COLOR-2.png',
iconUrl: iconUrl || 'https://i.ibb.co/Mh7LXsn/social-login-COLOR-2.png',
iconBackground: '#fff',
createConnector: () => {
const connector = new oAuthConnector({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class localStorageConnector extends Connector {
}

async disconnect(): Promise<void> {
this.wallet = undefined
localStorageWallet.deleteWallet()
}

Expand Down
5 changes: 4 additions & 1 deletion packages/rainbowkit-wallets/src/wagmi/oAuthConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ export class oAuthConnector extends localStorageConnector {
readonly name = 'OAuth'

private oAuthServiceUrl: string = ''
private oAuthServiceProvider: string = ''

constructor(config: { chains: Chain[]; options: any }) {
super(config)

if (!config.options.oAuthServiceUrl) throw new Error('oAuthServiceUrl is required')
this.oAuthServiceUrl = config.options.oAuthServiceUrl

if (config.options.oAuthServiceProvider) this.oAuthServiceProvider = config.options.oAuthServiceProvider
}

protected async createWallet() {
let wallet = await oAuthWallet.getWallet()
if (!wallet) {
const w = new oAuthWallet(this.oAuthServiceUrl)
const w = new oAuthWallet(this.oAuthServiceUrl, this.oAuthServiceProvider)
wallet = await w.create()
}

Expand Down

0 comments on commit 32b86e3

Please sign in to comment.