sequence

package module
v0.12.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2022 License: Apache-2.0 Imports: 34 Imported by: 3

README

go-sequence

Sequence Wallet client written in Go.

Usage

For documentation on sequence, please see our docs page.

Developing the go-sequence library

  1. make boostrap -- will install node modules of ./testutil/chain
  2. make start-test-chain -- starts the test ethereum chain (id 1337)
  3. (in a separate terminal) make test -- runs test suite

Testing

Testing is super important, to run the tests just call make test. As well, you can run the test-chain separately with make start-test-chain then in another terminal run make test.

NOTE: Go by default will execute tests in parallel if you run go test -v ./..., so ensure to pass -p 1 to set parallelization to just 1 (so it runs serially). The make test command is already set to do this.

A. If you'd like to use a local version of a dependency/module, you can use the replace directive in go.mod, for example, lets say you want to use a local version of "ethkit" that hasn't been released with go-sequence, you can add replace github.com/0xsequence/ethkit => /home/peter/Dev/0xsequence/ethkit to your go.mod

LICENSE

Apache 2.0

Documentation

Index

Constants

View Source
const (
	SignaturePartTypeEOA     uint8 = iota // 0
	SignaturePartTypeAddress              // 1
	SignaturePartTypeDynamic              // 2
)
View Source
const (
	SignatureTypeEip712  uint8 = iota + 1 // 1
	SignatureTypeEthSign                  // 2
	SignatureTypeEip1271                  // 3
)
View Source
const WalletContractBytecode = "0x603a600e3d39601a805130553df3363d3d373d3d3d363d30545af43d82803e903d91601857fd5bf3"

https://github.com/0xsequence/wallet-contracts/blob/master/src/contracts/Wallet.sol#L57-L59

Variables

View Source
var (
	// NonceChangeEventSig is the signature event emitted as the first event on the batch execution
	// 0x1f180c27086c7a39ea2a7b25239d1ab92348f07ca7bb59d1438fcf527568f881
	NonceChangeEventSig = MustEncodeSig("NonceChange(uint256,uint256)")

	// TxFailedEventSig is the signature event emitted in a failed smart-wallet meta-transaction batch
	// 0x3dbd1590ea96dd3253a91f24e64e3a502e1225d602a5731357bc12643070ccd7
	TxFailedEventSig = MustEncodeSig("TxFailed(bytes32,bytes)")

	// TxExecutedEventSig is the signature of the event emitted in a successful transaction
	// 0x0639b0b186d373976f8bb98f9f7226ba8070f10cb6c7f9bd5086d3933f169a25
	TxExecutedEventSig = MustEncodeSig("TxExecuted(bytes32)")
)

Transaction events as defined in wallet-contracts IModuleCalls.sol

View Source
var (
	ErrUnknownChainID = fmt.Errorf("chainID is unknown")
	ErrProviderNotSet = fmt.Errorf("provider is not set")
	ErrRelayerNotSet  = fmt.Errorf("relayer is not set")
)
View Source
var (
	// ImageHashUpdatedEventSig is emitted anytime wallet config is updated.
	ImageHashUpdatedEventSig = MustEncodeSig("ImageHashUpdated(bytes32)")

	// ImplementationUpdatedEventSig is emitted anytime a wallet's mainModule is changed,
	// this is a rare occurence.
	ImplementationUpdatedEventSig = MustEncodeSig("ImplementationUpdated(address)")
)

Functions

func AddressFromImageHash

func AddressFromImageHash(imageHash string, context WalletContext) (common.Address, error)

func AddressFromWalletConfig

func AddressFromWalletConfig(walletConfig WalletConfig, context WalletContext) (common.Address, error)

func BuildProxy added in v0.4.4

func BuildProxy(addr common.Address) string

BuildProxy for address based on https://eips.ethereum.org/EIPS/eip-1167 the bytecode contains an aditional SLOAD to mimic the Sequence proxies bytecode:

