new: pos deposit for ether
MODIFY
src/index.ts
src/index.ts
@@ -309,6 +309,13 @@ export default class Matic extends ContractsBase {
return this.posRootChainManager.depositERC20ForUser(rootToken, amount, user, options)
}
+ depositPOSEtherForUser(user: address, amount: BN | string, options?: SendOptions) {
+ if (options && (!options.from || !amount || !user)) {
+ throw new Error('options.from, user or amount is missing')
+ }
+ return this.posRootChainManager.depositEtherForUser(amount, user, options)
+ }
+
burnPOSERC20(childToken: address, amount: BN | string, options?: SendOptions) {
this._validateInputs(childToken, amount, options)
return this.posRootChainManager.burnERC20(childToken, amount, options)

MODIFY
src/root/POSRootChainManager.ts
src/root/POSRootChainManager.ts
@@ -62,6 +62,24 @@ export default class POSRootChainManager extends ContractsBase {
return this.web3Client.send(txObject, _options)
}
+ async depositEtherForUser(amount: BN | string, user: address, options: SendOptions = {}) {
+ const txObject = this.posRootChainManager.methods.depositEtherFor(user)
+
+ const _options = await this._fillOptions(
+ Object.assign(options, { value: this.encode(amount) }),
+ txObject,
+ this.web3Client.getParentWeb3()
+ )
+
+ if (options.encodeAbi) {
+ _options.data = txObject.encodeABI()
+ _options.to = this.posRootChainManager.options.address
+ return _options
+ }
+
+ return this.web3Client.send(txObject, _options)
+ }
+
async burnERC20(childToken: address, amount: BN | string, options?: SendOptions) {
const childTokenContract = new this.web3Client.web3.eth.Contract(ChildTokenArtifact.abi, childToken)
const txObject = childTokenContract.methods.withdraw(this.encode(amount))

new: pos deposit for ether