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 guardian funds retrieval function #7

Open
machuwey opened this issue Nov 4, 2024 · 39 comments
Open

feat: add guardian funds retrieval function #7

machuwey opened this issue Nov 4, 2024 · 39 comments
Labels
cairo good first issue Good for newcomers

Comments

@machuwey
Copy link
Collaborator

machuwey commented Nov 4, 2024

Enhancing Owner Inaccessibility Handling for strapex_child_contract

Issue Definition

When deploying a strapex_child_contract, which functions as a linked business account, there is a potential risk where the owner may lose access to their wallet. This scenario could occur due to various reasons, such as:

  • Loss of Private Keys: The owner might lose access to their private keys, making it impossible to manage the contract.
  • Prolonged Inactivity: The owner may become inactive for an extended period, unable to interact with the contract.
  • Major Life Events: Significant events (e.g., passing away, incapacitation) could prevent the owner from accessing the contract.
  • Acquaintance Access: In cases where the owner becomes successful, an acquaintance might need access to manage or retrieve funds.

To mitigate these risks, it's essential to implement a fallback mechanism that allows a designated party (e.g., the factory deployer) to withdraw funds from the strapex_child_contract if the owner has not interacted with the contract within a specified timeframe (e.g., one year).

Proposed Solution

Implement a time-based inactivity mechanism within the strapex_child_contract to track the last interaction timestamp of the owner. If the owner does not interact with the contract for a predetermined period (e.g., one year), the factory deployer gains the authority to withdraw funds from the contract.

Steps to Achieve the Solution

  1. Add a last_interaction Timestamp:
    Introduce a last_interaction field in the contract's storage to record the timestamp of the last owner's interaction.

  2. Update last_interaction on Owner Interactions:
    Modify all functions where the owner interacts with the contract to update the last_interaction timestamp.

  3. Implement a Withdrawal Mechanism for Factory Deployer:
    Add a function that allows the factory deployer to withdraw funds if the last_interaction exceeds the specified inactivity period.

    • Ensure that this function can only be called by the factory deployer and only after the inactivity period has elapsed.
  4. Integrate with the Factory Contract:
    Ensure that the factory contract is aware of the mechanism and can call the withdrawal function when necessary.

Please, consider writing also tests for this functionality.

Instructions to apply

  1. Introduce yourself, tell about your background, etc.
  2. Describe shortly how you plan to tackle the issue
@machuwey machuwey added good first issue Good for newcomers cairo labels Nov 4, 2024
@sandragcarrillo
Copy link

Hi, I would like to contribute to solve this issue. I have been learning Cairo and I think I have the knowledge to solve it

@machuwey
Copy link
Collaborator Author

machuwey commented Nov 9, 2024

Hi, I would like to contribute to solve this issue. I have been learning Cairo and I think I have the knowledge to solve it

@sandragcarrillo I'm happy for your interest in this issue. We are getting the issues ready for the next ODHack which will be celebrated at the end of the month, please, consider registering here OnlyDust and join Strapex Telegram where further announcements will be posted.

@Krishn1412
Copy link

I’d like to help with this.

@ikemHood
Copy link

I would be happy to solve this as soon as ODHack resume

@codebestia
Copy link

codebestia commented Nov 21, 2024

Can i work on this? @machuwey

I am a blockchain developer with ample experience in building smart contracts. I recently started my cairo journey and i believe i am able to completer this task

@Gerson2102
Copy link

strapex

Hey! I'm Gerson. 👋

I'm a member of Dojo Coding and have previously contributed to many projects such as:

  • kakarot-rpc
  • ef-tests
  • Madara
  • Raito
  • Starknet-Phone

I would like to work on this issue.

You can check my OnlyDust profile to see my contributions to various projects: Profile


Plan to Solve the Issue:

  1. Understand the Current Implementation:

    • Review the existing strapex_child_contract to comprehend how owner interactions and fund management are currently handled.
    • Identify where the new inactivity mechanism needs to be integrated.
  2. Design the Inactivity Mechanism:

    • Add a last_interaction Timestamp:
      • Introduce a last_interaction variable in the contract's storage to record the timestamp of the owner's last interaction.
    • Update last_interaction on Owner Actions:
      • Modify all owner-interactive functions to update the last_interaction timestamp whenever the owner performs an action.
  3. Implement the Withdrawal Mechanism for Factory Deployer:

    • Create a Function:
      • Implement a withdrawFunds function that allows the factory deployer to withdraw funds if the owner has been inactive beyond the specified period (e.g., one year).
    • Set Access Control:
      • Use modifiers to ensure that only the factory deployer can call this function.
      • Include checks to verify that the required inactivity period has elapsed.
  4. Integrate with the Factory Contract:

    • Ensure that the factory contract can interact with the new withdrawFunds function when necessary.
    • Update any relevant interfaces or references between the factory and child contracts.
  5. Write Comprehensive Tests:

    • Unit Tests:
      • Test that last_interaction updates correctly on all owner interactions.
      • Test that the factory deployer cannot withdraw funds before the inactivity period has passed.
      • Test successful withdrawal by the factory deployer after the inactivity period.
    • Edge Case Tests:
      • Test behavior exactly at the inactivity threshold.
      • Test that no other accounts can withdraw funds regardless of inactivity.
    • Failure Tests:
      • Attempt withdrawals with incorrect access or before the inactivity period to ensure proper reverts.
  6. Run and Validate All Tests:

    • Ensure that all existing and new tests pass successfully.
    • Use a continuous integration tool if available to automate testing.
  7. Seek and Incorporate Feedback:

    • Review Comments:
      • Monitor the PR for feedback from maintainers or other contributors.
    • Make Necessary Revisions:
      • Address any issues or suggestions promptly to refine the solution.
  8. Communication:

    • If any challenges arise, I will reach out immediately in the Telegram group to discuss and resolve them efficiently.

@Akshola00
Copy link

I’d like to help with this.

@ikemHood
Copy link

Hello, I'm Ikem, a blockchain developer with over 3 years of experience in smart contract development.

I would love to help with this issue

my proposed approach
add last_interaction Timestamp as proposed in the issue
add an internal function that's called in every admin interaction to update last_interaction
implement a emergency_withdraw function that allowsFactory Deployer to withdraw based on set parameter

@ShantelPeters
Copy link

I am a blockchain developer , can i please work on this

@SoarinSkySagar
Copy link

SoarinSkySagar commented Nov 21, 2024

May I work on this issue @machuwey ?

My background: I am a web3 developer with 2 years of experience and a regular contributor at @keep-starknet-strange. I have been solving issues related to cairo for the past 2 months and I'm pretty confident that I can resolve this issue too.

My approach: I would add the new timestamp field to the storage struct, then modify all functions to overwrite the field with the current timestamp so that it refreshes when calling the function. I will then add a new function which can only be called by the factory deployer where they can withdraw funds once the timestamp has expired

eta: 3 days

@suhas-sensei
Copy link

gm @machuwey, Suhas here, having worked in the last od, where I’ve worked on integrating on-chain mechanics into games and have contributed to optimizing user experience with tools like SPV wallets and Web3 integrations.

To address this issue, I propose implementing an inactivity-based fallback mechanism within the strapex_child_contract. This will include recording the last interaction timestamp for the owner, updating it during owner interactions, and enabling the factory deployer to withdraw funds after a specified inactivity period. I will ensure robust testing and integration with the factory contract to validate the functionality and safeguard against misuse.

draf pr : 24hrs

@Aditya-040
Copy link

Is this issue still available?

@Benjtalkshow
Copy link

Can I be assigned to this?

@mexes20
Copy link

mexes20 commented Nov 21, 2024

Can I be assigned to work on this? I have three years experience in Software development and have contributed to some projects on OD here.

ETA: 10 hours.

@od-hunter
Copy link

Hello, can I be assigned this issue please? My experience includes html, css, react, javaScript, typescript, c#, solidity & Cairo.

To solve this issue I'll take the following steps:

  1. I'll add a last_interaction timestamp to track the last interaction by the owner.
    Define a constant INACTIVITY_PERIOD to set the inactivity threshold.
  2. I'll modify owner interaction functions (e.g., interact()) to update the last_interaction timestamp each time the owner performs an action.
  3. I'll implement a withdrawFunds() function, callable by the factory deployer only, to withdraw funds if the owner has been inactive for the INACTIVITY_PERIOD.
    Ensure that the withdrawFunds() function can only be executed if the inactivity period has elapsed (checked using block.timestamp).
  4. I'll use onlyOwner modifier to restrict functions like interact() to the owner, use onlyFactoryDeployer modifier to restrict withdrawFunds() to the factory deployer, use onlyIfInactive modifier to ensure that the withdrawal function can only be called if the inactivity period has passed.
  5. I'll test interact() to ensure it updates last_interaction, test that withdrawFunds() cannot be called before the inactivity period has passed, test that withdrawFunds() works after the inactivity period, test that the withdrawal function is restricted to the factory deployer and lastly test for insufficient funds in the contract.

Please assign me I'm ready to work.

@martinvibes
Copy link

Can I take care of this issue?
i'm a frontend dev and a blockchain dev please kindly assign :)

@Amarjeet325
Copy link

Hi , I am a proficient MERN stack developer with experience in full-stack development. I believe I can contribute effectively to this project. Could you kindly assign this issue/task to me?

@bruhhgnik
Copy link

i am a cairo dev, let me try this issue.

@TheSQLguy
Copy link

hello, i would like to start my odhack journey with my contribution here. My proposed solution suggests adding an inactivity-based fallback to the strapex_child_contract. This will track the owner's last interaction, update it with each interaction, and allow the factory deployer to withdraw funds if the owner is inactive for a set period. I’ll ensure thorough testing and integration with the factory contract to prevent misuse.

@Supa-mega
Copy link

I’d love to work on this task.

@0xLemonn
Copy link

i want to contribute on this, i am new to open source and hope i can make the desired change.

@Emmanex01
Copy link

Could I be assigned to this?
I'm Emmanuel Tochukwu, software developer. I have experience writing smart contract on Starknet. I would love to work on this.

@aniruddhaaps
Copy link

Hey @machuwey, Aniruddha here. So I'm a typescript dev and also contributed in last odHack. Want to take up the issue and solve right away.

So, first I will add a time-locked inactivity function to strapex_child_contract. This function should update the last_interaction timestamp for every kind of owner interaction. Implement a withdrawal function for factory deployer-it should be accessible only after some inactivity time; let's say, one year elapsed. Then validate and test safe functionality with respect to timing and access.

@Jemiiah
Copy link

Jemiiah commented Nov 22, 2024

please can i take care of this issue

@mimisavage
Copy link

I'd like to take this issue.

@blessingbytes
Copy link

I am a frontend and blockchain developer specializing in creating intuitive user interfaces. I have experience with modern frameworks like React and smart contract development on platforms like Ethereum and Starknet.

HERE IS HOW I WILL GO ABOUT IN TACKLING THIS ISSUE
I will first fork and clone the repository to my local machine

I’ll then install the required dependencies by following the setup instructions provided in the project documentation.

I’ll design a solution that tracks the owner’s last interaction using a last_interaction timestamp.

Once i'm done with that , I will add a field to store the timestamp and initialize it in the contract’s constructor.

Then , I will use a testing framework like Hardhat or Foundry to create test cases.

I document my changes clearly in the pull request, explaining the problem, my solution, and how I tested it.

finally, I’ll ensure all tests pass locally before pushing my changes and then push it.

@hossamanany
Copy link

I'd be happy to do this.

@aniruddhaaps
Copy link

thank you for the assignment @machuwey

@Jemiiah
Copy link

Jemiiah commented Dec 4, 2024

@machuwey can i take up this issue

@aidenwong812
Copy link

May I take this issue on?

@PrathamJha1
Copy link

Can I try solving this issue?

@od-hunter
Copy link

od-hunter commented Jan 7, 2025

Hello, can I be assigned this issue please? My experience includes html, css, react, javaScript, typescript, c#, solidity & Cairo.

To solve this issue I'll take the following steps:

  1. I'll add a last_interaction timestamp to track the last interaction by the owner.
    Define a constant INACTIVITY_PERIOD to set the inactivity threshold.
  2. I'll modify owner interaction functions (e.g., interact()) to update the last_interaction timestamp each time the owner performs an action.
  3. I'll implement a withdrawFunds() function, callable by the factory deployer only, to withdraw funds if the owner has been inactive for the INACTIVITY_PERIOD.
    Ensure that the withdrawFunds() function can only be executed if the inactivity period has elapsed (checked using block.timestamp).
  4. I'll use onlyOwner modifier to restrict functions like interact() to the owner, use onlyFactoryDeployer modifier to restrict withdrawFunds() to the factory deployer, use onlyIfInactive modifier to ensure that the withdrawal function can only be called if the inactivity period has passed.
  5. I'll test interact() to ensure it updates last_interaction, test that withdrawFunds() cannot be called before the inactivity period has passed, test that withdrawFunds() works after the inactivity period, test that the withdrawal function is restricted to the factory deployer and lastly test for insufficient funds in the contract.

Please assign me I'm ready to work.

Hi @machuwey , please can I be assigned this issue?

@emarc99
Copy link

emarc99 commented Jan 7, 2025

Is it okay if I tackle this?

@ekumamatthew
Copy link

Can I be assigned to this?

@Elite-tch
Copy link

I'd love to give this a go.

@chiscookeke11
Copy link

May I be assigned to this?

@Emmy123222
Copy link

Can I handle this task?

1 similar comment
@RareMmemshima
Copy link

Can I handle this task?

@wheval
Copy link

wheval commented Feb 6, 2025

Hello @machuwey , can i work on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cairo good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests