Skip to content

Instantly share code, notes, and snippets.

@mcgingras
Created August 1, 2017 01:39
Show Gist options
  • Save mcgingras/b8c036df5b109fde13ba28d47c0a08d6 to your computer and use it in GitHub Desktop.
Save mcgingras/b8c036df5b109fde13ba28d47c0a08d6 to your computer and use it in GitHub Desktop.
Oraclize rucursive call errors....
// Izer.sol
//
// Michael Gingras
//
// 7.30.17
pragma solidity ^0.4.11;
import "./usingOraclize.sol";
contract Izer is usingOraclize {
bytes3[] public jsonRequests; // public var for token array
string public deposit;
string temp; // public var for reusable SS POST request
uint8 counter = 0;
event newDeposit(string deposit); // setting event for testing purposes
function Izer(bytes3[] jsons, string template) payable {
jsonRequests = jsons;
temp = template;
OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475); // required for testrpc + ethereumbridge
update();
}
function __callback(bytes32 myid, string result) {
if (msg.sender != oraclize_cbAddress()) throw;
deposit = result; // result is the address that we need to send the eth
newDeposit(deposit);
update(); // recursive call to update [POTENTIAL CAUSE OF BUG]
}
function update() payable {
if(counter < jsonRequests.length) {
bytes memory jsonQ = bytes(temp);
jsonQ[13] = byte(jsonRequests[counter]);
jsonQ[14] = byte(jsonRequests[counter] << 8);
jsonQ[15] = byte(jsonRequests[counter] << 16);
string memory json = string(jsonQ);
oraclize_query("URL", "json(https://shapeshift.io/shift).deposit",
json);
counter = ++counter;
}
else{
newDeposit('No new friends');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment