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

3.0.0: Refactor Transaction class #854

Merged
merged 17 commits into from
Feb 13, 2024
Merged

3.0.0: Refactor Transaction class #854

merged 17 commits into from
Feb 13, 2024

Conversation

jasonpaulos
Copy link
Contributor

@jasonpaulos jasonpaulos commented Jan 25, 2024

Specifically,

  • For the Transaction class, separated input type from internal representation (e.g. input types can be number | bigint, but internally the type is stored as bigint). Fixes Refactor Transaction class #850
  • Greatly simplified types related to transactions and transaction params
  • Removed all transaction maker methods that did not take objects (e.g. makePaymentTxnWithSuggestedParams(from, to, amount, closeRemainderTo, note, suggestedParams, rekeyTo) replaced by makePaymentTxnWithSuggestedParamsFromObject(object))
  • Removed "raw transaction objects" (i.e. raw objects with transactions properties like { from: addr, to: adder, ... })
  • Merged SuggestedParams and SuggestedParamsWithMinFee. Min fee is now required in SuggestedParams
  • Introduce Address class. Prior to this, addresses were represented internally in either their string form, or a deconstructed object containing public key and checksum. The new Address class standardizes the format used, and internally it only contains the 32 byte public key component
  • Removed unnecessary MultisigTransaction and TxGroup classes
  • Removed auction bids which were only relevant to mainnet launch

Additionally I started a v2 to v3 migration guide

Follow up to #853

@jasonpaulos jasonpaulos force-pushed the refactor-transaction branch 2 times, most recently from a4f56c1 to 13e0add Compare February 2, 2024 19:29
@jasonpaulos jasonpaulos marked this pull request as ready for review February 7, 2024 17:17
@jasonpaulos jasonpaulos requested a review from a team as a code owner February 7, 2024 17:17
@@ -89,7 +89,8 @@ jobs:
$(lsb_release -cs) stable" | $SUDO tee /etc/apt/sources.list.d/docker.list > /dev/null
$SUDO apt update
$SUDO apt -y install docker-ce docker-ce-cli containerd.io
- browser-tools/install-browser-tools
- browser-tools/install-browser-tools:
replace-existing-chrome: true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ensures we always get the latest stable chrome version, which our browser testing relies on

Copy link
Contributor

@gmalouf gmalouf Feb 7, 2024

Choose a reason for hiding this comment

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

Is there a reason to intentionally test on a cross-range of versions? Wondering if instead of doing latest, we should do latest, plus X releases back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There may be some value in selecting an older chrome version to test against, so that we can be sure the code isn't relying on APIs/behaviors that we think are too new.

But in reality it's easiest to test against latest and we still benefit a lot from having this.

I only included this change because for some reason circle stopped installing the latest chrome by default, which broke our test

Copy link

@jannotti jannotti left a comment

Choose a reason for hiding this comment

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

Some thoughts and questions.

examples/atomics.ts Show resolved Hide resolved
examples/overview.ts Outdated Show resolved Hide resolved
examples/participation.ts Outdated Show resolved Hide resolved
src/boxStorage.ts Show resolved Hide resolved
src/composer.ts Outdated Show resolved Hide resolved
src/encoding/address.ts Show resolved Hide resolved
src/client/v2/algod/getApplicationByID.ts Show resolved Hide resolved
src/client/v2/algod/suggestedParams.ts Show resolved Hide resolved
src/composer.ts Show resolved Hide resolved
src/composer.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@gmalouf gmalouf left a comment

Choose a reason for hiding this comment

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

Initial set of comments, about 20 files in.

@@ -89,7 +89,8 @@ jobs:
$(lsb_release -cs) stable" | $SUDO tee /etc/apt/sources.list.d/docker.list > /dev/null
$SUDO apt update
$SUDO apt -y install docker-ce docker-ce-cli containerd.io
- browser-tools/install-browser-tools
- browser-tools/install-browser-tools:
replace-existing-chrome: true
Copy link
Contributor

@gmalouf gmalouf Feb 7, 2024

Choose a reason for hiding this comment

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

Is there a reason to intentionally test on a cross-range of versions? Wondering if instead of doing latest, we should do latest, plus X releases back.

@@ -51,13 +51,12 @@ async function main() {
// example: ATOMIC_GROUP_SEND

// example: CONST_MIN_FEE
const minFee = algosdk.ALGORAND_MIN_TX_FEE;
console.log(minFee);
// This SDK does not expose a constant for the minimum fee
// example: CONST_MIN_FEE
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove the comment references to CONST_MIN_FEE entirely? Also, there seems to be two identical lines for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These comments are used to populate snippets of code in the dev site. This specific one is used here: https://developer.algorand.org/docs/get-details/dapps/smart-contracts/guidelines/#get-minimum-fee-off-chain-with-sdk

I think we want to preserve JS in that tab, but just have a comment saying a hard coded min fee is not available. That's currently what happens for the "using an algod API" JS snippet on that page

examples/overview.ts Outdated Show resolved Hide resolved
src/boxStorage.ts Show resolved Hide resolved
src/boxStorage.ts Show resolved Hide resolved
src/composer.ts Show resolved Hide resolved
src/dryrun.ts Show resolved Hide resolved
Copy link
Contributor

@gmalouf gmalouf left a comment

Choose a reason for hiding this comment

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

With this large of a refactor, found myself wishing we had a test coverage tool on the SDK. It was hard for me to track down if the varying types were handled properly etc and if we had added new tests in all the places they made sense.

v2_TO_v3_MIGRATION_GUIDE.md Show resolved Hide resolved
src/utils/utils.ts Show resolved Hide resolved
@@ -478,235 +487,4 @@ describe('Multisig Functionality', () => {
}, new Error('Invalid multisig transaction, multisig structure missing at index 1'));
});
});

describe('read-only transaction methods should work as expected on multisig transactions', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

what was removed that made these irrelevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The MultisigTransaction class was removed

src/makeTxn.ts Show resolved Hide resolved
Copy link
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

In general LGTM, not sure I am following the number | bigint vs bigint logic. Plus, few questions/remarks.

examples/participation.ts Outdated Show resolved Hide resolved
src/client/v2/algod/compile.ts Show resolved Hide resolved
src/makeTxn.ts Show resolved Hide resolved
tests/cucumber/steps/steps.js Show resolved Hide resolved
tests/5.Transaction.ts Outdated Show resolved Hide resolved
@jasonpaulos jasonpaulos merged commit 4184324 into 3.0.0 Feb 13, 2024
2 checks passed
@jasonpaulos jasonpaulos deleted the refactor-transaction branch February 13, 2024 20:58
Copy link
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

👍

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