stacks-archive / stacks-transactions-js

The JavaScript library for generating Stacks 2.0 transactions
19 stars 17 forks source link

Options object argument for transaction builders #72

Closed yknl closed 4 years ago

yknl commented 4 years ago

This PR replaces the arguments to transaction builder functions with an options object. This provides a cleaner interface compared to a list of optional and non-optional args.

New Usage:

const txOptions = {
  recipient: 'SP3FGQ8Z7JY9BWYZ5WM53E0M9NK7WHJF0691NZ159',
  amount: new BigNum(12345),
  senderKey: 'b244296d5907de9864c0b0d51f98a13c52890be0404e83f273144cd5b9960eed01',
  network,
  memo: "test memo",
  nonce: new BigNum(0),
  fee: new BigNum(200),
};

const transaction = await makeSTXTokenTransfer(txOptions);

Resolves issue #68

Type of Change

Does this introduce a breaking change?

This update breaks the transaction builder function APIs: makeSTXTokenTransfer makeSmartContractDeploy makeContractCall

Are documentation updates required?

Readme has been updated.

Testing information

Transaction builders should continue to generate valid transactions.

Checklist

codecov[bot] commented 4 years ago

Codecov Report

Merging #72 into master will decrease coverage by 0.55%. The diff coverage is 75.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #72      +/-   ##
==========================================
- Coverage   85.45%   84.90%   -0.56%     
==========================================
  Files          26       26              
  Lines        1403     1438      +35     
  Branches      250      262      +12     
==========================================
+ Hits         1199     1221      +22     
- Misses        203      215      +12     
- Partials        1        2       +1     
Impacted Files Coverage Δ
src/utils.ts 73.43% <ø> (ø)
src/builders.ts 71.50% <71.42%> (-3.66%) :arrow_down:
src/authorization.ts 76.96% <100.00%> (+0.26%) :arrow_up:
src/keys.ts 95.23% <100.00%> (+0.23%) :arrow_up:
src/network.ts 100.00% <100.00%> (ø)
src/transaction.ts 79.06% <100.00%> (+0.49%) :arrow_up:

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 b6b57fe...399c707. Read the comment docs.

kyranjamie commented 4 years ago

Nice update 👍