diff --git a/.gitignore b/.gitignore index 6dca5ea..e69de29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +0,0 @@ -build -cmd/sequencer/pebble-sequencer -cmd/sequencer/config/local.yml -cmd/sequencer/project.json -cmd/replication/config/local.yml -cmd/replication/replication-monitor -cmd/simulator/config/local.yml -cmd/simulator/simulator - diff --git a/LICENSE b/LICENSE index ea5a4e5..261eeb9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,201 @@ -MIT License - -Copyright (c) 2024 MachineFi Lab - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Makefile b/Makefile deleted file mode 100644 index 320e3ba..0000000 --- a/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -#PACKAGES=$(shell go list ./... | grep -E -v 'example|proto|testdata|mock') -PACKAGES=$(shell go list ./... | grep -E -v 'pb$|testdata|mock|proto|example') -MOD=$(shell cat go.mod | grep ^module -m 1 | awk '{ print $$2; }' || '') - -debug: - @echo ${PACKAGES} - -xgo: - @if [ "${XGO_OK}" != "0" ]; then \ - echo "installing xgo for unit test"; \ - go install github.com/xhd2015/xgo/cmd/xgo@latest; \ - fi - -tidy: - @go mod tidy - -cover: xgo tidy vet - @xgo test -failfast -parallel 1 -gcflags="all=-N -l" ${PACKAGES} -covermode=count -coverprofile=cover.out - -test: tidy vet - @xgo test -race -failfast -parallel 1 -gcflags="all=-N -l" ${PACKAGES} - -vet: - @go vet ${PACKAGES} - -fmt: - @echo ${MOD} - @for item in `find . -type f -name '*.go' -not -path '*.pb.go'` ; \ - do \ - if [ -z ${MOD} ]; then \ - goimports -w $$item ; \ - else \ - goimports -w -local "${MOD}" $$item ; \ - fi \ - done - -report: - @echo ">>>static checking" - @go vet ./... - @echo "done\n" - @echo ">>>detecting ineffectual assignments" - @ineffassign ./... - @echo "done\n" - @echo ">>>detecting icyclomatic complexities over 10 and average" - @gocyclo -over 10 -avg -ignore '_test|vendor' . || true - @echo "done\n" - -check: tidy vet test - -sequencer_image: - @cd cmd/sequencer && make image - diff --git a/api/http.go b/api/http.go new file mode 100644 index 0000000..00d444f --- /dev/null +++ b/api/http.go @@ -0,0 +1,42 @@ +package api + +import ( + "github.com/gin-gonic/gin" + "github.com/pkg/errors" + + "github.com/iotexproject/pebble-server/db" +) + +type errResp struct { + Error string `json:"error,omitempty"` +} + +func newErrResp(err error) *errResp { + return &errResp{Error: err.Error()} +} + +type httpServer struct { + engine *gin.Engine + db *db.DB +} + +func (s *httpServer) query(c *gin.Context) { + +} + +func (s *httpServer) receive(c *gin.Context) { + +} + +func Run(db *db.DB, address string) error { + s := &httpServer{ + engine: gin.Default(), + db: db, + } + + s.engine.GET("/device", s.query) + s.engine.POST("/device", s.receive) + + err := s.engine.Run(address) + return errors.Wrap(err, "failed to start http server") +} diff --git a/cmd/server/abis/account_updated.json b/cmd/server/abis/account_updated.json deleted file mode 100644 index 854964a..0000000 --- a/cmd/server/abis/account_updated.json +++ /dev/null @@ -1 +0,0 @@ -[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"avatar","type":"string"}],"name":"Updated","type":"event"}] \ No newline at end of file diff --git a/cmd/server/abis/bank_deposit.json b/cmd/server/abis/bank_deposit.json deleted file mode 100644 index f394b26..0000000 --- a/cmd/server/abis/bank_deposit.json +++ /dev/null @@ -1 +0,0 @@ -[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"balance","type":"uint256"}],"name":"Deposit","type":"event"}] \ No newline at end of file diff --git a/cmd/server/abis/bank_paid.json b/cmd/server/abis/bank_paid.json deleted file mode 100644 index 8bfbe01..0000000 --- a/cmd/server/abis/bank_paid.json +++ /dev/null @@ -1 +0,0 @@ -[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"balance","type":"uint256"}],"name":"Paid","type":"event"}] \ No newline at end of file diff --git a/cmd/server/abis/bank_withdraw.json b/cmd/server/abis/bank_withdraw.json deleted file mode 100644 index bd42c16..0000000 --- a/cmd/server/abis/bank_withdraw.json +++ /dev/null @@ -1 +0,0 @@ -[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"balance","type":"uint256"}],"name":"Withdraw","type":"event"}] \ No newline at end of file diff --git a/cmd/server/abis/firmware_removed.json b/cmd/server/abis/firmware_removed.json deleted file mode 100644 index 8deb73d..0000000 --- a/cmd/server/abis/firmware_removed.json +++ /dev/null @@ -1 +0,0 @@ -[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"FirmwareRemoved","type":"event"}] \ No newline at end of file diff --git a/cmd/server/abis/firmware_updated.json b/cmd/server/abis/firmware_updated.json deleted file mode 100644 index 38aeb28..0000000 --- a/cmd/server/abis/firmware_updated.json +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "projectId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "string", - "name": "name", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "key", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "AddMetadata", - "type": "event" - } -] \ No newline at end of file diff --git a/cmd/server/abis/pebble_config.json b/cmd/server/abis/pebble_config.json deleted file mode 100644 index a7e8312..0000000 --- a/cmd/server/abis/pebble_config.json +++ /dev/null @@ -1 +0,0 @@ -[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"string","name":"config","type":"string"}],"name":"Config","type":"event"}] \ No newline at end of file diff --git a/cmd/server/abis/pebble_confirm.json b/cmd/server/abis/pebble_confirm.json deleted file mode 100644 index 2051c45..0000000 --- a/cmd/server/abis/pebble_confirm.json +++ /dev/null @@ -1 +0,0 @@ -[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"device","type":"address"},{"indexed":false,"internalType":"uint32","name":"channel","type":"uint32"}],"name":"Confirm","type":"event"}] \ No newline at end of file diff --git a/cmd/server/abis/pebble_firmware.json b/cmd/server/abis/pebble_firmware.json deleted file mode 100644 index 1ed83c2..0000000 --- a/cmd/server/abis/pebble_firmware.json +++ /dev/null @@ -1 +0,0 @@ -[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"string","name":"app","type":"string"}],"name":"Firmware","type":"event"}] \ No newline at end of file diff --git a/cmd/server/abis/pebble_proposal.json b/cmd/server/abis/pebble_proposal.json deleted file mode 100644 index fb8c565..0000000 --- a/cmd/server/abis/pebble_proposal.json +++ /dev/null @@ -1 +0,0 @@ -[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"device","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"avatar","type":"string"}],"name":"Proposal","type":"event"}] \ No newline at end of file diff --git a/cmd/server/abis/pebble_remove.json b/cmd/server/abis/pebble_remove.json deleted file mode 100644 index c5d964b..0000000 --- a/cmd/server/abis/pebble_remove.json +++ /dev/null @@ -1 +0,0 @@ -[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"Remove","type":"event"}] \ No newline at end of file diff --git a/cmd/server/api/http.go b/cmd/server/api/http.go deleted file mode 100644 index d02daaf..0000000 --- a/cmd/server/api/http.go +++ /dev/null @@ -1,235 +0,0 @@ -package api - -import ( - "context" - "encoding/base64" - "io" - "log/slog" - "net/http" - "strings" - - "github.com/ethereum/go-ethereum/common" - "github.com/gin-gonic/gin" - "github.com/machinefi/ioconnect-go/pkg/ioconnect" - "github.com/pkg/errors" - - "github.com/iotexproject/pebble-server/cmd/server/apitypes" - "github.com/iotexproject/pebble-server/cmd/server/clients" - "github.com/iotexproject/pebble-server/models" - "github.com/iotexproject/pebble-server/modules/event" -) - -type httpServer struct { - ctx context.Context - engine *gin.Engine - jwk *ioconnect.JWK - clients *clients.Manager -} - -func Run(ctx context.Context, jwk *ioconnect.JWK, clientMgr *clients.Manager, address string) error { - s := &httpServer{ - ctx: ctx, - engine: gin.Default(), - jwk: jwk, - clients: clientMgr, - } - - s.engine.POST("/issue_vc", s.issueJWTCredential) - s.engine.POST("/device/data", s.verifyToken, s.receiveDeviceData) - s.engine.GET("/device/query", s.verifyToken, s.queryDeviceState) - s.engine.GET("/didDoc", s.didDoc) - - err := s.engine.Run(address) - return errors.Wrap(err, "failed to start http server") -} - -// verifyToken make sure the client token is issued by sequencer -func (s *httpServer) verifyToken(c *gin.Context) { - tok := c.GetHeader("Authorization") - if tok == "" { - tok = c.Query("authorization") - } - - if tok == "" { - slog.Error("empty authorization token") - return - } - - tok = strings.TrimSpace(strings.Replace(tok, "Bearer", " ", 1)) - - clientID, err := s.jwk.VerifyToken(tok) - if err != nil { - slog.Error("failed to verify token", "error", err) - c.JSON(http.StatusUnauthorized, apitypes.NewErrRsp(errors.Wrap(err, "invalid credential token"))) - return - } - client := s.clients.ClientByIoID(clientID) - if client == nil { - slog.Error("failed to get client by ioid", "client_id", clientID) - c.JSON(http.StatusUnauthorized, apitypes.NewErrRsp(errors.New("invalid credential token"))) - return - } - - ctx := clients.WithClientID(c.Request.Context(), client) - c.Request = c.Request.WithContext(ctx) - slog.Info("verify token succeed", "client_id", clientID) -} - -func (s *httpServer) receiveDeviceData(c *gin.Context) { - payload, err := io.ReadAll(c.Request.Body) - if err != nil { - slog.Error("failed to read request body", "error", err) - c.JSON(http.StatusInternalServerError, apitypes.NewErrRsp(errors.Wrap(err, "failed to read request body"))) - return - } - defer c.Request.Body.Close() - - // decrypt did comm message - client := clients.ClientIDFrom(c.Request.Context()) - if client != nil { - slog.Info("decrypted payload", "payload", string(payload)) - payload, err = s.jwk.Decrypt(payload, client.DID()) - if err != nil { - slog.Error("failed to decrypt didcomm cipher data", "error", err) - c.JSON(http.StatusBadRequest, apitypes.NewErrRsp(errors.Wrap(err, "failed to decrypt didcomm cipher data"))) - return - } - slog.Info("encrypted payload", "payload", string(payload)) - } - payload, err = base64.RawURLEncoding.DecodeString(string(payload)) - if err != nil { - slog.Error("failed to decode base64 data", "error", err) - c.JSON(http.StatusBadRequest, apitypes.NewErrRsp(errors.Wrap(err, "failed to decode base64 data"))) - return - } - - e := &event.DeviceData{} - if err := e.Unmarshal(payload); err != nil { - slog.Error("failed to unmarshal device data", "error", err) - c.JSON(http.StatusBadRequest, apitypes.NewErrRsp(errors.Wrap(err, "failed to unmarshal request body"))) - return - } - e.Imei = client.DID() - if err := e.Handle(s.ctx); err != nil { - slog.Error("failed to handle device data", "error", err) - c.JSON(http.StatusInternalServerError, apitypes.NewErrRsp(errors.Wrap(err, "failed to receive device data"))) - return - } - c.Status(http.StatusOK) -} - -func (s *httpServer) queryDeviceState(c *gin.Context) { - client := clients.ClientIDFrom(c.Request.Context()) - - dev := &models.Device{ID: client.DID()} - if err := event.FetchByPrimary(s.ctx, dev); err != nil { - slog.Error("failed to query device", "error", err) - c.JSON(http.StatusInternalServerError, apitypes.NewErrRsp(err)) - return - } - if dev.Status == models.CREATED { - slog.Error("device is not propsaled", "device_id", dev.ID) - c.JSON(http.StatusBadRequest, apitypes.NewErrRsp(errors.Errorf("device %s is not propsaled", dev.ID))) - return - } - var ( - firmware string - uri string - version string - ) - if parts := strings.Split(dev.RealFirmware, " "); len(parts) == 2 { - app := &models.App{ID: parts[0]} - err := event.FetchByPrimary(s.ctx, app) - if err == nil { - firmware = app.ID - uri = app.Uri - version = app.Version - } - } - - // meta := contexts.AppMeta().MustFrom(ctx) - //pubType := "pub_DeviceQueryRsp" - pubData := &struct { - Status int32 `json:"status"` - Proposer string `json:"proposer"` - Firmware string `json:"firmware,omitempty"` - URI string `json:"uri,omitempty"` - Version string `json:"version,omitempty"` - ServerMeta string `json:"server_meta,omitempty"` - }{ - Status: dev.Status, - Proposer: dev.Proposer, - Firmware: firmware, - URI: uri, - Version: version, - // ServerMeta: meta.String(), - } - - // if client != nil { - // slog.Info("encrypt response task query", "response", response) - // cipher, err := s.jwk.EncryptJSON(response, client.KeyAgreementKID()) - // if err != nil { - // c.JSON(http.StatusInternalServerError, apitypes.NewErrRsp(errors.Wrap(err, "failed to encrypt response when query task"))) - // return - // } - // c.Data(http.StatusOK, "application/octet-stream", cipher) - // return - // } - - c.JSON(http.StatusOK, pubData) -} - -func (s *httpServer) didDoc(c *gin.Context) { - if s.jwk == nil { - c.JSON(http.StatusNotAcceptable, apitypes.NewErrRsp(errors.New("jwk is not config"))) - return - } - c.JSON(http.StatusOK, s.jwk.Doc()) -} - -func (s *httpServer) issueJWTCredential(c *gin.Context) { - req := new(apitypes.IssueTokenReq) - if err := c.ShouldBindJSON(req); err != nil { - slog.Error("failed to bind request", "error", err) - c.JSON(http.StatusBadRequest, apitypes.NewErrRsp(err)) - return - } - - client := s.clients.ClientByIoID(req.ClientID) - if client == nil { - slog.Error("failed to get client", "client_id", req.ClientID) - c.String(http.StatusForbidden, errors.Errorf("client is not register to ioRegistry").Error()) - return - } - - token, err := s.jwk.SignToken(req.ClientID) - if err != nil { - slog.Error("failed to sign token", "client_id", req.ClientID, "error", err) - c.String(http.StatusInternalServerError, errors.Wrap(err, "failed to sign token").Error()) - return - } - slog.Info("token signed", "token", token) - - cipher, err := s.jwk.Encrypt([]byte(token), client.KeyAgreementKID()) - if err != nil { - slog.Error("failed to encrypt", "client_id", req.ClientID, "error", err) - c.String(http.StatusInternalServerError, errors.Wrap(err, "failed to encrypt").Error()) - return - } - - dev := &models.Device{ - ID: client.DID(), - Owner: client.Owner().String(), - Address: common.HexToAddress(strings.TrimPrefix(client.DID(), "did:io:")).String(), - Status: models.CONFIRM, - Proposer: client.Owner().String(), - OperationTimes: models.NewOperationTimes(), - } - if _, err := event.UpsertOnConflict(s.ctx, dev, "id", "owner", "proposer", "status", "updated_at"); err != nil { - slog.Error("failed to upsert device", "client_id", req.ClientID, "error", err) - c.String(http.StatusInternalServerError, errors.Wrap(err, "failed to upsert device").Error()) - return - } - - c.Data(http.StatusOK, "application/json", cipher) -} diff --git a/cmd/server/apitypes/apitypes.go b/cmd/server/apitypes/apitypes.go deleted file mode 100644 index f7263dc..0000000 --- a/cmd/server/apitypes/apitypes.go +++ /dev/null @@ -1,57 +0,0 @@ -package apitypes - -import "time" - -type ErrRsp struct { - Error string `json:"error,omitempty"` -} - -func NewErrRsp(err error) *ErrRsp { - return &ErrRsp{Error: err.Error()} -} - -type HandleMessageReq struct { - ProjectID uint64 `json:"projectID" binding:"required"` - ProjectVersion string `json:"projectVersion" binding:"required"` - Data string `json:"data" binding:"required"` -} - -type HandleMessageRsp struct { - MessageID string `json:"messageID"` -} - -type LivenessRsp struct { - Status string `json:"status"` -} - -type StateLog struct { - State string `json:"state"` - Time time.Time `json:"time"` - Comment string `json:"comment"` - Result string `json:"result"` -} - -type QueryTaskStateLogRsp struct { - TaskID uint64 `json:"taskID"` - ProjectID uint64 `json:"projectID"` - States []*StateLog `json:"states"` -} - -type QueryMessageStateLogRsp struct { - MessageID string `json:"messageID"` - States []*StateLog `json:"states"` -} - -type CoordinatorConfigRsp struct { - ProjectContractAddress string `json:"projectContractAddress"` - OperatorETHAddress string `json:"OperatorETHAddress,omitempty"` - OperatorSolanaAddress string `json:"operatorSolanaAddress,omitempty"` -} - -type IssueTokenReq struct { - ClientID string `json:"clientID"` -} - -type IssueTokenRsp struct { - Token string `json:"token"` -} diff --git a/cmd/server/clients/client.go b/cmd/server/clients/client.go deleted file mode 100644 index fa1754e..0000000 --- a/cmd/server/clients/client.go +++ /dev/null @@ -1,27 +0,0 @@ -package clients - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/machinefi/ioconnect-go/pkg/ioconnect" -) - -type Client struct { - owner common.Address - jwk *ioconnect.JWK -} - -func (c *Client) KeyAgreementKID() string { - return c.jwk.KeyAgreementKID() -} - -func (c *Client) DID() string { - return c.jwk.DID() -} - -func (c *Client) Doc() *ioconnect.Doc { - return c.jwk.Doc() -} - -func (c *Client) Owner() common.Address { - return c.owner -} diff --git a/cmd/server/clients/context.go b/cmd/server/clients/context.go deleted file mode 100644 index 5509fb7..0000000 --- a/cmd/server/clients/context.go +++ /dev/null @@ -1,17 +0,0 @@ -package clients - -import "context" - -type clientIDCtxKey struct{} - -func WithClientID(parent context.Context, client *Client) context.Context { - if parent == nil { - panic("with client id context, nil context") - } - return context.WithValue(parent, clientIDCtxKey{}, client) -} - -func ClientIDFrom(ctx context.Context) *Client { - v, _ := ctx.Value(clientIDCtxKey{}).(*Client) - return v -} diff --git a/cmd/server/clients/contracts/Makefile b/cmd/server/clients/contracts/Makefile deleted file mode 100644 index 8e48f6e..0000000 --- a/cmd/server/clients/contracts/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -.DEFAULT_GOAL := update - -.PHONY: update -update: fetch generate_abi - -.PHONY: fetch -fetch: - @echo "#### clone ioID-contracts main branch..." - @if [ -d "ioid" ]; then \ - cd ioid && git pull --quiet origin main; \ - else \ - git clone -b main --quiet git@github.com:machinefi/ioID-contracts.git ioid; \ - fi - @echo DONE - -.PHONY: generate_abi -generate_abi: generate_abi_ioid generate_abi_project_device - -.PHONY: generate_abi_ioid -generate_abi_ioid: - @echo "#### generate abis of ioID from latest contracts..." - @cd ioid && yarn install > /dev/null 2>&1 && yarn hardhat compile > /dev/null 2>&1 - @cat ioid/artifacts/contracts/ioIDRegistry.sol/ioIDRegistry.json | jq .abi > ioIDRegistry.json - @echo DONE - -.PHONY: generate_abi_project_device -generate_abi_project_device: - @echo "#### generate abis of ProjectDevice from latest contracts..." - @cd ../../smartcontracts && yarn install > /dev/null 2>&1 && yarn hardhat compile > /dev/null 2>&1 - @cat ../../smartcontracts/artifacts/contracts/examples/ProjectDevice.sol/ProjectDevice.json | jq .abi > ProjectDevice.json - @cat ../../smartcontracts/artifacts/contracts/W3bstreamProject.sol/W3bstreamProject.json | jq .abi > W3bstreamProject.json - @echo DONE - -.PHONY: clean -clean: - @rm -rf ioid - diff --git a/cmd/server/clients/contracts/ProjectDevice.json b/cmd/server/clients/contracts/ProjectDevice.json deleted file mode 100644 index aef14bd..0000000 --- a/cmd/server/clients/contracts/ProjectDevice.json +++ /dev/null @@ -1,142 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address", - "name": "_ioIDRegistry", - "type": "address" - }, - { - "internalType": "address", - "name": "_w3bstreamProject", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "projectId", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "device", - "type": "address" - } - ], - "name": "Approve", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "projectId", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "device", - "type": "address" - } - ], - "name": "Unapprove", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_device", - "type": "address" - } - ], - "name": "approve", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_device", - "type": "address" - } - ], - "name": "approved", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "ioIDRegistry", - "outputs": [ - { - "internalType": "contract IioIDRegistry", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_device", - "type": "address" - } - ], - "name": "unapprove", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "w3bstreamProject", - "outputs": [ - { - "internalType": "contract IW3bstreamProject", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/cmd/server/clients/contracts/W3bstreamProject.json b/cmd/server/clients/contracts/W3bstreamProject.json deleted file mode 100644 index a645a3c..0000000 --- a/cmd/server/clients/contracts/W3bstreamProject.json +++ /dev/null @@ -1,479 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "projectId", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "key", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "value", - "type": "bytes" - } - ], - "name": "AttributeSet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "binder", - "type": "address" - } - ], - "name": "BinderSet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "projectId", - "type": "uint256" - } - ], - "name": "ProjectBinded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "projectId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "string", - "name": "uri", - "type": "string" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "hash", - "type": "bytes32" - } - ], - "name": "ProjectConfigUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "projectId", - "type": "uint256" - } - ], - "name": "ProjectPaused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "projectId", - "type": "uint256" - } - ], - "name": "ProjectResumed", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "_name", - "type": "bytes32" - } - ], - "name": "attribute", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "name": "attributes", - "outputs": [ - { - "internalType": "bytes", - "name": "", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - }, - { - "internalType": "bytes32[]", - "name": "_keys", - "type": "bytes32[]" - } - ], - "name": "attributesOf", - "outputs": [ - { - "internalType": "bytes[]", - "name": "values_", - "type": "bytes[]" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - } - ], - "name": "bind", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "binder", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - } - ], - "name": "config", - "outputs": [ - { - "components": [ - { - "internalType": "string", - "name": "uri", - "type": "string" - }, - { - "internalType": "bytes32", - "name": "hash", - "type": "bytes32" - } - ], - "internalType": "struct W3bstreamProject.ProjectConfig", - "name": "", - "type": "tuple" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "count", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_project", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - } - ], - "name": "isPaused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - } - ], - "name": "isValidProject", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - } - ], - "name": "ownerOf", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - } - ], - "name": "pause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "project", - "outputs": [ - { - "internalType": "contract IERC721", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - } - ], - "name": "resume", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - }, - { - "internalType": "bytes32[]", - "name": "_keys", - "type": "bytes32[]" - }, - { - "internalType": "bytes[]", - "name": "_values", - "type": "bytes[]" - } - ], - "name": "setAttributes", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_binder", - "type": "address" - } - ], - "name": "setBinder", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - }, - { - "internalType": "string", - "name": "_uri", - "type": "string" - }, - { - "internalType": "bytes32", - "name": "_hash", - "type": "bytes32" - } - ], - "name": "updateConfig", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/cmd/server/clients/contracts/ioID.json b/cmd/server/clients/contracts/ioID.json deleted file mode 100644 index ce63bf1..0000000 --- a/cmd/server/clients/contracts/ioID.json +++ /dev/null @@ -1,781 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "approved", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "operator", - "type": "address" - }, - { - "indexed": false, - "internalType": "bool", - "name": "approved", - "type": "bool" - } - ], - "name": "ApprovalForAll", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "wallet", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "did", - "type": "string" - } - ], - "name": "CreateIoID", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "wallet", - "type": "address" - }, - { - "indexed": false, - "internalType": "string", - "name": "did", - "type": "string" - } - ], - "name": "RemoveDIDWallet", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "minter", - "type": "address" - } - ], - "name": "SetMinter", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "id", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "resolver", - "type": "address" - } - ], - "name": "SetResolver", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "deviceProject", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_device", - "type": "address" - } - ], - "name": "did", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "getApproved", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_minter", - "type": "address" - }, - { - "internalType": "address", - "name": "_walletRegistry", - "type": "address" - }, - { - "internalType": "address", - "name": "_walletImplementation", - "type": "address" - }, - { - "internalType": "string", - "name": "_name", - "type": "string" - }, - { - "internalType": "string", - "name": "_symbol", - "type": "string" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "operator", - "type": "address" - } - ], - "name": "isApprovedForAll", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_device", - "type": "address" - }, - { - "internalType": "address", - "name": "_owner", - "type": "address" - } - ], - "name": "mint", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "minter", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "ownerOf", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "projectDeviceCount", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_projectId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_start", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_pageSize", - "type": "uint256" - } - ], - "name": "projectIDs", - "outputs": [ - { - "internalType": "address[]", - "name": "array", - "type": "address[]" - }, - { - "internalType": "address", - "name": "next", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_device", - "type": "address" - } - ], - "name": "removeDID", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "resolver", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "safeTransferFrom", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "safeTransferFrom", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "operator", - "type": "address" - }, - { - "internalType": "bool", - "name": "approved", - "type": "bool" - } - ], - "name": "setApprovalForAll", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_minter", - "type": "address" - } - ], - "name": "setMinter", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_resolver", - "type": "address" - } - ], - "name": "setResolver", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes4", - "name": "interfaceId", - "type": "bytes4" - } - ], - "name": "supportsInterface", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - } - ], - "name": "tokenByIndex", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "uint256", - "name": "index", - "type": "uint256" - } - ], - "name": "tokenOfOwnerByIndex", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "tokenURI", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_id", - "type": "uint256" - } - ], - "name": "wallet", - "outputs": [ - { - "internalType": "address", - "name": "wallet_", - "type": "address" - }, - { - "internalType": "string", - "name": "did_", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "string", - "name": "_did", - "type": "string" - } - ], - "name": "wallet", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "walletImplementation", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "walletRegistry", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/cmd/server/clients/contracts/ioIDRegistry.json b/cmd/server/clients/contracts/ioIDRegistry.json deleted file mode 100644 index 784b550..0000000 --- a/cmd/server/clients/contracts/ioIDRegistry.json +++ /dev/null @@ -1,469 +0,0 @@ -[ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "device", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "hash", - "type": "bytes32" - } - ], - "name": "NewDevice", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "device", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "RemoveDevice", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "store", - "type": "address" - } - ], - "name": "SetIoIdStore", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "device", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "hash", - "type": "bytes32" - } - ], - "name": "UpdateDevice", - "type": "event" - }, - { - "inputs": [], - "name": "DOMAIN_SEPARATOR", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "EIP712DOMAIN_TYPEHASH", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "METHOD", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "device", - "type": "address" - } - ], - "name": "deviceTokenId", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "device", - "type": "address" - } - ], - "name": "documentHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "device", - "type": "address" - } - ], - "name": "documentID", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "device", - "type": "address" - } - ], - "name": "documentURI", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "device", - "type": "address" - } - ], - "name": "exists", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_ioIDStore", - "type": "address" - }, - { - "internalType": "address", - "name": "_ioID", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "ioID", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "ioIDStore", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "device", - "type": "address" - } - ], - "name": "nonces", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "device", - "type": "address" - } - ], - "name": "permitHash", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "deviceContract", - "type": "address" - }, - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "device", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "hash", - "type": "bytes32" - }, - { - "internalType": "string", - "name": "uri", - "type": "string" - }, - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "name": "register", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "registeredNFT", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "device", - "type": "address" - }, - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "name": "remove", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_ioIDStore", - "type": "address" - } - ], - "name": "setIoIDStore", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "device", - "type": "address" - }, - { - "internalType": "bytes32", - "name": "hash", - "type": "bytes32" - }, - { - "internalType": "string", - "name": "uri", - "type": "string" - }, - { - "internalType": "uint8", - "name": "v", - "type": "uint8" - }, - { - "internalType": "bytes32", - "name": "r", - "type": "bytes32" - }, - { - "internalType": "bytes32", - "name": "s", - "type": "bytes32" - } - ], - "name": "update", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/cmd/server/clients/manager.go b/cmd/server/clients/manager.go deleted file mode 100644 index bf965f2..0000000 --- a/cmd/server/clients/manager.go +++ /dev/null @@ -1,195 +0,0 @@ -package clients - -import ( - _ "embed" // embed mock clients configuration - "fmt" - "io" - "log/slog" - "math/big" - "net/http" - "strings" - "sync" - - "github.com/ethereum/go-ethereum/crypto" - - "github.com/iotexproject/pebble-server/cmd/server/contract" - - "github.com/ethereum/go-ethereum/common" - "github.com/machinefi/ioconnect-go/pkg/ioconnect" - "github.com/pkg/errors" -) - -var ( - //go:embed contracts/ioIDRegistry.json - abiIoIDRegistry []byte - //go:embed contracts/ProjectDevice.json - abiProjectClient []byte - //go:embed contracts/W3bstreamProject.json - abiW3bstreamProject []byte - //go:embed contracts/ioID.json - abiIoID []byte -) - -func NewManager( - projectClientContractAddress string, - ioIDRegisterContractAddress string, - w3bstreamProjectContractAddress string, - ioIDContractAddress string, - ioIDRegistryServiceEndpoint string, - chainEndpoint string, -) (*Manager, error) { - manager := &Manager{ - mux: sync.Mutex{}, - pool: make(map[string]*Client), - ioIDRegistryEndpoint: ioIDRegistryServiceEndpoint, - } - - { - name := "IoIDRegistry" - instance, err := contract.NewInstanceByABI(name, ioIDRegisterContractAddress, chainEndpoint, abiIoIDRegistry) - if err != nil { - return nil, errors.Wrapf(err, "failed to new contract instance: %s", name) - } - manager.ioIDRegistryInstance = instance - } - - { - name := "ProjectClient" - instance, err := contract.NewInstanceByABI(name, projectClientContractAddress, chainEndpoint, abiProjectClient) - if err != nil { - return nil, errors.Wrapf(err, "failed to new contract instance: %s", name) - } - manager.projectClientInstance = instance - } - - { - name := "W3bstreamProject" - instance, err := contract.NewInstanceByABI(name, w3bstreamProjectContractAddress, chainEndpoint, abiW3bstreamProject) - if err != nil { - return nil, errors.Wrapf(err, "failed to new contract instance: %s", name) - } - manager.w3bsteramProjectInstance = instance - } - - { - name := "ioID" - instance, err := contract.NewInstanceByABI(name, ioIDContractAddress, chainEndpoint, abiIoID) - if err != nil { - return nil, errors.Wrapf(err, "failed to new contract instance: %s", name) - } - manager.ioIDInstance = instance - } - - return manager, nil -} - -type Manager struct { - mux sync.Mutex - pool map[string]*Client - ioIDRegistryInstance contract.Instance - projectClientInstance contract.Instance - w3bsteramProjectInstance contract.Instance - ioIDInstance contract.Instance - ioIDRegistryEndpoint string -} - -// clientByIoID get client from pool -func (mgr *Manager) clientByIoID(id string) *Client { - mgr.mux.Lock() - defer mgr.mux.Unlock() - return mgr.pool[id] -} - -// ClientByIoID get client from pool, if not hit, try fetch client from contract -func (mgr *Manager) ClientByIoID(id string) *Client { - c := mgr.clientByIoID(id) - if c != nil { - return c - } - - c, err := mgr.fetchFromContract(id) - if err != nil { - slog.Error("fetch client", "error", err) - return c - } - slog.Info("new client fetched from contract", "id", id, "did", c.DID(), "kid", c.KeyAgreementKID(), "client_doc", c.Doc()) - - mgr.mux.Lock() - defer mgr.mux.Unlock() - mgr.pool[c.DID()] = c - return c -} - -func (mgr *Manager) fetchFromContract(id string) (*Client, error) { - var ( - address = common.HexToAddress(strings.TrimPrefix(id, "did:io:")) - uri string - ioID *big.Int - owner common.Address - ) - - if err := mgr.ioIDRegistryInstance.ReadResult("documentURI", &uri, address); err != nil { - return nil, errors.Wrapf(err, "failed to read client document uri: %s %s", id, address.String()) - } - if err := mgr.ioIDRegistryInstance.ReadResult("deviceTokenId", &ioID, address); err != nil { - return nil, errors.Wrapf(err, "failed to read client device token id: %s %s", id, address.String()) - } - if err := mgr.ioIDInstance.ReadResult("ownerOf", &owner, ioID); err != nil { - return nil, errors.Wrapf(err, "failed to read client ioID owner: %s %s", id, ioID.String()) - } - - url := fmt.Sprintf("https://%s/cid/%s", mgr.ioIDRegistryEndpoint, uri) - rsp, err := http.Get(url) - if err != nil { - return nil, errors.Wrap(err, "failed to fetch client did doc from io registry") - } - - defer rsp.Body.Close() - content, err := io.ReadAll(rsp.Body) - if err != nil { - return nil, errors.Wrap(err, "failed to read io registry response") - } - jwk, err := ioconnect.NewJWKFromDoc(content) - if err != nil { - return nil, errors.Wrap(err, "failed to parse did doc") - } - return &Client{ - owner: owner, - jwk: jwk, - }, nil -} - -func (mgr *Manager) HasProjectPermission(clientID string, projectID uint64) (bool, error) { - if c := mgr.clientByIoID(clientID); c == nil { - return false, nil - } - - var ( - _projectID = big.NewInt(int64(projectID)) - attrVal = make([]byte, 0) - attrKey = crypto.Keccak256Hash([]byte("key")) // todo replace with correct key name - instance = mgr.projectClientInstance // use default contract - ) - if err := mgr.w3bsteramProjectInstance.ReadResult("attribute", &attrVal, _projectID, attrKey); err == nil && len(attrVal) > 0 { - slog.Info("get project attribute", "key", "key", "value", string(attrVal)) - name := fmt.Sprintf("ProjectClientFor%d", projectID) - // todo should try acquire exists contract instance by name - // todo should parse attribute value to project assigned contract meta - projectAddress := "" - projectChain := "" - projectABI := "" // should have same interface for query is client is approved - if _instance, err := contract.NewInstanceByABI(name, projectAddress, projectChain, []byte(projectABI)); err == nil { - instance = _instance // use project assigned contract - } - } - - var ( - address = common.HexToAddress(strings.TrimPrefix(clientID, "did:io:")) - approved bool - ) - - if err := instance.ReadResult("approved", &approved, _projectID, address); err != nil { - return false, errors.Wrapf(err, "failed to read ProjectClient contract: %s", instance.Address()) - } - return approved, nil -} diff --git a/cmd/server/config/config.go b/cmd/server/config/config.go index 1c0c390..56f6285 100644 --- a/cmd/server/config/config.go +++ b/cmd/server/config/config.go @@ -1,14 +1,19 @@ package config import ( + "fmt" "log/slog" "os" + "reflect" + "strings" - "github.com/iotexproject/pebble-server/util/env" + "github.com/fatih/color" + "github.com/spf13/viper" ) type Config struct { LogLevel slog.Level `env:"LOG_LEVEL,optional"` + ServiceEndpoint string `env:"HTTP_SERVICE_ENDPOINT"` DatabaseDSN string `env:"DATABASE_DSN"` ChainEndpoint string `env:"CHAIN_ENDPOINT,optional"` BeginningBlockNumber uint64 `env:"BEGINNING_BLOCK_NUMBER,optional"` @@ -31,6 +36,7 @@ type Config struct { var ( defaultTestnetConfig = &Config{ LogLevel: slog.LevelInfo, + ServiceEndpoint: ":9000", DatabaseDSN: "postgres://postgres:mysecretpassword@postgres:5432/w3bstream?sslmode=disable", ChainEndpoint: "https://babel-api.testnet.iotex.io", BeginningBlockNumber: 28685000, @@ -50,7 +56,7 @@ var ( ) func (c *Config) init() error { - if err := env.ParseEnv(c); err != nil { + if err := parseEnv(c); err != nil { return err } h := slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.Level(c.LogLevel)}) @@ -76,5 +82,74 @@ func Get() (*Config, error) { } func (c *Config) Print() { - env.Print(c) + print(c) +} + +func parseEnvTag(tag string) (key string, require bool) { + if tag == "" || tag == "-" { + return "", false + } + tagKeys := strings.Split(tag, ",") + key = tagKeys[0] + if len(tagKeys) > 1 && tagKeys[1] == "optional" { + return key, false + } + return key, true +} + +func parseEnv(c any) error { + rv := reflect.ValueOf(c).Elem() + rt := reflect.TypeOf(c).Elem() + + for i := 0; i < rt.NumField(); i++ { + fi := rt.Field(i) + fv := rv.Field(i) + key, require := parseEnvTag(fi.Tag.Get("env")) + if key == "" { + continue + } + viper.MustBindEnv(key) + + v := viper.Get(key) + if require && v == nil && fv.IsZero() { + panic(fmt.Sprintf("env `%s` is require but got empty", key)) + } + if v == nil { + continue + } + + switch fv.Kind() { + case reflect.String: + fv.Set(reflect.ValueOf(viper.GetString(key))) + case reflect.Int: + if fi.Type == reflect.TypeOf(slog.Level(0)) { + level := slog.Level(viper.GetInt(key)) + fv.Set(reflect.ValueOf(level)) + } else { + fv.Set(reflect.ValueOf(viper.GetInt(key))) + } + case reflect.Uint64: + fv.Set(reflect.ValueOf(viper.GetUint64(key))) + } + } + return nil +} + +func print(c any) { + rt := reflect.TypeOf(c).Elem() + rv := reflect.ValueOf(c).Elem() + + if env, ok := c.(interface{ Env() string }); ok { + fmt.Println(color.CyanString("ENV: %s", env.Env())) + } + + for i := 0; i < rt.NumField(); i++ { + fi := rt.Field(i) + fv := rv.Field(i) + key, _ := parseEnvTag(fi.Tag.Get("env")) + if key == "" { + continue + } + fmt.Printf("%s: %v\n", color.GreenString(key), fv.Interface()) + } } diff --git a/cmd/server/config/default.yml b/cmd/server/config/default.yml deleted file mode 100755 index 5d0ab91..0000000 --- a/cmd/server/config/default.yml +++ /dev/null @@ -1,97 +0,0 @@ -PEBBLE_SEQUENCER__Blockchain_Clients_0_Endpoint: https://babel-api.testnet.iotex.io -PEBBLE_SEQUENCER__Blockchain_Clients_0_Network: IOTX_TESTNET -PEBBLE_SEQUENCER__Blockchain_Clients_1_Endpoint: https://babel-api.mainnet.iotex.io -PEBBLE_SEQUENCER__Blockchain_Clients_1_Network: IOTX_MAINNET -PEBBLE_SEQUENCER__Blockchain_Contracts_0_Address: 0x189e2ed6eafbceaf938d049cf3685828b5493952 -PEBBLE_SEQUENCER__Blockchain_Contracts_0_Events_0_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"avatar","type":"string"}],"name":"Updated","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_0_Events_0_Name: Updated -PEBBLE_SEQUENCER__Blockchain_Contracts_0_ID: PEBBLE_ACCOUNT -PEBBLE_SEQUENCER__Blockchain_Contracts_0_Network: IOTX_MAINNET -PEBBLE_SEQUENCER__Blockchain_Contracts_1_Address: 0xc5f406c42c96e68756311dad49de99b0f4a1a722 -PEBBLE_SEQUENCER__Blockchain_Contracts_1_Events_0_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"FirmwareRemoved","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_1_Events_0_Name: FirmwareRemoved -PEBBLE_SEQUENCER__Blockchain_Contracts_1_Events_1_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"version","type":"string"},{"indexed":false,"internalType":"string","name":"uri","type":"string"},{"indexed":false,"internalType":"string","name":"avatar","type":"string"}],"name":"FirmwareUpdated","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_1_Events_1_Name: FirmwareUpdated -PEBBLE_SEQUENCER__Blockchain_Contracts_1_ID: PEBBLE_FIRMWARE -PEBBLE_SEQUENCER__Blockchain_Contracts_1_Network: IOTX_MAINNET -PEBBLE_SEQUENCER__Blockchain_Contracts_2_Address: 0xb86f97d494eef8c6d618ee2049419ee0ce843f28 -PEBBLE_SEQUENCER__Blockchain_Contracts_2_Events_0_ABI: '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"balance","type":"uint256"}],"name":"Deposit","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_2_Events_0_Name: Deposit -PEBBLE_SEQUENCER__Blockchain_Contracts_2_Events_1_ABI: '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"balance","type":"uint256"}],"name":"Paid","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_2_Events_1_Name: Paid -PEBBLE_SEQUENCER__Blockchain_Contracts_2_Events_2_ABI: '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"balance","type":"uint256"}],"name":"Withdraw","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_2_Events_2_Name: Withdraw -PEBBLE_SEQUENCER__Blockchain_Contracts_2_ID: PEBBLE_BANK -PEBBLE_SEQUENCER__Blockchain_Contracts_2_Network: IOTX_MAINNET -PEBBLE_SEQUENCER__Blockchain_Contracts_3_Address: 0xc9d7d9f25b98119df5b2303ac0df6b15c982bbf5 -PEBBLE_SEQUENCER__Blockchain_Contracts_3_Events_0_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"string","name":"config","type":"string"}],"name":"Config","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_3_Events_0_Name: Config -PEBBLE_SEQUENCER__Blockchain_Contracts_3_Events_1_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"device","type":"address"},{"indexed":false,"internalType":"uint32","name":"channel","type":"uint32"}],"name":"Confirm","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_3_Events_1_Name: Confirm -PEBBLE_SEQUENCER__Blockchain_Contracts_3_Events_2_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"string","name":"app","type":"string"}],"name":"Firmware","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_3_Events_2_Name: Firmware -PEBBLE_SEQUENCER__Blockchain_Contracts_3_Events_3_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"device","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"avatar","type":"string"}],"name":"Proposal","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_3_Events_3_Name: Proposal -PEBBLE_SEQUENCER__Blockchain_Contracts_3_Events_4_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"Remove","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_3_Events_4_Name: Remove -PEBBLE_SEQUENCER__Blockchain_Contracts_3_ID: PEBBLE_DEVICE -PEBBLE_SEQUENCER__Blockchain_Contracts_3_Network: IOTX_MAINNET -PEBBLE_SEQUENCER__Blockchain_Contracts_4_Address: 0xbc458a041a50bf5abb900c78b7355d54e92fcfba -PEBBLE_SEQUENCER__Blockchain_Contracts_4_Events_0_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"avatar","type":"string"}],"name":"Updated","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_4_Events_0_Name: Updated -PEBBLE_SEQUENCER__Blockchain_Contracts_4_ID: PEBBLE_ACCOUNT -PEBBLE_SEQUENCER__Blockchain_Contracts_4_Network: IOTX_TESTNET -PEBBLE_SEQUENCER__Blockchain_Contracts_5_Address: 0x93ea43b4548058f4c02925f0725422e6dc81c92d -PEBBLE_SEQUENCER__Blockchain_Contracts_5_Events_0_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"FirmwareRemoved","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_5_Events_0_Name: FirmwareRemoved -PEBBLE_SEQUENCER__Blockchain_Contracts_5_Events_1_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"version","type":"string"},{"indexed":false,"internalType":"string","name":"uri","type":"string"},{"indexed":false,"internalType":"string","name":"avatar","type":"string"}],"name":"FirmwareUpdated","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_5_Events_1_Name: FirmwareUpdated -PEBBLE_SEQUENCER__Blockchain_Contracts_5_ID: PEBBLE_FIRMWARE -PEBBLE_SEQUENCER__Blockchain_Contracts_5_Network: IOTX_TESTNET -PEBBLE_SEQUENCER__Blockchain_Contracts_6_Address: 0xd313b3131e238c635f2fe4a84eadad71b3ed25fa -PEBBLE_SEQUENCER__Blockchain_Contracts_6_Events_0_ABI: '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"balance","type":"uint256"}],"name":"Deposit","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_6_Events_0_Name: Deposit -PEBBLE_SEQUENCER__Blockchain_Contracts_6_Events_1_ABI: '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"balance","type":"uint256"}],"name":"Paid","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_6_Events_1_Name: Paid -PEBBLE_SEQUENCER__Blockchain_Contracts_6_Events_2_ABI: '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"balance","type":"uint256"}],"name":"Withdraw","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_6_Events_2_Name: Withdraw -PEBBLE_SEQUENCER__Blockchain_Contracts_6_ID: PEBBLE_BANK -PEBBLE_SEQUENCER__Blockchain_Contracts_6_Network: IOTX_TESTNET -PEBBLE_SEQUENCER__Blockchain_Contracts_7_Address: 0x1aa325e5144f763a520867c56fc77cc1411430d0 -PEBBLE_SEQUENCER__Blockchain_Contracts_7_Events_0_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"string","name":"config","type":"string"}],"name":"Config","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_7_Events_0_Name: Config -PEBBLE_SEQUENCER__Blockchain_Contracts_7_Events_1_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"device","type":"address"},{"indexed":false,"internalType":"uint32","name":"channel","type":"uint32"}],"name":"Confirm","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_7_Events_1_Name: Confirm -PEBBLE_SEQUENCER__Blockchain_Contracts_7_Events_2_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"string","name":"app","type":"string"}],"name":"Firmware","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_7_Events_2_Name: Firmware -PEBBLE_SEQUENCER__Blockchain_Contracts_7_Events_3_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"device","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"avatar","type":"string"}],"name":"Proposal","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_7_Events_3_Name: Proposal -PEBBLE_SEQUENCER__Blockchain_Contracts_7_Events_4_ABI: '[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"imei","type":"string"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"Remove","type":"event"}]' -PEBBLE_SEQUENCER__Blockchain_Contracts_7_Events_4_Name: Remove -PEBBLE_SEQUENCER__Blockchain_Contracts_7_ID: PEBBLE_DEVICE -PEBBLE_SEQUENCER__Blockchain_Contracts_7_Network: IOTX_TESTNET -PEBBLE_SEQUENCER__Blockchain_Network: IOTX_MAINNET -PEBBLE_SEQUENCER__Blockchain_PersistPath: /tmp/pebble -PEBBLE_SEQUENCER__Database_Endpoint: postgres://127.0.0.1:5432/pebble?sslmode=disable -PEBBLE_SEQUENCER__DryRun: "false" -PEBBLE_SEQUENCER__LarkAlert_Env: PROD -PEBBLE_SEQUENCER__LarkAlert_Project: pebble-sequencer -PEBBLE_SEQUENCER__LarkAlert_Secret: "" -PEBBLE_SEQUENCER__LarkAlert_URL: "" -PEBBLE_SEQUENCER__LarkAlert_Version: "" -PEBBLE_SEQUENCER__Logger_Level: DEBUG -PEBBLE_SEQUENCER__MqttBroker_Cert_CA: "" -PEBBLE_SEQUENCER__MqttBroker_Cert_Crt: "" -PEBBLE_SEQUENCER__MqttBroker_Cert_Key: "" -PEBBLE_SEQUENCER__MqttBroker_Keepalive: "60000000000" -PEBBLE_SEQUENCER__MqttBroker_QoS: ONCE -PEBBLE_SEQUENCER__MqttBroker_RetainPublish: "false" -PEBBLE_SEQUENCER__MqttBroker_Retry_Interval: "3000000000" -PEBBLE_SEQUENCER__MqttBroker_Retry_Repeats: "3" -PEBBLE_SEQUENCER__MqttBroker_Server: tcp://127.0.0.1:1883 -PEBBLE_SEQUENCER__MqttBroker_Timeout: "10000000000" -PEBBLE_SEQUENCER__MqttClientID: 71c46dcf-629f-42ab-9f67-0a6dc39d4f80 -PEBBLE_SEQUENCER__PrivateKey_Hex: dbfe03b0406549232b8dccc04be8224fcc0afa300a33d4f335dcfdfead861c85 -PEBBLE_SEQUENCER__ProjectID: "0" -PEBBLE_SEQUENCER__ProjectVersion: "" -PEBBLE_SEQUENCER__IoIDProjectID: "0" diff --git a/cmd/server/contract/ethclients.go b/cmd/server/contract/ethclients.go deleted file mode 100644 index b8265e4..0000000 --- a/cmd/server/contract/ethclients.go +++ /dev/null @@ -1,76 +0,0 @@ -package contract - -import ( - "sync" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/ethclient" - "github.com/pkg/errors" -) - -var ( - // gEthClients global ethereum rpc clients pool - gEthClients = map[string]Client{} - // gMtxEthClients for thread-safe access gEthClients - gMtxEthClients sync.Mutex -) - -func NewEthClient(endpoint string) (Client, error) { - gMtxEthClients.Lock() - defer gMtxEthClients.Unlock() - - c, ok := gEthClients[endpoint] - if ok { - c.acquire() - return c, nil - } - - cc, err := ethclient.Dial(endpoint) - if err != nil { - return nil, errors.Wrapf(err, "failed to dail endpoint: %s", endpoint) - } - c = &client{ - Client: cc, - endpoint: endpoint, - } - c.acquire() - gEthClients[endpoint] = c - - return c, nil -} - -func ReleaseClient(c Client) { - gMtxEthClients.Lock() - defer gMtxEthClients.Unlock() - - c, ok := gEthClients[c.Endpoint()] - if !ok { - return - } - - if c.release() <= 0 { - c.close() - delete(gEthClients, c.Endpoint()) - } -} - -type Client interface { - Endpoint() string - bind.ContractBackend - Counter - close() -} - -type client struct { - *ethclient.Client - endpoint string - counter -} - -func (c *client) Endpoint() string { - return c.endpoint -} - -func (c *client) close() { - c.Client.Close() -} diff --git a/cmd/server/contract/instances.go b/cmd/server/contract/instances.go deleted file mode 100644 index 62e12fe..0000000 --- a/cmd/server/contract/instances.go +++ /dev/null @@ -1,173 +0,0 @@ -package contract - -import ( - "bytes" - "context" - "encoding/hex" - "reflect" - "sync" - - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/pkg/errors" -) - -var ( - // gInstances global contract instances - gInstances = map[string]*instance{} - // gMtxInstances for thread-safe access gInstances - gMtxInstances sync.Mutex -) - -func NewInstance(name, address, endpoint string, abi abi.ABI) (Instance, error) { - key := hex.EncodeToString([]byte(address + endpoint)) - - gMtxInstances.Lock() - defer gMtxInstances.Unlock() - - if i, ok := gInstances[key]; ok { - i.acquire() - return i, nil - } - - backend, err := NewEthClient(endpoint) - if err != nil { - return nil, errors.Wrap(err, "failed to new contract instance") - } - - _address := common.HexToAddress(address) - i := &instance{ - abi: abi, - name: name, - key: key, - backend: backend, - address: _address, - contract: bind.NewBoundContract(_address, abi, backend, backend, backend), - } - - i.acquire() - gInstances[key] = i - return i, nil -} - -func NewInstanceByABI(name, address, endpoint string, content []byte) (Instance, error) { - _abi, err := abi.JSON(bytes.NewReader(content)) - if err != nil { - return nil, err - } - return NewInstance(name, address, endpoint, _abi) -} - -func ReleaseInstance(i Instance) { - gMtxInstances.Lock() - defer gMtxInstances.Unlock() - - c, ok := gInstances[i.Key()] - if !ok { - return - } - - if c.release() <= 0 { - ReleaseClient(i.Client()) - delete(gInstances, i.Key()) - } -} - -type Instance interface { - Name() string - Key() string - Address() common.Address - Client() Client - ABI() abi.ABI - Counter - - ReadContext(ctx context.Context, method string, args ...any) (any, error) - Read(method string, args ...any) (any, error) - ReadResultContext(ctx context.Context, method string, res any, args ...any) error - ReadResult(method string, res any, args ...any) error -} - -type instance struct { - abi abi.ABI - name string - key string - address common.Address - contract *bind.BoundContract - backend Client - counter -} - -func (i *instance) Name() string { - return i.name -} - -func (i *instance) Key() string { - return i.key -} - -func (i *instance) Address() common.Address { - return i.address -} - -func (i *instance) Client() Client { - return i.backend -} - -func (i *instance) ABI() abi.ABI { - return i.abi -} - -func (i *instance) Read(method string, args ...any) (any, error) { - return i.ReadContext(context.Background(), method, args...) -} - -func (i *instance) ReadContext(ctx context.Context, method string, args ...any) (any, error) { - out := make([]any, 0) - err := i.contract.Call(&bind.CallOpts{Context: ctx}, &out, method, args...) - if err != nil { - return nil, err - } - return out[0], nil -} - -func (i *instance) ReadResult(method string, res any, args ...any) (err error) { - return i.ReadResultContext(context.Background(), method, res, args...) -} - -func (i *instance) ReadResultContext(ctx context.Context, method string, res any, args ...any) (err error) { - rv, ok := res.(reflect.Value) - if !ok { - rv = reflect.ValueOf(res) - } - - if !rv.IsValid() { - return errors.Errorf("expect valid result, but got: (nil)") - } - - rt := rv.Type() - if rt.Kind() == reflect.Pointer { - if rv.IsNil() && rv.CanSet() { - rv.Set(reflect.New(rt.Elem())) - } - return i.ReadResultContext(ctx, method, rv.Elem(), args...) - } - if !rv.CanSet() { - return errors.Errorf("expect result can be set, but got: %s", rt) - } - - out, err := i.ReadContext(ctx, method, args...) - if err != nil { - return err - } - - defer func() { - if v := recover(); v != nil { - err = errors.Errorf("%v", recover()) - } - }() - - v := abi.ConvertType(out, reflect.New(rt).Interface()) - rv.Set(reflect.ValueOf(v).Elem()) - return err -} diff --git a/cmd/server/contract/util.go b/cmd/server/contract/util.go deleted file mode 100644 index 409dd14..0000000 --- a/cmd/server/contract/util.go +++ /dev/null @@ -1,25 +0,0 @@ -package contract - -import "sync/atomic" - -type Counter interface { - acquire() int32 - release() int32 - RefCount() int32 -} - -type counter struct { - v atomic.Int32 -} - -func (i *counter) acquire() int32 { - return i.v.Add(1) -} - -func (i *counter) release() int32 { - return i.v.Add(-1) -} - -func (i *counter) RefCount() int32 { - return i.v.Load() -} diff --git a/cmd/server/contracts.go b/cmd/server/contracts.go deleted file mode 100644 index 3b213b6..0000000 --- a/cmd/server/contracts.go +++ /dev/null @@ -1,118 +0,0 @@ -package main - -import ( - _ "embed" - - "github.com/ethereum/go-ethereum/common" - - "github.com/iotexproject/pebble-server/enums" - "github.com/iotexproject/pebble-server/middlewares/blockchain" -) - -// config reference: https://github.com/iotexproject/pebble-contracts/blob/main/README.md - -var ( - //go:embed abis/account_updated.json - abiAccountUpdated string - //go:embed abis/firmware_removed.json - abiFirmwareRemoved string - //go:embed abis/firmware_updated.json - abiFirmwareUpdated string - //go:embed abis/bank_deposit.json - abiBankDeposit string - //go:embed abis/bank_paid.json - abiBankPaid string - //go:embed abis/bank_withdraw.json - abiBankWithdraw string - //go:embed abis/pebble_config.json - abiPebbleConfig string - //go:embed abis/pebble_confirm.json - abiPebbleConfirm string - //go:embed abis/pebble_firmware.json - abiPebbleFirmware string - //go:embed abis/pebble_proposal.json - abiPebbleProposal string - //go:embed abis/pebble_remove.json - abiPebbleRemove string -) - -var contracts = []*blockchain.Contract{ - { - ID: enums.CONTRACT__PEBBLE_ACCOUNT, - Network: blockchain.NETWORK__IOTX_MAINNET, - Address: common.HexToAddress("0x189e2ED6EAfBCeAF938d049cf3685828b5493952"), - Events: []*blockchain.Event{ - {Name: "Updated", ABI: abiAccountUpdated}, - }, - }, - { - ID: enums.CONTRACT__PEBBLE_FIRMWARE, - Network: blockchain.NETWORK__IOTX_MAINNET, - Address: common.HexToAddress("0xA596800891e6a95Bf737404411ef529c1F377b4e"), - Events: []*blockchain.Event{ - // {Name: "FirmwareRemoved", ABI: abiFirmwareRemoved}, - {Name: "AddMetadata", ABI: abiFirmwareUpdated}, - }, - }, - { - ID: enums.CONTRACT__PEBBLE_BANK, - Network: blockchain.NETWORK__IOTX_MAINNET, - Address: common.HexToAddress("0xb86f97D494EEf8c6d618ee2049419eE0Ce843F28"), - Events: []*blockchain.Event{ - {Name: "Deposit", ABI: abiBankDeposit}, - {Name: "Paid", ABI: abiBankPaid}, - {Name: "Withdraw", ABI: abiBankWithdraw}, - }, - }, - { - ID: enums.CONTRACT__PEBBLE_DEVICE, - Network: blockchain.NETWORK__IOTX_MAINNET, - Address: common.HexToAddress("0xC9D7D9f25b98119DF5b2303ac0Df6b15C982BbF5"), - Events: []*blockchain.Event{ - {Name: "Config", ABI: abiPebbleConfig}, - {Name: "Confirm", ABI: abiPebbleConfirm}, - {Name: "Firmware", ABI: abiPebbleFirmware}, - {Name: "Proposal", ABI: abiPebbleProposal}, - {Name: "Remove", ABI: abiPebbleRemove}, - }, - }, - { - ID: enums.CONTRACT__PEBBLE_ACCOUNT, - Network: blockchain.NETWORK__IOTX_TESTNET, - Address: common.HexToAddress("0xBC458A041a50BF5abb900C78b7355d54E92FCFBa"), - Events: []*blockchain.Event{ - {Name: "Updated", ABI: abiAccountUpdated}, - }, - }, - { - ID: enums.CONTRACT__PEBBLE_FIRMWARE, - Network: blockchain.NETWORK__IOTX_TESTNET, - Address: common.HexToAddress("0xf07336E1c77319B4e740b666eb0C2B19D11fc14F"), - Events: []*blockchain.Event{ - // {Name: "FirmwareRemoved", ABI: abiFirmwareRemoved}, - {Name: "AddMetadata", ABI: abiFirmwareUpdated}, - }, - }, - { - ID: enums.CONTRACT__PEBBLE_BANK, - Network: blockchain.NETWORK__IOTX_TESTNET, - Address: common.HexToAddress("0xd313b3131e238C635f2fE4a84EaDaD71b3ed25fa"), - Events: []*blockchain.Event{ - {Name: "Deposit", ABI: abiBankDeposit}, - {Name: "Paid", ABI: abiBankPaid}, - {Name: "Withdraw", ABI: abiBankWithdraw}, - }, - }, - { - ID: enums.CONTRACT__PEBBLE_DEVICE, - Network: blockchain.NETWORK__IOTX_TESTNET, - Address: common.HexToAddress("0x1AA325E5144f763a520867c56FC77cC1411430d0"), - Events: []*blockchain.Event{ - {Name: "Config", ABI: abiPebbleConfig}, - {Name: "Confirm", ABI: abiPebbleConfirm}, - {Name: "Firmware", ABI: abiPebbleFirmware}, - {Name: "Proposal", ABI: abiPebbleProposal}, - {Name: "Remove", ABI: abiPebbleRemove}, - }, - }, -} diff --git a/cmd/server/lib/linux-x86_64/libioConnectCore.a b/cmd/server/lib/linux-x86_64/libioConnectCore.a deleted file mode 100644 index d968748..0000000 Binary files a/cmd/server/lib/linux-x86_64/libioConnectCore.a and /dev/null differ diff --git a/cmd/server/lib/linux-x86_64/md5 b/cmd/server/lib/linux-x86_64/md5 deleted file mode 100644 index 73f4959..0000000 --- a/cmd/server/lib/linux-x86_64/md5 +++ /dev/null @@ -1,2 +0,0 @@ -e8eb2131e215259c15e1635787c92e5e - diff --git a/cmd/server/main.go b/cmd/server/main.go index 86399fd..dc094cb 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -1,191 +1,19 @@ package main import ( - "context" "log" "log/slog" "os" "os/signal" "syscall" - "github.com/google/uuid" "github.com/pkg/errors" - "github.com/xoctopus/confx/confapp" - "github.com/xoctopus/confx/confmws/confmqtt" - "github.com/xoctopus/x/contextx" - "github.com/xoctopus/x/misc/must" - "github.com/iotexproject/pebble-server/cmd/server/api" - "github.com/iotexproject/pebble-server/cmd/server/clients" - "github.com/iotexproject/pebble-server/cmd/server/commands" + "github.com/iotexproject/pebble-server/api" "github.com/iotexproject/pebble-server/cmd/server/config" - "github.com/iotexproject/pebble-server/contexts" "github.com/iotexproject/pebble-server/db" - "github.com/iotexproject/pebble-server/middlewares/alert" - "github.com/iotexproject/pebble-server/middlewares/blockchain" - "github.com/iotexproject/pebble-server/middlewares/crypto" - "github.com/iotexproject/pebble-server/middlewares/database" - "github.com/iotexproject/pebble-server/middlewares/logger" - "github.com/iotexproject/pebble-server/models" - "github.com/iotexproject/pebble-server/modules/event" - "github.com/machinefi/ioconnect-go/pkg/ioconnect" ) -var ( - Name = "pebble-sequencer" - Feature string - Version string - CommitID string - Date string - - app *confapp.AppCtx - config1 = &struct { - DryRun bool - MqttBroker *confmqtt.Broker - Database *database.Postgres - Blockchain *blockchain.Blockchain - Logger *logger.Logger - PrivateKey *crypto.EcdsaPrivateKey - ProjectID uint64 - ProjectVersion string - WhiteList contexts.WhiteList - LarkAlert *alert.LarkAlert - MqttClientID string - JwkSecret string - IoIDRegistryEndpoint string - IoIDRegistryContractAddress string - ProjectClientContractAddress string - W3bstreamProjectContractAddress string - IoIDContractAddress string - ChainEndpoint string - IoIDProjectID uint64 - }{ - DryRun: false, - Logger: &logger.Logger{Level: slog.LevelDebug}, - Blockchain: &blockchain.Blockchain{Contracts: contracts}, - MqttBroker: &confmqtt.Broker{}, - Database: &database.Postgres{}, - // from sprout default sequencer, to make coordinator validate sequencer signature - PrivateKey: &crypto.EcdsaPrivateKey{ - Hex: "dbfe03b0406549232b8dccc04be8224fcc0afa300a33d4f335dcfdfead861c85", - }, - LarkAlert: &alert.LarkAlert{ - Env: "PROD", - Project: Name, - Version: Version, - }, - MqttClientID: uuid.NewString(), - JwkSecret: "R3QNJihYLjtcaxALSTsKe1cYSX0pS28wZitFVXE4Y2klf2hxVCczYHw2dVg4fXJdSgdCcnM4PgV1aTo9DwYqEw==", - IoIDRegistryEndpoint: "did.iotex.me", - IoIDRegistryContractAddress: "0x0A7e595C7889dF3652A19aF52C18377bF17e027D", - ProjectClientContractAddress: "0xF4d6282C5dDD474663eF9e70c927c0d4926d1CEb", - W3bstreamProjectContractAddress: "0x6AfCB0EB71B7246A68Bb9c0bFbe5cD7c11c4839f", - IoIDContractAddress: "0x45Ce3E6f526e597628c73B731a3e9Af7Fc32f5b7", - ChainEndpoint: "https://babel-api.testnet.iotex.io", - // WhiteList: contexts.WhiteList{"103381234567407"}, - } - ctx context.Context -) - -func init() { - meta := confapp.Meta{ - Name: Name, - Feature: Feature, - Version: Version, - CommitID: CommitID, - Date: Date, - } - app = confapp.NewAppContext( - confapp.WithBuildMeta(meta), - confapp.WithMainRoot("."), - confapp.WithMainExecutor(Main), - ) - - app.Conf(config) - must.BeTrueWrap( - config.ProjectVersion != "" && config.ProjectID != 0 && config.IoIDProjectID != 0, - "project id, version and ioID project id is required", - ) - - ctx = contextx.WithContextCompose( - contexts.Logger().Compose(config.Logger), - contexts.Blockchain().Compose(config.Blockchain), - contexts.Database().Compose(config.Database), - contexts.MqttBroker().Compose(config.MqttBroker), - contexts.ProjectID().Compose(config.ProjectID), - contexts.ProjectVersion().Compose(config.ProjectVersion), - contexts.PrivateKey().Compose(config.PrivateKey), - contexts.IMEIFilter().Compose(config.WhiteList), - contexts.LarkAlert().Compose(config.LarkAlert), - contexts.AppMeta().Compose(&meta), - contexts.DryRun().Compose(config.DryRun), - contexts.MqttClientID().Compose(config.MqttClientID), - contexts.IoIDProjectID().Compose(config.IoIDProjectID), - )(context.Background()) - - app.AddCommand(commands.Migrate(ctx)) - app.AddCommand(commands.GenerateSproutConfig(ctx)) -} - -func runHTTP(ctx context.Context) { - secrets := ioconnect.JWKSecrets{} - if err := secrets.UnmarshalText([]byte(config.JwkSecret)); err != nil { - panic(errors.Wrap(err, "invalid jwk secrets from flag")) - } - jwk, err := ioconnect.NewJWKBySecret(secrets) - if err != nil { - panic(errors.Wrap(err, "failed to new jwk from secrets")) - } - clientMgr, err := clients.NewManager(config.ProjectClientContractAddress, config.IoIDRegistryContractAddress, config.W3bstreamProjectContractAddress, config.IoIDContractAddress, config.IoIDRegistryEndpoint, config.ChainEndpoint) - if err != nil { - panic(errors.Wrap(err, "failed to new clients manager")) - } - go func() { - if err := api.Run(ctx, jwk, clientMgr, ":9000"); err != nil { - panic(err) - } - }() -} - -// Main app main entry -func Main() error { - _ = config.LarkAlert.Push("service started", "") - - db := contexts.Database().MustFrom(ctx) - if err := db.AutoMigrate( - &models.Account{}, - &models.App{}, - &models.AppV2{}, - &models.Bank{}, - &models.BankRecord{}, - &models.Device{}, - &models.DeviceRecord{}, - &models.Task{}, - &models.Message{}, - ); err != nil { - slog.Error("failed to migrate database", "error", err) - return err - } - - blockchain.SetLogger(config.Logger) - if err := config.Blockchain.RunMonitor(); err != nil { - config.Logger.Error(err, "failed to start tx monitor") - return err - } - event.InitRunner(ctx)() - defer config.Blockchain.Close() - - go RunDebugServer(ctx) - runHTTP(ctx) - - sig := make(chan os.Signal, 1) - signal.Notify(sig, os.Interrupt) - <-sig - - config.LarkAlert.Push("service stopped", "") - return nil -} - func main() { cfg, err := config.Get() if err != nil { @@ -199,6 +27,12 @@ func main() { log.Fatal(errors.Wrap(err, "failed to new db")) } + go func() { + if err := api.Run(db, cfg.ServiceEndpoint); err != nil { + log.Fatal(err) + } + }() + done := make(chan os.Signal, 1) signal.Notify(done, syscall.SIGINT, syscall.SIGTERM) <-done diff --git a/go.mod b/go.mod index 4bdf00c..7348229 100644 --- a/go.mod +++ b/go.mod @@ -3,76 +3,31 @@ module github.com/iotexproject/pebble-server go 1.22.0 require ( - github.com/ClickHouse/clickhouse-go/v2 v2.26.0 - github.com/cockroachdb/pebble v1.1.1 - github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 - github.com/eclipse/paho.mqtt.golang v1.4.3 github.com/ethereum/go-ethereum v1.14.6 + github.com/fatih/color v1.17.0 github.com/gin-gonic/gin v1.10.0 - github.com/go-logr/logr v1.4.2 - github.com/google/uuid v1.6.0 - github.com/machinefi/ioconnect-go v0.0.9 github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.19.1 - github.com/shopspring/decimal v1.4.0 - github.com/spf13/cobra v1.8.1 - github.com/stretchr/testify v1.9.0 - github.com/xhd2015/xgo/runtime v1.0.45 - github.com/xoctopus/confx v0.1.6 - github.com/xoctopus/datatypex v0.0.7 - github.com/xoctopus/x v0.0.23 - golang.org/x/crypto v0.25.0 - google.golang.org/protobuf v1.34.2 - gorm.io/datatypes v1.2.1 + github.com/spf13/viper v1.19.0 gorm.io/driver/postgres v1.5.9 gorm.io/gorm v1.25.10 ) require ( - filippo.io/edwards25519 v1.1.0 // indirect - github.com/ClickHouse/ch-go v0.61.5 // indirect - github.com/DataDog/zstd v1.4.5 // indirect - github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/andybalholm/brotli v1.1.0 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect github.com/bytedance/sonic v1.11.6 // indirect github.com/bytedance/sonic/loader v0.1.1 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/iasm v0.2.0 // indirect - github.com/cockroachdb/errors v1.11.3 // indirect - github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect - github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect - github.com/cockroachdb/redact v1.1.5 // indirect - github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect - github.com/consensys/bavard v0.1.13 // indirect - github.com/consensys/gnark-crypto v0.12.1 // indirect - github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/deckarep/golang-set/v2 v2.6.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect - github.com/ethereum/c-kzg-4844 v1.0.0 // indirect - github.com/fatih/color v1.17.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect - github.com/getsentry/sentry-go v0.27.0 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/go-faster/city v1.0.1 // indirect - github.com/go-faster/errors v0.7.1 // indirect - github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.20.0 // indirect - github.com/go-sql-driver/mysql v1.8.1 // indirect github.com/goccy/go-json v0.10.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect - github.com/gorilla/websocket v1.5.3 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/holiman/uint256 v1.2.4 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect github.com/jackc/pgx/v5 v5.5.5 // indirect @@ -80,53 +35,34 @@ require ( github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.17.7 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/kr/text v0.2.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/paulmach/orb v0.11.1 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect - github.com/pierrec/lz4/v4 v4.1.21 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_model v0.5.0 // indirect - github.com/prometheus/common v0.48.0 // indirect - github.com/prometheus/procfs v0.12.0 // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/segmentio/asm v1.2.0 // indirect - github.com/shirou/gopsutil v3.21.11+incompatible // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/spf13/viper v1.19.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect - github.com/supranational/blst v0.3.11 // indirect - github.com/tklauser/go-sysconf v0.3.12 // indirect - github.com/tklauser/numcpus v0.6.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect - github.com/yusufpapurcu/wmi v1.2.3 // indirect - go.opentelemetry.io/otel v1.26.0 // indirect - go.opentelemetry.io/otel/trace v1.26.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/arch v0.8.0 // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20240716175740-e3f259677ff7 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - gorm.io/driver/mysql v1.5.6 // indirect - rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/go.sum b/go.sum index f768b5b..569c6f6 100644 --- a/go.sum +++ b/go.sum @@ -1,21 +1,3 @@ -filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= -filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= -github.com/ClickHouse/ch-go v0.61.5 h1:zwR8QbYI0tsMiEcze/uIMK+Tz1D3XZXLdNrlaOpeEI4= -github.com/ClickHouse/ch-go v0.61.5/go.mod h1:s1LJW/F/LcFs5HJnuogFMta50kKDO0lf9zzfrbl0RQg= -github.com/ClickHouse/clickhouse-go/v2 v2.26.0 h1:j4/y6NYaCcFkJwN/TU700ebW+nmsIy34RmUAAcZKy9w= -github.com/ClickHouse/clickhouse-go/v2 v2.26.0/go.mod h1:iDTViXk2Fgvf1jn2dbJd1ys+fBkdD1UMRnXlwmhijhQ= -github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= -github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= -github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= -github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= -github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= -github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= -github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= @@ -24,89 +6,32 @@ github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= -github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= -github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= -github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= -github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= -github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= -github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= -github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= -github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= -github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw= -github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= -github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= -github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= -github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= -github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= -github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= -github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= -github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= -github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= -github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= -github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= -github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= -github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= -github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= -github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564 h1:I6KUy4CI6hHjqnyJLNCEi7YHVMkwwtfSr2k9splgdSM= -github.com/dustinxie/ecc v0.0.0-20210511000915-959544187564/go.mod h1:yekO+3ZShy19S+bsmnERmznGy9Rfg6dWWWpiGJjNAz8= -github.com/eclipse/paho.mqtt.golang v1.4.3 h1:2kwcUGn8seMUfWndX0hGbvH8r7crgcJguQNCyp70xik= -github.com/eclipse/paho.mqtt.golang v1.4.3/go.mod h1:CSYvoAlsMkhYOXh/oKyxa8EcBci6dVkLCbo5tTC1RIE= -github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= -github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/ethereum/go-ethereum v1.14.6 h1:ZTxnErSopkDyxdvB8zW/KcK+/AVrdil/TzoWXVKaaC8= github.com/ethereum/go-ethereum v1.14.6/go.mod h1:hglUZo/5pVIYXNyYjWzsAUDpT/zI+WbWo/Nih7ot+G0= -github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 h1:KrE8I4reeVvf7C1tm8elRjj4BdscTYzz/WAbYyf/JI4= -github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0/go.mod h1:D9AJLVXSyZQXJQVk8oh1EwjISE+sJTn2duYIZC0dy3w= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= -github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA= -github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= -github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= -github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= -github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= -github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= -github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= -github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= -github.com/go-faster/city v1.0.1 h1:4WAxSZ3V2Ws4QRDrscLEDcibJY8uf41H6AhXDrNDcGw= -github.com/go-faster/city v1.0.1/go.mod h1:jKcUJId49qdW3L1qKHH/3wPeUstCVpVSXTM6vO3VcTw= -github.com/go-faster/errors v0.7.1 h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg= -github.com/go-faster/errors v0.7.1/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= -github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= -github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= @@ -115,51 +40,15 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= -github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= -github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= -github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= -github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= -github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= -github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= -github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= -github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= -github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= -github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= -github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= -github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= -github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= -github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= -github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= -github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= -github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 h1:L0QtFUgDarD7Fpv9jeVMgy/+Ec0mtnmYuImjTz6dtDA= @@ -168,40 +57,22 @@ github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw= github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= -github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= -github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= -github.com/jedib0t/go-pretty/v6 v6.5.9 h1:ACteMBRrrmm1gMsXe9PSTOClQ63IXDUt03H5U+UV8OU= -github.com/jedib0t/go-pretty/v6 v6.5.9/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= -github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= -github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= -github.com/machinefi/ioconnect-go v0.0.9 h1:WPHfyk1ikWceztI3LeVz4P7lMvLuQFrCuIp0/RA42RE= -github.com/machinefi/ioconnect-go v0.0.9/go.mod h1:J7nsaHy5aB3gyiYrxO5vzulAJQFryivrN0nvD5aVGUw= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -209,94 +80,41 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= -github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/microsoft/go-mssqldb v0.17.0 h1:Fto83dMZPnYv1Zwx5vHHxpNraeEaUlQ/hhHLgZiaenE= -github.com/microsoft/go-mssqldb v0.17.0/go.mod h1:OkoNGhGEs8EZqchVTtochlXruEhEOaO4S0d2sB5aeGQ= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= -github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= -github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= -github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= -github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= -github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= -github.com/paulmach/orb v0.11.1 h1:3koVegMC4X/WeiXYz9iswopaTwMem53NzTJuTF20JzU= -github.com/paulmach/orb v0.11.1/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU= -github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= -github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= -github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= -github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= -github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= -github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= -github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= -github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE= -github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= -github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= -github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= -github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= -github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= -github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= -github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= -github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= -github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= -github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= -github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= -github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= -github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= -github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= -github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -306,138 +124,43 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= -github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= -github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= -github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= -github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= -github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= -github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= -github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= -github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= -github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= -github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= -github.com/xhd2015/xgo/runtime v1.0.45 h1:ljowSgYNfN8TZclGqLlRIkLOXPPVHlawMXJAoeq8gS0= -github.com/xhd2015/xgo/runtime v1.0.45/go.mod h1:9GBQ2SzJCzpD3T+HRN+2C0TUOGv7qIz4s0mad1xJ8Jo= -github.com/xoctopus/confx v0.1.6 h1:jkpxlXIdQZ3aVnr/3LcdzXJ6vv3lDPKHSpQvqxiDqrE= -github.com/xoctopus/confx v0.1.6/go.mod h1:beNljogQ7I3TE5B6F9FPBb0aGs/uzodVCI4oKKlqpuI= -github.com/xoctopus/datatypex v0.0.7 h1:Y8rBAoxipQYj5f7pYR5zrNoMr7XtN0FnLkylxkiTvtA= -github.com/xoctopus/datatypex v0.0.7/go.mod h1:dQYLcyFDdkdjKTIlDlAEF/Rt45Slcq0B5GbbU38vvpU= -github.com/xoctopus/x v0.0.23 h1:bSE3V7uMbFF0qjgY7WBJXrqUHm8oZu3l7nrjdd7YclE= -github.com/xoctopus/x v0.0.23/go.mod h1:rjQLQYwpL43FUQuQ5nC6Wt93Q6nAx/j9lctxiE9O0+A= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= -github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFiw= -github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= -go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= -go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs= -go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4= -go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA= -go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20240716175740-e3f259677ff7 h1:wDLEX9a7YQoKdKNQt88rtydkqDxeGaBUTnIYc3iG/mA= golang.org/x/exp v0.0.0-20240716175740-e3f259677ff7/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= -golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= -gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/datatypes v1.2.1 h1:r+g0bk4LPCW2v4+Ls7aeNgGme7JYdNDQ2VtvlNUfBh0= -gorm.io/datatypes v1.2.1/go.mod h1:hYK6OTb/1x+m96PgoZZq10UXJ6RvEBb9kRDQ2yyhzGs= -gorm.io/driver/mysql v1.5.6 h1:Ld4mkIickM+EliaQZQx3uOJDJHtrd70MxAUqWqlx3Y8= -gorm.io/driver/mysql v1.5.6/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM= gorm.io/driver/postgres v1.5.9 h1:DkegyItji119OlcaLjqN11kHoUgZ/j13E0jkJZgD6A8= gorm.io/driver/postgres v1.5.9/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI= -gorm.io/driver/sqlite v1.4.3 h1:HBBcZSDnWi5BW3B3rwvVTc510KGkBkexlOg0QrmLUuU= -gorm.io/driver/sqlite v1.4.3/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI= -gorm.io/driver/sqlserver v1.4.1 h1:t4r4r6Jam5E6ejqP7N82qAJIJAht27EGT41HyPfXRw0= -gorm.io/driver/sqlserver v1.4.1/go.mod h1:DJ4P+MeZbc5rvY58PnmN1Lnyvb5gw5NPzGshHDnJLig= -gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= gorm.io/gorm v1.25.10 h1:dQpO+33KalOA+aFYGlK+EfxcI5MbO7EP2yYygwh9h+s= gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= -rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= -rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= diff --git a/pebblepb/gen.go b/pebblepb/gen.go deleted file mode 100644 index 06fcc1d..0000000 --- a/pebblepb/gen.go +++ /dev/null @@ -1,3 +0,0 @@ -package pebblepb - -//go:generate protoc --go_out=. pebble.proto diff --git a/pebblepb/pebble.pb.go b/pebblepb/pebble.pb.go deleted file mode 100644 index a41c435..0000000 --- a/pebblepb/pebble.pb.go +++ /dev/null @@ -1,771 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v5.26.1 -// source: pebble.proto - -package pebblepb - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type BinPackage_PackageType int32 - -const ( - BinPackage_DATA BinPackage_PackageType = 0 - BinPackage_CONFIG BinPackage_PackageType = 1 - BinPackage_STATE BinPackage_PackageType = 2 -) - -// Enum value maps for BinPackage_PackageType. -var ( - BinPackage_PackageType_name = map[int32]string{ - 0: "DATA", - 1: "CONFIG", - 2: "STATE", - } - BinPackage_PackageType_value = map[string]int32{ - "DATA": 0, - "CONFIG": 1, - "STATE": 2, - } -) - -func (x BinPackage_PackageType) Enum() *BinPackage_PackageType { - p := new(BinPackage_PackageType) - *p = x - return p -} - -func (x BinPackage_PackageType) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (BinPackage_PackageType) Descriptor() protoreflect.EnumDescriptor { - return file_pebble_proto_enumTypes[0].Descriptor() -} - -func (BinPackage_PackageType) Type() protoreflect.EnumType { - return &file_pebble_proto_enumTypes[0] -} - -func (x BinPackage_PackageType) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Do not use. -func (x *BinPackage_PackageType) UnmarshalJSON(b []byte) error { - num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) - if err != nil { - return err - } - *x = BinPackage_PackageType(num) - return nil -} - -// Deprecated: Use BinPackage_PackageType.Descriptor instead. -func (BinPackage_PackageType) EnumDescriptor() ([]byte, []int) { - return file_pebble_proto_rawDescGZIP(), []int{4, 0} -} - -type SensorData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Snr *uint32 `protobuf:"varint,1,opt,name=snr" json:"snr,omitempty"` - Vbat *uint32 `protobuf:"varint,2,opt,name=vbat" json:"vbat,omitempty"` - Latitude *int32 `protobuf:"zigzag32,3,opt,name=latitude" json:"latitude,omitempty"` - Longitude *int32 `protobuf:"zigzag32,4,opt,name=longitude" json:"longitude,omitempty"` - GasResistance *uint32 `protobuf:"varint,5,opt,name=gasResistance" json:"gasResistance,omitempty"` - Temperature *int32 `protobuf:"zigzag32,6,opt,name=temperature" json:"temperature,omitempty"` - Pressure *uint32 `protobuf:"varint,7,opt,name=pressure" json:"pressure,omitempty"` - Humidity *uint32 `protobuf:"varint,8,opt,name=humidity" json:"humidity,omitempty"` - Light *uint32 `protobuf:"varint,9,opt,name=light" json:"light,omitempty"` - Temperature2 *uint32 `protobuf:"varint,10,opt,name=temperature2" json:"temperature2,omitempty"` - Gyroscope []int32 `protobuf:"zigzag32,11,rep,name=gyroscope" json:"gyroscope,omitempty"` - Accelerometer []int32 `protobuf:"zigzag32,12,rep,name=accelerometer" json:"accelerometer,omitempty"` - Random *string `protobuf:"bytes,13,opt,name=random" json:"random,omitempty"` -} - -func (x *SensorData) Reset() { - *x = SensorData{} - if protoimpl.UnsafeEnabled { - mi := &file_pebble_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SensorData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SensorData) ProtoMessage() {} - -func (x *SensorData) ProtoReflect() protoreflect.Message { - mi := &file_pebble_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SensorData.ProtoReflect.Descriptor instead. -func (*SensorData) Descriptor() ([]byte, []int) { - return file_pebble_proto_rawDescGZIP(), []int{0} -} - -func (x *SensorData) GetSnr() uint32 { - if x != nil && x.Snr != nil { - return *x.Snr - } - return 0 -} - -func (x *SensorData) GetVbat() uint32 { - if x != nil && x.Vbat != nil { - return *x.Vbat - } - return 0 -} - -func (x *SensorData) GetLatitude() int32 { - if x != nil && x.Latitude != nil { - return *x.Latitude - } - return 0 -} - -func (x *SensorData) GetLongitude() int32 { - if x != nil && x.Longitude != nil { - return *x.Longitude - } - return 0 -} - -func (x *SensorData) GetGasResistance() uint32 { - if x != nil && x.GasResistance != nil { - return *x.GasResistance - } - return 0 -} - -func (x *SensorData) GetTemperature() int32 { - if x != nil && x.Temperature != nil { - return *x.Temperature - } - return 0 -} - -func (x *SensorData) GetPressure() uint32 { - if x != nil && x.Pressure != nil { - return *x.Pressure - } - return 0 -} - -func (x *SensorData) GetHumidity() uint32 { - if x != nil && x.Humidity != nil { - return *x.Humidity - } - return 0 -} - -func (x *SensorData) GetLight() uint32 { - if x != nil && x.Light != nil { - return *x.Light - } - return 0 -} - -func (x *SensorData) GetTemperature2() uint32 { - if x != nil && x.Temperature2 != nil { - return *x.Temperature2 - } - return 0 -} - -func (x *SensorData) GetGyroscope() []int32 { - if x != nil { - return x.Gyroscope - } - return nil -} - -func (x *SensorData) GetAccelerometer() []int32 { - if x != nil { - return x.Accelerometer - } - return nil -} - -func (x *SensorData) GetRandom() string { - if x != nil && x.Random != nil { - return *x.Random - } - return "" -} - -type SensorConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - BulkUpload *uint32 `protobuf:"varint,1,opt,name=bulkUpload" json:"bulkUpload,omitempty"` - DataChannel *uint32 `protobuf:"varint,2,opt,name=dataChannel" json:"dataChannel,omitempty"` - UploadPeriod *uint32 `protobuf:"varint,3,opt,name=uploadPeriod" json:"uploadPeriod,omitempty"` - BulkUploadSamplingCnt *uint32 `protobuf:"varint,4,opt,name=bulkUploadSamplingCnt" json:"bulkUploadSamplingCnt,omitempty"` - BulkUploadSamplingFreq *uint32 `protobuf:"varint,5,opt,name=bulkUploadSamplingFreq" json:"bulkUploadSamplingFreq,omitempty"` - Beep *uint32 `protobuf:"varint,6,opt,name=beep" json:"beep,omitempty"` - Firmware *string `protobuf:"bytes,7,opt,name=firmware" json:"firmware,omitempty"` - DeviceConfigurable *bool `protobuf:"varint,8,opt,name=deviceConfigurable" json:"deviceConfigurable,omitempty"` -} - -func (x *SensorConfig) Reset() { - *x = SensorConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_pebble_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SensorConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SensorConfig) ProtoMessage() {} - -func (x *SensorConfig) ProtoReflect() protoreflect.Message { - mi := &file_pebble_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SensorConfig.ProtoReflect.Descriptor instead. -func (*SensorConfig) Descriptor() ([]byte, []int) { - return file_pebble_proto_rawDescGZIP(), []int{1} -} - -func (x *SensorConfig) GetBulkUpload() uint32 { - if x != nil && x.BulkUpload != nil { - return *x.BulkUpload - } - return 0 -} - -func (x *SensorConfig) GetDataChannel() uint32 { - if x != nil && x.DataChannel != nil { - return *x.DataChannel - } - return 0 -} - -func (x *SensorConfig) GetUploadPeriod() uint32 { - if x != nil && x.UploadPeriod != nil { - return *x.UploadPeriod - } - return 0 -} - -func (x *SensorConfig) GetBulkUploadSamplingCnt() uint32 { - if x != nil && x.BulkUploadSamplingCnt != nil { - return *x.BulkUploadSamplingCnt - } - return 0 -} - -func (x *SensorConfig) GetBulkUploadSamplingFreq() uint32 { - if x != nil && x.BulkUploadSamplingFreq != nil { - return *x.BulkUploadSamplingFreq - } - return 0 -} - -func (x *SensorConfig) GetBeep() uint32 { - if x != nil && x.Beep != nil { - return *x.Beep - } - return 0 -} - -func (x *SensorConfig) GetFirmware() string { - if x != nil && x.Firmware != nil { - return *x.Firmware - } - return "" -} - -func (x *SensorConfig) GetDeviceConfigurable() bool { - if x != nil && x.DeviceConfigurable != nil { - return *x.DeviceConfigurable - } - return false -} - -type SensorState struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - State *uint32 `protobuf:"varint,1,opt,name=state" json:"state,omitempty"` -} - -func (x *SensorState) Reset() { - *x = SensorState{} - if protoimpl.UnsafeEnabled { - mi := &file_pebble_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SensorState) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SensorState) ProtoMessage() {} - -func (x *SensorState) ProtoReflect() protoreflect.Message { - mi := &file_pebble_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SensorState.ProtoReflect.Descriptor instead. -func (*SensorState) Descriptor() ([]byte, []int) { - return file_pebble_proto_rawDescGZIP(), []int{2} -} - -func (x *SensorState) GetState() uint32 { - if x != nil && x.State != nil { - return *x.State - } - return 0 -} - -type SensorConfirm struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Owner *string `protobuf:"bytes,1,opt,name=owner" json:"owner,omitempty"` -} - -func (x *SensorConfirm) Reset() { - *x = SensorConfirm{} - if protoimpl.UnsafeEnabled { - mi := &file_pebble_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SensorConfirm) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SensorConfirm) ProtoMessage() {} - -func (x *SensorConfirm) ProtoReflect() protoreflect.Message { - mi := &file_pebble_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SensorConfirm.ProtoReflect.Descriptor instead. -func (*SensorConfirm) Descriptor() ([]byte, []int) { - return file_pebble_proto_rawDescGZIP(), []int{3} -} - -func (x *SensorConfirm) GetOwner() string { - if x != nil && x.Owner != nil { - return *x.Owner - } - return "" -} - -type BinPackage struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Type *BinPackage_PackageType `protobuf:"varint,1,req,name=type,enum=pebblepb.BinPackage_PackageType" json:"type,omitempty"` - Data []byte `protobuf:"bytes,2,req,name=data" json:"data,omitempty"` - Timestamp *uint32 `protobuf:"varint,3,req,name=timestamp" json:"timestamp,omitempty"` - Signature []byte `protobuf:"bytes,4,req,name=signature" json:"signature,omitempty"` -} - -func (x *BinPackage) Reset() { - *x = BinPackage{} - if protoimpl.UnsafeEnabled { - mi := &file_pebble_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *BinPackage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BinPackage) ProtoMessage() {} - -func (x *BinPackage) ProtoReflect() protoreflect.Message { - mi := &file_pebble_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use BinPackage.ProtoReflect.Descriptor instead. -func (*BinPackage) Descriptor() ([]byte, []int) { - return file_pebble_proto_rawDescGZIP(), []int{4} -} - -func (x *BinPackage) GetType() BinPackage_PackageType { - if x != nil && x.Type != nil { - return *x.Type - } - return BinPackage_DATA -} - -func (x *BinPackage) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -func (x *BinPackage) GetTimestamp() uint32 { - if x != nil && x.Timestamp != nil { - return *x.Timestamp - } - return 0 -} - -func (x *BinPackage) GetSignature() []byte { - if x != nil { - return x.Signature - } - return nil -} - -type ConfirmPackage struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Owner []byte `protobuf:"bytes,1,req,name=owner" json:"owner,omitempty"` - Timestamp *uint32 `protobuf:"varint,2,req,name=timestamp" json:"timestamp,omitempty"` - Signature []byte `protobuf:"bytes,3,req,name=signature" json:"signature,omitempty"` - Channel *uint32 `protobuf:"varint,4,req,name=channel" json:"channel,omitempty"` -} - -func (x *ConfirmPackage) Reset() { - *x = ConfirmPackage{} - if protoimpl.UnsafeEnabled { - mi := &file_pebble_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ConfirmPackage) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ConfirmPackage) ProtoMessage() {} - -func (x *ConfirmPackage) ProtoReflect() protoreflect.Message { - mi := &file_pebble_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ConfirmPackage.ProtoReflect.Descriptor instead. -func (*ConfirmPackage) Descriptor() ([]byte, []int) { - return file_pebble_proto_rawDescGZIP(), []int{5} -} - -func (x *ConfirmPackage) GetOwner() []byte { - if x != nil { - return x.Owner - } - return nil -} - -func (x *ConfirmPackage) GetTimestamp() uint32 { - if x != nil && x.Timestamp != nil { - return *x.Timestamp - } - return 0 -} - -func (x *ConfirmPackage) GetSignature() []byte { - if x != nil { - return x.Signature - } - return nil -} - -func (x *ConfirmPackage) GetChannel() uint32 { - if x != nil && x.Channel != nil { - return *x.Channel - } - return 0 -} - -var File_pebble_proto protoreflect.FileDescriptor - -var file_pebble_proto_rawDesc = []byte{ - 0x0a, 0x0c, 0x70, 0x65, 0x62, 0x62, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, - 0x70, 0x65, 0x62, 0x62, 0x6c, 0x65, 0x70, 0x62, 0x22, 0x82, 0x03, 0x0a, 0x0a, 0x53, 0x65, 0x6e, - 0x73, 0x6f, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x6e, 0x72, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x73, 0x6e, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x76, 0x62, 0x61, - 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x76, 0x62, 0x61, 0x74, 0x12, 0x1a, 0x0a, - 0x08, 0x6c, 0x61, 0x74, 0x69, 0x74, 0x75, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x11, 0x52, - 0x08, 0x6c, 0x61, 0x74, 0x69, 0x74, 0x75, 0x64, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f, 0x6e, - 0x67, 0x69, 0x74, 0x75, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x11, 0x52, 0x09, 0x6c, 0x6f, - 0x6e, 0x67, 0x69, 0x74, 0x75, 0x64, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x67, 0x61, 0x73, 0x52, 0x65, - 0x73, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, - 0x67, 0x61, 0x73, 0x52, 0x65, 0x73, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x20, 0x0a, - 0x0b, 0x74, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x11, 0x52, 0x0b, 0x74, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, - 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x65, 0x73, 0x73, 0x75, 0x72, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x08, 0x70, 0x72, 0x65, 0x73, 0x73, 0x75, 0x72, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x68, - 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x68, - 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x67, 0x68, 0x74, - 0x18, 0x09, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x12, 0x22, 0x0a, - 0x0c, 0x74, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65, 0x32, 0x18, 0x0a, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x74, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x32, 0x12, 0x1c, 0x0a, 0x09, 0x67, 0x79, 0x72, 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x0b, - 0x20, 0x03, 0x28, 0x11, 0x52, 0x09, 0x67, 0x79, 0x72, 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, - 0x24, 0x0a, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x6c, 0x65, 0x72, 0x6f, 0x6d, 0x65, 0x74, 0x65, 0x72, - 0x18, 0x0c, 0x20, 0x03, 0x28, 0x11, 0x52, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x6c, 0x65, 0x72, 0x6f, - 0x6d, 0x65, 0x74, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x18, - 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x22, 0xc2, 0x02, - 0x0a, 0x0c, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1e, - 0x0a, 0x0a, 0x62, 0x75, 0x6c, 0x6b, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x0a, 0x62, 0x75, 0x6c, 0x6b, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x20, - 0x0a, 0x0b, 0x64, 0x61, 0x74, 0x61, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x64, 0x61, 0x74, 0x61, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, - 0x12, 0x22, 0x0a, 0x0c, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x50, 0x65, - 0x72, 0x69, 0x6f, 0x64, 0x12, 0x34, 0x0a, 0x15, 0x62, 0x75, 0x6c, 0x6b, 0x55, 0x70, 0x6c, 0x6f, - 0x61, 0x64, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x69, 0x6e, 0x67, 0x43, 0x6e, 0x74, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x15, 0x62, 0x75, 0x6c, 0x6b, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, - 0x61, 0x6d, 0x70, 0x6c, 0x69, 0x6e, 0x67, 0x43, 0x6e, 0x74, 0x12, 0x36, 0x0a, 0x16, 0x62, 0x75, - 0x6c, 0x6b, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x69, 0x6e, 0x67, - 0x46, 0x72, 0x65, 0x71, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x16, 0x62, 0x75, 0x6c, 0x6b, - 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x69, 0x6e, 0x67, 0x46, 0x72, - 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x65, 0x65, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x04, 0x62, 0x65, 0x65, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x72, 0x6d, 0x77, 0x61, - 0x72, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x72, 0x6d, 0x77, 0x61, - 0x72, 0x65, 0x12, 0x2e, 0x0a, 0x12, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, - 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x62, - 0x6c, 0x65, 0x22, 0x23, 0x0a, 0x0b, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0x25, 0x0a, 0x0d, 0x53, 0x65, 0x6e, 0x73, 0x6f, - 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, - 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x22, 0xc2, - 0x01, 0x0a, 0x0a, 0x42, 0x69, 0x6e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x34, 0x0a, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x02, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x70, 0x65, - 0x62, 0x62, 0x6c, 0x65, 0x70, 0x62, 0x2e, 0x42, 0x69, 0x6e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, - 0x65, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x02, 0x28, - 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x18, 0x03, 0x20, 0x02, 0x28, 0x0d, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, - 0x72, 0x65, 0x18, 0x04, 0x20, 0x02, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x22, 0x2e, 0x0a, 0x0b, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x44, 0x41, 0x54, 0x41, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, - 0x43, 0x4f, 0x4e, 0x46, 0x49, 0x47, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x54, 0x41, 0x54, - 0x45, 0x10, 0x02, 0x22, 0x7c, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x50, 0x61, - 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, - 0x20, 0x02, 0x28, 0x0c, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x74, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x02, 0x28, 0x0d, 0x52, 0x09, - 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x03, 0x20, 0x02, 0x28, 0x0c, 0x52, 0x09, 0x73, 0x69, - 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, - 0x65, 0x6c, 0x18, 0x04, 0x20, 0x02, 0x28, 0x0d, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, - 0x6c, 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x3b, 0x70, 0x65, 0x62, 0x62, 0x6c, 0x65, 0x70, 0x62, -} - -var ( - file_pebble_proto_rawDescOnce sync.Once - file_pebble_proto_rawDescData = file_pebble_proto_rawDesc -) - -func file_pebble_proto_rawDescGZIP() []byte { - file_pebble_proto_rawDescOnce.Do(func() { - file_pebble_proto_rawDescData = protoimpl.X.CompressGZIP(file_pebble_proto_rawDescData) - }) - return file_pebble_proto_rawDescData -} - -var file_pebble_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_pebble_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_pebble_proto_goTypes = []interface{}{ - (BinPackage_PackageType)(0), // 0: pebblepb.BinPackage.PackageType - (*SensorData)(nil), // 1: pebblepb.SensorData - (*SensorConfig)(nil), // 2: pebblepb.SensorConfig - (*SensorState)(nil), // 3: pebblepb.SensorState - (*SensorConfirm)(nil), // 4: pebblepb.SensorConfirm - (*BinPackage)(nil), // 5: pebblepb.BinPackage - (*ConfirmPackage)(nil), // 6: pebblepb.ConfirmPackage -} -var file_pebble_proto_depIdxs = []int32{ - 0, // 0: pebblepb.BinPackage.type:type_name -> pebblepb.BinPackage.PackageType - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_pebble_proto_init() } -func file_pebble_proto_init() { - if File_pebble_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_pebble_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SensorData); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pebble_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SensorConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pebble_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SensorState); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pebble_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SensorConfirm); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pebble_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BinPackage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pebble_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ConfirmPackage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_pebble_proto_rawDesc, - NumEnums: 1, - NumMessages: 6, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_pebble_proto_goTypes, - DependencyIndexes: file_pebble_proto_depIdxs, - EnumInfos: file_pebble_proto_enumTypes, - MessageInfos: file_pebble_proto_msgTypes, - }.Build() - File_pebble_proto = out.File - file_pebble_proto_rawDesc = nil - file_pebble_proto_goTypes = nil - file_pebble_proto_depIdxs = nil -} diff --git a/pebblepb/pebble.proto b/pebblepb/pebble.proto deleted file mode 100644 index dfad3e1..0000000 --- a/pebblepb/pebble.proto +++ /dev/null @@ -1,57 +0,0 @@ -syntax = "proto2"; -package pebblepb; -option go_package = "./;pebblepb"; - -message SensorData{ - optional uint32 snr = 1; - optional uint32 vbat = 2; - optional sint32 latitude = 3; - optional sint32 longitude = 4; - optional uint32 gasResistance = 5; - optional sint32 temperature = 6; - optional uint32 pressure = 7; - optional uint32 humidity = 8; - optional uint32 light = 9; - optional uint32 temperature2 = 10; - repeated sint32 gyroscope = 11; - repeated sint32 accelerometer = 12; - optional string random = 13; -} - -message SensorConfig{ - optional uint32 bulkUpload = 1; - optional uint32 dataChannel = 2; - optional uint32 uploadPeriod = 3; - optional uint32 bulkUploadSamplingCnt = 4; - optional uint32 bulkUploadSamplingFreq = 5; - optional uint32 beep = 6; - optional string firmware = 7; - optional bool deviceConfigurable = 8; -} - -message SensorState{ - optional uint32 state = 1; -} - -message SensorConfirm { - optional string owner = 1; -} - -message BinPackage{ - enum PackageType { - DATA = 0; - CONFIG = 1; - STATE = 2; - } - required PackageType type = 1; - required bytes data = 2; - required uint32 timestamp = 3; - required bytes signature = 4; -} - -message ConfirmPackage { - required bytes owner = 1; - required uint32 timestamp = 2; - required bytes signature = 3; - required uint32 channel = 4; -} \ No newline at end of file diff --git a/util/env/env.go b/util/env/env.go deleted file mode 100644 index 9c25d67..0000000 --- a/util/env/env.go +++ /dev/null @@ -1,80 +0,0 @@ -package env - -import ( - "fmt" - "log/slog" - "reflect" - "strings" - - "github.com/fatih/color" - "github.com/spf13/viper" -) - -func parseEnvTag(tag string) (key string, require bool) { - if tag == "" || tag == "-" { - return "", false - } - tagKeys := strings.Split(tag, ",") - key = tagKeys[0] - if len(tagKeys) > 1 && tagKeys[1] == "optional" { - return key, false - } - return key, true -} - -func ParseEnv(c any) error { - rv := reflect.ValueOf(c).Elem() - rt := reflect.TypeOf(c).Elem() - - for i := 0; i < rt.NumField(); i++ { - fi := rt.Field(i) - fv := rv.Field(i) - key, require := parseEnvTag(fi.Tag.Get("env")) - if key == "" { - continue - } - viper.MustBindEnv(key) - - v := viper.Get(key) - if require && v == nil && fv.IsZero() { - panic(fmt.Sprintf("env `%s` is require but got empty", key)) - } - if v == nil { - continue - } - - switch fv.Kind() { - case reflect.String: - fv.Set(reflect.ValueOf(viper.GetString(key))) - case reflect.Int: - if fi.Type == reflect.TypeOf(slog.Level(0)) { - level := slog.Level(viper.GetInt(key)) - fv.Set(reflect.ValueOf(level)) - } else { - fv.Set(reflect.ValueOf(viper.GetInt(key))) - } - case reflect.Uint64: - fv.Set(reflect.ValueOf(viper.GetUint64(key))) - } - } - return nil -} - -func Print(c any) { - rt := reflect.TypeOf(c).Elem() - rv := reflect.ValueOf(c).Elem() - - if env, ok := c.(interface{ Env() string }); ok { - fmt.Println(color.CyanString("ENV: %s", env.Env())) - } - - for i := 0; i < rt.NumField(); i++ { - fi := rt.Field(i) - fv := rv.Field(i) - key, _ := parseEnvTag(fi.Tag.Get("env")) - if key == "" { - continue - } - fmt.Printf("%s: %v\n", color.GreenString(key), fv.Interface()) - } -}