add config for erc721Predicate, erc20Predicate
MODIFY
src/interfaces/plasma_client_config.ts
src/interfaces/plasma_client_config.ts
@@ -7,4 +7,5 @@ export interface IPlasmaClientConfig extends IBaseClientConfig {
registry?: string;
rootChain?: string;
erc20Predicate?: string;
+ erc721Predicate?: string;
}
\ No newline at end of file

MODIFY
src/plasma/erc20.ts
src/plasma/erc20.ts
@@ -22,7 +22,7 @@ export class ERC20 extends PlasmaToken {
getPredicate() {
return this['getPredicate_'](
- "erc20Predicate", "ERC20Predicate"
+ "erc20Predicate", "ERC20Predicate", this.client.config.erc20Predicate
);
}

MODIFY
src/plasma/erc721.ts
src/plasma/erc721.ts
@@ -94,7 +94,11 @@ export class ERC721 extends PlasmaToken {
}
getPredicate() {
- return this['getPredicate_']("erc721Predicate", "ERC721Predicate");
+ return this.getPredicate_(
+ "erc721Predicate",
+ "ERC721Predicate",
+ this.client.config.erc721Predicate
+ );
}

MODIFY
src/plasma/plasma_token.ts
src/plasma/plasma_token.ts
@@ -16,18 +16,24 @@ export class PlasmaToken extends BaseToken {
super(contractParam_, client);
}
- protected getPredicate_(methodName: string, contractName: string): Promise<BaseContract> {
+ protected getPredicate_(methodName: string, contractName: string, predicateAddress: string): Promise<BaseContract> {
if (this.predicate_) {
return promiseResolve(this.predicate_);
}
+ const getPredicateAddress = () => {
+ if (predicateAddress) {
+ return promiseResolve<string>(predicateAddress);
+ }
return this.contracts_.registry.getContract().then(contract => {
return contract.method(
methodName
).read<string>();
- }).then(predicateAddress => {
+ });
+ };
+ getPredicateAddress().then(address => {
return new ErcPredicate(
this.client,
- predicateAddress,
+ address,
contractName
).getContract();
}).then(contract => {

add config for erc721Predicate, erc20Predicate