diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..ea240c7 --- /dev/null +++ b/config/config.go @@ -0,0 +1,73 @@ +package config + +import ( + "net/url" + + "git.grassecon.net/grassrootseconomics/common/env" +) + +const ( + createAccountPath = "/api/v2/account/create" + trackStatusPath = "/api/track" + balancePathPrefix = "/api/account" + trackPath = "/api/v2/account/status" + tokenTransferPrefix = "/api/v2/token/transfer" + voucherHoldingsPathPrefix = "/api/v1/holdings" + voucherTransfersPathPrefix = "/api/v1/transfers/last10" + voucherDataPathPrefix = "/api/v1/token" + AliasPrefix = "api/v1/alias" +) + +var ( + custodialURLBase string + dataURLBase string + BearerToken string +) + +var ( + CreateAccountURL string + TrackStatusURL string + BalanceURL string + TrackURL string + TokenTransferURL string + VoucherHoldingsURL string + VoucherTransfersURL string + VoucherDataURL string + CheckAliasURL string +) + +func setBase() error { + var err error + + custodialURLBase = env.GetEnv("CUSTODIAL_URL_BASE", "http://localhost:5003") + dataURLBase = env.GetEnv("DATA_URL_BASE", "http://localhost:5006") + BearerToken = env.GetEnv("BEARER_TOKEN", "") + + _, err = url.Parse(custodialURLBase) + if err != nil { + return err + } + _, err = url.Parse(dataURLBase) + if err != nil { + return err + } + + return nil +} + +func LoadConfig() error { + err := setBase() + if err != nil { + return err + } + CreateAccountURL, _ = url.JoinPath(custodialURLBase, createAccountPath) + TrackStatusURL, _ = url.JoinPath(custodialURLBase, trackStatusPath) + BalanceURL, _ = url.JoinPath(custodialURLBase, balancePathPrefix) + TrackURL, _ = url.JoinPath(custodialURLBase, trackPath) + TokenTransferURL, _ = url.JoinPath(custodialURLBase, tokenTransferPrefix) + VoucherHoldingsURL, _ = url.JoinPath(dataURLBase, voucherHoldingsPathPrefix) + VoucherTransfersURL, _ = url.JoinPath(dataURLBase, voucherTransfersPathPrefix) + VoucherDataURL, _ = url.JoinPath(dataURLBase, voucherDataPathPrefix) + CheckAliasURL, _ = url.JoinPath(dataURLBase, AliasPrefix) + return nil +} diff --git a/go.mod b/go.mod index 0138b1c..06f21b9 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.grassecon.net/grassrootseconomics/sarafu-api go 1.23.4 require ( - git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250111163106-c93a07832daa + git.grassecon.net/grassrootseconomics/common v0.0.0-20250112094202-96345daf4d75 github.com/grassrootseconomics/eth-custodial v1.3.0-beta github.com/grassrootseconomics/ussd-data-service v1.2.0-beta github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index c3a50ee..5f0ac97 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250111163106-c93a07832daa h1:owrXxiDOp7uuyvGxi4DU8gu8PyA7YxVnX8bo7i28Anw= -git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250111163106-c93a07832daa/go.mod h1:E6W7ZOa7ZvVr0Bc5ot0LNSwpSPYq4hXlAIvEPy3AJ7U= +git.grassecon.net/grassrootseconomics/common v0.0.0-20250112094202-96345daf4d75 h1:g/dZdu1teBggAMFCwm7BpV44bz394+nhAduULjX6Kk4= +git.grassecon.net/grassrootseconomics/common v0.0.0-20250112094202-96345daf4d75/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/grassrootseconomics/eth-custodial v1.3.0-beta h1:twrMBhl89GqDUL9PlkzQxMP/6OST1BByrNDj+rqXDmU= diff --git a/remote/http/service.go b/remote/http/service.go index 9abf677..53b8091 100644 --- a/remote/http/service.go +++ b/remote/http/service.go @@ -10,7 +10,7 @@ import ( "net/http" "net/url" - "git.grassecon.net/grassrootseconomics/visedriver/config" + "git.grassecon.net/grassrootseconomics/sarafu-api/config" "git.grassecon.net/grassrootseconomics/sarafu-api/models" "github.com/grassrootseconomics/eth-custodial/pkg/api" dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"