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

refactor(examples): secp256k1 transfer example #388

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

IronLu233
Copy link
Contributor

@IronLu233 IronLu233 commented Aug 25, 2022

Description

The origin secp256k1 transfer example is too hard to understand. because it builds up the transaction mannually. In current lumos version, we have commons.common.transfer method, which can manipulate the raw transaction's inputs/outputs. Thus, it's a time for reactoring it. And I add a new feature, which allows developer can transfer CKB to mulitple addresses

Type of change

[x] other

@vercel
Copy link

vercel bot commented Aug 25, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
lumos-website ✅ Ready (Inspect) Visit Preview Sep 16, 2022 at 3:43AM (UTC)

@codecov
Copy link

codecov bot commented Aug 25, 2022

Codecov Report

Merging #388 (579677f) into develop (f244d81) will increase coverage by 0.18%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #388      +/-   ##
===========================================
+ Coverage    81.94%   82.13%   +0.18%     
===========================================
  Files           93       94       +1     
  Lines        19003    19269     +266     
  Branches      1785     1820      +35     
===========================================
+ Hits         15572    15826     +254     
- Misses        3390     3401      +11     
- Partials        41       42       +1     
Impacted Files Coverage Δ
packages/ckb-indexer/src/services.ts 47.47% <0.00%> (-1.49%) ⬇️
packages/codec/src/high-order/nested.ts 99.17% <0.00%> (-0.83%) ⬇️
packages/ckb-indexer/src/type.ts 100.00% <0.00%> (ø)
packages/ckb-indexer/src/index.ts 100.00% <0.00%> (ø)
packages/ckb-indexer/src/paramsFormatter.ts 92.30% <0.00%> (ø)
packages/codec/src/error.ts 94.64% <0.00%> (ø)
packages/ckb-indexer/src/resultFormatter.ts 95.83% <0.00%> (+0.08%) ⬆️
packages/codec/src/number/uint.ts 99.23% <0.00%> (+0.10%) ⬆️
packages/codec/src/molecule/layout.ts 99.74% <0.00%> (+0.65%) ⬆️
packages/helpers/src/index.ts 86.63% <0.00%> (+0.91%) ⬆️
... and 3 more

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 f244d81...579677f. Read the comment docs.

examples/secp256k1-transfer/src/lib.ts Outdated Show resolved Hide resolved
examples/secp256k1-transfer/package.json Outdated Show resolved Hide resolved
examples/secp256k1-transfer/package.json Outdated Show resolved Hide resolved
@IronLu233 IronLu233 changed the title Draft:refactor Secp256k1 transfer example refactor(examples): Secp256k1 transfer example Aug 29, 2022
@IronLu233 IronLu233 changed the title refactor(examples): Secp256k1 transfer example refactor(examples): secp256k1 transfer example Aug 29, 2022
@IronLu233 IronLu233 force-pushed the secp256k1-transfer branch 2 times, most recently from 644af4a to 8a0363c Compare August 29, 2022 02:34
examples/secp256k1-transfer/src/lib.ts Outdated Show resolved Hide resolved
examples/secp256k1-transfer/src/lib.ts Outdated Show resolved Hide resolved
@homura
Copy link
Collaborator

homura commented Aug 30, 2022

can you please upgrade the example to [email protected]? checkout the migration guide

@homura
Copy link
Collaborator

homura commented Aug 31, 2022

IMO, as an example, it should be linear, procedural. Modular for engineering but not for viewing, especially for a web app like GitHub, which would require more memory if I had to jump between multiple methods.

Can you please refactor transfer into a method

function transfer(options: {
  recipients: Array<{address: Address, capacity: BIish}>,
  senderPrivkey: BytesLike
}): Promise<Hash> {
  // step 1 - convert a privkey to an lock(address)

  // step 2 - caculate the total capacity to be transferred

  // step 3 - call common.transfer to generate a txSkeleton

  // step 4 - pay tx fee

  // step 5 - prepare signing entries

  // step 6 - seal the transaction

  // step 7 - broadcast the transfer tx
}

@IronLu233
Copy link
Contributor Author

IronLu233 commented Sep 7, 2022

However, we need show the transaction fee. So we have to split the whole transfer into differient part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants