Skip to content

Commit

Permalink
fix: fix parameter types
Browse files Browse the repository at this point in the history
  • Loading branch information
Łukasz Kujawski committed Jan 13, 2023
1 parent b7dfbeb commit c54880c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
16 changes: 9 additions & 7 deletions contracts/QRNGApiRequester.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
pragma solidity 0.8.9;

import "@api3/airnode-protocol/contracts/rrp/requesters/RrpRequesterV0.sol";
import "@openzeppelin/contracts/utils/Strings.sol";


/// @notice contract handling QuantumBlockchains QRNG API communication
contract QRNGApiRequester is RrpRequesterV0 {
Expand All @@ -20,11 +22,11 @@ contract QRNGApiRequester is RrpRequesterV0 {
bytes32 endpointId,
address sponsor,
address sponsorWallet,
bytes32 _provider,
bytes32 _type,
uint _size
string memory _provider,
string memory _type,
uint256 _size
) external {
bytes memory parameters = _encodeParams(_provider, _type, _size);
bytes memory parameters = encodeParams(_provider, _type, _size);
bytes32 requestId = airnodeRrp.makeFullRequest(
airnode,
endpointId,
Expand Down Expand Up @@ -52,17 +54,17 @@ contract QRNGApiRequester is RrpRequesterV0 {
/// @param _provider - supported providers: qbck, qnulabs, sequre, realrandom
/// @param _type - supported types: short (uint16), int (uint32), long (uint64), bigint (uint256)
/// @param _size - quantity of random numbers to generate
function _encodeParams(bytes32 _provider, bytes32 _type, uint _size) private pure returns (bytes memory) {
function encodeParams(string memory _provider, string memory _type, uint256 _size) public pure returns (bytes memory) {
return abi.encode(
bytes32("1SSSS"),
bytes32("provider"),
_provider,
bytes32("type"),
_type,
bytes32("size"),
_size,
Strings.toString(_size),
bytes32("length"),
32
Strings.toString(uint256(32))
);
}
}
1 change: 0 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const config: HardhatUserConfig = {
goerli: {
url: GOERLI_URL,
accounts: [GOERLI_PRIVATE_KEY],
gasPrice: 20_000_000_000
}
},
namedAccounts: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@nomicfoundation/hardhat-chai-matchers": "^1.0.5",
"@nomiclabs/hardhat-ethers": "^2.2.1",
"@nomiclabs/hardhat-solhint": "^2.0.1",
"@openzeppelin/contracts": "^4.7.3",
"@typechain/ethers-v5": "^10.1.0",
"@typechain/hardhat": "^6.1.2",
"@types/chai": "^4.2.0",
Expand Down
3 changes: 1 addition & 2 deletions test/QRNGApiRequester.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ describe(QRNG_API_REQUESTER, () => {

// make request to for random numbers
await qrngApiRequester.makeRequest(airnode, '0x9b50a620b157676e7aac88732dbe117297e9127454d8a8575a962fc77b580569',
sponsor, sponsorWallet, formatBytes32String(params.provider),
formatBytes32String(params.type), params.size);
sponsor, sponsorWallet, params.provider, params.type, params.size);

// incoming fulfillment is in the contract
let incomingFulfilment = await qrngApiRequester.incomingFulfillments(formatBytes32String('1'));
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,11 @@
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.4.2.tgz#4e889c9c66e736f7de189a53f8ba5b8d789425c2"
integrity sha512-NyJV7sJgoGYqbtNUWgzzOGW4T6rR19FmX1IJgXGdapGPWsuMelGJn9h03nos0iqfforCbCB0iYIR0MtIuIFLLw==

"@openzeppelin/contracts@^4.7.3":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.8.0.tgz#6854c37df205dd2c056bdfa1b853f5d732109109"
integrity sha512-AGuwhRRL+NaKx73WKRNzeCxOCOCxpaqF+kp8TJ89QzAipSwZy/NoflkWaL9bywXFRhIzXt8j38sfF7KBKCPWLw==

"@scure/base@~1.1.0":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.1.tgz#ebb651ee52ff84f420097055f4bf46cfba403938"
Expand Down

0 comments on commit c54880c

Please sign in to comment.