|
@ -42,7 +42,6 @@ import { createPeerDid } from "../libs/crypto/vc/didPeer"; |
|
|
import { registerCredential } from "../libs/crypto/vc/passkeyDidPeer"; |
|
|
import { registerCredential } from "../libs/crypto/vc/passkeyDidPeer"; |
|
|
import { logger } from "../utils/logger"; |
|
|
import { logger } from "../utils/logger"; |
|
|
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory"; |
|
|
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory"; |
|
|
import OfferDetailsView from "@/views/OfferDetailsView.vue"; |
|
|
|
|
|
|
|
|
|
|
|
export interface GiverReceiverInputInfo { |
|
|
export interface GiverReceiverInputInfo { |
|
|
did?: string; |
|
|
did?: string; |
|
@ -81,18 +80,21 @@ export const UNIT_LONG: Record<string, string> = { |
|
|
}; |
|
|
}; |
|
|
/* eslint-enable prettier/prettier */ |
|
|
/* eslint-enable prettier/prettier */ |
|
|
|
|
|
|
|
|
const UNIT_CODES: Record<string, Record<string, string>> = { |
|
|
const UNIT_CODES: Record<string, { name: string; faIcon: string; decimals: number }> = { |
|
|
BTC: { |
|
|
BTC: { |
|
|
name: "Bitcoin", |
|
|
name: "Bitcoin", |
|
|
faIcon: "bitcoin-sign", |
|
|
faIcon: "bitcoin-sign", |
|
|
|
|
|
decimals: 4, |
|
|
}, |
|
|
}, |
|
|
HUR: { |
|
|
HUR: { |
|
|
name: "hours", |
|
|
name: "hours", |
|
|
faIcon: "clock", |
|
|
faIcon: "clock", |
|
|
|
|
|
decimals: 0, |
|
|
}, |
|
|
}, |
|
|
USD: { |
|
|
USD: { |
|
|
name: "US Dollars", |
|
|
name: "US Dollars", |
|
|
faIcon: "dollar", |
|
|
faIcon: "dollar", |
|
|
|
|
|
decimals: 2, |
|
|
}, |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -100,6 +102,13 @@ export function iconForUnitCode(unitCode: string) { |
|
|
return UNIT_CODES[unitCode]?.faIcon || "question"; |
|
|
return UNIT_CODES[unitCode]?.faIcon || "question"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function formattedAmount(amount: number, unitCode: string) { |
|
|
|
|
|
const unit = UNIT_CODES[unitCode]; |
|
|
|
|
|
const amountStr = amount.toFixed(unit?.decimals ?? 4); |
|
|
|
|
|
const unitName = unit?.name || "?"; |
|
|
|
|
|
return amountStr + " " + unitName; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// from https://stackoverflow.com/a/175787/845494
|
|
|
// from https://stackoverflow.com/a/175787/845494
|
|
|
// ... though it appears even this isn't precisely right so keep doing "|| 0" or something in sensitive places
|
|
|
// ... though it appears even this isn't precisely right so keep doing "|| 0" or something in sensitive places
|
|
|
//
|
|
|
//
|
|
|