File tree Expand file tree Collapse file tree 5 files changed +69
-6
lines changed Expand file tree Collapse file tree 5 files changed +69
-6
lines changed Original file line number Diff line number Diff line change 19
19
"@fontsource/merriweather" : " ^4.5.14" ,
20
20
"@fontsource/montserrat" : " ^4.5.13" ,
21
21
"@vercel/analytics" : " ^0.1.3" ,
22
+ "bip32" : " ^4.0.0" ,
23
+ "bip39" : " ^3.1.0" ,
24
+ "bitcoinjs-lib" : " ^6.1.3" ,
22
25
"crypto-js" : " ^4.1.1" ,
23
26
"dexie" : " ^3.2.2" ,
24
27
"dexie-react-hooks" : " ^1.1.1" ,
32
35
"react-dom" : " ^18.2.0" ,
33
36
"react-feather" : " ^2.0.10" ,
34
37
"react-hotjar" : " ^5.2.0" ,
35
- "react-qr-code" : " ^2.0.7"
38
+ "react-qr-code" : " ^2.0.7" ,
39
+ "tiny-secp256k1" : " ^2.2.3"
36
40
},
37
41
"devDependencies" : {
38
42
"@graphprotocol/client-cli" : " ^2.2.15" ,
Original file line number Diff line number Diff line change @@ -59,8 +59,8 @@ const Send = ({ onClose }) => {
59
59
60
60
// Component
61
61
const [ loading , setLoading ] = useState ( false ) ;
62
- const [ toAddress , setToAddress ] = useState ( '' ) ;
63
- const [ mount , setMount ] = useState ( '' ) ;
62
+ const [ toAddress , setToAddress ] = useState ( null ) ;
63
+ const [ mount , setMount ] = useState ( null ) ;
64
64
65
65
// Price
66
66
const [ price , setPrice ] = useState ( ) ;
@@ -117,15 +117,15 @@ const Send = ({ onClose }) => {
117
117
} ;
118
118
119
119
const handleCloseModal = ( ) => {
120
- setMount ( '' ) ;
120
+ setMount ( null ) ;
121
121
setGasPrice ( 0 ) ;
122
122
onClose ( ) ;
123
123
} ;
124
124
125
125
const handleChangeAddress = ( ) => {
126
126
setTokenSelected ( '' ) ;
127
127
setToAddress ( '' ) ;
128
- setMount ( '' ) ;
128
+ setMount ( null ) ;
129
129
} ;
130
130
131
131
return (
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export function BlockchainWrapper({ children }) {
9
9
10
10
useEffect ( ( ) => {
11
11
if ( ! kovanProvider ) {
12
- const kovan = new ethers . providers . InfuraProvider ( 'goerli ' , process . env . INFURA_TOKEN_API ) ;
12
+ const kovan = new ethers . providers . InfuraProvider ( 'homestead ' , process . env . INFURA_TOKEN_API ) ;
13
13
setKovanProvider ( kovan ) ;
14
14
}
15
15
} , [ kovanProvider ] ) ;
Original file line number Diff line number Diff line change
1
+ import { BIP32Factory } from 'bip32' ;
2
+ import bip39 from 'bip39' ;
3
+ import bitcoin from 'bitcoinjs-lib' ;
4
+ import * as ecc from 'tiny-secp256k1' ;
5
+
6
+ import { ethers } from 'ethers' ;
7
+
8
+ const createAccount = async ( req , res ) => {
9
+ if ( req . method === 'GET' ) {
10
+ try {
11
+ // Define the network
12
+ const network = bitcoin ?. networks ?. bitcoin ;
13
+
14
+ // Derivation path
15
+ const path = `m/49'/1'/0'/0` ;
16
+
17
+ // Use m/49'/0'/0'/0 for mainnet
18
+ // Use m/49'/1'/0'/0 for testnet
19
+
20
+ let mnemonic = bip39 ?. generateMnemonic ( ) ;
21
+ const seed = bip39 ?. mnemonicToSeedSync ( mnemonic ) ;
22
+ const bip32 = BIP32Factory ( ecc ) ;
23
+ let root = bip32 . fromSeed ( seed , network ) ;
24
+
25
+ let account = root ?. derivePath ( path ) ;
26
+ let node = account ?. derive ( 0 ) . derive ( 0 ) ;
27
+
28
+ let walletBTC = bitcoin ?. payments ?. p2pkh ( {
29
+ pubkey : node ?. publicKey ,
30
+ network : network ,
31
+ } ) . address ;
32
+
33
+ const walletETH = ethers . Wallet . fromMnemonic ( mnemonic ) ;
34
+
35
+ res . status ( 200 ) . json ( {
36
+ account : {
37
+ security : {
38
+ mnemonic,
39
+ } ,
40
+ wallet : {
41
+ btc : walletBTC ,
42
+ eth : walletETH ?. address ,
43
+ } ,
44
+ } ,
45
+ } ) ;
46
+ } catch ( error ) {
47
+ res . status ( 501 ) . json ( { error : error . message } ) ;
48
+ }
49
+ }
50
+ } ;
51
+
52
+ export default createAccount ;
Original file line number Diff line number Diff line change
1
+ export default function ( req , res ) {
2
+ if ( req . method === 'GET' ) {
3
+ return res . status ( 200 ) . json ( {
4
+ test : 'hola' ,
5
+ } ) ;
6
+ }
7
+ }
You can’t perform that action at this time.
0 commit comments