From 5b9182134fd69be4a3f86bb22d0f0c21ed92988a Mon Sep 17 00:00:00 2001 From: chibie Date: Fri, 21 Feb 2025 02:14:15 +0100 Subject: [PATCH] Revert "feat: added new `bundler_url` and `paymaster_url` columns to `networks` table" (#428) * Revert "refactor: remove debug logging in SendUserOperation utility function" This reverts commit 38b7f8b06ea0a7730e2c1441a43e2f45f3ade3a9. * Revert "refactor: update AA service integration and test URLs" This reverts commit 5a412af107db6bce5b252d82bde33e12ecca7bc8. * Revert "refactor: simplify database client access in getEndpoints" This reverts commit 89dff2fb2d19149e1325724677284f43991e415f. * Revert "feat(migrations): add bundler & paymaster URLs to networks table" This reverts commit cac5ef5abc200a89df1c74620cbda797e7728191. * Revert "refactor: remove redundant env vars, optimize database queries, and clean up tests" This reverts commit 594011913a59162ef9aca5b96f94a3127e1aaceb. * Revert "chore: update test file and remove unnecessary comments" This reverts commit 1f7d81e46b560450be7e1c1d849b312173f84178. * Revert "feat: added new `bundler_url` and `paymaster_url` columns to `networks` table" This reverts commit f7314949e87003755c8072af0adaca92d8816946. --- Dockerfile | 2 +- Dockerfile.prod | 2 +- config/order.go | 24 +++ .../migrations/20250220014823_aa_to_db.sql | 2 - ent/migrate/migrations/atlas.sum | 3 +- ent/migrate/schema.go | 2 - ent/mutation.go | 148 +------------- ent/network.go | 24 +-- ent/network/network.go | 16 -- ent/network/where.go | 160 ---------------- ent/network_create.go | 156 --------------- ent/network_update.go | 104 ---------- ent/runtime/runtime.go | 4 +- ent/schema/network.go | 4 - go.mod | 10 +- go.sum | 14 +- install_atlas.sh | 42 ---- utils/userop.go | 180 ++++++++++-------- utils/userop_test.go | 141 ++++++-------- 19 files changed, 198 insertions(+), 840 deletions(-) delete mode 100644 ent/migrate/migrations/20250220014823_aa_to_db.sql delete mode 100644 install_atlas.sh diff --git a/Dockerfile b/Dockerfile index 16b62f85..ff466145 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Start from golang base image -FROM golang:1.23.0-bullseye +FROM golang:1.22.11-bullseye # Install the air binary RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin diff --git a/Dockerfile.prod b/Dockerfile.prod index 1d445730..38ba40e5 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -1,5 +1,5 @@ # Start from golang base image -FROM golang:1.23-alpine3.21 as builder +FROM golang:1.22.11-alpine3.21 as builder # Install git. RUN apk update && apk add --no-cache git diff --git a/config/order.go b/config/order.go index ceba68ca..c98e8ed4 100644 --- a/config/order.go +++ b/config/order.go @@ -21,6 +21,17 @@ type OrderConfiguration struct { RefundCancellationCount int PercentDeviationFromExternalRate decimal.Decimal PercentDeviationFromMarketRate decimal.Decimal + BundlerUrlEthereum string + PaymasterUrlEthereum string + BundlerUrlPolygon string + PaymasterUrlPolygon string + BundlerUrlBase string + PaymasterUrlBase string + BundlerUrlBSC string + PaymasterUrlBSC string + BundlerUrlArbitrum string + PaymasterUrlArbitrum string + ActiveAAService string } // OrderConfig sets the order configuration @@ -34,12 +45,25 @@ func OrderConfig() *OrderConfiguration { viper.SetDefault("NETWORK_FEE", 0.05) viper.SetDefault("PERCENT_DEVIATION_FROM_EXTERNAL_RATE", 0.01) viper.SetDefault("PERCENT_DEVIATION_FROM_MARKET_RATE", 0.1) + viper.SetDefault("ACTIVE_AA_SERVICE", "stackup") return &OrderConfiguration{ OrderFulfillmentValidity: time.Duration(viper.GetInt("ORDER_FULFILLMENT_VALIDITY")) * time.Minute, + OrderRefundTimeout: time.Duration(viper.GetInt("ORDER_REFUND_TIMEOUT")) * time.Minute, ReceiveAddressValidity: time.Duration(viper.GetInt("RECEIVE_ADDRESS_VALIDITY")) * time.Minute, OrderRequestValidity: time.Duration(viper.GetInt("ORDER_REQUEST_VALIDITY")) * time.Second, TronProApiKey: viper.GetString("TRON_PRO_API_KEY"), + ActiveAAService: viper.GetString("ACTIVE_AA_SERVICE"), + BundlerUrlEthereum: viper.GetString("BUNDLER_URL_ETHEREUM"), + PaymasterUrlEthereum: viper.GetString("PAYMASTER_URL_ETHEREUM"), + BundlerUrlPolygon: viper.GetString("BUNDLER_URL_POLYGON"), + PaymasterUrlPolygon: viper.GetString("PAYMASTER_URL_POLYGON"), + BundlerUrlBase: viper.GetString("BUNDLER_URL_BASE"), + PaymasterUrlBase: viper.GetString("PAYMASTER_URL_BASE"), + BundlerUrlBSC: viper.GetString("BUNDLER_URL_BSC"), + PaymasterUrlBSC: viper.GetString("PAYMASTER_URL_BSC"), + BundlerUrlArbitrum: viper.GetString("BUNDLER_URL_ARBITRUM"), + PaymasterUrlArbitrum: viper.GetString("PAYMASTER_URL_ARBITRUM"), EntryPointContractAddress: common.HexToAddress(viper.GetString("ENTRY_POINT_CONTRACT_ADDRESS")), BucketQueueRebuildInterval: viper.GetInt("BUCKET_QUEUE_REBUILD_INTERVAL"), RefundCancellationCount: viper.GetInt("REFUND_CANCELLATION_COUNT"), diff --git a/ent/migrate/migrations/20250220014823_aa_to_db.sql b/ent/migrate/migrations/20250220014823_aa_to_db.sql deleted file mode 100644 index ea999e94..00000000 --- a/ent/migrate/migrations/20250220014823_aa_to_db.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Modify "networks" table -ALTER TABLE "networks" ADD COLUMN "bundler_url" character varying NULL, ADD COLUMN "paymaster_url" character varying NULL; diff --git a/ent/migrate/migrations/atlas.sum b/ent/migrate/migrations/atlas.sum index 080a01a3..9f8d7d1a 100644 --- a/ent/migrate/migrations/atlas.sum +++ b/ent/migrate/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:dR+GjJoPfeuDFy3ZE8clPJfTvnRV/Q1LPkeT1nxVxJ4= +h1:0TorEmKfcV3nUsITm2cbp5Yv14Y/YkjEuBOXQsvpcH4= 20240118234246_initial.sql h1:dYuYBqns33WT+3p8VQvbKUP62k3k6w6h8S+FqNqgSvU= 20240130122324_order_from_address.sql h1:mMVI2iBUd1roIYLUqu0d2jZ7+B6exppRN8qqn+aIHx4= 20240202010744_fees_on_order.sql h1:P7ngxZKqDKefBM5vk6M3kbWeMPVwbZ4MZVcLBjEfS34= @@ -43,4 +43,3 @@ h1:dR+GjJoPfeuDFy3ZE8clPJfTvnRV/Q1LPkeT1nxVxJ4= 20241011010524_linked_addresses.sql h1:JvCXlyrRTwXqYPwz5YoGoh+/KEaGiswxmRp//wyxyhU= 20241226183354_add_reference.sql h1:oS3oVJcfD6q7EvDQrTWudCEf3HjBm/yI8XTlPvGqLC8= 20250205002723_lof_optional_txid.sql h1:Ew1wBRx/K1cBIA//BAOjReVJW11idWCIkLnuaF8FdXY= -20250220014823_aa_to_db.sql h1:pqbdJZe7CXgXI7ak+ggHUhjncM7l5Kiw02S4N/hqCXU= diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index 3f98d4d3..00ee1b44 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -217,8 +217,6 @@ var ( {Name: "rpc_endpoint", Type: field.TypeString}, {Name: "gateway_contract_address", Type: field.TypeString, Default: ""}, {Name: "is_testnet", Type: field.TypeBool}, - {Name: "bundler_url", Type: field.TypeString, Nullable: true}, - {Name: "paymaster_url", Type: field.TypeString, Nullable: true}, {Name: "fee", Type: field.TypeFloat64}, } // NetworksTable holds the schema information for the "networks" table. diff --git a/ent/mutation.go b/ent/mutation.go index cb98f94b..9f235d41 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -6453,8 +6453,6 @@ type NetworkMutation struct { rpc_endpoint *string gateway_contract_address *string is_testnet *bool - bundler_url *string - paymaster_url *string fee *decimal.Decimal addfee *decimal.Decimal clearedFields map[string]struct{} @@ -6885,104 +6883,6 @@ func (m *NetworkMutation) ResetIsTestnet() { m.is_testnet = nil } -// SetBundlerURL sets the "bundler_url" field. -func (m *NetworkMutation) SetBundlerURL(s string) { - m.bundler_url = &s -} - -// BundlerURL returns the value of the "bundler_url" field in the mutation. -func (m *NetworkMutation) BundlerURL() (r string, exists bool) { - v := m.bundler_url - if v == nil { - return - } - return *v, true -} - -// OldBundlerURL returns the old "bundler_url" field's value of the Network entity. -// If the Network object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkMutation) OldBundlerURL(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBundlerURL is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBundlerURL requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldBundlerURL: %w", err) - } - return oldValue.BundlerURL, nil -} - -// ClearBundlerURL clears the value of the "bundler_url" field. -func (m *NetworkMutation) ClearBundlerURL() { - m.bundler_url = nil - m.clearedFields[network.FieldBundlerURL] = struct{}{} -} - -// BundlerURLCleared returns if the "bundler_url" field was cleared in this mutation. -func (m *NetworkMutation) BundlerURLCleared() bool { - _, ok := m.clearedFields[network.FieldBundlerURL] - return ok -} - -// ResetBundlerURL resets all changes to the "bundler_url" field. -func (m *NetworkMutation) ResetBundlerURL() { - m.bundler_url = nil - delete(m.clearedFields, network.FieldBundlerURL) -} - -// SetPaymasterURL sets the "paymaster_url" field. -func (m *NetworkMutation) SetPaymasterURL(s string) { - m.paymaster_url = &s -} - -// PaymasterURL returns the value of the "paymaster_url" field in the mutation. -func (m *NetworkMutation) PaymasterURL() (r string, exists bool) { - v := m.paymaster_url - if v == nil { - return - } - return *v, true -} - -// OldPaymasterURL returns the old "paymaster_url" field's value of the Network entity. -// If the Network object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NetworkMutation) OldPaymasterURL(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPaymasterURL is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPaymasterURL requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPaymasterURL: %w", err) - } - return oldValue.PaymasterURL, nil -} - -// ClearPaymasterURL clears the value of the "paymaster_url" field. -func (m *NetworkMutation) ClearPaymasterURL() { - m.paymaster_url = nil - m.clearedFields[network.FieldPaymasterURL] = struct{}{} -} - -// PaymasterURLCleared returns if the "paymaster_url" field was cleared in this mutation. -func (m *NetworkMutation) PaymasterURLCleared() bool { - _, ok := m.clearedFields[network.FieldPaymasterURL] - return ok -} - -// ResetPaymasterURL resets all changes to the "paymaster_url" field. -func (m *NetworkMutation) ResetPaymasterURL() { - m.paymaster_url = nil - delete(m.clearedFields, network.FieldPaymasterURL) -} - // SetFee sets the "fee" field. func (m *NetworkMutation) SetFee(d decimal.Decimal) { m.fee = &d @@ -7127,7 +7027,7 @@ func (m *NetworkMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *NetworkMutation) Fields() []string { - fields := make([]string, 0, 11) + fields := make([]string, 0, 9) if m.created_at != nil { fields = append(fields, network.FieldCreatedAt) } @@ -7152,12 +7052,6 @@ func (m *NetworkMutation) Fields() []string { if m.is_testnet != nil { fields = append(fields, network.FieldIsTestnet) } - if m.bundler_url != nil { - fields = append(fields, network.FieldBundlerURL) - } - if m.paymaster_url != nil { - fields = append(fields, network.FieldPaymasterURL) - } if m.fee != nil { fields = append(fields, network.FieldFee) } @@ -7185,10 +7079,6 @@ func (m *NetworkMutation) Field(name string) (ent.Value, bool) { return m.GatewayContractAddress() case network.FieldIsTestnet: return m.IsTestnet() - case network.FieldBundlerURL: - return m.BundlerURL() - case network.FieldPaymasterURL: - return m.PaymasterURL() case network.FieldFee: return m.Fee() } @@ -7216,10 +7106,6 @@ func (m *NetworkMutation) OldField(ctx context.Context, name string) (ent.Value, return m.OldGatewayContractAddress(ctx) case network.FieldIsTestnet: return m.OldIsTestnet(ctx) - case network.FieldBundlerURL: - return m.OldBundlerURL(ctx) - case network.FieldPaymasterURL: - return m.OldPaymasterURL(ctx) case network.FieldFee: return m.OldFee(ctx) } @@ -7287,20 +7173,6 @@ func (m *NetworkMutation) SetField(name string, value ent.Value) error { } m.SetIsTestnet(v) return nil - case network.FieldBundlerURL: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetBundlerURL(v) - return nil - case network.FieldPaymasterURL: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPaymasterURL(v) - return nil case network.FieldFee: v, ok := value.(decimal.Decimal) if !ok { @@ -7368,12 +7240,6 @@ func (m *NetworkMutation) ClearedFields() []string { if m.FieldCleared(network.FieldChainIDHex) { fields = append(fields, network.FieldChainIDHex) } - if m.FieldCleared(network.FieldBundlerURL) { - fields = append(fields, network.FieldBundlerURL) - } - if m.FieldCleared(network.FieldPaymasterURL) { - fields = append(fields, network.FieldPaymasterURL) - } return fields } @@ -7391,12 +7257,6 @@ func (m *NetworkMutation) ClearField(name string) error { case network.FieldChainIDHex: m.ClearChainIDHex() return nil - case network.FieldBundlerURL: - m.ClearBundlerURL() - return nil - case network.FieldPaymasterURL: - m.ClearPaymasterURL() - return nil } return fmt.Errorf("unknown Network nullable field %s", name) } @@ -7429,12 +7289,6 @@ func (m *NetworkMutation) ResetField(name string) error { case network.FieldIsTestnet: m.ResetIsTestnet() return nil - case network.FieldBundlerURL: - m.ResetBundlerURL() - return nil - case network.FieldPaymasterURL: - m.ResetPaymasterURL() - return nil case network.FieldFee: m.ResetFee() return nil diff --git a/ent/network.go b/ent/network.go index ae6e07bc..43228d30 100644 --- a/ent/network.go +++ b/ent/network.go @@ -34,10 +34,6 @@ type Network struct { GatewayContractAddress string `json:"gateway_contract_address,omitempty"` // IsTestnet holds the value of the "is_testnet" field. IsTestnet bool `json:"is_testnet,omitempty"` - // BundlerURL holds the value of the "bundler_url" field. - BundlerURL string `json:"bundler_url,omitempty"` - // PaymasterURL holds the value of the "paymaster_url" field. - PaymasterURL string `json:"paymaster_url,omitempty"` // Fee holds the value of the "fee" field. Fee decimal.Decimal `json:"fee,omitempty"` // Edges holds the relations/edges for other nodes in the graph. @@ -75,7 +71,7 @@ func (*Network) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullBool) case network.FieldID, network.FieldChainID: values[i] = new(sql.NullInt64) - case network.FieldChainIDHex, network.FieldIdentifier, network.FieldRPCEndpoint, network.FieldGatewayContractAddress, network.FieldBundlerURL, network.FieldPaymasterURL: + case network.FieldChainIDHex, network.FieldIdentifier, network.FieldRPCEndpoint, network.FieldGatewayContractAddress: values[i] = new(sql.NullString) case network.FieldCreatedAt, network.FieldUpdatedAt: values[i] = new(sql.NullTime) @@ -148,18 +144,6 @@ func (n *Network) assignValues(columns []string, values []any) error { } else if value.Valid { n.IsTestnet = value.Bool } - case network.FieldBundlerURL: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field bundler_url", values[i]) - } else if value.Valid { - n.BundlerURL = value.String - } - case network.FieldPaymasterURL: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field paymaster_url", values[i]) - } else if value.Valid { - n.PaymasterURL = value.String - } case network.FieldFee: if value, ok := values[i].(*decimal.Decimal); !ok { return fmt.Errorf("unexpected type %T for field fee", values[i]) @@ -231,12 +215,6 @@ func (n *Network) String() string { builder.WriteString("is_testnet=") builder.WriteString(fmt.Sprintf("%v", n.IsTestnet)) builder.WriteString(", ") - builder.WriteString("bundler_url=") - builder.WriteString(n.BundlerURL) - builder.WriteString(", ") - builder.WriteString("paymaster_url=") - builder.WriteString(n.PaymasterURL) - builder.WriteString(", ") builder.WriteString("fee=") builder.WriteString(fmt.Sprintf("%v", n.Fee)) builder.WriteByte(')') diff --git a/ent/network/network.go b/ent/network/network.go index 33e63f7e..059485fe 100644 --- a/ent/network/network.go +++ b/ent/network/network.go @@ -30,10 +30,6 @@ const ( FieldGatewayContractAddress = "gateway_contract_address" // FieldIsTestnet holds the string denoting the is_testnet field in the database. FieldIsTestnet = "is_testnet" - // FieldBundlerURL holds the string denoting the bundler_url field in the database. - FieldBundlerURL = "bundler_url" - // FieldPaymasterURL holds the string denoting the paymaster_url field in the database. - FieldPaymasterURL = "paymaster_url" // FieldFee holds the string denoting the fee field in the database. FieldFee = "fee" // EdgeTokens holds the string denoting the tokens edge name in mutations. @@ -60,8 +56,6 @@ var Columns = []string{ FieldRPCEndpoint, FieldGatewayContractAddress, FieldIsTestnet, - FieldBundlerURL, - FieldPaymasterURL, FieldFee, } @@ -134,16 +128,6 @@ func ByIsTestnet(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldIsTestnet, opts...).ToFunc() } -// ByBundlerURL orders the results by the bundler_url field. -func ByBundlerURL(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldBundlerURL, opts...).ToFunc() -} - -// ByPaymasterURL orders the results by the paymaster_url field. -func ByPaymasterURL(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPaymasterURL, opts...).ToFunc() -} - // ByFee orders the results by the fee field. func ByFee(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldFee, opts...).ToFunc() diff --git a/ent/network/where.go b/ent/network/where.go index 92ea064b..72da320b 100644 --- a/ent/network/where.go +++ b/ent/network/where.go @@ -96,16 +96,6 @@ func IsTestnet(v bool) predicate.Network { return predicate.Network(sql.FieldEQ(FieldIsTestnet, v)) } -// BundlerURL applies equality check predicate on the "bundler_url" field. It's identical to BundlerURLEQ. -func BundlerURL(v string) predicate.Network { - return predicate.Network(sql.FieldEQ(FieldBundlerURL, v)) -} - -// PaymasterURL applies equality check predicate on the "paymaster_url" field. It's identical to PaymasterURLEQ. -func PaymasterURL(v string) predicate.Network { - return predicate.Network(sql.FieldEQ(FieldPaymasterURL, v)) -} - // Fee applies equality check predicate on the "fee" field. It's identical to FeeEQ. func Fee(v decimal.Decimal) predicate.Network { return predicate.Network(sql.FieldEQ(FieldFee, v)) @@ -511,156 +501,6 @@ func IsTestnetNEQ(v bool) predicate.Network { return predicate.Network(sql.FieldNEQ(FieldIsTestnet, v)) } -// BundlerURLEQ applies the EQ predicate on the "bundler_url" field. -func BundlerURLEQ(v string) predicate.Network { - return predicate.Network(sql.FieldEQ(FieldBundlerURL, v)) -} - -// BundlerURLNEQ applies the NEQ predicate on the "bundler_url" field. -func BundlerURLNEQ(v string) predicate.Network { - return predicate.Network(sql.FieldNEQ(FieldBundlerURL, v)) -} - -// BundlerURLIn applies the In predicate on the "bundler_url" field. -func BundlerURLIn(vs ...string) predicate.Network { - return predicate.Network(sql.FieldIn(FieldBundlerURL, vs...)) -} - -// BundlerURLNotIn applies the NotIn predicate on the "bundler_url" field. -func BundlerURLNotIn(vs ...string) predicate.Network { - return predicate.Network(sql.FieldNotIn(FieldBundlerURL, vs...)) -} - -// BundlerURLGT applies the GT predicate on the "bundler_url" field. -func BundlerURLGT(v string) predicate.Network { - return predicate.Network(sql.FieldGT(FieldBundlerURL, v)) -} - -// BundlerURLGTE applies the GTE predicate on the "bundler_url" field. -func BundlerURLGTE(v string) predicate.Network { - return predicate.Network(sql.FieldGTE(FieldBundlerURL, v)) -} - -// BundlerURLLT applies the LT predicate on the "bundler_url" field. -func BundlerURLLT(v string) predicate.Network { - return predicate.Network(sql.FieldLT(FieldBundlerURL, v)) -} - -// BundlerURLLTE applies the LTE predicate on the "bundler_url" field. -func BundlerURLLTE(v string) predicate.Network { - return predicate.Network(sql.FieldLTE(FieldBundlerURL, v)) -} - -// BundlerURLContains applies the Contains predicate on the "bundler_url" field. -func BundlerURLContains(v string) predicate.Network { - return predicate.Network(sql.FieldContains(FieldBundlerURL, v)) -} - -// BundlerURLHasPrefix applies the HasPrefix predicate on the "bundler_url" field. -func BundlerURLHasPrefix(v string) predicate.Network { - return predicate.Network(sql.FieldHasPrefix(FieldBundlerURL, v)) -} - -// BundlerURLHasSuffix applies the HasSuffix predicate on the "bundler_url" field. -func BundlerURLHasSuffix(v string) predicate.Network { - return predicate.Network(sql.FieldHasSuffix(FieldBundlerURL, v)) -} - -// BundlerURLIsNil applies the IsNil predicate on the "bundler_url" field. -func BundlerURLIsNil() predicate.Network { - return predicate.Network(sql.FieldIsNull(FieldBundlerURL)) -} - -// BundlerURLNotNil applies the NotNil predicate on the "bundler_url" field. -func BundlerURLNotNil() predicate.Network { - return predicate.Network(sql.FieldNotNull(FieldBundlerURL)) -} - -// BundlerURLEqualFold applies the EqualFold predicate on the "bundler_url" field. -func BundlerURLEqualFold(v string) predicate.Network { - return predicate.Network(sql.FieldEqualFold(FieldBundlerURL, v)) -} - -// BundlerURLContainsFold applies the ContainsFold predicate on the "bundler_url" field. -func BundlerURLContainsFold(v string) predicate.Network { - return predicate.Network(sql.FieldContainsFold(FieldBundlerURL, v)) -} - -// PaymasterURLEQ applies the EQ predicate on the "paymaster_url" field. -func PaymasterURLEQ(v string) predicate.Network { - return predicate.Network(sql.FieldEQ(FieldPaymasterURL, v)) -} - -// PaymasterURLNEQ applies the NEQ predicate on the "paymaster_url" field. -func PaymasterURLNEQ(v string) predicate.Network { - return predicate.Network(sql.FieldNEQ(FieldPaymasterURL, v)) -} - -// PaymasterURLIn applies the In predicate on the "paymaster_url" field. -func PaymasterURLIn(vs ...string) predicate.Network { - return predicate.Network(sql.FieldIn(FieldPaymasterURL, vs...)) -} - -// PaymasterURLNotIn applies the NotIn predicate on the "paymaster_url" field. -func PaymasterURLNotIn(vs ...string) predicate.Network { - return predicate.Network(sql.FieldNotIn(FieldPaymasterURL, vs...)) -} - -// PaymasterURLGT applies the GT predicate on the "paymaster_url" field. -func PaymasterURLGT(v string) predicate.Network { - return predicate.Network(sql.FieldGT(FieldPaymasterURL, v)) -} - -// PaymasterURLGTE applies the GTE predicate on the "paymaster_url" field. -func PaymasterURLGTE(v string) predicate.Network { - return predicate.Network(sql.FieldGTE(FieldPaymasterURL, v)) -} - -// PaymasterURLLT applies the LT predicate on the "paymaster_url" field. -func PaymasterURLLT(v string) predicate.Network { - return predicate.Network(sql.FieldLT(FieldPaymasterURL, v)) -} - -// PaymasterURLLTE applies the LTE predicate on the "paymaster_url" field. -func PaymasterURLLTE(v string) predicate.Network { - return predicate.Network(sql.FieldLTE(FieldPaymasterURL, v)) -} - -// PaymasterURLContains applies the Contains predicate on the "paymaster_url" field. -func PaymasterURLContains(v string) predicate.Network { - return predicate.Network(sql.FieldContains(FieldPaymasterURL, v)) -} - -// PaymasterURLHasPrefix applies the HasPrefix predicate on the "paymaster_url" field. -func PaymasterURLHasPrefix(v string) predicate.Network { - return predicate.Network(sql.FieldHasPrefix(FieldPaymasterURL, v)) -} - -// PaymasterURLHasSuffix applies the HasSuffix predicate on the "paymaster_url" field. -func PaymasterURLHasSuffix(v string) predicate.Network { - return predicate.Network(sql.FieldHasSuffix(FieldPaymasterURL, v)) -} - -// PaymasterURLIsNil applies the IsNil predicate on the "paymaster_url" field. -func PaymasterURLIsNil() predicate.Network { - return predicate.Network(sql.FieldIsNull(FieldPaymasterURL)) -} - -// PaymasterURLNotNil applies the NotNil predicate on the "paymaster_url" field. -func PaymasterURLNotNil() predicate.Network { - return predicate.Network(sql.FieldNotNull(FieldPaymasterURL)) -} - -// PaymasterURLEqualFold applies the EqualFold predicate on the "paymaster_url" field. -func PaymasterURLEqualFold(v string) predicate.Network { - return predicate.Network(sql.FieldEqualFold(FieldPaymasterURL, v)) -} - -// PaymasterURLContainsFold applies the ContainsFold predicate on the "paymaster_url" field. -func PaymasterURLContainsFold(v string) predicate.Network { - return predicate.Network(sql.FieldContainsFold(FieldPaymasterURL, v)) -} - // FeeEQ applies the EQ predicate on the "fee" field. func FeeEQ(v decimal.Decimal) predicate.Network { return predicate.Network(sql.FieldEQ(FieldFee, v)) diff --git a/ent/network_create.go b/ent/network_create.go index e29c3f9e..b173e0b1 100644 --- a/ent/network_create.go +++ b/ent/network_create.go @@ -104,34 +104,6 @@ func (nc *NetworkCreate) SetIsTestnet(b bool) *NetworkCreate { return nc } -// SetBundlerURL sets the "bundler_url" field. -func (nc *NetworkCreate) SetBundlerURL(s string) *NetworkCreate { - nc.mutation.SetBundlerURL(s) - return nc -} - -// SetNillableBundlerURL sets the "bundler_url" field if the given value is not nil. -func (nc *NetworkCreate) SetNillableBundlerURL(s *string) *NetworkCreate { - if s != nil { - nc.SetBundlerURL(*s) - } - return nc -} - -// SetPaymasterURL sets the "paymaster_url" field. -func (nc *NetworkCreate) SetPaymasterURL(s string) *NetworkCreate { - nc.mutation.SetPaymasterURL(s) - return nc -} - -// SetNillablePaymasterURL sets the "paymaster_url" field if the given value is not nil. -func (nc *NetworkCreate) SetNillablePaymasterURL(s *string) *NetworkCreate { - if s != nil { - nc.SetPaymasterURL(*s) - } - return nc -} - // SetFee sets the "fee" field. func (nc *NetworkCreate) SetFee(d decimal.Decimal) *NetworkCreate { nc.mutation.SetFee(d) @@ -287,14 +259,6 @@ func (nc *NetworkCreate) createSpec() (*Network, *sqlgraph.CreateSpec) { _spec.SetField(network.FieldIsTestnet, field.TypeBool, value) _node.IsTestnet = value } - if value, ok := nc.mutation.BundlerURL(); ok { - _spec.SetField(network.FieldBundlerURL, field.TypeString, value) - _node.BundlerURL = value - } - if value, ok := nc.mutation.PaymasterURL(); ok { - _spec.SetField(network.FieldPaymasterURL, field.TypeString, value) - _node.PaymasterURL = value - } if value, ok := nc.mutation.Fee(); ok { _spec.SetField(network.FieldFee, field.TypeFloat64, value) _node.Fee = value @@ -463,42 +427,6 @@ func (u *NetworkUpsert) UpdateIsTestnet() *NetworkUpsert { return u } -// SetBundlerURL sets the "bundler_url" field. -func (u *NetworkUpsert) SetBundlerURL(v string) *NetworkUpsert { - u.Set(network.FieldBundlerURL, v) - return u -} - -// UpdateBundlerURL sets the "bundler_url" field to the value that was provided on create. -func (u *NetworkUpsert) UpdateBundlerURL() *NetworkUpsert { - u.SetExcluded(network.FieldBundlerURL) - return u -} - -// ClearBundlerURL clears the value of the "bundler_url" field. -func (u *NetworkUpsert) ClearBundlerURL() *NetworkUpsert { - u.SetNull(network.FieldBundlerURL) - return u -} - -// SetPaymasterURL sets the "paymaster_url" field. -func (u *NetworkUpsert) SetPaymasterURL(v string) *NetworkUpsert { - u.Set(network.FieldPaymasterURL, v) - return u -} - -// UpdatePaymasterURL sets the "paymaster_url" field to the value that was provided on create. -func (u *NetworkUpsert) UpdatePaymasterURL() *NetworkUpsert { - u.SetExcluded(network.FieldPaymasterURL) - return u -} - -// ClearPaymasterURL clears the value of the "paymaster_url" field. -func (u *NetworkUpsert) ClearPaymasterURL() *NetworkUpsert { - u.SetNull(network.FieldPaymasterURL) - return u -} - // SetFee sets the "fee" field. func (u *NetworkUpsert) SetFee(v decimal.Decimal) *NetworkUpsert { u.Set(network.FieldFee, v) @@ -674,48 +602,6 @@ func (u *NetworkUpsertOne) UpdateIsTestnet() *NetworkUpsertOne { }) } -// SetBundlerURL sets the "bundler_url" field. -func (u *NetworkUpsertOne) SetBundlerURL(v string) *NetworkUpsertOne { - return u.Update(func(s *NetworkUpsert) { - s.SetBundlerURL(v) - }) -} - -// UpdateBundlerURL sets the "bundler_url" field to the value that was provided on create. -func (u *NetworkUpsertOne) UpdateBundlerURL() *NetworkUpsertOne { - return u.Update(func(s *NetworkUpsert) { - s.UpdateBundlerURL() - }) -} - -// ClearBundlerURL clears the value of the "bundler_url" field. -func (u *NetworkUpsertOne) ClearBundlerURL() *NetworkUpsertOne { - return u.Update(func(s *NetworkUpsert) { - s.ClearBundlerURL() - }) -} - -// SetPaymasterURL sets the "paymaster_url" field. -func (u *NetworkUpsertOne) SetPaymasterURL(v string) *NetworkUpsertOne { - return u.Update(func(s *NetworkUpsert) { - s.SetPaymasterURL(v) - }) -} - -// UpdatePaymasterURL sets the "paymaster_url" field to the value that was provided on create. -func (u *NetworkUpsertOne) UpdatePaymasterURL() *NetworkUpsertOne { - return u.Update(func(s *NetworkUpsert) { - s.UpdatePaymasterURL() - }) -} - -// ClearPaymasterURL clears the value of the "paymaster_url" field. -func (u *NetworkUpsertOne) ClearPaymasterURL() *NetworkUpsertOne { - return u.Update(func(s *NetworkUpsert) { - s.ClearPaymasterURL() - }) -} - // SetFee sets the "fee" field. func (u *NetworkUpsertOne) SetFee(v decimal.Decimal) *NetworkUpsertOne { return u.Update(func(s *NetworkUpsert) { @@ -1060,48 +946,6 @@ func (u *NetworkUpsertBulk) UpdateIsTestnet() *NetworkUpsertBulk { }) } -// SetBundlerURL sets the "bundler_url" field. -func (u *NetworkUpsertBulk) SetBundlerURL(v string) *NetworkUpsertBulk { - return u.Update(func(s *NetworkUpsert) { - s.SetBundlerURL(v) - }) -} - -// UpdateBundlerURL sets the "bundler_url" field to the value that was provided on create. -func (u *NetworkUpsertBulk) UpdateBundlerURL() *NetworkUpsertBulk { - return u.Update(func(s *NetworkUpsert) { - s.UpdateBundlerURL() - }) -} - -// ClearBundlerURL clears the value of the "bundler_url" field. -func (u *NetworkUpsertBulk) ClearBundlerURL() *NetworkUpsertBulk { - return u.Update(func(s *NetworkUpsert) { - s.ClearBundlerURL() - }) -} - -// SetPaymasterURL sets the "paymaster_url" field. -func (u *NetworkUpsertBulk) SetPaymasterURL(v string) *NetworkUpsertBulk { - return u.Update(func(s *NetworkUpsert) { - s.SetPaymasterURL(v) - }) -} - -// UpdatePaymasterURL sets the "paymaster_url" field to the value that was provided on create. -func (u *NetworkUpsertBulk) UpdatePaymasterURL() *NetworkUpsertBulk { - return u.Update(func(s *NetworkUpsert) { - s.UpdatePaymasterURL() - }) -} - -// ClearPaymasterURL clears the value of the "paymaster_url" field. -func (u *NetworkUpsertBulk) ClearPaymasterURL() *NetworkUpsertBulk { - return u.Update(func(s *NetworkUpsert) { - s.ClearPaymasterURL() - }) -} - // SetFee sets the "fee" field. func (u *NetworkUpsertBulk) SetFee(v decimal.Decimal) *NetworkUpsertBulk { return u.Update(func(s *NetworkUpsert) { diff --git a/ent/network_update.go b/ent/network_update.go index d9072aa1..8d9fd58f 100644 --- a/ent/network_update.go +++ b/ent/network_update.go @@ -133,46 +133,6 @@ func (nu *NetworkUpdate) SetNillableIsTestnet(b *bool) *NetworkUpdate { return nu } -// SetBundlerURL sets the "bundler_url" field. -func (nu *NetworkUpdate) SetBundlerURL(s string) *NetworkUpdate { - nu.mutation.SetBundlerURL(s) - return nu -} - -// SetNillableBundlerURL sets the "bundler_url" field if the given value is not nil. -func (nu *NetworkUpdate) SetNillableBundlerURL(s *string) *NetworkUpdate { - if s != nil { - nu.SetBundlerURL(*s) - } - return nu -} - -// ClearBundlerURL clears the value of the "bundler_url" field. -func (nu *NetworkUpdate) ClearBundlerURL() *NetworkUpdate { - nu.mutation.ClearBundlerURL() - return nu -} - -// SetPaymasterURL sets the "paymaster_url" field. -func (nu *NetworkUpdate) SetPaymasterURL(s string) *NetworkUpdate { - nu.mutation.SetPaymasterURL(s) - return nu -} - -// SetNillablePaymasterURL sets the "paymaster_url" field if the given value is not nil. -func (nu *NetworkUpdate) SetNillablePaymasterURL(s *string) *NetworkUpdate { - if s != nil { - nu.SetPaymasterURL(*s) - } - return nu -} - -// ClearPaymasterURL clears the value of the "paymaster_url" field. -func (nu *NetworkUpdate) ClearPaymasterURL() *NetworkUpdate { - nu.mutation.ClearPaymasterURL() - return nu -} - // SetFee sets the "fee" field. func (nu *NetworkUpdate) SetFee(d decimal.Decimal) *NetworkUpdate { nu.mutation.ResetFee() @@ -307,18 +267,6 @@ func (nu *NetworkUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := nu.mutation.IsTestnet(); ok { _spec.SetField(network.FieldIsTestnet, field.TypeBool, value) } - if value, ok := nu.mutation.BundlerURL(); ok { - _spec.SetField(network.FieldBundlerURL, field.TypeString, value) - } - if nu.mutation.BundlerURLCleared() { - _spec.ClearField(network.FieldBundlerURL, field.TypeString) - } - if value, ok := nu.mutation.PaymasterURL(); ok { - _spec.SetField(network.FieldPaymasterURL, field.TypeString, value) - } - if nu.mutation.PaymasterURLCleared() { - _spec.ClearField(network.FieldPaymasterURL, field.TypeString) - } if value, ok := nu.mutation.Fee(); ok { _spec.SetField(network.FieldFee, field.TypeFloat64, value) } @@ -493,46 +441,6 @@ func (nuo *NetworkUpdateOne) SetNillableIsTestnet(b *bool) *NetworkUpdateOne { return nuo } -// SetBundlerURL sets the "bundler_url" field. -func (nuo *NetworkUpdateOne) SetBundlerURL(s string) *NetworkUpdateOne { - nuo.mutation.SetBundlerURL(s) - return nuo -} - -// SetNillableBundlerURL sets the "bundler_url" field if the given value is not nil. -func (nuo *NetworkUpdateOne) SetNillableBundlerURL(s *string) *NetworkUpdateOne { - if s != nil { - nuo.SetBundlerURL(*s) - } - return nuo -} - -// ClearBundlerURL clears the value of the "bundler_url" field. -func (nuo *NetworkUpdateOne) ClearBundlerURL() *NetworkUpdateOne { - nuo.mutation.ClearBundlerURL() - return nuo -} - -// SetPaymasterURL sets the "paymaster_url" field. -func (nuo *NetworkUpdateOne) SetPaymasterURL(s string) *NetworkUpdateOne { - nuo.mutation.SetPaymasterURL(s) - return nuo -} - -// SetNillablePaymasterURL sets the "paymaster_url" field if the given value is not nil. -func (nuo *NetworkUpdateOne) SetNillablePaymasterURL(s *string) *NetworkUpdateOne { - if s != nil { - nuo.SetPaymasterURL(*s) - } - return nuo -} - -// ClearPaymasterURL clears the value of the "paymaster_url" field. -func (nuo *NetworkUpdateOne) ClearPaymasterURL() *NetworkUpdateOne { - nuo.mutation.ClearPaymasterURL() - return nuo -} - // SetFee sets the "fee" field. func (nuo *NetworkUpdateOne) SetFee(d decimal.Decimal) *NetworkUpdateOne { nuo.mutation.ResetFee() @@ -697,18 +605,6 @@ func (nuo *NetworkUpdateOne) sqlSave(ctx context.Context) (_node *Network, err e if value, ok := nuo.mutation.IsTestnet(); ok { _spec.SetField(network.FieldIsTestnet, field.TypeBool, value) } - if value, ok := nuo.mutation.BundlerURL(); ok { - _spec.SetField(network.FieldBundlerURL, field.TypeString, value) - } - if nuo.mutation.BundlerURLCleared() { - _spec.ClearField(network.FieldBundlerURL, field.TypeString) - } - if value, ok := nuo.mutation.PaymasterURL(); ok { - _spec.SetField(network.FieldPaymasterURL, field.TypeString, value) - } - if nuo.mutation.PaymasterURLCleared() { - _spec.ClearField(network.FieldPaymasterURL, field.TypeString) - } if value, ok := nuo.mutation.Fee(); ok { _spec.SetField(network.FieldFee, field.TypeFloat64, value) } diff --git a/ent/runtime/runtime.go b/ent/runtime/runtime.go index 92e671fe..cb5a05d8 100644 --- a/ent/runtime/runtime.go +++ b/ent/runtime/runtime.go @@ -496,6 +496,6 @@ func init() { } const ( - Version = "v0.14.1" // Version of ent codegen. - Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen. + Version = "v0.14.0" // Version of ent codegen. + Sum = "h1:EO3Z9aZ5bXJatJeGqu/EVdnNr6K4mRq3rWe5owt0MC4=" // Sum of ent codegen. ) diff --git a/ent/schema/network.go b/ent/schema/network.go index 3c921727..be3df581 100644 --- a/ent/schema/network.go +++ b/ent/schema/network.go @@ -31,10 +31,6 @@ func (Network) Fields() []ent.Field { field.String("rpc_endpoint"), field.String("gateway_contract_address").Default(""), field.Bool("is_testnet"), - field.String("bundler_url"). - Optional(), - field.String("paymaster_url"). - Optional(), field.Float("fee"). GoType(decimal.Decimal{}), } diff --git a/go.mod b/go.mod index 1bedb452..e7f9eb9c 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/paycrest/aggregator -go 1.23.0 - -toolchain go1.23.6 +go 1.22.0 require ( github.com/JGLTechnologies/gin-rate-limit v1.5.4 @@ -89,14 +87,14 @@ require ( go.uber.org/atomic v1.9.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/sync v0.10.0 // indirect - golang.org/x/tools v0.24.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) require ( ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect - entgo.io/ent v0.14.1 + entgo.io/ent v0.14.0 github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/bytedance/sonic v1.10.0 // indirect @@ -137,7 +135,7 @@ require ( github.com/zclconf/go-cty v1.13.2 // indirect golang.org/x/arch v0.4.0 // indirect golang.org/x/crypto v0.31.0 - golang.org/x/mod v0.20.0 // indirect + golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect diff --git a/go.sum b/go.sum index 553abd71..952f1a38 100644 --- a/go.sum +++ b/go.sum @@ -38,8 +38,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -entgo.io/ent v0.14.1 h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s= -entgo.io/ent v0.14.1/go.mod h1:MH6XLG0KXpkcDQhKiHfANZSzR55TJyPL5IGNpI8wpco= +entgo.io/ent v0.14.0 h1:EO3Z9aZ5bXJatJeGqu/EVdnNr6K4mRq3rWe5owt0MC4= +entgo.io/ent v0.14.0/go.mod h1:qCEmo+biw3ccBn9OyL4ZK5dfpwg++l1Gxwac5B1206A= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= @@ -562,6 +562,8 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= @@ -709,8 +711,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= -golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -901,8 +903,8 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= -golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/install_atlas.sh b/install_atlas.sh deleted file mode 100644 index 4b98ccf7..00000000 --- a/install_atlas.sh +++ /dev/null @@ -1,42 +0,0 @@ - - - - - -Atlas | Manage your database schema as code - - - - - - - - - - - - - - - - - - - - - - -

manage your database schema as code

Used by
4000+ projects
Why Atlas

Database Schemas as Code

Define database schemas in declarative code. Use HCL, SQL or any ORM or language.
Supports all popular ORMs, such as GORM, Sequelize, Django, SQLAlchemy, Hibernate, and more.
Test your schemas and migrations using the Atlas testing framework.
Getting Started
ATLAS
HCL
SQL
table"users"{
schema=schema.main
column"id"{
null=false
type=int
}
column"first_name"{
null=true
type=varchar
}
column"last_name"{
null=true
type=varchar
}
primary_key{
columns=[column.id]
}
}
table"orders"{
schema=schema.main
column"id"{
null=false
type=int
}
column"name"{
null=true
type=varchar
}
column"user_id"{
null=false
type=int
}
column"product_id"{
null=false
type=int
}
primary_key{
columns=[column.id]
}
foreign_key"product_id"{
columns=[column.product_id]
ref_columns=[column.products.column.id]
on_update=NO_ACTION
on_delete=NO_ACTION
}
foreign_key"user_id"{
columns=[column.user_id]
ref_columns=[table.users.column.id]
on_update=NO_ACTION
on_delete=NO_ACTION
}
}
table"products"{
schema=schema.main
column"id"{
null=false
type=int
}
column"name"{
null=true
type=varchar
}
column"description"{
null=false
type=int
}
column"quantity"{
null=false
type=int
}
primary_key{
columns=[column.id]
}
}
schema"main"{
}

Automatic Migration Planning

Define the desired state of your schema, and let Atlas automatically plan the SQL migrations. Like Terraform, but for databases.
Standardize schema changes using policies, regardless of the database or the ORM used.
Works with existing schema migration tools like Flyway, Liquibase, or migrate.
Planning Quick start

Verify Migration Safety in CI

Prevent destructive and backward-incompatible changes, or schema migrations that might fail or lock the database before they reach production.


Automate and customize reviews and approvals using policies.

GitHub Action Quick start
GitLab CI Quick start
CI RUN
#85485452
ISSUES FOUND
Repo
ariga/demo
Branch
new-t
Commit
c725c63
Summary
SQL Change
ERD
Migration Integrity check
Detect New Migration Files
Analyze Schema Changes
2 reports were found in analysis

Deploy to production with modern tooling

Atlas seamlessly integrates with modern deployment tools like Kubernetes and Terraform to make it easy to deploy your database migrations to production as part of your existing CD process.
Terraform Quick start
ArgoCD Quick start

Full visibility and control on your databases

Gain full visibility into the databases in your development and production environments with detailed logs and troubleshooting capabilities.
Prevent schema drift in production by detecting manual and accidental changes to your database.
Atlas Cloud Quick start
CI RUN
#85485452
ISSUES FOUND
Branch
Main
Updated at
a minute ago
ERD
Search

The most advanced migration tool out there

See how Atlas compares with classic migration tools like Liquibase, Flyway and others

vs

ORMs

More guides
All guides

Modern Database CI/CD

Learn how to apply modern CI/CD principles to database management using Atlas

Read

Integration tests with docker-compose

Prepare your database for integration tests using docker-compose

Read

Functional Indexes in MySQL

Learn how to optimize queries containing expressions by indexing values that are not stored directly in the table itself

Read

Using Atlas with Fly.io

Learn how Atlas can be used to perform database schema migrations for Fly.io deployment processes

Read

Manage MySQL on RDS with Terraform and Atlas

Learn how to use the Atlas Terraform Provider to manage the schema of an RDS-managed MySQL database

Read

Automatic migration planning for golang-migrate

Use Atlas to automatically plan schema migrations based on your schema's desired state

Read
Trusted by engineers at

Newsletter

Learn more about Atlas and get updates

Find us

Discover

- - - - \ No newline at end of file diff --git a/utils/userop.go b/utils/userop.go index 16cf80ab..ce658d3d 100644 --- a/utils/userop.go +++ b/utils/userop.go @@ -19,9 +19,7 @@ import ( "github.com/shopspring/decimal" "github.com/paycrest/aggregator/config" - "github.com/paycrest/aggregator/ent/network" "github.com/paycrest/aggregator/services/contracts" - "github.com/paycrest/aggregator/storage" "github.com/paycrest/aggregator/types" cryptoUtils "github.com/paycrest/aggregator/utils/crypto" "github.com/stackup-wallet/stackup-bundler/pkg/userop" @@ -102,12 +100,12 @@ func InitializeUserOperation(ctx context.Context, client types.RPCClient, rpcUrl return userOperation, nil } -// SponsorUserOperation sponsors the user operation with different AA services +// SponsorUserOperation sponsors the user operation from stackup +// ref: https://docs.stackup.sh/docs/paymaster-api-rpc-methods#pm_sponsoruseroperation func SponsorUserOperation(userOp *userop.UserOperation, mode string, token string, chainId int64) error { - _, paymasterUrl, err := getEndpoints(chainId) if err != nil { - return fmt.Errorf("failed to get endpoints for chain ID %d: %w", chainId, err) + return fmt.Errorf("failed to get endpoints: %w", err) } client, err := rpc.Dial(paymasterUrl) @@ -115,16 +113,36 @@ func SponsorUserOperation(userOp *userop.UserOperation, mode string, token strin return fmt.Errorf("failed to connect to RPC client: %w", err) } - aaService, err := detectAAService(paymasterUrl) - if err != nil { - return fmt.Errorf("invalid AA service URL pattern: %w", err) - } - var payload map[string]interface{} var requestParams []interface{} - switch aaService { - case "biconomy": + if orderConf.ActiveAAService == "stackup" { + switch mode { + case "sponsored": + payload = map[string]interface{}{ + "type": "payg", + } + case "erc20": + if token == "" { + return fmt.Errorf("token address is required") + } + + payload = map[string]interface{}{ + "type": "erc20token", + "token": token, + } + default: + return fmt.Errorf("invalid mode") + } + + requestParams = []interface{}{ + userOp, + orderConf.EntryPointContractAddress.Hex(), + payload, + } + } else if orderConf.ActiveAAService == "biconomy" { + mode = "sponsored" + switch mode { case "sponsored": payload = map[string]interface{}{ @@ -143,6 +161,7 @@ func SponsorUserOperation(userOp *userop.UserOperation, mode string, token strin if token == "" { return fmt.Errorf("token address is required") } + payload = map[string]interface{}{ "mode": "ERC20", "tokenInfo": map[string]string{ @@ -170,8 +189,6 @@ func SponsorUserOperation(userOp *userop.UserOperation, mode string, token strin }, payload, } - default: - return fmt.Errorf("unsupported AA service: %s", aaService) } var result json.RawMessage @@ -181,9 +198,28 @@ func SponsorUserOperation(userOp *userop.UserOperation, mode string, token strin return fmt.Errorf("RPC error: %w\nUser Operation: %s", err, string(op)) } - switch aaService { - case "biconomy": + if orderConf.ActiveAAService == "stackup" { + type Response struct { + PaymasterAndData string `json:"paymasterAndData" mapstructure:"paymasterAndData"` + PreVerificationGas string `json:"preVerificationGas" mapstructure:"preVerificationGas"` + VerificationGasLimit string `json:"verificationGasLimit" mapstructure:"verificationGasLimit"` + CallGasLimit string `json:"callGasLimit" mapstructure:"callGasLimit"` + } + var response Response + + err = json.Unmarshal(result, &response) + if err != nil { + return fmt.Errorf("failed to unmarshal response: %w", err) + } + + userOp.CallGasLimit, _ = new(big.Int).SetString(response.CallGasLimit, 0) + userOp.VerificationGasLimit, _ = new(big.Int).SetString(response.VerificationGasLimit, 0) + userOp.PreVerificationGas, _ = new(big.Int).SetString(response.PreVerificationGas, 0) + userOp.PaymasterAndData = common.FromHex(response.PaymasterAndData) + + } else if orderConf.ActiveAAService == "biconomy" { var response map[string]interface{} + err = json.Unmarshal(result, &response) if err != nil { return fmt.Errorf("failed to unmarshal response: %w", err) @@ -217,10 +253,9 @@ func SignUserOperation(userOperation *userop.UserOperation, chainId int64) error // SendUserOperation sends the user operation func SendUserOperation(userOp *userop.UserOperation, chainId int64) (string, string, int64, error) { - bundlerUrl, _, err := getEndpoints(chainId) if err != nil { - return "", "", 0, fmt.Errorf("failed to get endpoints for chain ID %d: %w", chainId, err) + return "", "", 0, fmt.Errorf("failed to get endpoints: %w", err) } client, err := rpc.Dial(bundlerUrl) @@ -228,14 +263,14 @@ func SendUserOperation(userOp *userop.UserOperation, chainId int64) (string, str return "", "", 0, fmt.Errorf("failed to connect to RPC client: %w", err) } - aaService, err := detectAAService(bundlerUrl) - if err != nil { - return "", "", 0, fmt.Errorf("invalid AA service URL pattern: %w", err) - } - var requestParams []interface{} - switch aaService { - case "biconomy": + + if orderConf.ActiveAAService == "stackup" { + requestParams = []interface{}{ + userOp, + orderConf.EntryPointContractAddress.Hex(), + } + } else if orderConf.ActiveAAService == "biconomy" { requestParams = []interface{}{ userOp, orderConf.EntryPointContractAddress.Hex(), @@ -243,8 +278,6 @@ func SendUserOperation(userOp *userop.UserOperation, chainId int64) (string, str "simulation_type": "validation_and_execution", }, } - default: - return "", "", 0, fmt.Errorf("unsupported AA service: %s", aaService) } var result json.RawMessage @@ -293,7 +326,7 @@ func SendUserOperation(userOp *userop.UserOperation, chainId int64) (string, str func GetUserOperationByReceipt(userOpHash string, chainId int64) (map[string]interface{}, error) { bundlerUrl, _, err := getEndpoints(chainId) if err != nil { - return nil, fmt.Errorf("failed to get endpoints for chain ID %d: %w", chainId, err) + return nil, fmt.Errorf("failed to get endpoints: %w", err) } client, err := rpc.Dial(bundlerUrl) @@ -382,22 +415,16 @@ func GetUserOperationByReceipt(userOpHash string, chainId int64) (map[string]int }, nil } -// GetPaymasterAccount returns the paymaster account for the given chain ID +// GetPaymasterAccount fetches the paymaster account from stackup +// ref: https://docs.stackup.sh/docs/paymaster-api-rpc-methods#pm_accounts func GetPaymasterAccount(chainId int64) (string, error) { - - _, paymasterUrl, err := getEndpoints(chainId) - if err != nil { - return "", fmt.Errorf("failed to get endpoints for chain ID %d: %w", chainId, err) + if orderConf.ActiveAAService == "biconomy" { + return "0x00000f79b7faf42eebadba19acc07cd08af44789", nil } - aaService, err := detectAAService(paymasterUrl) + _, paymasterUrl, err := getEndpoints(chainId) if err != nil { - return "", fmt.Errorf("failed to detect AA service: %w", err) - } - - // Handle biconomy case specifically - if aaService == "biconomy" { - return "0x00000f79b7faf42eebadba19acc07cd08af44789", nil + return "", fmt.Errorf("failed to get endpoints: %w", err) } client, err := rpc.Dial(paymasterUrl) @@ -426,10 +453,9 @@ func GetPaymasterAccount(chainId int64) (string, error) { // GetUserOperationStatus returns the status of the user operation func GetUserOperationStatus(userOpHash string, chainId int64) (bool, error) { - bundlerUrl, _, err := getEndpoints(chainId) if err != nil { - return false, fmt.Errorf("failed to get endpoints for chain ID %d: %w", chainId, err) + return false, fmt.Errorf("failed to get endpoints: %w", err) } client, err := rpc.Dial(bundlerUrl) @@ -499,50 +525,42 @@ func eip1559GasPrice(ctx context.Context, client types.RPCClient) (maxFeePerGas, return maxFeePerGas, maxPriorityFeePerGas, nil } -// getEndpoints fetches bundler and paymaster URLs for the given chain ID from the database -func getEndpoints(chainID int64) (string, string, error) { - ctx := context.Background() - - network, err := storage.Client.Network. - Query(). - Where(network.ChainID(chainID)). - Only(ctx) - if err != nil { - return "", "", fmt.Errorf("failed to fetch network: %w", err) - } - - // Handle optional AA service - if network.BundlerURL == "" && network.PaymasterURL == "" { - return "", "", fmt.Errorf("AA service not enabled for network ID: %d", chainID) - } - - // Ensure consistency if AA service is enabled - if (network.BundlerURL == "") != (network.PaymasterURL == "") { - return "", "", fmt.Errorf("incomplete AA configuration for network ID: %d - both bundler and paymaster URLs must be set if AA service is enabled", chainID) - } - - // Validate URL patterns - _, err = detectAAService(network.BundlerURL) - if err != nil { - return "", "", fmt.Errorf("invalid bundler URL pattern: %w", err) - } - - return network.BundlerURL, network.PaymasterURL, nil -} - -// detectAAService detects the AA service based on the provided URL pattern -func detectAAService(url string) (string, error) { - switch { - case strings.Contains(url, "biconomy.io"): - return "biconomy", nil - case strings.Contains(url, "api.pimlico.io"): - return "pimlico", nil +// getEndpoints returns the bundler and paymaster URLs for the given chain ID +func getEndpoints(chainId int64) (bundlerUrl, paymasterUrl string, err error) { + switch chainId { + case 1: + bundlerUrl = orderConf.BundlerUrlEthereum + paymasterUrl = orderConf.PaymasterUrlEthereum + case 11155111: + bundlerUrl = orderConf.BundlerUrlEthereum + paymasterUrl = orderConf.PaymasterUrlEthereum + case 137: + bundlerUrl = orderConf.BundlerUrlPolygon + paymasterUrl = orderConf.PaymasterUrlPolygon + case 56: + bundlerUrl = orderConf.BundlerUrlBSC + paymasterUrl = orderConf.PaymasterUrlBSC + case 8453: + bundlerUrl = orderConf.BundlerUrlBase + paymasterUrl = orderConf.PaymasterUrlBase + case 84532: + bundlerUrl = orderConf.BundlerUrlBase + paymasterUrl = orderConf.PaymasterUrlBase + case 42161: + bundlerUrl = orderConf.BundlerUrlArbitrum + paymasterUrl = orderConf.PaymasterUrlArbitrum + case 421614: + bundlerUrl = orderConf.BundlerUrlArbitrum + paymasterUrl = orderConf.PaymasterUrlArbitrum default: - return "", fmt.Errorf("unsupported AA service URL pattern: %s", url) + return "", "", fmt.Errorf("unsupported chain ID") } + + return bundlerUrl, paymasterUrl, nil } // getNonce returns the nonce for the given sender +// https://docs.stackup.sh/docs/useroperation-nonce func getNonce(client types.RPCClient, sender common.Address) (nonce *big.Int, err error) { entrypoint, err := contracts.NewEntryPoint(orderConf.EntryPointContractAddress, client.(bind.ContractBackend)) if err != nil { diff --git a/utils/userop_test.go b/utils/userop_test.go index f1bee8f8..37944ae6 100644 --- a/utils/userop_test.go +++ b/utils/userop_test.go @@ -1,55 +1,23 @@ package utils import ( - "context" "io" "log" "math/big" "net/http" "strings" + "testing" "github.com/ethereum/go-ethereum/common" "github.com/jarcoal/httpmock" - _ "github.com/mattn/go-sqlite3" - "github.com/paycrest/aggregator/ent/enttest" - "github.com/paycrest/aggregator/storage" - "github.com/shopspring/decimal" "github.com/stackup-wallet/stackup-bundler/pkg/userop" "github.com/stretchr/testify/assert" ) func TestUserOp(t *testing.T) { - ctx := context.Background() - - // Initialize SQLite database using enttest.Open (in-memory) - client := enttest.Open(t, "sqlite3", "file:ent?mode=memory&_fk=1") - defer client.Close() - - // Set the global client in storage package - storage.Client = client - - _, err := client.Network.Create(). - SetChainID(1). - SetIdentifier("ethereum"). - SetIsTestnet(true). - SetRPCEndpoint("https://mock-rpc-url"). - SetBundlerURL("http://bundler.biconomy.io"). - SetPaymasterURL("http://paymaster.biconomy.io"). - SetFee(decimal.NewFromInt(1)). - Save(ctx) - assert.NoError(t, err) - t.Run("test getEndpoints", func(t *testing.T) { - - // Query and verify the saved data - t.Run("test getEndpoints with mock data", func(t *testing.T) { - bundlerURL, paymasterURL, err := getEndpoints(1) - assert.NoError(t, err) - assert.Equal(t, "http://bundler.biconomy.io", bundlerURL) - assert.Equal(t, "http://paymaster.biconomy.io", paymasterURL) - }) t.Run("when chainID is supported getEndpoints", func(t *testing.T) { bundlerID, paymaster, err := getEndpoints(1) assert.NoError(t, err) @@ -86,7 +54,7 @@ func TestUserOp(t *testing.T) { } // register mock response - httpmock.RegisterResponder("POST", "http://bundler.biconomy.io", + httpmock.RegisterResponder("POST", orderConf.BundlerUrlEthereum, func(r *http.Request) (*http.Response, error) { bytes, err := io.ReadAll(r.Body) if err != nil { @@ -94,13 +62,7 @@ func TestUserOp(t *testing.T) { } if strings.Contains(string(bytes), "eth_sendUserOperation") { - - aaService, err := detectAAService("http://bundler.biconomy.io") - if err != nil { - return nil, err - } - - if aaService == "biconomy" { + if orderConf.ActiveAAService == "biconomy" { assert.True(t, strings.Contains(string(bytes), "validation_and_execution")) } else { assert.False(t, strings.Contains(string(bytes), "validation_and_execution")) @@ -113,10 +75,10 @@ func TestUserOp(t *testing.T) { return resp, err } else if strings.Contains(string(bytes), "eth_getUserOperationReceipt") { resp, err := httpmock.NewJsonResponse(200, map[string]interface{}{ - "jsonrpc": "2.0", - "id": 1, - "result": map[string]interface{}{ - "logs": []interface{}{ + "jsonrpc": "2.0", + "id": 1, + "result": map[string]interface{}{ + "logs": []interface{}{ map[string]interface{}{ "topics": []interface{}{ "0x49628fd1471006c1482da88028e9ce4dbb080b815c9b0344d39e5a8e6ec1419f", @@ -124,35 +86,35 @@ func TestUserOp(t *testing.T) { "0x000000000000000000000000500081e858f7a214cfe4f729f0321ee0e24f900f", "0x00000000000000000000000000000f79b7faf42eebadba19acc07cd08af44789", }, - "blockNumber": "0x3494a41", + "blockNumber": "0x3494a41", "transactionHash": "0xd4c6ca8929833176505e4a1ee5693a5f5116415414ab672d0949bbd82df4ff54", }, }, - "receipt": map[string]interface{}{ - "blockNumber": "0x3494a41", - "logs": []interface{}{ - map[string]interface{}{ - "address": "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789", - "topics": []interface{}{ - "0x40ccd1ceb111a3c186ef9911e1b876dc1f789ed331b86097b3b8851055b6a137", - }, - "data": "0x0000000000000000000000000000000000000000000000000001c6bf526340008800aa2f3eb91b515b70ae1940b3ed9947d8fec227ac393d41e7be6c951626880000000000000000000000000000000000000000000000000000000000000679000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001584770777869632f3654654d58754f4b3766723171484c6f616936554a5168663744424b7949592f6744704c736a706d614e5a4e646e3059342b7561564d79414a554f466f4b4f7168424d7244555443756e47514a35412f6c554e726f415643575235444c31544b595a446d7279744c4f7a676a68642b69786e57557667394734654a43426c6e763473392f6f4575306d4d7a65644e53636d724b7273424f3977725275384b2f48466c69576765643334664a68343474484d6a6148753154324c765947646b754c53393647717244733471734b634c44466a47676267487962696a7351734d4b6646384a6c5369614f584156484e73756c2f554636644f5a7939784a39714156584a6a32577a367631416f48306137674d794e684f6c664b537667504a414d766a6d675741364d50524f74376e33564972644e743076535a58724244544441357354616439722b614f754b66357636513d3d0000000000000000", - "blockNumber": "0x3494a41", - "transactionHash": "0xd4c6ca8929833176505e4a1ee5693a5f5116415414ab672d0949bbd82df4ff54", - "transactionIndex": "0x68", - "blockHash": "0x93412643414b664e4fd3467ff58c3bcbd6dc83b84080e1f044e7a16fcf015806", + "receipt": map[string]interface{}{ + "blockNumber": "0x3494a41", + "logs": []interface{}{ + map[string]interface{}{ + "address": "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789", + "topics": []interface{}{ + "0x40ccd1ceb111a3c186ef9911e1b876dc1f789ed331b86097b3b8851055b6a137", }, + "data": "0x0000000000000000000000000000000000000000000000000001c6bf526340008800aa2f3eb91b515b70ae1940b3ed9947d8fec227ac393d41e7be6c951626880000000000000000000000000000000000000000000000000000000000000679000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001584770777869632f3654654d58754f4b3766723171484c6f616936554a5168663744424b7949592f6744704c736a706d614e5a4e646e3059342b7561564d79414a554f466f4b4f7168424d7244555443756e47514a35412f6c554e726f415643575235444c31544b595a446d7279744c4f7a676a68642b69786e57557667394734654a43426c6e763473392f6f4575306d4d7a65644e53636d724b7273424f3977725275384b2f48466c69576765643334664a68343474484d6a6148753154324c765947646b754c53393647717244733471734b634c44466a47676267487962696a7351734d4b6646384a6c5369614f584156484e73756c2f554636644f5a7939784a39714156584a6a32577a367631416f48306137674d794e684f6c664b537667504a414d766a6d675741364d50524f74376e33564972644e743076535a58724244544441357354616439722b614f754b66357636513d3d0000000000000000", + "blockNumber": "0x3494a41", + "transactionHash": "0xd4c6ca8929833176505e4a1ee5693a5f5116415414ab672d0949bbd82df4ff54", + "transactionIndex": "0x68", + "blockHash": "0x93412643414b664e4fd3467ff58c3bcbd6dc83b84080e1f044e7a16fcf015806", }, - "logsBloom": "0x000000000000010000000000000000000000000000000000000000000000020000090000000000040002001100400000001081000000000000000200000000000000000000000000000000280000008000080000000020000001000000000000000000000a000000000000000000280000000000080000408080001000080000004008000004000000000000000000020000000000000000000000000000000020000000000400000050...", - "status": "0x1", - "to": "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789", - "transactionIndex": "0x68", - "type": "0x2", }, + "logsBloom": "0x000000000000010000000000000000000000000000000000000000000000020000090000000000040002001100400000001081000000000000000200000000000000000000000000000000280000008000080000000020000001000000000000000000000a000000000000000000280000000000080000408080001000080000004008000004000000000000000000020000000000000000000000000000000020000000000400000050...", + "status": "0x1", + "to": "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789", + "transactionIndex": "0x68", + "type": "0x2", }, - }) - - return resp, err + }, + }) + + return resp, err } return httpmock.NewBytesResponse(200, []byte(`{"jsonrpc": "2.0","id": 1,"result":[]}`)), nil @@ -186,7 +148,7 @@ func TestUserOp(t *testing.T) { } // register mock response - httpmock.RegisterResponder("POST", "http://paymaster.biconomy.io", + httpmock.RegisterResponder("POST", orderConf.PaymasterUrlEthereum, func(r *http.Request) (*http.Response, error) { bytes, err := io.ReadAll(r.Body) if err != nil { @@ -194,24 +156,33 @@ func TestUserOp(t *testing.T) { } if strings.Contains(string(bytes), "pm_sponsorUserOperation") { - aaService, err := detectAAService("http://paymaster.biconomy.io") - if err != nil { - return nil, err + if orderConf.ActiveAAService == "biconomy" { + assert.True(t, strings.Contains(string(bytes), "INFINITISM")) + resp, err := httpmock.NewJsonResponse(200, map[string]interface{}{ + "jsonrpc": "2.0", + "id": 1, + "result": map[string]interface{}{ + "paymasterAndData": "0x00000f79b7faf42eebadba19acc07cd08af447890000000000000000000...", + "preVerificationGas": "186034", + "verificationGasLimit": 395693, + "callGasLimit": 55412, + }, + }) + return resp, err + } else { + assert.True(t, strings.Contains(string(bytes), "payg")) + resp, err := httpmock.NewJsonResponse(200, map[string]interface{}{ + "jsonrpc": "2.0", + "id": 1, + "result": map[string]interface{}{ + "paymasterAndData": "0x00000f79b7faf42eebadba19acc07cd08af447890000000000000000000...", + "preVerificationGas": "0x1234", + "verificationGasLimit": "0x1234", + "callGasLimit": "0x1234", + }, + }) + return resp, err } - assert.Equal(t, "biconomy", aaService) - assert.True(t, strings.Contains(string(bytes), "INFINITISM")) - - resp, err := httpmock.NewJsonResponse(200, map[string]interface{}{ - "jsonrpc": "2.0", - "id": 1, - "result": map[string]interface{}{ - "paymasterAndData": "0x00000f79b7faf42eebadba19acc07cd08af447890000000000000000000...", - "preVerificationGas": "186034", - "verificationGasLimit": 395693, - "callGasLimit": 55412, - }, - }) - return resp, err } return httpmock.NewBytesResponse(200, []byte(`{"jsonrpc": "2.0","id": 1,"result":[]}`)), nil