Skip to content

Commit

Permalink
add GetBridgeTxByNonce
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobeyw committed Mar 21, 2024
1 parent 744f162 commit d444fb9
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 d444fb9

Please sign in to comment.