Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/bridge/bridgedHrc20Token/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class BridgedHRC20Token extends EthBaseContract {
return this.write('transferFrom', [from, to, amount], txOptions)
}

public async mint(account: string, amount: BigNumberish, txOptions?: CallOverrides): Promise<TransactionReceipt> {
return this.write('mint', [account, amount], txOptions)
}

public async symbol(): Promise<string> {
return this.read<string>('symbol')
}
Expand Down
35 changes: 35 additions & 0 deletions src/tests/bridged-hrc20-token.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Wallet } from '@ethersproject/wallet'
import { expect } from 'chai'
import sinon from 'sinon'
import { BridgedHRC20Token } from '../bridge'

const CONTRACT_ADDRESS = '0x0000000000000000000000000000000000000001'
const PRIVATE_KEY = '0x0123456789012345678901234567890123456789012345678901234567890123'
const ACCOUNT = '0x0000000000000000000000000000000000000002'
const AMOUNT = '1000000000000000000'
const TX_OPTIONS = { gasLimit: 21000 }
const TX_RECEIPT = { transactionHash: '0xfakeHash' } as any

describe('BridgedHRC20Token', () => {
let token: BridgedHRC20Token

beforeEach(() => {
token = new BridgedHRC20Token(CONTRACT_ADDRESS, new Wallet(PRIVATE_KEY))
})

afterEach(() => {
sinon.restore()
})

describe('mint', () => {
it('should mint the provided amount to the account', async () => {
const stub = sinon.stub(token, 'write')
stub.withArgs('mint', [ACCOUNT, AMOUNT], TX_OPTIONS).resolves(TX_RECEIPT)

const receipt = await token.mint(ACCOUNT, AMOUNT, TX_OPTIONS)

expect(stub.calledOnce).to.be.true
expect(receipt).to.equal(TX_RECEIPT)
})
})
})