Skip to content

Commit

Permalink
show address name
Browse files Browse the repository at this point in the history
  • Loading branch information
lAmeR1 committed Sep 2, 2024
1 parent 8b0a291 commit fca09fa
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/AddressInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Toggle from "react-toggle";
import usePrevious, {floatToStr, numberWithCommas} from "../helper";
import {
getAddressBalance,
getAddressName,
getAddressTxCount,
getAddressUtxos,
getBlock,
Expand Down Expand Up @@ -40,6 +41,8 @@ const AddressInfo = () => {
const [view, setView] = useState("transactions")
const [showQr, setShowQr] = useState(false);

const [addressName, setAddressName] = useState("");

const [detailedView, setDetailedView] = useState(localStorage.getItem('detailedView') == "true")

const [utxos, setUtxos] = useState([])
Expand Down Expand Up @@ -149,6 +152,14 @@ const AddressInfo = () => {
}
)

getAddressName(addr).then(
(res) => {
if (res.name) {
setAddressName(res.name)
}
}
)

getBlockdagInfo().then(
(blockdag) => {
getBlock(blockdag.tipHashes[0]).then(
Expand Down Expand Up @@ -271,7 +282,8 @@ const AddressInfo = () => {
<Row>
<Col md={12} className="mt-sm-4">

<div className="addressinfo-header">Address</div>
<div className="addressinfo-header">Address{addressName ?
<span className="address-name">{addressName ? addressName : ""}</span> : ""}</div>
<div className="utxo-value-mono"><span
class="addressinfo-color">kaspa:</span>{addr.substring(6, addr.length - 8)}<span
class="addressinfo-color">{addr.substring(addr.length - 8)}</span>
Expand Down
12 changes: 12 additions & 0 deletions src/components/blockinfo.scss
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@

}

.address-name {
background-color: rgb(50, 115, 110);
font-size: small;
font-weight: lighter;
padding: .2rem .7rem;
margin-left: .8rem;
border-radius: .4rem;
word-wrap: none;
display: inline-block;

}

.utxo-amount-minus {
background-color: rgb(195, 38, 38);
padding: .2rem .7rem;
Expand Down
8 changes: 8 additions & 0 deletions src/kaspa-api-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ export async function getAddressUtxos(addr) {
})
return res
}
export async function getAddressName(addr) {
const res = await fetch(`${API_BASE}addresses/${addr}/name`, {headers: {'Access-Control-Allow-Origin': '*'}})
.then((response) => response.json())
.then(data => {
return data
})
return res
}


export async function getHalving() {
Expand Down

0 comments on commit fca09fa

Please sign in to comment.