This commit is contained in:
jackg22 2026-06-18 21:54:25 -07:00 committed by GitHub
commit 0c83da6483
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 45 additions and 0 deletions

View file

@ -235,6 +235,9 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
accessList := tx.AccessList() accessList := tx.AccessList()
args.AccessList = &accessList args.AccessList = &accessList
} }
if tx.Type() == types.SetCodeTxType {
args.AuthorizationList = tx.SetCodeAuthorizations()
}
if tx.Type() == types.BlobTxType { if tx.Type() == types.BlobTxType {
args.BlobHashes = tx.BlobHashes() args.BlobHashes = tx.BlobHashes()
sidecar := tx.BlobTxSidecar() sidecar := tx.BlobTxSidecar()

View file

@ -103,6 +103,9 @@ type SendTxArgs struct {
AccessList *types.AccessList `json:"accessList,omitempty"` AccessList *types.AccessList `json:"accessList,omitempty"`
ChainID *hexutil.Big `json:"chainId,omitempty"` ChainID *hexutil.Big `json:"chainId,omitempty"`
// For SetCodeTxType
AuthorizationList []types.SetCodeAuthorization `json:"authorizationList,omitempty"`
// For BlobTxType // For BlobTxType
BlobFeeCap *hexutil.Big `json:"maxFeePerBlobGas,omitempty"` BlobFeeCap *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
BlobHashes []common.Hash `json:"blobVersionedHashes,omitempty"` BlobHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
@ -175,6 +178,24 @@ func (args *SendTxArgs) ToTransaction() (*types.Transaction, error) {
data.(*types.BlobTx).Sidecar = types.NewBlobTxSidecar(version, args.Blobs, args.Commitments, args.Proofs) data.(*types.BlobTx).Sidecar = types.NewBlobTxSidecar(version, args.Blobs, args.Commitments, args.Proofs)
} }
case args.AuthorizationList != nil:
al := types.AccessList{}
if args.AccessList != nil {
al = *args.AccessList
}
data = &types.SetCodeTx{
To: *to,
ChainID: uint256.MustFromBig((*big.Int)(args.ChainID)),
Nonce: uint64(args.Nonce),
Gas: uint64(args.Gas),
GasFeeCap: uint256.MustFromBig((*big.Int)(args.MaxFeePerGas)),
GasTipCap: uint256.MustFromBig((*big.Int)(args.MaxPriorityFeePerGas)),
Value: uint256.MustFromBig((*big.Int)(&args.Value)),
Data: args.data(),
AccessList: al,
AuthList: args.AuthorizationList,
}
case args.MaxFeePerGas != nil: case args.MaxFeePerGas != nil:
al := types.AccessList{} al := types.AccessList{}
if args.AccessList != nil { if args.AccessList != nil {

View file

@ -99,6 +99,27 @@ func TestTxArgs(t *testing.T) {
} }
} }
func TestTxArgsSetCodeTx(t *testing.T) {
data := []byte(`{"from":"0x1b442286e32ddcaa6e2570ce9ed85f4b4fc87425","authorizationList":[{"chainId":"0x7","address":"0x0000000000000000000000000000000000000001","nonce":"0x1","yParity":"0x0","r":"0x1","s":"0x2"}],"accessList":[],"chainId":"0x7","gas":"0x124f8","input":"0x","maxFeePerGas":"0x6fc23ac00","maxPriorityFeePerGas":"0x3b9aca00","nonce":"0x0","to":"0x1b442286e32ddcaa6e2570ce9ed85f4b4fc87425","value":"0x0"}`)
var txArgs SendTxArgs
if err := json.Unmarshal(data, &txArgs); err != nil {
t.Fatal(err)
}
tx, err := txArgs.ToTransaction()
if err != nil {
t.Fatal(err)
}
if have := tx.Type(); have != types.SetCodeTxType {
t.Fatalf("have tx type %d, want %d", have, types.SetCodeTxType)
}
if have := tx.SetCodeAuthorizations(); len(have) != 1 {
t.Fatalf("have %d authorizations, want 1", len(have))
} else if have[0] != txArgs.AuthorizationList[0] {
t.Fatalf("authorization mismatch: have %#v, want %#v", have[0], txArgs.AuthorizationList[0])
}
}
func TestBlobTxs(t *testing.T) { func TestBlobTxs(t *testing.T) {
blob := kzg4844.Blob{0x1} blob := kzg4844.Blob{0x1}
commitment, err := kzg4844.BlobToCommitment(&blob) commitment, err := kzg4844.BlobToCommitment(&blob)