Skip to content

Evaluate js in contract write body #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions core/taskengine/vm_runner_contract_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,26 @@ func (r *ContractWriteProcessor) Execute(stepID string, node *avsproto.ContractW
s.Success = err == nil
}()

contractAddress := common.HexToAddress(node.ContractAddress)
calldata := common.FromHex(node.CallData)
contractAddressHex := strings.Clone(node.ContractAddress)
callDataHex := strings.Clone(node.CallData)

if strings.Contains(contractAddressHex, "{{") {
contractAddressHex = r.vm.preprocessText(contractAddressHex)
}
if strings.Contains(callDataHex, "{{") {
callDataHex = r.vm.preprocessText(callDataHex)
}

contractAddress := common.HexToAddress(contractAddressHex)
calldata := common.FromHex(callDataHex)

userOpCalldata, err := aa.PackExecute(
contractAddress,
big.NewInt(0), // TODO: load correct salt from the task
calldata,
)
log.WriteString(fmt.Sprintf("\nprepare to send userops target contract %s\ninitialize bundler client\n", node.ContractAddress))
// bundlerClient, err := bundler.NewBundlerClient(r.smartWalletConfig.BundlerURL)

// if err != nil {
// log.WriteString(fmt.Sprintf("error creating bundle client: %s", err))
// s.Error = fmt.Sprintf("error creating bundler client : %s", err)
// return s, err
// }
log.WriteString(fmt.Sprintf("\nwill send message %s to contract %s\n", callDataHex, contractAddressHex))
log.WriteString(fmt.Sprintf("\nprepare to send userops to target contract %s\ninitialize bundler client\n", contractAddress.Hex()))

log.WriteString("\nsend userops to bundler rpc\n")

Expand All @@ -83,6 +88,13 @@ func (r *ContractWriteProcessor) Execute(stepID string, node *avsproto.ContractW
}

bloom, _ := txReceipt.Bloom.MarshalText()

blobGasPrice := uint64(0)

if txReceipt.BlobGasPrice != nil {
blobGasPrice = uint64(txReceipt.BlobGasPrice.Int64())
}

outputData := &avsproto.Execution_Step_ContractWrite{
ContractWrite: &avsproto.ContractWriteNode_Output{
UserOp: &avsproto.Evm_UserOp{
Expand Down Expand Up @@ -118,7 +130,7 @@ func (r *ContractWriteProcessor) Execute(stepID string, node *avsproto.ContractW
Root: common.Bytes2Hex(txReceipt.PostState),
Status: uint32(txReceipt.Status),
Type: uint32(txReceipt.Type),
BlobGasPrice: uint64(txReceipt.BlobGasPrice.Int64()),
BlobGasPrice: blobGasPrice,
BlobGasUsed: uint64(txReceipt.BlobGasUsed),
},
},
Expand Down