Skip to content

Commit fd38928

Browse files
committed
edit some routes
1 parent d53b4da commit fd38928

File tree

4 files changed

+11
-39
lines changed

4 files changed

+11
-39
lines changed

extractors/susy/bridge/common.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ func ValidateSolanaAddress(address string) bool {
138138
return true
139139
}
140140

141-
func ValidateErgoAddress(address string) bool {
142-
isValid, err := helpers.ValidateErgoAddress(address)
141+
func ValidateErgoAddress(address string, proxyUrl string) bool {
142+
isValid, err := helpers.ValidateErgoAddress(address, proxyUrl)
143143
if err != nil {
144144
fmt.Printf("error: %v", err)
145145
return false

extractors/susy/bridge/ergo.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (provider *ErgoToErgoExtractionBridge) pickRequestFromLUPortQueue(luRequest
7272
if isExist(luRequest) {
7373
continue
7474
}
75-
isValid := ValidateErgoAddress(luRequest.Receiver)
75+
isValid := ValidateErgoAddress(luRequest.Receiver, provider.config.SourceNodeUrl)
7676
if !isValid {
7777
continue
7878
}
@@ -104,7 +104,7 @@ func (provider *ErgoToErgoExtractionBridge) pickRequestFromIBPortQueue(ibRequest
104104
if isExist(ibRequest) {
105105
continue
106106
}
107-
isValid := ValidateErgoAddress(ibRequest.Receiver)
107+
isValid := ValidateErgoAddress(ibRequest.Receiver, provider.config.DestinationNodeUrl)
108108
if !isValid {
109109
continue
110110
}

extractors/susy/bridge/ergo_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ func TestErgoToErgoExtractionBridge_ExtractReverseTransferRequest(t *testing.T)
6565
cmd := ConfigureCommand{
6666
SourceDecimals: 9,
6767
DestinationDecimals: 9,
68-
SourceNodeUrl: "http://176.9.65.58:9017",
69-
DestinationNodeUrl: "http://176.9.65.58:9016",
68+
SourceNodeUrl: "",
69+
DestinationNodeUrl: "",
7070
IBPortAddress: "ibport",
7171
LUPortAddress: "luport",
7272
}
@@ -106,8 +106,8 @@ func TestErgoToErgoExtractionBridge_ExtractDirectTransferRequest(t *testing.T) {
106106
cmd := ConfigureCommand{
107107
SourceDecimals: 9,
108108
DestinationDecimals: 9,
109-
SourceNodeUrl: "http://176.9.65.58:9017",
110-
DestinationNodeUrl: "http://176.9.65.58:9016",
109+
SourceNodeUrl: "",
110+
DestinationNodeUrl: "",
111111
IBPortAddress: "ibport",
112112
LUPortAddress: "luport",
113113
}

helpers/ergo.go

+3-31
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type ErgOptions struct {
2626
}
2727

2828
var DefaultOptions = ErgOptions{
29-
BaseUrl: "http://176.9.65.58:9016",
29+
BaseUrl: "",
3030
Doer: &http.Client{Timeout: 30 * time.Second},
3131
}
3232

@@ -90,39 +90,11 @@ func NewClient(options ...ErgOptions) (*ErgClient, error) {
9090
return c, nil
9191
}
9292

93-
func GetDataType(ctx context.Context) (int, error) {
94-
type Result struct {
95-
Success bool `json:"success"`
96-
DataType int `json:"dataType"`
97-
}
98-
client, err := NewClient()
99-
if err != nil {
100-
return 0, err
101-
}
102-
url, err := JoinUrl(client.Options.BaseUrl, "adaptor/getDataType")
103-
if err != nil {
104-
return 0, err
105-
}
106-
req, err := http.NewRequestWithContext(ctx, "GET", url.String(), nil)
107-
result := new(Result)
108-
_, err = client.Do(req, result)
109-
if err != nil {
110-
return 0, err
111-
}
112-
if !result.Success {
113-
return 0, errors.New("can't get lastRound")
114-
}
115-
return result.DataType, nil
116-
}
11793

11894
func (client ErgClient) GetOptions() ErgOptions {
11995
return client.Options
12096
}
12197

122-
func withContext(ctx context.Context, req *http.Request) *http.Request {
123-
return req.WithContext(ctx)
124-
}
125-
12698
func newResponse(response *http.Response) *Response {
12799
return &Response{
128100
Response: response,
@@ -135,13 +107,13 @@ type Request struct {
135107
Receiver string `json:"receiver"`
136108
}
137109

138-
func ValidateErgoAddress(address string) (bool, error) {
110+
func ValidateErgoAddress(address string, peorxyUrl string) (bool, error) {
139111
type Result struct {
140112
Success bool `json:"success"`
141113
IsValid bool `json:"isValid"`
142114
}
143115

144-
url := fmt.Sprintf("%s/%s", DefaultOptions.BaseUrl, "adaptor/validateAddress")
116+
url := fmt.Sprintf("%s/%s", peorxyUrl, "validateAddress")
145117

146118
values := map[string]string{"address": address}
147119
jsonValue, _ := json.Marshal(values)

0 commit comments

Comments
 (0)