Documentation
¶
Overview ¶
Package safe contains types for working with Safe smart contract wallets. These are used to build batch transactions for the tx-builder app. The types are based on https://github.com/safe-global/safe-react-apps/blob/development/apps/tx-builder/src/typings/models.ts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Batch ¶ added in v1.1.6
type Batch struct { SkipCalldata bool `json:"-"` Version string `json:"version"` ChainID *big.Int `json:"chainId"` CreatedAt uint64 `json:"createdAt"` Meta BatchMeta `json:"meta"` Transactions []BatchTransaction `json:"transactions"` }
Batch represents a Safe tx-builder transaction. SkipCalldata will skip adding the calldata to the BatchTransaction. This is useful for when using the Safe UI because it prefers using the raw calldata when both the calldata and ABIs with arguments are present.
func (*Batch) AddCall ¶ added in v1.1.6
func (b *Batch) AddCall(to common.Address, value *big.Int, sig string, args []any, iface *abi.ABI) error
AddCall will add a call to the batch. After a series of calls are added to the batch, it can be serialized to JSON.
func (*Batch) MarshalJSON ¶ added in v1.1.6
MarshalJSON will marshal a Batch to JSON.
func (*Batch) UnmarshalJSON ¶ added in v1.1.6
UnmarshalJSON will unmarshal a Batch from JSON.
type BatchMeta ¶ added in v1.1.6
type BatchMeta struct { TxBuilderVersion string `json:"txBuilderVersion,omitempty"` Checksum string `json:"checksum,omitempty"` CreatedFromSafeAddress string `json:"createdFromSafeAddress"` CreatedFromOwnerAddress string `json:"createdFromOwnerAddress"` Name string `json:"name"` Description string `json:"description"` }
BatchMeta contains metadata about a Batch. Not all of the fields are required.
type BatchTransaction ¶
type BatchTransaction struct { To common.Address `json:"to"` Value *big.Int `json:"value"` Data []byte `json:"data"` Method ContractMethod `json:"contractMethod"` InputValues map[string]string `json:"contractInputsValues"` }
BatchTransaction represents a single call in a tx-builder transaction.
func (*BatchTransaction) Arguments ¶ added in v1.1.6
func (bt *BatchTransaction) Arguments() abi.Arguments
func (*BatchTransaction) Check ¶ added in v1.1.6
func (bt *BatchTransaction) Check() error
Check will check the batch transaction for errors. An error is defined by: - incorrectly encoded calldata - mismatch in number of arguments It does not currently work on structs, will return no error if a "tuple" is used as an argument. Need to find a generic way to work with structs.
func (*BatchTransaction) MarshalJSON ¶
func (b *BatchTransaction) MarshalJSON() ([]byte, error)
MarshalJSON will marshal a BatchTransaction to JSON.
func (*BatchTransaction) Signature ¶ added in v1.1.6
func (bt *BatchTransaction) Signature() string
Signature returns the function signature of the batch transaction.
func (*BatchTransaction) UnmarshalJSON ¶
func (b *BatchTransaction) UnmarshalJSON(data []byte) error
UnmarshalJSON will unmarshal a BatchTransaction from JSON.
type ContractInput ¶
type ContractInput struct { InternalType string `json:"internalType"` Name string `json:"name"` Type string `json:"type"` Components []ContractInput `json:"components,omitempty"` }
ContractInput represents an input to a contract method.
type ContractMethod ¶
type ContractMethod struct { Inputs []ContractInput `json:"inputs"` Name string `json:"name"` Payable bool `json:"payable"` }
ContractMethod represents a method call in a tx-builder transaction.