Skip to content

Commit

Permalink
feat: \using fee credits (#3276)
Browse files Browse the repository at this point in the history
* feat: add banner to migrate to alby hub for alby account users before march

* chore: rename to using_fee_credits

* feat: update copy

* chore: format sats

* chore: update shared wallet notification text

---------

Co-authored-by: Michael Bumann <hello@michaelbumann.com>
  • Loading branch information
pavanjoshi914 and bumi authored Nov 29, 2024
1 parent 549eda6 commit 55de0a1
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/app/context/AccountContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ interface AccountContextType {
avatarUrl?: AccountInfo["avatarUrl"];
connectorType?: AccountInfo["connectorType"];
lightningAddress?: AccountInfo["lightningAddress"];
sharedNode?: AccountInfo["sharedNode"];
nodeRequired?: AccountInfo["nodeRequired"];
usingFeeCredits?: AccountInfo["usingFeeCredits"];
limits?: AccountInfo["limits"];
} | null;
balancesDecorated: {
fiatBalance: string;
Expand Down
66 changes: 66 additions & 0 deletions src/app/screens/Home/DefaultView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Hyperlink from "~/app/components/Hyperlink";
import { IconLinkCard } from "~/app/components/IconLinkCard/IconLinkCard";
import toast from "~/app/components/Toast";
import { useAccount } from "~/app/context/AccountContext";
import { useSettings } from "~/app/context/SettingsContext";
import { useTransactions } from "~/app/hooks/useTransactions";
import { PublisherLnData } from "~/app/screens/Home/PublisherLnData";
import { isAlbyLNDHubAccount } from "~/app/utils";
Expand All @@ -45,6 +46,8 @@ const DefaultView: FC<Props> = (props) => {

const navigate = useNavigate();

const { getFormattedSats } = useSettings();

const { account, accountLoading } = useAccount();

const lightningAddress = account?.lightningAddress || "";
Expand Down Expand Up @@ -172,6 +175,69 @@ const DefaultView: FC<Props> = (props) => {
</div>
</Alert>
)}

{account?.sharedNode && (
<Alert type="info">
<div className="flex items-center gap-2">
<div className="shrink-0">
<PopiconsCircleExclamationLine className="w-5 h-5" />
</div>
<span className="text-sm">
<Trans
i18nKey={"default_view.using_shared_node"}
t={t}
components={[
// eslint-disable-next-line react/jsx-key
<Hyperlink
className="underline"
href="https://getalby.com/node/embrace_albyhub"
target="_blank"
rel="noopener nofollow"
/>,
]}
/>
</span>
</div>
</Alert>
)}

{account?.usingFeeCredits && (
<Alert type="info">
<div className="flex items-center gap-2">
<div className="shrink-0">
<PopiconsCircleExclamationLine className="w-5 h-5" />
</div>
<span className="text-sm">
<Trans
i18nKey={"default_view.using_fee_credits"}
t={t}
values={{
max_account_balance: getFormattedSats(
account?.limits?.max_account_balance || 0
),
}}
components={[
// eslint-disable-next-line react/jsx-key
<Hyperlink
className="underline"
href="https://getalby.com/onboarding/node/new"
target="_blank"
rel="noopener nofollow"
/>,
// eslint-disable-next-line react/jsx-key
<Hyperlink
className="underline"
href="https://guides.getalby.com/user-guide/alby-account-and-browser-extension/alby-account/faqs-alby-account/what-are-fee-credits-in-my-alby-account"
target="_blank"
rel="noopener nofollow"
/>,
]}
/>
</span>
</div>
</Alert>
)}

{account?.nodeRequired ? (
<Alert type="info">
<div className="flex items-center gap-2">
Expand Down
13 changes: 13 additions & 0 deletions src/common/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ export interface AccountInfoRes {
pubkey?: string;
lightning_address?: string;
node_required?: boolean;
shared_node?: boolean;
using_fee_credits?: boolean;
limits?: {
max_send_volume: number;
max_send_amount: number;
max_receive_volume: number;
max_receive_amount: number;
max_account_balance: number;
max_volume_period_in_days: number;
};
};
name: string;
avatarUrl?: string;
Expand Down Expand Up @@ -121,6 +131,9 @@ export const swrGetAccountInfo = async (
avatarUrl,
lightningAddress: response.info.lightning_address,
nodeRequired: response.info.node_required,
sharedNode: response.info.shared_node,
usingFeeCredits: response.info.using_fee_credits,
limits: response.info.limits,
};
storeAccounts({
...accountsCache,
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,9 @@
"description": "Fund your account and receive via your lightning address or an invoice"
}
},
"upgrade_account": "You are using the old LNDHub setup. <0>Please re-connect</0> your Alby account to get access to the latest features."
"upgrade_account": "You are using the old LNDHub setup. <0>Please re-connect</0> your Alby account to get access to the latest features.",
"using_fee_credits": "Finish your setup and connect your wallet to your <0>Alby account</0> for unlimited payments. Until your setup is complete, you can receive up to {{max_account_balance}} sats as <1>fee credits</1>",
"using_shared_node": "The shared wallet that you use is being deprecated in favor of the Alby Hub wallet. To continue sending and receiving payments <0>setup your wallet</0> by January 3, 2025."
}
},
"accounts": {
Expand Down
11 changes: 11 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,21 @@ export interface AccountInfo {
avatarUrl?: string;
lightningAddress?: string;
nodeRequired?: boolean;
sharedNode?: boolean;
usingFeeCredits?: boolean;
limits?: {
max_send_volume: number;
max_send_amount: number;
max_receive_volume: number;
max_receive_amount: number;
max_account_balance: number;
max_volume_period_in_days: number;
};
}

export type GetAccountInformationResponses = GetAccountInformationResponse & {
node_required: boolean;
using_fee_credits: boolean;
limits?: {
max_send_volume: number;
max_send_amount: number;
Expand Down

0 comments on commit 55de0a1

Please sign in to comment.