turbo-eth / template-web3-app

⚑️ Web3 App Template built using Next.js, RainbowKit, SIWE, Disco, and more!
https://www.turboeth.xyz
MIT License
334 stars 89 forks source link

Bounty: Delegatable Integration & Subscription Enforcer - 325 OP Reward #56

Open kamescg opened 1 year ago

kamescg commented 1 year ago

πŸ‘¨β€πŸ’» User Story

As a Web3 experience architect I want to create streamlined and user experience optimized transaction flows.

More specifically I want to integrate the Delegatable framework and gas-less subscription services into my Web3 application.

πŸ“œ Disclaimer

To be eligible for the payout you must first get approval to work on the bounty.

It's recommended to share a link to your personal Github account.

🧱 Project

Integrate the delegatable smart contract framework into a TurboETH template.

Integrate the DistrictERC20PermitSubscriptionsEnforcer enforcer smart contract.

Delegatable using rather complex EIP712 signatures to embed transaction execution conditionals directly into a transaction signature.

It's recommended to review the DistrictERC20PermitSubscriptionsEnforcer unit tests to see how implement the terms bytecode packing.

Options You can fork the Gifte Cards template and add the integration in the template.

This will require removing the existing functionality or adding the subscription functionality to the existing user interface.

Or...

Create an integration/streaming-delegatable integration in the TurboETH integrations branch and expose the funcionality in the integrations section.

Either way it's recommended to review the Giftee Cards application to see how delegatable is integrated. The EIP712 signatures can be tricky.

Required Functionality:

Developer Tasks:

Potential File Structure

Integration

The core delegatable-subscription integration should be added to the integrations/delegatable-subscription folder.

integrations/delegatable-subscription
β”œβ”€ components/
β”‚  β”œβ”€ form-delegatable-subscription-start.tsx
β”‚  β”œβ”€ form-delegatable-subscription-revoke.tsx
β”œβ”€ hooks/
β”‚  β”œβ”€ **/*.ts
β”œβ”€ utils/
β”‚  β”œβ”€ **/*.ts
β”œβ”€ delegatable-wagmi.ts
β”œβ”€ delegatable-enforcers-wagmi.ts
β”œβ”€ wagmi.config.ts
β”œβ”€ README.md
Application

The subscription pages should be added to the app/delegatable folder.

app/delegatable
β”œβ”€ subscription
β”‚  β”œβ”€ page.tsx

Resources

Delegatable is a complex smart contract solidity framework. It handles transaction formatting and execution differently, compared to a standard transaction or meta-transaction.

Below is an example of delegatable transaction object.

const INVOCATION_MESSAGE = {
      replayProtection: {
        nonce: '0x01',
        queue: '0x00',
      },
      batch: [
        {
          authority: [],
          transaction: {
            to: verifyingContract.address,
            gasLimit: '210000000000000000',
            data: (
              await verifyingContract.populateTransaction.approveSubscription(
                wallet0.address,
                totalSubscriptionAmount,
                deadline,
                v,
                r,
                s,
              )
            ).data,
          },
        },
        {
          authority: [_delegation],
          transaction: {
            to: verifyingContract.address,
            gasLimit: '210000000000000000',
            data: (await verifyingContract.populateTransaction.paySubscription()).data,
          },
        },
      ],
    };

πŸ’° Bounty Reward

The bounty reward is 325 OP tokens and TurboETH DevPass digital collectible.

TurboETH is the recipient of 18,271.88 OP Tokens from Optimism Retroactive Public Goods Funding. The OP tokens earned from the PGF program are the primary funding source for TurboETH bounties.

Notice

The final integration may not resemble the proposed integration - that's O.K - a natural part of software development.

During development you might discover an original hypothesis doesn't make sense. No problem. Make a comment and clearly explain why a new approach is better than old one. Get rewarded for thinking out of the box.

The final bounty reward can be increased to match new bounty tasks.

Resources

0xJoichiro commented 8 months ago

Interested

ManyRios commented 3 months ago

Hey @kamescg is this available?