| 0x00000000 36 calldatasize cds | 0x00000001 3d returndatasize 0 cds | 0x00000002 3d returndatasize 0 0 cds | 0x00000003 37 calldatacopy | 0x00000004 30 address addr | 0x00000005 54 sload stub | 0x00000006 50 pop | 0x00000007 3d returndatasize 0 | 0x00000008 3d returndatasize 0 0 | 0x00000009 3d returndatasize 0 0 0 | 0x0000000a 36 calldatasize cds 0 0 0 | 0x0000000b 3d returndatasize 0 cds 0 0 0 | 0x0000000c 73bebebebebe. push20 0xbebebebe 0xbebe 0 cds 0 0 0 | 0x00000020 5a gas gas 0xbebe 0 cds 0 0 0 | 0x00000021 f4 delegatecall suc 0 | 0x00000022 3d returndatasize rds suc 0 | 0x00000023 82 dup3 0 rds suc 0 | 0x00000024 80 dup1 0 0 rds suc 0 | 0x00000025 3e returndatacopy suc 0 | 0x00000026 90 swap1 0 suc | 0x00000027 3d returndatasize rds 0 suc | 0x00000028 91 swap2 suc 0 rds | 0x00000029 602d push1 0x2e 0x2e suc 0 rds | ,=< 0x0000002b 57 jumpi 0 rds | | 0x0000002c fd revert | `-> 0x0000002d 5b jumpdest 0 rds \ 0x0000002e f3 return

func ComputeGuestExecDigest added in v0.3.3

func ComputeGuestExecDigest(txns Transactions) (common.Hash, error)

func ComputeSelfExecDigest added in v0.3.3

func ComputeSelfExecDigest(txns Transactions) (common.Hash, error)

func ComputeWalletExecDigest added in v0.3.3

func ComputeWalletExecDigest(nonce *big.Int, txns Transactions) (common.Hash, error)

func DecodeNonce

func DecodeNonce(raw *big.Int) (*big.Int, *big.Int)

DecodeNonce raw nonce, returns (space, nonce)

func DecodeNonceChangeEvent added in v0.3.1

func DecodeNonceChangeEvent(log *types.Log) (*big.Int, *big.Int, error)

func DecodeRevertReason added in v0.3.3

func DecodeRevertReason(logs []*types.Log) []string

func DecodeTxFailedEvent added in v0.3.1

func DecodeTxFailedEvent(log *types.Log) (common.Hash, string, error)

func DeploySequenceWallet

func DeploySequenceWallet(sender *ethwallet.Wallet, walletConfig WalletConfig, walletContext WalletContext) (common.Address, *types.Transaction, ethtxn.WaitReceipt, error)

func EncodeNonce

func EncodeNonce(space *big.Int, nonce *big.Int) (*big.Int, error)

EncodeNonce with space

func EncodeTransactionsForRelaying

func EncodeTransactionsForRelaying(relayer Relayer, walletConfig WalletConfig, walletContext WalletContext, txns Transactions, nonce *big.Int, seqSig []byte) (common.Address, []byte, error)

returns `to` address (either guest or wallet) and `data` of signed-metatx-calldata, aka execdata

func EncodeWalletDeployment added in v0.3.3

func EncodeWalletDeployment(walletConfig WalletConfig, walletContext WalletContext) (common.Address, common.Address, []byte, error)

func GenerateRandomNonce

func GenerateRandomNonce() (*big.Int, error)

GenerateRandomNonce returns a random space for a nonce to ensure transactions can be executed in parallel.

func GetWalletNonce

func GetWalletNonce(provider *ethrpc.Provider, walletConfig WalletConfig, walletContext WalletContext, space *big.Int, blockNum *big.Int) (*big.Int, error)

func ImageHashOfWalletConfig

func ImageHashOfWalletConfig(walletConfig WalletConfig) (string, error)

func ImageHashOfWalletConfigBytes

func ImageHashOfWalletConfigBytes(walletConfig WalletConfig) ([]byte, error)

func ImageHashOfWalletConfigBytes32 added in v0.6.5

func ImageHashOfWalletConfigBytes32(walletConfig WalletConfig) ([32]byte, error)

func IsTxExecutedEvent added in v0.3.1

func IsTxExecutedEvent(log *types.Log, hash common.Hash) bool

func IsValidSignature

func IsValidSignature(walletAddress common.Address, digest common.Hash, seqSig []byte, walletContext WalletContext, chainID *big.Int, provider *ethrpc.Provider) (bool, error)

func IsWalletConfigEqual

func IsWalletConfigEqual(walletConfigA, walletConfigB WalletConfig) bool

func IsWalletConfigUsable

func IsWalletConfigUsable(walletConfig WalletConfig) (bool, error)

func IsWalletDeployed

func IsWalletDeployed(provider *ethrpc.Provider, walletAddress common.Address) (bool, error)

func MessageDigest

func MessageDigest(message []byte) common.Hash

func MustEncodeSig

func MustEncodeSig(str string) common.Hash

func PackMessageData

func PackMessageData(chainID *big.Int, address common.Address, digest common.Hash) ([]byte, error)

PackMessageData encodes a Sequence contract "message"

func ReduceExecdataSignatures added in v0.6.6

func ReduceExecdataSignatures(chainID *big.Int, data []byte) ([]byte, error)

func SortWalletConfig

func SortWalletConfig(walletConfig WalletConfig) error

func SubDigest

func SubDigest(chainID *big.Int, address common.Address, digest common.Hash) ([]byte, error)

func ValidateSequenceAccountProof

func ValidateSequenceAccountProof() ethauth.ValidatorFunc

func ValidateSequenceAccountProofWith

func ValidateSequenceAccountProofWith(factory, mainModule common.Address) ethauth.ValidatorFunc

Types

type BlockOfReceipts added in v0.4.17

type BlockOfReceipts []ReceiptResult

type CallOverride added in v0.4.0

type CallOverride struct {
	Code      string
	Balance   *big.Int
	Nonce     *big.Int
	StateDiff []*StateOverride
	State     []*StateOverride
}

type EstimateTransaction added in v0.4.0

type EstimateTransaction struct {
	From common.Address
	To   common.Address
	Data []byte
}

type Estimator added in v0.4.0

type Estimator struct {
	BaseCost     uint64
	DataOneCost  uint64
	DataZeroCost uint64
	// contains filtered or unexported fields
}

func NewEstimator added in v0.4.0

func NewEstimator() *Estimator

func (*Estimator) AreEOAs added in v0.4.0

func (e *Estimator) AreEOAs(ctx context.Context, provider *ethrpc.Provider, walletConfig WalletConfig) ([]bool, error)

func (*Estimator) BuildStubSignature added in v0.4.0

func (e *Estimator) BuildStubSignature(walletConfig WalletConfig, willSign []bool, isEoa []bool) []byte

func (*Estimator) CalldataCost added in v0.4.0

func (e *Estimator) CalldataCost(data []byte) uint64

func (*Estimator) Estimate added in v0.4.0

func (e *Estimator) Estimate(ctx context.Context, provider *ethrpc.Provider, address common.Address, walletConfig WalletConfig, walletContext WalletContext, txs Transactions) (uint64, error)

func (*Estimator) EstimateCall added in v0.4.0

func (e *Estimator) EstimateCall(ctx context.Context, provider *ethrpc.Provider, call *EstimateTransaction, overrides map[common.Address]*CallOverride, blockTag string) (*big.Int, error)

func (*Estimator) PickSigners added in v0.4.0

func (e *Estimator) PickSigners(ctx context.Context, walletConfig WalletConfig, isEoa []bool) ([]bool, error)

func (*Estimator) SetCache added in v0.4.16

func (e *Estimator) SetCache(cache cachestore.Store[[]byte]) *Estimator

type MetaTxnExecType added in v0.3.3

type MetaTxnExecType uint32

MetaTxnExecType represents the kind of execution call for the meta-transaction

const (
	MetaTxnWalletExec MetaTxnExecType = iota // MainModule.execute
	MetaTxnSelfExec                          // MainModule.selfExecute
	MetaTxnGuestExec                         // GuestModule.execute
)

type MetaTxnID

type MetaTxnID string

func ComputeMetaTxnID

func ComputeMetaTxnID(chainID *big.Int, address common.Address, txns Transactions, nonce *big.Int, execType MetaTxnExecType) (MetaTxnID, common.Hash, error)

func ComputeMetaTxnIDFromDigest added in v0.3.3

func ComputeMetaTxnIDFromDigest(chainID *big.Int, address common.Address, digest common.Hash) (MetaTxnID, common.Hash, error)

type MetaTxnResult added in v0.10.0

type MetaTxnResult struct {
	Status MetaTxnStatus
	Reason string
}

type MetaTxnStatus added in v0.2.0

type MetaTxnStatus uint8
const (
	MetaTxnStatusUnknown MetaTxnStatus = iota
	MetaTxnExecuted
	MetaTxnFailed
	MetaTxnReverted
)

func WaitForMetaTxn

func WaitForMetaTxn(ctx context.Context, provider *ethrpc.Provider, metaTxnID MetaTxnID, optTimeout ...time.Duration) (MetaTxnStatus, *types.Receipt, error)

TODO: this method is horribly inefficient and we need to rethink how such a method should be designed.

TOOD: first, we can start by making it use a cachestore for receipts.. that will help at least.. but it should be used very sparingly in all cases.

type NetworkConfig

type NetworkConfig struct {
	Name       string
	ChainID    big.Int
	ENSAddress *common.Address

	RpcURL   string
	Provider *ethrpc.Provider

	RelayerURL *string // optional, one of the these should be set
	Relayer    Relayer

	IndexerURL *string // optional, one of these should be set

	IsDefaultChain bool
	IsAuthChain    bool

	SequenceAPIURL string
}

type Networks

type Networks []NetworkConfig

type Receipt added in v0.3.1

type Receipt struct {
	*types.Receipt

	MetaTxnID MetaTxnID
	Status    MetaTxnStatus
	Reason    string
	Logs      []*types.Log

	Index       uint
	Transaction *Transaction
	Receipts    []*Receipt
}

func DecodeReceipt added in v0.3.1

func DecodeReceipt(ctx context.Context, receipt *types.Receipt, provider *ethrpc.Provider) ([]*Receipt, []*types.Log, error)

func (*Receipt) Find added in v0.4.6

func (r *Receipt) Find(metaTxnID MetaTxnID) *Receipt

type ReceiptListener added in v0.4.18

type ReceiptListener struct {
	// contains filtered or unexported fields
}

func NewReceiptListener added in v0.4.18

func NewReceiptListener(log zerolog.Logger, provider *ethrpc.Provider, monitor *ethmonitor.Monitor) (*ReceiptListener, error)

func (*ReceiptListener) Run added in v0.4.18

func (l *ReceiptListener) Run(ctx context.Context) error

func (*ReceiptListener) WaitForMetaTxn added in v0.4.18

func (l *ReceiptListener) WaitForMetaTxn(ctx context.Context, metaTxnID MetaTxnID, optTimeout ...time.Duration) ([]*MetaTxnResult, *types.Receipt, error)

type ReceiptResult added in v0.4.18

type ReceiptResult struct {
	MetaTxnID  MetaTxnID
	Results    []*MetaTxnResult
	TxnReceipt *types.Receipt
}

type Relayer

type Relayer interface {
	// ..
	GetProvider() *ethrpc.Provider

	// ..
	EstimateGasLimits(ctx context.Context, walletConfig WalletConfig, walletContext WalletContext, txns Transactions) (Transactions, error)

	// NOTE: nonce space is 160 bits wide
	GetNonce(ctx context.Context, walletConfig WalletConfig, walletContext WalletContext, space *big.Int, blockNum *big.Int) (*big.Int, error)

	// Relay will submit the Sequence signed meta transaction to the relayer. The method will block until the relayer
	// responds with the native transaction hash (*types.Transaction), which means the relayer has submitted the transaction
	// request to the network. Clients can use WaitReceipt to wait until the metaTxnID has been mined.
	Relay(ctx context.Context, signedTxs *SignedTransactions) (MetaTxnID, *types.Transaction, ethtxn.WaitReceipt, error)

	// ..
	Wait(ctx context.Context, metaTxnID MetaTxnID, optTimeout ...time.Duration) (MetaTxnStatus, *types.Receipt, error)
}

type Signature

type Signature struct {
	Threshold uint16         `json:"threshold"`
	Signers   SignatureParts `json:"signers"`
}

Signature for sequence message

func DecodeSignature

func DecodeSignature(sequenceSignature []byte) (*Signature, error)

DecodeSignature sequence into individual parts

func JoinSignatures

func JoinSignatures(sigs ...*Signature) (*Signature, error)

Join signatures

func Sign

func Sign(wallet *Wallet, input common.Hash) ([]byte, *Signature, error)

func (*Signature) Copy

func (s *Signature) Copy() *Signature

Copy a signature

func (*Signature) Encode

func (s *Signature) Encode() ([]byte, error)

Encode returns encoded sequence signature bytes of all signatures in the Signers set

func (*Signature) ImageHash

func (s *Signature) ImageHash() ([32]byte, error)

ImageHash returns the imagehash for a given signature

func (*Signature) JoinTwo

func (s *Signature) JoinTwo(s2 *Signature) error

JoinTwo signatures, saves the aggregated one into s1

func (*Signature) Recover

func (s *Signature) Recover(msg []byte, provider *ethrpc.Provider) error

Recover signers of signature

func (*Signature) Reduce added in v0.6.6

func (s *Signature) Reduce(msg []byte) error

Minimizes the cost of a signature's encoding while keeping it valid

func (*Signature) Weight

func (s *Signature) Weight() (uint16, error)

Weight of combined signatures, assumes all signatures to be valid

type SignaturePart

type SignaturePart struct {
	Weight  uint8          `json:"weight"`
	Address common.Address `json:"address"`
	Type    uint8          `json:"type"`  // signature type, ie. EOA, Address, Dynamic
	Value   []byte         `json:"value"` // signature value for this part
}

SignaturePart of an overall sequence signature message

func (*SignaturePart) IsValid

func (p *SignaturePart) IsValid(digest [32]byte, provider *ethrpc.Provider) (bool, error)

IsValid signature part

func (*SignaturePart) Recover

func (p *SignaturePart) Recover(msg []byte) (common.Address, error)

Recover signature part

type SignatureParts

type SignatureParts []*SignaturePart

func (SignatureParts) Len

func (a SignatureParts) Len() int

func (SignatureParts) Less

func (a SignatureParts) Less(i, j int) bool

func (SignatureParts) Swap

func (a SignatureParts) Swap(i, j int)

type SignedTransactions

type SignedTransactions struct {
	ChainID       *big.Int
	WalletConfig  WalletConfig
	WalletContext WalletContext

	Transactions Transactions // The meta-transactions
	Nonce        *big.Int     // Nonce of the transactions
	Digest       common.Hash  // Digest of the transactions
	Signature    []byte       // Signature (encoded as bytes from *Signature) of the txn digest
}

SignedTransactions includes a signed meta-transaction payload intended for the relayer.

func (*SignedTransactions) Execdata added in v0.2.0

func (t *SignedTransactions) Execdata() ([]byte, error)

type SimulateResult added in v0.6.9

func Simulate added in v0.6.9

func Simulate(provider *ethrpc.Provider, wallet common.Address, transactions Transactions, block string, overrides map[common.Address]*CallOverride) ([]SimulateResult, error)

type StateOverride added in v0.4.0

type StateOverride struct {
	Key   string
	Value string
}

type Transaction

type Transaction struct {
	DelegateCall  bool           `abi:"delegateCall"`  // Performs delegatecall
	RevertOnError bool           `abi:"revertOnError"` // Reverts transaction bundle if tx fails
	GasLimit      *big.Int       `abi:"gasLimit"`      // Maximum gas to be forwarded
	To            common.Address `abi:"target"`        // Address to send transaction, aka target
	Value         *big.Int       `abi:"value"`         // Amount of ETH to pass with the call
	Data          []byte         `abi:"data"`          // Calldata to pass

	Transactions Transactions // Child transactions
	Nonce        *big.Int     // Meta-Transaction nonce, with encoded space
	Signature    []byte       // Meta-Transaction signature
	// contains filtered or unexported fields
}

Transaction type for Sequence meta-transaction, with encoded calldata.

The fields with abi struct tags match the `Transaction` type as defined in the IModuleCalls interface.

https://github.com/0xsequence/wallet-contracts/blob/master/src/contracts/modules/commons/interfaces/IModuleCalls.sol#L13

func (*Transaction) AddToBundle added in v0.2.0

func (t *Transaction) AddToBundle(txns Transactions)

AddToBundle will create a bundle from the passed txns and add it to current transaction

func (*Transaction) Bundle added in v0.2.0

func (t *Transaction) Bundle() Transactions

func (*Transaction) Clone added in v0.3.2

func (t *Transaction) Clone() *Transaction

func (*Transaction) Digest added in v0.2.0

func (t *Transaction) Digest() (common.Hash, error)

func (*Transaction) Execdata added in v0.2.0

func (t *Transaction) Execdata() ([]byte, error)

func (*Transaction) GuestDigest added in v0.3.1

func (t *Transaction) GuestDigest() (common.Hash, error)

func (*Transaction) IsBundle added in v0.2.0

func (t *Transaction) IsBundle() bool

func (*Transaction) IsEncoded added in v0.3.3

func (t *Transaction) IsEncoded() bool

func (*Transaction) IsValid added in v0.2.1

func (t *Transaction) IsValid() error

func (*Transaction) ReduceSignatures added in v0.6.6

func (t *Transaction) ReduceSignatures(chainID *big.Int) error

type Transactions

type Transactions []*Transaction

func DecodeExecdata added in v0.3.2

func DecodeExecdata(data []byte) (Transactions, *big.Int, []byte, error)

func DecodeRawTransactions added in v0.4.2

func DecodeRawTransactions(data []byte) (Transactions, error)

func NewTransactionsFromValues added in v0.2.0

func NewTransactionsFromValues(values []Transaction) Transactions

func (*Transactions) Append added in v0.2.0

func (t *Transactions) Append(txns Transactions)

Append will append the passed txns to the `t` array (as separate Transaction elements).

func (Transactions) AppendBundle added in v0.2.0

func (t Transactions) AppendBundle(txns Transactions)

AppendBundle will append the passed txns as *a bundle of txns*. This means, it will be included as a single element at this level of the `t` array.

func (Transactions) AsValues

func (t Transactions) AsValues() []Transaction

func (Transactions) Clone added in v0.3.2

func (t Transactions) Clone() Transactions

func (Transactions) EncodeRaw added in v0.4.2

func (t Transactions) EncodeRaw() ([]byte, error)

func (Transactions) EncodedTransactions added in v0.3.3

func (t Transactions) EncodedTransactions() ([]Transaction, error)

func (Transactions) Nonce

func (t Transactions) Nonce() (*big.Int, error)

func (*Transactions) Prepend added in v0.2.0

func (t *Transactions) Prepend(txns Transactions)

Prepend will prepend the passed txns to the `t` array (as separate Transaction elements).

func (Transactions) PrependBundle added in v0.2.0

func (t Transactions) PrependBundle(txns Transactions)

PrependBundle will prepend the passed txns as *a bundle of txns*. This means, it will be included as a single element at this level of the `t` array.

type Wallet

type Wallet struct {
	// contains filtered or unexported fields
}

func NewWallet

func NewWallet(walletOptions WalletOptions, signers ...*ethwallet.Wallet) (*Wallet, error)

func NewWalletSingleOwner

func NewWalletSingleOwner(owner *ethwallet.Wallet, optContext ...WalletContext) (*Wallet, error)

func (*Wallet) Address

func (w *Wallet) Address() common.Address

func (*Wallet) Connect

func (w *Wallet) Connect(provider *ethrpc.Provider, relayer Relayer) error

func (*Wallet) GetChainID

func (w *Wallet) GetChainID() *big.Int

func (*Wallet) GetNonce

func (w *Wallet) GetNonce(optBlockNum ...*big.Int) (*big.Int, error)

func (*Wallet) GetProvider

func (w *Wallet) GetProvider() *ethrpc.Provider

func (*Wallet) GetRelayer

func (w *Wallet) GetRelayer() Relayer

func (*Wallet) GetSigner

func (w *Wallet) GetSigner(address common.Address) (*ethwallet.Wallet, bool)

func (*Wallet) GetSignerAddresses

func (w *Wallet) GetSignerAddresses() []common.Address

func (*Wallet) GetSignerWeight

func (w *Wallet) GetSignerWeight() *big.Int

func (*Wallet) GetTransactionCount

func (w *Wallet) GetTransactionCount(optBlockNum ...*big.Int) (*big.Int, error)

func (*Wallet) GetWalletConfig

func (w *Wallet) GetWalletConfig() WalletConfig

func (*Wallet) GetWalletContext

func (w *Wallet) GetWalletContext() WalletContext

func (*Wallet) ImageHash

func (w *Wallet) ImageHash() (common.Hash, error)

func (*Wallet) IsDeployed

func (w *Wallet) IsDeployed() (bool, error)

func (*Wallet) IsSignerAvailable

func (w *Wallet) IsSignerAvailable(address common.Address) bool

func (*Wallet) IsValidSignature

func (w *Wallet) IsValidSignature(digest common.Hash, signature []byte) (bool, error)

func (*Wallet) SendTransaction

func (w *Wallet) SendTransaction(ctx context.Context, signedTxns *SignedTransactions) (MetaTxnID, *types.Transaction, ethtxn.WaitReceipt, error)

func (*Wallet) SendTransactions

func (w *Wallet) SendTransactions(ctx context.Context, signedTxns *SignedTransactions) (MetaTxnID, *types.Transaction, ethtxn.WaitReceipt, error)

func (*Wallet) SetChainID

func (w *Wallet) SetChainID(chainID *big.Int)

SetChainID will set the wallet's associated chainID. However, for most part, this will automatically be set by the provider rpc.

func (*Wallet) SetProvider

func (w *Wallet) SetProvider(provider *ethrpc.Provider) error

func (*Wallet) SetRelayer

func (w *Wallet) SetRelayer(relayer Relayer) error

func (*Wallet) SignDigest

func (w *Wallet) SignDigest(digest common.Hash, optChainID ...*big.Int) ([]byte, *Signature, error)

func (*Wallet) SignMessage

func (w *Wallet) SignMessage(msg []byte) ([]byte, *Signature, error)

func (*Wallet) SignTransaction

func (w *Wallet) SignTransaction(ctx context.Context, txn *Transaction) (*SignedTransactions, error)

func (*Wallet) SignTransactions

func (w *Wallet) SignTransactions(ctx context.Context, txns Transactions) (*SignedTransactions, error)

func (*Wallet) UseConfig

func (w *Wallet) UseConfig(config WalletConfig) (*Wallet, error)

func (*Wallet) UseSigners

func (w *Wallet) UseSigners(signers ...*ethwallet.Wallet) (*Wallet, error)

type WalletConfig

type WalletConfig struct {
	Threshold uint16              `json:"threshold"`
	Signers   WalletConfigSigners `json:"signers"`
}

func RecoverWalletConfigFromDigest

func RecoverWalletConfigFromDigest(digest, seqSig []byte, context WalletContext, chainID *big.Int, provider *ethrpc.Provider) (WalletConfig, error)

func (WalletConfig) Clone added in v0.7.3

func (s WalletConfig) Clone() WalletConfig

type WalletConfigSigner

type WalletConfigSigner struct {
	Weight  uint8          `json:"weight"`
	Address common.Address `json:"address"`
}

type WalletConfigSigners

type WalletConfigSigners []WalletConfigSigner

func (WalletConfigSigners) GetWeightByAddress

func (s WalletConfigSigners) GetWeightByAddress(address common.Address) (uint8, bool)

func (WalletConfigSigners) Len

func (s WalletConfigSigners) Len() int

func (WalletConfigSigners) Less

func (s WalletConfigSigners) Less(i, j int) bool

func (WalletConfigSigners) Swap

func (s WalletConfigSigners) Swap(i, j int)

type WalletContext

type WalletContext struct {
	FactoryAddress              common.Address `json:"factory" toml:"factory_address"`
	MainModuleAddress           common.Address `json:"mainModule" toml:"main_module_address"`
	MainModuleUpgradableAddress common.Address `json:"mainModuleUpgradable" toml:"main_module_upgradable_address"`
	GuestModuleAddress          common.Address `json:"guestModule" toml:"guest_module_address"`
	UtilsAddress                common.Address `json:"utils" toml:"utils_address"`
}

WalletContext is the module addresses deployed on a network, aka the context / environment of the Sequence Smart Wallet system on Ethereum.

func SequenceContext

func SequenceContext() WalletContext

SequenceContext returns copy of the package-level internal variable, to prevent change by other packages.

type WalletOptions

type WalletOptions struct {
	// Config is the wallet multi-sig configuration. Note: the first config of any wallet
	// before it is deployed is used to derive it's the account address of the wallet.
	Config WalletConfig

	// Context is the WalletContext of deployed wallet-contract modules for the Smart Wallet.
	// NOTE: if a WalletContext is not provided, then `SequenceContext()` value is used.
	Context *WalletContext

	// Skips config sorting and keeps signers order as-is
	SkipSortSigners bool

	// Address used for the wallet
	// if this value is defined, the address derived from the sequence config is ignored
	Address common.Address
}

Directories

Path Synopsis
sequence-api v0.4.0 4d2479b7b4da1f3902a2593f729835aa16931146 -- This file has been generated by https://github.com/webrpc/webrpc using gen/golang Do not edit by hand.
sequence-api v0.4.0 4d2479b7b4da1f3902a2593f729835aa16931146 -- This file has been generated by https://github.com/webrpc/webrpc using gen/golang Do not edit by hand.
gen
sequence-indexer v0.4.0 340c4e7dc237c5d68951da5bffe4edc603a1af8f -- This file has been generated by https://github.com/webrpc/webrpc using gen/golang Do not edit by hand.
sequence-indexer v0.4.0 340c4e7dc237c5d68951da5bffe4edc603a1af8f -- This file has been generated by https://github.com/webrpc/webrpc using gen/golang Do not edit by hand.
lib
sequence-metadata v0.4.0 3f6b0f4aa1a7b58488e9399c277fc17995d74f5a -- This file has been generated by https://github.com/webrpc/webrpc using gen/golang Do not edit by hand.
sequence-metadata v0.4.0 3f6b0f4aa1a7b58488e9399c277fc17995d74f5a -- This file has been generated by https://github.com/webrpc/webrpc using gen/golang Do not edit by hand.
proto
sequence-relayer v0.4.0 59a862f763edcaca2fb2e11901b24873c4c02034 -- This file has been generated by https://github.com/webrpc/webrpc using gen/golang Do not edit by hand.
sequence-relayer v0.4.0 59a862f763edcaca2fb2e11901b24873c4c02034 -- This file has been generated by https://github.com/webrpc/webrpc using gen/golang Do not edit by hand.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL