Return an array of data instead of reading from the file
This commit is contained in:
parent
d7ae1cc096
commit
52e1be1104
133
dev/api.go
133
dev/api.go
@ -6,9 +6,7 @@ import (
|
|||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -740,71 +738,88 @@ func (das *DevAccountService) RequestAlias(ctx context.Context, publicKey string
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) FetchTopPools(ctx context.Context) ([]models.Pool, error) {
|
func (das *DevAccountService) FetchTopPools(ctx context.Context, publicKey string) ([]dataserviceapi.PoolDetails, error) {
|
||||||
var (
|
topPools := []dataserviceapi.PoolDetails{
|
||||||
r struct {
|
{
|
||||||
OK bool `json:"ok"`
|
PoolName: "Kenya ROLA Pool",
|
||||||
Description string `json:"description"`
|
PoolSymbol: "ROLA",
|
||||||
Result struct {
|
PoolContractAdrress: "0x48a953cA5cf5298bc6f6Af3C608351f537AAcb9e",
|
||||||
Pools []models.Pool `json:"topPools"`
|
LimiterAddress: "",
|
||||||
} `json:"result"`
|
VoucherRegistry: "",
|
||||||
}
|
},
|
||||||
)
|
{
|
||||||
data, err := os.ReadFile("./data/top_pools.json")
|
PoolName: "Nairobi ROLA Pool",
|
||||||
if err != nil {
|
PoolSymbol: "NAIROBI",
|
||||||
log.Fatal(err)
|
PoolContractAdrress: "0xB0660Ac1Ee3d32ea35bc728D7CA1705Fa5A37528",
|
||||||
|
LimiterAddress: "",
|
||||||
|
VoucherRegistry: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PoolName: "Friends of Kiriba Ecosystem",
|
||||||
|
PoolSymbol: "FRIENDS",
|
||||||
|
PoolContractAdrress: "0xC4848263821FA02baB2181910A2eFb9CECb2c21C",
|
||||||
|
LimiterAddress: "",
|
||||||
|
VoucherRegistry: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PoolName: "Resilient Community Waqfs",
|
||||||
|
PoolSymbol: "REZILIENS",
|
||||||
|
PoolContractAdrress: "0x1e40951d7a28147D8B4A554C60c42766C92e2Fc6",
|
||||||
|
LimiterAddress: "",
|
||||||
|
VoucherRegistry: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
PoolName: "GrE Tech",
|
||||||
|
PoolSymbol: "GRET",
|
||||||
|
PoolContractAdrress: "0xb7B9d0A264eD1a8E2418571B7AC5933C79C9c2B8",
|
||||||
|
LimiterAddress: "",
|
||||||
|
VoucherRegistry: "",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(data, &r)
|
return topPools, nil
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r.Result.Pools, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) GetPoolSwappableFromVouchers(ctx context.Context) ([]models.SwappableVoucher, error) {
|
func (das *DevAccountService) GetPoolSwappableFromVouchers(ctx context.Context, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
var (
|
swapFromList := []dataserviceapi.TokenHoldings{
|
||||||
r struct {
|
{
|
||||||
OK bool `json:"ok"`
|
ContractAddress: "0xc7B78Ac9ACB9E025C8234621FC515bC58179dEAe",
|
||||||
Description string `json:"description"`
|
TokenSymbol: "AMANI",
|
||||||
Result struct {
|
TokenDecimals: "6",
|
||||||
SwappableVouchers []models.SwappableVoucher `json:"filtered"`
|
Balance: "",
|
||||||
} `json:"result"`
|
},
|
||||||
}
|
{
|
||||||
)
|
ContractAddress: "0xF0C3C7581b8b96B59a97daEc8Bd48247cE078674",
|
||||||
data, err := os.ReadFile("./data/swap_from.json")
|
TokenSymbol: "AMUA",
|
||||||
if err != nil {
|
TokenDecimals: "6",
|
||||||
log.Fatal(err)
|
Balance: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddress: "0x371455a30fc62736145Bd8429Fcc6481186f235F",
|
||||||
|
TokenSymbol: "BAHARI",
|
||||||
|
TokenDecimals: "6",
|
||||||
|
Balance: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ContractAddress: "0x7cA6113b59c24a880F382C7E12d609a6Eb05246b",
|
||||||
|
TokenSymbol: "BANGLA",
|
||||||
|
TokenDecimals: "6",
|
||||||
|
Balance: "",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(data, &r)
|
return swapFromList, nil
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r.Result.SwappableVouchers, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context) ([]models.SwappableVoucher, error) {
|
func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
var (
|
swapToList := []dataserviceapi.TokenHoldings{
|
||||||
r struct {
|
{
|
||||||
OK bool `json:"ok"`
|
ContractAddress: "0x765DE816845861e75A25fCA122bb6898B8B1282a",
|
||||||
Description string `json:"description"`
|
TokenSymbol: "cUSD",
|
||||||
Result struct {
|
TokenDecimals: "18",
|
||||||
SwappableVouchers []models.SwappableVoucher `json:"filtered"`
|
Balance: "",
|
||||||
} `json:"result"`
|
},
|
||||||
}
|
|
||||||
)
|
|
||||||
data, err := os.ReadFile("./data/swap_to.json")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(data, &r)
|
return swapToList, nil
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r.Result.SwappableVouchers, nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user