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

Support extracting token deposit info from txs #481

Merged
merged 4 commits into from
Dec 13, 2024

Conversation

Lbqds
Copy link
Member

@Lbqds Lbqds commented Dec 10, 2024

No description provided.

@Lbqds Lbqds requested review from polarker and h0ngcha0 December 10, 2024 11:13
Copy link
Member

@h0ngcha0 h0ngcha0 left a comment

Choose a reason for hiding this comment

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

LGTM

return isTransferTx(tx) && checkTokenOutput(tx)
}

export function getTokenDepositInfo(tx: Transaction): {
Copy link
Member

Choose a reason for hiding this comment

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

Does this generate information for ALPH if ALPH and tokens are sent in a single transaction?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it only returns the token info.

Copy link
Member Author

Choose a reason for hiding this comment

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

The latest commit will return the token and ALPH deposit information.

@@ -62,6 +62,7 @@ function getInputAddresses(tx: Transaction): Address[] {
const inputAddresses: Address[] = []
for (const input of tx.unsigned.inputs) {
try {
if (input.unlockScript === '03') continue // SameAsPrevious
Copy link
Member

Choose a reason for hiding this comment

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

IIRC, we have a constant somewhere for 03, should reuse that one.

Copy link
Member Author

Choose a reason for hiding this comment

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

We didn't define encoded SameAsPrevious before, so I added a constant for it in the codec

}

export function getDepositInfo(tx: Transaction): DepositInfo {
if (!isTransferTx) return { alph: [], tokens: [] }
Copy link
Member

Choose a reason for hiding this comment

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

It should be isTransferTx(tx)

@polarker polarker merged commit 08a962a into master Dec 13, 2024
6 of 7 checks passed
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.

3 participants