Skip to content

Commit

Permalink
feat(random-datasource): rebrand code and update
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardopersiani committed Jul 12, 2019
1 parent c57b27a commit a638c2a
Show file tree
Hide file tree
Showing 6 changed files with 3,915 additions and 949 deletions.
9 changes: 8 additions & 1 deletion solidity/truffle-examples/random-datasource/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ __`❍ npx truffle test --network rinkeby`__

## :camera: Passing Tests:

[The passing tests!](random-datasource-tests.jpg)
```javascript
Contract: Random Example Tests
✓ Should log a new Provable query (2421ms)
✓ Callback should have logged a new uint random number result event (54739)
✓ Should revert on second query attempt due to lack of funds (15290ms)

3 passing (1m)
```

 

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
*/
pragma solidity >= 0.5.0 < 0.6.0;

import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";
import "github.com/provable-things/ethereum-api/provableAPI.sol";

contract RandomExample is usingOraclize {
contract RandomExample is usingProvable {

uint256 constant MAX_INT_FROM_BYTE = 256;
uint256 constant NUM_RANDOM_BYTES_REQUESTED = 7;

event LogNewOraclizeQuery(string description);
event LogNewProvableQuery(string description);
event generatedRandomNumber(uint256 randomNumber);

constructor()
public
{
oraclize_setProof(proofType_Ledger);
provable_setProof(proofType_Ledger);
update();
}

Expand All @@ -34,10 +34,10 @@ contract RandomExample is usingOraclize {
)
public
{
require(msg.sender == oraclize_cbAddress());
require(msg.sender == provable_cbAddress());

if (
oraclize_randomDS_proofVerify__returnCode(
provable_randomDS_proofVerify__returnCode(
_queryId,
_result,
_proof
Expand Down Expand Up @@ -78,11 +78,11 @@ contract RandomExample is usingOraclize {
{
uint256 QUERY_EXECUTION_DELAY = 0;
uint256 GAS_FOR_CALLBACK = 200000;
oraclize_newRandomDSQuery(
provable_newRandomDSQuery(
QUERY_EXECUTION_DELAY,
NUM_RANDOM_BYTES_REQUESTED,
GAS_FOR_CALLBACK
);
emit LogNewOraclizeQuery("Oraclize query was sent, standing by for the answer...");
emit LogNewProvableQuery("Provable query was sent, standing by for the answer...");
}
}
Loading

0 comments on commit a638c2a

Please sign in to comment.