Skip to content

Commit a298e0d

Browse files
committed
Add lifi compact to api
1 parent 0ff7314 commit a298e0d

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

api/handlers/signing.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const (
2020
AcrossProtocol ProtocolType = "across"
2121
MayanProtocol ProtocolType = "mayan"
2222
RhinestoneProtocol ProtocolType = "rhinestone"
23+
LifiCompact ProtocolType = "lifi-compact"
2324
)
2425

2526
type SigningBody struct {
@@ -109,6 +110,19 @@ func (h *SigningHandler) HandleSigning(w http.ResponseWriter, r *http.Request) {
109110
BorrowAmount: b.BorrowAmount.Int,
110111
})
111112
}
113+
case LifiCompact:
114+
{
115+
m = evmMessage.NewLifiData(0, b.ChainId, &evmMessage.LifiData{
116+
OrderID: b.DepositId,
117+
Nonce: b.Nonce.Int,
118+
LiquidityPool: common.HexToAddress(b.LiquidityPool),
119+
Caller: common.HexToAddress(b.Caller),
120+
ErrChn: errChn,
121+
Source: 0,
122+
Destination: b.ChainId,
123+
BorrowAmount: b.BorrowAmount.Int,
124+
})
125+
}
112126
default:
113127
JSONError(w, fmt.Errorf("invalid protocol %s", b.Protocol), http.StatusBadRequest)
114128
return

api/handlers/signing_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,40 @@ func (s *SigningHandlerTestSuite) Test_HandleSigning_RhinestoneSuccess() {
358358
s.Equal(http.StatusAccepted, recorder.Code)
359359
}
360360

361+
func (s *SigningHandlerTestSuite) Test_HandleSigning_LifiSuccess() {
362+
msgChn := make(chan []*message.Message)
363+
handler := handlers.NewSigningHandler(msgChn, s.chains)
364+
365+
input := handlers.SigningBody{
366+
DepositId: "depositID",
367+
Protocol: "lifi-compact",
368+
LiquidityPool: "0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657",
369+
Caller: "0xbe526bA5d1ad94cC59D7A79d99A59F607d31A657",
370+
Calldata: "0xbe5",
371+
Nonce: &handlers.BigInt{big.NewInt(1001)},
372+
BorrowAmount: &handlers.BigInt{big.NewInt(1000)},
373+
}
374+
body, _ := json.Marshal(input)
375+
376+
req := httptest.NewRequest(http.MethodPost, "/v1/chains/1/signatures", bytes.NewReader(body))
377+
req = mux.SetURLVars(req, map[string]string{
378+
"chainId": "1",
379+
})
380+
req.Header.Set("Content-Type", "application/json")
381+
382+
recorder := httptest.NewRecorder()
383+
384+
go func() {
385+
msg := <-msgChn
386+
ad := msg[0].Data.(*across.LifiData)
387+
ad.ErrChn <- nil
388+
}()
389+
390+
handler.HandleSigning(recorder, req)
391+
392+
s.Equal(http.StatusAccepted, recorder.Code)
393+
}
394+
361395
type StatusHandlerTestSuite struct {
362396
suite.Suite
363397

chains/evm/message/lifi_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func (s *LifiCompactMessageHandlerTestSuite) Test_HandleMessage_OrderInvalidOutp
301301
common.HexToAddress(s.mockOrder.Order.User),
302302
gomock.Any(),
303303
).Return(contracts.STATUS_DISABLED, nil)
304-
s.mockOrder.Order.Outputs[0].Token = "invalid"
304+
s.mockOrder.Order.Outputs[0].Token = "0x000000000000000000000000036CbD53842c5426634e7929541eC2318f3dCF7b"
305305
s.mockOrderFetcher.EXPECT().GetOrder("orderID").Return(s.mockOrder, nil)
306306

307307
m := &coreMessage.Message{

0 commit comments

Comments
 (0)