Skip to content

Commit

Permalink
feat: Witnet*.class(): string
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed Nov 23, 2023
1 parent 77bee1d commit 14cbe74
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions contracts/WitnetBytecodes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ abstract contract WitnetBytecodes
is
IWitnetBytecodes
{
function class() virtual external view returns (string memory) {
return type(WitnetBytecodes).name;
}
function specs() virtual external view returns (bytes4);
}
3 changes: 3 additions & 0 deletions contracts/WitnetRequestBoard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ abstract contract WitnetRequestBoard
is
IWitnetRequestBoard
{
function class() virtual external view returns (string memory) {
return type(WitnetRequestBoard).name;
}
function factory() virtual external view returns (WitnetRequestFactory);
function registry() virtual external view returns (WitnetBytecodes);
function specs() virtual external view returns (bytes4);
Expand Down
1 change: 1 addition & 0 deletions contracts/WitnetRequestFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ abstract contract WitnetRequestFactory
is
IWitnetRequestFactory
{
function class() virtual external view returns (string memory);
function registry() virtual external view returns (WitnetBytecodes);
function specs() virtual external view returns (bytes4);
function witnet() virtual external view returns (WitnetRequestBoard);
Expand Down
1 change: 1 addition & 0 deletions contracts/WitnetRequestTemplate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ abstract contract WitnetRequestTemplate
{
event WitnetRequestBuilt(address indexed request, bytes32 indexed radHash, string[][] args);

function class() virtual external view returns (string memory);
function factory() virtual external view returns (WitnetRequestFactory);
function registry() virtual external view returns (WitnetBytecodes);
function specs() virtual external view returns (bytes4);
Expand Down
17 changes: 17 additions & 0 deletions contracts/core/defaults/WitnetRequestFactoryDefault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,23 @@ contract WitnetRequestFactoryDefault
);
}

function class()
virtual override(WitnetRequestFactory, WitnetRequestTemplate)
external view
returns (string memory)
{
if (
address(this) == _SELF
|| address(this) == __proxy()
) {
return type(WitnetRequestFactory).name;
} else if (__witnetRequest().radHash != bytes32(0)) {
return type(WitnetRequest).name;
} else {
return type(WitnetRequestTemplate).name;
}
}

function specs()
virtual override(WitnetRequestFactory, WitnetRequestTemplate)
external view
Expand Down

0 comments on commit 14cbe74

Please sign in to comment.