-
Notifications
You must be signed in to change notification settings - Fork 9
NET-205: Simplify DataUnion interface #202
Conversation
…ataUnion.getContract()
… call getMemberBalance -> getWithdrawableEarnings move getTokenBalance annotate tokenAddress as non-nullable in config as it has the default value
…actorySidechainAddress config option
…tWithdrawableEarnings and getTokenBalance DeployDataUnion throws an error if owner address is invalid
… deployable DataUnion address
NET-205 JS-client: Simplify DataUnion interface
|
… member), partMembers -> removeMembers
…wait until join request has been processed
jtakalai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataUnion object is good stuff! So much better structure, used to be such a megafile amoeba.
Tests are passing but not exiting due to open handles. Just --forceExit them and make a ticket to track down the reason later. It can be really hard to find what it is, and it's probably inside ethers.js somewhere (despite doing await providerMainnet.removeAllListeners() in the end of tests, --detectOpenHandles isn't going to help much IIRC)
README.md
Outdated
|
|
||
| Data union functions take a third parameter, `options`, which are either overrides to options given in the constructor, or optional arguments to the function. | ||
|
|
||
| TODO: do we need these parameters (and `confirmations` parameter) somewhere? Either add the support, or remove from `DataUnionDeployOptions` interface (currently commented out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea could be a good thing I guess, goes together with gasPrice really. Leaving it out for now is no issue, can make a ticket to backlog to add it back later
| }, | ||
| "#IMPORTANT": "babel-runtime must be in dependencies, not devDependencies", | ||
| "dependencies": { | ||
| "@ethersproject/abi": "^5.0.12", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this needed in the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm looks like yes (abi.encode)
timoxley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
DataUnion is now an object which we can operate on. To get an instance of DU object, call
client.getDataUnion(contractAddress). As the object encapsulates the contract address, we don't need to specify it when we access the DU methods.Some methods that need a member address were previously optional, and the default value for those were the currently authenticated user. Now we need to be more explicit about the parameter and the member address is always required. Also previously there was a
dataUnionclient option which was a default value for some DU actions. That is no longer supported.There is a new config option
factorySidechainAddress. Users don't need to specify this as it has default value in test and will have a default value in production once we know the address.Member join functions:
joinDataUnion()->join(secret?), if secret is given this will wait until the automatic join request has been processedisMember(memberAddress), returns true if the member is an active memberhasJoined()removedWithdraw functions renamed to have word "all" if the amount is not specified:
withdrawAll(options?)withdrawAllTo(recipient, options?)signWithdrawAllTo(recipientAddress)signWithdrawAmountTo(recipientAddress, amountTokenWei)withdrawFor()->withdrawAllToMember(memberAddress, options?)withdrawAllToSigned(memberAddress, recipientAddress, signature, options?)getWithdrawTx(),getWithdrawTxTo(),getWithdrawTxFor()Public query functions:
getDataUnionStats()->getStats()getMemberStats(memberAddress)getMembersas it is not supported in DU v2getBalance()->getWithdrawableEarnings(memberAddress)getAdminFee()getAdminAddress()getVersion()Admin functions:
client.deployDataUnion(options), waits until the deployment is ready, supports new options:confirmationsandgasPricecreateSecret(name?)addMembers(memberAddressList, options?)kick()->removeMembers(memberAddressList, options?)setAdminFee(newFeeFraction)Other functions:
client.getTokenBalance()Public accessors for DataUnion objects:
getAddress(), returns stringgetSidechainAddress(), returns stringInternal functions:
client._getDataUnionFromName({ dataUnionName, deployerAddress }), returns DataUniondataUnion._getContract(), returns PromiseFuture refactoring, should be done after this PR is in 5.x:
getTokenBalanceto a separate class as it is not DU-relatedfetchDataUnionMainnetAddress