new: approve mintable erc1155
MODIFY
package-lock.json
package-lock.json
}
},
"@maticnetwork/meta": {
- "version": "2.4.6",
- "resolved": "https://registry.npmjs.org/@maticnetwork/meta/-/meta-2.4.6.tgz",
- "integrity": "sha512-4tjN3lilEYkMfb+GEczR+c1/gGz2z2lXkCEsg6z1Kz6BWLFcnBCYxLjV8alkay4yJrlsTHs6Oj2CE/mAm3bINg=="
+ "version": "2.4.13",
+ "resolved": "https://registry.npmjs.org/@maticnetwork/meta/-/meta-2.4.13.tgz",
+ "integrity": "sha512-Z1+gh7dQTbq6b9TI8oGq/B0qOqx7Suj/FQeAuR17j9WeLiHWugd5+eBKuK14NYrRff20yb1E7px0aIt1FnCUGw=="
},
"@samverschueren/stream-to-observable": {
"version": "0.3.0",

MODIFY
package.json
package.json
},
"homepage": "https://github.com/maticnetwork/matic.js#readme",
"dependencies": {
- "@maticnetwork/meta": "^2.4.6",
+ "@maticnetwork/meta": "^2.4.13",
"@types/bluebird": "^3.5.29",
"@types/bn.js": "4.11.5",
"@types/web3": "1.0.19",

MODIFY
src/index.ts
src/index.ts
@@ -235,6 +235,13 @@ export class MaticPOSClient extends SDKClient {
return this.posRootChainManager.approveERC1155(rootToken, options)
}
+ approveMintableERC1155ForDeposit(rootToken: address, options?: SendOptions) {
+ if (options && (!options.from || !rootToken)) {
+ throw new Error('options.from or rootToken is missing')
+ }
+ return this.posRootChainManager.approveMintableERC1155(rootToken, options)
+ }
+
depositSingleERC1155ForUser(
rootToken: address,
user: address,

MODIFY
src/root/POSRootChainManager.ts
src/root/POSRootChainManager.ts
@@ -24,6 +24,7 @@ export default class POSRootChainManager extends ContractsBase {
private erc20Predicate: address | null
private erc721Predicate: address | null
private erc1155Predicate: address | null
+ private erc1155MintablePredicate: address | null
private rootTunnelContractAbi: any
private formatUint256 = this.encode
@@ -39,6 +40,8 @@ export default class POSRootChainManager extends ContractsBase {
this.erc20Predicate = options.posERC20Predicate || options.network.Main.POSContracts.ERC20PredicateProxy
this.erc721Predicate = options.posERC721Predicate || options.network.Main.POSContracts.ERC721PredicateProxy
this.erc1155Predicate = options.posERC1155Predicate || options.network.Main.POSContracts.ERC1155PredicateProxy
+ this.erc1155MintablePredicate =
+ options.posMintableERC1155Predicate || options.network.Main.POSContracts.MintableERC1155PredicateProxy
}
async depositEtherForUser(amount: BN | string, user: address, options: SendOptions = {}) {
@@ -325,6 +328,21 @@ export default class POSRootChainManager extends ContractsBase {
return this.web3Client.send(txObject, web3Options, options)
}
+ async approveMintableERC1155(rootToken: address, options?: SendOptions) {
+ if (!this.erc1155Predicate) {
+ throw new Error('posERC1155Predicate address not found. Set it while constructing MaticPOSClient.')
+ }
+ const txObject = this.getPOSERC1155TokenContract(rootToken, true).methods.setApprovalForAll(
+ this.erc1155MintablePredicate,
+ true
+ )
+ const web3Options = await this.web3Client.fillOptions(txObject, true /* onRootChain */, options)
+ if (web3Options.encodeAbi) {
+ return Object.assign(web3Options, { data: txObject.encodeABI(), to: rootToken })
+ }
+ return this.web3Client.send(txObject, web3Options, options)
+ }
+
async depositSingleERC1155ForUser(
rootToken: address,
tokenId: BN | string,

MODIFY
src/types/Common.ts
src/types/Common.ts
@@ -37,4 +37,5 @@ export declare interface MaticClientInitializationOptions {
posERC20Predicate?: string
posERC721Predicate?: string
posERC1155Predicate?: string
+ posMintableERC1155Predicate?: string
}

new: approve mintable erc1155