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

feat: move predicate to work as a wallet #789

Merged
merged 30 commits into from
Feb 21, 2023
Merged

feat: move predicate to work as a wallet #789

merged 30 commits into from
Feb 21, 2023

Conversation

luizstacio
Copy link
Member

@luizstacio luizstacio commented Feb 16, 2023

This PR enables Predicate to be used as a Wallet, enabling predicates to be passed to contract instances, do transfers, and pay for transactions.

On this PR;

  • Move BaseWalletLocked to Account.
  • Move the implementation of buildPredicate, spend, and another method directly to Predicate and add the same API of Account by extending it.
  • Fix the tests related to Predicate.
  • Add new unit tests to Predicate object
  • Fix test predicate docs example
  • Re enable UTXO validation on fuel-core and fix tests related to it

close: #788

@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2023

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
94.45% (+5.68% 🔼)
4288/4540
🟢 Branches
82.45% (+11.33% 🔼)
766/929
🟢 Functions
91.46% (+7.72% 🔼)
846/925
🟢 Lines
94.32% (+5.69% 🔼)
4121/4369
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / index.ts
100% 100% 50% 100%
🟢
... / contract-factory.ts
86.49% 66.67% 83.33% 86.49%
🟢
... / util.ts
96.97% 0% 100% 96.15%
🟢 merkle/src/index.ts 100% 100% 100% 100%
🟢
... / index.ts
100% 100% 100% 100%
🟢
... / contract.ts
95.45% 85.71% 100% 95.24%
🟢
... / invocation-scope.ts
100% 57.14% 100% 100%
🟢
... / base-invocation-scope.ts
100% 92.86% 100% 100%
🟢
... / scripts.ts
96.15% 87.5% 100% 96%
🟢 script/src/index.ts 100% 100% 100% 100%
🟢
... / script.ts
82.76% 62.5% 83.33% 82.76%
🟢
... / errors.ts
100% 83.33% 100% 100%
🟢 script/src/utils.ts 100% 60% 100% 100%
🟢
... / constants.ts
100% 100% 100% 100%
🔴
... / scripts.ts
50% 100% 0% 50%
🟢
... / multicall-bin.ts
100% 100% 100% 100%
🟢
... / invocation-results.ts
97.62% 66.67% 100% 97.56%
🟢
... / multicall-scope.ts
100% 100% 100% 100%
🟢
... / utils.ts
100% 100% 100% 100%
🟢
... / index.ts
100% 100% 100% 100%
🟢
... / index.ts
100% 100% 100% 100%
🟢
... / index.ts
100% 100% 100% 100%
🟢
... / index.ts
100% 100% 100% 100%
🟢
... / index.ts
100% 100% 100% 100%
🟢
... / index.ts
100% 100% 100% 100%
🟢
... / index.ts
100% 100% 100% 100%
🟢
... / wallet-manager.ts
100% 100% 100% 100%
🟢
... / mnemonic-vault.ts
94.12% 87.5% 100% 94.12%
🟢
... / privatekey-vault.ts
95.24% 60% 100% 95.24%
🟢
... / wallet-manager-spec.ts
100% 100% 100% 100%
🟢
... / account.ts
87.36% 81.25% 83.33% 87.36%
🟢
... / predicate.ts
97.22% 75% 100% 97.14%
🟢
... / index.ts
100% 100% 100% 100%
🟢
... / getContractRoot.ts
100% 100% 100% 100%
🟢
... / index.ts
100% 100% 100% 100%
🟢
... / ExampleContractAbi__factory.ts
83.33% 100% 50% 83.33%
🟢 fuels/src/index.ts 100% 100% 100% 100%

Test suite run success

713 tests passing in 98 suites.

Report generated by 🧪jest coverage report action from c6d7c9c

@luizstacio luizstacio marked this pull request as ready for review February 17, 2023 00:04
@luizstacio luizstacio self-assigned this Feb 17, 2023
Copy link
Contributor

@camsjams camsjams left a comment

Choose a reason for hiding this comment

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

Looks good on first pass, need to also add to typedoc generation and adjust address usage

packages/account/src/account.ts Outdated Show resolved Hide resolved
packages/account/src/account.ts Outdated Show resolved Hide resolved
@luizstacio luizstacio requested a review from camsjams February 17, 2023 03:17
camsjams
camsjams previously approved these changes Feb 17, 2023
Copy link
Contributor

@camsjams camsjams left a comment

Choose a reason for hiding this comment

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

Looks good, some small questions

packages/address/src/address.ts Outdated Show resolved Hide resolved
packages/fuel-gauge/src/doc-examples.test.ts Show resolved Hide resolved
packages/fuel-gauge/src/contract.test.ts Show resolved Hide resolved
@luizstacio luizstacio requested a review from camsjams February 17, 2023 17:29
camsjams
camsjams previously approved these changes Feb 17, 2023
Copy link
Contributor

@camsjams camsjams left a comment

Choose a reason for hiding this comment

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

LGTM

packages/account/README.md Outdated Show resolved Hide resolved
packages/account/README.md Outdated Show resolved Hide resolved
packages/address/src/address.ts Outdated Show resolved Hide resolved
packages/fuel-gauge/src/doc-examples.test.ts Outdated Show resolved Hide resolved
packages/predicate/src/predicate.ts Show resolved Hide resolved
LuizAsFight
LuizAsFight previously approved these changes Feb 20, 2023
Copy link
Member

@arboleya arboleya left a comment

Choose a reason for hiding this comment

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

Great job! 🚀

I've just left a single comment about type overloading (again). All other things I'd request have been requested from others reviewers and implemented already.

The only noteworthy exception is that we don't need to add a new package for this code split. We can DRY stuff by keeping the account.ts and account.test.ts inside the wallet package, removing many boilerplate files that don't need to exist.

packages/address/src/address.ts Show resolved Hide resolved
LuizAsFight
LuizAsFight previously approved these changes Feb 21, 2023
Copy link
Member

@arboleya arboleya left a comment

Choose a reason for hiding this comment

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

@luizstacio Can you please move the account.ts and account.test.ts files inside the wallet package instead of creating a new package for holding only these two files?

Let's try to DRY things, reducing the amount of boilerplate code.

arboleya
arboleya previously approved these changes Feb 21, 2023
Copy link
Member

@arboleya arboleya left a comment

Choose a reason for hiding this comment

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

Beautiful. ❤️

I left some final and minor suggestions regarding the changelogs. ✨

.changeset/clever-chefs-shop.md Outdated Show resolved Hide resolved
.changeset/honest-ways-learn.md Outdated Show resolved Hide resolved
.changeset/nine-bottles-jog.md Outdated Show resolved Hide resolved
arboleya and others added 2 commits February 21, 2023 18:36
Co-authored-by: Anderson Arboleya <anderson@arboleya.me>
luizstacio and others added 2 commits February 21, 2023 10:24
Co-authored-by: Anderson Arboleya <anderson@arboleya.me>
Co-authored-by: Anderson Arboleya <anderson@arboleya.me>
@luizstacio luizstacio requested a review from arboleya February 21, 2023 18:24
@luizstacio luizstacio enabled auto-merge (squash) February 21, 2023 18:42
@arboleya arboleya requested a review from Torres-ssf February 21, 2023 18:43
@luizstacio luizstacio merged commit 66c200a into master Feb 21, 2023
@luizstacio luizstacio deleted the ls/feat/788 branch February 21, 2023 18:47
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.

Allow users to pay for transaction fees using predicates
5 participants