update safeDepositForERC721 on readme
MODIFY
README.md
README.md
@@ -71,6 +71,13 @@ await matic.depositERC20ForUser(
options // transaction fields
)
+// Deposit ERC721 token into Matic chain.
+await matic.safeDepositERC721Tokens(
+ token, // Token address
+ tokenId, // TokenId for deposit
+ options // transaction fields
+)
+
// Transfer token on Matic
await matic.transferERC20Tokens(
token, // Token address
@@ -127,6 +134,7 @@ Please write to info@matic.network to request TEST tokens for development purpos
- <a href="#initialize"><code>new Matic()</code></a>
- <a href="#approveERC20TokensForDeposit"><code>matic.<b>approveERC20TokensForDeposit()</b></code></a>
- <a href="#depositERC20ForUser"><code>matic.<b>depositERC20ForUser()</b></code></a>
+- <a href="#safeDepositERC721Tokens"><code>matic.<b>safeDepositERC721Tokens()</b></code></a>
- <a href="#transferERC20Tokens"><code>matic.<b>transferERC20Tokens()</b></code></a>
- <a href="#startWithdraw"><code>matic.<b>startWithdraw()</b></code></a>
- <a href="#withdraw"><code>matic.<b>withdraw()</b></code></a>
@@ -214,6 +222,29 @@ matic.depositToken('0x718Ca123...', user, '1000000000000000000', {
---
+<a name="safeDepositERC721Tokens"></a>
+
+#### matic.safeDepositERC721Tokens(token, tokenId, options)
+
+Deposit given `TokenID` of `token` with user `user`.
+
+- `token` must be valid ERC20 token address
+- `tokenId` must be valid token ID
+- `options` see [more infomation here](#approveERC20TokensForDeposit)
+
+This returns `Promise` object, which will be fulfilled when transaction gets confirmed (when receipt is generated).
+
+Example:
+
+```js
+
+matic.safeDepositERC721Tokens('0x718Ca123...', '70000000000', {
+ from: '0xABc578455...'
+})
+```
+
+---
+
<a name="transferERC20Tokens"></a>
#### matic.transferERC20Tokens(token, user, amount, options)

MODIFY
examples/node/package-lock.json
examples/node/package-lock.json
"integrity": "sha512-oqsQXzu+ejJACVHy864WwIyw+oB21nw/pI65/sD95Zi98+/HQzFfNcIFneF1NC4bVF3VNX4YHTNq2I2o97LAiA==",
"requires": {
"underscore": "1.9.1",
- "web3-core-helpers": "1.2.1",
- "websocket": "github:web3-js/WebSocket-Node#905deb4812572b344f5801f8c9ce8bb02799d82e"
+ "web3-core-helpers": "1.2.1"
+ }
+ },
+ "websocket": {
+ "version": "github:web3-js/WebSocket-Node#905deb4812572b344f5801f8c9ce8bb02799d82e",
+ "from": "github:web3-js/WebSocket-Node#905deb4812572b344f5801f8c9ce8bb02799d82e",
+ "requires": {
+ "debug": "^2.2.0",
+ "es5-ext": "^0.10.50",
+ "nan": "^2.14.0",
+ "typedarray-to-buffer": "^3.1.5",
+ "yaeti": "^0.0.6"
}
}
}
"integrity": "sha512-oqsQXzu+ejJACVHy864WwIyw+oB21nw/pI65/sD95Zi98+/HQzFfNcIFneF1NC4bVF3VNX4YHTNq2I2o97LAiA==",
"requires": {
"underscore": "1.9.1",
- "web3-core-helpers": "1.2.1",
- "websocket": "github:web3-js/WebSocket-Node#905deb4812572b344f5801f8c9ce8bb02799d82e"
+ "web3-core-helpers": "1.2.1"
},
"dependencies": {
"websocket": {
"version": "github:web3-js/WebSocket-Node#905deb4812572b344f5801f8c9ce8bb02799d82e",
- "from": "github:web3-js/WebSocket-Node#polyfill/globalThis",
+ "from": "github:web3-js/WebSocket-Node#905deb4812572b344f5801f8c9ce8bb02799d82e",
"requires": {
"debug": "^2.2.0",
"es5-ext": "^0.10.50",

MODIFY
examples/node/safeDepositERC721Tokens.js
examples/node/safeDepositERC721Tokens.js
@@ -2,8 +2,9 @@ const Matic = require('../../dist/index').default
const config = require('./config')
const token = config.ROPSTEN_ERC721_TOKEN // test token address
-const tokenId = '1734' // ERC721 token Id
const from = config.FROM_ADDRESS // from address
+const tokenId = 1963
+
// Create object of Matic
const matic = new Matic({
@@ -18,6 +19,7 @@ const matic = new Matic({
matic.wallet = config.PRIVATE_KEY // prefix with `0x`sla
matic.initialize().then(() => {
+ matic.setWallet(config.PRIVATE_KEY)
matic.safeDepositERC721Tokens(token, tokenId, {
from,
}).then((receipt) => {

MODIFY
src/index.ts
src/index.ts
@@ -42,7 +42,7 @@ export default class Matic extends ContractsBase {
return Promise.all([this.withdrawManager.initialize()])
}
- wallet(_wallet) {
+ setWallet(_wallet) {
this.web3Client.wallet = _wallet
}
@@ -102,13 +102,13 @@ export default class Matic extends ContractsBase {
return this.depositManager.depositERC20ForUser(token, amount, user, options)
}
- async safeDepositERC721Tokens(token: address, tokenId: string, options?: SendOptions) {
+ async safeDepositERC721Tokens(token: address, tokenId: BN, options?: SendOptions) {
if (options && (!options.from || !tokenId || !token)) {
throw new Error('options.from, token or tokenId is missing')
}
const txObject = this.getERC721TokenContract(
token,
- options.parent,
+ true,
).methods.safeTransferFrom(options.from, this.depositManager.getAddress(), tokenId)
const _options = await this._fillOptions(

update safeDepositForERC721 on readme