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: add prepareForSend for EVM and SVM connector #477

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

danielbate
Copy link
Member

@danielbate danielbate commented Feb 11, 2025

  • Closes FE-1490

Summary

  1. Added usePrepareForSend = true flag to connectors to indicate support for the inverted flow
  2. Implemented prepareForSend method in all connectors that:
    • Prepares and signs transactions
    • Returns the prepared transaction without submitting it
  3. Refactored predicate-based connectors (EVM, Solana, WalletConnect) to use a shared helper method for transaction preparation

Checklist

  • I've added error handling for all actions/requests, and verified how this error will show on UI. (or there was no error handling)
  • I've reviewed all the copy changed/added in this PR, using AI if needed. (or there was no copy changes)
  • I've included the reference to the issues being closed from Github and/or Linear (or there was no issues)
  • I've changed the Docs to reflect my changes (or it was not needed)
  • I've put docs links where it may be helpful (or it was not needed)
  • I checked the resulting UI both in Light and Dark mode (or no UI changes were made)
  • I reviewed the entire PR myself (preferably, on GH UI)

Copy link

vercel bot commented Feb 11, 2025

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

Name Status Preview Comments Updated (UTC)
fuel-connectors ❌ Failed (Inspect) Feb 27, 2025 11:54pm

@danielbate danielbate changed the title feat: add prepareForSend for EVM and SVM connecot feat: add prepareForSend for EVM and SVM connector Feb 11, 2025
Copy link
Contributor

github-actions bot commented Feb 11, 2025

Coverage Report for Fuel Wallet (./packages/fuel-wallet)

Status Category Percentage Covered / Total
🔵 Lines 62.39% 151 / 242
🔵 Statements 62.39% 151 / 242
🔵 Functions 56.66% 17 / 30
🔵 Branches 68.75% 22 / 32
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/fuel-wallet/src/FuelWalletConnector.ts 59.91% 67.74% 56.66% 59.91% 71-78, 82-89, 93, 97-98, 101-102, 105-112, 115-116, 119-126, 129-133, 136-145, 153-154, 158-163, 206-207, 241-242, 248-265, 305-312
Generated in workflow #1476 for commit a8ed72c by the Vitest Coverage Report Action

Copy link
Contributor

github-actions bot commented Feb 11, 2025

Coverage Report for Fuel Development Wallet (./packages/fuel-development-wallet)

Status Category Percentage Covered / Total
🔵 Lines 100% 19 / 19
🔵 Statements 100% 19 / 19
🔵 Functions 100% 1 / 1
🔵 Branches 100% 1 / 1
File CoverageNo changed files found.
Generated in workflow #1475 for commit 8df536f by the Vitest Coverage Report Action

Copy link
Contributor

github-actions bot commented Feb 11, 2025

Coverage Report for Fuelet Wallet (./packages/fuelet-wallet)

Status Category Percentage Covered / Total
🔵 Lines 40.9% 27 / 66
🔵 Statements 40.9% 27 / 66
🔵 Functions 33.33% 1 / 3
🔵 Branches 100% 1 / 1
File CoverageNo changed files found.
Generated in workflow #1475 for commit 8df536f by the Vitest Coverage Report Action

@@ -56,6 +57,7 @@ export class EVMWalletConnector extends PredicateConnector {
private _currentAccount: string | null = null;
private config: EVMWalletConnectorConfig = {};
private _ethereumEvents = 0;
usePrepareForSend = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

@petertonysmith94 @danielbate
makes sense to the need for this flag? the sdk could just verify if prepareForSend method exists

Copy link
Contributor

Choose a reason for hiding this comment

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

The prepareForSend method is on the abstract FuelConnector class, and therefore, this method will always exist. Open to suggestions if you have another solution for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

it can't be optional?

Copy link
Contributor

Choose a reason for hiding this comment

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

As it's an abstract method on the abstract class, it can't be optional. We could introduce a new interface that the underlying connector would implement, however, this could lead to unexpected behaviours with the Fuel SDK.

interface PrepareForSendConnector {
  prepareForSend(
    address: string,
    transaction: TransactionRequestLike
  ): Promise<TransactionRequestLike>;
}

IMO the flag is simple and explicit.

Copy link
Contributor

Choose a reason for hiding this comment

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

it can't be an optional method in the abstract class?

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