Merge pull request #43 from MAGICGrants/count-crypto-by-project

Count crypto by project
This commit is contained in:
Rucknium
2022-11-25 20:51:09 +00:00
committed by GitHub
2 changed files with 7 additions and 3 deletions

View File

@@ -158,8 +158,6 @@ export async function getServerSideProps({ params }: { params: any }) {
const content = await markdownToHtml(post.content || '')
const crypto = await fetchGetJSONAuthedBTCPay()
let stats : any = {};
for(let i=0;i<projects.length;i++){
@@ -183,6 +181,7 @@ export async function getServerSideProps({ params }: { params: any }) {
totaldonations: projects[i].fiattotaldonations,
}
} else {
const crypto = await fetchGetJSONAuthedBTCPay(projects[i].slug)
xmr = await crypto.xmr
btc = await crypto.btc
usd = await fetchGetJSONAuthedStripe()

View File

@@ -65,7 +65,9 @@ export async function fetchPostJSONAuthed(
}
}
export async function fetchGetJSONAuthedBTCPay() {
export async function fetchGetJSONAuthedBTCPay(
slug: string
) {
try {
const url = `${process.env.BTCPAY_URL!}stores/${process.env.BTCPAY_STORE_ID}/invoices`
const auth = `token ${process.env.BTCPAY_API_KEY}`
@@ -84,6 +86,9 @@ export async function fetchGetJSONAuthedBTCPay() {
let totaldonationsinfiatxmr = 0
let totaldonationsinfiatbtc = 0
for(let i=0;i<data.length;i++){
if (data[i].metadata.orderId != slug) {
continue
}
const id = data[i].id
const urliter = `${process.env.BTCPAY_URL!}stores/${process.env.BTCPAY_STORE_ID}/invoices/${id}/payment-methods`
const authiter = `token ${process.env.BTCPAY_API_KEY}`