Skip to content

Commit 1998fcf

Browse files
committed
data type issue and getting data
1 parent 445bbd1 commit 1998fcf

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

config/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const (
1010
)
1111

1212
const (
13-
MountedVolume = "/etc/extractor"
13+
MountedVolume = "."
1414
)
1515

1616
type MainConfig struct {

erg-erg.json erg-sigma.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"SourceNodeURL": "http://176.9.65.58:9016/",
2+
"SourceNodeURL": "http://127.0.0.1:9000",
33
"SourceDecimals": 9,
44
"DestinationDecimals": 9,
5-
"DestinationNodeURL": "http://176.9.65.58:9016/",
5+
"DestinationNodeURL": "http://127.0.0.1:9090",
66
"IBPortAddress": "ibport",
77
"LUPortAddress": "luport"
88
}

extractors/susy/bridge/ergo.go

+20-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package bridge
22

33
import (
44
"context"
5-
"encoding/base64"
5+
"encoding/binary"
6+
"encoding/hex"
67
"fmt"
78
"strconv"
89

@@ -88,8 +89,7 @@ func (provider *ErgoToErgoExtractionBridge) ExtractDirectTransferRequest(ctx con
8889
return nil, extractors.NotFoundErr
8990
}
9091

91-
rqInt, _ := strconv.ParseInt(rq.RequestId, 10, 64)
92-
rqBigInt := big.NewInt(rqInt)
92+
rqId, _ := strconv.ParseInt(rq.RequestId, 10, 64)
9393
amount, _ := strconv.ParseInt(rq.Amount, 10, 64)
9494

9595
sourceDecimals := big.NewInt(10)
@@ -106,16 +106,18 @@ func (provider *ErgoToErgoExtractionBridge) ExtractDirectTransferRequest(ctx con
106106

107107
result := []byte{'m'}
108108
var newAmountBytes [32]byte
109-
var RequestIdBytes [32]byte
110-
result = append(result, rqBigInt.FillBytes(RequestIdBytes[:])...)
109+
var RequestIdBytes = make([]byte, 32)
110+
binary.PutVarint(RequestIdBytes, rqId)
111+
result = append(result, RequestIdBytes[:]...)
111112
result = append(result, newAmount.FillBytes(newAmountBytes[:])...)
112-
result = append(result, []byte(rq.Receiver)...)
113+
receiver, _ := hex.DecodeString(rq.Receiver)
114+
result = append(result, receiver[:]...)
113115

114116
println(newAmount.String())
115-
println(base64.StdEncoding.EncodeToString(result))
117+
println(hex.EncodeToString(result))
116118
return &extractors.Data{
117-
Type: extractors.Base64,
118-
Value: base64.StdEncoding.EncodeToString(result),
119+
Type: extractors.String,
120+
Value: hex.EncodeToString(result),
119121
}, err
120122
}
121123

@@ -131,8 +133,7 @@ func (provider *ErgoToErgoExtractionBridge) ExtractReverseTransferRequest(ctx co
131133
return nil, extractors.NotFoundErr
132134
}
133135

134-
rqInt, _ := strconv.ParseInt(rq.RequestId, 10, 64)
135-
rqBigInt := big.NewInt(rqInt)
136+
rqId, _ := strconv.ParseInt(rq.RequestId, 10, 64)
136137
amount, _ := strconv.ParseInt(rq.Amount, 10, 64)
137138

138139
sourceDecimals := big.NewInt(10)
@@ -149,15 +150,17 @@ func (provider *ErgoToErgoExtractionBridge) ExtractReverseTransferRequest(ctx co
149150

150151
result := []byte{'u'}
151152
var newAmountBytes [32]byte
152-
var RequestIdBytes [32]byte
153-
result = append(result, rqBigInt.FillBytes(RequestIdBytes[:])...)
153+
var RequestIdBytes = make([]byte, 32)
154+
binary.PutVarint(RequestIdBytes, rqId)
155+
result = append(result, RequestIdBytes[:]...)
154156
result = append(result, newAmount.FillBytes(newAmountBytes[:])...)
155-
result = append(result, []byte(rq.Receiver)...)
157+
receiver, _ := hex.DecodeString(rq.Receiver)
158+
result = append(result, receiver[:]...)
156159

157160
println(newAmount.String())
158-
println(base64.StdEncoding.EncodeToString(result))
161+
println(hex.EncodeToString(result))
159162
return &extractors.Data{
160-
Type: extractors.Base64,
161-
Value: base64.StdEncoding.EncodeToString(result),
163+
Type: extractors.String,
164+
Value: hex.EncodeToString(result),
162165
}, err
163166
}

helpers/ergo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func CheckAddress(address string) (bool, error) {
140140
IsValid bool `json:"isValid"`
141141
}
142142

143-
url := fmt.Sprintf("%s/%s", DefaultOptions.BaseUrl, "/adpator/validateAddress")
143+
url := fmt.Sprintf("%s/%s", DefaultOptions.BaseUrl, "/adaptor/validateAddress")
144144

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

0 commit comments

Comments
 (0)