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

Documentation setup #110

Open
wants to merge 29 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
01ecc26
add package.json
doerfli Jun 2, 2023
fabd05e
Edit Docu
ladylyly Jun 2, 2023
65b9037
Documentation of smart contracts
ladylyly Jun 5, 2023
77adc63
First push of docs
ladylyly Jun 7, 2023
99de8cd
add artifacts to .gitignore
christoph2806 Jun 7, 2023
bf74a77
remove artifacts from git
christoph2806 Jun 7, 2023
1d9ed50
add solidity-docgen dev dependency
christoph2806 Jun 7, 2023
4c9ec80
add cache/ to .gitignore
christoph2806 Jun 7, 2023
7c14c9a
update .gitignore
christoph2806 Jun 7, 2023
a6edb79
Fix natspec syntax
christoph2806 Jun 7, 2023
bad8168
Add README.adoc to every contract subfolder
christoph2806 Jun 8, 2023
094647c
Update list formatting
christoph2806 Jun 8, 2023
2e367d2
Rerun docgen
christoph2806 Jun 8, 2023
e509a29
Error Codes
christoph2806 Jun 9, 2023
2a591be
Format error codes
christoph2806 Jun 9, 2023
ffdefb8
Fix link
christoph2806 Jun 9, 2023
ae27dba
Reformat
christoph2806 Jun 9, 2023
66a7fcc
Fix format
christoph2806 Jun 9, 2023
79a4676
Fix heading
christoph2806 Jun 9, 2023
33239fa
Fix format...
christoph2806 Jun 9, 2023
330f64f
fix format....
christoph2806 Jun 9, 2023
105fb82
test new format
christoph2806 Jun 9, 2023
ab8f62d
zwischenstand
christoph2806 Jun 12, 2023
9c88a8e
Docs update
ladylyly Jun 12, 2023
60372ce
Docs update
ladylyly Jun 15, 2023
fa3c77c
Update adocs
ladylyly Jun 15, 2023
966efcb
Updated ReadMe comments
ladylyly Jun 15, 2023
e3cbd76
only validate and list error codes surrounded by quotes
doerfli Jun 15, 2023
a91d3ce
ReadMe.adoc updates
ladylyly Jun 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/scripts/list_all_errorcodes.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

printf "|Errorcode|File|\n|:--|:--|\n"
egrep -or "(ERROR\:[A-Z0-9_-]+\:[A-Z0-9_-]+)" contracts/* | sed -E "s/([^\:]+)\:(.+)/|\2|\1|/g" | sort
egrep -or "\"(ERROR\:[A-Z0-9_-]+\:[A-Z0-9_-]+)\"" contracts/* | sed -E "s/([^\:]+)\:\"(.+)\"/|\2|\1|/g" | sort
2 changes: 1 addition & 1 deletion .github/workflows/scripts/validate_errorcodes.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

DUPES=`egrep -or "(ERROR\:[A-Z0-9_-]+)" contracts/* | sort | uniq -cd`
DUPES=`egrep -or "\"(ERROR\:[A-Z0-9_-]+)\"" contracts/* | sort | uniq -cd`

if [ -z "$DUPES" ]; then
echo "No duplicate error codes found"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ __pycache__
.history
.hypothesis/
build/
artifacts/
reports/
cache/
dump_sources/
node_modules
tmp/
Expand All @@ -14,3 +16,4 @@ tmp/
.vscode/launch.json

etherisc*.tgz

11 changes: 11 additions & 0 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ contract Migrations {
address public owner;
uint256 public last_completed_migration; // solhint-disable-line

/**
* @dev Constructor function that sets the contract owner to the address of the sender.
*/
constructor() {
owner = msg.sender;
}
Expand All @@ -13,10 +16,18 @@ contract Migrations {
if (msg.sender == owner) _;
}

/**
* @dev Sets the value of the last completed migration to the given value.
* @param _completed The new value for the last completed migration.
*/
function setCompleted(uint256 _completed) public restricted {
last_completed_migration = _completed;
}

/**
* @dev Upgrades the Migrations contract to a new address.
* @param _newAddress The address of the new Migrations contract.
*/
function upgrade(address _newAddress) public restricted {
Migrations upgraded = Migrations(_newAddress);
upgraded.setCompleted(last_completed_migration);
Expand Down
63 changes: 63 additions & 0 deletions contracts/examples/AyiiOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ contract AyiiOracle is
uint256 aaay
);

/**
* @dev Constructor function for the ChainlinkOracle contract.
* @param _name The name of the oracle contract.
* @param _registry The address of the oracle registry contract.
* @param _chainLinkToken The address of the Chainlink token contract.
* @param _chainLinkOperator The address of the Chainlink oracle operator.
* @param _jobId The ID of the Chainlink job to be used.
* @param _payment The payment amount to be sent to the Chainlink oracle operator.
*/
constructor(
bytes32 _name,
address _registry,
Expand All @@ -44,6 +53,13 @@ contract AyiiOracle is
_payment);
}

/**
* @dev Update request details for Chainlink oracle job.
* @param _chainLinkToken The address of the Chainlink token contract.
* @param _chainLinkOperator The address of the Chainlink oracle operator.
* @param _jobId The job ID for the Chainlink oracle job.
* @param _payment The payment amount for the Chainlink oracle job.
*/
function updateRequestDetails(
address _chainLinkToken,
address _chainLinkOperator,
Expand All @@ -60,6 +76,14 @@ contract AyiiOracle is
payment = _payment;
}

/**
* @dev Sends a Chainlink request to retrieve data for a specific GIF request.
* @param gifRequestId The ID of the GIF request.
* @param input The encoded input data containing the project ID, UAI ID, and crop ID.
* The input must be in the following format: abi.encode([bytes32 projectId, bytes32 uaiId, bytes32 cropId]).
* @notice This function emits 1 events:
* - LogAyiiRequest
*/
function request(uint256 gifRequestId, bytes calldata input)
external override
onlyQuery
Expand All @@ -86,6 +110,16 @@ contract AyiiOracle is
emit LogAyiiRequest(gifRequestId, chainlinkRequestId);
}

/**
* @dev This function is used to fulfill a Chainlink request for the given parameters.
* @param chainlinkRequestId The ID of the Chainlink request to fulfill.
* @param projectId The ID of the project.
* @param uaiId The ID of the UAI.
* @param cropId The ID of the crop.
* @param aaay The amount of AAAY.
* @notice This function emits 1 events:
* - LogAyiiFulfill
*/
function fulfill(
bytes32 chainlinkRequestId,
bytes32 projectId,
Expand All @@ -103,6 +137,10 @@ contract AyiiOracle is
emit LogAyiiFulfill(gifRequest, chainlinkRequestId, projectId, uaiId, cropId, aaay);
}

/**
* @dev Cancels a Chainlink request.
* @param requestId The ID of the request to cancel.
*/
function cancel(uint256 requestId)
external override
onlyOwner
Expand All @@ -112,6 +150,15 @@ contract AyiiOracle is
}

// only used for testing of chainlink operator
/**
* @dev Encodes the parameters required for a Chainlink request fulfillment.
* @param chainlinkRequestId The ID of the Chainlink request.
* @param projectId The ID of the project.
* @param uaiId The ID of the UAI.
* @param cropId The ID of the crop.
* @param aaay The value of aaay.
* @return parameterData The encoded parameter data.
*/
function encodeFulfillParameters(
bytes32 chainlinkRequestId,
bytes32 projectId,
Expand All @@ -132,18 +179,34 @@ contract AyiiOracle is
);
}

/**
* @dev Returns the Chainlink Job ID associated with this contract.
* @return chainlinkJobId The Chainlink Job ID as a bytes32 variable.
*/
function getChainlinkJobId() external view returns(bytes32 chainlinkJobId) {
return jobId;
}

/**
* @dev Returns the payment amount for a Chainlink oracle request.
* @return paymentAmount The payment amount in uint256.
*/
function getChainlinkPayment() external view returns(uint256 paymentAmount) {
return payment;
}

/**
* @dev Returns the address of the Chainlink token.
* @return linkTokenAddress The address of the Chainlink token.
*/
function getChainlinkToken() external view returns(address linkTokenAddress) {
return chainlinkTokenAddress();
}

/**
* @dev Returns the address of the Chainlink operator.
* @return operator The address of the Chainlink operator.
*/
function getChainlinkOperator() external view returns(address operator) {
return chainlinkOracleAddress();
}
Expand Down
Loading