Skip to content

Commit

Permalink
Merge pull request #247 from Tobeyw/dev-mindy
Browse files Browse the repository at this point in the history
add GetBridgeTxByNonce
  • Loading branch information
Tobeyw authored Mar 21, 2024
2 parents c99536b + d444fb9 commit 5b810f5
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
54 changes: 54 additions & 0 deletions neo3fura_http/biz/api/bridge.GetBridgeTxByNonce.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package api

import (
"encoding/json"
"go.mongodb.org/mongo-driver/bson"
"neo3fura_http/lib/type/h160"
"neo3fura_http/var/stderr"
"strconv"
)

func (me *T) GetBridgeTxByNonce(args struct {
ContractHash h160.T
Nonce int64
Limit int64
Skip int64
Filter map[string]interface{}
}, ret *json.RawMessage) error {
if args.ContractHash.Valid() == false {
return stderr.ErrInvalidArgs
}
nonceStr := strconv.FormatInt(args.Nonce, 10)
r1, _, err := me.Client.QueryAll(struct {
Collection string
Index string
Sort bson.M
Filter bson.M
Query []string
Limit int64
Skip int64
}{
Collection: "Notification",
Index: "GetBridgeTxByNonce",
Sort: bson.M{"_id": -1},
Filter: bson.M{"contract": args.ContractHash.Val(),
"$or": []interface{}{bson.M{"eventname": "Withdrawal"}, bson.M{"eventname": "Claimable"}},
"state.value.0.value": nonceStr,
},
Query: []string{},
Limit: args.Limit,
Skip: args.Skip,
}, ret)

var result map[string]interface{}
if len(r1) > 0 {
result = r1[0]
}
r, err := json.Marshal(result)
if err != nil {
return err
}
*ret = json.RawMessage(r)

return nil
}
1 change: 1 addition & 0 deletions neo3fura_http/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,5 @@ var Apis = []string{
"GetInfoByNFTPrimaryMarket",
"GetMarketCollectionWhitelist",
"GetRedEnvelopeUsers",
"GetBridgeTxByNonce",
}

0 comments on commit 5b810f5

Please sign in to comment.