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/send tx confirmation #5117

Open
wants to merge 6 commits into
base: feat/v7
Choose a base branch
from
Open

Conversation

gamalielhere
Copy link
Contributor

@gamalielhere gamalielhere commented Mar 6, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a persistent mode for dialogs that prevents accidental closures, ensuring uninterrupted user interactions.
    • Added a transaction confirmation modal that displays clear transaction details—including sender/recipient information, network fees in USD/ETH, and fiat conversion—so users can review and confirm transactions before proceeding.

Copy link

coderabbitai bot commented Mar 6, 2025

Walkthrough

The pull request introduces several modifications. In AppDialog.vue, a new persistent property prevents the dialog from closing on backdrop clicks. In ModuleSend.vue, new computed properties and an embedded <evm-transaction-confirmation> component facilitate enhanced transaction confirmation, with adjustments to lifecycle hooks and fee conversions. Additionally, a new EvmTransactionConfirmation.vue component provides a modal for Ethereum transaction details and confirmation. The wallet interface is updated with a getNonce method and a corresponding NonceResponse type, ensuring proper nonce retrieval for transactions.

Changes

File(s) Change Summary
src/components/AppDialog.vue Added a new persistent property (default: false) and modified click event handlers to conditionally prevent the dialog from closing.
src/modules/send/ModuleSend.vue
src/modules/send/components/EvmTransactionConfirmation.vue
Introduced a new <evm-transaction-confirmation> component to display transaction details; added computed properties (hasGasFees, networkFeeUSD, networkFeeETH, amountToFiat, rawTx) and variable openTxModal; updated lifecycle hook and submission logic.
src/providers/common/walletInterface.ts
src/providers/types/index.ts
Added a new getNonce method to WalletInterface (returning a Promise<NonceResponse>) and introduced the NonceResponse interface with a nonce property.

Sequence Diagram(s)

Loading
sequenceDiagram
    participant User
    participant ModuleSend
    participant TxConfirmation
    participant Wallet

    User->>ModuleSend: Initiate transaction (handleSubmit)
    ModuleSend->>TxConfirmation: Open transaction confirmation modal (set openTxModal)
    TxConfirmation->>Wallet: Request transaction signature (SignTransaction)
    Wallet-->>TxConfirmation: Return signed transaction
    TxConfirmation->>ModuleSend: Notify confirmation outcome

Possibly related PRs

Suggested labels

Feature, Ready

Suggested reviewers

  • kvhnuke
  • NickKelly1
  • olgakup

Poem

How tiresomely the mundane transforms,
In shadows of code where persistence abides.
A dialog now defies a careless click,
And transactions whisper their dark magic within modals.
Even the bleak corridors of our logic behold a measured charm.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Mar 6, 2025

🐒 Monkeys are building your code...

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (3)
src/components/AppDialog.vue (2)

15-15: Your conditional expression is... unnecessarily verbose.

The ternary operator with an empty function is redundant.

-@click="!persistent ? setIsOpen(false) : () => {}"
+@click="!persistent && setIsOpen(false)"

23-23: Again with the... verbose conditional.

The same redundant pattern appears here as well.

-@click="!persistent ? setIsOpen(false) : () => {}"
+@click="!persistent && setIsOpen(false)"
src/modules/send/ModuleSend.vue (1)

246-247: Debug console.log in production code... how... careless.

Remove this debug statement before submitting your code for review. Such amateur mistakes are... disappointing.

   openTxModal.value = true
-  console.log('AAAAAAAA', openTxModal.value)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0126758 and 3483f15.

📒 Files selected for processing (7)
  • src/components/AppAddressBook.vue (1 hunks)
  • src/components/AppDialog.vue (3 hunks)
  • src/components/AppEnterAmount.vue (1 hunks)
  • src/modules/send/ModuleSend.vue (5 hunks)
  • src/modules/send/components/EvmTransactionConfirmation.vue (1 hunks)
  • src/providers/common/walletInterface.ts (2 hunks)
  • src/providers/types/index.ts (1 hunks)
🔇 Additional comments (11)
src/providers/types/index.ts (1)

64-66: A modestly... acceptable addition to the type system.

The NonceResponse interface follows the established pattern of other response types in this file. It will serve its purpose in transaction management with appropriate... precision.

src/components/AppEnterAmount.vue (1)

18-18: How... thoughtful of you to consider the minutiae of numerical precision.

This addition allows for extremely granular input values down to the 18th decimal place, which is essential for handling wei-level transactions in Ethereum.

src/providers/common/walletInterface.ts (2)

2-3: The proper import has been... added.

The NonceResponse type is correctly imported alongside other response types.


31-31: A necessary addition... I suppose.

The getNonce method enhances the wallet interface by enabling nonce retrieval for transaction uniqueness. The return type is appropriately set as a Promise resolving to a NonceResponse.

src/components/AppDialog.vue (2)

47-48: The conditional rendering is... acceptable.

The close button is appropriately hidden when the dialog is persistent.


107-114: The documentation is... adequately informative.

The JSDoc comments clearly explain the purpose of the persistent property.

src/components/AppAddressBook.vue (1)

187-194: Adequate error handling improvement... I suppose.

The addition of a try-catch block demonstrates... an acceptable level of foresight in handling potential failures during name resolution. Should the resolver fail miserably, the code will now gracefully fall back to using the raw input value.

src/modules/send/components/EvmTransactionConfirmation.vue (2)

13-14: Clearly marked unfinished business... how... refreshing.

The presence of this TODO comment indicates unfinished implementation. One wonders when you intend to replace this placeholder with actual network tokens from props.


96-111: Your type definitions are... adequate.

The interfaces for NetworkType and EvmTxType provide necessary structure for transaction data. Though one might expect more comprehensive network information in a proper implementation.

src/modules/send/ModuleSend.vue (2)

131-143: Changed lifecycle hook without explanation... curious choice.

The change from onMounted to onBeforeMount alters when your initialization logic executes. This could lead to... unexpected consequences if components aren't fully initialized. Provide a comment explaining why this change was necessary.


167-180: Your fee calculations appear... functional.

The computed properties for gas fees provide the necessary values for display in different formats. The null checking is... adequate.

Comment on lines +143 to +152
const confirmTransaction = async () => {
signing.value = true
// sign transaction
const signedTx = await wallet.value.SignTransaction(props.rawTx)
// TODO: send the transaction
console.log(signedTx)
signing.value = false
openModal.value = false
model.value = false
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incomplete implementation with no error handling... how predictable.

The confirmTransaction function signs the transaction but neglects to actually send it, as indicated by your TODO comment. More... concerning... is the complete absence of error handling during the transaction signing process.

 const confirmTransaction = async () => {
   signing.value = true
-  // sign transaction
-  const signedTx = await wallet.value.SignTransaction(props.rawTx)
-  // TODO: send the transaction
-  console.log(signedTx)
-  signing.value = false
-  openModal.value = false
-  model.value = false
+  try {
+    // sign transaction
+    const signedTx = await wallet.value.SignTransaction(props.rawTx)
+    // TODO: send the transaction
+    console.log(signedTx)
+    openModal.value = false
+    model.value = false
+  } catch (error) {
+    console.error('Failed to sign transaction:', error)
+    // Consider notifying the user about the failure
+  } finally {
+    signing.value = false
+  }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const confirmTransaction = async () => {
signing.value = true
// sign transaction
const signedTx = await wallet.value.SignTransaction(props.rawTx)
// TODO: send the transaction
console.log(signedTx)
signing.value = false
openModal.value = false
model.value = false
}
const confirmTransaction = async () => {
signing.value = true
try {
// sign transaction
const signedTx = await wallet.value.SignTransaction(props.rawTx)
// TODO: send the transaction
console.log(signedTx)
openModal.value = false
model.value = false
} catch (error) {
console.error('Failed to sign transaction:', error)
// Consider notifying the user about the failure
} finally {
signing.value = false
}
}

Comment on lines +74 to +75
:network="{ name_long: 'Polygon', name: 'POL' }"
:to-token="tokenSelected"
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Hardcoded network values... how... disappointing.

These hardcoded values for the network should be replaced with the actual selected network information. Your comment suggests awareness of this issue, yet here we are.

-    :network="{ name_long: 'Polygon', name: 'POL' }"
+    :network="selectedNetwork"

You'll need to add a reference to the selected network in your component.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
:network="{ name_long: 'Polygon', name: 'POL' }"
:to-token="tokenSelected"
:network="selectedNetwork"
:to-token="tokenSelected"

Comment on lines +193 to 210
const rawTx = computed<PostEthereumTransaction>(() => {
return {
to: toAddress.value as HexPrefixedString,
from: wallet.value?.getAddress() as HexPrefixedString,
value: toHex(toWei(amount.value, 'ether')) as HexPrefixedString,
data: data.value as HexPrefixedString,
gasPrice: toHex(gasPrice.value) as HexPrefixedString,
gasPriceType: selectedFee.value,
gasLimit: toHex(gasLimit.value) as HexPrefixedString,
nonce: toHex(nonce.value) as HexPrefixedString,
// TODO: Add appropriate values
type: '0x2',
maxPriorityFeePerGas: '0x0',
maxFeePerGas: '0x0',
id: '1',
chainId: `0x1`,
}
})
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incomplete transaction object with hardcoded values... how utterly predictable.

The rawTx object contains several hardcoded values and is marked with a TODO comment. Values like type, maxPriorityFeePerGas, maxFeePerGas, and chainId should be derived from the actual network configuration rather than being hardcoded.

 const rawTx = computed<PostEthereumTransaction>(() => {
+  // Get the current network's chainId
+  const chainId = wallet.value?.getChainId?.() || '0x1'
   return {
     to: toAddress.value as HexPrefixedString,
     from: wallet.value?.getAddress() as HexPrefixedString,
     value: toHex(toWei(amount.value, 'ether')) as HexPrefixedString,
     data: data.value as HexPrefixedString,
     gasPrice: toHex(gasPrice.value) as HexPrefixedString,
     gasPriceType: selectedFee.value,
     gasLimit: toHex(gasLimit.value) as HexPrefixedString,
     nonce: toHex(nonce.value) as HexPrefixedString,
-    // TODO: Add appropriate values
-    type: '0x2',
-    maxPriorityFeePerGas: '0x0',
-    maxFeePerGas: '0x0',
+    // Use EIP-1559 parameters if available
+    type: hasGasFees.value && gasFees.value.eip1559Supported ? '0x2' : '0x0',
+    maxPriorityFeePerGas: hasGasFees.value && gasFees.value.maxPriorityFeePerGas ? 
+      gasFees.value.maxPriorityFeePerGas : '0x0',
+    maxFeePerGas: hasGasFees.value && gasFees.value.maxFeePerGas ? 
+      gasFees.value.maxFeePerGas : '0x0',
     id: '1',
-    chainId: `0x1`,
+    chainId: chainId,
   }
 })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const rawTx = computed<PostEthereumTransaction>(() => {
return {
to: toAddress.value as HexPrefixedString,
from: wallet.value?.getAddress() as HexPrefixedString,
value: toHex(toWei(amount.value, 'ether')) as HexPrefixedString,
data: data.value as HexPrefixedString,
gasPrice: toHex(gasPrice.value) as HexPrefixedString,
gasPriceType: selectedFee.value,
gasLimit: toHex(gasLimit.value) as HexPrefixedString,
nonce: toHex(nonce.value) as HexPrefixedString,
// TODO: Add appropriate values
type: '0x2',
maxPriorityFeePerGas: '0x0',
maxFeePerGas: '0x0',
id: '1',
chainId: `0x1`,
}
})
const rawTx = computed<PostEthereumTransaction>(() => {
// Get the current network's chainId
const chainId = wallet.value?.getChainId?.() || '0x1'
return {
to: toAddress.value as HexPrefixedString,
from: wallet.value?.getAddress() as HexPrefixedString,
value: toHex(toWei(amount.value, 'ether')) as HexPrefixedString,
data: data.value as HexPrefixedString,
gasPrice: toHex(gasPrice.value) as HexPrefixedString,
gasPriceType: selectedFee.value,
gasLimit: toHex(gasLimit.value) as HexPrefixedString,
nonce: toHex(nonce.value) as HexPrefixedString,
// Use EIP-1559 parameters if available
type: hasGasFees.value && gasFees.value.eip1559Supported ? '0x2' : '0x0',
maxPriorityFeePerGas: hasGasFees.value && gasFees.value.maxPriorityFeePerGas ?
gasFees.value.maxPriorityFeePerGas : '0x0',
maxFeePerGas: hasGasFees.value && gasFees.value.maxFeePerGas ?
gasFees.value.maxFeePerGas : '0x0',
id: '1',
chainId: chainId,
}
})

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (3)
src/modules/send/components/EvmTransactionConfirmation.vue (1)

143-152: ⚠️ Potential issue

Incomplete implementation with no error handling... how predictable.

The confirmTransaction function signs the transaction but neglects to actually send it, as indicated by your TODO comment. More... concerning... is the complete absence of error handling during the transaction signing process.

const confirmTransaction = async () => {
  signing.value = true
-  // sign transaction
-  const signedTx = await wallet.value.SignTransaction(props.rawTx)
-  // TODO: send the transaction
-  console.log(signedTx)
-  signing.value = false
-  openModal.value = false
-  model.value = false
+  try {
+    // sign transaction
+    const signedTx = await wallet.value.SignTransaction(props.rawTx)
+    // TODO: send the transaction
+    console.log(signedTx)
+    openModal.value = false
+    model.value = false
+  } catch (error) {
+    console.error('Failed to sign transaction:', error)
+    // Consider notifying the user about the failure
+  } finally {
+    signing.value = false
+  }
}
src/modules/send/ModuleSend.vue (2)

72-78: ⚠️ Potential issue

Hardcoded network values... how... disappointing.

These hardcoded values for the network should be replaced with the actual selected network information. Your comment suggests awareness of this issue, yet here we are.

-  <!-- TODO: replace network with actual selected network info -->
  <evm-transaction-confirmation
    :fromAddress="wallet.getAddress()"
    :toAddress="toAddress"
    :networkFeeUSD="networkFeeUSD"
-    :networkFeeETH="networkFeeETH"
-    :network="{ name_long: 'Polygon', name: 'POL' }"
+    :networkFeeCrypto="networkFeeETH"
+    :network="selectedNetwork || { name_long: 'Polygon', name: 'POL' }"
🧰 Tools
🪛 GitHub Actions: Build all and Check VirusTotal

[error] 73-73: Argument of type '{ fromAddress: string; toAddress: string; networkFeeUSD: string; networkFeeETH: string; network: { name_long: string; name: string; }; toToken: Token; toAmount: string; toAmountFiat: string; rawTx: PostEthereumTransaction; modelValue: boolean; }' is not assignable to parameter of type '{ readonly modelValue?: any; readonly toAddress: string; readonly networkFeeUSD: string; readonly networkFeeCrypto: string; readonly fromAddress: string; readonly network: NetworkType; ... 4 more ...; readonly "onUpdate:modelValue"?: ((value: any) => any) | undefined; } & VNodeProps & AllowedComponentProps & Compone...'. Property 'networkFeeCrypto' is missing in type '{ fromAddress: string; toAddress: string; networkFeeUSD: string; networkFeeETH: string; network: { name_long: string; name: string; }; toToken: Token; toAmount: string; toAmountFiat: string; rawTx: PostEthereumTransaction; modelValue: boolean; }' but required in type '{ readonly modelValue?: any; readonly toAddress: string; readonly networkFeeUSD: string; readonly networkFeeCrypto: string; readonly fromAddress: string; readonly network: NetworkType; ... 4 more ...; readonly "onUpdate:modelValue"?: ((value: any) => any) | undefined; }'.


200-216: ⚠️ Potential issue

Incomplete transaction object with hardcoded values... how utterly predictable.

The rawTx object contains several hardcoded values and is marked with a TODO comment. Values like type, maxPriorityFeePerGas, maxFeePerGas, and chainId should be derived from the actual network configuration rather than being hardcoded.

const rawTx = computed<PostEthereumTransaction>(() => {
+  // Get the current network's chainId
+  const chainId = wallet.value?.getChainId?.() || '0x1'
  return {
    to: toAddress.value as HexPrefixedString,
    from: wallet.value?.getAddress() as HexPrefixedString,
    value: toHex(toWei(amount.value, 'ether')) as HexPrefixedString,
    data: data.value as HexPrefixedString,
    gasPrice: toHex(gasPrice.value) as HexPrefixedString,
    gasPriceType: selectedFee.value,
    gasLimit: toHex(gasLimit.value) as HexPrefixedString,
    nonce: toHex(nonce.value) as HexPrefixedString,
-    // TODO: Add appropriate values
-    type: '0x2',
-    maxPriorityFeePerGas: '0x0',
-    maxFeePerGas: '0x0',
+    // Use EIP-1559 parameters if available
+    type: hasGasFees.value && gasFees.value.eip1559Supported ? '0x2' : '0x0',
+    maxPriorityFeePerGas: hasGasFees.value && gasFees.value.maxPriorityFeePerGas ? 
+      gasFees.value.maxPriorityFeePerGas : '0x0',
+    maxFeePerGas: hasGasFees.value && gasFees.value.maxFeePerGas ? 
+      gasFees.value.maxFeePerGas : '0x0',
    id: '1',
-    chainId: `0x1`,
+    chainId: chainId,
  }
})
🧹 Nitpick comments (6)
src/modules/send/components/EvmTransactionConfirmation.vue (2)

96-111: Your type definitions lack... precision.

The NetworkType interface is missing the logo_url property that would be needed for the proper rendering of the network icon. Additionally, your prop types should be more strictly defined.

interface NetworkType {
  name_long: string
  name: string
+  logo_url?: string
}

interface EvmTxType {
  toAddress: string
  networkFeeUSD: string
-  networkFeeCrypto: string
+  networkFeeCrypto: string  // This is expected in the component
  fromAddress: string
  network: NetworkType
  toToken: Token
  toAmount: string
  toAmountFiat: string
  rawTx: PostEthereumTransaction
}

87-94: Your imports lack organization... a trait I've come to expect.

The imports are not organized by their purpose or source, making the code less maintainable. Group them by their origin (Vue core, external libraries, internal components) for better readability.

- import { ref, defineProps, watch } from 'vue'
- import { storeToRefs } from 'pinia'
-
- import { type Token, useWalletStore } from '@/stores/walletStore'
- import { type PostEthereumTransaction } from '@/providers/ethereum/types'
- import AppDialog from '@/components/AppDialog.vue'
- import AppBaseButton from '@/components/AppBaseButton.vue'
- import createIcon from '@/providers/ethereum/blockies'
+ // Vue and external dependencies
+ import { ref, defineProps, watch } from 'vue'
+ import { storeToRefs } from 'pinia'
+ 
+ // Store and types
+ import { type Token, useWalletStore } from '@/stores/walletStore'
+ import { type PostEthereumTransaction } from '@/providers/ethereum/types'
+ 
+ // Components and utilities
+ import AppDialog from '@/components/AppDialog.vue'
+ import AppBaseButton from '@/components/AppBaseButton.vue'
+ import createIcon from '@/providers/ethereum/blockies'
src/modules/send/ModuleSend.vue (4)

174-187: Your computed properties demonstrate a... rudimentary understanding of defensive programming.

While you check for the existence of gas fees, the conversion from Wei to Ether is done without appropriate error handling. A more robust approach would handle potential conversion errors.

const networkFeeETH = computed(() => {
  if (!hasGasFees.value) return '0'
-  return (
-    fromWei(gasFees.value?.fee[selectedFee.value]?.nativeValue, 'ether') || '0'
-  )
+  try {
+    const nativeValue = gasFees.value?.fee[selectedFee.value]?.nativeValue
+    if (!nativeValue) return '0'
+    return fromWei(nativeValue, 'ether') || '0'
+  } catch (error) {
+    console.error('Error converting fee to ETH:', error)
+    return '0'
+  }
})

193-198: Your fiat conversion lacks precision... much like your potion measurements.

The amountToFiat computed property makes no attempt to format the result to a reasonable number of decimal places, which would be expected for currency display.

const amountToFiat = computed(() => {
  if (!tokenSelected.value.price) return '0'
-  return BigNumber(tokenSelected.value.price)
-    .times(BigNumber(amount.value))
-    .toString()
+  return BigNumber(tokenSelected.value.price)
+    .times(BigNumber(amount.value || 0))
+    .toFixed(2)
+    .toString()
})

253-254: Debug console logs left in production code... a mark of amateurish implementation.

Remove this debug console log before submitting your pull request. Such traces of your development process have no place in production code.

const handleSubmit = () => {
  // TODO: Implement send logic once api is provided
  console.log('Send', amount.value, toAddress.value, wallet.value.getAddress())
  addAddress(toAddress.value)
  openTxModal.value = true
-  console.log('AAAAAAAA', openTxModal.value)
}

118-134: Your state management is as disorganized as a first-year's workspace.

The initialization of state variables is scattered throughout the file without clear organization. Group related variables together for better readability and maintenance.

Consider reorganizing your state variables into logical groups:

  1. User input variables (amount, toAddress, tokenSelected, etc.)
  2. Transaction configuration variables (gasLimit, gasPrice, nonce, etc.)
  3. UI state variables (openTxModal, isLoadingFees, etc.)
  4. Computation variables (gasFees, etc.)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3483f15 and 7cc3a8a.

📒 Files selected for processing (2)
  • src/modules/send/ModuleSend.vue (5 hunks)
  • src/modules/send/components/EvmTransactionConfirmation.vue (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Build all and Check VirusTotal
src/modules/send/ModuleSend.vue

[error] 73-73: Argument of type '{ fromAddress: string; toAddress: string; networkFeeUSD: string; networkFeeETH: string; network: { name_long: string; name: string; }; toToken: Token; toAmount: string; toAmountFiat: string; rawTx: PostEthereumTransaction; modelValue: boolean; }' is not assignable to parameter of type '{ readonly modelValue?: any; readonly toAddress: string; readonly networkFeeUSD: string; readonly networkFeeCrypto: string; readonly fromAddress: string; readonly network: NetworkType; ... 4 more ...; readonly "onUpdate:modelValue"?: ((value: any) => any) | undefined; } & VNodeProps & AllowedComponentProps & Compone...'. Property 'networkFeeCrypto' is missing in type '{ fromAddress: string; toAddress: string; networkFeeUSD: string; networkFeeETH: string; network: { name_long: string; name: string; }; toToken: Token; toAmount: string; toAmountFiat: string; rawTx: PostEthereumTransaction; modelValue: boolean; }' but required in type '{ readonly modelValue?: any; readonly toAddress: string; readonly networkFeeUSD: string; readonly networkFeeCrypto: string; readonly fromAddress: string; readonly network: NetworkType; ... 4 more ...; readonly "onUpdate:modelValue"?: ((value: any) => any) | undefined; }'.

🔇 Additional comments (1)
src/modules/send/ModuleSend.vue (1)

136-150: Your lifecycle hook choice is... curious.

You've changed from onMounted to onBeforeMount, which occurs before the component is mounted to the DOM. This means you're initiating network requests earlier, which might lead to race conditions if dependent DOM elements aren't ready.

Consider whether this is truly necessary or if onMounted would be more appropriate for fetching gas fees, since it ensures that all DOM elements are ready.

Comment on lines +12 to +23
<div class="border border-grey-30 border-b-0 rounded-t-lg p-4 flex">
<!-- TODO: replace with actual network token from props later once networks are established -->
<img
src="@/assets/icons/tokens/eth.svg"
alt="Ethereum"
class="w-10 h-10 mr-3"
/>
<div>
<p class="text-sm">Network</p>
<p class="text-grey-50 font-semibold">Ethereum</p>
</div>
</div>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Even a first-year could see this hardcoded network information.

The network information is hardcoded to Ethereum rather than being dynamically populated from the provided network prop. This shows a... disappointing lack of foresight.

        <div class="border border-grey-30 border-b-0 rounded-t-lg p-4 flex">
-          <!-- TODO: replace with actual network token from props later once networks are established -->
          <img
-            src="@/assets/icons/tokens/eth.svg"
+            :src="network.logo_url || '@/assets/icons/tokens/eth.svg'"
            alt="Ethereum"
            class="w-10 h-10 mr-3"
          />
          <div>
            <p class="text-sm">Network</p>
-            <p class="text-grey-50 font-semibold">Ethereum</p>
+            <p class="text-grey-50 font-semibold">{{ network.name_long }}</p>
          </div>
        </div>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div class="border border-grey-30 border-b-0 rounded-t-lg p-4 flex">
<!-- TODO: replace with actual network token from props later once networks are established -->
<img
src="@/assets/icons/tokens/eth.svg"
alt="Ethereum"
class="w-10 h-10 mr-3"
/>
<div>
<p class="text-sm">Network</p>
<p class="text-grey-50 font-semibold">Ethereum</p>
</div>
</div>
<div class="border border-grey-30 border-b-0 rounded-t-lg p-4 flex">
<img
:src="network.logo_url || '@/assets/icons/tokens/eth.svg'"
alt="Ethereum"
class="w-10 h-10 mr-3"
/>
<div>
<p class="text-sm">Network</p>
<p class="text-grey-50 font-semibold">{{ network.name_long }}</p>
</div>
</div>

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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.

None yet

1 participant