Skip to content

Commit b31ace8

Browse files
authored
Merge pull request #226 from chaitanyapotti/master
- Update Torus Version - add support for enabled verifiers
2 parents 5887938 + 6ec3b3f commit b31ace8

File tree

6 files changed

+51
-311
lines changed

6 files changed

+51
-311
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@ledgerhq/hw-app-eth": "^5.7.0",
4343
"@ledgerhq/hw-transport-u2f": "^5.7.0",
4444
"@portis/web3": "^2.0.0-beta.42",
45-
"@toruslabs/torus-embed": "^0.2.11",
45+
"@toruslabs/torus-embed": "^1.1.1",
4646
"@walletconnect/web3-provider": "^1.0.0-beta.45",
4747
"authereum": "^0.0.4-beta.88",
4848
"bignumber.js": "^9.0.0",

src/interfaces.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,16 @@ export interface TorusOptions {
158158
showTorusButton?: boolean
159159
buttonPosition?: 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left'
160160
enableLogging?: boolean
161+
enabledVerifiers: TorusVerifierStatus
162+
}
163+
164+
165+
interface TorusVerifierStatus {
166+
google?: boolean;
167+
facebook?: boolean;
168+
reddit?: boolean;
169+
twitch?: boolean;
170+
discord?: boolean;
161171
}
162172

163173
export interface AuthereumOptions {

src/modules/select/wallets/torus.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ function torus(options: TorusOptions & CommonWalletOptions): WalletModule {
1818
buttonPosition,
1919
enableLogging,
2020
loginMethod,
21-
showTorusButton
21+
showTorusButton,
22+
enabledVerifiers
2223
} = options
2324

2425
return {
@@ -39,7 +40,8 @@ function torus(options: TorusOptions & CommonWalletOptions): WalletModule {
3940
chainId: networkId, // default: 1
4041
networkName: `${networkName(networkId)} Network` // default: Main Ethereum Network
4142
},
42-
showTorusButton: showTorusButton // default: true
43+
showTorusButton: showTorusButton, // default: true
44+
enabledVerifiers: enabledVerifiers
4345
})
4446

4547
const provider = instance.provider

src/utilities.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ export function createLegacyProviderInterface(provider: any): WalletInterface {
153153
export function getProviderName(provider: any): string | undefined {
154154
if (!provider) return
155155

156+
// Torus also exports isMetamask to be true for backward compatibility
157+
if (provider.isTorus) {
158+
return 'Torus'
159+
}
160+
156161
if (provider.isMetaMask) {
157162
return 'MetaMask'
158163
}
@@ -177,10 +182,6 @@ export function getProviderName(provider: any): string | undefined {
177182
return 'Toshi'
178183
}
179184

180-
if (provider.isTorus) {
181-
return 'Torus'
182-
}
183-
184185
if (provider.isCipher) {
185186
return 'Cipher'
186187
}

src/validation.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ export function validateWalletInit(
532532
enableLogging,
533533
loginMethod,
534534
showTorusButton,
535+
enabledVerifiers,
535536
disableNotifications,
536537
...otherParams
537538
} = walletInit
@@ -554,7 +555,8 @@ export function validateWalletInit(
554555
'buttonPosition',
555556
'enableLogging',
556557
'loginMethod',
557-
'showTorusButton'
558+
'showTorusButton',
559+
'enabledVerifiers'
558560
],
559561
'walletInitObject'
560562
)
@@ -658,6 +660,14 @@ export function validateWalletInit(
658660
optional: true
659661
})
660662

663+
664+
validateType({
665+
name: 'walletInit.enabledVerifiers',
666+
value: enabledVerifiers,
667+
type: 'object',
668+
optional: true
669+
})
670+
661671
validateType({
662672
name: 'walletInit.buttonPosition',
663673
value: buttonPosition,

0 commit comments

Comments
 (0)