Skip to content

Commit 1982ae9

Browse files
authored
Use order id mayan explorer api (#49)
1 parent 4c8762a commit 1982ae9

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

chains/evm/message/mayan.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ func NewMayanMessageHandler(
9494
// cache through the result channel.
9595
func (h *MayanMessageHandler) HandleMessage(m *message.Message) (*proposal.Proposal, error) {
9696
data := m.Data.(*MayanData)
97-
txHash := common.HexToHash(data.DepositTxHash)
9897

9998
err := h.notify(data)
10099
if err != nil {
@@ -151,7 +150,7 @@ func (h *MayanMessageHandler) HandleMessage(m *message.Message) (*proposal.Propo
151150
err = h.confirmationWatcher.WaitForConfirmations(
152151
context.Background(),
153152
h.chainID,
154-
txHash,
153+
common.HexToHash(swap.SourceTxHash),
155154
tokenIn,
156155
new(big.Int).SetUint64(msg.PromisedAmount))
157156
if err != nil {

protocol/mayan/api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type MayanSwap struct {
2424
RefundRelayerFee64 uint64
2525
Trader string
2626
MinAmountOut64 string
27+
SourceTxHash string
2728
}
2829

2930
type MayanExplorer struct {
@@ -39,7 +40,7 @@ func NewMayanExplorer() *MayanExplorer {
3940
}
4041

4142
func (c *MayanExplorer) GetSwap(hash string) (*MayanSwap, error) {
42-
url := fmt.Sprintf("%s/v3/swap/trx/%s", MAYAN_EXPLORER_URL, hash)
43+
url := fmt.Sprintf("%s/v3/swap/order-id/SWIFT_%s", MAYAN_EXPLORER_URL, hash)
4344
resp, err := c.HTTPClient.Get(url)
4445
if err != nil {
4546
return nil, fmt.Errorf("request failed: %w", err)

protocol/mayan/api_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ func Test_MayanExplorer_GetSwap(t *testing.T) {
3939
"redeemRelayerFee": "0.1",
4040
"refundRelayerFee": "0.05",
4141
"trader": "0xTrader",
42-
"minAmountOut64": "100"
42+
"minAmountOut64": "100",
43+
"sourceTxHash": "0xhash"
4344
}`),
4445
statusCode: http.StatusOK,
4546
wantResult: &mayan.MayanSwap{
@@ -51,6 +52,7 @@ func Test_MayanExplorer_GetSwap(t *testing.T) {
5152
RefundRelayerFee: "0.05",
5253
Trader: "0xTrader",
5354
MinAmountOut64: "100",
55+
SourceTxHash: "0xhash",
5456
},
5557
},
5658
{
@@ -80,7 +82,7 @@ func Test_MayanExplorer_GetSwap(t *testing.T) {
8082
client := mayan.NewMayanExplorer()
8183
client.HTTPClient.Transport = roundTripperFunc(func(req *http.Request) (*http.Response, error) {
8284
// Verify URL construction
83-
expectedURL := fmt.Sprintf("%s/v3/swap/trx/%s", mayan.MAYAN_EXPLORER_URL, tc.hash)
85+
expectedURL := fmt.Sprintf("%s/v3/swap/order-id/SWIFT_%s", mayan.MAYAN_EXPLORER_URL, tc.hash)
8486
if req.URL.String() != expectedURL {
8587
return nil, fmt.Errorf("unexpected URL: got %s, want %s", req.URL.String(), expectedURL)
8688
}

0 commit comments

Comments
 (0)