feat(RemoteDestructedAmount): Add RemoteDestructedAmount function

Issue #1182
This commit is contained in:
Michal Iskierko 2023-07-13 10:57:37 +02:00 committed by Michał Iskierko
parent 6f849bc6c6
commit 1592d2a079
1 changed files with 26 additions and 13 deletions

View File

@ -332,6 +332,32 @@ func (api *API) EstimateMintAssets(ctx context.Context, chainID uint64, contract
return api.estimateMethod(ctx, chainID, contractAddress, "mintTo", usersAddresses, amountsList) return api.estimateMethod(ctx, chainID, contractAddress, "mintTo", usersAddresses, amountsList)
} }
// This is only ERC721 function
func (api *API) RemoteDestructedAmount(ctx context.Context, chainID uint64, contractAddress string) (*bigint.BigInt, error) {
callOpts := &bind.CallOpts{Context: ctx, Pending: false}
contractInst, err := api.newCollectiblesInstance(chainID, contractAddress)
if err != nil {
return nil, err
}
// total supply = airdropped only (w/o burnt)
totalSupply, err := contractInst.TotalSupply(callOpts)
if err != nil {
return nil, err
}
// minted = all created tokens (airdropped and remotely destructed)
mintedCount, err := contractInst.MintedCount(callOpts)
if err != nil {
return nil, err
}
var res = new(big.Int)
res.Sub(mintedCount, totalSupply)
return &bigint.BigInt{Int: res}, nil
}
// This is only ERC721 function // This is only ERC721 function
func (api *API) RemoteBurn(ctx context.Context, chainID uint64, contractAddress string, txArgs transactions.SendTxArgs, password string, tokenIds []*bigint.BigInt) (string, error) { func (api *API) RemoteBurn(ctx context.Context, chainID uint64, contractAddress string, txArgs transactions.SendTxArgs, password string, tokenIds []*bigint.BigInt) (string, error) {
err := api.validateTokens(tokenIds) err := api.validateTokens(tokenIds)
@ -411,19 +437,6 @@ func (api *API) ContractOwner(ctx context.Context, chainID uint64, contractAddre
return "", fmt.Errorf("unknown token type: %v", tokenType) return "", fmt.Errorf("unknown token type: %v", tokenType)
} }
func (api *API) MintedCount(ctx context.Context, chainID uint64, contractAddress string) (*big.Int, error) {
callOpts := &bind.CallOpts{Context: ctx, Pending: false}
contractInst, err := api.newCollectiblesInstance(chainID, contractAddress)
if err != nil {
return nil, err
}
mintedCount, err := contractInst.MintedCount(callOpts)
if err != nil {
return nil, err
}
return mintedCount, nil
}
func (api *API) RemainingSupply(ctx context.Context, chainID uint64, contractAddress string) (*bigint.BigInt, error) { func (api *API) RemainingSupply(ctx context.Context, chainID uint64, contractAddress string) (*bigint.BigInt, error) {
tokenType, err := api.db.GetTokenType(chainID, contractAddress) tokenType, err := api.db.GetTokenType(chainID, contractAddress)
if err != nil { if err != nil {