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

Proposal: add onConstructorRetry special contract function. #122

Open
mnill opened this issue Nov 19, 2022 · 1 comment
Open

Proposal: add onConstructorRetry special contract function. #122

mnill opened this issue Nov 19, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@mnill
Copy link

mnill commented Nov 19, 2022

Hi. In Distributed programming paradigm we have a problem with gas management when we trying to redeploy an already deployed contract.

I'll try to explain it with by using tip-3 architecture. When some application transfers tokens from one wallet to another we always firstly deploy the target wallet, then we send an onAcceptTokensTransfer call with amount of tokens to transfer. If target wallet is already deployed - constructor will throw an error and gas will be bounce back to the contract which one tried to deploy the wallet. But we would like to send remain gas to the user's wallet which one started the transaction.

So we have a constructor like this:

constructor(address remainingGasTo) public
{
  require(msg.sender == root);
  tvm.rawReserve(_reserve(), 0);
  remainingGasTo.transfer({
      value: 0,
      flag: TokenMsgFlag.ALL_NOT_RESERVED + TokenMsgFlag.IGNORE_ERRORS,
      bounce: false
  });
}

If contract already deployed, message will bounce back to the msg.sender. Will be nice to to have an opportunity to declare such special function:

onConstructorRetry(address remainingGasTo) {
    require(msg.sender == root);
    tvm.rawReserve(_reserve(), 0);
    remainingGasTo.transfer({
      value: 0,
      flag: TokenMsgFlag.ALL_NOT_RESERVED + TokenMsgFlag.IGNORE_ERRORS,
      bounce: false
  });
}

Because an attempt to re-deploy is a regular situation for our application.

If you need more details I can try to draw a scheme of some real application.

@cryshado
Copy link
Contributor

Thanks for the suggestion! We don't think that adding new built-in "magic" functions will solve the problem, and we're moving towards expanding the possibilities of the language, with which it will be possible to describe the solution to almost any situation.

@cryshado cryshado reopened this Mar 23, 2023
@cryshado cryshado added the enhancement New feature or request label Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants