Skip to content

Commit

Permalink
Feat/add SubWallet wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
S2kael committed Aug 10, 2023
1 parent cf2e5f7 commit 88cfd53
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ const injected = injectedModule({
- Fordefi - _Desktop_
- Ronin Wallet - _Desktop & Mobile_
- Coin98 Wallet - _Desktop & Mobile_
- SubWallet - _Desktop & Mobile_

## Build Environments

Expand Down
2 changes: 1 addition & 1 deletion packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@web3-onboard/gas": "^2.1.7",
"@web3-onboard/gnosis": "^2.1.9",
"@web3-onboard/infinity-wallet": "^2.0.3",
"@web3-onboard/injected-wallets": "^2.10.5-alpha.1",
"@web3-onboard/injected-wallets": "^2.10.6-alpha.1",
"@web3-onboard/keepkey": "^2.3.7",
"@web3-onboard/keystone": "^2.3.7",
"@web3-onboard/ledger": "^2.5.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/injected/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/injected-wallets",
"version": "2.10.5-alpha.1",
"version": "2.10.6-alpha.1",
"description": "Injected wallet module for connecting browser extension and mobile wallets to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
"keywords": [
"Ethereum",
Expand Down
3 changes: 2 additions & 1 deletion packages/injected/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ export const WALLET_NAMES: { [key: string]: string } = {
onekey: 'OneKey',
fordefi: 'Fordefi',
roninWallet: 'Ronin Wallet',
coin98wallet:'Coin98 Wallet'
coin98wallet:'Coin98 Wallet',
SubWallet:'SubWallet'
}
22 changes: 22 additions & 0 deletions packages/injected/src/icons/subwallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default `
<svg width="704" height="704" viewBox="0 0 704 704" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_362_8013)">
<rect width="704" height="704" rx="48" fill="url(#paint0_linear_362_8013)"/>
<g clip-path="url(#clip1_362_8013)">
<path d="M512 285.599V218.99L245.286 112L192 139.06L192.281 346.38L391.824 426.727L285.251 472.104V437.013L236.324 417.152L192.281 437.967L192.281 564.94L245.333 592L512 471.688V386.345L272 290.283V232L462.417 308.08L512 285.599Z" fill="white"/>
</g>
</g>
<defs>
<linearGradient id="paint0_linear_362_8013" x1="352" y1="0" x2="352" y2="704" gradientUnits="userSpaceOnUse">
<stop stop-color="#004BFF"/>
<stop offset="1" stop-color="#4CEAAC"/>
</linearGradient>
<clipPath id="clip0_362_8013">
<rect width="704" height="704" rx="16" fill="white"/>
</clipPath>
<clipPath id="clip1_362_8013">
<rect width="320" height="480" fill="white" transform="translate(192 112)"/>
</clipPath>
</defs>
</svg>
`
21 changes: 14 additions & 7 deletions packages/injected/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export enum ProviderIdentityFlag {
Talisman = 'isTalisman',
OneKey = 'isOneKey',
Fordefi = 'isFordefi',
Coin98Wallet = 'isCoin98'
Coin98Wallet = 'isCoin98',
SubWallet = 'isSubWallet',
}


Expand All @@ -88,7 +89,8 @@ export enum ProviderExternalUrl {
Trust = 'https://trustwallet.com/download/',
OneKey = 'https://onekey.so/download/',
RoninWallet = 'https://wallet.skymavis.com/',
Coin98Wallet = 'https://coin98.com/wallet/'
Coin98Wallet = 'https://coin98.com/wallet/',
SubWallet = 'https://www.subwallet.app/',
}

export enum ProviderLabel {
Expand Down Expand Up @@ -145,7 +147,8 @@ export enum ProviderLabel {
OneKey = 'OneKey',
Fordefi = 'Fordefi',
RoninWallet = 'Ronin Wallet',
Coin98Wallet = 'Coin98 Wallet'
Coin98Wallet = 'Coin98 Wallet',
SubWallet = 'SubWallet',
}

export interface MeetOneProvider extends ExternalProvider {
Expand Down Expand Up @@ -180,7 +183,8 @@ export enum InjectedNameSpace {
Talisman = 'talismanEth',
OneKey = '$onekey',
RoninWallet = 'ronin',
Coin98Wallet = 'coin98'
Coin98Wallet = 'coin98',
SubWallet = 'SubWallet'
}

export interface CustomWindow extends Window {
Expand Down Expand Up @@ -223,9 +227,12 @@ export interface CustomWindow extends Window {
ronin: {
provider: InjectedProvider
}
coin98: {
provider: InjectedProvider
}
coin98: {
provider: InjectedProvider
},
SubWallet: {
provider: InjectedProvider
},
}

export type InjectedProvider = ExternalProvider &
Expand Down
16 changes: 15 additions & 1 deletion packages/injected/src/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,19 @@ const coin98wallet: InjectedWalletModule = {
externalUrl: ProviderExternalUrl.Coin98Wallet
}

const subwallet: InjectedWalletModule = {
label: ProviderLabel.SubWallet,
injectedNamespace: InjectedNameSpace.SubWallet,
checkProviderIdentity: ({ provider }) =>
!!provider && !!provider[ProviderIdentityFlag.SubWallet],
getIcon: async () => (await import('./icons/subwallet.js')).default,
getInterface: async () => ({
provider: createEIP1193Provider(window.SubWallet)
}),
platforms: ['all'],
externalUrl: ProviderExternalUrl.SubWallet
}

const wallets = [
zeal,
exodus,
Expand Down Expand Up @@ -906,7 +919,8 @@ const wallets = [
onekey,
fordefi,
ronin,
coin98wallet
coin98wallet,
subwallet
]

export default wallets

0 comments on commit 88cfd53

Please sign in to comment.