Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deliver non revert #43

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
539 changes: 539 additions & 0 deletions abis/0.8.27/AgentFactory.json

Large diffs are not rendered by default.

1,083 changes: 1,083 additions & 0 deletions abis/0.8.27/AgentMech.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/AgentFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;
pragma solidity ^0.8.27;

import {AgentMech} from "./AgentMech.sol";
import {GenericManager} from "../lib/autonolas-registries/contracts/GenericManager.sol";
Expand All @@ -20,7 +20,7 @@
string public constant VERSION = "1.1.0";

// Agent registry address
address public immutable agentRegistry;

Check warning on line 23 in contracts/AgentFactory.sol

View workflow job for this annotation

GitHub Actions / build

Immutable variables name are set to be in capitalized SNAKE_CASE

constructor(address _agentRegistry) {
agentRegistry = _agentRegistry;
Expand Down
24 changes: 18 additions & 6 deletions contracts/AgentMech.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;
pragma solidity ^0.8.27;

import {ERC721Mech} from "../lib/gnosis-mech/contracts/ERC721Mech.sol";

Expand All @@ -9,8 +9,8 @@
address priorityMech;
// Delivery mech address
address deliveryMech;
// Account address sending the request
address account;
// Requester address
address requester;
// Response timeout window
uint32 responseTimeout;
}
Expand Down Expand Up @@ -97,9 +97,9 @@
bytes32 public constant DOMAIN_SEPARATOR_TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
// Original domain separator value
bytes32 public immutable domainSeparator;

Check warning on line 100 in contracts/AgentMech.sol

View workflow job for this annotation

GitHub Actions / build

Immutable variables name are set to be in capitalized SNAKE_CASE
// Original chain Id
uint256 public immutable chainId;

Check warning on line 102 in contracts/AgentMech.sol

View workflow job for this annotation

GitHub Actions / build

Immutable variables name are set to be in capitalized SNAKE_CASE

