Skip to content

Commit

Permalink
FEATURE: Add cede.store wallet package
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnikter committed May 1, 2023
1 parent 96b0290 commit 98e2bf8
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/unstoppable-resolution
steps:
- node-build-steps
build-cede-store:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/cede-store
steps:
- node-build-steps

# Build staging/Alpha releases
build-staging-core:
Expand Down Expand Up @@ -599,6 +605,12 @@ jobs:
working_directory: ~/web3-onboard-monorepo/packages/unstoppable-resolution
steps:
- node-staging-build-steps
build-staging-cede-store:
docker:
- image: cimg/node:16.13.1
working_directory: ~/web3-onboard-monorepo/packages/cede-store
steps:
- node-staging-build-steps

workflows:
version: 2
Expand Down Expand Up @@ -819,3 +831,10 @@ workflows:
<<: *deploy_production_filters
- build-staging-unstoppable-resolution:
<<: *deploy_staging_filters
cede-store:
jobs:
- build-cede-store:
<<: *deploy_production_filters
- build-staging-cede-store:
<<: *deploy_staging_filters

28 changes: 28 additions & 0 deletions packages/cede-store/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# @web3-onboard/cede-store

## Wallet module for connecting cede.store Wallet SDK to web3-onboard
See [cede.store Wallet Developer Docs](https://docs.cede.store)

### Install

`npm i @web3-onboard/cede-store`

## Usage

```typescript
import Onboard from '@web3-onboard/core'
import cedeStoreWalletModule from '@web3-onboard/cede-store'

const cedeStoreWallet = cedeStoreWalletModule()

const onboard = Onboard({
// ... other Onboard options
wallets: [
cedeStoreWallet
//... other wallets
]
})

const connectedWallets = await onboard.connectWallet()
console.log(connectedWallets)
```
75 changes: 75 additions & 0 deletions packages/cede-store/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "@web3-onboard/cede-store",
"version": "2.0.0-alpha.1",
"description": "cede.store 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",
"Taho",
"Taho Wallet",
"cede.store",
"cede",
"cedelabs"
],
"repository": {
"type": "git",
"url": "/~https://github.com/blocknative/web3-onboard.git",
"directory": "packages/core"
},
"homepage": "https://onboard.blocknative.com",
"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": {
"@cedelabs/providers": "^0.0.7",
"@web3-onboard/common": "^2.3.0-alpha.1"
}
}
19 changes: 19 additions & 0 deletions packages/cede-store/src/icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export default `
<svg width="100%" height="100%" viewBox="0 0 115 115" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0.00779067 27.599C0.00779067 12.3521 12.3668 0 27.605 0H87.4028C102.649 0 115 12.3599 115 27.599V87.4009C115 102.648 102.641 115 87.4028 115H27.4645C12.2966 115 0 102.703 0 87.5336V27.5913L0.00779067 27.599Z" fill="url(#paint0_linear_1990_147351)"/>
<path d="M6.64611 31.0476C6.64611 17.5641 17.5773 6.63214 31.0599 6.63214H83.9604C97.443 6.63214 108.374 17.5641 108.374 31.0476V83.9517C108.374 97.4352 97.443 108.367 83.9604 108.367H30.9351C17.5149 108.367 6.6383 97.4898 6.6383 84.0687V31.0398L6.64611 31.0476Z" fill="black"/>
<path d="M13.2766 34.4968C13.2766 22.769 22.78 13.265 34.507 13.265H80.5101C92.2372 13.265 101.741 22.769 101.741 34.4968V80.5031C101.741 92.231 92.2372 101.735 80.5101 101.735H34.4056C22.741 101.735 13.2844 92.2778 13.2844 80.6045V34.4968H13.2766Z" fill="white"/>
<path d="M47.815 61.914C52.1457 54.4124 50.9067 45.5889 45.0477 42.2059C39.1887 38.823 30.9284 42.1618 26.5977 49.6633C22.267 57.1648 23.5059 65.9884 29.3649 69.3713C35.2239 72.7542 43.4843 69.4155 47.815 61.914Z" fill="black"/>
<path d="M43.179 55.1448C45.7257 55.1448 47.7902 53.0801 47.7902 50.5332C47.7902 47.9863 45.7257 45.9217 43.179 45.9217C40.6323 45.9217 38.5678 47.9863 38.5678 50.5332C38.5678 53.0801 40.6323 55.1448 43.179 55.1448Z" fill="white"/>
<path d="M85.8952 69.4338C91.7542 66.0508 92.9931 57.2273 88.6624 49.7258C84.3317 42.2243 76.0713 38.8855 70.2123 42.2684C64.3533 45.6513 63.1144 54.4749 67.4451 61.9764C71.7758 69.4779 80.0362 72.8167 85.8952 69.4338Z" fill="black"/>
<path d="M72.0841 55.2146C74.6308 55.2146 76.6953 53.15 76.6953 50.6031C76.6953 48.0562 74.6308 45.9915 72.0841 45.9915C69.5374 45.9915 67.4729 48.0562 67.4729 50.6031C67.4729 53.15 69.5374 55.2146 72.0841 55.2146Z" fill="white"/>
<path d="M57.629 74.6895C57.629 74.6895 54.3363 74.5569 53.1582 75.3996C51.98 76.2423 52.058 77.5454 52.058 77.5454C52.058 77.5454 51.902 78.8797 52.2921 79.7458C52.6822 80.612 54.9683 80.4637 56.0919 82.3911C56.0919 82.3911 57.1218 82.7422 57.629 82.6408" fill="black"/>
<path d="M57.629 74.6895C57.629 74.6895 60.9217 74.5567 62.0999 75.3994C63.2781 76.2421 63.2001 77.5452 63.2001 77.5452C63.2001 77.5452 63.3561 78.8795 62.966 79.7457C62.5759 80.6118 60.2897 80.4635 59.1662 82.3909C59.1662 82.3909 58.1361 82.7422 57.629 82.6408" fill="black"/>
<defs>
<linearGradient id="paint0_linear_1990_147351" x1="79.5" y1="133.5" x2="80.5" y2="-67" gradientUnits="userSpaceOnUse">
<stop stop-color="#5EA6FF"/>
<stop offset="1" stop-color="#5EA6FF" stop-opacity="0.4"/>
</linearGradient>
</defs>
</svg>
`
45 changes: 45 additions & 0 deletions packages/cede-store/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { detectCedeProvider } from '@cedelabs/providers';
import type { WalletInit } from '@web3-onboard/common';
import { createEIP1193Provider } from '@web3-onboard/common';
import { CustomWindow } from './types';
declare const window: CustomWindow

