@@ -2,7 +2,8 @@ package bridge
22
33import (
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}
0 commit comments