Compare commits
64 Commits
multi-pool
...
handle-err
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
532547899f
|
||
|
|
6f7802b58c
|
||
|
|
73e6220a8c
|
||
| 8d4fbb9c2e | |||
|
|
61410b2b29
|
||
| c44ac0116f | |||
|
|
814bef2b20
|
||
|
|
12940bb5f2
|
||
|
|
50ee455e70
|
||
|
|
57ee409f96
|
||
|
|
49a8184d02
|
||
|
|
9a6ab7e6e2
|
||
| d177942bd2 | |||
|
|
339ba854c9
|
||
|
|
5aa032400c
|
||
|
|
7b42d509e6
|
||
|
|
d945964b0b
|
||
|
|
c1797e7a32
|
||
|
|
54dfe037b4
|
||
|
|
b5ccaea575
|
||
|
|
bf830e92de
|
||
|
|
24224e553d
|
||
|
|
6c3719e3b6
|
||
|
|
62cc5eed89
|
||
|
|
343d30a2f2
|
||
|
|
a354371a94
|
||
|
|
857f564aae
|
||
|
|
f234d51104
|
||
|
|
81fbc2574c
|
||
|
|
334aa07f9f
|
||
|
|
e6677015d9
|
||
|
|
050998ff82
|
||
|
|
ee434dba69
|
||
|
|
f101ffd4c9
|
||
|
|
8b2bd72143
|
||
|
|
3b85167ad8
|
||
|
|
5d221b8d56 | ||
|
|
341901ec83
|
||
|
|
ed416c57c7
|
||
|
|
6fc99661f7
|
||
|
|
d509477de3
|
||
|
|
4ea8fd1f04
|
||
|
|
5c0ed48e67
|
||
|
|
5ff139b649
|
||
|
|
86cfb9c020
|
||
|
|
58366274c3
|
||
|
|
b85511e436
|
||
|
|
a243fe8c29
|
||
|
|
492b101aa4
|
||
| 34957e5b6f | |||
|
|
6597d6b6a2
|
||
|
|
441e289854
|
||
|
|
5b41c8dc64
|
||
|
|
417e7f0179
|
||
|
|
2eed990921
|
||
|
|
56ed9b2439
|
||
|
|
064e749b04
|
||
|
|
80c2493e80
|
||
|
|
4444ac0255
|
||
|
|
720fa94b56
|
||
|
|
ee04552cbb
|
||
|
|
4a5de68a8c
|
||
|
|
6c4702e2ba
|
||
|
|
7280784ee1
|
@@ -7,42 +7,56 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
createAccountPath = "/api/v2/account/create"
|
createAccountPath = "/api/v2/account/create"
|
||||||
trackStatusPath = "/api/track"
|
trackStatusPath = "/api/track"
|
||||||
balancePathPrefix = "/api/account"
|
balancePathPrefix = "/api/account"
|
||||||
trackPath = "/api/v2/account/status"
|
trackPath = "/api/v2/account/status"
|
||||||
tokenTransferPrefix = "/api/v2/token/transfer"
|
tokenTransferPrefix = "/api/v2/token/transfer"
|
||||||
voucherHoldingsPathPrefix = "/api/v1/holdings"
|
voucherHoldingsPathPrefix = "/api/v1/holdings"
|
||||||
voucherTransfersPathPrefix = "/api/v1/transfers/last10"
|
voucherTransfersPathPrefix = "/api/v1/transfers/last10"
|
||||||
voucherDataPathPrefix = "/api/v1/token"
|
voucherDataPathPrefix = "/api/v1/token"
|
||||||
aliasPrefix = "api/v1/alias"
|
SendSMSPrefix = "api/v1/external/upsell"
|
||||||
poolDepositPrefix = "/api/v2/pool/deposit"
|
poolDepositPrefix = "/api/v2/pool/deposit"
|
||||||
poolSwapQoutePrefix = "/api/v2/pool/quote"
|
poolSwapQoutePrefix = "/api/v2/pool/quote"
|
||||||
poolSwapPrefix = "/api/v2/pool/swap"
|
poolSwapPrefix = "/api/v2/pool/swap"
|
||||||
AliasEnsPrefix = "/api/v1/bypass"
|
topPoolsPrefix = "/api/v1/pool/top"
|
||||||
|
retrievePoolDetailsPrefix = "/api/v1/pool/reverse"
|
||||||
|
poolSwappableVouchersPrefix = "/api/v1/pool"
|
||||||
|
AliasRegistrationPrefix = "/api/v1/internal/register"
|
||||||
|
AliasResolverPrefix = "/api/v1/resolve"
|
||||||
|
ExternalSMSPrefix = "/api/v1/external"
|
||||||
|
AliasUpdatePrefix = "/api/v1/internal/update"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
custodialURLBase string
|
custodialURLBase string
|
||||||
dataURLBase string
|
dataURLBase string
|
||||||
BearerToken string
|
BearerToken string
|
||||||
aliasEnsURLBase string
|
aliasEnsURLBase string
|
||||||
|
externalSMSBase string
|
||||||
|
IncludeStablesParam string
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
CreateAccountURL string
|
CreateAccountURL string
|
||||||
TrackStatusURL string
|
TrackStatusURL string
|
||||||
BalanceURL string
|
BalanceURL string
|
||||||
TrackURL string
|
TrackURL string
|
||||||
TokenTransferURL string
|
TokenTransferURL string
|
||||||
VoucherHoldingsURL string
|
VoucherHoldingsURL string
|
||||||
VoucherTransfersURL string
|
VoucherTransfersURL string
|
||||||
VoucherDataURL string
|
VoucherDataURL string
|
||||||
CheckAliasURL string
|
PoolDepositURL string
|
||||||
PoolDepositURL string
|
PoolSwapQuoteURL string
|
||||||
PoolSwapQuoteURL string
|
PoolSwapURL string
|
||||||
PoolSwapURL string
|
TopPoolsURL string
|
||||||
AliasEnsURL string
|
RetrievePoolDetailsURL string
|
||||||
|
PoolSwappableVouchersURL string
|
||||||
|
SendSMSURL string
|
||||||
|
AliasRegistrationURL string
|
||||||
|
AliasResolverURL string
|
||||||
|
ExternalSMSURL string
|
||||||
|
AliasUpdateURL string
|
||||||
)
|
)
|
||||||
|
|
||||||
func setBase() error {
|
func setBase() error {
|
||||||
@@ -51,7 +65,9 @@ func setBase() error {
|
|||||||
custodialURLBase = env.GetEnv("CUSTODIAL_URL_BASE", "http://localhost:5003")
|
custodialURLBase = env.GetEnv("CUSTODIAL_URL_BASE", "http://localhost:5003")
|
||||||
dataURLBase = env.GetEnv("DATA_URL_BASE", "http://localhost:5006")
|
dataURLBase = env.GetEnv("DATA_URL_BASE", "http://localhost:5006")
|
||||||
aliasEnsURLBase = env.GetEnv("ALIAS_ENS_BASE", "http://localhost:5015")
|
aliasEnsURLBase = env.GetEnv("ALIAS_ENS_BASE", "http://localhost:5015")
|
||||||
|
externalSMSBase = env.GetEnv("EXTERNAL_SMS_BASE", "http://localhost:5035")
|
||||||
BearerToken = env.GetEnv("BEARER_TOKEN", "")
|
BearerToken = env.GetEnv("BEARER_TOKEN", "")
|
||||||
|
IncludeStablesParam = env.GetEnv("INCLUDE_STABLES_PARAM", "false")
|
||||||
|
|
||||||
_, err = url.Parse(custodialURLBase)
|
_, err = url.Parse(custodialURLBase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -78,11 +94,17 @@ func LoadConfig() error {
|
|||||||
VoucherHoldingsURL, _ = url.JoinPath(dataURLBase, voucherHoldingsPathPrefix)
|
VoucherHoldingsURL, _ = url.JoinPath(dataURLBase, voucherHoldingsPathPrefix)
|
||||||
VoucherTransfersURL, _ = url.JoinPath(dataURLBase, voucherTransfersPathPrefix)
|
VoucherTransfersURL, _ = url.JoinPath(dataURLBase, voucherTransfersPathPrefix)
|
||||||
VoucherDataURL, _ = url.JoinPath(dataURLBase, voucherDataPathPrefix)
|
VoucherDataURL, _ = url.JoinPath(dataURLBase, voucherDataPathPrefix)
|
||||||
CheckAliasURL, _ = url.JoinPath(dataURLBase, aliasPrefix)
|
SendSMSURL, _ = url.JoinPath(dataURLBase, SendSMSPrefix)
|
||||||
PoolDepositURL, _ = url.JoinPath(custodialURLBase, poolDepositPrefix)
|
PoolDepositURL, _ = url.JoinPath(custodialURLBase, poolDepositPrefix)
|
||||||
PoolSwapQuoteURL, _ = url.JoinPath(custodialURLBase, poolSwapQoutePrefix)
|
PoolSwapQuoteURL, _ = url.JoinPath(custodialURLBase, poolSwapQoutePrefix)
|
||||||
PoolSwapURL, _ = url.JoinPath(custodialURLBase, poolSwapPrefix)
|
PoolSwapURL, _ = url.JoinPath(custodialURLBase, poolSwapPrefix)
|
||||||
|
TopPoolsURL, _ = url.JoinPath(dataURLBase, topPoolsPrefix)
|
||||||
|
RetrievePoolDetailsURL, _ = url.JoinPath(dataURLBase, retrievePoolDetailsPrefix)
|
||||||
|
PoolSwappableVouchersURL, _ = url.JoinPath(dataURLBase, poolSwappableVouchersPrefix)
|
||||||
|
AliasRegistrationURL, _ = url.JoinPath(aliasEnsURLBase, AliasRegistrationPrefix)
|
||||||
|
AliasResolverURL, _ = url.JoinPath(aliasEnsURLBase, AliasResolverPrefix)
|
||||||
|
ExternalSMSURL, _ = url.JoinPath(externalSMSBase, ExternalSMSPrefix)
|
||||||
|
AliasUpdateURL, _ = url.JoinPath(aliasEnsURLBase, AliasUpdatePrefix)
|
||||||
|
|
||||||
AliasEnsURL, _ = url.JoinPath(aliasEnsURLBase, AliasEnsPrefix)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
55
dev/api.go
55
dev/api.go
@@ -233,7 +233,6 @@ func (das *DevAccountService) loadItem(ctx context.Context, k []byte, v []byte)
|
|||||||
if len(ss) != 2 {
|
if len(ss) != 2 {
|
||||||
return fmt.Errorf("malformed key: %s", s)
|
return fmt.Errorf("malformed key: %s", s)
|
||||||
}
|
}
|
||||||
fmt.Println("S1", ss[0])
|
|
||||||
if ss[0] == "account" {
|
if ss[0] == "account" {
|
||||||
err = das.loadAccount(ctx, ss[1], v)
|
err = das.loadAccount(ctx, ss[1], v)
|
||||||
logg.ErrorCtxf(ctx, "loading saved account failed", "error_load_account", err)
|
logg.ErrorCtxf(ctx, "loading saved account failed", "error_load_account", err)
|
||||||
@@ -588,7 +587,7 @@ func (das *DevAccountService) FetchVouchers(ctx context.Context, publicKey strin
|
|||||||
//TODO: Iterate over the account acc.Balances object
|
//TODO: Iterate over the account acc.Balances object
|
||||||
for _, voucher := range das.vouchers {
|
for _, voucher := range das.vouchers {
|
||||||
holdings = append(holdings, dataserviceapi.TokenHoldings{
|
holdings = append(holdings, dataserviceapi.TokenHoldings{
|
||||||
ContractAddress: voucher.Address,
|
TokenAddress: voucher.Address,
|
||||||
TokenSymbol: voucher.Symbol,
|
TokenSymbol: voucher.Symbol,
|
||||||
TokenDecimals: strconv.Itoa(voucher.Decimals),
|
TokenDecimals: strconv.Itoa(voucher.Decimals),
|
||||||
Balance: strconv.Itoa(int(defaultVoucherBalance)),
|
Balance: strconv.Itoa(int(defaultVoucherBalance)),
|
||||||
@@ -807,6 +806,28 @@ func (das *DevAccountService) RequestAlias(ctx context.Context, publicKey string
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (das *DevAccountService) UpdateAlias(ctx context.Context, publicKey string, name string) (*models.RequestAliasResult, error) {
|
||||||
|
logg.DebugCtxf(ctx, "Updated the alias", "address", publicKey, "name", name)
|
||||||
|
return &models.RequestAliasResult{
|
||||||
|
Alias: name,
|
||||||
|
}, 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) SendPINResetSMS(ctx context.Context, admin, phone string) error {
|
||||||
|
return fmt.Errorf("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (das *DevAccountService) SendAddressSMS(ctx context.Context, publicKey, originPhone string) error {
|
||||||
|
return fmt.Errorf("unimplemented")
|
||||||
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error) {
|
func (das *DevAccountService) FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error) {
|
||||||
var topPools []dataserviceapi.PoolDetails
|
var topPools []dataserviceapi.PoolDetails
|
||||||
for _, p := range das.pools {
|
for _, p := range das.pools {
|
||||||
@@ -819,6 +840,18 @@ func (das *DevAccountService) FetchTopPools(ctx context.Context) ([]dataservicea
|
|||||||
return topPools, nil
|
return topPools, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (das *DevAccountService) RetrievePoolDetails(ctx context.Context, sym string) (*dataserviceapi.PoolDetails, error) {
|
||||||
|
testPool := &dataserviceapi.PoolDetails{
|
||||||
|
PoolName: "DevTest",
|
||||||
|
PoolSymbol: "DEVT",
|
||||||
|
PoolContractAdrress: "0x145F87d6198dEDD45C614FFD8b70E9a2fCCc5cc9",
|
||||||
|
LimiterAddress: "",
|
||||||
|
VoucherRegistry: "",
|
||||||
|
}
|
||||||
|
|
||||||
|
return testPool, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (das *DevAccountService) GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
var swapFromList []dataserviceapi.TokenHoldings
|
var swapFromList []dataserviceapi.TokenHoldings
|
||||||
|
|
||||||
@@ -828,7 +861,7 @@ func (das *DevAccountService) GetPoolSwappableFromVouchers(ctx context.Context,
|
|||||||
}
|
}
|
||||||
for _, v := range p.Vouchers {
|
for _, v := range p.Vouchers {
|
||||||
swapFromList = append(swapFromList, dataserviceapi.TokenHoldings{
|
swapFromList = append(swapFromList, dataserviceapi.TokenHoldings{
|
||||||
ContractAddress: v.Address,
|
TokenAddress: v.Address,
|
||||||
TokenSymbol: v.Symbol,
|
TokenSymbol: v.Symbol,
|
||||||
TokenDecimals: string(defaultDecimals),
|
TokenDecimals: string(defaultDecimals),
|
||||||
Balance: fmt.Sprintf("%f", defaultVoucherBalance),
|
Balance: fmt.Sprintf("%f", defaultVoucherBalance),
|
||||||
@@ -838,7 +871,7 @@ func (das *DevAccountService) GetPoolSwappableFromVouchers(ctx context.Context,
|
|||||||
return swapFromList, nil
|
return swapFromList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
var swapToList []dataserviceapi.TokenHoldings
|
var swapToList []dataserviceapi.TokenHoldings
|
||||||
_, ok := das.pools[poolAddress]
|
_, ok := das.pools[poolAddress]
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -846,17 +879,15 @@ func (das *DevAccountService) GetPoolSwappableVouchers(ctx context.Context, pool
|
|||||||
}
|
}
|
||||||
for _, voucher := range das.vouchers {
|
for _, voucher := range das.vouchers {
|
||||||
swapToList = append(swapToList, dataserviceapi.TokenHoldings{
|
swapToList = append(swapToList, dataserviceapi.TokenHoldings{
|
||||||
ContractAddress: voucher.Address,
|
TokenAddress: voucher.Address,
|
||||||
TokenSymbol: voucher.Symbol,
|
TokenSymbol: voucher.Symbol,
|
||||||
TokenDecimals: string(defaultDecimals),
|
TokenDecimals: strconv.Itoa(voucher.Decimals),
|
||||||
Balance: fmt.Sprintf("%f", defaultVoucherBalance),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return swapToList, nil
|
return swapToList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error) {
|
func (das *DevAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error) {
|
||||||
|
|
||||||
p, ok := das.pools[poolAddress]
|
p, ok := das.pools[poolAddress]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("Pool address: %v not found ", poolAddress)
|
return nil, fmt.Errorf("Pool address: %v not found ", poolAddress)
|
||||||
@@ -870,3 +901,9 @@ func (das *DevAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, pool
|
|||||||
Max: limit,
|
Max: limit,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (das *DevAccountService) CheckTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error) {
|
||||||
|
return &models.TokenInPoolResult{
|
||||||
|
CanSwapFrom: true,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -8,7 +8,7 @@ require (
|
|||||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122123424-6749c632b0a2
|
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122123424-6749c632b0a2
|
||||||
github.com/gofrs/uuid v4.4.0+incompatible
|
github.com/gofrs/uuid v4.4.0+incompatible
|
||||||
github.com/grassrootseconomics/eth-custodial v1.3.0-beta
|
github.com/grassrootseconomics/eth-custodial v1.3.0-beta
|
||||||
github.com/grassrootseconomics/ussd-data-service v1.4.0-beta
|
github.com/grassrootseconomics/ussd-data-service v1.6.0-beta
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
8
go.sum
8
go.sum
@@ -20,6 +20,14 @@ github.com/grassrootseconomics/ussd-data-service v1.2.0-beta h1:fn1gwbWIwHVEBtUC
|
|||||||
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta/go.mod h1:omfI0QtUwIdpu9gMcUqLMCG8O1XWjqJGBx1qUMiGWC0=
|
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta/go.mod h1:omfI0QtUwIdpu9gMcUqLMCG8O1XWjqJGBx1qUMiGWC0=
|
||||||
github.com/grassrootseconomics/ussd-data-service v1.4.0-beta h1:4fMd/3h2ZIhRg4GdHQmRw5FfD3MpJvFNNJQo+Q27f5M=
|
github.com/grassrootseconomics/ussd-data-service v1.4.0-beta h1:4fMd/3h2ZIhRg4GdHQmRw5FfD3MpJvFNNJQo+Q27f5M=
|
||||||
github.com/grassrootseconomics/ussd-data-service v1.4.0-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
github.com/grassrootseconomics/ussd-data-service v1.4.0-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
||||||
|
github.com/grassrootseconomics/ussd-data-service v1.4.4-beta h1:turlyo0i3OLj29mWpWNoB/3Qao8qEngT/5d1jDWTZE4=
|
||||||
|
github.com/grassrootseconomics/ussd-data-service v1.4.4-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
||||||
|
github.com/grassrootseconomics/ussd-data-service v1.4.7-beta h1:yAe1YaOBsdxW2m20jnVU4F0kLmFr+mK/gHCWEdHmE90=
|
||||||
|
github.com/grassrootseconomics/ussd-data-service v1.4.7-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
||||||
|
github.com/grassrootseconomics/ussd-data-service v1.5.0-beta h1:BSSQL/yPEvTVku9ja/ENZyZdwZkEaiTzzOUfg72bTy4=
|
||||||
|
github.com/grassrootseconomics/ussd-data-service v1.5.0-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
||||||
|
github.com/grassrootseconomics/ussd-data-service v1.6.0-beta h1:pY6zns6ifXyClRxP+JJaWrged3oRE7tTS2xaftF9clA=
|
||||||
|
github.com/grassrootseconomics/ussd-data-service v1.6.0-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
||||||
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 h1:U4kkNYryi/qfbBF8gh7Vsbuz+cVmhf5kt6pE9bYYyLo=
|
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 h1:U4kkNYryi/qfbBF8gh7Vsbuz+cVmhf5kt6pE9bYYyLo=
|
||||||
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4/go.mod h1:zpZDgZFzeq9s0MIeB1P50NIEWDFFHSFBohI/NbaTD/Y=
|
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4/go.mod h1:zpZDgZFzeq9s0MIeB1P50NIEWDFFHSFBohI/NbaTD/Y=
|
||||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||||
|
|||||||
@@ -16,3 +16,7 @@ type PoolSwapResult struct {
|
|||||||
type MaxLimitResult struct {
|
type MaxLimitResult struct {
|
||||||
Max string `json:"max"`
|
Max string `json:"max"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TokenInPoolResult struct {
|
||||||
|
CanSwapFrom bool `json:"canSwapFrom"`
|
||||||
|
}
|
||||||
|
|||||||
5
models/send_sms_response.go
Normal file
5
models/send_sms_response.go
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
type SendSMSResponse struct {
|
||||||
|
Invitee string `json:"invitee"`
|
||||||
|
}
|
||||||
@@ -17,11 +17,17 @@ type AccountService interface {
|
|||||||
TokenTransfer(ctx context.Context, amount, from, to, tokenAddress string) (*models.TokenTransferResponse, error)
|
TokenTransfer(ctx context.Context, amount, from, to, tokenAddress string) (*models.TokenTransferResponse, error)
|
||||||
CheckAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error)
|
CheckAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error)
|
||||||
RequestAlias(ctx context.Context, hint string, publicKey string) (*models.RequestAliasResult, error)
|
RequestAlias(ctx context.Context, hint string, publicKey string) (*models.RequestAliasResult, error)
|
||||||
|
UpdateAlias(ctx context.Context, name 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
|
||||||
PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error)
|
PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error)
|
||||||
FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error)
|
FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error)
|
||||||
|
RetrievePoolDetails(ctx context.Context, sym string) (*dataserviceapi.PoolDetails, error)
|
||||||
GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error)
|
GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error)
|
||||||
GetPoolSwappableVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error)
|
GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error)
|
||||||
GetPoolSwapQuote(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapQuoteResult, error)
|
GetPoolSwapQuote(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapQuoteResult, error)
|
||||||
PoolSwap(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapResult, error)
|
PoolSwap(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapResult, error)
|
||||||
GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error)
|
GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error)
|
||||||
|
CheckTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,11 +27,36 @@ var (
|
|||||||
logg = logging.NewVanilla().WithDomain("sarafu-api.devapi")
|
logg = logging.NewVanilla().WithDomain("sarafu-api.devapi")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type APIError struct {
|
||||||
|
Code string
|
||||||
|
Description string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *APIError) Error() string {
|
||||||
|
if e.Code != "" {
|
||||||
|
return fmt.Sprintf("[%s] %s", e.Code, e.Description)
|
||||||
|
}
|
||||||
|
return e.Description
|
||||||
|
}
|
||||||
|
|
||||||
type HTTPAccountService struct {
|
type HTTPAccountService struct {
|
||||||
SS storage.StorageService
|
SS storage.StorageService
|
||||||
UseApi bool
|
UseApi bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// symbolReplacements holds mappings of invalid symbols → valid ones
|
||||||
|
var symbolReplacements = map[string]string{
|
||||||
|
"USD₮": "USDT",
|
||||||
|
}
|
||||||
|
|
||||||
|
// sanitizeSymbol replaces known invalid token symbols with normalized ones
|
||||||
|
func sanitizeSymbol(symbol string) string {
|
||||||
|
if replacement, ok := symbolReplacements[symbol]; ok {
|
||||||
|
return replacement
|
||||||
|
}
|
||||||
|
return symbol
|
||||||
|
}
|
||||||
|
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// - trackingId: A unique identifier for the account.This should be obtained from a previous call to
|
// - trackingId: A unique identifier for the account.This should be obtained from a previous call to
|
||||||
// CreateAccount or a similar function that returns an AccountResponse. The `trackingId` field in the
|
// CreateAccount or a similar function that returns an AccountResponse. The `trackingId` field in the
|
||||||
@@ -130,6 +155,11 @@ func (as *HTTPAccountService) FetchVouchers(ctx context.Context, publicKey strin
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Normalize symbols before returning
|
||||||
|
for i := range r.Holdings {
|
||||||
|
r.Holdings[i].TokenSymbol = sanitizeSymbol(r.Holdings[i].TokenSymbol)
|
||||||
|
}
|
||||||
|
|
||||||
return r.Holdings, nil
|
return r.Holdings, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +186,11 @@ func (as *HTTPAccountService) FetchTransactions(ctx context.Context, publicKey s
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Normalize symbols before returning
|
||||||
|
for i := range r.Transfers {
|
||||||
|
r.Transfers[i].TokenSymbol = sanitizeSymbol(r.Transfers[i].TokenSymbol)
|
||||||
|
}
|
||||||
|
|
||||||
return r.Transfers, nil
|
return r.Transfers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,6 +212,9 @@ func (as *HTTPAccountService) VoucherData(ctx context.Context, address string) (
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Normalize symbols before returning
|
||||||
|
r.TokenDetails.TokenSymbol = sanitizeSymbol(r.TokenDetails.TokenSymbol)
|
||||||
|
|
||||||
_, err = doRequest(ctx, req, &r)
|
_, err = doRequest(ctx, req, &r)
|
||||||
return &r.TokenDetails, err
|
return &r.TokenDetails, err
|
||||||
}
|
}
|
||||||
@@ -234,38 +272,76 @@ func (as *HTTPAccountService) CheckAliasAddress(ctx context.Context, alias strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
func resolveAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) {
|
func resolveAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) {
|
||||||
var (
|
var aliasEnsResult models.AliasEnsAddressResult
|
||||||
aliasEnsResult models.AliasEnsAddressResult
|
|
||||||
)
|
|
||||||
|
|
||||||
ep, err := url.JoinPath(config.AliasEnsURL, "/resolve")
|
fullURL, err := url.JoinPath(config.AliasResolverURL, alias)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
u, err := url.Parse(ep)
|
req, err := http.NewRequest("GET", fullURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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)
|
_, err = doRequest(ctx, req, &aliasEnsResult)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &models.AliasAddress{Address: aliasEnsResult.Address}, err
|
|
||||||
|
return &models.AliasAddress{Address: aliasEnsResult.Address}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error) {
|
func (as *HTTPAccountService) FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error) {
|
||||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||||
return svc.FetchTopPools(ctx)
|
if as.UseApi {
|
||||||
|
return fetchCustodialTopPools(ctx)
|
||||||
|
} else {
|
||||||
|
return svc.FetchTopPools(ctx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func fetchCustodialTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error) {
|
||||||
|
var r struct {
|
||||||
|
TopPools []dataserviceapi.PoolDetails `json:"topPools"`
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", config.TopPoolsURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = doRequest(ctx, req, &r)
|
||||||
|
return r.TopPools, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (as *HTTPAccountService) RetrievePoolDetails(ctx context.Context, sym string) (*dataserviceapi.PoolDetails, error) {
|
||||||
|
if as.UseApi {
|
||||||
|
return retrievePoolDetails(ctx, sym)
|
||||||
|
} else {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func retrievePoolDetails(ctx context.Context, sym string) (*dataserviceapi.PoolDetails, error) {
|
||||||
|
var r struct {
|
||||||
|
PoolDetails dataserviceapi.PoolDetails `json:"poolDetails"`
|
||||||
|
}
|
||||||
|
|
||||||
|
ep, err := url.JoinPath(config.RetrievePoolDetailsURL, sym)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req, err := http.NewRequest("GET", ep, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_, err = doRequest(ctx, req, &r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &r.PoolDetails, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error) {
|
func (as *HTTPAccountService) PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error) {
|
||||||
@@ -310,6 +386,7 @@ func (as *HTTPAccountService) GetPoolSwapQuote(ctx context.Context, amount, from
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", config.PoolSwapQuoteURL, bytes.NewBuffer(payloadBytes))
|
req, err := http.NewRequest("POST", config.PoolSwapQuoteURL, bytes.NewBuffer(payloadBytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -322,13 +399,85 @@ func (as *HTTPAccountService) GetPoolSwapQuote(ctx context.Context, amount, from
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (as *HTTPAccountService) GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
if as.UseApi {
|
||||||
return svc.GetPoolSwappableFromVouchers(ctx, poolAddress, publicKey)
|
return as.getPoolSwappableFromVouchers(ctx, poolAddress, publicKey)
|
||||||
|
} else {
|
||||||
|
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||||
|
return svc.GetPoolSwappableFromVouchers(ctx, poolAddress, publicKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (as *HTTPAccountService) getPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
|
var r struct {
|
||||||
|
PoolSwappableVouchers []dataserviceapi.TokenHoldings `json:"filtered"`
|
||||||
|
}
|
||||||
|
ep, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "from", publicKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req, err := http.NewRequest("GET", ep, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_, err = doRequest(ctx, req, &r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalize symbols before returning
|
||||||
|
for i := range r.PoolSwappableVouchers {
|
||||||
|
r.PoolSwappableVouchers[i].TokenSymbol = sanitizeSymbol(r.PoolSwappableVouchers[i].TokenSymbol)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r.PoolSwappableVouchers, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||||
return svc.GetPoolSwappableVouchers(ctx, poolAddress, publicKey)
|
if as.UseApi {
|
||||||
|
return as.getPoolSwappableVouchers(ctx, poolAddress)
|
||||||
|
} else {
|
||||||
|
return svc.GetPoolSwappableVouchers(ctx, poolAddress)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (as HTTPAccountService) getPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
|
var r struct {
|
||||||
|
PoolSwappableVouchers []dataserviceapi.TokenHoldings `json:"filtered"`
|
||||||
|
}
|
||||||
|
|
||||||
|
basePath, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "to")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
parsedURL, err := url.Parse(basePath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
query := parsedURL.Query()
|
||||||
|
if config.IncludeStablesParam != "" {
|
||||||
|
query.Set("stables", config.IncludeStablesParam)
|
||||||
|
}
|
||||||
|
parsedURL.RawQuery = query.Encode()
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", parsedURL.String(), nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = doRequest(ctx, req, &r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalize symbols before returning
|
||||||
|
for i := range r.PoolSwappableVouchers {
|
||||||
|
r.PoolSwappableVouchers[i].TokenSymbol = sanitizeSymbol(r.PoolSwappableVouchers[i].TokenSymbol)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r.PoolSwappableVouchers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) PoolSwap(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapResult, error) {
|
func (as *HTTPAccountService) PoolSwap(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapResult, error) {
|
||||||
@@ -347,7 +496,8 @@ func (as *HTTPAccountService) PoolSwap(ctx context.Context, amount, from, fromTo
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
req, err := http.NewRequest("POST", config.PoolSwapQuoteURL, bytes.NewBuffer(payloadBytes))
|
|
||||||
|
req, err := http.NewRequest("POST", config.PoolSwapURL, bytes.NewBuffer(payloadBytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -359,10 +509,62 @@ func (as *HTTPAccountService) PoolSwap(ctx context.Context, amount, from, fromTo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error) {
|
func (as *HTTPAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error) {
|
||||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
if as.UseApi {
|
||||||
return svc.GetSwapFromTokenMaxLimit(ctx, poolAddress, fromTokenAddress, toTokenAddress, publicKey)
|
return as.getSwapFromTokenMaxLimit(ctx, poolAddress, fromTokenAddress, toTokenAddress, publicKey)
|
||||||
|
} else {
|
||||||
|
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||||
|
return svc.GetSwapFromTokenMaxLimit(ctx, poolAddress, fromTokenAddress, toTokenAddress, publicKey)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (as *HTTPAccountService) getSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokeAddress, publicKey string) (*models.MaxLimitResult, error) {
|
||||||
|
var r models.MaxLimitResult
|
||||||
|
|
||||||
|
ep, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "limit", fromTokenAddress, toTokeAddress, publicKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req, err := http.NewRequest("GET", ep, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_, err = doRequest(ctx, req, &r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &r, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (as *HTTPAccountService) CheckTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error) {
|
||||||
|
if as.UseApi {
|
||||||
|
return as.checkTokenInPool(ctx, poolAddress, tokenAddress)
|
||||||
|
} else {
|
||||||
|
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||||
|
return svc.CheckTokenInPool(ctx, poolAddress, tokenAddress)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (as *HTTPAccountService) checkTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error) {
|
||||||
|
var r models.TokenInPoolResult
|
||||||
|
|
||||||
|
ep, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "check", tokenAddress)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req, err := http.NewRequest("GET", ep, nil)
|
||||||
|
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) {
|
func (as *HTTPAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) {
|
||||||
if as.SS == nil {
|
if as.SS == nil {
|
||||||
return nil, fmt.Errorf("The storage service cannot be nil")
|
return nil, fmt.Errorf("The storage service cannot be nil")
|
||||||
@@ -385,11 +587,9 @@ func (as *HTTPAccountService) RequestAlias(ctx context.Context, publicKey string
|
|||||||
func requestEnsAlias(ctx context.Context, publicKey string, hint string) (*models.AliasEnsResult, error) {
|
func requestEnsAlias(ctx context.Context, publicKey string, hint string) (*models.AliasEnsResult, error) {
|
||||||
var r models.AliasEnsResult
|
var r models.AliasEnsResult
|
||||||
|
|
||||||
ep, err := url.JoinPath(config.AliasEnsURL, "/register")
|
endpoint := config.AliasRegistrationURL
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
logg.InfoCtxf(ctx, "requesting alias", "endpoint", endpoint, "hint", hint)
|
||||||
}
|
|
||||||
logg.InfoCtxf(ctx, "requesting alias", "endpoint", ep, "hint", hint)
|
|
||||||
//Payload with the address and hint to derive an ENS name
|
//Payload with the address and hint to derive an ENS name
|
||||||
payload := map[string]string{
|
payload := map[string]string{
|
||||||
"address": publicKey,
|
"address": publicKey,
|
||||||
@@ -399,7 +599,7 @@ func requestEnsAlias(ctx context.Context, publicKey string, hint string) (*model
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
req, err := http.NewRequest("POST", ep, bytes.NewBuffer(payloadBytes))
|
req, err := http.NewRequest("POST", endpoint, bytes.NewBuffer(payloadBytes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -413,6 +613,135 @@ func requestEnsAlias(ctx context.Context, publicKey string, hint string) (*model
|
|||||||
return &r, nil
|
return &r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (as *HTTPAccountService) UpdateAlias(ctx context.Context, name string, publicKey string) (*models.RequestAliasResult, error) {
|
||||||
|
if as.SS == nil {
|
||||||
|
return nil, fmt.Errorf("The storage service cannot be nil")
|
||||||
|
}
|
||||||
|
if as.UseApi {
|
||||||
|
if !strings.Contains(name, ".") {
|
||||||
|
name = as.ToFqdn(name)
|
||||||
|
}
|
||||||
|
enr, err := updateEnsAlias(ctx, name, publicKey)
|
||||||
|
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, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateEnsAlias(ctx context.Context, name string, publicKey string) (*models.AliasEnsResult, error) {
|
||||||
|
var r models.AliasEnsResult
|
||||||
|
|
||||||
|
endpoint := config.AliasUpdateURL
|
||||||
|
|
||||||
|
logg.InfoCtxf(ctx, "updating alias", "endpoint", endpoint, "name", name)
|
||||||
|
|
||||||
|
payload := map[string]string{
|
||||||
|
"name": name,
|
||||||
|
"address": publicKey,
|
||||||
|
}
|
||||||
|
payloadBytes, err := json.Marshal(payload)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req, err := http.NewRequest("PUT", endpoint, 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 updated", "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
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: remove eth-custodial api dependency
|
// TODO: remove eth-custodial api dependency
|
||||||
func doRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKResponse, error) {
|
func doRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKResponse, error) {
|
||||||
var okResponse api.OKResponse
|
var okResponse api.OKResponse
|
||||||
@@ -421,6 +750,7 @@ func doRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKRespons
|
|||||||
req.Header.Set("Authorization", "Bearer "+config.BearerToken)
|
req.Header.Set("Authorization", "Bearer "+config.BearerToken)
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
|
||||||
|
// Log request
|
||||||
logRequestDetails(req)
|
logRequestDetails(req)
|
||||||
|
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := http.DefaultClient.Do(req)
|
||||||
@@ -431,24 +761,32 @@ func doRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKRespons
|
|||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
log.Printf("Received response for %s: Status Code: %d | Content-Type: %s", req.URL, resp.StatusCode, resp.Header.Get("Content-Type"))
|
// Read and log response body
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("Received response for %s: Status Code: %d | Content-Type: %s | Body: %s",
|
||||||
|
req.URL, resp.StatusCode, resp.Header.Get("Content-Type"), string(body))
|
||||||
|
|
||||||
if resp.StatusCode >= http.StatusBadRequest {
|
if resp.StatusCode >= http.StatusBadRequest {
|
||||||
err := json.Unmarshal([]byte(body), &errResponse)
|
if err := json.Unmarshal(body, &errResponse); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return nil, errors.New(errResponse.Description)
|
|
||||||
|
return nil, &APIError{
|
||||||
|
Code: errResponse.ErrCode,
|
||||||
|
Description: errResponse.Description,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
err = json.Unmarshal([]byte(body), &okResponse)
|
|
||||||
if err != nil {
|
if err := json.Unmarshal(body, &okResponse); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(okResponse.Result) == 0 {
|
if len(okResponse.Result) == 0 {
|
||||||
return nil, errors.New("Empty api result")
|
return nil, errors.New("empty api result")
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := json.Marshal(okResponse.Result)
|
v, err := json.Marshal(okResponse.Result)
|
||||||
@@ -463,16 +801,14 @@ func doRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKRespons
|
|||||||
func logRequestDetails(req *http.Request) {
|
func logRequestDetails(req *http.Request) {
|
||||||
var bodyBytes []byte
|
var bodyBytes []byte
|
||||||
contentType := req.Header.Get("Content-Type")
|
contentType := req.Header.Get("Content-Type")
|
||||||
|
|
||||||
if req.Body != nil {
|
if req.Body != nil {
|
||||||
bodyBytes, err := io.ReadAll(req.Body)
|
bodyBytes, _ = io.ReadAll(req.Body)
|
||||||
if err != nil {
|
req.Body = io.NopCloser(bytes.NewBuffer(bodyBytes)) // Restore body
|
||||||
log.Printf("Error reading request body: %s", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
|
|
||||||
} else {
|
} else {
|
||||||
bodyBytes = []byte("-")
|
bodyBytes = []byte("-")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("URL: %s | Content-Type: %s | Method: %s| Request Body: %s", req.URL, contentType, req.Method, string(bodyBytes))
|
log.Printf("Outgoing Request -> URL: %s | Method: %s | Content-Type: %s | Body: %s",
|
||||||
|
req.URL.String(), req.Method, contentType, string(bodyBytes))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,14 @@ func (m MockApi) RequestAlias(ctx context.Context, publicKey string, hint string
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m MockApi) UpdateAlias(ctx context.Context, publicKey string, name string) (*models.RequestAliasResult, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m MockApi) TokenTransfer(ctx context.Context, amount, from, to, tokenAddress string) (*models.TokenTransferResponse, error) {
|
func (m MockApi) TokenTransfer(ctx context.Context, amount, from, to, tokenAddress string) (*models.TokenTransferResponse, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m MockApi) SendUpsellSMS(ctx context.Context, inviterPhone, inviteePhone string) (*models.SendSMSResponse, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -53,11 +53,29 @@ func (m *MockAccountService) CheckAliasAddress(ctx context.Context, alias string
|
|||||||
return args.Get(0).(*models.AliasAddress), args.Error(1)
|
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)
|
args := m.Called(publicKey, hint)
|
||||||
return args.Get(0).(*models.RequestAliasResult), args.Error(1)
|
return args.Get(0).(*models.RequestAliasResult), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *MockAccountService) UpdateAlias(ctx context.Context, publicKey string, name string) (*models.RequestAliasResult, error) {
|
||||||
|
args := m.Called(publicKey, name)
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
func (m MockAccountService) PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error) {
|
func (m MockAccountService) PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error) {
|
||||||
args := m.Called(amount, from, poolAddress, tokenAddress)
|
args := m.Called(amount, from, poolAddress, tokenAddress)
|
||||||
return args.Get(0).(*models.PoolDepositResult), args.Error(1)
|
return args.Get(0).(*models.PoolDepositResult), args.Error(1)
|
||||||
@@ -68,13 +86,18 @@ func (m MockAccountService) FetchTopPools(ctx context.Context) ([]dataserviceapi
|
|||||||
return args.Get(0).([]dataserviceapi.PoolDetails), args.Error(1)
|
return args.Get(0).([]dataserviceapi.PoolDetails), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m MockAccountService) RetrievePoolDetails(ctx context.Context, sym string) (*dataserviceapi.PoolDetails, error) {
|
||||||
|
args := m.Called()
|
||||||
|
return args.Get(0).(*dataserviceapi.PoolDetails), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
func (m MockAccountService) GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (m MockAccountService) GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
args := m.Called(poolAddress, publicKey)
|
args := m.Called(poolAddress, publicKey)
|
||||||
return args.Get(0).([]dataserviceapi.TokenHoldings), args.Error(1)
|
return args.Get(0).([]dataserviceapi.TokenHoldings), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m MockAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (m MockAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
args := m.Called(poolAddress, publicKey)
|
args := m.Called(poolAddress)
|
||||||
return args.Get(0).([]dataserviceapi.TokenHoldings), args.Error(1)
|
return args.Get(0).([]dataserviceapi.TokenHoldings), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,3 +115,8 @@ func (m MockAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, poolAd
|
|||||||
args := m.Called(poolAddress, fromTokenAddress, toTokenAddress, publicKey)
|
args := m.Called(poolAddress, fromTokenAddress, toTokenAddress, publicKey)
|
||||||
return args.Get(0).(*models.MaxLimitResult), args.Error(1)
|
return args.Get(0).(*models.MaxLimitResult), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m MockAccountService) CheckTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error) {
|
||||||
|
args := m.Called(poolAddress, tokenAddress)
|
||||||
|
return args.Get(0).(*models.TokenInPoolResult), args.Error(1)
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ func (tas *TestAccountService) TrackAccountStatus(ctx context.Context, publicKey
|
|||||||
func (tas *TestAccountService) FetchVouchers(ctx context.Context, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (tas *TestAccountService) FetchVouchers(ctx context.Context, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
return []dataserviceapi.TokenHoldings{
|
return []dataserviceapi.TokenHoldings{
|
||||||
dataserviceapi.TokenHoldings{
|
dataserviceapi.TokenHoldings{
|
||||||
ContractAddress: "0x6CC75A06ac72eB4Db2eE22F781F5D100d8ec03ee",
|
TokenAddress: "0x6CC75A06ac72eB4Db2eE22F781F5D100d8ec03ee",
|
||||||
TokenSymbol: "SRF",
|
TokenSymbol: "SRF",
|
||||||
TokenDecimals: "6",
|
TokenDecimals: "6",
|
||||||
Balance: "2745987",
|
Balance: "2745987",
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@@ -61,23 +61,43 @@ func (m TestAccountService) PoolDeposit(ctx context.Context, amount, from, poolA
|
|||||||
return &models.PoolDepositResult{}, nil
|
return &models.PoolDepositResult{}, 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
|
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
|
return &models.RequestAliasResult{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *TestAccountService) UpdateAlias(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
|
||||||
|
}
|
||||||
|
|
||||||
func (m TestAccountService) FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error) {
|
func (m TestAccountService) FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error) {
|
||||||
return []dataserviceapi.PoolDetails{}, nil
|
return []dataserviceapi.PoolDetails{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m TestAccountService) RetrievePoolDetails(ctx context.Context, sym string) (*dataserviceapi.PoolDetails, error) {
|
||||||
|
return &dataserviceapi.PoolDetails{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m TestAccountService) GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (m TestAccountService) GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
return []dataserviceapi.TokenHoldings{}, nil
|
return []dataserviceapi.TokenHoldings{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m TestAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (m TestAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
return []dataserviceapi.TokenHoldings{}, nil
|
return []dataserviceapi.TokenHoldings{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,3 +112,7 @@ func (m TestAccountService) PoolSwap(ctx context.Context, amount, from, fromToke
|
|||||||
func (m TestAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error) {
|
func (m TestAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error) {
|
||||||
return &models.MaxLimitResult{}, nil
|
return &models.MaxLimitResult{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m TestAccountService) CheckTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error) {
|
||||||
|
return &models.TokenInPoolResult{}, nil
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user