contracts

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 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 ContractsService

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

	// generic method to call any contract
	CallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error)
	GetBalanceOf(ctx context.Context, client *ethclient.Client, tokenAddress common.Address, address common.Address) (*big.Int, error)
	IsContractDeployed(ctx context.Context, client *ethclient.Client, address common.Address) (bool, error)
	// will return .owner of the contract
	GetOwnerOfSmartContractWallet(ctx context.Context, client *ethclient.Client, address common.Address) (common.Address, error)

	// ENS methods
	GetOwnerForNamehash(ctx context.Context, client *ethclient.Client, namehash [32]byte) (common.Address, error)
	GetAdditionalNameInfo(ctx context.Context, conn *ethclient.Client, currentOwner common.Address, fullName string) (ownerEthAddress string, ownerAnyAddress string, spaceId string, expiration *big.Int, err error)

	MakeCommitment(nameFirstPart string, registrantAccount common.Address, secret [32]byte, controller *ac.AnytypeRegistrarControllerPrivate, fullName string, ownerAnyAddr string, spaceId string, isReverseRecordUpdate bool, registerPeriodMonths uint32) ([32]byte, error)
	Commit(ctx context.Context, conn *ethclient.Client, opts *bind.TransactOpts, commitment [32]byte, controller *ac.AnytypeRegistrarControllerPrivate) (*types.Transaction, error)
	Register(ctx context.Context, conn *ethclient.Client, authOpts *bind.TransactOpts, nameFirstPart string, registrantAccount common.Address, secret [32]byte, controller *ac.AnytypeRegistrarControllerPrivate, fullName string, ownerAnyAddr string, spaceId string, isReverseRecord bool, registerPeriodMonths uint32) (*types.Transaction, error)
	RenewName(ctx context.Context, conn *ethclient.Client, opts *bind.TransactOpts, fullName string, durationSec uint64, controller *ac.AnytypeRegistrarControllerPrivate) (*types.Transaction, error)
	GetNameByAddress(conn *ethclient.Client, address common.Address) (string, error)

	// Aux methods
	ConnectToRegistryContract(conn *ethclient.Client) (*ac.ENSRegistry, error)
	ConnectToNamewrapperContract(conn *ethclient.Client) (*ac.AnytypeNameWrapper, error)
	ConnectToResolver(conn *ethclient.Client) (*ac.AnytypeResolver, error)
	ConnectToRegistrar(conn *ethclient.Client) (*ac.AnytypeRegistrarImplementation, error)
	ConnectToPrivateController(conn *ethclient.Client) (*ac.AnytypeRegistrarControllerPrivate, error)

	GenerateAuthOptsForAdmin(conn *ethclient.Client) (*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, conn *ethclient.Client, txHash common.Hash) error
	WaitMined(ctx context.Context, client *ethclient.Client, tx *types.Transaction) (wasMined bool, err error)
	TxByHash(ctx context.Context, client *ethclient.Client, txHash common.Hash) (*types.Transaction, error)

	app.Component
}

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

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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