2023-02-05 06:29:46 +00:00
import { ApiHost , KieranPubKey , SnortPubKey } from "Const" ;
2023-01-20 11:11:50 +00:00
import ProfilePreview from "Element/ProfilePreview" ;
2023-01-24 15:24:50 +00:00
import ZapButton from "Element/ZapButton" ;
2023-02-11 20:05:46 +00:00
import { HexKey } from "@snort/nostr" ;
2023-01-24 12:26:14 +00:00
import { useEffect , useState } from "react" ;
2023-02-11 18:05:33 +00:00
import { FormattedMessage } from "react-intl" ;
2023-01-20 17:07:14 +00:00
import { bech32ToHex } from "Util" ;
2023-01-19 00:03:24 +00:00
const Developers = [
2023-02-07 20:04:50 +00:00
bech32ToHex ( KieranPubKey ) , // kieran
2023-02-09 12:26:54 +00:00
bech32ToHex ( "npub107jk7htfv243u0x5ynn43scq9wrxtaasmrwwa8lfu2ydwag6cx2quqncxg" ) , // verbiricha
bech32ToHex ( "npub1r0rs5q2gk0e3dk3nlc7gnu378ec6cnlenqp8a3cjhyzu6f8k5sgs4sq9ac" ) , // Karnage
2023-01-20 17:07:14 +00:00
] ;
const Contributors = [
2023-02-09 12:26:54 +00:00
bech32ToHex ( "npub10djxr5pvdu97rjkde7tgcsjxzpdzmdguwacfjwlchvj7t88dl7nsdl54nf" ) , // ivan
bech32ToHex ( "npub148jmlutaa49y5wl5mcll003ftj59v79vf7wuv3apcwpf75hx22vs7kk9ay" ) , // liran cohen
bech32ToHex ( "npub1xdtducdnjerex88gkg2qk2atsdlqsyxqaag4h05jmcpyspqt30wscmntxy" ) , // artur
bech32ToHex ( "npub1vp8fdcyejd4pqjyrjk9sgz68vuhq7pyvnzk8j0ehlljvwgp8n6eqsrnpsw" ) , // samsamskies
2023-02-28 10:24:55 +00:00
bech32ToHex ( "npub179rec9sw2a5ngkr2wsjpjhwp2ksygjxn6uw5py9daj2ezhw3aw5swv3s6q" ) , // h3y6e - JA + other stuff
2023-02-24 22:20:44 +00:00
bech32ToHex ( "npub17q5n2z8naw0xl6vu9lvt560lg33pdpe29k0k09umlfxm3vc4tqrq466f2y" ) , // w3irdrobot
2023-01-19 00:03:24 +00:00
] ;
2023-02-11 20:07:30 +00:00
const Translators = [
bech32ToHex ( "npub1s8zws5frm94esxnp9v6zf7vk60m3hum3305n78sr73t78kleus7q8zpwna" ) , // middlingphys - JA
bech32ToHex ( "npub1z0ykz6lp3y8rjjntenns0ee02062g2f0n55u49w44xdemw35vcpsda5jhh" ) , // noraglyphs - JA
bech32ToHex ( "npub13wa880se2h3l54k7x76edrkrt4p94sh4q090974mt0z6n09qtntqxp47uk" ) , // numpad0 - JA
2023-02-28 10:24:55 +00:00
bech32ToHex ( "npub147ccm75um0zkn0lr9fg9wrag2g6yxfw234fpmhdwuvaqjyegrhgs46t2td" ) , // ROBO358 - JA
2023-02-11 20:07:30 +00:00
bech32ToHex ( "npub1ww8kjxz2akn82qptdpl7glywnchhkx3x04hez3d3rye397turrhssenvtp" ) , // Zoltan - HU
bech32ToHex ( "npub1x8dzy9xegwmdk2vy30l8u08caspcqq2yzncxehdsa6kvnte9pr3qnt8pg4" ) , // solobalbo - FR
bech32ToHex ( "npub1xwm9svxrlymymph0hka40zw9frg98m6adxmzcq26jhtm5gwlhjrshhgzfd" ) , // meitsjustme - ZH
2023-02-28 10:24:55 +00:00
bech32ToHex ( "npub13tkge7eqeem5cz8gk7gdju76nytvvf064hm5mzmv3x26k2uvaxfqczet2j" ) , // Mendace - IT
bech32ToHex ( "npub10529hxckjm5t5mchss5lnpsqrmavulglxhrmu5quuu4hs6yuyh3qc9gxd5" ) , // aadbitcoin - ID
2023-02-11 20:07:30 +00:00
] ;
2023-03-03 22:01:15 +00:00
export const DonateLNURL = "donate@snort.social" ;
2023-01-24 12:26:14 +00:00
interface Splits {
2023-02-07 20:04:50 +00:00
pubKey : string ;
split : number ;
2023-01-24 12:26:14 +00:00
}
2023-01-26 15:41:10 +00:00
interface TotalToday {
2023-02-07 20:04:50 +00:00
donations : number ;
nip5 : number ;
2023-01-26 15:41:10 +00:00
}
2023-01-19 00:03:24 +00:00
const DonatePage = ( ) = > {
2023-02-07 20:04:50 +00:00
const [ splits , setSplits ] = useState < Splits [ ] > ( [ ] ) ;
const [ today , setSumToday ] = useState < TotalToday > ( ) ;
2023-01-24 12:26:14 +00:00
2023-02-07 20:04:50 +00:00
async function loadData() {
2023-02-07 19:47:57 +00:00
const rsp = await fetch ( ` ${ ApiHost } /api/v1/revenue/splits ` ) ;
2023-02-07 20:04:50 +00:00
if ( rsp . ok ) {
setSplits ( await rsp . json ( ) ) ;
2023-01-24 12:26:14 +00:00
}
2023-02-07 19:47:57 +00:00
const rsp2 = await fetch ( ` ${ ApiHost } /api/v1/revenue/today ` ) ;
2023-02-07 20:04:50 +00:00
if ( rsp2 . ok ) {
setSumToday ( await rsp2 . json ( ) ) ;
}
}
2023-01-24 12:26:14 +00:00
2023-02-07 20:04:50 +00:00
useEffect ( ( ) = > {
loadData ( ) . catch ( console . warn ) ;
} , [ ] ) ;
2023-01-24 12:26:14 +00:00
2023-02-07 20:04:50 +00:00
function actions ( pk : HexKey ) {
2023-02-09 12:26:54 +00:00
const split = splits . find ( a = > bech32ToHex ( a . pubKey ) === pk ) ;
2023-02-07 20:04:50 +00:00
if ( split ) {
return < > { ( 100 * split . split ) . toLocaleString ( ) } % < / > ;
2023-01-24 12:26:14 +00:00
}
2023-02-07 20:04:50 +00:00
return < > < / > ;
}
return (
< div className = "main-content m5" >
2023-02-11 18:05:33 +00:00
< h2 >
< FormattedMessage defaultMessage = "Help fund the development of Snort" / >
< / h2 >
2023-02-07 20:04:50 +00:00
< p >
2023-02-11 18:05:33 +00:00
< FormattedMessage defaultMessage = "Snort is an open source project built by passionate people in their free time" / >
2023-02-07 20:04:50 +00:00
< / p >
< p >
2023-02-11 18:05:33 +00:00
< FormattedMessage defaultMessage = "Your donations are greatly appreciated" / >
< / p >
< p >
< FormattedMessage
defaultMessage = { "Check out the code here: {link}" }
values = { {
link : (
< a className = "highlight" href = "https://github.com/v0l/snort" rel = "noreferrer" target = "_blank" >
https : //github.com/v0l/snort
< / a >
) ,
} }
/ >
< / p >
< p >
< FormattedMessage defaultMessage = "Each contributor will get paid a percentage of all donations and NIP-05 orders, you can see the split amounts below" / >
2023-02-07 20:04:50 +00:00
< / p >
< div className = "flex" >
2023-02-11 18:05:33 +00:00
< div className = "mr10" >
< FormattedMessage defaultMessage = "Lightning Donation: " / >
< / div >
2023-03-03 22:01:15 +00:00
< ZapButton pubkey = { bech32ToHex ( SnortPubKey ) } lnurl = { DonateLNURL } / >
2023-02-07 20:04:50 +00:00
< / div >
2023-02-11 18:05:33 +00:00
{ today && (
< small >
< FormattedMessage
defaultMessage = "Total today (UTC): {amount} sats"
values = { { amount : today.donations.toLocaleString ( ) } }
/ >
< / small >
) }
< h3 >
< FormattedMessage defaultMessage = "Primary Developers" / >
< / h3 >
2023-02-09 12:26:54 +00:00
{ Developers . map ( a = > (
2023-02-07 20:04:50 +00:00
< ProfilePreview pubkey = { a } key = { a } actions = { actions ( a ) } / >
) ) }
2023-02-11 18:05:33 +00:00
< h4 >
< FormattedMessage defaultMessage = "Contributors" / >
< / h4 >
2023-02-09 12:26:54 +00:00
{ Contributors . map ( a = > (
2023-02-07 20:04:50 +00:00
< ProfilePreview pubkey = { a } key = { a } actions = { actions ( a ) } / >
) ) }
2023-02-11 20:07:30 +00:00
< h4 >
< FormattedMessage defaultMessage = "Translators" / >
< / h4 >
{ Translators . map ( a = > (
< ProfilePreview pubkey = { a } key = { a } actions = { actions ( a ) } / >
) ) }
2023-02-07 20:04:50 +00:00
< / div >
) ;
} ;
2023-01-19 00:03:24 +00:00
2023-01-19 11:14:41 +00:00
export default DonatePage ;