-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cowboy credits (aka nov-5 (aka jan-3)) #1678
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far! Only looked through all the code and tested buying credits.
Left some questions.
api/paidAction/zap.js
Outdated
// if the zap is dust, or if me doesn't have a send wallet but has enough sats/credits to pay for it | ||
// then we don't invoice the peer | ||
if (sats < me?.sendCreditsBelowSats || | ||
(me && !hasSendWallet && (me.mcredits > cost || me.msats > cost))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't the balance checks use >=
?
if (act === 'TIP' && me) { | ||
return existingSats + sats | ||
} | ||
return existingSats | ||
}, | ||
meCredits: (existingCredits = 0) => { | ||
if (act === 'TIP' && !p2p && me) { | ||
return existingCredits + sats | ||
} | ||
return existingCredits | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is me
required for the item to stack real sats? an anon zap can also be p2p
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you made it so that we manage anon sats elsewhere, right?
components/notifications.js
Outdated
@@ -535,9 +535,31 @@ function Referral ({ n }) { | |||
) | |||
} | |||
|
|||
function stackedText (item) { | |||
let text = '' | |||
console.log(item.sats, item.credits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log
😱
components/notifications.js
Outdated
if (item.sats) { | ||
text += `${numWithUnits(item.sats, { abbreviate: false })}` | ||
|
||
if (item.credits) { | ||
text += ' (' | ||
} | ||
} | ||
if (item.credits) { | ||
text += `${numWithUnits(item.credits, { abbreviate: false, unitSingular: 'CC', unitPlural: 'CCs' })}` | ||
if (item.sats) { | ||
text += ')' | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mhh, maybe we should split them so it's also easy to see how many sats were stacked. Currently, the parentheses only give you the exact number of CCs. Also, the item info already shows the same number of sats + credits:
so I am proposing this instead:
naive patch:
diff --git a/components/notifications.js b/components/notifications.js
index faae6f80..98aec7a6 100644
--- a/components/notifications.js
+++ b/components/notifications.js
@@ -537,19 +537,14 @@ function Referral ({ n }) {
function stackedText (item) {
let text = ''
- console.log(item.sats, item.credits)
if (item.sats) {
- text += `${numWithUnits(item.sats, { abbreviate: false })}`
-
- if (item.credits) {
- text += ' ('
- }
+ text += `${numWithUnits(item.sats - item.credits, { abbreviate: false })}`
}
if (item.credits) {
- text += `${numWithUnits(item.credits, { abbreviate: false, unitSingular: 'CC', unitPlural: 'CCs' })}`
if (item.sats) {
- text += ')'
+ text += ' and'
}
+ text += ` ${numWithUnits(item.credits, { abbreviate: false, unitSingular: 'CC', unitPlural: 'CCs' })}`
}
return text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right that looks better
pages/settings/index.js
Outdated
@@ -110,6 +110,8 @@ export default function Settings ({ ssrData }) { | |||
// if we switched to anon, me is null before the page is reloaded | |||
if ((!data && !ssrData) || !me) return <PageLoading /> | |||
|
|||
console.log(settings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
second console.log
😱
This is ready for review. It primarily just gets the important jobs done. Some of more involved things I've discussed like overhauling: settings, top stackers, satistics, etc are prohibitively involved, ie it's too much to change at once a priori like this, ie it's easy to bike shed myself on nonsense things.
TODO
SATS
in the final column toSATS/CCs
me.satsStackedpuntme.creditsStackedpunt