Skip to content

Commit 5b925b3

Browse files
committed
mooncx fix
1 parent 057fa86 commit 5b925b3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

abi/mooncx.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ func (m *MoonNextPayload) UnmarshalJSON(data []byte) error {
7676
if err := json.Unmarshal(data, &r); err != nil {
7777
return err
7878
}
79-
id := ton.MustParseAccountID(r.Recipient)
80-
m.Recipient = id.ToMsgAddress()
79+
if r.Recipient == "" {
80+
m.Recipient = tlb.MsgAddress{SumType: "AddrNone"}
81+
} else {
82+
id := ton.MustParseAccountID(r.Recipient)
83+
m.Recipient = id.ToMsgAddress()
84+
}
8185
if r.Payload != "" {
8286
c, err := boc.DeserializeBocHex(r.Payload)
8387
if err != nil {

abi/mooncx_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ func TestMooncxSwapParams(t *testing.T) {
4646
json: `{"MinOut":"3","Deadline":0,"Excess":"0:05ea635b2a168cadfca174d72b12744a5b57d70378e6912e8a33b6b39bd3ee9d","Referral":"0:05ea635b2a168cadfca174d72b12744a5b57d70378e6912e8a33b6b39bd3ee9d","NextFulfill":{"Recipient":"0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb","Payload":"b5ee9c7201010101000800000b0000177beb90"},"NextReject":null}`,
4747
want: `{"MinOut":"3","Deadline":0,"Excess":"0:05ea635b2a168cadfca174d72b12744a5b57d70378e6912e8a33b6b39bd3ee9d","Referral":"0:05ea635b2a168cadfca174d72b12744a5b57d70378e6912e8a33b6b39bd3ee9d","NextFulfill":{"Recipient":"0:2cf3b5b8c891e517c9addbda1c0386a09ccacbb0e3faf630b51cfc8152325acb","Payload":"b5ee9c7201010101000800000b0000177beb90"},"NextReject":null}`,
4848
},
49+
{
50+
name: "problem",
51+
json: `{"MinOut":"1","Deadline":0,"Excess":"0:84c49bf79ed9a5720dbe973e2c654521cb4959415a3d003a16b8bc65c09e8bd6","Referral":"","NextFulfill":{"Payload":null,"Recipient":""},"NextReject":null}`,
52+
want: `{"MinOut":"1","Deadline":0,"Excess":"0:84c49bf79ed9a5720dbe973e2c654521cb4959415a3d003a16b8bc65c09e8bd6","Referral":"","NextFulfill":{"Recipient":"","Payload":null},"NextReject":null}`,
53+
},
4954
}
5055
for _, tt := range tests {
5156
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)