new: getBalance method
ADD
src/plasma/erc721.ts
+import { BaseToken, Web3SideChainClient } from "../model";
+import BN from "bn.js";
+import { ITransactionConfig, ITransactionOption } from "../interfaces";
+import { formatAmount, IEventBusPromise, eventBusPromise, merge } from "../utils";
+import { createTransactionConfig } from "../utils/create_tx_config";
+import { DepositManager } from "./deposit_manager";
+
+export class ERC721 extends BaseToken {
+
+ constructor(
+ tokenAddress: string,
+ isParent: boolean,
+ client: Web3SideChainClient,
+ public depositManager: DepositManager
+ ) {
+ super({
+ isParent,
+ tokenAddress,
+ abi: client.getABI('ChildERC721')
+ }, client);
+ }
+
+ /**
+ * READ
+ * how many ERC721s are owned by this user
+ *
+ * @param userAddress
+ * @param option
+ */
+ getBalance(userAddress: string, option: ITransactionOption = {}) {
+ const contract = this.contract;
+ const method = contract.method(
+ "balanceOf",
+ userAddress
+ );
+
+ return createTransactionConfig(
+ {
+ txConfig: {},
+ defaultTxConfig: this.childDefaultConfig,
+ }).then(config => {
+ return method.read<string>(config);
+ });
+ }
+
+}

MODIFY
src/plasma/index.ts
src/plasma/index.ts
import { ERC20 } from "./erc20";
+import { ERC721 } from "./erc721";
import { Web3SideChainClient } from "../model";
import { IPlasmaClientConfig } from "../interfaces";
import { DepositManager } from "./deposit_manager";
@@ -21,6 +22,15 @@ export class PlasmaClient {
);
}
+ erc721(tokenAddress: string, isParent?: boolean) {
+ return new ERC721(
+ tokenAddress,
+ isParent,
+ this.client_,
+ this.depositManager
+ );
+ }
+
constructor(config: IPlasmaClientConfig) {
this.client_ = new Web3SideChainClient(config);

new: getBalance method