Compare commits
7 Commits
sohail/exp
...
pool-swap-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8c58a8f33
|
||
|
|
67d7ec1567
|
||
|
|
b05734f976
|
||
|
|
f723e0aa45
|
||
|
|
aef8efa2bf
|
||
|
|
a1fe416f51
|
||
|
|
3473a4413b
|
@@ -15,18 +15,16 @@ const (
|
||||
voucherHoldingsPathPrefix = "/api/v1/holdings"
|
||||
voucherTransfersPathPrefix = "/api/v1/transfers/last10"
|
||||
voucherDataPathPrefix = "/api/v1/token"
|
||||
AliasPrefix = "api/v1/alias"
|
||||
SendSMSPrefix = "api/v1/external/upsell"
|
||||
AliasEnsPrefix = "/api/v1/bypass"
|
||||
ExternalSMSPrefix = "/api/v1/external"
|
||||
aliasPrefix = "api/v1/alias"
|
||||
poolDepositPrefix = "/api/v2/pool/deposit"
|
||||
poolSwapQoutePrefix = "/api/v2/pool/quote"
|
||||
poolSwapPrefix = "/api/v2/pool/swap"
|
||||
)
|
||||
|
||||
var (
|
||||
custodialURLBase string
|
||||
dataURLBase string
|
||||
BearerToken string
|
||||
aliasEnsURLBase string
|
||||
externalSMSBase string
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -39,9 +37,9 @@ var (
|
||||
VoucherTransfersURL string
|
||||
VoucherDataURL string
|
||||
CheckAliasURL string
|
||||
SendSMSURL string
|
||||
AliasEnsURL string
|
||||
ExternalSMSURL string
|
||||
PoolDepositURL string
|
||||
PoolSwapQuoteURL string
|
||||
PoolSwapURL string
|
||||
)
|
||||
|
||||
func setBase() error {
|
||||
@@ -49,8 +47,6 @@ func setBase() error {
|
||||
|
||||
custodialURLBase = env.GetEnv("CUSTODIAL_URL_BASE", "http://localhost:5003")
|
||||
dataURLBase = env.GetEnv("DATA_URL_BASE", "http://localhost:5006")
|
||||
aliasEnsURLBase = env.GetEnv("ALIAS_ENS_BASE", "http://localhost:5015")
|
||||
externalSMSBase = env.GetEnv("EXTERNAL_SMS_BASE", "http://localhost:5035")
|
||||
BearerToken = env.GetEnv("BEARER_TOKEN", "")
|
||||
|
||||
_, err = url.Parse(custodialURLBase)
|
||||
@@ -78,10 +74,10 @@ func LoadConfig() error {
|
||||
VoucherHoldingsURL, _ = url.JoinPath(dataURLBase, voucherHoldingsPathPrefix)
|
||||
VoucherTransfersURL, _ = url.JoinPath(dataURLBase, voucherTransfersPathPrefix)
|
||||
VoucherDataURL, _ = url.JoinPath(dataURLBase, voucherDataPathPrefix)
|
||||
CheckAliasURL, _ = url.JoinPath(dataURLBase, AliasPrefix)
|
||||
SendSMSURL, _ = url.JoinPath(dataURLBase, SendSMSPrefix)
|
||||
AliasEnsURL, _ = url.JoinPath(aliasEnsURLBase, AliasEnsPrefix)
|
||||
ExternalSMSURL, _ = url.JoinPath(externalSMSBase, ExternalSMSPrefix)
|
||||
CheckAliasURL, _ = url.JoinPath(dataURLBase, aliasPrefix)
|
||||
PoolDepositURL, _ = url.JoinPath(custodialURLBase, poolDepositPrefix)
|
||||
PoolSwapQuoteURL, _ = url.JoinPath(custodialURLBase, poolSwapQoutePrefix)
|
||||
PoolSwapURL, _ = url.JoinPath(custodialURLBase, poolSwapPrefix)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
162
dev/api.go
162
dev/api.go
@@ -6,19 +6,21 @@ import (
|
||||
"crypto/sha1"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.defalsify.org/vise.git/db"
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.grassecon.net/grassrootseconomics/common/phone"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/grassrootseconomics/go-vise/db"
|
||||
"github.com/grassrootseconomics/go-vise/logging"
|
||||
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||
)
|
||||
|
||||
@@ -91,6 +93,11 @@ type Voucher struct {
|
||||
Location string `json: "location"`
|
||||
}
|
||||
|
||||
type Pool struct {
|
||||
vouchers []Voucher
|
||||
poolLimit map[string]string
|
||||
}
|
||||
|
||||
type DevAccountService struct {
|
||||
db db.Db
|
||||
accounts map[string]Account
|
||||
@@ -106,6 +113,7 @@ type DevAccountService struct {
|
||||
defaultAccount string
|
||||
emitterFunc event.EmitterFunc
|
||||
pfx []byte
|
||||
pool Pool
|
||||
}
|
||||
|
||||
func NewDevAccountService(ctx context.Context, ss storage.StorageService) *DevAccountService {
|
||||
@@ -118,6 +126,7 @@ func NewDevAccountService(ctx context.Context, ss storage.StorageService) *DevAc
|
||||
txs: make(map[string]Tx),
|
||||
txsTrack: make(map[string]string),
|
||||
autoVoucherValue: make(map[string]int),
|
||||
pool: Pool{},
|
||||
defaultAccount: zeroAddress,
|
||||
pfx: []byte("__"),
|
||||
}
|
||||
@@ -171,6 +180,15 @@ func (das *DevAccountService) loadAccount(ctx context.Context, pubKey string, v
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Pool) hasVoucher(voucherAddress string) bool {
|
||||
for _, value := range p.vouchers {
|
||||
if value.Address == voucherAddress {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (das *DevAccountService) loadTx(ctx context.Context, hsh string, v []byte) error {
|
||||
var mytx Tx
|
||||
|
||||
@@ -415,6 +433,74 @@ func (das *DevAccountService) CreateAccount(ctx context.Context) (*models.Accoun
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (das *DevAccountService) PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error) {
|
||||
sym, ok := das.vouchersAddress[tokenAddress]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("voucher address %v not found", tokenAddress)
|
||||
}
|
||||
uid, err := uuid.NewV4()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
voucher, ok := das.vouchers[sym]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("voucher address %v found but does not resolve", tokenAddress)
|
||||
}
|
||||
|
||||
das.pool = Pool{
|
||||
vouchers: append(das.pool.vouchers, voucher),
|
||||
poolLimit: map[string]string{tokenAddress: amount},
|
||||
}
|
||||
return &models.PoolDepositResult{
|
||||
TrackingId: uid.String(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (das *DevAccountService) GetPoolSwapQuote(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapQuoteResult, error) {
|
||||
_, ok := das.accounts[from]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("account not found (publickey): %v", from)
|
||||
}
|
||||
//resolve the token address you are trying to swap from(fromTokenAddress)
|
||||
_, ok = das.vouchersAddress[fromTokenAddress]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("voucher address %v not found", fromTokenAddress)
|
||||
}
|
||||
p := das.pool
|
||||
|
||||
//check if pool has voucher to swap to
|
||||
if !p.hasVoucher(toTokenAddress) {
|
||||
return nil, fmt.Errorf("Voucher with address: %v not found in the pool", toTokenAddress)
|
||||
}
|
||||
//Return a a quote that is equal to the amount enter
|
||||
return &models.PoolSwapQuoteResult{IncludesFeesDeduction: false, OutValue: amount}, nil
|
||||
}
|
||||
|
||||
func (das *DevAccountService) PoolSwap(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapResult, error) {
|
||||
uid, err := uuid.NewV4()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, ok := das.accounts[from]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("account not found (publickey): %v", from)
|
||||
}
|
||||
_, ok = das.vouchersAddress[fromTokenAddress]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("voucher address %v not found", fromTokenAddress)
|
||||
}
|
||||
p := das.pool
|
||||
|
||||
//check if pool has voucher to swap to
|
||||
if !p.hasVoucher(toTokenAddress) {
|
||||
return nil, fmt.Errorf("Voucher with address: %v not found in the pool", toTokenAddress)
|
||||
}
|
||||
|
||||
return &models.PoolSwapResult{TrackingId: uid.String()}, nil
|
||||
}
|
||||
|
||||
func (das *DevAccountService) TrackAccountStatus(ctx context.Context, publicKey string) (*models.TrackStatusResult, error) {
|
||||
var ok bool
|
||||
_, ok = das.accounts[publicKey]
|
||||
@@ -654,17 +740,71 @@ func (das *DevAccountService) RequestAlias(ctx context.Context, publicKey string
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (das *DevAccountService) SendUpsellSMS(ctx context.Context, inviterPhone, inviteePhone string) (*models.SendSMSResponse, error) {
|
||||
logg.DebugCtxf(ctx, "sent an SMS", "inviterPhone", inviterPhone, "inviteePhone", inviteePhone)
|
||||
return &models.SendSMSResponse{
|
||||
Invitee: inviteePhone,
|
||||
}, nil
|
||||
func (das *DevAccountService) FetchTopPools(ctx context.Context) ([]models.Pool, error) {
|
||||
var (
|
||||
r struct {
|
||||
OK bool `json:"ok"`
|
||||
Description string `json:"description"`
|
||||
Result struct {
|
||||
Pools []models.Pool `json:"topPools"`
|
||||
} `json:"result"`
|
||||
}
|
||||
)
|
||||
data, err := os.ReadFile("./data/top_pools.json")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &r)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return r.Result.Pools, nil
|
||||
}
|
||||
|
||||
func (das *DevAccountService) SendPINResetSMS(ctx context.Context, admin, phone string) error {
|
||||
return fmt.Errorf("unimplemented")
|
||||
func (das *DevAccountService) GetPoolSwappableFromVouchers(ctx context.Context) ([]models.SwappableVoucher, error) {
|
||||
var (
|
||||
r struct {
|
||||
OK bool `json:"ok"`
|
||||
Description string `json:"description"`
|
||||
Result struct {
|
||||
SwappableVouchers []models.SwappableVoucher `json:"filtered"`
|
||||
} `json:"result"`
|
||||
}
|
||||
)
|
||||
data, err := os.ReadFile("./data/swap_from.json")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &r)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return r.Result.SwappableVouchers, nil
|
||||
}
|
||||
|
||||
func (das *DevAccountService) SendAddressSMS(ctx context.Context, publicKey, originPhone string) error {
|
||||
return fmt.Errorf("unimplemented")
|
||||
func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context) ([]models.SwappableVoucher, error) {
|
||||
var (
|
||||
r struct {
|
||||
OK bool `json:"ok"`
|
||||
Description string `json:"description"`
|
||||
Result struct {
|
||||
SwappableVouchers []models.SwappableVoucher `json:"filtered"`
|
||||
} `json:"result"`
|
||||
}
|
||||
)
|
||||
data, err := os.ReadFile("./data/swap_to.json")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = json.Unmarshal(data, &r)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return r.Result.SwappableVouchers, nil
|
||||
}
|
||||
|
||||
32
dev/data/swap_from.json
Normal file
32
dev/data/swap_from.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"ok": true,
|
||||
"description": "Swap from list",
|
||||
"result": {
|
||||
"filtered": [
|
||||
{
|
||||
"contractAddress": "0xc7B78Ac9ACB9E025C8234621FC515bC58179dEAe",
|
||||
"tokenSymbol": "AMANI",
|
||||
"tokenDecimals": "6",
|
||||
"balance": ""
|
||||
},
|
||||
{
|
||||
"contractAddress": "0xF0C3C7581b8b96B59a97daEc8Bd48247cE078674",
|
||||
"tokenSymbol": "AMUA",
|
||||
"tokenDecimals": "6",
|
||||
"balance": ""
|
||||
},
|
||||
{
|
||||
"contractAddress": "0x371455a30fc62736145Bd8429Fcc6481186f235F",
|
||||
"tokenSymbol": "BAHARI",
|
||||
"tokenDecimals": "6",
|
||||
"balance": ""
|
||||
},
|
||||
{
|
||||
"contractAddress": "0x7cA6113b59c24a880F382C7E12d609a6Eb05246b",
|
||||
"tokenSymbol": "BANGLA",
|
||||
"tokenDecimals": "6",
|
||||
"balance": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
14
dev/data/swap_to.json
Normal file
14
dev/data/swap_to.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"ok": true,
|
||||
"description": "Swap to list",
|
||||
"result": {
|
||||
"filtered": [
|
||||
{
|
||||
"contractAddress": "0x765DE816845861e75A25fCA122bb6898B8B1282a",
|
||||
"tokenSymbol": "cUSD",
|
||||
"tokenDecimals": "18",
|
||||
"balance": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
43
dev/data/top_pools.json
Normal file
43
dev/data/top_pools.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"ok": true,
|
||||
"description": "Top 5 pools sorted by swaps",
|
||||
"result": {
|
||||
"topPools": [
|
||||
{
|
||||
"poolName": "Kenya ROLA Pool",
|
||||
"poolSymbol": "ROLA",
|
||||
"poolContractAddress": "0x48a953cA5cf5298bc6f6Af3C608351f537AAcb9e",
|
||||
"limiterAddress": "",
|
||||
"voucherRegistry": ""
|
||||
},
|
||||
{
|
||||
"poolName": "Nairobi ROLA Pool",
|
||||
"poolSymbol": "NAIROBI",
|
||||
"poolContractAddress": "0xB0660Ac1Ee3d32ea35bc728D7CA1705Fa5A37528",
|
||||
"limiterAddress": "",
|
||||
"voucherRegistry": ""
|
||||
},
|
||||
{
|
||||
"poolName": "Friends of Kiriba Ecosystem ",
|
||||
"poolSymbol": "FRIENDS",
|
||||
"poolContractAddress": "0xC4848263821FA02baB2181910A2eFb9CECb2c21C",
|
||||
"limiterAddress": "",
|
||||
"voucherRegistry": ""
|
||||
},
|
||||
{
|
||||
"poolName": "Resilient Community Waqfs",
|
||||
"poolSymbol": "REZILIENS",
|
||||
"poolContractAddress": "0x1e40951d7a28147D8B4A554C60c42766C92e2Fc6",
|
||||
"limiterAddress": "",
|
||||
"voucherRegistry": ""
|
||||
},
|
||||
{
|
||||
"poolName": "GrE Tech",
|
||||
"poolSymbol": "GRET",
|
||||
"poolContractAddress": "0xb7B9d0A264eD1a8E2418571B7AC5933C79C9c2B8",
|
||||
"limiterAddress": "",
|
||||
"voucherRegistry": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
17
go.mod
17
go.mod
@@ -1,28 +1,25 @@
|
||||
module git.grassecon.net/grassrootseconomics/sarafu-api
|
||||
|
||||
go 1.24
|
||||
|
||||
toolchain go1.24.2
|
||||
go 1.23.4
|
||||
|
||||
require (
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9
|
||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250507100938-d07f95e1b4ad
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122123424-6749c632b0a2
|
||||
github.com/gofrs/uuid v4.4.0+incompatible
|
||||
github.com/grassrootseconomics/eth-custodial v1.3.0-beta
|
||||
github.com/grassrootseconomics/go-vise v0.4.2
|
||||
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta
|
||||
github.com/stretchr/testify v1.9.0
|
||||
)
|
||||
|
||||
require (
|
||||
git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9 // indirect
|
||||
github.com/barbashov/iso639-3 v0.0.0-20211020172741-1f4ffb2d8d1c // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
|
||||
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||
github.com/jackc/pgx/v5 v5.7.4 // indirect
|
||||
github.com/jackc/pgx/v5 v5.7.1 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||
github.com/joho/godotenv v1.5.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
@@ -31,9 +28,9 @@ require (
|
||||
github.com/rogpeppe/go-internal v1.13.1 // indirect
|
||||
github.com/stretchr/objx v0.5.2 // indirect
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
golang.org/x/crypto v0.38.0 // indirect
|
||||
golang.org/x/sync v0.14.0 // indirect
|
||||
golang.org/x/text v0.25.0 // indirect
|
||||
golang.org/x/crypto v0.32.0 // indirect
|
||||
golang.org/x/sync v0.10.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
gopkg.in/leonelquinteros/gotext.v1 v1.3.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
26
go.sum
26
go.sum
@@ -4,8 +4,6 @@ git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d
|
||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122123424-6749c632b0a2 h1:ON77G5K0JNuwPb5JT/hRfF6G6+xstlBQgEIEzWydnhg=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122123424-6749c632b0a2/go.mod h1:pjKp9L/ZsWW3kMB0UoIl1yv9TBIuU33mn9Aghxp7vGk=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250507100938-d07f95e1b4ad h1:u5em3djRpQ+iMruyDtjCKq+yY+g4dMivz4kbl9hVknw=
|
||||
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250507100938-d07f95e1b4ad/go.mod h1:QnfvU88T7bSoXFkcXrUgTLpKD/YYiXjYh0rfFoNbGaE=
|
||||
github.com/barbashov/iso639-3 v0.0.0-20211020172741-1f4ffb2d8d1c h1:H9Nm+I7Cg/YVPpEV1RzU3Wq2pjamPc/UtHDgItcb7lE=
|
||||
github.com/barbashov/iso639-3 v0.0.0-20211020172741-1f4ffb2d8d1c/go.mod h1:rGod7o6KPeJ+hyBpHfhi4v7blx9sf+QsHsA7KAsdN6U=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
@@ -18,10 +16,6 @@ github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1
|
||||
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/grassrootseconomics/eth-custodial v1.3.0-beta h1:twrMBhl89GqDUL9PlkzQxMP/6OST1BByrNDj+rqXDmU=
|
||||
github.com/grassrootseconomics/eth-custodial v1.3.0-beta/go.mod h1:7uhRcdnJplX4t6GKCEFkbeDhhjlcaGJeJqevbcvGLZo=
|
||||
github.com/grassrootseconomics/go-vise v0.4.1 h1:g26jvYnsWaTns60ZHdltGcsL9cjWqvYZwUZ2FWVKOGo=
|
||||
github.com/grassrootseconomics/go-vise v0.4.1/go.mod h1:tt3/Swp9F9PdhSDBDvwuI1GZRrCg32kWXWzyATIpTO4=
|
||||
github.com/grassrootseconomics/go-vise v0.4.2 h1:6c6ncOCvvXOGWBtMRhuDDLvhsUb+wn11zW6NuCmlFXY=
|
||||
github.com/grassrootseconomics/go-vise v0.4.2/go.mod h1:tt3/Swp9F9PdhSDBDvwuI1GZRrCg32kWXWzyATIpTO4=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta h1:fn1gwbWIwHVEBtUC2zi5OqTlfI/5gU1SMk0fgGixIXk=
|
||||
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta/go.mod h1:omfI0QtUwIdpu9gMcUqLMCG8O1XWjqJGBx1qUMiGWC0=
|
||||
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 h1:U4kkNYryi/qfbBF8gh7Vsbuz+cVmhf5kt6pE9bYYyLo=
|
||||
@@ -30,8 +24,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.7.4 h1:9wKznZrhWa2QiHL+NjTSPP6yjl3451BX3imWDnokYlg=
|
||||
github.com/jackc/pgx/v5 v5.7.4/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ=
|
||||
github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs=
|
||||
github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA=
|
||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
@@ -42,8 +36,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a h1:0Q3H0YXzMHiciXtRcM+j0jiCe8WKPQHoRgQiRTnfcLY=
|
||||
github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a/go.mod h1:CdTTBOYzS5E4mWS1N8NWP6AHI19MP0A2B18n3hLzRMk=
|
||||
github.com/pashagolub/pgxmock/v4 v4.7.0 h1:de2ORuFYyjwOQR7NBm57+321RnZxpYiuUjsmqRiqgh8=
|
||||
github.com/pashagolub/pgxmock/v4 v4.7.0/go.mod h1:9L57pC193h2aKRHVyiiE817avasIPZnPwPlw3JczWvM=
|
||||
github.com/pashagolub/pgxmock/v4 v4.3.0 h1:DqT7fk0OCK6H0GvqtcMsLpv8cIwWqdxWgfZNLeHCb/s=
|
||||
github.com/pashagolub/pgxmock/v4 v4.3.0/go.mod h1:9VoVHXwS3XR/yPtKGzwQvwZX1kzGB9sM8SviDcHDa3A=
|
||||
github.com/peteole/testdata-loader v0.3.0 h1:8jckE9KcyNHgyv/VPoaljvKZE0Rqr8+dPVYH6rfNr9I=
|
||||
github.com/peteole/testdata-loader v0.3.0/go.mod h1:Mt0ZbRtb56u8SLJpNP+BnQbENljMorYBpqlvt3cS83U=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
@@ -60,12 +54,12 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
||||
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
|
||||
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
|
||||
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
|
||||
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
||||
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
||||
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
||||
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
||||
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
|
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
|
||||
@@ -7,13 +7,3 @@ type RequestAliasResult struct {
|
||||
type AliasAddress struct {
|
||||
Address string
|
||||
}
|
||||
|
||||
type AliasEnsResult struct {
|
||||
Address string `json:"address"`
|
||||
AutoChoose bool `json:"autoChoose"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type AliasEnsAddressResult struct {
|
||||
Address string `json:"address"`
|
||||
}
|
||||
|
||||
10
models/pool.go
Normal file
10
models/pool.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package models
|
||||
|
||||
|
||||
type Pool struct {
|
||||
PoolName string `json:"poolName"`
|
||||
PoolSymbol string `json:"poolSymbol"`
|
||||
PoolContractAddress string `json:"poolContractAddress"`
|
||||
LimiterAddress string `json:"limiterAddress"`
|
||||
VoucherRegistry string `json:"voucherRegistry"`
|
||||
}
|
||||
14
models/pool_swap_response.go
Normal file
14
models/pool_swap_response.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package models
|
||||
|
||||
type PoolDepositResult struct {
|
||||
TrackingId string `json:"trackingId"`
|
||||
}
|
||||
|
||||
type PoolSwapQuoteResult struct {
|
||||
IncludesFeesDeduction bool `json:"includesFeesDeduction"`
|
||||
OutValue string `json:"outValue"`
|
||||
}
|
||||
|
||||
type PoolSwapResult struct {
|
||||
TrackingId string `json:"trackingId"`
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package models
|
||||
|
||||
type SendSMSResponse struct {
|
||||
Invitee string `json:"invitee"`
|
||||
}
|
||||
@@ -8,3 +8,10 @@ type VoucherDataResult struct {
|
||||
TokenCommodity string `json:"tokenCommodity"`
|
||||
TokenLocation string `json:"tokenLocation"`
|
||||
}
|
||||
|
||||
type SwappableVoucher struct {
|
||||
ContractAddress string `json:"contractAddress"`
|
||||
TokenSymbol string `json:"tokenSymbol"`
|
||||
TokenDecimals string `json:"tokenDecimals"`
|
||||
Balance string `json:"balance"`
|
||||
}
|
||||
|
||||
@@ -17,7 +17,4 @@ type AccountService interface {
|
||||
TokenTransfer(ctx context.Context, amount, from, to, tokenAddress string) (*models.TokenTransferResponse, error)
|
||||
CheckAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error)
|
||||
RequestAlias(ctx context.Context, hint string, publicKey string) (*models.RequestAliasResult, error)
|
||||
SendUpsellSMS(ctx context.Context, inviterPhone, inviteePhone string) (*models.SendSMSResponse, error)
|
||||
SendAddressSMS(ctx context.Context, publicKey, originPhone string) error
|
||||
SendPINResetSMS(ctx context.Context, admin, phone string) error
|
||||
}
|
||||
|
||||
@@ -11,20 +11,17 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/config"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/dev"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"github.com/grassrootseconomics/eth-custodial/pkg/api"
|
||||
"github.com/grassrootseconomics/go-vise/logging"
|
||||
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||
)
|
||||
|
||||
var (
|
||||
aliasRegex = regexp.MustCompile("^\\+?[a-zA-Z0-9\\-_]+$")
|
||||
logg = logging.NewVanilla().WithDomain("sarafu-api.devapi")
|
||||
)
|
||||
|
||||
type HTTPAccountService struct {
|
||||
@@ -62,10 +59,6 @@ func (as *HTTPAccountService) TrackAccountStatus(ctx context.Context, publicKey
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (as *HTTPAccountService) ToFqdn(alias string) string {
|
||||
return alias + ".sarafu.eth"
|
||||
}
|
||||
|
||||
// CheckBalance retrieves the balance for a given public key from the custodial balance API endpoint.
|
||||
// Parameters:
|
||||
// - publicKey: The public key associated with the account whose balance needs to be checked.
|
||||
@@ -223,10 +216,8 @@ func (as *HTTPAccountService) CheckAliasAddress(ctx context.Context, alias strin
|
||||
if as.SS == nil {
|
||||
return nil, fmt.Errorf("The storage service cannot be nil")
|
||||
}
|
||||
logg.InfoCtxf(ctx, "resolving alias before formatting", "alias", alias)
|
||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||
if as.UseApi {
|
||||
logg.InfoCtxf(ctx, "resolving alias to address", "alias", alias)
|
||||
return resolveAliasAddress(ctx, alias)
|
||||
} else {
|
||||
return svc.CheckAliasAddress(ctx, alias)
|
||||
@@ -234,164 +225,120 @@ func (as *HTTPAccountService) CheckAliasAddress(ctx context.Context, alias strin
|
||||
}
|
||||
|
||||
func resolveAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) {
|
||||
var (
|
||||
aliasEnsResult models.AliasEnsAddressResult
|
||||
)
|
||||
var r models.AliasAddress
|
||||
|
||||
ep, err := url.JoinPath(config.AliasEnsURL, "/resolve")
|
||||
ep, err := url.JoinPath(config.CheckAliasURL, alias)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
u, err := url.Parse(ep)
|
||||
req, err := http.NewRequest("GET", ep, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
query := u.Query()
|
||||
query.Set("name", alias)
|
||||
u.RawQuery = query.Encode()
|
||||
|
||||
req, err := http.NewRequest("GET", u.String(), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = doRequest(ctx, req, &aliasEnsResult)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &models.AliasAddress{Address: aliasEnsResult.Address}, err
|
||||
_, err = doRequest(ctx, req, &r)
|
||||
return &r, err
|
||||
}
|
||||
|
||||
func (as *HTTPAccountService) FetchTopPools(ctx context.Context) ([]models.Pool, error) {
|
||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||
return svc.FetchTopPools(ctx)
|
||||
}
|
||||
|
||||
func (as *HTTPAccountService) PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error) {
|
||||
var r models.PoolDepositResult
|
||||
|
||||
//pool deposit payload
|
||||
payload := map[string]string{
|
||||
"amount": amount,
|
||||
"from": from,
|
||||
"poolAddress": poolAddress,
|
||||
"tokenAddress": tokenAddress,
|
||||
}
|
||||
|
||||
payloadBytes, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := http.NewRequest("POST", config.TokenTransferURL, bytes.NewBuffer(payloadBytes))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = doRequest(ctx, req, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (as *HTTPAccountService) GetPoolSwapQuote(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapQuoteResult, error) {
|
||||
var r models.PoolSwapQuoteResult
|
||||
|
||||
//pool swap quote payload
|
||||
payload := map[string]string{
|
||||
"amount": amount,
|
||||
"from": from,
|
||||
"fromTokenAddress": fromTokenAddress,
|
||||
"poolAddress": poolAddress,
|
||||
"toTokenAddress": toTokenAddress,
|
||||
}
|
||||
|
||||
payloadBytes, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := http.NewRequest("POST", config.PoolSwapQuoteURL, bytes.NewBuffer(payloadBytes))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = doRequest(ctx, req, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (as *HTTPAccountService) GetPoolSwappableFromVouchers(ctx context.Context) ([]models.SwappableVoucher, error) {
|
||||
return as.GetPoolSwappableFromVouchers(ctx)
|
||||
}
|
||||
|
||||
func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context) ([]models.SwappableVoucher, error) {
|
||||
return as.GetPoolSwappableVouchers(ctx)
|
||||
}
|
||||
|
||||
func (as *HTTPAccountService) PoolSwap(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapResult, error) {
|
||||
var r models.PoolSwapResult
|
||||
|
||||
//swap payload
|
||||
payload := map[string]string{
|
||||
"amount": amount,
|
||||
"from": from,
|
||||
"fromTokenAddress": fromTokenAddress,
|
||||
"poolAddress": poolAddress,
|
||||
"toTokenAddress": toTokenAddress,
|
||||
}
|
||||
|
||||
payloadBytes, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := http.NewRequest("POST", config.PoolSwapQuoteURL, bytes.NewBuffer(payloadBytes))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = doRequest(ctx, req, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
// TODO: Use actual custodial api to request available alias
|
||||
func (as *HTTPAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) {
|
||||
if as.SS == nil {
|
||||
return nil, fmt.Errorf("The storage service cannot be nil")
|
||||
}
|
||||
if as.UseApi {
|
||||
if !strings.Contains(hint, ".") {
|
||||
hint = as.ToFqdn(hint)
|
||||
}
|
||||
enr, err := requestEnsAlias(ctx, publicKey, hint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &models.RequestAliasResult{Alias: enr.Name}, nil
|
||||
} else {
|
||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||
return svc.RequestAlias(ctx, publicKey, hint)
|
||||
}
|
||||
}
|
||||
|
||||
func requestEnsAlias(ctx context.Context, publicKey string, hint string) (*models.AliasEnsResult, error) {
|
||||
var r models.AliasEnsResult
|
||||
|
||||
ep, err := url.JoinPath(config.AliasEnsURL, "/register")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logg.InfoCtxf(ctx, "requesting alias", "endpoint", ep, "hint", hint)
|
||||
//Payload with the address and hint to derive an ENS name
|
||||
payload := map[string]string{
|
||||
"address": publicKey,
|
||||
"hint": hint,
|
||||
}
|
||||
payloadBytes, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := http.NewRequest("POST", ep, bytes.NewBuffer(payloadBytes))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Log the request body
|
||||
logg.InfoCtxf(ctx, "request body", "payload", string(payloadBytes))
|
||||
_, err = doRequest(ctx, req, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logg.InfoCtxf(ctx, "alias successfully assigned", "alias", r.Name)
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
// SendSMS calls the API to send out an SMS.
|
||||
// Parameters:
|
||||
// - inviterPhone: The user initiating the SMS.
|
||||
// - inviteePhone: The number being invited to Sarafu.
|
||||
func (as *HTTPAccountService) SendUpsellSMS(ctx context.Context, inviterPhone, inviteePhone string) (*models.SendSMSResponse, error) {
|
||||
var r models.SendSMSResponse
|
||||
|
||||
// Create request payload
|
||||
payload := map[string]string{
|
||||
"inviterPhone": inviterPhone,
|
||||
"inviteePhone": inviteePhone,
|
||||
}
|
||||
|
||||
payloadBytes, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Create a new request
|
||||
req, err := http.NewRequest("POST", config.SendSMSURL, bytes.NewBuffer(payloadBytes))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = doRequest(ctx, req, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
func (as *HTTPAccountService) SendAddressSMS(ctx context.Context, publicKey, originPhone string) error {
|
||||
ep, err := url.JoinPath(config.ExternalSMSURL, "address")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logg.InfoCtxf(ctx, "sending an address sms", "endpoint", ep, "address", publicKey, "origin-phone", originPhone)
|
||||
payload := map[string]string{
|
||||
"address": publicKey,
|
||||
"originPhone": originPhone,
|
||||
}
|
||||
payloadBytes, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req, err := http.NewRequest("POST", ep, bytes.NewBuffer(payloadBytes))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = doRequest(ctx, req, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (as *HTTPAccountService) SendPINResetSMS(ctx context.Context, admin, phone string) error {
|
||||
ep, err := url.JoinPath(config.ExternalSMSURL, "pinreset")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logg.InfoCtxf(ctx, "sending pin reset sms", "endpoint", ep, "admin", admin, "phone", phone)
|
||||
payload := map[string]string{
|
||||
"admin": admin,
|
||||
"phone": phone,
|
||||
}
|
||||
payloadBytes, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req, err := http.NewRequest("POST", ep, bytes.NewBuffer(payloadBytes))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = doRequest(ctx, req, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||
return svc.RequestAlias(ctx, publicKey, hint)
|
||||
}
|
||||
|
||||
// TODO: remove eth-custodial api dependency
|
||||
|
||||
@@ -3,8 +3,8 @@ package mocks
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
|
||||
"github.com/grassrootseconomics/go-vise/logging"
|
||||
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||
)
|
||||
|
||||
@@ -61,7 +61,3 @@ func (m MockApi) RequestAlias(ctx context.Context, publicKey string, hint string
|
||||
func (m MockApi) TokenTransfer(ctx context.Context, amount, from, to, tokenAddress string) (*models.TokenTransferResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m MockApi) SendUpsellSMS(ctx context.Context, inviterPhone, inviteePhone string) (*models.SendSMSResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -53,20 +53,7 @@ func (m *MockAccountService) CheckAliasAddress(ctx context.Context, alias string
|
||||
return args.Get(0).(*models.AliasAddress), args.Error(1)
|
||||
}
|
||||
|
||||
func (m *MockAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) {
|
||||
func (m MockAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) {
|
||||
args := m.Called(publicKey, hint)
|
||||
return args.Get(0).(*models.RequestAliasResult), args.Error(1)
|
||||
}
|
||||
|
||||
func (m *MockAccountService) SendUpsellSMS(ctx context.Context, inviterPhone, inviteePhone string) (*models.SendSMSResponse, error) {
|
||||
args := m.Called(inviterPhone, inviteePhone)
|
||||
return args.Get(0).(*models.SendSMSResponse), args.Error(1)
|
||||
}
|
||||
|
||||
func (m *MockAccountService) SendPINResetSMS(ctx context.Context, admin, phone string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MockAccountService) SendAddressSMS(ctx context.Context, publicKey, originPhone string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -57,22 +57,10 @@ func (tas *TestAccountService) TokenTransfer(ctx context.Context, amount, from,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (m *TestAccountService) CheckAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) {
|
||||
func (m TestAccountService) CheckAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) {
|
||||
return &models.AliasAddress{}, nil
|
||||
}
|
||||
|
||||
func (m *TestAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) {
|
||||
func (m TestAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) {
|
||||
return &models.RequestAliasResult{}, nil
|
||||
}
|
||||
|
||||
func (m *TestAccountService) SendUpsellSMS(ctx context.Context, inviterPhone, inviteePhone string) (*models.SendSMSResponse, error) {
|
||||
return &models.SendSMSResponse{}, nil
|
||||
}
|
||||
|
||||
func (m *TestAccountService) SendAddressSMS(ctx context.Context, publicKey, originPhone string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TestAccountService) SendPINResetSMS(ctx context.Context, admin, phone string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user