-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Enrique Soares
committed
Sep 2, 2020
1 parent
81cd2b4
commit 9c6ee56
Showing
3 changed files
with
92 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,30 @@ | ||
const random = require("random"); | ||
const random = require('random'); | ||
|
||
let sapis = ["https://sapi2.smartcash.org", "https://sapi.smartcash.cc"]; | ||
const request = require('request-promise'); | ||
|
||
let sapis = ['https://sapi2.smartcash.org', 'https://sapi.smartcash.cc']; | ||
/* | ||
request.get('https://sapi.smartcash.cc/v1/smartnodes/list').then((list) => { | ||
list = JSON.parse(list); | ||
const mappedKey = Object.keys(list).map((key) => { | ||
return list[key]; | ||
}); | ||
const serves = mappedKey | ||
.filter((f) => f.protocol === 90030 && f.status === 'ENABLED') | ||
.map((server) => { | ||
return { | ||
status: server.status, | ||
protocol: server.protocol, | ||
payee: server.payee, | ||
uptime: server.uptime, | ||
ip_sapi: server.ip.split(':')[0] + ':8080', | ||
ip: server.ip, | ||
}; | ||
}); | ||
if (serves.length > 0) { | ||
sapis = serves.map((server) => 'http://' + server.ip_sapi); | ||
} | ||
});*/ | ||
module.exports = () => sapis[random.int(0, sapis.length - 1)]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 63 additions & 71 deletions
134
src/pages/send/components/transactions-history/TransactionHistory.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,70 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import ReactDOM from "react-dom"; | ||
import style from "./TransactionHistory.module.css"; | ||
import { getTransactionHistory } from "../../../../lib/sapi"; | ||
import React, { useEffect, useState } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import style from './TransactionHistory.module.css'; | ||
import { getTransactionHistory } from '../../../../lib/sapi'; | ||
|
||
const TransactionsHistory = ({ isShowing, hide, address }) => { | ||
const [history, setHistory] = useState(); | ||
const [history, setHistory] = useState(); | ||
|
||
useEffect(() => { | ||
async function _getTransactionHistory() { | ||
await getTransactionHistory(address) | ||
.then((data) => { | ||
setHistory(data); | ||
}) | ||
.catch((error) => console.error(error)); | ||
} | ||
_getTransactionHistory(); | ||
}, [address]); | ||
useEffect(() => { | ||
async function _getTransactionHistory() { | ||
await getTransactionHistory(address) | ||
.then((data) => { | ||
setHistory(data); | ||
}) | ||
.catch((error) => console.error(error)); | ||
} | ||
_getTransactionHistory(); | ||
}, [address]); | ||
|
||
return isShowing | ||
? ReactDOM.createPortal( | ||
<React.Fragment> | ||
<div className={style["modal-overlay"]} /> | ||
<div | ||
className={style["modal-wrapper"]} | ||
aria-modal | ||
aria-hidden | ||
tabIndex={-1} | ||
role="dialog" | ||
> | ||
<div className={style["modal"]}> | ||
<div className={style["modal-header"]}> | ||
<strong>Transactions</strong> | ||
<button | ||
type="button" | ||
className={style["modal-close-button"]} | ||
data-dismiss="modal" | ||
aria-label="Close" | ||
onClick={hide} | ||
> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div className={style["modal-body"]}> | ||
Showing last 5 transactions. | ||
<a | ||
href={`https://sapi-explorer.herokuapp.com/#/address/${address}`} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
See all | ||
</a> | ||
{ | ||
history?.map((tx, index) => { | ||
return ( | ||
|
||
<div className={style.cardWrapper} key={index}> | ||
<strong>Type</strong> | ||
<p>{tx.direction}</p> | ||
<strong>Fees</strong> | ||
<p>{tx.fees}</p> | ||
<strong>Amount</strong> | ||
<p>{tx.amount}</p> | ||
<strong>Transaction Id</strong> | ||
<p>{tx.txid}</p> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
</div> | ||
</React.Fragment>, | ||
document.body | ||
) | ||
: null; | ||
return isShowing | ||
? ReactDOM.createPortal( | ||
<React.Fragment> | ||
<div className={style['modal-overlay']} /> | ||
<div className={style['modal-wrapper']} aria-modal aria-hidden tabIndex={-1} role="dialog"> | ||
<div className={style['modal']}> | ||
<div className={style['modal-header']}> | ||
<strong>Transactions</strong> | ||
<button | ||
type="button" | ||
className={style['modal-close-button']} | ||
data-dismiss="modal" | ||
aria-label="Close" | ||
onClick={hide} | ||
> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div className={style['modal-body']}> | ||
Showing last 5 transactions. | ||
<a | ||
href={`https://sapi-explorer.herokuapp.com/#/address/${address}`} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
See all | ||
</a> | ||
{history?.map((tx, index) => { | ||
return ( | ||
<div className={style.cardWrapper} key={index}> | ||
<strong>Type</strong> | ||
<p>{tx.direction}</p> | ||
<strong>Fees</strong> | ||
<p>{tx.fees}</p> | ||
<strong>Amount</strong> | ||
<p>{tx.amount}</p> | ||
<strong>Transaction Id</strong> | ||
<p>{tx.txid}</p> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
</div> | ||
</React.Fragment>, | ||
document.body | ||
) | ||
: null; | ||
}; | ||
|
||
export default TransactionsHistory; |