-
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 tomo wallet extension
- Loading branch information
1 parent
e854945
commit 9f0f065
Showing
12 changed files
with
137 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,5 +33,6 @@ declare global { | |
bitkeep: any; | ||
mytonwallet: any; | ||
offlineSigner: any; | ||
tomo_evm: any; | ||
} | ||
} |
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-tomo", | ||
"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-tomo", | ||
"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.0", | ||
"rango-types": "^0.1.69" | ||
}, | ||
"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-tomo |
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,8 @@ | ||
export function tomo() { | ||
const { tomo_evm } = window; | ||
if (tomo_evm) { | ||
return tomo_evm; | ||
} | ||
|
||
return 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,67 @@ | ||
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 { tomo as tomo_instance } from './helpers'; | ||
import signer from './signer'; | ||
|
||
const WALLET = WalletTypes.TOMO; | ||
|
||
export const config = { | ||
type: WALLET, | ||
}; | ||
|
||
export const getInstance = tomo_instance; | ||
export const connect: Connect = async ({ instance }) => { | ||
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: 'Tomo', | ||
img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/tomo/icon.svg', | ||
color: '#b2dbff', | ||
installLink: { | ||
CHROME: | ||
'https://chromewebstore.google.com/detail/tomo-wallet/pfccjkejcgoppjnllalolplgogenfojk?hl=en', | ||
BRAVE: | ||
'https://chromewebstore.google.com/detail/tomo-wallet/pfccjkejcgoppjnllalolplgogenfojk?hl=en', | ||
DEFAULT: 'https://tomo.inc/', | ||
}, | ||
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,12 @@ | ||
import type { SignerFactory } from 'rango-types'; | ||
|
||
import { DefaultEvmSigner } from '@rango-dev/signer-evm'; | ||
import { getNetworkInstance, Networks } from '@rango-dev/wallets-shared'; | ||
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types'; | ||
|
||
export default function getSigners(provider: any): SignerFactory { | ||
const ethProvider = getNetworkInstance(provider, Networks.ETHEREUM); | ||
const signers = new DefaultSignerFactory(); | ||
signers.registerSigner(TxType.EVM, new DefaultEvmSigner(ethProvider)); | ||
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