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!: prevent implicit asset burn #3540

Merged
merged 37 commits into from
Jan 10, 2025
Merged

Conversation

petertonysmith94
Copy link
Contributor

@petertonysmith94 petertonysmith94 commented Jan 3, 2025

Release notes

In this release, we:

  • Added a guard to sendTransaction to ensure that we prevent implicit asset burns

Summary

Users can add inputs to a transaction in two ways:

  1. transactionRequest.addCoinInput() or transactionRequest.addMessageInput()
    • These methods automatically adds change outputs if there are none, preventing involuntary asset burn.
  2. transactionRequest.inputs.push({ ... })
    • This, however, is less safe and can result in assets being burned by mistake if users don't also explicitly add output changes via transactionRequest.outputs.push({ ... }).

This PR focuses on the second, less safe method and adds a new check to prevent implicit asset burn unless the enableAssetBurn flag is set to true in the <wallet|provider>.sendTransaction() method.

Breaking Changes

// before
const transactionRequest = new ScriptTransactionRequest();
transactionRequest.inputs.push({ ... });

// since outputs weren't added, assets would be burned
await sender.sendTransaction(transactionRequest);
// after
const transactionRequest = new ScriptTransactionRequest();
transactionRequest.inputs.push({ ... });

// now, an error will be thrown unless `enableAssetBurn`is true,
// in which case, assets can still be burned
await sender.sendTransaction(transactionRequest, {
  enableAssetBurn: true,
});

Checklist

  • All changes are covered by tests (or not applicable)
  • All changes are documented (or not applicable)
  • I reviewed the entire PR myself (preferably, on GH UI)
  • I described all Breaking Changes (or there's none)

@petertonysmith94 petertonysmith94 added the feat Issue is a feature label Jan 3, 2025
@petertonysmith94 petertonysmith94 self-assigned this Jan 3, 2025
Copy link

vercel bot commented Jan 3, 2025

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

Name Status Preview Comments Updated (UTC)
fuels-template ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2025 11:12am
ts-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2025 11:12am
ts-docs-api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2025 11:12am

@petertonysmith94 petertonysmith94 changed the title feat: prevent illicit burn feat: prevent illicit asset burn Jan 3, 2025
@petertonysmith94 petertonysmith94 changed the title feat: prevent illicit asset burn feat: prevent implicit asset burn Jan 3, 2025
packages/fuel-gauge/src/transaction.test.ts Outdated Show resolved Hide resolved
Co-authored-by: Sérgio Torres <[email protected]>
@arboleya arboleya enabled auto-merge (squash) January 10, 2025 10:28
Copy link
Contributor

Coverage Report:

Lines Branches Functions Statements
77.03%(+0.05%) 70.62%(+0.2%) 75.14%(+0.09%) 77.04%(+0.06%)
Changed Files:
Ok File (✨=New File) Lines Branches Functions Statements
🔴 packages/account/src/account.ts 80.58%
(+0%)
71.23%
(+1.37%)
82.5%
(+0%)
80.34%
(+0%)
🔴 packages/account/src/providers/provider.ts 68.76%
(+0.07%)
58.58%
(+0.5%)
70.21%
(+0%)
68.49%
(+0.07%)
🔴 packages/account/src/providers/transaction-request/helpers.ts 100%
(+0%)
97.14%
(+0.99%)
100%
(+0%)
100%
(+0%)
🔴 packages/account/src/providers/transaction-request/transaction-request.ts 88.57%
(+0%)
78.08%
(+1.37%)
84%
(+0%)
88.81%
(+0%)
🔴 packages/account/src/wallet/base-wallet-unlocked.ts 96.29%
(+0.14%)
75%
(+0%)
100%
(+0%)
96.42%
(+0.13%)

@arboleya arboleya merged commit 08a31d8 into master Jan 10, 2025
24 checks passed
@arboleya arboleya deleted the ps/feat/prevent-illicit-burn branch January 10, 2025 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Issue is a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent implicit burn
5 participants