@witnet/solidity 2.2.8 → 2.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +1 -1
  2. package/build/contracts/Clonable.json +2 -2
  3. package/build/contracts/Context.json +1 -1
  4. package/build/contracts/Create3.json +2 -2
  5. package/build/contracts/ERC165.json +1 -1
  6. package/build/contracts/IERC165.json +1 -1
  7. package/build/contracts/IERC20.json +1 -1
  8. package/build/contracts/IERC2362.json +1 -1
  9. package/build/contracts/IFeeds.json +2 -2
  10. package/build/contracts/IWitnetConsumer.json +2 -2
  11. package/build/contracts/IWitnetFeeds.json +2 -2
  12. package/build/contracts/IWitnetFeedsAdmin.json +2 -2
  13. package/build/contracts/IWitnetOracle.json +2 -2
  14. package/build/contracts/IWitnetOracleEvents.json +2 -2
  15. package/build/contracts/IWitnetOracleReporter.json +2 -2
  16. package/build/contracts/IWitnetPriceFeeds.json +2 -2
  17. package/build/contracts/IWitnetPriceSolver.json +2 -2
  18. package/build/contracts/IWitnetPriceSolverDeployer.json +2 -2
  19. package/build/contracts/IWitnetRandomness.json +2 -2
  20. package/build/contracts/IWitnetRandomnessAdmin.json +2 -2
  21. package/build/contracts/IWitnetRandomnessEvents.json +2 -2
  22. package/build/contracts/IWitnetRequestBoardAdmin.json +2 -2
  23. package/build/contracts/IWitnetRequestBoardAdminACLs.json +2 -2
  24. package/build/contracts/IWitnetRequestBytecodes.json +2 -2
  25. package/build/contracts/IWitnetRequestFactory.json +2 -2
  26. package/build/contracts/Initializable.json +1 -1
  27. package/build/contracts/OVM_GasPriceOracle.json +2 -2
  28. package/build/contracts/Ownable.json +1 -1
  29. package/build/contracts/Ownable2Step.json +2 -2
  30. package/build/contracts/Payable.json +2 -2
  31. package/build/contracts/Proxiable.json +2 -2
  32. package/build/contracts/ReentrancyGuard.json +1 -1
  33. package/build/contracts/Slices.json +2 -2
  34. package/build/contracts/Upgradeable.json +2 -2
  35. package/build/contracts/UsingWitnet.json +2 -2
  36. package/build/contracts/UsingWitnetRandomness.json +2 -2
  37. package/build/contracts/UsingWitnetRequest.json +2 -2
  38. package/build/contracts/UsingWitnetRequestTemplate.json +2 -2
  39. package/build/contracts/Witnet.json +2 -2
  40. package/build/contracts/WitnetBuffer.json +2 -2
  41. package/build/contracts/WitnetCBOR.json +2 -2
  42. package/build/contracts/WitnetConsumer.json +2 -2
  43. package/build/contracts/WitnetDeployer.json +2 -2
  44. package/build/contracts/WitnetDeployerCfxCore.json +2 -2
  45. package/build/contracts/WitnetDeployerMeter.json +2 -2
  46. package/build/contracts/WitnetEncodingLib.json +2 -2
  47. package/build/contracts/WitnetErrorsLib.json +2 -2
  48. package/build/contracts/WitnetFeeds.json +2 -2
  49. package/build/contracts/WitnetMockedOracle.json +2 -2
  50. package/build/contracts/WitnetMockedPriceFeeds.json +2 -2
  51. package/build/contracts/WitnetMockedRandomness.json +2 -2
  52. package/build/contracts/WitnetMockedRequestBytecodes.json +2 -2
  53. package/build/contracts/WitnetMockedRequestFactory.json +2 -2
  54. package/build/contracts/WitnetOracle.json +2 -2
  55. package/build/contracts/WitnetOracleDataLib.json +2 -2
  56. package/build/contracts/WitnetOracleTrustableBase.json +2 -2
  57. package/build/contracts/WitnetOracleTrustableDefault.json +2 -2
  58. package/build/contracts/WitnetOracleTrustableObscuro.json +2 -2
  59. package/build/contracts/WitnetOracleTrustableOvm2.json +2 -2
  60. package/build/contracts/WitnetOracleTrustableReef.json +2 -2
  61. package/build/contracts/WitnetPriceFeeds.json +2 -2
  62. package/build/contracts/WitnetPriceFeedsData.json +2 -2
  63. package/build/contracts/WitnetPriceFeedsDefault.json +2 -2
  64. package/build/contracts/WitnetPriceFeedsLib.json +2 -2
  65. package/build/contracts/WitnetPriceSolverBase.json +2 -2
  66. package/build/contracts/WitnetProxy.json +2 -2
  67. package/build/contracts/WitnetRandomness.json +2 -2
  68. package/build/contracts/WitnetRandomnessRequestConsumer.json +2 -2
  69. package/build/contracts/WitnetRandomnessV2.json +2 -2
  70. package/build/contracts/WitnetRequest.json +2 -2
  71. package/build/contracts/WitnetRequestBytecodes.json +2 -2
  72. package/build/contracts/WitnetRequestBytecodesData.json +2 -2
  73. package/build/contracts/WitnetRequestBytecodesDefault.json +2 -2
  74. package/build/contracts/WitnetRequestBytecodesNoSha256.json +2 -2
  75. package/build/contracts/WitnetRequestConsumer.json +2 -2
  76. package/build/contracts/WitnetRequestFactory.json +2 -2
  77. package/build/contracts/WitnetRequestFactoryCfxCore.json +2 -2
  78. package/build/contracts/WitnetRequestFactoryData.json +2 -2
  79. package/build/contracts/WitnetRequestFactoryDefault.json +2 -2
  80. package/build/contracts/WitnetRequestTemplate.json +2 -2
  81. package/build/contracts/WitnetRequestTemplateConsumer.json +2 -2
  82. package/build/contracts/WitnetUpgradableBase.json +2 -2
  83. package/build/contracts/WitnetV2.json +2 -2
  84. package/package.json +1 -1
@@ -124,7 +124,7 @@
124
124
  "sourceMap": "",
125
125
  "deployedSourceMap": "",
126
126
  "source": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./Ownable.sol\";\n\n/**\n * @dev Contract module which provides access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is specified at deployment time in the constructor for `Ownable`. This\n * can later be changed with {transferOwnership} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2Step is Ownable {\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() public virtual {\n address sender = _msgSender();\n if (pendingOwner() != sender) {\n revert(\"Ownable2Step: caller is not the new owner\");\n }\n _transferOwnership(sender);\n }\n}\n",
127
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/patterns/Ownable2Step.sol",
127
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/patterns/Ownable2Step.sol",
128
128
  "ast": {
129
129
  "absolutePath": "project:/contracts/patterns/Ownable2Step.sol",
130
130
  "exportedSymbols": {
@@ -1119,7 +1119,7 @@
1119
1119
  },
1120
1120
  "networks": {},
1121
1121
  "schemaVersion": "3.4.16",
1122
- "updatedAt": "2025-10-15T17:39:33.056Z",
1122
+ "updatedAt": "2025-10-15T18:03:23.940Z",
1123
1123
  "devdoc": {
1124
1124
  "details": "Contract module which provides access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions. The initial owner is specified at deployment time in the constructor for `Ownable`. This can later be changed with {transferOwnership} and {acceptOwnership}. This module is used through inheritance. It will make available all functions from parent (Ownable).",
1125
1125
  "errors": {
@@ -62,7 +62,7 @@
62
62
  "sourceMap": "",
63
63
  "deployedSourceMap": "",
64
64
  "source": "// SPDX-License-Identifier: MIT\npragma solidity >=0.6.0 <0.9.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nabstract contract Payable {\n IERC20 public immutable currency;\n\n event Received(address from, uint256 value);\n event Transfer(address to, uint256 value);\n\n constructor(address _currency) {\n currency = IERC20(_currency);\n }\n\n /// Gets current transaction price.\n function _getGasPrice() internal view virtual returns (uint256);\n\n /// Gets current payment value.\n function _getMsgValue() internal view virtual returns (uint256);\n\n /// Perform safe transfer or whatever token is used for paying rewards.\n function __safeTransferTo(address payable, uint256) internal virtual;\n}\n",
65
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/patterns/Payable.sol",
65
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/patterns/Payable.sol",
66
66
  "ast": {
67
67
  "absolutePath": "project:/contracts/patterns/Payable.sol",
68
68
  "exportedSymbols": {
@@ -670,7 +670,7 @@
670
670
  },
671
671
  "networks": {},
672
672
  "schemaVersion": "3.4.16",
673
- "updatedAt": "2025-10-15T17:39:33.064Z",
673
+ "updatedAt": "2025-10-15T18:03:23.940Z",
674
674
  "devdoc": {
675
675
  "kind": "dev",
676
676
  "methods": {},
@@ -24,7 +24,7 @@
24
24
  "sourceMap": "",
25
25
  "deployedSourceMap": "",
26
26
  "source": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.9.0;\n\nabstract contract Proxiable {\n /// @dev Complying with EIP-1822: Universal Upgradeable Proxy Standard (UUPS)\n /// @dev See https://eips.ethereum.org/EIPS/eip-1822.\n function proxiableUUID() virtual external view returns (bytes32);\n\n struct ProxiableSlot {\n address implementation;\n address proxy;\n bytes32 codehash;\n }\n\n function __implementation() internal view returns (address) {\n return __proxiable().implementation;\n }\n\n function __proxy() internal view returns (address) {\n return __proxiable().proxy;\n }\n\n function __proxiable() internal pure returns (ProxiableSlot storage proxiable) {\n assembly {\n // bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)\n proxiable.slot := 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\n }\n }\n}\n",
27
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/patterns/Proxiable.sol",
27
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/patterns/Proxiable.sol",
28
28
  "ast": {
29
29
  "absolutePath": "project:/contracts/patterns/Proxiable.sol",
30
30
  "exportedSymbols": {
@@ -581,7 +581,7 @@
581
581
  },
582
582
  "networks": {},
583
583
  "schemaVersion": "3.4.16",
584
- "updatedAt": "2025-10-15T17:39:33.081Z",
584
+ "updatedAt": "2025-10-15T18:03:23.941Z",
585
585
  "devdoc": {
586
586
  "kind": "dev",
587
587
  "methods": {
@@ -748,7 +748,7 @@
748
748
  },
749
749
  "networks": {},
750
750
  "schemaVersion": "3.4.16",
751
- "updatedAt": "2025-10-15T17:39:32.407Z",
751
+ "updatedAt": "2025-10-15T18:03:23.532Z",
752
752
  "devdoc": {
753
753
  "details": "Contract module that helps prevent reentrant calls to a function. Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier available, which can be applied to functions to make sure there are no nested (reentrant) calls to them. Note that because there is a single `nonReentrant` guard, functions marked as `nonReentrant` may not call one another. This can be worked around by making those functions `private`, and then adding `external` `nonReentrant` entry points to them. TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at, consider using {ReentrancyGuardTransient} instead. TIP: If you would like to learn more about reentrancy and alternative ways to protect against it, check out our blog post https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].",
754
754
  "errors": {
@@ -10,7 +10,7 @@
10
10
  "sourceMap": "2050:23729:63:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;2050:23729:63;;;;;;;;;;;;;;;;;",
11
11
  "deployedSourceMap": "2050:23729:63:-:0;;;;;;;;",
12
12
  "source": "// SPDX-License-Identifier: APACHE-2.0\n\npragma solidity >=0.8.0 <0.9.0;\n\n/*\n * @title String & Slice utility library for Solidity contracts.\n * @author Nick Johnson <arachnid@notdot.net>\n *\n * @dev Functionality in this library is largely implemented using an\n * abstraction called a 'Slice'. A Slice represents a part of a string -\n * anything from the entire string to a single character, or even no\n * characters at all (a 0-length Slice). Since a Slice only has to specify\n * an offset and a length, copying and manipulating slices is a lot less\n * expensive than copying and manipulating the strings they reference.\n *\n * To further reduce gas costs, most functions on Slice that need to return\n * a Slice modify the original one instead of allocating a new one; for\n * instance, `s.split(\".\")` will return the text up to the first '.',\n * modifying s to only contain the remainder of the string after the '.'.\n * In situations where you do not want to modify the original Slice, you\n * can make a copy first with `.copy()`, for example:\n * `s.copy().split(\".\")`. Try and avoid using this idiom in loops; since\n * Solidity has no memory management, it will result in allocating many\n * short-lived slices that are later discarded.\n *\n * Functions that return two slices come in two versions: a non-allocating\n * version that takes the second Slice as an argument, modifying it in\n * place, and an allocating version that allocates and returns the second\n * Slice; see `nextRune` for example.\n *\n * Functions that have to copy string data will return strings rather than\n * slices; these can be cast back to slices for further processing if\n * required.\n *\n * For convenience, some functions are provided with non-modifying\n * variants that create a new Slice and return both; for instance,\n * `s.splitNew('.')` leaves s unmodified, and returns two values\n * corresponding to the left and right parts of the string.\n */\n\nlibrary Slices {\n \n struct Slice {\n uint _len;\n uint _ptr;\n }\n\n function _memcpy(uint _dest, uint _src, uint _len) private pure {\n // Copy word-length chunks while possible\n for(; _len >= 32; _len -= 32) {\n assembly {\n mstore(_dest, mload(_src))\n }\n _dest += 32;\n _src += 32;\n }\n\n // Copy remaining bytes\n uint _mask = type(uint).max;\n if (_len > 0) {\n _mask = 256 ** (32 - _len) - 1;\n }\n assembly {\n let srcpart := and(mload(_src), not(_mask))\n let destpart := and(mload(_dest), _mask)\n mstore(_dest, or(destpart, srcpart))\n }\n }\n\n /*\n * @dev Returns a Slice containing the entire string.\n * @param self The string to make a Slice from.\n * @return A newly allocated Slice containing the entire string.\n */\n function toSlice(string memory self) internal pure returns (Slice memory) {\n uint ptr;\n assembly {\n ptr := add(self, 0x20)\n }\n return Slice(bytes(self).length, ptr);\n }\n\n /*\n * @dev Returns the length of a null-terminated bytes32 string.\n * @param self The value to find the length of.\n * @return The length of the string, from 0 to 32.\n */\n function len(bytes32 self) internal pure returns (uint) {\n uint ret;\n if (self == 0)\n return 0;\n if (uint(self) & type(uint128).max == 0) {\n ret += 16;\n self = bytes32(uint(self) / 0x100000000000000000000000000000000);\n }\n if (uint(self) & type(uint64).max == 0) {\n ret += 8;\n self = bytes32(uint(self) / 0x10000000000000000);\n }\n if (uint(self) & type(uint32).max == 0) {\n ret += 4;\n self = bytes32(uint(self) / 0x100000000);\n }\n if (uint(self) & type(uint16).max == 0) {\n ret += 2;\n self = bytes32(uint(self) / 0x10000);\n }\n if (uint(self) & type(uint8).max == 0) {\n ret += 1;\n }\n return 32 - ret;\n }\n\n /*\n * @dev Returns a Slice containing the entire bytes32, interpreted as a\n * null-terminated utf-8 string.\n * @param self The bytes32 value to convert to a Slice.\n * @return A new Slice containing the value of the input argument up to the\n * first null.\n */\n function toSliceB32(bytes32 self) internal pure returns (Slice memory ret) {\n // Allocate space for `self` in memory, copy it there, and point ret at it\n assembly {\n let ptr := mload(0x40)\n mstore(0x40, add(ptr, 0x20))\n mstore(ptr, self)\n mstore(add(ret, 0x20), ptr)\n }\n ret._len = len(self);\n }\n\n /*\n * @dev Returns a new Slice containing the same data as the current Slice.\n * @param self The Slice to copy.\n * @return A new Slice containing the same data as `self`.\n */\n function copy(Slice memory self) internal pure returns (Slice memory) {\n return Slice(self._len, self._ptr);\n }\n\n /*\n * @dev Copies a Slice to a new string.\n * @param self The Slice to copy.\n * @return A newly allocated string containing the Slice's text.\n */\n function toString(Slice memory self) internal pure returns (string memory) {\n string memory ret = new string(self._len);\n uint retptr;\n assembly { retptr := add(ret, 32) }\n\n _memcpy(retptr, self._ptr, self._len);\n return ret;\n }\n\n /*\n * @dev Returns the length in runes of the Slice. Note that this operation\n * takes time proportional to the length of the Slice; avoid using it\n * in loops, and call `Slice.empty()` if you only need to know whether\n * the Slice is empty or not.\n * @param self The Slice to operate on.\n * @return The length of the Slice in runes.\n */\n function len(Slice memory self) internal pure returns (uint _l) {\n // Starting at ptr-31 means the LSB will be the byte we care about\n uint ptr = self._ptr - 31;\n uint end = ptr + self._len;\n for (_l = 0; ptr < end; _l++) {\n uint8 b;\n assembly { b := and(mload(ptr), 0xFF) }\n if (b < 0x80) {\n ptr += 1;\n } else if(b < 0xE0) {\n ptr += 2;\n } else if(b < 0xF0) {\n ptr += 3;\n } else if(b < 0xF8) {\n ptr += 4;\n } else if(b < 0xFC) {\n ptr += 5;\n } else {\n ptr += 6;\n }\n }\n }\n\n /*\n * @dev Returns true if the Slice is empty (has a length of 0).\n * @param self The Slice to operate on.\n * @return True if the Slice is empty, False otherwise.\n */\n function empty(Slice memory self) internal pure returns (bool) {\n return self._len == 0;\n }\n\n /*\n * @dev Returns a positive number if `other` comes lexicographically after\n * `self`, a negative number if it comes before, or zero if the\n * contents of the two slices are equal. Comparison is done per-rune,\n * on unicode codepoints.\n * @param self The first Slice to compare.\n * @param other The second Slice to compare.\n * @return The result of the comparison.\n */\n function compare(Slice memory self, Slice memory other) internal pure returns (int) {\n uint shortest = self._len;\n if (other._len < self._len)\n shortest = other._len;\n\n uint selfptr = self._ptr;\n uint otherptr = other._ptr;\n for (uint idx = 0; idx < shortest; idx += 32) {\n uint a;\n uint b;\n assembly {\n a := mload(selfptr)\n b := mload(otherptr)\n }\n if (a != b) {\n // Mask out irrelevant bytes and check again\n uint mask = type(uint).max; // 0xffff...\n if(shortest < 32) {\n mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);\n }\n unchecked {\n uint diff = (a & mask) - (b & mask);\n if (diff != 0)\n return int(diff);\n }\n }\n selfptr += 32;\n otherptr += 32;\n }\n return int(self._len) - int(other._len);\n }\n\n /*\n * @dev Returns true if the two slices contain the same text.\n * @param self The first Slice to compare.\n * @param self The second Slice to compare.\n * @return True if the slices are equal, false otherwise.\n */\n function equals(Slice memory self, Slice memory other) internal pure returns (bool) {\n return compare(self, other) == 0;\n }\n\n /*\n * @dev Extracts the first rune in the Slice into `rune`, advancing the\n * Slice to point to the next rune and returning `self`.\n * @param self The Slice to operate on.\n * @param rune The Slice that will contain the first rune.\n * @return `rune`.\n */\n function nextRune(Slice memory self, Slice memory rune) internal pure returns (Slice memory) {\n rune._ptr = self._ptr;\n\n if (self._len == 0) {\n rune._len = 0;\n return rune;\n }\n\n uint _l;\n uint _b;\n // Load the first byte of the rune into the LSBs of _b\n assembly { _b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) }\n if (_b < 0x80) {\n _l = 1;\n } else if(_b < 0xE0) {\n _l = 2;\n } else if(_b < 0xF0) {\n _l = 3;\n } else {\n _l = 4;\n }\n\n // Check for truncated codepoints\n if (_l > self._len) {\n rune._len = self._len;\n self._ptr += self._len;\n self._len = 0;\n return rune;\n }\n\n self._ptr += _l;\n self._len -= _l;\n rune._len = _l;\n return rune;\n }\n\n /*\n * @dev Returns the first rune in the Slice, advancing the Slice to point\n * to the next rune.\n * @param self The Slice to operate on.\n * @return A Slice containing only the first rune from `self`.\n */\n function nextRune(Slice memory self) internal pure returns (Slice memory ret) {\n nextRune(self, ret);\n }\n\n /*\n * @dev Returns the number of the first codepoint in the Slice.\n * @param self The Slice to operate on.\n * @return The number of the first codepoint in the Slice.\n */\n function ord(Slice memory self) internal pure returns (uint ret) {\n if (self._len == 0) {\n return 0;\n }\n\n uint word;\n uint length;\n uint divisor = 2 ** 248;\n\n // Load the rune into the MSBs of b\n assembly { word:= mload(mload(add(self, 32))) }\n uint b = word / divisor;\n if (b < 0x80) {\n ret = b;\n length = 1;\n } else if(b < 0xE0) {\n ret = b & 0x1F;\n length = 2;\n } else if(b < 0xF0) {\n ret = b & 0x0F;\n length = 3;\n } else {\n ret = b & 0x07;\n length = 4;\n }\n\n // Check for truncated codepoints\n if (length > self._len) {\n return 0;\n }\n\n for (uint i = 1; i < length; i++) {\n divisor = divisor / 256;\n b = (word / divisor) & 0xFF;\n if (b & 0xC0 != 0x80) {\n // Invalid UTF-8 sequence\n return 0;\n }\n ret = (ret * 64) | (b & 0x3F);\n }\n\n return ret;\n }\n\n /*\n * @dev Returns the keccak-256 hash of the Slice.\n * @param self The Slice to hash.\n * @return The hash of the Slice.\n */\n function keccak(Slice memory self) internal pure returns (bytes32 ret) {\n assembly {\n ret := keccak256(mload(add(self, 32)), mload(self))\n }\n }\n\n /*\n * @dev Returns true if `self` starts with `needle`.\n * @param self The Slice to operate on.\n * @param needle The Slice to search for.\n * @return True if the Slice starts with the provided text, false otherwise.\n */\n function startsWith(Slice memory self, Slice memory needle) internal pure returns (bool) {\n if (self._len < needle._len) {\n return false;\n }\n\n if (self._ptr == needle._ptr) {\n return true;\n }\n\n bool equal;\n assembly {\n let length := mload(needle)\n let selfptr := mload(add(self, 0x20))\n let needleptr := mload(add(needle, 0x20))\n equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))\n }\n return equal;\n }\n\n /*\n * @dev If `self` starts with `needle`, `needle` is removed from the\n * beginning of `self`. Otherwise, `self` is unmodified.\n * @param self The Slice to operate on.\n * @param needle The Slice to search for.\n * @return `self`\n */\n function beyond(Slice memory self, Slice memory needle) internal pure returns (Slice memory) {\n if (self._len < needle._len) {\n return self;\n }\n\n bool equal = true;\n if (self._ptr != needle._ptr) {\n assembly {\n let length := mload(needle)\n let selfptr := mload(add(self, 0x20))\n let needleptr := mload(add(needle, 0x20))\n equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))\n }\n }\n\n if (equal) {\n self._len -= needle._len;\n self._ptr += needle._len;\n }\n\n return self;\n }\n\n /*\n * @dev Returns true if the Slice ends with `needle`.\n * @param self The Slice to operate on.\n * @param needle The Slice to search for.\n * @return True if the Slice starts with the provided text, false otherwise.\n */\n function endsWith(Slice memory self, Slice memory needle) internal pure returns (bool) {\n if (self._len < needle._len) {\n return false;\n }\n\n uint selfptr = self._ptr + self._len - needle._len;\n\n if (selfptr == needle._ptr) {\n return true;\n }\n\n bool equal;\n assembly {\n let length := mload(needle)\n let needleptr := mload(add(needle, 0x20))\n equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))\n }\n\n return equal;\n }\n\n /*\n * @dev If `self` ends with `needle`, `needle` is removed from the\n * end of `self`. Otherwise, `self` is unmodified.\n * @param self The Slice to operate on.\n * @param needle The Slice to search for.\n * @return `self`\n */\n function until(Slice memory self, Slice memory needle) internal pure returns (Slice memory) {\n if (self._len < needle._len) {\n return self;\n }\n\n uint selfptr = self._ptr + self._len - needle._len;\n bool equal = true;\n if (selfptr != needle._ptr) {\n assembly {\n let length := mload(needle)\n let needleptr := mload(add(needle, 0x20))\n equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))\n }\n }\n\n if (equal) {\n self._len -= needle._len;\n }\n\n return self;\n }\n\n // Returns the memory address of the first byte of the first occurrence of\n // `needle` in `self`, or the first byte after `self` if not found.\n function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {\n uint ptr = selfptr;\n uint idx;\n\n if (needlelen <= selflen) {\n if (needlelen <= 32) {\n bytes32 mask;\n if (needlelen > 0) {\n mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));\n }\n\n bytes32 needledata;\n assembly { needledata := and(mload(needleptr), mask) }\n\n uint end = selfptr + selflen - needlelen;\n bytes32 ptrdata;\n assembly { ptrdata := and(mload(ptr), mask) }\n\n while (ptrdata != needledata) {\n if (ptr >= end)\n return selfptr + selflen;\n ptr++;\n assembly { ptrdata := and(mload(ptr), mask) }\n }\n return ptr;\n } else {\n // For long needles, use hashing\n bytes32 hash;\n assembly { hash := keccak256(needleptr, needlelen) }\n\n for (idx = 0; idx <= selflen - needlelen; idx++) {\n bytes32 testHash;\n assembly { testHash := keccak256(ptr, needlelen) }\n if (hash == testHash)\n return ptr;\n ptr += 1;\n }\n }\n }\n return selfptr + selflen;\n }\n\n // Returns the memory address of the first byte after the last occurrence of\n // `needle` in `self`, or the address of `self` if not found.\n function rfindPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) {\n uint ptr;\n\n if (needlelen <= selflen) {\n if (needlelen <= 32) {\n bytes32 mask;\n if (needlelen > 0) {\n mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1));\n }\n\n bytes32 needledata;\n assembly { needledata := and(mload(needleptr), mask) }\n\n ptr = selfptr + selflen - needlelen;\n bytes32 ptrdata;\n assembly { ptrdata := and(mload(ptr), mask) }\n\n while (ptrdata != needledata) {\n if (ptr <= selfptr)\n return selfptr;\n ptr--;\n assembly { ptrdata := and(mload(ptr), mask) }\n }\n return ptr + needlelen;\n } else {\n // For long needles, use hashing\n bytes32 hash;\n assembly { hash := keccak256(needleptr, needlelen) }\n ptr = selfptr + (selflen - needlelen);\n while (ptr >= selfptr) {\n bytes32 testHash;\n assembly { testHash := keccak256(ptr, needlelen) }\n if (hash == testHash)\n return ptr + needlelen;\n ptr -= 1;\n }\n }\n }\n return selfptr;\n }\n\n /*\n * @dev Modifies `self` to contain everything from the first occurrence of\n * `needle` to the end of the Slice. `self` is set to the empty Slice\n * if `needle` is not found.\n * @param self The Slice to search and modify.\n * @param needle The text to search for.\n * @return `self`.\n */\n function find(Slice memory self, Slice memory needle) internal pure returns (Slice memory) {\n uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);\n self._len -= ptr - self._ptr;\n self._ptr = ptr;\n return self;\n }\n\n /*\n * @dev Modifies `self` to contain the part of the string from the start of\n * `self` to the end of the first occurrence of `needle`. If `needle`\n * is not found, `self` is set to the empty Slice.\n * @param self The Slice to search and modify.\n * @param needle The text to search for.\n * @return `self`.\n */\n function rfind(Slice memory self, Slice memory needle) internal pure returns (Slice memory) {\n uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);\n self._len = ptr - self._ptr;\n return self;\n }\n\n /*\n * @dev Splits the Slice, setting `self` to everything after the first\n * occurrence of `needle`, and `token` to everything before it. If\n * `needle` does not occur in `self`, `self` is set to the empty Slice,\n * and `token` is set to the entirety of `self`.\n * @param self The Slice to split.\n * @param needle The text to search for in `self`.\n * @param token An output parameter to which the first token is written.\n * @return `token`.\n */\n function split(Slice memory self, Slice memory needle, Slice memory token) internal pure returns (Slice memory) {\n uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);\n token._ptr = self._ptr;\n token._len = ptr - self._ptr;\n if (ptr == self._ptr + self._len) {\n // Not found\n self._len = 0;\n } else {\n self._len -= token._len + needle._len;\n self._ptr = ptr + needle._len;\n }\n return token;\n }\n\n /*\n * @dev Splits the Slice, setting `self` to everything after the first\n * occurrence of `needle`, and returning everything before it. If\n * `needle` does not occur in `self`, `self` is set to the empty Slice,\n * and the entirety of `self` is returned.\n * @param self The Slice to split.\n * @param needle The text to search for in `self`.\n * @return The part of `self` up to the first occurrence of `delim`.\n */\n function split(Slice memory self, Slice memory needle) internal pure returns (Slice memory token) {\n split(self, needle, token);\n }\n\n /*\n * @dev Splits the Slice, setting `self` to everything before the last\n * occurrence of `needle`, and `token` to everything after it. If\n * `needle` does not occur in `self`, `self` is set to the empty Slice,\n * and `token` is set to the entirety of `self`.\n * @param self The Slice to split.\n * @param needle The text to search for in `self`.\n * @param token An output parameter to which the first token is written.\n * @return `token`.\n */\n function rsplit(Slice memory self, Slice memory needle, Slice memory token) internal pure returns (Slice memory) {\n uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);\n token._ptr = ptr;\n token._len = self._len - (ptr - self._ptr);\n if (ptr == self._ptr) {\n // Not found\n self._len = 0;\n } else {\n self._len -= token._len + needle._len;\n }\n return token;\n }\n\n /*\n * @dev Splits the Slice, setting `self` to everything before the last\n * occurrence of `needle`, and returning everything after it. If\n * `needle` does not occur in `self`, `self` is set to the empty Slice,\n * and the entirety of `self` is returned.\n * @param self The Slice to split.\n * @param needle The text to search for in `self`.\n * @return The part of `self` after the last occurrence of `delim`.\n */\n function rsplit(Slice memory self, Slice memory needle) internal pure returns (Slice memory token) {\n rsplit(self, needle, token);\n }\n\n /*\n * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`.\n * @param self The Slice to search.\n * @param needle The text to search for in `self`.\n * @return The number of occurrences of `needle` found in `self`.\n */\n function count(Slice memory self, Slice memory needle) internal pure returns (uint cnt) {\n uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len;\n while (ptr <= self._ptr + self._len) {\n cnt++;\n ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len;\n }\n }\n\n /*\n * @dev Returns True if `self` contains `needle`.\n * @param self The Slice to search.\n * @param needle The text to search for in `self`.\n * @return True if `needle` is found in `self`, false otherwise.\n */\n function contains(Slice memory self, Slice memory needle) internal pure returns (bool) {\n return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr;\n }\n\n /*\n * @dev Returns a newly allocated string containing the concatenation of\n * `self` and `other`.\n * @param self The first Slice to concatenate.\n * @param other The second Slice to concatenate.\n * @return The concatenation of the two strings.\n */\n function concat(Slice memory self, Slice memory other) internal pure returns (string memory) {\n string memory ret = new string(self._len + other._len);\n uint retptr;\n assembly { retptr := add(ret, 32) }\n _memcpy(retptr, self._ptr, self._len);\n _memcpy(retptr + self._len, other._ptr, other._len);\n return ret;\n }\n\n /*\n * @dev Joins an array of slices, using `self` as a delimiter, returning a\n * newly allocated string.\n * @param self The delimiter to use.\n * @param parts A list of slices to join.\n * @return A newly allocated string containing all the slices in `parts`,\n * joined with `self`.\n */\n function join(Slice memory self, Slice[] memory parts) internal pure returns (string memory) {\n if (parts.length == 0)\n return \"\";\n\n uint length = self._len * (parts.length - 1);\n for(uint i = 0; i < parts.length; i++)\n length += parts[i]._len;\n\n string memory ret = new string(length);\n uint retptr;\n assembly { retptr := add(ret, 32) }\n\n for(uint i = 0; i < parts.length; i++) {\n _memcpy(retptr, parts[i]._ptr, parts[i]._len);\n retptr += parts[i]._len;\n if (i < parts.length - 1) {\n _memcpy(retptr, self._ptr, self._len);\n retptr += self._len;\n }\n }\n\n return ret;\n }\n}",
13
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/libs/Slices.sol",
13
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/libs/Slices.sol",
14
14
  "ast": {
15
15
  "absolutePath": "project:/contracts/libs/Slices.sol",
16
16
  "exportedSymbols": {
@@ -25457,7 +25457,7 @@
25457
25457
  },
25458
25458
  "networks": {},
25459
25459
  "schemaVersion": "3.4.16",
25460
- "updatedAt": "2025-10-15T17:39:32.817Z",
25460
+ "updatedAt": "2025-10-15T18:03:23.794Z",
25461
25461
  "devdoc": {
25462
25462
  "kind": "dev",
25463
25463
  "methods": {},
@@ -162,7 +162,7 @@
162
162
  "sourceMap": "",
163
163
  "deployedSourceMap": "",
164
164
  "source": "// SPDX-License-Identifier: MIT\n\n/* solhint-disable var-name-mixedcase */\n\npragma solidity >=0.6.0 <0.9.0;\n\nimport \"@openzeppelin/contracts/utils/introspection/ERC165.sol\";\n\nimport \"./Initializable.sol\";\nimport \"./Proxiable.sol\";\n\nabstract contract Upgradeable is Initializable, Proxiable {\n\n address internal immutable _BASE;\n bytes32 internal immutable _CODEHASH;\n bool internal immutable _UPGRADABLE;\n\n modifier onlyDelegateCalls virtual {\n require(\n address(this) != _BASE,\n \"Upgradeable: not a delegate call\"\n );\n _;\n }\n\n /// Emitted every time the contract gets upgraded.\n /// @param from The address who ordered the upgrading. Namely, the WRB operator in \"trustable\" implementations.\n /// @param baseAddr The address of the new implementation contract.\n /// @param baseCodehash The EVM-codehash of the new implementation contract.\n /// @param versionTag Ascii-encoded version literal with which the implementation deployer decided to tag it.\n event Upgraded(\n address indexed from,\n address indexed baseAddr,\n bytes32 indexed baseCodehash,\n string versionTag\n );\n\n constructor (bool _isUpgradable) {\n address _base = address(this);\n _BASE = _base;\n _UPGRADABLE = _isUpgradable;\n }\n\n /// @dev Retrieves base contract. Differs from address(this) when called via delegate-proxy pattern.\n function base() public view returns (address) {\n return _BASE;\n }\n\n /// @dev Retrieves the immutable codehash of this contract, even if invoked as delegatecall.\n function codehash() public view returns (bytes32 _codehash) {\n address _base = _BASE;\n assembly {\n _codehash := extcodehash(_base)\n }\n }\n\n /// @dev Determines whether the logic of this contract is potentially upgradable.\n function isUpgradable() public view returns (bool) {\n return _UPGRADABLE;\n }\n\n /// @dev Tells whether provided address could eventually upgrade the contract.\n function isUpgradableFrom(address from) virtual external view returns (bool);\n\n /// @notice Re-initialize contract's storage context upon a new upgrade from a proxy. \n /// @dev Must fail when trying to upgrade to same logic contract more than once.\n function initialize(bytes memory) virtual external;\n\n /// @dev Retrieves human-redable named version of current implementation.\n function version() virtual public view returns (string memory); \n}",
165
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/patterns/Upgradeable.sol",
165
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/patterns/Upgradeable.sol",
166
166
  "ast": {
167
167
  "absolutePath": "project:/contracts/patterns/Upgradeable.sol",
168
168
  "exportedSymbols": {
@@ -1508,7 +1508,7 @@
1508
1508
  },
1509
1509
  "networks": {},
1510
1510
  "schemaVersion": "3.4.16",
1511
- "updatedAt": "2025-10-15T17:39:33.107Z",
1511
+ "updatedAt": "2025-10-15T18:03:23.942Z",
1512
1512
  "devdoc": {
1513
1513
  "errors": {
1514
1514
  "InvalidInitialization()": [
@@ -161,7 +161,7 @@
161
161
  "sourceMap": "",
162
162
  "deployedSourceMap": "",
163
163
  "source": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.0 <0.9.0;\npragma experimental ABIEncoderV2;\n\nimport \"../WitnetOracle.sol\";\n\n/// @title The UsingWitnet contract\n/// @dev Witnet-aware contracts can inherit from this contract in order to interact with Witnet.\n/// @author The Witnet Foundation.\nabstract contract UsingWitnet\n is\n IWitnetOracleEvents\n{\n /// @dev Immutable reference to the Witnet Request Board contract.\n WitnetOracle internal immutable __witnet;\n \n /// @dev Default Security-Level Agreement parameters to be fulfilled by the Witnet blockchain\n /// @dev when solving a data request.\n WitnetV2.RadonSLA internal __witnetDefaultSLA;\n\n /// @dev Percentage over base fee to pay on every data request, \n /// @dev as to deal with volatility of evmGasPrice and evmWitPrice during the live time of \n /// @dev a data request (since being posted until a result gets reported back), at both the EVM and \n /// @dev the Witnet blockchain levels, respectivelly. \n uint16 internal __witnetBaseFeeOverheadPercentage;\n\n /// @param _wrb Address of the WitnetOracle contract.\n constructor(WitnetOracle _wrb) {\n require(\n _wrb.specs() == type(IWitnetOracle).interfaceId,\n \"UsingWitnet: uncompliant WitnetOracle\"\n );\n __witnet = _wrb;\n __witnetDefaultSLA = WitnetV2.RadonSLA({\n // Number of nodes in the Witnet blockchain that will take part in solving the data request:\n committeeSize: 10,\n // Fee in $nanoWIT paid to every node in the Witnet blockchain involved in solving the data request:\n witnessingFeeNanoWit: 2 * 10 ** 8 // defaults to 0.2 $WIT\n });\n \n __witnetBaseFeeOverheadPercentage = 33; // defaults to 33%\n }\n\n /// @dev Provides a convenient way for client contracts extending this to block the execution of the main logic of the\n /// @dev contract until a particular request has been successfully solved and reported by Witnet,\n /// @dev either with an error or successfully.\n modifier witnetQuerySolved(uint256 _witnetQueryId) {\n require(_witnetCheckQueryResultAvailability(_witnetQueryId), \"UsingWitnet: unsolved query\");\n _;\n }\n\n function witnet() virtual public view returns (WitnetOracle) {\n return __witnet;\n }\n\n /// @notice Check if given query was already reported back from the Witnet oracle.\n /// @param _id The unique identifier of a previously posted data request.\n function _witnetCheckQueryResultAvailability(uint256 _id)\n internal view\n returns (bool)\n {\n return __witnet.getQueryStatus(_id) == WitnetV2.QueryStatus.Reported;\n }\n\n /// @notice Estimate the minimum reward required for posting a data request, using `tx.gasprice` as a reference.\n /// @dev Underestimates if the size of returned data is greater than `_resultMaxSize`. \n /// @param _resultMaxSize Maximum expected size of returned data (in bytes).\n function _witnetEstimateEvmReward(uint16 _resultMaxSize)\n virtual internal view\n returns (uint256)\n {\n return (\n (100 + __witnetBaseFeeOverheadPercentage)\n * __witnet.estimateBaseFee(tx.gasprice, _resultMaxSize) \n ) / 100;\n }\n\n function _witnetCheckQueryResponseStatus(uint256 _witnetQueryId)\n internal view\n returns (WitnetV2.ResponseStatus)\n {\n return __witnet.getQueryResponseStatus(_witnetQueryId);\n }\n\n function _witnetCheckQueryResultError(uint256 _witnetQueryId)\n internal view\n returns (Witnet.ResultError memory)\n {\n return __witnet.getQueryResultError(_witnetQueryId);\n }\n}\n",
164
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/apps/UsingWitnet.sol",
164
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/apps/UsingWitnet.sol",
165
165
  "ast": {
166
166
  "absolutePath": "project:/contracts/apps/UsingWitnet.sol",
167
167
  "exportedSymbols": {
@@ -2137,7 +2137,7 @@
2137
2137
  },
2138
2138
  "networks": {},
2139
2139
  "schemaVersion": "3.4.16",
2140
- "updatedAt": "2025-10-15T17:39:32.422Z",
2140
+ "updatedAt": "2025-10-15T18:03:23.539Z",
2141
2141
  "devdoc": {
2142
2142
  "author": "The Witnet Foundation.",
2143
2143
  "details": "Witnet-aware contracts can inherit from this contract in order to interact with Witnet.",
@@ -223,7 +223,7 @@
223
223
  "sourceMap": "",
224
224
  "deployedSourceMap": "",
225
225
  "source": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.0 <0.9.0;\npragma experimental ABIEncoderV2;\n\nimport \"../WitnetRandomness.sol\";\n\n/// @title The UsingWitnetRandomness contract\n/// @dev Contracts willing to interact with WitnetRandomness appliance should just inherit from this contract.\n/// @author The Witnet Foundation.\nabstract contract UsingWitnetRandomness\n is\n IWitnetOracleEvents,\n IWitnetRandomnessEvents\n{\n WitnetOracle immutable public witnet;\n WitnetRandomness immutable public __RNG;\n\n constructor(WitnetRandomness _witnetRandomness) {\n require(\n address(_witnetRandomness).code.length > 0\n && _witnetRandomness.specs() == type(WitnetRandomness).interfaceId,\n \"UsingWitnetRandomness: uncompliant WitnetRandomness appliance\"\n );\n __RNG = _witnetRandomness;\n witnet = __RNG.witnet();\n }\n\n}\n\n",
226
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/apps/UsingWitnetRandomness.sol",
226
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/apps/UsingWitnetRandomness.sol",
227
227
  "ast": {
228
228
  "absolutePath": "project:/contracts/apps/UsingWitnetRandomness.sol",
229
229
  "exportedSymbols": {
@@ -989,7 +989,7 @@
989
989
  },
990
990
  "networks": {},
991
991
  "schemaVersion": "3.4.16",
992
- "updatedAt": "2025-10-15T17:39:32.424Z",
992
+ "updatedAt": "2025-10-15T18:03:23.540Z",
993
993
  "devdoc": {
994
994
  "author": "The Witnet Foundation.",
995
995
  "details": "Contracts willing to interact with WitnetRandomness appliance should just inherit from this contract.",
@@ -174,7 +174,7 @@
174
174
  "sourceMap": "",
175
175
  "deployedSourceMap": "",
176
176
  "source": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./UsingWitnet.sol\";\nimport \"../WitnetRequest.sol\";\n\nabstract contract UsingWitnetRequest\n is UsingWitnet\n{\n WitnetRequest immutable public dataRequest;\n \n bytes32 immutable internal __witnetRequestRadHash;\n uint16 immutable internal __witnetQueryResultMaxSize;\n \n /// @param _witnetRequest Address of the WitnetRequest contract containing the actual data request.\n /// @param _baseFeeOverheadPercentage Percentage over base fee to pay as on every data request.\n constructor (\n WitnetRequest _witnetRequest,\n uint16 _baseFeeOverheadPercentage\n )\n UsingWitnet(_witnetRequest.witnet())\n {\n require(\n _witnetRequest.specs() == type(WitnetRequest).interfaceId,\n \"UsingWitnetRequest: uncompliant WitnetRequest\"\n );\n dataRequest = _witnetRequest;\n __witnetQueryResultMaxSize = _witnetRequest.resultDataMaxSize();\n __witnetRequestRadHash = _witnetRequest.radHash();\n __witnetBaseFeeOverheadPercentage = _baseFeeOverheadPercentage;\n }\n\n function _witnetEstimateEvmReward()\n virtual internal view\n returns (uint256)\n {\n return _witnetEstimateEvmReward(__witnetQueryResultMaxSize);\n }\n\n function __witnetRequestData(uint256 _witnetEvmReward)\n virtual internal returns (uint256)\n {\n return __witnetRequestData(_witnetEvmReward, __witnetDefaultSLA);\n }\n\n function __witnetRequestData(\n uint256 _witnetEvmReward,\n WitnetV2.RadonSLA memory _witnetQuerySLA\n )\n virtual internal returns (uint256)\n {\n return __witnet.postRequest{value: _witnetEvmReward}(\n __witnetRequestRadHash,\n _witnetQuerySLA\n );\n }\n}\n",
177
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/apps/UsingWitnetRequest.sol",
177
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/apps/UsingWitnetRequest.sol",
178
178
  "ast": {
179
179
  "absolutePath": "project:/contracts/apps/UsingWitnetRequest.sol",
180
180
  "exportedSymbols": {
@@ -1551,7 +1551,7 @@
1551
1551
  },
1552
1552
  "networks": {},
1553
1553
  "schemaVersion": "3.4.16",
1554
- "updatedAt": "2025-10-15T17:39:32.427Z",
1554
+ "updatedAt": "2025-10-15T18:03:23.541Z",
1555
1555
  "devdoc": {
1556
1556
  "kind": "dev",
1557
1557
  "methods": {
@@ -174,7 +174,7 @@
174
174
  "sourceMap": "",
175
175
  "deployedSourceMap": "",
176
176
  "source": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./UsingWitnet.sol\";\nimport \"../WitnetRequest.sol\";\n\nabstract contract UsingWitnetRequestTemplate\n is UsingWitnet\n{\n WitnetRequestTemplate immutable public dataRequestTemplate;\n \n uint16 immutable internal __witnetQueryResultMaxSize;\n \n /// @param _witnetRequestTemplate Address of the WitnetRequestTemplate from which actual data requests will get built.\n /// @param _baseFeeOverheadPercentage Percentage over base fee to pay as on every data request.\n constructor (\n WitnetRequestTemplate _witnetRequestTemplate, \n uint16 _baseFeeOverheadPercentage\n )\n UsingWitnet(_witnetRequestTemplate.witnet())\n {\n require(\n _witnetRequestTemplate.specs() == type(WitnetRequestTemplate).interfaceId,\n \"UsingWitnetRequestTemplate: uncompliant WitnetRequestTemplate\"\n );\n dataRequestTemplate = _witnetRequestTemplate;\n __witnetQueryResultMaxSize = _witnetRequestTemplate.resultDataMaxSize();\n __witnetBaseFeeOverheadPercentage = _baseFeeOverheadPercentage;\n }\n\n function _witnetBuildRadHash(string[][] memory _witnetRequestArgs)\n internal returns (bytes32)\n {\n return dataRequestTemplate.verifyRadonRequest(_witnetRequestArgs);\n }\n \n function _witnetBuildRequest(string[][] memory _witnetRequestArgs)\n internal returns (WitnetRequest)\n {\n return WitnetRequest(dataRequestTemplate.buildRequest(_witnetRequestArgs));\n }\n\n function _witnetEstimateEvmReward()\n virtual internal view\n returns (uint256)\n {\n return _witnetEstimateEvmReward(__witnetQueryResultMaxSize);\n }\n\n function __witnetRequestData(\n uint256 _witnetEvmReward,\n string[][] memory _witnetRequestArgs\n )\n virtual internal returns (uint256)\n {\n return __witnetRequestData(_witnetEvmReward, _witnetRequestArgs, __witnetDefaultSLA);\n }\n\n function __witnetRequestData(\n uint256 _witnetEvmReward,\n string[][] memory _witnetRequestArgs,\n WitnetV2.RadonSLA memory _witnetQuerySLA\n )\n virtual internal returns (uint256)\n {\n return __witnet.postRequest{value: _witnetEvmReward}(\n _witnetBuildRadHash(_witnetRequestArgs),\n _witnetQuerySLA\n );\n }\n}\n",
177
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/apps/UsingWitnetRequestTemplate.sol",
177
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/apps/UsingWitnetRequestTemplate.sol",
178
178
  "ast": {
179
179
  "absolutePath": "project:/contracts/apps/UsingWitnetRequestTemplate.sol",
180
180
  "exportedSymbols": {
@@ -1992,7 +1992,7 @@
1992
1992
  },
1993
1993
  "networks": {},
1994
1994
  "schemaVersion": "3.4.16",
1995
- "updatedAt": "2025-10-15T17:39:32.436Z",
1995
+ "updatedAt": "2025-10-15T18:03:23.542Z",
1996
1996
  "devdoc": {
1997
1997
  "kind": "dev",
1998
1998
  "methods": {
@@ -10,7 +10,7 @@
10
10
  "sourceMap": "128:31067:64:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;128:31067:64;;;;;;;;;;;;;;;;;",
11
11
  "deployedSourceMap": "128:31067:64:-:0;;;;;;;;",
12
12
  "source": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.7.0 <0.9.0;\npragma experimental ABIEncoderV2;\n\nimport \"./WitnetCBOR.sol\";\n\nlibrary Witnet {\n\n using WitnetBuffer for WitnetBuffer.Buffer;\n using WitnetCBOR for WitnetCBOR.CBOR;\n using WitnetCBOR for WitnetCBOR.CBOR[];\n\n /// Struct containing both request and response data related to every query posted to the Witnet Request Board\n struct Query {\n Request request;\n Response response;\n address from; // Address from which the request was posted.\n }\n\n /// Possible status of a Witnet query.\n enum QueryStatus {\n Unknown,\n Posted,\n Reported,\n Deleted\n }\n\n /// Data kept in EVM-storage for every Request posted to the Witnet Request Board.\n struct Request {\n address addr; // Address of the (deprecated) IWitnetRequest contract containing Witnet data request raw bytecode.\n bytes32 slaHash; // Radon SLA hash of the Witnet data request.\n bytes32 radHash; // Radon radHash of the Witnet data request.\n uint256 gasprice; // Minimum gas price the DR resolver should pay on the solving tx.\n uint256 reward; // Escrowed reward to be paid to the DR resolver.\n }\n\n /// Data kept in EVM-storage containing the Witnet-provided response metadata and CBOR-encoded result.\n struct Response {\n address reporter; // Address from which the result was reported.\n uint256 timestamp; // Timestamp of the Witnet-provided result.\n bytes32 drTxHash; // Hash of the Witnet transaction that solved the queried Data Request.\n bytes cborBytes; // Witnet-provided result CBOR-bytes to the queried Data Request.\n }\n\n /// Data struct containing the Witnet-provided result to a Data Request.\n struct Result {\n bool success; // Flag stating whether the request could get solved successfully, or not.\n WitnetCBOR.CBOR value; // Resulting value, in CBOR-serialized bytes.\n }\n\n /// Final query's result status from a requester's point of view.\n enum ResultStatus {\n Void,\n Awaiting,\n Ready,\n Error\n }\n\n /// Data struct describing an error when trying to fetch a Witnet-provided result to a Data Request.\n struct ResultError {\n ResultErrorCodes code;\n string reason;\n }\n\n enum ResultErrorCodes {\n /// 0x00: Unknown error. Something went really bad!\n Unknown, \n \n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n /// Source-specific format error sub-codes ============================================================================\n /// 0x01: At least one of the source scripts is not a valid CBOR-encoded value.\n SourceScriptNotCBOR, \n /// 0x02: The CBOR value decoded from a source script is not an Array.\n SourceScriptNotArray,\n /// 0x03: The Array value decoded form a source script is not a valid Data Request.\n SourceScriptNotRADON,\n /// 0x04: The request body of at least one data source was not properly formated.\n SourceRequestBody,\n /// 0x05: The request headers of at least one data source was not properly formated.\n SourceRequestHeaders,\n /// 0x06: The request URL of at least one data source was not properly formated.\n SourceRequestURL,\n /// Unallocated\n SourceFormat0x07, SourceFormat0x08, SourceFormat0x09, SourceFormat0x0A, SourceFormat0x0B, SourceFormat0x0C,\n SourceFormat0x0D, SourceFormat0x0E, SourceFormat0x0F, \n \n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n /// Complexity error sub-codes ========================================================================================\n /// 0x10: The request contains too many sources.\n RequestTooManySources,\n /// 0x11: The script contains too many calls.\n ScriptTooManyCalls,\n /// Unallocated\n Complexity0x12, Complexity0x13, Complexity0x14, Complexity0x15, Complexity0x16, Complexity0x17, Complexity0x18,\n Complexity0x19, Complexity0x1A, Complexity0x1B, Complexity0x1C, Complexity0x1D, Complexity0x1E, Complexity0x1F,\n\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n /// Lack of support error sub-codes ===================================================================================\n /// 0x20: Some Radon operator code was found that is not supported (1+ args).\n UnsupportedOperator,\n /// 0x21: Some Radon filter opcode is not currently supported (1+ args).\n UnsupportedFilter,\n /// 0x22: Some Radon request type is not currently supported (1+ args).\n UnsupportedHashFunction,\n /// 0x23: Some Radon reducer opcode is not currently supported (1+ args)\n UnsupportedReducer,\n /// 0x24: Some Radon hash function is not currently supported (1+ args).\n UnsupportedRequestType, \n /// 0x25: Some Radon encoding function is not currently supported (1+ args).\n UnsupportedEncodingFunction,\n /// Unallocated\n Operator0x26, Operator0x27, \n /// 0x28: Wrong number (or type) of arguments were passed to some Radon operator.\n WrongArguments,\n /// Unallocated\n Operator0x29, Operator0x2A, Operator0x2B, Operator0x2C, Operator0x2D, Operator0x2E, Operator0x2F,\n \n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n /// Retrieve-specific circumstantial error sub-codes ================================================================================\n /// 0x30: A majority of data sources returned an HTTP status code other than 200 (1+ args):\n HttpErrors,\n /// 0x31: A majority of data sources timed out:\n RetrievalsTimeout,\n /// Unallocated\n RetrieveCircumstance0x32, RetrieveCircumstance0x33, RetrieveCircumstance0x34, RetrieveCircumstance0x35,\n RetrieveCircumstance0x36, RetrieveCircumstance0x37, RetrieveCircumstance0x38, RetrieveCircumstance0x39,\n RetrieveCircumstance0x3A, RetrieveCircumstance0x3B, RetrieveCircumstance0x3C, RetrieveCircumstance0x3D,\n RetrieveCircumstance0x3E, RetrieveCircumstance0x3F,\n \n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n /// Scripting-specific runtime error sub-code =========================================================================\n /// 0x40: Math operator caused an underflow.\n MathUnderflow,\n /// 0x41: Math operator caused an overflow.\n MathOverflow,\n /// 0x42: Math operator tried to divide by zero.\n MathDivisionByZero, \n /// 0x43:Wrong input to subscript call.\n WrongSubscriptInput,\n /// 0x44: Value cannot be extracted from input binary buffer.\n BufferIsNotValue,\n /// 0x45: Value cannot be decoded from expected type.\n Decode,\n /// 0x46: Unexpected empty array.\n EmptyArray,\n /// 0x47: Value cannot be encoded to expected type.\n Encode,\n /// 0x48: Failed to filter input values (1+ args).\n Filter,\n /// 0x49: Failed to hash input value.\n Hash,\n /// 0x4A: Mismatching array ranks.\n MismatchingArrays,\n /// 0x4B: Failed to process non-homogenous array.\n NonHomegeneousArray,\n /// 0x4C: Failed to parse syntax of some input value, or argument.\n Parse,\n /// 0x4E: Parsing logic limits were exceeded.\n ParseOverflow,\n /// 0x4F: Unallocated\n ScriptError0x4F,\n \n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n /// Actual first-order result error codes =============================================================================\n /// 0x50: Not enough reveals were received in due time:\n InsufficientReveals,\n /// 0x51: No actual reveal majority was reached on tally stage:\n InsufficientMajority,\n /// 0x52: Not enough commits were received before tally stage:\n InsufficientCommits,\n /// 0x53: Generic error during tally execution (to be deprecated after WIP #0028)\n TallyExecution,\n /// 0x54: A majority of data sources could either be temporarily unresponsive or failing to report the requested data:\n CircumstantialFailure,\n /// 0x55: At least one data source is inconsistent when queried through multiple transports at once:\n InconsistentSources,\n /// 0x56: Any one of the (multiple) Retrieve, Aggregate or Tally scripts were badly formated:\n MalformedDataRequest,\n /// 0x57: Values returned from a majority of data sources don't match the expected schema:\n MalformedResponses,\n /// Unallocated: \n OtherError0x58, OtherError0x59, OtherError0x5A, OtherError0x5B, OtherError0x5C, OtherError0x5D, OtherError0x5E, \n /// 0x5F: Size of serialized tally result exceeds allowance:\n OversizedTallyResult,\n\n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n /// Inter-stage runtime error sub-codes ===============================================================================\n /// 0x60: Data aggregation reveals could not get decoded on the tally stage:\n MalformedReveals,\n /// 0x61: The result to data aggregation could not get encoded:\n EncodeReveals, \n /// 0x62: A mode tie ocurred when calculating some mode value on the aggregation or the tally stage:\n ModeTie, \n /// Unallocated:\n OtherError0x63, OtherError0x64, OtherError0x65, OtherError0x66, OtherError0x67, OtherError0x68, OtherError0x69, \n OtherError0x6A, OtherError0x6B, OtherError0x6C, OtherError0x6D, OtherError0x6E, OtherError0x6F,\n \n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n /// Runtime access error sub-codes ====================================================================================\n /// 0x70: Tried to access a value from an array using an index that is out of bounds (1+ args):\n ArrayIndexOutOfBounds,\n /// 0x71: Tried to access a value from a map using a key that does not exist (1+ args):\n MapKeyNotFound,\n /// 0X72: Tried to extract value from a map using a JSON Path that returns no values (+1 args):\n JsonPathNotFound,\n /// Unallocated:\n OtherError0x73, OtherError0x74, OtherError0x75, OtherError0x76, OtherError0x77, OtherError0x78, \n OtherError0x79, OtherError0x7A, OtherError0x7B, OtherError0x7C, OtherError0x7D, OtherError0x7E, OtherError0x7F, \n OtherError0x80, OtherError0x81, OtherError0x82, OtherError0x83, OtherError0x84, OtherError0x85, OtherError0x86, \n OtherError0x87, OtherError0x88, OtherError0x89, OtherError0x8A, OtherError0x8B, OtherError0x8C, OtherError0x8D, \n OtherError0x8E, OtherError0x8F, OtherError0x90, OtherError0x91, OtherError0x92, OtherError0x93, OtherError0x94, \n OtherError0x95, OtherError0x96, OtherError0x97, OtherError0x98, OtherError0x99, OtherError0x9A, OtherError0x9B,\n OtherError0x9C, OtherError0x9D, OtherError0x9E, OtherError0x9F, OtherError0xA0, OtherError0xA1, OtherError0xA2, \n OtherError0xA3, OtherError0xA4, OtherError0xA5, OtherError0xA6, OtherError0xA7, OtherError0xA8, OtherError0xA9, \n OtherError0xAA, OtherError0xAB, OtherError0xAC, OtherError0xAD, OtherError0xAE, OtherError0xAF, OtherError0xB0,\n OtherError0xB1, OtherError0xB2, OtherError0xB3, OtherError0xB4, OtherError0xB5, OtherError0xB6, OtherError0xB7,\n OtherError0xB8, OtherError0xB9, OtherError0xBA, OtherError0xBB, OtherError0xBC, OtherError0xBD, OtherError0xBE,\n OtherError0xBF, OtherError0xC0, OtherError0xC1, OtherError0xC2, OtherError0xC3, OtherError0xC4, OtherError0xC5,\n OtherError0xC6, OtherError0xC7, OtherError0xC8, OtherError0xC9, OtherError0xCA, OtherError0xCB, OtherError0xCC,\n OtherError0xCD, OtherError0xCE, OtherError0xCF, OtherError0xD0, OtherError0xD1, OtherError0xD2, OtherError0xD3,\n OtherError0xD4, OtherError0xD5, OtherError0xD6, OtherError0xD7, OtherError0xD8, OtherError0xD9, OtherError0xDA,\n OtherError0xDB, OtherError0xDC, OtherError0xDD, OtherError0xDE, OtherError0xDF,\n \n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n /// Inter-client generic error codes ==================================================================================\n /// Data requests that cannot be relayed into the Witnet blockchain should be reported\n /// with one of these errors. \n /// 0xE0: Requests that cannot be parsed must always get this error as their result.\n BridgeMalformedDataRequest,\n /// 0xE1: Witnesses exceeds 100\n BridgePoorIncentives,\n /// 0xE2: The request is rejected on the grounds that it may cause the submitter to spend or stake an\n /// amount of value that is unjustifiably high when compared with the reward they will be getting\n BridgeOversizedTallyResult,\n \n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n /// Unallocated =======================================================================================================\n OtherError0xE3, OtherError0xE4, OtherError0xE5, OtherError0xE6, OtherError0xE7, OtherError0xE8, OtherError0xE9,\n OtherError0xEA, OtherError0xEB, OtherError0xEC, OtherError0xED, OtherError0xEE, OtherError0xEF, OtherError0xF0,\n OtherError0xF1, OtherError0xF2, OtherError0xF3, OtherError0xF4, OtherError0xF5, OtherError0xF6, OtherError0xF7,\n OtherError0xF8, OtherError0xF9, OtherError0xFA, OtherError0xFB, OtherError0xFC, OtherError0xFD, OtherError0xFE,\n \n ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n /// 0xFF: Some tally error is not intercepted but it should (0+ args)\n UnhandledIntercept\n }\n\n function isCircumstantial(ResultErrorCodes self) internal pure returns (bool) {\n return (self == ResultErrorCodes.CircumstantialFailure);\n }\n\n function lackOfConsensus(ResultErrorCodes self) internal pure returns (bool) {\n return (\n self == ResultErrorCodes.InsufficientCommits\n || self == ResultErrorCodes.InsufficientMajority\n || self == ResultErrorCodes.InsufficientReveals\n );\n }\n\n function isRetriable(ResultErrorCodes self) internal pure returns (bool) {\n return (\n lackOfConsensus(self)\n || isCircumstantial(self)\n || poorIncentives(self)\n );\n }\n\n function poorIncentives(ResultErrorCodes self) internal pure returns (bool) {\n return (\n self == ResultErrorCodes.OversizedTallyResult\n || self == ResultErrorCodes.InsufficientCommits\n || self == ResultErrorCodes.BridgePoorIncentives\n || self == ResultErrorCodes.BridgeOversizedTallyResult\n );\n }\n \n\n /// Possible Radon data request methods that can be used within a Radon Retrieval. \n enum RadonDataRequestMethods {\n /* 0 */ Unknown,\n /* 1 */ HttpGet,\n /* 2 */ RNG,\n /* 3 */ HttpPost,\n /* 4 */ HttpHead\n }\n\n /// Possible types either processed by Witnet Radon Scripts or included within results to Witnet Data Requests.\n enum RadonDataTypes {\n /* 0x00 */ Any, \n /* 0x01 */ Array,\n /* 0x02 */ Bool,\n /* 0x03 */ Bytes,\n /* 0x04 */ Integer,\n /* 0x05 */ Float,\n /* 0x06 */ Map,\n /* 0x07 */ String,\n Unused0x08, Unused0x09, Unused0x0A, Unused0x0B,\n Unused0x0C, Unused0x0D, Unused0x0E, Unused0x0F,\n /* 0x10 */ Same,\n /* 0x11 */ Inner,\n /* 0x12 */ Match,\n /* 0x13 */ Subscript\n }\n\n /// Structure defining some data filtering that can be applied at the Aggregation or the Tally stages\n /// within a Witnet Data Request resolution workflow.\n struct RadonFilter {\n RadonFilterOpcodes opcode;\n bytes args;\n }\n\n /// Filtering methods currently supported on the Witnet blockchain. \n enum RadonFilterOpcodes {\n /* 0x00 */ Reserved0x00, //GreaterThan,\n /* 0x01 */ Reserved0x01, //LessThan,\n /* 0x02 */ Reserved0x02, //Equals,\n /* 0x03 */ Reserved0x03, //AbsoluteDeviation,\n /* 0x04 */ Reserved0x04, //RelativeDeviation\n /* 0x05 */ StandardDeviation,\n /* 0x06 */ Reserved0x06, //Top,\n /* 0x07 */ Reserved0x07, //Bottom,\n /* 0x08 */ Mode,\n /* 0x09 */ Reserved0x09 //LessOrEqualThan\n }\n\n /// Structure defining the array of filters and reducting function to be applied at either the Aggregation\n /// or the Tally stages within a Witnet Data Request resolution workflow.\n struct RadonReducer {\n RadonReducerOpcodes opcode;\n RadonFilter[] filters;\n }\n\n /// Reducting functions currently supported on the Witnet blockchain.\n enum RadonReducerOpcodes {\n /* 0x00 */ Reserved0x00, //Minimum,\n /* 0x01 */ Reserved0x01, //Maximum,\n /* 0x02 */ Mode,\n /* 0x03 */ AverageMean,\n /* 0x04 */ Reserved0x04, //AverageMeanWeighted,\n /* 0x05 */ AverageMedian,\n /* 0x06 */ Reserved0x06, //AverageMedianWeighted,\n /* 0x07 */ StandardDeviation,\n /* 0x08 */ Reserved0x08, //AverageDeviation,\n /* 0x09 */ Reserved0x09, //MedianDeviation,\n /* 0x0A */ Reserved0x10, //MaximumDeviation,\n /* 0x0B */ ConcatenateAndHash\n }\n\n /// Structure containing all the parameters that fully describe a Witnet Radon Retrieval within a Witnet Data Request.\n struct RadonRetrieval {\n uint8 argsCount;\n RadonDataRequestMethods method;\n RadonDataTypes resultDataType;\n string url;\n string body;\n string[2][] headers;\n bytes script;\n }\n\n /// Structure containing the Retrieve-Attestation-Delivery parts of a Witnet Data Request.\n struct RadonRAD {\n RadonRetrieval[] retrieve;\n RadonReducer aggregate;\n RadonReducer tally;\n }\n\n /// Structure containing the Service Level Aggreement parameters of a Witnet Data Request.\n struct RadonSLA {\n uint8 numWitnesses;\n uint8 minConsensusPercentage;\n uint64 witnessReward;\n uint64 witnessCollateral;\n uint64 minerCommitRevealFee;\n }\n\n\n /// ===============================================================================================================\n /// --- 'uint*' helper methods ------------------------------------------------------------------------------------\n\n /// @notice Convert a `uint8` into a 2 characters long `string` representing its two less significant hexadecimal values.\n function toHexString(uint8 _u)\n internal pure\n returns (string memory)\n {\n bytes memory b2 = new bytes(2);\n uint8 d0 = uint8(_u / 16) + 48;\n uint8 d1 = uint8(_u % 16) + 48;\n if (d0 > 57)\n d0 += 7;\n if (d1 > 57)\n d1 += 7;\n b2[0] = bytes1(d0);\n b2[1] = bytes1(d1);\n return string(b2);\n }\n\n /// @notice Convert a `uint8` into a 1, 2 or 3 characters long `string` representing its.\n /// three less significant decimal values.\n function toString(uint8 _u)\n internal pure\n returns (string memory)\n {\n if (_u < 10) {\n bytes memory b1 = new bytes(1);\n b1[0] = bytes1(uint8(_u) + 48);\n return string(b1);\n } else if (_u < 100) {\n bytes memory b2 = new bytes(2);\n b2[0] = bytes1(uint8(_u / 10) + 48);\n b2[1] = bytes1(uint8(_u % 10) + 48);\n return string(b2);\n } else {\n bytes memory b3 = new bytes(3);\n b3[0] = bytes1(uint8(_u / 100) + 48);\n b3[1] = bytes1(uint8(_u % 100 / 10) + 48);\n b3[2] = bytes1(uint8(_u % 10) + 48);\n return string(b3);\n }\n }\n\n /// @notice Convert a `uint` into a string` representing its value.\n function toString(uint v)\n internal pure \n returns (string memory)\n {\n uint maxlength = 100;\n bytes memory reversed = new bytes(maxlength);\n uint i = 0;\n do {\n uint8 remainder = uint8(v % 10);\n v = v / 10;\n reversed[i ++] = bytes1(48 + remainder);\n } while (v != 0);\n bytes memory buf = new bytes(i);\n for (uint j = 1; j <= i; j ++) {\n buf[j - 1] = reversed[i - j];\n }\n return string(buf);\n }\n\n\n /// ===============================================================================================================\n /// --- 'bytes' helper methods ------------------------------------------------------------------------------------\n\n /// @dev Transform given bytes into a Witnet.Result instance.\n /// @param cborBytes Raw bytes representing a CBOR-encoded value.\n /// @return A `Witnet.Result` instance.\n function toWitnetResult(bytes memory cborBytes)\n internal pure\n returns (Witnet.Result memory)\n {\n WitnetCBOR.CBOR memory cborValue = WitnetCBOR.fromBytes(cborBytes);\n return _resultFromCborValue(cborValue);\n }\n\n function toAddress(bytes memory _value) internal pure returns (address) {\n return address(toBytes20(_value));\n }\n\n function toBytes4(bytes memory _value) internal pure returns (bytes4) {\n return bytes4(toFixedBytes(_value, 4));\n }\n \n function toBytes20(bytes memory _value) internal pure returns (bytes20) {\n return bytes20(toFixedBytes(_value, 20));\n }\n \n function toBytes32(bytes memory _value) internal pure returns (bytes32) {\n return toFixedBytes(_value, 32);\n }\n\n function toFixedBytes(bytes memory _value, uint8 _numBytes)\n internal pure\n returns (bytes32 _bytes32)\n {\n assert(_numBytes <= 32);\n unchecked {\n uint _len = _value.length > _numBytes ? _numBytes : _value.length;\n for (uint _i = 0; _i < _len; _i ++) {\n _bytes32 |= bytes32(_value[_i] & 0xff) >> (_i * 8);\n }\n }\n }\n\n\n /// ===============================================================================================================\n /// --- 'string' helper methods -----------------------------------------------------------------------------------\n\n function toLowerCase(string memory str)\n internal pure\n returns (string memory)\n {\n bytes memory lowered = new bytes(bytes(str).length);\n unchecked {\n for (uint i = 0; i < lowered.length; i ++) {\n uint8 char = uint8(bytes(str)[i]);\n if (char >= 65 && char <= 90) {\n lowered[i] = bytes1(char + 32);\n } else {\n lowered[i] = bytes1(char);\n }\n }\n }\n return string(lowered);\n }\n\n /// @notice Converts bytes32 into string.\n function toString(bytes32 _bytes32)\n internal pure\n returns (string memory)\n {\n bytes memory _bytes = new bytes(_toStringLength(_bytes32));\n for (uint _i = 0; _i < _bytes.length;) {\n _bytes[_i] = _bytes32[_i];\n unchecked {\n _i ++;\n }\n }\n return string(_bytes);\n }\n\n function tryUint(string memory str)\n internal pure\n returns (uint res, bool)\n {\n unchecked {\n for (uint256 i = 0; i < bytes(str).length; i++) {\n if (\n (uint8(bytes(str)[i]) - 48) < 0\n || (uint8(bytes(str)[i]) - 48) > 9\n ) {\n return (0, false);\n }\n res += (uint8(bytes(str)[i]) - 48) * 10 ** (bytes(str).length - i - 1);\n }\n return (res, true);\n }\n }\n \n\n /// ===============================================================================================================\n /// --- 'Witnet.Result' helper methods ----------------------------------------------------------------------------\n\n modifier _isReady(Result memory result) {\n require(result.success, \"Witnet: tried to decode value from errored result.\");\n _;\n }\n\n /// @dev Decode an address from the Witnet.Result's CBOR value.\n function asAddress(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns (address)\n {\n if (result.value.majorType == uint8(WitnetCBOR.MAJOR_TYPE_BYTES)) {\n return toAddress(result.value.readBytes());\n } else {\n // TODO\n revert(\"WitnetLib: reading address from string not yet supported.\");\n }\n }\n\n /// @dev Decode a `bool` value from the Witnet.Result's CBOR value.\n function asBool(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns (bool)\n {\n return result.value.readBool();\n }\n\n /// @dev Decode a `bytes` value from the Witnet.Result's CBOR value.\n function asBytes(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns(bytes memory)\n {\n return result.value.readBytes();\n }\n\n /// @dev Decode a `bytes4` value from the Witnet.Result's CBOR value.\n function asBytes4(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns (bytes4)\n {\n return toBytes4(asBytes(result));\n }\n\n /// @dev Decode a `bytes32` value from the Witnet.Result's CBOR value.\n function asBytes32(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns (bytes32)\n {\n return toBytes32(asBytes(result));\n }\n\n /// @notice Returns the Witnet.Result's unread CBOR value.\n function asCborValue(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns (WitnetCBOR.CBOR memory)\n {\n return result.value;\n }\n\n /// @notice Decode array of CBOR values from the Witnet.Result's CBOR value. \n function asCborArray(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns (WitnetCBOR.CBOR[] memory)\n {\n return result.value.readArray();\n }\n\n /// @dev Decode a fixed16 (half-precision) numeric value from the Witnet.Result's CBOR value.\n /// @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values.\n /// by 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `fixed16`.\n /// use cases. In other words, the output of this method is 10,000 times the actual value, encoded into an `int32`.\n function asFixed16(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns (int32)\n {\n return result.value.readFloat16();\n }\n\n /// @dev Decode an array of fixed16 values from the Witnet.Result's CBOR value.\n function asFixed16Array(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns (int32[] memory)\n {\n return result.value.readFloat16Array();\n }\n\n /// @dev Decode an `int64` value from the Witnet.Result's CBOR value.\n function asInt(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns (int)\n {\n return result.value.readInt();\n }\n\n /// @dev Decode an array of integer numeric values from a Witnet.Result as an `int[]` array.\n /// @param result An instance of Witnet.Result.\n /// @return The `int[]` decoded from the Witnet.Result.\n function asIntArray(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns (int[] memory)\n {\n return result.value.readIntArray();\n }\n\n /// @dev Decode a `string` value from the Witnet.Result's CBOR value.\n /// @param result An instance of Witnet.Result.\n /// @return The `string` decoded from the Witnet.Result.\n function asText(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns(string memory)\n {\n return result.value.readString();\n }\n\n /// @dev Decode an array of strings from the Witnet.Result's CBOR value.\n /// @param result An instance of Witnet.Result.\n /// @return The `string[]` decoded from the Witnet.Result.\n function asTextArray(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns (string[] memory)\n {\n return result.value.readStringArray();\n }\n\n /// @dev Decode a `uint64` value from the Witnet.Result's CBOR value.\n /// @param result An instance of Witnet.Result.\n /// @return The `uint` decoded from the Witnet.Result.\n function asUint(Witnet.Result memory result)\n internal pure\n _isReady(result)\n returns (uint)\n {\n return result.value.readUint();\n }\n\n /// @dev Decode an array of `uint64` values from the Witnet.Result's CBOR value.\n /// @param result An instance of Witnet.Result.\n /// @return The `uint[]` decoded from the Witnet.Result.\n function asUintArray(Witnet.Result memory result)\n internal pure\n returns (uint[] memory)\n {\n return result.value.readUintArray();\n }\n\n\n /// ===============================================================================================================\n /// --- Witnet library private methods ----------------------------------------------------------------------------\n\n /// @dev Decode a CBOR value into a Witnet.Result instance.\n function _resultFromCborValue(WitnetCBOR.CBOR memory cbor)\n private pure\n returns (Witnet.Result memory) \n {\n // Witnet uses CBOR tag 39 to represent RADON error code identifiers.\n // [CBOR tag 39] Identifiers for CBOR: https://github.com/lucas-clemente/cbor-specs/blob/master/id.md\n bool success = cbor.tag != 39;\n return Witnet.Result(success, cbor);\n }\n\n /// @dev Calculate length of string-equivalent to given bytes32.\n function _toStringLength(bytes32 _bytes32)\n private pure\n returns (uint _length)\n {\n for (; _length < 32; ) {\n if (_bytes32[_length] == 0) {\n break;\n }\n unchecked {\n _length ++;\n }\n }\n }\n}",
13
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/libs/Witnet.sol",
13
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/libs/Witnet.sol",
14
14
  "ast": {
15
15
  "absolutePath": "project:/contracts/libs/Witnet.sol",
16
16
  "exportedSymbols": {
@@ -18070,7 +18070,7 @@
18070
18070
  },
18071
18071
  "networks": {},
18072
18072
  "schemaVersion": "3.4.16",
18073
- "updatedAt": "2025-10-15T17:39:32.830Z",
18073
+ "updatedAt": "2025-10-15T18:03:23.802Z",
18074
18074
  "devdoc": {
18075
18075
  "kind": "dev",
18076
18076
  "methods": {},
@@ -48,7 +48,7 @@
48
48
  "sourceMap": "634:22381:65:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;634:22381:65;;;;;;;;;;;;;;;;;",
49
49
  "deployedSourceMap": "634:22381:65:-:0;;;;;;;;",
50
50
  "source": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0 <0.9.0;\n\n/// @title A convenient wrapper around the `bytes memory` type that exposes a buffer-like interface\n/// @notice The buffer has an inner cursor that tracks the final offset of every read, i.e. any subsequent read will\n/// start with the byte that goes right after the last one in the previous read.\n/// @dev `uint32` is used here for `cursor` because `uint16` would only enable seeking up to 8KB, which could in some\n/// theoretical use cases be exceeded. Conversely, `uint32` supports up to 512MB, which cannot credibly be exceeded.\n/// @author The Witnet Foundation.\nlibrary WitnetBuffer {\n\n error EmptyBuffer();\n error IndexOutOfBounds(uint index, uint range);\n error MissingArgs(uint expected, uint given);\n\n /// Iterable bytes buffer.\n struct Buffer {\n bytes data;\n uint cursor;\n }\n\n // Ensures we access an existing index in an array\n modifier withinRange(uint index, uint _range) {\n if (index > _range) {\n revert IndexOutOfBounds(index, _range);\n }\n _;\n }\n\n /// @notice Concatenate undefinite number of bytes chunks.\n /// @dev Faster than looping on `abi.encodePacked(output, _buffs[ix])`.\n function concat(bytes[] memory _buffs)\n internal pure\n returns (bytes memory output)\n {\n unchecked {\n uint destinationPointer;\n uint destinationLength;\n assembly {\n // get safe scratch location\n output := mload(0x40)\n // set starting destination pointer\n destinationPointer := add(output, 32)\n } \n for (uint ix = 1; ix <= _buffs.length; ix ++) { \n uint source;\n uint sourceLength;\n uint sourcePointer; \n assembly {\n // load source length pointer\n source := mload(add(_buffs, mul(ix, 32)))\n // load source length\n sourceLength := mload(source)\n // sets source memory pointer\n sourcePointer := add(source, 32)\n }\n memcpy(\n destinationPointer,\n sourcePointer,\n sourceLength\n );\n assembly { \n // increase total destination length\n destinationLength := add(destinationLength, sourceLength)\n // sets destination memory pointer\n destinationPointer := add(destinationPointer, sourceLength)\n }\n }\n assembly {\n // protect output bytes\n mstore(output, destinationLength)\n // set final output length\n mstore(0x40, add(mload(0x40), add(destinationLength, 32)))\n }\n }\n }\n\n function fork(WitnetBuffer.Buffer memory buffer)\n internal pure\n returns (WitnetBuffer.Buffer memory)\n {\n return Buffer(\n buffer.data,\n buffer.cursor\n );\n }\n\n function mutate(\n WitnetBuffer.Buffer memory buffer,\n uint length,\n bytes memory pokes\n )\n internal pure\n withinRange(length, buffer.data.length - buffer.cursor + 1)\n {\n bytes[] memory parts = new bytes[](3);\n parts[0] = peek(\n buffer,\n 0,\n buffer.cursor\n );\n parts[1] = pokes;\n parts[2] = peek(\n buffer,\n buffer.cursor + length,\n buffer.data.length - buffer.cursor - length\n );\n buffer.data = concat(parts);\n }\n\n /// @notice Read and consume the next byte from the buffer.\n /// @param buffer An instance of `Buffer`.\n /// @return The next byte in the buffer counting from the cursor position.\n function next(Buffer memory buffer)\n internal pure\n withinRange(buffer.cursor, buffer.data.length)\n returns (bytes1)\n {\n // Return the byte at the position marked by the cursor and advance the cursor all at once\n return buffer.data[buffer.cursor ++];\n }\n\n function peek(\n WitnetBuffer.Buffer memory buffer,\n uint offset,\n uint length\n )\n internal pure\n withinRange(offset + length, buffer.data.length)\n returns (bytes memory)\n {\n bytes memory data = buffer.data;\n bytes memory peeks = new bytes(length);\n uint destinationPointer;\n uint sourcePointer;\n assembly {\n destinationPointer := add(peeks, 32)\n sourcePointer := add(add(data, 32), offset)\n }\n memcpy(\n destinationPointer,\n sourcePointer,\n length\n );\n return peeks;\n }\n\n // @notice Extract bytes array from buffer starting from current cursor.\n /// @param buffer An instance of `Buffer`.\n /// @param length How many bytes to peek from the Buffer.\n // solium-disable-next-line security/no-assign-params\n function peek(\n WitnetBuffer.Buffer memory buffer,\n uint length\n )\n internal pure\n withinRange(length, buffer.data.length - buffer.cursor)\n returns (bytes memory)\n {\n return peek(\n buffer,\n buffer.cursor,\n length\n );\n }\n\n /// @notice Read and consume a certain amount of bytes from the buffer.\n /// @param buffer An instance of `Buffer`.\n /// @param length How many bytes to read and consume from the buffer.\n /// @return output A `bytes memory` containing the first `length` bytes from the buffer, counting from the cursor position.\n function read(Buffer memory buffer, uint length)\n internal pure\n withinRange(buffer.cursor + length, buffer.data.length)\n returns (bytes memory output)\n {\n // Create a new `bytes memory destination` value\n output = new bytes(length);\n // Early return in case that bytes length is 0\n if (length > 0) {\n bytes memory input = buffer.data;\n uint offset = buffer.cursor;\n // Get raw pointers for source and destination\n uint sourcePointer;\n uint destinationPointer;\n assembly {\n sourcePointer := add(add(input, 32), offset)\n destinationPointer := add(output, 32)\n }\n // Copy `length` bytes from source to destination\n memcpy(\n destinationPointer,\n sourcePointer,\n length\n );\n // Move the cursor forward by `length` bytes\n seek(\n buffer,\n length,\n true\n );\n }\n }\n \n /// @notice Read and consume the next 2 bytes from the buffer as an IEEE 754-2008 floating point number enclosed in an\n /// `int32`.\n /// @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values\n /// by 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `float16`\n /// use cases. In other words, the integer output of this method is 10,000 times the actual value. The input bytes are\n /// expected to follow the 16-bit base-2 format (a.k.a. `binary16`) in the IEEE 754-2008 standard.\n /// @param buffer An instance of `Buffer`.\n /// @return result The `int32` value of the next 4 bytes in the buffer counting from the cursor position.\n function readFloat16(Buffer memory buffer)\n internal pure\n returns (int32 result)\n {\n uint32 value = readUint16(buffer);\n // Get bit at position 0\n uint32 sign = value & 0x8000;\n // Get bits 1 to 5, then normalize to the [-15, 16] range so as to counterweight the IEEE 754 exponent bias\n int32 exponent = (int32(value & 0x7c00) >> 10) - 15;\n // Get bits 6 to 15\n int32 fraction = int32(value & 0x03ff);\n // Add 2^10 to the fraction if exponent is not -15\n if (exponent != -15) {\n fraction |= 0x400;\n } else if (exponent == 16) {\n revert(\n string(abi.encodePacked(\n \"WitnetBuffer.readFloat16: \",\n sign != 0 ? \"negative\" : hex\"\",\n \" infinity\"\n ))\n );\n }\n // Compute `2 ^ exponent · (1 + fraction / 1024)`\n if (exponent >= 0) {\n result = int32(int(\n int(1 << uint256(int256(exponent)))\n * 10000\n * fraction\n ) >> 10);\n } else {\n result = int32(int(\n int(fraction)\n * 10000\n / int(1 << uint(int(- exponent)))\n ) >> 10);\n }\n // Make the result negative if the sign bit is not 0\n if (sign != 0) {\n result *= -1;\n }\n }\n\n /// @notice Consume the next 4 bytes from the buffer as an IEEE 754-2008 floating point number enclosed into an `int`.\n /// @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values\n /// by 9 decimal orders so as to get a fixed precision of 9 decimal positions, which should be OK for most `float32`\n /// use cases. In other words, the integer output of this method is 10^9 times the actual value. The input bytes are\n /// expected to follow the 64-bit base-2 format (a.k.a. `binary32`) in the IEEE 754-2008 standard.\n /// @param buffer An instance of `Buffer`.\n /// @return result The `int` value of the next 8 bytes in the buffer counting from the cursor position.\n function readFloat32(Buffer memory buffer)\n internal pure\n returns (int result)\n {\n uint value = readUint32(buffer);\n // Get bit at position 0\n uint sign = value & 0x80000000;\n // Get bits 1 to 8, then normalize to the [-127, 128] range so as to counterweight the IEEE 754 exponent bias\n int exponent = (int(value & 0x7f800000) >> 23) - 127;\n // Get bits 9 to 31\n int fraction = int(value & 0x007fffff);\n // Add 2^23 to the fraction if exponent is not -127\n if (exponent != -127) {\n fraction |= 0x800000;\n } else if (exponent == 128) {\n revert(\n string(abi.encodePacked(\n \"WitnetBuffer.readFloat32: \",\n sign != 0 ? \"negative\" : hex\"\",\n \" infinity\"\n ))\n );\n }\n // Compute `2 ^ exponent · (1 + fraction / 2^23)`\n if (exponent >= 0) {\n result = (\n int(1 << uint(exponent))\n * (10 ** 9)\n * fraction\n ) >> 23;\n } else {\n result = (\n fraction \n * (10 ** 9)\n / int(1 << uint(-exponent)) \n ) >> 23;\n }\n // Make the result negative if the sign bit is not 0\n if (sign != 0) {\n result *= -1;\n }\n }\n\n /// @notice Consume the next 8 bytes from the buffer as an IEEE 754-2008 floating point number enclosed into an `int`.\n /// @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values\n /// by 15 decimal orders so as to get a fixed precision of 15 decimal positions, which should be OK for most `float64`\n /// use cases. In other words, the integer output of this method is 10^15 times the actual value. The input bytes are\n /// expected to follow the 64-bit base-2 format (a.k.a. `binary64`) in the IEEE 754-2008 standard.\n /// @param buffer An instance of `Buffer`.\n /// @return result The `int` value of the next 8 bytes in the buffer counting from the cursor position.\n function readFloat64(Buffer memory buffer)\n internal pure\n returns (int result)\n {\n uint value = readUint64(buffer);\n // Get bit at position 0\n uint sign = value & 0x8000000000000000;\n // Get bits 1 to 12, then normalize to the [-1023, 1024] range so as to counterweight the IEEE 754 exponent bias\n int exponent = (int(value & 0x7ff0000000000000) >> 52) - 1023;\n // Get bits 6 to 15\n int fraction = int(value & 0x000fffffffffffff);\n // Add 2^52 to the fraction if exponent is not -1023\n if (exponent != -1023) {\n fraction |= 0x10000000000000;\n } else if (exponent == 1024) {\n revert(\n string(abi.encodePacked(\n \"WitnetBuffer.readFloat64: \",\n sign != 0 ? \"negative\" : hex\"\",\n \" infinity\"\n ))\n );\n }\n // Compute `2 ^ exponent · (1 + fraction / 1024)`\n if (exponent >= 0) {\n result = (\n int(1 << uint(exponent))\n * (10 ** 15)\n * fraction\n ) >> 52;\n } else {\n result = (\n fraction \n * (10 ** 15)\n / int(1 << uint(-exponent)) \n ) >> 52;\n }\n // Make the result negative if the sign bit is not 0\n if (sign != 0) {\n result *= -1;\n }\n }\n\n // Read a text string of a given length from a buffer. Returns a `bytes memory` value for the sake of genericness,\n /// but it can be easily casted into a string with `string(result)`.\n // solium-disable-next-line security/no-assign-params\n function readText(\n WitnetBuffer.Buffer memory buffer,\n uint64 length\n )\n internal pure\n returns (bytes memory text)\n {\n text = new bytes(length);\n unchecked {\n for (uint64 index = 0; index < length; index ++) {\n uint8 char = readUint8(buffer);\n if (char & 0x80 != 0) {\n if (char < 0xe0) {\n char = (char & 0x1f) << 6\n | (readUint8(buffer) & 0x3f);\n length -= 1;\n } else if (char < 0xf0) {\n char = (char & 0x0f) << 12\n | (readUint8(buffer) & 0x3f) << 6\n | (readUint8(buffer) & 0x3f);\n length -= 2;\n } else {\n char = (char & 0x0f) << 18\n | (readUint8(buffer) & 0x3f) << 12\n | (readUint8(buffer) & 0x3f) << 6 \n | (readUint8(buffer) & 0x3f);\n length -= 3;\n }\n }\n text[index] = bytes1(char);\n }\n // Adjust text to actual length:\n assembly {\n mstore(text, length)\n }\n }\n }\n\n /// @notice Read and consume the next byte from the buffer as an `uint8`.\n /// @param buffer An instance of `Buffer`.\n /// @return value The `uint8` value of the next byte in the buffer counting from the cursor position.\n function readUint8(Buffer memory buffer)\n internal pure\n withinRange(buffer.cursor, buffer.data.length)\n returns (uint8 value)\n {\n bytes memory data = buffer.data;\n uint offset = buffer.cursor;\n assembly {\n value := mload(add(add(data, 1), offset))\n }\n buffer.cursor ++;\n }\n\n /// @notice Read and consume the next 2 bytes from the buffer as an `uint16`.\n /// @param buffer An instance of `Buffer`.\n /// @return value The `uint16` value of the next 2 bytes in the buffer counting from the cursor position.\n function readUint16(Buffer memory buffer)\n internal pure\n withinRange(buffer.cursor + 2, buffer.data.length)\n returns (uint16 value)\n {\n bytes memory data = buffer.data;\n uint offset = buffer.cursor;\n assembly {\n value := mload(add(add(data, 2), offset))\n }\n buffer.cursor += 2;\n }\n\n /// @notice Read and consume the next 4 bytes from the buffer as an `uint32`.\n /// @param buffer An instance of `Buffer`.\n /// @return value The `uint32` value of the next 4 bytes in the buffer counting from the cursor position.\n function readUint32(Buffer memory buffer)\n internal pure\n withinRange(buffer.cursor + 4, buffer.data.length)\n returns (uint32 value)\n {\n bytes memory data = buffer.data;\n uint offset = buffer.cursor;\n assembly {\n value := mload(add(add(data, 4), offset))\n }\n buffer.cursor += 4;\n }\n\n /// @notice Read and consume the next 8 bytes from the buffer as an `uint64`.\n /// @param buffer An instance of `Buffer`.\n /// @return value The `uint64` value of the next 8 bytes in the buffer counting from the cursor position.\n function readUint64(Buffer memory buffer)\n internal pure\n withinRange(buffer.cursor + 8, buffer.data.length)\n returns (uint64 value)\n {\n bytes memory data = buffer.data;\n uint offset = buffer.cursor;\n assembly {\n value := mload(add(add(data, 8), offset))\n }\n buffer.cursor += 8;\n }\n\n /// @notice Read and consume the next 16 bytes from the buffer as an `uint128`.\n /// @param buffer An instance of `Buffer`.\n /// @return value The `uint128` value of the next 16 bytes in the buffer counting from the cursor position.\n function readUint128(Buffer memory buffer)\n internal pure\n withinRange(buffer.cursor + 16, buffer.data.length)\n returns (uint128 value)\n {\n bytes memory data = buffer.data;\n uint offset = buffer.cursor;\n assembly {\n value := mload(add(add(data, 16), offset))\n }\n buffer.cursor += 16;\n }\n\n /// @notice Read and consume the next 32 bytes from the buffer as an `uint256`.\n /// @param buffer An instance of `Buffer`.\n /// @return value The `uint256` value of the next 32 bytes in the buffer counting from the cursor position.\n function readUint256(Buffer memory buffer)\n internal pure\n withinRange(buffer.cursor + 32, buffer.data.length)\n returns (uint256 value)\n {\n bytes memory data = buffer.data;\n uint offset = buffer.cursor;\n assembly {\n value := mload(add(add(data, 32), offset))\n }\n buffer.cursor += 32;\n }\n\n /// @notice Count number of required parameters for given bytes arrays\n /// @dev Wildcard format: \"\\#\\\", with # in [\"0\"..\"9\"].\n /// @param input Bytes array containing strings.\n /// @param count Highest wildcard index found, plus 1.\n function argsCountOf(bytes memory input)\n internal pure\n returns (uint8 count)\n {\n if (input.length < 3) {\n return 0;\n }\n unchecked {\n uint ix = 0; \n uint length = input.length - 2;\n for (; ix < length; ) {\n if (\n input[ix] == bytes1(\"\\\\\")\n && input[ix + 2] == bytes1(\"\\\\\")\n && input[ix + 1] >= bytes1(\"0\")\n && input[ix + 1] <= bytes1(\"9\")\n ) {\n uint8 ax = uint8(uint8(input[ix + 1]) - uint8(bytes1(\"0\")) + 1);\n if (ax > count) {\n count = ax;\n }\n ix += 3;\n } else {\n ix ++;\n }\n }\n }\n }\n\n /// @notice Replace bytecode indexed wildcards by correspondent substrings.\n /// @dev Wildcard format: \"\\#\\\", with # in [\"0\"..\"9\"].\n /// @param input Bytes array containing strings.\n /// @param args Array of substring values for replacing indexed wildcards.\n /// @return output Resulting bytes array after replacing all wildcards.\n /// @return hits Total number of replaced wildcards.\n function replace(bytes memory input, string[] memory args)\n internal pure\n returns (bytes memory output, uint hits)\n {\n uint ix = 0; uint lix = 0;\n uint inputLength;\n uint inputPointer;\n uint outputLength;\n uint outputPointer; \n uint source;\n uint sourceLength;\n uint sourcePointer;\n\n if (input.length < 3) {\n return (input, 0);\n }\n \n assembly {\n // set starting input pointer\n inputPointer := add(input, 32)\n // get safe output location\n output := mload(0x40)\n // set starting output pointer\n outputPointer := add(output, 32)\n } \n\n unchecked {\n uint length = input.length - 2;\n for (; ix < length; ) {\n if (\n input[ix] == bytes1(\"\\\\\")\n && input[ix + 2] == bytes1(\"\\\\\")\n && input[ix + 1] >= bytes1(\"0\")\n && input[ix + 1] <= bytes1(\"9\")\n ) {\n inputLength = (ix - lix);\n if (ix > lix) {\n memcpy(\n outputPointer,\n inputPointer,\n inputLength\n );\n inputPointer += inputLength + 3;\n outputPointer += inputLength;\n } else {\n inputPointer += 3;\n }\n uint ax = uint(uint8(input[ix + 1]) - uint8(bytes1(\"0\")));\n if (ax >= args.length) {\n revert MissingArgs(ax + 1, args.length);\n }\n assembly {\n source := mload(add(args, mul(32, add(ax, 1))))\n sourceLength := mload(source)\n sourcePointer := add(source, 32) \n } \n memcpy(\n outputPointer,\n sourcePointer,\n sourceLength\n );\n outputLength += inputLength + sourceLength;\n outputPointer += sourceLength;\n ix += 3;\n lix = ix;\n hits ++;\n } else {\n ix ++;\n }\n }\n ix = input.length; \n }\n if (outputLength > 0) {\n if (ix > lix ) {\n memcpy(\n outputPointer,\n inputPointer,\n ix - lix\n );\n outputLength += (ix - lix);\n }\n assembly {\n // set final output length\n mstore(output, outputLength)\n // protect output bytes\n mstore(0x40, add(mload(0x40), add(outputLength, 32)))\n }\n }\n else {\n return (input, 0);\n }\n }\n\n /// @notice Replace string indexed wildcards by correspondent substrings.\n /// @dev Wildcard format: \"\\#\\\", with # in [\"0\"..\"9\"].\n /// @param input String potentially containing wildcards.\n /// @param args Array of substring values for replacing indexed wildcards.\n /// @return output Resulting string after replacing all wildcards.\n function replace(string memory input, string[] memory args)\n internal pure\n returns (string memory)\n {\n (bytes memory _outputBytes, ) = replace(bytes(input), args);\n return string(_outputBytes);\n }\n\n /// @notice Move the inner cursor of the buffer to a relative or absolute position.\n /// @param buffer An instance of `Buffer`.\n /// @param offset How many bytes to move the cursor forward.\n /// @param relative Whether to count `offset` from the last position of the cursor (`true`) or the beginning of the\n /// buffer (`true`).\n /// @return The final position of the cursor (will equal `offset` if `relative` is `false`).\n // solium-disable-next-line security/no-assign-params\n function seek(\n Buffer memory buffer,\n uint offset,\n bool relative\n )\n internal pure\n withinRange(offset, buffer.data.length)\n returns (uint)\n {\n // Deal with relative offsets\n if (relative) {\n offset += buffer.cursor;\n }\n buffer.cursor = offset;\n return offset;\n }\n\n /// @notice Move the inner cursor a number of bytes forward.\n /// @dev This is a simple wrapper around the relative offset case of `seek()`.\n /// @param buffer An instance of `Buffer`.\n /// @param relativeOffset How many bytes to move the cursor forward.\n /// @return The final position of the cursor.\n function seek(\n Buffer memory buffer,\n uint relativeOffset\n )\n internal pure\n returns (uint)\n {\n return seek(\n buffer,\n relativeOffset,\n true\n );\n }\n\n /// @notice Copy bytes from one memory address into another.\n /// @dev This function was borrowed from Nick Johnson's `solidity-stringutils` lib, and reproduced here under the terms\n /// of [Apache License 2.0](https://github.com/Arachnid/solidity-stringutils/blob/master/LICENSE).\n /// @param dest Address of the destination memory.\n /// @param src Address to the source memory.\n /// @param len How many bytes to copy.\n // solium-disable-next-line security/no-assign-params\n function memcpy(\n uint dest,\n uint src,\n uint len\n )\n private pure\n {\n unchecked {\n // Copy word-length chunks while possible\n for (; len >= 32; len -= 32) {\n assembly {\n mstore(dest, mload(src))\n }\n dest += 32;\n src += 32;\n }\n if (len > 0) {\n // Copy remaining bytes\n uint _mask = 256 ** (32 - len) - 1;\n assembly {\n let srcpart := and(mload(src), not(_mask))\n let destpart := and(mload(dest), _mask)\n mstore(dest, or(destpart, srcpart))\n }\n }\n }\n }\n\n}",
51
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/libs/WitnetBuffer.sol",
51
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/libs/WitnetBuffer.sol",
52
52
  "ast": {
53
53
  "absolutePath": "project:/contracts/libs/WitnetBuffer.sol",
54
54
  "exportedSymbols": {
@@ -23588,7 +23588,7 @@
23588
23588
  },
23589
23589
  "networks": {},
23590
23590
  "schemaVersion": "3.4.16",
23591
- "updatedAt": "2025-10-15T17:39:32.894Z",
23591
+ "updatedAt": "2025-10-15T18:03:23.811Z",
23592
23592
  "devdoc": {
23593
23593
  "author": "The Witnet Foundation.",
23594
23594
  "details": "`uint32` is used here for `cursor` because `uint16` would only enable seeking up to 8KB, which could in some theoretical use cases be exceeded. Conversely, `uint32` supports up to 512MB, which cannot credibly be exceeded.",
@@ -65,7 +65,7 @@
65
65
  "sourceMap": "524:18438:66:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;524:18438:66;;;;;;;;;;;;;;;;;",
66
66
  "deployedSourceMap": "524:18438:66:-:0;;;;;;;;",
67
67
  "source": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"./WitnetBuffer.sol\";\n\n/// @title A minimalistic implementation of “RFC 7049 Concise Binary Object Representation”\n/// @notice This library leverages a buffer-like structure for step-by-step decoding of bytes so as to minimize\n/// the gas cost of decoding them into a useful native type.\n/// @dev Most of the logic has been borrowed from Patrick Gansterer’s cbor.js library: https://github.com/paroga/cbor-js\n/// @author The Witnet Foundation.\n\nlibrary WitnetCBOR {\n\n using WitnetBuffer for WitnetBuffer.Buffer;\n using WitnetCBOR for WitnetCBOR.CBOR;\n\n /// Data struct following the RFC-7049 standard: Concise Binary Object Representation.\n struct CBOR {\n WitnetBuffer.Buffer buffer;\n uint8 initialByte;\n uint8 majorType;\n uint8 additionalInformation;\n uint64 len;\n uint64 tag;\n }\n\n uint8 internal constant MAJOR_TYPE_INT = 0;\n uint8 internal constant MAJOR_TYPE_NEGATIVE_INT = 1;\n uint8 internal constant MAJOR_TYPE_BYTES = 2;\n uint8 internal constant MAJOR_TYPE_STRING = 3;\n uint8 internal constant MAJOR_TYPE_ARRAY = 4;\n uint8 internal constant MAJOR_TYPE_MAP = 5;\n uint8 internal constant MAJOR_TYPE_TAG = 6;\n uint8 internal constant MAJOR_TYPE_CONTENT_FREE = 7;\n\n uint32 internal constant UINT32_MAX = type(uint32).max;\n uint64 internal constant UINT64_MAX = type(uint64).max;\n \n error EmptyArray();\n error InvalidLengthEncoding(uint length);\n error UnexpectedMajorType(uint read, uint expected);\n error UnsupportedPrimitive(uint primitive);\n error UnsupportedMajorType(uint unexpected); \n\n modifier isMajorType(\n WitnetCBOR.CBOR memory cbor,\n uint8 expected\n ) {\n if (cbor.majorType != expected) {\n revert UnexpectedMajorType(cbor.majorType, expected);\n }\n _;\n }\n\n modifier notEmpty(WitnetBuffer.Buffer memory buffer) {\n if (buffer.data.length == 0) {\n revert WitnetBuffer.EmptyBuffer();\n }\n _;\n }\n\n function eof(CBOR memory cbor)\n internal pure\n returns (bool)\n {\n return cbor.buffer.cursor >= cbor.buffer.data.length;\n }\n\n /// @notice Decode a CBOR structure from raw bytes.\n /// @dev This is the main factory for CBOR instances, which can be later decoded into native EVM types.\n /// @param bytecode Raw bytes representing a CBOR-encoded value.\n /// @return A `CBOR` instance containing a partially decoded value.\n function fromBytes(bytes memory bytecode)\n internal pure\n returns (CBOR memory)\n {\n WitnetBuffer.Buffer memory buffer = WitnetBuffer.Buffer(bytecode, 0);\n return fromBuffer(buffer);\n }\n\n /// @notice Decode a CBOR structure from raw bytes.\n /// @dev This is an alternate factory for CBOR instances, which can be later decoded into native EVM types.\n /// @param buffer A Buffer structure representing a CBOR-encoded value.\n /// @return A `CBOR` instance containing a partially decoded value.\n function fromBuffer(WitnetBuffer.Buffer memory buffer)\n internal pure\n notEmpty(buffer)\n returns (CBOR memory)\n {\n uint8 initialByte;\n uint8 majorType = 255;\n uint8 additionalInformation;\n uint64 tag = UINT64_MAX;\n uint256 len;\n bool isTagged = true;\n while (isTagged) {\n // Extract basic CBOR properties from input bytes\n initialByte = buffer.readUint8();\n len ++;\n majorType = initialByte >> 5;\n additionalInformation = initialByte & 0x1f;\n // Early CBOR tag parsing.\n if (majorType == MAJOR_TYPE_TAG) {\n uint _cursor = buffer.cursor;\n tag = readLength(buffer, additionalInformation);\n len += buffer.cursor - _cursor;\n } else {\n isTagged = false;\n }\n }\n if (majorType > MAJOR_TYPE_CONTENT_FREE) {\n revert UnsupportedMajorType(majorType);\n }\n return CBOR(\n buffer,\n initialByte,\n majorType,\n additionalInformation,\n uint64(len),\n tag\n );\n }\n\n function fork(WitnetCBOR.CBOR memory self)\n internal pure\n returns (WitnetCBOR.CBOR memory)\n {\n return CBOR({\n buffer: self.buffer.fork(),\n initialByte: self.initialByte,\n majorType: self.majorType,\n additionalInformation: self.additionalInformation,\n len: self.len,\n tag: self.tag\n });\n }\n\n function settle(CBOR memory self)\n internal pure\n returns (WitnetCBOR.CBOR memory)\n {\n if (!self.eof()) {\n return fromBuffer(self.buffer);\n } else {\n return self;\n }\n }\n\n function skip(CBOR memory self)\n internal pure\n returns (WitnetCBOR.CBOR memory)\n {\n if (\n self.majorType == MAJOR_TYPE_INT\n || self.majorType == MAJOR_TYPE_NEGATIVE_INT\n || (\n self.majorType == MAJOR_TYPE_CONTENT_FREE \n && self.additionalInformation >= 25\n && self.additionalInformation <= 27\n )\n ) {\n self.buffer.cursor += self.peekLength();\n } else if (\n self.majorType == MAJOR_TYPE_STRING\n || self.majorType == MAJOR_TYPE_BYTES\n ) {\n uint64 len = readLength(self.buffer, self.additionalInformation);\n self.buffer.cursor += len;\n } else if (\n self.majorType == MAJOR_TYPE_ARRAY\n || self.majorType == MAJOR_TYPE_MAP\n ) { \n self.len = readLength(self.buffer, self.additionalInformation); \n } else if (\n self.majorType != MAJOR_TYPE_CONTENT_FREE\n || (\n self.additionalInformation != 20\n && self.additionalInformation != 21\n )\n ) {\n revert(\"WitnetCBOR.skip: unsupported major type\");\n }\n return self;\n }\n\n function peekLength(CBOR memory self)\n internal pure\n returns (uint64)\n {\n if (self.additionalInformation < 24) {\n return 0;\n } else if (self.additionalInformation < 28) {\n return uint64(1 << (self.additionalInformation - 24));\n } else {\n revert InvalidLengthEncoding(self.additionalInformation);\n }\n }\n\n function readArray(CBOR memory self)\n internal pure\n isMajorType(self, MAJOR_TYPE_ARRAY)\n returns (CBOR[] memory items)\n {\n // read array's length and move self cursor forward to the first array element:\n uint64 len = readLength(self.buffer, self.additionalInformation);\n items = new CBOR[](len + 1);\n for (uint ix = 0; ix < len; ix ++) {\n // settle next element in the array:\n self = self.settle();\n // fork it and added to the list of items to be returned:\n items[ix] = self.fork();\n if (self.majorType == MAJOR_TYPE_ARRAY) {\n CBOR[] memory _subitems = self.readArray();\n // move forward to the first element after inner array:\n self = _subitems[_subitems.length - 1];\n } else if (self.majorType == MAJOR_TYPE_MAP) {\n CBOR[] memory _subitems = self.readMap();\n // move forward to the first element after inner map:\n self = _subitems[_subitems.length - 1];\n } else {\n // move forward to the next element:\n self.skip();\n }\n }\n // return self cursor as extra item at the end of the list,\n // as to optimize recursion when jumping over nested arrays:\n items[len] = self;\n }\n\n function readMap(CBOR memory self)\n internal pure\n isMajorType(self, MAJOR_TYPE_MAP)\n returns (CBOR[] memory items)\n {\n // read number of items within the map and move self cursor forward to the first inner element:\n uint64 len = readLength(self.buffer, self.additionalInformation) * 2;\n items = new CBOR[](len + 1);\n for (uint ix = 0; ix < len; ix ++) {\n // settle next element in the array:\n self = self.settle();\n // fork it and added to the list of items to be returned:\n items[ix] = self.fork();\n if (ix % 2 == 0 && self.majorType != MAJOR_TYPE_STRING) {\n revert UnexpectedMajorType(self.majorType, MAJOR_TYPE_STRING);\n } else if (self.majorType == MAJOR_TYPE_ARRAY || self.majorType == MAJOR_TYPE_MAP) {\n CBOR[] memory _subitems = (self.majorType == MAJOR_TYPE_ARRAY\n ? self.readArray()\n : self.readMap()\n );\n // move forward to the first element after inner array or map:\n self = _subitems[_subitems.length - 1];\n } else {\n // move forward to the next element:\n self.skip();\n }\n }\n // return self cursor as extra item at the end of the list,\n // as to optimize recursion when jumping over nested arrays:\n items[len] = self;\n }\n\n /// Reads the length of the settle CBOR item from a buffer, consuming a different number of bytes depending on the\n /// value of the `additionalInformation` argument.\n function readLength(\n WitnetBuffer.Buffer memory buffer,\n uint8 additionalInformation\n ) \n internal pure\n returns (uint64)\n {\n if (additionalInformation < 24) {\n return additionalInformation;\n }\n if (additionalInformation == 24) {\n return buffer.readUint8();\n }\n if (additionalInformation == 25) {\n return buffer.readUint16();\n }\n if (additionalInformation == 26) {\n return buffer.readUint32();\n }\n if (additionalInformation == 27) {\n return buffer.readUint64();\n }\n if (additionalInformation == 31) {\n return UINT64_MAX;\n }\n revert InvalidLengthEncoding(additionalInformation);\n }\n\n /// @notice Read a `CBOR` structure into a native `bool` value.\n /// @param cbor An instance of `CBOR`.\n /// @return The value represented by the input, as a `bool` value.\n function readBool(CBOR memory cbor)\n internal pure\n isMajorType(cbor, MAJOR_TYPE_CONTENT_FREE)\n returns (bool)\n {\n if (cbor.additionalInformation == 20) {\n return false;\n } else if (cbor.additionalInformation == 21) {\n return true;\n } else {\n revert UnsupportedPrimitive(cbor.additionalInformation);\n }\n }\n\n /// @notice Decode a `CBOR` structure into a native `bytes` value.\n /// @param cbor An instance of `CBOR`.\n /// @return output The value represented by the input, as a `bytes` value. \n function readBytes(CBOR memory cbor)\n internal pure\n isMajorType(cbor, MAJOR_TYPE_BYTES)\n returns (bytes memory output)\n {\n cbor.len = readLength(\n cbor.buffer,\n cbor.additionalInformation\n );\n if (cbor.len == UINT32_MAX) {\n // These checks look repetitive but the equivalent loop would be more expensive.\n uint32 length = uint32(_readIndefiniteStringLength(\n cbor.buffer,\n cbor.majorType\n ));\n if (length < UINT32_MAX) {\n output = abi.encodePacked(cbor.buffer.read(length));\n length = uint32(_readIndefiniteStringLength(\n cbor.buffer,\n cbor.majorType\n ));\n if (length < UINT32_MAX) {\n output = abi.encodePacked(\n output,\n cbor.buffer.read(length)\n );\n }\n }\n } else {\n return cbor.buffer.read(uint32(cbor.len));\n }\n }\n\n /// @notice Decode a `CBOR` structure into a `fixed16` value.\n /// @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values\n /// by 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `fixed16`\n /// use cases. In other words, the output of this method is 10,000 times the actual value, encoded into an `int32`.\n /// @param cbor An instance of `CBOR`.\n /// @return The value represented by the input, as an `int128` value.\n function readFloat16(CBOR memory cbor)\n internal pure\n isMajorType(cbor, MAJOR_TYPE_CONTENT_FREE)\n returns (int32)\n {\n if (cbor.additionalInformation == 25) {\n return cbor.buffer.readFloat16();\n } else {\n revert UnsupportedPrimitive(cbor.additionalInformation);\n }\n }\n\n /// @notice Decode a `CBOR` structure into a `fixed32` value.\n /// @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values\n /// by 9 decimal orders so as to get a fixed precision of 9 decimal positions, which should be OK for most `fixed64`\n /// use cases. In other words, the output of this method is 10^9 times the actual value, encoded into an `int`.\n /// @param cbor An instance of `CBOR`.\n /// @return The value represented by the input, as an `int` value.\n function readFloat32(CBOR memory cbor)\n internal pure\n isMajorType(cbor, MAJOR_TYPE_CONTENT_FREE)\n returns (int)\n {\n if (cbor.additionalInformation == 26) {\n return cbor.buffer.readFloat32();\n } else {\n revert UnsupportedPrimitive(cbor.additionalInformation);\n }\n }\n\n /// @notice Decode a `CBOR` structure into a `fixed64` value.\n /// @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values\n /// by 15 decimal orders so as to get a fixed precision of 15 decimal positions, which should be OK for most `fixed64`\n /// use cases. In other words, the output of this method is 10^15 times the actual value, encoded into an `int`.\n /// @param cbor An instance of `CBOR`.\n /// @return The value represented by the input, as an `int` value.\n function readFloat64(CBOR memory cbor)\n internal pure\n isMajorType(cbor, MAJOR_TYPE_CONTENT_FREE)\n returns (int)\n {\n if (cbor.additionalInformation == 27) {\n return cbor.buffer.readFloat64();\n } else {\n revert UnsupportedPrimitive(cbor.additionalInformation);\n }\n }\n\n /// @notice Decode a `CBOR` structure into a native `int128[]` value whose inner values follow the same convention \n /// @notice as explained in `decodeFixed16`.\n /// @param cbor An instance of `CBOR`.\n function readFloat16Array(CBOR memory cbor)\n internal pure\n isMajorType(cbor, MAJOR_TYPE_ARRAY)\n returns (int32[] memory values)\n {\n uint64 length = readLength(cbor.buffer, cbor.additionalInformation);\n if (length < UINT64_MAX) {\n values = new int32[](length);\n for (uint64 i = 0; i < length; ) {\n CBOR memory item = fromBuffer(cbor.buffer);\n values[i] = readFloat16(item);\n unchecked {\n i ++;\n }\n }\n } else {\n revert InvalidLengthEncoding(length);\n }\n }\n\n /// @notice Decode a `CBOR` structure into a native `int128` value.\n /// @param cbor An instance of `CBOR`.\n /// @return The value represented by the input, as an `int128` value.\n function readInt(CBOR memory cbor)\n internal pure\n returns (int)\n {\n if (cbor.majorType == 1) {\n uint64 _value = readLength(\n cbor.buffer,\n cbor.additionalInformation\n );\n return int(-1) - int(uint(_value));\n } else if (cbor.majorType == 0) {\n // Any `uint64` can be safely casted to `int128`, so this method supports majorType 1 as well so as to have offer\n // a uniform API for positive and negative numbers\n return int(readUint(cbor));\n }\n else {\n revert UnexpectedMajorType(cbor.majorType, 1);\n }\n }\n\n /// @notice Decode a `CBOR` structure into a native `int[]` value.\n /// @param cbor instance of `CBOR`.\n /// @return array The value represented by the input, as an `int[]` value.\n function readIntArray(CBOR memory cbor)\n internal pure\n isMajorType(cbor, MAJOR_TYPE_ARRAY)\n returns (int[] memory array)\n {\n uint64 length = readLength(cbor.buffer, cbor.additionalInformation);\n if (length < UINT64_MAX) {\n array = new int[](length);\n for (uint i = 0; i < length; ) {\n CBOR memory item = fromBuffer(cbor.buffer);\n array[i] = readInt(item);\n unchecked {\n i ++;\n }\n }\n } else {\n revert InvalidLengthEncoding(length);\n }\n }\n\n /// @notice Decode a `CBOR` structure into a native `string` value.\n /// @param cbor An instance of `CBOR`.\n /// @return text The value represented by the input, as a `string` value.\n function readString(CBOR memory cbor)\n internal pure\n isMajorType(cbor, MAJOR_TYPE_STRING)\n returns (string memory text)\n {\n cbor.len = readLength(cbor.buffer, cbor.additionalInformation);\n if (cbor.len == UINT64_MAX) {\n bool _done;\n while (!_done) {\n uint64 length = _readIndefiniteStringLength(\n cbor.buffer,\n cbor.majorType\n );\n if (length < UINT64_MAX) {\n text = string(abi.encodePacked(\n text,\n cbor.buffer.readText(length / 4)\n ));\n } else {\n _done = true;\n }\n }\n } else {\n return string(cbor.buffer.readText(cbor.len));\n }\n }\n\n /// @notice Decode a `CBOR` structure into a native `string[]` value.\n /// @param cbor An instance of `CBOR`.\n /// @return strings The value represented by the input, as an `string[]` value.\n function readStringArray(CBOR memory cbor)\n internal pure\n isMajorType(cbor, MAJOR_TYPE_ARRAY)\n returns (string[] memory strings)\n {\n uint length = readLength(cbor.buffer, cbor.additionalInformation);\n if (length < UINT64_MAX) {\n strings = new string[](length);\n for (uint i = 0; i < length; ) {\n CBOR memory item = fromBuffer(cbor.buffer);\n strings[i] = readString(item);\n unchecked {\n i ++;\n }\n }\n } else {\n revert InvalidLengthEncoding(length);\n }\n }\n\n /// @notice Decode a `CBOR` structure into a native `uint64` value.\n /// @param cbor An instance of `CBOR`.\n /// @return The value represented by the input, as an `uint64` value.\n function readUint(CBOR memory cbor)\n internal pure\n isMajorType(cbor, MAJOR_TYPE_INT)\n returns (uint)\n {\n return readLength(\n cbor.buffer,\n cbor.additionalInformation\n );\n }\n\n /// @notice Decode a `CBOR` structure into a native `uint64[]` value.\n /// @param cbor An instance of `CBOR`.\n /// @return values The value represented by the input, as an `uint64[]` value.\n function readUintArray(CBOR memory cbor)\n internal pure\n isMajorType(cbor, MAJOR_TYPE_ARRAY)\n returns (uint[] memory values)\n {\n uint64 length = readLength(cbor.buffer, cbor.additionalInformation);\n if (length < UINT64_MAX) {\n values = new uint[](length);\n for (uint ix = 0; ix < length; ) {\n CBOR memory item = fromBuffer(cbor.buffer);\n values[ix] = readUint(item);\n unchecked {\n ix ++;\n }\n }\n } else {\n revert InvalidLengthEncoding(length);\n }\n } \n\n /// Read the length of a CBOR indifinite-length item (arrays, maps, byte strings and text) from a buffer, consuming\n /// as many bytes as specified by the first byte.\n function _readIndefiniteStringLength(\n WitnetBuffer.Buffer memory buffer,\n uint8 majorType\n )\n private pure\n returns (uint64 len)\n {\n uint8 initialByte = buffer.readUint8();\n if (initialByte == 0xff) {\n return UINT64_MAX;\n }\n len = readLength(\n buffer,\n initialByte & 0x1f\n );\n if (len >= UINT64_MAX) {\n revert InvalidLengthEncoding(len);\n } else if (majorType != (initialByte >> 5)) {\n revert UnexpectedMajorType((initialByte >> 5), majorType);\n }\n }\n \n}",
68
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/libs/WitnetCBOR.sol",
68
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/libs/WitnetCBOR.sol",
69
69
  "ast": {
70
70
  "absolutePath": "project:/contracts/libs/WitnetCBOR.sol",
71
71
  "exportedSymbols": {
@@ -19387,7 +19387,7 @@
19387
19387
  },
19388
19388
  "networks": {},
19389
19389
  "schemaVersion": "3.4.16",
19390
- "updatedAt": "2025-10-15T17:39:32.922Z",
19390
+ "updatedAt": "2025-10-15T18:03:23.822Z",
19391
19391
  "devdoc": {
19392
19392
  "author": "The Witnet Foundation.",
19393
19393
  "details": "Most of the logic has been borrowed from Patrick Gansterer’s cbor.js library: https://github.com/paroga/cbor-js",
@@ -339,7 +339,7 @@
339
339
  "sourceMap": "",
340
340
  "deployedSourceMap": "",
341
341
  "source": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./UsingWitnet.sol\";\nimport \"../interfaces/IWitnetConsumer.sol\";\n\nabstract contract WitnetConsumer\n is\n IWitnetConsumer,\n UsingWitnet\n{ \n /// @dev Maximum gas to be spent by the IWitnetConsumer's callback methods. \n uint24 internal immutable __witnetCallbackGasLimit;\n \n modifier onlyFromWitnet {\n require(msg.sender == address(__witnet), \"WitnetConsumer: unauthorized\");\n _;\n }\n\n /// @param _callbackGasLimit Maximum gas to be spent by the IWitnetConsumer's callback methods.\n constructor (uint24 _callbackGasLimit) {\n __witnetCallbackGasLimit = _callbackGasLimit;\n }\n\n \n /// ===============================================================================================================\n /// --- Base implementation of IWitnetConsumer --------------------------------------------------------------------\n\n function reportableFrom(address _from) virtual override external view returns (bool) {\n return _from == address(__witnet);\n }\n\n\n /// ===============================================================================================================\n /// --- WitnetConsumer virtual methods ----------------------------------------------------------------------------\n\n function _witnetEstimateEvmReward() virtual internal view returns (uint256) {\n return (\n (100 + __witnetBaseFeeOverheadPercentage)\n * __witnet.estimateBaseFeeWithCallback(\n tx.gasprice,\n __witnetCallbackGasLimit\n )\n ) / 100;\n }\n \n function _witnetEstimateEvmReward(uint16)\n virtual override internal view\n returns (uint256)\n {\n return _witnetEstimateEvmReward();\n }\n\n\n /// @notice Estimate the minimum reward required for posting a data request, using `tx.gasprice` as a reference.\n /// @dev Underestimates if the size of returned data is greater than `_resultMaxSize`. \n /// @param _callbackGasLimit Maximum gas to be spent when reporting the data request result.\n function _witnetEstimateEvmRewardWithCallback(uint24 _callbackGasLimit)\n virtual internal view\n returns (uint256)\n {\n return (\n (100 + __witnetBaseFeeOverheadPercentage)\n * __witnet.estimateBaseFeeWithCallback(\n tx.gasprice, \n _callbackGasLimit\n )\n ) / 100;\n }\n}\n",
342
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/apps/WitnetConsumer.sol",
342
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/apps/WitnetConsumer.sol",
343
343
  "ast": {
344
344
  "absolutePath": "project:/contracts/apps/WitnetConsumer.sol",
345
345
  "exportedSymbols": {
@@ -1795,7 +1795,7 @@
1795
1795
  },
1796
1796
  "networks": {},
1797
1797
  "schemaVersion": "3.4.16",
1798
- "updatedAt": "2025-10-15T17:39:32.442Z",
1798
+ "updatedAt": "2025-10-15T18:03:23.543Z",
1799
1799
  "devdoc": {
1800
1800
  "kind": "dev",
1801
1801
  "methods": {
@@ -5981,7 +5981,7 @@
5981
5981
  "sourceMap": "343:2814:26:-:0;;;;;;;;;;;;;;;;;;;",
5982
5982
  "deployedSourceMap": "343:2814:26:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2051:146;;;;;;:::i;:::-;;:::i;:::-;;;-1:-1:-1;;;;;363:32:84;;;345:51;;333:2;318:18;2051:146:26;;;;;;;879:431;;;;;;:::i;:::-;;:::i;2203:951::-;;;;;;:::i;:::-;;:::i;1650:395::-;;;;;;:::i;:::-;;:::i;2051:146::-;2132:7;2162:28;2184:5;2162:21;:28::i;:::-;2155:35;2051:146;-1:-1:-1;;2051:146:26:o;879:431::-;968:17;1013:31;1027:9;1038:5;1013:13;:31::i;:::-;1001:43;;1058:9;-1:-1:-1;;;;;1058:21:26;;1083:1;1058:26;1054:250;;1191:5;1179:9;1173:16;1166:4;1155:9;1151:20;1148:1;1140:57;1127:70;-1:-1:-1;;;;;;1232:23:26;;1224:69;;;;-1:-1:-1;;;1224:69:26;;2660:2:84;1224:69:26;;;2642:21:84;2699:2;2679:18;;;2672:30;2738:34;2718:18;;;2711:62;-1:-1:-1;;;2789:18:84;;;2782:31;2830:19;;1224:69:26;;;;;;;;2203:951;2329:11;2356:18;2377:30;2396:10;2377:18;:30::i;:::-;2356:51;;2421:10;-1:-1:-1;;;;;2421:22:26;;2447:1;2421:27;2417:731;;2502:58;2517:10;2529:30;;;;;;;;:::i;:::-;-1:-1:-1;;2529:30:26;;;;;;;;;;;;;;2502:14;:58::i;:::-;;2646:10;-1:-1:-1;;;;;2626:42:26;;2686:20;2873:10;2969:9;2773:223;;;;;;;;;:::i;:::-;;;;;;;;;;;;;2626:384;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;-1:-1:-1;3051:10:26;-1:-1:-1;3024:39:26;;2417:731;3094:43;;-1:-1:-1;;;3094:43:26;;4095:2:84;3094:43:26;;;4077:21:84;4134:2;4114:18;;;4107:30;4173:34;4153:18;;;4146:62;-1:-1:-1;;;4224:18:84;;;4217:31;4265:19;;3094:43:26;3893:397:84;2203:951:26;;;;;;:::o;1650:395::-;1974:20;;;;;;;1840:172;;;-1:-1:-1;;;;;;1840:172:26;;;4506:39:84;1920:4:26;4582:2:84;4578:15;-1:-1:-1;;4574:53:84;4561:11;;;4554:74;4644:12;;;4637:28;;;;4681:12;;;;4674:28;;;;1840:172:26;;;;;;;;;;4718:12:84;;;;1840:172:26;;;1813:213;;;;;;1650:395::o;4934:1132:62:-;2406:24;;;;;;;;;;;-1:-1:-1;;;2406:24:62;;;;;5143:211;;-1:-1:-1;;;;;;5143:211:62;;;5027:26:84;5234:4:62;5090:2:84;5086:15;;;-1:-1:-1;;5082:53:84;;;5069:11;;;5062:74;5152:12;;;5145:28;;;;2396:35:62;5189:12:84;;;;5182:28;;;;5143:211:62;;;;;;;;;;5226:12:84;;;5143:211:62;;5108:268;;;;;;-1:-1:-1;;;5545:450:62;;;5580:28:84;5641:15;;5637:53;;;5624:11;;;5617:74;-1:-1:-1;;;5707:12:84;;;5700:33;5545:450:62;;;;;;;;;5749:12:84;;;;5545:450:62;;;5510:507;;;;;;4934:1132::o;2826:162::-;2920:7;2950:31;2957:5;2964:13;2979:1;3573:17;3654:20;3668:5;3654:13;:20::i;:::-;3642:32;-1:-1:-1;;;;;;3688:21:62;;;:26;3684:72;;3716:40;;-1:-1:-1;;;3716:40:62;;5974:2:84;3716:40:62;;;5956:21:84;6013:2;5993:18;;;5986:30;6052:32;6032:18;;;6025:60;6102:18;;3716:40:62;5772:354:84;3684:72:62;3851:24;;;;;;;;;;;;;-1:-1:-1;;;3851:24:62;;;;;;3793:16;;3851:24;4188:5;;3793:16;4125:69;4113:81;-1:-1:-1;;;;;;4221:22:62;;4213:66;;;;-1:-1:-1;;;4213:66:62;;6333:2:84;4213:66:62;;;6315:21:84;6372:2;6352:18;;;6345:30;6411:33;6391:18;;;6384:61;6462:18;;4213:66:62;6131:355:84;4213:66:62;4338:13;4357:8;-1:-1:-1;;;;;4357:13:62;4378:6;4386:13;4357:43;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4337:63;;;4418:8;:38;;;;-1:-1:-1;;;;;;4430:21:62;;;:26;;4418:38;4410:81;;;;-1:-1:-1;;;4410:81:62;;6985:2:84;4410:81:62;;;6967:21:84;7024:2;7004:18;;;6997:30;7063:32;7043:18;;;7036:60;7113:18;;4410:81:62;6783:354:84;4410:81:62;3596:902;;;3464:1034;;;;;:::o;-1:-1:-1:-;;;;;;;;:::o;14:180:84:-;73:6;126:2;114:9;105:7;101:23;97:32;94:52;;;142:1;139;132:12;94:52;-1:-1:-1;165:23:84;;14:180;-1:-1:-1;14:180:84:o;407:127::-;468:10;463:3;459:20;456:1;449:31;499:4;496:1;489:15;523:4;520:1;513:15;539:718;581:5;634:3;627:4;619:6;615:17;611:27;601:55;;652:1;649;642:12;601:55;688:6;675:20;714:18;751:2;747;744:10;741:36;;;757:18;;:::i;:::-;832:2;826:9;800:2;886:13;;-1:-1:-1;;882:22:84;;;906:2;878:31;874:40;862:53;;;930:18;;;950:22;;;927:46;924:72;;;976:18;;:::i;:::-;1016:10;1012:2;1005:22;1051:2;1043:6;1036:18;1097:3;1090:4;1085:2;1077:6;1073:15;1069:26;1066:35;1063:55;;;1114:1;1111;1104:12;1063:55;1178:2;1171:4;1163:6;1159:17;1152:4;1144:6;1140:17;1127:54;1225:1;1218:4;1213:2;1205:6;1201:15;1197:26;1190:37;1245:6;1236:15;;;;;;539:718;;;;:::o;1262:388::-;1339:6;1347;1400:2;1388:9;1379:7;1375:23;1371:32;1368:52;;;1416:1;1413;1406:12;1368:52;1456:9;1443:23;1489:18;1481:6;1478:30;1475:50;;;1521:1;1518;1511:12;1475:50;1544:49;1585:7;1576:6;1565:9;1561:22;1544:49;:::i;:::-;1534:59;1640:2;1625:18;;;;1612:32;;-1:-1:-1;;;;1262:388:84:o;1655:562::-;1741:6;1749;1757;1810:2;1798:9;1789:7;1785:23;1781:32;1778:52;;;1826:1;1823;1816:12;1778:52;1849:23;;;-1:-1:-1;1922:2:84;1907:18;;1894:32;-1:-1:-1;;;;;1955:31:84;;1945:42;;1935:70;;2001:1;1998;1991:12;1935:70;2024:5;-1:-1:-1;2080:2:84;2065:18;;2052:32;2107:18;2096:30;;2093:50;;;2139:1;2136;2129:12;2093:50;2162:49;2203:7;2194:6;2183:9;2179:22;2162:49;:::i;:::-;2152:59;;;1655:562;;;;;:::o;2860:250::-;2945:1;2955:113;2969:6;2966:1;2963:13;2955:113;;;3045:11;;;3039:18;3026:11;;;3019:39;2991:2;2984:10;2955:113;;;-1:-1:-1;;3102:1:84;3084:16;;3077:27;2860:250::o;3115:491::-;3319:1;3315;3310:3;3306:11;3302:19;3294:6;3290:32;3279:9;3272:51;3359:2;3354;3343:9;3339:18;3332:30;3253:4;3391:6;3385:13;3434:6;3429:2;3418:9;3414:18;3407:34;3450:79;3522:6;3517:2;3506:9;3502:18;3497:2;3489:6;3485:15;3450:79;:::i;:::-;3590:2;3569:15;-1:-1:-1;;3565:29:84;3550:45;;;;3597:2;3546:54;;3115:491;-1:-1:-1;;;3115:491:84:o;3611:277::-;3678:6;3731:2;3719:9;3710:7;3706:23;3702:32;3699:52;;;3747:1;3744;3737:12;3699:52;3779:9;3773:16;3832:5;3825:13;3818:21;3811:5;3808:32;3798:60;;3854:1;3851;3844:12;6491:287;6620:3;6658:6;6652:13;6674:66;6733:6;6728:3;6721:4;6713:6;6709:17;6674:66;:::i;:::-;6756:16;;;;;6491:287;-1:-1:-1;;6491:287:84:o",
5983
5983
  "source": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"./WitnetProxy.sol\";\nimport \"../libs/Create3.sol\";\n\n/// @notice WitnetDeployer contract used both as CREATE2 (EIP-1014) factory for Witnet artifacts, \n/// @notice and CREATE3 (EIP-3171) factory for Witnet proxies.\n/// @author Guillermo Díaz <guillermo@otherplane.com>\n\ncontract WitnetDeployer {\n\n /// @notice Use given `_initCode` and `_salt` to deploy a contract into a deterministic address. \n /// @dev The address of deployed address will be determined by both the `_initCode` and the `_salt`, but not the address\n /// @dev nor the nonce of the caller (i.e. see EIP-1014). \n /// @param _initCode Creation code, including construction logic and input parameters.\n /// @param _salt Arbitrary value to modify resulting address.\n /// @return _deployed Just deployed contract address.\n function deploy(bytes memory _initCode, bytes32 _salt)\n external\n returns (address _deployed)\n {\n _deployed = determineAddr(_initCode, _salt);\n if (_deployed.code.length == 0) {\n assembly {\n _deployed := create2(0, add(_initCode, 0x20), mload(_initCode), _salt)\n }\n require(_deployed != address(0), \"WitnetDeployer: deployment failed\");\n }\n }\n\n /// @notice Determine counter-factual address of the contract that would be deployed by the given `_initCode` and a `_salt`.\n /// @param _initCode Creation code, including construction logic and input parameters.\n /// @param _salt Arbitrary value to modify resulting address.\n /// @return Deterministic contract address.\n function determineAddr(bytes memory _initCode, bytes32 _salt)\n public view\n returns (address)\n {\n return address(\n uint160(uint(keccak256(\n abi.encodePacked(\n bytes1(0xff),\n address(this),\n _salt,\n keccak256(_initCode)\n )\n )))\n );\n }\n\n function determineProxyAddr(bytes32 _salt) \n public view\n returns (address)\n {\n return Create3.determineAddr(_salt);\n }\n\n function proxify(bytes32 _proxySalt, address _firstImplementation, bytes memory _initData)\n external \n returns (WitnetProxy)\n {\n address _proxyAddr = determineProxyAddr(_proxySalt);\n if (_proxyAddr.code.length == 0) {\n // deploy the WitnetProxy\n Create3.deploy(_proxySalt, type(WitnetProxy).creationCode);\n // settle first implementation address,\n WitnetProxy(payable(_proxyAddr)).upgradeTo(\n _firstImplementation, \n // and initialize it, providing\n abi.encode(\n // the owner (i.e. the caller of this function)\n msg.sender,\n // and some (optional) initialization data\n _initData\n )\n );\n return WitnetProxy(payable(_proxyAddr));\n } else {\n revert(\"WitnetDeployer: already proxified\");\n }\n }\n\n}",
5984
- "sourcePath": "/home/asdpc/Witnet/witnet-solidity-bridge/contracts/core/WitnetDeployer.sol",
5984
+ "sourcePath": "/home/runner/work/witnet-solidity-bridge/witnet-solidity-bridge/contracts/core/WitnetDeployer.sol",
5985
5985
  "ast": {
5986
5986
  "absolutePath": "project:/contracts/core/WitnetDeployer.sol",
5987
5987
  "exportedSymbols": {
@@ -8279,7 +8279,7 @@
8279
8279
  },
8280
8280
  "networks": {},
8281
8281
  "schemaVersion": "3.4.16",
8282
- "updatedAt": "2025-10-15T17:39:32.472Z",
8282
+ "updatedAt": "2025-10-15T18:03:23.566Z",
8283
8283
  "devdoc": {
8284
8284
  "author": "Guillermo Díaz <guillermo@otherplane.com>",
8285
8285
  "kind": "dev",