Skip to content

Conversation

@ivanfong01
Copy link
Contributor

Description

solves #1157
reorganised to remove unnecessary rebased commit
As no event will be emitted for transfer action, it will parse the arguments for the following function if the status is success:

  • 0x1::aptos_account::transfer_fungible_assets
  • 0x1::aptos_account::batch_transfer_fungible_assets
  • 0x1::aptos_account::transfer_coins
  • 0x1::aptos_account::batch_transfer_coins
  • 0x1::primary_fungible_store::transfer

This is a interim solution right now. Only work for using those entry function directly. Maybe the 0x1 library should consider emitting transfer event.

image

Related Links

For verifying - view Binance's addresses
https://explorer.aptoslabs.com/account/0xae1a6f3d3daccaf77b55044cea133379934bba04a11b9d0bbd643eae5e6e9c70?network=mainnet

Checklist

@gregnazario gregnazario requested a review from Copilot August 17, 2025 02:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements parsing of 0x1 FA/Coin transfer functions to display transfer actions in the user transaction overview tab. Since no events are emitted for transfer actions, the solution parses function arguments directly from successful transactions.

  • Adds support for parsing 5 different transfer functions from the 0x1 module
  • Introduces new function-based action parsing alongside existing event-based parsing
  • Displays transfer actions with sender, recipient, asset, and amount information

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@gregnazario gregnazario requested a review from Copilot September 11, 2025 02:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 6 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +1227 to +1232
asset:
payload.arguments[0] &&
typeof payload.arguments[0] === "object" &&
"inner" in payload.arguments[0]
? payload.arguments[0].inner
: undefined,
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

The asset value could be undefined, but the AssetTransfer type expects asset to be a string. This will cause type mismatch errors when rendering.

Copilot uses AI. Check for mistakes.
Comment on lines +1246 to +1251
asset:
payload.arguments[0] &&
typeof payload.arguments[0] === "object" &&
"inner" in payload.arguments[0]
? payload.arguments[0].inner
: undefined,
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

Same issue as above - asset could be undefined but AssetTransfer type expects string.

Copilot uses AI. Check for mistakes.
Comment on lines +1264 to +1268
asset:
Array.isArray(payload.type_arguments) &&
payload.type_arguments.length > 0
? payload.type_arguments.join("::")
: "unknown",
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

Inconsistent fallback values: 'unknown' is used here while undefined is used in the FA cases above. Consider using consistent fallback handling across all asset parsing.

Copilot uses AI. Check for mistakes.
Comment on lines +1286 to +1290
asset:
Array.isArray(payload.type_arguments) &&
payload.type_arguments.length > 0
? payload.type_arguments.join("::")
: "unknown",
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

Same inconsistent fallback issue as Comment 3.

Copilot uses AI. Check for mistakes.
Comment on lines +1237 to +1253
for (let i = 0; i < payload.arguments[1].length; i++) {
actions.push({
actionType: "asset transfer",
from: sender,
to:
payload.arguments[1][i] &&
typeof payload.arguments[1][i] === "string"
? payload.arguments[1][i]
: "unknown",
asset:
payload.arguments[0] &&
typeof payload.arguments[0] === "object" &&
"inner" in payload.arguments[0]
? payload.arguments[0].inner
: undefined,
amount: Number(payload.arguments[2][i]),
});
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

No validation that payload.arguments[1] exists or is an array before accessing .length property. This could cause runtime errors.

Suggested change
for (let i = 0; i < payload.arguments[1].length; i++) {
actions.push({
actionType: "asset transfer",
from: sender,
to:
payload.arguments[1][i] &&
typeof payload.arguments[1][i] === "string"
? payload.arguments[1][i]
: "unknown",
asset:
payload.arguments[0] &&
typeof payload.arguments[0] === "object" &&
"inner" in payload.arguments[0]
? payload.arguments[0].inner
: undefined,
amount: Number(payload.arguments[2][i]),
});
if (Array.isArray(payload.arguments[1])) {
for (let i = 0; i < payload.arguments[1].length; i++) {
actions.push({
actionType: "asset transfer",
from: sender,
to:
payload.arguments[1][i] &&
typeof payload.arguments[1][i] === "string"
? payload.arguments[1][i]
: "unknown",
asset:
payload.arguments[0] &&
typeof payload.arguments[0] === "object" &&
"inner" in payload.arguments[0]
? payload.arguments[0].inner
: undefined,
amount: Number(payload.arguments[2][i]),
});
}

Copilot uses AI. Check for mistakes.
Array.isArray(payload.arguments[1]) &&
Array.isArray(payload.arguments[0])
) {
for (let i = 0; i < payload.arguments[1].length; i++) {
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

Same issue as Comment 5 - accessing .length without validation that payload.arguments[1] exists.

Copilot uses AI. Check for mistakes.
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.

1 participant