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

Add accountToAccount RPC #284

Merged
merged 23 commits into from
May 28, 2021
Merged

Add accountToAccount RPC #284

merged 23 commits into from
May 28, 2021

Conversation

jingyi2811
Copy link
Contributor

@jingyi2811 jingyi2811 commented May 24, 2021

What kind of PR is this?:

/kind feature

What this PR does / why we need it:

Add accounttoaccount rpc and assertion to prevent sending DFI in account form

Which issue(s) does this PR fixes?:

Fixes #228

Additional comments?:

@defichain-bot
Copy link
Member

@jingyi2811: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.

  • /kind feature
  • /kind fix
  • /kind chore
  • /kind docs
  • /kind refactor
  • /kind dependencies
Details

I am a bot created to help the DeFiCh developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the DeFiCh/oss-governance-bot repository.

@codeclimate
Copy link

codeclimate bot commented May 24, 2021

Code Climate has analyzed commit cd9982e and detected 0 issues on this pull request.

View more on Code Climate.

@jingyi2811 jingyi2811 changed the title Jimmy/accounttoaccount Add accounttoaccount rpc May 24, 2021
@netlify
Copy link

netlify bot commented May 24, 2021

✔️ Deploy Preview for jellyfish-defi ready!

🔨 Explore the source changes: ae29d49

🔍 Inspect the deploy log: https://app.netlify.com/sites/jellyfish-defi/deploys/60af1284dd646c0007cefe68

😎 Browse the preview: https://deploy-preview-284--jellyfish-defi.netlify.app

@github-actions
Copy link

github-actions bot commented May 24, 2021

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/jellyfish/dist/jellyfish.umd.js 19.51 KB (+0.18% 🔺) 391 ms (+0.18% 🔺) 169 ms (+2.54% 🔺) 559 ms

@jingyi2811 jingyi2811 changed the title Add accounttoaccount rpc Add accounttoaccount rpc and assertion to prevent sending DFI in account form May 24, 2021
@codecov
Copy link

codecov bot commented May 24, 2021

Codecov Report

Merging #284 (cd9982e) into main (7f1e36d) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #284      +/-   ##
==========================================
+ Coverage   96.87%   96.92%   +0.05%     
==========================================
  Files          88       89       +1     
  Lines        2366     2410      +44     
  Branches      303      309       +6     
==========================================
+ Hits         2292     2336      +44     
  Misses         74       74              
