fix: use config object for node-example
MODIFY
.eslintrc.js
.eslintrc.js
@@ -7,6 +7,7 @@ module.exports = {
fetch: true,
require: true,
process: true,
+ module: true,
},
rules: {
'space-before-function-paren': ['error', 'never'],

ADD
examples/node/config.js
+module.exports = {
+ 'MATIC_PROVIDER': 'https://testnet.matic.network',
+ 'PARENT_PROVIDER': 'https://kovan.infura.io/matic',
+ 'ROOTCHAIN_ADDRESS': '0x24e01716a6ac34d5f2c4c082f553d86a557543a7',
+ 'SYNCER_URL': 'https://eth-syncer.api.matic.network/api/v1',
+ 'WATCHER_URL': 'https://eth-watcher.api.matic.network/api/v1',
+}

MODIFY
examples/node/deposit.js
examples/node/deposit.js
-const Matic = require('maticjs')
+const Matic = require('maticjs').default
+const config = require('./config')
-const maticProvider = 'https://testnet.matic.network'
-const parentProvider = 'https://kovan.infura.io/matic'
-const rootChainAddress = '0x24e01716a6ac34d5f2c4c082f553d86a557543a7'
-const syncerUrl = 'https://eth-syncer.api.matic.network/api/v1'
-const watcherUrl = 'https://eth-watcher.api.matic.network/api/v1'
-
-const token = '0xC4375B7De8af5a38a93548eb8453a498222C4fF2'
+const token = '0xC4375B7De8af5a38a93548eb8453a498222C4fF2' // test token address
const amount = '10000000000000000'
-const from = '0x6e0c217de3235f1d8a95605d10bcc1b36ff7996f'
+const from = '0x6e0c217de3235f1d8a95605d10bcc1b36ff7996f' // test user address
// Create object of Matic
const matic = new Matic({
- maticProvider,
- parentProvider,
- rootChainAddress,
- syncerUrl,
- watcherUrl,
+ maticProvider: config.MATIC_PROVIDER,
+ parentProvider: config.PARENT_PROVIDER,
+ rootChainAddress: config.ROOTCHAIN_ADDRESS,
+ syncerUrl: config.SYNCER_URL,
+ watcherUrl: config.WATCHER_URL,
})
matic.wallet = '<private-key>'

MODIFY
examples/node/index.js
examples/node/index.js
-const Matic = require('maticjs')
+const Matic = require('maticjs').default
+const config = require('./config')
-const maticProvider = 'https://testnet.matic.network'
-const parentProvider = 'https://kovan.infura.io/matic'
-const rootChainAddress = '0x24e01716a6ac34d5f2c4c082f553d86a557543a7'
-const syncerUrl = 'localhost:9001/api/v1'
-const watcherUrl = 'localhost:9000/api/v1'
-
-const token = '0xC4375B7De8af5a38a93548eb8453a498222C4fF2'
-const user = '0x7ed7f36694153ba6eff6ca6726b60f6e2bb17fcf'
+const token = '0xC4375B7De8af5a38a93548eb8453a498222C4fF2' // test token address
+const user = '0x7ed7f36694153ba6eff6ca6726b60f6e2bb17fcf' // test user address
const amount = '10000000000000000'
-const from = '0x6e0c217de3235f1d8a95605d10bcc1b36ff7996f'
+const from = '0x6e0c217de3235f1d8a95605d10bcc1b36ff7996f' // test user address
// Create object of Matic
const matic = new Matic({
- maticProvider,
- parentProvider,
- rootChainAddress,
- syncerUrl,
- watcherUrl,
+ maticProvider: config.MATIC_PROVIDER,
+ parentProvider: config.PARENT_PROVIDER,
+ rootChainAddress: config.ROOTCHAIN_ADDRESS,
+ syncerUrl: config.SYNCER_URL,
+ watcherUrl: config.WATCHER_URL,
})
matic.wallet = '<Private key>'

MODIFY
examples/node/package-lock.json
examples/node/package-lock.json
}
},
"@types/node": {
- "version": "10.11.7",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-10.11.7.tgz",
- "integrity": "sha512-yOxFfkN9xUFLyvWaeYj90mlqTJ41CsQzWKS3gXdOMOyPVacUsymejKxJ4/pMW7exouubuEeZLJawGgcNGYlTeg=="
+ "version": "10.12.0",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.0.tgz",
+ "integrity": "sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ=="
},
"abstract-leveldown": {
"version": "2.6.3",
"integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE="
},
"form-data": {
- "version": "2.3.2",
- "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
- "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
+ "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
"requires": {
"asynckit": "^0.4.0",
- "combined-stream": "1.0.6",
+ "combined-stream": "^1.0.6",
"mime-types": "^2.1.12"
- },
- "dependencies": {
- "combined-stream": {
- "version": "1.0.6",
- "resolved": "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
- "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
- "requires": {
- "delayed-stream": "~1.0.0"
- }
- }
}
},
"forwarded": {
},
"level-iterator-stream": {
"version": "1.3.1",
- "resolved": "https://registry.npmjs.org/level-iterator-stream/-/level-iterator-stream-1.3.1.tgz",
+ "resolved": "http://registry.npmjs.org/level-iterator-stream/-/level-iterator-stream-1.3.1.tgz",
"integrity": "sha1-5Dt4sagUPm+pek9IXrjqUwNS8u0=",
"requires": {
"inherits": "^2.0.1",
}
},
"maticjs": {
- "version": "1.0.0-beta.4",
- "resolved": "https://registry.npmjs.org/maticjs/-/maticjs-1.0.0-beta.4.tgz",
- "integrity": "sha512-DQnmdUMK8UdzwwtWd9PjXgu/vkloqzjrHF2C0SzTzr0ebS1IV/51/E3K3iQzaBfsFrZvbc34BIvHJ6uSeZDPeA==",
+ "version": "1.0.0-beta.5",
+ "resolved": "https://registry.npmjs.org/maticjs/-/maticjs-1.0.0-beta.5.tgz",
+ "integrity": "sha512-FXJ0RufH22iwHyZ5CYT6OGDzdTZzX/xyQuNkaE8TPIrklFzqpxSSPu+aST7wcsxbTDV+OIIHNgNLUNmknfiZSQ==",
"requires": {
"@babel/polyfill": "7.0.0",
"@babel/runtime": "7.1.2",
},
"media-typer": {
"version": "0.3.0",
- "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
+ "resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
},
"memdown": {
"integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ=="
},
"mime-db": {
- "version": "1.36.0",
- "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz",
- "integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw=="
+ "version": "1.37.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz",
+ "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg=="
},
"mime-types": {
- "version": "2.1.20",
- "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz",
- "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==",
+ "version": "2.1.21",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz",
+ "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==",
"requires": {
- "mime-db": "~1.36.0"
+ "mime-db": "~1.37.0"
}
},
"mimic-response": {
},
"pify": {
"version": "2.3.0",
- "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
+ "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
},
"pinkie": {

MODIFY
examples/node/package.json
examples/node/package.json
"author": "Sayli Patil <sayli@matic.network>",
"license": "ISC",
"dependencies": {
- "maticjs": "latest"
+ "maticjs": "1.0.0-beta.5"
}
}

MODIFY
examples/node/transfer.js
examples/node/transfer.js
-const Matic = require('maticjs')
+const Matic = require('maticjs').default
+const config = require('./config')
-const maticProvider = 'https://testnet.matic.network'
-const parentProvider = 'https://kovan.infura.io/matic'
-const rootChainAddress = '0x24e01716a6ac34d5f2c4c082f553d86a557543a7'
-const syncerUrl = 'https://eth-syncer.api.matic.network/api/v1'
-const watcherUrl = 'https://eth-watcher.api.matic.network/api/v1'
-
-const token = '0xC4375B7De8af5a38a93548eb8453a498222C4fF2'
-const user = '0x7ed7f36694153ba6eff6ca6726b60f6e2bb17fcf'
+const token = '0xC4375B7De8af5a38a93548eb8453a498222C4fF2' // test token address
+const user = '0x7ed7f36694153ba6eff6ca6726b60f6e2bb17fcf' // test user address
const amount = '10000000000000000'
-const from = '0x6e0c217de3235f1d8a95605d10bcc1b36ff7996f'
+const from = '0x6e0c217de3235f1d8a95605d10bcc1b36ff7996f' // test user address
// Create object of Matic
const matic = new Matic({
- maticProvider,
- parentProvider,
- rootChainAddress,
- syncerUrl,
- watcherUrl,
+ maticProvider: config.MATIC_PROVIDER,
+ parentProvider: config.PARENT_PROVIDER,
+ rootChainAddress: config.ROOTCHAIN_ADDRESS,
+ syncerUrl: config.SYNCER_URL,
+ watcherUrl: config.WATCHER_URL,
})
matic.wallet = '<private-key>'

MODIFY
examples/node/withdraw.js
examples/node/withdraw.js
-const Matic = require('maticjs')
+const Matic = require('maticjs').default
+const config = require('./config')
-const maticProvider = 'https://testnet.matic.network'
-const parentProvider = 'https://kovan.infura.io/matic'
-const rootChainAddress = '0x24e01716a6ac34d5f2c4c082f553d86a557543a7'
-const syncerUrl = 'https://eth-syncer.api.matic.network/api/v1'
-const watcherUrl = 'https://eth-watcher.api.matic.network/api/v1'
-
-const mtoken = '0xc60CEc8200513c4eAaF179783d30CdcE8DED8492'
+const mtoken = '0xc60CEc8200513c4eAaF179783d30CdcE8DED8492' // test token address
const amount = '10000000000000000'
-const from = '0x6e0c217de3235f1d8a95605d10bcc1b36ff7996f'
+const from = '0x6e0c217de3235f1d8a95605d10bcc1b36ff7996f' // test user address
// Create object of Matic
const matic = new Matic({
- maticProvider,
- parentProvider,
- rootChainAddress,
- syncerUrl,
- watcherUrl,
+ maticProvider: config.MATIC_PROVIDER,
+ parentProvider: config.PARENT_PROVIDER,
+ rootChainAddress: config.ROOTCHAIN_ADDRESS,
+ syncerUrl: config.SYNCER_URL,
+ watcherUrl: config.WATCHER_URL,
})
matic.wallet = '<private-key>'

fix: use config object for node-example