Compare commits
No commits in common. "2c98a8e1331861a0c1754ed62ea72baec1853af3" and "cb4a52e4f245bddf9755434004a4cdb7fffd9f65" have entirely different histories.
2c98a8e133
...
cb4a52e4f2
@ -4,7 +4,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
|
|
||||||
"git.grassecon.net/urdt/ussd/config"
|
"git.grassecon.net/urdt/ussd/config"
|
||||||
"git.grassecon.net/urdt/ussd/internal/models"
|
"git.grassecon.net/urdt/ussd/internal/models"
|
||||||
@ -111,16 +110,46 @@ func (as *AccountService) CreateAccount() (*models.AccountResponse, error) {
|
|||||||
// Parameters:
|
// Parameters:
|
||||||
// - publicKey: The public key associated with the account.
|
// - publicKey: The public key associated with the account.
|
||||||
func (as *AccountService) FetchVouchers(publicKey string) (*models.VoucherHoldingResponse, error) {
|
func (as *AccountService) FetchVouchers(publicKey string) (*models.VoucherHoldingResponse, error) {
|
||||||
file, err := os.Open("sample_tokens.json")
|
// TODO replace with the actual request once ready
|
||||||
|
mockJSON := `{
|
||||||
|
"ok": true,
|
||||||
|
"description": "Token holdings with current balances",
|
||||||
|
"result": {
|
||||||
|
"holdings": [
|
||||||
|
{
|
||||||
|
"contractAddress": "0x6CC75A06ac72eB4Db2eE22F781F5D100d8ec03ee",
|
||||||
|
"tokenSymbol": "FSPTST",
|
||||||
|
"tokenDecimals": "6",
|
||||||
|
"balance": "8869964242"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"contractAddress": "0x724F2910D790B54A39a7638282a45B1D83564fFA",
|
||||||
|
"tokenSymbol": "GEO",
|
||||||
|
"tokenDecimals": "6",
|
||||||
|
"balance": "9884"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"contractAddress": "0x2105a206B7bec31E2F90acF7385cc8F7F5f9D273",
|
||||||
|
"tokenSymbol": "MFNK",
|
||||||
|
"tokenDecimals": "6",
|
||||||
|
"balance": "19788697"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"contractAddress": "0x63DE2Ac8D1008351Cc69Fb8aCb94Ba47728a7E83",
|
||||||
|
"tokenSymbol": "MILO",
|
||||||
|
"tokenDecimals": "6",
|
||||||
|
"balance": "75"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
|
||||||
|
// Unmarshal the JSON response
|
||||||
|
var holdings models.VoucherHoldingResponse
|
||||||
|
err := json.Unmarshal([]byte(mockJSON), &holdings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer file.Close()
|
|
||||||
var holdings models.VoucherHoldingResponse
|
|
||||||
|
|
||||||
if err := json.NewDecoder(file).Decode(&holdings); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &holdings, nil
|
return &holdings, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
type ApiResponse struct {
|
|
||||||
OK bool `json:"ok"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
Result Result `json:"result"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Result struct {
|
|
||||||
Holdings []Holding `json:"holdings"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Holding struct {
|
|
||||||
ContractAddress string `json:"contractAddress"`
|
|
||||||
TokenSymbol string `json:"tokenSymbol"`
|
|
||||||
TokenDecimals string `json:"tokenDecimals"`
|
|
||||||
Balance string `json:"balance"`
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
{
|
|
||||||
"ok": true,
|
|
||||||
"description": "Token holdings with current balances",
|
|
||||||
"result": {
|
|
||||||
"holdings": [
|
|
||||||
{
|
|
||||||
"contractAddress": "0x6CC75A06ac72eB4Db2eE22F781F5D100d8ec03ee",
|
|
||||||
"tokenSymbol": "FSPTST",
|
|
||||||
"tokenDecimals": "6",
|
|
||||||
"balance": "8869964242"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"contractAddress": "0x724F2910D790B54A39a7638282a45B1D83564fFA",
|
|
||||||
"tokenSymbol": "GEO",
|
|
||||||
"tokenDecimals": "6",
|
|
||||||
"balance": "9884"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"contractAddress": "0x2105a206B7bec31E2F90acF7385cc8F7F5f9D273",
|
|
||||||
"tokenSymbol": "MFNK",
|
|
||||||
"tokenDecimals": "6",
|
|
||||||
"balance": "19788697"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"contractAddress": "0x63DE2Ac8D1008351Cc69Fb8aCb94Ba47728a7E83",
|
|
||||||
"tokenSymbol": "MILO",
|
|
||||||
"tokenDecimals": "6",
|
|
||||||
"balance": "75"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"contractAddress": "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
|
||||||
"tokenSymbol": "SOHAIL",
|
|
||||||
"tokenDecimals": "6",
|
|
||||||
"balance": "27874115"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"contractAddress": "0x45d747172e77d55575c197CbA9451bC2CD8F4958",
|
|
||||||
"tokenSymbol": "SRF",
|
|
||||||
"tokenDecimals": "6",
|
|
||||||
"balance": "2745987"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user