// Minimum required price
uint256 public price;
Expand Down Expand Up @@ -258,10 +258,19 @@
function _deliver(uint256 requestId, bytes memory data) internal returns (bytes memory requestData) {
// Get an account to deliver request to
address account = mapRequestAddresses[requestId];

// Get the mech delivery info from the mech marketplace
MechDelivery memory mechDelivery = IMechMarketplace(mechMarketplace).getMechDeliveryInfo(requestId);

// Instantly return if the request has been delivered
if (mechDelivery.deliveryMech != address(0)) {
return requestData;
}

// The account is zero if the delivery mech is different from a priority mech, or if request does not exist
if (account == address(0)) {
if (mechMarketplace != address(0)) {
account = IMechMarketplace(mechMarketplace).getMechDeliveryInfo(requestId).account;
account = mechDelivery.requester;
}

// Check if request exists in the mech marketplace or locally in the mech
Expand Down Expand Up @@ -383,8 +392,11 @@
// Request delivery
bytes memory requestData = _deliver(requestId, data);

// Mech marketplace delivery finalization
IMechMarketplace(mechMarketplace).deliverMarketplace(requestId, requestData, mechStakingInstance, mechServiceId);
// Mech marketplace delivery finalization if the request was not delivered already
if (requestData.length > 0) {
IMechMarketplace(mechMarketplace).deliverMarketplace(requestId, requestData, mechStakingInstance,
mechServiceId);
}

_locked = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ module.exports = {
solidity: {
compilers: [
{
version: "0.8.25",
version: "0.8.27",
settings: {
optimizer: {
enabled: true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"chai": "^4.3.10",
"eslint": "^8.52.0",
"ethers": "^5.7.2",
"hardhat": "^2.22.9",
"hardhat": "^2.22.13",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-deploy": "^0.11.43",
"hardhat-deploy-ethers": "^0.3.0-beta.13",
Expand Down
3 changes: 3 additions & 0 deletions test/AgentMech.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ describe("AgentMech", function () {
status = await mechMarketplace.getRequestStatus(requestId);
expect(status).to.equal(3);

// Try to deliver the same request again
await agentMech.deliverToMarketplace(requestId, data, serviceStakingMech.address, serviceId);

// Check mech karma
let mechKarma = await karma.mapMechKarma(agentMech.address);
expect(mechKarma).to.equal(1);
Expand Down
126 changes: 72 additions & 54 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -647,53 +647,53 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@nomicfoundation/edr-darwin-arm64@0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-darwin-arm64/-/edr-darwin-arm64-0.5.2.tgz#72f7a826c9f0f2c91308edca562de3b9484ac079"
integrity sha512-Gm4wOPKhbDjGTIRyFA2QUAPfCXA1AHxYOKt3yLSGJkQkdy9a5WW+qtqKeEKHc/+4wpJSLtsGQfpzyIzggFfo/A==

"@nomicfoundation/edr-darwin-x64@0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-darwin-x64/-/edr-darwin-x64-0.5.2.tgz#6d0fedb219d664631c6feddc596ab8c3bbc36fa8"
integrity sha512-ClyABq2dFCsrYEED3/UIO0c7p4H1/4vvlswFlqUyBpOkJccr75qIYvahOSJRM62WgUFRhbSS0OJXFRwc/PwmVg==

"@nomicfoundation/edr-linux-arm64-gnu@0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-arm64-gnu/-/edr-linux-arm64-gnu-0.5.2.tgz#60e4d52d963141bc2bb4a02639dc590a7fbdda2f"
integrity sha512-HWMTVk1iOabfvU2RvrKLDgtFjJZTC42CpHiw2h6rfpsgRqMahvIlx2jdjWYzFNy1jZKPTN1AStQ/91MRrg5KnA==

"@nomicfoundation/edr-linux-arm64-musl@0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-arm64-musl/-/edr-linux-arm64-musl-0.5.2.tgz#6676a09eab57c435a16ffc144658c896acca9baa"
integrity sha512-CwsQ10xFx/QAD5y3/g5alm9+jFVuhc7uYMhrZAu9UVF+KtVjeCvafj0PaVsZ8qyijjqVuVsJ8hD1x5ob7SMcGg==

"@nomicfoundation/edr-linux-x64-gnu@0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-x64-gnu/-/edr-linux-x64-gnu-0.5.2.tgz#f558d9697ce961410e7a7468f9ab8c8a601b9df6"
integrity sha512-CWVCEdhWJ3fmUpzWHCRnC0/VLBDbqtqTGTR6yyY1Ep3S3BOrHEAvt7h5gx85r2vLcztisu2vlDq51auie4IU1A==

"@nomicfoundation/edr-linux-x64-musl@0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-x64-musl/-/edr-linux-x64-musl-0.5.2.tgz#c9c9cbb2997499f75c1d022be724b0551d44569f"
integrity sha512-+aJDfwhkddy2pP5u1ISg3IZVAm0dO836tRlDTFWtvvSMQ5hRGqPcWwlsbobhDQsIxhPJyT7phL0orCg5W3WMeA==

"@nomicfoundation/edr-win32-x64-msvc@0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-win32-x64-msvc/-/edr-win32-x64-msvc-0.5.2.tgz#f16db88bf4fe09a996af0a25096e09deecb72bfa"
integrity sha512-CcvvuA3sAv7liFNPsIR/68YlH6rrybKzYttLlMr80d4GKJjwJ5OKb3YgE6FdZZnOfP19HEHhsLcE0DPLtY3r0w==

"@nomicfoundation/edr@^0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr/-/edr-0.5.2.tgz#e8c7b3d3dd4a312432ab3930dec60f76dc5c4926"
integrity sha512-hW/iLvUQZNTVjFyX/I40rtKvvDOqUEyIi96T28YaLfmPL+3LW2lxmYLUXEJ6MI14HzqxDqrLyhf6IbjAa2r3Dw==
dependencies:
"@nomicfoundation/edr-darwin-arm64" "0.5.2"
"@nomicfoundation/edr-darwin-x64" "0.5.2"
"@nomicfoundation/edr-linux-arm64-gnu" "0.5.2"
"@nomicfoundation/edr-linux-arm64-musl" "0.5.2"
"@nomicfoundation/edr-linux-x64-gnu" "0.5.2"
"@nomicfoundation/edr-linux-x64-musl" "0.5.2"
"@nomicfoundation/edr-win32-x64-msvc" "0.5.2"
"@nomicfoundation/edr-darwin-arm64@0.6.3":
version "0.6.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-darwin-arm64/-/edr-darwin-arm64-0.6.3.tgz#7f94f80f25bbf8f15421aca0626b1e243c5b6fba"
integrity sha512-hqtI7tYDqKG5PDmZ//Z65EH5cgH8VL/SAAu50rpHP7WAVfJWkOCcYbecywwF6nhHdonJbRTDGAeG1/+VOy6zew==

"@nomicfoundation/edr-darwin-x64@0.6.3":
version "0.6.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-darwin-x64/-/edr-darwin-x64-0.6.3.tgz#57cbbe09c70480e7eb79273ba5a497327d72347b"
integrity sha512-4fGi79/lyOlRUORhCYsYb3sWqRHuHT7qqzyZfZuNOn8llaxmT1k36xNmvpyg37R8SzjnhT/DzoukSJrs23Ip9Q==

"@nomicfoundation/edr-linux-arm64-gnu@0.6.3":
version "0.6.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-arm64-gnu/-/edr-linux-arm64-gnu-0.6.3.tgz#122f5ec8b00297e9ed0111405c8779a3c3ba26f3"
integrity sha512-yFFTvGFMhfAvQ1Z2itUh1jpoUA+mVROyVELcaxjIq8fyg602lQmbS+NXkhQ+oaeDgJ+06mSENrHBg4fcfRf9cw==

"@nomicfoundation/edr-linux-arm64-musl@0.6.3":
version "0.6.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-arm64-musl/-/edr-linux-arm64-musl-0.6.3.tgz#2b0371371540373b10521ead4ffa70a2d9e6ac8e"
integrity sha512-pOKmd0Fa3a6BHg5qbjbl/jMRELVi9oazbfiuU7Bvgn/dpTK+ID3jwT0SXiuC2zxjmPByWgXL6G9XRf5BPAM2rQ==

"@nomicfoundation/edr-linux-x64-gnu@0.6.3":
version "0.6.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-x64-gnu/-/edr-linux-x64-gnu-0.6.3.tgz#63849575eddbcd7a5da581d401fba6f5f9347644"
integrity sha512-3AUferhkLIXtLV63w5GjpHttzdxZ36i656XMy+pkBZbbiqnzIVeKWg6DJv1A94fQY16gB4gqj9CLq4CWvbNN6w==

"@nomicfoundation/edr-linux-x64-musl@0.6.3":
version "0.6.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-x64-musl/-/edr-linux-x64-musl-0.6.3.tgz#3b5e6462f47b40cde81bafc6da003c58b2eb9839"
integrity sha512-fr6bD872WIBXe9YnTDi0CzYepMcYRgSnkVqn0yK4wRnIvKrloWhxXNVY45GVIl51aNZguBnvoA4WEt6HIazs3A==

"@nomicfoundation/edr-win32-x64-msvc@0.6.3":
version "0.6.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-win32-x64-msvc/-/edr-win32-x64-msvc-0.6.3.tgz#45be7ba94b950e78e862cb3af0c320e070e0e452"
integrity sha512-sn34MvN1ajw2Oq1+Drpxej78Z0HfIzI4p4WlolupAV9dOZKzp2JAIQeLVfZpjIFbF3zuyxLPP4dUBrQoFPEqhA==

"@nomicfoundation/edr@^0.6.3":
version "0.6.3"
resolved "https://registry.yarnpkg.com/@nomicfoundation/edr/-/edr-0.6.3.tgz#47f1b217ce5eb09aef419d76a8488bb77cd88b94"
integrity sha512-hThe5ORR75WFYTXKL0K2AyLDxkTMrG+VQ1yL9BhQYsuh3OIH+3yNDxMz2LjfvrpOrMmJ4kk5NKdFewpqDojjXQ==
dependencies:
"@nomicfoundation/edr-darwin-arm64" "0.6.3"
"@nomicfoundation/edr-darwin-x64" "0.6.3"
"@nomicfoundation/edr-linux-arm64-gnu" "0.6.3"
"@nomicfoundation/edr-linux-arm64-musl" "0.6.3"
"@nomicfoundation/edr-linux-x64-gnu" "0.6.3"
"@nomicfoundation/edr-linux-x64-musl" "0.6.3"
"@nomicfoundation/edr-win32-x64-msvc" "0.6.3"

"@nomicfoundation/[email protected]":
version "4.0.4"
Expand Down Expand Up @@ -1572,7 +1572,7 @@ check-error@^1.0.2, check-error@^1.0.3:
dependencies:
get-func-name "^2.0.2"

chokidar@^3.4.0, chokidar@^3.5.2, chokidar@^3.5.3:
chokidar@^3.5.2, chokidar@^3.5.3:
version "3.6.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b"
integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==
Expand All @@ -1587,6 +1587,13 @@ chokidar@^3.4.0, chokidar@^3.5.2, chokidar@^3.5.3:
optionalDependencies:
fsevents "~2.3.2"

chokidar@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-4.0.1.tgz#4a6dff66798fb0f72a94f616abbd7e1a19f31d41"
integrity sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==
dependencies:
readdirp "^4.0.1"

chownr@^1.1.1:
version "1.1.4"
resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b"
Expand Down Expand Up @@ -2722,14 +2729,14 @@ hardhat-tracer@^2.6.0:
debug "^4.3.4"
ethers "^5.6.1"

hardhat@^2.22.9:
version "2.22.9"
resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.22.9.tgz#d8f2720561dc60f5cc0ee80c82f9b1907fd61c88"
integrity sha512-sWiuI/yRdFUPfndIvL+2H18Vs2Gav0XacCFYY5msT5dHOWkhLxESJySIk9j83mXL31aXL8+UMA9OgViFLexklg==
hardhat@^2.22.13:
version "2.22.13"
resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.22.13.tgz#1d2c7c4b640d060ae0f5b04757322118a003955a"
integrity sha512-psVJX4FSXDpSXwsU8OcKTJN04pQEj9cFBMX5OPko+OFwbIoiOpvRmafa954/UaA1934npTj8sV3gaTSdx9bPbA==
dependencies:
"@ethersproject/abi" "^5.1.2"
"@metamask/eth-sig-util" "^4.0.0"
"@nomicfoundation/edr" "^0.5.2"
"@nomicfoundation/edr" "^0.6.3"
"@nomicfoundation/ethereumjs-common" "4.0.4"
"@nomicfoundation/ethereumjs-tx" "5.0.4"
"@nomicfoundation/ethereumjs-util" "9.0.4"
Expand All @@ -2742,7 +2749,7 @@ hardhat@^2.22.9:
ansi-escapes "^4.3.0"
boxen "^5.1.2"
chalk "^2.4.2"
chokidar "^3.4.0"
chokidar "^4.0.0"
ci-info "^2.0.0"
debug "^4.1.1"
enquirer "^2.3.0"
Expand All @@ -2755,6 +2762,7 @@ hardhat@^2.22.9:
glob "7.2.0"
immutable "^4.0.0-rc.12"
io-ts "1.10.4"
json-stream-stringify "^3.1.4"
keccak "^3.0.2"
lodash "^4.17.11"
mnemonist "^0.38.0"
Expand Down Expand Up @@ -3103,6 +3111,11 @@ json-stable-stringify-without-jsonify@^1.0.1:
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==

json-stream-stringify@^3.1.4:
version "3.1.6"
resolved "https://registry.yarnpkg.com/json-stream-stringify/-/json-stream-stringify-3.1.6.tgz#ebe32193876fb99d4ec9f612389a8d8e2b5d54d4"
integrity sha512-x7fpwxOkbhFCaJDJ8vb1fBY3DdSa4AlITaz+HHILQJzdPMnHEFjxPwVUi1ALIbcIxDE0PNe/0i7frnY8QnBQog==

jsonfile@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
Expand Down Expand Up @@ -3828,6 +3841,11 @@ readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.6.0:
string_decoder "^1.1.1"
util-deprecate "^1.0.1"

readdirp@^4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-4.0.2.tgz#388fccb8b75665da3abffe2d8f8ed59fe74c230a"
integrity sha512-yDMz9g+VaZkqBYS/ozoBJwaBhTbZo3UNYQHNRw1D3UFQB8oHB4uS/tAODO+ZLjGWmUbKnIlOWO+aaIiAxrUWHA==

readdirp@~3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7"
Expand Down
Loading