-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* optimize get API * add GetSupportStrategy * change response * add Support gas * add userop convert * add userop gasCompute * add paymaster_generator impl change swagger * update * update * support get token price * fix debug * fix debug * optimize gas compute * update API * update API * update API * update API * fix bug * fix bug * fix bug * fix bug * generatePaymasterData * add GetCoinPrice * update PackUserOp * update PackUserOp * update PackUserOp * update PackUserOp * update PackUserOp * update PackUserOp * update PackUserOp * update PackUserOp * feat: change call methods function * feat: split string * update PackUserOp * fix packOp bug * fix packOp bug * fix packOp bug * fix packOp bug * fix sign bug * fix sign bug * fix sign bug * fix sign bug * fix sign bug * fix sign bug * change paymasterAddress * change paymasterAddress * change paymasterAddress * v1.0 init * v1.0 init * init * v1.0 add abi * optimize * optimize * optimize * optimize * optimize * optimize * optimize * optimize * optimize * optimize * optimize * optimize * optimize * optimize * optimize * add verifying paymaster * fix start error * optimize * optimize catalog * optimize catalog * add Starknet demo * optimize * optimize * optimize * optimize * optimize * optimize * add Estimate userOp Gas API * add Estimate userOp Gas API * add Estimate userOp Gas API * optimize * optimize * optimize * optimize Gas Compute * optimize Gas Compute * optimize Gas Compute * optimize Gas Compute getBasicPreVerificationGas * optimize Gas Compute getPreVerificationGas * optimize Gas Compute getPreVerificationGas * optimize Gas Compute getPreVerificationGas * optimize Gas Compute getPreVerificationGas * optimize Gas Compute getPreVerificationGas * optimize Gas Compute getPreVerificationGas * optimize Gas Compute getPreVerificationGas * go mod tidy * fix init * fix init * fix init * optimize gas * optimize gas * optimize gas * optimize gas * update * update * update * update * update * update string * update string * update * update * update * update * add test * add test * add gas Price * optimize gas * optimize gas * fix test * fix test * fix test * fix init error * fix dep * fix version issue * fix bug * optimize test * optimize test * optimize test * optimize test * optimize test * optimize test * optimize test * optimize code * optimize code * optimize code * skip test in Github action * fix test * fix test * fix test * fix test * fix test * fix test * config files cp to image * upgrade base image * fix comment * fix comment * fix comment * fix comment * fix comment * Update coverage.yml * fix comment * fix comment * fix comment * fix comment --------- Co-authored-by: 0xRory <[email protected]> Co-authored-by: devops <[email protected]>
- Loading branch information
1 parent
4991f0d
commit cedeb46
Showing
118 changed files
with
21,908 additions
and
1,168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
conf/appsettings.yaml | ||
config/appsettings.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
##generate-verifyingPaymaster-v06-pkg: | ||
# abigen --abi=./common/ethereum_contract/paymaster_abi/simulate_entrypoint_abi.json --pkg=contract --out=./common/ethereum_contract/contract/simulate_entrypoint/simulate_entrypoint.go | ||
## | ||
## | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"github.com/gin-gonic/gin" | ||
"github.com/sirupsen/logrus" | ||
"golang.org/x/xerrors" | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
) | ||
|
||
func APITestCall(engine *gin.Engine, method, url string, body any, response any, apiToken string) (*http.Response, error) { | ||
bodyBytes, err := json.Marshal(body) | ||
logrus.Debug("bodyBytes: ", string(bodyBytes)) | ||
if err != nil { | ||
return nil, xerrors.Errorf("ERROR Marshal ", err) | ||
} | ||
w := httptest.NewRecorder() | ||
w.Header().Set("Content-Type", "application/json") | ||
w.Header().Set("Authorization", "Bearer "+apiToken) | ||
w.Header().Set("Accept", "application/json") | ||
req, _ := http.NewRequest(method, url, bytes.NewReader(bodyBytes)) | ||
engine.ServeHTTP(w, req) | ||
|
||
logrus.Debug(req) | ||
if w.Code != 200 { | ||
return w.Result(), xerrors.Errorf("ERROR Code ", w.Result().Status) | ||
} | ||
if w.Body == nil { | ||
return w.Result(), xerrors.Errorf("ERROR Body is nil") | ||
} | ||
err = json.Unmarshal(w.Body.Bytes(), response) | ||
if err != nil { | ||
return w.Result(), xerrors.Errorf("ERROR Unmarshal ", err) | ||
} | ||
//logrus.Debugf("Response: %s", w.Body) | ||
return w.Result(), nil | ||
} | ||
|
||
func TestAPI(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("skipping test in short mode.") | ||
} | ||
|
||
initEngine("../../config/basic_strategy_config.json", "../../config/basic_config.json", "../../config/secret_config.json") | ||
tests := []struct { | ||
name string | ||
test func(t *testing.T) | ||
}{ | ||
{ | ||
"TestHealthz", | ||
func(t *testing.T) { | ||
var rssponse map[string]any | ||
_, err := APITestCall(Engine, "GET", "/api/healthz", nil, &rssponse, "") | ||
if err != nil { | ||
t.Error(err) | ||
return | ||
} | ||
t.Logf("Response: %v", rssponse) | ||
}, | ||
}, | ||
|
||
//TODO fix this test | ||
// | ||
//{ | ||
// name: "TestAuth", | ||
// test: func(t *testing.T) { | ||
// request := model.ClientCredential{ | ||
// ApiKey: "String", | ||
// } | ||
// var response map[string]any | ||
// _, err := APITestCall(Engine, "POST", "/api/auth", &request, &response, "") | ||
// if err != nil { | ||
// t.Error(err) | ||
// return | ||
// } | ||
// }, | ||
//}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, tt.test) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package data_utils | ||
|
||
import ( | ||
"AAStarCommunity/EthPaymaster_BackService/common/global_const" | ||
"AAStarCommunity/EthPaymaster_BackService/common/model" | ||
"AAStarCommunity/EthPaymaster_BackService/common/network" | ||
"AAStarCommunity/EthPaymaster_BackService/common/paymaster_data" | ||
"AAStarCommunity/EthPaymaster_BackService/common/user_op" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func GetUserOpWithPaymasterAndDataForSimulate(op user_op.UserOpInput, strategy *model.Strategy, paymasterDataInput *paymaster_data.PaymasterDataInput, gasPriceResult *model.GasPrice) (*user_op.UserOpInput, error) { | ||
executor := network.GetEthereumExecutor(strategy.GetNewWork()) | ||
op.MaxFeePerGas = gasPriceResult.MaxFeePerGas | ||
op.MaxPriorityFeePerGas = gasPriceResult.MaxPriorityFeePerGas | ||
logrus.Debug("MaxFeePerGas", op.MaxFeePerGas) | ||
logrus.Debug("MaxPriorityFeePerGas", op.MaxPriorityFeePerGas) | ||
paymasterDataInput.PaymasterPostOpGasLimit = global_const.DummyPaymasterPostoperativelyBigint | ||
paymasterDataInput.PaymasterVerificationGasLimit = global_const.DummyPaymasterOversimplificationBigint | ||
op.AccountGasLimits = user_op.DummyAccountGasLimits | ||
op.GasFees = user_op.DummyGasFees | ||
if op.PreVerificationGas == nil { | ||
op.PreVerificationGas = global_const.DummyReverificationsBigint | ||
} | ||
if op.VerificationGasLimit == nil { | ||
op.VerificationGasLimit = global_const.DummyVerificationGasLimit | ||
} | ||
if op.Signature == nil { | ||
op.Signature = global_const.DummySignatureByte | ||
} | ||
if op.CallGasLimit == nil { | ||
op.CallGasLimit = global_const.DummyCallGasLimit | ||
} | ||
|
||
paymasterData, err := executor.GetPaymasterData(&op, strategy, paymasterDataInput) | ||
if err != nil { | ||
return nil, err | ||
} | ||
op.PaymasterAndData = paymasterData | ||
return &op, nil | ||
} |
2,262 changes: 2,262 additions & 0 deletions
2,262
common/ethereum_contract/contract/contract_entrypoint_v06/eth_entrypoint_v06.go
Large diffs are not rendered by default.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
common/ethereum_contract/contract/contract_entrypoint_v06/simulate_op_revert.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package contract_entrypoint_v06 | ||
|
||
import ( | ||
"AAStarCommunity/EthPaymaster_BackService/common/ethereum_contract/paymaster_abi" | ||
"AAStarCommunity/EthPaymaster_BackService/common/utils" | ||
"errors" | ||
"fmt" | ||
"github.com/ethereum/go-ethereum/accounts/abi" | ||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/rpc" | ||
"github.com/sirupsen/logrus" | ||
"golang.org/x/xerrors" | ||
"math/big" | ||
) | ||
|
||
type ExecutionResultRevert struct { | ||
PreOpGas *big.Int | ||
Paid *big.Int | ||
ValidAfter *big.Int | ||
ValidUntil *big.Int | ||
TargetSuccess bool | ||
TargetResult []byte | ||
} | ||
|
||
func ExecutionResult() abi.Error { | ||
return abi.NewError("ExecutionResult", abi.Arguments{ | ||
{Name: "preOpGas", Type: paymaster_abi.Uint256Type}, | ||
{Name: "paid", Type: paymaster_abi.Uint256Type}, | ||
{Name: "validAfter", Type: paymaster_abi.Uint48Type}, | ||
{Name: "validUntil", Type: paymaster_abi.Uint48Type}, | ||
{Name: "targetSuccess", Type: paymaster_abi.BooleanType}, | ||
{Name: "targetResult", Type: paymaster_abi.BytesType}, | ||
}) | ||
} | ||
|
||
func NewExecutionResult(inputError error, abi *abi.ABI) (*ExecutionResultRevert, error) { | ||
|
||
var rpcErr rpc.DataError | ||
ok := errors.As(inputError, &rpcErr) | ||
if !ok { | ||
return nil, xerrors.Errorf("ExecutionResult: cannot assert type: error is not of type rpc.DataError") | ||
} | ||
|
||
data, ok := rpcErr.ErrorData().(string) | ||
|
||
logrus.Debug("data: ", data) | ||
if !ok { | ||
return nil, xerrors.Errorf("ExecutionResult: cannot assert type: data is not of type string") | ||
} | ||
|
||
sim := ExecutionResult() | ||
revert, upPackerr := sim.Unpack(common.Hex2Bytes(data[2:])) | ||
if upPackerr != nil { | ||
// is another ERROR | ||
errstr, parseErr := utils.ParseCallError(inputError, abi) | ||
return nil, fmt.Errorf("executionResult err: [%s] parErr [%s]", errstr, parseErr) | ||
} | ||
|
||
args, ok := revert.([]any) | ||
if !ok { | ||
return nil, xerrors.Errorf("executionResult: cannot assert type: args is not of type []any") | ||
} | ||
if len(args) != 6 { | ||
return nil, xerrors.Errorf("executionResult: invalid args length: expected 6, got %d", len(args)) | ||
} | ||
|
||
return &ExecutionResultRevert{ | ||
PreOpGas: args[0].(*big.Int), | ||
Paid: args[1].(*big.Int), | ||
ValidAfter: args[2].(*big.Int), | ||
ValidUntil: args[3].(*big.Int), | ||
TargetSuccess: args[4].(bool), | ||
TargetResult: args[5].([]byte), | ||
}, nil | ||
} |
Oops, something went wrong.