@@ -7,19 +7,23 @@ import {connect} from "react-redux";
7
7
import { Table } from "../components-ui/Table" ;
8
8
import { WalletGenerate } from "./GatewayApplicationWalletGenerate" ;
9
9
import {
10
- generateGatewayApplicationWallet ,
10
+ exportApplicationWalletPrivateKey ,
11
+ generateGatewayApplicationWallet , importGatewayApplicationWallet ,
11
12
removeGatewayApplicationWallet
12
13
} from "../actions/gateway-wallet" ;
13
14
14
15
import { getGatewayWalletSelector } from "../selectors/getGatewayWalletsSelector" ;
15
16
16
17
import { GatewayApplicationWalletRemove } from "./GatewayApplicationWalletRemove" ;
18
+ import { GatewayApplicationWalletPrivateKey } from "./GatewayApplicationWalletPrivateKey" ;
19
+ import { WalletImport } from "./GatewayApplicationWalletImport" ;
20
+ import { OpenScanLink } from "../components-ui/OpenScanLink" ;
17
21
18
- const getColumns = ( wallets , onRemove ) => [
22
+ const getColumns = ( wallets , onRemove , onExport ) => [
19
23
{
20
24
Header : 'Wallet Address' ,
21
25
accessor : 'address' ,
22
- Cell : ( { value } ) => < EtherscanLink > { value } </ EtherscanLink > ,
26
+ Cell : ( { value } ) => < OpenScanLink > { value } </ OpenScanLink > ,
23
27
sortable : false
24
28
} ,
25
29
{
@@ -39,6 +43,17 @@ const getColumns = (wallets, onRemove) => [
39
43
</ span >
40
44
) ,
41
45
sortable : false
46
+ } ,
47
+ {
48
+ Header : '' ,
49
+ accessor : 'address' ,
50
+ width : 150 ,
51
+ Cell : ( props ) => (
52
+ < span >
53
+ < GatewayApplicationWalletPrivateKey onSubmit = { ( ) => onExport ( props . row . _original . address , props . row . _original . blockchain ) } />
54
+ </ span >
55
+ ) ,
56
+ sortable : false
42
57
}
43
58
] ;
44
59
@@ -49,19 +64,28 @@ class GatewayApplicationWalletComponent extends React.Component {
49
64
return this . props . removeGatewayApplicationWallet ( gateway . id , address ) ;
50
65
} ;
51
66
67
+ onExportPrivateKey = ( address , blockchain ) => {
68
+ return this . props . exportApplicationWalletPrivateKey ( address , blockchain ) ;
69
+ }
70
+
52
71
onGenerateWallet = blockchain => {
53
72
const { gateway } = this . props ;
54
73
this . props . generateGatewayApplicationWallet ( { applicationId : gateway . id , webHook : gateway . webHook } , blockchain ) ;
55
74
}
56
75
76
+ onImportWallet = walletImport => {
77
+ this . props . importGatewayApplicationWallet ( walletImport . walletRequest , { address : walletImport . address , blockchain : walletImport . blockchain } ) ;
78
+ }
79
+
57
80
render ( ) {
58
81
const { wallets, gateway } = this . props ;
59
82
60
- const columns = getColumns ( wallets . list , this . onRemoveWallet ) ;
83
+ const columns = getColumns ( wallets . list , this . onRemoveWallet , this . onExportPrivateKey ) ;
61
84
const noDataText = 'No Wallet exist'
62
85
return (
63
86
< div className = "table-with-add" >
64
87
< WalletGenerate gateway = { gateway } onSubmit = { this . onGenerateWallet } />
88
+ < WalletImport gateway = { gateway } onSubmit = { this . onImportWallet } />
65
89
< Segment attached styles = { { padding : 0 } } >
66
90
< Table data = { wallets . list } columns = { columns } noDataText = { noDataText } />
67
91
</ Segment >
@@ -70,7 +94,7 @@ class GatewayApplicationWalletComponent extends React.Component {
70
94
}
71
95
}
72
96
73
- const mapStateToProps = ( state , { gateway } ) => {
97
+ const mapStateToProps = ( state , { gateway} ) => {
74
98
const wallets = getGatewayWalletSelector ( state , gateway . id ) ;
75
99
return { gateway, wallets } ;
76
100
} ;
@@ -79,6 +103,8 @@ export const GatewayApplicationWallet = connect(
79
103
mapStateToProps ,
80
104
{
81
105
generateGatewayApplicationWallet,
82
- removeGatewayApplicationWallet
106
+ importGatewayApplicationWallet,
107
+ removeGatewayApplicationWallet,
108
+ exportApplicationWalletPrivateKey
83
109
}
84
110
) ( GatewayApplicationWalletComponent ) ;
0 commit comments