From a2595c74a8133e5a0f136eab16f676b85bed23d3 Mon Sep 17 00:00:00 2001 From: Nikita TEREKHOV Date: Mon, 1 May 2023 14:13:50 +0200 Subject: [PATCH 1/4] FEATURE: Add cede.store wallet package --- .circleci/config.yml | 19 ++++++++ packages/cede-store/README.md | 28 ++++++++++++ packages/cede-store/package.json | 75 +++++++++++++++++++++++++++++++ packages/cede-store/src/icon.ts | 19 ++++++++ packages/cede-store/src/index.ts | 45 +++++++++++++++++++ packages/cede-store/src/types.ts | 4 ++ packages/cede-store/tsconfig.json | 14 ++++++ packages/demo/package.json | 1 + packages/demo/src/App.svelte | 5 ++- yarn.lock | 5 +++ 10 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 packages/cede-store/README.md create mode 100644 packages/cede-store/package.json create mode 100644 packages/cede-store/src/icon.ts create mode 100644 packages/cede-store/src/index.ts create mode 100644 packages/cede-store/src/types.ts create mode 100644 packages/cede-store/tsconfig.json diff --git a/.circleci/config.yml b/.circleci/config.yml index 362a39b39..69de2f94a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: @@ -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 @@ -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 + diff --git a/packages/cede-store/README.md b/packages/cede-store/README.md new file mode 100644 index 000000000..f5328e570 --- /dev/null +++ b/packages/cede-store/README.md @@ -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) +``` diff --git a/packages/cede-store/package.json b/packages/cede-store/package.json new file mode 100644 index 000000000..a5179c705 --- /dev/null +++ b/packages/cede-store/package.json @@ -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" + } +} diff --git a/packages/cede-store/src/icon.ts b/packages/cede-store/src/icon.ts new file mode 100644 index 000000000..8d56febc1 --- /dev/null +++ b/packages/cede-store/src/icon.ts @@ -0,0 +1,19 @@ +export default ` + + + + + + + + + + + + + + + + + +` diff --git a/packages/cede-store/src/index.ts b/packages/cede-store/src/index.ts new file mode 100644 index 000000000..865da6ff5 --- /dev/null +++ b/packages/cede-store/src/index.ts @@ -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; \ No newline at end of file diff --git a/packages/cede-store/src/types.ts b/packages/cede-store/src/types.ts new file mode 100644 index 000000000..d57e09951 --- /dev/null +++ b/packages/cede-store/src/types.ts @@ -0,0 +1,4 @@ +import type { ExternalProvider } from '@ethersproject/providers' +export interface CustomWindow extends Window { + cede: ExternalProvider +} \ No newline at end of file diff --git a/packages/cede-store/tsconfig.json b/packages/cede-store/tsconfig.json new file mode 100644 index 000000000..4e5bdd4b8 --- /dev/null +++ b/packages/cede-store/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*"], + "compilerOptions": { + "outDir": "dist", + "rootDir": "src", + "declarationDir": "dist", + "paths": { + "*": ["./src/*", "./node_modules/*"] + }, + "typeRoots": ["node_modules/@types"], + } + } + \ No newline at end of file diff --git a/packages/demo/package.json b/packages/demo/package.json index 3565f8a78..6c44aec0d 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -52,6 +52,7 @@ "@web3-onboard/xdefi": "^2.0.2", "@web3-onboard/uauth": "^2.0.3", "@web3-onboard/zeal": "^2.0.2", + "@web3-onboard/cede-store": "^2.0.0-alpha.1", "vconsole": "^3.9.5" }, "license": "MIT", diff --git a/packages/demo/src/App.svelte b/packages/demo/src/App.svelte index 09f5400c3..b28eca0ce 100644 --- a/packages/demo/src/App.svelte +++ b/packages/demo/src/App.svelte @@ -28,6 +28,7 @@ import phantomModule from '@web3-onboard/phantom' import trustModule from '@web3-onboard/trust' import frontierModule from '@web3-onboard/frontier' + import cedeStoreModule from '@web3-onboard/cede-store' import { recoverAddress, arrayify, @@ -137,6 +138,7 @@ const phantom = phantomModule() const trust = trustModule() const frontier = frontierModule() + const cedeStore = cedeStoreModule() const trezorOptions = { email: 'test@test.com', @@ -194,7 +196,8 @@ zeal, frontier, phantom, - xdefi + xdefi, + cedeStore ], transactionPreview, gas, diff --git a/yarn.lock b/yarn.lock index 6c81ce637..72b701c49 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" From bd8ec18e40946a80aeebcb82b27361d759a642ca Mon Sep 17 00:00:00 2001 From: Adam Carpenter Date: Tue, 2 May 2023 11:40:14 -0600 Subject: [PATCH 2/4] Formatting and add to docs site --- docs/package.json | 1 + docs/src/lib/services/onboard.js | 7 ++- .../routes/docs/[...4]wallets/cede-store.md | 44 ++++++++++++++++++ packages/cede-store/src/index.ts | 46 ++++++++++--------- 4 files changed, 74 insertions(+), 24 deletions(-) create mode 100644 docs/src/routes/docs/[...4]wallets/cede-store.md diff --git a/docs/package.json b/docs/package.json index 1b0906cd7..27c0089a6 100644 --- a/docs/package.json +++ b/docs/package.json @@ -56,6 +56,7 @@ }, "type": "module", "dependencies": { + "@web3-onboard/cede-store": "^2.0.0-alpha.1", "@web3-onboard/coinbase": "^2.2.2", "@web3-onboard/core": "^2.17.0-alpha.1", "@web3-onboard/dcent": "^2.2.5", diff --git a/docs/src/lib/services/onboard.js b/docs/src/lib/services/onboard.js index 9294c43da..d3844e5a5 100644 --- a/docs/src/lib/services/onboard.js +++ b/docs/src/lib/services/onboard.js @@ -27,6 +27,7 @@ const classMutationListener = () => { } const intiOnboard = async (theme) => { + const { default: cedeModule } = await import('@web3-onboard/cede-store') const { default: Onboard } = await import('@web3-onboard/core') const { default: injectedModule } = await import('@web3-onboard/injected-wallets') const { default: trezorModule } = await import('@web3-onboard/trezor') @@ -75,6 +76,7 @@ const intiOnboard = async (theme) => { const torus = torusModule() const trust = trustModule() const xdefi = xdefiModule() + const cede = cedeModule() const portis = portisModule({ apiKey: 'b2b7586f-2b1e-4c30-a7fb-c2d1533b153b' @@ -117,11 +119,11 @@ const intiOnboard = async (theme) => { gnosis, uauth, taho, + cede, xdefi, torus, sequence, web3auth, - infinityWallet, dcent, enkrypt, mewWallet, @@ -129,7 +131,8 @@ const intiOnboard = async (theme) => { fortmatic, keystone, keepkey, - portis + portis, + infinityWallet ], chains: [ { diff --git a/docs/src/routes/docs/[...4]wallets/cede-store.md b/docs/src/routes/docs/[...4]wallets/cede-store.md new file mode 100644 index 000000000..adbfcc029 --- /dev/null +++ b/docs/src/routes/docs/[...4]wallets/cede-store.md @@ -0,0 +1,44 @@ +# cede-store + +## Wallet module for connecting cede.store Wallet SDK to web3-onboard + +See [cede.store Wallet Developer Docs](https://docs.cede.store) + +### Install + + + + +```sh copy +yarn add @web3-onboard/coinbase +``` + + + + +```sh copy +npm install @web3-onboard/coinbase +``` + + + + +## 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) +``` diff --git a/packages/cede-store/src/index.ts b/packages/cede-store/src/index.ts index 865da6ff5..fd5cc99dc 100644 --- a/packages/cede-store/src/index.ts +++ b/packages/cede-store/src/index.ts @@ -1,45 +1,47 @@ -import { detectCedeProvider } from '@cedelabs/providers'; -import type { WalletInit } from '@web3-onboard/common'; -import { createEIP1193Provider } from '@web3-onboard/common'; -import { CustomWindow } from './types'; +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; + if (typeof window === 'undefined') return () => null return () => ({ - label: "cede.store", - injectedNamespace: "cede", + label: 'cede.store', + injectedNamespace: 'cede', checkProviderIdentity: () => (window as CustomWindow).cede, - getIcon: async () => (await import("./icon.js")).default, + getIcon: async () => (await import('./icon.js')).default, getInterface: async () => { - const provider: any = await detectCedeProvider(); + const provider: any = await detectCedeProvider() if (!provider) { - window.open("https://cede.store", "_blank"); - throw new Error("Please, install cede.store to use this wallet"); + 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"] : []; + 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 + 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, - }), - }); + eth_selectAccounts: null + }) + }) }, - platforms: ["desktop"], + platforms: ['desktop'] }) } -export default cedeStoreWallet; \ No newline at end of file +export default cedeStoreWallet From b2ff2b65025f65beec154163c957afd2beb9062a Mon Sep 17 00:00:00 2001 From: Nikita TEREKHOV Date: Tue, 2 May 2023 22:15:29 +0200 Subject: [PATCH 3/4] DOCS: Add cede.store detailed documentation with an example flow --- .../routes/docs/[...4]wallets/cede-store.md | 58 ++++++++++++++++++- packages/cede-store/README.md | 55 ++++++++++++++++++ 2 files changed, 110 insertions(+), 3 deletions(-) diff --git a/docs/src/routes/docs/[...4]wallets/cede-store.md b/docs/src/routes/docs/[...4]wallets/cede-store.md index adbfcc029..5616d6159 100644 --- a/docs/src/routes/docs/[...4]wallets/cede-store.md +++ b/docs/src/routes/docs/[...4]wallets/cede-store.md @@ -1,7 +1,11 @@ -# cede-store +# cede.store ## Wallet module for connecting cede.store Wallet SDK to web3-onboard +cede.store is a non-custodial browser extension designed to store CEX (centralized exchange) API keys and to sign CEX requests from the client-side. It allows users to manage their cryptos in their CEX through a unified interface. + +Any dApp can integrate cede.store in order to track and/or manage a user's CEX assets. In this way, we offer the dApp a way to monitor and manage a user's CEX assets while remaining non-custodial and maintaining the same user experience as any DeFi browser wallet. + See [cede.store Wallet Developer Docs](https://docs.cede.store) ### Install @@ -10,14 +14,14 @@ See [cede.store Wallet Developer Docs](https://docs.cede.store) ```sh copy -yarn add @web3-onboard/coinbase +yarn add @web3-onboard/cede-store ``` ```sh copy -npm install @web3-onboard/coinbase +npm install @web3-onboard/cede-store ``` @@ -42,3 +46,51 @@ const onboard = Onboard({ const connectedWallets = await onboard.connectWallet() console.log(connectedWallets) ``` +## Vault management + +Vaults allow creating bundles of CEX accounts. The extension connects with CEX through CEX API keys and everything is stored in the Local Storage of the browser, on a mobile or on a Ledger (more coming soon...). We can compare Vaults with the [Keyring concept](https://www.wispwisp.com/index.php/2020/12/25/how-metamask-stores-your-wallet-secret/) of Metamask. + +A user can have multiple vaults with different CEX accounts inside. +This system allows the user to give a dApp custom access to his accounts depending on the degree of trust he has in the dApp in question. + +Let's say the user has three vaults: a main one with full access (track, trade, withdraw) to all his CEX, one just for tracking and one just for trading. +If the user does not know the reputation of the dApp he is using, the most logical solution would be to give access +only to the tracking vault so the dApp will not be able to initiate trade requests. + +## CEX connection + +All requests are divided into two categories: +- private requests +- public requests + +All public data, such as prices, volumes, historical data are collected from different exchanges and provided with our API. + +All private requests, such as user balances, trades, open positions are coming from cede.store (from the user's machine). + +You can access both public and private data through the extension's API. cede.store handles all exchanges requests, as well as API keys secure storage. + +## Example of a workflow (fetch user's balances and transactions) + +```typescript +// get available vaults and accounts +const { vaultPreview } = provider.getVaultPreviews(); +console.log(vaultPreview); + +// Fetch user's balances from Binance and Coinbase +const vaultId = vaultPreview[0].id; +await provider.request({ + method: "balances", + params: { + vaultId, + accountNames: ["Binance 1", "Coinbase 1"] + } +}); + +// Fetch user's transactions +await provider.request({ + method: "transactions", + params: { + vaultId + } +}); +``` diff --git a/packages/cede-store/README.md b/packages/cede-store/README.md index f5328e570..51c4fcb50 100644 --- a/packages/cede-store/README.md +++ b/packages/cede-store/README.md @@ -1,6 +1,11 @@ # @web3-onboard/cede-store ## Wallet module for connecting cede.store Wallet SDK to web3-onboard + +cede.store is a non-custodial browser extension designed to store CEX (centralized exchange) API keys and to sign CEX requests from the client-side. It allows users to manage their cryptos in their CEX through a unified interface. + +Any dApp can integrate cede.store in order to track and/or manage a user's CEX assets. In this way, we offer the dApp a way to monitor and manage a user's CEX assets while remaining non-custodial and maintaining the same user experience as any DeFi browser wallet. + See [cede.store Wallet Developer Docs](https://docs.cede.store) ### Install @@ -26,3 +31,53 @@ const onboard = Onboard({ const connectedWallets = await onboard.connectWallet() console.log(connectedWallets) ``` + +## Vault management + +Vaults allow creating bundles of CEX accounts. The extension connects with CEX through CEX API keys and everything is stored in the Local Storage of the browser, on a mobile or on a Ledger (more coming soon...). We can compare Vaults with the [Keyring concept](https://www.wispwisp.com/index.php/2020/12/25/how-metamask-stores-your-wallet-secret/) of Metamask. + +A user can have multiple vaults with different CEX accounts inside. +This system allows the user to give a dApp custom access to his accounts depending on the degree of trust he has in the dApp in question. + +Let's say the user has three vaults: a main one with full access (track, trade, withdraw) to all his CEX, one just for tracking and one just for trading. +If the user does not know the reputation of the dApp he is using, the most logical solution would be to give access +only to the tracking vault so the dApp will not be able to initiate trade requests. + +## CEX connection + +All requests are divided into two categories: +- private requests +- public requests + +All public data, such as prices, volumes, historical data are collected from different exchanges and +provided with our API. + +All private requests, such as user balances, trades, open positions are coming from cede.store (from the user's machine). + +You can access both public and private data through the extension's API. cede.store handles all exchanges requests, as well as API keys secure storage. + +## Example of a workflow (fetch user's balances and transactions) + +```typescript +// get available vaults and accounts +const { vaultPreview } = provider.getVaultPreviews(); +console.log(vaultPreview); + +// Fetch user's balances from Binance and Coinbase +const vaultId = vaultPreview[0].id; +await provider.request({ + method: "balances", + params: { + vaultId, + accountNames: ["Binance 1", "Coinbase 1"] + } +}); + +// Fetch user's transactions +await provider.request({ + method: "transactions", + params: { + vaultId + } +}); +``` From 42786132b337041e3a589a593b3ab07e8116bebf Mon Sep 17 00:00:00 2001 From: Adam Carpenter Date: Tue, 2 May 2023 14:23:51 -0600 Subject: [PATCH 4/4] Update formatting - looks good! --- .../routes/docs/[...4]wallets/cede-store.md | 26 +++++++++--------- packages/cede-store/README.md | 27 ++++++++++--------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/docs/src/routes/docs/[...4]wallets/cede-store.md b/docs/src/routes/docs/[...4]wallets/cede-store.md index 5616d6159..609d3d2f6 100644 --- a/docs/src/routes/docs/[...4]wallets/cede-store.md +++ b/docs/src/routes/docs/[...4]wallets/cede-store.md @@ -46,24 +46,26 @@ const onboard = Onboard({ const connectedWallets = await onboard.connectWallet() console.log(connectedWallets) ``` + ## Vault management Vaults allow creating bundles of CEX accounts. The extension connects with CEX through CEX API keys and everything is stored in the Local Storage of the browser, on a mobile or on a Ledger (more coming soon...). We can compare Vaults with the [Keyring concept](https://www.wispwisp.com/index.php/2020/12/25/how-metamask-stores-your-wallet-secret/) of Metamask. -A user can have multiple vaults with different CEX accounts inside. +A user can have multiple vaults with different CEX accounts inside. This system allows the user to give a dApp custom access to his accounts depending on the degree of trust he has in the dApp in question. -Let's say the user has three vaults: a main one with full access (track, trade, withdraw) to all his CEX, one just for tracking and one just for trading. +Let's say the user has three vaults: a main one with full access (track, trade, withdraw) to all his CEX, one just for tracking and one just for trading. If the user does not know the reputation of the dApp he is using, the most logical solution would be to give access only to the tracking vault so the dApp will not be able to initiate trade requests. ## CEX connection -All requests are divided into two categories: +All requests are divided into two categories: + - private requests - public requests -All public data, such as prices, volumes, historical data are collected from different exchanges and provided with our API. +All public data, such as prices, volumes, historical data are collected from different exchanges and provided with our API. All private requests, such as user balances, trades, open positions are coming from cede.store (from the user's machine). @@ -73,24 +75,24 @@ You can access both public and private data through the extension's API. cede.st ```typescript // get available vaults and accounts -const { vaultPreview } = provider.getVaultPreviews(); -console.log(vaultPreview); +const { vaultPreview } = provider.getVaultPreviews() +console.log(vaultPreview) // Fetch user's balances from Binance and Coinbase -const vaultId = vaultPreview[0].id; +const vaultId = vaultPreview[0].id await provider.request({ - method: "balances", + method: 'balances', params: { vaultId, - accountNames: ["Binance 1", "Coinbase 1"] + accountNames: ['Binance 1', 'Coinbase 1'] } -}); +}) // Fetch user's transactions await provider.request({ - method: "transactions", + method: 'transactions', params: { vaultId } -}); +}) ``` diff --git a/packages/cede-store/README.md b/packages/cede-store/README.md index 51c4fcb50..faca15f5c 100644 --- a/packages/cede-store/README.md +++ b/packages/cede-store/README.md @@ -36,21 +36,22 @@ console.log(connectedWallets) Vaults allow creating bundles of CEX accounts. The extension connects with CEX through CEX API keys and everything is stored in the Local Storage of the browser, on a mobile or on a Ledger (more coming soon...). We can compare Vaults with the [Keyring concept](https://www.wispwisp.com/index.php/2020/12/25/how-metamask-stores-your-wallet-secret/) of Metamask. -A user can have multiple vaults with different CEX accounts inside. +A user can have multiple vaults with different CEX accounts inside. This system allows the user to give a dApp custom access to his accounts depending on the degree of trust he has in the dApp in question. -Let's say the user has three vaults: a main one with full access (track, trade, withdraw) to all his CEX, one just for tracking and one just for trading. +Let's say the user has three vaults: a main one with full access (track, trade, withdraw) to all his CEX, one just for tracking and one just for trading. If the user does not know the reputation of the dApp he is using, the most logical solution would be to give access only to the tracking vault so the dApp will not be able to initiate trade requests. ## CEX connection -All requests are divided into two categories: +All requests are divided into two categories: + - private requests - public requests -All public data, such as prices, volumes, historical data are collected from different exchanges and -provided with our API. +All public data, such as prices, volumes, historical data are collected from different exchanges and +provided with our API. All private requests, such as user balances, trades, open positions are coming from cede.store (from the user's machine). @@ -60,24 +61,24 @@ You can access both public and private data through the extension's API. cede.st ```typescript // get available vaults and accounts -const { vaultPreview } = provider.getVaultPreviews(); -console.log(vaultPreview); +const { vaultPreview } = provider.getVaultPreviews() +console.log(vaultPreview) // Fetch user's balances from Binance and Coinbase -const vaultId = vaultPreview[0].id; +const vaultId = vaultPreview[0].id await provider.request({ - method: "balances", + method: 'balances', params: { vaultId, - accountNames: ["Binance 1", "Coinbase 1"] + accountNames: ['Binance 1', 'Coinbase 1'] } -}); +}) // Fetch user's transactions await provider.request({ - method: "transactions", + method: 'transactions', params: { vaultId } -}); +}) ```