Skip to content

Commit

Permalink
v5 1155
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidmeister committed Feb 28, 2024
1 parent 2ad3e61 commit 79b567f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
20 changes: 10 additions & 10 deletions src/concrete/erc1155/FlowERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ import {ICloneableV2, ICLONEABLE_V2_SUCCESS} from "rain.factory/src/interface/IC
import {LibUint256Array} from "rain.solmem/lib/LibUint256Array.sol";
import {LibUint256Matrix} from "rain.solmem/lib/LibUint256Matrix.sol";
import {
IFlowERC1155V4,
IFlowERC1155V5,
FlowERC1155IOV1,
SignedContextV1,
FlowERC1155ConfigV2,
FlowERC1155ConfigV3,
ERC1155SupplyChange,
RAIN_FLOW_SENTINEL,
FLOW_ERC1155_HANDLE_TRANSFER_ENTRYPOINT,
FLOW_ERC1155_HANDLE_TRANSFER_MAX_OUTPUTS,
FLOW_ERC1155_HANDLE_TRANSFER_MIN_OUTPUTS,
FLOW_ERC1155_MIN_FLOW_SENTINELS
FLOW_ERC1155_MIN_FLOW_SENTINELS,
EvaluableV2
} from "../../interface/unstable/IFlowERC1155V5.sol";
import {LibBytecode} from "rain.interpreter.interface/lib/bytecode/LibBytecode.sol";
import {
IInterpreterV2, DEFAULT_STATE_NAMESPACE
} from "rain.interpreter.interface/interface/unstable/IInterpreterV2.sol";
import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/unstable/IInterpreterStoreV2.sol";
import {EvaluableV2} from "rain.interpreter.interface/lib/caller/LibEvaluable.sol";
import {Pointer} from "rain.solmem/lib/LibPointer.sol";
import {LibFlow} from "../../lib/LibFlow.sol";
import {SourceIndexV2} from "rain.interpreter.interface/interface/unstable/IInterpreterV2.sol";
Expand All @@ -36,8 +36,8 @@ import {LibNamespace, StateNamespace} from "rain.interpreter.interface/lib/ns/Li
import {InsufficientHandleTransferOutputs, UnsupportedHandleTransferInputs} from "../../error/ErrFlow.sol";

/// @title FlowERC1155
/// See `IFlowERC1155V4` for documentation.
contract FlowERC1155 is ICloneableV2, IFlowERC1155V4, FlowCommon, ERC1155 {
/// See `IFlowERC1155V5` for documentation.
contract FlowERC1155 is ICloneableV2, IFlowERC1155V5, FlowCommon, ERC1155 {
using LibStackSentinel for Pointer;
using LibUint256Matrix for uint256[];
using LibUint256Array for uint256[];
Expand All @@ -51,13 +51,13 @@ contract FlowERC1155 is ICloneableV2, IFlowERC1155V4, FlowCommon, ERC1155 {

/// Overloaded typed initialize function MUST revert with this error.
/// As per `ICloneableV2` interface.
function initialize(FlowERC1155ConfigV2 memory) external pure {
function initialize(FlowERC1155ConfigV3 memory) external pure {
revert InitializeSignatureFn();
}

/// @inheritdoc ICloneableV2
function initialize(bytes calldata data) external initializer returns (bytes32) {
FlowERC1155ConfigV2 memory flowERC1155Config = abi.decode(data, (FlowERC1155ConfigV2));
FlowERC1155ConfigV3 memory flowERC1155Config = abi.decode(data, (FlowERC1155ConfigV3));
emit Initialize(msg.sender, flowERC1155Config);
__ERC1155_init(flowERC1155Config.uri);

Expand Down Expand Up @@ -169,7 +169,7 @@ contract FlowERC1155 is ICloneableV2, IFlowERC1155V4, FlowCommon, ERC1155 {
}
}

/// @inheritdoc IFlowERC1155V4
/// @inheritdoc IFlowERC1155V5
function stackToFlow(uint256[] memory stack)
external
pure
Expand All @@ -179,7 +179,7 @@ contract FlowERC1155 is ICloneableV2, IFlowERC1155V4, FlowCommon, ERC1155 {
return _stackToFlow(stack.dataPointer(), stack.endPointer());
}

/// @inheritdoc IFlowERC1155V4
/// @inheritdoc IFlowERC1155V5
function flow(EvaluableV2 memory evaluable, uint256[] memory callerContext, SignedContextV1[] memory signedContexts)
external
virtual
Expand Down
9 changes: 5 additions & 4 deletions src/interface/deprecated/v4/IFlowERC1155V4.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: CAL
pragma solidity ^0.8.18;

import {SignedContextV1, EvaluableConfigV3} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol";
import {EvaluableConfigV2, Evaluable} 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 {RAIN_FLOW_SENTINEL} from "./IFlowV4.sol";
Expand All @@ -23,8 +24,8 @@ import {
/// flow behaviours outside self mints/burns.
struct FlowERC1155ConfigV2 {
string uri;
EvaluableConfigV3 evaluableConfig;
EvaluableConfigV3[] flowConfig;
EvaluableConfigV2 evaluableConfig;
EvaluableConfigV2[] flowConfig;
}

/// @title IFlowERC1155V4
Expand Down Expand Up @@ -61,7 +62,7 @@ interface IFlowERC1155V4 {
/// @return flowERC1155IO The `FlowERC1155IOV1` representing all token
/// mint/burns and transfers that occurred during the flow.
function flow(
EvaluableV2 calldata evaluable,
Evaluable calldata evaluable,
uint256[] calldata callerContext,
SignedContextV1[] calldata signedContexts
) external returns (FlowERC1155IOV1 calldata);
Expand Down
16 changes: 8 additions & 8 deletions src/interface/unstable/IFlowERC1155V5.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ SourceIndexV2 constant FLOW_ERC1155_HANDLE_TRANSFER_ENTRYPOINT = SourceIndexV2.w

/// Initialization config.
/// @param uri As per Open Zeppelin `ERC1155Upgradeable`.
/// @param evaluableConfig The `EvaluableConfigV2` to use to build the
/// `evaluable` that can be used to handle transfers.
/// @param evaluableConfig Config to use to build the `evaluable` that can be
/// used to handle transfers.
/// @param flowConfig Initialization config for the `Evaluable`s that define the
/// flow behaviours outside self mints/burns.
struct FlowERC1155ConfigV2 {
struct FlowERC1155ConfigV3 {
string uri;
EvaluableConfigV3 evaluableConfig;
EvaluableConfigV3[] flowConfig;
}

/// @title IFlowERC1155V4
/// Conceptually identical to `IFlowV4`, but the flow contract itself is an
/// @title IFlowERC1155V5
/// Conceptually identical to `IFlowV5`, but the flow contract itself is an
/// ERC1155 token. This means that ERC1155 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
Expand All @@ -42,12 +42,12 @@ struct FlowERC1155ConfigV2 {
/// allows expression authors to prevent transfers from occurring if they don't
/// want them to, by reverting within the expression.
///
/// Otherwise the flow contract is identical to `IFlowV4`.
interface IFlowERC1155V4 {
/// Otherwise the flow contract is identical to `IFlowV5`.
interface IFlowERC1155V5 {
/// Contract has initialized.
/// @param sender `msg.sender` initializing the contract (factory).
/// @param config All initialized config.
event Initialize(address sender, FlowERC1155ConfigV2 config);
event Initialize(address sender, FlowERC1155ConfigV3 config);

/// As per `IFlowV4` but returns a `FlowERC1155IOV1` instead of a
/// `FlowTransferV1`.
Expand Down

0 comments on commit 79b567f

Please sign in to comment.