Help us shape the future of Go! Take the 2026 Go Developer Survey

contracts

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const CName = "any-ns.contracts"
View Source
const MAX_NAME_LENGTH = 100

Variables

View Source
var (
	ErrNonceTooLow  = errors.New("nonce too low")
	ErrNonceTooHigh = errors.New("nonce too high")

	// ErrNotAContract is returned by GetScwOwner when there is no code at the address:
	// it is either an EOA or a smart contract wallet that is not deployed yet
	ErrNotAContract = errors.New("address is not a smart contract")
)

Functions

func GenerateRandomSecret

func GenerateRandomSecret() ([32]byte, error)

func NameHash

func NameHash(name string) (hash [32]byte, err error)

NameHash generates a hash from a name that can be used to look up the name in ENS

func New

func New() app.Component

func NormalizeAnyName added in v0.3.0

func NormalizeAnyName(name string, useEnsip15 bool) (string, error)

func PeriodMonthsToTimestamp added in v0.1.9

func PeriodMonthsToTimestamp(registerPeriodMonths uint32) big.Int

func PrepareCallData_SetContentHashSpaceID

func PrepareCallData_SetContentHashSpaceID(fullName string, contentHash string, spaceID string) ([][]byte, error)

func RemoveTLD

func RemoveTLD(str string) string

Types

type Block added in v0.7.0

type Block struct {
	Number int64
	Hash   common.Hash
	// the block timestamp (unix seconds)
	Time uint64
}

Block identifies a block of the chain

type CommitParams added in v0.2.3

type CommitParams struct {
	Opts       *bind.TransactOpts
	Commitment [32]byte
	Controller *ac.AnytypeRegistrarControllerPrivate
}

type ContractsService

type ContractsService interface {
	CreateEthConnection() (*ethclient.Client, error)

	// generic method to call any contract
	CallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error)

	// AA methods:
	IsContractDeployed(ctx context.Context, address common.Address) (bool, error)
	// will return .owner of the contract (at the block, a zero hash: the latest one)
	GetScwOwner(ctx context.Context, address common.Address, block common.Hash) (common.Address, error)

	// ENS methods.
	// block pins a read to one block by its hash (EIP-1898; a zero hash: the latest block).
	// all the reads of one cache refresh use the same block, so that they see one chain state
	// (one fork too, even behind a load balancer) and can be ordered by it
	LatestBlock(ctx context.Context) (*Block, error)
	// FinalizedBlock is the newest block that can not be reorged away (the "finalized" tag, or
	// "safe" if the provider does not know it)
	FinalizedBlock(ctx context.Context) (*Block, error)
	GetOwnerForNamehash(ctx context.Context, namehash [32]byte, block common.Hash) (common.Address, error)
	GetNameExpires(ctx context.Context, fullName string, block common.Hash) (*big.Int, error)
	GetAdditionalNameInfo(ctx context.Context, currentOwner common.Address, fullName string, block common.Hash) (ownerEthAddress string, ownerAnyAddress string, spaceID string, err error)

	Commit(ctx context.Context, params *CommitParams) (*types.Transaction, error)
	Register(ctx context.Context, params *RegisterParams) (*types.Transaction, error)
	Renew(ctx context.Context, params *RenewParams) (*types.Transaction, error)

	// Aux methods
	MakeCommitment(params *MakeCommitmentParams) ([32]byte, error)
	GetNameByAddress(address common.Address) (string, error)
	GetBalanceOf(ctx context.Context, tokenAddress common.Address, address common.Address) (*big.Int, error)

	ConnectToRegistryContract() (*ac.ENSRegistry, error)
	ConnectToNamewrapperContract() (*ac.AnytypeNameWrapper, error)
	ConnectToResolver() (*ac.AnytypeResolver, error)
	ConnectToRegistrar() (*ac.AnytypeRegistrarImplementation, error)
	ConnectToPrivateController() (*ac.AnytypeRegistrarControllerPrivate, error)

	GenerateAuthOptsForAdmin() (*bind.TransactOpts, error)
	CalculateTxParams(conn *ethclient.Client, address common.Address) (*big.Int, uint64, error)

	// Check if tx is even started to mine
	WaitForTxToStartMining(ctx context.Context, txHash common.Hash) error
	WaitMined(ctx context.Context, tx *types.Transaction) (wasMined bool, err error)
	TxByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, error)

	app.Component
}

TODO: refactor, split into several interfaces Low-level calls to contracts

type MakeCommitmentParams added in v0.2.3

type MakeCommitmentParams struct {
	NameFirstPart         string
	RegisterPeriodMonths  uint32
	IsReverseRecordUpdate bool
	SpaceId               string
	OwnerAnyAddr          string
	FullName              string
	Controller            *ac.AnytypeRegistrarControllerPrivate
	Secret                [32]byte
	RegistrantAccount     common.Address
}

type RegisterParams added in v0.2.3

type RegisterParams struct {
	AuthOpts             *bind.TransactOpts
	NameFirstPart        string
	RegistrantAccount    common.Address
	Secret               [32]byte
	Controller           *ac.AnytypeRegistrarControllerPrivate
	FullName             string
	OwnerAnyAddr         string
	SpaceId              string
	IsReverseRecord      bool
	RegisterPeriodMonths uint32
}

type RenewParams added in v0.2.3

type RenewParams struct {
	TxOpts      *bind.TransactOpts
	FullName    string
	DurationSec uint64
	Controller  *ac.AnytypeRegistrarControllerPrivate
}

Directories

Path Synopsis
Package mock_contracts is a generated GoMock package.
Package mock_contracts is a generated GoMock package.

Jump to

Keyboard shortcuts

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