Impacted Files Coverage Δ
...ackages/jellyfish-api-core/src/category/account.ts 100.00% <100.00%> (ø)
...ages/jellyfish-api-core/src/category/blockchain.ts 100.00% <0.00%> (ø)
...ish-transaction/src/script/defi/dftx_masternode.ts 100.00% <0.00%> (ø)
...ellyfish-transaction/src/buffer/buffer_composer.ts 99.46% <0.00%> (+0.03%) ⬆️
...ages/jellyfish-transaction/src/script/defi/dftx.ts 97.01% <0.00%> (+0.24%) ⬆️
...ckages/jellyfish-transaction/src/script/mapping.ts 96.20% <0.00%> (+0.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f1e36d...cd9982e. Read the comment docs.

Copy link
Contributor

@canonbrother canonbrother left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor naming issues and desc write-up

@jingyi2811
Copy link
Contributor Author

Look like one of the unit tests fails occasionally. I am now Investigating it.

@jingyi2811
Copy link
Contributor Author

jingyi2811 commented May 25, 2021

Below is my finding

After adding await container.call('utxostoaccount', [{ [address]: '100@0' }])

Line 233

const account = await client.account.getAccount(accounts[0].owner.addresses[0], pagination)
expect(account.length).toStrictEqual(1)

sometimes returns 0. (Expect to get 1)

[Fail scenario]
if the accounts are arranged in this order [Retrieving from await client.account.listAccounts()]

2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G 200.00000000@DFI
2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G 177.00000000@DBTC
2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G 154.00000000@DETH
2N5a9Pq7uDLkHYzDgPK5geCfb4VLR45CUsQ 23.00000000@DBTC
2NBb5ShtxDmkzTvmnmgyL3uCvW7Jcu6PBir 46.00000000@DETH

const account = await client.account.getAccount(2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G,  {start: 3,
including_start: true})

The account length will be 0

[Success scenario]
if the accounts are arranged in this order [Retrieving from await client.account.listAccounts()]

2MwXSFp9jp5JtzzJ8J2GYJMRbPx6rjk5jrR 46.00000000@DETH
2N3RAgU3hBUEHUpJwxNxQYP38hUh84KaQip 200.00000000@DFI
2N3RAgU3hBUEHUpJwxNxQYP38hUh84KaQip 177.00000000@DBTC
2N3RAgU3hBUEHUpJwxNxQYP38hUh84KaQip 154.00000000@DETH
2N5ibMXpwieA1hAi5k9WsuEMadzsWdaNjSh 23.00000000@DBTC

const account = await client.account.getAccount(2MwXSFp9jp5JtzzJ8J2GYJMRbPx6rjk5jrR,  {start: 1,
including_start: true})

The account length will be 1

@canonbrother Maybe could you help me to check why this could happen. As you are the one who works on this RPC.

@fuxingloh
Copy link
Contributor

Below is my finding

After adding await container.call('utxostoaccount', [{ [address]: '100@0' }])

Line 247

const account = await client.account.getAccount(accounts[0].owner.addresses[0], pagination)
expect(account.length).toStrictEqual(1)

sometimes returns 0. (Expect to get 1)

[Fail scenario]
if the accounts are arranged in this order [Retrieving from await client.account.listAccounts()]

2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G 200.00000000@DFI
2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G 177.00000000@DBTC
2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G 154.00000000@DETH
2N5a9Pq7uDLkHYzDgPK5geCfb4VLR45CUsQ 23.00000000@DBTC
2NBb5ShtxDmkzTvmnmgyL3uCvW7Jcu6PBir 46.00000000@DETH

const account = await client.account.getAccount(2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G,  {start: 3,
including_start: true})

The account length will be 0

[Success scenario]
if the accounts are arranged in this order [Retrieving from await client.account.listAccounts()]

2MwXSFp9jp5JtzzJ8J2GYJMRbPx6rjk5jrR 46.00000000@DETH
2N3RAgU3hBUEHUpJwxNxQYP38hUh84KaQip 200.00000000@DFI
2N3RAgU3hBUEHUpJwxNxQYP38hUh84KaQip 177.00000000@DBTC
2N3RAgU3hBUEHUpJwxNxQYP38hUh84KaQip 154.00000000@DETH
2N5ibMXpwieA1hAi5k9WsuEMadzsWdaNjSh 23.00000000@DBTC

const account = await client.account.getAccount(2MwXSFp9jp5JtzzJ8J2GYJMRbPx6rjk5jrR,  {start: 1,
including_start: true})

The account length will be 1

@canonbrother Maybe could you help me to check why this could happen. As you are the one who works on this RPC.

Better to quote a code for context, hard to understand sometimes.

@canonbrother
Copy link
Contributor

Below is my finding

After adding await container.call('utxostoaccount', [{ [address]: '100@0' }])

Line 233

const account = await client.account.getAccount(accounts[0].owner.addresses[0], pagination)
expect(account.length).toStrictEqual(1)

sometimes returns 0. (Expect to get 1)

[Fail scenario]
if the accounts are arranged in this order [Retrieving from await client.account.listAccounts()]

2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G 200.00000000@DFI
2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G 177.00000000@DBTC
2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G 154.00000000@DETH
2N5a9Pq7uDLkHYzDgPK5geCfb4VLR45CUsQ 23.00000000@DBTC
2NBb5ShtxDmkzTvmnmgyL3uCvW7Jcu6PBir 46.00000000@DETH

const account = await client.account.getAccount(2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G,  {start: 3,
including_start: true})

The account length will be 0

[Success scenario]
if the accounts are arranged in this order [Retrieving from await client.account.listAccounts()]

2MwXSFp9jp5JtzzJ8J2GYJMRbPx6rjk5jrR 46.00000000@DETH
2N3RAgU3hBUEHUpJwxNxQYP38hUh84KaQip 200.00000000@DFI
2N3RAgU3hBUEHUpJwxNxQYP38hUh84KaQip 177.00000000@DBTC
2N3RAgU3hBUEHUpJwxNxQYP38hUh84KaQip 154.00000000@DETH
2N5ibMXpwieA1hAi5k9WsuEMadzsWdaNjSh 23.00000000@DBTC

const account = await client.account.getAccount(2MwXSFp9jp5JtzzJ8J2GYJMRbPx6rjk5jrR,  {start: 1,
including_start: true})

The account length will be 1

@canonbrother Maybe could you help me to check why this could happen. As you are the one who works on this RPC.

nothing wrong
you have to know how getaccount work

@jingyi2811
Copy link
Contributor Author

Below is my finding
After adding await container.call('utxostoaccount', [{ [address]: '100@0' }])
Line 233

const account = await client.account.getAccount(accounts[0].owner.addresses[0], pagination)
expect(account.length).toStrictEqual(1)

sometimes returns 0. (Expect to get 1)
[Fail scenario]
if the accounts are arranged in this order [Retrieving from await client.account.listAccounts()]
2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G 200.00000000@DFI
2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G 177.00000000@DBTC
2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G 154.00000000@DETH
2N5a9Pq7uDLkHYzDgPK5geCfb4VLR45CUsQ 23.00000000@DBTC
2NBb5ShtxDmkzTvmnmgyL3uCvW7Jcu6PBir 46.00000000@DETH

const account = await client.account.getAccount(2N3asj6NyoRGSx9Niu9qeAfJL7Ymu1R1b6G,  {start: 3,
including_start: true})

The account length will be 0
[Success scenario]
if the accounts are arranged in this order [Retrieving from await client.account.listAccounts()]
2MwXSFp9jp5JtzzJ8J2GYJMRbPx6rjk5jrR 46.00000000@DETH
2N3RAgU3hBUEHUpJwxNxQYP38hUh84KaQip 200.00000000@DFI
2N3RAgU3hBUEHUpJwxNxQYP38hUh84KaQip 177.00000000@DBTC
2N3RAgU3hBUEHUpJwxNxQYP38hUh84KaQip 154.00000000@DETH
2N5ibMXpwieA1hAi5k9WsuEMadzsWdaNjSh 23.00000000@DBTC

const account = await client.account.getAccount(2MwXSFp9jp5JtzzJ8J2GYJMRbPx6rjk5jrR,  {start: 1,
including_start: true})

The account length will be 1
@canonbrother Maybe could you help me to check why this could happen. As you are the one who works on this RPC.

nothing wrong
you have to know how getaccount work

Nevermind, this will be fixed in #295

@jingyi2811 jingyi2811 marked this pull request as ready for review May 27, 2021 04:22
@jingyi2811 jingyi2811 marked this pull request as draft May 27, 2021 04:24
@jingyi2811
Copy link
Contributor Author

jingyi2811 commented May 27, 2021

Sorry, I need to refactor accountToAccount rpc test file into a separate folder in this PR. Doing it now.

@jingyi2811
Copy link
Contributor Author

jingyi2811 commented May 27, 2021

I have separated out the code. See accountToAccount.test.ts.
Probably it is not the minimum setup. But I will optimize the code in another PR.

There is minimum code refactoring in the existing account.test.ts. Added a test. There are no changes to the existing logic.

@jingyi2811 jingyi2811 marked this pull request as ready for review May 27, 2021 04:53
@fuxingloh fuxingloh merged commit 3f9138a into main May 28, 2021
@fuxingloh fuxingloh deleted the jimmy/accounttoaccount branch May 28, 2021 05:32
canonbrother pushed a commit that referenced this pull request Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

additional test in jellyfish-api-core to ensure DFI can only be sent as UTXO
5 participants