From 5c1cbe84051e3b0ae6a857758eaf99d2a678f974 Mon Sep 17 00:00:00 2001 From: silverpill Date: Thu, 30 Jun 2022 12:50:30 +0000 Subject: [PATCH] Show token symbol on subscription setup page --- src/api/subscriptions.ts | 23 +++++++++++++++++++---- src/components/SubscriptionSetup.vue | 20 ++++++++++++++------ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/api/subscriptions.ts b/src/api/subscriptions.ts index a157ff7..82354c4 100644 --- a/src/api/subscriptions.ts +++ b/src/api/subscriptions.ts @@ -11,15 +11,30 @@ import { Contracts, getContract } from "./contracts" const SECONDS_IN_DAY = 3600 * 24 const SECONDS_IN_MONTH = SECONDS_IN_DAY * 30 -export async function getPricePerSec( +export interface SubscriptionToken { + address: string; + symbol: string; + decimals: string; +} + +export async function getSubscriptionToken( contractAddress: string, signer: Signer, - pricePerMonth: number, -): Promise { +): Promise { const adapter = await getContract(Contracts.SubscriptionAdapter, contractAddress, signer) const tokenAddress = await adapter.subscriptionToken() const token = await getContract(Contracts.ERC20, tokenAddress, signer) - const tokenDecimals = await token.decimals() + return { + address: tokenAddress, + symbol: await token.symbol(), + decimals: await token.decimals(), + } +} + +export function getPricePerSec( + pricePerMonth: number, + tokenDecimals: number, +): BigNumber { const pricePerMonthInt = floatToBigNumber(pricePerMonth, tokenDecimals) return pricePerMonthInt.div(SECONDS_IN_MONTH) } diff --git a/src/components/SubscriptionSetup.vue b/src/components/SubscriptionSetup.vue index 4bfe7f9..fedd901 100644 --- a/src/components/SubscriptionSetup.vue +++ b/src/components/SubscriptionSetup.vue @@ -22,7 +22,7 @@
- per month + {{ subscriptionToken.symbol }} per month