diff --git a/.circleci/config.yml b/.circleci/config.yml index b9e384ee2..30b2c461c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -303,6 +303,12 @@ jobs: working_directory: ~/web3-onboard-monorepo/packages/sequence steps: - node-build-steps + build-tallyho: + docker: + - image: cimg/node:16.13.1 + working_directory: ~/web3-onboard-monorepo/packages/tallyho + steps: + - node-build-steps # Build staging/Alpha releases build-staging-core: @@ -443,6 +449,12 @@ jobs: working_directory: ~/web3-onboard-monorepo/packages/sequence steps: - node-staging-build-steps + build-staging-tallyho: + docker: + - image: cimg/node:16.13.1 + working_directory: ~/web3-onboard-monorepo/packages/tallyho + steps: + - node-staging-build-steps workflows: version: 2 @@ -585,3 +597,9 @@ workflows: <<: *deploy_production_filters - build-staging-sequence: <<: *deploy_staging_filters + tallyho: + jobs: + - build-tallyho: + <<: *deploy_production_filters + - build-staging-tallyho: + <<: *deploy_staging_filters diff --git a/README.md b/README.md index c387d372a..55f09836c 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,7 @@ For full documentation, check out the README.md for each package: - [MEW](packages/mew/README.md) - [Web3Auth](packages/web3auth/README.md) - [Sequence](packages/sequence/README.md) +- [TallyHo](packages/tallyho/README.md) **Hardware Wallets** diff --git a/packages/demo/package.json b/packages/demo/package.json index f7b03eeb6..dd27261d5 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -37,6 +37,7 @@ "@web3-onboard/sequence": "^2.0.1", "@web3-onboard/torus": "^2.1.2", "@web3-onboard/trezor": "^2.3.0", + "@web3-onboard/tallyho": "^2.0.0-alpha.1", "@web3-onboard/walletconnect": "^2.1.2", "@web3-onboard/web3auth": "^2.1.2", "vconsole": "^3.9.5" diff --git a/packages/demo/src/App.svelte b/packages/demo/src/App.svelte index 3e851d7cb..bd9c1da21 100644 --- a/packages/demo/src/App.svelte +++ b/packages/demo/src/App.svelte @@ -16,6 +16,7 @@ import gas from '@web3-onboard/gas' import dcentModule from '@web3-onboard/dcent' import sequenceModule from '@web3-onboard/sequence' + import tallyHoModule from '@web3-onboard/tallyho' import { recoverAddress, arrayify, @@ -84,6 +85,7 @@ const keepkey = keepkeyModule() const keystone = keystoneModule() const gnosis = gnosisModule() + const tallyho = tallyHoModule() const trezorOptions = { email: 'test@test.com', @@ -118,7 +120,8 @@ torus, gnosis, dcent, - sequence + sequence, + tallyho ], gas, chains: [ diff --git a/packages/injected/src/constants.ts b/packages/injected/src/constants.ts index 4d60094ff..35f373164 100644 --- a/packages/injected/src/constants.ts +++ b/packages/injected/src/constants.ts @@ -13,5 +13,5 @@ export const WALLET_NAMES: { [key: string]: string } = { meetone: 'MeetOne', frame: 'Frame', bitkeep: 'BitKeep', - sequence: 'Sequence', + sequence: 'Sequence' } diff --git a/packages/injected/src/icons/gamestop.ts b/packages/injected/src/icons/gamestop.ts index e59687a0b..ee35113da 100644 --- a/packages/injected/src/icons/gamestop.ts +++ b/packages/injected/src/icons/gamestop.ts @@ -4,4 +4,4 @@ export default ` -` \ No newline at end of file +` diff --git a/packages/injected/src/icons/mathwallet.ts b/packages/injected/src/icons/mathwallet.ts index 07e81896a..18974bc9c 100644 --- a/packages/injected/src/icons/mathwallet.ts +++ b/packages/injected/src/icons/mathwallet.ts @@ -44,4 +44,4 @@ export default ` -` \ No newline at end of file +` diff --git a/packages/injected/src/types.ts b/packages/injected/src/types.ts index 24b32adda..12988bd1c 100644 --- a/packages/injected/src/types.ts +++ b/packages/injected/src/types.ts @@ -77,7 +77,7 @@ export enum ProviderLabel { XDEFI = 'XDEFI Wallet', OneInch = '1inch Wallet', Tokenary = 'Tokenary Wallet', - Tally = 'Tally Wallet', + Tally = 'Tally Ho Wallet', Rabby = 'Rabby', MathWallet = 'MathWallet', GameStop = 'GameStop Wallet', @@ -115,7 +115,7 @@ export interface CustomWindow extends Window { xfi: { ethereum: InjectedProvider } - gamestop: InjectedProvider, + gamestop: InjectedProvider bitkeep: { ethereum: InjectedProvider } diff --git a/packages/injected/src/wallets.ts b/packages/injected/src/wallets.ts index 1602a9323..aa15318ab 100644 --- a/packages/injected/src/wallets.ts +++ b/packages/injected/src/wallets.ts @@ -94,8 +94,8 @@ const binance: InjectedWalletModule = { const provider = createEIP1193Provider(window.BinanceChain, { eth_chainId: ({ baseRequest }) => - baseRequest({ method: 'eth_chainId' }).then(id => - `0x${parseInt(id as string).toString(16)}` + baseRequest({ method: 'eth_chainId' }).then( + id => `0x${parseInt(id as string).toString(16)}` ), // Unsupported method -- will throw error eth_selectAccounts: UNSUPPORTED_METHOD, @@ -512,10 +512,10 @@ const bitkeep: InjectedWalletModule = { label: ProviderLabel.BitKeep, injectedNamespace: InjectedNameSpace.BitKeep, checkProviderIdentity: ({ provider }) => - !!provider && !!provider["ethereum"][ProviderIdentityFlag.BitKeep], + !!provider && !!provider['ethereum'][ProviderIdentityFlag.BitKeep], getIcon: async () => (await import('./icons/bitkeep.js')).default, getInterface: async () => ({ - provider: window.bitkeep && window.bitkeep.ethereum, + provider: window.bitkeep && window.bitkeep.ethereum }), platforms: ['all'] } diff --git a/packages/tallyho/README.json b/packages/tallyho/README.json new file mode 100644 index 000000000..928c58cf5 --- /dev/null +++ b/packages/tallyho/README.json @@ -0,0 +1,30 @@ +# @web3-onboard/tallyho + +## Wallet module for connecting Tally Ho Wallet to web3-onboard +See [Tally Ho Wallet Developer Docs](https://docs.tally.cash/tally/developers/integrating-dapps) + +### Install + +`npm i @web3-onboard/tallyho` + + +## Usage + +```typescript +import Onboard from '@web3-onboard/core' +import tallyHoWalletModule from '@web3-onboard/tallyho' + +// initialize the module with options +const talltHoWalletSdk = tallyHoWalletModule() + +const onboard = Onboard({ + // ... other Onboard options + wallets: [ + tallyHoWalletModule() + //... other wallets + ] +}) + +const connectedWallets = await onboard.connectWallet() +console.log(connectedWallets) +``` diff --git a/packages/tallyho/package.json b/packages/tallyho/package.json new file mode 100644 index 000000000..9ef2aac77 --- /dev/null +++ b/packages/tallyho/package.json @@ -0,0 +1,71 @@ +{ + "name": "@web3-onboard/tallyho", + "version": "2.0.0-alpha.1", + "description": "Tally Ho SDK wallet module for connecting 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", + "Web3", + "EVM", + "dapp", + "Multichain", + "Wallet", + "Transaction", + "Provider", + "Hardware Wallet", + "Notifications", + "React", + "Svelte", + "Vue", + "Next", + "Nuxt", + "MetaMask", + "Coinbase", + "WalletConnect", + "Ledger", + "Trezor", + "Connect Wallet", + "Ethereum Hooks", + "Blocknative", + "Mempool", + "pending", + "confirmed", + "Injected Wallet", + "Crypto", + "Crypto Wallet", + "Tally Ho" + ], + "repository": { + "type": "git", + "url": "https://github.com/blocknative/web3-onboard.git", + "directory": "packages/core" + }, + "homepage": "https://www.blocknative.com/onboard", + "bugs": "https://github.com/blocknative/web3-onboard/issues", + "module": "dist/index.js", + "browser": "dist/index.js", + "main": "dist/index.js", + "type": "module", + "typings": "dist/index.d.ts", + "files": [ + "dist" + ], + "scripts": { + "build": "tsc", + "dev": "tsc -w", + "type-check": "tsc --noEmit" + }, + "license": "MIT", + "devDependencies": { + "@ethersproject/providers": "^5.5.0", + "@types/lodash.uniqby": "^4.7.6", + "@types/node": "^17.0.21", + "ts-node": "^10.2.1", + "typescript": "^4.5.5", + "window": "^4.2.7" + }, + "dependencies": { + "@web3-onboard/common": "^2.2.2", + "tallyho-detect-provider": "^1.0.0", + "tallyho-onboarding": "^1.0.2" + } +} diff --git a/packages/tallyho/src/icon.ts b/packages/tallyho/src/icon.ts new file mode 100644 index 000000000..c9f2358e7 --- /dev/null +++ b/packages/tallyho/src/icon.ts @@ -0,0 +1,6 @@ +export default ` + + + + +` diff --git a/packages/tallyho/src/index.ts b/packages/tallyho/src/index.ts new file mode 100644 index 000000000..6e616155c --- /dev/null +++ b/packages/tallyho/src/index.ts @@ -0,0 +1,33 @@ +import type { WalletInit } from '@web3-onboard/common' +import { createEIP1193Provider } from '@web3-onboard/common' +import { CustomWindow } from './types.js' +import detectEthereumProvider from 'tallyho-detect-provider' +import TallyHoOnboarding from 'tallyho-onboarding' +declare const window: CustomWindow + +function tallyHoWallet(): WalletInit { + if (typeof window === 'undefined') return () => null + return () => { + return { + label: 'Tally Ho Wallet', + injectedNamespace: 'tally', + checkProviderIdentity: ({ provider }: { provider: any }) => { + !!provider && !!provider['isTally'] + }, + getIcon: async () => (await import('./icon.js')).default, + getInterface: async () => { + const provider = await detectEthereumProvider({ mustBeTallyHo: true }) + if (!provider) { + const onboarding = new TallyHoOnboarding() + onboarding.startOnboarding() + throw new Error('Please install Tally Ho to use this wallet') + } else { + return { provider: createEIP1193Provider(window.tally) } + } + }, + platforms: ['desktop'] + } + } +} + +export default tallyHoWallet diff --git a/packages/tallyho/src/types.ts b/packages/tallyho/src/types.ts new file mode 100644 index 000000000..1503a530d --- /dev/null +++ b/packages/tallyho/src/types.ts @@ -0,0 +1,4 @@ +import type { ExternalProvider } from '@ethersproject/providers' +export interface CustomWindow extends Window { + tally: ExternalProvider +} diff --git a/packages/tallyho/tsconfig.json b/packages/tallyho/tsconfig.json new file mode 100644 index 000000000..53a27ffad --- /dev/null +++ b/packages/tallyho/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*"], + + "compilerOptions": { + "outDir": "dist", + "rootDir": "src", + "declaration": true, + "declarationDir": "dist", + "allowSyntheticDefaultImports": true, + "paths": { + "*": ["./src/*", "./node_modules/*"] + }, + "typeRoots": ["node_modules/@types"] + } + } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index a0fda2dc6..229e204c5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3897,7 +3897,7 @@ borsh@^0.7.0: bs58 "^4.0.0" text-encoding-utf-8 "^1.0.2" -bowser@^2.11.0: +bowser@^2.11.0, bowser@^2.9.0: version "2.11.0" resolved "https://registry.yarnpkg.com/bowser/-/bowser-2.11.0.tgz#5ca3c35757a7aa5771500c70a73a9f91ef420a8f" integrity sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA== @@ -10111,6 +10111,18 @@ table@^6.0.9: string-width "^4.2.3" strip-ansi "^6.0.1" +tallyho-detect-provider@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/tallyho-detect-provider/-/tallyho-detect-provider-1.0.2.tgz#6e462c34494217d39a83e22709dd855488b2d32d" + integrity sha512-VUGZiWUrKJUUjtnkib09tuNO7Kld4UWLs54nnNYP0tewvzmeb1VWDK0UTv88bEUcuRKx2YWGDIuOuK9v270Ewg== + +tallyho-onboarding@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/tallyho-onboarding/-/tallyho-onboarding-1.0.2.tgz#afc7dc4eb05b3a7861ead215e798585e1cbe2e91" + integrity sha512-bdFT/fNrFrq1BYVgjl/JKtwDmeS+z2u0415PoxmGmmYYRfdcKqXtEPImMoEbVwGtOeN0iFVohuS8ESrrAe+w7w== + dependencies: + bowser "^2.9.0" + tapable@^2.1.1, tapable@^2.2.0: version "2.2.1" resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0"