-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PUBLIC: Add token filter feature based on available user balance to a…
…void error while pay. If checkout price as token is above user owned balance for specified token, payment is unavailable
- Loading branch information
1 parent
fc9e14b
commit 8d43af8
Showing
4 changed files
with
129 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { MAINNET_ENDPOINTS, TESTNET_ENDPOINTS } from '../../commons/constants/endpoints'; | ||
import { JsonRpc } from "@proton/light-api" | ||
import type { UserBalance } from '../type'; | ||
|
||
|
||
export async function getUserBalances(actor: string, isTestnet: boolean):Promise<UserBalance[]> { | ||
|
||
const rpc = new JsonRpc("proton") | ||
const userBalance = await rpc.get_balances(actor); | ||
if (userBalance && userBalance.balances) return userBalance.balances; | ||
return [] | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type {UserBalance } from "../type"; | ||
|
||
export function getUserBalanceForToken(token:string,userBalances:UserBalance[]) { | ||
|
||
const foundToken = userBalances.find((balance) => balance.currency == token) | ||
if (foundToken) return foundToken | ||
return null | ||
|
||
|
||
} |