function cedeStoreWallet(): WalletInit {
if (typeof window === 'undefined') return () => null;
return () => ({
label: "cede.store",
injectedNamespace: "cede",
checkProviderIdentity: () => (window as CustomWindow).cede,
getIcon: async () => (await import("./icon.js")).default,
getInterface: async () => {
const provider: any = await detectCedeProvider();
if (!provider) {
window.open("https://cede.store", "_blank");
throw new Error("Please, install cede.store to use this wallet");
}

// handle disconnect
provider.once('lock', () => {
provider.emit('accountsChanged', [])
});

return Promise.resolve({
provider: createEIP1193Provider(window.cede, {
eth_requestAccounts: async ({ baseRequest }) => {
const vaults = await baseRequest({
method: "connect",
}) as [];
return vaults.length > 0 ? ["To access cede.store vaults and accounts, use cede provider"] : [];
},
eth_chainId: () => Promise.resolve("0x0"), // cede.store doesn't support chains, but we have to provide a value to complete the connection
wallet_switchEthereumChain: null,
wallet_addEthereumChain: null,
eth_getBalance: null,
eth_selectAccounts: null,
}),
});
},
platforms: ["desktop"],
})
}
export default cedeStoreWallet;
4 changes: 4 additions & 0 deletions packages/cede-store/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { ExternalProvider } from '@ethersproject/providers'
export interface CustomWindow extends Window {
cede: ExternalProvider
}
14 changes: 14 additions & 0 deletions packages/cede-store/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"declarationDir": "dist",
"paths": {
"*": ["./src/*", "./node_modules/*"]
},
"typeRoots": ["node_modules/@types"],
}
}

5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@
"@babel/helper-validator-identifier" "^7.16.7"
to-fast-properties "^2.0.0"

"@cedelabs/providers@^0.0.7":
version "0.0.7"
resolved "https://registry.yarnpkg.com/@cedelabs/providers/-/providers-0.0.7.tgz#859070c5cf0a86841ce98d32c1599cc8de9b7869"
integrity sha512-rjOcEff5dnuKif+dJmEygCC/mp05oztkFYAmGEcGa1HW9EcVP3id1PTjBEYZLieVBNwJdg4kcl8Jh1dboG8pCA==

"@chainsafe/as-sha256@^0.3.1":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@chainsafe/as-sha256/-/as-sha256-0.3.1.tgz#3639df0e1435cab03f4d9870cc3ac079e57a6fc9"
Expand Down

0 comments on commit 98e2bf8

Please sign in to comment.