diff --git a/.circleci/config.yml b/.circleci/config.yml index 0d39a348b..40c720b78 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -267,6 +267,12 @@ jobs: working_directory: ~/web3-onboard-monorepo/packages/coinbase steps: - node-build-steps + build-dcent: + docker: + - image: cimg/node:16.13.1 + working_directory: ~/web3-onboard-monorepo/packages/dcent + steps: + - node-build-steps # Build staging/Alpha releases build-staging-core: @@ -371,6 +377,12 @@ jobs: working_directory: ~/web3-onboard-monorepo/packages/coinbase steps: - node-staging-build-steps + build-staging-dcent: + docker: + - image: cimg/node:16.13.1 + working_directory: ~/web3-onboard-monorepo/packages/dcent + steps: + - node-staging-build-steps workflows: version: 2 @@ -477,3 +489,9 @@ workflows: <<: *deploy_production_filters - build-staging-coinbase: <<: *deploy_staging_filters + dcent: + jobs: + - build-dcent: + <<: *deploy_production_filters + - build-staging-dcent: + <<: *deploy_staging_filters diff --git a/packages/dcent/src/index.ts b/packages/dcent/src/index.ts index 56e68c2fc..14ad919a0 100644 --- a/packages/dcent/src/index.ts +++ b/packages/dcent/src/index.ts @@ -35,7 +35,7 @@ const generateAccounts = async ( provider: providers.StaticJsonRpcProvider ): Promise => { const accounts = [] - + const addressList = await keyring.addAccounts() const derivationPath = DEFAULT_BASE_PATH const account = { @@ -48,8 +48,7 @@ const generateAccounts = async ( } accounts.push(account) - - // console.log('generateAccounts/accounts = ', accounts) + return accounts } @@ -62,25 +61,26 @@ function dcent({ return helpers => { const { device } = helpers const isMobile = device.type === 'mobile' - // console.log('device.type ', device.type) let accounts: Account[] | undefined return { - label: 'D\'CENT', + label: "D'CENT", getIcon, getInterface: async ({ EventEmitter, chains }) => { - const eventEmitter = new EventEmitter() if (isMobile) { - const provider = window.ethereum as EIP1193Provider - if(isMobile && (!provider)) { - location.replace("https://link.dcentwallet.com/DAppBrowser/?url=" + document.location) + const provider = window.ethereum as EIP1193Provider + if (isMobile && !provider) { + location.replace( + 'https://link.dcentwallet.com/DAppBrowser/?url=' + + document.location + ) } provider.on = eventEmitter.on.bind(eventEmitter) return { provider } - } + } const { StaticJsonRpcProvider } = await import( '@ethersproject/providers' @@ -89,23 +89,20 @@ function dcent({ const { default: EthDcentKeyring } = await import('eth-dcent-keyring') const dcentKeyring = new EthDcentKeyring({}) - - // console.log('dcentKeyring ', dcentKeyring) + const { TransactionFactory: Transaction } = await import( '@ethereumjs/tx' ) - + let currentChain: Chain = chains[0] const scanAccounts = async ({ - derivationPath, - chainId, - asset + chainId }: ScanAccountsOptions): Promise => { currentChain = chains.find(({ id }: Chain) => id === chainId) || currentChain const provider = new StaticJsonRpcProvider(currentChain.rpcUrl) - + return generateAccounts(dcentKeyring, provider) } @@ -218,23 +215,22 @@ function dcent({ from, transaction ) - - // console.log(`0x${result.serialize().toString('hex')}`) + return `0x${result.serialize().toString('hex')}` } catch (err) { throw err } }, eth_sendTransaction: async ({ baseRequest, params }) => { - const signedTx = await provider.request({ + const signedTx = (await provider.request({ method: 'eth_signTransaction', params - }) as string + })) as string - const transactionHash = await baseRequest({ + const transactionHash = (await baseRequest({ method: 'eth_sendRawTransaction', params: [signedTx] - }) as string + })) as string return transactionHash }, @@ -273,7 +269,7 @@ function dcent({ accounts[0] const opt = { - version: "V4" + version: 'V4' } return dcentKeyring.signTypedData(account.address, typedData, opt) }, @@ -290,11 +286,10 @@ function dcent({ }) provider.on = eventEmitter.on.bind(eventEmitter) - + return { provider } - } } } diff --git a/packages/injected/package.json b/packages/injected/package.json index 5e38bac98..7d9fb1969 100644 --- a/packages/injected/package.json +++ b/packages/injected/package.json @@ -1,6 +1,6 @@ { "name": "@web3-onboard/injected-wallets", - "version": "2.0.7", + "version": "2.0.8-alpha.1", "description": "Injected wallets module for web3-onboard", "module": "dist/index.js", "browser": "dist/index.js",