Documentation
¶
Index ¶
- Constants
- Variables
- func PackHydrateExecute(packedPayload, hydratePayload []byte) ([]byte, error)
- func PackHydrateExecuteAndSweep(packedPayload, hydratePayload []byte, sweepTarget common.Address, ...) ([]byte, error)
- type AddrSource
- type Builder
- type CallSection
- func (s *CallSection) CallTo(src AddrSource) error
- func (s *CallSection) CallValue(src AddrSource) error
- func (s *CallSection) DataAddress(sel abicalldata.Selector, src AddrSource) error
- func (s *CallSection) DataERC20Allowance(sel abicalldata.Selector, owner AddrSource, token common.Address, ...) error
- func (s *CallSection) DataERC20Balance(sel abicalldata.Selector, token common.Address, holder AddrSource) error
- func (s *CallSection) DataNativeBalance(sel abicalldata.Selector, src AddrSource) error
Constants ¶
const ( TypeDataAddress = 0x01 TypeDataBalance = 0x02 TypeDataERC20Balance = 0x03 TypeDataERC20Allowance = 0x04 TypeTo = 0x05 TypeValue = 0x06 )
Hydration op-type nibble (high bits of command flag byte). Must match HydrateProxy.sol.
const ( DataSelf = 0x00 DataMsgSender = 0x01 DataTxOrigin = 0x02 DataAnyAddress = 0x03 )
Hydration address-source nibble (low bits of command flag byte).
Variables ¶
var ABI abi.ABI
ABI is the parsed HydrateProxy contract ABI (from trails-contracts artifact).
Functions ¶
func PackHydrateExecute ¶
PackHydrateExecute ABI-encodes a call to HydrateProxy.hydrateExecute.
Types ¶
type AddrSource ¶
type AddrSource struct {
// contains filtered or unexported fields
}
AddrSource selects how HydrateProxy resolves an address at execution time (low nibble of the command flag; literal addresses add 20 bytes after the flag).
func SourceAddress ¶
func SourceAddress(a common.Address) AddrSource
func SourceMsgSender ¶
func SourceMsgSender() AddrSource
func SourceSelf ¶
func SourceSelf() AddrSource
func SourceTxOrigin ¶
func SourceTxOrigin() AddrSource
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs hydratePayload bytes for HydrateProxy using abicalldata.Selector (calldata selectors: ABI paths via abicalldata.NewPath().AsSelector() in app code, fixed ranges via abicalldata.NewRangeSelector, etc.) so call-data offsets are not hand-computed.
Sections are emitted in ascending call index order, which matches how HydrateProxy consumes the stream during sequential execution.
func NewBuilder ¶
func NewBuilder(payload *v3.CallsPayload) *Builder
func (*Builder) Build ¶
Build returns hydratePayload. An empty builder yields nil, which HydrateProxy treats as "no hydration".
func (*Builder) ForCall ¶
func (b *Builder) ForCall(tindex int) *CallSection
ForCall begins or continues the hydrate section for packed call tindex.
type CallSection ¶
type CallSection struct {
// contains filtered or unexported fields
}
CallSection targets one packed call index; method calls append hydrate commands for that call.
func (*CallSection) CallTo ¶
func (s *CallSection) CallTo(src AddrSource) error
CallTo sets decoded.calls[tindex].to to the address resolved from src at execution time.
func (*CallSection) CallValue ¶
func (s *CallSection) CallValue(src AddrSource) error
CallValue sets decoded.calls[tindex].value to the native balance of the address resolved from src.
func (*CallSection) DataAddress ¶
func (s *CallSection) DataAddress(sel abicalldata.Selector, src AddrSource) error
DataAddress patches calldata at sel with replaceAddress (20 bytes) using src as the hydrated address.
func (*CallSection) DataERC20Allowance ¶
func (s *CallSection) DataERC20Allowance(sel abicalldata.Selector, owner AddrSource, token common.Address, spender AddrSource) error
DataERC20Allowance patches calldata at sel with IERC20(token).allowance(owner, spender) at execution time.
func (*CallSection) DataERC20Balance ¶
func (s *CallSection) DataERC20Balance(sel abicalldata.Selector, token common.Address, holder AddrSource) error
DataERC20Balance patches calldata at sel with IERC20(token).balanceOf(holder) at execution time.
func (*CallSection) DataNativeBalance ¶
func (s *CallSection) DataNativeBalance(sel abicalldata.Selector, src AddrSource) error
DataNativeBalance patches calldata at sel with replaceUint256 using the native balance of the address resolved from src at execution time.