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 auto transfer mode #235

Open
wants to merge 60 commits into
base: development
Choose a base branch
from

Conversation

hhio618
Copy link

@hhio618 hhio618 commented Jan 6, 2025

Resolves #226

@0x4007
Copy link
Member

0x4007 commented Jan 6, 2025

@gentlementlegen There should be formatting checks with linter and cspell

@gentlementlegen
Copy link
Member

gentlementlegen commented Jan 6, 2025

@0x4007 Yes they seems to happen? The following run failed: https://github.com/ubiquity-os-marketplace/text-conversation-rewards/actions/runs/12629551075/job/35187679129?pr=235

This is what I see
image

@hhio618 hhio618 force-pushed the development branch 3 times, most recently from 52b8f03 to c7d396e Compare January 7, 2025 16:28
@gentlementlegen
Copy link
Member

@hhio618 I saw you marked it as [WIP] in the title, if that's the case this pull-request should be a draft so we don't review it yet.

@hhio618
Copy link
Author

hhio618 commented Jan 8, 2025

@gentlementlegen I'll definitely keep that in mind for the future! For now, this task is ready for review.

@gentlementlegen gentlementlegen changed the title [WIP] feat: add auto transfer mode feat: add auto transfer mode Jan 8, 2025
@gentlementlegen
Copy link
Member

@hhio618 If you can please fix the tests:

FAIL tests/permit-generatable.test.ts
  ● Test suite failed to run

    tests/permit-generatable.test.ts:162:49 - error TS2307: Cannot find module '../src/parser/permit-generation-module' or its corresponding type declarations.

    162 const { PermitGenerationModule } = await import("../src/parser/permit-generation-module");

(cf https://github.com/ubiquity-os-marketplace/text-conversation-rewards/actions/runs/12664483458/job/35292699217?pr=235#step:5:82)

@hhio618
Copy link
Author

hhio618 commented Jan 9, 2025

@gentlementlegen I'm on it! I'll update the PR once the tests are fixed.

@hhio618 hhio618 force-pushed the development branch 2 times, most recently from acd3ea1 to a205697 Compare January 16, 2025 16:35
@hhio618 hhio618 requested a review from whilefoo January 17, 2025 08:37
@whilefoo
Copy link
Member

@hhio618 next time please don't force push because I have to check the whole code again

@hhio618
Copy link
Author

hhio618 commented Jan 20, 2025

@hhio618 next time please don't force push because I have to check the whole code again

Sure, no problem! I'll avoid force-pushing next time to make reviewing easier.

Copy link
Contributor

! No question provided

@hhio618 hhio618 requested a review from whilefoo January 21, 2025 09:47
Copy link
Member

@whilefoo whilefoo left a comment

Choose a reason for hiding this comment

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

You still need to handle RPC retries (exponential backoff), handling reopen issue to avoid transferring multiple times and transaction failures for fatal errors like not enough funds.

For handling reopen issues, you can look at the previous comment and check transaction hashes.
For transaction failures, you proposed Multicall contract but I don't think that will work because msg.sender changes when the Multicall contract calls transfer on the ERC20 contract. @rndquu can you confirm this?

Copy link
Contributor

! No question provided

1 similar comment
Copy link
Contributor

! No question provided

@rndquu
Copy link
Member

rndquu commented Jan 23, 2025

For transaction failures, you proposed Multicall contract but I don't think that will work because msg.sender changes when the Multicall contract calls transfer on the ERC20 contract. @rndquu can you confirm this?

You're right, permit2 doesn't work with Multicall

@whilefoo
Copy link
Member

You're right, permit2 doesn't work with Multicall

ERC20 transfer doesn't work too, right?

@rndquu
Copy link
Member

rndquu commented Jan 23, 2025

You're right, permit2 doesn't work with Multicall

ERC20 transfer doesn't work too, right?

As far as I understand we're trying to solve an issue of transferring ERC20 token to multiple addresses in a single transaction.

While it's technically possible to do so via Multicall it's not safe because user has to set allowance for the Multicall contract first and only then call transferFrom(msg.sender, ...) which means that an advesary may simply call transferFrom(user, ...) which would not revert since the user has already granted allowance for the Multicall contract.

For such kind kind of task we need a contract responsible solely for transferring tokens from msg.sender. The closest thing I've found is this contract. Not sure if it's audited though. We definitely need an audited solution, there must be one somewhere in the wild.

@hhio618 hhio618 requested a review from whilefoo February 13, 2025 16:36
Copy link
Contributor

@hhio618, this task has been idle for a while. Please provide an update.

@ubiquity-os-beta ubiquity-os-beta bot marked this pull request as draft February 17, 2025 05:00
@hhio618 hhio618 marked this pull request as ready for review February 17, 2025 07:58
Copy link
Member

@whilefoo whilefoo left a comment

Choose a reason for hiding this comment

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

Did you QA this? I've just tested it and it doesn't work because when it checks allowance it fails because the ERC20 ABI doesn't contain allowance function. Next time please QA your work to avoid unnecessary reviews.

@hhio618 hhio618 requested a review from whilefoo February 19, 2025 22:45
@hhio618
Copy link
Author

hhio618 commented Feb 19, 2025

Did you QA this? I've just tested it and it doesn't work because when it checks allowance it fails because the ERC20 ABI doesn't contain allowance function. Next time please QA your work to avoid unnecessary reviews.

I apologize for the inconvenience. I’ve attached the QA for reference. Please let me know if there’s anything else I can assist with.

@gentlementlegen
Copy link
Member

@hhio618 Would be nice to fix CI runs as well, thanks.

@hhio618
Copy link
Author

hhio618 commented Feb 20, 2025

@gentlementlegen I’ve addressed the problem. Let me know if you notice anything else or if there’s anything further I can assist with.

Comment on lines 336 to 340
const { data: walletData } = await this._supabase.from("wallets").select("address").eq("id", userId).single();
if (!walletData?.address) {
this.context.logger.error("Beneficiary wallet not found");
return null;
}
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure you are QA-ing correctly, I think you're just generating permits?
When testing I got this error: Beneficiary wallet not found and the error is because the id in wallets table is not an id of a user but an id of a wallet. You can check permit-generation for reference

Copy link
Author

Choose a reason for hiding this comment

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

@whilefoo I’ve double-checked this, and it’s working as expected. Here’s the transaction for QA reference: https://sepolia.etherscan.io/tx/0xec56a4d482fde94a3528e4745ea30145f0d5849fa0d8fe8cc4447952b3a068e2.

Just to note, when I attempted to close the issue for the second time, the result comment was edited. Due to the nonce being invalid, it resulted in no second transfer. Additionally, it seems the GithubCommentModule inadvertently inserted an invalid link into the edited comment.

When testing I got this error: Beneficiary wallet not found and the error is because the id in wallets table is not an id of a user but an id of a wallet. You can check permit-generation for reference

No, I didn't get that error! It might be related to your database configuration. By the way, I'll update it according to the reference.

Copy link
Author

Choose a reason for hiding this comment

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

@whilefoo You're absolutely right about the database part! It looks like my wallets/users table doesn't match the reference. I'm fixing it now!

@hhio618
Copy link
Author

hhio618 commented Feb 21, 2025

@hhio618 hhio618 requested a review from whilefoo February 21, 2025 14:50
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.

Transfers then Permits
6 participants