Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a high-level transfer helper #113

Open
troggy opened this issue May 28, 2019 · 1 comment
Open

Create a high-level transfer helper #113

troggy opened this issue May 28, 2019 · 1 comment

Comments

@troggy
Copy link
Member

troggy commented May 28, 2019

Bounty

⚠️Bounty has EXPIRED. If you want to work on this issue, chime in into comments first ⚠️

We already have transferFromUtxos helper which is good, but still too low-level. Proposing to make an additional API hiding the whole UTXO thing completely and overall making it as lenient as possible. Aim to replace boilerplate like this, this and this with a one line of code.

API sketch:

type BigIntable = BigIntType | Number | string; // defined in `jsbi-utils` package
type PlasmaProvider = ExtendedWeb3 | LeapEthers | JsonRpcProvider;

function transfer(transferParams: {
  from: string, 
  to: string, 
  amount: BigIntable, 
  color: string | number, 
  plasma: PlasmaProvider, 
  signer: Signer // optional
}): Promise

Inspired by Exit.fastSellAmount

Scope

  • the helper should get UTXOs for a given color from plasma provider, create a transfer tx, sign it and send out
  • should return a Promise which resolves to TransactionReceipt (for now, as returned by sendSignedTransaction)
  • should support
    • NST
    • NFT
    • ERC20
  • if it takes more than 15 inputs to transfer the given amount, it should create a consolidation transaction and resume the transfer upon it's mined (see fastSell helper for inspiration)
  • if there is not enough balance on the from account, it should throw a meaningful exception
  • validates all the parameters are provided (except optional signer), otherwise throws a meaningful exception
  • make sure from and to are both accepting valid Ethereum addresses only
  • amount parameter. Should accept both string, BigInt or number. Consider to use jsbi-utils helper. Should validate the param and throw a meaningful exception if it is not coercible to integer value.
  • color parameter. Should accept both string and number. Should validate it and throw a meaningful exception if it is not coercible to integer value.
  • plasma parameter. Should support plasma providers:
  • signer parameter. Is optional. If omitted, then default signer should be used (see fastExit helper for the examples)

Deliverables

  • updated library with the helper
  • updated typedef
  • updated Transfer Tokens page in docs. Keep the current content, add a "high level" option with example of how to use this API

Gain for the project

Roles

bounty gardener: @troggy / 20%
bounty worker: name / share
bounty reviewer: name / share

@troggy troggy added bounty size-M effort of ~8h and removed bounty size-M effort of ~8h labels Jul 6, 2019
@troggy troggy added size-M effort of ~8h bounty labels Jul 26, 2019
@troggy
Copy link
Member Author

troggy commented Jul 26, 2019

@troggy troggy removed bounty size-M effort of ~8h labels Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant