add test for balanceof api
MODIFY
package.json
package.json
"scripts": {
"clean": "rimraf lib dist",
"build:webpack": "npm run lint && webpack",
+ "build:pack": "npm run build:dev && npm pack",
"build:dev": "cross-env NODE_ENV=development npm run build:webpack",
"build:prod": "cross-env NODE_ENV=production npm run build:webpack",
"deploy": "npm run build:dev && npm run build:prod",

MODIFY
src/common/SDKClient.ts
src/common/SDKClient.ts
@@ -25,8 +25,8 @@ export default class SDKClient extends ContractsBase {
this.web3Client.wallet = _wallet
}
- async balanceOfERC20(userAddress: address, token: address, options?: SendOptions) {
- if (options && (!token || !userAddress)) {
+ async balanceOfERC20(userAddress: address, token: address, options: SendOptions = {}) {
+ if (!token || !userAddress) {
throw new Error('token address or user address is missing')
}
@@ -36,7 +36,7 @@ export default class SDKClient extends ContractsBase {
return balance
}
- async balanceOfERC721(userAddress: address, token: address, options?: SendOptions) {
+ async balanceOfERC721(userAddress: address, token: address, options: SendOptions = {}) {
if (options && (!token || !userAddress)) {
throw new Error('token address or user address is missing')
}

MODIFY
test/package-lock.json
test/package-lock.json
},
"@maticnetwork/maticjs": {
"version": "file:../maticnetwork-maticjs-2.0.43.tgz",
- "integrity": "sha512-vhgoTkw5V3xGBTvgy9Tm8jQMg4+LNB1DlxW7Y05Takr7xF3HjPlqKxJBOKocKXS3+1oY5tTt4tdjSutoUMr5Aw==",
+ "integrity": "sha512-t4WdPICYq9SSJl/9jxMKjGrbUbdp4uFQjGVTsMRdI8psUoJzweeS8i3ruDDYjG1iFMuqIv2IcnHURtpk2meuLA==",
"requires": {
"@maticnetwork/meta": "^2.4.13",
"axios": "^0.21.1",

MODIFY
test/specs/plasma_bridge.ts
test/specs/plasma_bridge.ts
import Matic from '@maticnetwork/maticjs'
import assert from 'assert'
+import { expect } from 'chai'
const env = process.env
const from = env.user1_address
@@ -26,7 +27,13 @@ describe('Plasma Bridge', () => {
assert.ok(matic)
})
- it('plasma: deposit ether', async () => {
+ it('balanceOfERC20', async () => {
+ const balance = await matic.balanceOfERC20(from, tokenERC20)
+ console.log('balance', balance)
+ expect(balance).not.equal(null)
+ })
+
+ it('deposit ether', async () => {
let response = await matic.depositEther(amount, {
from,
gasPrice: '200000000000',
@@ -35,7 +42,7 @@ describe('Plasma Bridge', () => {
assert.ok(response)
}).timeout(30000)
- it('plasma : approve ERC20', async () => {
+ it('approve ERC20', async () => {
let response = await matic.approveERC20TokensForDeposit(tokenERC20, amount, {
from,
gasPrice: '200000000000',
@@ -45,7 +52,7 @@ describe('Plasma Bridge', () => {
assert.ok(response)
})
- it('plasma: deposit ERC20', async () => {
+ it('deposit ERC20', async () => {
let response = await matic.depositERC20ForUser(tokenERC20, from, amount, {
from,
gasPrice: '200000000000',
@@ -54,7 +61,13 @@ describe('Plasma Bridge', () => {
assert.ok(response)
}).timeout(20000)
- it('plasma: deposit ERC721 successfully', async () => {
+ it('balanceOfERC721', async () => {
+ const balance = await matic.balanceOfERC721(from, tokenERC721)
+ console.log('balance', balance)
+ expect(balance).not.equal(null)
+ })
+
+ it('deposit ERC721 successfully', async () => {
let response = await matic.safeDepositERC721Tokens(tokenERC721, tokenId721 as any, {
from,
gasPrice: '10000000000',
@@ -62,7 +75,7 @@ describe('Plasma Bridge', () => {
assert.ok(response)
}).timeout(20000)
- it('plasma: transfer ERC20 successfully', async () => {
+ it('transfer ERC20 successfully', async () => {
let response = await matic.transferERC20Tokens(tokenERC20, recipient, amount, {
from,
gas: 100000,
@@ -72,7 +85,7 @@ describe('Plasma Bridge', () => {
assert.ok(response)
}).timeout(30000)
- it('plasma: withdraw: initate burn ERC20', async () => {
+ it('withdraw: initate burn ERC20', async () => {
let response = await matic.startWithdraw(tokenERC20, amount, {
from,
gas: 100000,
@@ -88,7 +101,7 @@ describe('Plasma Bridge', () => {
assert.ok(response)
}).timeout(30000)
- it('plasma: exit: ERC20', async () => {
+ it('exit ERC20', async () => {
let response = await matic.processExits(rootTokenAddressERC20, {
from,
gas: 100000,

add test for balanceof api