Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dcent - v1.0.0-alpha.1, injected v2.0.8-alpha.1] : Update - CI and cleanup #1041

Merged
merged 2 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
47 changes: 21 additions & 26 deletions packages/dcent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const generateAccounts = async (
provider: providers.StaticJsonRpcProvider
): Promise<Account[]> => {
const accounts = []

const addressList = await keyring.addAccounts()
const derivationPath = DEFAULT_BASE_PATH
const account = {
Expand All @@ -48,8 +48,7 @@ const generateAccounts = async (
}

accounts.push(account)

// console.log('generateAccounts/accounts = ', accounts)

return accounts
}

Expand All @@ -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'
Expand All @@ -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<Account[]> => {
currentChain =
chains.find(({ id }: Chain) => id === chainId) || currentChain

const provider = new StaticJsonRpcProvider(currentChain.rpcUrl)

return generateAccounts(dcentKeyring, provider)
}

Expand Down Expand Up @@ -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
},
Expand Down Expand Up @@ -273,7 +269,7 @@ function dcent({
accounts[0]

const opt = {
version: "V4"
version: 'V4'
}
return dcentKeyring.signTypedData(account.address, typedData, opt)
},
Expand All @@ -290,11 +286,10 @@ function dcent({
})

provider.on = eventEmitter.on.bind(eventEmitter)

return {
provider
}

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/injected/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down