diff --git a/common/model/api_request.go b/common/model/api_request.go index 51ea0f26..29a1c2f2 100644 --- a/common/model/api_request.go +++ b/common/model/api_request.go @@ -1,11 +1,14 @@ package model -import "errors" +import ( + "AAStarCommunity/EthPaymaster_BackService/common/types" + "errors" +) type TryPayUserOpRequest struct { ForceStrategyId string `json:"force_strategy_id"` - ForceNetWork string `json:"force_network"` - ForceTokens string `json:"force_tokens"` + ForceNetwork types.NetWork `json:"force_network"` + ForceToken string `json:"force_token"` ForceEntryPointAddress string `json:"force_entrypoint_address"` UserOperation UserOperationItem `json:"user_operation"` Extra interface{} `json:"extra"` @@ -13,7 +16,7 @@ type TryPayUserOpRequest struct { func (request *TryPayUserOpRequest) Validate() error { if len(request.ForceStrategyId) == 0 { - if len(request.ForceNetWork) == 0 || len(request.ForceTokens) == 0 || len(request.ForceEntryPointAddress) == 0 { + if len(request.ForceNetwork) == 0 || len(request.ForceToken) == 0 || len(request.ForceEntryPointAddress) == 0 { return errors.New("strategy configuration illegal") } } diff --git a/common/model/api_response.go b/common/model/api_response.go index 6272ba12..4a361925 100644 --- a/common/model/api_response.go +++ b/common/model/api_response.go @@ -1,18 +1,30 @@ package model +import ( + "AAStarCommunity/EthPaymaster_BackService/common/types" + "math/big" +) + type TryPayUserOpResponse struct { StrategyId string `json:"strategy_id"` EntryPointAddress string `json:"entrypoint_address"` PayMasterAddress string `json:"paymaster_address"` PayMasterSignature string `json:"paymaster_signature"` - PayReceipt interface{} `json:"pay_receipt"` + PayReceipt *PayReceipt `json:"pay_receipt"` GasInfo *ComputeGasResponse `json:"gas_info"` } type ComputeGasResponse struct { - StrategyId string `json:"strategy_id"` - TokenCost string `json:"token_cost"` - Network string `json:"network"` - Token string `json:"token"` - UsdCost string `json:"usd_cost"` + GasPriceInWei uint64 `json:"gas_price_wei"` // wei + GasPriceInGwei *big.Float `json:"gas_price_gwei"` + GasPriceInEther string `json:"gas_price_ether"` + TokenCost string `json:"token_cost"` + Network types.NetWork `json:"network"` + Token types.TokenType `json:"token"` + UsdCost string `json:"usd_cost"` + BlobEnable bool `json:"blob_enable"` +} +type PayReceipt struct { + TransactionHash string `json:"transaction_hash"` + Sponsor string `json:"sponsor"` } diff --git a/common/model/strategy.go b/common/model/strategy.go index e23e5988..a86516c0 100644 --- a/common/model/strategy.go +++ b/common/model/strategy.go @@ -1,7 +1,30 @@ package model +import "AAStarCommunity/EthPaymaster_BackService/common/types" + type Strategy struct { - Id string - EntryPointAddress string - PayMasterAddress string + Id string `json:"id"` + EntryPointAddress string `json:"entrypoint_address"` + PayMasterAddress string `json:"paymaster_address"` + NetWork types.NetWork `json:"network"` + Token types.TokenType `json:"token"` + Description string `json:"description"` + ExecuteRestriction StrategyExecuteRestriction `json:"execute_restriction"` + EnableEoa bool `json:"enable_eoa"` + Enable7560 bool `json:"enable_7560"` + EnableErc20 bool `json:"enable_erc20"` + Enable4844 bool `json:"enable_4844"` + EnableCurrency bool `json:"enable_currency"` +} +type StrategyExecuteRestriction struct { + BanSenderAddress string `json:"ban_sender_address"` + EffectiveStartTime int64 `json:"effective_start_time"` + EffectiveEndTime int64 `json:"effective_end_time"` + GlobalMaxUSD int64 `json:"global_max_usd"` + GlobalMaxOpCount int64 `json:"global_max_op_count"` + DayMaxUSD int64 `json:"day_max_usd"` +} + +type StrategyValidateConfig struct { + ValidateContractAddress string `json:"validate_contract_address"` } diff --git a/common/model/user_operation.go b/common/model/user_operation.go index d7e2c9c1..c1fb22b5 100644 --- a/common/model/user_operation.go +++ b/common/model/user_operation.go @@ -4,9 +4,10 @@ type UserOperationItem struct { Sender string `json:"sender" binding:"required"` Nonce string `json:"nonce" binding:"required"` InitCode string `json:"init_code"` + CallData string `json:"call_data" binding:"required"` CallGasLimit string `json:"call_gas_limit" binding:"required"` VerificationGasList string `json:"verification_gas_list" binding:"required"` - PerVerificationGas string `json:"per_verification_gas" binding:"required"` + PreVerificationGas string `json:"per_verification_gas" binding:"required"` MaxFeePerGas string `json:"max_fee_per_gas" binding:"required"` MaxPriorityFeePerGas string `json:"max_priority_fee_per_gas" binding:"required"` Signature string `json:"signature"` diff --git a/common/types/chain.go b/common/types/chain.go new file mode 100644 index 00000000..fa0e68d1 --- /dev/null +++ b/common/types/chain.go @@ -0,0 +1,22 @@ +package types + +type NetworkInfo struct { + Name string `json:"main_net_name"` + RpcUrl string `json:"main_net_rpc_url"` +} + +//type Chain string +// +//const ( +// Ethereum Chain = "Ethereum" +// Arbitrum Chain = "Arbitrum" +// Optimism Chain = "Optimism" +//) + +type NetWork string + +const ( + Ethereum NetWork = "ethereum" + Sepolia NetWork = "sepolia" + Arbitrum NetWork = "arbitrum" +) diff --git a/common/types/currency.go b/common/types/currency.go new file mode 100644 index 00000000..efb4511b --- /dev/null +++ b/common/types/currency.go @@ -0,0 +1,7 @@ +package types + +type Currency string + +const ( + USD Currency = "USD" +) diff --git a/common/types/token.go b/common/types/token.go new file mode 100644 index 00000000..f5321605 --- /dev/null +++ b/common/types/token.go @@ -0,0 +1,8 @@ +package types + +type TokenType string + +const ( + USDT TokenType = "USDT" + ETH TokenType = "ETH" +) diff --git a/common/utils/util.go b/common/utils/util.go index d4b585bf..faef363c 100644 --- a/common/utils/util.go +++ b/common/utils/util.go @@ -1 +1,58 @@ package utils + +import ( + "AAStarCommunity/EthPaymaster_BackService/common/model" + "encoding/json" + "github.com/ethereum/go-ethereum/crypto" +) + +func GenerateMockUserOperation() *model.UserOperationItem { + //TODO use config + return &model.UserOperationItem{ + Sender: "0x4A2FD3215420376DA4eD32853C19E4755deeC4D1", + Nonce: "1", + InitCode: "0x", + CallData: "0xb61d27f6000000000000000000000000c206b552ab127608c3f666156c8e03a8471c72df000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000", + CallGasLimit: "39837", + VerificationGasList: "100000", + PreVerificationGas: "44020", + MaxFeePerGas: "1743509478", + MaxPriorityFeePerGas: "1500000000", + Signature: "0x760868cd7d9539c6e31c2169c4cab6817beb8247516a90e4301e929011451658623455035b83d38e987ef2e57558695040a25219c39eaa0e31a0ead16a5c925c1c", + } +} +func GenerateUserOperation() *model.UserOperationItem { + return &model.UserOperationItem{} +} + +func SignUserOp(privateKeyHex string, userOp *model.UserOperationItem) ([]byte, error) { + + serializedUserOp, err := json.Marshal(userOp) + if err != nil { + return nil, err + } + + signature, err := SignMessage(privateKeyHex, string(serializedUserOp)) + if err != nil { + return nil, err + } + + return signature, nil +} +func SignMessage(privateKeyHex string, message string) ([]byte, error) { + privateKey, err := crypto.HexToECDSA(privateKeyHex) + if err != nil { + return nil, err + } + + // Hash the message + hash := crypto.Keccak256([]byte(message)) + + // Sign the hash + signature, err := crypto.Sign(hash, privateKey) + if err != nil { + return nil, err + } + + return signature, nil +} diff --git a/common/utils/util_test.go b/common/utils/util_test.go new file mode 100644 index 00000000..f9574b11 --- /dev/null +++ b/common/utils/util_test.go @@ -0,0 +1,33 @@ +package utils + +import ( + "crypto/ecdsa" + "encoding/hex" + "fmt" + "github.com/ethereum/go-ethereum/crypto" + "github.com/stretchr/testify/assert" + "testing" +) + +func TestGenerateKeypair(t *testing.T) { + privateKey, _ := crypto.GenerateKey() + privateKeyHex := crypto.FromECDSA(privateKey) + publicKey := privateKey.Public() + publicKeyECDSA, _ := publicKey.(*ecdsa.PublicKey) + publicKeyBytes := crypto.FromECDSAPub(publicKeyECDSA) + address := crypto.PubkeyToAddress(*publicKeyECDSA).Hex() + fmt.Printf("privateKeyHex: %x\n", privateKeyHex) + fmt.Printf("publicKey: %x\n", publicKeyBytes) + fmt.Printf("address: %s\n", address) +} +func TestSignUserOp(t *testing.T) { + //privateKeyHex: 1d8a58126e87e53edc7b24d58d1328230641de8c4242c135492bf5560e0ff421 + //publicKey: 044eaed6b1f16e60354156fa334a094affc76d7b7061875a0b04290af9a14cc14ce2bce6ceba941856bd55c63f8199f408fff6495ce9d4c76899055972d23bdb3e + //address: 0x0E1375d18a4A2A867bEfe908E87322ad031386a6 + signByte, err := SignUserOp("1d8a58126e87e53edc7b24d58d1328230641de8c4242c135492bf5560e0ff421", GenerateMockUserOperation()) + assert.NoError(t, err) + fmt.Printf("signByte: %x\n", signByte) + singature := hex.EncodeToString(signByte) + fmt.Printf("singature: %s\n", singature) + +} diff --git a/conf/env.go b/conf/env.go index c6b677ac..5d8b7a7d 100644 --- a/conf/env.go +++ b/conf/env.go @@ -38,7 +38,7 @@ func getConfFilePath() *string { var Environment *Env func init() { - envName := ProdEnv + envName := DevEnv if len(os.Getenv(envKey)) > 0 { envName = os.Getenv(envKey) } diff --git a/docs/docs.go b/docs/docs.go index a6959e2d..0e07f2c2 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -156,12 +156,12 @@ const docTemplate = `{ "type": "string" }, "force_network": { - "type": "string" + "$ref": "#/definitions/types.NetWork" }, "force_strategy_id": { "type": "string" }, - "force_tokens": { + "force_token": { "type": "string" }, "user_operation": { @@ -172,6 +172,7 @@ const docTemplate = `{ "model.UserOperationItem": { "type": "object", "required": [ + "call_data", "call_gas_limit", "max_fee_per_gas", "max_priority_fee_per_gas", @@ -181,6 +182,9 @@ const docTemplate = `{ "verification_gas_list" ], "properties": { + "call_data": { + "type": "string" + }, "call_gas_limit": { "type": "string" }, @@ -209,6 +213,19 @@ const docTemplate = `{ "type": "string" } } + }, + "types.NetWork": { + "type": "string", + "enum": [ + "ethereum", + "sepolia", + "arbitrum" + ], + "x-enum-varnames": [ + "Ethereum", + "Sepolia", + "Arbitrum" + ] } }, "securityDefinitions": { diff --git a/docs/swagger.json b/docs/swagger.json index f5b5ef35..e9a7fd87 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -145,12 +145,12 @@ "type": "string" }, "force_network": { - "type": "string" + "$ref": "#/definitions/types.NetWork" }, "force_strategy_id": { "type": "string" }, - "force_tokens": { + "force_token": { "type": "string" }, "user_operation": { @@ -161,6 +161,7 @@ "model.UserOperationItem": { "type": "object", "required": [ + "call_data", "call_gas_limit", "max_fee_per_gas", "max_priority_fee_per_gas", @@ -170,6 +171,9 @@ "verification_gas_list" ], "properties": { + "call_data": { + "type": "string" + }, "call_gas_limit": { "type": "string" }, @@ -198,6 +202,19 @@ "type": "string" } } + }, + "types.NetWork": { + "type": "string", + "enum": [ + "ethereum", + "sepolia", + "arbitrum" + ], + "x-enum-varnames": [ + "Ethereum", + "Sepolia", + "Arbitrum" + ] } }, "securityDefinitions": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 8852545d..b20ce651 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -10,16 +10,18 @@ definitions: force_entrypoint_address: type: string force_network: - type: string + $ref: '#/definitions/types.NetWork' force_strategy_id: type: string - force_tokens: + force_token: type: string user_operation: $ref: '#/definitions/model.UserOperationItem' type: object model.UserOperationItem: properties: + call_data: + type: string call_gas_limit: type: string init_code: @@ -39,6 +41,7 @@ definitions: verification_gas_list: type: string required: + - call_data - call_gas_limit - max_fee_per_gas - max_priority_fee_per_gas @@ -47,6 +50,16 @@ definitions: - sender - verification_gas_list type: object + types.NetWork: + enum: + - ethereum + - sepolia + - arbitrum + type: string + x-enum-varnames: + - Ethereum + - Sepolia + - Arbitrum info: contact: name: AAStar Support diff --git a/go.mod b/go.mod index 1279dd3f..62750d97 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.22.1 require ( github.com/appleboy/gin-jwt/v2 v2.9.2 + github.com/ethereum/go-ethereum v1.13.14 github.com/gin-contrib/cors v1.5.0 github.com/gin-gonic/gin v1.9.1 github.com/stretchr/testify v1.8.4 @@ -11,17 +12,29 @@ require ( github.com/swaggo/gin-swagger v1.6.0 github.com/swaggo/swag v1.16.3 golang.org/x/time v0.3.0 + golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 k8s.io/apimachinery v0.29.2 ) require ( github.com/KyleBanks/depth v1.2.1 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/StackExchange/wmi v1.2.1 // indirect + github.com/bits-and-blooms/bitset v1.10.0 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect github.com/bytedance/sonic v1.11.1 // indirect github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect github.com/chenzhuoyu/iasm v0.9.1 // indirect + github.com/consensys/bavard v0.1.13 // indirect + github.com/consensys/gnark-crypto v0.12.1 // indirect + github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/deckarep/golang-set/v2 v2.1.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/ethereum/c-kzg-4844 v0.4.0 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-openapi/jsonpointer v0.20.2 // indirect github.com/go-openapi/jsonreference v0.20.4 // indirect github.com/go-openapi/spec v0.20.14 // indirect @@ -31,28 +44,38 @@ require ( github.com/go-playground/validator/v10 v10.18.0 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/gorilla/websocket v1.4.2 // indirect + github.com/holiman/uint256 v1.2.4 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect + github.com/supranational/blst v0.3.11 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect golang.org/x/arch v0.7.0 // indirect golang.org/x/crypto v0.20.0 // indirect + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect + golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.21.0 // indirect + golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect - golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect google.golang.org/protobuf v1.32.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + rsc.io/tmplfunc v0.0.3 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/go.sum b/go.sum index 106a0867..3050129d 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,31 @@ +github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= +github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= +github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= github.com/appleboy/gin-jwt/v2 v2.9.2 h1:GeS3lm9mb9HMmj7+GNjYUtpp3V1DAQ1TkUFa5poiZ7Y= github.com/appleboy/gin-jwt/v2 v2.9.2/go.mod h1:mxGjKt9Lrx9Xusy1SrnmsCJMZG6UJwmdHN9bN27/QDw= github.com/appleboy/gofight/v2 v2.1.2 h1:VOy3jow4vIK8BRQJoC/I9muxyYlJ2yb9ht2hZoS3rf4= github.com/appleboy/gofight/v2 v2.1.2/go.mod h1:frW+U1QZEdDgixycTj4CygQ48yLTUhplt43+Wczp3rw= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= +github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= +github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM= github.com/bytedance/sonic v1.11.1 h1:JC0+6c9FoWYYxakaoa+c5QTtJeiSZNeByOBhXtAFSn4= github.com/bytedance/sonic v1.11.1/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0= @@ -15,11 +33,51 @@ github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpV github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog= github.com/chenzhuoyu/iasm v0.9.1 h1:tUHQJXo3NhBqw6s33wkGn9SP3bvrWLdlVIJ3hQBL7P0= github.com/chenzhuoyu/iasm v0.9.1/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog= +github.com/cockroachdb/errors v1.8.1 h1:A5+txlVZfOqFBDa4mGz2bUWSp0aHElvHX2bKkdbQu+Y= +github.com/cockroachdb/errors v1.8.1/go.mod h1:qGwQn6JmZ+oMjuLwjWzUNqblqk0xl4CVV3SQbGwK7Ac= +github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY= +github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= +github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 h1:aPEJyR4rPBvDmeyi+l/FS/VtA00IWvjeFvjen1m1l1A= +github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593/go.mod h1:6hk1eMY/u5t+Cf18q5lFMUA1Rc+Sm5I6Ra1QuPyxXCo= +github.com/cockroachdb/redact v1.0.8 h1:8QG/764wK+vmEYoOlfobpe12EQcS81ukx/a4hdVMxNw= +github.com/cockroachdb/redact v1.0.8/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= +github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 h1:IKgmqgMQlVJIZj19CdocBeSfSaiCbEBZGKODaixqtHM= +github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2/go.mod h1:8BT+cPK6xvFOcRlk0R8eg+OTkcqI6baNH4xAkpiYVvQ= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= +github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= +github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ= +github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= +github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ= +github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA= +github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/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.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY= +github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= +github.com/ethereum/go-ethereum v1.13.14 h1:EwiY3FZP94derMCIam1iW4HFVrSgIcpsu0HwTQtm6CQ= +github.com/ethereum/go-ethereum v1.13.14/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= +github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA= +github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= +github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2GihuqhwdILrV+7GJel5lyPV3u1+PgzrWLc0TkE= +github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= github.com/gin-contrib/cors v1.5.0 h1:DgGKV7DDoOn36DFkNtbHrjoRiT5ExCe+PC9/xp7aKvk= github.com/gin-contrib/cors v1.5.0/go.mod h1:TvU7MAZ3EwrPLI2ztzTt3tqgvBCq+wn8WpZmfADjupI= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= @@ -28,6 +86,9 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= +github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-openapi/jsonpointer v0.20.2 h1:mQc3nmndL8ZBzStEo3JYF8wzmeWffDH4VbXz58sAx6Q= github.com/go-openapi/jsonpointer v0.20.2/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1RfD91Ar825/PuiRVs= github.com/go-openapi/jsonreference v0.20.4 h1:bKlDxQxQJgwpUSgOENiMPzCTBVuc7vTdXSSgNeAhojU= @@ -46,15 +107,42 @@ github.com/go-playground/validator/v10 v10.18.0 h1:BvolUXjp4zuvkZ5YN5t7ebzbhlUtP github.com/go-playground/validator/v10 v10.18.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang/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.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.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +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/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= +github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= +github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= +github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= +github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= +github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= @@ -63,23 +151,62 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= +github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= +github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= +github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= +github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI= github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +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/prometheus/client_golang v1.12.0 h1:C+UIj/QWtmqY13Arb8kwMt5j34/0Z2iKamrJ+ryC0Gg= +github.com/prometheus/client_golang v1.12.0/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= 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/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= +github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/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/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -90,22 +217,36 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= 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/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE= github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg= github.com/swaggo/gin-swagger v1.6.0 h1:y8sxvQ3E20/RCyrXeFfg60r6H0Z+SwpTjMYsMm+zy8M= github.com/swaggo/gin-swagger v1.6.0/go.mod h1:BG00cCEy294xtVpyIAHG6+e2Qzj/xKlRdOqDkvq0uzo= github.com/swaggo/swag v1.16.3 h1:PnCYjPCah8FK4I26l2F/KQ4yz3sILcVUN3cTlBFA9Pg= github.com/swaggo/swag v1.16.3/go.mod h1:DImHIuOFXKpMFAQjcC7FG4m3Dg4+QuUgUzJmKjI/gRk= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= +github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc= @@ -114,6 +255,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= @@ -125,13 +268,19 @@ golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= 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.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/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.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -158,6 +307,8 @@ google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHh 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/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= +gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= 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= @@ -167,6 +318,8 @@ k8s.io/apimachinery v0.29.2 h1:EWGpfJ856oj11C52NRCHuU7rFDwxev48z+6DSlGNsV8= k8s.io/apimachinery v0.29.2/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU= nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= +rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/service/chain_service/chain_config.go b/service/chain_service/chain_config.go new file mode 100644 index 00000000..3ce2b73d --- /dev/null +++ b/service/chain_service/chain_config.go @@ -0,0 +1,39 @@ +package chain_service + +import ( + "AAStarCommunity/EthPaymaster_BackService/common/types" + "github.com/ethereum/go-ethereum/ethclient" +) + +var NetworkInfoMap map[types.NetWork]*types.NetworkInfo +var NetWorkClientMap map[types.NetWork]*ethclient.Client + +func init() { + ConfigInit() + ClientInit() +} +func ConfigInit() { + //TODO api key secret store + NetworkInfoMap = map[types.NetWork]*types.NetworkInfo{ + types.Ethereum: { + Name: "ethereum", + RpcUrl: "https://eth-mainnet.g.alchemy.com/v2/bIZQS43-rJMgv2_SiHqfVvXa-Z1UGoGt", + }, + types.Sepolia: { + Name: "sepolia", + RpcUrl: "https://eth-sepolia.g.alchemy.com/v2/wKeLycGxgYRykgf0aGfcpEkUtqyLQg4v", + }, + } +} + +func ClientInit() { + NetWorkClientMap = make(map[types.NetWork]*ethclient.Client) + for chain, networkInfo := range NetworkInfoMap { + client, err := ethclient.Dial(networkInfo.RpcUrl) + if err != nil { + panic(err) + } + NetWorkClientMap[chain] = client + continue + } +} diff --git a/service/chain_service/chain_service.go b/service/chain_service/chain_service.go new file mode 100644 index 00000000..0a43ca0e --- /dev/null +++ b/service/chain_service/chain_service.go @@ -0,0 +1,52 @@ +package chain_service + +import ( + "AAStarCommunity/EthPaymaster_BackService/common/types" + "context" + "github.com/ethereum/go-ethereum/common" + "golang.org/x/xerrors" + "math/big" +) + +var GweiFactor = new(big.Float).SetInt(big.NewInt(1e9)) +var EthWeiFactor = new(big.Float).SetInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)) + +func CheckContractAddressAccess(contract string, chain types.NetWork) (bool, error) { + if chain == "" { + return false, xerrors.Errorf("chain can not be empty") + } + contractAddress := common.HexToAddress(contract) + + client, exist := NetWorkClientMap[chain] + if !exist { + return false, xerrors.Errorf("chain Client [%s] not exist", chain) + } + code, err := client.CodeAt(context.Background(), contractAddress, nil) + if err != nil { + return false, err + } + if len(code) == 0 { + return false, xerrors.Errorf("contract [%s] address not exist in [%s] network", contract, chain) + } + return true, nil +} + +// GetGasPrice return gas price in wei, gwei, ether +func GetGasPrice(chain types.NetWork) (*big.Int, *big.Float, *string, error) { + client, exist := NetWorkClientMap[chain] + if !exist { + return nil, nil, nil, xerrors.Errorf("chain Client [%s] not exist", chain) + } + priceWei, err := client.SuggestGasPrice(context.Background()) + if err != nil { + return nil, nil, nil, err + } + + gasPriceInGwei := new(big.Float).SetInt(priceWei) + gasPriceInGwei.Quo(gasPriceInGwei, GweiFactor) + + gasPriceInEther := new(big.Float).SetInt(priceWei) + gasPriceInEther.Quo(gasPriceInEther, EthWeiFactor) + gasPriceInEtherStr := gasPriceInEther.Text('f', 18) + return priceWei, gasPriceInGwei, &gasPriceInEtherStr, nil +} diff --git a/service/chain_service/chain_test.go b/service/chain_service/chain_test.go new file mode 100644 index 00000000..6831ad39 --- /dev/null +++ b/service/chain_service/chain_test.go @@ -0,0 +1,30 @@ +package chain_service + +import ( + "AAStarCommunity/EthPaymaster_BackService/common/types" + "context" + "fmt" + "github.com/stretchr/testify/assert" + "testing" +) + +func TestCheckContractAddressAccess(t *testing.T) { + res, err := CheckContractAddressAccess("0x0576a174D229E3cFA37253523E645A78A0C91B57", types.Sepolia) + assert.NoError(t, err) + assert.True(t, res) +} +func TestGetGasPrice(t *testing.T) { + priceWei, gasPriceInGwei, gasPriceInEtherStr, _ := GetGasPrice(types.Ethereum) + priceWeiInt := priceWei.Uint64() + fmt.Printf("priceWeiInt %d\n", priceWeiInt) + fmt.Printf("gasPriceInGwei %f\n", gasPriceInGwei) + fmt.Printf("gasPriceInEtherStr %s\n", *gasPriceInEtherStr) + +} + +func TestGethClient(t *testing.T) { + client, _ := NetWorkClientMap[types.Sepolia] + num, _ := client.BlockNumber(context.Background()) + assert.NotEqual(t, 0, num) + fmt.Println(num) +} diff --git a/service/contract_service/geth_recall.go b/service/contract_service/geth_recall.go deleted file mode 100644 index f300daad..00000000 --- a/service/contract_service/geth_recall.go +++ /dev/null @@ -1 +0,0 @@ -package contract_service diff --git a/service/dashboard_service/dashboard_service.go b/service/dashboard_service/dashboard_service.go index a8acdeec..0aa0b4c0 100644 --- a/service/dashboard_service/dashboard_service.go +++ b/service/dashboard_service/dashboard_service.go @@ -1,16 +1,26 @@ package dashboard_service -import "AAStarCommunity/EthPaymaster_BackService/common/model" +import ( + "AAStarCommunity/EthPaymaster_BackService/common/model" + "AAStarCommunity/EthPaymaster_BackService/common/types" + "errors" +) var mockStrategyMap = map[string]*model.Strategy{} func init() { mockStrategyMap["1"] = &model.Strategy{ Id: "1", - EntryPointAddress: "0x123", - PayMasterAddress: "0x123", + EntryPointAddress: "0x0576a174D229E3cFA37253523E645A78A0C91B57", + PayMasterAddress: "0x0000000000325602a77416A16136FDafd04b299f", + NetWork: types.Sepolia, + Token: types.USDT, } } func GetStrategyById(strategyId string) *model.Strategy { return mockStrategyMap[strategyId] } + +func GetSuitableStrategy(entrypoint string, chain types.NetWork, token string) (*model.Strategy, error) { + return nil, errors.New("not implemented") +} diff --git a/service/dashboard_service/strategy_selector.go b/service/dashboard_service/strategy_selector.go deleted file mode 100644 index e540d521..00000000 --- a/service/dashboard_service/strategy_selector.go +++ /dev/null @@ -1,10 +0,0 @@ -package dashboard_service - -import ( - "AAStarCommunity/EthPaymaster_BackService/common/model" - "errors" -) - -func GetSuitableStrategy(entrypoint string, network string, token string) (*model.Strategy, error) { - return nil, errors.New("not implemented") -} diff --git a/service/gas_service/gas_compotor.go b/service/gas_service/gas_compotor.go deleted file mode 100644 index d80a4526..00000000 --- a/service/gas_service/gas_compotor.go +++ /dev/null @@ -1,11 +0,0 @@ -package gas_service - -import "AAStarCommunity/EthPaymaster_BackService/common/model" - -func ComputeGas(userOp *model.UserOperationItem, strategy *model.Strategy) (*model.ComputeGasResponse, error) { - return &model.ComputeGasResponse{}, nil -} - -func ValidateGas(userOp *model.UserOperationItem, gasComputeResponse *model.ComputeGasResponse) error { - return nil -} diff --git a/service/gas_service/gas_computor.go b/service/gas_service/gas_computor.go new file mode 100644 index 00000000..37c0b65c --- /dev/null +++ b/service/gas_service/gas_computor.go @@ -0,0 +1,28 @@ +package gas_service + +import ( + "AAStarCommunity/EthPaymaster_BackService/common/model" + "AAStarCommunity/EthPaymaster_BackService/common/types" + "AAStarCommunity/EthPaymaster_BackService/service/chain_service" +) + +func ComputeGas(userOp *model.UserOperationItem, strategy *model.Strategy) (*model.ComputeGasResponse, error) { + priceInWei, gasPriceInGwei, gasPriceInEtherStr, getGasErr := chain_service.GetGasPrice(types.Sepolia) + if getGasErr != nil { + return nil, getGasErr + } + return &model.ComputeGasResponse{ + GasPriceInWei: priceInWei.Uint64(), + GasPriceInGwei: gasPriceInGwei, + GasPriceInEther: *gasPriceInEtherStr, + TokenCost: "0.0001", + Network: strategy.NetWork, + Token: strategy.Token, + UsdCost: "0.4", + BlobEnable: strategy.Enable4844, + }, nil +} + +func ValidateGas(userOp *model.UserOperationItem, gasComputeResponse *model.ComputeGasResponse) error { + return nil +} diff --git a/service/gas_service/gas_computor_test.go b/service/gas_service/gas_computor_test.go new file mode 100644 index 00000000..27fcf074 --- /dev/null +++ b/service/gas_service/gas_computor_test.go @@ -0,0 +1 @@ +package gas_service diff --git a/service/operator/try_pay_user_op_execute.go b/service/operator/try_pay_user_op_execute.go index d2edc05a..f7c01853 100644 --- a/service/operator/try_pay_user_op_execute.go +++ b/service/operator/try_pay_user_op_execute.go @@ -2,9 +2,13 @@ package operator import ( "AAStarCommunity/EthPaymaster_BackService/common/model" + "AAStarCommunity/EthPaymaster_BackService/common/utils" + "AAStarCommunity/EthPaymaster_BackService/service/chain_service" "AAStarCommunity/EthPaymaster_BackService/service/dashboard_service" "AAStarCommunity/EthPaymaster_BackService/service/gas_service" + "AAStarCommunity/EthPaymaster_BackService/service/pay_service" "AAStarCommunity/EthPaymaster_BackService/service/validator_service" + "encoding/hex" "golang.org/x/xerrors" ) @@ -35,6 +39,7 @@ func TryPayUserOpExecute(request *model.TryPayUserOpRequest) (*model.Result, err if err := gas_service.ValidateGas(&userOp, gasResponse); err != nil { return nil, err } + //pay payReceipt, payError := executePay(strategy, &userOp, gasResponse) if payError != nil { @@ -44,7 +49,7 @@ func TryPayUserOpExecute(request *model.TryPayUserOpRequest) (*model.Result, err var result = model.TryPayUserOpResponse{ StrategyId: strategy.Id, EntryPointAddress: strategy.EntryPointAddress, - PayMasterAddress: strategy.EntryPointAddress, + PayMasterAddress: strategy.PayMasterAddress, PayReceipt: payReceipt, PayMasterSignature: paymasterSignature, GasInfo: gasResponse, @@ -57,19 +62,44 @@ func TryPayUserOpExecute(request *model.TryPayUserOpRequest) (*model.Result, err Cost: "cost", }, nil } + func businessParamValidate(request *model.TryPayUserOpRequest) error { + if request.ForceStrategyId == "" && (request.ForceToken == "" || request.ForceNetwork == "") { + return xerrors.Errorf("Token And Network Must Set When ForceStrategyId Is Empty") + } //UserOp Validate + if err := validator_service.ValidateUserOp(&request.UserOperation); err != nil { + return err + } + if request.ForceEntryPointAddress != "" && request.ForceNetwork != "" { + // check Address is available in NetWork + if ok, err := chain_service.CheckContractAddressAccess(request.ForceEntryPointAddress, request.ForceNetwork); err != nil { + return err + } else if !ok { + return xerrors.Errorf("ForceEntryPointAddress: [%s] not exist in [%s] network", request.ForceEntryPointAddress, request.ForceNetwork) + } + } return nil } -func executePay(strategy *model.Strategy, userOp *model.UserOperationItem, gasResponse *model.ComputeGasResponse) (interface{}, error) { +func executePay(strategy *model.Strategy, userOp *model.UserOperationItem, gasResponse *model.ComputeGasResponse) (*model.PayReceipt, error) { //1.Recharge + ethereumPayservice := pay_service.EthereumPayService{} + if err := ethereumPayservice.Pay(); err != nil { + return nil, err + } //2.record account + ethereumPayservice.RecordAccount() //3.return Receipt - return nil, nil + ethereumPayservice.GetReceipt() + return &model.PayReceipt{ + TransactionHash: "0x110406d44ec1681fcdab1df2310181dee26ff43c37167b2c9c496b35cce69437", + Sponsor: "aastar", + }, nil } func getPayMasterSignature(strategy *model.Strategy, userOp *model.UserOperationItem) string { - return "" + signatureBytes, _ := utils.SignUserOp("1d8a58126e87e53edc7b24d58d1328230641de8c4242c135492bf5560e0ff421", userOp) + return hex.EncodeToString(signatureBytes) } func strategyGenerate(request *model.TryPayUserOpRequest) (*model.Strategy, error) { @@ -82,7 +112,7 @@ func strategyGenerate(request *model.TryPayUserOpRequest) (*model.Strategy, erro } } - suitableStrategy, err := dashboard_service.GetSuitableStrategy(request.ForceEntryPointAddress, request.ForceNetWork, request.ForceTokens) //TODO + suitableStrategy, err := dashboard_service.GetSuitableStrategy(request.ForceEntryPointAddress, request.ForceNetwork, request.ForceToken) //TODO if err != nil { return nil, err } diff --git a/service/operator/try_pay_user_op_execute_test.go b/service/operator/try_pay_user_op_execute_test.go index 937bcf85..39a11329 100644 --- a/service/operator/try_pay_user_op_execute_test.go +++ b/service/operator/try_pay_user_op_execute_test.go @@ -2,30 +2,24 @@ package operator import ( "AAStarCommunity/EthPaymaster_BackService/common/model" + "AAStarCommunity/EthPaymaster_BackService/common/utils" + "encoding/json" "fmt" "github.com/stretchr/testify/assert" - "testing" ) func TestTryPayUserOpExecute(t *testing.T) { request := getMockTryPayUserOpRequest() - result, err := TryPayUserOpExecute(&request) + result, err := TryPayUserOpExecute(request) assert.NoError(t, err) - fmt.Printf("Result: %v", result) + resultJson, _ := json.Marshal(result) + fmt.Printf("Result: %v", string(resultJson)) } -func getMockTryPayUserOpRequest() model.TryPayUserOpRequest { - return model.TryPayUserOpRequest{ +func getMockTryPayUserOpRequest() *model.TryPayUserOpRequest { + return &model.TryPayUserOpRequest{ ForceStrategyId: "1", - UserOperation: model.UserOperationItem{ - Sender: "0x123", - Nonce: "", - CallGasLimit: "", - VerificationGasList: "", - PerVerificationGas: "", - MaxFeePerGas: "", - MaxPriorityFeePerGas: "", - }, + UserOperation: *utils.GenerateMockUserOperation(), } } diff --git a/service/pay_service/pay_service.go b/service/pay_service/pay_service.go new file mode 100644 index 00000000..86ae6fc0 --- /dev/null +++ b/service/pay_service/pay_service.go @@ -0,0 +1,25 @@ +package pay_service + +type PayService interface { + Pay() error + RecordAccount() + getReceipt() +} + +type EthereumPayService struct { +} + +func (e *EthereumPayService) RecordAccount() { + //TODO implement me + +} + +func (e *EthereumPayService) GetReceipt() { + //TODO implement me + +} + +func (e *EthereumPayService) Pay() error { + //TODO implement me + return nil +} diff --git a/service/validator_service/basic_validator.go b/service/validator_service/basic_validator.go index d893f658..d52effca 100644 --- a/service/validator_service/basic_validator.go +++ b/service/validator_service/basic_validator.go @@ -1,7 +1,29 @@ package validator_service -import "AAStarCommunity/EthPaymaster_BackService/common/model" +import ( + "AAStarCommunity/EthPaymaster_BackService/common/model" + "AAStarCommunity/EthPaymaster_BackService/service/chain_service" + "golang.org/x/xerrors" +) func ValidateStrategy(strategy *model.Strategy, userOp *model.UserOperationItem) error { + if strategy == nil { + return xerrors.Errorf("empty strategy") + } + if strategy.NetWork == "" { + return xerrors.Errorf("empty strategy network") + } + // check Paymaster + ok, err := chain_service.CheckContractAddressAccess(strategy.PayMasterAddress, strategy.NetWork) + if !ok || err != nil { + return err + } + // check EntryPoint + return nil +} + +func ValidateUserOp(userOp *model.UserOperationItem) error { + // check Sender is valid ,if sender is invalid And InitCode empty, return error + // nonce is valid return nil }