-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: integrate rabby wallet extension
- Loading branch information
1 parent
753b1e6
commit 145fb8f
Showing
12 changed files
with
162 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "@rango-dev/provider-rabby", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
"type": "module", | ||
"source": "./src/index.ts", | ||
"main": "./dist/index.js", | ||
"exports": { | ||
".": "./dist/index.js" | ||
}, | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"scripts": { | ||
"build": "node ../../scripts/build/command.mjs --path wallets/provider-rabby", | ||
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json", | ||
"clean": "rimraf dist", | ||
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'", | ||
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore" | ||
}, | ||
"dependencies": { | ||
"@rango-dev/signer-evm": "^0.27.2-next.0", | ||
"@rango-dev/wallets-shared": "^0.34.1-next.1", | ||
"rango-types": "^0.1.59" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @rango-dev/provider-rabby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export function rabby() { | ||
const { ethereum } = window; | ||
|
||
return ethereum?.isRabby ? ethereum : null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import type { | ||
CanEagerConnect, | ||
CanSwitchNetwork, | ||
Connect, | ||
Subscribe, | ||
SwitchNetwork, | ||
WalletInfo, | ||
} from '@rango-dev/wallets-shared'; | ||
import type { BlockchainMeta, SignerFactory } from 'rango-types'; | ||
|
||
import { | ||
canEagerlyConnectToEvm, | ||
canSwitchNetworkToEvm, | ||
getEvmAccounts, | ||
subscribeToEvm, | ||
switchNetworkForEvm, | ||
WalletTypes, | ||
} from '@rango-dev/wallets-shared'; | ||
import { evmBlockchains } from 'rango-types'; | ||
|
||
import { rabby as rabby_instance } from './helpers'; | ||
import signer from './signer'; | ||
|
||
export const config = { | ||
type: WalletTypes.Rabby, | ||
}; | ||
|
||
export const getInstance = rabby_instance; | ||
export const connect: Connect = async ({ instance }) => { | ||
/* | ||
* Note: We need to get `chainId` here, because for the first time | ||
* after opening the browser, wallet is locked, and don't give us accounts and chainId | ||
* on `check` phase, so `network` will be null. For this case we need to get chainId | ||
* whenever we are requesting accounts. | ||
*/ | ||
const { accounts, chainId } = await getEvmAccounts(instance); | ||
|
||
return { | ||
accounts, | ||
chainId, | ||
}; | ||
}; | ||
|
||
export const subscribe: Subscribe = subscribeToEvm; | ||
|
||
export const switchNetwork: SwitchNetwork = switchNetworkForEvm; | ||
|
||
export const canSwitchNetworkTo: CanSwitchNetwork = canSwitchNetworkToEvm; | ||
|
||
export const getSigners: (provider: any) => SignerFactory = signer; | ||
|
||
export const canEagerConnect: CanEagerConnect = canEagerlyConnectToEvm; | ||
|
||
export const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = ( | ||
allBlockChains | ||
) => { | ||
const evms = evmBlockchains(allBlockChains); | ||
return { | ||
name: 'Rabby', | ||
img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/rabby/icon.svg', | ||
installLink: { | ||
CHROME: | ||
'https://chromewebstore.google.com/detail/rabby-wallet/acmacodkjbdgmoleebolmdjonilkdbch', | ||
DEFAULT: 'https://rabby.io/', | ||
}, | ||
color: '#fff', | ||
supportedChains: evms, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { SignerFactory } from 'rango-types'; | ||
|
||
import { DefaultEvmSigner } from '@rango-dev/signer-evm'; | ||
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types'; | ||
|
||
export default function getSigners(provider: any): SignerFactory { | ||
const signers = new DefaultSignerFactory(); | ||
signers.registerSigner(TxType.EVM, new DefaultEvmSigner(provider)); | ||
return signers; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
// see https://www.typescriptlang.org/tsconfig to better understand tsconfigs | ||
"extends": "../../tsconfig.lib.json", | ||
"include": ["src", "types", "../../global-wallets-env.d.ts"], | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDir": "./src", | ||
"lib": ["dom", "esnext"] | ||
// match output dir to input dir. e.g. dist/index instead of dist/src/index | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters