imx

package
Version: v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: Apache-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ContractInvalidError = "contract_invalid_error"
	EthClientError       = "ethereum_client_error"
)
View Source
const (
	ETHTokenType    = "ETH"
	ERC20TokenType  = "ERC20"
	ERC721TokenType = "ERC721"
)

Variables

View Source
var (
	Sandbox = Environment{
		BaseAPIPath:                 "https://api.sandbox.x.immutable.com",
		EthereumRPC:                 "https://eth-goerli.alchemyapi.io/v2/",
		RegistrationContractAddress: "0x1C97Ada273C9A52253f463042f29117090Cd7D83",
		CoreContractAddress:         "0x7917eDb51ecD6CdB3F9854c3cc593F33de10c623",
		ChainID:                     big.NewInt(5),
	}
	Mainnet = Environment{
		BaseAPIPath:                 "https://api.x.immutable.com",
		EthereumRPC:                 "https://eth-mainnet.alchemyapi.io/v2/",
		RegistrationContractAddress: "0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c",
		CoreContractAddress:         "0x5FDCCA53617f4d2b9134B29090C87D01058e27e9",
		ChainID:                     big.NewInt(1),
	}
	Ropsten = Environment{
		BaseAPIPath:                 "https://api.ropsten.x.immutable.com",
		EthereumRPC:                 "https://eth-ropsten.alchemyapi.io/v2/",
		RegistrationContractAddress: "0x6C21EC8DE44AE44D0992ec3e2d9f1aBb6207D864",
		CoreContractAddress:         "0x4527BE8f31E2ebFbEF4fCADDb5a17447B27d2aef",
		ChainID:                     big.NewInt(3),
	}
)

Functions

func NewIMXError

func NewIMXError(httpResponse *http.Response, err error) error

NewIMXError returns an IMXError when Api Request fails. @param httpResponse httpResponse. @param err Error message. @return IMXError

func SignableERC20Token

func SignableERC20Token(decimals int, tokenAddress string) api.SignableToken

SignableERC20Token returns a new ERC20 type token. https://docs.x.immutable.com/docs/token-data-object#type-erc20

func SignableERC721Token

func SignableERC721Token(tokenID, tokenAddress string) api.SignableToken

SignableERC721Token returns a new ERC721 type token. https://docs.x.immutable.com/docs/token-data-object#type-erc721

func SignableETHToken

func SignableETHToken() api.SignableToken

SignableETHToken returns a new ETH type token. https://docs.x.immutable.com/docs/token-data-object#type-eth

Types

type Client

type Client struct {
	Environment          Environment
	EthClient            *ethclient.Client
	RegistrationContract *contracts.Registration
	CoreContract         *contracts.Core

	api.EncodingApi
	// contains filtered or unexported fields
}

Client implements functions to get the work done with Immutable X API. It manages communication with the Immutable X API.

func NewClient

func NewClient(cfg *Config) (*Client, error)

NewClient creates a new Client. Requires config to setup and initialise. See examples for usage reference.

func (*Client) AddMetadataSchemaToCollection

func (c *Client) AddMetadataSchemaToCollection(
	ctx context.Context,
	l1signer L1Signer,
	contractAddress string,
	addMetadataSchemaToCollectionRequest api.AddMetadataSchemaToCollectionRequest,
) (*api.SuccessResponse, error)

AddMetadataSchemaToCollection Add metadata schema to collection

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1signer Ethereum signer used for ownership authentication. @param contractAddress Collection contract address @param addMetadataSchemaToCollectionRequest The request struct with all the params. @return SuccessResponse

func (*Client) BatchNftTransfer

func (c *Client) BatchNftTransfer(
	ctx context.Context,
	l1signer L1Signer,
	l2signer L2Signer,
	request api.GetSignableTransferRequest,
) (*api.CreateTransferResponse, error)

BatchNftTransfer performs a bulk transfer of NFTs given an array of models.SignableToken and their receivers.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1Signer Ethereum signer to sign message. @param l2signer Stark signer to sign the payload hash. @param request The request struct with all the params. @return CreateTransferResponse

func (*Client) CancelOrder

func (c *Client) CancelOrder(ctx context.Context,
	l1signer L1Signer,
	l2signer L2Signer,
	request api.GetSignableCancelOrderRequest,
) (*api.CancelOrderResponse, error)

CancelOrder will remove the listed asset on marketplace from sale.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1Signer Ethereum signer to sign message. @param l2signer Stark signer to sign the payload hash. @param request The request struct with all the params. @return CancelOrderResponse

func (*Client) CreateCollection

func (c *Client) CreateCollection(
	ctx context.Context,
	l1signer L1Signer,
	createCollectionRequest *api.CreateCollectionRequest,
) (*api.Collection, error)

CreateCollection Creates a new collection

A collection refers to a series of NFTs, minted under a project, and corresponds to a specific deployed smart contract. All minted assets belong to a collection, and in order to mint assets on L2 you must first register your collection (smart contract) with Immutable X. * Each collection belongs to a project. * Each collection may contain many similar or different NFTs.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1signer Ethereum signer used for ownership authentication. @param createCollectionRequest The request struct with all the params. @return Collection

func (*Client) CreateMetadataRefresh

func (c *Client) CreateMetadataRefresh(
	ctx context.Context,
	l1signer L1Signer,
	createMetadataRefreshRequest *api.CreateMetadataRefreshRequest,
) (*api.CreateMetadataRefreshResponse, error)

CreateMetadataRefresh Creates a metadata refresh

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1signer Ethereum signer used for ownership authentication. @param createMetadataRefreshRequest The request struct with all the params. @return CreateMetadataRefreshResponse

func (*Client) CreateOrder

func (c *Client) CreateOrder(ctx context.Context,
	l1signer L1Signer,
	l2signer L2Signer,
	request *api.GetSignableOrderRequest,
) (*api.CreateOrderResponse, error)

CreateOrder will list the given asset for sale on the marketplace.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1Signer Ethereum signer to sign message. @param l2signer Stark signer to sign the payload hash. @param request The request struct with all the params. @return CreateOrderResponse

func (*Client) CreateProject

func (c *Client) CreateProject(
	ctx context.Context,
	l1signer L1Signer,
	projectName, companyName, contactEmail string,
) (*api.CreateProjectResponse, error)

CreateProject Creates a new project

In order to create a collection of NFTs, you must first register a project as the creator of the collection. A project is an administrative level entity that is associated with an owner address, i.e. the address of the Ethereum wallet used to register a user account. Only the project owner will be authorized to perform administrative tasks such as creating and updating collections and metadata schema.

@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param l1signer Ethereum signer used for ownership authentication. @param projectName Project name @param companyName Company name to whom this project belongs to. @param contactEmail Contact email for this project. @return CreateProjectResponse

func (*Client) CreateTrade

func (c *Client) CreateTrade(
	ctx context.Context,
	l1signer L1Signer,
	l2signer L2Signer,
	request api.GetSignableTradeRequest,
) (*api.CreateTradeResponse, error)

CreateTrade submits a matched order to the CreateTrade endpoint. https://docs.x.immutable.com/reference#/operations/createTrade

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1Signer Ethereum signer to sign message. @param l2signer Stark signer to sign the payload hash. @param request The request struct with all the params. @return CreateTradeResponse

func (*Client) GetAsset

func (c *Client) GetAsset(ctx context.Context, tokenAddress, tokenID string, includeFees *bool) (*api.Asset, error)

GetAsset Get details of an asset

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param tokenAddress Address of the ERC721 contract @param tokenID Either ERC721 token ID or internal IMX ID @param includeFees optional param. @return Asset

func (*Client) GetBalance

func (c *Client) GetBalance(ctx context.Context, owner, tokenAddress string) (*api.Balance, error)

GetBalance Fetches the token balances of the user

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param owner Address of the owner/user @param tokenAddress Token address @return Balance

func (*Client) GetCollection

func (c *Client) GetCollection(ctx context.Context, collectionContractAddress string) (*api.Collection, error)

GetCollection Get details of a collection at the given address

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param collectionContractAddress Collection contract address @return Collection

func (*Client) GetDeposit

func (c *Client) GetDeposit(ctx context.Context, id string) (*api.Deposit, error)

GetDeposit Gets details of a deposit with the given ID

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param id Deposit Id @return Deposit

func (*Client) GetMetadataRefreshErrors

func (c *Client) GetMetadataRefreshErrors(
	ctx context.Context,
	l1signer L1Signer,
	refreshID string,
	pageSize *int32,
	cursor *string,
) (*api.GetMetadataRefreshErrorsResponse, error)

GetMetadataRefreshErrors Gets metadata refresh errors for the given refresh id

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1signer Ethereum signer used for ownership authentication. @param collectionAddress Collection contract address @param pageSize The page size of the result @param cursor The cursor @return GetMetadataRefreshes

func (*Client) GetMetadataRefreshResults

func (c *Client) GetMetadataRefreshResults(
	ctx context.Context,
	l1signer L1Signer,
	refreshID string,
) (*api.GetMetadataRefreshResponse, error)

GetMetadataRefreshResults Gets metadata refresh results for the given refresh id

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1signer Ethereum signer used for ownership authentication. @param collectionAddress Collection contract address @param pageSize The page size of the result @param cursor The cursor @return GetMetadataRefreshes

func (*Client) GetMetadataSchema

func (c *Client) GetMetadataSchema(ctx context.Context, collectionContractAddress string) ([]api.MetadataSchemaProperty, error)

GetMetadataSchema Gets collection metadata schema

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param collectionContractAddress Collection contract address @return []MetadataSchemaProperty

func (*Client) GetMint

func (c *Client) GetMint(ctx context.Context, id string) (*api.Mint, error)

GetMint Get details of a mint with the given ID

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param id Mint ID. This is the transaction_id returned from listMints @return ApiGetMintRequest

func (*Client) GetOrder

func (c *Client) GetOrder(ctx context.Context, id string) (*api.Order, error)

GetOrder Get details of an order with the given ID

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param id Order ID @return Order

func (*Client) GetProject

func (c *Client) GetProject(ctx context.Context, l1signer L1Signer, id string) (*api.Project, error)

GetProject Gets a project detail

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1signer Ethereum signer used for ownership authentication. @param id Project ID @return Balance

func (*Client) GetProjects

func (c *Client) GetProjects(
	ctx context.Context,
	l1signer L1Signer,
	pageSize *int32,
	cursor, orderBy, direction *string,
) (*api.GetProjectsResponse, error)

GetProjects Gets projects owned by given user

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1signer Ethereum signer used for ownership authentication. @param pageSize The page size of the result @param cursor The cursor @param orderBy The property to sort by @param direction Direction to sort (asc/desc) @return GetProjectsResponse

func (*Client) GetToken

func (c *Client) GetToken(ctx context.Context, id string) (*api.TokenDetails, error)

GetToken Get details of a token with the given ID

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param id Token ID @return TokenDetails

func (*Client) GetTrade

func (c *Client) GetTrade(ctx context.Context, id string) (*api.Trade, error)

GetTrade Get details of a trade with the given ID

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param id Trade ID @return Trade

func (*Client) GetTransfer

func (c *Client) GetTransfer(ctx context.Context, id string) (*api.Transfer, error)

GetTransfer Get details of a transfer with the given ID

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param id Transfer ID @return Transfer

func (*Client) GetUsers

func (c *Client) GetUsers(ctx context.Context, user string) (*api.GetUsersApiResponse, error)

GetUsers Get stark keys for a registered user. Can also be used to check if the user is registered or not when it returns an error.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param user User @return GetUsersApiResponse

func (*Client) GetWithdrawal

func (c *Client) GetWithdrawal(ctx context.Context, id string) (*api.Withdrawal, error)

GetWithdrawal Get details of a withdrawal with the given ID

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param id Withdrawal ID @return Withdrawal

func (*Client) IsRegisteredOnChain

func (c *Client) IsRegisteredOnChain(ctx context.Context, starkPublicKey string) (*bool, error)

IsRegisteredOnChain checks if the given public address is already registered on the onchain (L1 network).

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param starkPublicKey The stark wallet public address. @return true if registered or false. Nil on error.

func (*Client) ListAssets

func (c *Client) ListAssets(req *api.ApiListAssetsRequest) (*api.ListAssetsResponse, error)

ListAssets Get a list of assets

@param req the api request struct with all params populated to make the request @return ListAssetsResponse

func (*Client) ListBalances

func (c *Client) ListBalances(req *api.ApiListBalancesRequest) (*api.ListBalancesResponse, error)

ListBalances Get a list of balances for given user

@param req the api request struct with all params populated to make the request @return ListBalancesResponse

func (*Client) ListCollectionFilters

func (c *Client) ListCollectionFilters(req *api.ApiListCollectionFiltersRequest) (*api.CollectionFilter, error)

ListCollectionFilters Get a list of collection filters

@param req the api request struct with all params populated to make the request @return CollectionFilter

func (*Client) ListCollections

ListCollections Get a list of collections

@param req the api request struct with all params populated to make the request @return ListCollectionsResponse

func (*Client) ListDeposits

func (c *Client) ListDeposits(req *api.ApiListDepositsRequest) (*api.ListDepositsResponse, error)

ListDeposits Gets a list of deposits

@param req the api request struct with all params populated to make the request @return ListDepositsResponse

func (*Client) ListMetadataRefreshes

func (c *Client) ListMetadataRefreshes(
	ctx context.Context,
	l1signer L1Signer,
	collectionAddress *string,
	pageSize *int32,
	cursor *string,
) (*api.GetMetadataRefreshes, error)

ListMetadataRefreshes Gets a list of metadata refreshes

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1signer Ethereum signer used for ownership authentication. @param collectionAddress Collection contract address @param pageSize The page size of the result @param cursor The cursor @return GetMetadataRefreshes

func (*Client) ListMints

func (c *Client) ListMints(req *api.ApiListMintsRequest) (*api.ListMintsResponse, error)

ListMints Gets a list of mints

@param req the api request struct with all params populated to make the request @return ListMintsResponse

func (*Client) ListOrders

func (c *Client) ListOrders(req *api.ApiListOrdersRequest) (*api.ListOrdersResponse, error)

ListOrders Gets a list of orders

@param req the api request struct with all params populated to make the request @return ListOrdersResponse

func (*Client) ListTokens

func (c *Client) ListTokens(req *api.ApiListTokensRequest) (*api.ListTokensResponse, error)

ListTokens Gets a list of tokens

@param req the api request struct with all params populated to make the request @return ListTokensResponse

func (*Client) ListTrades

func (c *Client) ListTrades(req *api.ApiListTradesRequest) (*api.ListTradesResponse, error)

ListTrades Gets a list of trades

@param req the api request struct with all params populated to make the request @return ListTradesResponse

func (*Client) ListTransfers

func (c *Client) ListTransfers(req *api.ApiListTransfersRequest) (*api.ListTransfersResponse, error)

ListTransfers Gets a list of transfers

@param req the api request struct with all params populated to make the request @return ListTransfersResponse

func (*Client) ListWithdrawals

ListWithdrawals Gets a list of withdrawals

@param req the api request struct with all params populated to make the request @return ListWithdrawalsResponse

func (*Client) Mint

func (c *Client) Mint(
	ctx context.Context,
	l1signer L1Signer,
	unsignedMintRequest []UnsignedMintRequest,
) (*api.MintTokensResponse, error)

Mint assists in minting tokens to the given imx user.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1Signer Ethereum signer to sign message. @param unsignedMintRequest An array to UnsignedMintRequests to mint. @return MintTokensResponse

func (*Client) NewIERC20Contract

func (c *Client) NewIERC20Contract(ctx context.Context, address string) (*contracts.IERC20, error)

func (*Client) NewIERC721Contract

func (c *Client) NewIERC721Contract(ctx context.Context, address string) (*contracts.IERC721, error)

func (*Client) NewListAssetsRequest

func (c *Client) NewListAssetsRequest(ctx context.Context) api.ApiListAssetsRequest

NewListAssetsRequest Creates a new ApiListAssetsRequest object with required params.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @return ApiListAssetsRequest

func (*Client) NewListBalancesRequest

func (c *Client) NewListBalancesRequest(ctx context.Context, owner string) api.ApiListBalancesRequest

NewListBalancesRequest Creates a new ApiListBalancesRequest object with required params.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @return ApiListBalancesRequest

func (*Client) NewListCollectionFiltersRequest

func (c *Client) NewListCollectionFiltersRequest(ctx context.Context, collectionContractAddress string) api.ApiListCollectionFiltersRequest

NewListCollectionFiltersRequest Creates a new ApiListCollectionFiltersRequest object with required params.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param collectionContractAddress Collection contract address @return ApiListCollectionFiltersRequest

func (*Client) NewListCollectionsRequest

func (c *Client) NewListCollectionsRequest(ctx context.Context) api.ApiListCollectionsRequest

NewListCollectionsRequest Creates a new ApiListCollectionsRequest object with required params.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @return ApiListCollectionsRequest

func (*Client) NewListDepositsRequest

func (c *Client) NewListDepositsRequest(ctx context.Context) api.ApiListDepositsRequest

NewListDepositsRequest Creates a new ApiListDepositsRequest object with required params.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @return ApiListDepositsRequest

func (*Client) NewListMintsRequest

func (c *Client) NewListMintsRequest(ctx context.Context) api.ApiListMintsRequest

NewListMintsRequest Creates a new ApiListMintsRequest object with required params.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @return ApiListMintsRequest

func (*Client) NewListOrdersRequest

func (c *Client) NewListOrdersRequest(ctx context.Context) api.ApiListOrdersRequest

NewListOrdersRequest Creates a new ApiListOrdersRequest object with required params.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @return ApiListOrdersRequest

func (*Client) NewListTokensRequest

func (c *Client) NewListTokensRequest(ctx context.Context) api.ApiListTokensRequest

NewListTokensRequest Creates a new ApiListTokensRequest object with required params.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @return ApiListTokensRequest

func (*Client) NewListTradesRequest

func (c *Client) NewListTradesRequest(ctx context.Context) api.ApiListTradesRequest

NewListTradesRequest Creates a new ApiListTradesRequest object with required params.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @return ApiListTradesRequest

func (*Client) NewListTransfersRequest

func (c *Client) NewListTransfersRequest(ctx context.Context) api.ApiListTransfersRequest

NewListTransfersRequest Creates a new ApiListTransfersRequest object with required params.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @return ApiListTransfersRequest

func (*Client) NewListWithdrawalsRequest

func (c *Client) NewListWithdrawalsRequest(ctx context.Context) api.ApiListWithdrawalsRequest

NewListWithdrawalsRequest Creates a new ApiListWithdrawalsRequest object with required params.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @return ApiListWithdrawalsRequest

func (*Client) PrepareWithdrawal

func (c *Client) PrepareWithdrawal(
	ctx context.Context,
	l1signer L1Signer,
	l2signer L2Signer,
	request api.GetSignableWithdrawalRequest,
) (*api.CreateWithdrawalResponse, error)

PrepareWithdrawal submits a withdrawal request for ETH, ERC20 and ERC721 tokens to be included in the generation and submission of the next batch. Upon batch confirmation (on-chain state update), the asset is available to be withdrawn by the initial owner/originator of the asset.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1Signer Ethereum signer to sign message. @param l2signer Stark signer to sign the payload hash. @param request The request struct with all the params. @return CreateWithdrawalResponse

func (*Client) RegisterOffchain

func (c *Client) RegisterOffchain(ctx context.Context,
	l1signer L1Signer,
	l2signer L2Signer,
	userEmail string,
) (*api.RegisterUserResponse, error)

RegisterOffchain performs off chain user registration i.e, on the L2 network.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1Signer Ethereum signer to sign message. @param l2signer Stark signer to sign the payload hash. @param userEmail A valid user email. @return RegisterUserResponse

func (*Client) Transfer

func (c *Client) Transfer(
	ctx context.Context,
	l1signer L1Signer,
	l2signer L2Signer,
	request api.GetSignableTransferRequestV1,
) (*api.CreateTransferResponseV1, error)

Transfer transfers the request's models.SignableToken from Sender's imx account to Receiver's imx account.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1Signer Ethereum signer to sign message. @param l2signer Stark signer to sign the payload hash. @param request The request struct with all the params. @return CreateTransferResponseV1

func (*Client) UpdateCollection

func (c *Client) UpdateCollection(
	ctx context.Context,
	l1signer L1Signer,
	contractAddress string,
	updateCollectionRequest *api.UpdateCollectionRequest,
) (*api.Collection, error)

UpdateCollection Updates an existing collection

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1signer Ethereum signer used for ownership authentication. @param contractAddress Collection contract address @param updateCollectionRequest The request struct with all the params. @return Collection

func (*Client) UpdateMetadataSchemaByName

func (c *Client) UpdateMetadataSchemaByName(
	ctx context.Context,
	l1signer L1Signer,
	contractAddress, metadataSchemaName string,
	metadataSchemaRequest api.MetadataSchemaRequest,
) (*api.SuccessResponse, error)

UpdateMetadataSchemaByName Update metadata schema by name

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param l1signer Ethereum signer used for ownership authentication. @param contractAddress Collection contract address @param metadataSchemaName Metadata schema name @param metadataSchemaRequest The request struct with all the params. @return SuccessResponse

type Config

type Config struct {
	AlchemyAPIKey string
	APIConfig     *api.Configuration
	Environment
}

Config is used to initialise NewClient object.

type ERC20Deposit

type ERC20Deposit struct {
	Amount       string
	TokenAddress string
}

ERC20Deposit implements TokenDeposit. Used to deposit ERC20 Tokens.

func NewERC20Deposit

func NewERC20Deposit(unDecimalisedAmount uint64, tokenAddress string) *ERC20Deposit

NewERC20Deposit instantiates a new ERC20Deposit object with given amount and tokenAddress.

func (*ERC20Deposit) Deposit

func (d *ERC20Deposit) Deposit(ctx context.Context, c *Client, l1signer L1Signer, overrides *bind.TransactOpts) (*types.Transaction, error)

Deposit performs the deposit workflow on the ERC20Deposit.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param c Client object from interface.go used to make API calls. @param l1Signer Ethereum signer to sign message. @param overrides Optional transaction params that overrides the default values. @return Transaction

type ERC20Withdrawal

type ERC20Withdrawal struct {
	TokenAddress string
}

ERC20Withdrawal implements TokenWithdrawal. Used for withdrawal of ERC20 Tokens.

func NewERC20Withdrawal

func NewERC20Withdrawal(tokenAddress string) *ERC20Withdrawal

NewERC20Withdrawal instantiates a new ERC20Withdrawal object with the given tokenAddress.

func (*ERC20Withdrawal) CompleteWithdrawal

func (w *ERC20Withdrawal) CompleteWithdrawal(
	ctx context.Context,
	c *Client,
	l1signer L1Signer,
	starkKeyHex string,
	overrides *bind.TransactOpts,
) (*types.Transaction, error)

CompleteWithdrawal performs the complete withdrawal workflow for ERC20 tokens.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param c Client object from interface.go used to make API calls. @param l1Signer Ethereum signer to sign message. @param starkKeyHex Stark key string in hex decimal format. @param overrides Optional transaction params that overrides the default values. @return Transaction

type ERC721Deposit

type ERC721Deposit struct {
	TokenID      string
	TokenAddress string
}

ERC721Deposit implements TokenDeposit. Used to deposit ERC721 Tokens.

func NewERC721Deposit

func NewERC721Deposit(tokenID, tokenAddress string) *ERC721Deposit

NewERC721Deposit instantiates a new ERC721Deposit object with given tokenID and tokenAddress.

func (*ERC721Deposit) Deposit

func (d *ERC721Deposit) Deposit(ctx context.Context, c *Client, l1signer L1Signer, overrides *bind.TransactOpts) (*types.Transaction, error)

Deposit performs the deposit workflow on the ERC721Deposit.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param c Client object from interface.go used to make API calls. @param l1Signer Ethereum signer to sign message. @param overrides Optional transaction params that overrides the default values. @return Transaction

type ERC721Withdrawal

type ERC721Withdrawal struct {
	TokenID      string
	TokenAddress string
}

ERC721Withdrawal implements TokenWithdrawal. Used for withdrawal of ERC721 Tokens.

func NewERC721Withdrawal

func NewERC721Withdrawal(tokenID, tokenAddress string) *ERC721Withdrawal

NewERC721Withdrawal instantiates a new ERC721Withdrawal object with the given tokenId and tokenAddress.

func (*ERC721Withdrawal) CompleteWithdrawal

func (w *ERC721Withdrawal) CompleteWithdrawal(
	ctx context.Context,
	c *Client,
	l1signer L1Signer,
	starkKeyHex string,
	overrides *bind.TransactOpts,
) (*types.Transaction, error)

CompleteWithdrawal performs the completion step of the withdrawal process for ERC721 token.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param c Client object from interface.go used to make API calls. @param l1Signer Ethereum signer to sign message. @param starkKeyHex Stark key string in hex decimal format. @param overrides Optional transaction params that overrides the default values. @return Transaction

type ETHDeposit

type ETHDeposit struct {
	Amount string
}

ETHDeposit implements TokenDeposit. Used to deposit Eth Tokens.

func NewETHDeposit

func NewETHDeposit(amount Wei) *ETHDeposit

NewETHDeposit instantiates a new ETHDeposit object with the given amount.

func (*ETHDeposit) Deposit

func (d *ETHDeposit) Deposit(ctx context.Context, c *Client, l1signer L1Signer, overrides *bind.TransactOpts) (*types.Transaction, error)

Deposit performs the deposit workflow on the ETHDeposit.

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param c Client object from interface.go used to make API calls. @param l1Signer Ethereum signer to sign message. @param overrides Optional transaction params that overrides the default values. @return Transaction

type Environment

type Environment struct {
	BaseAPIPath                 string
	EthereumRPC                 string
	RegistrationContractAddress string
	CoreContractAddress         string
	ChainID                     *big.Int
}

Environment holds Ethereum network and contract address information.

type EthWithdrawal

type EthWithdrawal struct {
}

ERC20Withdrawal implements TokenWithdrawal. Used for withdrawal of ETh Tokens.

func NewEthWithdrawal

func NewEthWithdrawal() *EthWithdrawal

NewEthWithdrawal instantiates a new EthWithdrawal object with the given tokenAddress.

func (*EthWithdrawal) CompleteWithdrawal

func (w *EthWithdrawal) CompleteWithdrawal(
	ctx context.Context,
	c *Client,
	l1signer L1Signer,
	starkKeyHex string,
	overrides *bind.TransactOpts,
) (*types.Transaction, error)

CompleteWithdrawal performs the complete withdrawal workflow for ETH

@param ctx context.Context - for cancellation, deadlines, tracing, etc or context.Background(). @param c Client object from interface.go used to make API calls. @param l1Signer Ethereum signer to sign message. @param starkKeyHex Stark key string in hex decimal format. @param overrides Optional transaction params that overrides the default values. @return Transaction

type IMXError

type IMXError struct {
	HTTPStatusCode int // e.g. 400
	RequestURL     string
	api.APIError
}

IMXError struct contains the details of the error for the API request. For more information about the API error codes, see https://docs.x.immutable.com/docs/error-codes/

func (*IMXError) Error

func (e *IMXError) Error() string

type L1Signer

type L1Signer interface {
	SignMessage(message string) ([]byte, error)
	SignTx(tx *types.Transaction) (*types.Transaction, error)
	GetAddress() string
}

L1Signer interface to implement signing functionality using ethereum wallet key.

type L2Signer

type L2Signer interface {
	SignMessage(message string) (string, error)
	GetAddress() string
}

L1Signer interface to implement signing functionality using Stark wallet key.

type MintFee

type MintFee struct {
	Recipient  string  `json:"recipient"`
	Percentage float32 `json:"percentage" validate:"max=100,gt=0"`
}

type MintableTokenData

type MintableTokenData struct {
	ID        string    `json:"id"`
	Blueprint *string   `json:"blueprint"`
	Royalties []MintFee `json:"royalties,omitempty"` // token-level overridable fees (optional)
}

type TokenDeposit

type TokenDeposit interface {
	Deposit(ctx context.Context, c *Client, l1signer L1Signer, overrides *bind.TransactOpts) (*types.Transaction, error)
}

type TokenWithdrawal

type TokenWithdrawal interface {
	CompleteWithdrawal(ctx context.Context, c *Client, l1signer L1Signer, starkPublicKey string, overrides *bind.TransactOpts) (*types.Transaction, error)
}

type UnsignedMintRequest

type UnsignedMintRequest struct {
	ContractAddress string    `json:"contract_address" validate:"required,eth_addr"`
	Royalties       []MintFee `json:"royalties,omitempty" validate:"dive"` // contract-level (optional)
	Users           []User    `json:"users" validate:"required,dive,min=1"`
	AuthSignature   string    `json:"auth_signature" validate:"required"`
}

type User

type User struct {
	User   string              `json:"ether_key"`
	Tokens []MintableTokenData `json:"tokens"`
}

type Wei

type Wei = uint64

Wei type used to specify the token amounts.

For example, wei = Wei(1) gwei = Wei(1000000000) eth = Wei(1000000000000000000)

Directories

Path Synopsis
examples module
signers
stark
Package stark implements utilities for generating imx.L2Signer
Package stark implements utilities for generating imx.L2Signer
internal

Jump to

Keyboard shortcuts

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