contracts

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

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

Variables

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

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 Normalize added in v0.1.9

func Normalize(name string) (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 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
	GetScwOwner(ctx context.Context, address common.Address) (common.Address, error)

	// ENS methods
	GetOwnerForNamehash(ctx context.Context, namehash [32]byte) (common.Address, error)
	GetAdditionalNameInfo(ctx context.Context, currentOwner common.Address, fullName string) (ownerEthAddress string, ownerAnyAddress string, spaceId string, expiration *big.Int, 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