Skip to content

Commit

Permalink
Merge pull request #22 from Mintbase/batch-burn-added
Browse files Browse the repository at this point in the history
Add Burn to the API
  • Loading branch information
Nate Geier authored Apr 20, 2021
2 parents f10915f + 695021e commit fb230f6
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,32 @@ export class Wallet {
await contract.batch_transfer({ token_ids: tokenIds }, MAX_GAS, YOCTO)
}

/**
* Burn one or more tokens.
* @param contractName The contract name to burn tokens from.
* @param tokenIds The mapping of burns, defined by: [[accountName1, tokenId1], [accountName2, tokenId2]]
*/

// TODO: need more checks on the tokenIds
public async burn(tokenIds: number[], contractName: string): Promise<void> {
const account = this.activeWallet?.account()
const accountId = this.activeWallet?.account().accountId
const MAX_GAS = new BN('300000000000000')
const YOCTO = new BN('1')

if (!account || !accountId) throw new Error('Account is undefined.')

if (!contractName) throw new Error('No contract was provided.')

const contract = new Contract(account, contractName, {
viewMethods: STORE_CONTRACT_VIEW_METHODS,
changeMethods: STORE_CONTRACT_CALL_METHODS,
})

// @ts-ignore: method does not exist on Contract type
await contract.batch_burn({ token_ids: tokenIds }, MAX_GAS, YOCTO)
}

/**
* List an item for sale in the market.
* @param tokenId The token id list.
Expand Down

0 comments on commit fb230f6

Please sign in to comment.