Compare commits

..

No commits in common. "b40ad782949f682e02eb90f6347e6c122476a8f1" and "c8fc32a4e7a618c5a55ddb96536251cfa0265a8e" have entirely different histories.

8 changed files with 4 additions and 49 deletions

View File

@ -109,7 +109,6 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountServiceIn
ls.DbRs.AddLocalFunc("get_vouchers", ussdHandlers.GetVoucherList)
ls.DbRs.AddLocalFunc("view_voucher", ussdHandlers.ViewVoucher)
ls.DbRs.AddLocalFunc("set_voucher", ussdHandlers.SetVoucher)
ls.DbRs.AddLocalFunc("get_voucher_details", ussdHandlers.GetVoucherDetails)
ls.DbRs.AddLocalFunc("reset_valid_pin", ussdHandlers.ResetValidPin)
ls.DbRs.AddLocalFunc("check_pin_mismatch", ussdHandlers.CheckPinMisMatch)
ls.DbRs.AddLocalFunc("validate_blocked_number", ussdHandlers.ValidateBlockedNumber)

View File

@ -1624,36 +1624,3 @@ func (h *Handlers) SetVoucher(ctx context.Context, sym string, input []byte) (re
res.Content = tempData.TokenSymbol
return res, nil
}
// GetVoucherDetails retrieves the voucher details
func (h *Handlers) GetVoucherDetails(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
store := h.userdataStore
sessionId, ok := ctx.Value("SessionId").(string)
if !ok {
return res, fmt.Errorf("missing session")
}
flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error")
// get the active address
activeAddress, err := store.ReadEntry(ctx, sessionId, common.DATA_ACTIVE_ADDRESS)
if err != nil {
logg.ErrorCtxf(ctx, "failed to read activeAddress entry with", "key", common.DATA_ACTIVE_ADDRESS, "error", err)
return res, err
}
// use the voucher contract address to get the data from the API
voucherData, err := h.accountService.VoucherData(ctx, string(activeAddress))
if err != nil {
res.FlagSet = append(res.FlagSet, flag_api_error)
return res, nil
}
tokenSymbol := voucherData.TokenSymbol
tokenName := voucherData.TokenName
res.Content = fmt.Sprintf("%s %s", tokenSymbol, tokenName)
return res, nil
}

View File

@ -3,6 +3,6 @@ package models
type VoucherDataResult struct {
TokenName string `json:"tokenName"`
TokenSymbol string `json:"tokenSymbol"`
TokenDecimals int `json:"tokenDecimals"`
TokenDecimals string `json:"tokenDecimals"`
SinkAddress string `json:"sinkAddress"`
}

View File

@ -156,9 +156,7 @@ func (as *AccountService) FetchTransactions(ctx context.Context, publicKey strin
// Parameters:
// - address: The voucher address.
func (as *AccountService) VoucherData(ctx context.Context, address string) (*models.VoucherDataResult, error) {
var r struct {
TokenDetails models.VoucherDataResult `json:"tokenDetails"`
}
var voucherDataResult models.VoucherDataResult
ep, err := url.JoinPath(config.VoucherDataURL, address)
if err != nil {
@ -170,8 +168,8 @@ func (as *AccountService) VoucherData(ctx context.Context, address string) (*mod
return nil, err
}
_, err = doRequest(ctx, req, &r)
return &r.TokenDetails, err
_, err = doRequest(ctx, req, &voucherDataResult)
return &voucherDataResult, err
}
// TokenTransfer creates a new token transfer in the custodial system.

View File

@ -6,4 +6,3 @@ MOUT back 0
HALT
INCMP _ 0
INCMP select_voucher 1
INCMP voucher_details 2

View File

@ -1 +0,0 @@
{{.get_voucher_details}}

View File

@ -1,6 +0,0 @@
CATCH no_voucher flag_no_active_voucher 1
LOAD get_voucher_details 0
MAP get_voucher_details
MOUT back 0
HALT
INCMP _ 0

View File

@ -1 +0,0 @@
{{.get_voucher_details}}