Skip to content

feat(soroban): add increment_with_pause example (Refs #1901)#1911

Open
Amit5601 wants to merge 3 commits into
hyperledger-solang:mainfrom
Amit5601:add-increment-example-pause
Open

feat(soroban): add increment_with_pause example (Refs #1901)#1911
Amit5601 wants to merge 3 commits into
hyperledger-solang:mainfrom
Amit5601:add-increment-example-pause

Conversation

@Amit5601

Copy link
Copy Markdown
Contributor

Adds the Solidity equivalent of the increment_with_pause contract to the Soroban examples directory.

…ang#1901)

Signed-off-by: Amit Singhmar <abhay.singhmar2@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Soroban Solidity example intended to mirror the upstream increment_with_pause pattern (an incrementing counter gated by a separate “pause” contract).

Changes:

  • Introduces a new increment_with_pause.sol example with an IPause interface and an increment function that reverts when paused.
  • Stores counter state in Soroban instance storage and increments it when unpaused.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +4 to +20
interface IPause {
function paused() external view returns (bool);
}

contract IncrementContract {
IPause private instance pauseContract;
uint32 private instance count;

error PausedError();

constructor(IPause _pause) {
pauseContract = _pause;
}

function increment() public returns (uint32) {
// Cross-contract call to check the paused state
if (pauseContract.paused()) {
Comment on lines +1 to +2
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
function paused() external view returns (bool);
}

contract IncrementContract {
Comment on lines +4 to +16
interface IPause {
function paused() external view returns (bool);
}

contract IncrementContract {
IPause private instance pauseContract;
uint32 private instance count;

error PausedError();

constructor(IPause _pause) {
pauseContract = _pause;
}
Signed-off-by: Amit Singhmar <abhay.singhmar2@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines +3 to +18
interface IPause {
function paused() external view returns (bool);
}

contract increment_with_pause {
IPause private instance pauseContract;
uint32 private instance count;

error PausedError();

constructor(IPause _pause) {
pauseContract = _pause;
}

function increment() public returns (uint32) {
if (pauseContract.paused()) {
…support matrix

Signed-off-by: Amit Singhmar <abhay.singhmar2@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment on lines +16 to +22

// Decode the return value if the call succeeds
if (ok) {
bool isPaused = abi.decode(ret, (bool));
if (isPaused) {
revert PausedError();
}
Comment on lines +30 to +37
contract pause {
bool private instance _isPaused;

function paused() public view returns (bool) {
return _isPaused;
}

function set(bool p) public {
function increment() public returns (uint32) {
bytes memory payload = abi.encode("paused");
(bool ok, bytes memory ret) = pauseAddr.call(payload);

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.

2 participants