Skip to content

Commit ebbf21f

Browse files
shoom3301Adamj1232
andauthored
1inch wallet (#779)
* 1inch wallet * Up version due to 1inch wallet integration * Fix lint Co-authored-by: Adam Carpenter <adamcarpenter86@gmail.com>
1 parent b5b6468 commit ebbf21f

File tree

6 files changed

+46
-1
lines changed

6 files changed

+46
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-onboard",
3-
"version": "1.37.1",
3+
"version": "1.37.1-0.0.1",
44
"description": "Onboard users to web3 by allowing them to select a wallet, get that wallet ready to transact and have access to synced wallet state.",
55
"keywords": [
66
"ethereum",

src/modules/select/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const desktopDefaultWalletNames = [
2121
]
2222

2323
const mobileDefaultWalletNames = [
24+
'1inch',
2425
'metamask',
2526
'coinbase',
2627
'trust',
@@ -229,6 +230,8 @@ function getModule(name: string): Promise<{
229230
// return import('./wallets/mewwallet')
230231
case 'mathwallet':
231232
return import('./wallets/mathwallet')
233+
case '1inch':
234+
return import('./wallets/1inch')
232235
case 'blankwallet':
233236
return import('./wallets/blankwallet')
234237
case 'ronin':
6.93 KB
Loading
10.3 KB
Loading

src/modules/select/wallets/1inch.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { mobileWalletInstallMessage } from '../content'
2+
import { WalletModule, Helpers, CommonWalletOptions } from '../../../interfaces'
3+
4+
import oneInchIcon from '../wallet-icons/1inch.png'
5+
import oneInchIcon2x from '../wallet-icons/1inch@2x.png'
6+
7+
function oneInchWallet(options: CommonWalletOptions): WalletModule {
8+
const { preferred, label, iconSrc, svg } = options
9+
10+
return {
11+
name: label || '1inch',
12+
iconSrc: iconSrc || oneInchIcon,
13+
iconSrcSet: iconSrc || oneInchIcon2x,
14+
svg,
15+
wallet: async (helpers: Helpers) => {
16+
const { createModernProviderInterface, getProviderName } = helpers
17+
const windowAsAny = window as any
18+
const provider =
19+
windowAsAny || (windowAsAny.web3 && windowAsAny.web3.currentProvider)
20+
21+
return {
22+
provider,
23+
interface:
24+
provider && getProviderName(provider) === '1inch'
25+
? createModernProviderInterface(provider)
26+
: null
27+
}
28+
},
29+
type: 'injected',
30+
link: `https://wallet.1inch.io?url=${window.location.host}`,
31+
installMessage: mobileWalletInstallMessage,
32+
mobile: true,
33+
preferred,
34+
osExclusions: ['Android']
35+
}
36+
}
37+
38+
export default oneInchWallet

src/utilities.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ export function getProviderName(provider: any): string | undefined {
357357
return 'BlankWallet'
358358
}
359359

360+
if (provider.isOneInchIOSWallet) {
361+
return '1inch'
362+
}
363+
360364
// =====================================
361365
// When adding new wallet place above this metamask check as some providers
362366
// have an isMetaMask property in addition to the wallet's own `is[WalletName]`

0 commit comments

Comments
 (0)