@@ -35,7 +35,7 @@ const generateAccounts = async (
35
35
provider : providers . StaticJsonRpcProvider
36
36
) : Promise < Account [ ] > => {
37
37
const accounts = [ ]
38
-
38
+
39
39
const addressList = await keyring . addAccounts ( )
40
40
const derivationPath = DEFAULT_BASE_PATH
41
41
const account = {
@@ -48,8 +48,7 @@ const generateAccounts = async (
48
48
}
49
49
50
50
accounts . push ( account )
51
-
52
- // console.log('generateAccounts/accounts = ', accounts)
51
+
53
52
return accounts
54
53
}
55
54
@@ -62,25 +61,26 @@ function dcent({
62
61
return helpers => {
63
62
const { device } = helpers
64
63
const isMobile = device . type === 'mobile'
65
- // console.log('device.type ', device.type)
66
64
let accounts : Account [ ] | undefined
67
65
return {
68
- label : 'D\ 'CENT' ,
66
+ label : "D 'CENT" ,
69
67
getIcon,
70
68
getInterface : async ( { EventEmitter, chains } ) => {
71
-
72
69
const eventEmitter = new EventEmitter ( )
73
70
74
71
if ( isMobile ) {
75
- const provider = window . ethereum as EIP1193Provider
76
- if ( isMobile && ( ! provider ) ) {
77
- location . replace ( "https://link.dcentwallet.com/DAppBrowser/?url=" + document . location )
72
+ const provider = window . ethereum as EIP1193Provider
73
+ if ( isMobile && ! provider ) {
74
+ location . replace (
75
+ 'https://link.dcentwallet.com/DAppBrowser/?url=' +
76
+ document . location
77
+ )
78
78
}
79
79
provider . on = eventEmitter . on . bind ( eventEmitter )
80
80
return {
81
81
provider
82
82
}
83
- }
83
+ }
84
84
85
85
const { StaticJsonRpcProvider } = await import (
86
86
'@ethersproject/providers'
@@ -89,23 +89,20 @@ function dcent({
89
89
90
90
const { default : EthDcentKeyring } = await import ( 'eth-dcent-keyring' )
91
91
const dcentKeyring = new EthDcentKeyring ( { } )
92
-
93
- // console.log('dcentKeyring ', dcentKeyring)
92
+
94
93
const { TransactionFactory : Transaction } = await import (
95
94
'@ethereumjs/tx'
96
95
)
97
-
96
+
98
97
let currentChain : Chain = chains [ 0 ]
99
98
const scanAccounts = async ( {
100
- derivationPath,
101
- chainId,
102
- asset
99
+ chainId
103
100
} : ScanAccountsOptions ) : Promise < Account [ ] > => {
104
101
currentChain =
105
102
chains . find ( ( { id } : Chain ) => id === chainId ) || currentChain
106
103
107
104
const provider = new StaticJsonRpcProvider ( currentChain . rpcUrl )
108
-
105
+
109
106
return generateAccounts ( dcentKeyring , provider )
110
107
}
111
108
@@ -218,23 +215,22 @@ function dcent({
218
215
from ,
219
216
transaction
220
217
)
221
-
222
- // console.log(`0x${result.serialize().toString('hex')}`)
218
+
223
219
return `0x${ result . serialize ( ) . toString ( 'hex' ) } `
224
220
} catch ( err ) {
225
221
throw err
226
222
}
227
223
} ,
228
224
eth_sendTransaction : async ( { baseRequest, params } ) => {
229
- const signedTx = await provider . request ( {
225
+ const signedTx = ( await provider . request ( {
230
226
method : 'eth_signTransaction' ,
231
227
params
232
- } ) as string
228
+ } ) ) as string
233
229
234
- const transactionHash = await baseRequest ( {
230
+ const transactionHash = ( await baseRequest ( {
235
231
method : 'eth_sendRawTransaction' ,
236
232
params : [ signedTx ]
237
- } ) as string
233
+ } ) ) as string
238
234
239
235
return transactionHash
240
236
} ,
@@ -273,7 +269,7 @@ function dcent({
273
269
accounts [ 0 ]
274
270
275
271
const opt = {
276
- version : "V4"
272
+ version : 'V4'
277
273
}
278
274
return dcentKeyring . signTypedData ( account . address , typedData , opt )
279
275
} ,
@@ -290,11 +286,10 @@ function dcent({
290
286
} )
291
287
292
288
provider . on = eventEmitter . on . bind ( eventEmitter )
293
-
289
+
294
290
return {
295
291
provider
296
292
}
297
-
298
293
}
299
294
}
300
295
}
0 commit comments