Skip to content

Commit f460165

Browse files
authored
Merge pull request #470 from chaitanyapotti/master
Fix Torus integration
2 parents 140db9a + a07c667 commit f460165

File tree

4 files changed

+494
-233
lines changed

4 files changed

+494
-233
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@ledgerhq/hw-app-eth": "^5.21.0",
4949
"@ledgerhq/hw-transport-u2f": "^5.21.0",
5050
"@portis/web3": "^2.0.0-beta.57",
51-
"@toruslabs/torus-embed": "1.8.2",
51+
"@toruslabs/torus-embed": "^1.9.2",
5252
"@unilogin/provider": "^0.6.1",
5353
"@walletconnect/web3-provider": "^1.3.1",
5454
"authereum": "^0.1.12",

src/interfaces.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ interface LocaleLinks<T> {
274274
ja?: T
275275
ko?: T
276276
de?: T
277-
zh?: T
277+
zh?: T,
278+
es?: T,
278279
}
279280

280281
interface ThemeParams {
@@ -283,15 +284,19 @@ interface ThemeParams {
283284
}
284285

285286
interface LoginConfigItem {
286-
name?: string
287+
name: string
287288
typeOfLogin: LOGIN_TYPE
288289
description?: string
289290
clientId?: string
290291
logoHover?: string
291292
logoLight?: string
292293
logoDark?: string
293294
showOnModal?: boolean
295+
showOnMobile?: boolean
296+
showOnDesktop?: boolean
297+
mainOption?: boolean
294298
jwtParameters?: JwtParameters
299+
priority?: number
295300
}
296301

297302
interface LoginConfig {
@@ -302,7 +307,7 @@ export interface TorusOptions extends CommonWalletOptions {
302307
buttonPosition?: 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left'
303308
modalZIndex?: number
304309
apiKey?: string
305-
buildEnv?: 'production' | 'development' | 'staging' | 'testing' | 'lrc'
310+
buildEnv?: 'production' | 'development' | 'binance' | 'testing' | 'lrc' | 'beta'
306311
enableLogging?: boolean
307312
enabledVerifiers?: VerifierStatus
308313
loginConfig?: LoginConfig

src/modules/select/wallets/torus.ts

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { networkName } from '../../../utilities'
2-
import { TorusOptions, WalletModule } from '../../../interfaces'
2+
import { Helpers, TorusOptions, WalletModule } from '../../../interfaces'
33

44
import torusIcon from '../wallet-icons/icon-torus'
55

@@ -27,7 +27,11 @@ function torus(options: TorusOptions & { networkId: number }): WalletModule {
2727
name: label || 'Torus',
2828
svg: svg || torusIcon,
2929
iconSrc,
30-
wallet: async () => {
30+
wallet: async (helpers: Helpers) => {
31+
const {
32+
createModernProviderInterface
33+
} = helpers
34+
3135
const { default: Torus } = await import('@toruslabs/torus-embed')
3236
const instance = new Torus({
3337
buttonPosition, // default: bottom-left
@@ -54,37 +58,17 @@ function torus(options: TorusOptions & { networkId: number }): WalletModule {
5458

5559
return {
5660
provider,
57-
instance,
5861
interface: {
62+
...createModernProviderInterface(provider),
5963
name: 'Torus',
64+
dashboard: () => instance.showWallet('home'),
6065
connect: async () => {
6166
const result = await instance.login({ verifier: loginMethod })
6267
return { message: result[0] }
6368
},
6469
disconnect: () => instance.cleanUp(),
65-
address: {
66-
get: () => Promise.resolve(instance.web3.eth.accounts[0])
67-
},
68-
network: {
69-
get: () => Promise.resolve(Number(instance.web3.version.network))
70-
},
71-
balance: {
72-
get: () =>
73-
new Promise(async (resolve, reject) => {
74-
instance.web3.eth.getBalance(
75-
instance.web3.eth.accounts[0],
76-
(err: any, data: any) => {
77-
if (err) {
78-
reject(`Error while checking Balance: ${err}`)
79-
} else {
80-
resolve(data.toString(10))
81-
}
82-
}
83-
)
84-
})
85-
},
86-
dashboard: () => instance.showWallet('home')
87-
}
70+
},
71+
instance
8872
}
8973
},
9074
type: 'sdk',

0 commit comments

Comments
 (0)