arrow_up: meta, :arrow_up: mumbai
MODIFY
examples/utils.js
examples/utils.js
@@ -6,7 +6,7 @@ const Matic = require('../lib/index').default
const SCALING_FACTOR = new bn(10).pow(new bn(18))
-async function getMaticClient(_network = 'testnet', _version = 'cs-2008') {
+async function getMaticClient(_network = 'testnet', _version = 'mumbai') {
const network = new Network(_network, _version)
const { from } = getAccount()
const matic = new Matic({

MODIFY
package-lock.json
package-lock.json
}
},
"@maticnetwork/meta": {
- "version": "github:maticnetwork/static#6fcc2eee5dd3fd4ab7ca0331aa5a09b604a0214d",
- "from": "github:maticnetwork/static#6fcc2eee5dd3fd4ab7ca0331aa5a09b604a0214d"
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@maticnetwork/meta/-/meta-2.0.0.tgz",
+ "integrity": "sha512-sZlBodVQaUXnOF5e+qPfApW8FCgYPWdiMpJ9iuTLMeN4Vzl4Ny+DhKDTxzf/mDDV1NaJ+P0kQ8PykjD3aLNlhw=="
},
"@openzeppelin/contracts": {
"version": "3.0.1",

MODIFY
package.json
package.json
},
"homepage": "https://github.com/maticnetwork/matic.js#readme",
"dependencies": {
- "@maticnetwork/meta": "github:maticnetwork/static#6fcc2eee5dd3fd4ab7ca0331aa5a09b604a0214d",
+ "@maticnetwork/meta": "^2.0.0",
"@truffle/hdwallet-provider": "^1.0.35",
"@types/bluebird": "^3.5.29",
"@types/bn.js": "4.11.5",

MODIFY
src/common/SDKClient.ts
src/common/SDKClient.ts
import BN from 'bn.js'
+import Network from '@maticnetwork/meta/network'
import Web3Client from '../common/Web3Client'
import { address, SendOptions } from '../types/Common'
import ContractsBase from '../common/ContractsBase'
export default class SDKClient extends ContractsBase {
+ static initializeNetwork(network = 'testnet', version = 'mumbai') {
+ const _network = new Network(network, version)
+ if (!_network) throw new Error(`network ${network} - ${version} is not supported`)
+ return _network
+ }
+
constructor(options: any = {}) {
const web3Client = new Web3Client(
options.parentProvider || options.network.Main.RPC,

MODIFY
src/index.ts
src/index.ts
import BN from 'bn.js'
-import Network from '@maticnetwork/meta/network'
import DepositManager from './root/DepositManager'
import RootChain from './root/RootChain'
@@ -15,8 +14,12 @@ export class MaticPOSClient extends SDKClient {
private posRootChainManager: POSRootChainManager
constructor(options: any = {}) {
+ if (!options.rootChain) {
+ const network = SDKClient.initializeNetwork(options.network, options.version)
+ options.rootChain = network.Main.Contracts.RootChainProxy
+ }
super(options)
- this.rootChain = new RootChain(options.rootChain, this.web3Client)
+ this.rootChain = new RootChain(options, this.web3Client)
this.posRootChainManager = new POSRootChainManager(options.posRootChainManager, this.rootChain, this.web3Client)
}
@@ -75,15 +78,7 @@ export default class Matic extends SDKClient {
public static MaticPOSClient = MaticPOSClient // workaround for web compatibility
constructor(options: MaticClientInitializationOptions = {}) {
- let network
- if (options.network && options.version) {
- network = new Network(options.network, options.version)
- if (!network) throw new Error(`network ${options.network} - ${options.version} is not supported`)
- } else {
- // User provided the contract addresses in options object
- // We'll use latest network that this version of maticjs supports to pickup abis.
- network = new Network('testnet', 'cs-2008')
- }
+ const network = SDKClient.initializeNetwork(options.network, options.version)
// override contract addresses if they were provided during initialization
options = Object.assign(
{

:arrow_up: meta, :arrow_up: mumbai