commit
55b4961996
117 changed files with 13666 additions and 0 deletions
@ -0,0 +1,38 @@ |
|||||
|
# Reference https://github.com/github/gitignore/blob/master/Go.gitignore |
||||
|
# Binaries for programs and plugins |
||||
|
*.exe |
||||
|
*.exe~ |
||||
|
*.dll |
||||
|
*.dylib |
||||
|
|
||||
|
# Test binary, built with `go test -c` |
||||
|
*.test |
||||
|
|
||||
|
# Output of the go coverage tool, specifically when used with LiteIDE |
||||
|
*.out |
||||
|
|
||||
|
# Dependency directories (remove the comment below to include it) |
||||
|
vendor/ |
||||
|
|
||||
|
# Go workspace file |
||||
|
go.work |
||||
|
|
||||
|
# Compiled Object files, Static and Dynamic libs (Shared Objects) |
||||
|
*.o |
||||
|
*.a |
||||
|
*.so |
||||
|
|
||||
|
# OS General |
||||
|
Thumbs.db |
||||
|
.DS_Store |
||||
|
|
||||
|
# project |
||||
|
*.cert |
||||
|
*.key |
||||
|
*.log |
||||
|
bin/ |
||||
|
|
||||
|
# Develop tools |
||||
|
.vscode/ |
||||
|
.idea/ |
||||
|
*.swp |
@ -0,0 +1,24 @@ |
|||||
|
FROM golang:1.18 AS builder |
||||
|
|
||||
|
COPY . /src |
||||
|
WORKDIR /src |
||||
|
|
||||
|
RUN GOPROXY=https://goproxy.cn make build |
||||
|
|
||||
|
FROM debian:stable-slim |
||||
|
|
||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \ |
||||
|
ca-certificates \ |
||||
|
netbase \ |
||||
|
&& rm -rf /var/lib/apt/lists/ \ |
||||
|
&& apt-get autoremove -y && apt-get autoclean -y |
||||
|
|
||||
|
COPY --from=builder /src/bin /app |
||||
|
|
||||
|
WORKDIR /app |
||||
|
|
||||
|
EXPOSE 8000 |
||||
|
EXPOSE 9000 |
||||
|
VOLUME /data/conf |
||||
|
|
||||
|
CMD ["./server", "-conf", "/data/conf"] |
@ -0,0 +1,21 @@ |
|||||
|
MIT License |
||||
|
|
||||
|
Copyright (c) 2020 go-kratos |
||||
|
|
||||
|
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. |
@ -0,0 +1,93 @@ |
|||||
|
GOHOSTOS:=$(shell go env GOHOSTOS) |
||||
|
GOPATH:=$(shell go env GOPATH) |
||||
|
VERSION=$(shell git describe --tags --always) |
||||
|
|
||||
|
ifeq ($(GOHOSTOS), windows) |
||||
|
#the `find.exe` is different from `find` in bash/shell. |
||||
|
#to see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find. |
||||
|
#changed to use git-bash.exe to run find cli or other cli friendly, caused of every developer has a Git. |
||||
|
#Git_Bash= $(subst cmd\,bin\bash.exe,$(dir $(shell where git))) |
||||
|
Git_Bash=$(subst \,/,$(subst cmd\,bin\bash.exe,$(dir $(shell where git)))) |
||||
|
INTERNAL_PROTO_FILES=$(shell $(Git_Bash) -c "find internal -name *.proto") |
||||
|
API_PROTO_FILES=$(shell $(Git_Bash) -c "find api -name *.proto") |
||||
|
else |
||||
|
INTERNAL_PROTO_FILES=$(shell find internal -name *.proto) |
||||
|
API_PROTO_FILES=$(shell find api -name *.proto) |
||||
|
endif |
||||
|
|
||||
|
.PHONY: init |
||||
|
# init env
|
||||
|
init: |
||||
|
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest |
||||
|
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest |
||||
|
go install github.com/go-kratos/kratos/cmd/kratos/v2@latest |
||||
|
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest |
||||
|
go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest |
||||
|
go install github.com/google/wire/cmd/wire@latest |
||||
|
|
||||
|
.PHONY: config |
||||
|
# generate internal proto
|
||||
|
config: |
||||
|
protoc --proto_path=./internal \
|
||||
|
--proto_path=./third_party \
|
||||
|
--go_out=paths=source_relative:./internal \
|
||||
|
$(INTERNAL_PROTO_FILES) |
||||
|
|
||||
|
.PHONY: api |
||||
|
# generate api proto
|
||||
|
api: |
||||
|
protoc --proto_path=./api \
|
||||
|
--proto_path=./third_party \
|
||||
|
--go_out=paths=source_relative:./api \
|
||||
|
--go-http_out=paths=source_relative:./api \
|
||||
|
--go-grpc_out=paths=source_relative:./api \
|
||||
|
--openapi_out=fq_schema_naming=true,default_response=false:. \
|
||||
|
$(API_PROTO_FILES) |
||||
|
|
||||
|
.PHONY: wire |
||||
|
# wire
|
||||
|
wire: |
||||
|
cd cmd/wallet-system/ && wire |
||||
|
|
||||
|
.PHONY: run |
||||
|
# run
|
||||
|
run: |
||||
|
kratos run |
||||
|
|
||||
|
.PHONY: build |
||||
|
# build
|
||||
|
build: |
||||
|
mkdir -p bin/ && go build -ldflags "-X main.Version=$(VERSION)" -o ./bin/ ./... |
||||
|
|
||||
|
.PHONY: generate |
||||
|
# generate
|
||||
|
generate: |
||||
|
go mod tidy |
||||
|
go get github.com/google/wire/cmd/wire@latest |
||||
|
go generate ./... |
||||
|
|
||||
|
.PHONY: all |
||||
|
# generate all
|
||||
|
all: |
||||
|
make api; |
||||
|
make config; |
||||
|
make generate; |
||||
|
|
||||
|
# show help
|
||||
|
help: |
||||
|
@echo '' |
||||
|
@echo 'Usage:' |
||||
|
@echo ' make [target]' |
||||
|
@echo '' |
||||
|
@echo 'Targets:' |
||||
|
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
|
||||
|
helpMessage = match(lastLine, /^# (.*)/); \
|
||||
|
if (helpMessage) { \
|
||||
|
helpCommand = substr($$1, 0, index($$1, ":")); \
|
||||
|
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
|
||||
|
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
|
||||
|
} \
|
||||
|
} \
|
||||
|
{ lastLine = $$0 }' $(MAKEFILE_LIST) |
||||
|
|
||||
|
.DEFAULT_GOAL := help |
@ -0,0 +1,51 @@ |
|||||
|
# Kratos Project Template |
||||
|
|
||||
|
## Install Kratos |
||||
|
``` |
||||
|
go install github.com/go-kratos/kratos/cmd/kratos/v2@latest |
||||
|
``` |
||||
|
## Create a service |
||||
|
``` |
||||
|
# Create a template project |
||||
|
kratos new server |
||||
|
|
||||
|
cd server |
||||
|
# Add a proto template |
||||
|
kratos proto add api/server/server.proto |
||||
|
# Generate the proto code |
||||
|
kratos proto client api/server/server.proto |
||||
|
# Generate the source code of service by proto file |
||||
|
kratos proto server api/server/server.proto -t internal/service |
||||
|
|
||||
|
go generate ./... |
||||
|
go build -o ./bin/ ./... |
||||
|
./bin/server -conf ./configs |
||||
|
``` |
||||
|
## Generate other auxiliary files by Makefile |
||||
|
``` |
||||
|
# Download and update dependencies |
||||
|
make init |
||||
|
# Generate API files (include: pb.go, http, grpc, validate, swagger) by proto file |
||||
|
make api |
||||
|
# Generate all files |
||||
|
make all |
||||
|
``` |
||||
|
## Automated Initialization (wire) |
||||
|
``` |
||||
|
# install wire |
||||
|
go get github.com/google/wire/cmd/wire |
||||
|
|
||||
|
# generate wire |
||||
|
cd cmd/server |
||||
|
wire |
||||
|
``` |
||||
|
|
||||
|
## Docker |
||||
|
```bash |
||||
|
# build |
||||
|
docker build -t <your-docker-image-name> . |
||||
|
|
||||
|
# run |
||||
|
docker run --rm -p 8000:8000 -p 9000:9000 -v </path/to/your/configs>:/data/conf <your-docker-image-name> |
||||
|
``` |
||||
|
|
@ -0,0 +1,132 @@ |
|||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
|
// versions:
|
||||
|
// protoc-gen-go v1.34.2
|
||||
|
// protoc v5.27.1
|
||||
|
// source: walletSystem/v1/error_reason.proto
|
||||
|
|
||||
|
package v1 |
||||
|
|
||||
|
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 ErrorReason int32 |
||||
|
|
||||
|
const ( |
||||
|
ErrorReason_GREETER_UNSPECIFIED ErrorReason = 0 |
||||
|
ErrorReason_USER_NOT_FOUND ErrorReason = 1 |
||||
|
) |
||||
|
|
||||
|
// Enum value maps for ErrorReason.
|
||||
|
var ( |
||||
|
ErrorReason_name = map[int32]string{ |
||||
|
0: "GREETER_UNSPECIFIED", |
||||
|
1: "USER_NOT_FOUND", |
||||
|
} |
||||
|
ErrorReason_value = map[string]int32{ |
||||
|
"GREETER_UNSPECIFIED": 0, |
||||
|
"USER_NOT_FOUND": 1, |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
func (x ErrorReason) Enum() *ErrorReason { |
||||
|
p := new(ErrorReason) |
||||
|
*p = x |
||||
|
return p |
||||
|
} |
||||
|
|
||||
|
func (x ErrorReason) String() string { |
||||
|
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) |
||||
|
} |
||||
|
|
||||
|
func (ErrorReason) Descriptor() protoreflect.EnumDescriptor { |
||||
|
return file_walletSystem_v1_error_reason_proto_enumTypes[0].Descriptor() |
||||
|
} |
||||
|
|
||||
|
func (ErrorReason) Type() protoreflect.EnumType { |
||||
|
return &file_walletSystem_v1_error_reason_proto_enumTypes[0] |
||||
|
} |
||||
|
|
||||
|
func (x ErrorReason) Number() protoreflect.EnumNumber { |
||||
|
return protoreflect.EnumNumber(x) |
||||
|
} |
||||
|
|
||||
|
// Deprecated: Use ErrorReason.Descriptor instead.
|
||||
|
func (ErrorReason) EnumDescriptor() ([]byte, []int) { |
||||
|
return file_walletSystem_v1_error_reason_proto_rawDescGZIP(), []int{0} |
||||
|
} |
||||
|
|
||||
|
var File_walletSystem_v1_error_reason_proto protoreflect.FileDescriptor |
||||
|
|
||||
|
var file_walletSystem_v1_error_reason_proto_rawDesc = []byte{ |
||||
|
0x0a, 0x22, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x76, |
||||
|
0x31, 0x2f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x2e, 0x70, |
||||
|
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x53, 0x79, 0x73, 0x74, |
||||
|
0x65, 0x6d, 0x2e, 0x76, 0x31, 0x2a, 0x3a, 0x0a, 0x0b, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, |
||||
|
0x61, 0x73, 0x6f, 0x6e, 0x12, 0x17, 0x0a, 0x13, 0x47, 0x52, 0x45, 0x45, 0x54, 0x45, 0x52, 0x5f, |
||||
|
0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x12, 0x0a, |
||||
|
0x0e, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, |
||||
|
0x01, 0x42, 0x26, 0x5a, 0x24, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x2d, 0x73, 0x79, 0x73, 0x74, |
||||
|
0x65, 0x6d, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x53, 0x79, 0x73, |
||||
|
0x74, 0x65, 0x6d, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, |
||||
|
0x33, |
||||
|
} |
||||
|
|
||||
|
var ( |
||||
|
file_walletSystem_v1_error_reason_proto_rawDescOnce sync.Once |
||||
|
file_walletSystem_v1_error_reason_proto_rawDescData = file_walletSystem_v1_error_reason_proto_rawDesc |
||||
|
) |
||||
|
|
||||
|
func file_walletSystem_v1_error_reason_proto_rawDescGZIP() []byte { |
||||
|
file_walletSystem_v1_error_reason_proto_rawDescOnce.Do(func() { |
||||
|
file_walletSystem_v1_error_reason_proto_rawDescData = protoimpl.X.CompressGZIP(file_walletSystem_v1_error_reason_proto_rawDescData) |
||||
|
}) |
||||
|
return file_walletSystem_v1_error_reason_proto_rawDescData |
||||
|
} |
||||
|
|
||||
|
var file_walletSystem_v1_error_reason_proto_enumTypes = make([]protoimpl.EnumInfo, 1) |
||||
|
var file_walletSystem_v1_error_reason_proto_goTypes = []any{ |
||||
|
(ErrorReason)(0), // 0: walletSystem.v1.ErrorReason
|
||||
|
} |
||||
|
var file_walletSystem_v1_error_reason_proto_depIdxs = []int32{ |
||||
|
0, // [0:0] is the sub-list for method output_type
|
||||
|
0, // [0:0] is the sub-list for method input_type
|
||||
|
0, // [0:0] is the sub-list for extension type_name
|
||||
|
0, // [0:0] is the sub-list for extension extendee
|
||||
|
0, // [0:0] is the sub-list for field type_name
|
||||
|
} |
||||
|
|
||||
|
func init() { file_walletSystem_v1_error_reason_proto_init() } |
||||
|
func file_walletSystem_v1_error_reason_proto_init() { |
||||
|
if File_walletSystem_v1_error_reason_proto != nil { |
||||
|
return |
||||
|
} |
||||
|
type x struct{} |
||||
|
out := protoimpl.TypeBuilder{ |
||||
|
File: protoimpl.DescBuilder{ |
||||
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), |
||||
|
RawDescriptor: file_walletSystem_v1_error_reason_proto_rawDesc, |
||||
|
NumEnums: 1, |
||||
|
NumMessages: 0, |
||||
|
NumExtensions: 0, |
||||
|
NumServices: 0, |
||||
|
}, |
||||
|
GoTypes: file_walletSystem_v1_error_reason_proto_goTypes, |
||||
|
DependencyIndexes: file_walletSystem_v1_error_reason_proto_depIdxs, |
||||
|
EnumInfos: file_walletSystem_v1_error_reason_proto_enumTypes, |
||||
|
}.Build() |
||||
|
File_walletSystem_v1_error_reason_proto = out.File |
||||
|
file_walletSystem_v1_error_reason_proto_rawDesc = nil |
||||
|
file_walletSystem_v1_error_reason_proto_goTypes = nil |
||||
|
file_walletSystem_v1_error_reason_proto_depIdxs = nil |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
syntax = "proto3"; |
||||
|
|
||||
|
package walletSystem.v1; |
||||
|
|
||||
|
option go_package = "wallet-system/api/walletSystem/v1;v1"; |
||||
|
|
||||
|
enum ErrorReason { |
||||
|
GREETER_UNSPECIFIED = 0; |
||||
|
USER_NOT_FOUND = 1; |
||||
|
} |
File diff suppressed because it is too large
@ -0,0 +1,132 @@ |
|||||
|
syntax = "proto3"; |
||||
|
|
||||
|
package walletSystem.v1; |
||||
|
|
||||
|
import "google/api/annotations.proto"; |
||||
|
|
||||
|
option go_package = "wallet-system/api/walletSystem/v1;v1"; |
||||
|
|
||||
|
// The greeting service definition. |
||||
|
service Wallet { |
||||
|
// GenerateAddress Generate wallet address |
||||
|
rpc GenerateAddress (GenerateAddressRequest) returns (WalletReply) { |
||||
|
option (google.api.http) = { |
||||
|
post:"/wallet/generateAddress", |
||||
|
body:"*", |
||||
|
}; |
||||
|
} |
||||
|
// SignatureTrc20Grpc GrpcTrc20 Wallet Signature |
||||
|
rpc SignatureTrc20Grpc (SignatureTrc20Request) returns (SignatureTrc20Reply) { |
||||
|
option (google.api.http) = { |
||||
|
post:"/wallet/signatureTrc20Grpc", |
||||
|
body:"*", |
||||
|
}; |
||||
|
} |
||||
|
// GetAllAddress Check all wallet addresses |
||||
|
rpc GetAllAddress (WalletRequest) returns (WalletReply) { |
||||
|
option (google.api.http) = { |
||||
|
post:"/wallet/allAddress", |
||||
|
body:"*", |
||||
|
}; |
||||
|
} |
||||
|
// GetAllAddressAndPrivateKey Query all private keys |
||||
|
rpc GetAllAddressAndPrivateKey (WalletRequest) returns (WalletKeyReply) { |
||||
|
option (google.api.http) = { |
||||
|
post:"/wallet/allAddressAndPrivateKey", |
||||
|
body:"*", |
||||
|
}; |
||||
|
} |
||||
|
// GetPrivateKeyByAddress Query private key through wallet address |
||||
|
rpc GetPrivateKeyByAddress (GetPrivateKeyByAddressRequest) returns (WalletPKeysReply) { |
||||
|
option (google.api.http) = { |
||||
|
post:"/wallet/privateKeyByAddress", |
||||
|
body:"*", |
||||
|
}; |
||||
|
} |
||||
|
// DeleteAddress Clean all wallets |
||||
|
rpc DeleteAddress (WalletRequest) returns (WalletReply) { |
||||
|
option (google.api.http) = { |
||||
|
post:"/wallet/allDeleteAddress", |
||||
|
body:"*", |
||||
|
}; |
||||
|
} |
||||
|
// WalletApprove Wallet authorization |
||||
|
rpc WalletApprove(WalletApproveRequest)returns(WalletApproveReply){ |
||||
|
option (google.api.http) = { |
||||
|
post:"/wallet/walletApprove", |
||||
|
body:"*", |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
message WalletApproveRequest{ |
||||
|
string from = 1; |
||||
|
string to = 2; |
||||
|
string contract = 3; |
||||
|
uint32 amount = 4; |
||||
|
string trcCheck = 5; |
||||
|
string tokenId = 6; |
||||
|
uint32 feeLimit = 7; |
||||
|
} |
||||
|
|
||||
|
message WalletApproveReply{ |
||||
|
uint32 code = 1; |
||||
|
bytes data = 2; |
||||
|
string message = 3; |
||||
|
} |
||||
|
|
||||
|
message WalletRequest { |
||||
|
} |
||||
|
|
||||
|
message GetPrivateKeyByAddressRequest { |
||||
|
string address = 1; |
||||
|
} |
||||
|
|
||||
|
message GenerateAddressRequest { |
||||
|
string wallet = 1; |
||||
|
uint32 number = 2; |
||||
|
} |
||||
|
|
||||
|
message SignatureTrc20Request { |
||||
|
string from = 1; |
||||
|
string to = 2; |
||||
|
string contract = 3; |
||||
|
uint32 amount = 4; |
||||
|
string trcCheck = 5; |
||||
|
string tokenId = 6; |
||||
|
uint32 feeLimit = 7; |
||||
|
} |
||||
|
|
||||
|
message SignatureTrc20Reply { |
||||
|
uint32 code = 1; |
||||
|
Data data = 2; |
||||
|
string message = 3; |
||||
|
} |
||||
|
|
||||
|
message Data { |
||||
|
bool Result = 1; |
||||
|
string TxId = 2; |
||||
|
} |
||||
|
|
||||
|
message WalletReply { |
||||
|
uint32 code = 1; |
||||
|
repeated string data = 2; |
||||
|
string message = 3; |
||||
|
} |
||||
|
|
||||
|
message WalletKeyReply { |
||||
|
uint32 code = 1; |
||||
|
repeated Keys data = 2; |
||||
|
string message = 3; |
||||
|
} |
||||
|
|
||||
|
message Keys { |
||||
|
string key =1; |
||||
|
bytes value =2; |
||||
|
} |
||||
|
|
||||
|
message WalletPKeysReply { |
||||
|
uint32 code = 1; |
||||
|
string data = 2; |
||||
|
string message = 3; |
||||
|
} |
@ -0,0 +1,356 @@ |
|||||
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
|
// versions:
|
||||
|
// - protoc-gen-go-grpc v1.4.0
|
||||
|
// - protoc v5.27.1
|
||||
|
// source: walletSystem/v1/wallet.proto
|
||||
|
|
||||
|
package v1 |
||||
|
|
||||
|
import ( |
||||
|
context "context" |
||||
|
grpc "google.golang.org/grpc" |
||||
|
codes "google.golang.org/grpc/codes" |
||||
|
status "google.golang.org/grpc/status" |
||||
|
) |
||||
|
|
||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||
|
// is compatible with the grpc package it is being compiled against.
|
||||
|
// Requires gRPC-Go v1.62.0 or later.
|
||||
|
const _ = grpc.SupportPackageIsVersion8 |
||||
|
|
||||
|
const ( |
||||
|
Wallet_GenerateAddress_FullMethodName = "/walletSystem.v1.Wallet/GenerateAddress" |
||||
|
Wallet_SignatureTrc20Grpc_FullMethodName = "/walletSystem.v1.Wallet/SignatureTrc20Grpc" |
||||
|
Wallet_GetAllAddress_FullMethodName = "/walletSystem.v1.Wallet/GetAllAddress" |
||||
|
Wallet_GetAllAddressAndPrivateKey_FullMethodName = "/walletSystem.v1.Wallet/GetAllAddressAndPrivateKey" |
||||
|
Wallet_GetPrivateKeyByAddress_FullMethodName = "/walletSystem.v1.Wallet/GetPrivateKeyByAddress" |
||||
|
Wallet_DeleteAddress_FullMethodName = "/walletSystem.v1.Wallet/DeleteAddress" |
||||
|
Wallet_WalletApprove_FullMethodName = "/walletSystem.v1.Wallet/WalletApprove" |
||||
|
) |
||||
|
|
||||
|
// WalletClient is the client API for Wallet service.
|
||||
|
//
|
||||
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
|
//
|
||||
|
// The greeting service definition.
|
||||
|
type WalletClient interface { |
||||
|
// GenerateAddress Generate wallet address
|
||||
|
GenerateAddress(ctx context.Context, in *GenerateAddressRequest, opts ...grpc.CallOption) (*WalletReply, error) |
||||
|
// SignatureTrc20Grpc GrpcTrc20 Wallet Signature
|
||||
|
SignatureTrc20Grpc(ctx context.Context, in *SignatureTrc20Request, opts ...grpc.CallOption) (*SignatureTrc20Reply, error) |
||||
|
// GetAllAddress Check all wallet addresses
|
||||
|
GetAllAddress(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*WalletReply, error) |
||||
|
// GetAllAddressAndPrivateKey Query all private keys
|
||||
|
GetAllAddressAndPrivateKey(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*WalletKeyReply, error) |
||||
|
// GetPrivateKeyByAddress Query private key through wallet address
|
||||
|
GetPrivateKeyByAddress(ctx context.Context, in *GetPrivateKeyByAddressRequest, opts ...grpc.CallOption) (*WalletPKeysReply, error) |
||||
|
// DeleteAddress Clean all wallets
|
||||
|
DeleteAddress(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*WalletReply, error) |
||||
|
// WalletApprove Wallet authorization
|
||||
|
WalletApprove(ctx context.Context, in *WalletApproveRequest, opts ...grpc.CallOption) (*WalletApproveReply, error) |
||||
|
} |
||||
|
|
||||
|
type walletClient struct { |
||||
|
cc grpc.ClientConnInterface |
||||
|
} |
||||
|
|
||||
|
func NewWalletClient(cc grpc.ClientConnInterface) WalletClient { |
||||
|
return &walletClient{cc} |
||||
|
} |
||||
|
|
||||
|
func (c *walletClient) GenerateAddress(ctx context.Context, in *GenerateAddressRequest, opts ...grpc.CallOption) (*WalletReply, error) { |
||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) |
||||
|
out := new(WalletReply) |
||||
|
err := c.cc.Invoke(ctx, Wallet_GenerateAddress_FullMethodName, in, out, cOpts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return out, nil |
||||
|
} |
||||
|
|
||||
|
func (c *walletClient) SignatureTrc20Grpc(ctx context.Context, in *SignatureTrc20Request, opts ...grpc.CallOption) (*SignatureTrc20Reply, error) { |
||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) |
||||
|
out := new(SignatureTrc20Reply) |
||||
|
err := c.cc.Invoke(ctx, Wallet_SignatureTrc20Grpc_FullMethodName, in, out, cOpts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return out, nil |
||||
|
} |
||||
|
|
||||
|
func (c *walletClient) GetAllAddress(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*WalletReply, error) { |
||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) |
||||
|
out := new(WalletReply) |
||||
|
err := c.cc.Invoke(ctx, Wallet_GetAllAddress_FullMethodName, in, out, cOpts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return out, nil |
||||
|
} |
||||
|
|
||||
|
func (c *walletClient) GetAllAddressAndPrivateKey(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*WalletKeyReply, error) { |
||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) |
||||
|
out := new(WalletKeyReply) |
||||
|
err := c.cc.Invoke(ctx, Wallet_GetAllAddressAndPrivateKey_FullMethodName, in, out, cOpts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return out, nil |
||||
|
} |
||||
|
|
||||
|
func (c *walletClient) GetPrivateKeyByAddress(ctx context.Context, in *GetPrivateKeyByAddressRequest, opts ...grpc.CallOption) (*WalletPKeysReply, error) { |
||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) |
||||
|
out := new(WalletPKeysReply) |
||||
|
err := c.cc.Invoke(ctx, Wallet_GetPrivateKeyByAddress_FullMethodName, in, out, cOpts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return out, nil |
||||
|
} |
||||
|
|
||||
|
func (c *walletClient) DeleteAddress(ctx context.Context, in *WalletRequest, opts ...grpc.CallOption) (*WalletReply, error) { |
||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) |
||||
|
out := new(WalletReply) |
||||
|
err := c.cc.Invoke(ctx, Wallet_DeleteAddress_FullMethodName, in, out, cOpts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return out, nil |
||||
|
} |
||||
|
|
||||
|
func (c *walletClient) WalletApprove(ctx context.Context, in *WalletApproveRequest, opts ...grpc.CallOption) (*WalletApproveReply, error) { |
||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) |
||||
|
out := new(WalletApproveReply) |
||||
|
err := c.cc.Invoke(ctx, Wallet_WalletApprove_FullMethodName, in, out, cOpts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return out, nil |
||||
|
} |
||||
|
|
||||
|
// WalletServer is the server API for Wallet service.
|
||||
|
// All implementations must embed UnimplementedWalletServer
|
||||
|
// for forward compatibility
|
||||
|
//
|
||||
|
// The greeting service definition.
|
||||
|
type WalletServer interface { |
||||
|
// GenerateAddress Generate wallet address
|
||||
|
GenerateAddress(context.Context, *GenerateAddressRequest) (*WalletReply, error) |
||||
|
// SignatureTrc20Grpc GrpcTrc20 Wallet Signature
|
||||
|
SignatureTrc20Grpc(context.Context, *SignatureTrc20Request) (*SignatureTrc20Reply, error) |
||||
|
// GetAllAddress Check all wallet addresses
|
||||
|
GetAllAddress(context.Context, *WalletRequest) (*WalletReply, error) |
||||
|
// GetAllAddressAndPrivateKey Query all private keys
|
||||
|
GetAllAddressAndPrivateKey(context.Context, *WalletRequest) (*WalletKeyReply, error) |
||||
|
// GetPrivateKeyByAddress Query private key through wallet address
|
||||
|
GetPrivateKeyByAddress(context.Context, *GetPrivateKeyByAddressRequest) (*WalletPKeysReply, error) |
||||
|
// DeleteAddress Clean all wallets
|
||||
|
DeleteAddress(context.Context, *WalletRequest) (*WalletReply, error) |
||||
|
// WalletApprove Wallet authorization
|
||||
|
WalletApprove(context.Context, *WalletApproveRequest) (*WalletApproveReply, error) |
||||
|
mustEmbedUnimplementedWalletServer() |
||||
|
} |
||||
|
|
||||
|
// UnimplementedWalletServer must be embedded to have forward compatible implementations.
|
||||
|
type UnimplementedWalletServer struct { |
||||
|
} |
||||
|
|
||||
|
func (UnimplementedWalletServer) GenerateAddress(context.Context, *GenerateAddressRequest) (*WalletReply, error) { |
||||
|
return nil, status.Errorf(codes.Unimplemented, "method GenerateAddress not implemented") |
||||
|
} |
||||
|
func (UnimplementedWalletServer) SignatureTrc20Grpc(context.Context, *SignatureTrc20Request) (*SignatureTrc20Reply, error) { |
||||
|
return nil, status.Errorf(codes.Unimplemented, "method SignatureTrc20Grpc not implemented") |
||||
|
} |
||||
|
func (UnimplementedWalletServer) GetAllAddress(context.Context, *WalletRequest) (*WalletReply, error) { |
||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetAllAddress not implemented") |
||||
|
} |
||||
|
func (UnimplementedWalletServer) GetAllAddressAndPrivateKey(context.Context, *WalletRequest) (*WalletKeyReply, error) { |
||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetAllAddressAndPrivateKey not implemented") |
||||
|
} |
||||
|
func (UnimplementedWalletServer) GetPrivateKeyByAddress(context.Context, *GetPrivateKeyByAddressRequest) (*WalletPKeysReply, error) { |
||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetPrivateKeyByAddress not implemented") |
||||
|
} |
||||
|
func (UnimplementedWalletServer) DeleteAddress(context.Context, *WalletRequest) (*WalletReply, error) { |
||||
|
return nil, status.Errorf(codes.Unimplemented, "method DeleteAddress not implemented") |
||||
|
} |
||||
|
func (UnimplementedWalletServer) WalletApprove(context.Context, *WalletApproveRequest) (*WalletApproveReply, error) { |
||||
|
return nil, status.Errorf(codes.Unimplemented, "method WalletApprove not implemented") |
||||
|
} |
||||
|
func (UnimplementedWalletServer) mustEmbedUnimplementedWalletServer() {} |
||||
|
|
||||
|
// UnsafeWalletServer may be embedded to opt out of forward compatibility for this service.
|
||||
|
// Use of this interface is not recommended, as added methods to WalletServer will
|
||||
|
// result in compilation errors.
|
||||
|
type UnsafeWalletServer interface { |
||||
|
mustEmbedUnimplementedWalletServer() |
||||
|
} |
||||
|
|
||||
|
func RegisterWalletServer(s grpc.ServiceRegistrar, srv WalletServer) { |
||||
|
s.RegisterService(&Wallet_ServiceDesc, srv) |
||||
|
} |
||||
|
|
||||
|
func _Wallet_GenerateAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { |
||||
|
in := new(GenerateAddressRequest) |
||||
|
if err := dec(in); err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
if interceptor == nil { |
||||
|
return srv.(WalletServer).GenerateAddress(ctx, in) |
||||
|
} |
||||
|
info := &grpc.UnaryServerInfo{ |
||||
|
Server: srv, |
||||
|
FullMethod: Wallet_GenerateAddress_FullMethodName, |
||||
|
} |
||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.(WalletServer).GenerateAddress(ctx, req.(*GenerateAddressRequest)) |
||||
|
} |
||||
|
return interceptor(ctx, in, info, handler) |
||||
|
} |
||||
|
|
||||
|
func _Wallet_SignatureTrc20Grpc_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { |
||||
|
in := new(SignatureTrc20Request) |
||||
|
if err := dec(in); err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
if interceptor == nil { |
||||
|
return srv.(WalletServer).SignatureTrc20Grpc(ctx, in) |
||||
|
} |
||||
|
info := &grpc.UnaryServerInfo{ |
||||
|
Server: srv, |
||||
|
FullMethod: Wallet_SignatureTrc20Grpc_FullMethodName, |
||||
|
} |
||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.(WalletServer).SignatureTrc20Grpc(ctx, req.(*SignatureTrc20Request)) |
||||
|
} |
||||
|
return interceptor(ctx, in, info, handler) |
||||
|
} |
||||
|
|
||||
|
func _Wallet_GetAllAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { |
||||
|
in := new(WalletRequest) |
||||
|
if err := dec(in); err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
if interceptor == nil { |
||||
|
return srv.(WalletServer).GetAllAddress(ctx, in) |
||||
|
} |
||||
|
info := &grpc.UnaryServerInfo{ |
||||
|
Server: srv, |
||||
|
FullMethod: Wallet_GetAllAddress_FullMethodName, |
||||
|
} |
||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.(WalletServer).GetAllAddress(ctx, req.(*WalletRequest)) |
||||
|
} |
||||
|
return interceptor(ctx, in, info, handler) |
||||
|
} |
||||
|
|
||||
|
func _Wallet_GetAllAddressAndPrivateKey_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { |
||||
|
in := new(WalletRequest) |
||||
|
if err := dec(in); err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
if interceptor == nil { |
||||
|
return srv.(WalletServer).GetAllAddressAndPrivateKey(ctx, in) |
||||
|
} |
||||
|
info := &grpc.UnaryServerInfo{ |
||||
|
Server: srv, |
||||
|
FullMethod: Wallet_GetAllAddressAndPrivateKey_FullMethodName, |
||||
|
} |
||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.(WalletServer).GetAllAddressAndPrivateKey(ctx, req.(*WalletRequest)) |
||||
|
} |
||||
|
return interceptor(ctx, in, info, handler) |
||||
|
} |
||||
|
|
||||
|
func _Wallet_GetPrivateKeyByAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { |
||||
|
in := new(GetPrivateKeyByAddressRequest) |
||||
|
if err := dec(in); err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
if interceptor == nil { |
||||
|
return srv.(WalletServer).GetPrivateKeyByAddress(ctx, in) |
||||
|
} |
||||
|
info := &grpc.UnaryServerInfo{ |
||||
|
Server: srv, |
||||
|
FullMethod: Wallet_GetPrivateKeyByAddress_FullMethodName, |
||||
|
} |
||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.(WalletServer).GetPrivateKeyByAddress(ctx, req.(*GetPrivateKeyByAddressRequest)) |
||||
|
} |
||||
|
return interceptor(ctx, in, info, handler) |
||||
|
} |
||||
|
|
||||
|
func _Wallet_DeleteAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { |
||||
|
in := new(WalletRequest) |
||||
|
if err := dec(in); err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
if interceptor == nil { |
||||
|
return srv.(WalletServer).DeleteAddress(ctx, in) |
||||
|
} |
||||
|
info := &grpc.UnaryServerInfo{ |
||||
|
Server: srv, |
||||
|
FullMethod: Wallet_DeleteAddress_FullMethodName, |
||||
|
} |
||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.(WalletServer).DeleteAddress(ctx, req.(*WalletRequest)) |
||||
|
} |
||||
|
return interceptor(ctx, in, info, handler) |
||||
|
} |
||||
|
|
||||
|
func _Wallet_WalletApprove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { |
||||
|
in := new(WalletApproveRequest) |
||||
|
if err := dec(in); err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
if interceptor == nil { |
||||
|
return srv.(WalletServer).WalletApprove(ctx, in) |
||||
|
} |
||||
|
info := &grpc.UnaryServerInfo{ |
||||
|
Server: srv, |
||||
|
FullMethod: Wallet_WalletApprove_FullMethodName, |
||||
|
} |
||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.(WalletServer).WalletApprove(ctx, req.(*WalletApproveRequest)) |
||||
|
} |
||||
|
return interceptor(ctx, in, info, handler) |
||||
|
} |
||||
|
|
||||
|
// Wallet_ServiceDesc is the grpc.ServiceDesc for Wallet service.
|
||||
|
// It's only intended for direct use with grpc.RegisterService,
|
||||
|
// and not to be introspected or modified (even as a copy)
|
||||
|
var Wallet_ServiceDesc = grpc.ServiceDesc{ |
||||
|
ServiceName: "walletSystem.v1.Wallet", |
||||
|
HandlerType: (*WalletServer)(nil), |
||||
|
Methods: []grpc.MethodDesc{ |
||||
|
{ |
||||
|
MethodName: "GenerateAddress", |
||||
|
Handler: _Wallet_GenerateAddress_Handler, |
||||
|
}, |
||||
|
{ |
||||
|
MethodName: "SignatureTrc20Grpc", |
||||
|
Handler: _Wallet_SignatureTrc20Grpc_Handler, |
||||
|
}, |
||||
|
{ |
||||
|
MethodName: "GetAllAddress", |
||||
|
Handler: _Wallet_GetAllAddress_Handler, |
||||
|
}, |
||||
|
{ |
||||
|
MethodName: "GetAllAddressAndPrivateKey", |
||||
|
Handler: _Wallet_GetAllAddressAndPrivateKey_Handler, |
||||
|
}, |
||||
|
{ |
||||
|
MethodName: "GetPrivateKeyByAddress", |
||||
|
Handler: _Wallet_GetPrivateKeyByAddress_Handler, |
||||
|
}, |
||||
|
{ |
||||
|
MethodName: "DeleteAddress", |
||||
|
Handler: _Wallet_DeleteAddress_Handler, |
||||
|
}, |
||||
|
{ |
||||
|
MethodName: "WalletApprove", |
||||
|
Handler: _Wallet_WalletApprove_Handler, |
||||
|
}, |
||||
|
}, |
||||
|
Streams: []grpc.StreamDesc{}, |
||||
|
Metadata: "walletSystem/v1/wallet.proto", |
||||
|
} |
@ -0,0 +1,319 @@ |
|||||
|
// Code generated by protoc-gen-go-http. DO NOT EDIT.
|
||||
|
// versions:
|
||||
|
// - protoc-gen-go-http v2.7.3
|
||||
|
// - protoc v5.27.1
|
||||
|
// source: walletSystem/v1/wallet.proto
|
||||
|
|
||||
|
package v1 |
||||
|
|
||||
|
import ( |
||||
|
context "context" |
||||
|
http "github.com/go-kratos/kratos/v2/transport/http" |
||||
|
binding "github.com/go-kratos/kratos/v2/transport/http/binding" |
||||
|
) |
||||
|
|
||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||
|
// is compatible with the kratos package it is being compiled against.
|
||||
|
var _ = new(context.Context) |
||||
|
var _ = binding.EncodeURL |
||||
|
|
||||
|
const _ = http.SupportPackageIsVersion1 |
||||
|
|
||||
|
const OperationWalletDeleteAddress = "/walletSystem.v1.Wallet/DeleteAddress" |
||||
|
const OperationWalletGenerateAddress = "/walletSystem.v1.Wallet/GenerateAddress" |
||||
|
const OperationWalletGetAllAddress = "/walletSystem.v1.Wallet/GetAllAddress" |
||||
|
const OperationWalletGetAllAddressAndPrivateKey = "/walletSystem.v1.Wallet/GetAllAddressAndPrivateKey" |
||||
|
const OperationWalletGetPrivateKeyByAddress = "/walletSystem.v1.Wallet/GetPrivateKeyByAddress" |
||||
|
const OperationWalletSignatureTrc20Grpc = "/walletSystem.v1.Wallet/SignatureTrc20Grpc" |
||||
|
const OperationWalletWalletApprove = "/walletSystem.v1.Wallet/WalletApprove" |
||||
|
|
||||
|
type WalletHTTPServer interface { |
||||
|
// DeleteAddress DeleteAddress Clean all wallets
|
||||
|
DeleteAddress(context.Context, *WalletRequest) (*WalletReply, error) |
||||
|
// GenerateAddress GenerateAddress Generate wallet address
|
||||
|
GenerateAddress(context.Context, *GenerateAddressRequest) (*WalletReply, error) |
||||
|
// GetAllAddress GetAllAddress Check all wallet addresses
|
||||
|
GetAllAddress(context.Context, *WalletRequest) (*WalletReply, error) |
||||
|
// GetAllAddressAndPrivateKey GetAllAddressAndPrivateKey Query all private keys
|
||||
|
GetAllAddressAndPrivateKey(context.Context, *WalletRequest) (*WalletKeyReply, error) |
||||
|
// GetPrivateKeyByAddress GetPrivateKeyByAddress Query private key through wallet address
|
||||
|
GetPrivateKeyByAddress(context.Context, *GetPrivateKeyByAddressRequest) (*WalletPKeysReply, error) |
||||
|
// SignatureTrc20Grpc SignatureTrc20Grpc GrpcTrc20 Wallet Signature
|
||||
|
SignatureTrc20Grpc(context.Context, *SignatureTrc20Request) (*SignatureTrc20Reply, error) |
||||
|
// WalletApprove WalletApprove Wallet authorization
|
||||
|
WalletApprove(context.Context, *WalletApproveRequest) (*WalletApproveReply, error) |
||||
|
} |
||||
|
|
||||
|
func RegisterWalletHTTPServer(s *http.Server, srv WalletHTTPServer) { |
||||
|
r := s.Route("/") |
||||
|
r.POST("/wallet/generateAddress", _Wallet_GenerateAddress0_HTTP_Handler(srv)) |
||||
|
r.POST("/wallet/signatureTrc20Grpc", _Wallet_SignatureTrc20Grpc0_HTTP_Handler(srv)) |
||||
|
r.POST("/wallet/allAddress", _Wallet_GetAllAddress0_HTTP_Handler(srv)) |
||||
|
r.POST("/wallet/allAddressAndPrivateKey", _Wallet_GetAllAddressAndPrivateKey0_HTTP_Handler(srv)) |
||||
|
r.POST("/wallet/privateKeyByAddress", _Wallet_GetPrivateKeyByAddress0_HTTP_Handler(srv)) |
||||
|
r.POST("/wallet/allDeleteAddress", _Wallet_DeleteAddress0_HTTP_Handler(srv)) |
||||
|
r.POST("/wallet/walletApprove", _Wallet_WalletApprove0_HTTP_Handler(srv)) |
||||
|
} |
||||
|
|
||||
|
func _Wallet_GenerateAddress0_HTTP_Handler(srv WalletHTTPServer) func(ctx http.Context) error { |
||||
|
return func(ctx http.Context) error { |
||||
|
var in GenerateAddressRequest |
||||
|
if err := ctx.Bind(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
if err := ctx.BindQuery(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
http.SetOperation(ctx, OperationWalletGenerateAddress) |
||||
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.GenerateAddress(ctx, req.(*GenerateAddressRequest)) |
||||
|
}) |
||||
|
out, err := h(ctx, &in) |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
reply := out.(*WalletReply) |
||||
|
return ctx.Result(200, reply) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func _Wallet_SignatureTrc20Grpc0_HTTP_Handler(srv WalletHTTPServer) func(ctx http.Context) error { |
||||
|
return func(ctx http.Context) error { |
||||
|
var in SignatureTrc20Request |
||||
|
if err := ctx.Bind(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
if err := ctx.BindQuery(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
http.SetOperation(ctx, OperationWalletSignatureTrc20Grpc) |
||||
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.SignatureTrc20Grpc(ctx, req.(*SignatureTrc20Request)) |
||||
|
}) |
||||
|
out, err := h(ctx, &in) |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
reply := out.(*SignatureTrc20Reply) |
||||
|
return ctx.Result(200, reply) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func _Wallet_GetAllAddress0_HTTP_Handler(srv WalletHTTPServer) func(ctx http.Context) error { |
||||
|
return func(ctx http.Context) error { |
||||
|
var in WalletRequest |
||||
|
if err := ctx.Bind(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
if err := ctx.BindQuery(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
http.SetOperation(ctx, OperationWalletGetAllAddress) |
||||
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.GetAllAddress(ctx, req.(*WalletRequest)) |
||||
|
}) |
||||
|
out, err := h(ctx, &in) |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
reply := out.(*WalletReply) |
||||
|
return ctx.Result(200, reply) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func _Wallet_GetAllAddressAndPrivateKey0_HTTP_Handler(srv WalletHTTPServer) func(ctx http.Context) error { |
||||
|
return func(ctx http.Context) error { |
||||
|
var in WalletRequest |
||||
|
if err := ctx.Bind(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
if err := ctx.BindQuery(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
http.SetOperation(ctx, OperationWalletGetAllAddressAndPrivateKey) |
||||
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.GetAllAddressAndPrivateKey(ctx, req.(*WalletRequest)) |
||||
|
}) |
||||
|
out, err := h(ctx, &in) |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
reply := out.(*WalletKeyReply) |
||||
|
return ctx.Result(200, reply) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func _Wallet_GetPrivateKeyByAddress0_HTTP_Handler(srv WalletHTTPServer) func(ctx http.Context) error { |
||||
|
return func(ctx http.Context) error { |
||||
|
var in GetPrivateKeyByAddressRequest |
||||
|
if err := ctx.Bind(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
if err := ctx.BindQuery(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
http.SetOperation(ctx, OperationWalletGetPrivateKeyByAddress) |
||||
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.GetPrivateKeyByAddress(ctx, req.(*GetPrivateKeyByAddressRequest)) |
||||
|
}) |
||||
|
out, err := h(ctx, &in) |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
reply := out.(*WalletPKeysReply) |
||||
|
return ctx.Result(200, reply) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func _Wallet_DeleteAddress0_HTTP_Handler(srv WalletHTTPServer) func(ctx http.Context) error { |
||||
|
return func(ctx http.Context) error { |
||||
|
var in WalletRequest |
||||
|
if err := ctx.Bind(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
if err := ctx.BindQuery(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
http.SetOperation(ctx, OperationWalletDeleteAddress) |
||||
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.DeleteAddress(ctx, req.(*WalletRequest)) |
||||
|
}) |
||||
|
out, err := h(ctx, &in) |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
reply := out.(*WalletReply) |
||||
|
return ctx.Result(200, reply) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func _Wallet_WalletApprove0_HTTP_Handler(srv WalletHTTPServer) func(ctx http.Context) error { |
||||
|
return func(ctx http.Context) error { |
||||
|
var in WalletApproveRequest |
||||
|
if err := ctx.Bind(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
if err := ctx.BindQuery(&in); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
http.SetOperation(ctx, OperationWalletWalletApprove) |
||||
|
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { |
||||
|
return srv.WalletApprove(ctx, req.(*WalletApproveRequest)) |
||||
|
}) |
||||
|
out, err := h(ctx, &in) |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
reply := out.(*WalletApproveReply) |
||||
|
return ctx.Result(200, reply) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
type WalletHTTPClient interface { |
||||
|
DeleteAddress(ctx context.Context, req *WalletRequest, opts ...http.CallOption) (rsp *WalletReply, err error) |
||||
|
GenerateAddress(ctx context.Context, req *GenerateAddressRequest, opts ...http.CallOption) (rsp *WalletReply, err error) |
||||
|
GetAllAddress(ctx context.Context, req *WalletRequest, opts ...http.CallOption) (rsp *WalletReply, err error) |
||||
|
GetAllAddressAndPrivateKey(ctx context.Context, req *WalletRequest, opts ...http.CallOption) (rsp *WalletKeyReply, err error) |
||||
|
GetPrivateKeyByAddress(ctx context.Context, req *GetPrivateKeyByAddressRequest, opts ...http.CallOption) (rsp *WalletPKeysReply, err error) |
||||
|
SignatureTrc20Grpc(ctx context.Context, req *SignatureTrc20Request, opts ...http.CallOption) (rsp *SignatureTrc20Reply, err error) |
||||
|
WalletApprove(ctx context.Context, req *WalletApproveRequest, opts ...http.CallOption) (rsp *WalletApproveReply, err error) |
||||
|
} |
||||
|
|
||||
|
type WalletHTTPClientImpl struct { |
||||
|
cc *http.Client |
||||
|
} |
||||
|
|
||||
|
func NewWalletHTTPClient(client *http.Client) WalletHTTPClient { |
||||
|
return &WalletHTTPClientImpl{client} |
||||
|
} |
||||
|
|
||||
|
func (c *WalletHTTPClientImpl) DeleteAddress(ctx context.Context, in *WalletRequest, opts ...http.CallOption) (*WalletReply, error) { |
||||
|
var out WalletReply |
||||
|
pattern := "/wallet/allDeleteAddress" |
||||
|
path := binding.EncodeURL(pattern, in, false) |
||||
|
opts = append(opts, http.Operation(OperationWalletDeleteAddress)) |
||||
|
opts = append(opts, http.PathTemplate(pattern)) |
||||
|
err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return &out, nil |
||||
|
} |
||||
|
|
||||
|
func (c *WalletHTTPClientImpl) GenerateAddress(ctx context.Context, in *GenerateAddressRequest, opts ...http.CallOption) (*WalletReply, error) { |
||||
|
var out WalletReply |
||||
|
pattern := "/wallet/generateAddress" |
||||
|
path := binding.EncodeURL(pattern, in, false) |
||||
|
opts = append(opts, http.Operation(OperationWalletGenerateAddress)) |
||||
|
opts = append(opts, http.PathTemplate(pattern)) |
||||
|
err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return &out, nil |
||||
|
} |
||||
|
|
||||
|
func (c *WalletHTTPClientImpl) GetAllAddress(ctx context.Context, in *WalletRequest, opts ...http.CallOption) (*WalletReply, error) { |
||||
|
var out WalletReply |
||||
|
pattern := "/wallet/allAddress" |
||||
|
path := binding.EncodeURL(pattern, in, false) |
||||
|
opts = append(opts, http.Operation(OperationWalletGetAllAddress)) |
||||
|
opts = append(opts, http.PathTemplate(pattern)) |
||||
|
err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return &out, nil |
||||
|
} |
||||
|
|
||||
|
func (c *WalletHTTPClientImpl) GetAllAddressAndPrivateKey(ctx context.Context, in *WalletRequest, opts ...http.CallOption) (*WalletKeyReply, error) { |
||||
|
var out WalletKeyReply |
||||
|
pattern := "/wallet/allAddressAndPrivateKey" |
||||
|
path := binding.EncodeURL(pattern, in, false) |
||||
|
opts = append(opts, http.Operation(OperationWalletGetAllAddressAndPrivateKey)) |
||||
|
opts = append(opts, http.PathTemplate(pattern)) |
||||
|
err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return &out, nil |
||||
|
} |
||||
|
|
||||
|
func (c *WalletHTTPClientImpl) GetPrivateKeyByAddress(ctx context.Context, in *GetPrivateKeyByAddressRequest, opts ...http.CallOption) (*WalletPKeysReply, error) { |
||||
|
var out WalletPKeysReply |
||||
|
pattern := "/wallet/privateKeyByAddress" |
||||
|
path := binding.EncodeURL(pattern, in, false) |
||||
|
opts = append(opts, http.Operation(OperationWalletGetPrivateKeyByAddress)) |
||||
|
opts = append(opts, http.PathTemplate(pattern)) |
||||
|
err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return &out, nil |
||||
|
} |
||||
|
|
||||
|
func (c *WalletHTTPClientImpl) SignatureTrc20Grpc(ctx context.Context, in *SignatureTrc20Request, opts ...http.CallOption) (*SignatureTrc20Reply, error) { |
||||
|
var out SignatureTrc20Reply |
||||
|
pattern := "/wallet/signatureTrc20Grpc" |
||||
|
path := binding.EncodeURL(pattern, in, false) |
||||
|
opts = append(opts, http.Operation(OperationWalletSignatureTrc20Grpc)) |
||||
|
opts = append(opts, http.PathTemplate(pattern)) |
||||
|
err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return &out, nil |
||||
|
} |
||||
|
|
||||
|
func (c *WalletHTTPClientImpl) WalletApprove(ctx context.Context, in *WalletApproveRequest, opts ...http.CallOption) (*WalletApproveReply, error) { |
||||
|
var out WalletApproveReply |
||||
|
pattern := "/wallet/walletApprove" |
||||
|
path := binding.EncodeURL(pattern, in, false) |
||||
|
opts = append(opts, http.Operation(OperationWalletWalletApprove)) |
||||
|
opts = append(opts, http.PathTemplate(pattern)) |
||||
|
err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return &out, nil |
||||
|
} |
@ -0,0 +1,86 @@ |
|||||
|
package main |
||||
|
|
||||
|
import ( |
||||
|
"flag" |
||||
|
"github.com/go-kratos/kratos/v2" |
||||
|
"github.com/go-kratos/kratos/v2/log" |
||||
|
"github.com/go-kratos/kratos/v2/middleware/tracing" |
||||
|
"github.com/go-kratos/kratos/v2/transport/grpc" |
||||
|
"github.com/go-kratos/kratos/v2/transport/http" |
||||
|
"gopkg.in/yaml.v2" |
||||
|
"io/ioutil" |
||||
|
"os" |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/pkg/logging/applogger" |
||||
|
|
||||
|
_ "go.uber.org/automaxprocs" |
||||
|
) |
||||
|
|
||||
|
// go build -ldflags "-X main.Version=x.y.z"
|
||||
|
var ( |
||||
|
// Name is the name of the compiled software.
|
||||
|
Name string |
||||
|
// Version is the version of the compiled software.
|
||||
|
Version string |
||||
|
// flagconf is the config flag.
|
||||
|
flagconf string |
||||
|
|
||||
|
id, _ = os.Hostname() |
||||
|
) |
||||
|
|
||||
|
func init() { |
||||
|
flag.StringVar(&flagconf, "conf", "../../configs/wallet.yaml", "wallet path, eg: -conf wallet.yaml") |
||||
|
} |
||||
|
|
||||
|
func newApp(logger log.Logger, gs *grpc.Server, hs *http.Server) *kratos.App { |
||||
|
return kratos.New( |
||||
|
kratos.ID(id), |
||||
|
kratos.Name(Name), |
||||
|
kratos.Version(Version), |
||||
|
kratos.Metadata(map[string]string{}), |
||||
|
kratos.Logger(logger), |
||||
|
kratos.Server( |
||||
|
gs, |
||||
|
hs, |
||||
|
), |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
func main() { |
||||
|
flag.Parse() |
||||
|
logger := log.With(log.NewStdLogger(os.Stdout), |
||||
|
"ts", log.DefaultTimestamp, |
||||
|
"caller", log.DefaultCaller, |
||||
|
"service.id", id, |
||||
|
"service.name", Name, |
||||
|
"service.version", Version, |
||||
|
"trace.id", tracing.TraceID(), |
||||
|
"span.id", tracing.SpanID(), |
||||
|
) |
||||
|
|
||||
|
// Read Configuration File
|
||||
|
yamlFile, err := ioutil.ReadFile(flagconf) |
||||
|
if err != nil { |
||||
|
panic(err) |
||||
|
} |
||||
|
|
||||
|
// Parsing protopuf
|
||||
|
var bc conf.Bootstrap |
||||
|
err = yaml.Unmarshal(yamlFile, &bc) |
||||
|
if err != nil { |
||||
|
panic(err) |
||||
|
} |
||||
|
|
||||
|
applogger.Debug("数据配置:%v", bc) |
||||
|
|
||||
|
app, cleanup, err := wireApp(bc.Server, bc.Data, bc.Aws, logger) |
||||
|
if err != nil { |
||||
|
panic(err) |
||||
|
} |
||||
|
defer cleanup() |
||||
|
|
||||
|
// start and wait for stop signal
|
||||
|
if err := app.Run(); err != nil { |
||||
|
panic(err) |
||||
|
} |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
//go:build wireinject
|
||||
|
// +build wireinject
|
||||
|
|
||||
|
// The build tag makes sure the stub is not built in the final build.
|
||||
|
|
||||
|
package main |
||||
|
|
||||
|
import ( |
||||
|
"github.com/go-kratos/kratos/v2" |
||||
|
"github.com/go-kratos/kratos/v2/log" |
||||
|
"github.com/google/wire" |
||||
|
"wallet-system/internal/biz" |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/data" |
||||
|
"wallet-system/internal/server" |
||||
|
"wallet-system/internal/service" |
||||
|
) |
||||
|
|
||||
|
// wireApp init kratos application.
|
||||
|
func wireApp(*conf.Server, *conf.Data, *conf.Aws, log.Logger) (*kratos.App, func(), error) { |
||||
|
panic(wire.Build(server.ProviderSet, data.ProviderSet, biz.ProviderSet, service.ProviderSet, newApp)) |
||||
|
} |
@ -0,0 +1,48 @@ |
|||||
|
// Code generated by Wire. DO NOT EDIT.
|
||||
|
|
||||
|
//go:generate go run -mod=mod github.com/google/wire/cmd/wire
|
||||
|
//go:build !wireinject
|
||||
|
// +build !wireinject
|
||||
|
|
||||
|
package main |
||||
|
|
||||
|
import ( |
||||
|
"github.com/go-kratos/kratos/v2" |
||||
|
"github.com/go-kratos/kratos/v2/log" |
||||
|
"wallet-system/internal/biz" |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/data" |
||||
|
"wallet-system/internal/data/aws/kms" |
||||
|
"wallet-system/internal/data/aws/s3" |
||||
|
"wallet-system/internal/data/leveldb" |
||||
|
"wallet-system/internal/data/tron" |
||||
|
"wallet-system/internal/server" |
||||
|
"wallet-system/internal/service" |
||||
|
) |
||||
|
|
||||
|
import ( |
||||
|
_ "go.uber.org/automaxprocs" |
||||
|
) |
||||
|
|
||||
|
// Injectors from wire.go:
|
||||
|
|
||||
|
// wireApp init kratos application.
|
||||
|
func wireApp(confServer *conf.Server, confData *conf.Data, aws *conf.Aws, logger log.Logger) (*kratos.App, func(), error) { |
||||
|
s3Client := s3.NewClientS3(aws) |
||||
|
kmsClient := kms.NewClientKms(aws) |
||||
|
levelDB := leveldb.NewLevelDB(confData) |
||||
|
client := tron.NewTronGrpc(aws) |
||||
|
dataData, cleanup, err := data.NewData(confData, aws, s3Client, kmsClient, levelDB, client, logger) |
||||
|
if err != nil { |
||||
|
return nil, nil, err |
||||
|
} |
||||
|
walletRepo := data.NewWalletRepo(dataData, logger) |
||||
|
walletInfo := biz.NewWalletInfo(walletRepo, logger) |
||||
|
walletService := service.NewWalletService(walletInfo) |
||||
|
grpcServer := server.NewGRPCServer(confServer, walletService, logger) |
||||
|
httpServer := server.NewHTTPServer(confServer, walletService, logger) |
||||
|
app := newApp(logger, grpcServer, httpServer) |
||||
|
return app, func() { |
||||
|
cleanup() |
||||
|
}, nil |
||||
|
} |
Binary file not shown.
@ -0,0 +1 @@ |
|||||
|
MANIFEST-000060 |
@ -0,0 +1 @@ |
|||||
|
MANIFEST-000058 |
@ -0,0 +1,270 @@ |
|||||
|
=============== Aug 21, 2023 (+08) =============== |
||||
|
13:54:40.476657 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
13:54:40.482421 db@open opening |
||||
|
13:54:40.482885 version@stat F·[] S·0B[] Sc·[] |
||||
|
13:54:40.484885 db@janitor F·2 G·0 |
||||
|
13:54:40.484930 db@open done T·2.462693ms |
||||
|
=============== Aug 21, 2023 (+08) =============== |
||||
|
14:19:28.007901 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
14:19:28.008125 version@stat F·[] S·0B[] Sc·[] |
||||
|
14:19:28.008160 db@open opening |
||||
|
14:19:28.008225 journal@recovery F·1 |
||||
|
14:19:28.010281 journal@recovery recovering @1 |
||||
|
14:19:28.015777 memdb@flush created L0@2 N·400 S·71KiB "TA2..2tX,v327":"TZG..NgP,v351" |
||||
|
14:19:28.015983 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
14:19:28.025625 db@janitor F·3 G·0 |
||||
|
14:19:28.025664 db@open done T·17.492315ms |
||||
|
=============== Aug 21, 2023 (+08) =============== |
||||
|
14:25:39.505417 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
14:25:39.505711 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
14:25:39.505749 db@open opening |
||||
|
14:25:39.505828 journal@recovery F·1 |
||||
|
14:25:39.507639 journal@recovery recovering @3 |
||||
|
14:25:39.509177 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
14:25:39.518418 db@janitor F·3 G·0 |
||||
|
14:25:39.518445 db@open done T·12.679773ms |
||||
|
=============== Aug 21, 2023 (CST) =============== |
||||
|
14:52:59.712399 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
14:52:59.714026 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
14:52:59.714026 db@open opening |
||||
|
14:52:59.714026 journal@recovery F·1 |
||||
|
14:52:59.715057 journal@recovery recovering @5 |
||||
|
14:52:59.716030 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
14:52:59.725982 db@janitor F·5 G·2 |
||||
|
14:52:59.726981 db@janitor removing journal-2 |
||||
|
14:52:59.726981 db@janitor removing manifest-3 |
||||
|
14:52:59.726981 db@open done T·12.9547ms |
||||
|
=============== Aug 21, 2023 (CST) =============== |
||||
|
14:56:16.611447 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
14:56:16.611839 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
14:56:16.611839 db@open opening |
||||
|
14:56:16.612840 journal@recovery F·1 |
||||
|
14:56:16.612840 journal@recovery recovering @7 |
||||
|
14:56:16.613841 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
14:56:16.625130 db@janitor F·3 G·0 |
||||
|
14:56:16.626135 db@open done T·14.2957ms |
||||
|
=============== Aug 21, 2023 (CST) =============== |
||||
|
14:57:47.029243 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
14:57:47.030639 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
14:57:47.030639 db@open opening |
||||
|
14:57:47.031195 journal@recovery F·1 |
||||
|
14:57:47.031195 journal@recovery recovering @9 |
||||
|
14:57:47.032511 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
14:57:47.054330 db@janitor F·3 G·0 |
||||
|
14:57:47.054330 db@open done T·23.6912ms |
||||
|
=============== Aug 21, 2023 (CST) =============== |
||||
|
14:58:46.566800 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
14:58:46.568469 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
14:58:46.568530 db@open opening |
||||
|
14:58:46.568530 journal@recovery F·1 |
||||
|
14:58:46.569108 journal@recovery recovering @11 |
||||
|
14:58:46.570419 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
14:58:46.591262 db@janitor F·3 G·0 |
||||
|
14:58:46.591262 db@open done T·22.732ms |
||||
|
=============== Aug 21, 2023 (CST) =============== |
||||
|
15:04:36.371524 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
15:04:36.372698 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:04:36.373203 db@open opening |
||||
|
15:04:36.373203 journal@recovery F·1 |
||||
|
15:04:36.373203 journal@recovery recovering @13 |
||||
|
15:04:36.374254 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:04:36.387688 db@janitor F·3 G·0 |
||||
|
15:04:36.387688 db@open done T·14.4853ms |
||||
|
=============== Aug 21, 2023 (CST) =============== |
||||
|
15:10:58.082326 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
15:10:58.083646 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:10:58.084249 db@open opening |
||||
|
15:10:58.084308 journal@recovery F·1 |
||||
|
15:10:58.084922 journal@recovery recovering @15 |
||||
|
15:10:58.086316 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:10:58.109799 db@janitor F·3 G·0 |
||||
|
15:10:58.110776 db@open done T·26.527ms |
||||
|
=============== Aug 21, 2023 (CST) =============== |
||||
|
15:14:04.886902 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
15:14:04.888563 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:14:04.888563 db@open opening |
||||
|
15:14:04.888962 journal@recovery F·1 |
||||
|
15:14:04.888962 journal@recovery recovering @17 |
||||
|
15:14:04.891119 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:14:04.912785 db@janitor F·3 G·0 |
||||
|
15:14:04.912785 db@open done T·24.2218ms |
||||
|
=============== Aug 21, 2023 (CST) =============== |
||||
|
15:16:21.109224 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
15:16:21.110277 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:16:21.110383 db@open opening |
||||
|
15:16:21.110661 journal@recovery F·1 |
||||
|
15:16:21.110719 journal@recovery recovering @19 |
||||
|
15:16:21.112368 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:16:21.134643 db@janitor F·3 G·0 |
||||
|
15:16:21.134643 db@open done T·24.2593ms |
||||
|
=============== Aug 21, 2023 (CST) =============== |
||||
|
15:18:51.345723 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
15:18:51.347370 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:18:51.347370 db@open opening |
||||
|
15:18:51.347370 journal@recovery F·1 |
||||
|
15:18:51.347925 journal@recovery recovering @21 |
||||
|
15:18:51.348472 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:18:51.372094 db@janitor F·3 G·0 |
||||
|
15:18:51.372094 db@open done T·24.7237ms |
||||
|
=============== Aug 30, 2023 (CST) =============== |
||||
|
16:54:06.408338 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
16:54:06.416521 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:54:06.416521 db@open opening |
||||
|
16:54:06.417139 journal@recovery F·1 |
||||
|
16:54:06.417394 journal@recovery recovering @23 |
||||
|
16:54:06.420149 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:54:06.431385 db@janitor F·3 G·0 |
||||
|
16:54:06.431385 db@open done T·14.8644ms |
||||
|
=============== Aug 30, 2023 (CST) =============== |
||||
|
16:56:39.964117 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
16:56:39.965918 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:56:39.965918 db@open opening |
||||
|
16:56:39.965918 journal@recovery F·1 |
||||
|
16:56:39.966425 journal@recovery recovering @25 |
||||
|
16:56:39.967561 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:56:39.978156 db@janitor F·3 G·0 |
||||
|
16:56:39.978156 db@open done T·12.2379ms |
||||
|
=============== Aug 31, 2023 (CST) =============== |
||||
|
15:05:04.172988 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
15:05:04.173523 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:05:04.173523 db@open opening |
||||
|
15:05:04.173523 journal@recovery F·1 |
||||
|
15:05:04.174031 journal@recovery recovering @27 |
||||
|
15:05:04.174580 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:05:04.179450 db@janitor F·3 G·0 |
||||
|
15:05:04.179450 db@open done T·5.9268ms |
||||
|
=============== Aug 31, 2023 (CST) =============== |
||||
|
15:10:52.444819 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
15:10:52.445333 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:10:52.445333 db@open opening |
||||
|
15:10:52.445333 journal@recovery F·1 |
||||
|
15:10:52.445333 journal@recovery recovering @29 |
||||
|
15:10:52.446354 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:10:52.448874 db@janitor F·3 G·0 |
||||
|
15:10:52.448874 db@open done T·3.5417ms |
||||
|
=============== Aug 31, 2023 (CST) =============== |
||||
|
15:11:10.493116 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
15:11:10.493116 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:11:10.493116 db@open opening |
||||
|
15:11:10.493116 journal@recovery F·1 |
||||
|
15:11:10.493626 journal@recovery recovering @31 |
||||
|
15:11:10.494135 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:11:10.511153 db@janitor F·3 G·0 |
||||
|
15:11:10.511220 db@open done T·18.1042ms |
||||
|
=============== Aug 31, 2023 (CST) =============== |
||||
|
15:12:49.887964 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
15:12:49.887964 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:12:49.887964 db@open opening |
||||
|
15:12:49.887964 journal@recovery F·1 |
||||
|
15:12:49.887964 journal@recovery recovering @33 |
||||
|
15:12:49.893536 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:12:49.893536 db@janitor F·3 G·0 |
||||
|
15:12:49.893536 db@open done T·5.5722ms |
||||
|
=============== Aug 31, 2023 (CST) =============== |
||||
|
15:13:36.578472 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
15:13:36.578472 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:13:36.578472 db@open opening |
||||
|
15:13:36.578472 journal@recovery F·1 |
||||
|
15:13:36.578472 journal@recovery recovering @35 |
||||
|
15:13:36.579490 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:13:36.582032 db@janitor F·3 G·0 |
||||
|
15:13:36.582535 db@open done T·3.5597ms |
||||
|
=============== Aug 31, 2023 (CST) =============== |
||||
|
15:16:25.348702 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
15:16:25.349242 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:16:25.349242 db@open opening |
||||
|
15:16:25.349242 journal@recovery F·1 |
||||
|
15:16:25.349242 journal@recovery recovering @37 |
||||
|
15:16:25.350328 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:16:25.352997 db@janitor F·3 G·0 |
||||
|
15:16:25.352997 db@open done T·3.7554ms |
||||
|
=============== Aug 31, 2023 (CST) =============== |
||||
|
15:17:14.243290 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
15:17:14.243290 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:17:14.243290 db@open opening |
||||
|
15:17:14.243290 journal@recovery F·1 |
||||
|
15:17:14.243792 journal@recovery recovering @39 |
||||
|
15:17:14.244355 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:17:14.260923 db@janitor F·3 G·0 |
||||
|
15:17:14.260923 db@open done T·17.6332ms |
||||
|
=============== Aug 31, 2023 (CST) =============== |
||||
|
15:21:41.042752 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
15:21:41.042752 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:21:41.042752 db@open opening |
||||
|
15:21:41.042752 journal@recovery F·1 |
||||
|
15:21:41.042752 journal@recovery recovering @41 |
||||
|
15:21:41.042752 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
15:21:41.047328 db@janitor F·3 G·0 |
||||
|
15:21:41.047328 db@open done T·4.576ms |
||||
|
=============== Aug 31, 2023 (CST) =============== |
||||
|
16:23:07.861886 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
16:23:07.861886 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:23:07.861886 db@open opening |
||||
|
16:23:07.861886 journal@recovery F·1 |
||||
|
16:23:07.862437 journal@recovery recovering @43 |
||||
|
16:23:07.862990 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:23:07.870934 db@janitor F·3 G·0 |
||||
|
16:23:07.870934 db@open done T·9.0482ms |
||||
|
=============== Aug 31, 2023 (CST) =============== |
||||
|
16:34:19.039054 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
16:34:19.039054 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:34:19.039054 db@open opening |
||||
|
16:34:19.039054 journal@recovery F·1 |
||||
|
16:34:19.039054 journal@recovery recovering @45 |
||||
|
16:34:19.040044 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:34:19.043044 db@janitor F·3 G·0 |
||||
|
16:34:19.043044 db@open done T·3.9901ms |
||||
|
=============== Aug 31, 2023 (CST) =============== |
||||
|
16:36:38.047579 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
16:36:38.048157 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:36:38.048157 db@open opening |
||||
|
16:36:38.048157 journal@recovery F·1 |
||||
|
16:36:38.048157 journal@recovery recovering @47 |
||||
|
16:36:38.049272 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:36:38.053181 db@janitor F·3 G·0 |
||||
|
16:36:38.053181 db@open done T·5.0235ms |
||||
|
=============== Aug 31, 2023 (CST) =============== |
||||
|
16:38:29.224498 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
16:38:29.225091 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:38:29.225091 db@open opening |
||||
|
16:38:29.225091 journal@recovery F·1 |
||||
|
16:38:29.225091 journal@recovery recovering @49 |
||||
|
16:38:29.225600 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:38:29.228703 db@janitor F·3 G·0 |
||||
|
16:38:29.228703 db@open done T·3.6124ms |
||||
|
=============== Sep 4, 2023 (CST) =============== |
||||
|
10:43:32.620179 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
10:43:32.620774 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
10:43:32.620774 db@open opening |
||||
|
10:43:32.620774 journal@recovery F·1 |
||||
|
10:43:32.620774 journal@recovery recovering @51 |
||||
|
10:43:32.621311 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
10:43:32.624268 db@janitor F·3 G·0 |
||||
|
10:43:32.624268 db@open done T·3.4937ms |
||||
|
=============== Sep 5, 2023 (CST) =============== |
||||
|
09:34:37.210766 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
09:34:37.211280 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
09:34:37.211280 db@open opening |
||||
|
09:34:37.211280 journal@recovery F·1 |
||||
|
09:34:37.211280 journal@recovery recovering @53 |
||||
|
09:34:37.212402 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
09:34:37.218141 db@janitor F·3 G·0 |
||||
|
09:34:37.218141 db@open done T·6.8607ms |
||||
|
=============== Sep 5, 2023 (CST) =============== |
||||
|
09:50:33.927455 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
09:50:33.928479 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
09:50:33.928479 db@open opening |
||||
|
09:50:33.928479 journal@recovery F·1 |
||||
|
09:50:33.929114 journal@recovery recovering @55 |
||||
|
09:50:33.929626 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
09:50:33.932236 db@janitor F·3 G·0 |
||||
|
09:50:33.932236 db@open done T·3.7571ms |
||||
|
=============== Sep 5, 2023 (CST) =============== |
||||
|
16:07:28.243456 log@legend F·NumFile S·FileSize N·Entry C·BadEntry B·BadBlock Ke·KeyError D·DroppedEntry L·Level Q·SeqNum T·TimeElapsed |
||||
|
16:07:28.243547 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:07:28.243547 db@open opening |
||||
|
16:07:28.243547 journal@recovery F·1 |
||||
|
16:07:28.243547 journal@recovery recovering @57 |
||||
|
16:07:28.244783 version@stat F·[1] S·71KiB[71KiB] Sc·[0.25] |
||||
|
16:07:28.247498 db@janitor F·3 G·0 |
||||
|
16:07:28.247498 db@open done T·3.9501ms |
Binary file not shown.
@ -0,0 +1,24 @@ |
|||||
|
server: |
||||
|
http: |
||||
|
addr: 0.0.0.0:8007 |
||||
|
grpc: |
||||
|
addr: 0.0.0.0:9007 |
||||
|
data: |
||||
|
database: |
||||
|
driver: mysql |
||||
|
source: root:root@tcp(127.0.0.1:3306)/test |
||||
|
redis: |
||||
|
addr: 127.0.0.1:6379 |
||||
|
level: |
||||
|
driver: leveldb |
||||
|
aws: |
||||
|
link: |
||||
|
telnet: grpc.shasta.trongrid.io:50051 |
||||
|
point: s3.ap-southeast-1.amazonaws.com |
||||
|
set: |
||||
|
bucket: owneraddresskey |
||||
|
region: ap-southeast-1 |
||||
|
id: AKIAUKMLSNHYAP7EOBDE |
||||
|
secret: OW1EcVvbuJ2ZDW2X8G1m9K5XIN/KlDgwxNoSOHR5 |
||||
|
key: 7167910a-2468-4e9f-a1ef-51a7ebee53ae |
||||
|
token: |
@ -0,0 +1,67 @@ |
|||||
|
module wallet-system |
||||
|
|
||||
|
go 1.18 |
||||
|
|
||||
|
require ( |
||||
|
github.com/aws/aws-sdk-go v1.44.323 |
||||
|
github.com/ethereum/go-ethereum v1.12.2 |
||||
|
github.com/fbsobreira/gotron-sdk v0.0.0-20230714102740-d3204bd08259 |
||||
|
github.com/go-kratos/kratos/v2 v2.6.2 |
||||
|
github.com/google/wire v0.5.0 |
||||
|
github.com/gorilla/handlers v1.5.1 |
||||
|
github.com/mr-tron/base58 v1.2.0 |
||||
|
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 |
||||
|
go.uber.org/automaxprocs v1.5.2 |
||||
|
go.uber.org/zap v1.25.0 |
||||
|
google.golang.org/genproto v0.0.0-20230227214838-9b19f0bdc514 |
||||
|
google.golang.org/grpc v1.53.0 |
||||
|
google.golang.org/protobuf v1.31.0 |
||||
|
gopkg.in/yaml.v2 v2.4.0 |
||||
|
) |
||||
|
|
||||
|
require ( |
||||
|
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect |
||||
|
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect |
||||
|
github.com/deckarep/golang-set v1.8.0 // indirect |
||||
|
github.com/deckarep/golang-set/v2 v2.1.0 // indirect |
||||
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect |
||||
|
github.com/felixge/httpsnoop v1.0.1 // indirect |
||||
|
github.com/fsnotify/fsnotify v1.6.0 // indirect |
||||
|
github.com/go-kratos/aegis v0.2.0 // indirect |
||||
|
github.com/go-logr/logr v1.2.3 // indirect |
||||
|
github.com/go-logr/stdr v1.2.2 // indirect |
||||
|
github.com/go-ole/go-ole v1.2.6 // indirect |
||||
|
github.com/go-playground/assert/v2 v2.2.0 // indirect |
||||
|
github.com/go-playground/form/v4 v4.2.0 // indirect |
||||
|
github.com/go-stack/stack v1.8.1 // indirect |
||||
|
github.com/golang/protobuf v1.5.3 // indirect |
||||
|
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect |
||||
|
github.com/google/uuid v1.3.1 // indirect |
||||
|
github.com/gorilla/mux v1.8.0 // indirect |
||||
|
github.com/gorilla/websocket v1.4.2 // indirect |
||||
|
github.com/holiman/uint256 v1.2.3 // indirect |
||||
|
github.com/jmespath/go-jmespath v0.4.0 // indirect |
||||
|
github.com/mitchellh/go-homedir v1.1.0 // indirect |
||||
|
github.com/pborman/uuid v1.2.1 // indirect |
||||
|
github.com/pkg/errors v0.9.1 // indirect |
||||
|
github.com/rjeczalik/notify v0.9.3 // indirect |
||||
|
github.com/rogpeppe/go-internal v1.11.0 // indirect |
||||
|
github.com/shengdoushi/base58 v1.0.0 // indirect |
||||
|
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect |
||||
|
github.com/stretchr/testify v1.8.4 // indirect |
||||
|
github.com/tklauser/go-sysconf v0.3.11 // indirect |
||||
|
github.com/tklauser/numcpus v0.6.0 // indirect |
||||
|
github.com/tyler-smith/go-bip39 v1.1.0 // indirect |
||||
|
go.opentelemetry.io/otel v1.7.0 // indirect |
||||
|
go.opentelemetry.io/otel/trace v1.7.0 // indirect |
||||
|
go.uber.org/multierr v1.10.0 // indirect |
||||
|
golang.org/x/crypto v0.12.0 // indirect |
||||
|
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad // indirect |
||||
|
golang.org/x/net v0.14.0 // indirect |
||||
|
golang.org/x/sync v0.3.0 // indirect |
||||
|
golang.org/x/sys v0.11.0 // indirect |
||||
|
golang.org/x/text v0.12.0 // indirect |
||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect |
||||
|
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect |
||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect |
||||
|
) |
@ -0,0 +1,272 @@ |
|||||
|
github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= |
||||
|
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= |
||||
|
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= |
||||
|
github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= |
||||
|
github.com/aws/aws-sdk-go v1.44.323 h1:97/dn93DWrN1VfhAWQ2tV+xuE6oO/LO9rSsEsuC4PLU= |
||||
|
github.com/aws/aws-sdk-go v1.44.323/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= |
||||
|
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= |
||||
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= |
||||
|
github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo= |
||||
|
github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= |
||||
|
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= |
||||
|
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= |
||||
|
github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g= |
||||
|
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= |
||||
|
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= |
||||
|
github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b h1:ACGZRIr7HsgBKHsueQ1yM4WaVaXh21ynwqsF8M8tXhA= |
||||
|
github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= |
||||
|
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= |
||||
|
github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 h1:ytcWPaNPhNoGMWEhDvS3zToKcDpRsLuRolQJBVGdozk= |
||||
|
github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= |
||||
|
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= |
||||
|
github.com/consensys/gnark-crypto v0.10.0 h1:zRh22SR7o4K35SoNqouS9J/TKHTyU2QWaj5ldehyXtA= |
||||
|
github.com/crate-crypto/go-kzg-4844 v0.3.0 h1:UBlWE0CgyFqqzTI+IFyCzA7A3Zw4iip6uzRv5NIXG0A= |
||||
|
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/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= |
||||
|
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= |
||||
|
github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= |
||||
|
github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= |
||||
|
github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= |
||||
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= |
||||
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= |
||||
|
github.com/envoyproxy/go-control-plane v0.10.3 h1:xdCVXxEe0Y3FQith+0cj2irwZudqGYvecuLB1HtdexY= |
||||
|
github.com/envoyproxy/protoc-gen-validate v0.9.1 h1:PS7VIOgmSVhWUEeZwTe7z7zouA22Cr590PzXKbZHOVY= |
||||
|
github.com/ethereum/c-kzg-4844 v0.3.1 h1:sR65+68+WdnMKxseNWxSJuAv2tsUrihTpVBTfM/U5Zg= |
||||
|
github.com/ethereum/go-ethereum v1.12.2 h1:eGHJ4ij7oyVqUQn48LBz3B7pvQ8sV0wGJiIE6gDq/6Y= |
||||
|
github.com/ethereum/go-ethereum v1.12.2/go.mod h1:1cRAEV+rp/xX0zraSCBnu9Py3HQ+geRMj3HdR+k0wfI= |
||||
|
github.com/fbsobreira/gotron-sdk v0.0.0-20230714102740-d3204bd08259 h1:HAcHwvPamxsjiPkU6TtFsHbYYdauhJ1BnDt631nPZvI= |
||||
|
github.com/fbsobreira/gotron-sdk v0.0.0-20230714102740-d3204bd08259/go.mod h1:Sj3nZuicr/3RoekvShKtFRwmYVDSOE/X1gLez8f+7ps= |
||||
|
github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= |
||||
|
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= |
||||
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= |
||||
|
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= |
||||
|
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= |
||||
|
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= |
||||
|
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= |
||||
|
github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= |
||||
|
github.com/go-kratos/aegis v0.2.0 h1:dObzCDWn3XVjUkgxyBp6ZeWtx/do0DPZ7LY3yNSJLUQ= |
||||
|
github.com/go-kratos/aegis v0.2.0/go.mod h1:v0R2m73WgEEYB3XYu6aE2WcMwsZkJ/Rzuf5eVccm7bI= |
||||
|
github.com/go-kratos/kratos/v2 v2.6.2 h1:9ar3d6tbci4GhqUsar18MB20hgFDOV70buDkWGUrX3M= |
||||
|
github.com/go-kratos/kratos/v2 v2.6.2/go.mod h1:xTeAeI9iYBP8MauISfxmRGSmKdDTLRQ3rbarKYmt6P4= |
||||
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= |
||||
|
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= |
||||
|
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= |
||||
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= |
||||
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= |
||||
|
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= |
||||
|
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= |
||||
|
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= |
||||
|
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/form/v4 v4.2.0 h1:N1wh+Goz61e6w66vo8vJkQt+uwZSoLz50kZPJWR8eic= |
||||
|
github.com/go-playground/form/v4 v4.2.0/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U= |
||||
|
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= |
||||
|
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= |
||||
|
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= |
||||
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= |
||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= |
||||
|
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= |
||||
|
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= |
||||
|
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= |
||||
|
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= |
||||
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= |
||||
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= |
||||
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= |
||||
|
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= |
||||
|
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= |
||||
|
github.com/golang/snappy v0.0.4/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.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= |
||||
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= |
||||
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= |
||||
|
github.com/google/go-cmp v0.4.0/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.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= |
||||
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= |
||||
|
github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= |
||||
|
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
||||
|
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= |
||||
|
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= |
||||
|
github.com/google/wire v0.5.0 h1:I7ELFeVBr3yfPIcc8+MWvrjk+3VjbcSzoXm3JVa+jD8= |
||||
|
github.com/google/wire v0.5.0/go.mod h1:ngWDr9Qvq3yZA10YrxfyGELY/AFWGVpy9c1LTRi1EoU= |
||||
|
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= |
||||
|
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= |
||||
|
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= |
||||
|
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= |
||||
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= |
||||
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= |
||||
|
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= |
||||
|
github.com/holiman/uint256 v1.2.3 h1:K8UWO1HUJpRMXBxbmaY1Y8IAMZC/RsKB+ArEnnK4l5o= |
||||
|
github.com/holiman/uint256 v1.2.3/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= |
||||
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= |
||||
|
github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= |
||||
|
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= |
||||
|
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= |
||||
|
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= |
||||
|
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= |
||||
|
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= |
||||
|
github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= |
||||
|
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= |
||||
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= |
||||
|
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/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= |
||||
|
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= |
||||
|
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= |
||||
|
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= |
||||
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= |
||||
|
github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= |
||||
|
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= |
||||
|
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= |
||||
|
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= |
||||
|
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= |
||||
|
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= |
||||
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= |
||||
|
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= |
||||
|
github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= |
||||
|
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= |
||||
|
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= |
||||
|
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= |
||||
|
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= |
||||
|
github.com/pborman/uuid v1.2.1 h1:+ZZIw58t/ozdjRaXh/3awHfmWRbzYxJoAdNJxe/3pvw= |
||||
|
github.com/pborman/uuid v1.2.1/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= |
||||
|
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/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= |
||||
|
github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= |
||||
|
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= |
||||
|
github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= |
||||
|
github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= |
||||
|
github.com/rjeczalik/notify v0.9.3 h1:6rJAzHTGKXGj76sbRgDiDcYj/HniypXmSJo1SWakZeY= |
||||
|
github.com/rjeczalik/notify v0.9.3/go.mod h1:gF3zSOrafR9DQEWSE8TjfI9NkooDxbyT4UgRGKZA0lc= |
||||
|
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= |
||||
|
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= |
||||
|
github.com/shengdoushi/base58 v1.0.0 h1:tGe4o6TmdXFJWoI31VoSWvuaKxf0Px3gqa3sUWhAxBs= |
||||
|
github.com/shengdoushi/base58 v1.0.0/go.mod h1:m5uIILfzcKMw6238iWAhP4l3s5+uXyF3+bJKUNhAL9I= |
||||
|
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= |
||||
|
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= |
||||
|
github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= |
||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= |
||||
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= |
||||
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= |
||||
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= |
||||
|
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= |
||||
|
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/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM= |
||||
|
github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI= |
||||
|
github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms= |
||||
|
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4= |
||||
|
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/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= |
||||
|
go.opentelemetry.io/otel v1.7.0 h1:Z2lA3Tdch0iDcrhJXDIlC94XE+bxok1F9B+4Lz/lGsM= |
||||
|
go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= |
||||
|
go.opentelemetry.io/otel/sdk v1.7.0 h1:4OmStpcKVOfvDOgCt7UriAPtKolwIhxpnSNI/yK+1B0= |
||||
|
go.opentelemetry.io/otel/trace v1.7.0 h1:O37Iogk1lEkMRXewVtZ1BBTVn5JEp8GrJvP92bJqC6o= |
||||
|
go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU= |
||||
|
go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME= |
||||
|
go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0= |
||||
|
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= |
||||
|
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= |
||||
|
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= |
||||
|
go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= |
||||
|
go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= |
||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= |
||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= |
||||
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= |
||||
|
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= |
||||
|
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= |
||||
|
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad h1:g0bG7Z4uG+OgH2QDODnjp6ggkk1bJDsINcuWmJN1iJU= |
||||
|
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= |
||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= |
||||
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
||||
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= |
||||
|
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-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= |
||||
|
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= |
||||
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= |
||||
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= |
||||
|
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= |
||||
|
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= |
||||
|
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= |
||||
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
||||
|
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= |
||||
|
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= |
||||
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
||||
|
golang.org/x/sys v0.0.0-20180926160741-c2ed4eda69e7/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
||||
|
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-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
|
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
|
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
|
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
|
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
|
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/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-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/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.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||
|
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= |
||||
|
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= |
||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= |
||||
|
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= |
||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
||||
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= |
||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |
||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= |
||||
|
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= |
||||
|
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= |
||||
|
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= |
||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
||||
|
golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= |
||||
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= |
||||
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= |
||||
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/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= |
||||
|
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df h1:5Pf6pFKu98ODmgnpvkJ3kFUOQGGLIzLIkbzUHp47618= |
||||
|
google.golang.org/genproto v0.0.0-20230227214838-9b19f0bdc514 h1:rtNKfB++wz5mtDY2t5C8TXlU5y52ojSu7tZo0z7u8eQ= |
||||
|
google.golang.org/genproto v0.0.0-20230227214838-9b19f0bdc514/go.mod h1:TvhZT5f700eVlTNwND1xoEZQeWTB2RY/65kplwl/bFA= |
||||
|
google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= |
||||
|
google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= |
||||
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= |
||||
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= |
||||
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= |
||||
|
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= |
||||
|
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= |
||||
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= |
||||
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= |
||||
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= |
||||
|
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= |
||||
|
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= |
||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/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/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= |
||||
|
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= |
||||
|
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= |
||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= |
||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= |
||||
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
||||
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
||||
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
||||
|
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= |
||||
|
rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= |
@ -0,0 +1 @@ |
|||||
|
# Biz |
@ -0,0 +1,8 @@ |
|||||
|
package biz |
||||
|
|
||||
|
import ( |
||||
|
"github.com/google/wire" |
||||
|
) |
||||
|
|
||||
|
// ProviderSet is biz providers.
|
||||
|
var ProviderSet = wire.NewSet(NewWalletInfo) |
@ -0,0 +1,164 @@ |
|||||
|
package biz |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"github.com/go-kratos/kratos/v2/log" |
||||
|
) |
||||
|
|
||||
|
// Wallet
|
||||
|
// @Description:
|
||||
|
type Wallet struct { |
||||
|
From string `json:"from,omitempty"` // 转账地址
|
||||
|
To string `json:"to,omitempty"` // 接收地址
|
||||
|
Amount uint32 `json:"amount,omitempty"` // 转账金额
|
||||
|
Contract string `json:"contract,omitempty"` // 合约地址(Trc20签名传入,其他签名不用传)
|
||||
|
TrcCheck string `json:"trc_check,omitempty"` // 签名钱包标识
|
||||
|
TokenId string `json:"token_id,omitempty"` // Trc10签名传入,其他签名不用传
|
||||
|
FeeLimit uint32 `json:"fee_limit,omitempty"` // 限制交易费
|
||||
|
} |
||||
|
|
||||
|
// WalletRepo
|
||||
|
// @Description:
|
||||
|
type WalletRepo interface { |
||||
|
GenerateAddress(context.Context, string, uint32) ([]string, error) |
||||
|
SignatureTrc20Grpc(context.Context, *Wallet) (bool, string, error) |
||||
|
WalletApprove(ctx context.Context, wallet *Wallet) (bool, []byte, error) |
||||
|
GetAllAddress(context.Context) ([]string, error) |
||||
|
GetAllAddressAndPrivateKey(context.Context) (map[string][]byte, error) |
||||
|
GetPrivateKeyByAddress(context.Context, string) (string, error) |
||||
|
DeleteAddress(context.Context) error |
||||
|
} |
||||
|
|
||||
|
// WalletInfo
|
||||
|
// @Description:
|
||||
|
type WalletInfo struct { |
||||
|
repo WalletRepo |
||||
|
log *log.Helper |
||||
|
} |
||||
|
|
||||
|
// NewWalletInfo new a Wallet Info.
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param repo
|
||||
|
// @param logger
|
||||
|
// @return *WalletInfo
|
||||
|
func NewWalletInfo(repo WalletRepo, logger log.Logger) *WalletInfo { |
||||
|
return &WalletInfo{repo: repo, log: log.NewHelper(logger)} |
||||
|
} |
||||
|
|
||||
|
// GenerateAddress .
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver w
|
||||
|
// @param ctx
|
||||
|
// @param wallet
|
||||
|
// @param number
|
||||
|
// @return []string
|
||||
|
// @return error
|
||||
|
func (w *WalletInfo) GenerateAddress(ctx context.Context, wallet string, number uint32) ([]string, error) { |
||||
|
data, err := w.repo.GenerateAddress(ctx, wallet, number) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
return data, nil |
||||
|
} |
||||
|
|
||||
|
// SignatureTrc20Grpc .
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver w
|
||||
|
// @param ctx
|
||||
|
// @param wallet
|
||||
|
// @return bool
|
||||
|
// @return string
|
||||
|
// @return error
|
||||
|
func (w *WalletInfo) SignatureTrc20Grpc(ctx context.Context, wallet *Wallet) (bool, string, error) { |
||||
|
check, data, err := w.repo.SignatureTrc20Grpc(ctx, wallet) |
||||
|
if err != nil { |
||||
|
return false, "", err |
||||
|
} |
||||
|
|
||||
|
return check, data, nil |
||||
|
} |
||||
|
|
||||
|
// WalletApprove .
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver w
|
||||
|
// @param ctx
|
||||
|
// @param wallet
|
||||
|
// @return bool
|
||||
|
// @return []byte
|
||||
|
// @return error
|
||||
|
func (w *WalletInfo) WalletApprove(ctx context.Context, wallet *Wallet) (bool, []byte, error) { |
||||
|
check, tx, err := w.WalletApprove(ctx, wallet) |
||||
|
if err != nil { |
||||
|
return check, []byte{}, nil |
||||
|
} |
||||
|
|
||||
|
return check, tx, nil |
||||
|
} |
||||
|
|
||||
|
// GetAllAddress .
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver w
|
||||
|
// @param ctx
|
||||
|
// @return []string
|
||||
|
// @return error
|
||||
|
func (w *WalletInfo) GetAllAddress(ctx context.Context) ([]string, error) { |
||||
|
data, err := w.repo.GetAllAddress(ctx) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
return data, nil |
||||
|
} |
||||
|
|
||||
|
// GetAllAddressAndPrivateKey .
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver w
|
||||
|
// @param ctx
|
||||
|
// @return map[string][]byte
|
||||
|
// @return error
|
||||
|
func (w *WalletInfo) GetAllAddressAndPrivateKey(ctx context.Context) (map[string][]byte, error) { |
||||
|
data, err := w.repo.GetAllAddressAndPrivateKey(ctx) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
return data, nil |
||||
|
} |
||||
|
|
||||
|
// GetPrivateKeyByAddress .
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver w
|
||||
|
// @param ctx
|
||||
|
// @param address
|
||||
|
// @return string
|
||||
|
// @return error
|
||||
|
func (w *WalletInfo) GetPrivateKeyByAddress(ctx context.Context, address string) (string, error) { |
||||
|
data, err := w.repo.GetPrivateKeyByAddress(ctx, address) |
||||
|
if err != nil { |
||||
|
return "", err |
||||
|
} |
||||
|
|
||||
|
return data, nil |
||||
|
} |
||||
|
|
||||
|
// DeleteAddress .
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver w
|
||||
|
// @param ctx
|
||||
|
// @return error
|
||||
|
func (w *WalletInfo) DeleteAddress(ctx context.Context) error { |
||||
|
if err := w.repo.DeleteAddress(ctx); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
return nil |
||||
|
} |
@ -0,0 +1,937 @@ |
|||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
|
// versions:
|
||||
|
// protoc-gen-go v1.34.2
|
||||
|
// protoc v5.27.1
|
||||
|
// source: conf/conf.proto
|
||||
|
|
||||
|
package conf |
||||
|
|
||||
|
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 Bootstrap struct { |
||||
|
state protoimpl.MessageState |
||||
|
sizeCache protoimpl.SizeCache |
||||
|
unknownFields protoimpl.UnknownFields |
||||
|
|
||||
|
Server *Server `protobuf:"bytes,1,opt,name=server,proto3" json:"server,omitempty"` |
||||
|
Data *Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` |
||||
|
Aws *Aws `protobuf:"bytes,3,opt,name=aws,proto3" json:"aws,omitempty"` |
||||
|
} |
||||
|
|
||||
|
func (x *Bootstrap) Reset() { |
||||
|
*x = Bootstrap{} |
||||
|
if protoimpl.UnsafeEnabled { |
||||
|
mi := &file_conf_conf_proto_msgTypes[0] |
||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
||||
|
ms.StoreMessageInfo(mi) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func (x *Bootstrap) String() string { |
||||
|
return protoimpl.X.MessageStringOf(x) |
||||
|
} |
||||
|
|
||||
|
func (*Bootstrap) ProtoMessage() {} |
||||
|
|
||||
|
func (x *Bootstrap) ProtoReflect() protoreflect.Message { |
||||
|
mi := &file_conf_conf_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 Bootstrap.ProtoReflect.Descriptor instead.
|
||||
|
func (*Bootstrap) Descriptor() ([]byte, []int) { |
||||
|
return file_conf_conf_proto_rawDescGZIP(), []int{0} |
||||
|
} |
||||
|
|
||||
|
func (x *Bootstrap) GetServer() *Server { |
||||
|
if x != nil { |
||||
|
return x.Server |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
func (x *Bootstrap) GetData() *Data { |
||||
|
if x != nil { |
||||
|
return x.Data |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
func (x *Bootstrap) GetAws() *Aws { |
||||
|
if x != nil { |
||||
|
return x.Aws |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
type Server struct { |
||||
|
state protoimpl.MessageState |
||||
|
sizeCache protoimpl.SizeCache |
||||
|
unknownFields protoimpl.UnknownFields |
||||
|
|
||||
|
Http *Server_HTTP `protobuf:"bytes,1,opt,name=http,proto3" json:"http,omitempty"` |
||||
|
Grpc *Server_GRPC `protobuf:"bytes,2,opt,name=grpc,proto3" json:"grpc,omitempty"` |
||||
|
} |
||||
|
|
||||
|
func (x *Server) Reset() { |
||||
|
*x = Server{} |
||||
|
if protoimpl.UnsafeEnabled { |
||||
|
mi := &file_conf_conf_proto_msgTypes[1] |
||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
||||
|
ms.StoreMessageInfo(mi) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func (x *Server) String() string { |
||||
|
return protoimpl.X.MessageStringOf(x) |
||||
|
} |
||||
|
|
||||
|
func (*Server) ProtoMessage() {} |
||||
|
|
||||
|
func (x *Server) ProtoReflect() protoreflect.Message { |
||||
|
mi := &file_conf_conf_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 Server.ProtoReflect.Descriptor instead.
|
||||
|
func (*Server) Descriptor() ([]byte, []int) { |
||||
|
return file_conf_conf_proto_rawDescGZIP(), []int{1} |
||||
|
} |
||||
|
|
||||
|
func (x *Server) GetHttp() *Server_HTTP { |
||||
|
if x != nil { |
||||
|
return x.Http |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
func (x *Server) GetGrpc() *Server_GRPC { |
||||
|
if x != nil { |
||||
|
return x.Grpc |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
type Data struct { |
||||
|
state protoimpl.MessageState |
||||
|
sizeCache protoimpl.SizeCache |
||||
|
unknownFields protoimpl.UnknownFields |
||||
|
|
||||
|
Database *Data_Database `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"` |
||||
|
Redis *Data_Redis `protobuf:"bytes,2,opt,name=redis,proto3" json:"redis,omitempty"` |
||||
|
Level *Data_Level `protobuf:"bytes,3,opt,name=level,proto3" json:"level,omitempty"` |
||||
|
} |
||||
|
|
||||
|
func (x *Data) Reset() { |
||||
|
*x = Data{} |
||||
|
if protoimpl.UnsafeEnabled { |
||||
|
mi := &file_conf_conf_proto_msgTypes[2] |
||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
||||
|
ms.StoreMessageInfo(mi) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func (x *Data) String() string { |
||||
|
return protoimpl.X.MessageStringOf(x) |
||||
|
} |
||||
|
|
||||
|
func (*Data) ProtoMessage() {} |
||||
|
|
||||
|
func (x *Data) ProtoReflect() protoreflect.Message { |
||||
|
mi := &file_conf_conf_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 Data.ProtoReflect.Descriptor instead.
|
||||
|
func (*Data) Descriptor() ([]byte, []int) { |
||||
|
return file_conf_conf_proto_rawDescGZIP(), []int{2} |
||||
|
} |
||||
|
|
||||
|
func (x *Data) GetDatabase() *Data_Database { |
||||
|
if x != nil { |
||||
|
return x.Database |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
func (x *Data) GetRedis() *Data_Redis { |
||||
|
if x != nil { |
||||
|
return x.Redis |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
func (x *Data) GetLevel() *Data_Level { |
||||
|
if x != nil { |
||||
|
return x.Level |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
type Aws struct { |
||||
|
state protoimpl.MessageState |
||||
|
sizeCache protoimpl.SizeCache |
||||
|
unknownFields protoimpl.UnknownFields |
||||
|
|
||||
|
Link *Aws_Link `protobuf:"bytes,1,opt,name=link,proto3" json:"link,omitempty"` |
||||
|
Set *Aws_Set `protobuf:"bytes,2,opt,name=set,proto3" json:"set,omitempty"` |
||||
|
} |
||||
|
|
||||
|
func (x *Aws) Reset() { |
||||
|
*x = Aws{} |
||||
|
if protoimpl.UnsafeEnabled { |
||||
|
mi := &file_conf_conf_proto_msgTypes[3] |
||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
||||
|
ms.StoreMessageInfo(mi) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func (x *Aws) String() string { |
||||
|
return protoimpl.X.MessageStringOf(x) |
||||
|
} |
||||
|
|
||||
|
func (*Aws) ProtoMessage() {} |
||||
|
|
||||
|
func (x *Aws) ProtoReflect() protoreflect.Message { |
||||
|
mi := &file_conf_conf_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 Aws.ProtoReflect.Descriptor instead.
|
||||
|
func (*Aws) Descriptor() ([]byte, []int) { |
||||
|
return file_conf_conf_proto_rawDescGZIP(), []int{3} |
||||
|
} |
||||
|
|
||||
|
func (x *Aws) GetLink() *Aws_Link { |
||||
|
if x != nil { |
||||
|
return x.Link |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
func (x *Aws) GetSet() *Aws_Set { |
||||
|
if x != nil { |
||||
|
return x.Set |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
type Server_HTTP struct { |
||||
|
state protoimpl.MessageState |
||||
|
sizeCache protoimpl.SizeCache |
||||
|
unknownFields protoimpl.UnknownFields |
||||
|
|
||||
|
Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"` |
||||
|
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` |
||||
|
} |
||||
|
|
||||
|
func (x *Server_HTTP) Reset() { |
||||
|
*x = Server_HTTP{} |
||||
|
if protoimpl.UnsafeEnabled { |
||||
|
mi := &file_conf_conf_proto_msgTypes[4] |
||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
||||
|
ms.StoreMessageInfo(mi) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func (x *Server_HTTP) String() string { |
||||
|
return protoimpl.X.MessageStringOf(x) |
||||
|
} |
||||
|
|
||||
|
func (*Server_HTTP) ProtoMessage() {} |
||||
|
|
||||
|
func (x *Server_HTTP) ProtoReflect() protoreflect.Message { |
||||
|
mi := &file_conf_conf_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 Server_HTTP.ProtoReflect.Descriptor instead.
|
||||
|
func (*Server_HTTP) Descriptor() ([]byte, []int) { |
||||
|
return file_conf_conf_proto_rawDescGZIP(), []int{1, 0} |
||||
|
} |
||||
|
|
||||
|
func (x *Server_HTTP) GetNetwork() string { |
||||
|
if x != nil { |
||||
|
return x.Network |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
func (x *Server_HTTP) GetAddr() string { |
||||
|
if x != nil { |
||||
|
return x.Addr |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
type Server_GRPC struct { |
||||
|
state protoimpl.MessageState |
||||
|
sizeCache protoimpl.SizeCache |
||||
|
unknownFields protoimpl.UnknownFields |
||||
|
|
||||
|
Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"` |
||||
|
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` |
||||
|
} |
||||
|
|
||||
|
func (x *Server_GRPC) Reset() { |
||||
|
*x = Server_GRPC{} |
||||
|
if protoimpl.UnsafeEnabled { |
||||
|
mi := &file_conf_conf_proto_msgTypes[5] |
||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
||||
|
ms.StoreMessageInfo(mi) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func (x *Server_GRPC) String() string { |
||||
|
return protoimpl.X.MessageStringOf(x) |
||||
|
} |
||||
|
|
||||
|
func (*Server_GRPC) ProtoMessage() {} |
||||
|
|
||||
|
func (x *Server_GRPC) ProtoReflect() protoreflect.Message { |
||||
|
mi := &file_conf_conf_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 Server_GRPC.ProtoReflect.Descriptor instead.
|
||||
|
func (*Server_GRPC) Descriptor() ([]byte, []int) { |
||||
|
return file_conf_conf_proto_rawDescGZIP(), []int{1, 1} |
||||
|
} |
||||
|
|
||||
|
func (x *Server_GRPC) GetNetwork() string { |
||||
|
if x != nil { |
||||
|
return x.Network |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
func (x *Server_GRPC) GetAddr() string { |
||||
|
if x != nil { |
||||
|
return x.Addr |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
type Data_Database struct { |
||||
|
state protoimpl.MessageState |
||||
|
sizeCache protoimpl.SizeCache |
||||
|
unknownFields protoimpl.UnknownFields |
||||
|
|
||||
|
Driver string `protobuf:"bytes,1,opt,name=driver,proto3" json:"driver,omitempty"` |
||||
|
Source string `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"` |
||||
|
} |
||||
|
|
||||
|
func (x *Data_Database) Reset() { |
||||
|
*x = Data_Database{} |
||||
|
if protoimpl.UnsafeEnabled { |
||||
|
mi := &file_conf_conf_proto_msgTypes[6] |
||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
||||
|
ms.StoreMessageInfo(mi) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func (x *Data_Database) String() string { |
||||
|
return protoimpl.X.MessageStringOf(x) |
||||
|
} |
||||
|
|
||||
|
func (*Data_Database) ProtoMessage() {} |
||||
|
|
||||
|
func (x *Data_Database) ProtoReflect() protoreflect.Message { |
||||
|
mi := &file_conf_conf_proto_msgTypes[6] |
||||
|
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 Data_Database.ProtoReflect.Descriptor instead.
|
||||
|
func (*Data_Database) Descriptor() ([]byte, []int) { |
||||
|
return file_conf_conf_proto_rawDescGZIP(), []int{2, 0} |
||||
|
} |
||||
|
|
||||
|
func (x *Data_Database) GetDriver() string { |
||||
|
if x != nil { |
||||
|
return x.Driver |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
func (x *Data_Database) GetSource() string { |
||||
|
if x != nil { |
||||
|
return x.Source |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
type Data_Redis struct { |
||||
|
state protoimpl.MessageState |
||||
|
sizeCache protoimpl.SizeCache |
||||
|
unknownFields protoimpl.UnknownFields |
||||
|
|
||||
|
Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"` |
||||
|
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` |
||||
|
} |
||||
|
|
||||
|
func (x *Data_Redis) Reset() { |
||||
|
*x = Data_Redis{} |
||||
|
if protoimpl.UnsafeEnabled { |
||||
|
mi := &file_conf_conf_proto_msgTypes[7] |
||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
||||
|
ms.StoreMessageInfo(mi) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func (x *Data_Redis) String() string { |
||||
|
return protoimpl.X.MessageStringOf(x) |
||||
|
} |
||||
|
|
||||
|
func (*Data_Redis) ProtoMessage() {} |
||||
|
|
||||
|
func (x *Data_Redis) ProtoReflect() protoreflect.Message { |
||||
|
mi := &file_conf_conf_proto_msgTypes[7] |
||||
|
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 Data_Redis.ProtoReflect.Descriptor instead.
|
||||
|
func (*Data_Redis) Descriptor() ([]byte, []int) { |
||||
|
return file_conf_conf_proto_rawDescGZIP(), []int{2, 1} |
||||
|
} |
||||
|
|
||||
|
func (x *Data_Redis) GetNetwork() string { |
||||
|
if x != nil { |
||||
|
return x.Network |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
func (x *Data_Redis) GetAddr() string { |
||||
|
if x != nil { |
||||
|
return x.Addr |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
type Data_Level struct { |
||||
|
state protoimpl.MessageState |
||||
|
sizeCache protoimpl.SizeCache |
||||
|
unknownFields protoimpl.UnknownFields |
||||
|
|
||||
|
Driver string `protobuf:"bytes,1,opt,name=driver,proto3" json:"driver,omitempty"` |
||||
|
} |
||||
|
|
||||
|
func (x *Data_Level) Reset() { |
||||
|
*x = Data_Level{} |
||||
|
if protoimpl.UnsafeEnabled { |
||||
|
mi := &file_conf_conf_proto_msgTypes[8] |
||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
||||
|
ms.StoreMessageInfo(mi) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func (x *Data_Level) String() string { |
||||
|
return protoimpl.X.MessageStringOf(x) |
||||
|
} |
||||
|
|
||||
|
func (*Data_Level) ProtoMessage() {} |
||||
|
|
||||
|
func (x *Data_Level) ProtoReflect() protoreflect.Message { |
||||
|
mi := &file_conf_conf_proto_msgTypes[8] |
||||
|
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 Data_Level.ProtoReflect.Descriptor instead.
|
||||
|
func (*Data_Level) Descriptor() ([]byte, []int) { |
||||
|
return file_conf_conf_proto_rawDescGZIP(), []int{2, 2} |
||||
|
} |
||||
|
|
||||
|
func (x *Data_Level) GetDriver() string { |
||||
|
if x != nil { |
||||
|
return x.Driver |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
type Aws_Link struct { |
||||
|
state protoimpl.MessageState |
||||
|
sizeCache protoimpl.SizeCache |
||||
|
unknownFields protoimpl.UnknownFields |
||||
|
|
||||
|
Telnet string `protobuf:"bytes,1,opt,name=telnet,proto3" json:"telnet,omitempty"` |
||||
|
Point string `protobuf:"bytes,2,opt,name=point,proto3" json:"point,omitempty"` |
||||
|
} |
||||
|
|
||||
|
func (x *Aws_Link) Reset() { |
||||
|
*x = Aws_Link{} |
||||
|
if protoimpl.UnsafeEnabled { |
||||
|
mi := &file_conf_conf_proto_msgTypes[9] |
||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
||||
|
ms.StoreMessageInfo(mi) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func (x *Aws_Link) String() string { |
||||
|
return protoimpl.X.MessageStringOf(x) |
||||
|
} |
||||
|
|
||||
|
func (*Aws_Link) ProtoMessage() {} |
||||
|
|
||||
|
func (x *Aws_Link) ProtoReflect() protoreflect.Message { |
||||
|
mi := &file_conf_conf_proto_msgTypes[9] |
||||
|
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 Aws_Link.ProtoReflect.Descriptor instead.
|
||||
|
func (*Aws_Link) Descriptor() ([]byte, []int) { |
||||
|
return file_conf_conf_proto_rawDescGZIP(), []int{3, 0} |
||||
|
} |
||||
|
|
||||
|
func (x *Aws_Link) GetTelnet() string { |
||||
|
if x != nil { |
||||
|
return x.Telnet |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
func (x *Aws_Link) GetPoint() string { |
||||
|
if x != nil { |
||||
|
return x.Point |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
type Aws_Set struct { |
||||
|
state protoimpl.MessageState |
||||
|
sizeCache protoimpl.SizeCache |
||||
|
unknownFields protoimpl.UnknownFields |
||||
|
|
||||
|
Region string `protobuf:"bytes,1,opt,name=region,proto3" json:"region,omitempty"` |
||||
|
Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` |
||||
|
Secret string `protobuf:"bytes,3,opt,name=secret,proto3" json:"secret,omitempty"` |
||||
|
Key string `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty"` |
||||
|
Token string `protobuf:"bytes,5,opt,name=token,proto3" json:"token,omitempty"` |
||||
|
Bucket string `protobuf:"bytes,6,opt,name=bucket,proto3" json:"bucket,omitempty"` |
||||
|
} |
||||
|
|
||||
|
func (x *Aws_Set) Reset() { |
||||
|
*x = Aws_Set{} |
||||
|
if protoimpl.UnsafeEnabled { |
||||
|
mi := &file_conf_conf_proto_msgTypes[10] |
||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) |
||||
|
ms.StoreMessageInfo(mi) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func (x *Aws_Set) String() string { |
||||
|
return protoimpl.X.MessageStringOf(x) |
||||
|
} |
||||
|
|
||||
|
func (*Aws_Set) ProtoMessage() {} |
||||
|
|
||||
|
func (x *Aws_Set) ProtoReflect() protoreflect.Message { |
||||
|
mi := &file_conf_conf_proto_msgTypes[10] |
||||
|
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 Aws_Set.ProtoReflect.Descriptor instead.
|
||||
|
func (*Aws_Set) Descriptor() ([]byte, []int) { |
||||
|
return file_conf_conf_proto_rawDescGZIP(), []int{3, 1} |
||||
|
} |
||||
|
|
||||
|
func (x *Aws_Set) GetRegion() string { |
||||
|
if x != nil { |
||||
|
return x.Region |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
func (x *Aws_Set) GetId() string { |
||||
|
if x != nil { |
||||
|
return x.Id |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
func (x *Aws_Set) GetSecret() string { |
||||
|
if x != nil { |
||||
|
return x.Secret |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
func (x *Aws_Set) GetKey() string { |
||||
|
if x != nil { |
||||
|
return x.Key |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
func (x *Aws_Set) GetToken() string { |
||||
|
if x != nil { |
||||
|
return x.Token |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
func (x *Aws_Set) GetBucket() string { |
||||
|
if x != nil { |
||||
|
return x.Bucket |
||||
|
} |
||||
|
return "" |
||||
|
} |
||||
|
|
||||
|
var File_conf_conf_proto protoreflect.FileDescriptor |
||||
|
|
||||
|
var file_conf_conf_proto_rawDesc = []byte{ |
||||
|
0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x70, 0x72, 0x6f, 0x74, |
||||
|
0x6f, 0x12, 0x0a, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x22, 0x80, 0x01, |
||||
|
0x0a, 0x09, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x12, 0x2a, 0x0a, 0x06, 0x73, |
||||
|
0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, |
||||
|
0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, |
||||
|
0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x24, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, |
||||
|
0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, |
||||
|
0x70, 0x69, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x21, 0x0a, |
||||
|
0x03, 0x61, 0x77, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6b, 0x72, 0x61, |
||||
|
0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x77, 0x73, 0x52, 0x03, 0x61, 0x77, 0x73, |
||||
|
0x22, 0xce, 0x01, 0x0a, 0x06, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x04, 0x68, |
||||
|
0x74, 0x74, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6b, 0x72, 0x61, 0x74, |
||||
|
0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x54, |
||||
|
0x54, 0x50, 0x52, 0x04, 0x68, 0x74, 0x74, 0x70, 0x12, 0x2b, 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63, |
||||
|
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, |
||||
|
0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x47, 0x52, 0x50, 0x43, 0x52, |
||||
|
0x04, 0x67, 0x72, 0x70, 0x63, 0x1a, 0x34, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x12, 0x18, 0x0a, |
||||
|
0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, |
||||
|
0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, 0x18, |
||||
|
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x64, 0x64, 0x72, 0x1a, 0x34, 0x0a, 0x04, 0x47, |
||||
|
0x52, 0x50, 0x43, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, |
||||
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x12, 0x0a, |
||||
|
0x04, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x64, 0x64, |
||||
|
0x72, 0x22, 0xad, 0x02, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x35, 0x0a, 0x08, 0x64, 0x61, |
||||
|
0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6b, |
||||
|
0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x44, |
||||
|
0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, |
||||
|
0x65, 0x12, 0x2c, 0x0a, 0x05, 0x72, 0x65, 0x64, 0x69, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, |
||||
|
0x32, 0x16, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x61, |
||||
|
0x74, 0x61, 0x2e, 0x52, 0x65, 0x64, 0x69, 0x73, 0x52, 0x05, 0x72, 0x65, 0x64, 0x69, 0x73, 0x12, |
||||
|
0x2c, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, |
||||
|
0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x61, 0x74, 0x61, |
||||
|
0x2e, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x1a, 0x3a, 0x0a, |
||||
|
0x08, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x72, 0x69, |
||||
|
0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, |
||||
|
0x72, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, |
||||
|
0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x1a, 0x35, 0x0a, 0x05, 0x52, 0x65, 0x64, |
||||
|
0x69, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, |
||||
|
0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x12, 0x0a, 0x04, |
||||
|
0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x64, 0x64, 0x72, |
||||
|
0x1a, 0x1f, 0x0a, 0x05, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x72, 0x69, |
||||
|
0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, |
||||
|
0x72, 0x22, 0x94, 0x02, 0x0a, 0x03, 0x41, 0x77, 0x73, 0x12, 0x28, 0x0a, 0x04, 0x6c, 0x69, 0x6e, |
||||
|
0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, |
||||
|
0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x77, 0x73, 0x2e, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x04, 0x6c, |
||||
|
0x69, 0x6e, 0x6b, 0x12, 0x25, 0x0a, 0x03, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, |
||||
|
0x32, 0x13, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x77, |
||||
|
0x73, 0x2e, 0x53, 0x65, 0x74, 0x52, 0x03, 0x73, 0x65, 0x74, 0x1a, 0x34, 0x0a, 0x04, 0x4c, 0x69, |
||||
|
0x6e, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x65, 0x6c, 0x6e, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, |
||||
|
0x28, 0x09, 0x52, 0x06, 0x74, 0x65, 0x6c, 0x6e, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x6f, |
||||
|
0x69, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x6f, 0x69, 0x6e, 0x74, |
||||
|
0x1a, 0x85, 0x01, 0x0a, 0x03, 0x53, 0x65, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x67, 0x69, |
||||
|
0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, |
||||
|
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, |
||||
|
0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, |
||||
|
0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, |
||||
|
0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, |
||||
|
0x6b, 0x65, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, |
||||
|
0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, |
||||
|
0x52, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x42, 0x22, 0x5a, 0x20, 0x77, 0x61, 0x6c, 0x6c, |
||||
|
0x65, 0x74, 0x2d, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, |
||||
|
0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x3b, 0x63, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, |
||||
|
0x6f, 0x74, 0x6f, 0x33, |
||||
|
} |
||||
|
|
||||
|
var ( |
||||
|
file_conf_conf_proto_rawDescOnce sync.Once |
||||
|
file_conf_conf_proto_rawDescData = file_conf_conf_proto_rawDesc |
||||
|
) |
||||
|
|
||||
|
func file_conf_conf_proto_rawDescGZIP() []byte { |
||||
|
file_conf_conf_proto_rawDescOnce.Do(func() { |
||||
|
file_conf_conf_proto_rawDescData = protoimpl.X.CompressGZIP(file_conf_conf_proto_rawDescData) |
||||
|
}) |
||||
|
return file_conf_conf_proto_rawDescData |
||||
|
} |
||||
|
|
||||
|
var file_conf_conf_proto_msgTypes = make([]protoimpl.MessageInfo, 11) |
||||
|
var file_conf_conf_proto_goTypes = []any{ |
||||
|
(*Bootstrap)(nil), // 0: kratos.api.Bootstrap
|
||||
|
(*Server)(nil), // 1: kratos.api.Server
|
||||
|
(*Data)(nil), // 2: kratos.api.Data
|
||||
|
(*Aws)(nil), // 3: kratos.api.Aws
|
||||
|
(*Server_HTTP)(nil), // 4: kratos.api.Server.HTTP
|
||||
|
(*Server_GRPC)(nil), // 5: kratos.api.Server.GRPC
|
||||
|
(*Data_Database)(nil), // 6: kratos.api.Data.Database
|
||||
|
(*Data_Redis)(nil), // 7: kratos.api.Data.Redis
|
||||
|
(*Data_Level)(nil), // 8: kratos.api.Data.Level
|
||||
|
(*Aws_Link)(nil), // 9: kratos.api.Aws.Link
|
||||
|
(*Aws_Set)(nil), // 10: kratos.api.Aws.Set
|
||||
|
} |
||||
|
var file_conf_conf_proto_depIdxs = []int32{ |
||||
|
1, // 0: kratos.api.Bootstrap.server:type_name -> kratos.api.Server
|
||||
|
2, // 1: kratos.api.Bootstrap.data:type_name -> kratos.api.Data
|
||||
|
3, // 2: kratos.api.Bootstrap.aws:type_name -> kratos.api.Aws
|
||||
|
4, // 3: kratos.api.Server.http:type_name -> kratos.api.Server.HTTP
|
||||
|
5, // 4: kratos.api.Server.grpc:type_name -> kratos.api.Server.GRPC
|
||||
|
6, // 5: kratos.api.Data.database:type_name -> kratos.api.Data.Database
|
||||
|
7, // 6: kratos.api.Data.redis:type_name -> kratos.api.Data.Redis
|
||||
|
8, // 7: kratos.api.Data.level:type_name -> kratos.api.Data.Level
|
||||
|
9, // 8: kratos.api.Aws.link:type_name -> kratos.api.Aws.Link
|
||||
|
10, // 9: kratos.api.Aws.set:type_name -> kratos.api.Aws.Set
|
||||
|
10, // [10:10] is the sub-list for method output_type
|
||||
|
10, // [10:10] is the sub-list for method input_type
|
||||
|
10, // [10:10] is the sub-list for extension type_name
|
||||
|
10, // [10:10] is the sub-list for extension extendee
|
||||
|
0, // [0:10] is the sub-list for field type_name
|
||||
|
} |
||||
|
|
||||
|
func init() { file_conf_conf_proto_init() } |
||||
|
func file_conf_conf_proto_init() { |
||||
|
if File_conf_conf_proto != nil { |
||||
|
return |
||||
|
} |
||||
|
if !protoimpl.UnsafeEnabled { |
||||
|
file_conf_conf_proto_msgTypes[0].Exporter = func(v any, i int) any { |
||||
|
switch v := v.(*Bootstrap); i { |
||||
|
case 0: |
||||
|
return &v.state |
||||
|
case 1: |
||||
|
return &v.sizeCache |
||||
|
case 2: |
||||
|
return &v.unknownFields |
||||
|
default: |
||||
|
return nil |
||||
|
} |
||||
|
} |
||||
|
file_conf_conf_proto_msgTypes[1].Exporter = func(v any, i int) any { |
||||
|
switch v := v.(*Server); i { |
||||
|
case 0: |
||||
|
return &v.state |
||||
|
case 1: |
||||
|
return &v.sizeCache |
||||
|
case 2: |
||||
|
return &v.unknownFields |
||||
|
default: |
||||
|
return nil |
||||
|
} |
||||
|
} |
||||
|
file_conf_conf_proto_msgTypes[2].Exporter = func(v any, i int) any { |
||||
|
switch v := v.(*Data); i { |
||||
|
case 0: |
||||
|
return &v.state |
||||
|
case 1: |
||||
|
return &v.sizeCache |
||||
|
case 2: |
||||
|
return &v.unknownFields |
||||
|
default: |
||||
|
return nil |
||||
|
} |
||||
|
} |
||||
|
file_conf_conf_proto_msgTypes[3].Exporter = func(v any, i int) any { |
||||
|
switch v := v.(*Aws); i { |
||||
|
case 0: |
||||
|
return &v.state |
||||
|
case 1: |
||||
|
return &v.sizeCache |
||||
|
case 2: |
||||
|
return &v.unknownFields |
||||
|
default: |
||||
|
return nil |
||||
|
} |
||||
|
} |
||||
|
file_conf_conf_proto_msgTypes[4].Exporter = func(v any, i int) any { |
||||
|
switch v := v.(*Server_HTTP); i { |
||||
|
case 0: |
||||
|
return &v.state |
||||
|
case 1: |
||||
|
return &v.sizeCache |
||||
|
case 2: |
||||
|
return &v.unknownFields |
||||
|
default: |
||||
|
return nil |
||||
|
} |
||||
|
} |
||||
|
file_conf_conf_proto_msgTypes[5].Exporter = func(v any, i int) any { |
||||
|
switch v := v.(*Server_GRPC); i { |
||||
|
case 0: |
||||
|
return &v.state |
||||
|
case 1: |
||||
|
return &v.sizeCache |
||||
|
case 2: |
||||
|
return &v.unknownFields |
||||
|
default: |
||||
|
return nil |
||||
|
} |
||||
|
} |
||||
|
file_conf_conf_proto_msgTypes[6].Exporter = func(v any, i int) any { |
||||
|
switch v := v.(*Data_Database); i { |
||||
|
case 0: |
||||
|
return &v.state |
||||
|
case 1: |
||||
|
return &v.sizeCache |
||||
|
case 2: |
||||
|
return &v.unknownFields |
||||
|
default: |
||||
|
return nil |
||||
|
} |
||||
|
} |
||||
|
file_conf_conf_proto_msgTypes[7].Exporter = func(v any, i int) any { |
||||
|
switch v := v.(*Data_Redis); i { |
||||
|
case 0: |
||||
|
return &v.state |
||||
|
case 1: |
||||
|
return &v.sizeCache |
||||
|
case 2: |
||||
|
return &v.unknownFields |
||||
|
default: |
||||
|
return nil |
||||
|
} |
||||
|
} |
||||
|
file_conf_conf_proto_msgTypes[8].Exporter = func(v any, i int) any { |
||||
|
switch v := v.(*Data_Level); i { |
||||
|
case 0: |
||||
|
return &v.state |
||||
|
case 1: |
||||
|
return &v.sizeCache |
||||
|
case 2: |
||||
|
return &v.unknownFields |
||||
|
default: |
||||
|
return nil |
||||
|
} |
||||
|
} |
||||
|
file_conf_conf_proto_msgTypes[9].Exporter = func(v any, i int) any { |
||||
|
switch v := v.(*Aws_Link); i { |
||||
|
case 0: |
||||
|
return &v.state |
||||
|
case 1: |
||||
|
return &v.sizeCache |
||||
|
case 2: |
||||
|
return &v.unknownFields |
||||
|
default: |
||||
|
return nil |
||||
|
} |
||||
|
} |
||||
|
file_conf_conf_proto_msgTypes[10].Exporter = func(v any, i int) any { |
||||
|
switch v := v.(*Aws_Set); 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_conf_conf_proto_rawDesc, |
||||
|
NumEnums: 0, |
||||
|
NumMessages: 11, |
||||
|
NumExtensions: 0, |
||||
|
NumServices: 0, |
||||
|
}, |
||||
|
GoTypes: file_conf_conf_proto_goTypes, |
||||
|
DependencyIndexes: file_conf_conf_proto_depIdxs, |
||||
|
MessageInfos: file_conf_conf_proto_msgTypes, |
||||
|
}.Build() |
||||
|
File_conf_conf_proto = out.File |
||||
|
file_conf_conf_proto_rawDesc = nil |
||||
|
file_conf_conf_proto_goTypes = nil |
||||
|
file_conf_conf_proto_depIdxs = nil |
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
syntax = "proto3"; |
||||
|
package kratos.api; |
||||
|
|
||||
|
option go_package = "wallet-system/internal/conf;conf"; |
||||
|
|
||||
|
message Bootstrap { |
||||
|
Server server = 1; |
||||
|
Data data = 2; |
||||
|
Aws aws = 3; |
||||
|
} |
||||
|
|
||||
|
message Server { |
||||
|
message HTTP { |
||||
|
string network = 1; |
||||
|
string addr = 2; |
||||
|
} |
||||
|
message GRPC { |
||||
|
string network = 1; |
||||
|
string addr = 2; |
||||
|
} |
||||
|
HTTP http = 1; |
||||
|
GRPC grpc = 2; |
||||
|
} |
||||
|
|
||||
|
message Data { |
||||
|
message Database { |
||||
|
string driver = 1; |
||||
|
string source = 2; |
||||
|
} |
||||
|
message Redis { |
||||
|
string network = 1; |
||||
|
string addr = 2; |
||||
|
} |
||||
|
message Level{ |
||||
|
string driver =1; |
||||
|
} |
||||
|
Database database = 1; |
||||
|
Redis redis = 2; |
||||
|
Level level=3; |
||||
|
} |
||||
|
|
||||
|
message Aws{ |
||||
|
message Link{ |
||||
|
string telnet =1; |
||||
|
string point= 2; |
||||
|
} |
||||
|
message Set{ |
||||
|
string region =1; |
||||
|
string id = 2; |
||||
|
string secret =3; |
||||
|
string key =4; |
||||
|
string token =5; |
||||
|
string bucket=6; |
||||
|
} |
||||
|
Link link = 1; |
||||
|
Set set = 2; |
||||
|
} |
@ -0,0 +1,2 @@ |
|||||
|
# Data |
||||
|
|
@ -0,0 +1,20 @@ |
|||||
|
package kms |
||||
|
|
||||
|
import ( |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/pkg/aws/kms" |
||||
|
) |
||||
|
|
||||
|
// NewClientKms
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param c
|
||||
|
// @return *kms.KmsClient
|
||||
|
func NewClientKms(c *conf.Aws) *kms.KmsClient { |
||||
|
kmsClient, err := kms.NewKms(c) |
||||
|
if err != nil { |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
return kmsClient |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package kms |
||||
|
|
||||
|
import ( |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/pkg/aws/kms" |
||||
|
) |
||||
|
|
||||
|
func TestNewClientKms(t *testing.T) { |
||||
|
type args struct { |
||||
|
c *conf.Aws |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *kms.KmsClient |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := NewClientKms(tt.args.c); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("NewClientKms() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
package s3 |
||||
|
|
||||
|
import ( |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/pkg/aws/s3" |
||||
|
) |
||||
|
|
||||
|
// NewClientS3
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param c
|
||||
|
// @return *s3.S3Client
|
||||
|
func NewClientS3(c *conf.Aws) *s3.S3Client { |
||||
|
s3Client, err := s3.NewS3(c) |
||||
|
if err != nil { |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
return s3Client |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package s3 |
||||
|
|
||||
|
import ( |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/pkg/aws/s3" |
||||
|
) |
||||
|
|
||||
|
func TestNewClientS3(t *testing.T) { |
||||
|
type args struct { |
||||
|
c *conf.Aws |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *s3.S3Client |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := NewClientS3(tt.args.c); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("NewClientS3() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,69 @@ |
|||||
|
package data |
||||
|
|
||||
|
import ( |
||||
|
"github.com/go-kratos/kratos/v2/log" |
||||
|
"github.com/google/wire" |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/data/tron" |
||||
|
"wallet-system/internal/pkg/aws/kms" |
||||
|
"wallet-system/internal/pkg/aws/s3" |
||||
|
"wallet-system/internal/pkg/leveldb" |
||||
|
"wallet-system/internal/pkg/wallet/tron/grpc" |
||||
|
|
||||
|
kmsClient "wallet-system/internal/data/aws/kms" |
||||
|
s3Client "wallet-system/internal/data/aws/s3" |
||||
|
levelClient "wallet-system/internal/data/leveldb" |
||||
|
) |
||||
|
|
||||
|
// ProviderSet is data providers.
|
||||
|
var ProviderSet = wire.NewSet( |
||||
|
NewData, |
||||
|
NewWalletRepo, |
||||
|
s3Client.NewClientS3, |
||||
|
kmsClient.NewClientKms, |
||||
|
levelClient.NewLevelDB, |
||||
|
tron.NewTronGrpc) |
||||
|
|
||||
|
// Data
|
||||
|
// @Description:
|
||||
|
type Data struct { |
||||
|
aws *conf.Aws |
||||
|
s3C *s3.S3Client |
||||
|
kmsC *kms.KmsClient |
||||
|
levelC *leveldb.LevelDB |
||||
|
grpcT *grpc.Client |
||||
|
} |
||||
|
|
||||
|
// NewData
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param c
|
||||
|
// @param aws
|
||||
|
// @param s3C
|
||||
|
// @param kmsC
|
||||
|
// @param levelC
|
||||
|
// @param grpcT
|
||||
|
// @param logger
|
||||
|
// @return *Data
|
||||
|
// @return func()
|
||||
|
// @return error
|
||||
|
func NewData( |
||||
|
c *conf.Data, |
||||
|
aws *conf.Aws, |
||||
|
s3C *s3.S3Client, |
||||
|
kmsC *kms.KmsClient, |
||||
|
levelC *leveldb.LevelDB, |
||||
|
grpcT *grpc.Client, |
||||
|
logger log.Logger) (*Data, func(), error) { |
||||
|
cleanup := func() { |
||||
|
log.NewHelper(logger).Info("closing the data resources") |
||||
|
} |
||||
|
return &Data{ |
||||
|
aws: aws, |
||||
|
s3C: s3C, |
||||
|
kmsC: kmsC, |
||||
|
levelC: levelC, |
||||
|
grpcT: grpcT}, |
||||
|
cleanup, |
||||
|
nil |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
package eth |
@ -0,0 +1,20 @@ |
|||||
|
package leveldb |
||||
|
|
||||
|
import ( |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/pkg/leveldb" |
||||
|
) |
||||
|
|
||||
|
// NewLevelDB
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param c
|
||||
|
// @return *leveldb.LevelDB
|
||||
|
func NewLevelDB(c *conf.Data) *leveldb.LevelDB { |
||||
|
db, err := leveldb.NewLevelDB(c.Level.Driver) |
||||
|
if err != nil { |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
return db |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package leveldb |
||||
|
|
||||
|
import ( |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/pkg/leveldb" |
||||
|
) |
||||
|
|
||||
|
func TestNewLevelDB(t *testing.T) { |
||||
|
type args struct { |
||||
|
c *conf.Data |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *leveldb.LevelDB |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := NewLevelDB(tt.args.c); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("NewLevelDB() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
package tron |
||||
|
|
||||
|
import ( |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/pkg/wallet/tron/grpc" |
||||
|
) |
||||
|
|
||||
|
// NewTronGrpc
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param c
|
||||
|
// @return *grpc.Client
|
||||
|
func NewTronGrpc(c *conf.Aws) *grpc.Client { |
||||
|
grpcClient, err := grpc.NewClient(c.Link.Telnet) |
||||
|
if err != nil { |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
return grpcClient |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package tron |
||||
|
|
||||
|
import ( |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/pkg/wallet/tron/grpc" |
||||
|
) |
||||
|
|
||||
|
func TestNewTronGrpc(t *testing.T) { |
||||
|
type args struct { |
||||
|
c *conf.Aws |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *grpc.Client |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := NewTronGrpc(tt.args.c); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("NewTronGrpc() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,255 @@ |
|||||
|
package data |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"encoding/json" |
||||
|
"errors" |
||||
|
"github.com/fbsobreira/gotron-sdk/pkg/address" |
||||
|
"github.com/fbsobreira/gotron-sdk/pkg/proto/api" |
||||
|
"github.com/go-kratos/kratos/v2/log" |
||||
|
"math/big" |
||||
|
"wallet-system/internal/biz" |
||||
|
"wallet-system/internal/pkg/logging/applogger" |
||||
|
"wallet-system/internal/pkg/wallet/tron" |
||||
|
"wallet-system/internal/pkg/wallet/tron/sign" |
||||
|
) |
||||
|
|
||||
|
// walletRepo
|
||||
|
// @Description:
|
||||
|
type walletRepo struct { |
||||
|
data *Data |
||||
|
|
||||
|
log *log.Helper |
||||
|
} |
||||
|
|
||||
|
// NewWalletRepo
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param data
|
||||
|
// @param logger
|
||||
|
// @return biz.WalletRepo
|
||||
|
func NewWalletRepo(data *Data, logger log.Logger) biz.WalletRepo { |
||||
|
return &walletRepo{ |
||||
|
data: data, |
||||
|
log: log.NewHelper(logger), |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
GenerateAddress Private key encryption management |
||||
|
1、KMS encryption |
||||
|
2、Leveldb storage |
||||
|
3、S3 storage |
||||
|
*/ |
||||
|
func (r *walletRepo) GenerateAddress(ctx context.Context, wallet string, number uint32) ([]string, error) { |
||||
|
var addressList []string |
||||
|
for i := 1; i <= int(number); i++ { |
||||
|
walletAddress, privateKey, err := tron.TronWalletAddress() |
||||
|
if err != nil { |
||||
|
applogger.Error("Error generating wallet address and private key:%v", err) |
||||
|
return []string{}, err |
||||
|
} |
||||
|
|
||||
|
encryptByte, err := r.data.kmsC.Encrypt(r.data.aws.Set.Key, privateKey) |
||||
|
if err != nil { |
||||
|
applogger.Error("GenerateAddress.Encrypt err:%v", err) |
||||
|
return nil, err |
||||
|
} |
||||
|
applogger.Debug("AWS-KMS encrypted data:%v", encryptByte) |
||||
|
|
||||
|
if err = r.data.s3C.Storage(encryptByte, r.data.aws.Set.Bucket, walletAddress); err != nil { |
||||
|
applogger.Error("GenerateAddress.storage err:%v", err) |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
if err = r.data.levelC.WriteDB(ctx, walletAddress, encryptByte); err != nil { |
||||
|
applogger.Error("Error writing wallet cache address:%v", err) |
||||
|
return []string{}, err |
||||
|
} |
||||
|
|
||||
|
addressList = append(addressList, walletAddress) |
||||
|
} |
||||
|
|
||||
|
return addressList, nil |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
SignatureTrc20Grpc 钱包签名转账上链 |
||||
|
1、Determine signature type |
||||
|
2、Obtain wallet private key |
||||
|
3、Decrypting private keys |
||||
|
4、signature |
||||
|
5、Upper chain |
||||
|
6、Return status and transaction hash |
||||
|
*/ |
||||
|
func (r *walletRepo) SignatureTrc20Grpc(ctx context.Context, wallet *biz.Wallet) (bool, string, error) { |
||||
|
// 获取钱包私钥地址
|
||||
|
private, err := r.data.levelC.ReadPrivateKeyByAddress(ctx, wallet.From) |
||||
|
if err != nil { |
||||
|
return false, "", err |
||||
|
} |
||||
|
|
||||
|
// 解密私钥
|
||||
|
pky, err := r.data.kmsC.Decrypt(private) |
||||
|
if err != nil { |
||||
|
return false, "", err |
||||
|
} |
||||
|
privateKey := string(pky) |
||||
|
|
||||
|
// 发送者地址
|
||||
|
from, err := address.Base58ToAddress(wallet.From) |
||||
|
if err != nil { |
||||
|
return false, "", err |
||||
|
} |
||||
|
|
||||
|
// 接受者地址
|
||||
|
to, err := address.Base58ToAddress(wallet.To) |
||||
|
if err != nil { |
||||
|
return false, "", err |
||||
|
} |
||||
|
|
||||
|
var contract address.Address // 转账合约地址
|
||||
|
var tx *api.TransactionExtention // 创建交易信息
|
||||
|
|
||||
|
switch wallet.TrcCheck { |
||||
|
case tron.Trx: |
||||
|
tx, err = r.data.grpcT.Transfer(from.String(), to.String(), tron.AmountInt(int(wallet.Amount))) |
||||
|
if err != nil { |
||||
|
applogger.Error("SignatureTrc20Grpc.Transfer err:%v", err) |
||||
|
return false, "", err |
||||
|
} |
||||
|
|
||||
|
return r.SignTransactionAndBroadcastTransaction(ctx, tx, privateKey) |
||||
|
case tron.Trc20: |
||||
|
contract, err = address.Base58ToAddress(wallet.Contract) |
||||
|
if err != nil { |
||||
|
return false, "", err |
||||
|
} |
||||
|
|
||||
|
tx, err = r.data.grpcT.TransferTrc20(from.String(), to.String(), contract.String(), tron.AmountBigInt(int(wallet.Amount)), tron.FeeLimitInt(int(wallet.FeeLimit))) |
||||
|
if err != nil { |
||||
|
applogger.Error("SignatureTrc20Grpc.TransferTrc20 err:%v", err) |
||||
|
return false, "", err |
||||
|
} |
||||
|
|
||||
|
return r.SignTransactionAndBroadcastTransaction(ctx, tx, privateKey) |
||||
|
default: |
||||
|
return false, "", errors.New("Please enter the correct signature type.") |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/* |
||||
|
WalletApprove |
||||
|
1、Determine signature type |
||||
|
2、Obtain wallet private key |
||||
|
3、Decrypting private keys |
||||
|
4、signature |
||||
|
5、Upper chain |
||||
|
6、Return status and transaction hash |
||||
|
*/ |
||||
|
func (r *walletRepo) WalletApprove(ctx context.Context, wallet *biz.Wallet) (bool, []byte, error) { |
||||
|
tx, err := r.data.grpcT.TRC20Approve(wallet.From, wallet.To, wallet.Contract, big.NewInt(int64(wallet.Amount)), tron.FeeLimitInt(int(wallet.FeeLimit))) |
||||
|
if err != nil { |
||||
|
applogger.Error("TRC20Approve err:%v", err) |
||||
|
return false, []byte{}, err |
||||
|
} |
||||
|
|
||||
|
jms, err := json.Marshal(tx) |
||||
|
if err != nil { |
||||
|
return false, []byte{}, err |
||||
|
} |
||||
|
|
||||
|
return false, jms, nil |
||||
|
} |
||||
|
|
||||
|
// GetAllAddress
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver r
|
||||
|
// @param ctx
|
||||
|
// @return []string
|
||||
|
// @return error
|
||||
|
func (r *walletRepo) GetAllAddress(ctx context.Context) ([]string, error) { |
||||
|
listAddress, err := r.data.levelC.ReadWalletAddrList(ctx) |
||||
|
if err != nil { |
||||
|
return []string{}, err |
||||
|
} |
||||
|
return listAddress, nil |
||||
|
} |
||||
|
|
||||
|
// GetAllAddressAndPrivateKey
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver r
|
||||
|
// @param ctx
|
||||
|
// @return map[string][]byte
|
||||
|
// @return error
|
||||
|
func (r *walletRepo) GetAllAddressAndPrivateKey(ctx context.Context) (map[string][]byte, error) { |
||||
|
listAddress, err := r.data.levelC.ReadWalletAddressPrivateKeyList(ctx) |
||||
|
if err != nil { |
||||
|
return map[string][]byte{}, err |
||||
|
} |
||||
|
|
||||
|
return listAddress, nil |
||||
|
} |
||||
|
|
||||
|
// GetPrivateKeyByAddress
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver r
|
||||
|
// @param ctx
|
||||
|
// @param address
|
||||
|
// @return []byte
|
||||
|
// @return error
|
||||
|
func (r *walletRepo) GetPrivateKeyByAddress(ctx context.Context, address string) (string, error) { |
||||
|
private, err := r.data.levelC.ReadPrivateKeyByAddress(ctx, address) |
||||
|
if err != nil { |
||||
|
return "", err |
||||
|
} |
||||
|
|
||||
|
pky, err := r.data.kmsC.Decrypt(private) |
||||
|
if err != nil { |
||||
|
return "", err |
||||
|
} |
||||
|
privateKey := string(pky) |
||||
|
|
||||
|
return privateKey, nil |
||||
|
} |
||||
|
|
||||
|
// DeleteAddress
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver r
|
||||
|
// @param ctx
|
||||
|
// @return error
|
||||
|
func (r *walletRepo) DeleteAddress(ctx context.Context) error { |
||||
|
if err := r.data.levelC.DeleteAllByKey(ctx); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
// SignTransactionAndBroadcastTransaction
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver r
|
||||
|
// @param ctx
|
||||
|
// @param tx
|
||||
|
// @param privateKey
|
||||
|
// @return bool
|
||||
|
// @return string
|
||||
|
// @return error
|
||||
|
func (r *walletRepo) SignTransactionAndBroadcastTransaction(ctx context.Context, tx *api.TransactionExtention, privateKey string) (bool, string, error) { |
||||
|
signTx, err := sign.SignTransaction(tx.Transaction, privateKey) |
||||
|
if err != nil { |
||||
|
applogger.Error("SignTransactionAndBroadcastTransaction err:%v", err) |
||||
|
return false, "", err |
||||
|
} |
||||
|
|
||||
|
if err := r.data.grpcT.BroadcastTransaction(signTx); err != nil { |
||||
|
return false, "", err |
||||
|
} |
||||
|
|
||||
|
return true, tron.Encode(tx.GetTxid()), nil |
||||
|
} |
@ -0,0 +1,324 @@ |
|||||
|
package data |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"github.com/fbsobreira/gotron-sdk/pkg/proto/api" |
||||
|
"github.com/go-kratos/kratos/v2/log" |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
"wallet-system/internal/biz" |
||||
|
) |
||||
|
|
||||
|
func TestNewWalletRepo(t *testing.T) { |
||||
|
type args struct { |
||||
|
data *Data |
||||
|
logger log.Logger |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want biz.WalletRepo |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := NewWalletRepo(tt.args.data, tt.args.logger); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("NewWalletRepo() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func Test_walletRepo_DeleteAddress(t *testing.T) { |
||||
|
type fields struct { |
||||
|
data *Data |
||||
|
log *log.Helper |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
r := &walletRepo{ |
||||
|
data: tt.fields.data, |
||||
|
log: tt.fields.log, |
||||
|
} |
||||
|
if err := r.DeleteAddress(tt.args.ctx); (err != nil) != tt.wantErr { |
||||
|
t.Errorf("DeleteAddress() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func Test_walletRepo_GenerateAddress(t *testing.T) { |
||||
|
type fields struct { |
||||
|
data *Data |
||||
|
log *log.Helper |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
wallet string |
||||
|
number uint32 |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want []string |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
r := &walletRepo{ |
||||
|
data: tt.fields.data, |
||||
|
log: tt.fields.log, |
||||
|
} |
||||
|
got, err := r.GenerateAddress(tt.args.ctx, tt.args.wallet, tt.args.number) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("GenerateAddress() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("GenerateAddress() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func Test_walletRepo_GetAllAddress(t *testing.T) { |
||||
|
type fields struct { |
||||
|
data *Data |
||||
|
log *log.Helper |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want []string |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
r := &walletRepo{ |
||||
|
data: tt.fields.data, |
||||
|
log: tt.fields.log, |
||||
|
} |
||||
|
got, err := r.GetAllAddress(tt.args.ctx) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("GetAllAddress() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("GetAllAddress() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func Test_walletRepo_GetAllAddressAndPrivateKey(t *testing.T) { |
||||
|
type fields struct { |
||||
|
data *Data |
||||
|
log *log.Helper |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want map[string][]byte |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
r := &walletRepo{ |
||||
|
data: tt.fields.data, |
||||
|
log: tt.fields.log, |
||||
|
} |
||||
|
got, err := r.GetAllAddressAndPrivateKey(tt.args.ctx) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("GetAllAddressAndPrivateKey() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("GetAllAddressAndPrivateKey() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func Test_walletRepo_GetPrivateKeyByAddress(t *testing.T) { |
||||
|
type fields struct { |
||||
|
data *Data |
||||
|
log *log.Helper |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
address string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want []byte |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
r := &walletRepo{ |
||||
|
data: tt.fields.data, |
||||
|
log: tt.fields.log, |
||||
|
} |
||||
|
got, err := r.GetPrivateKeyByAddress(tt.args.ctx, tt.args.address) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("GetPrivateKeyByAddress() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("GetPrivateKeyByAddress() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func Test_walletRepo_SignTransactionAndBroadcastTransaction(t *testing.T) { |
||||
|
type fields struct { |
||||
|
data *Data |
||||
|
log *log.Helper |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
tx *api.TransactionExtention |
||||
|
privateKey string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want bool |
||||
|
want1 string |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
r := &walletRepo{ |
||||
|
data: tt.fields.data, |
||||
|
log: tt.fields.log, |
||||
|
} |
||||
|
got, got1, err := r.SignTransactionAndBroadcastTransaction(tt.args.ctx, tt.args.tx, tt.args.privateKey) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("SignTransactionAndBroadcastTransaction() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if got != tt.want { |
||||
|
t.Errorf("SignTransactionAndBroadcastTransaction() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
if got1 != tt.want1 { |
||||
|
t.Errorf("SignTransactionAndBroadcastTransaction() got1 = %v, want %v", got1, tt.want1) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func Test_walletRepo_SignatureTrc20Grpc(t *testing.T) { |
||||
|
type fields struct { |
||||
|
data *Data |
||||
|
log *log.Helper |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
wallet *biz.Wallet |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want bool |
||||
|
want1 string |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
r := &walletRepo{ |
||||
|
data: tt.fields.data, |
||||
|
log: tt.fields.log, |
||||
|
} |
||||
|
got, got1, err := r.SignatureTrc20Grpc(tt.args.ctx, tt.args.wallet) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("SignatureTrc20Grpc() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if got != tt.want { |
||||
|
t.Errorf("SignatureTrc20Grpc() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
if got1 != tt.want1 { |
||||
|
t.Errorf("SignatureTrc20Grpc() got1 = %v, want %v", got1, tt.want1) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func Test_walletRepo_WalletApprove(t *testing.T) { |
||||
|
type fields struct { |
||||
|
data *Data |
||||
|
log *log.Helper |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
wallet *biz.Wallet |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want bool |
||||
|
want1 string |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
r := &walletRepo{ |
||||
|
data: tt.fields.data, |
||||
|
log: tt.fields.log, |
||||
|
} |
||||
|
got, got1, err := r.WalletApprove(tt.args.ctx, tt.args.wallet) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("WalletApprove() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if got != tt.want { |
||||
|
t.Errorf("WalletApprove() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
if got1 != tt.want1 { |
||||
|
t.Errorf("WalletApprove() got1 = %v, want %v", got1, tt.want1) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package kms |
||||
|
|
||||
|
import ( |
||||
|
"github.com/aws/aws-sdk-go/service/kms" |
||||
|
"wallet-system/internal/pkg/logging/applogger" |
||||
|
) |
||||
|
|
||||
|
// Decrypt
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver k
|
||||
|
// @param cipherText
|
||||
|
// @return []byte
|
||||
|
// @return error
|
||||
|
func (k *KmsClient) Decrypt(cipherText []byte) ([]byte, error) { |
||||
|
decryptResult, err := k.KmsC.Decrypt(&kms.DecryptInput{ |
||||
|
CiphertextBlob: cipherText, |
||||
|
}) |
||||
|
if err != nil { |
||||
|
applogger.Error("Decrypting errors using Kms:%v", err) |
||||
|
return []byte{}, err |
||||
|
} |
||||
|
return decryptResult.Plaintext, nil |
||||
|
} |
@ -0,0 +1,40 @@ |
|||||
|
package kms |
||||
|
|
||||
|
import ( |
||||
|
"github.com/aws/aws-sdk-go/service/kms" |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
) |
||||
|
|
||||
|
func TestKmsClient_Decrypt(t *testing.T) { |
||||
|
type fields struct { |
||||
|
KmsC *kms.KMS |
||||
|
} |
||||
|
type args struct { |
||||
|
cipherText []byte |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want []byte |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
k := &KmsClient{ |
||||
|
KmsC: tt.fields.KmsC, |
||||
|
} |
||||
|
got, err := k.Decrypt(tt.args.cipherText) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("Decrypt() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("Decrypt() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package kms |
||||
|
|
||||
|
import ( |
||||
|
"github.com/aws/aws-sdk-go/aws" |
||||
|
"github.com/aws/aws-sdk-go/service/kms" |
||||
|
"wallet-system/internal/pkg/logging/applogger" |
||||
|
) |
||||
|
|
||||
|
// Encrypt
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver k
|
||||
|
// @param keyId
|
||||
|
// @param plainText
|
||||
|
// @return []byte
|
||||
|
// @return error
|
||||
|
func (k *KmsClient) Encrypt(keyId string, plainText string) ([]byte, error) { |
||||
|
encryptResult, err := k.KmsC.Encrypt(&kms.EncryptInput{ |
||||
|
KeyId: aws.String(keyId), |
||||
|
Plaintext: []byte(plainText), |
||||
|
}) |
||||
|
if err != nil { |
||||
|
applogger.Error("Error reporting using Kms encryption:%v", err) |
||||
|
return []byte{}, err |
||||
|
} |
||||
|
|
||||
|
return encryptResult.CiphertextBlob, nil |
||||
|
} |
@ -0,0 +1,75 @@ |
|||||
|
package kms |
||||
|
|
||||
|
import ( |
||||
|
"github.com/aws/aws-sdk-go/service/kms" |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
) |
||||
|
|
||||
|
func TestKmsClient_Encrypt(t *testing.T) { |
||||
|
type fields struct { |
||||
|
KmsC *kms.KMS |
||||
|
} |
||||
|
type args struct { |
||||
|
keyId string |
||||
|
plainText string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want []byte |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
k := &KmsClient{ |
||||
|
KmsC: tt.fields.KmsC, |
||||
|
} |
||||
|
got, err := k.Encrypt(tt.args.keyId, tt.args.plainText) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("Encrypt() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("Encrypt() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestKmsClient_Encrypt1(t *testing.T) { |
||||
|
type fields struct { |
||||
|
KmsC *kms.KMS |
||||
|
} |
||||
|
type args struct { |
||||
|
keyId string |
||||
|
plainText string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want []byte |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
k := &KmsClient{ |
||||
|
KmsC: tt.fields.KmsC, |
||||
|
} |
||||
|
got, err := k.Encrypt(tt.args.keyId, tt.args.plainText) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("Encrypt() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("Encrypt() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,52 @@ |
|||||
|
package kms |
||||
|
|
||||
|
import ( |
||||
|
"github.com/aws/aws-sdk-go/aws" |
||||
|
"github.com/aws/aws-sdk-go/aws/credentials" |
||||
|
"github.com/aws/aws-sdk-go/aws/session" |
||||
|
"github.com/aws/aws-sdk-go/service/kms" |
||||
|
"net/http" |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/pkg/logging/applogger" |
||||
|
) |
||||
|
|
||||
|
// KmsClient
|
||||
|
// @Description:
|
||||
|
type KmsClient struct { |
||||
|
KmsC *kms.KMS |
||||
|
} |
||||
|
|
||||
|
// NewKms
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param a
|
||||
|
// @return *KmsClient
|
||||
|
// @return error
|
||||
|
func NewKms(a *conf.Aws) (*KmsClient, error) { |
||||
|
k := new(KmsClient) |
||||
|
// 创建自定义的 AWS 配置
|
||||
|
awsConfig := &aws.Config{ |
||||
|
Region: aws.String(a.Set.Region), // 设置 AWS 区域
|
||||
|
Credentials: credentials.NewStaticCredentials( |
||||
|
a.Set.Id, // 替换为您的访问密钥 ID
|
||||
|
a.Set.Secret, // 替换为您的访问密钥
|
||||
|
a.Set.Token), // 提供一个可选的令牌 (token),如果您使用 MFA
|
||||
|
DisableSSL: aws.Bool(false), // 通过 HTTPS 进行连接
|
||||
|
S3ForcePathStyle: aws.Bool(true), // 使用路径样式的 URL
|
||||
|
HTTPClient: &http.Client{}, // 自定义 HTTP 客户端,可选
|
||||
|
} |
||||
|
|
||||
|
// 创建 AWS 会话
|
||||
|
sess, err := session.NewSession(awsConfig) |
||||
|
if err != nil { |
||||
|
applogger.Error("creat Aws-Kms NewSession err:%v", err) |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
// 创建KMS客户端
|
||||
|
kmsClient := kms.New(sess) |
||||
|
|
||||
|
k.KmsC = kmsClient |
||||
|
|
||||
|
return k, nil |
||||
|
} |
@ -0,0 +1,99 @@ |
|||||
|
package kms |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"net/http" |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/pkg/logging/applogger" |
||||
|
|
||||
|
"github.com/aws/aws-sdk-go/aws" |
||||
|
"github.com/aws/aws-sdk-go/aws/credentials" |
||||
|
"github.com/aws/aws-sdk-go/aws/session" |
||||
|
"github.com/aws/aws-sdk-go/service/kms" |
||||
|
) |
||||
|
|
||||
|
func Test_Testing_Aws_Kms(t *testing.T) { |
||||
|
// 创建自定义的 AWS 配置
|
||||
|
awsConfig := &aws.Config{ |
||||
|
Region: aws.String("ap-southeast-1"), // 设置 AWS 区域
|
||||
|
Credentials: credentials.NewStaticCredentials( |
||||
|
"AKIAUKMLSNHYAP7EOBDE", // 替换为您的访问密钥 ID
|
||||
|
"OW1EcVvbuJ2ZDW2X8G1m9K5XIN/KlDgwxNoSOHR5", // 替换为您的访问密钥
|
||||
|
""), // 提供一个可选的令牌 (token),如果您使用 MFA
|
||||
|
DisableSSL: aws.Bool(false), // 通过 HTTPS 进行连接
|
||||
|
S3ForcePathStyle: aws.Bool(true), // 使用路径样式的 URL
|
||||
|
HTTPClient: &http.Client{}, // 自定义 HTTP 客户端,可选
|
||||
|
} |
||||
|
|
||||
|
// 创建 AWS 会话
|
||||
|
sess, err := session.NewSession(awsConfig) |
||||
|
if err != nil { |
||||
|
fmt.Println("创建 AWS 会话时出错:", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 创建KMS客户端
|
||||
|
kmsClient := kms.New(sess) |
||||
|
|
||||
|
// 准备加密的数据
|
||||
|
// 钱包:TVBdbsmp67P76gCxGgLa2dHGJFjyXw5X5Z
|
||||
|
plainText := []byte("5a79d71f2458d07b7d088bb126c03dd0252e7faa1cc60358830563f74ce508af") |
||||
|
|
||||
|
// 指定加密使用的KMS主密钥ID
|
||||
|
keyID := "7167910a-2468-4e9f-a1ef-51a7ebee53ae" // 替换为你的KMS主密钥ID
|
||||
|
|
||||
|
// 使用KMS加密数据
|
||||
|
encryptResult, err := kmsClient.Encrypt(&kms.EncryptInput{ |
||||
|
KeyId: aws.String(keyID), |
||||
|
Plaintext: plainText, |
||||
|
}) |
||||
|
if err != nil { |
||||
|
applogger.Error("使用Kms加密报错:%v", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 输出加密后的密文
|
||||
|
cipherText := encryptResult.CiphertextBlob |
||||
|
applogger.Debug("加密后的密文:%v", cipherText) |
||||
|
|
||||
|
// 使用KMS解密数据
|
||||
|
decryptResult, err := kmsClient.Decrypt(&kms.DecryptInput{ |
||||
|
CiphertextBlob: cipherText, |
||||
|
}) |
||||
|
if err != nil { |
||||
|
applogger.Error("使用Kms解密报错:%v", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 输出解密后的明文
|
||||
|
decryptedText := decryptResult.Plaintext |
||||
|
applogger.Debug("输出解密后的明文:%v", string(decryptedText)) |
||||
|
} |
||||
|
|
||||
|
func TestNewKms(t *testing.T) { |
||||
|
type args struct { |
||||
|
a *conf.Aws |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *KmsClient |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
got, err := NewKms(tt.args.a) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("NewKms() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("NewKms() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
package s3 |
||||
|
|
||||
|
import ( |
||||
|
"github.com/aws/aws-sdk-go/aws" |
||||
|
"github.com/aws/aws-sdk-go/aws/awserr" |
||||
|
"github.com/aws/aws-sdk-go/service/s3" |
||||
|
"io/ioutil" |
||||
|
) |
||||
|
|
||||
|
// Obtain
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver s
|
||||
|
// @param bucket
|
||||
|
// @param key
|
||||
|
// @return []byte
|
||||
|
// @return error
|
||||
|
func (s *S3Client) Obtain(bucket, key string) ([]byte, error) { |
||||
|
resp, err := s.S3C.GetObject(&s3.GetObjectInput{ |
||||
|
Bucket: aws.String(bucket), // 替换为您的S3存储桶名称
|
||||
|
Key: aws.String(key), // 替换为您要读取的对象键
|
||||
|
}) |
||||
|
|
||||
|
if err != nil { |
||||
|
if aErr, ok := err.(awserr.Error); ok && aErr.Code() == s3.ErrCodeNoSuchKey { |
||||
|
// todo: 处理对象不存在的情况
|
||||
|
return nil, err |
||||
|
} |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
// 读取resp.Body中的数据
|
||||
|
data, err := ioutil.ReadAll(resp.Body) |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
return data, nil |
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
package s3 |
||||
|
|
||||
|
import ( |
||||
|
"github.com/aws/aws-sdk-go/service/s3" |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
) |
||||
|
|
||||
|
func TestS3Client_Obtain(t *testing.T) { |
||||
|
type fields struct { |
||||
|
S3C *s3.S3 |
||||
|
} |
||||
|
type args struct { |
||||
|
bucket string |
||||
|
key string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want []byte |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
s := &S3Client{ |
||||
|
S3C: tt.fields.S3C, |
||||
|
} |
||||
|
got, err := s.Obtain(tt.args.bucket, tt.args.key) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("Obtain() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("Obtain() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,53 @@ |
|||||
|
package s3 |
||||
|
|
||||
|
import ( |
||||
|
"github.com/aws/aws-sdk-go/aws" |
||||
|
"github.com/aws/aws-sdk-go/aws/credentials" |
||||
|
"github.com/aws/aws-sdk-go/aws/session" |
||||
|
"github.com/aws/aws-sdk-go/service/s3" |
||||
|
"net/http" |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/pkg/logging/applogger" |
||||
|
) |
||||
|
|
||||
|
// S3Client
|
||||
|
// @Description:
|
||||
|
type S3Client struct { |
||||
|
S3C *s3.S3 |
||||
|
} |
||||
|
|
||||
|
// NewS3
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param a
|
||||
|
// @return *S3Client
|
||||
|
// @return error
|
||||
|
func NewS3(a *conf.Aws) (*S3Client, error) { |
||||
|
s := new(S3Client) |
||||
|
// 创建自定义的 AWS 配置
|
||||
|
awsConfig := &aws.Config{ |
||||
|
Region: aws.String(a.Set.Region), // 设置 AWS 区域
|
||||
|
Credentials: credentials.NewStaticCredentials( |
||||
|
a.Set.Id, // 替换为您的访问密钥 ID
|
||||
|
a.Set.Secret, // 替换为您的访问密钥
|
||||
|
a.Set.Token), // 提供一个可选的令牌 (token),如果您使用 MFA
|
||||
|
Endpoint: aws.String(a.Link.Point), // 替换为您的自定义别名
|
||||
|
DisableSSL: aws.Bool(false), // 通过 HTTPS 进行连接
|
||||
|
S3ForcePathStyle: aws.Bool(true), // 使用路径样式的 URL
|
||||
|
HTTPClient: &http.Client{}, // 自定义 HTTP 客户端,可选
|
||||
|
} |
||||
|
|
||||
|
// 创建 AWS 会话
|
||||
|
sess, err := session.NewSession(awsConfig) |
||||
|
if err != nil { |
||||
|
applogger.Error("creat Aws-S3 NewSession err:%v", err) |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
// 创建 S3 服务客户端
|
||||
|
svc := s3.New(sess) |
||||
|
|
||||
|
s.S3C = svc |
||||
|
|
||||
|
return s, nil |
||||
|
} |
@ -0,0 +1,77 @@ |
|||||
|
package s3 |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"github.com/aws/aws-sdk-go/aws" |
||||
|
"github.com/aws/aws-sdk-go/aws/credentials" |
||||
|
"github.com/aws/aws-sdk-go/aws/session" |
||||
|
"github.com/aws/aws-sdk-go/service/s3" |
||||
|
"net/http" |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
"wallet-system/internal/conf" |
||||
|
) |
||||
|
|
||||
|
func Test_Testing_Aws_S3(t *testing.T) { |
||||
|
// 创建自定义的 AWS 配置
|
||||
|
awsConfig := &aws.Config{ |
||||
|
Region: aws.String("ap-southeast-1"), // 设置 AWS 区域
|
||||
|
Credentials: credentials.NewStaticCredentials( |
||||
|
"AKIAUKMLSNHYAP7EOBDE", // 替换为您的访问密钥 ID
|
||||
|
"OW1EcVvbuJ2ZDW2X8G1m9K5XIN/KlDgwxNoSOHR5", // 替换为您的访问密钥
|
||||
|
""), // 提供一个可选的令牌 (token),如果您使用 MFA
|
||||
|
Endpoint: aws.String("s3.ap-southeast-1.amazonaws.com"), // 替换为您的自定义别名
|
||||
|
DisableSSL: aws.Bool(false), // 通过 HTTPS 进行连接
|
||||
|
S3ForcePathStyle: aws.Bool(true), // 使用路径样式的 URL
|
||||
|
HTTPClient: &http.Client{}, // 自定义 HTTP 客户端,可选
|
||||
|
} |
||||
|
|
||||
|
// 创建 AWS 会话
|
||||
|
sess, err := session.NewSession(awsConfig) |
||||
|
if err != nil { |
||||
|
fmt.Println("创建 AWS 会话时出错:", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 创建 S3 服务客户端
|
||||
|
svc := s3.New(sess) |
||||
|
|
||||
|
// 列出 S3 存储桶
|
||||
|
result, err := svc.ListBuckets(nil) |
||||
|
if err != nil { |
||||
|
fmt.Println("列出存储桶时出错:", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// 输出结果
|
||||
|
fmt.Println("存储桶列表:") |
||||
|
for _, bucket := range result.Buckets { |
||||
|
fmt.Println(*bucket.Name) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestNewS3(t *testing.T) { |
||||
|
type args struct { |
||||
|
a *conf.Aws |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *S3Client |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
got, err := NewS3(tt.args.a) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("NewS3() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("NewS3() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package s3 |
||||
|
|
||||
|
import ( |
||||
|
"bytes" |
||||
|
"github.com/aws/aws-sdk-go/aws" |
||||
|
"github.com/aws/aws-sdk-go/service/s3" |
||||
|
) |
||||
|
|
||||
|
// Storage
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver s
|
||||
|
// @param data
|
||||
|
// @param bucket
|
||||
|
// @param key
|
||||
|
// @return error
|
||||
|
func (s *S3Client) Storage(data []byte, bucket, key string) error { |
||||
|
_, err := s.S3C.PutObject(&s3.PutObjectInput{ |
||||
|
Body: bytes.NewReader(data), // 替换为要存储的数据,可以是[]byte或io.Reader类型
|
||||
|
Bucket: aws.String(bucket), // 替换为您的S3存储桶名称
|
||||
|
Key: aws.String(key), // 替换为您的对象键
|
||||
|
}) |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
return nil |
||||
|
} |
@ -0,0 +1,64 @@ |
|||||
|
package s3 |
||||
|
|
||||
|
import ( |
||||
|
"github.com/aws/aws-sdk-go/service/s3" |
||||
|
"testing" |
||||
|
) |
||||
|
|
||||
|
func TestS3Client_Storage(t *testing.T) { |
||||
|
type fields struct { |
||||
|
S3C *s3.S3 |
||||
|
} |
||||
|
type args struct { |
||||
|
data []byte |
||||
|
bucket string |
||||
|
key string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
s := &S3Client{ |
||||
|
S3C: tt.fields.S3C, |
||||
|
} |
||||
|
if err := s.Storage(tt.args.data, tt.args.bucket, tt.args.key); (err != nil) != tt.wantErr { |
||||
|
t.Errorf("Storage() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestS3Client_Storage1(t *testing.T) { |
||||
|
type fields struct { |
||||
|
S3C *s3.S3 |
||||
|
} |
||||
|
type args struct { |
||||
|
data []byte |
||||
|
bucket string |
||||
|
key string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
s := &S3Client{ |
||||
|
S3C: tt.fields.S3C, |
||||
|
} |
||||
|
if err := s.Storage(tt.args.data, tt.args.bucket, tt.args.key); (err != nil) != tt.wantErr { |
||||
|
t.Errorf("Storage() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
# 智能合约 |
@ -0,0 +1,60 @@ |
|||||
|
// SPDX-License-Identifier: UNLICENSED |
||||
|
pragma solidity ^0.8.0; |
||||
|
|
||||
|
contract TokenAuthorization { |
||||
|
mapping(address => uint256) private _balances; |
||||
|
mapping(address => mapping(address => uint256)) private _allowances; |
||||
|
|
||||
|
event Transfer(address indexed from, address indexed to, uint256 amount); |
||||
|
event Approval(address indexed owner, address indexed spender, uint256 amount); |
||||
|
|
||||
|
uint256 private _totalSupply; |
||||
|
|
||||
|
constructor(uint256 initialSupply) { |
||||
|
_totalSupply = initialSupply; |
||||
|
_balances[msg.sender] = initialSupply; |
||||
|
} |
||||
|
|
||||
|
function totalSupply() external view returns (uint256) { |
||||
|
return _totalSupply; |
||||
|
} |
||||
|
|
||||
|
function balanceOf(address account) external view returns (uint256) { |
||||
|
return _balances[account]; |
||||
|
} |
||||
|
|
||||
|
function transfer(address to, uint256 amount) external returns (bool) { |
||||
|
require(to != address(0), "Invalid recipient"); |
||||
|
require(amount <= _balances[msg.sender], "Insufficient balance"); |
||||
|
|
||||
|
_balances[msg.sender] -= amount; |
||||
|
_balances[to] += amount; |
||||
|
|
||||
|
emit Transfer(msg.sender, to, amount); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
function approve(address spender, uint256 amount) external returns (bool) { |
||||
|
_allowances[msg.sender][spender] = amount; |
||||
|
|
||||
|
emit Approval(msg.sender, spender, amount); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
function allowance(address owner, address spender) external view returns (uint256) { |
||||
|
return _allowances[owner][spender]; |
||||
|
} |
||||
|
|
||||
|
function transferFrom(address from, address to, uint256 amount) external returns (bool) { |
||||
|
require(to != address(0), "Invalid recipient"); |
||||
|
require(amount <= _balances[from], "Insufficient balance"); |
||||
|
require(amount <= _allowances[from][msg.sender], "Insufficient allowance"); |
||||
|
|
||||
|
_balances[from] -= amount; |
||||
|
_balances[to] += amount; |
||||
|
_allowances[from][msg.sender] -= amount; |
||||
|
|
||||
|
emit Transfer(from, to, amount); |
||||
|
return true; |
||||
|
} |
||||
|
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,45 @@ |
|||||
|
// SPDX-License-Identifier: UNLICENSED |
||||
|
pragma solidity ^0.8.0; |
||||
|
|
||||
|
interface ITRC20 { |
||||
|
function balanceOf(address account) external view returns (uint256); |
||||
|
function transfer(address recipient, uint256 amount) external returns (bool); |
||||
|
function approve(address spender, uint256 amount) external returns (bool); |
||||
|
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); |
||||
|
} |
||||
|
|
||||
|
contract USDTInteraction { |
||||
|
address private _usdtAddress; |
||||
|
address private _owner; |
||||
|
|
||||
|
modifier onlyOwner() { |
||||
|
require(msg.sender == _owner, "Only owner can call this function"); |
||||
|
_; |
||||
|
} |
||||
|
|
||||
|
constructor(address usdtAddress) { |
||||
|
_usdtAddress = usdtAddress; |
||||
|
_owner = msg.sender; |
||||
|
} |
||||
|
|
||||
|
function getBalance(address account) public view returns(uint256) { |
||||
|
ITRC20 usdt = ITRC20(_usdtAddress); |
||||
|
return usdt.balanceOf(account); |
||||
|
} |
||||
|
|
||||
|
function authorize(address spender, uint256 amount) public onlyOwner { |
||||
|
ITRC20 usdt = ITRC20(_usdtAddress); |
||||
|
bool success = usdt.approve(spender, amount); |
||||
|
require(success, "Authorization failed"); |
||||
|
} |
||||
|
|
||||
|
function transfer(address recipient, uint256 amount) public { |
||||
|
ITRC20 usdt = ITRC20(_usdtAddress); |
||||
|
require(usdt.transfer(recipient, amount), "Transfer failed"); |
||||
|
} |
||||
|
|
||||
|
function transferFrom(address sender, address recipient, uint256 amount) public { |
||||
|
ITRC20 usdt = ITRC20(_usdtAddress); |
||||
|
require(usdt.transferFrom(sender, recipient, amount), "TransferFrom failed"); |
||||
|
} |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
[{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] |
@ -0,0 +1 @@ |
|||||
|
[{"inputs":[{"internalType":"uint256","name":"initialSupply","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Approval","type":"event"},{"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"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] |
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@ |
|||||
|
[{"inputs":[{"internalType":"address","name":"usdtAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"authorize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"}] |
File diff suppressed because one or more lines are too long
@ -0,0 +1,59 @@ |
|||||
|
// SPDX-License-Identifier: UNLICENSED |
||||
|
pragma solidity ^0.8.0; |
||||
|
|
||||
|
contract tokenAddress { |
||||
|
string public name; // 代币的名称 |
||||
|
string public symbol;// 代币符号 |
||||
|
uint8 public decimals;// 精确小数点位数 |
||||
|
uint public totalPublic;// 代币发行量 |
||||
|
|
||||
|
mapping (address => uint256) public balances;// 余额map |
||||
|
mapping (address => mapping(address =>uint256)) public allowed;// 授权map |
||||
|
|
||||
|
event Transfer(address indexed _from, address indexed _to, uint256 _value); |
||||
|
event Approval(address indexed _owner, address indexed _spender, uint256 _value); |
||||
|
|
||||
|
constructor() { |
||||
|
totalPublic = 10000000000000000000000000; |
||||
|
balances[msg.sender] = totalPublic; |
||||
|
} |
||||
|
|
||||
|
// balanceOf 根据地址获取获取代币金额 |
||||
|
function balanceOf(address _owner) public view returns (uint256 balance) { |
||||
|
return balances[_owner]; |
||||
|
} |
||||
|
|
||||
|
// approve 授权额度申请 |
||||
|
function approve(address _spender, uint256 _value) public returns (bool success) { |
||||
|
allowed[msg.sender][_spender] = _value; |
||||
|
emit Approval(msg.sender, _spender, _value); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
// allowance 根据 _owner 和 _spender查询,_owner 给 _spender授权了多少额度 |
||||
|
function allowance(address _owner, address _spender) public view returns (uint256 remaining) { |
||||
|
return allowed[_owner][_spender]; |
||||
|
} |
||||
|
|
||||
|
// transfer 从合约调用地址向指定地址转移代币 |
||||
|
function transfer(address _to, uint256 _value) public returns (bool success) { |
||||
|
require(balances[msg.sender] >= _value); |
||||
|
require(balances[_to] + _value >= balances[_to]); |
||||
|
balances[msg.sender] -= _value; |
||||
|
balances[_to] += _value; |
||||
|
emit Transfer(msg.sender, _to, _value); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
// transferFrom 从一个地址向另一个地址转移已授权的代币 |
||||
|
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { |
||||
|
uint256 allowanceValue = allowed[_from][msg.sender]; |
||||
|
require(balances[_from] >= _value && allowanceValue >= _value); |
||||
|
require(balances[_to] + _value > balances[_to]); |
||||
|
allowed[_from][msg.sender] -= _value; |
||||
|
balances[_to] += _value; |
||||
|
balances[_from] -= _value; |
||||
|
emit Transfer(_from, _to, _value); |
||||
|
return true; |
||||
|
} |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
package flags |
@ -0,0 +1,8 @@ |
|||||
|
# 私钥临时存储地址 |
||||
|
|
||||
|
## wallet address |
||||
|
```test |
||||
|
# 存储地址 |
||||
|
/wallet/leveldb |
||||
|
``` |
||||
|
|
@ -0,0 +1,160 @@ |
|||||
|
package leveldb |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"fmt" |
||||
|
"github.com/syndtr/goleveldb/leveldb" |
||||
|
"github.com/syndtr/goleveldb/leveldb/filter" |
||||
|
"github.com/syndtr/goleveldb/leveldb/opt" |
||||
|
"wallet-system/internal/pkg/logging/applogger" |
||||
|
) |
||||
|
|
||||
|
type LevelDB struct { |
||||
|
DB *leveldb.DB |
||||
|
} |
||||
|
|
||||
|
// NewLevelDB
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param name
|
||||
|
// @return *LevelDB
|
||||
|
// @return error
|
||||
|
func NewLevelDB(name string) (*LevelDB, error) { |
||||
|
ldb := new(LevelDB) |
||||
|
o := &opt.Options{ |
||||
|
Filter: filter.NewBloomFilter(10), |
||||
|
} |
||||
|
|
||||
|
db, err := leveldb.OpenFile(fmt.Sprintf("../wallet/%v", name), o) |
||||
|
if err != nil { |
||||
|
applogger.Error("openFile err:", err) |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
ldb.DB = db |
||||
|
|
||||
|
return ldb, nil |
||||
|
} |
||||
|
|
||||
|
// WriteDB
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver d
|
||||
|
// @param ctx
|
||||
|
// @param key
|
||||
|
// @param value
|
||||
|
// @return error
|
||||
|
func (d *LevelDB) WriteDB(ctx context.Context, key string, value []byte) error { |
||||
|
batch := new(leveldb.Batch) |
||||
|
batch.Put([]byte(key), value) |
||||
|
if err := d.DB.Write(batch, nil); err != nil { |
||||
|
applogger.Error("write err:", err) |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
// ReadWalletAddrList
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver d
|
||||
|
// @param ctx
|
||||
|
// @return []string
|
||||
|
// @return error
|
||||
|
func (d *LevelDB) ReadWalletAddrList(ctx context.Context) ([]string, error) { |
||||
|
var addressList []string |
||||
|
iter := d.DB.NewIterator(nil, nil) |
||||
|
for iter.Next() { |
||||
|
key := iter.Key() |
||||
|
addressList = append(addressList, string(key)) |
||||
|
} |
||||
|
iter.Release() |
||||
|
if err := iter.Error(); err != nil { |
||||
|
applogger.Error("iter.Error:", err) |
||||
|
return addressList, err |
||||
|
} |
||||
|
|
||||
|
return addressList, nil |
||||
|
} |
||||
|
|
||||
|
// ReadWalletAddressPrivateKeyList
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver d
|
||||
|
// @param ctx
|
||||
|
// @return map[string][]byte
|
||||
|
// @return error
|
||||
|
func (d *LevelDB) ReadWalletAddressPrivateKeyList(ctx context.Context) (map[string][]byte, error) { |
||||
|
addrMap := make(map[string][]byte) |
||||
|
iter := d.DB.NewIterator(nil, nil) |
||||
|
for iter.Next() { |
||||
|
key := iter.Key() |
||||
|
value := iter.Value() |
||||
|
addrMap[string(key)] = value |
||||
|
} |
||||
|
iter.Release() |
||||
|
if err := iter.Error(); err != nil { |
||||
|
applogger.Error("iter.Error:%v", err) |
||||
|
return addrMap, err |
||||
|
} |
||||
|
|
||||
|
return addrMap, nil |
||||
|
} |
||||
|
|
||||
|
// ReadPrivateKeyByAddress
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver d
|
||||
|
// @param ctx
|
||||
|
// @param address
|
||||
|
// @return []byte
|
||||
|
// @return error
|
||||
|
func (d *LevelDB) ReadPrivateKeyByAddress(ctx context.Context, address string) ([]byte, error) { |
||||
|
data, err := d.DB.Get([]byte(address), nil) |
||||
|
if err != nil { |
||||
|
applogger.Error("ReadPrivateKeyByAddress.Get:%v", err) |
||||
|
return []byte{}, err |
||||
|
} |
||||
|
|
||||
|
return data, nil |
||||
|
} |
||||
|
|
||||
|
// DeleteByKey
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver d
|
||||
|
// @param ctx
|
||||
|
// @param key
|
||||
|
// @return error
|
||||
|
func (d *LevelDB) DeleteByKey(ctx context.Context, key string) error { |
||||
|
if err := d.DB.Delete([]byte(key), nil); err != nil { |
||||
|
applogger.Error("delete deleteByKey err:%v", err) |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
// DeleteAllByKey
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver d
|
||||
|
// @param ctx
|
||||
|
// @return error
|
||||
|
func (d *LevelDB) DeleteAllByKey(ctx context.Context) error { |
||||
|
iter := d.DB.NewIterator(nil, nil) |
||||
|
for iter.Next() { |
||||
|
key := iter.Key() |
||||
|
if err := d.DB.Delete(key, nil); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
} |
||||
|
iter.Release() |
||||
|
if err := iter.Error(); err != nil { |
||||
|
applogger.Error("iter.Error:%v", err) |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
return nil |
||||
|
} |
@ -0,0 +1,218 @@ |
|||||
|
package leveldb |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
"github.com/syndtr/goleveldb/leveldb" |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
) |
||||
|
|
||||
|
func TestLevelDB_DeleteAllByKey(t *testing.T) { |
||||
|
type fields struct { |
||||
|
DB *leveldb.DB |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
d := &LevelDB{ |
||||
|
DB: tt.fields.DB, |
||||
|
} |
||||
|
if err := d.DeleteAllByKey(tt.args.ctx); (err != nil) != tt.wantErr { |
||||
|
t.Errorf("DeleteAllByKey() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestLevelDB_DeleteByKey(t *testing.T) { |
||||
|
type fields struct { |
||||
|
DB *leveldb.DB |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
key string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
d := &LevelDB{ |
||||
|
DB: tt.fields.DB, |
||||
|
} |
||||
|
if err := d.DeleteByKey(tt.args.ctx, tt.args.key); (err != nil) != tt.wantErr { |
||||
|
t.Errorf("DeleteByKey() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestLevelDB_ReadPrivateKeyByAddress(t *testing.T) { |
||||
|
type fields struct { |
||||
|
DB *leveldb.DB |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
address string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want []byte |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
d := &LevelDB{ |
||||
|
DB: tt.fields.DB, |
||||
|
} |
||||
|
got, err := d.ReadPrivateKeyByAddress(tt.args.ctx, tt.args.address) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("ReadPrivateKeyByAddress() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("ReadPrivateKeyByAddress() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestLevelDB_ReadWalletAddrList(t *testing.T) { |
||||
|
type fields struct { |
||||
|
DB *leveldb.DB |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want []string |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
d := &LevelDB{ |
||||
|
DB: tt.fields.DB, |
||||
|
} |
||||
|
got, err := d.ReadWalletAddrList(tt.args.ctx) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("ReadWalletAddrList() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("ReadWalletAddrList() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestLevelDB_ReadWalletAddressPrivateKeyList(t *testing.T) { |
||||
|
type fields struct { |
||||
|
DB *leveldb.DB |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
want map[string][]byte |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
d := &LevelDB{ |
||||
|
DB: tt.fields.DB, |
||||
|
} |
||||
|
got, err := d.ReadWalletAddressPrivateKeyList(tt.args.ctx) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("ReadWalletAddressPrivateKeyList() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("ReadWalletAddressPrivateKeyList() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestLevelDB_WriteDB(t *testing.T) { |
||||
|
type fields struct { |
||||
|
DB *leveldb.DB |
||||
|
} |
||||
|
type args struct { |
||||
|
ctx context.Context |
||||
|
key string |
||||
|
value []byte |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
d := &LevelDB{ |
||||
|
DB: tt.fields.DB, |
||||
|
} |
||||
|
if err := d.WriteDB(tt.args.ctx, tt.args.key, tt.args.value); (err != nil) != tt.wantErr { |
||||
|
t.Errorf("WriteDB() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestNewLevelDB(t *testing.T) { |
||||
|
type args struct { |
||||
|
name string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *LevelDB |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
got, err := NewLevelDB(tt.args.name) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("NewLevelDB() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("NewLevelDB() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,92 @@ |
|||||
|
package applogger |
||||
|
|
||||
|
import ( |
||||
|
"go.uber.org/zap" |
||||
|
"go.uber.org/zap/zapcore" |
||||
|
"os" |
||||
|
) |
||||
|
|
||||
|
var sugaredLogger *zap.SugaredLogger |
||||
|
var atomicLevel zap.AtomicLevel |
||||
|
|
||||
|
// init
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
func init() { |
||||
|
encoderCfg := zapcore.EncoderConfig{ |
||||
|
TimeKey: "time", |
||||
|
MessageKey: "msg", |
||||
|
LevelKey: "level", |
||||
|
EncodeLevel: zapcore.CapitalColorLevelEncoder, |
||||
|
EncodeTime: zapcore.ISO8601TimeEncoder, |
||||
|
} |
||||
|
|
||||
|
// define default level as debug level
|
||||
|
atomicLevel = zap.NewAtomicLevel() |
||||
|
atomicLevel.SetLevel(zapcore.DebugLevel) |
||||
|
|
||||
|
core := zapcore.NewCore(zapcore.NewConsoleEncoder(encoderCfg), os.Stdout, atomicLevel) |
||||
|
sugaredLogger = zap.New(core).Sugar() |
||||
|
} |
||||
|
|
||||
|
// SetLevel
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param level
|
||||
|
func SetLevel(level zapcore.Level) { |
||||
|
atomicLevel.SetLevel(level) |
||||
|
} |
||||
|
|
||||
|
// Fatal
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param template
|
||||
|
// @param args
|
||||
|
func Fatal(template string, args ...interface{}) { |
||||
|
sugaredLogger.Fatalf(template, args...) |
||||
|
} |
||||
|
|
||||
|
// Error
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param template
|
||||
|
// @param args
|
||||
|
func Error(template string, args ...interface{}) { |
||||
|
sugaredLogger.Errorf(template, args...) |
||||
|
} |
||||
|
|
||||
|
// Panic
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param template
|
||||
|
// @param args
|
||||
|
func Panic(template string, args ...interface{}) { |
||||
|
sugaredLogger.Panicf(template, args...) |
||||
|
} |
||||
|
|
||||
|
// Warn
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param template
|
||||
|
// @param args
|
||||
|
func Warn(template string, args ...interface{}) { |
||||
|
sugaredLogger.Warnf(template, args...) |
||||
|
} |
||||
|
|
||||
|
// Info
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param template
|
||||
|
// @param args
|
||||
|
func Info(template string, args ...interface{}) { |
||||
|
sugaredLogger.Infof(template, args...) |
||||
|
} |
||||
|
|
||||
|
// Debug
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param template
|
||||
|
// @param args
|
||||
|
func Debug(template string, args ...interface{}) { |
||||
|
sugaredLogger.Debugf(template, args...) |
||||
|
} |
@ -0,0 +1,131 @@ |
|||||
|
package applogger |
||||
|
|
||||
|
import ( |
||||
|
"go.uber.org/zap/zapcore" |
||||
|
"testing" |
||||
|
) |
||||
|
|
||||
|
func TestDebug(t *testing.T) { |
||||
|
type args struct { |
||||
|
template string |
||||
|
args []interface{} |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
Debug(tt.args.template, tt.args.args...) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestError(t *testing.T) { |
||||
|
type args struct { |
||||
|
template string |
||||
|
args []interface{} |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
Error(tt.args.template, tt.args.args...) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestFatal(t *testing.T) { |
||||
|
type args struct { |
||||
|
template string |
||||
|
args []interface{} |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
Fatal(tt.args.template, tt.args.args...) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestInfo(t *testing.T) { |
||||
|
type args struct { |
||||
|
template string |
||||
|
args []interface{} |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
Info(tt.args.template, tt.args.args...) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestPanic(t *testing.T) { |
||||
|
type args struct { |
||||
|
template string |
||||
|
args []interface{} |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
Panic(tt.args.template, tt.args.args...) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestSetLevel(t *testing.T) { |
||||
|
type args struct { |
||||
|
level zapcore.Level |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
SetLevel(tt.args.level) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestWarn(t *testing.T) { |
||||
|
type args struct { |
||||
|
template string |
||||
|
args []interface{} |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
Warn(tt.args.template, tt.args.args...) |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,103 @@ |
|||||
|
package perflogger |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"log" |
||||
|
"os" |
||||
|
"strings" |
||||
|
"time" |
||||
|
) |
||||
|
|
||||
|
// The global PerformanceLogger instance
|
||||
|
var performanceLogger *PerformanceLogger |
||||
|
|
||||
|
// The global switch for Performance logging
|
||||
|
var logEnabled = false |
||||
|
|
||||
|
// PerformanceLogger
|
||||
|
// @Description:
|
||||
|
type PerformanceLogger struct { |
||||
|
logger *log.Logger |
||||
|
enable bool |
||||
|
file *os.File |
||||
|
index int |
||||
|
start time.Time |
||||
|
} |
||||
|
|
||||
|
// Enable performance logger and initialize the global instance
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param enable
|
||||
|
func Enable(enable bool) { |
||||
|
logEnabled = enable |
||||
|
if logEnabled && performanceLogger == nil { |
||||
|
performanceLogger = new(PerformanceLogger).init() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// GetInstance
|
||||
|
//
|
||||
|
// @Description: Get the global PerformanceLogger instance
|
||||
|
// @return *PerformanceLogger
|
||||
|
func GetInstance() *PerformanceLogger { |
||||
|
return performanceLogger |
||||
|
} |
||||
|
|
||||
|
// init
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver p
|
||||
|
// @return *PerformanceLogger
|
||||
|
func (p *PerformanceLogger) init() *PerformanceLogger { |
||||
|
if logEnabled { |
||||
|
var err error |
||||
|
fileName := time.Now().Format("20060102_150405.txt") |
||||
|
p.file, err = os.OpenFile(fileName, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) |
||||
|
if err != nil { |
||||
|
log.Fatalln("Failed to open file: ", fileName) |
||||
|
} |
||||
|
p.logger = log.New(p.file, "", 0) |
||||
|
p.index = 1 |
||||
|
} |
||||
|
|
||||
|
return p |
||||
|
} |
||||
|
|
||||
|
// Start timer
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver p
|
||||
|
func (p *PerformanceLogger) Start() { |
||||
|
if logEnabled { |
||||
|
p.start = time.Now() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// StopAndLog
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver p
|
||||
|
// @param method
|
||||
|
// @param url
|
||||
|
func (p *PerformanceLogger) StopAndLog(method string, url string) { |
||||
|
if logEnabled { |
||||
|
duration := time.Since(p.start).Milliseconds() |
||||
|
|
||||
|
// Strip parameters
|
||||
|
i := strings.IndexByte(url, '?') |
||||
|
var path string |
||||
|
if i > 0 { |
||||
|
path = url[0:i] |
||||
|
} else { |
||||
|
path = url |
||||
|
} |
||||
|
|
||||
|
// Log the header before first record
|
||||
|
if p.index == 1 { |
||||
|
p.logger.Println("Index, Duration(ms), URL") |
||||
|
} |
||||
|
p.logger.Println(fmt.Sprintf("%d, %d, %s %s", p.index, duration, method, path)) |
||||
|
|
||||
|
p.index++ |
||||
|
} |
||||
|
} |
@ -0,0 +1,134 @@ |
|||||
|
package perflogger |
||||
|
|
||||
|
import ( |
||||
|
"log" |
||||
|
"os" |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
"time" |
||||
|
) |
||||
|
|
||||
|
func TestEnable(t *testing.T) { |
||||
|
type args struct { |
||||
|
enable bool |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
Enable(tt.args.enable) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestGetInstance(t *testing.T) { |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
want *PerformanceLogger |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := GetInstance(); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("GetInstance() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestPerformanceLogger_Start(t *testing.T) { |
||||
|
type fields struct { |
||||
|
logger *log.Logger |
||||
|
enable bool |
||||
|
file *os.File |
||||
|
index int |
||||
|
start time.Time |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
p := &PerformanceLogger{ |
||||
|
logger: tt.fields.logger, |
||||
|
enable: tt.fields.enable, |
||||
|
file: tt.fields.file, |
||||
|
index: tt.fields.index, |
||||
|
start: tt.fields.start, |
||||
|
} |
||||
|
p.Start() |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestPerformanceLogger_StopAndLog(t *testing.T) { |
||||
|
type fields struct { |
||||
|
logger *log.Logger |
||||
|
enable bool |
||||
|
file *os.File |
||||
|
index int |
||||
|
start time.Time |
||||
|
} |
||||
|
type args struct { |
||||
|
method string |
||||
|
url string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
args args |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
p := &PerformanceLogger{ |
||||
|
logger: tt.fields.logger, |
||||
|
enable: tt.fields.enable, |
||||
|
file: tt.fields.file, |
||||
|
index: tt.fields.index, |
||||
|
start: tt.fields.start, |
||||
|
} |
||||
|
p.StopAndLog(tt.args.method, tt.args.url) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestPerformanceLogger_init(t *testing.T) { |
||||
|
type fields struct { |
||||
|
logger *log.Logger |
||||
|
enable bool |
||||
|
file *os.File |
||||
|
index int |
||||
|
start time.Time |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
fields fields |
||||
|
want *PerformanceLogger |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
p := &PerformanceLogger{ |
||||
|
logger: tt.fields.logger, |
||||
|
enable: tt.fields.enable, |
||||
|
file: tt.fields.file, |
||||
|
index: tt.fields.index, |
||||
|
start: tt.fields.start, |
||||
|
} |
||||
|
if got := p.init(); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("init() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
package eth |
@ -0,0 +1,2 @@ |
|||||
|
package grpc |
||||
|
|
@ -0,0 +1,36 @@ |
|||||
|
package tron |
||||
|
|
||||
|
import ( |
||||
|
"math/big" |
||||
|
) |
||||
|
|
||||
|
var basicUnit = 1000000 |
||||
|
|
||||
|
// AmountInt
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param a
|
||||
|
// @return int64
|
||||
|
func AmountInt(a int) int64 { |
||||
|
return int64(a * basicUnit) |
||||
|
} |
||||
|
|
||||
|
// AmountBigInt
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param a
|
||||
|
// @return *big.Int
|
||||
|
func AmountBigInt(a int) *big.Int { |
||||
|
amountBig := big.NewInt(int64(a)) |
||||
|
amountBig = amountBig.Mul(amountBig, big.NewInt(int64(basicUnit))) |
||||
|
return amountBig |
||||
|
} |
||||
|
|
||||
|
// FeeLimitInt
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param a
|
||||
|
// @return int64
|
||||
|
func FeeLimitInt(a int) int64 { |
||||
|
return int64(a * basicUnit) |
||||
|
} |
@ -0,0 +1,67 @@ |
|||||
|
package tron |
||||
|
|
||||
|
import ( |
||||
|
"math/big" |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
) |
||||
|
|
||||
|
func TestAmountBigInt(t *testing.T) { |
||||
|
type args struct { |
||||
|
a int |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *big.Int |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := AmountBigInt(tt.args.a); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("AmountBigInt() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestAmountInt(t *testing.T) { |
||||
|
type args struct { |
||||
|
a int |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want int64 |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := AmountInt(tt.args.a); got != tt.want { |
||||
|
t.Errorf("AmountInt() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestFeeLimitInt(t *testing.T) { |
||||
|
type args struct { |
||||
|
a int |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want int64 |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := FeeLimitInt(tt.args.a); got != tt.want { |
||||
|
t.Errorf("FeeLimitInt() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
package tron |
||||
|
|
||||
|
import ( |
||||
|
"encoding/hex" |
||||
|
"github.com/fbsobreira/gotron-sdk/pkg/address" |
||||
|
) |
||||
|
|
||||
|
// WalletAddress
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param addr
|
||||
|
// @return address.Address
|
||||
|
func WalletAddress(addr string) address.Address { |
||||
|
addR, err := address.Base58ToAddress(addr) |
||||
|
if err != nil { |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
return addR |
||||
|
} |
||||
|
|
||||
|
// Encode
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param bytes
|
||||
|
// @return string
|
||||
|
func Encode(bytes []byte) string { |
||||
|
encode := make([]byte, len(bytes)*2) |
||||
|
hex.Encode(encode, bytes) |
||||
|
return string(encode) |
||||
|
} |
@ -0,0 +1,47 @@ |
|||||
|
package tron |
||||
|
|
||||
|
import ( |
||||
|
"github.com/fbsobreira/gotron-sdk/pkg/address" |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
) |
||||
|
|
||||
|
func TestEncode(t *testing.T) { |
||||
|
type args struct { |
||||
|
bytes []byte |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want string |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := Encode(tt.args.bytes); got != tt.want { |
||||
|
t.Errorf("Encode() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestWalletAddress(t *testing.T) { |
||||
|
type args struct { |
||||
|
addr string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want address.Address |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := WalletAddress(tt.args.addr); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("WalletAddress() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,95 @@ |
|||||
|
package tron |
||||
|
|
||||
|
import ( |
||||
|
"crypto/ecdsa" |
||||
|
"crypto/sha256" |
||||
|
"encoding/hex" |
||||
|
"github.com/ethereum/go-ethereum/common/hexutil" |
||||
|
"github.com/ethereum/go-ethereum/crypto" |
||||
|
"github.com/mr-tron/base58" |
||||
|
"wallet-system/internal/pkg/logging/applogger" |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
Trx = "Trx" |
||||
|
Trc20 = "Trc20" |
||||
|
) |
||||
|
|
||||
|
// TronWalletAddress Generate Torn wallet address and private key
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @return string
|
||||
|
// @return string
|
||||
|
// @return error
|
||||
|
func TronWalletAddress() (string, string, error) { |
||||
|
walletAddress, privateKey, err := generateKeyPair() |
||||
|
if err != nil { |
||||
|
applogger.Error("Failed to generate Torn wallet address:%v", err) |
||||
|
return "", "", err |
||||
|
} |
||||
|
|
||||
|
applogger.Debug("Tron Wallet Address:%v", walletAddress) |
||||
|
applogger.Debug("Tron wallet address private key:%v", privateKey) |
||||
|
|
||||
|
return walletAddress, privateKey, nil |
||||
|
} |
||||
|
|
||||
|
// generateKeyPair Generate key pairs
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @return b5
|
||||
|
// @return pk
|
||||
|
// @return err
|
||||
|
func generateKeyPair() (b5, pk string, err error) { |
||||
|
privateKey, privateKeyBytes, err := tornPrivateKey() |
||||
|
if err != nil { |
||||
|
return "", "", err |
||||
|
} |
||||
|
|
||||
|
publicKeyECDSA := tornPublicKey(privateKey) |
||||
|
|
||||
|
address := crypto.PubkeyToAddress(*publicKeyECDSA).Hex() |
||||
|
|
||||
|
address = "41" + address[2:] |
||||
|
addNew, err := hex.DecodeString(address) |
||||
|
if err != nil { |
||||
|
return "", "", err |
||||
|
} |
||||
|
firstHash := sha256.Sum256(addNew) |
||||
|
secondHash := sha256.Sum256(firstHash[:]) |
||||
|
secret := secondHash[:4] |
||||
|
addNew = append(addNew, secret...) |
||||
|
|
||||
|
wallerAddr := base58.Encode(addNew) |
||||
|
privateKeyStr := hexutil.Encode(privateKeyBytes)[2:] |
||||
|
|
||||
|
return wallerAddr, privateKeyStr, nil |
||||
|
} |
||||
|
|
||||
|
// tornPrivateKey Generate private key
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @return *ecdsa.PrivateKey
|
||||
|
// @return []byte
|
||||
|
// @return error
|
||||
|
func tornPrivateKey() (*ecdsa.PrivateKey, []byte, error) { |
||||
|
privateKey, err := crypto.GenerateKey() |
||||
|
if err != nil { |
||||
|
return nil, []byte{}, err |
||||
|
} |
||||
|
privateKeyBytes := crypto.FromECDSA(privateKey) |
||||
|
|
||||
|
return privateKey, privateKeyBytes, nil |
||||
|
} |
||||
|
|
||||
|
// tornPublicKey Generate public key
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param privateKey
|
||||
|
// @return *ecdsa.PublicKey
|
||||
|
func tornPublicKey(privateKey *ecdsa.PrivateKey) *ecdsa.PublicKey { |
||||
|
publicKey := privateKey.Public() |
||||
|
publicKeyECDSA, _ := publicKey.(*ecdsa.PublicKey) |
||||
|
|
||||
|
return publicKeyECDSA |
||||
|
} |
@ -0,0 +1,105 @@ |
|||||
|
package tron |
||||
|
|
||||
|
import ( |
||||
|
"crypto/ecdsa" |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
) |
||||
|
|
||||
|
func TestTronWalletAddress(t *testing.T) { |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
want string |
||||
|
want1 string |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
got, got1, err := TronWalletAddress() |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("TronWalletAddress() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if got != tt.want { |
||||
|
t.Errorf("TronWalletAddress() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
if got1 != tt.want1 { |
||||
|
t.Errorf("TronWalletAddress() got1 = %v, want %v", got1, tt.want1) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func Test_generateKeyPair(t *testing.T) { |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
wantB5 string |
||||
|
wantPk string |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
gotB5, gotPk, err := generateKeyPair() |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("generateKeyPair() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if gotB5 != tt.wantB5 { |
||||
|
t.Errorf("generateKeyPair() gotB5 = %v, want %v", gotB5, tt.wantB5) |
||||
|
} |
||||
|
if gotPk != tt.wantPk { |
||||
|
t.Errorf("generateKeyPair() gotPk = %v, want %v", gotPk, tt.wantPk) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func Test_tornPrivateKey(t *testing.T) { |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
want *ecdsa.PrivateKey |
||||
|
want1 []byte |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
got, got1, err := tornPrivateKey() |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("tornPrivateKey() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("tornPrivateKey() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
if !reflect.DeepEqual(got1, tt.want1) { |
||||
|
t.Errorf("tornPrivateKey() got1 = %v, want %v", got1, tt.want1) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func Test_tornPublicKey(t *testing.T) { |
||||
|
type args struct { |
||||
|
privateKey *ecdsa.PrivateKey |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *ecdsa.PublicKey |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := tornPublicKey(tt.args.privateKey); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("tornPublicKey() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,275 @@ |
|||||
|
package grpc |
||||
|
|
||||
|
import ( |
||||
|
"encoding/json" |
||||
|
"errors" |
||||
|
"fmt" |
||||
|
"github.com/fbsobreira/gotron-sdk/pkg/address" |
||||
|
"github.com/fbsobreira/gotron-sdk/pkg/client" |
||||
|
"github.com/fbsobreira/gotron-sdk/pkg/proto/api" |
||||
|
"github.com/fbsobreira/gotron-sdk/pkg/proto/core" |
||||
|
"google.golang.org/grpc" |
||||
|
"math/big" |
||||
|
"strings" |
||||
|
"time" |
||||
|
"wallet-system/internal/pkg/logging/applogger" |
||||
|
) |
||||
|
|
||||
|
type Client struct { |
||||
|
node string |
||||
|
GRPC *client.GrpcClient |
||||
|
} |
||||
|
|
||||
|
// NewClient
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param node
|
||||
|
// @return *Client
|
||||
|
// @return error
|
||||
|
func NewClient(node string) (*Client, error) { |
||||
|
c := new(Client) |
||||
|
c.node = node |
||||
|
c.GRPC = client.NewGrpcClient(node) |
||||
|
|
||||
|
err := c.GRPC.Start(grpc.WithInsecure()) |
||||
|
if err != nil { |
||||
|
return nil, fmt.Errorf("grpc client start error:%v", err) |
||||
|
} |
||||
|
return c, nil |
||||
|
} |
||||
|
|
||||
|
// SetTimeout
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver c
|
||||
|
// @param timeout
|
||||
|
// @return error
|
||||
|
func (c *Client) SetTimeout(timeout time.Duration) error { |
||||
|
if c == nil { |
||||
|
return errors.New("client is nil ptr") |
||||
|
} |
||||
|
c.GRPC = client.NewGrpcClientWithTimeout(c.node, timeout) |
||||
|
err := c.GRPC.Start() |
||||
|
if err != nil { |
||||
|
return fmt.Errorf("grpc start error: %v", err) |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
// keepConnect
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver c
|
||||
|
// @return error
|
||||
|
func (c *Client) keepConnect() error { |
||||
|
_, err := c.GRPC.GetNodeInfo() |
||||
|
if err != nil { |
||||
|
if strings.Contains(err.Error(), "no such host") { |
||||
|
return c.GRPC.Reconnect(c.node) |
||||
|
} |
||||
|
return fmt.Errorf("node connect error: %v", err) |
||||
|
} |
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
// Transfer
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver c
|
||||
|
// @param from
|
||||
|
// @param to
|
||||
|
// @param amount
|
||||
|
// @return *api.TransactionExtention
|
||||
|
// @return error
|
||||
|
func (c *Client) Transfer(from, to string, amount int64) (*api.TransactionExtention, error) { |
||||
|
err := c.keepConnect() |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return c.GRPC.Transfer(from, to, amount) |
||||
|
} |
||||
|
|
||||
|
// GetTrc10Balance
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver c
|
||||
|
// @param addr
|
||||
|
// @param assetId
|
||||
|
// @return int64
|
||||
|
// @return error
|
||||
|
func (c *Client) GetTrc10Balance(addr, assetId string) (int64, error) { |
||||
|
err := c.keepConnect() |
||||
|
if err != nil { |
||||
|
return 0, err |
||||
|
} |
||||
|
acc, err := c.GRPC.GetAccount(addr) |
||||
|
if err != nil || acc == nil { |
||||
|
return 0, fmt.Errorf("get %s account error:%v", addr, err) |
||||
|
} |
||||
|
for key, value := range acc.AssetV2 { |
||||
|
if key == assetId { |
||||
|
return value, nil |
||||
|
} |
||||
|
} |
||||
|
return 0, fmt.Errorf("%s do not find this assetID=%s amount", addr, assetId) |
||||
|
} |
||||
|
|
||||
|
// GetTrxBalance
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver c
|
||||
|
// @param addr
|
||||
|
// @return *core.Account
|
||||
|
// @return error
|
||||
|
func (c *Client) GetTrxBalance(addr string) (*core.Account, error) { |
||||
|
err := c.keepConnect() |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return c.GRPC.GetAccount(addr) |
||||
|
} |
||||
|
|
||||
|
// GetTrc20Balance
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver c
|
||||
|
// @param addr
|
||||
|
// @param contractAddress
|
||||
|
// @return *big.Int
|
||||
|
// @return error
|
||||
|
func (c *Client) GetTrc20Balance(addr, contractAddress string) (*big.Int, error) { |
||||
|
err := c.keepConnect() |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
return c.GRPC.TRC20ContractBalance(addr, contractAddress) |
||||
|
} |
||||
|
|
||||
|
// TransferTrc10
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver c
|
||||
|
// @param from
|
||||
|
// @param to
|
||||
|
// @param assetId
|
||||
|
// @param amount
|
||||
|
// @return *api.TransactionExtention
|
||||
|
// @return error
|
||||
|
func (c *Client) TransferTrc10(from, to, assetId string, amount int64) (*api.TransactionExtention, error) { |
||||
|
err := c.keepConnect() |
||||
|
if err != nil { |
||||
|
return nil, err |
||||
|
} |
||||
|
fromAddr, err := address.Base58ToAddress(from) |
||||
|
if err != nil { |
||||
|
return nil, fmt.Errorf("from address is not equal") |
||||
|
} |
||||
|
toAddr, err := address.Base58ToAddress(to) |
||||
|
if err != nil { |
||||
|
return nil, fmt.Errorf("to address is not equal") |
||||
|
} |
||||
|
return c.GRPC.TransferAsset(fromAddr.String(), toAddr.String(), assetId, amount) |
||||
|
} |
||||
|
|
||||
|
// TransferTrc20
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver c
|
||||
|
// @param from
|
||||
|
// @param to
|
||||
|
// @param contract
|
||||
|
// @param amount
|
||||
|
// @param feeLimit
|
||||
|
// @return *api.TransactionExtention
|
||||
|
// @return error
|
||||
|
func (c *Client) TransferTrc20(from, to, contract string, amount *big.Int, feeLimit int64) (*api.TransactionExtention, error) { |
||||
|
err := c.keepConnect() |
||||
|
if err != nil { |
||||
|
applogger.Error("link failure:%v", err) |
||||
|
return nil, err |
||||
|
} |
||||
|
return c.GRPC.TRC20Send(from, to, contract, amount, feeLimit) |
||||
|
} |
||||
|
|
||||
|
// BroadcastTransaction
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver c
|
||||
|
// @param transaction
|
||||
|
// @return error
|
||||
|
func (c *Client) BroadcastTransaction(transaction *core.Transaction) error { |
||||
|
err := c.keepConnect() |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
result, err := c.GRPC.Broadcast(transaction) |
||||
|
if err != nil { |
||||
|
return fmt.Errorf("broadcast transaction error:%v", err) |
||||
|
} |
||||
|
if result.Code != 0 { |
||||
|
return fmt.Errorf("bad transaction:%v", string(result.GetMessage())) |
||||
|
} |
||||
|
if result.Result == true { |
||||
|
return nil |
||||
|
} |
||||
|
d, _ := json.Marshal(result) |
||||
|
return fmt.Errorf("tx send fail:%s", string(d)) |
||||
|
} |
||||
|
|
||||
|
// TRC20Approve
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver c
|
||||
|
// @param from
|
||||
|
// @param to
|
||||
|
// @param contract
|
||||
|
// @param amount
|
||||
|
// @param feeLimit
|
||||
|
// @return *api.TransactionExtention
|
||||
|
// @return error
|
||||
|
func (c *Client) TRC20Approve(from, to, contract string, amount *big.Int, feeLimit int64) (*api.TransactionExtention, error) { |
||||
|
err := c.keepConnect() |
||||
|
if err != nil { |
||||
|
applogger.Error("link failure:%v", err) |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
return c.GRPC.TRC20Approve(from, to, contract, amount, feeLimit) |
||||
|
} |
||||
|
|
||||
|
// GetContractABI .
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver c
|
||||
|
// @param contractAddress
|
||||
|
// @return *core.SmartContract_ABI
|
||||
|
// @return error
|
||||
|
func (c *Client) GetContractABI(contractAddress string) (*core.SmartContract_ABI, error) { |
||||
|
err := c.keepConnect() |
||||
|
if err != nil { |
||||
|
applogger.Error("link failure:%v", err) |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
return c.GRPC.GetContractABI(contractAddress) |
||||
|
} |
||||
|
|
||||
|
// TransferAsset from to base58 address
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver c
|
||||
|
// @param from
|
||||
|
// @param toAddress
|
||||
|
// @param assetName
|
||||
|
// @param amount
|
||||
|
// @return *api.TransactionExtention
|
||||
|
// @return error
|
||||
|
func (c *Client) TransferAsset(from, toAddress, assetName string, amount int64) (*api.TransactionExtention, error) { |
||||
|
err := c.keepConnect() |
||||
|
if err != nil { |
||||
|
applogger.Error("link failure:%v", err) |
||||
|
return nil, err |
||||
|
} |
||||
|
|
||||
|
return c.GRPC.TransferAsset(from, toAddress, assetName, amount) |
||||
|
} |
@ -0,0 +1,194 @@ |
|||||
|
package grpc |
||||
|
|
||||
|
import ( |
||||
|
"bytes" |
||||
|
"context" |
||||
|
"fmt" |
||||
|
"github.com/ethereum/go-ethereum" |
||||
|
"github.com/ethereum/go-ethereum/accounts/abi" |
||||
|
"github.com/ethereum/go-ethereum/common" |
||||
|
"github.com/ethereum/go-ethereum/rpc" |
||||
|
"math/big" |
||||
|
"testing" |
||||
|
"wallet-system/internal/pkg/contract/coin" |
||||
|
"wallet-system/internal/pkg/logging/applogger" |
||||
|
"wallet-system/internal/pkg/wallet/tron" |
||||
|
"wallet-system/internal/pkg/wallet/tron/sign" |
||||
|
) |
||||
|
|
||||
|
// TestTRC20Balance
|
||||
|
func TestTRC20Balance(t *testing.T) { |
||||
|
grpcClient, err := NewClient("grpc.shasta.trongrid.io:50051") |
||||
|
if err != nil { |
||||
|
fmt.Println("链接地址失败:", err) |
||||
|
} |
||||
|
|
||||
|
balance, err := grpcClient.GetTrc20Balance("TSNEe5Tf4rnc9zPMNXfaTF5fZfHDDH8oyW", "TTVFLcvHJfVF1JBm91eQ4aNW2qAQU2Ax3d") |
||||
|
if err != nil { |
||||
|
fmt.Println("grpc客户端:", err) |
||||
|
} |
||||
|
|
||||
|
fmt.Println("查询可用余额:", balance) |
||||
|
} |
||||
|
|
||||
|
// TestGetContractABI
|
||||
|
func TestGetContractABI(t *testing.T) { |
||||
|
grpcClient, err := NewClient("grpc.shasta.trongrid.io:50051") |
||||
|
if err != nil { |
||||
|
fmt.Println("链接地址失败:", err) |
||||
|
} |
||||
|
|
||||
|
abi, err := grpcClient.GetContractABI("TTVFLcvHJfVF1JBm91eQ4aNW2qAQU2Ax3d") |
||||
|
if err != nil { |
||||
|
|
||||
|
fmt.Println("获取合约ABI信息:", err) |
||||
|
} |
||||
|
fmt.Println("数据展示:", abi.String()) |
||||
|
} |
||||
|
|
||||
|
// TestContractApprove 授权设置
|
||||
|
func TestContractApprove(t *testing.T) { |
||||
|
// 创建一个 Tron 客户端
|
||||
|
client, err := NewClient("grpc.shasta.trongrid.io:50051") |
||||
|
if err != nil { |
||||
|
applogger.Error("链接地址错误:%v", err) |
||||
|
return |
||||
|
} |
||||
|
fmt.Println("链接客户端:", client) |
||||
|
|
||||
|
// from地址,to地址,合约地址,转账金额
|
||||
|
from := "TM9xH19dZtTVszRVfQgrTEqxqhbyzqnPxi" |
||||
|
to := "TWqpv3h4Vc3KosHhn4tpSRiuayaVLQF9Xe" |
||||
|
contractAddress := "TU1vLr6K4XF8Uddqj8PXr3pSENVb3teY4J" |
||||
|
amount := big.NewInt(300000000) |
||||
|
|
||||
|
// 授权账号信息
|
||||
|
tx, err := client.TRC20Approve(from, to, contractAddress, amount, int64(15000000000)) |
||||
|
if err != nil { |
||||
|
applogger.Error("TRC20Approve 授权:%v", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
applogger.Debug("授权转账:%v", tx.Transaction) |
||||
|
|
||||
|
privateKey := "08b407316ddec4a164d6bbc09357591df580ac380a93f898ddc16e0e11f830c9" |
||||
|
|
||||
|
signTx, err := sign.SignTransaction(tx.Transaction, privateKey) |
||||
|
if err != nil { |
||||
|
applogger.Error("签名失败:%v", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
if err = client.BroadcastTransaction(signTx); err != nil { |
||||
|
applogger.Error("上链失败:%v", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
applogger.Debug("授权转账信息:%v", tron.Encode(tx.GetTxid())) |
||||
|
} |
||||
|
|
||||
|
func TestTRC20Transfer(t *testing.T) { |
||||
|
// 创建一个 Tron 客户端
|
||||
|
client, err := NewClient("grpc.shasta.trongrid.io:50051") |
||||
|
if err != nil { |
||||
|
applogger.Error("链接地址错误:%v", err) |
||||
|
return |
||||
|
} |
||||
|
fmt.Println("链接客户端:", client) |
||||
|
|
||||
|
// from地址,to地址,合约地址,转账金额
|
||||
|
from := "TVBdbsmp67P76gCxGgLa2dHGJFjyXw5X5Z" |
||||
|
to := "TM9xH19dZtTVszRVfQgrTEqxqhbyzqnPxi" |
||||
|
amount := big.NewInt(100000000) |
||||
|
|
||||
|
tx, err := client.Transfer(from, to, amount.Int64()) |
||||
|
if err != nil { |
||||
|
applogger.Error("转账失败:%v", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
privateKey := "5a79d71f2458d07b7d088bb126c03dd0252e7faa1cc60358830563f74ce508af" |
||||
|
|
||||
|
signTx, err := sign.SignTransaction(tx.Transaction, privateKey) |
||||
|
if err != nil { |
||||
|
applogger.Error("签名失败:%v", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
if err = client.BroadcastTransaction(signTx); err != nil { |
||||
|
applogger.Error("上链失败:%v", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
applogger.Debug("授权转账信息:%v", tron.Encode(tx.GetTxid())) |
||||
|
} |
||||
|
|
||||
|
// TestTRC20TransferTest 授权之后如何将授权额度转出
|
||||
|
func TestTRC20TransferTest(t *testing.T) { |
||||
|
// 创建一个 Tron 客户端
|
||||
|
client, err := NewClient("grpc.shasta.trongrid.io:50051") |
||||
|
if err != nil { |
||||
|
applogger.Error("链接地址错误:%v", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// from授权地址,to接受地址, 合约地址, 授权额度
|
||||
|
from := "TWqpv3h4Vc3KosHhn4tpSRiuayaVLQF9Xe" |
||||
|
to := "TEBZJWzTEezZ4CdZZC91J6zb2MwwqAfoBa" |
||||
|
contractAddress := "TU1vLr6K4XF8Uddqj8PXr3pSENVb3teY4J" |
||||
|
amount := big.NewInt(10000000) |
||||
|
|
||||
|
// 授权账号信息
|
||||
|
tx, err := client.TransferAsset(from, to, contractAddress, amount.Int64()) |
||||
|
if err != nil { |
||||
|
applogger.Error("TransferAsset 转账:%v", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
applogger.Debug("转账失败:%v", tx.Transaction) |
||||
|
|
||||
|
privateKey := "1e65c007c7e68d2b51e2610d610afbe1be232b893017bbd287336b9ef494f007" |
||||
|
|
||||
|
signTx, err := sign.SignTransaction(tx.Transaction, privateKey) |
||||
|
if err != nil { |
||||
|
applogger.Error("签名失败:%v", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
if err = client.BroadcastTransaction(signTx); err != nil { |
||||
|
applogger.Error("上链失败:%v", err) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
applogger.Debug("授权转账信息:%v", tron.Encode(tx.GetTxid())) |
||||
|
} |
||||
|
|
||||
|
// TestWeb3Trc20 使用web3调用地址
|
||||
|
func TestWeb3Trc20(t *testing.T) { |
||||
|
tronNodeURL := "http://localhost:8090" // 替换为实际的Tron节点URL
|
||||
|
client, err := rpc.Dial(tronNodeURL) |
||||
|
if err != nil { |
||||
|
// 处理错误
|
||||
|
} |
||||
|
contractABI, err := abi.JSON(bytes.NewReader([]byte(coin.ContractABI))) // 替换为智能合约的ABI定义
|
||||
|
if err != nil { |
||||
|
// 处理错误
|
||||
|
} |
||||
|
contractAddress := common.HexToAddress("TU1vLr6K4XF8Uddqj8PXr3pSENVb3teY4J") // 替换为实际的合约地址
|
||||
|
methodName := "myMethod" // 替换为合约的方法名
|
||||
|
input, err := contractABI.Methods[methodName].Inputs.Pack("aaaa") // 替换为传入合约方法的参数
|
||||
|
if err != nil { |
||||
|
// 处理错误
|
||||
|
} |
||||
|
|
||||
|
msg := ethereum.CallMsg{ |
||||
|
To: &contractAddress, |
||||
|
Data: input, |
||||
|
} |
||||
|
|
||||
|
err = client.CallContext(context.Background(), msg, methodName, nil) |
||||
|
if err != nil { |
||||
|
// 处理错误
|
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,55 @@ |
|||||
|
package sign |
||||
|
|
||||
|
import ( |
||||
|
"crypto/ecdsa" |
||||
|
"crypto/sha256" |
||||
|
"encoding/hex" |
||||
|
"errors" |
||||
|
"fmt" |
||||
|
"github.com/ethereum/go-ethereum/crypto" |
||||
|
"github.com/fbsobreira/gotron-sdk/pkg/proto/core" |
||||
|
"google.golang.org/protobuf/proto" |
||||
|
) |
||||
|
|
||||
|
// SignTransaction
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param transaction
|
||||
|
// @param privateKey
|
||||
|
// @return *core.Transaction
|
||||
|
// @return error
|
||||
|
func SignTransaction(transaction *core.Transaction, privateKey string) (*core.Transaction, error) { |
||||
|
privateBytes, err := hex.DecodeString(privateKey) |
||||
|
if err != nil { |
||||
|
return nil, errors.New(fmt.Errorf("hex decode private key error:%v", err).Error()) |
||||
|
} |
||||
|
prIv := crypto.ToECDSAUnsafe(privateBytes) |
||||
|
defer zeroKey(prIv) |
||||
|
|
||||
|
rawData, err := proto.Marshal(transaction.GetRawData()) |
||||
|
if err != nil { |
||||
|
return nil, errors.New(fmt.Errorf("proto marshal tx raw data error:%v", err).Error()) |
||||
|
} |
||||
|
|
||||
|
h256h := sha256.New() |
||||
|
h256h.Write(rawData) |
||||
|
hash := h256h.Sum(nil) |
||||
|
signature, err := crypto.Sign(hash, prIv) |
||||
|
if err != nil { |
||||
|
return nil, errors.New(err.Error()) |
||||
|
} |
||||
|
transaction.Signature = append(transaction.Signature, signature) |
||||
|
|
||||
|
return transaction, nil |
||||
|
} |
||||
|
|
||||
|
// zeroKey
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param k
|
||||
|
func zeroKey(k *ecdsa.PrivateKey) { |
||||
|
b := k.D.Bits() |
||||
|
for i := range b { |
||||
|
b[i] = 0 |
||||
|
} |
||||
|
} |
@ -0,0 +1,52 @@ |
|||||
|
package sign |
||||
|
|
||||
|
import ( |
||||
|
"crypto/ecdsa" |
||||
|
"github.com/fbsobreira/gotron-sdk/pkg/proto/core" |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
) |
||||
|
|
||||
|
func TestSignTransaction(t *testing.T) { |
||||
|
type args struct { |
||||
|
transaction *core.Transaction |
||||
|
privateKey string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *core.Transaction |
||||
|
wantErr bool |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
got, err := SignTransaction(tt.args.transaction, tt.args.privateKey) |
||||
|
if (err != nil) != tt.wantErr { |
||||
|
t.Errorf("SignTransaction() error = %v, wantErr %v", err, tt.wantErr) |
||||
|
return |
||||
|
} |
||||
|
if !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("SignTransaction() got = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func Test_zeroKey(t *testing.T) { |
||||
|
type args struct { |
||||
|
k *ecdsa.PrivateKey |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
zeroKey(tt.args.k) |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package server |
||||
|
|
||||
|
import ( |
||||
|
"github.com/go-kratos/kratos/v2/log" |
||||
|
"github.com/go-kratos/kratos/v2/middleware/recovery" |
||||
|
"github.com/go-kratos/kratos/v2/transport/grpc" |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/service" |
||||
|
|
||||
|
v1 "wallet-system/api/walletSystem/v1" |
||||
|
) |
||||
|
|
||||
|
// NewGRPCServer new a gRPC server.
|
||||
|
func NewGRPCServer(c *conf.Server, wallet *service.WalletService, logger log.Logger) *grpc.Server { |
||||
|
var opts = []grpc.ServerOption{ |
||||
|
grpc.Middleware( |
||||
|
recovery.Recovery(), |
||||
|
), |
||||
|
} |
||||
|
if c.Grpc.Network != "" { |
||||
|
opts = append(opts, grpc.Network(c.Grpc.Network)) |
||||
|
} |
||||
|
if c.Grpc.Addr != "" { |
||||
|
opts = append(opts, grpc.Address(c.Grpc.Addr)) |
||||
|
} |
||||
|
srv := grpc.NewServer(opts...) |
||||
|
v1.RegisterWalletServer(srv, wallet) |
||||
|
return srv |
||||
|
} |
@ -0,0 +1,38 @@ |
|||||
|
package server |
||||
|
|
||||
|
import ( |
||||
|
"github.com/go-kratos/kratos/v2/log" |
||||
|
"github.com/go-kratos/kratos/v2/middleware/logging" |
||||
|
"github.com/go-kratos/kratos/v2/middleware/recovery" |
||||
|
"github.com/go-kratos/kratos/v2/transport/http" |
||||
|
"github.com/gorilla/handlers" |
||||
|
"wallet-system/internal/conf" |
||||
|
"wallet-system/internal/service" |
||||
|
|
||||
|
v1 "wallet-system/api/walletSystem/v1" |
||||
|
) |
||||
|
|
||||
|
// NewHTTPServer new an HTTP server.
|
||||
|
func NewHTTPServer(c *conf.Server, wallet *service.WalletService, logger log.Logger) *http.Server { |
||||
|
var opts = []http.ServerOption{ |
||||
|
http.Middleware( |
||||
|
recovery.Recovery(), |
||||
|
logging.Server(logger), |
||||
|
), |
||||
|
http.Filter(handlers.CORS( |
||||
|
handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization", "token", "Language"}), |
||||
|
handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "OPTIONS"}), |
||||
|
handlers.AllowedOrigins([]string{"*"}), |
||||
|
handlers.AllowCredentials(), |
||||
|
)), |
||||
|
} |
||||
|
if c.Http.Network != "" { |
||||
|
opts = append(opts, http.Network(c.Http.Network)) |
||||
|
} |
||||
|
if c.Http.Addr != "" { |
||||
|
opts = append(opts, http.Address(c.Http.Addr)) |
||||
|
} |
||||
|
srv := http.NewServer(opts...) |
||||
|
v1.RegisterWalletHTTPServer(srv, wallet) |
||||
|
return srv |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package server |
||||
|
|
||||
|
import ( |
||||
|
"github.com/google/wire" |
||||
|
) |
||||
|
|
||||
|
// ProviderSet is server providers.
|
||||
|
var ProviderSet = wire.NewSet(NewGRPCServer, NewHTTPServer) |
@ -0,0 +1 @@ |
|||||
|
# Service |
@ -0,0 +1,100 @@ |
|||||
|
package result |
||||
|
|
||||
|
import ( |
||||
|
"net/http" |
||||
|
|
||||
|
v1 "wallet-system/api/walletSystem/v1" |
||||
|
) |
||||
|
|
||||
|
// CodeResult
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param check
|
||||
|
// @return uint32
|
||||
|
func CodeResult(check bool) uint32 { |
||||
|
var code int |
||||
|
switch check { |
||||
|
case true: |
||||
|
code = http.StatusOK |
||||
|
case false: |
||||
|
code = http.StatusBadRequest |
||||
|
default: |
||||
|
code = http.StatusBadRequest |
||||
|
} |
||||
|
return uint32(code) |
||||
|
} |
||||
|
|
||||
|
// WalletReplyErrorResult
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param check
|
||||
|
// @param data
|
||||
|
// @param ret
|
||||
|
// @return *v1.WalletReply
|
||||
|
func WalletReplyErrorResult(check bool, data []string, ret string) *v1.WalletReply { |
||||
|
return &v1.WalletReply{ |
||||
|
Code: CodeResult(check), |
||||
|
Data: data, |
||||
|
Message: ret, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// WalletKeyReplyErrorResult
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param check
|
||||
|
// @param data
|
||||
|
// @param ret
|
||||
|
// @return *v1.WalletKeyReply
|
||||
|
func WalletKeyReplyErrorResult(check bool, data []*v1.Keys, ret string) *v1.WalletKeyReply { |
||||
|
return &v1.WalletKeyReply{ |
||||
|
Code: CodeResult(check), |
||||
|
Data: data, |
||||
|
Message: ret, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// WalletPKeysReplyErrorResult
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param check
|
||||
|
// @param data
|
||||
|
// @param ret
|
||||
|
// @return *v1.WalletPKeysReply
|
||||
|
func WalletPKeysReplyErrorResult(check bool, data string, ret string) *v1.WalletPKeysReply { |
||||
|
return &v1.WalletPKeysReply{ |
||||
|
Code: CodeResult(check), |
||||
|
Data: data, |
||||
|
Message: ret, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// SignatureTrc20GrpcResult
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param check
|
||||
|
// @param data
|
||||
|
// @param ret
|
||||
|
// @return *v1.SignatureTrc20Reply
|
||||
|
func SignatureTrc20GrpcResult(check bool, data *v1.Data, ret string) *v1.SignatureTrc20Reply { |
||||
|
return &v1.SignatureTrc20Reply{ |
||||
|
Code: CodeResult(check), |
||||
|
Data: data, |
||||
|
Message: ret, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// WalletApproveResult
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param check
|
||||
|
// @param data
|
||||
|
// @param ret
|
||||
|
// @return *v1.WalletApproveReply
|
||||
|
func WalletApproveResult(check bool, data []byte, ret string) *v1.WalletApproveReply { |
||||
|
return &v1.WalletApproveReply{ |
||||
|
Code: CodeResult(check), |
||||
|
Data: data, |
||||
|
Message: ret, |
||||
|
} |
||||
|
} |
@ -0,0 +1,137 @@ |
|||||
|
package result |
||||
|
|
||||
|
import ( |
||||
|
"reflect" |
||||
|
"testing" |
||||
|
v1 "wallet-system/api/walletSystem/v1" |
||||
|
) |
||||
|
|
||||
|
func TestCodeResult(t *testing.T) { |
||||
|
type args struct { |
||||
|
check bool |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want uint32 |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := CodeResult(tt.args.check); got != tt.want { |
||||
|
t.Errorf("CodeResult() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestSignatureTrc20GrpcResult(t *testing.T) { |
||||
|
type args struct { |
||||
|
check bool |
||||
|
data *v1.Data |
||||
|
ret string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *v1.SignatureTrc20Reply |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := SignatureTrc20GrpcResult(tt.args.check, tt.args.data, tt.args.ret); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("SignatureTrc20GrpcResult() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestWalletApproveResult(t *testing.T) { |
||||
|
type args struct { |
||||
|
check bool |
||||
|
data []byte |
||||
|
ret string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *v1.WalletApproveReply |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := WalletApproveResult(tt.args.check, tt.args.data, tt.args.ret); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("WalletApproveResult() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestWalletKeyReplyErrorResult(t *testing.T) { |
||||
|
type args struct { |
||||
|
check bool |
||||
|
data []*v1.Keys |
||||
|
ret string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *v1.WalletKeyReply |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := WalletKeyReplyErrorResult(tt.args.check, tt.args.data, tt.args.ret); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("WalletKeyReplyErrorResult() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestWalletPKeysReplyErrorResult(t *testing.T) { |
||||
|
type args struct { |
||||
|
check bool |
||||
|
data string |
||||
|
ret string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *v1.WalletPKeysReply |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := WalletPKeysReplyErrorResult(tt.args.check, tt.args.data, tt.args.ret); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("WalletPKeysReplyErrorResult() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestWalletReplyErrorResult(t *testing.T) { |
||||
|
type args struct { |
||||
|
check bool |
||||
|
data []string |
||||
|
ret string |
||||
|
} |
||||
|
tests := []struct { |
||||
|
name string |
||||
|
args args |
||||
|
want *v1.WalletReply |
||||
|
}{ |
||||
|
// TODO: Add test cases.
|
||||
|
} |
||||
|
for _, tt := range tests { |
||||
|
t.Run(tt.name, func(t *testing.T) { |
||||
|
if got := WalletReplyErrorResult(tt.args.check, tt.args.data, tt.args.ret); !reflect.DeepEqual(got, tt.want) { |
||||
|
t.Errorf("WalletReplyErrorResult() = %v, want %v", got, tt.want) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package service |
||||
|
|
||||
|
import ( |
||||
|
"github.com/google/wire" |
||||
|
) |
||||
|
|
||||
|
// ProviderSet is service providers.
|
||||
|
var ProviderSet = wire.NewSet(NewWalletService) |
@ -0,0 +1,92 @@ |
|||||
|
package validation |
||||
|
|
||||
|
import ( |
||||
|
"errors" |
||||
|
"fmt" |
||||
|
|
||||
|
v1 "wallet-system/api/walletSystem/v1" |
||||
|
) |
||||
|
|
||||
|
var ps = fmt.Sprintf |
||||
|
var parameterV = "Parameter verification error." |
||||
|
var Success = "success" |
||||
|
|
||||
|
// GenerateAddressValidation 验证生成钱包地址参数
|
||||
|
func GenerateAddressValidation(in *v1.GenerateAddressRequest) error { |
||||
|
if len(in.Wallet) <= 0 { |
||||
|
return errors.New(ps("wallet err=%v", parameterV)) |
||||
|
} |
||||
|
if in.Number <= 0 { |
||||
|
return errors.New(ps("number err=%v", parameterV)) |
||||
|
} |
||||
|
|
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
// SignatureTrc20GrpcValidation 验证签名参数
|
||||
|
func SignatureTrc20GrpcValidation(in *v1.SignatureTrc20Request) error { |
||||
|
if len(in.From) <= 0 { |
||||
|
return errors.New(ps("from err=%v", parameterV)) |
||||
|
} |
||||
|
if len(in.To) <= 0 { |
||||
|
return errors.New(ps("to err=%v", parameterV)) |
||||
|
} |
||||
|
if in.Amount <= 0 { |
||||
|
return errors.New(ps("amount err=%v", parameterV)) |
||||
|
} |
||||
|
if in.FeeLimit <= 0 { |
||||
|
return errors.New(ps("fee_limit err=%v", parameterV)) |
||||
|
} |
||||
|
|
||||
|
switch in.TrcCheck { |
||||
|
case "Trx": |
||||
|
return nil |
||||
|
case "Trc20": |
||||
|
if len(in.Contract) <= 0 { |
||||
|
return errors.New(ps("contract err=%v", parameterV)) |
||||
|
} |
||||
|
default: |
||||
|
return errors.New(ps("trc_check err=%v", parameterV)) |
||||
|
} |
||||
|
|
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
// GetPrivateKeyByAddressValidation 验证钱包地址参数
|
||||
|
func GetPrivateKeyByAddressValidation(in *v1.GetPrivateKeyByAddressRequest) error { |
||||
|
if len(in.Address) <= 0 { |
||||
|
return errors.New(ps("address err=%v", parameterV)) |
||||
|
|
||||
|
} |
||||
|
|
||||
|
return nil |
||||
|
} |
||||
|
|
||||
|
// WalletApproveValidation 验证签名参数
|
||||
|
func WalletApproveValidation(in *v1.WalletApproveRequest) error { |
||||
|
if len(in.From) <= 0 { |
||||
|
return errors.New(ps("from err=%v", parameterV)) |
||||
|
} |
||||
|
if len(in.To) <= 0 { |
||||
|
return errors.New(ps("to err=%v", parameterV)) |
||||
|
} |
||||
|
if in.Amount <= 0 { |
||||
|
return errors.New(ps("amount err=%v", parameterV)) |
||||
|
} |
||||
|
if in.FeeLimit <= 0 { |
||||
|
return errors.New(ps("fee_limit err=%v", parameterV)) |
||||
|
} |
||||
|
|
||||
|
switch in.TrcCheck { |
||||
|
case "Trx": |
||||
|
return nil |
||||
|
case "Trc20": |
||||
|
if len(in.Contract) <= 0 { |
||||
|
return errors.New(ps("contract err=%v", parameterV)) |
||||
|
} |
||||
|
default: |
||||
|
return errors.New(ps("trc_check err=%v", parameterV)) |
||||
|
} |
||||
|
|
||||
|
return nil |
||||
|
} |
@ -0,0 +1,223 @@ |
|||||
|
package service |
||||
|
|
||||
|
import ( |
||||
|
"bytes" |
||||
|
"context" |
||||
|
"net/http" |
||||
|
"wallet-system/internal/biz" |
||||
|
"wallet-system/internal/service/result" |
||||
|
"wallet-system/internal/service/validation" |
||||
|
|
||||
|
v1 "wallet-system/api/walletSystem/v1" |
||||
|
) |
||||
|
|
||||
|
// WalletService
|
||||
|
// @Description:
|
||||
|
type WalletService struct { |
||||
|
v1.UnimplementedWalletServer |
||||
|
|
||||
|
uc *biz.WalletInfo |
||||
|
} |
||||
|
|
||||
|
// NewWalletService
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @param uc
|
||||
|
// @return *WalletService
|
||||
|
func NewWalletService(uc *biz.WalletInfo) *WalletService { |
||||
|
return &WalletService{uc: uc} |
||||
|
} |
||||
|
|
||||
|
// GenerateAddress
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver s
|
||||
|
// @param ctx
|
||||
|
// @param in
|
||||
|
// @return *v1.WalletReply
|
||||
|
// @return error
|
||||
|
func (s *WalletService) GenerateAddress(ctx context.Context, in *v1.GenerateAddressRequest) (*v1.WalletReply, error) { |
||||
|
if err := validation.GenerateAddressValidation(in); err != nil { |
||||
|
return result.WalletReplyErrorResult(false, []string{}, err.Error()), err |
||||
|
} |
||||
|
|
||||
|
data, err := s.uc.GenerateAddress(ctx, in.Wallet, in.Number) |
||||
|
if err != nil { |
||||
|
return result.WalletReplyErrorResult(false, []string{}, err.Error()), err |
||||
|
} |
||||
|
|
||||
|
return &v1.WalletReply{ |
||||
|
Code: http.StatusOK, |
||||
|
Data: data, |
||||
|
Message: validation.Success, |
||||
|
}, nil |
||||
|
} |
||||
|
|
||||
|
// SignatureTrc20Grpc
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver s
|
||||
|
// @param ctx
|
||||
|
// @param in
|
||||
|
// @return *v1.SignatureTrc20Reply
|
||||
|
// @return error
|
||||
|
func (s *WalletService) SignatureTrc20Grpc(ctx context.Context, in *v1.SignatureTrc20Request) (*v1.SignatureTrc20Reply, error) { |
||||
|
if err := validation.SignatureTrc20GrpcValidation(in); err != nil { |
||||
|
return result.SignatureTrc20GrpcResult(false, &v1.Data{}, err.Error()), err |
||||
|
} |
||||
|
|
||||
|
check, data, err := s.uc.SignatureTrc20Grpc(ctx, &biz.Wallet{ |
||||
|
From: in.From, |
||||
|
To: in.To, |
||||
|
Amount: in.Amount, |
||||
|
Contract: in.Contract, |
||||
|
TrcCheck: in.TrcCheck, |
||||
|
TokenId: in.TokenId, |
||||
|
FeeLimit: in.FeeLimit, |
||||
|
}) |
||||
|
if err != nil { |
||||
|
return result.SignatureTrc20GrpcResult(false, &v1.Data{}, err.Error()), err |
||||
|
} |
||||
|
|
||||
|
return &v1.SignatureTrc20Reply{ |
||||
|
Code: http.StatusOK, |
||||
|
Data: &v1.Data{ |
||||
|
Result: check, |
||||
|
TxId: data, |
||||
|
}, |
||||
|
Message: validation.Success, |
||||
|
}, nil |
||||
|
} |
||||
|
|
||||
|
// GetAllAddress
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver s
|
||||
|
// @param ctx
|
||||
|
// @param in
|
||||
|
// @return *v1.WalletReply
|
||||
|
// @return error
|
||||
|
func (s *WalletService) GetAllAddress(ctx context.Context, in *v1.WalletRequest) (*v1.WalletReply, error) { |
||||
|
data, err := s.uc.GetAllAddress(ctx) |
||||
|
if err != nil { |
||||
|
return result.WalletReplyErrorResult(false, []string{}, err.Error()), err |
||||
|
} |
||||
|
|
||||
|
return &v1.WalletReply{ |
||||
|
Code: http.StatusOK, |
||||
|
Data: data, |
||||
|
Message: validation.Success, |
||||
|
}, nil |
||||
|
} |
||||
|
|
||||
|
// GetAllAddressAndPrivateKey
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver s
|
||||
|
// @param ctx
|
||||
|
// @param in
|
||||
|
// @return *v1.WalletKeyReply
|
||||
|
// @return error
|
||||
|
func (s *WalletService) GetAllAddressAndPrivateKey(ctx context.Context, in *v1.WalletRequest) (*v1.WalletKeyReply, error) { |
||||
|
data, err := s.uc.GetAllAddressAndPrivateKey(ctx) |
||||
|
if err != nil { |
||||
|
return result.WalletKeyReplyErrorResult(false, []*v1.Keys{}, err.Error()), err |
||||
|
} |
||||
|
|
||||
|
var keys []*v1.Keys |
||||
|
for key, value := range data { |
||||
|
var b bytes.Buffer |
||||
|
b.Write(value) |
||||
|
bytesData := b.Bytes() |
||||
|
|
||||
|
vue := &v1.Keys{ |
||||
|
Key: key, |
||||
|
Value: bytesData, |
||||
|
} |
||||
|
keys = append(keys, vue) |
||||
|
} |
||||
|
|
||||
|
return &v1.WalletKeyReply{ |
||||
|
Code: http.StatusOK, |
||||
|
Data: keys, |
||||
|
Message: validation.Success, |
||||
|
}, nil |
||||
|
} |
||||
|
|
||||
|
// GetPrivateKeyByAddress
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver s
|
||||
|
// @param ctx
|
||||
|
// @param in
|
||||
|
// @return *v1.WalletPKeysReply
|
||||
|
// @return error
|
||||
|
func (s *WalletService) GetPrivateKeyByAddress(ctx context.Context, in *v1.GetPrivateKeyByAddressRequest) (*v1.WalletPKeysReply, error) { |
||||
|
if err := validation.GetPrivateKeyByAddressValidation(in); err != nil { |
||||
|
return result.WalletPKeysReplyErrorResult(false, "", err.Error()), err |
||||
|
} |
||||
|
|
||||
|
data, err := s.uc.GetPrivateKeyByAddress(ctx, in.Address) |
||||
|
if err != nil { |
||||
|
return result.WalletPKeysReplyErrorResult(false, "", err.Error()), err |
||||
|
} |
||||
|
|
||||
|
return &v1.WalletPKeysReply{ |
||||
|
Code: http.StatusOK, |
||||
|
Data: data, |
||||
|
Message: validation.Success, |
||||
|
}, nil |
||||
|
} |
||||
|
|
||||
|
// DeleteAddress
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver s
|
||||
|
// @param ctx
|
||||
|
// @param in
|
||||
|
// @return *v1.WalletReply
|
||||
|
// @return error
|
||||
|
func (s *WalletService) DeleteAddress(ctx context.Context, in *v1.WalletRequest) (*v1.WalletReply, error) { |
||||
|
if err := s.uc.DeleteAddress(ctx); err != nil { |
||||
|
return result.WalletReplyErrorResult(false, []string{}, err.Error()), err |
||||
|
} |
||||
|
|
||||
|
return &v1.WalletReply{ |
||||
|
Code: http.StatusOK, |
||||
|
Data: []string{}, |
||||
|
Message: validation.Success, |
||||
|
}, nil |
||||
|
} |
||||
|
|
||||
|
// WalletApprove
|
||||
|
//
|
||||
|
// @Description:
|
||||
|
// @receiver s
|
||||
|
// @param ctx
|
||||
|
// @param in
|
||||
|
// @return *v1.WalletApproveReply
|
||||
|
// @return error
|
||||
|
func (s *WalletService) WalletApprove(ctx context.Context, in *v1.WalletApproveRequest) (*v1.WalletApproveReply, error) { |
||||
|
if err := validation.WalletApproveValidation(in); err != nil { |
||||
|
return result.WalletApproveResult(false, []byte{}, err.Error()), err |
||||
|
} |
||||
|
|
||||
|
check, data, err := s.uc.WalletApprove(ctx, &biz.Wallet{ |
||||
|
From: in.From, |
||||
|
To: in.To, |
||||
|
Amount: in.Amount, |
||||
|
Contract: in.Contract, |
||||
|
TrcCheck: in.TrcCheck, |
||||
|
TokenId: in.TokenId, |
||||
|
FeeLimit: in.FeeLimit, |
||||
|
}) |
||||
|
if err != nil || !check { |
||||
|
return result.WalletApproveResult(false, []byte{}, err.Error()), err |
||||
|
} |
||||
|
|
||||
|
return &v1.WalletApproveReply{ |
||||
|
Code: http.StatusOK, |
||||
|
Data: data, |
||||
|
Message: validation.Success, |
||||
|
}, nil |
||||
|
} |
@ -0,0 +1,270 @@ |
|||||
|
# Generated with protoc-gen-openapi |
||||
|
# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi |
||||
|
|
||||
|
openapi: 3.0.3 |
||||
|
info: |
||||
|
title: Wallet API |
||||
|
description: The greeting service definition. |
||||
|
version: 0.0.1 |
||||
|
paths: |
||||
|
/wallet/allAddress: |
||||
|
post: |
||||
|
tags: |
||||
|
- Wallet |
||||
|
description: GetAllAddress Check all wallet addresses |
||||
|
operationId: Wallet_GetAllAddress |
||||
|
requestBody: |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.WalletRequest' |
||||
|
required: true |
||||
|
responses: |
||||
|
"200": |
||||
|
description: OK |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.WalletReply' |
||||
|
/wallet/allAddressAndPrivateKey: |
||||
|
post: |
||||
|
tags: |
||||
|
- Wallet |
||||
|
description: GetAllAddressAndPrivateKey Query all private keys |
||||
|
operationId: Wallet_GetAllAddressAndPrivateKey |
||||
|
requestBody: |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.WalletRequest' |
||||
|
required: true |
||||
|
responses: |
||||
|
"200": |
||||
|
description: OK |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.WalletKeyReply' |
||||
|
/wallet/allDeleteAddress: |
||||
|
post: |
||||
|
tags: |
||||
|
- Wallet |
||||
|
description: DeleteAddress Clean all wallets |
||||
|
operationId: Wallet_DeleteAddress |
||||
|
requestBody: |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.WalletRequest' |
||||
|
required: true |
||||
|
responses: |
||||
|
"200": |
||||
|
description: OK |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.WalletReply' |
||||
|
/wallet/generateAddress: |
||||
|
post: |
||||
|
tags: |
||||
|
- Wallet |
||||
|
description: GenerateAddress Generate wallet address |
||||
|
operationId: Wallet_GenerateAddress |
||||
|
requestBody: |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.GenerateAddressRequest' |
||||
|
required: true |
||||
|
responses: |
||||
|
"200": |
||||
|
description: OK |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.WalletReply' |
||||
|
/wallet/privateKeyByAddress: |
||||
|
post: |
||||
|
tags: |
||||
|
- Wallet |
||||
|
description: GetPrivateKeyByAddress Query private key through wallet address |
||||
|
operationId: Wallet_GetPrivateKeyByAddress |
||||
|
requestBody: |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.GetPrivateKeyByAddressRequest' |
||||
|
required: true |
||||
|
responses: |
||||
|
"200": |
||||
|
description: OK |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.WalletPKeysReply' |
||||
|
/wallet/signatureTrc20Grpc: |
||||
|
post: |
||||
|
tags: |
||||
|
- Wallet |
||||
|
description: SignatureTrc20Grpc GrpcTrc20 Wallet Signature |
||||
|
operationId: Wallet_SignatureTrc20Grpc |
||||
|
requestBody: |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.SignatureTrc20Request' |
||||
|
required: true |
||||
|
responses: |
||||
|
"200": |
||||
|
description: OK |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.SignatureTrc20Reply' |
||||
|
/wallet/walletApprove: |
||||
|
post: |
||||
|
tags: |
||||
|
- Wallet |
||||
|
description: WalletApprove Wallet authorization |
||||
|
operationId: Wallet_WalletApprove |
||||
|
requestBody: |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.WalletApproveRequest' |
||||
|
required: true |
||||
|
responses: |
||||
|
"200": |
||||
|
description: OK |
||||
|
content: |
||||
|
application/json: |
||||
|
schema: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.WalletApproveReply' |
||||
|
components: |
||||
|
schemas: |
||||
|
walletSystem.v1.Data: |
||||
|
type: object |
||||
|
properties: |
||||
|
Result: |
||||
|
type: boolean |
||||
|
TxId: |
||||
|
type: string |
||||
|
walletSystem.v1.GenerateAddressRequest: |
||||
|
type: object |
||||
|
properties: |
||||
|
wallet: |
||||
|
type: string |
||||
|
number: |
||||
|
type: integer |
||||
|
format: uint32 |
||||
|
walletSystem.v1.GetPrivateKeyByAddressRequest: |
||||
|
type: object |
||||
|
properties: |
||||
|
address: |
||||
|
type: string |
||||
|
walletSystem.v1.Keys: |
||||
|
type: object |
||||
|
properties: |
||||
|
key: |
||||
|
type: string |
||||
|
value: |
||||
|
type: string |
||||
|
format: bytes |
||||
|
walletSystem.v1.SignatureTrc20Reply: |
||||
|
type: object |
||||
|
properties: |
||||
|
code: |
||||
|
type: integer |
||||
|
format: uint32 |
||||
|
data: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.Data' |
||||
|
message: |
||||
|
type: string |
||||
|
walletSystem.v1.SignatureTrc20Request: |
||||
|
type: object |
||||
|
properties: |
||||
|
from: |
||||
|
type: string |
||||
|
to: |
||||
|
type: string |
||||
|
contract: |
||||
|
type: string |
||||
|
amount: |
||||
|
type: integer |
||||
|
format: uint32 |
||||
|
trcCheck: |
||||
|
type: string |
||||
|
tokenId: |
||||
|
type: string |
||||
|
feeLimit: |
||||
|
type: integer |
||||
|
format: uint32 |
||||
|
walletSystem.v1.WalletApproveReply: |
||||
|
type: object |
||||
|
properties: |
||||
|
code: |
||||
|
type: integer |
||||
|
format: uint32 |
||||
|
data: |
||||
|
type: string |
||||
|
format: bytes |
||||
|
message: |
||||
|
type: string |
||||
|
walletSystem.v1.WalletApproveRequest: |
||||
|
type: object |
||||
|
properties: |
||||
|
from: |
||||
|
type: string |
||||
|
to: |
||||
|
type: string |
||||
|
contract: |
||||
|
type: string |
||||
|
amount: |
||||
|
type: integer |
||||
|
format: uint32 |
||||
|
trcCheck: |
||||
|
type: string |
||||
|
tokenId: |
||||
|
type: string |
||||
|
feeLimit: |
||||
|
type: integer |
||||
|
format: uint32 |
||||
|
walletSystem.v1.WalletKeyReply: |
||||
|
type: object |
||||
|
properties: |
||||
|
code: |
||||
|
type: integer |
||||
|
format: uint32 |
||||
|
data: |
||||
|
type: array |
||||
|
items: |
||||
|
$ref: '#/components/schemas/walletSystem.v1.Keys' |
||||
|
message: |
||||
|
type: string |
||||
|
walletSystem.v1.WalletPKeysReply: |
||||
|
type: object |
||||
|
properties: |
||||
|
code: |
||||
|
type: integer |
||||
|
format: uint32 |
||||
|
data: |
||||
|
type: string |
||||
|
message: |
||||
|
type: string |
||||
|
walletSystem.v1.WalletReply: |
||||
|
type: object |
||||
|
properties: |
||||
|
code: |
||||
|
type: integer |
||||
|
format: uint32 |
||||
|
data: |
||||
|
type: array |
||||
|
items: |
||||
|
type: string |
||||
|
message: |
||||
|
type: string |
||||
|
walletSystem.v1.WalletRequest: |
||||
|
type: object |
||||
|
properties: {} |
||||
|
tags: |
||||
|
- name: Wallet |
@ -0,0 +1 @@ |
|||||
|
# third_party |
@ -0,0 +1,18 @@ |
|||||
|
syntax = "proto3"; |
||||
|
|
||||
|
package errors; |
||||
|
|
||||
|
option go_package = "github.com/go-kratos/kratos/v2/errors;errors"; |
||||
|
option java_multiple_files = true; |
||||
|
option java_package = "com.github.kratos.errors"; |
||||
|
option objc_class_prefix = "KratosErrors"; |
||||
|
|
||||
|
import "google/protobuf/descriptor.proto"; |
||||
|
|
||||
|
extend google.protobuf.EnumOptions { |
||||
|
int32 default_code = 1108; |
||||
|
} |
||||
|
|
||||
|
extend google.protobuf.EnumValueOptions { |
||||
|
int32 code = 1109; |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
// Copyright (c) 2015, Google Inc. |
||||
|
// |
||||
|
// 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. |
||||
|
|
||||
|
syntax = "proto3"; |
||||
|
|
||||
|
package google.api; |
||||
|
|
||||
|
import "google/api/http.proto"; |
||||
|
import "google/protobuf/descriptor.proto"; |
||||
|
|
||||
|
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; |
||||
|
option java_multiple_files = true; |
||||
|
option java_outer_classname = "AnnotationsProto"; |
||||
|
option java_package = "com.google.api"; |
||||
|
option objc_class_prefix = "GAPI"; |
||||
|
|
||||
|
extend google.protobuf.MethodOptions { |
||||
|
// See `HttpRule`. |
||||
|
HttpRule http = 72295728; |
||||
|
} |
@ -0,0 +1,101 @@ |
|||||
|
// Copyright 2019 Google LLC. |
||||
|
// |
||||
|
// 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 |
||||
|
// |
||||
|
// https://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. |
||||
|
|
||||
|
syntax = "proto3"; |
||||
|
|
||||
|
package google.api; |
||||
|
|
||||
|
import "google/protobuf/descriptor.proto"; |
||||
|
|
||||
|
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; |
||||
|
option java_multiple_files = true; |
||||
|
option java_outer_classname = "ClientProto"; |
||||
|
option java_package = "com.google.api"; |
||||
|
option objc_class_prefix = "GAPI"; |
||||
|
|
||||
|
|
||||
|
extend google.protobuf.ServiceOptions { |
||||
|
// The hostname for this service. |
||||
|
// This should be specified with no prefix or protocol. |
||||
|
// |
||||
|
// Example: |
||||
|
// |
||||
|
// service Foo { |
||||
|
// option (google.api.default_host) = "foo.googleapi.com"; |
||||
|
// ... |
||||
|
// } |
||||
|
string default_host = 1049; |
||||
|
|
||||
|
// OAuth scopes needed for the client. |
||||
|
// |
||||
|
// Example: |
||||
|
// |
||||
|
// service Foo { |
||||
|
// option (google.api.oauth_scopes) = \ |
||||
|
// "https://www.googleapis.com/auth/cloud-platform"; |
||||
|
// ... |
||||
|
// } |
||||
|
// |
||||
|
// If there is more than one scope, use a comma-separated string: |
||||
|
// |
||||
|
// Example: |
||||
|
// |
||||
|
// service Foo { |
||||
|
// option (google.api.oauth_scopes) = \ |
||||
|
// "https://www.googleapis.com/auth/cloud-platform," |
||||
|
// "https://www.googleapis.com/auth/monitoring"; |
||||
|
// ... |
||||
|
// } |
||||
|
string oauth_scopes = 1050; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
extend google.protobuf.MethodOptions { |
||||
|
// A definition of a client library method signature. |
||||
|
// |
||||
|
// In client libraries, each proto RPC corresponds to one or more methods |
||||
|
// which the end user is able to call, and calls the underlying RPC. |
||||
|
// Normally, this method receives a single argument (a struct or instance |
||||
|
// corresponding to the RPC request object). Defining this field will |
||||
|
// add one or more overloads providing flattened or simpler method signatures |
||||
|
// in some languages. |
||||
|
// |
||||
|
// The fields on the method signature are provided as a comma-separated |
||||
|
// string. |
||||
|
// |
||||
|
// For example, the proto RPC and annotation: |
||||
|
// |
||||
|
// rpc CreateSubscription(CreateSubscriptionRequest) |
||||
|
// returns (Subscription) { |
||||
|
// option (google.api.method_signature) = "name,topic"; |
||||
|
// } |
||||
|
// |
||||
|
// Would add the following Java overload (in addition to the method accepting |
||||
|
// the request object): |
||||
|
// |
||||
|
// public final Subscription createSubscription(String name, String topic) |
||||
|
// |
||||
|
// The following backwards-compatibility guidelines apply: |
||||
|
// |
||||
|
// * Adding this annotation to an unannotated method is backwards |
||||
|
// compatible. |
||||
|
// * Adding this annotation to a method which already has existing |
||||
|
// method signature annotations is backwards compatible if and only if |
||||
|
// the new method signature annotation is last in the sequence. |
||||
|
// * Modifying or removing an existing method signature annotation is |
||||
|
// a breaking change. |
||||
|
// * Re-ordering existing method signature annotations is a breaking |
||||
|
// change. |
||||
|
repeated string method_signature = 1051; |
||||
|
} |
@ -0,0 +1,80 @@ |
|||||
|
// Copyright 2019 Google LLC. |
||||
|
// |
||||
|
// 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 |
||||
|
// |
||||
|
// https://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. |
||||
|
|
||||
|
syntax = "proto3"; |
||||
|
|
||||
|
package google.api; |
||||
|
|
||||
|
import "google/protobuf/descriptor.proto"; |
||||
|
|
||||
|
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; |
||||
|
option java_multiple_files = true; |
||||
|
option java_outer_classname = "FieldBehaviorProto"; |
||||
|
option java_package = "com.google.api"; |
||||
|
option objc_class_prefix = "GAPI"; |
||||
|
|
||||
|
|
||||
|
// An indicator of the behavior of a given field (for example, that a field |
||||
|
// is required in requests, or given as output but ignored as input). |
||||
|
// This **does not** change the behavior in protocol buffers itself; it only |
||||
|
// denotes the behavior and may affect how API tooling handles the field. |
||||
|
// |
||||
|
// Note: This enum **may** receive new values in the future. |
||||
|
enum FieldBehavior { |
||||
|
// Conventional default for enums. Do not use this. |
||||
|
FIELD_BEHAVIOR_UNSPECIFIED = 0; |
||||
|
|
||||
|
// Specifically denotes a field as optional. |
||||
|
// While all fields in protocol buffers are optional, this may be specified |
||||
|
// for emphasis if appropriate. |
||||
|
OPTIONAL = 1; |
||||
|
|
||||
|
// Denotes a field as required. |
||||
|
// This indicates that the field **must** be provided as part of the request, |
||||
|
// and failure to do so will cause an error (usually `INVALID_ARGUMENT`). |
||||
|
REQUIRED = 2; |
||||
|
|
||||
|
// Denotes a field as output only. |
||||
|
// This indicates that the field is provided in responses, but including the |
||||
|
// field in a request does nothing (the server *must* ignore it and |
||||
|
// *must not* throw an error as a result of the field's presence). |
||||
|
OUTPUT_ONLY = 3; |
||||
|
|
||||
|
// Denotes a field as input only. |
||||
|
// This indicates that the field is provided in requests, and the |
||||
|
// corresponding field is not included in output. |
||||
|
INPUT_ONLY = 4; |
||||
|
|
||||
|
// Denotes a field as immutable. |
||||
|
// This indicates that the field may be set once in a request to create a |
||||
|
// resource, but may not be changed thereafter. |
||||
|
IMMUTABLE = 5; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
extend google.protobuf.FieldOptions { |
||||
|
// A designation of a specific field behavior (required, output only, etc.) |
||||
|
// in protobuf messages. |
||||
|
// |
||||
|
// Examples: |
||||
|
// |
||||
|
// string name = 1 [(google.api.field_behavior) = REQUIRED]; |
||||
|
// State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; |
||||
|
// google.protobuf.Duration ttl = 1 |
||||
|
// [(google.api.field_behavior) = INPUT_ONLY]; |
||||
|
// google.protobuf.Timestamp expire_time = 1 |
||||
|
// [(google.api.field_behavior) = OUTPUT_ONLY, |
||||
|
// (google.api.field_behavior) = IMMUTABLE]; |
||||
|
repeated FieldBehavior field_behavior = 1052; |
||||
|
} |
@ -0,0 +1,375 @@ |
|||||
|
// Copyright 2020 Google LLC |
||||
|
// |
||||
|
// 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. |
||||
|
|
||||
|
syntax = "proto3"; |
||||
|
|
||||
|
package google.api; |
||||
|
|
||||
|
option cc_enable_arenas = true; |
||||
|
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; |
||||
|
option java_multiple_files = true; |
||||
|
option java_outer_classname = "HttpProto"; |
||||
|
option java_package = "com.google.api"; |
||||
|
option objc_class_prefix = "GAPI"; |
||||
|
|
||||
|
// Defines the HTTP configuration for an API service. It contains a list of |
||||
|
// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method |
||||
|
// to one or more HTTP REST API methods. |
||||
|
message Http { |
||||
|
// A list of HTTP configuration rules that apply to individual API methods. |
||||
|
// |
||||
|
// **NOTE:** All service configuration rules follow "last one wins" order. |
||||
|
repeated HttpRule rules = 1; |
||||
|
|
||||
|
// When set to true, URL path parameters will be fully URI-decoded except in |
||||
|
// cases of single segment matches in reserved expansion, where "%2F" will be |
||||
|
// left encoded. |
||||
|
// |
||||
|
// The default behavior is to not decode RFC 6570 reserved characters in multi |
||||
|
// segment matches. |
||||
|
bool fully_decode_reserved_expansion = 2; |
||||
|
} |
||||
|
|
||||
|
// # gRPC Transcoding |
||||
|
// |
||||
|
// gRPC Transcoding is a feature for mapping between a gRPC method and one or |
||||
|
// more HTTP REST endpoints. It allows developers to build a single API service |
||||
|
// that supports both gRPC APIs and REST APIs. Many systems, including [Google |
||||
|
// APIs](https://github.com/googleapis/googleapis), |
||||
|
// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC |
||||
|
// Gateway](https://github.com/grpc-ecosystem/grpc-gateway), |
||||
|
// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature |
||||
|
// and use it for large scale production services. |
||||
|
// |
||||
|
// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies |
||||
|
// how different portions of the gRPC request message are mapped to the URL |
||||
|
// path, URL query parameters, and HTTP request body. It also controls how the |
||||
|
// gRPC response message is mapped to the HTTP response body. `HttpRule` is |
||||
|
// typically specified as an `google.api.http` annotation on the gRPC method. |
||||
|
// |
||||
|
// Each mapping specifies a URL path template and an HTTP method. The path |
||||
|
// template may refer to one or more fields in the gRPC request message, as long |
||||
|
// as each field is a non-repeated field with a primitive (non-message) type. |
||||
|
// The path template controls how fields of the request message are mapped to |
||||
|
// the URL path. |
||||
|
// |
||||
|
// Example: |
||||
|
// |
||||
|
// service Messaging { |
||||
|
// rpc GetMessage(GetMessageRequest) returns (Message) { |
||||
|
// option (google.api.http) = { |
||||
|
// get: "/v1/{name=messages/*}" |
||||
|
// }; |
||||
|
// } |
||||
|
// } |
||||
|
// message GetMessageRequest { |
||||
|
// string name = 1; // Mapped to URL path. |
||||
|
// } |
||||
|
// message Message { |
||||
|
// string text = 1; // The resource content. |
||||
|
// } |
||||
|
// |
||||
|
// This enables an HTTP REST to gRPC mapping as below: |
||||
|
// |
||||
|
// HTTP | gRPC |
||||
|
// -----|----- |
||||
|
// `GET /v1/messages/123456` | `GetMessage(name: "messages/123456")` |
||||
|
// |
||||
|
// Any fields in the request message which are not bound by the path template |
||||
|
// automatically become HTTP query parameters if there is no HTTP request body. |
||||
|
// For example: |
||||
|
// |
||||
|
// service Messaging { |
||||
|
// rpc GetMessage(GetMessageRequest) returns (Message) { |
||||
|
// option (google.api.http) = { |
||||
|
// get:"/v1/messages/{message_id}" |
||||
|
// }; |
||||
|
// } |
||||
|
// } |
||||
|
// message GetMessageRequest { |
||||
|
// message SubMessage { |
||||
|
// string subfield = 1; |
||||
|
// } |
||||
|
// string message_id = 1; // Mapped to URL path. |
||||
|
// int64 revision = 2; // Mapped to URL query parameter `revision`. |
||||
|
// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. |
||||
|
// } |
||||
|
// |
||||
|
// This enables a HTTP JSON to RPC mapping as below: |
||||
|
// |
||||
|
// HTTP | gRPC |
||||
|
// -----|----- |
||||
|
// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | |
||||
|
// `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: |
||||
|
// "foo"))` |
||||
|
// |
||||
|
// Note that fields which are mapped to URL query parameters must have a |
||||
|
// primitive type or a repeated primitive type or a non-repeated message type. |
||||
|
// In the case of a repeated type, the parameter can be repeated in the URL |
||||
|
// as `...?param=A¶m=B`. In the case of a message type, each field of the |
||||
|
// message is mapped to a separate parameter, such as |
||||
|
// `...?foo.a=A&foo.b=B&foo.c=C`. |
||||
|
// |
||||
|
// For HTTP methods that allow a request body, the `body` field |
||||
|
// specifies the mapping. Consider a REST update method on the |
||||
|
// message resource collection: |
||||
|
// |
||||
|
// service Messaging { |
||||
|
// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { |
||||
|
// option (google.api.http) = { |
||||
|
// patch: "/v1/messages/{message_id}" |
||||
|
// body: "message" |
||||
|
// }; |
||||
|
// } |
||||
|
// } |
||||
|
// message UpdateMessageRequest { |
||||
|
// string message_id = 1; // mapped to the URL |
||||
|
// Message message = 2; // mapped to the body |
||||
|
// } |
||||
|
// |
||||
|
// The following HTTP JSON to RPC mapping is enabled, where the |
||||
|
// representation of the JSON in the request body is determined by |
||||
|
// protos JSON encoding: |
||||
|
// |
||||
|
// HTTP | gRPC |
||||
|
// -----|----- |
||||
|
// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: |
||||
|
// "123456" message { text: "Hi!" })` |
||||
|
// |
||||
|
// The special name `*` can be used in the body mapping to define that |
||||
|
// every field not bound by the path template should be mapped to the |
||||
|
// request body. This enables the following alternative definition of |
||||
|
// the update method: |
||||
|
// |
||||
|
// service Messaging { |
||||
|
// rpc UpdateMessage(Message) returns (Message) { |
||||
|
// option (google.api.http) = { |
||||
|
// patch: "/v1/messages/{message_id}" |
||||
|
// body: "*" |
||||
|
// }; |
||||
|
// } |
||||
|
// } |
||||
|
// message Message { |
||||
|
// string message_id = 1; |
||||
|
// string text = 2; |
||||
|
// } |
||||
|
// |
||||
|
// |
||||
|
// The following HTTP JSON to RPC mapping is enabled: |
||||
|
// |
||||
|
// HTTP | gRPC |
||||
|
// -----|----- |
||||
|
// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: |
||||
|
// "123456" text: "Hi!")` |
||||
|
// |
||||
|
// Note that when using `*` in the body mapping, it is not possible to |
||||
|
// have HTTP parameters, as all fields not bound by the path end in |
||||
|
// the body. This makes this option more rarely used in practice when |
||||
|
// defining REST APIs. The common usage of `*` is in custom methods |
||||
|
// which don't use the URL at all for transferring data. |
||||
|
// |
||||
|
// It is possible to define multiple HTTP methods for one RPC by using |
||||
|
// the `additional_bindings` option. Example: |
||||
|
// |
||||
|
// service Messaging { |
||||
|
// rpc GetMessage(GetMessageRequest) returns (Message) { |
||||
|
// option (google.api.http) = { |
||||
|
// get: "/v1/messages/{message_id}" |
||||
|
// additional_bindings { |
||||
|
// get: "/v1/users/{user_id}/messages/{message_id}" |
||||
|
// } |
||||
|
// }; |
||||
|
// } |
||||
|
// } |
||||
|
// message GetMessageRequest { |
||||
|
// string message_id = 1; |
||||
|
// string user_id = 2; |
||||
|
// } |
||||
|
// |
||||
|
// This enables the following two alternative HTTP JSON to RPC mappings: |
||||
|
// |
||||
|
// HTTP | gRPC |
||||
|
// -----|----- |
||||
|
// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` |
||||
|
// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: |
||||
|
// "123456")` |
||||
|
// |
||||
|
// ## Rules for HTTP mapping |
||||
|
// |
||||
|
// 1. Leaf request fields (recursive expansion nested messages in the request |
||||
|
// message) are classified into three categories: |
||||
|
// - Fields referred by the path template. They are passed via the URL path. |
||||
|
// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They are passed via the HTTP |
||||
|
// request body. |
||||
|
// - All other fields are passed via the URL query parameters, and the |
||||
|
// parameter name is the field path in the request message. A repeated |
||||
|
// field can be represented as multiple query parameters under the same |
||||
|
// name. |
||||
|
// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL query parameter, all fields |
||||
|
// are passed via URL path and HTTP request body. |
||||
|
// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP request body, all |
||||
|
// fields are passed via URL path and URL query parameters. |
||||
|
// |
||||
|
// ### Path template syntax |
||||
|
// |
||||
|
// Template = "/" Segments [ Verb ] ; |
||||
|
// Segments = Segment { "/" Segment } ; |
||||
|
// Segment = "*" | "**" | LITERAL | Variable ; |
||||
|
// Variable = "{" FieldPath [ "=" Segments ] "}" ; |
||||
|
// FieldPath = IDENT { "." IDENT } ; |
||||
|
// Verb = ":" LITERAL ; |
||||
|
// |
||||
|
// The syntax `*` matches a single URL path segment. The syntax `**` matches |
||||
|
// zero or more URL path segments, which must be the last part of the URL path |
||||
|
// except the `Verb`. |
||||
|
// |
||||
|
// The syntax `Variable` matches part of the URL path as specified by its |
||||
|
// template. A variable template must not contain other variables. If a variable |
||||
|
// matches a single path segment, its template may be omitted, e.g. `{var}` |
||||
|
// is equivalent to `{var=*}`. |
||||
|
// |
||||
|
// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` |
||||
|
// contains any reserved character, such characters should be percent-encoded |
||||
|
// before the matching. |
||||
|
// |
||||
|
// If a variable contains exactly one path segment, such as `"{var}"` or |
||||
|
// `"{var=*}"`, when such a variable is expanded into a URL path on the client |
||||
|
// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The |
||||
|
// server side does the reverse decoding. Such variables show up in the |
||||
|
// [Discovery |
||||
|
// Document](https://developers.google.com/discovery/v1/reference/apis) as |
||||
|
// `{var}`. |
||||
|
// |
||||
|
// If a variable contains multiple path segments, such as `"{var=foo/*}"` |
||||
|
// or `"{var=**}"`, when such a variable is expanded into a URL path on the |
||||
|
// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. |
||||
|
// The server side does the reverse decoding, except "%2F" and "%2f" are left |
||||
|
// unchanged. Such variables show up in the |
||||
|
// [Discovery |
||||
|
// Document](https://developers.google.com/discovery/v1/reference/apis) as |
||||
|
// `{+var}`. |
||||
|
// |
||||
|
// ## Using gRPC API Service Configuration |
||||
|
// |
||||
|
// gRPC API Service Configuration (service config) is a configuration language |
||||
|
// for configuring a gRPC service to become a user-facing product. The |
||||
|
// service config is simply the YAML representation of the `google.api.Service` |
||||
|
// proto message. |
||||
|
// |
||||
|
// As an alternative to annotating your proto file, you can configure gRPC |
||||
|
// transcoding in your service config YAML files. You do this by specifying a |
||||
|
// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same |
||||
|
// effect as the proto annotation. This can be particularly useful if you |
||||
|
// have a proto that is reused in multiple services. Note that any transcoding |
||||
|
// specified in the service config will override any matching transcoding |
||||
|
// configuration in the proto. |
||||
|
// |
||||
|
// Example: |
||||
|
// |
||||
|
// http: |
||||
|
// rules: |
||||
|
// # Selects a gRPC method and applies HttpRule to it. |
||||
|
// - selector: example.v1.Messaging.GetMessage |
||||
|
// get: /v1/messages/{message_id}/{sub.subfield} |
||||
|
// |
||||
|
// ## Special notes |
||||
|
// |
||||
|
// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the |
||||
|
// proto to JSON conversion must follow the [proto3 |
||||
|
// specification](https://developers.google.com/protocol-buffers/docs/proto3#json). |
||||
|
// |
||||
|
// While the single segment variable follows the semantics of |
||||
|
// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String |
||||
|
// Expansion, the multi segment variable **does not** follow RFC 6570 Section |
||||
|
// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion |
||||
|
// does not expand special characters like `?` and `#`, which would lead |
||||
|
// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding |
||||
|
// for multi segment variables. |
||||
|
// |
||||
|
// The path variables **must not** refer to any repeated or mapped field, |
||||
|
// because client libraries are not capable of handling such variable expansion. |
||||
|
// |
||||
|
// The path variables **must not** capture the leading "/" character. The reason |
||||
|
// is that the most common use case "{var}" does not capture the leading "/" |
||||
|
// character. For consistency, all path variables must share the same behavior. |
||||
|
// |
||||
|
// Repeated message fields must not be mapped to URL query parameters, because |
||||
|
// no client library can support such complicated mapping. |
||||
|
// |
||||
|
// If an API needs to use a JSON array for request or response body, it can map |
||||
|
// the request or response body to a repeated field. However, some gRPC |
||||
|
// Transcoding implementations may not support this feature. |
||||
|
message HttpRule { |
||||
|
// Selects a method to which this rule applies. |
||||
|
// |
||||
|
// Refer to [selector][google.api.DocumentationRule.selector] for syntax details. |
||||
|
string selector = 1; |
||||
|
|
||||
|
// Determines the URL pattern is matched by this rules. This pattern can be |
||||
|
// used with any of the {get|put|post|delete|patch} methods. A custom method |
||||
|
// can be defined using the 'custom' field. |
||||
|
oneof pattern { |
||||
|
// Maps to HTTP GET. Used for listing and getting information about |
||||
|
// resources. |
||||
|
string get = 2; |
||||
|
|
||||
|
// Maps to HTTP PUT. Used for replacing a resource. |
||||
|
string put = 3; |
||||
|
|
||||
|
// Maps to HTTP POST. Used for creating a resource or performing an action. |
||||
|
string post = 4; |
||||
|
|
||||
|
// Maps to HTTP DELETE. Used for deleting a resource. |
||||
|
string delete = 5; |
||||
|
|
||||
|
// Maps to HTTP PATCH. Used for updating a resource. |
||||
|
string patch = 6; |
||||
|
|
||||
|
// The custom pattern is used for specifying an HTTP method that is not |
||||
|
// included in the `pattern` field, such as HEAD, or "*" to leave the |
||||
|
// HTTP method unspecified for this rule. The wild-card rule is useful |
||||
|
// for services that provide content to Web (HTML) clients. |
||||
|
CustomHttpPattern custom = 8; |
||||
|
} |
||||
|
|
||||
|
// The name of the request field whose value is mapped to the HTTP request |
||||
|
// body, or `*` for mapping all request fields not captured by the path |
||||
|
// pattern to the HTTP body, or omitted for not having any HTTP request body. |
||||
|
// |
||||
|
// NOTE: the referred field must be present at the top-level of the request |
||||
|
// message type. |
||||
|
string body = 7; |
||||
|
|
||||
|
// Optional. The name of the response field whose value is mapped to the HTTP |
||||
|
// response body. When omitted, the entire response message will be used |
||||
|
// as the HTTP response body. |
||||
|
// |
||||
|
// NOTE: The referred field must be present at the top-level of the response |
||||
|
// message type. |
||||
|
string response_body = 12; |
||||
|
|
||||
|
// Additional HTTP bindings for the selector. Nested bindings must |
||||
|
// not contain an `additional_bindings` field themselves (that is, |
||||
|
// the nesting may only be one level deep). |
||||
|
repeated HttpRule additional_bindings = 11; |
||||
|
} |
||||
|
|
||||
|
// A custom pattern is used for defining custom HTTP verb. |
||||
|
message CustomHttpPattern { |
||||
|
// The name of this custom HTTP verb. |
||||
|
string kind = 1; |
||||
|
|
||||
|
// The path matched by this custom verb. |
||||
|
string path = 2; |
||||
|
} |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue