Skip to content

Commit

Permalink
Added async precompile
Browse files Browse the repository at this point in the history
  • Loading branch information
backsapc committed Dec 24, 2024
1 parent efa1a42 commit 97c74f8
Show file tree
Hide file tree
Showing 65 changed files with 1,834 additions and 185 deletions.
2 changes: 1 addition & 1 deletion localnet.just
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
chain_id := "warden_1337-1"
shulgin := "warden1d652c9nngq5cneak2whyaqa4g9ehr8pstxj0r5"
shulgin_mnemonic := "exclude try nephew main caught favorite tone degree lottery device tissue tent ugly mouse pelican gasp lava flush pen river noise remind balcony emerge"
warden-precompiles := '["0x0000000000000000000000000000000000000900", "0x0000000000000000000000000000000000000901", "0x0000000000000000000000000000000000000902"]'
warden-precompiles := '["0x0000000000000000000000000000000000000900", "0x0000000000000000000000000000000000000901", "0x0000000000000000000000000000000000000902", "0x0000000000000000000000000000000000000903"]'

# run a single-node chain locally, use "bin" to specify the binary name
start bin="wardend" install="true":
Expand Down
1 change: 1 addition & 0 deletions precompiles/act/Types.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
509 changes: 509 additions & 0 deletions precompiles/async/IAsync.go

Large diffs are not rendered by default.

105 changes: 105 additions & 0 deletions precompiles/async/IAsync.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.8.18;

import "../common/Types.sol";

/// @dev The IAsync contract's address.
address constant IASYNC_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000903;

/// @dev The IAsync contract's instance.
IAsync constant IASYNC_CONTRACT = IAsync(IASYNC_PRECOMPILE_ADDRESS);

struct Future {
uint64 id;
address creator;
string handler;
bytes input;
}

enum FutureVoteType {
Unspecified,
Verified,
Rejected
}

struct FutureVote {
uint64 futureId;
bytes Voter;
FutureVoteType vote;
}

struct FutureResult {
uint64 id;
bytes output;
bytes submitter;
}

struct FutureResponse {
Future future;
FutureVote[] votes;
FutureResult result;
}

struct PendingFuturesResponse {
Types.PageResponse pagination;
Future[] futures;
}

struct FuturesResponse {
Types.PageResponse pagination;
FutureResponse[] futures;
}

struct FutureByIdResponse {
Future future;
}

/**
* @author Warden Team
* @title x/async Interface
* @dev The interface through which users and solidity contracts will interact with x/async.
* @custom:address 0x0000000000000000000000000000000000000903
*/
interface IAsync {
/// @dev Defines a method to add a future.
/// @param handler The unique name of the handler
/// @param input The handler's input
/// @return futureId The id of the future
function addFuture(
string calldata handler,
bytes calldata input
) external returns (uint64 futureId);

/// @dev Defines a method to query future by id.
/// @param futureId The pagination details
/// @return response The future
function futureById(
uint64 futureId
) external view returns (FutureByIdResponse memory response);

/// @dev Defines a method to query futures.
/// @param pagination The pagination details
/// @param creator Optional creator address filter
/// @return response The paged futures
function futures(
Types.PageRequest calldata pagination,
address creator
) external view returns (FuturesResponse memory response);

/// @dev Defines a method to query pending futures.
/// @param pagination The pagination details
/// @return response The paged futures
function pendingFutures(
Types.PageRequest calldata pagination
) external view returns (PendingFuturesResponse memory response);

/// @dev CreateFuture defines an Event emitted when a future is created.
/// @param creator The address of the creator
/// @param futureId The future Id
/// @param handler The name of the handler
event CreateFuture(
uint64 indexed futureId,
address indexed creator,
string handler
);
}
1 change: 1 addition & 0 deletions precompiles/async/Types.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Loading

0 comments on commit 97c74f8

Please sign in to comment.