Skip to content

Commit f737d90

Browse files
authored
fix: use memo for lighter destination address (#99)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> ## Related Issue Or Context <!--- If suggesting a new feature or change, please discuss it in an issue first --> <!--- If fixing a bug, there should be an issue describing it with steps to reproduce --> <!--- Otherwise, describe context and motivation for change herre --> Closes: #<issue> ## How Has This Been Tested? Testing details. <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have ensured that all acceptance criteria (or expected behavior) from issue are met - [ ] I have updated the documentation locally and in docs. - [ ] I have added tests to cover my changes. - [ ] I have ensured that all the checks are passing and green, I've signed the CLA bot
1 parent 8462167 commit f737d90

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

chains/lighter/message/lighter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (h *LighterMessageHandler) calldata(tx *lighter.LighterTx, borrowAmount *bi
155155
return consts.LighterABI.Pack(
156156
"withdraw",
157157
common.HexToHash(tx.Hash),
158-
common.HexToAddress(tx.L1Address),
158+
common.BytesToAddress(tx.Transfer.Memo[:20]),
159159
borrowAmount)
160160
}
161161

chains/lighter/message/lighter_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_ValidMessage() {
9595
Transfer: &lighter.Transfer{
9696
USDCAmount: 2000000,
9797
ToAccountIndex: 3,
98+
Memo: []byte{238, 123, 250, 212, 202, 237, 62, 98, 106, 248, 169, 199, 213, 3, 76, 213, 137, 238, 73, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
9899
},
99100
}, nil)
100101

@@ -137,6 +138,7 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_InvalidTxType() {
137138
Transfer: &lighter.Transfer{
138139
USDCAmount: 2000000,
139140
ToAccountIndex: 3,
141+
Memo: []byte{238, 123, 250, 212, 202, 237, 62, 98, 106, 248, 169, 199, 213, 3, 76, 213, 137, 238, 73, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
140142
},
141143
}, nil)
142144

@@ -179,6 +181,7 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_InvalidAccount() {
179181
Transfer: &lighter.Transfer{
180182
USDCAmount: 2000000,
181183
ToAccountIndex: 5,
184+
Memo: []byte{238, 123, 250, 212, 202, 237, 62, 98, 106, 248, 169, 199, 213, 3, 76, 213, 137, 238, 73, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
182185
},
183186
}, nil)
184187

@@ -258,6 +261,7 @@ func (s *LighterMessageHandlerTestSuite) Test_HandleMessage_BorrowAmountTooHigh(
258261
Transfer: &lighter.Transfer{
259262
USDCAmount: 2000000,
260263
ToAccountIndex: 3,
264+
Memo: []byte{238, 123, 250, 212, 202, 237, 62, 98, 106, 248, 169, 199, 213, 3, 76, 213, 137, 238, 73, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
261265
},
262266
}, nil)
263267

protocol/lighter/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Transfer struct {
2424
FromAccountIndex uint64
2525
ToAccountIndex int
2626
Fee uint64
27+
Memo []byte
2728
}
2829

2930
type LighterTx struct {

0 commit comments

Comments
 (0)