From 175ea766288aa08ae2a9b97cef13aeef2d349227 Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Wed, 3 May 2017 07:30:18 +0000 Subject: [PATCH] use url and nested for cheaper calls --- contracts/src/GitHubAPI.sol | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/contracts/src/GitHubAPI.sol b/contracts/src/GitHubAPI.sol index 99cca60..3890f45 100644 --- a/contracts/src/GitHubAPI.sol +++ b/contracts/src/GitHubAPI.sol @@ -47,10 +47,10 @@ contract GitHubAPIOraclize is GitHubAPI, Owned, usingOraclize{ //register or change a github user ethereum address. 100000000000000000 function register(address _sender, string _github_user, string _gistid) - payable only_owner{ - StringLib.concat(_github_user,",",_gistid); - bytes32 ocid = oraclize_query("computation", [script, "user-add", _github_user.concat(",",_gistid), cred]); - + payable only_owner{ + bytes32 ocid = oraclize_query("nested", StringLib.concat("[identity] ${[URL] https://gist.githubusercontent.com/",_github_user,"/",_gistid,"/raw/}, ${[URL] json(https://api.github.com/gists/").concat(_gistid,credentials,").owner.[id,login]}")); + claimType[ocid] = OracleType.SET_USER; + userClaim[ocid] = UserClaim({sender: _sender, githubid: _github_user}); } function updateCommits(string _repository, bytes20 _commitid) @@ -62,10 +62,10 @@ contract GitHubAPIOraclize is GitHubAPI, Owned, usingOraclize{ function addRepository(string _repository) payable only_owner{ - bytes32 ocid = oraclize_query("computation", [script, "repo-add", _repository, cred],4000000); + bytes32 ocid = oraclize_query("URL", StringLib.concat("json(https://api.github.com/repos/",_repository,credentials,").$.id,full_name,watchers,subscribers_count"),4000000); claimType[ocid] = OracleType.SET_REPOSITORY; - } - + } + function updateIssue(string _repository, string issue) payable only_owner{ bytes32 ocid = oraclize_query("computation", [script, "issue-update",_repository.concat(",",issue),cred]); }