Skip to content

Commit

Permalink
Merge pull request #62 from shivam-agarwal-0/issue51
Browse files Browse the repository at this point in the history
changes to remove stringToBytes32
  • Loading branch information
PatrickAlphaC authored Nov 16, 2021
2 parents a427f14 + 813da29 commit 7abff23
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
15 changes: 2 additions & 13 deletions contracts/APIConsumer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract APIConsumer is ChainlinkClient {
* Job ID: d5270d1c311941d0b08bead21fea7747
* Fee: 0.1 LINK
*/
constructor(address _oracle, string memory _jobId, uint256 _fee, address _link) public {
constructor(address _oracle, bytes32 _jobId, uint256 _fee, address _link) public {
if (_link == address(0)) {
setPublicChainlinkToken();
} else {
Expand All @@ -32,7 +32,7 @@ contract APIConsumer is ChainlinkClient {
// jobId = "29fa9aa13bf1468788b7cc4a500a45b8";
// fee = 0.1 * 10 ** 18; // 0.1 LINK
oracle = _oracle;
jobId = stringToBytes32(_jobId);
jobId = _jobId;
fee = _fee;
}

Expand Down Expand Up @@ -75,17 +75,6 @@ contract APIConsumer is ChainlinkClient {
volume = _volume;
}

function stringToBytes32(string memory source) public pure returns (bytes32 result) {
bytes memory tempEmptyStringTest = bytes(source);
if (tempEmptyStringTest.length == 0) {
return 0x0;
}

assembly {
result := mload(add(source, 32))
}
}

// function withdrawLink() external {} - Implement a withdraw function to avoid locking your LINK in the contract
}

2 changes: 1 addition & 1 deletion deploy/02_Deploy_APIConsumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = async ({
linkTokenAddress = networkConfig[chainId]['linkToken']
oracle = networkConfig[chainId]['oracle']
}
const jobId = networkConfig[chainId]['jobId']
const jobId = ethers.utils.toUtf8Bytes(networkConfig[chainId]['jobId'])
const fee = networkConfig[chainId]['fee']
const networkName = networkConfig[chainId]['name']

Expand Down

0 comments on commit 7abff23

Please sign in to comment.