Compare commits

...

4 Commits

4 changed files with 14 additions and 14 deletions

View File

@ -84,18 +84,18 @@ func GetTransferData(ctx context.Context, db storage.PrefixDb, publicKey string,
// Adjust for 0-based indexing // Adjust for 0-based indexing
i := index - 1 i := index - 1
transactionType := "received" transactionType := "Received"
party := fmt.Sprintf("from: %s", strings.TrimSpace(senders[i])) party := fmt.Sprintf("From: %s", strings.TrimSpace(senders[i]))
if strings.TrimSpace(senders[i]) == publicKey { if strings.TrimSpace(senders[i]) == publicKey {
transactionType = "sent" transactionType = "Sent"
party = fmt.Sprintf("to: %s", strings.TrimSpace(recipients[i])) party = fmt.Sprintf("To: %s", strings.TrimSpace(recipients[i]))
} }
formattedDate := formatDate(strings.TrimSpace(dates[i])) formattedDate := formatDate(strings.TrimSpace(dates[i]))
// Build the full transaction detail // Build the full transaction detail
detail := fmt.Sprintf( detail := fmt.Sprintf(
"%s %s %s\n%s\ncontract address: %s\ntxhash: %s\ndate: %s", "%s %s %s\n%s\nContract address: %s\nTxhash: %s\nDate: %s",
transactionType, transactionType,
strings.TrimSpace(values[i]), strings.TrimSpace(values[i]),
strings.TrimSpace(syms[i]), strings.TrimSpace(syms[i]),

View File

@ -24,7 +24,7 @@ func ProcessVouchers(holdings []dataserviceapi.TokenHoldings) VoucherMetadata {
var symbols, balances, decimals, addresses []string var symbols, balances, decimals, addresses []string
for i, h := range holdings { for i, h := range holdings {
symbols = append(symbols, fmt.Sprintf("%d:%s", i+1, h.TokenSymbol)) symbols = append(symbols, fmt.Sprintf("%d: %s", i+1, h.TokenSymbol))
// Scale down the balance // Scale down the balance
scaledBalance := ScaleDownBalance(h.Balance, h.TokenDecimals) scaledBalance := ScaleDownBalance(h.Balance, h.TokenDecimals)
@ -103,7 +103,7 @@ func MatchVoucher(input, symbols, balances, decimals, addresses string) (symbol,
logg.Tracef("found", "symlist", symList, "syms", symbols, "input", input) logg.Tracef("found", "symlist", symList, "syms", symbols, "input", input)
for i, sym := range symList { for i, sym := range symList {
parts := strings.SplitN(sym, ":", 2) parts := strings.SplitN(sym, ": ", 2)
if input == parts[0] || strings.EqualFold(input, parts[1]) { if input == parts[0] || strings.EqualFold(input, parts[1]) {
symbol = parts[1] symbol = parts[1]

View File

@ -34,7 +34,7 @@ func InitializeTestDb(t *testing.T) (context.Context, *UserDataStore) {
} }
func TestMatchVoucher(t *testing.T) { func TestMatchVoucher(t *testing.T) {
symbols := "1:SRF\n2:MILO" symbols := "1: SRF\n2: MILO"
balances := "1:100\n2:200" balances := "1:100\n2:200"
decimals := "1:6\n2:4" decimals := "1:6\n2:4"
addresses := "1:0xd4c288865Ce\n2:0x41c188d63Qa" addresses := "1:0xd4c288865Ce\n2:0x41c188d63Qa"
@ -65,7 +65,7 @@ func TestProcessVouchers(t *testing.T) {
} }
expectedResult := VoucherMetadata{ expectedResult := VoucherMetadata{
Symbols: "1:SRF\n2:MILO", Symbols: "1: SRF\n2: MILO",
Balances: "1:100\n2:20000", Balances: "1:100\n2:20000",
Decimals: "1:6\n2:4", Decimals: "1:6\n2:4",
Addresses: "1:0xd4c288865Ce\n2:0x41c188d63Qa", Addresses: "1:0xd4c288865Ce\n2:0x41c188d63Qa",
@ -90,7 +90,7 @@ func TestGetVoucherData(t *testing.T) {
// Test voucher data // Test voucher data
mockData := map[DataTyp][]byte{ mockData := map[DataTyp][]byte{
DATA_VOUCHER_SYMBOLS: []byte("1:SRF\n2:MILO"), DATA_VOUCHER_SYMBOLS: []byte("1: SRF\n2: MILO"),
DATA_VOUCHER_BALANCES: []byte("1:100\n2:200"), DATA_VOUCHER_BALANCES: []byte("1:100\n2:200"),
DATA_VOUCHER_DECIMALS: []byte("1:6\n2:4"), DATA_VOUCHER_DECIMALS: []byte("1:6\n2:4"),
DATA_VOUCHER_ADDRESSES: []byte("1:0xd4c288865Ce\n2:0x41c188d63Qa"), DATA_VOUCHER_ADDRESSES: []byte("1:0xd4c288865Ce\n2:0x41c188d63Qa"),

View File

@ -1846,7 +1846,7 @@ func (h *Handlers) CheckTransactions(ctx context.Context, sym string, input []by
return res, nil return res, nil
} }
// GetTransactionsList fetches the list of transactions and formats them // GetTransactionsList reads the list of transactions from the db and formats them
func (h *Handlers) GetTransactionsList(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (h *Handlers) GetTransactionsList(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result var res resource.Result
sessionId, ok := ctx.Value("SessionId").(string) sessionId, ok := ctx.Value("SessionId").(string)
@ -1895,12 +1895,12 @@ func (h *Handlers) GetTransactionsList(ctx context.Context, sym string, input []
value := strings.TrimSpace(values[i]) value := strings.TrimSpace(values[i])
date := strings.Split(strings.TrimSpace(dates[i]), " ")[0] date := strings.Split(strings.TrimSpace(dates[i]), " ")[0]
status := "received" status := "Received"
if sender == string(publicKey) { if sender == string(publicKey) {
status = "sent" status = "Sent"
} }
formattedTransactions = append(formattedTransactions, fmt.Sprintf("%d:%s %s %s %s", i+1, status, value, sym, date)) formattedTransactions = append(formattedTransactions, fmt.Sprintf("%d: %s %s %s %s", i+1, status, value, sym, date))
} }
res.Content = strings.Join(formattedTransactions, "\n") res.Content = strings.Join(formattedTransactions, "\n")