Skip to content

Commit 5a47fdc

Browse files
committed
channel fund reverted
1 parent 35c1f96 commit 5a47fdc

File tree

2 files changed

+2
-133
lines changed

2 files changed

+2
-133
lines changed

xrpl/transaction/payment_channel_fund.go

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package transaction
22

33
import (
4-
"encoding/json"
54
"time"
65

76
rippletime "github.com/Peersyst/xrpl-go/xrpl/time"
@@ -28,7 +27,7 @@ type PaymentChannelFund struct {
2827
// The unique ID of the channel to fund, as a 64-character hexadecimal string.
2928
Channel types.Hash256
3029
// Amount of XRP, in drops to add to the channel. Must be a positive amount of XRP.
31-
Amount types.CurrencyAmount
30+
Amount types.XRPCurrencyAmount
3231
// (Optional) New Expiration time to set for the channel, in seconds since the Ripple Epoch.
3332
// This must be later than either the current time plus the SettleDelay of the channel, or the existing Expiration of the channel.
3433
// After the Expiration time, any transaction that would access the channel closes the channel without taking its normal action.
@@ -46,7 +45,7 @@ func (p *PaymentChannelFund) Flatten() FlatTransaction {
4645
flattened := p.BaseTx.Flatten()
4746

4847
flattened["Channel"] = p.Channel.String()
49-
flattened["Amount"] = p.Amount.Flatten()
48+
flattened["Amount"] = p.Amount.String()
5049

5150
if p.Expiration != 0 {
5251
flattened["Expiration"] = p.Expiration
@@ -70,26 +69,3 @@ func (p *PaymentChannelFund) Validate() (bool, error) {
7069

7170
return true, nil
7271
}
73-
74-
// UnmarshalJSON unmarshals the PaymentChannelFund transaction from JSON.
75-
func (p *PaymentChannelFund) UnmarshalJSON(data []byte) error {
76-
type paymentChannelFundHelper struct {
77-
BaseTx
78-
Amount json.RawMessage
79-
Expiration uint32 `json:",omitempty"`
80-
}
81-
var h paymentChannelFundHelper
82-
if err := json.Unmarshal(data, &h); err != nil {
83-
return err
84-
}
85-
*p = PaymentChannelFund{
86-
BaseTx: h.BaseTx,
87-
Expiration: h.Expiration,
88-
}
89-
amount, err := types.UnmarshalCurrencyAmount(h.Amount)
90-
if err != nil {
91-
return err
92-
}
93-
p.Amount = amount
94-
return nil
95-
}

xrpl/transaction/payment_channel_fund_test.go

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package transaction
22

33
import (
4-
"encoding/json"
54
"testing"
65
"time"
76

@@ -58,58 +57,6 @@ func TestPaymentChannelFund_Flatten(t *testing.T) {
5857
"Expiration": 543171558
5958
}`,
6059
},
61-
{
62-
name: "pass - with Expiration and Amount as MPTCurrencyAmount",
63-
tx: &PaymentChannelFund{
64-
BaseTx: BaseTx{
65-
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
66-
TransactionType: PaymentChannelFundTx,
67-
},
68-
Channel: "DEF456",
69-
Amount: types.MPTCurrencyAmount{
70-
MPTIssuanceID: "1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF",
71-
Value: "300000",
72-
},
73-
Expiration: 543171558,
74-
},
75-
expected: `{
76-
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
77-
"TransactionType": "PaymentChannelFund",
78-
"Channel": "DEF456",
79-
"Amount": {
80-
"mpt_issuance_id": "1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF",
81-
"value": "300000"
82-
},
83-
"Expiration": 543171558
84-
}`,
85-
},
86-
{
87-
name: "pass - with Expiration and Amount as IssuedCurrencyAmount",
88-
tx: &PaymentChannelFund{
89-
BaseTx: BaseTx{
90-
Account: "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
91-
TransactionType: PaymentChannelFundTx,
92-
},
93-
Channel: "DEF456",
94-
Amount: types.IssuedCurrencyAmount{
95-
Issuer: "rEXAMPLE123456789ABCDEFGHJKLMNPQRSTUVWXYZ",
96-
Currency: "USD",
97-
Value: "300000",
98-
},
99-
Expiration: 543171558,
100-
},
101-
expected: `{
102-
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
103-
"TransactionType": "PaymentChannelFund",
104-
"Channel": "DEF456",
105-
"Amount": {
106-
"issuer": "rEXAMPLE123456789ABCDEFGHJKLMNPQRSTUVWXYZ",
107-
"currency": "USD",
108-
"value": "300000"
109-
},
110-
"Expiration": 543171558
111-
}`,
112-
},
11360
}
11461

11562
for _, tt := range tests {
@@ -197,57 +144,3 @@ func TestPaymentChannelFund_Validate(t *testing.T) {
197144
})
198145
}
199146
}
200-
201-
func TestPaymentChannelFund_Unmarshal(t *testing.T) {
202-
tests := []struct {
203-
name string
204-
jsonData string
205-
expectUnmarshalError bool
206-
}{
207-
{
208-
name: "pass - full PaymentChannelFund with MPTCurrencyAmount",
209-
jsonData: `{
210-
"TransactionType": "PaymentChannelFund",
211-
"Account": "rEXAMPLE123456789ABCDEFGHJKLMNPQRSTUVWXYZ",
212-
"Channel": "DEF456",
213-
"Amount": {
214-
"mpt_issuance_id": "1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF",
215-
"value": "300000"
216-
},
217-
"Expiration": 543171558
218-
}`,
219-
},
220-
{
221-
name: "pass - full PaymentChannelFund with IssuedCurrencyAmount",
222-
jsonData: `{
223-
"TransactionType": "PaymentChannelFund",
224-
"Account": "rEXAMPLE123456789ABCDEFGHJKLMNPQRSTUVWXYZ",
225-
"Channel": "DEF456",
226-
"Amount": {
227-
"issuer": "rEXAMPLE123456789ABCDEFGHJKLMNPQRSTUVWXYZ",
228-
"currency": "USD",
229-
"value": "300000"
230-
},
231-
"Expiration": 543171558
232-
}`,
233-
},
234-
{
235-
name: "pass - full PaymentChannelFund with XRPCurrencyAmount",
236-
jsonData: `{
237-
"TransactionType": "PaymentChannelFund",
238-
"Account": "rEXAMPLE123456789ABCDEFGHJKLMNPQRSTUVWXYZ",
239-
"Channel": "DEF456",
240-
"Amount": "300000",
241-
"Expiration": 543171558
242-
}`,
243-
},
244-
}
245-
246-
for _, tt := range tests {
247-
t.Run(tt.name, func(t *testing.T) {
248-
var paymentChannelFund PaymentChannelFund
249-
err := json.Unmarshal([]byte(tt.jsonData), &paymentChannelFund)
250-
assert.Equal(t, tt.expectUnmarshalError, err != nil)
251-
})
252-
}
253-
}

0 commit comments

Comments
 (0)