From 272ff50b8d2f9440460fdc2eeeaa1b8b2257cc5d Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Wed, 28 Feb 2024 09:02:31 +0400 Subject: [PATCH] wip on i9r bump --- src/abstract/FlowCommon.sol | 6 +- src/concrete/basic/Flow.meta.json | 52 -------- src/concrete/basic/Flow.sol | 3 +- src/concrete/erc1155/FlowERC1155.meta.json | 121 ------------------ src/concrete/erc1155/FlowERC1155.sol | 14 +- src/concrete/erc20/FlowERC20.meta.json | 115 ----------------- src/concrete/erc20/FlowERC20.sol | 37 +++--- src/concrete/erc721/FlowERC721.meta.json | 121 ------------------ src/concrete/erc721/FlowERC721.sol | 46 ++++--- src/interface/deprecated/v2/IFlowV2.sol | 1 + src/interface/deprecated/v3/IFlowERC20V3.sol | 5 +- src/interface/deprecated/v3/IFlowV3.sol | 16 --- .../deprecated/v4/IFlowERC1155V4.sol | 2 +- src/interface/deprecated/v4/IFlowERC20V4.sol | 4 +- src/interface/deprecated/v4/IFlowERC721V4.sol | 5 +- src/interface/deprecated/v4/IFlowV4.sol | 6 +- src/interface/unstable/IFlowERC1155V5.sol | 4 +- src/interface/unstable/IFlowERC20V5.sol | 12 +- src/interface/unstable/IFlowERC721V5.sol | 30 ++--- src/interface/unstable/IFlowV5.sol | 9 +- src/lib/LibFlow.sol | 14 +- test/interface/unstable/IFlowV4.t.sol | 2 +- 22 files changed, 95 insertions(+), 530 deletions(-) delete mode 100644 src/concrete/basic/Flow.meta.json delete mode 100644 src/concrete/erc1155/FlowERC1155.meta.json delete mode 100644 src/concrete/erc20/FlowERC20.meta.json delete mode 100644 src/concrete/erc721/FlowERC721.meta.json diff --git a/src/abstract/FlowCommon.sol b/src/abstract/FlowCommon.sol index fea5f9c1..faa9ef8d 100644 --- a/src/abstract/FlowCommon.sol +++ b/src/abstract/FlowCommon.sol @@ -10,7 +10,7 @@ import { } from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; import {LibEncodedDispatch} from "rain.interpreter.interface/lib/caller/LibEncodedDispatch.sol"; import {LibContext} from "rain.interpreter.interface/lib/caller/LibContext.sol"; -import {UnregisteredFlow, MIN_FLOW_SENTINELS} from "../interface/unstable/IFlowV4.sol"; +import {UnregisteredFlow, MIN_FLOW_SENTINELS} from "../interface/unstable/IFlowV5.sol"; import {LibEvaluable, EvaluableV2} from "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; import { SourceIndexV2, @@ -198,10 +198,10 @@ abstract contract FlowCommon is ERC721Holder, ERC1155Holder, Multicall, Reentran } } - (uint256[] memory stack, uint256[] memory kvs) = evaluable.interpreter.eval( + (uint256[] memory stack, uint256[] memory kvs) = evaluable.interpreter.eval2( evaluable.store, DEFAULT_STATE_NAMESPACE, - LibEncodedDispatch.encode(evaluable.expression, FLOW_ENTRYPOINT, FLOW_MAX_OUTPUTS), + LibEncodedDispatch.encode2(evaluable.expression, FLOW_ENTRYPOINT, FLOW_MAX_OUTPUTS), context ); return (stack.dataPointer(), stack.endPointer(), kvs); diff --git a/src/concrete/basic/Flow.meta.json b/src/concrete/basic/Flow.meta.json deleted file mode 100644 index 03fb64f6..00000000 --- a/src/concrete/basic/Flow.meta.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "Flow", - "abiName": "Flow", - "desc": "Flow contracts transfer tokens based on deployed expressions.", - "alias": "flow", - "source": "https://github.com/rainprotocol/rain-protocol", - "methods": [ - { - "name": "initialize", - "abiName": "initialize", - "desc": "Initialize a new Flow ERC20 contract.", - "expressions": [ - { - "name": "Dummy Expression", - "abiName": "dummyConfig", - "desc": "A dummy expression. This is here to workaround a bug in Solidity.", - "path": "[13].inputs[1].components[0]" - }, - { - "name": "Flows", - "abiName": "config", - "desc": "The available flows.", - "path": "[13].inputs[1].components[1]", - "signedContext": true, - "callerContext": true, - "contextColumns": [ - { - "name": "Base", - "desc": "Base context column.", - "alias": "base", - "columnIndex": 0, - "cells": [ - { - "name": "Flow caller", - "desc": "The contract or wallet that called flow.", - "alias": "flow-caller", - "cellIndex": 0 - }, - { - "name": "Flow contract", - "desc": "The address of the flow contract.", - "alias": "flow-contract", - "cellIndex": 1 - } - ] - } - ] - } - ] - } - ] -} diff --git a/src/concrete/basic/Flow.sol b/src/concrete/basic/Flow.sol index aa8503cf..e7a07b7c 100644 --- a/src/concrete/basic/Flow.sol +++ b/src/concrete/basic/Flow.sol @@ -3,13 +3,12 @@ pragma solidity =0.8.19; import {ICloneableV2, ICLONEABLE_V2_SUCCESS} from "rain.factory/src/interface/ICloneableV2.sol"; import {FlowCommon, LibContext} from "../../abstract/FlowCommon.sol"; -import {IFlowV4, MIN_FLOW_SENTINELS} from "../../interface/unstable/IFlowV4.sol"; +import {IFlowV4, MIN_FLOW_SENTINELS, FlowTransferV1} from "../../interface/unstable/IFlowV5.sol"; import {LibFlow} from "../../lib/LibFlow.sol"; import {LibUint256Matrix} from "rain.solmem/lib/LibUint256Matrix.sol"; import {Pointer} from "rain.solmem/lib/LibPointer.sol"; import {LibUint256Array} from "rain.solmem/lib/LibUint256Array.sol"; import {EvaluableV2} from "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; -import {FlowTransferV1} from "../../interface/unstable/IFlowV4.sol"; import {SignedContextV1, EvaluableConfigV3} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; /// @title Flow diff --git a/src/concrete/erc1155/FlowERC1155.meta.json b/src/concrete/erc1155/FlowERC1155.meta.json deleted file mode 100644 index c004228c..00000000 --- a/src/concrete/erc1155/FlowERC1155.meta.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "name": "Flow ERC1155", - "abiName": "FlowERC1155", - "desc": "A flow contract that is also an ERC1155 token that can be minted by expressions. Transfers can be restricted by an expression.", - "alias": "flow-erc1155", - "source": "https://github.com/rainprotocol/rain-protocol", - "methods": [ - { - "name": "initialize", - "abiName": "initialize", - "desc": "Initialize a FlowERC1155 contract.", - "inputs": [ - { - "name": "URI", - "abiName": "uri", - "desc": "The URI for the ERC1155 token that is minted.", - "path": "[14].inputs[1].components[0]" - } - ], - "expressions": [ - { - "name": "Handle transfer", - "abiName": "evaluableConfig", - "desc": "Review and restrict transfers of the flow contract's own ERC1155 token. Mint and burns must be controlled by the flow expressions instead.", - "path": "[14].inputs[1].components[1]", - "signedContext": false, - "contextColumns": [ - { - "name": "Base", - "desc": "Base context column", - "alias": "base", - "columnIndex": 0, - "cells": [ - { - "name": "Transfer caller", - "desc": "The contract or wallet that called transfer.", - "alias": "transfer-caller", - "cellIndex": 0 - }, - { - "name": "Flow contract", - "desc": "The address of the FlowERC1155 contract.", - "alias": "flow-contract", - "cellIndex": 1 - } - ] - }, - { - "name": "Transfer information", - "desc": "Information about the current transfer.", - "alias": "transfer-information", - "columnIndex": 1, - "cells": [ - { - "name": "Transfer operator", - "desc": "The address of the transfer operator.", - "alias": "transfer-operator-address", - "cellIndex": 0 - }, - { - "name": "Transfer from address", - "desc": "The address the token is being transferred from.", - "alias": "transfer-from-address", - "cellIndex": 1 - }, - { - "name": "Transfer to address", - "desc": "The address the token is being transferred to.", - "alias": "transfer-to-address", - "cellIndex": 2 - } - ] - }, - { - "name": "Token IDs", - "desc": "All the ERC1155 ids being transferred.", - "alias": "transfer-ids", - "columnIndex": 2 - }, - { - "name": "Token amounts", - "desc": "All the ERC1155 amounts being transferred, pairwise with the IDs.", - "alias": "transfer-amounts", - "columnIndex": 3 - } - ] - }, - { - "name": "Flows", - "abiName": "flowConfig", - "desc": "The available flows for this token.", - "path": "[14].inputs[1].components[2]", - "signedContext": true, - "callerContext": true, - "contextColumns": [ - { - "name": "Base", - "desc": "Base context column.", - "alias": "base", - "columnIndex": 0, - "cells": [ - { - "name": "Flow caller", - "desc": "The contract or wallet that called flow.", - "alias": "flow-caller", - "cellIndex": 0 - }, - { - "name": "Flow contract", - "desc": "The address of the FlowERC1155 contract.", - "alias": "flow-contract", - "cellIndex": 1 - } - ] - } - ] - } - ] - } - ] -} diff --git a/src/concrete/erc1155/FlowERC1155.sol b/src/concrete/erc1155/FlowERC1155.sol index 4c7e89f1..4a086719 100644 --- a/src/concrete/erc1155/FlowERC1155.sol +++ b/src/concrete/erc1155/FlowERC1155.sol @@ -20,7 +20,7 @@ import { FLOW_ERC1155_HANDLE_TRANSFER_MAX_OUTPUTS, FLOW_ERC1155_HANDLE_TRANSFER_MIN_OUTPUTS, FLOW_ERC1155_MIN_FLOW_SENTINELS -} from "../../interface/unstable/IFlowERC1155V4.sol"; +} from "../../interface/unstable/IFlowERC1155V5.sol"; import {LibBytecode} from "rain.interpreter.interface/lib/bytecode/LibBytecode.sol"; import { IInterpreterV2, DEFAULT_STATE_NAMESPACE @@ -68,10 +68,10 @@ contract FlowERC1155 is ICloneableV2, IFlowERC1155V4, FlowCommon, ERC1155 { flowCommonInit(flowERC1155Config.flowConfig, FLOW_ERC1155_MIN_FLOW_SENTINELS); if (evalHandleTransfer) { - (IInterpreterV1 interpreter, IInterpreterStoreV1 store, address expression) = flowERC1155Config + (IInterpreterV2 interpreter, IInterpreterStoreV2 store, address expression) = flowERC1155Config .evaluableConfig .deployer - .deployExpression( + .deployExpression2( flowERC1155Config.evaluableConfig.bytecode, flowERC1155Config.evaluableConfig.constants, LibUint256Array.arrayFrom(FLOW_ERC1155_HANDLE_TRANSFER_MIN_OUTPUTS) @@ -83,7 +83,7 @@ contract FlowERC1155 is ICloneableV2, IFlowERC1155V4, FlowCommon, ERC1155 { // integrity checks are complete. // The deployer MUST be a trusted contract anyway. // slither-disable-next-line reentrancy-benign - sEvaluable = Evaluable(interpreter, store, expression); + sEvaluable = EvaluableV2(interpreter, store, expression); } return ICLONEABLE_V2_SUCCESS; @@ -115,7 +115,7 @@ contract FlowERC1155 is ICloneableV2, IFlowERC1155V4, FlowCommon, ERC1155 { // Mint and burn access MUST be handled by flow. // HANDLE_TRANSFER will only restrict subsequent transfers. if (sEvalHandleTransfer && !(from == address(0) || to == address(0))) { - Evaluable memory evaluable = sEvaluable; + EvaluableV2 memory evaluable = sEvaluable; uint256[][] memory context; { context = LibContext.build( @@ -132,10 +132,10 @@ contract FlowERC1155 is ICloneableV2, IFlowERC1155V4, FlowCommon, ERC1155 { ); } - (uint256[] memory stack, uint256[] memory kvs) = evaluable.interpreter.eval( + (uint256[] memory stack, uint256[] memory kvs) = evaluable.interpreter.eval2( evaluable.store, DEFAULT_STATE_NAMESPACE, - LibEncodedDispatch.encode( + LibEncodedDispatch.encode2( evaluable.expression, FLOW_ERC1155_HANDLE_TRANSFER_ENTRYPOINT, FLOW_ERC1155_HANDLE_TRANSFER_MAX_OUTPUTS diff --git a/src/concrete/erc20/FlowERC20.meta.json b/src/concrete/erc20/FlowERC20.meta.json deleted file mode 100644 index 4b624ed2..00000000 --- a/src/concrete/erc20/FlowERC20.meta.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "name": "Flow ERC20", - "abiName": "FlowERC20", - "desc": "A flow contract that is also an ERC20 token that can be minted by expressions. Transfers can be restricted by an expression.", - "alias": "flow-erc20", - "source": "https://github.com/rainprotocol/rain-protocol", - "methods": [ - { - "name": "initialize", - "abiName": "initialize", - "desc": "Initialize a FlowERC20 contract.", - "inputs": [ - { - "name": "Name", - "abiName": "name", - "desc": "Name of the ERC20 token that is minted.", - "path": "[14].inputs[1].components[0]" - }, - { - "name": "Symbol", - "abiName": "symbol", - "desc": "Symbol of the ERC20 token that is minted.", - "path": "[14].inputs[1].components[1]" - } - ], - "expressions": [ - { - "name": "Handle Transfer", - "abiName": "evaluableConfig", - "desc": "Review and restrict transfers of the flow contract's own ERC20 token. Mint and burns must be controlled by the flow expressions instead.", - "path": "[14].inputs[1].components[2]", - "signedContext": false, - "contextColumns": [ - { - "name": "Base", - "desc": "Base context column.", - "alias": "base", - "columnIndex": 0, - "cells": [ - { - "name": "Transfer caller", - "desc": "The contract or wallet that called transfer.", - "alias": "transfer-caller", - "cellIndex": 0 - }, - { - "name": "Flow contract", - "desc": "The address of the FlowERC20 contract.", - "alias": "flow-contract", - "cellIndex": 1 - } - ] - }, - { - "name": "Transfer information", - "desc": "Information about the current transfer.", - "alias": "transfer-information", - "columnIndex": 1, - "cells": [ - { - "name": "Transfer from address", - "desc": "The address the token is being transferred from.", - "alias": "transfer-from-address", - "cellIndex": 0 - }, - { - "name": "Transfer to address", - "desc": "The address the token is being transferred to.", - "alias": "transfer-to-address", - "cellIndex": 1 - }, - { - "name": "Transfer amount", - "desc": "The amount of token being transferred.", - "alias": "transfer-amount", - "cellIndex": 2 - } - ] - } - ] - }, - { - "name": "Flows", - "abiName": "flowConfig", - "desc": "The available flows.", - "path": "[14].inputs[1].components[3]", - "signedContext": true, - "callerContext": true, - "contextColumns": [ - { - "name": "Base", - "desc": "Base context column.", - "alias": "base", - "columnIndex": 0, - "cells": [ - { - "name": "Flow caller", - "desc": "The contract or wallet that called flow.", - "alias": "flow-caller", - "cellIndex": 0 - }, - { - "name": "Flow contract", - "desc": "The address of the FlowERC20 contract.", - "alias": "flow-contract", - "cellIndex": 1 - } - ] - } - ] - } - ] - } - ] -} diff --git a/src/concrete/erc20/FlowERC20.sol b/src/concrete/erc20/FlowERC20.sol index 85012f7b..20bb18be 100644 --- a/src/concrete/erc20/FlowERC20.sol +++ b/src/concrete/erc20/FlowERC20.sol @@ -7,7 +7,7 @@ import {LibUint256Array} from "rain.solmem/lib/LibUint256Array.sol"; import {LibUint256Matrix} from "rain.solmem/lib/LibUint256Matrix.sol"; import {ICloneableV2, ICLONEABLE_V2_SUCCESS} from "rain.factory/src/interface/ICloneableV2.sol"; import { - IFlowERC20V4, + IFlowERC20V5, FlowERC20IOV1, FlowERC20ConfigV2, ERC20SupplyChange, @@ -17,7 +17,7 @@ import { FLOW_ERC20_HANDLE_TRANSFER_MAX_OUTPUTS, RAIN_FLOW_SENTINEL, FLOW_ERC20_MIN_FLOW_SENTINELS -} from "../../interface/unstable/IFlowERC20V4.sol"; +} from "../../interface/unstable/IFlowERC20V5.sol"; import {LibBytecode} from "rain.interpreter.interface/lib/bytecode/LibBytecode.sol"; import {EncodedDispatch, LibEncodedDispatch} from "rain.interpreter.interface/lib/caller/LibEncodedDispatch.sol"; import {Sentinel, LibStackSentinel} from "rain.solmem/lib/LibStackSentinel.sol"; @@ -28,7 +28,7 @@ import { IInterpreterV2, DEFAULT_STATE_NAMESPACE } from "rain.interpreter.interface/interface/unstable/IInterpreterV2.sol"; -import {IInterpreterStoreV1} from "rain.interpreter.interface/interface/IInterpreterStoreV1.sol"; +import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/unstable/IInterpreterStoreV2.sol"; import {Pointer} from "rain.solmem/lib/LibPointer.sol"; import {EvaluableV2} from "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; import {LibContext} from "rain.interpreter.interface/lib/caller/LibContext.sol"; @@ -38,8 +38,8 @@ import {LibContext} from "rain.interpreter.interface/lib/caller/LibContext.sol"; bytes32 constant CALLER_META_HASH = bytes32(0xff0499e4ee7171a54d176cfe13165a7ea512d146dbd99d42b3d3ec9963025acf); /// @title FlowERC20 -/// See `IFlowERC20V4` for documentation. -contract FlowERC20 is ICloneableV2, IFlowERC20V4, FlowCommon, ERC20 { +/// See `IFlowERC20V5` for documentation. +contract FlowERC20 is ICloneableV2, IFlowERC20V5, FlowCommon, ERC20 { using LibStackSentinel for Pointer; using LibUint256Matrix for uint256[]; using LibUint256Array for uint256[]; @@ -51,10 +51,7 @@ contract FlowERC20 is ICloneableV2, IFlowERC20V4, FlowCommon, ERC20 { /// @dev The evaluable that will be used to evaluate `handleTransfer` on /// every transfer. This is only set if `sEvalHandleTransfer` is true. - Evaluable internal sEvaluable; - - /// Forwards the `FlowCommon` constructor arguments to the `FlowCommon`. - constructor(DeployerDiscoverableMetaV2ConstructionConfig memory config) FlowCommon(CALLER_META_HASH, config) {} + EvaluableV2 internal sEvaluable; /// Overloaded typed initialize function MUST revert with this error. /// As per `ICloneableV2` interface. @@ -71,17 +68,17 @@ contract FlowERC20 is ICloneableV2, IFlowERC20V4, FlowCommon, ERC20 { // Set state before external calls here. bool evalHandleTransfer = LibBytecode.sourceCount(flowERC20Config.evaluableConfig.bytecode) > 0 && LibBytecode.sourceOpsCount( - flowERC20Config.evaluableConfig.bytecode, SourceIndex.unwrap(FLOW_ERC20_HANDLE_TRANSFER_ENTRYPOINT) + flowERC20Config.evaluableConfig.bytecode, SourceIndexV2.unwrap(FLOW_ERC20_HANDLE_TRANSFER_ENTRYPOINT) ) > 0; sEvalHandleTransfer = evalHandleTransfer; flowCommonInit(flowERC20Config.flowConfig, FLOW_ERC20_MIN_FLOW_SENTINELS); if (evalHandleTransfer) { - (IInterpreterV1 interpreter, IInterpreterStoreV1 store, address expression) = flowERC20Config + (IInterpreterV2 interpreter, IInterpreterStoreV2 store, address expression) = flowERC20Config .evaluableConfig .deployer - .deployExpression( + .deployExpression2( flowERC20Config.evaluableConfig.bytecode, flowERC20Config.evaluableConfig.constants, LibUint256Array.arrayFrom(FLOW_ERC20_HANDLE_TRANSFER_MIN_OUTPUTS) @@ -93,19 +90,19 @@ contract FlowERC20 is ICloneableV2, IFlowERC20V4, FlowCommon, ERC20 { // integrity checks are complete. // The deployer MUST be a trusted contract anyway. // slither-disable-next-line reentrancy-benign - sEvaluable = Evaluable(interpreter, store, expression); + sEvaluable = EvaluableV2(interpreter, store, expression); } return ICLONEABLE_V2_SUCCESS; } - /// @inheritdoc IFlowERC20V4 + /// @inheritdoc IFlowERC20V5 function stackToFlow(uint256[] memory stack) external pure virtual override returns (FlowERC20IOV1 memory) { return _stackToFlow(stack.dataPointer(), stack.endPointer()); } - /// @inheritdoc IFlowERC20V4 - function flow(Evaluable memory evaluable, uint256[] memory callerContext, SignedContextV1[] memory signedContexts) + /// @inheritdoc IFlowERC20V5 + function flow(EvaluableV2 memory evaluable, uint256[] memory callerContext, SignedContextV1[] memory signedContexts) external virtual returns (FlowERC20IOV1 memory) @@ -126,11 +123,11 @@ contract FlowERC20 is ICloneableV2, IFlowERC20V4, FlowCommon, ERC20 { // Mint and burn access MUST be handled by flow. // HANDLE_TRANSFER will only restrict subsequent transfers. if (sEvalHandleTransfer && !(from == address(0) || to == address(0))) { - Evaluable memory evaluable = sEvaluable; - (uint256[] memory stack, uint256[] memory kvs) = evaluable.interpreter.eval( + EvaluableV2 memory evaluable = sEvaluable; + (uint256[] memory stack, uint256[] memory kvs) = evaluable.interpreter.eval2( evaluable.store, DEFAULT_STATE_NAMESPACE, - LibEncodedDispatch.encode( + LibEncodedDispatch.encode2( evaluable.expression, FLOW_ERC20_HANDLE_TRANSFER_ENTRYPOINT, FLOW_ERC20_HANDLE_TRANSFER_MAX_OUTPUTS @@ -185,7 +182,7 @@ contract FlowERC20 is ICloneableV2, IFlowERC20V4, FlowCommon, ERC20 { /// the mints and burns from the `FlowERC20IOV1` struct. The mints are /// processed first, then the burns, then the remaining flow is processed /// as normal. - function _flow(Evaluable memory evaluable, uint256[] memory callerContext, SignedContextV1[] memory signedContexts) + function _flow(EvaluableV2 memory evaluable, uint256[] memory callerContext, SignedContextV1[] memory signedContexts) internal virtual nonReentrant diff --git a/src/concrete/erc721/FlowERC721.meta.json b/src/concrete/erc721/FlowERC721.meta.json deleted file mode 100644 index be45f4de..00000000 --- a/src/concrete/erc721/FlowERC721.meta.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "name": "Flow ERC721", - "abiName": "FlowERC721", - "desc": "A flow contract that is also an ERC721 token that can be minted by expressions. Transfers can be restricted by an expression.", - "alias": "flow-erc721", - "source": "https://github.com/rainprotocol/rain-protocol", - "methods": [ - { - "name": "initialize", - "abiName": "initialize", - "desc": "Initialize a FlowERC721 contract.", - "inputs": [ - { - "name": "Name", - "abiName": "name", - "desc": "Name of the ERC721 token that is minted.", - "path": "[16].inputs[1].components[0]" - }, - { - "name": "Symbol", - "abiName": "symbol", - "desc": "Symbol for the ERC721 token that is minted.", - "path": "[16].inputs[1].components[1]" - }, - { - "name": "Base URI", - "abiName": "baseURI", - "desc": "Base URI for the ERC721 token that is minted.", - "path": "[16].inputs[1].components[2]" - } - ], - "expressions": [ - { - "name": "Handle transfer", - "abiName": "evaluableConfig", - "desc": "Review and restrict transfers of the flow contract's own ERC721 token. Mint and burns must be controlled by the flow expressions instead.", - "path": "[16].inputs[1].components[3]", - "signedContext": false, - "contextColumns": [ - { - "name": "Base", - "desc": "Base context column", - "alias": "base", - "columnIndex": 0, - "cells": [ - { - "name": "Transfer caller", - "desc": "The contract or wallet that called transfer.", - "alias": "transfer-caller", - "cellIndex": 0 - }, - { - "name": "Flow contract", - "desc": "The address of the FlowERC721 contract.", - "alias": "flow-contract", - "cellIndex": 1 - } - ] - }, - { - "name": "Transfer information", - "desc": "Information about the current transfer.", - "alias": "transfer-information", - "columnIndex": 1, - "cells": [ - { - "name": "Transfer from address", - "desc": "The address the token is being transferred from.", - "alias": "transfer-from-address", - "cellIndex": 0 - }, - { - "name": "Transfer to address", - "desc": "The address the token is being transferred to.", - "alias": "transfer-to-address", - "cellIndex": 1 - }, - { - "name": "Token ID", - "desc": "The ID of the token being transferred.", - "alias": "transfer-token-id", - "cellIndex": 2 - } - ] - } - ] - }, - { - "name": "Flows", - "abiName": "flowConfig", - "desc": "The available flows.", - "path": "[16].inputs[1].components[4]", - "signedContext": true, - "callerContext": true, - "contextColumns": [ - { - "name": "Base", - "desc": "Base context column.", - "alias": "base", - "columnIndex": 0, - "cells": [ - { - "name": "Flow caller", - "desc": "The contract or wallet that called flow.", - "alias": "flow-caller", - "cellIndex": 0 - }, - { - "name": "Flow contract", - "desc": "The address of the FlowERC721 contract.", - "alias": "flow-contract", - "cellIndex": 1 - } - ] - } - ] - } - ] - } - ] -} diff --git a/src/concrete/erc721/FlowERC721.sol b/src/concrete/erc721/FlowERC721.sol index de3b1896..9840f984 100644 --- a/src/concrete/erc721/FlowERC721.sol +++ b/src/concrete/erc721/FlowERC721.sol @@ -10,7 +10,7 @@ import {Sentinel, LibStackSentinel} from "rain.solmem/lib/LibStackSentinel.sol"; import {EncodedDispatch, LibEncodedDispatch} from "rain.interpreter.interface/lib/caller/LibEncodedDispatch.sol"; import {ICloneableV2, ICLONEABLE_V2_SUCCESS} from "rain.factory/src/interface/ICloneableV2.sol"; import { - IFlowERC721V4, + IFlowERC721V5, FlowERC721IOV1, SignedContextV1, FlowERC721ConfigV2, @@ -21,8 +21,9 @@ import { FLOW_ERC721_HANDLE_TRANSFER_MAX_OUTPUTS, FLOW_ERC721_TOKEN_URI_ENTRYPOINT, FLOW_ERC721_HANDLE_TRANSFER_ENTRYPOINT, - FLOW_ERC721_MIN_FLOW_SENTINELS -} from "../../interface/unstable/IFlowERC721V4.sol"; + FLOW_ERC721_MIN_FLOW_SENTINELS, + RAIN_FLOW_SENTINEL +} from "../../interface/unstable/IFlowERC721V5.sol"; import {LibBytecode} from "rain.interpreter.interface/lib/bytecode/LibBytecode.sol"; import {SourceIndexV2} from "rain.interpreter.interface/interface/unstable/IInterpreterV2.sol"; import {LibFlow} from "../../lib/LibFlow.sol"; @@ -33,7 +34,7 @@ import { } from "rain.interpreter.interface/interface/unstable/IInterpreterV2.sol"; import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/unstable/IInterpreterStoreV2.sol"; import {Pointer} from "rain.solmem/lib/LibPointer.sol"; -import {RAIN_FLOW_SENTINEL, BurnerNotOwner} from "../../interface/unstable/IFlowERC721V4.sol"; +import {BurnerNotOwner} from "../../error/ErrFlow.sol"; /// @dev The hash of the meta data expected to be passed to `FlowCommon`'s /// constructor. @@ -41,7 +42,7 @@ bytes32 constant CALLER_META_HASH = bytes32(0xf0003e81ff90467c9933f3ac68db3ca49d /// @title FlowERC721 /// See `IFlowERC721V4` for documentation. -contract FlowERC721 is ICloneableV2, IFlowERC721V4, FlowCommon, ERC721 { +contract FlowERC721 is ICloneableV2, IFlowERC721V5, FlowCommon, ERC721 { using LibUint256Matrix for uint256[]; using LibUint256Array for uint256[]; using LibStackSentinel for Pointer; @@ -59,16 +60,13 @@ contract FlowERC721 is ICloneableV2, IFlowERC721V4, FlowCommon, ERC721 { /// @dev The evaluable that contains the entrypoints for `handleTransfer` and /// `tokenURI`. This is only set if `sEvalHandleTransfer` or `sEvalTokenURI` /// is true. - Evaluable internal sEvaluable; + EvaluableV2 internal sEvaluable; /// @dev The base URI for all token URIs. This is set during initialization /// and cannot be changed. The token URI evaluable can be used for dynamic /// token URIs from the base URI. string private sBaseURI; - /// Forwards the `FlowCommon` constructor arguments to the `FlowCommon`. - constructor(DeployerDiscoverableMetaV2ConstructionConfig memory config) FlowCommon(CALLER_META_HASH, config) {} - /// Needed here to fix Open Zeppelin implementing `supportsInterface` on /// multiple base contracts. function supportsInterface(bytes4 interfaceId) @@ -98,11 +96,11 @@ contract FlowERC721 is ICloneableV2, IFlowERC721V4, FlowCommon, ERC721 { uint256 sourceCount = LibBytecode.sourceCount(flowERC721Config.evaluableConfig.bytecode); bool evalHandleTransfer = sourceCount > 0 && LibBytecode.sourceOpsCount( - flowERC721Config.evaluableConfig.bytecode, SourceIndex.unwrap(FLOW_ERC721_HANDLE_TRANSFER_ENTRYPOINT) + flowERC721Config.evaluableConfig.bytecode, SourceIndexV2.unwrap(FLOW_ERC721_HANDLE_TRANSFER_ENTRYPOINT) ) > 0; bool evalTokenURI = sourceCount > 1 && LibBytecode.sourceOpsCount( - flowERC721Config.evaluableConfig.bytecode, SourceIndex.unwrap(FLOW_ERC721_TOKEN_URI_ENTRYPOINT) + flowERC721Config.evaluableConfig.bytecode, SourceIndexV2.unwrap(FLOW_ERC721_TOKEN_URI_ENTRYPOINT) ) > 0; sEvalHandleTransfer = evalHandleTransfer; sEvalTokenURI = evalTokenURI; @@ -116,10 +114,10 @@ contract FlowERC721 is ICloneableV2, IFlowERC721V4, FlowCommon, ERC721 { ? LibUint256Array.arrayFrom(FLOW_ERC721_HANDLE_TRANSFER_MIN_OUTPUTS, FLOW_ERC721_TOKEN_URI_MIN_OUTPUTS) : LibUint256Array.arrayFrom(FLOW_ERC721_HANDLE_TRANSFER_MIN_OUTPUTS); - (IInterpreterV1 interpreter, IInterpreterStoreV1 store, address expression) = flowERC721Config + (IInterpreterV2 interpreter, IInterpreterStoreV2 store, address expression) = flowERC721Config .evaluableConfig .deployer - .deployExpression( + .deployExpression2( flowERC721Config.evaluableConfig.bytecode, flowERC721Config.evaluableConfig.constants, minOutputs ); // There's no way to set this before the external call because the @@ -129,7 +127,7 @@ contract FlowERC721 is ICloneableV2, IFlowERC721V4, FlowCommon, ERC721 { // integrity checks are complete. // The deployer MUST be a trusted contract anyway. // slither-disable-next-line reentrancy-benign - sEvaluable = Evaluable(interpreter, store, expression); + sEvaluable = EvaluableV2(interpreter, store, expression); } return ICLONEABLE_V2_SUCCESS; @@ -151,11 +149,11 @@ contract FlowERC721 is ICloneableV2, IFlowERC721V4, FlowCommon, ERC721 { /// @inheritdoc ERC721 function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (sEvalTokenURI) { - Evaluable memory evaluable = sEvaluable; - (uint256[] memory stack, uint256[] memory kvs) = evaluable.interpreter.eval( + EvaluableV2 memory evaluable = sEvaluable; + (uint256[] memory stack, uint256[] memory kvs) = evaluable.interpreter.eval2( evaluable.store, DEFAULT_STATE_NAMESPACE, - LibEncodedDispatch.encode( + LibEncodedDispatch.encode2( evaluable.expression, FLOW_ERC721_TOKEN_URI_ENTRYPOINT, FLOW_ERC721_TOKEN_URI_MAX_OUTPUTS ), LibContext.build(LibUint256Array.arrayFrom(tokenId).matrixFrom(), new SignedContextV1[](0)) @@ -169,13 +167,13 @@ contract FlowERC721 is ICloneableV2, IFlowERC721V4, FlowCommon, ERC721 { return super.tokenURI(tokenId); } - /// @inheritdoc IFlowERC721V4 + /// @inheritdoc IFlowERC721V5 function stackToFlow(uint256[] memory stack) external pure virtual override returns (FlowERC721IOV1 memory) { return _stackToFlow(stack.dataPointer(), stack.endPointer()); } - /// @inheritdoc IFlowERC721V4 - function flow(Evaluable memory evaluable, uint256[] memory callerContext, SignedContextV1[] memory signedContexts) + /// @inheritdoc IFlowERC721V5 + function flow(EvaluableV2 memory evaluable, uint256[] memory callerContext, SignedContextV1[] memory signedContexts) external virtual returns (FlowERC721IOV1 memory) @@ -200,11 +198,11 @@ contract FlowERC721 is ICloneableV2, IFlowERC721V4, FlowCommon, ERC721 { // Mint and burn access MUST be handled by flow. // HANDLE_TRANSFER will only restrict subsequent transfers. if (sEvalHandleTransfer && !(from == address(0) || to == address(0))) { - Evaluable memory evaluable = sEvaluable; - (uint256[] memory stack, uint256[] memory kvs) = evaluable.interpreter.eval( + EvaluableV2 memory evaluable = sEvaluable; + (uint256[] memory stack, uint256[] memory kvs) = evaluable.interpreter.eval2( evaluable.store, DEFAULT_STATE_NAMESPACE, - LibEncodedDispatch.encode( + LibEncodedDispatch.encode2( evaluable.expression, FLOW_ERC721_HANDLE_TRANSFER_ENTRYPOINT, FLOW_ERC721_HANDLE_TRANSFER_MAX_OUTPUTS @@ -261,7 +259,7 @@ contract FlowERC721 is ICloneableV2, IFlowERC721V4, FlowCommon, ERC721 { /// from the stack as additional sentinel separated tuples. The mints are /// consumed first, then the burns, then the remaining stack is converted to /// a flow as normal. - function _flow(Evaluable memory evaluable, uint256[] memory callerContext, SignedContextV1[] memory signedContexts) + function _flow(EvaluableV2 memory evaluable, uint256[] memory callerContext, SignedContextV1[] memory signedContexts) internal virtual nonReentrant diff --git a/src/interface/deprecated/v2/IFlowV2.sol b/src/interface/deprecated/v2/IFlowV2.sol index aaa62197..cb1e9d53 100644 --- a/src/interface/deprecated/v2/IFlowV2.sol +++ b/src/interface/deprecated/v2/IFlowV2.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: CAL pragma solidity ^0.8.18; +import {Evaluable, EvaluableConfig} from "rain.interpreter.interface/interface/deprecated/IInterpreterCallerV1.sol"; import "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; import "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; diff --git a/src/interface/deprecated/v3/IFlowERC20V3.sol b/src/interface/deprecated/v3/IFlowERC20V3.sol index bb4d93ef..0c191742 100644 --- a/src/interface/deprecated/v3/IFlowERC20V3.sol +++ b/src/interface/deprecated/v3/IFlowERC20V3.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: CAL pragma solidity ^0.8.18; -import "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; -import "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; +import {SourceIndex} from "rain.interpreter.interface/interface/deprecated/IInterpreterV1.sol"; +import {EvaluableConfig, Evaluable} from "rain.interpreter.interface/interface/deprecated/IInterpreterCallerV1.sol"; +import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; import {Sentinel} from "rain.solmem/lib/LibStackSentinel.sol"; import {MIN_FLOW_SENTINELS, SENTINEL_HIGH_BITS, FlowTransferV1} from "./IFlowV3.sol"; diff --git a/src/interface/deprecated/v3/IFlowV3.sol b/src/interface/deprecated/v3/IFlowV3.sol index 6fef197d..f305d4f9 100644 --- a/src/interface/deprecated/v3/IFlowV3.sol +++ b/src/interface/deprecated/v3/IFlowV3.sol @@ -7,22 +7,6 @@ import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreter import "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; import {Sentinel} from "rain.solmem/lib/LibStackSentinel.sol"; -/// Thrown when the flow being evaluated is unregistered. -/// @param unregisteredHash Hash of the unregistered flow. -error UnregisteredFlow(bytes32 unregisteredHash); - -/// Thrown for unsupported native transfers. -error UnsupportedNativeFlow(); - -/// Thrown for unsupported erc20 transfers. -error UnsupportedERC20Flow(); - -/// Thrown for unsupported erc721 transfers. -error UnsupportedERC721Flow(); - -/// Thrown for unsupported erc1155 transfers. -error UnsupportedERC1155Flow(); - /// @dev The number of sentinels required by `FlowCommon`. An evaluable can never /// have fewer minimum outputs than required sentinels. uint256 constant MIN_FLOW_SENTINELS = 3; diff --git a/src/interface/deprecated/v4/IFlowERC1155V4.sol b/src/interface/deprecated/v4/IFlowERC1155V4.sol index 4c2cdcb1..37100940 100644 --- a/src/interface/deprecated/v4/IFlowERC1155V4.sol +++ b/src/interface/deprecated/v4/IFlowERC1155V4.sol @@ -13,7 +13,7 @@ import { FLOW_ERC1155_HANDLE_TRANSFER_ENTRYPOINT, FLOW_ERC1155_HANDLE_TRANSFER_MIN_OUTPUTS, FLOW_ERC1155_MIN_FLOW_SENTINELS -} from "../IFlowERC1155V3.sol"; +} from "../v3/IFlowERC1155V3.sol"; /// Initialization config. /// @param uri As per Open Zeppelin `ERC1155Upgradeable`. diff --git a/src/interface/deprecated/v4/IFlowERC20V4.sol b/src/interface/deprecated/v4/IFlowERC20V4.sol index 728e093a..873424b1 100644 --- a/src/interface/deprecated/v4/IFlowERC20V4.sol +++ b/src/interface/deprecated/v4/IFlowERC20V4.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: CAL pragma solidity ^0.8.18; +import {Evaluable, EvaluableConfigV2} from "rain.interpreter.interface/interface/deprecated/IInterpreterCallerV1.sol"; import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; -import {EvaluableV2} from "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; import {Sentinel} from "rain.solmem/lib/LibStackSentinel.sol"; import { FlowERC20IOV1, @@ -11,7 +11,7 @@ import { FLOW_ERC20_HANDLE_TRANSFER_MIN_OUTPUTS, FLOW_ERC20_HANDLE_TRANSFER_MAX_OUTPUTS, FLOW_ERC20_MIN_FLOW_SENTINELS -} from "../IFlowERC20V3.sol"; +} from "../v3/IFlowERC20V3.sol"; import {RAIN_FLOW_SENTINEL} from "./IFlowV4.sol"; /// Initialization config. diff --git a/src/interface/deprecated/v4/IFlowERC721V4.sol b/src/interface/deprecated/v4/IFlowERC721V4.sol index d76a94a2..789d7e25 100644 --- a/src/interface/deprecated/v4/IFlowERC721V4.sol +++ b/src/interface/deprecated/v4/IFlowERC721V4.sol @@ -1,7 +1,8 @@ // SPDX-License-Identifier: CAL pragma solidity ^0.8.18; -import "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; +import {Evaluable, EvaluableConfigV2} from "rain.interpreter.interface/interface/deprecated/IInterpreterCallerV1.sol"; +import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; import "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; import { @@ -14,7 +15,7 @@ import { FLOW_ERC721_TOKEN_URI_ENTRYPOINT, FLOW_ERC721_HANDLE_TRANSFER_ENTRYPOINT, FLOW_ERC721_MIN_FLOW_SENTINELS -} from "../IFlowERC721V3.sol"; +} from "../v3/IFlowERC721V3.sol"; import {RAIN_FLOW_SENTINEL} from "./IFlowV4.sol"; diff --git a/src/interface/deprecated/v4/IFlowV4.sol b/src/interface/deprecated/v4/IFlowV4.sol index 27998b5e..d0e66fc5 100644 --- a/src/interface/deprecated/v4/IFlowV4.sol +++ b/src/interface/deprecated/v4/IFlowV4.sol @@ -12,12 +12,8 @@ import { ERC721Transfer, ERC1155Transfer, RAIN_FLOW_SENTINEL, - UnregisteredFlow, - UnsupportedERC20Flow, - UnsupportedERC721Flow, - UnsupportedERC1155Flow, MIN_FLOW_SENTINELS -} from "../IFlowV3.sol"; +} from "../v3/IFlowV3.sol"; /// @title IFlowV4 /// @notice Interface for a flow contract that does NOT require native minting diff --git a/src/interface/unstable/IFlowERC1155V5.sol b/src/interface/unstable/IFlowERC1155V5.sol index 4c2cdcb1..aa1c8e51 100644 --- a/src/interface/unstable/IFlowERC1155V5.sol +++ b/src/interface/unstable/IFlowERC1155V5.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.18; import {SignedContextV1, EvaluableConfigV3} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; import {EvaluableV2} from "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; import {Sentinel} from "rain.solmem/lib/LibStackSentinel.sol"; -import {RAIN_FLOW_SENTINEL} from "./IFlowV4.sol"; +import {RAIN_FLOW_SENTINEL} from "./IFlowV5.sol"; import { FlowERC1155IOV1, @@ -13,7 +13,7 @@ import { FLOW_ERC1155_HANDLE_TRANSFER_ENTRYPOINT, FLOW_ERC1155_HANDLE_TRANSFER_MIN_OUTPUTS, FLOW_ERC1155_MIN_FLOW_SENTINELS -} from "../IFlowERC1155V3.sol"; +} from "../deprecated/v4/IFlowERC1155V4.sol"; /// Initialization config. /// @param uri As per Open Zeppelin `ERC1155Upgradeable`. diff --git a/src/interface/unstable/IFlowERC20V5.sol b/src/interface/unstable/IFlowERC20V5.sol index 190c1cd4..feca5cf7 100644 --- a/src/interface/unstable/IFlowERC20V5.sol +++ b/src/interface/unstable/IFlowERC20V5.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: CAL pragma solidity ^0.8.18; -import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; +import {SignedContextV1, EvaluableConfigV3} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; import {EvaluableV2} from "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; import {Sentinel} from "rain.solmem/lib/LibStackSentinel.sol"; import { @@ -11,8 +11,8 @@ import { FLOW_ERC20_HANDLE_TRANSFER_MIN_OUTPUTS, FLOW_ERC20_HANDLE_TRANSFER_MAX_OUTPUTS, FLOW_ERC20_MIN_FLOW_SENTINELS -} from "../IFlowERC20V3.sol"; -import {RAIN_FLOW_SENTINEL} from "./IFlowV4.sol"; +} from "../deprecated/v4/IFlowERC20V4.sol"; +import {RAIN_FLOW_SENTINEL} from "./IFlowV5.sol"; /// Initialization config. /// @param name As per Open Zeppelin `ERC20Upgradeable`. @@ -24,8 +24,8 @@ import {RAIN_FLOW_SENTINEL} from "./IFlowV4.sol"; struct FlowERC20ConfigV2 { string name; string symbol; - EvaluableConfigV2 evaluableConfig; - EvaluableConfigV2[] flowConfig; + EvaluableConfigV3 evaluableConfig; + EvaluableConfigV3[] flowConfig; } /// @title IFlowERC20V5 @@ -62,7 +62,7 @@ interface IFlowERC20V5 { /// @return flowERC20IO The `FlowERC20IOV1` representing all token mint/burns /// and transfers that occurred during the flow. function flow( - Evaluable calldata evaluable, + EvaluableV2 calldata evaluable, uint256[] calldata callerContext, SignedContextV1[] calldata signedContexts ) external returns (FlowERC20IOV1 calldata flowERC20IO); diff --git a/src/interface/unstable/IFlowERC721V5.sol b/src/interface/unstable/IFlowERC721V5.sol index d76a94a2..2032c143 100644 --- a/src/interface/unstable/IFlowERC721V5.sol +++ b/src/interface/unstable/IFlowERC721V5.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: CAL pragma solidity ^0.8.18; -import "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; -import "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; +import {SignedContextV1, EvaluableConfigV3} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol"; +import {EvaluableV2} from "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; import { FlowERC721IOV1, @@ -14,32 +14,28 @@ import { FLOW_ERC721_TOKEN_URI_ENTRYPOINT, FLOW_ERC721_HANDLE_TRANSFER_ENTRYPOINT, FLOW_ERC721_MIN_FLOW_SENTINELS -} from "../IFlowERC721V3.sol"; +} from "../deprecated/v4/IFlowERC721V4.sol"; -import {RAIN_FLOW_SENTINEL} from "./IFlowV4.sol"; - -/// Thrown when burner of tokens is not the owner of tokens. -error BurnerNotOwner(); +import {RAIN_FLOW_SENTINEL} from "../deprecated/v4/IFlowV4.sol"; /// Initialization config. /// @param name As per Open Zeppelin `ERC721Upgradeable`. /// @param symbol As per Open Zeppelin `ERC721Upgradeable`. /// @param baseURI As per Open Zeppelin `ERC721Upgradeable`. -/// @param evaluableConfig The `EvaluableConfigV2` to use to build the -/// `evaluable` that can be used to handle transfers and build token IDs for the -/// token URI. +/// @param evaluableConfig Config to use to build the `evaluable` that can be +/// used to handle transfers and build token IDs for the token URI. /// @param flowConfig Initialization config for the `Evaluable`s that define the /// flow behaviours outside self mints/burns. struct FlowERC721ConfigV2 { string name; string symbol; string baseURI; - EvaluableConfigV2 evaluableConfig; - EvaluableConfigV2[] flowConfig; + EvaluableConfigV3 evaluableConfig; + EvaluableConfigV3[] flowConfig; } -/// @title IFlowERC721V4 -/// Conceptually identical to `IFlowV4`, but the flow contract itself is an +/// @title IFlowERC721V5 +/// Conceptually identical to `IFlowV5`, but the flow contract itself is an /// ERC721 token. This means that ERC721 self mints and burns are included in the /// stack that the flows must evaluate to. As stacks are processed by flow from /// bottom to top, this means that the self mint/burn will be the last thing @@ -57,8 +53,8 @@ struct FlowERC721ConfigV2 { /// optional, and if not provided the token URI will be the default Open Zeppelin /// token URI logic. /// -/// Otherwise the flow contract is identical to `IFlowV4`. -interface IFlowERC721V4 { +/// Otherwise the flow contract is identical to `IFlowV5`. +interface IFlowERC721V5 { /// Contract has initialized. /// @param sender `msg.sender` initializing the contract (factory). /// @param config All initialized config. @@ -76,7 +72,7 @@ interface IFlowERC721V4 { /// @return flowERC721IO The `FlowERC721IOV1` representing all token /// mint/burns and transfers that occurred during the flow. function flow( - Evaluable calldata evaluable, + EvaluableV2 calldata evaluable, uint256[] calldata callerContext, SignedContextV1[] calldata signedContexts ) external returns (FlowERC721IOV1 calldata flowERC721IO); diff --git a/src/interface/unstable/IFlowV5.sol b/src/interface/unstable/IFlowV5.sol index 27998b5e..97e6cd97 100644 --- a/src/interface/unstable/IFlowV5.sol +++ b/src/interface/unstable/IFlowV5.sol @@ -12,12 +12,11 @@ import { ERC721Transfer, ERC1155Transfer, RAIN_FLOW_SENTINEL, - UnregisteredFlow, - UnsupportedERC20Flow, - UnsupportedERC721Flow, - UnsupportedERC1155Flow, MIN_FLOW_SENTINELS -} from "../IFlowV3.sol"; +} from "../deprecated/v4/IFlowV4.sol"; +import { + UnregisteredFlow +} from "../../error/ErrFlow.sol"; /// @title IFlowV4 /// @notice Interface for a flow contract that does NOT require native minting diff --git a/src/lib/LibFlow.sol b/src/lib/LibFlow.sol index 0d170f81..5be3e153 100644 --- a/src/lib/LibFlow.sol +++ b/src/lib/LibFlow.sol @@ -1,17 +1,14 @@ // SPDX-License-Identifier: CAL pragma solidity ^0.8.18; -import {IFlowV4, RAIN_FLOW_SENTINEL} from "../interface/unstable/IFlowV4.sol"; +import {IFlowV4, RAIN_FLOW_SENTINEL} from "../interface/unstable/IFlowV5.sol"; import {Pointer} from "rain.solmem/lib/LibPointer.sol"; import { FlowTransferV1, ERC20Transfer, ERC721Transfer, - ERC1155Transfer, - UnsupportedERC20Flow, - UnsupportedERC721Flow, - UnsupportedERC1155Flow -} from "../interface/unstable/IFlowV4.sol"; + ERC1155Transfer +} from "../interface/unstable/IFlowV5.sol"; import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/unstable/IInterpreterStoreV2.sol"; import {LibStackSentinel} from "rain.solmem/lib/LibStackSentinel.sol"; import {DEFAULT_STATE_NAMESPACE} from "rain.interpreter.interface/interface/unstable/IInterpreterV2.sol"; @@ -20,6 +17,11 @@ import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; import {IERC721} from "openzeppelin-contracts/contracts/token/ERC721/IERC721.sol"; import {IERC1155} from "openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol"; +import { + UnsupportedERC20Flow, + UnsupportedERC721Flow, + UnsupportedERC1155Flow +} from "../error/ErrFlow.sol"; /// @title LibFlow /// Standard processing used by all variants of `Flow`. These utilities can't diff --git a/test/interface/unstable/IFlowV4.t.sol b/test/interface/unstable/IFlowV4.t.sol index b6325e5e..9ea6c4d2 100644 --- a/test/interface/unstable/IFlowV4.t.sol +++ b/test/interface/unstable/IFlowV4.t.sol @@ -3,7 +3,7 @@ pragma solidity =0.8.19; import "forge-std/Test.sol"; -import {IFlowV4, RAIN_FLOW_SENTINEL} from "src/interface/unstable/IFlowV4.sol"; +import {IFlowV4, RAIN_FLOW_SENTINEL} from "src/interface/deprecated/v4/IFlowV4.sol"; import {Sentinel} from "rain.solmem/lib/LibStackSentinel.sol"; contract IFlowV4Test is Test {