From f4aa99b6f3a9293ec6a64041a76ed4adcdd95ec2 Mon Sep 17 00:00:00 2001 From: LexLuthr Date: Fri, 31 Jan 2025 14:07:19 +0530 Subject: [PATCH] make contract immutable --- market/ipni/ipni-provider/ipni-provider.go | 6 + market/ipni/ipni-provider/spark.go | 25 +- .../sol/contracts/MinerPeerIDMapping.sol | 35 +- .../spark/sol/deployments/mainnet/.chainId | 1 + .../mainnet/MinerPeerIDMapping.json | 414 ++++++++++++++++++ .../4e4cab9ef25a7e1e2da858f2991af0c6.json | 75 ++++ market/ipni/spark/sol/hardhat.config.ts | 1 + market/ipni/spark/sol/package-lock.json | 8 +- market/ipni/spark/sol/package.json | 2 +- market/ipni/spark/spark.go | 13 +- 10 files changed, 531 insertions(+), 49 deletions(-) create mode 100644 market/ipni/spark/sol/deployments/mainnet/.chainId create mode 100644 market/ipni/spark/sol/deployments/mainnet/MinerPeerIDMapping.json create mode 100644 market/ipni/spark/sol/deployments/mainnet/solcInputs/4e4cab9ef25a7e1e2da858f2991af0c6.json diff --git a/market/ipni/ipni-provider/ipni-provider.go b/market/ipni/ipni-provider/ipni-provider.go index 5474c08c5..d14cb3563 100644 --- a/market/ipni/ipni-provider/ipni-provider.go +++ b/market/ipni/ipni-provider/ipni-provider.go @@ -11,6 +11,7 @@ import ( "strings" "time" + "github.com/filecoin-project/curio/build" "github.com/go-chi/chi/v5" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" @@ -456,6 +457,11 @@ func Routes(r *chi.Mux, p *Provider) { // StartPublishing starts a poller which publishes the head for each provider every 10 minutes. func (p *Provider) StartPublishing(ctx context.Context) { + // Do not publish for any network except mainnet + if build.BuildType != build.BuildMainnet { + return + } + // A poller which publishes head for each provider // every 10 minutes ticker := time.NewTicker(publishInterval) diff --git a/market/ipni/ipni-provider/spark.go b/market/ipni/ipni-provider/spark.go index 670fae6b7..21b52a85e 100644 --- a/market/ipni/ipni-provider/spark.go +++ b/market/ipni/ipni-provider/spark.go @@ -107,15 +107,34 @@ func (p *Provider) updateSparkContract(ctx context.Context) error { return xerrors.Errorf("failed to get spark params for %s: %w", pInfo.Miner.String(), err) } } else { - pd := spark.SparkMessage{} + pd := struct { + PeerID string + SignedMessage []byte + }{} err = parsedABI.UnpackIntoInterface(&pd, "getPeerData", res.MsgRct.Return) if err != nil { log.Fatalf("Failed to unpack result: %v", err) } - if pd.Peer == pInfo.ID.String() { - continue + if pd.PeerID == pInfo.ID.String() { + detail := spark.SparkMessage{ + Miner: pInfo.SPID, + Peer: pInfo.ID.String(), + } + + jdetail, err := json.Marshal(detail) + if err != nil { + return xerrors.Errorf("failed to marshal spark message: %w", err) + } + + ok, err := pKey.GetPublic().Verify(jdetail, pd.SignedMessage) + if err != nil { + return xerrors.Errorf("failed to verify signed message: %w", err) + } + if ok { + continue + } } params, err = p.getSparkParams(pInfo.SPID, pInfo.ID.String(), pKey, "update") diff --git a/market/ipni/spark/sol/contracts/MinerPeerIDMapping.sol b/market/ipni/spark/sol/contracts/MinerPeerIDMapping.sol index 5c365689e..140eab5c0 100644 --- a/market/ipni/spark/sol/contracts/MinerPeerIDMapping.sol +++ b/market/ipni/spark/sol/contracts/MinerPeerIDMapping.sol @@ -10,36 +10,15 @@ contract MinerPeerIDMapping { bytes signedMessage; } - // State variables - address public owner; mapping(uint64 => PeerData) public minerToPeerData; // Events event PeerDataAdded(uint64 indexed minerID, string peerID); event PeerDataUpdated(uint64 indexed minerID, string oldPeerID, string newPeerID); event PeerDataDeleted(uint64 indexed minerID); - event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); - // Modifier to restrict access to the owner - modifier onlyOwner() { - require(msg.sender == owner, "Caller is not the owner"); - _; - } - - // Constructor: Set the deployer as the initial owner constructor() { - owner = msg.sender; - emit OwnershipTransferred(address(0), msg.sender); - } - - /** - * @notice Transfer ownership to a new address. - * @param newOwner The address of the new owner. - */ - function transferOwnership(address newOwner) public onlyOwner { - require(newOwner != address(0), "New owner is the zero address"); - emit OwnershipTransferred(owner, newOwner); - owner = newOwner; + // The contract is immutable from the owner now, no ownership transfer is possible } /** @@ -55,9 +34,7 @@ contract MinerPeerIDMapping { ) public { require(bytes(minerToPeerData[minerID].peerID).length == 0, "Peer data already exists for this MinerID"); - if (msg.sender != owner) { - require(isControllingAddress(msg.sender, minerID), "Caller is not the controlling address"); - } + require(isControllingAddress(msg.sender, minerID), "Caller is not the controlling address"); minerToPeerData[minerID] = PeerData(newPeerID, signedMessage); @@ -77,9 +54,7 @@ contract MinerPeerIDMapping { ) public { require(bytes(minerToPeerData[minerID].peerID).length > 0, "No peer data exists for this MinerID"); - if (msg.sender != owner) { - require(isControllingAddress(msg.sender, minerID), "Caller is not the controlling address"); - } + require(isControllingAddress(msg.sender, minerID), "Caller is not the controlling address"); string memory oldPeerID = minerToPeerData[minerID].peerID; minerToPeerData[minerID] = PeerData(newPeerID, signedMessage); @@ -94,9 +69,7 @@ contract MinerPeerIDMapping { function deletePeerData(uint64 minerID) public { require(bytes(minerToPeerData[minerID].peerID).length > 0, "No peer data exists for this MinerID"); - if (msg.sender != owner) { - require(isControllingAddress(msg.sender, minerID), "Caller is not the controlling address"); - } + require(isControllingAddress(msg.sender, minerID), "Caller is not the controlling address"); delete minerToPeerData[minerID]; diff --git a/market/ipni/spark/sol/deployments/mainnet/.chainId b/market/ipni/spark/sol/deployments/mainnet/.chainId new file mode 100644 index 000000000..c0d6976f6 --- /dev/null +++ b/market/ipni/spark/sol/deployments/mainnet/.chainId @@ -0,0 +1 @@ +314 \ No newline at end of file diff --git a/market/ipni/spark/sol/deployments/mainnet/MinerPeerIDMapping.json b/market/ipni/spark/sol/deployments/mainnet/MinerPeerIDMapping.json new file mode 100644 index 000000000..5eb53cfee --- /dev/null +++ b/market/ipni/spark/sol/deployments/mainnet/MinerPeerIDMapping.json @@ -0,0 +1,414 @@ +{ + "address": "0x599172a7654E47f070576ca7e56Ab9564FbD4041", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "errorCode", + "type": "int256" + } + ], + "name": "ActorError", + "type": "error" + }, + { + "inputs": [], + "name": "ActorNotFound", + "type": "error" + }, + { + "inputs": [], + "name": "FailToCallActor", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "CommonTypes.FilActorId", + "name": "actorId", + "type": "uint64" + } + ], + "name": "InvalidActorID", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "name": "InvalidCodec", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidResponseLength", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "NotEnoughBalance", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint64", + "name": "minerID", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "string", + "name": "peerID", + "type": "string" + } + ], + "name": "PeerDataAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint64", + "name": "minerID", + "type": "uint64" + } + ], + "name": "PeerDataDeleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint64", + "name": "minerID", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "string", + "name": "oldPeerID", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "newPeerID", + "type": "string" + } + ], + "name": "PeerDataUpdated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "minerID", + "type": "uint64" + }, + { + "internalType": "string", + "name": "newPeerID", + "type": "string" + }, + { + "internalType": "bytes", + "name": "signedMessage", + "type": "bytes" + } + ], + "name": "addPeerData", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "minerID", + "type": "uint64" + } + ], + "name": "deletePeerData", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "minerID", + "type": "uint64" + } + ], + "name": "getPeerData", + "outputs": [ + { + "components": [ + { + "internalType": "string", + "name": "peerID", + "type": "string" + }, + { + "internalType": "bytes", + "name": "signedMessage", + "type": "bytes" + } + ], + "internalType": "struct MinerPeerIDMapping.PeerData", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "name": "minerToPeerData", + "outputs": [ + { + "internalType": "string", + "name": "peerID", + "type": "string" + }, + { + "internalType": "bytes", + "name": "signedMessage", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "minerID", + "type": "uint64" + }, + { + "internalType": "string", + "name": "newPeerID", + "type": "string" + }, + { + "internalType": "bytes", + "name": "signedMessage", + "type": "bytes" + } + ], + "name": "updatePeerData", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xd6ed18238a3acbbe46f1afe332729f89352004e0469897055e2394256310e925", + "receipt": { + "to": null, + "from": "0x8DFd03566Bf1b32eF0AeA70cCf5101870e871412", + "contractAddress": "0x599172a7654E47f070576ca7e56Ab9564FbD4041", + "transactionIndex": 30, + "gasUsed": "88870696", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x46d109e55204c399c2dc648053a0e0636ee43010a3e22842f152026eadcf88b2", + "transactionHash": "0xd6ed18238a3acbbe46f1afe332729f89352004e0469897055e2394256310e925", + "logs": [], + "blockNumber": 4666808, + "cumulativeGasUsed": "0", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "4e4cab9ef25a7e1e2da858f2991af0c6", + "metadata": "{\"compiler\":{\"version\":\"0.8.23+commit.f704f362\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"errorCode\",\"type\":\"int256\"}],\"name\":\"ActorError\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ActorNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FailToCallActor\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"CommonTypes.FilActorId\",\"name\":\"actorId\",\"type\":\"uint64\"}],\"name\":\"InvalidActorID\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"name\":\"InvalidCodec\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidResponseLength\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"NotEnoughBalance\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"minerID\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"peerID\",\"type\":\"string\"}],\"name\":\"PeerDataAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"minerID\",\"type\":\"uint64\"}],\"name\":\"PeerDataDeleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint64\",\"name\":\"minerID\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"oldPeerID\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"newPeerID\",\"type\":\"string\"}],\"name\":\"PeerDataUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"minerID\",\"type\":\"uint64\"},{\"internalType\":\"string\",\"name\":\"newPeerID\",\"type\":\"string\"},{\"internalType\":\"bytes\",\"name\":\"signedMessage\",\"type\":\"bytes\"}],\"name\":\"addPeerData\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"minerID\",\"type\":\"uint64\"}],\"name\":\"deletePeerData\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"minerID\",\"type\":\"uint64\"}],\"name\":\"getPeerData\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"peerID\",\"type\":\"string\"},{\"internalType\":\"bytes\",\"name\":\"signedMessage\",\"type\":\"bytes\"}],\"internalType\":\"struct MinerPeerIDMapping.PeerData\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"name\":\"minerToPeerData\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"peerID\",\"type\":\"string\"},{\"internalType\":\"bytes\",\"name\":\"signedMessage\",\"type\":\"bytes\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"minerID\",\"type\":\"uint64\"},{\"internalType\":\"string\",\"name\":\"newPeerID\",\"type\":\"string\"},{\"internalType\":\"bytes\",\"name\":\"signedMessage\",\"type\":\"bytes\"}],\"name\":\"updatePeerData\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"addPeerData(uint64,string,bytes)\":{\"params\":{\"minerID\":\"The MinerID to associate with the new PeerID.\",\"newPeerID\":\"The new PeerID to bind to the MinerID.\",\"signedMessage\":\"The signed message to store.\"}},\"deletePeerData(uint64)\":{\"params\":{\"minerID\":\"The MinerID whose peer data will be deleted.\"}},\"getPeerData(uint64)\":{\"params\":{\"minerID\":\"The MinerID to query.\"},\"returns\":{\"_0\":\"The PeerID and signed message associated with the MinerID.\"}},\"updatePeerData(uint64,string,bytes)\":{\"params\":{\"minerID\":\"The MinerID whose PeerID will be updated.\",\"newPeerID\":\"The new PeerID to bind to the MinerID.\",\"signedMessage\":\"The new signed message to store.\"}}},\"version\":1},\"userdoc\":{\"errors\":{\"ActorError(int256)\":[{\"notice\":\"the called actor returned an error as part of its expected behaviour\"}],\"ActorNotFound()\":[{\"notice\":\"the actor is not found\"}],\"FailToCallActor()\":[{\"notice\":\"an error happened trying to call the actor\"}],\"InvalidActorID(uint64)\":[{\"notice\":\"the provided actor id is not valid\"}],\"InvalidCodec(uint64)\":[{\"notice\":\"the codec received is not valid\"}],\"InvalidResponseLength()\":[{\"notice\":\"the response received is not correct. In some case no response is expected and we received one, or a response was indeed expected and we received none.\"}],\"NotEnoughBalance(uint256,uint256)\":[{\"notice\":\"the smart contract has no enough balance to transfer\"}]},\"kind\":\"user\",\"methods\":{\"addPeerData(uint64,string,bytes)\":{\"notice\":\"Add a new PeerID and signed message for a MinerID in the contract.\"},\"deletePeerData(uint64)\":{\"notice\":\"Delete an existing PeerID and signed message for a MinerID in the contract.\"},\"getPeerData(uint64)\":{\"notice\":\"Fetch the PeerID and signed message associated with a MinerID.\"},\"updatePeerData(uint64,string,bytes)\":{\"notice\":\"Update an existing PeerID and signed message for a MinerID in the contract.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/MinerPeerIDMapping.sol\":\"MinerPeerIDMapping\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"details\":{\"constantOptimizer\":true,\"cse\":true,\"deduplicate\":true,\"inliner\":true,\"jumpdestRemover\":true,\"orderLiterals\":true,\"peephole\":true,\"simpleCounterForLoopUncheckedIncrement\":true,\"yul\":false},\"runs\":1000},\"remappings\":[]},\"sources\":{\"@ensdomains/buffer/contracts/Buffer.sol\":{\"content\":\"// SPDX-License-Identifier: BSD-2-Clause\\npragma solidity ^0.8.4;\\n\\n/**\\n* @dev A library for working with mutable byte buffers in Solidity.\\n*\\n* Byte buffers are mutable and expandable, and provide a variety of primitives\\n* for appending to them. At any time you can fetch a bytes object containing the\\n* current contents of the buffer. The bytes object should not be stored between\\n* operations, as it may change due to resizing of the buffer.\\n*/\\nlibrary Buffer {\\n /**\\n * @dev Represents a mutable buffer. Buffers have a current value (buf) and\\n * a capacity. The capacity may be longer than the current value, in\\n * which case it can be extended without the need to allocate more memory.\\n */\\n struct buffer {\\n bytes buf;\\n uint capacity;\\n }\\n\\n /**\\n * @dev Initializes a buffer with an initial capacity.\\n * @param buf The buffer to initialize.\\n * @param capacity The number of bytes of space to allocate the buffer.\\n * @return The buffer, for chaining.\\n */\\n function init(buffer memory buf, uint capacity) internal pure returns(buffer memory) {\\n if (capacity % 32 != 0) {\\n capacity += 32 - (capacity % 32);\\n }\\n // Allocate space for the buffer data\\n buf.capacity = capacity;\\n assembly {\\n let ptr := mload(0x40)\\n mstore(buf, ptr)\\n mstore(ptr, 0)\\n let fpm := add(32, add(ptr, capacity))\\n if lt(fpm, ptr) {\\n revert(0, 0)\\n }\\n mstore(0x40, fpm)\\n }\\n return buf;\\n }\\n\\n /**\\n * @dev Initializes a new buffer from an existing bytes object.\\n * Changes to the buffer may mutate the original value.\\n * @param b The bytes object to initialize the buffer with.\\n * @return A new buffer.\\n */\\n function fromBytes(bytes memory b) internal pure returns(buffer memory) {\\n buffer memory buf;\\n buf.buf = b;\\n buf.capacity = b.length;\\n return buf;\\n }\\n\\n function resize(buffer memory buf, uint capacity) private pure {\\n bytes memory oldbuf = buf.buf;\\n init(buf, capacity);\\n append(buf, oldbuf);\\n }\\n\\n /**\\n * @dev Sets buffer length to 0.\\n * @param buf The buffer to truncate.\\n * @return The original buffer, for chaining..\\n */\\n function truncate(buffer memory buf) internal pure returns (buffer memory) {\\n assembly {\\n let bufptr := mload(buf)\\n mstore(bufptr, 0)\\n }\\n return buf;\\n }\\n\\n /**\\n * @dev Appends len bytes of a byte string to a buffer. Resizes if doing so would exceed\\n * the capacity of the buffer.\\n * @param buf The buffer to append to.\\n * @param data The data to append.\\n * @param len The number of bytes to copy.\\n * @return The original buffer, for chaining.\\n */\\n function append(buffer memory buf, bytes memory data, uint len) internal pure returns(buffer memory) {\\n require(len <= data.length);\\n\\n uint off = buf.buf.length;\\n uint newCapacity = off + len;\\n if (newCapacity > buf.capacity) {\\n resize(buf, newCapacity * 2);\\n }\\n\\n uint dest;\\n uint src;\\n assembly {\\n // Memory address of the buffer data\\n let bufptr := mload(buf)\\n // Length of existing buffer data\\n let buflen := mload(bufptr)\\n // Start address = buffer address + offset + sizeof(buffer length)\\n dest := add(add(bufptr, 32), off)\\n // Update buffer length if we're extending it\\n if gt(newCapacity, buflen) {\\n mstore(bufptr, newCapacity)\\n }\\n src := add(data, 32)\\n }\\n\\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 unchecked {\\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 return buf;\\n }\\n\\n /**\\n * @dev Appends a byte string to a buffer. Resizes if doing so would exceed\\n * the capacity of the buffer.\\n * @param buf The buffer to append to.\\n * @param data The data to append.\\n * @return The original buffer, for chaining.\\n */\\n function append(buffer memory buf, bytes memory data) internal pure returns (buffer memory) {\\n return append(buf, data, data.length);\\n }\\n\\n /**\\n * @dev Appends a byte to the buffer. Resizes if doing so would exceed the\\n * capacity of the buffer.\\n * @param buf The buffer to append to.\\n * @param data The data to append.\\n * @return The original buffer, for chaining.\\n */\\n function appendUint8(buffer memory buf, uint8 data) internal pure returns(buffer memory) {\\n uint off = buf.buf.length;\\n uint offPlusOne = off + 1;\\n if (off >= buf.capacity) {\\n resize(buf, offPlusOne * 2);\\n }\\n\\n assembly {\\n // Memory address of the buffer data\\n let bufptr := mload(buf)\\n // Address = buffer address + sizeof(buffer length) + off\\n let dest := add(add(bufptr, off), 32)\\n mstore8(dest, data)\\n // Update buffer length if we extended it\\n if gt(offPlusOne, mload(bufptr)) {\\n mstore(bufptr, offPlusOne)\\n }\\n }\\n\\n return buf;\\n }\\n\\n /**\\n * @dev Appends len bytes of bytes32 to a buffer. Resizes if doing so would\\n * exceed the capacity of the buffer.\\n * @param buf The buffer to append to.\\n * @param data The data to append.\\n * @param len The number of bytes to write (left-aligned).\\n * @return The original buffer, for chaining.\\n */\\n function append(buffer memory buf, bytes32 data, uint len) private pure returns(buffer memory) {\\n uint off = buf.buf.length;\\n uint newCapacity = len + off;\\n if (newCapacity > buf.capacity) {\\n resize(buf, newCapacity * 2);\\n }\\n\\n unchecked {\\n uint mask = (256 ** len) - 1;\\n // Right-align data\\n data = data >> (8 * (32 - len));\\n assembly {\\n // Memory address of the buffer data\\n let bufptr := mload(buf)\\n // Address = buffer address + sizeof(buffer length) + newCapacity\\n let dest := add(bufptr, newCapacity)\\n mstore(dest, or(and(mload(dest), not(mask)), data))\\n // Update buffer length if we extended it\\n if gt(newCapacity, mload(bufptr)) {\\n mstore(bufptr, newCapacity)\\n }\\n }\\n }\\n return buf;\\n }\\n\\n /**\\n * @dev Appends a bytes20 to the buffer. Resizes if doing so would exceed\\n * the capacity of the buffer.\\n * @param buf The buffer to append to.\\n * @param data The data to append.\\n * @return The original buffer, for chhaining.\\n */\\n function appendBytes20(buffer memory buf, bytes20 data) internal pure returns (buffer memory) {\\n return append(buf, bytes32(data), 20);\\n }\\n\\n /**\\n * @dev Appends a bytes32 to the buffer. Resizes if doing so would exceed\\n * the capacity of the buffer.\\n * @param buf The buffer to append to.\\n * @param data The data to append.\\n * @return The original buffer, for chaining.\\n */\\n function appendBytes32(buffer memory buf, bytes32 data) internal pure returns (buffer memory) {\\n return append(buf, data, 32);\\n }\\n\\n /**\\n * @dev Appends a byte to the end of the buffer. Resizes if doing so would\\n * exceed the capacity of the buffer.\\n * @param buf The buffer to append to.\\n * @param data The data to append.\\n * @param len The number of bytes to write (right-aligned).\\n * @return The original buffer.\\n */\\n function appendInt(buffer memory buf, uint data, uint len) internal pure returns(buffer memory) {\\n uint off = buf.buf.length;\\n uint newCapacity = len + off;\\n if (newCapacity > buf.capacity) {\\n resize(buf, newCapacity * 2);\\n }\\n\\n uint mask = (256 ** len) - 1;\\n assembly {\\n // Memory address of the buffer data\\n let bufptr := mload(buf)\\n // Address = buffer address + sizeof(buffer length) + newCapacity\\n let dest := add(bufptr, newCapacity)\\n mstore(dest, or(and(mload(dest), not(mask)), data))\\n // Update buffer length if we extended it\\n if gt(newCapacity, mload(bufptr)) {\\n mstore(bufptr, newCapacity)\\n }\\n }\\n return buf;\\n }\\n}\\n\",\"keccak256\":\"0xd6dd3b0b327288f8e1b711a609f4040fea602e2ad4bba9febdf2f33b4e56eb0c\",\"license\":\"BSD-2-Clause\"},\"@zondax/filecoin-solidity/contracts/v0.8/MinerAPI.sol\":{\"content\":\"/*******************************************************************************\\n * (c) 2022 Zondax AG\\n *\\n * Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n * distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n * See the License for the specific language governing permissions and\\n * limitations under the License.\\n ********************************************************************************/\\n//\\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\\n\\n// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.17;\\n\\nimport \\\"./types/MinerTypes.sol\\\";\\nimport \\\"./types/CommonTypes.sol\\\";\\nimport \\\"./cbor/MinerCbor.sol\\\";\\nimport \\\"./cbor/FilecoinCbor.sol\\\";\\nimport \\\"./cbor/BytesCbor.sol\\\";\\nimport \\\"./utils/Misc.sol\\\";\\nimport \\\"./utils/Actor.sol\\\";\\n\\n/// @title This library is a proxy to a built-in Miner actor. Calling one of its methods will result in a cross-actor call being performed.\\n/// @notice During miner initialization, a miner actor is created on the chain, and this actor gives the miner its ID f0.... The miner actor is in charge of collecting all the payments sent to the miner.\\n/// @dev For more info about the miner actor, please refer to https://lotus.filecoin.io/storage-providers/operate/addresses/\\n/// @author Zondax AG\\nlibrary MinerAPI {\\n using MinerCBOR for *;\\n using FilecoinCBOR for *;\\n using BytesCBOR for bytes;\\n\\n /// @notice Income and returned collateral are paid to this address\\n /// @notice This address is also allowed to change the worker address for the miner\\n /// @param target The miner actor id you want to interact with\\n /// @return the owner address of a Miner\\n function getOwner(CommonTypes.FilActorId target) internal returns (MinerTypes.GetOwnerReturn memory) {\\n bytes memory raw_request = new bytes(0);\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetOwnerMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\\n\\n return result.deserializeGetOwnerReturn();\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n /// @param addr New owner address\\n /// @notice Proposes or confirms a change of owner address.\\n /// @notice If invoked by the current owner, proposes a new owner address for confirmation. If the proposed address is the current owner address, revokes any existing proposal that proposed address.\\n function changeOwnerAddress(CommonTypes.FilActorId target, CommonTypes.FilAddress memory addr) internal {\\n bytes memory raw_request = addr.serializeAddress();\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.ChangeOwnerAddressMethodNum, Misc.CBOR_CODEC, raw_request, 0, false);\\n if (result.length != 0) {\\n revert Actor.InvalidResponseLength();\\n }\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n /// @param addr The \\\"controlling\\\" addresses are the Owner, the Worker, and all Control Addresses.\\n /// @return Whether the provided address is \\\"controlling\\\".\\n function isControllingAddress(CommonTypes.FilActorId target, CommonTypes.FilAddress memory addr) internal returns (bool) {\\n bytes memory raw_request = addr.serializeAddress();\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.IsControllingAddressMethodNum, Misc.CBOR_CODEC, raw_request, 0, true);\\n\\n return result.deserializeBool();\\n }\\n\\n /// @return the miner's sector size.\\n /// @param target The miner actor id you want to interact with\\n /// @dev For more information about sector sizes, please refer to https://spec.filecoin.io/systems/filecoin_mining/sector/#section-systems.filecoin_mining.sector\\n function getSectorSize(CommonTypes.FilActorId target) internal returns (uint64) {\\n bytes memory raw_request = new bytes(0);\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetSectorSizeMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\\n\\n return result.deserializeUint64();\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n /// @notice This is calculated as actor balance - (vesting funds + pre-commit deposit + initial pledge requirement + fee debt)\\n /// @notice Can go negative if the miner is in IP debt.\\n /// @return the available balance of this miner.\\n function getAvailableBalance(CommonTypes.FilActorId target) internal returns (CommonTypes.BigInt memory) {\\n bytes memory raw_request = new bytes(0);\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetAvailableBalanceMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\\n\\n return result.deserializeBytesBigInt();\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n /// @return the funds vesting in this miner as a list of (vesting_epoch, vesting_amount) tuples.\\n function getVestingFunds(CommonTypes.FilActorId target) internal returns (MinerTypes.GetVestingFundsReturn memory) {\\n bytes memory raw_request = new bytes(0);\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetVestingFundsMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\\n\\n return result.deserializeGetVestingFundsReturn();\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n /// @notice Proposes or confirms a change of beneficiary address.\\n /// @notice A proposal must be submitted by the owner, and takes effect after approval of both the proposed beneficiary and current beneficiary, if applicable, any current beneficiary that has time and quota remaining.\\n /// @notice See FIP-0029, https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0029.md\\n function changeBeneficiary(CommonTypes.FilActorId target, MinerTypes.ChangeBeneficiaryParams memory params) internal {\\n bytes memory raw_request = params.serializeChangeBeneficiaryParams();\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.ChangeBeneficiaryMethodNum, Misc.CBOR_CODEC, raw_request, 0, false);\\n if (result.length != 0) {\\n revert Actor.InvalidResponseLength();\\n }\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n /// @notice This method is for use by other actors (such as those acting as beneficiaries), and to abstract the state representation for clients.\\n /// @notice Retrieves the currently active and proposed beneficiary information.\\n function getBeneficiary(CommonTypes.FilActorId target) internal returns (MinerTypes.GetBeneficiaryReturn memory) {\\n bytes memory raw_request = new bytes(0);\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetBeneficiaryMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\\n\\n return result.deserializeGetBeneficiaryReturn();\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n function changeWorkerAddress(CommonTypes.FilActorId target, MinerTypes.ChangeWorkerAddressParams memory params) internal {\\n bytes memory raw_request = params.serializeChangeWorkerAddressParams();\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.ChangeWorkerAddressMethodNum, Misc.CBOR_CODEC, raw_request, 0, false);\\n if (result.length != 0) {\\n revert Actor.InvalidResponseLength();\\n }\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n function changePeerId(CommonTypes.FilActorId target, CommonTypes.FilAddress memory newId) internal {\\n bytes memory raw_request = newId.serializeArrayFilAddress();\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.ChangePeerIDMethodNum, Misc.CBOR_CODEC, raw_request, 0, false);\\n if (result.length != 0) {\\n revert Actor.InvalidResponseLength();\\n }\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n function changeMultiaddresses(CommonTypes.FilActorId target, MinerTypes.ChangeMultiaddrsParams memory params) internal {\\n bytes memory raw_request = params.serializeChangeMultiaddrsParams();\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.ChangeMultiaddrsMethodNum, Misc.CBOR_CODEC, raw_request, 0, false);\\n if (result.length != 0) {\\n revert Actor.InvalidResponseLength();\\n }\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n function repayDebt(CommonTypes.FilActorId target) internal {\\n bytes memory raw_request = new bytes(0);\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.RepayDebtMethodNum, Misc.NONE_CODEC, raw_request, 0, false);\\n if (result.length != 0) {\\n revert Actor.InvalidResponseLength();\\n }\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n function confirmChangeWorkerAddress(CommonTypes.FilActorId target) internal {\\n bytes memory raw_request = new bytes(0);\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.ConfirmChangeWorkerAddressMethodNum, Misc.NONE_CODEC, raw_request, 0, false);\\n if (result.length != 0) {\\n revert Actor.InvalidResponseLength();\\n }\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n function getPeerId(CommonTypes.FilActorId target) internal returns (CommonTypes.FilAddress memory) {\\n bytes memory raw_request = new bytes(0);\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetPeerIDMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\\n\\n return result.deserializeArrayFilAddress();\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n function getMultiaddresses(CommonTypes.FilActorId target) internal returns (MinerTypes.GetMultiaddrsReturn memory) {\\n bytes memory raw_request = new bytes(0);\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetMultiaddrsMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\\n\\n return result.deserializeGetMultiaddrsReturn();\\n }\\n\\n /// @param target The miner actor id you want to interact with\\n /// @param amount the amount you want to withdraw\\n function withdrawBalance(CommonTypes.FilActorId target, CommonTypes.BigInt memory amount) internal returns (CommonTypes.BigInt memory) {\\n bytes memory raw_request = amount.serializeArrayBigInt();\\n\\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.WithdrawBalanceMethodNum, Misc.CBOR_CODEC, raw_request, 0, false);\\n\\n return result.deserializeBytesBigInt();\\n }\\n}\\n\",\"keccak256\":\"0x441de61a7d91510848def8bb0c0acbae12a79973ea604dc82d6a18dd9cb796fb\",\"license\":\"Apache-2.0\"},\"@zondax/filecoin-solidity/contracts/v0.8/cbor/BigIntCbor.sol\":{\"content\":\"/*******************************************************************************\\n * (c) 2022 Zondax AG\\n *\\n * Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n * distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n * See the License for the specific language governing permissions and\\n * limitations under the License.\\n ********************************************************************************/\\n//\\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\\n\\n// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.17;\\n\\nimport \\\"../types/CommonTypes.sol\\\";\\n\\n/// @title This library is a set of functions meant to handle CBOR serialization and deserialization for BigInt type\\n/// @author Zondax AG\\nlibrary BigIntCBOR {\\n /// @notice serialize BigInt instance to bytes\\n /// @param num BigInt instance to serialize\\n /// @return serialized BigInt as bytes\\n function serializeBigInt(CommonTypes.BigInt memory num) internal pure returns (bytes memory) {\\n bytes memory raw = new bytes(num.val.length + 1);\\n\\n raw[0] = num.neg == true ? bytes1(0x01) : bytes1(0x00);\\n\\n uint index = 1;\\n for (uint i = 0; i < num.val.length; i++) {\\n raw[index] = num.val[i];\\n index++;\\n }\\n\\n return raw;\\n }\\n\\n /// @notice deserialize big int (encoded as bytes) to BigInt instance\\n /// @param raw as bytes to parse\\n /// @return parsed BigInt instance\\n function deserializeBigInt(bytes memory raw) internal pure returns (CommonTypes.BigInt memory) {\\n if (raw.length == 0) {\\n return CommonTypes.BigInt(hex\\\"00\\\", false);\\n }\\n\\n bytes memory val = new bytes(raw.length - 1);\\n bool neg = false;\\n\\n if (raw[0] == 0x01) {\\n neg = true;\\n }\\n\\n for (uint i = 1; i < raw.length; i++) {\\n val[i - 1] = raw[i];\\n }\\n\\n return CommonTypes.BigInt(val, neg);\\n }\\n}\\n\",\"keccak256\":\"0xbe9eb7f33f943e12a2ca6d8a02178c30cef91f8c9db1c1b50f88a77e31784ac4\",\"license\":\"Apache-2.0\"},\"@zondax/filecoin-solidity/contracts/v0.8/cbor/BytesCbor.sol\":{\"content\":\"/*******************************************************************************\\n * (c) 2022 Zondax AG\\n *\\n * Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n * distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n * See the License for the specific language governing permissions and\\n * limitations under the License.\\n ********************************************************************************/\\n//\\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\\n\\n// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.17;\\n\\nimport \\\"solidity-cborutils/contracts/CBOR.sol\\\";\\n\\nimport \\\"../utils/CborDecode.sol\\\";\\nimport \\\"../utils/Misc.sol\\\";\\n\\nimport \\\"../types/CommonTypes.sol\\\";\\n\\nimport \\\"./BigIntCbor.sol\\\";\\n\\n/// @title This library is a set of functions meant to handle CBOR serialization and deserialization for bytes\\n/// @author Zondax AG\\nlibrary BytesCBOR {\\n using CBOR for CBOR.CBORBuffer;\\n using CBORDecoder for bytes;\\n using BigIntCBOR for bytes;\\n\\n /// @notice serialize raw bytes as cbor bytes string encoded\\n /// @param data raw data in bytes\\n /// @return encoded cbor bytes\\n function serializeBytes(bytes memory data) internal pure returns (bytes memory) {\\n uint256 capacity = Misc.getBytesSize(data);\\n\\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\\n\\n buf.writeBytes(data);\\n\\n return buf.data();\\n }\\n\\n /// @notice serialize raw address (in bytes) as cbor bytes string encoded (how an address is passed to filecoin actors)\\n /// @param addr raw address in bytes\\n /// @return encoded address as cbor bytes\\n function serializeAddress(bytes memory addr) internal pure returns (bytes memory) {\\n return serializeBytes(addr);\\n }\\n\\n /// @notice encoded null value as cbor\\n /// @return cbor encoded null\\n function serializeNull() internal pure returns (bytes memory) {\\n CBOR.CBORBuffer memory buf = CBOR.create(1);\\n\\n buf.writeNull();\\n\\n return buf.data();\\n }\\n\\n /// @notice deserialize cbor encoded filecoin address to bytes\\n /// @param ret cbor encoded filecoin address\\n /// @return raw bytes representing a filecoin address\\n function deserializeAddress(bytes memory ret) internal pure returns (bytes memory) {\\n bytes memory addr;\\n uint byteIdx = 0;\\n\\n (addr, byteIdx) = ret.readBytes(byteIdx);\\n\\n return addr;\\n }\\n\\n /// @notice deserialize cbor encoded string\\n /// @param ret cbor encoded string (in bytes)\\n /// @return decoded string\\n function deserializeString(bytes memory ret) internal pure returns (string memory) {\\n string memory response;\\n uint byteIdx = 0;\\n\\n (response, byteIdx) = ret.readString(byteIdx);\\n\\n return response;\\n }\\n\\n /// @notice deserialize cbor encoded bool\\n /// @param ret cbor encoded bool (in bytes)\\n /// @return decoded bool\\n function deserializeBool(bytes memory ret) internal pure returns (bool) {\\n bool response;\\n uint byteIdx = 0;\\n\\n (response, byteIdx) = ret.readBool(byteIdx);\\n\\n return response;\\n }\\n\\n /// @notice deserialize cbor encoded BigInt\\n /// @param ret cbor encoded BigInt (in bytes)\\n /// @return decoded BigInt\\n /// @dev BigInts are cbor encoded as bytes string first. That is why it unwraps the cbor encoded bytes first, and then parse the result into BigInt\\n function deserializeBytesBigInt(bytes memory ret) internal pure returns (CommonTypes.BigInt memory) {\\n bytes memory tmp;\\n uint byteIdx = 0;\\n\\n if (ret.length > 0) {\\n (tmp, byteIdx) = ret.readBytes(byteIdx);\\n if (tmp.length > 0) {\\n return tmp.deserializeBigInt();\\n }\\n }\\n\\n return CommonTypes.BigInt(new bytes(0), false);\\n }\\n\\n /// @notice deserialize cbor encoded uint64\\n /// @param rawResp cbor encoded uint64 (in bytes)\\n /// @return decoded uint64\\n function deserializeUint64(bytes memory rawResp) internal pure returns (uint64) {\\n uint byteIdx = 0;\\n uint64 value;\\n\\n (value, byteIdx) = rawResp.readUInt64(byteIdx);\\n return value;\\n }\\n\\n /// @notice deserialize cbor encoded int64\\n /// @param rawResp cbor encoded int64 (in bytes)\\n /// @return decoded int64\\n function deserializeInt64(bytes memory rawResp) internal pure returns (int64) {\\n uint byteIdx = 0;\\n int64 value;\\n\\n (value, byteIdx) = rawResp.readInt64(byteIdx);\\n return value;\\n }\\n}\\n\",\"keccak256\":\"0x092be34452eead511a33e8d5c0a0878bf53ac5747ada8788099a81bdf888eccf\",\"license\":\"Apache-2.0\"},\"@zondax/filecoin-solidity/contracts/v0.8/cbor/FilecoinCbor.sol\":{\"content\":\"/*******************************************************************************\\n * (c) 2022 Zondax AG\\n *\\n * Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n * distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n * See the License for the specific language governing permissions and\\n * limitations under the License.\\n ********************************************************************************/\\n//\\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\\n\\n// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.17;\\n\\nimport \\\"solidity-cborutils/contracts/CBOR.sol\\\";\\nimport \\\"@ensdomains/buffer/contracts/Buffer.sol\\\";\\n\\nimport \\\"../utils/CborDecode.sol\\\";\\nimport \\\"../utils/Misc.sol\\\";\\n\\nimport \\\"../types/CommonTypes.sol\\\";\\n\\nimport \\\"../cbor/BigIntCbor.sol\\\";\\n\\n/// @title This library is a set of functions meant to handle CBOR serialization and deserialization for general data types on the filecoin network.\\n/// @author Zondax AG\\nlibrary FilecoinCBOR {\\n using Buffer for Buffer.buffer;\\n using CBOR for CBOR.CBORBuffer;\\n using CBORDecoder for *;\\n using BigIntCBOR for *;\\n\\n uint8 private constant MAJOR_TYPE_TAG = 6;\\n uint8 private constant TAG_TYPE_CID_CODE = 42;\\n uint8 private constant PAYLOAD_LEN_8_BITS = 24;\\n\\n /// @notice Write a CID into a CBOR buffer.\\n /// @dev The CBOR major will be 6 (type 'tag') and the tag type value is 42, as per CBOR tag assignments.\\n /// @dev https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml\\n /// @param buf buffer containing the actual CBOR serialization process\\n /// @param value CID value to serialize as CBOR\\n function writeCid(CBOR.CBORBuffer memory buf, bytes memory value) internal pure {\\n buf.buf.appendUint8(uint8(((MAJOR_TYPE_TAG << 5) | PAYLOAD_LEN_8_BITS)));\\n buf.buf.appendUint8(TAG_TYPE_CID_CODE);\\n // See https://ipld.io/specs/codecs/dag-cbor/spec/#links for explanation on 0x00 prefix.\\n buf.writeBytes(bytes.concat(hex'00', value));\\n }\\n\\n function readCid(bytes memory cborData, uint byteIdx) internal pure returns (CommonTypes.Cid memory, uint) {\\n uint8 maj;\\n uint value;\\n\\n (maj, value, byteIdx) = cborData.parseCborHeader(byteIdx);\\n require(maj == MAJOR_TYPE_TAG, \\\"expected major type tag when parsing cid\\\");\\n require(value == TAG_TYPE_CID_CODE, \\\"expected tag 42 when parsing cid\\\");\\n\\n bytes memory raw;\\n (raw, byteIdx) = cborData.readBytes(byteIdx);\\n require(raw[0] == 0x00, \\\"expected first byte to be 0 when parsing cid\\\");\\n\\n // Pop off the first byte, which corresponds to the historical multibase 0x00 byte.\\n // https://ipld.io/specs/codecs/dag-cbor/spec/#links\\n CommonTypes.Cid memory ret;\\n ret.data = new bytes(raw.length - 1);\\n for (uint256 i = 1; i < raw.length; i++) {\\n ret.data[i-1] = raw[i];\\n }\\n\\n return (ret, byteIdx);\\n }\\n\\n /// @notice serialize filecoin address to cbor encoded\\n /// @param addr filecoin address to serialize\\n /// @return cbor serialized data as bytes\\n function serializeAddress(CommonTypes.FilAddress memory addr) internal pure returns (bytes memory) {\\n uint256 capacity = Misc.getBytesSize(addr.data);\\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\\n\\n buf.writeBytes(addr.data);\\n\\n return buf.data();\\n }\\n\\n /// @notice serialize a BigInt value wrapped in a cbor fixed array.\\n /// @param value BigInt to serialize as cbor inside an\\n /// @return cbor serialized data as bytes\\n function serializeArrayBigInt(CommonTypes.BigInt memory value) internal pure returns (bytes memory) {\\n uint256 capacity = 0;\\n bytes memory valueBigInt = value.serializeBigInt();\\n\\n capacity += Misc.getPrefixSize(1);\\n capacity += Misc.getBytesSize(valueBigInt);\\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\\n\\n buf.startFixedArray(1);\\n buf.writeBytes(value.serializeBigInt());\\n\\n return buf.data();\\n }\\n\\n /// @notice serialize a FilAddress value wrapped in a cbor fixed array.\\n /// @param addr FilAddress to serialize as cbor inside an\\n /// @return cbor serialized data as bytes\\n function serializeArrayFilAddress(CommonTypes.FilAddress memory addr) internal pure returns (bytes memory) {\\n uint256 capacity = 0;\\n\\n capacity += Misc.getPrefixSize(1);\\n capacity += Misc.getBytesSize(addr.data);\\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\\n\\n buf.startFixedArray(1);\\n buf.writeBytes(addr.data);\\n\\n return buf.data();\\n }\\n\\n /// @notice deserialize a FilAddress wrapped on a cbor fixed array coming from a actor call\\n /// @param rawResp cbor encoded response\\n /// @return ret new instance of FilAddress created based on parsed data\\n function deserializeArrayFilAddress(bytes memory rawResp) internal pure returns (CommonTypes.FilAddress memory ret) {\\n uint byteIdx = 0;\\n uint len;\\n\\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\\n require(len == 1, \\\"Wrong numbers of parameters (should find 1)\\\");\\n\\n (ret.data, byteIdx) = rawResp.readBytes(byteIdx);\\n\\n return ret;\\n }\\n\\n /// @notice deserialize a BigInt wrapped on a cbor fixed array coming from a actor call\\n /// @param rawResp cbor encoded response\\n /// @return ret new instance of BigInt created based on parsed data\\n function deserializeArrayBigInt(bytes memory rawResp) internal pure returns (CommonTypes.BigInt memory) {\\n uint byteIdx = 0;\\n uint len;\\n bytes memory tmp;\\n\\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\\n assert(len == 1);\\n\\n (tmp, byteIdx) = rawResp.readBytes(byteIdx);\\n return tmp.deserializeBigInt();\\n }\\n\\n /// @notice serialize UniversalReceiverParams struct to cbor in order to pass as arguments to an actor\\n /// @param params UniversalReceiverParams to serialize as cbor\\n /// @return cbor serialized data as bytes\\n function serializeUniversalReceiverParams(CommonTypes.UniversalReceiverParams memory params) internal pure returns (bytes memory) {\\n uint256 capacity = 0;\\n\\n capacity += Misc.getPrefixSize(2);\\n capacity += Misc.getPrefixSize(params.type_);\\n capacity += Misc.getBytesSize(params.payload);\\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\\n\\n buf.startFixedArray(2);\\n buf.writeUInt64(params.type_);\\n buf.writeBytes(params.payload);\\n\\n return buf.data();\\n }\\n\\n /// @notice deserialize UniversalReceiverParams cbor to struct when receiving a message\\n /// @param rawResp cbor encoded response\\n /// @return ret new instance of UniversalReceiverParams created based on parsed data\\n function deserializeUniversalReceiverParams(bytes memory rawResp) internal pure returns (CommonTypes.UniversalReceiverParams memory ret) {\\n uint byteIdx = 0;\\n uint len;\\n\\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\\n require(len == 2, \\\"Wrong numbers of parameters (should find 2)\\\");\\n\\n (ret.type_, byteIdx) = rawResp.readUInt32(byteIdx);\\n (ret.payload, byteIdx) = rawResp.readBytes(byteIdx);\\n }\\n\\n /// @notice attempt to read a FilActorId value\\n /// @param rawResp cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return a FilActorId decoded from input bytes and the byte index after moving past the value\\n function readFilActorId(bytes memory rawResp, uint byteIdx) internal pure returns (CommonTypes.FilActorId, uint) {\\n uint64 tmp = 0;\\n\\n (tmp, byteIdx) = rawResp.readUInt64(byteIdx);\\n return (CommonTypes.FilActorId.wrap(tmp), byteIdx);\\n }\\n\\n /// @notice write FilActorId into a cbor buffer\\n /// @dev FilActorId is just wrapping a uint64\\n /// @param buf buffer containing the actual cbor serialization process\\n /// @param id FilActorId to serialize as cbor\\n function writeFilActorId(CBOR.CBORBuffer memory buf, CommonTypes.FilActorId id) internal pure {\\n buf.writeUInt64(CommonTypes.FilActorId.unwrap(id));\\n }\\n\\n /// @notice attempt to read a ChainEpoch value\\n /// @param rawResp cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return a ChainEpoch decoded from input bytes and the byte index after moving past the value\\n function readChainEpoch(bytes memory rawResp, uint byteIdx) internal pure returns (CommonTypes.ChainEpoch, uint) {\\n int64 tmp = 0;\\n\\n (tmp, byteIdx) = rawResp.readInt64(byteIdx);\\n return (CommonTypes.ChainEpoch.wrap(tmp), byteIdx);\\n }\\n\\n /// @notice write ChainEpoch into a cbor buffer\\n /// @dev ChainEpoch is just wrapping a int64\\n /// @param buf buffer containing the actual cbor serialization process\\n /// @param id ChainEpoch to serialize as cbor\\n function writeChainEpoch(CBOR.CBORBuffer memory buf, CommonTypes.ChainEpoch id) internal pure {\\n buf.writeInt64(CommonTypes.ChainEpoch.unwrap(id));\\n }\\n\\n /// @notice write DealLabel into a cbor buffer\\n /// @param buf buffer containing the actual cbor serialization process\\n /// @param label DealLabel to serialize as cbor\\n function writeDealLabel(CBOR.CBORBuffer memory buf, CommonTypes.DealLabel memory label) internal pure {\\n label.isString ? buf.writeString(string(label.data)) : buf.writeBytes(label.data);\\n }\\n\\n /// @notice deserialize DealLabel cbor to struct when receiving a message\\n /// @param rawResp cbor encoded response\\n /// @return ret new instance of DealLabel created based on parsed data\\n function deserializeDealLabel(bytes memory rawResp) internal pure returns (CommonTypes.DealLabel memory) {\\n uint byteIdx = 0;\\n CommonTypes.DealLabel memory label;\\n\\n (label, byteIdx) = readDealLabel(rawResp, byteIdx);\\n return label;\\n }\\n\\n /// @notice attempt to read a DealLabel value\\n /// @param rawResp cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return a DealLabel decoded from input bytes and the byte index after moving past the value\\n function readDealLabel(bytes memory rawResp, uint byteIdx) internal pure returns (CommonTypes.DealLabel memory, uint) {\\n uint8 maj;\\n uint len;\\n\\n (maj, len, byteIdx) = CBORDecoder.parseCborHeader(rawResp, byteIdx);\\n require(maj == MajByteString || maj == MajTextString, \\\"invalid maj (expected MajByteString or MajTextString)\\\");\\n\\n uint max_len = byteIdx + len;\\n bytes memory slice = new bytes(len);\\n uint slice_index = 0;\\n for (uint256 i = byteIdx; i < max_len; i++) {\\n slice[slice_index] = rawResp[i];\\n slice_index++;\\n }\\n\\n return (CommonTypes.DealLabel(slice, maj == MajTextString), byteIdx + len);\\n }\\n}\\n\",\"keccak256\":\"0x9c73c2969df5325f1f86c401b05b8983e633e8bd21c1c72b2b9039a731174098\",\"license\":\"Apache-2.0\"},\"@zondax/filecoin-solidity/contracts/v0.8/cbor/MinerCbor.sol\":{\"content\":\"/*******************************************************************************\\n * (c) 2022 Zondax AG\\n *\\n * Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n * distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n * See the License for the specific language governing permissions and\\n * limitations under the License.\\n ********************************************************************************/\\n//\\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\\n\\n// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.17;\\n\\nimport \\\"solidity-cborutils/contracts/CBOR.sol\\\";\\n\\nimport \\\"./BigIntCbor.sol\\\";\\nimport \\\"./FilecoinCbor.sol\\\";\\n\\nimport \\\"../types/MinerTypes.sol\\\";\\nimport \\\"../types/CommonTypes.sol\\\";\\n\\nimport \\\"../utils/CborDecode.sol\\\";\\nimport \\\"../utils/Misc.sol\\\";\\n\\n/// @title This library is a set of functions meant to handle CBOR parameters serialization and return values deserialization for Miner actor exported methods.\\n/// @author Zondax AG\\nlibrary MinerCBOR {\\n using CBOR for CBOR.CBORBuffer;\\n using CBORDecoder for bytes;\\n using BigIntCBOR for *;\\n using FilecoinCBOR for *;\\n\\n /// @notice serialize ChangeBeneficiaryParams struct to cbor in order to pass as arguments to the miner actor\\n /// @param params ChangeBeneficiaryParams to serialize as cbor\\n /// @return cbor serialized data as bytes\\n function serializeChangeBeneficiaryParams(MinerTypes.ChangeBeneficiaryParams memory params) internal pure returns (bytes memory) {\\n uint256 capacity = 0;\\n bytes memory new_quota = params.new_quota.serializeBigInt();\\n\\n capacity += Misc.getPrefixSize(3);\\n capacity += Misc.getBytesSize(params.new_beneficiary.data);\\n capacity += Misc.getBytesSize(new_quota);\\n capacity += Misc.getChainEpochSize(params.new_expiration);\\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\\n\\n buf.startFixedArray(3);\\n buf.writeBytes(params.new_beneficiary.data);\\n buf.writeBytes(new_quota);\\n buf.writeChainEpoch(params.new_expiration);\\n\\n return buf.data();\\n }\\n\\n /// @notice deserialize GetOwnerReturn struct from cbor encoded bytes coming from a miner actor call\\n /// @param rawResp cbor encoded response\\n /// @return ret new instance of GetOwnerReturn created based on parsed data\\n function deserializeGetOwnerReturn(bytes memory rawResp) internal pure returns (MinerTypes.GetOwnerReturn memory ret) {\\n uint byteIdx = 0;\\n uint len;\\n\\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\\n assert(len == 2);\\n\\n (ret.owner.data, byteIdx) = rawResp.readBytes(byteIdx);\\n\\n if (!rawResp.isNullNext(byteIdx)) {\\n (ret.proposed.data, byteIdx) = rawResp.readBytes(byteIdx);\\n } else {\\n ret.proposed.data = new bytes(0);\\n }\\n\\n return ret;\\n }\\n\\n /// @notice deserialize GetBeneficiaryReturn struct from cbor encoded bytes coming from a miner actor call\\n /// @param rawResp cbor encoded response\\n /// @return ret new instance of GetBeneficiaryReturn created based on parsed data\\n function deserializeGetBeneficiaryReturn(bytes memory rawResp) internal pure returns (MinerTypes.GetBeneficiaryReturn memory ret) {\\n bytes memory tmp;\\n uint byteIdx = 0;\\n uint len;\\n\\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\\n assert(len == 2);\\n\\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\\n assert(len == 2);\\n\\n (ret.active.beneficiary.data, byteIdx) = rawResp.readBytes(byteIdx);\\n\\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\\n assert(len == 3);\\n\\n (tmp, byteIdx) = rawResp.readBytes(byteIdx);\\n if (tmp.length > 0) {\\n ret.active.term.quota = tmp.deserializeBigInt();\\n } else {\\n ret.active.term.quota = CommonTypes.BigInt(new bytes(0), false);\\n }\\n\\n (tmp, byteIdx) = rawResp.readBytes(byteIdx);\\n if (tmp.length > 0) {\\n ret.active.term.used_quota = tmp.deserializeBigInt();\\n } else {\\n ret.active.term.used_quota = CommonTypes.BigInt(new bytes(0), false);\\n }\\n\\n (ret.active.term.expiration, byteIdx) = rawResp.readChainEpoch(byteIdx);\\n\\n if (!rawResp.isNullNext(byteIdx)) {\\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\\n assert(len == 5);\\n\\n (ret.proposed.new_beneficiary.data, byteIdx) = rawResp.readBytes(byteIdx);\\n\\n (tmp, byteIdx) = rawResp.readBytes(byteIdx);\\n if (tmp.length > 0) {\\n ret.proposed.new_quota = tmp.deserializeBigInt();\\n } else {\\n ret.proposed.new_quota = CommonTypes.BigInt(new bytes(0), false);\\n }\\n\\n (ret.proposed.new_expiration, byteIdx) = rawResp.readChainEpoch(byteIdx);\\n (ret.proposed.approved_by_beneficiary, byteIdx) = rawResp.readBool(byteIdx);\\n (ret.proposed.approved_by_nominee, byteIdx) = rawResp.readBool(byteIdx);\\n }\\n\\n return ret;\\n }\\n\\n /// @notice deserialize GetVestingFundsReturn struct from cbor encoded bytes coming from a miner actor call\\n /// @param rawResp cbor encoded response\\n /// @return ret new instance of GetVestingFundsReturn created based on parsed data\\n function deserializeGetVestingFundsReturn(bytes memory rawResp) internal pure returns (MinerTypes.GetVestingFundsReturn memory ret) {\\n CommonTypes.ChainEpoch epoch;\\n CommonTypes.BigInt memory amount;\\n bytes memory tmp;\\n\\n uint byteIdx = 0;\\n uint len;\\n uint leni;\\n\\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\\n assert(len == 1);\\n\\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\\n ret.vesting_funds = new MinerTypes.VestingFunds[](len);\\n\\n for (uint i = 0; i < len; i++) {\\n (leni, byteIdx) = rawResp.readFixedArray(byteIdx);\\n assert(leni == 2);\\n\\n (epoch, byteIdx) = rawResp.readChainEpoch(byteIdx);\\n (tmp, byteIdx) = rawResp.readBytes(byteIdx);\\n\\n amount = tmp.deserializeBigInt();\\n ret.vesting_funds[i] = MinerTypes.VestingFunds(epoch, amount);\\n }\\n\\n return ret;\\n }\\n\\n /// @notice serialize ChangeWorkerAddressParams struct to cbor in order to pass as arguments to the miner actor\\n /// @param params ChangeWorkerAddressParams to serialize as cbor\\n /// @return cbor serialized data as bytes\\n function serializeChangeWorkerAddressParams(MinerTypes.ChangeWorkerAddressParams memory params) internal pure returns (bytes memory) {\\n uint256 capacity = 0;\\n\\n capacity += Misc.getPrefixSize(2);\\n capacity += Misc.getBytesSize(params.new_worker.data);\\n capacity += Misc.getPrefixSize(uint256(params.new_control_addresses.length));\\n for (uint64 i = 0; i < params.new_control_addresses.length; i++) {\\n capacity += Misc.getBytesSize(params.new_control_addresses[i].data);\\n }\\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\\n\\n buf.startFixedArray(2);\\n buf.writeBytes(params.new_worker.data);\\n buf.startFixedArray(uint64(params.new_control_addresses.length));\\n\\n for (uint64 i = 0; i < params.new_control_addresses.length; i++) {\\n buf.writeBytes(params.new_control_addresses[i].data);\\n }\\n\\n return buf.data();\\n }\\n\\n /// @notice serialize ChangeMultiaddrsParams struct to cbor in order to pass as arguments to the miner actor\\n /// @param params ChangeMultiaddrsParams to serialize as cbor\\n /// @return cbor serialized data as bytes\\n function serializeChangeMultiaddrsParams(MinerTypes.ChangeMultiaddrsParams memory params) internal pure returns (bytes memory) {\\n uint256 capacity = 0;\\n\\n capacity += Misc.getPrefixSize(1);\\n capacity += Misc.getPrefixSize(uint256(params.new_multi_addrs.length));\\n for (uint64 i = 0; i < params.new_multi_addrs.length; i++) {\\n capacity += Misc.getBytesSize(params.new_multi_addrs[i].data);\\n }\\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\\n\\n buf.startFixedArray(1);\\n buf.startFixedArray(uint64(params.new_multi_addrs.length));\\n\\n for (uint64 i = 0; i < params.new_multi_addrs.length; i++) {\\n buf.writeBytes(params.new_multi_addrs[i].data);\\n }\\n\\n return buf.data();\\n }\\n\\n /// @notice deserialize GetMultiaddrsReturn struct from cbor encoded bytes coming from a miner actor call\\n /// @param rawResp cbor encoded response\\n /// @return ret new instance of GetMultiaddrsReturn created based on parsed data\\n function deserializeGetMultiaddrsReturn(bytes memory rawResp) internal pure returns (MinerTypes.GetMultiaddrsReturn memory ret) {\\n uint byteIdx = 0;\\n uint len;\\n\\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\\n assert(len == 1);\\n\\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\\n ret.multi_addrs = new CommonTypes.FilAddress[](len);\\n\\n for (uint i = 0; i < len; i++) {\\n (ret.multi_addrs[i].data, byteIdx) = rawResp.readBytes(byteIdx);\\n }\\n\\n return ret;\\n }\\n}\\n\",\"keccak256\":\"0x8893ec187418e90131eedce500b721c7195d2f7cef24643910c85f9000a211b3\",\"license\":\"Apache-2.0\"},\"@zondax/filecoin-solidity/contracts/v0.8/types/CommonTypes.sol\":{\"content\":\"/*******************************************************************************\\n * (c) 2022 Zondax AG\\n *\\n * Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n * distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n * See the License for the specific language governing permissions and\\n * limitations under the License.\\n ********************************************************************************/\\n//\\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\\n\\n// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.17;\\n\\n\\n/// @title Filecoin actors' common types for Solidity.\\n/// @author Zondax AG\\nlibrary CommonTypes {\\n uint constant UniversalReceiverHookMethodNum = 3726118371;\\n\\n /// @param idx index for the failure in batch\\n /// @param code failure code\\n struct FailCode {\\n uint32 idx;\\n uint32 code;\\n }\\n\\n /// @param success_count total successes in batch\\n /// @param fail_codes list of failures code and index for each failure in batch\\n struct BatchReturn {\\n uint32 success_count;\\n FailCode[] fail_codes;\\n }\\n\\n /// @param type_ asset type\\n /// @param payload payload corresponding to asset type\\n struct UniversalReceiverParams {\\n uint32 type_;\\n bytes payload;\\n }\\n\\n /// @param val contains the actual arbitrary number written as binary\\n /// @param neg indicates if val is negative or not\\n struct BigInt {\\n bytes val;\\n bool neg;\\n }\\n\\n /// @param data filecoin address in bytes format\\n struct FilAddress {\\n bytes data;\\n }\\n\\n /// @param data cid in bytes format\\n struct Cid {\\n bytes data;\\n }\\n\\n /// @param data deal proposal label in bytes format (it can be utf8 string or arbitrary bytes string).\\n /// @param isString indicates if the data is string or raw bytes\\n struct DealLabel {\\n bytes data;\\n bool isString;\\n }\\n\\n type FilActorId is uint64;\\n\\n type ChainEpoch is int64;\\n}\\n\",\"keccak256\":\"0x1819b8e82cf53f0fadc446d064a380979888b97a0004f1e70c9fa1a6f4f13ed9\",\"license\":\"Apache-2.0\"},\"@zondax/filecoin-solidity/contracts/v0.8/types/MinerTypes.sol\":{\"content\":\"/*******************************************************************************\\n * (c) 2022 Zondax AG\\n *\\n * Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n * distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n * See the License for the specific language governing permissions and\\n * limitations under the License.\\n ********************************************************************************/\\n//\\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\\n\\n// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.17;\\n\\nimport \\\"../cbor/BigIntCbor.sol\\\";\\nimport \\\"./CommonTypes.sol\\\";\\n\\n/// @title Filecoin miner actor types for Solidity.\\n/// @author Zondax AG\\nlibrary MinerTypes {\\n uint constant GetOwnerMethodNum = 3275365574;\\n uint constant ChangeOwnerAddressMethodNum = 1010589339;\\n uint constant IsControllingAddressMethodNum = 348244887;\\n uint constant GetSectorSizeMethodNum = 3858292296;\\n uint constant GetAvailableBalanceMethodNum = 4026106874;\\n uint constant GetVestingFundsMethodNum = 1726876304;\\n uint constant ChangeBeneficiaryMethodNum = 1570634796;\\n uint constant GetBeneficiaryMethodNum = 4158972569;\\n uint constant ChangeWorkerAddressMethodNum = 3302309124;\\n uint constant ChangePeerIDMethodNum = 1236548004;\\n uint constant ChangeMultiaddrsMethodNum = 1063480576;\\n uint constant RepayDebtMethodNum = 3665352697;\\n uint constant ConfirmChangeWorkerAddressMethodNum = 2354970453;\\n uint constant GetPeerIDMethodNum = 2812875329;\\n uint constant GetMultiaddrsMethodNum = 1332909407;\\n uint constant WithdrawBalanceMethodNum = 2280458852;\\n\\n /// @param owner owner address.\\n /// @param proposed owner address.\\n struct GetOwnerReturn {\\n CommonTypes.FilAddress owner;\\n CommonTypes.FilAddress proposed;\\n }\\n\\n /// @param vesting_funds funds\\n struct GetVestingFundsReturn {\\n VestingFunds[] vesting_funds;\\n }\\n\\n /// @param new_beneficiary the new beneficiary address.\\n /// @param new_quota the new quota token amount.\\n /// @param new_expiration the epoch that the new quota will be expired.\\n struct ChangeBeneficiaryParams {\\n CommonTypes.FilAddress new_beneficiary;\\n CommonTypes.BigInt new_quota;\\n CommonTypes.ChainEpoch new_expiration;\\n }\\n\\n /// @param active current active beneficiary.\\n /// @param proposed the proposed and pending beneficiary.\\n struct GetBeneficiaryReturn {\\n ActiveBeneficiary active;\\n PendingBeneficiaryChange proposed;\\n }\\n\\n /// @param new_worker the new worker address.\\n /// @param new_control_addresses the new controller addresses.\\n struct ChangeWorkerAddressParams {\\n CommonTypes.FilAddress new_worker;\\n CommonTypes.FilAddress[] new_control_addresses;\\n }\\n\\n /// @param new_multi_addrs the new multi-signature address.\\n struct ChangeMultiaddrsParams {\\n CommonTypes.FilAddress[] new_multi_addrs;\\n }\\n\\n /// @param multi_addrs the multi-signature address.\\n struct GetMultiaddrsReturn {\\n CommonTypes.FilAddress[] multi_addrs;\\n }\\n\\n /// @param epoch the epoch of funds vested.\\n /// @param amount the amount of funds vested.\\n struct VestingFunds {\\n CommonTypes.ChainEpoch epoch;\\n CommonTypes.BigInt amount;\\n }\\n\\n /// @param quota the quota token amount.\\n /// @param used_quota the used quota token amount.\\n /// @param expiration the epoch that the quota will be expired.\\n struct BeneficiaryTerm {\\n CommonTypes.BigInt quota;\\n CommonTypes.BigInt used_quota;\\n CommonTypes.ChainEpoch expiration;\\n }\\n\\n /// @param beneficiary the address of the beneficiary.\\n /// @param term BeneficiaryTerm\\n struct ActiveBeneficiary {\\n CommonTypes.FilAddress beneficiary;\\n BeneficiaryTerm term;\\n }\\n\\n /// @param new_beneficiary the new beneficiary address.\\n /// @param new_quota the new quota token amount.\\n /// @param new_expiration the epoch that the new quota will be expired.\\n /// @param approved_by_beneficiary if this proposal is approved by beneficiary or not.\\n /// @param approved_by_nominee if this proposal is approved by nominee or not.\\n struct PendingBeneficiaryChange {\\n CommonTypes.FilAddress new_beneficiary;\\n CommonTypes.BigInt new_quota;\\n CommonTypes.ChainEpoch new_expiration;\\n bool approved_by_beneficiary;\\n bool approved_by_nominee;\\n }\\n\\n enum SectorSize {\\n _2KiB,\\n _8MiB,\\n _512MiB,\\n _32GiB,\\n _64GiB\\n }\\n}\\n\",\"keccak256\":\"0x6d7839a173dc3b84142cb3ea3a834148e57a89ad3d15383c26b6036461145e72\",\"license\":\"Apache-2.0\"},\"@zondax/filecoin-solidity/contracts/v0.8/utils/Actor.sol\":{\"content\":\"/*******************************************************************************\\n * (c) 2022 Zondax AG\\n *\\n * Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n * distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n * See the License for the specific language governing permissions and\\n * limitations under the License.\\n ********************************************************************************/\\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\\n\\n// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.17;\\n\\nimport \\\"./Misc.sol\\\";\\nimport \\\"../types/CommonTypes.sol\\\";\\n\\n/// @title Call actors utilities library, meant to interact with Filecoin builtin actors\\n/// @author Zondax AG\\nlibrary Actor {\\n /// @notice precompile address for the call_actor precompile\\n address constant CALL_ACTOR_ADDRESS = 0xfe00000000000000000000000000000000000003;\\n\\n /// @notice precompile address for the call_actor_id precompile\\n address constant CALL_ACTOR_ID = 0xfe00000000000000000000000000000000000005;\\n\\n /// @notice flag used to indicate that the call_actor or call_actor_id should perform a static_call to the desired actor\\n uint64 constant READ_ONLY_FLAG = 0x00000001;\\n\\n /// @notice flag used to indicate that the call_actor or call_actor_id should perform a call to the desired actor\\n uint64 constant DEFAULT_FLAG = 0x00000000;\\n\\n /// @notice the provided address is not valid\\n error InvalidAddress(bytes addr);\\n\\n /// @notice the smart contract has no enough balance to transfer\\n error NotEnoughBalance(uint256 balance, uint256 value);\\n\\n /// @notice the provided actor id is not valid\\n error InvalidActorID(CommonTypes.FilActorId actorId);\\n\\n /// @notice an error happened trying to call the actor\\n error FailToCallActor();\\n\\n /// @notice the response received is not correct. In some case no response is expected and we received one, or a response was indeed expected and we received none.\\n error InvalidResponseLength();\\n\\n /// @notice the codec received is not valid\\n error InvalidCodec(uint64);\\n\\n /// @notice the called actor returned an error as part of its expected behaviour\\n error ActorError(int256 errorCode);\\n\\n /// @notice the actor is not found\\n error ActorNotFound();\\n\\n /// @notice allows to interact with an specific actor by its address (bytes format)\\n /// @param actor_address actor address (bytes format) to interact with\\n /// @param method_num id of the method from the actor to call\\n /// @param codec how the request data passed as argument is encoded\\n /// @param raw_request encoded arguments to be passed in the call\\n /// @param value tokens to be transferred to the called actor\\n /// @param static_call indicates if the call will be allowed to change the actor state or not (just read the state)\\n /// @return payload (in bytes) with the actual response data (without codec or response code)\\n function callByAddress(\\n bytes memory actor_address,\\n uint256 method_num,\\n uint64 codec,\\n bytes memory raw_request,\\n uint256 value,\\n bool static_call\\n ) internal returns (bytes memory) {\\n if (actor_address.length < 2) {\\n revert InvalidAddress(actor_address);\\n }\\n\\n validatePrecompileCall(CALL_ACTOR_ADDRESS, value);\\n\\n // We have to delegate-call the call-actor precompile because the call-actor precompile will\\n // call the target actor on our behalf. This will _not_ delegate to the target `actor_address`.\\n //\\n // Specifically:\\n //\\n // - `static_call == false`: `CALLER (you) --(DELEGATECALL)-> CALL_ACTOR_PRECOMPILE --(CALL)-> actor_address\\n // - `static_call == true`: `CALLER (you) --(DELEGATECALL)-> CALL_ACTOR_PRECOMPILE --(STATICCALL)-> actor_address\\n (bool success, bytes memory data) = address(CALL_ACTOR_ADDRESS).delegatecall(\\n abi.encode(uint64(method_num), value, static_call ? READ_ONLY_FLAG : DEFAULT_FLAG, codec, raw_request, actor_address)\\n );\\n if (!success) {\\n revert FailToCallActor();\\n }\\n\\n return readRespData(data);\\n }\\n\\n /// @notice allows to interact with an specific actor by its id (uint64)\\n /// @param target actor id (uint64) to interact with\\n /// @param method_num id of the method from the actor to call\\n /// @param codec how the request data passed as argument is encoded\\n /// @param raw_request encoded arguments to be passed in the call\\n /// @param value tokens to be transferred to the called actor\\n /// @param static_call indicates if the call will be allowed to change the actor state or not (just read the state)\\n /// @return payload (in bytes) with the actual response data (without codec or response code)\\n function callByID(\\n CommonTypes.FilActorId target,\\n uint256 method_num,\\n uint64 codec,\\n bytes memory raw_request,\\n uint256 value,\\n bool static_call\\n ) internal returns (bytes memory) {\\n validatePrecompileCall(CALL_ACTOR_ID, value);\\n\\n (bool success, bytes memory data) = address(CALL_ACTOR_ID).delegatecall(\\n abi.encode(uint64(method_num), value, static_call ? READ_ONLY_FLAG : DEFAULT_FLAG, codec, raw_request, target)\\n );\\n if (!success) {\\n revert FailToCallActor();\\n }\\n\\n return readRespData(data);\\n }\\n\\n /// @notice allows to run some generic validations before calling the precompile actor\\n /// @param addr precompile actor address to run check to\\n /// @param value tokens to be transferred to the called actor\\n function validatePrecompileCall(address addr, uint256 value) internal view {\\n uint balance = address(this).balance;\\n if (balance < value) {\\n revert NotEnoughBalance(balance, value);\\n }\\n\\n bool actorExists = Misc.addressExists(addr);\\n if (!actorExists) {\\n revert ActorNotFound();\\n }\\n }\\n\\n /// @notice allows to interact with an non-singleton actors by its id (uint64)\\n /// @param target actor id (uint64) to interact with\\n /// @param method_num id of the method from the actor to call\\n /// @param codec how the request data passed as argument is encoded\\n /// @param raw_request encoded arguments to be passed in the call\\n /// @param value tokens to be transfered to the called actor\\n /// @param static_call indicates if the call will be allowed to change the actor state or not (just read the state)\\n /// @dev it requires the id to be bigger than 99, as singleton actors are smaller than that\\n function callNonSingletonByID(\\n CommonTypes.FilActorId target,\\n uint256 method_num,\\n uint64 codec,\\n bytes memory raw_request,\\n uint256 value,\\n bool static_call\\n ) internal returns (bytes memory) {\\n if (CommonTypes.FilActorId.unwrap(target) < 100) {\\n revert InvalidActorID(target);\\n }\\n\\n return callByID(target, method_num, codec, raw_request, value, static_call);\\n }\\n\\n /// @notice parse the response an actor returned\\n /// @notice it will validate the return code (success) and the codec (valid one)\\n /// @param raw_response raw data (bytes) the actor returned\\n /// @return the actual raw data (payload, in bytes) to be parsed according to the actor and method called\\n function readRespData(bytes memory raw_response) internal pure returns (bytes memory) {\\n (int256 exit, uint64 return_codec, bytes memory return_value) = abi.decode(raw_response, (int256, uint64, bytes));\\n\\n if (return_codec == Misc.NONE_CODEC) {\\n if (return_value.length != 0) {\\n revert InvalidResponseLength();\\n }\\n } else if (return_codec == Misc.CBOR_CODEC || return_codec == Misc.DAG_CBOR_CODEC) {\\n if (return_value.length == 0) {\\n revert InvalidResponseLength();\\n }\\n } else {\\n revert InvalidCodec(return_codec);\\n }\\n\\n if (exit != 0) {\\n revert ActorError(exit);\\n }\\n\\n return return_value;\\n }\\n}\\n\",\"keccak256\":\"0xa4b9eb4d84491477a3c11336a431c4f3a0796977efb92779bd062f273824c67a\",\"license\":\"Apache-2.0\"},\"@zondax/filecoin-solidity/contracts/v0.8/utils/CborDecode.sol\":{\"content\":\"/*******************************************************************************\\n * (c) 2022 Zondax AG\\n *\\n * Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n * distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n * See the License for the specific language governing permissions and\\n * limitations under the License.\\n ********************************************************************************/\\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\\n\\n// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.17;\\n\\n// \\tMajUnsignedInt = 0\\n// \\tMajSignedInt = 1\\n// \\tMajByteString = 2\\n// \\tMajTextString = 3\\n// \\tMajArray = 4\\n// \\tMajMap = 5\\n// \\tMajTag = 6\\n// \\tMajOther = 7\\n\\nuint8 constant MajUnsignedInt = 0;\\nuint8 constant MajSignedInt = 1;\\nuint8 constant MajByteString = 2;\\nuint8 constant MajTextString = 3;\\nuint8 constant MajArray = 4;\\nuint8 constant MajMap = 5;\\nuint8 constant MajTag = 6;\\nuint8 constant MajOther = 7;\\n\\nuint8 constant TagTypeBigNum = 2;\\nuint8 constant TagTypeNegativeBigNum = 3;\\n\\nuint8 constant True_Type = 21;\\nuint8 constant False_Type = 20;\\n\\n/// @notice This library is a set a functions that allows anyone to decode cbor encoded bytes\\n/// @dev methods in this library try to read the data type indicated from cbor encoded data stored in bytes at a specific index\\n/// @dev if it successes, methods will return the read value and the new index (intial index plus read bytes)\\n/// @author Zondax AG\\nlibrary CBORDecoder {\\n /// @notice check if next value on the cbor encoded data is null\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n function isNullNext(bytes memory cborData, uint byteIdx) internal pure returns (bool) {\\n return cborData[byteIdx] == hex\\\"f6\\\";\\n }\\n\\n /// @notice attempt to read a bool value\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return a bool decoded from input bytes and the byte index after moving past the value\\n function readBool(bytes memory cborData, uint byteIdx) internal pure returns (bool, uint) {\\n uint8 maj;\\n uint value;\\n\\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajOther, \\\"invalid maj (expected MajOther)\\\");\\n assert(value == True_Type || value == False_Type);\\n\\n return (value != False_Type, byteIdx);\\n }\\n\\n /// @notice attempt to read the length of a fixed array\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return length of the fixed array decoded from input bytes and the byte index after moving past the value\\n function readFixedArray(bytes memory cborData, uint byteIdx) internal pure returns (uint, uint) {\\n uint8 maj;\\n uint len;\\n\\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajArray, \\\"invalid maj (expected MajArray)\\\");\\n\\n return (len, byteIdx);\\n }\\n\\n /// @notice attempt to read an arbitrary length string value\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return arbitrary length string decoded from input bytes and the byte index after moving past the value\\n function readString(bytes memory cborData, uint byteIdx) internal pure returns (string memory, uint) {\\n uint8 maj;\\n uint len;\\n\\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajTextString, \\\"invalid maj (expected MajTextString)\\\");\\n\\n uint max_len = byteIdx + len;\\n bytes memory slice = new bytes(len);\\n uint slice_index = 0;\\n for (uint256 i = byteIdx; i < max_len; i++) {\\n slice[slice_index] = cborData[i];\\n slice_index++;\\n }\\n\\n return (string(slice), byteIdx + len);\\n }\\n\\n /// @notice attempt to read an arbitrary byte string value\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return arbitrary byte string decoded from input bytes and the byte index after moving past the value\\n function readBytes(bytes memory cborData, uint byteIdx) internal pure returns (bytes memory, uint) {\\n uint8 maj;\\n uint len;\\n\\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajTag || maj == MajByteString, \\\"invalid maj (expected MajTag or MajByteString)\\\");\\n\\n if (maj == MajTag) {\\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\\n assert(maj == MajByteString);\\n }\\n\\n uint max_len = byteIdx + len;\\n bytes memory slice = new bytes(len);\\n uint slice_index = 0;\\n for (uint256 i = byteIdx; i < max_len; i++) {\\n slice[slice_index] = cborData[i];\\n slice_index++;\\n }\\n\\n return (slice, byteIdx + len);\\n }\\n\\n /// @notice attempt to read a bytes32 value\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return a bytes32 decoded from input bytes and the byte index after moving past the value\\n function readBytes32(bytes memory cborData, uint byteIdx) internal pure returns (bytes32, uint) {\\n uint8 maj;\\n uint len;\\n\\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajByteString, \\\"invalid maj (expected MajByteString)\\\");\\n\\n uint max_len = byteIdx + len;\\n bytes memory slice = new bytes(32);\\n uint slice_index = 32 - len;\\n for (uint256 i = byteIdx; i < max_len; i++) {\\n slice[slice_index] = cborData[i];\\n slice_index++;\\n }\\n\\n return (bytes32(slice), byteIdx + len);\\n }\\n\\n /// @notice attempt to read a uint256 value encoded per cbor specification\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return an uint256 decoded from input bytes and the byte index after moving past the value\\n function readUInt256(bytes memory cborData, uint byteIdx) internal pure returns (uint256, uint) {\\n uint8 maj;\\n uint256 value;\\n\\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajTag || maj == MajUnsignedInt, \\\"invalid maj (expected MajTag or MajUnsignedInt)\\\");\\n\\n if (maj == MajTag) {\\n require(value == TagTypeBigNum, \\\"invalid tag (expected TagTypeBigNum)\\\");\\n\\n uint len;\\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajByteString, \\\"invalid maj (expected MajByteString)\\\");\\n\\n require(cborData.length >= byteIdx + len, \\\"slicing out of range\\\");\\n assembly {\\n value := mload(add(cborData, add(len, byteIdx)))\\n }\\n\\n return (value, byteIdx + len);\\n }\\n\\n return (value, byteIdx);\\n }\\n\\n /// @notice attempt to read a int256 value encoded per cbor specification\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return an int256 decoded from input bytes and the byte index after moving past the value\\n function readInt256(bytes memory cborData, uint byteIdx) internal pure returns (int256, uint) {\\n uint8 maj;\\n uint value;\\n\\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajTag || maj == MajSignedInt, \\\"invalid maj (expected MajTag or MajSignedInt)\\\");\\n\\n if (maj == MajTag) {\\n assert(value == TagTypeNegativeBigNum);\\n\\n uint len;\\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajByteString, \\\"invalid maj (expected MajByteString)\\\");\\n\\n require(cborData.length >= byteIdx + len, \\\"slicing out of range\\\");\\n assembly {\\n value := mload(add(cborData, add(len, byteIdx)))\\n }\\n\\n return (int256(value), byteIdx + len);\\n }\\n\\n return (int256(value), byteIdx);\\n }\\n\\n /// @notice attempt to read a uint64 value\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return an uint64 decoded from input bytes and the byte index after moving past the value\\n function readUInt64(bytes memory cborData, uint byteIdx) internal pure returns (uint64, uint) {\\n uint8 maj;\\n uint value;\\n\\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajUnsignedInt, \\\"invalid maj (expected MajUnsignedInt)\\\");\\n\\n return (uint64(value), byteIdx);\\n }\\n\\n /// @notice attempt to read a uint32 value\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return an uint32 decoded from input bytes and the byte index after moving past the value\\n function readUInt32(bytes memory cborData, uint byteIdx) internal pure returns (uint32, uint) {\\n uint8 maj;\\n uint value;\\n\\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajUnsignedInt, \\\"invalid maj (expected MajUnsignedInt)\\\");\\n\\n return (uint32(value), byteIdx);\\n }\\n\\n /// @notice attempt to read a uint16 value\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return an uint16 decoded from input bytes and the byte index after moving past the value\\n function readUInt16(bytes memory cborData, uint byteIdx) internal pure returns (uint16, uint) {\\n uint8 maj;\\n uint value;\\n\\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajUnsignedInt, \\\"invalid maj (expected MajUnsignedInt)\\\");\\n\\n return (uint16(value), byteIdx);\\n }\\n\\n /// @notice attempt to read a uint8 value\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return an uint8 decoded from input bytes and the byte index after moving past the value\\n function readUInt8(bytes memory cborData, uint byteIdx) internal pure returns (uint8, uint) {\\n uint8 maj;\\n uint value;\\n\\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajUnsignedInt, \\\"invalid maj (expected MajUnsignedInt)\\\");\\n\\n return (uint8(value), byteIdx);\\n }\\n\\n /// @notice attempt to read a int64 value\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return an int64 decoded from input bytes and the byte index after moving past the value\\n function readInt64(bytes memory cborData, uint byteIdx) internal pure returns (int64, uint) {\\n uint8 maj;\\n uint value;\\n\\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajSignedInt || maj == MajUnsignedInt, \\\"invalid maj (expected MajSignedInt or MajUnsignedInt)\\\");\\n\\n return (int64(uint64(value)), byteIdx);\\n }\\n\\n /// @notice attempt to read a int32 value\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return an int32 decoded from input bytes and the byte index after moving past the value\\n function readInt32(bytes memory cborData, uint byteIdx) internal pure returns (int32, uint) {\\n uint8 maj;\\n uint value;\\n\\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajSignedInt || maj == MajUnsignedInt, \\\"invalid maj (expected MajSignedInt or MajUnsignedInt)\\\");\\n\\n return (int32(uint32(value)), byteIdx);\\n }\\n\\n /// @notice attempt to read a int16 value\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return an int16 decoded from input bytes and the byte index after moving past the value\\n function readInt16(bytes memory cborData, uint byteIdx) internal pure returns (int16, uint) {\\n uint8 maj;\\n uint value;\\n\\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajSignedInt || maj == MajUnsignedInt, \\\"invalid maj (expected MajSignedInt or MajUnsignedInt)\\\");\\n\\n return (int16(uint16(value)), byteIdx);\\n }\\n\\n /// @notice attempt to read a int8 value\\n /// @param cborData cbor encoded bytes to parse from\\n /// @param byteIdx current position to read on the cbor encoded bytes\\n /// @return an int8 decoded from input bytes and the byte index after moving past the value\\n function readInt8(bytes memory cborData, uint byteIdx) internal pure returns (int8, uint) {\\n uint8 maj;\\n uint value;\\n\\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\\n require(maj == MajSignedInt || maj == MajUnsignedInt, \\\"invalid maj (expected MajSignedInt or MajUnsignedInt)\\\");\\n\\n return (int8(uint8(value)), byteIdx);\\n }\\n\\n /// @notice slice uint8 from bytes starting at a given index\\n /// @param bs bytes to slice from\\n /// @param start current position to slice from bytes\\n /// @return uint8 sliced from bytes\\n function sliceUInt8(bytes memory bs, uint start) internal pure returns (uint8) {\\n require(bs.length >= start + 1, \\\"slicing out of range\\\");\\n return uint8(bs[start]);\\n }\\n\\n /// @notice slice uint16 from bytes starting at a given index\\n /// @param bs bytes to slice from\\n /// @param start current position to slice from bytes\\n /// @return uint16 sliced from bytes\\n function sliceUInt16(bytes memory bs, uint start) internal pure returns (uint16) {\\n require(bs.length >= start + 2, \\\"slicing out of range\\\");\\n bytes2 x;\\n assembly {\\n x := mload(add(bs, add(0x20, start)))\\n }\\n return uint16(x);\\n }\\n\\n /// @notice slice uint32 from bytes starting at a given index\\n /// @param bs bytes to slice from\\n /// @param start current position to slice from bytes\\n /// @return uint32 sliced from bytes\\n function sliceUInt32(bytes memory bs, uint start) internal pure returns (uint32) {\\n require(bs.length >= start + 4, \\\"slicing out of range\\\");\\n bytes4 x;\\n assembly {\\n x := mload(add(bs, add(0x20, start)))\\n }\\n return uint32(x);\\n }\\n\\n /// @notice slice uint64 from bytes starting at a given index\\n /// @param bs bytes to slice from\\n /// @param start current position to slice from bytes\\n /// @return uint64 sliced from bytes\\n function sliceUInt64(bytes memory bs, uint start) internal pure returns (uint64) {\\n require(bs.length >= start + 8, \\\"slicing out of range\\\");\\n bytes8 x;\\n assembly {\\n x := mload(add(bs, add(0x20, start)))\\n }\\n return uint64(x);\\n }\\n\\n /// @notice Parse cbor header for major type and extra info.\\n /// @param cbor cbor encoded bytes to parse from\\n /// @param byteIndex current position to read on the cbor encoded bytes\\n /// @return major type, extra info and the byte index after moving past header bytes\\n function parseCborHeader(bytes memory cbor, uint byteIndex) internal pure returns (uint8, uint64, uint) {\\n uint8 first = sliceUInt8(cbor, byteIndex);\\n byteIndex += 1;\\n uint8 maj = (first & 0xe0) >> 5;\\n uint8 low = first & 0x1f;\\n // We don't handle CBOR headers with extra > 27, i.e. no indefinite lengths\\n require(low < 28, \\\"cannot handle headers with extra > 27\\\");\\n\\n // extra is lower bits\\n if (low < 24) {\\n return (maj, low, byteIndex);\\n }\\n\\n // extra in next byte\\n if (low == 24) {\\n uint8 next = sliceUInt8(cbor, byteIndex);\\n byteIndex += 1;\\n require(next >= 24, \\\"invalid cbor\\\"); // otherwise this is invalid cbor\\n return (maj, next, byteIndex);\\n }\\n\\n // extra in next 2 bytes\\n if (low == 25) {\\n uint16 extra16 = sliceUInt16(cbor, byteIndex);\\n byteIndex += 2;\\n return (maj, extra16, byteIndex);\\n }\\n\\n // extra in next 4 bytes\\n if (low == 26) {\\n uint32 extra32 = sliceUInt32(cbor, byteIndex);\\n byteIndex += 4;\\n return (maj, extra32, byteIndex);\\n }\\n\\n // extra in next 8 bytes\\n assert(low == 27);\\n uint64 extra64 = sliceUInt64(cbor, byteIndex);\\n byteIndex += 8;\\n return (maj, extra64, byteIndex);\\n }\\n}\\n\",\"keccak256\":\"0x3babe3c71558c21f0bef9de09088c42b8b148d16d856f84a350b9c43b4da6018\",\"license\":\"Apache-2.0\"},\"@zondax/filecoin-solidity/contracts/v0.8/utils/Misc.sol\":{\"content\":\"/*******************************************************************************\\n * (c) 2022 Zondax AG\\n *\\n * Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\\n * you may not use this file except in compliance with the License.\\n * You may obtain a copy of the License at\\n *\\n * http://www.apache.org/licenses/LICENSE-2.0\\n *\\n * Unless required by applicable law or agreed to in writing, software\\n * distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\\n * See the License for the specific language governing permissions and\\n * limitations under the License.\\n ********************************************************************************/\\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\\n\\n// SPDX-License-Identifier: Apache-2.0\\npragma solidity ^0.8.17;\\n\\nimport \\\"../types/CommonTypes.sol\\\";\\n\\n/// @title Library containing miscellaneous functions used on the project\\n/// @author Zondax AG\\nlibrary Misc {\\n uint64 constant DAG_CBOR_CODEC = 0x71;\\n uint64 constant CBOR_CODEC = 0x51;\\n uint64 constant NONE_CODEC = 0x00;\\n\\n // Code taken from Openzeppelin repo\\n // Link: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/0320a718e8e07b1d932f5acb8ad9cec9d9eed99b/contracts/utils/math/SignedMath.sol#L37-L42\\n /// @notice get the abs from a signed number\\n /// @param n number to get abs from\\n /// @return unsigned number\\n function abs(int256 n) internal pure returns (uint256) {\\n unchecked {\\n // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n\\n /// @notice validate if an address exists or not\\n /// @dev read this article for more information https://blog.finxter.com/how-to-find-out-if-an-ethereum-address-is-a-contract/\\n /// @param addr address to check\\n /// @return whether the address exists or not\\n function addressExists(address addr) internal view returns (bool) {\\n bytes32 codehash;\\n assembly {\\n codehash := extcodehash(addr)\\n }\\n return codehash != 0x0;\\n }\\n\\n /// Returns the data size required by CBOR.writeFixedNumeric\\n function getPrefixSize(uint256 data_size) internal pure returns (uint256) {\\n if (data_size <= 23) {\\n return 1;\\n } else if (data_size <= 0xFF) {\\n return 2;\\n } else if (data_size <= 0xFFFF) {\\n return 3;\\n } else if (data_size <= 0xFFFFFFFF) {\\n return 5;\\n }\\n return 9;\\n }\\n\\n function getBytesSize(bytes memory value) internal pure returns (uint256) {\\n return getPrefixSize(value.length) + value.length;\\n }\\n\\n function getCidSize(bytes memory value) internal pure returns (uint256) {\\n return getPrefixSize(2) + value.length;\\n }\\n\\n function getFilActorIdSize(CommonTypes.FilActorId value) internal pure returns (uint256) {\\n uint64 val = CommonTypes.FilActorId.unwrap(value);\\n return getPrefixSize(uint256(val));\\n }\\n\\n function getChainEpochSize(CommonTypes.ChainEpoch value) internal pure returns (uint256) {\\n int64 val = CommonTypes.ChainEpoch.unwrap(value);\\n if (val >= 0) {\\n return getPrefixSize(uint256(uint64(val)));\\n } else {\\n return getPrefixSize(uint256(uint64(-1 - val)));\\n }\\n }\\n\\n function getBoolSize() internal pure returns (uint256) {\\n return getPrefixSize(1);\\n }\\n}\\n\",\"keccak256\":\"0x97b02c3ab9cb11169b0b1a143b513017c6bf0f2cba2fc4f81a77345b5dfe96b4\",\"license\":\"Apache-2.0\"},\"contracts/MinerPeerIDMapping.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\n\\nimport \\\"@zondax/filecoin-solidity/contracts/v0.8/MinerAPI.sol\\\";\\nimport \\\"@zondax/filecoin-solidity/contracts/v0.8/types/CommonTypes.sol\\\";\\n\\ncontract MinerPeerIDMapping {\\n struct PeerData {\\n string peerID;\\n bytes signedMessage;\\n }\\n\\n mapping(uint64 => PeerData) public minerToPeerData;\\n\\n // Events\\n event PeerDataAdded(uint64 indexed minerID, string peerID);\\n event PeerDataUpdated(uint64 indexed minerID, string oldPeerID, string newPeerID);\\n event PeerDataDeleted(uint64 indexed minerID);\\n\\n constructor() {\\n // The contract is immutable from the owner now, no ownership transfer is possible\\n }\\n\\n /**\\n * @notice Add a new PeerID and signed message for a MinerID in the contract.\\n * @param minerID The MinerID to associate with the new PeerID.\\n * @param newPeerID The new PeerID to bind to the MinerID.\\n * @param signedMessage The signed message to store.\\n */\\n function addPeerData(\\n uint64 minerID,\\n string memory newPeerID,\\n bytes memory signedMessage\\n ) public {\\n require(bytes(minerToPeerData[minerID].peerID).length == 0, \\\"Peer data already exists for this MinerID\\\");\\n\\n require(isControllingAddress(msg.sender, minerID), \\\"Caller is not the controlling address\\\");\\n\\n minerToPeerData[minerID] = PeerData(newPeerID, signedMessage);\\n\\n emit PeerDataAdded(minerID, newPeerID);\\n }\\n\\n /**\\n * @notice Update an existing PeerID and signed message for a MinerID in the contract.\\n * @param minerID The MinerID whose PeerID will be updated.\\n * @param newPeerID The new PeerID to bind to the MinerID.\\n * @param signedMessage The new signed message to store.\\n */\\n function updatePeerData(\\n uint64 minerID,\\n string memory newPeerID,\\n bytes memory signedMessage\\n ) public {\\n require(bytes(minerToPeerData[minerID].peerID).length > 0, \\\"No peer data exists for this MinerID\\\");\\n\\n require(isControllingAddress(msg.sender, minerID), \\\"Caller is not the controlling address\\\");\\n\\n string memory oldPeerID = minerToPeerData[minerID].peerID;\\n minerToPeerData[minerID] = PeerData(newPeerID, signedMessage);\\n\\n emit PeerDataUpdated(minerID, oldPeerID, newPeerID);\\n }\\n\\n /**\\n * @notice Delete an existing PeerID and signed message for a MinerID in the contract.\\n * @param minerID The MinerID whose peer data will be deleted.\\n */\\n function deletePeerData(uint64 minerID) public {\\n require(bytes(minerToPeerData[minerID].peerID).length > 0, \\\"No peer data exists for this MinerID\\\");\\n\\n require(isControllingAddress(msg.sender, minerID), \\\"Caller is not the controlling address\\\");\\n\\n delete minerToPeerData[minerID];\\n\\n emit PeerDataDeleted(minerID);\\n }\\n\\n /**\\n * @notice Fetch the PeerID and signed message associated with a MinerID.\\n * @param minerID The MinerID to query.\\n * @return The PeerID and signed message associated with the MinerID.\\n */\\n function getPeerData(uint64 minerID) public view returns (PeerData memory) {\\n return minerToPeerData[minerID];\\n }\\n\\n /**\\n * @notice Check if the caller is the controlling address for the given MinerID.\\n * @param caller The address of the caller.\\n * @param minerID The MinerID to check.\\n * @return True if the caller is the controlling address, false otherwise.\\n */\\n function isControllingAddress(address caller, uint64 minerID) internal returns (bool) {\\n // Wrap the uint64 miner ID into a FilActorId\\n CommonTypes.FilActorId minerActorID = CommonTypes.FilActorId.wrap(minerID);\\n\\n // Create a FilAddress for the caller\\n CommonTypes.FilAddress memory callerAddress = CommonTypes.FilAddress({data: abi.encodePacked(caller)});\\n\\n // Call the MinerAPI function\\n bool isControlling = MinerAPI.isControllingAddress(minerActorID, callerAddress);\\n\\n return isControlling;\\n }\\n}\\n\",\"keccak256\":\"0xe3939aa393e100a6952a85b921b3311ba380a59f77f533f4b7b8304d44143481\",\"license\":\"MIT\"},\"solidity-cborutils/contracts/CBOR.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.4;\\n\\nimport \\\"@ensdomains/buffer/contracts/Buffer.sol\\\";\\n\\n/**\\n* @dev A library for populating CBOR encoded payload in Solidity.\\n*\\n* https://datatracker.ietf.org/doc/html/rfc7049\\n*\\n* The library offers various write* and start* methods to encode values of different types.\\n* The resulted buffer can be obtained with data() method.\\n* Encoding of primitive types is staightforward, whereas encoding of sequences can result\\n* in an invalid CBOR if start/write/end flow is violated.\\n* For the purpose of gas saving, the library does not verify start/write/end flow internally,\\n* except for nested start/end pairs.\\n*/\\n\\nlibrary CBOR {\\n using Buffer for Buffer.buffer;\\n\\n struct CBORBuffer {\\n Buffer.buffer buf;\\n uint256 depth;\\n }\\n\\n uint8 private constant MAJOR_TYPE_INT = 0;\\n uint8 private constant MAJOR_TYPE_NEGATIVE_INT = 1;\\n uint8 private constant MAJOR_TYPE_BYTES = 2;\\n uint8 private constant MAJOR_TYPE_STRING = 3;\\n uint8 private constant MAJOR_TYPE_ARRAY = 4;\\n uint8 private constant MAJOR_TYPE_MAP = 5;\\n uint8 private constant MAJOR_TYPE_TAG = 6;\\n uint8 private constant MAJOR_TYPE_CONTENT_FREE = 7;\\n\\n uint8 private constant TAG_TYPE_BIGNUM = 2;\\n uint8 private constant TAG_TYPE_NEGATIVE_BIGNUM = 3;\\n\\n uint8 private constant CBOR_FALSE = 20;\\n uint8 private constant CBOR_TRUE = 21;\\n uint8 private constant CBOR_NULL = 22;\\n uint8 private constant CBOR_UNDEFINED = 23;\\n\\n function create(uint256 capacity) internal pure returns(CBORBuffer memory cbor) {\\n Buffer.init(cbor.buf, capacity);\\n cbor.depth = 0;\\n return cbor;\\n }\\n\\n function data(CBORBuffer memory buf) internal pure returns(bytes memory) {\\n require(buf.depth == 0, \\\"Invalid CBOR\\\");\\n return buf.buf.buf;\\n }\\n\\n function writeUInt256(CBORBuffer memory buf, uint256 value) internal pure {\\n buf.buf.appendUint8(uint8((MAJOR_TYPE_TAG << 5) | TAG_TYPE_BIGNUM));\\n writeBytes(buf, abi.encode(value));\\n }\\n\\n function writeInt256(CBORBuffer memory buf, int256 value) internal pure {\\n if (value < 0) {\\n buf.buf.appendUint8(\\n uint8((MAJOR_TYPE_TAG << 5) | TAG_TYPE_NEGATIVE_BIGNUM)\\n );\\n writeBytes(buf, abi.encode(uint256(-1 - value)));\\n } else {\\n writeUInt256(buf, uint256(value));\\n }\\n }\\n\\n function writeUInt64(CBORBuffer memory buf, uint64 value) internal pure {\\n writeFixedNumeric(buf, MAJOR_TYPE_INT, value);\\n }\\n\\n function writeInt64(CBORBuffer memory buf, int64 value) internal pure {\\n if(value >= 0) {\\n writeFixedNumeric(buf, MAJOR_TYPE_INT, uint64(value));\\n } else{\\n writeFixedNumeric(buf, MAJOR_TYPE_NEGATIVE_INT, uint64(-1 - value));\\n }\\n }\\n\\n function writeBytes(CBORBuffer memory buf, bytes memory value) internal pure {\\n writeFixedNumeric(buf, MAJOR_TYPE_BYTES, uint64(value.length));\\n buf.buf.append(value);\\n }\\n\\n function writeString(CBORBuffer memory buf, string memory value) internal pure {\\n writeFixedNumeric(buf, MAJOR_TYPE_STRING, uint64(bytes(value).length));\\n buf.buf.append(bytes(value));\\n }\\n\\n function writeBool(CBORBuffer memory buf, bool value) internal pure {\\n writeContentFree(buf, value ? CBOR_TRUE : CBOR_FALSE);\\n }\\n\\n function writeNull(CBORBuffer memory buf) internal pure {\\n writeContentFree(buf, CBOR_NULL);\\n }\\n\\n function writeUndefined(CBORBuffer memory buf) internal pure {\\n writeContentFree(buf, CBOR_UNDEFINED);\\n }\\n\\n function startArray(CBORBuffer memory buf) internal pure {\\n writeIndefiniteLengthType(buf, MAJOR_TYPE_ARRAY);\\n buf.depth += 1;\\n }\\n\\n function startFixedArray(CBORBuffer memory buf, uint64 length) internal pure {\\n writeDefiniteLengthType(buf, MAJOR_TYPE_ARRAY, length);\\n }\\n\\n function startMap(CBORBuffer memory buf) internal pure {\\n writeIndefiniteLengthType(buf, MAJOR_TYPE_MAP);\\n buf.depth += 1;\\n }\\n\\n function startFixedMap(CBORBuffer memory buf, uint64 length) internal pure {\\n writeDefiniteLengthType(buf, MAJOR_TYPE_MAP, length);\\n }\\n\\n function endSequence(CBORBuffer memory buf) internal pure {\\n writeIndefiniteLengthType(buf, MAJOR_TYPE_CONTENT_FREE);\\n buf.depth -= 1;\\n }\\n\\n function writeKVString(CBORBuffer memory buf, string memory key, string memory value) internal pure {\\n writeString(buf, key);\\n writeString(buf, value);\\n }\\n\\n function writeKVBytes(CBORBuffer memory buf, string memory key, bytes memory value) internal pure {\\n writeString(buf, key);\\n writeBytes(buf, value);\\n }\\n\\n function writeKVUInt256(CBORBuffer memory buf, string memory key, uint256 value) internal pure {\\n writeString(buf, key);\\n writeUInt256(buf, value);\\n }\\n\\n function writeKVInt256(CBORBuffer memory buf, string memory key, int256 value) internal pure {\\n writeString(buf, key);\\n writeInt256(buf, value);\\n }\\n\\n function writeKVUInt64(CBORBuffer memory buf, string memory key, uint64 value) internal pure {\\n writeString(buf, key);\\n writeUInt64(buf, value);\\n }\\n\\n function writeKVInt64(CBORBuffer memory buf, string memory key, int64 value) internal pure {\\n writeString(buf, key);\\n writeInt64(buf, value);\\n }\\n\\n function writeKVBool(CBORBuffer memory buf, string memory key, bool value) internal pure {\\n writeString(buf, key);\\n writeBool(buf, value);\\n }\\n\\n function writeKVNull(CBORBuffer memory buf, string memory key) internal pure {\\n writeString(buf, key);\\n writeNull(buf);\\n }\\n\\n function writeKVUndefined(CBORBuffer memory buf, string memory key) internal pure {\\n writeString(buf, key);\\n writeUndefined(buf);\\n }\\n\\n function writeKVMap(CBORBuffer memory buf, string memory key) internal pure {\\n writeString(buf, key);\\n startMap(buf);\\n }\\n\\n function writeKVArray(CBORBuffer memory buf, string memory key) internal pure {\\n writeString(buf, key);\\n startArray(buf);\\n }\\n\\n function writeFixedNumeric(\\n CBORBuffer memory buf,\\n uint8 major,\\n uint64 value\\n ) private pure {\\n if (value <= 23) {\\n buf.buf.appendUint8(uint8((major << 5) | value));\\n } else if (value <= 0xFF) {\\n buf.buf.appendUint8(uint8((major << 5) | 24));\\n buf.buf.appendInt(value, 1);\\n } else if (value <= 0xFFFF) {\\n buf.buf.appendUint8(uint8((major << 5) | 25));\\n buf.buf.appendInt(value, 2);\\n } else if (value <= 0xFFFFFFFF) {\\n buf.buf.appendUint8(uint8((major << 5) | 26));\\n buf.buf.appendInt(value, 4);\\n } else {\\n buf.buf.appendUint8(uint8((major << 5) | 27));\\n buf.buf.appendInt(value, 8);\\n }\\n }\\n\\n function writeIndefiniteLengthType(CBORBuffer memory buf, uint8 major)\\n private\\n pure\\n {\\n buf.buf.appendUint8(uint8((major << 5) | 31));\\n }\\n\\n function writeDefiniteLengthType(CBORBuffer memory buf, uint8 major, uint64 length)\\n private\\n pure\\n {\\n writeFixedNumeric(buf, major, length);\\n }\\n\\n function writeContentFree(CBORBuffer memory buf, uint8 value) private pure {\\n buf.buf.appendUint8(uint8((MAJOR_TYPE_CONTENT_FREE << 5) | value));\\n }\\n}\",\"keccak256\":\"0xe03d8889bf66e7a30e8010b022b6c86ad0f8c19764cc6c7f50b6bb4ad860cb9b\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50611de9806100206000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c80633e2eac07116100505780633e2eac07146100ab57806376d81bd8146100cb5780639b9b0030146100de57600080fd5b80630ba149f31461006c5780631768dd2714610081575b600080fd5b61007f61007a3660046113dc565b6100f1565b005b61009461008f366004611462565b6101fd565b6040516100a29291906114d9565b60405180910390f35b6100be6100b9366004611462565b610329565b6040516100a29190611530565b61007f6100d93660046113dc565b61048a565b61007f6100ec366004611462565b610639565b67ffffffffffffffff83166000908152602081905260409020805461011590611557565b15905061013d5760405162461bcd60e51b8152600401610134906115e0565b60405180910390fd5b610147338461070e565b6101635760405162461bcd60e51b81526004016101349061164a565b604080518082018252838152602080820184905267ffffffffffffffff8616600090815290819052919091208151819061019d90826116f9565b50602082015160018201906101b290826116f9565b509050508267ffffffffffffffff167f4773104dfc3f54d3e3c74b1e3701be51e0b85f9b40327b9f23299c62290a24d6836040516101f091906117bd565b60405180910390a2505050565b60006020819052908152604090208054819061021890611557565b80601f016020809104026020016040519081016040528092919081815260200182805461024490611557565b80156102915780601f1061026657610100808354040283529160200191610291565b820191906000526020600020905b81548152906001019060200180831161027457829003601f168201915b5050505050908060010180546102a690611557565b80601f01602080910402602001604051908101604052809291908181526020018280546102d290611557565b801561031f5780601f106102f45761010080835404028352916020019161031f565b820191906000526020600020905b81548152906001019060200180831161030257829003601f168201915b5050505050905082565b604080518082019091526060808252602082015267ffffffffffffffff821660009081526020819052604090819020815180830190925280548290829061036f90611557565b80601f016020809104026020016040519081016040528092919081815260200182805461039b90611557565b80156103e85780601f106103bd576101008083540402835291602001916103e8565b820191906000526020600020905b8154815290600101906020018083116103cb57829003601f168201915b5050505050815260200160018201805461040190611557565b80601f016020809104026020016040519081016040528092919081815260200182805461042d90611557565b801561047a5780601f1061044f5761010080835404028352916020019161047a565b820191906000526020600020905b81548152906001019060200180831161045d57829003601f168201915b5050505050815250509050919050565b67ffffffffffffffff8316600090815260208190526040812080546104ae90611557565b9050116104cd5760405162461bcd60e51b815260040161013490611828565b6104d7338461070e565b6104f35760405162461bcd60e51b81526004016101349061164a565b67ffffffffffffffff83166000908152602081905260408120805461051790611557565b80601f016020809104026020016040519081016040528092919081815260200182805461054390611557565b80156105905780601f1061056557610100808354040283529160200191610590565b820191906000526020600020905b81548152906001019060200180831161057357829003601f168201915b5050604080518082018252888152602080820189905267ffffffffffffffff8b1660009081529081905291909120815195965090949093508392506105d69150826116f9565b50602082015160018201906105eb90826116f9565b509050508367ffffffffffffffff167fcf89288f93fcf9c864295f589ce6d46880f5c5c570a1fba5d1419c48bc3aa252828560405161062b9291906114d9565b60405180910390a250505050565b67ffffffffffffffff81166000908152602081905260408120805461065d90611557565b90501161067c5760405162461bcd60e51b815260040161013490611828565b610686338261070e565b6106a25760405162461bcd60e51b81526004016101349061164a565b67ffffffffffffffff81166000908152602081905260408120906106c68282611234565b6106d4600183016000611234565b505060405167ffffffffffffffff8216907fdb4dc10059cc48dd78b522c4d9c235a47463d5af55feb03dff25f92d7534fd8490600090a250565b60008082905060006040518060200160405280866040516020016107329190611884565b60405160208183030381529060405281525090506000610752838361075e565b93505050505b92915050565b60008061076a83610797565b90506000610783856314c1cb97605185600060016107d6565b905061078e81610838565b95945050505050565b606060006107a8836000015161084f565b905060006107b582610867565b84519091506107c5908290610888565b6107ce816108a6565b949350505050565b606060648767ffffffffffffffff16101561081f57866040517fa292827300000000000000000000000000000000000000000000000000000000815260040161013491906118b4565b61082d8787878787876108d2565b979650505050505050565b6000808061084684826109df565b50949350505050565b6000815161085d8351610a4b565b61075891906118d8565b61086f611271565b805161087b9083610a99565b5060006020820152919050565b6108958260028351610b10565b81516108a19082610c37565b505050565b606081602001516000146108cc5760405162461bcd60e51b815260040161013490611922565b50515190565b60606108f273fe0000000000000000000000000000000000000584610c5f565b60008073fe0000000000000000000000000000000000000588868661091857600061091b565b60015b8a8a8e60405160200161093396959493929190611948565b60408051601f198184030181529082905261094d916119c0565b600060405180830381855af49150503d8060008114610988576040519150601f19603f3d011682016040523d82523d6000602084013e61098d565b606091505b5091509150816109c9576040517f8a7db5bf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109d281610cd9565b9998505050505050505050565b6000806000806109ef8686610de7565b965090925067ffffffffffffffff16905060ff8216600714610a235760405162461bcd60e51b815260040161013490611a00565b6015811480610a325750601481145b610a3e57610a3e611a10565b6014141595939450505050565b600060178211610a5d57506001919050565b60ff8211610a6d57506002919050565b61ffff8211610a7e57506003919050565b63ffffffff8211610a9157506005919050565b506009919050565b604080518082019091526060815260006020820152610ab9602083611a3c565b15610ae157610ac9602083611a3c565b610ad4906020611a50565b610ade90836118d8565b91505b602080840183905260405180855260008152908184010181811015610b0557600080fd5b604052509192915050565b60178167ffffffffffffffff1611610b3d578251610b379060e0600585901b168317610f64565b50505050565b60ff8167ffffffffffffffff1611610b7f578251610b66906018611fe0600586901b1617610f64565b508251610b379067ffffffffffffffff83166001610fcd565b61ffff8167ffffffffffffffff1611610bc2578251610ba9906019611fe0600586901b1617610f64565b508251610b379067ffffffffffffffff83166002610fcd565b63ffffffff8167ffffffffffffffff1611610c07578251610bee90601a611fe0600586901b1617610f64565b508251610b379067ffffffffffffffff83166004610fcd565b8251610c1e90601b611fe0600586901b1617610f64565b508251610b379067ffffffffffffffff83166008610fcd565b604080518082019091526060815260006020820152610c5883838451611052565b9392505050565b4781811015610c9e5780826040517f8f0f4206000000000000000000000000000000000000000000000000000000008152600401610134929190611a63565b823f151580610b37576040517f64d954b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6060600080600084806020019051810190610cf49190611af2565b9194509250905067ffffffffffffffff8216610d2f57805115610d2a57604051630e74990760e01b815260040160405180910390fd5b610dad565b67ffffffffffffffff821660511480610d52575067ffffffffffffffff82166071145b15610d79578051600003610d2a57604051630e74990760e01b815260040160405180910390fd5b816040517ff1f6bced0000000000000000000000000000000000000000000000000000000081526004016101349190611b53565b82156107ce57826040517fd4bb66710000000000000000000000000000000000000000000000000000000081526004016101349190611b61565b600080600080610df78686611123565b9050610e046001866118d8565b94506007600582901c16601f8216601c8110610e325760405162461bcd60e51b815260040161013490611bc9565b60188160ff161015610e505790945060ff169250849150610f5d9050565b8060ff16601803610ead576000610e678989611123565b9050610e746001896118d8565b975060188160ff161015610e9a5760405162461bcd60e51b815260040161013490611c0d565b9195505060ff169250849150610f5d9050565b8060ff16601903610ee7576000610ec48989611172565b9050610ed16002896118d8565b97509195505061ffff169250849150610f5d9050565b8060ff16601a03610f23576000610efe89896111ab565b9050610f0b6004896118d8565b97509195505063ffffffff169250849150610f5d9050565b8060ff16601b14610f3657610f36611a10565b6000610f4289896111e4565b9050610f4f6008896118d8565b975091955090935085925050505b9250925092565b6040805180820190915260608152600060208201528251516000610f898260016118d8565b905084602001518210610faa57610faa85610fa5836002611c1d565b61121d565b84516020838201018581538151831115610fc2578282525b509495945050505050565b6040805180820190915260608152600060208201528351516000610ff182856118d8565b9050856020015181111561100e5761100e86610fa5836002611c1d565b6000600161101e86610100611d4a565b6110289190611a50565b905086518281018783198251161781528151841115611045578382525b5096979650505050505050565b604080518082019091526060815260006020820152825182111561107557600080fd5b835151600061108484836118d8565b905085602001518111156110a1576110a186610fa5836002611c1d565b8551805183820160200191600091808511156110bb578482525b505050602086015b602086106110fb57805182526110da6020836118d8565b91506110e76020826118d8565b90506110f4602087611a50565b95506110c3565b51815160001960208890036101000a0190811690199190911617905250849150509392505050565b60006111308260016118d8565b835110156111505760405162461bcd60e51b815260040161013490611d8d565b82828151811061116257611162611d9d565b016020015160f81c905092915050565b600061117f8260026118d8565b8351101561119f5760405162461bcd60e51b815260040161013490611d8d565b50016020015160f01c90565b60006111b88260046118d8565b835110156111d85760405162461bcd60e51b815260040161013490611d8d565b50016020015160e01c90565b60006111f18260086118d8565b835110156112115760405162461bcd60e51b815260040161013490611d8d565b50016020015160c01c90565b81516112298383610a99565b50610b378382610c37565b50805461124090611557565b6000825580601f10611250575050565b601f01602090049060005260206000209081019061126e91906112a6565b50565b6040518060400160405280611299604051806040016040528060608152602001600081525090565b8152602001600081525090565b5b808211156112bb57600081556001016112a7565b5090565b67ffffffffffffffff81165b811461126e57600080fd5b8035610758816112bf565b634e487b7160e01b600052604160045260246000fd5b601f19601f830116810181811067ffffffffffffffff8211171561131d5761131d6112e1565b6040525050565b600061132f60405190565b905061133b82826112f7565b919050565b600067ffffffffffffffff82111561135a5761135a6112e1565b601f19601f83011660200192915050565b82818337506000910152565b600061138a61138584611340565b611324565b9050828152602081018484840111156113a5576113a5600080fd5b6113b084828561136b565b509392505050565b600082601f8301126113cc576113cc600080fd5b81356107ce848260208601611377565b6000806000606084860312156113f4576113f4600080fd5b600061140086866112d6565b935050602084013567ffffffffffffffff81111561142057611420600080fd5b61142c868287016113b8565b925050604084013567ffffffffffffffff81111561144c5761144c600080fd5b611458868287016113b8565b9150509250925092565b60006020828403121561147757611477600080fd5b60006107ce84846112d6565b60005b8381101561149e578181015183820152602001611486565b50506000910152565b60006114b1825190565b8084526020840193506114c8818560208601611483565b601f01601f19169290920192915050565b604080825281016114ea81856114a7565b905081810360208301526107ce81846114a7565b805160408084526000919084019061151682826114a7565b9150506020830151848203602086015261078e82826114a7565b60208082528101610c5881846114fe565b634e487b7160e01b600052602260045260246000fd5b60028104600182168061156b57607f821691505b60208210810361157d5761157d611541565b50919050565b602981526000602082017f50656572206461746120616c72656164792065786973747320666f722074686981527f73204d696e657249440000000000000000000000000000000000000000000000602082015291505b5060400190565b6020808252810161075881611583565b602581526000602082017f43616c6c6572206973206e6f742074686520636f6e74726f6c6c696e6720616481527f6472657373000000000000000000000000000000000000000000000000000000602082015291506115d9565b60208082528101610758816115f0565b60006107586116668381565b90565b6116728361165a565b815460001960089490940293841b1916921b91909117905550565b60006108a1818484611669565b818110156116b5576116ad60008261168d565b60010161169a565b5050565b601f8211156108a1576000818152602090206020601f850104810160208510156116e05750805b6116f26020601f86010483018261169a565b5050505050565b815167ffffffffffffffff811115611713576117136112e1565b61171d8254611557565b6117288282856116b9565b6020601f83116001811461175c57600084156117445750858201515b600019600886021c19811660028602178655506117b5565b600085815260208120601f198616915b8281101561178c578885015182556020948501946001909201910161176c565b868310156117a85784890151600019601f89166008021c191682555b6001600288020188555050505b505050505050565b60208082528101610c5881846114a7565b602481526000602082017f4e6f207065657220646174612065786973747320666f722074686973204d696e81527f6572494400000000000000000000000000000000000000000000000000000000602082015291506115d9565b60208082528101610758816117ce565b600073ffffffffffffffffffffffffffffffffffffffff8216610758565b60006107588260601b90565b600061075882611856565b61187e61187982611838565b611862565b82525050565b6000611890828461186d565b50601401919050565b600067ffffffffffffffff8216610758565b61187e81611899565b6020810161075882846118ab565b634e487b7160e01b600052601160045260246000fd5b80820180821115610758576107586118c2565b600c81526000602082017f496e76616c69642043424f520000000000000000000000000000000000000000815291505b5060200190565b60208082528101610758816118eb565b67ffffffffffffffff811661187e565b8061187e565b60c081016119568289611932565b6119636020830188611942565b6119706040830187611932565b61197d6060830186611932565b818103608083015261198f81856114a7565b905061082d60a08301846118ab565b60006119a8825190565b6119b6818560208601611483565b9290920192915050565b6000610c58828461199e565b601f81526000602082017f696e76616c6964206d616a20286578706563746564204d616a4f7468657229008152915061191b565b60208082528101610758816119cc565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b600082611a4b57611a4b611a26565b500690565b81810381811115610758576107586118c2565b60408101611a718285611942565b610c586020830184611942565b806112cb565b805161075881611a7e565b8051610758816112bf565b6000611aa861138584611340565b905082815260208101848484011115611ac357611ac3600080fd5b6113b0848285611483565b600082601f830112611ae257611ae2600080fd5b81516107ce848260208601611a9a565b600080600060608486031215611b0a57611b0a600080fd5b6000611b168686611a84565b9350506020611b2786828701611a8f565b925050604084015167ffffffffffffffff811115611b4757611b47600080fd5b61145886828701611ace565b602081016107588284611932565b602081016107588284611942565b602581526000602082017f63616e6e6f742068616e646c652068656164657273207769746820657874726181527f203e203237000000000000000000000000000000000000000000000000000000602082015291506115d9565b6020808252810161075881611b6f565b600c81526000602082017f696e76616c69642063626f7200000000000000000000000000000000000000008152915061191b565b6020808252810161075881611bd9565b818102808215838204851417611c3557611c356118c2565b5092915050565b80825b6001851115611c7b57808604811115611c5a57611c5a6118c2565b6001851615611c6857908102905b8002611c748560011c90565b9450611c3f565b94509492505050565b600082611c9357506001610c58565b81611ca057506000610c58565b8160018114611cb65760028114611cc057611ced565b6001915050610c58565b60ff841115611cd157611cd16118c2565b8360020a915084821115611ce757611ce76118c2565b50610c58565b5060208310610133831016604e8410600b8410161715611d20575081810a83811115611d1b57611d1b6118c2565b610c58565b611d2d8484846001611c3c565b92509050818404811115611d4357611d436118c2565b0292915050565b6000610c586000198484611c84565b601481526000602082017f736c6963696e67206f7574206f662072616e67650000000000000000000000008152915061191b565b6020808252810161075881611d59565b634e487b7160e01b600052603260045260246000fdfea26469706673582212207dc4c93c3f9bf16a0acf690239af65fe2c7828501afaf04c121e47011c1a9ed864736f6c63430008170033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100675760003560e01c80633e2eac07116100505780633e2eac07146100ab57806376d81bd8146100cb5780639b9b0030146100de57600080fd5b80630ba149f31461006c5780631768dd2714610081575b600080fd5b61007f61007a3660046113dc565b6100f1565b005b61009461008f366004611462565b6101fd565b6040516100a29291906114d9565b60405180910390f35b6100be6100b9366004611462565b610329565b6040516100a29190611530565b61007f6100d93660046113dc565b61048a565b61007f6100ec366004611462565b610639565b67ffffffffffffffff83166000908152602081905260409020805461011590611557565b15905061013d5760405162461bcd60e51b8152600401610134906115e0565b60405180910390fd5b610147338461070e565b6101635760405162461bcd60e51b81526004016101349061164a565b604080518082018252838152602080820184905267ffffffffffffffff8616600090815290819052919091208151819061019d90826116f9565b50602082015160018201906101b290826116f9565b509050508267ffffffffffffffff167f4773104dfc3f54d3e3c74b1e3701be51e0b85f9b40327b9f23299c62290a24d6836040516101f091906117bd565b60405180910390a2505050565b60006020819052908152604090208054819061021890611557565b80601f016020809104026020016040519081016040528092919081815260200182805461024490611557565b80156102915780601f1061026657610100808354040283529160200191610291565b820191906000526020600020905b81548152906001019060200180831161027457829003601f168201915b5050505050908060010180546102a690611557565b80601f01602080910402602001604051908101604052809291908181526020018280546102d290611557565b801561031f5780601f106102f45761010080835404028352916020019161031f565b820191906000526020600020905b81548152906001019060200180831161030257829003601f168201915b5050505050905082565b604080518082019091526060808252602082015267ffffffffffffffff821660009081526020819052604090819020815180830190925280548290829061036f90611557565b80601f016020809104026020016040519081016040528092919081815260200182805461039b90611557565b80156103e85780601f106103bd576101008083540402835291602001916103e8565b820191906000526020600020905b8154815290600101906020018083116103cb57829003601f168201915b5050505050815260200160018201805461040190611557565b80601f016020809104026020016040519081016040528092919081815260200182805461042d90611557565b801561047a5780601f1061044f5761010080835404028352916020019161047a565b820191906000526020600020905b81548152906001019060200180831161045d57829003601f168201915b5050505050815250509050919050565b67ffffffffffffffff8316600090815260208190526040812080546104ae90611557565b9050116104cd5760405162461bcd60e51b815260040161013490611828565b6104d7338461070e565b6104f35760405162461bcd60e51b81526004016101349061164a565b67ffffffffffffffff83166000908152602081905260408120805461051790611557565b80601f016020809104026020016040519081016040528092919081815260200182805461054390611557565b80156105905780601f1061056557610100808354040283529160200191610590565b820191906000526020600020905b81548152906001019060200180831161057357829003601f168201915b5050604080518082018252888152602080820189905267ffffffffffffffff8b1660009081529081905291909120815195965090949093508392506105d69150826116f9565b50602082015160018201906105eb90826116f9565b509050508367ffffffffffffffff167fcf89288f93fcf9c864295f589ce6d46880f5c5c570a1fba5d1419c48bc3aa252828560405161062b9291906114d9565b60405180910390a250505050565b67ffffffffffffffff81166000908152602081905260408120805461065d90611557565b90501161067c5760405162461bcd60e51b815260040161013490611828565b610686338261070e565b6106a25760405162461bcd60e51b81526004016101349061164a565b67ffffffffffffffff81166000908152602081905260408120906106c68282611234565b6106d4600183016000611234565b505060405167ffffffffffffffff8216907fdb4dc10059cc48dd78b522c4d9c235a47463d5af55feb03dff25f92d7534fd8490600090a250565b60008082905060006040518060200160405280866040516020016107329190611884565b60405160208183030381529060405281525090506000610752838361075e565b93505050505b92915050565b60008061076a83610797565b90506000610783856314c1cb97605185600060016107d6565b905061078e81610838565b95945050505050565b606060006107a8836000015161084f565b905060006107b582610867565b84519091506107c5908290610888565b6107ce816108a6565b949350505050565b606060648767ffffffffffffffff16101561081f57866040517fa292827300000000000000000000000000000000000000000000000000000000815260040161013491906118b4565b61082d8787878787876108d2565b979650505050505050565b6000808061084684826109df565b50949350505050565b6000815161085d8351610a4b565b61075891906118d8565b61086f611271565b805161087b9083610a99565b5060006020820152919050565b6108958260028351610b10565b81516108a19082610c37565b505050565b606081602001516000146108cc5760405162461bcd60e51b815260040161013490611922565b50515190565b60606108f273fe0000000000000000000000000000000000000584610c5f565b60008073fe0000000000000000000000000000000000000588868661091857600061091b565b60015b8a8a8e60405160200161093396959493929190611948565b60408051601f198184030181529082905261094d916119c0565b600060405180830381855af49150503d8060008114610988576040519150601f19603f3d011682016040523d82523d6000602084013e61098d565b606091505b5091509150816109c9576040517f8a7db5bf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109d281610cd9565b9998505050505050505050565b6000806000806109ef8686610de7565b965090925067ffffffffffffffff16905060ff8216600714610a235760405162461bcd60e51b815260040161013490611a00565b6015811480610a325750601481145b610a3e57610a3e611a10565b6014141595939450505050565b600060178211610a5d57506001919050565b60ff8211610a6d57506002919050565b61ffff8211610a7e57506003919050565b63ffffffff8211610a9157506005919050565b506009919050565b604080518082019091526060815260006020820152610ab9602083611a3c565b15610ae157610ac9602083611a3c565b610ad4906020611a50565b610ade90836118d8565b91505b602080840183905260405180855260008152908184010181811015610b0557600080fd5b604052509192915050565b60178167ffffffffffffffff1611610b3d578251610b379060e0600585901b168317610f64565b50505050565b60ff8167ffffffffffffffff1611610b7f578251610b66906018611fe0600586901b1617610f64565b508251610b379067ffffffffffffffff83166001610fcd565b61ffff8167ffffffffffffffff1611610bc2578251610ba9906019611fe0600586901b1617610f64565b508251610b379067ffffffffffffffff83166002610fcd565b63ffffffff8167ffffffffffffffff1611610c07578251610bee90601a611fe0600586901b1617610f64565b508251610b379067ffffffffffffffff83166004610fcd565b8251610c1e90601b611fe0600586901b1617610f64565b508251610b379067ffffffffffffffff83166008610fcd565b604080518082019091526060815260006020820152610c5883838451611052565b9392505050565b4781811015610c9e5780826040517f8f0f4206000000000000000000000000000000000000000000000000000000008152600401610134929190611a63565b823f151580610b37576040517f64d954b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6060600080600084806020019051810190610cf49190611af2565b9194509250905067ffffffffffffffff8216610d2f57805115610d2a57604051630e74990760e01b815260040160405180910390fd5b610dad565b67ffffffffffffffff821660511480610d52575067ffffffffffffffff82166071145b15610d79578051600003610d2a57604051630e74990760e01b815260040160405180910390fd5b816040517ff1f6bced0000000000000000000000000000000000000000000000000000000081526004016101349190611b53565b82156107ce57826040517fd4bb66710000000000000000000000000000000000000000000000000000000081526004016101349190611b61565b600080600080610df78686611123565b9050610e046001866118d8565b94506007600582901c16601f8216601c8110610e325760405162461bcd60e51b815260040161013490611bc9565b60188160ff161015610e505790945060ff169250849150610f5d9050565b8060ff16601803610ead576000610e678989611123565b9050610e746001896118d8565b975060188160ff161015610e9a5760405162461bcd60e51b815260040161013490611c0d565b9195505060ff169250849150610f5d9050565b8060ff16601903610ee7576000610ec48989611172565b9050610ed16002896118d8565b97509195505061ffff169250849150610f5d9050565b8060ff16601a03610f23576000610efe89896111ab565b9050610f0b6004896118d8565b97509195505063ffffffff169250849150610f5d9050565b8060ff16601b14610f3657610f36611a10565b6000610f4289896111e4565b9050610f4f6008896118d8565b975091955090935085925050505b9250925092565b6040805180820190915260608152600060208201528251516000610f898260016118d8565b905084602001518210610faa57610faa85610fa5836002611c1d565b61121d565b84516020838201018581538151831115610fc2578282525b509495945050505050565b6040805180820190915260608152600060208201528351516000610ff182856118d8565b9050856020015181111561100e5761100e86610fa5836002611c1d565b6000600161101e86610100611d4a565b6110289190611a50565b905086518281018783198251161781528151841115611045578382525b5096979650505050505050565b604080518082019091526060815260006020820152825182111561107557600080fd5b835151600061108484836118d8565b905085602001518111156110a1576110a186610fa5836002611c1d565b8551805183820160200191600091808511156110bb578482525b505050602086015b602086106110fb57805182526110da6020836118d8565b91506110e76020826118d8565b90506110f4602087611a50565b95506110c3565b51815160001960208890036101000a0190811690199190911617905250849150509392505050565b60006111308260016118d8565b835110156111505760405162461bcd60e51b815260040161013490611d8d565b82828151811061116257611162611d9d565b016020015160f81c905092915050565b600061117f8260026118d8565b8351101561119f5760405162461bcd60e51b815260040161013490611d8d565b50016020015160f01c90565b60006111b88260046118d8565b835110156111d85760405162461bcd60e51b815260040161013490611d8d565b50016020015160e01c90565b60006111f18260086118d8565b835110156112115760405162461bcd60e51b815260040161013490611d8d565b50016020015160c01c90565b81516112298383610a99565b50610b378382610c37565b50805461124090611557565b6000825580601f10611250575050565b601f01602090049060005260206000209081019061126e91906112a6565b50565b6040518060400160405280611299604051806040016040528060608152602001600081525090565b8152602001600081525090565b5b808211156112bb57600081556001016112a7565b5090565b67ffffffffffffffff81165b811461126e57600080fd5b8035610758816112bf565b634e487b7160e01b600052604160045260246000fd5b601f19601f830116810181811067ffffffffffffffff8211171561131d5761131d6112e1565b6040525050565b600061132f60405190565b905061133b82826112f7565b919050565b600067ffffffffffffffff82111561135a5761135a6112e1565b601f19601f83011660200192915050565b82818337506000910152565b600061138a61138584611340565b611324565b9050828152602081018484840111156113a5576113a5600080fd5b6113b084828561136b565b509392505050565b600082601f8301126113cc576113cc600080fd5b81356107ce848260208601611377565b6000806000606084860312156113f4576113f4600080fd5b600061140086866112d6565b935050602084013567ffffffffffffffff81111561142057611420600080fd5b61142c868287016113b8565b925050604084013567ffffffffffffffff81111561144c5761144c600080fd5b611458868287016113b8565b9150509250925092565b60006020828403121561147757611477600080fd5b60006107ce84846112d6565b60005b8381101561149e578181015183820152602001611486565b50506000910152565b60006114b1825190565b8084526020840193506114c8818560208601611483565b601f01601f19169290920192915050565b604080825281016114ea81856114a7565b905081810360208301526107ce81846114a7565b805160408084526000919084019061151682826114a7565b9150506020830151848203602086015261078e82826114a7565b60208082528101610c5881846114fe565b634e487b7160e01b600052602260045260246000fd5b60028104600182168061156b57607f821691505b60208210810361157d5761157d611541565b50919050565b602981526000602082017f50656572206461746120616c72656164792065786973747320666f722074686981527f73204d696e657249440000000000000000000000000000000000000000000000602082015291505b5060400190565b6020808252810161075881611583565b602581526000602082017f43616c6c6572206973206e6f742074686520636f6e74726f6c6c696e6720616481527f6472657373000000000000000000000000000000000000000000000000000000602082015291506115d9565b60208082528101610758816115f0565b60006107586116668381565b90565b6116728361165a565b815460001960089490940293841b1916921b91909117905550565b60006108a1818484611669565b818110156116b5576116ad60008261168d565b60010161169a565b5050565b601f8211156108a1576000818152602090206020601f850104810160208510156116e05750805b6116f26020601f86010483018261169a565b5050505050565b815167ffffffffffffffff811115611713576117136112e1565b61171d8254611557565b6117288282856116b9565b6020601f83116001811461175c57600084156117445750858201515b600019600886021c19811660028602178655506117b5565b600085815260208120601f198616915b8281101561178c578885015182556020948501946001909201910161176c565b868310156117a85784890151600019601f89166008021c191682555b6001600288020188555050505b505050505050565b60208082528101610c5881846114a7565b602481526000602082017f4e6f207065657220646174612065786973747320666f722074686973204d696e81527f6572494400000000000000000000000000000000000000000000000000000000602082015291506115d9565b60208082528101610758816117ce565b600073ffffffffffffffffffffffffffffffffffffffff8216610758565b60006107588260601b90565b600061075882611856565b61187e61187982611838565b611862565b82525050565b6000611890828461186d565b50601401919050565b600067ffffffffffffffff8216610758565b61187e81611899565b6020810161075882846118ab565b634e487b7160e01b600052601160045260246000fd5b80820180821115610758576107586118c2565b600c81526000602082017f496e76616c69642043424f520000000000000000000000000000000000000000815291505b5060200190565b60208082528101610758816118eb565b67ffffffffffffffff811661187e565b8061187e565b60c081016119568289611932565b6119636020830188611942565b6119706040830187611932565b61197d6060830186611932565b818103608083015261198f81856114a7565b905061082d60a08301846118ab565b60006119a8825190565b6119b6818560208601611483565b9290920192915050565b6000610c58828461199e565b601f81526000602082017f696e76616c6964206d616a20286578706563746564204d616a4f7468657229008152915061191b565b60208082528101610758816119cc565b634e487b7160e01b600052600160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b600082611a4b57611a4b611a26565b500690565b81810381811115610758576107586118c2565b60408101611a718285611942565b610c586020830184611942565b806112cb565b805161075881611a7e565b8051610758816112bf565b6000611aa861138584611340565b905082815260208101848484011115611ac357611ac3600080fd5b6113b0848285611483565b600082601f830112611ae257611ae2600080fd5b81516107ce848260208601611a9a565b600080600060608486031215611b0a57611b0a600080fd5b6000611b168686611a84565b9350506020611b2786828701611a8f565b925050604084015167ffffffffffffffff811115611b4757611b47600080fd5b61145886828701611ace565b602081016107588284611932565b602081016107588284611942565b602581526000602082017f63616e6e6f742068616e646c652068656164657273207769746820657874726181527f203e203237000000000000000000000000000000000000000000000000000000602082015291506115d9565b6020808252810161075881611b6f565b600c81526000602082017f696e76616c69642063626f7200000000000000000000000000000000000000008152915061191b565b6020808252810161075881611bd9565b818102808215838204851417611c3557611c356118c2565b5092915050565b80825b6001851115611c7b57808604811115611c5a57611c5a6118c2565b6001851615611c6857908102905b8002611c748560011c90565b9450611c3f565b94509492505050565b600082611c9357506001610c58565b81611ca057506000610c58565b8160018114611cb65760028114611cc057611ced565b6001915050610c58565b60ff841115611cd157611cd16118c2565b8360020a915084821115611ce757611ce76118c2565b50610c58565b5060208310610133831016604e8410600b8410161715611d20575081810a83811115611d1b57611d1b6118c2565b610c58565b611d2d8484846001611c3c565b92509050818404811115611d4357611d436118c2565b0292915050565b6000610c586000198484611c84565b601481526000602082017f736c6963696e67206f7574206f662072616e67650000000000000000000000008152915061191b565b6020808252810161075881611d59565b634e487b7160e01b600052603260045260246000fdfea26469706673582212207dc4c93c3f9bf16a0acf690239af65fe2c7828501afaf04c121e47011c1a9ed864736f6c63430008170033", + "devdoc": { + "kind": "dev", + "methods": { + "addPeerData(uint64,string,bytes)": { + "params": { + "minerID": "The MinerID to associate with the new PeerID.", + "newPeerID": "The new PeerID to bind to the MinerID.", + "signedMessage": "The signed message to store." + } + }, + "deletePeerData(uint64)": { + "params": { + "minerID": "The MinerID whose peer data will be deleted." + } + }, + "getPeerData(uint64)": { + "params": { + "minerID": "The MinerID to query." + }, + "returns": { + "_0": "The PeerID and signed message associated with the MinerID." + } + }, + "updatePeerData(uint64,string,bytes)": { + "params": { + "minerID": "The MinerID whose PeerID will be updated.", + "newPeerID": "The new PeerID to bind to the MinerID.", + "signedMessage": "The new signed message to store." + } + } + }, + "version": 1 + }, + "userdoc": { + "errors": { + "ActorError(int256)": [ + { + "notice": "the called actor returned an error as part of its expected behaviour" + } + ], + "ActorNotFound()": [ + { + "notice": "the actor is not found" + } + ], + "FailToCallActor()": [ + { + "notice": "an error happened trying to call the actor" + } + ], + "InvalidActorID(uint64)": [ + { + "notice": "the provided actor id is not valid" + } + ], + "InvalidCodec(uint64)": [ + { + "notice": "the codec received is not valid" + } + ], + "InvalidResponseLength()": [ + { + "notice": "the response received is not correct. In some case no response is expected and we received one, or a response was indeed expected and we received none." + } + ], + "NotEnoughBalance(uint256,uint256)": [ + { + "notice": "the smart contract has no enough balance to transfer" + } + ] + }, + "kind": "user", + "methods": { + "addPeerData(uint64,string,bytes)": { + "notice": "Add a new PeerID and signed message for a MinerID in the contract." + }, + "deletePeerData(uint64)": { + "notice": "Delete an existing PeerID and signed message for a MinerID in the contract." + }, + "getPeerData(uint64)": { + "notice": "Fetch the PeerID and signed message associated with a MinerID." + }, + "updatePeerData(uint64,string,bytes)": { + "notice": "Update an existing PeerID and signed message for a MinerID in the contract." + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 5309, + "contract": "contracts/MinerPeerIDMapping.sol:MinerPeerIDMapping", + "label": "minerToPeerData", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_uint64,t_struct(PeerData)5304_storage)" + } + ], + "types": { + "t_bytes_storage": { + "encoding": "bytes", + "label": "bytes", + "numberOfBytes": "32" + }, + "t_mapping(t_uint64,t_struct(PeerData)5304_storage)": { + "encoding": "mapping", + "key": "t_uint64", + "label": "mapping(uint64 => struct MinerPeerIDMapping.PeerData)", + "numberOfBytes": "32", + "value": "t_struct(PeerData)5304_storage" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(PeerData)5304_storage": { + "encoding": "inplace", + "label": "struct MinerPeerIDMapping.PeerData", + "members": [ + { + "astId": 5301, + "contract": "contracts/MinerPeerIDMapping.sol:MinerPeerIDMapping", + "label": "peerID", + "offset": 0, + "slot": "0", + "type": "t_string_storage" + }, + { + "astId": 5303, + "contract": "contracts/MinerPeerIDMapping.sol:MinerPeerIDMapping", + "label": "signedMessage", + "offset": 0, + "slot": "1", + "type": "t_bytes_storage" + } + ], + "numberOfBytes": "64" + }, + "t_uint64": { + "encoding": "inplace", + "label": "uint64", + "numberOfBytes": "8" + } + } + } +} \ No newline at end of file diff --git a/market/ipni/spark/sol/deployments/mainnet/solcInputs/4e4cab9ef25a7e1e2da858f2991af0c6.json b/market/ipni/spark/sol/deployments/mainnet/solcInputs/4e4cab9ef25a7e1e2da858f2991af0c6.json new file mode 100644 index 000000000..774b0b18d --- /dev/null +++ b/market/ipni/spark/sol/deployments/mainnet/solcInputs/4e4cab9ef25a7e1e2da858f2991af0c6.json @@ -0,0 +1,75 @@ +{ + "language": "Solidity", + "sources": { + "@ensdomains/buffer/contracts/Buffer.sol": { + "content": "// SPDX-License-Identifier: BSD-2-Clause\npragma solidity ^0.8.4;\n\n/**\n* @dev A library for working with mutable byte buffers in Solidity.\n*\n* Byte buffers are mutable and expandable, and provide a variety of primitives\n* for appending to them. At any time you can fetch a bytes object containing the\n* current contents of the buffer. The bytes object should not be stored between\n* operations, as it may change due to resizing of the buffer.\n*/\nlibrary Buffer {\n /**\n * @dev Represents a mutable buffer. Buffers have a current value (buf) and\n * a capacity. The capacity may be longer than the current value, in\n * which case it can be extended without the need to allocate more memory.\n */\n struct buffer {\n bytes buf;\n uint capacity;\n }\n\n /**\n * @dev Initializes a buffer with an initial capacity.\n * @param buf The buffer to initialize.\n * @param capacity The number of bytes of space to allocate the buffer.\n * @return The buffer, for chaining.\n */\n function init(buffer memory buf, uint capacity) internal pure returns(buffer memory) {\n if (capacity % 32 != 0) {\n capacity += 32 - (capacity % 32);\n }\n // Allocate space for the buffer data\n buf.capacity = capacity;\n assembly {\n let ptr := mload(0x40)\n mstore(buf, ptr)\n mstore(ptr, 0)\n let fpm := add(32, add(ptr, capacity))\n if lt(fpm, ptr) {\n revert(0, 0)\n }\n mstore(0x40, fpm)\n }\n return buf;\n }\n\n /**\n * @dev Initializes a new buffer from an existing bytes object.\n * Changes to the buffer may mutate the original value.\n * @param b The bytes object to initialize the buffer with.\n * @return A new buffer.\n */\n function fromBytes(bytes memory b) internal pure returns(buffer memory) {\n buffer memory buf;\n buf.buf = b;\n buf.capacity = b.length;\n return buf;\n }\n\n function resize(buffer memory buf, uint capacity) private pure {\n bytes memory oldbuf = buf.buf;\n init(buf, capacity);\n append(buf, oldbuf);\n }\n\n /**\n * @dev Sets buffer length to 0.\n * @param buf The buffer to truncate.\n * @return The original buffer, for chaining..\n */\n function truncate(buffer memory buf) internal pure returns (buffer memory) {\n assembly {\n let bufptr := mload(buf)\n mstore(bufptr, 0)\n }\n return buf;\n }\n\n /**\n * @dev Appends len bytes of a byte string to a buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @param len The number of bytes to copy.\n * @return The original buffer, for chaining.\n */\n function append(buffer memory buf, bytes memory data, uint len) internal pure returns(buffer memory) {\n require(len <= data.length);\n\n uint off = buf.buf.length;\n uint newCapacity = off + len;\n if (newCapacity > buf.capacity) {\n resize(buf, newCapacity * 2);\n }\n\n uint dest;\n uint src;\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Length of existing buffer data\n let buflen := mload(bufptr)\n // Start address = buffer address + offset + sizeof(buffer length)\n dest := add(add(bufptr, 32), off)\n // Update buffer length if we're extending it\n if gt(newCapacity, buflen) {\n mstore(bufptr, newCapacity)\n }\n src := add(data, 32)\n }\n\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 unchecked {\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 return buf;\n }\n\n /**\n * @dev Appends a byte string to a buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function append(buffer memory buf, bytes memory data) internal pure returns (buffer memory) {\n return append(buf, data, data.length);\n }\n\n /**\n * @dev Appends a byte to the buffer. Resizes if doing so would exceed the\n * capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function appendUint8(buffer memory buf, uint8 data) internal pure returns(buffer memory) {\n uint off = buf.buf.length;\n uint offPlusOne = off + 1;\n if (off >= buf.capacity) {\n resize(buf, offPlusOne * 2);\n }\n\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Address = buffer address + sizeof(buffer length) + off\n let dest := add(add(bufptr, off), 32)\n mstore8(dest, data)\n // Update buffer length if we extended it\n if gt(offPlusOne, mload(bufptr)) {\n mstore(bufptr, offPlusOne)\n }\n }\n\n return buf;\n }\n\n /**\n * @dev Appends len bytes of bytes32 to a buffer. Resizes if doing so would\n * exceed the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @param len The number of bytes to write (left-aligned).\n * @return The original buffer, for chaining.\n */\n function append(buffer memory buf, bytes32 data, uint len) private pure returns(buffer memory) {\n uint off = buf.buf.length;\n uint newCapacity = len + off;\n if (newCapacity > buf.capacity) {\n resize(buf, newCapacity * 2);\n }\n\n unchecked {\n uint mask = (256 ** len) - 1;\n // Right-align data\n data = data >> (8 * (32 - len));\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Address = buffer address + sizeof(buffer length) + newCapacity\n let dest := add(bufptr, newCapacity)\n mstore(dest, or(and(mload(dest), not(mask)), data))\n // Update buffer length if we extended it\n if gt(newCapacity, mload(bufptr)) {\n mstore(bufptr, newCapacity)\n }\n }\n }\n return buf;\n }\n\n /**\n * @dev Appends a bytes20 to the buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chhaining.\n */\n function appendBytes20(buffer memory buf, bytes20 data) internal pure returns (buffer memory) {\n return append(buf, bytes32(data), 20);\n }\n\n /**\n * @dev Appends a bytes32 to the buffer. Resizes if doing so would exceed\n * the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @return The original buffer, for chaining.\n */\n function appendBytes32(buffer memory buf, bytes32 data) internal pure returns (buffer memory) {\n return append(buf, data, 32);\n }\n\n /**\n * @dev Appends a byte to the end of the buffer. Resizes if doing so would\n * exceed the capacity of the buffer.\n * @param buf The buffer to append to.\n * @param data The data to append.\n * @param len The number of bytes to write (right-aligned).\n * @return The original buffer.\n */\n function appendInt(buffer memory buf, uint data, uint len) internal pure returns(buffer memory) {\n uint off = buf.buf.length;\n uint newCapacity = len + off;\n if (newCapacity > buf.capacity) {\n resize(buf, newCapacity * 2);\n }\n\n uint mask = (256 ** len) - 1;\n assembly {\n // Memory address of the buffer data\n let bufptr := mload(buf)\n // Address = buffer address + sizeof(buffer length) + newCapacity\n let dest := add(bufptr, newCapacity)\n mstore(dest, or(and(mload(dest), not(mask)), data))\n // Update buffer length if we extended it\n if gt(newCapacity, mload(bufptr)) {\n mstore(bufptr, newCapacity)\n }\n }\n return buf;\n }\n}\n" + }, + "@zondax/filecoin-solidity/contracts/v0.8/cbor/BigIntCbor.sol": { + "content": "/*******************************************************************************\n * (c) 2022 Zondax AG\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ********************************************************************************/\n//\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\n\n// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.17;\n\nimport \"../types/CommonTypes.sol\";\n\n/// @title This library is a set of functions meant to handle CBOR serialization and deserialization for BigInt type\n/// @author Zondax AG\nlibrary BigIntCBOR {\n /// @notice serialize BigInt instance to bytes\n /// @param num BigInt instance to serialize\n /// @return serialized BigInt as bytes\n function serializeBigInt(CommonTypes.BigInt memory num) internal pure returns (bytes memory) {\n bytes memory raw = new bytes(num.val.length + 1);\n\n raw[0] = num.neg == true ? bytes1(0x01) : bytes1(0x00);\n\n uint index = 1;\n for (uint i = 0; i < num.val.length; i++) {\n raw[index] = num.val[i];\n index++;\n }\n\n return raw;\n }\n\n /// @notice deserialize big int (encoded as bytes) to BigInt instance\n /// @param raw as bytes to parse\n /// @return parsed BigInt instance\n function deserializeBigInt(bytes memory raw) internal pure returns (CommonTypes.BigInt memory) {\n if (raw.length == 0) {\n return CommonTypes.BigInt(hex\"00\", false);\n }\n\n bytes memory val = new bytes(raw.length - 1);\n bool neg = false;\n\n if (raw[0] == 0x01) {\n neg = true;\n }\n\n for (uint i = 1; i < raw.length; i++) {\n val[i - 1] = raw[i];\n }\n\n return CommonTypes.BigInt(val, neg);\n }\n}\n" + }, + "@zondax/filecoin-solidity/contracts/v0.8/cbor/BytesCbor.sol": { + "content": "/*******************************************************************************\n * (c) 2022 Zondax AG\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ********************************************************************************/\n//\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\n\n// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.17;\n\nimport \"solidity-cborutils/contracts/CBOR.sol\";\n\nimport \"../utils/CborDecode.sol\";\nimport \"../utils/Misc.sol\";\n\nimport \"../types/CommonTypes.sol\";\n\nimport \"./BigIntCbor.sol\";\n\n/// @title This library is a set of functions meant to handle CBOR serialization and deserialization for bytes\n/// @author Zondax AG\nlibrary BytesCBOR {\n using CBOR for CBOR.CBORBuffer;\n using CBORDecoder for bytes;\n using BigIntCBOR for bytes;\n\n /// @notice serialize raw bytes as cbor bytes string encoded\n /// @param data raw data in bytes\n /// @return encoded cbor bytes\n function serializeBytes(bytes memory data) internal pure returns (bytes memory) {\n uint256 capacity = Misc.getBytesSize(data);\n\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\n\n buf.writeBytes(data);\n\n return buf.data();\n }\n\n /// @notice serialize raw address (in bytes) as cbor bytes string encoded (how an address is passed to filecoin actors)\n /// @param addr raw address in bytes\n /// @return encoded address as cbor bytes\n function serializeAddress(bytes memory addr) internal pure returns (bytes memory) {\n return serializeBytes(addr);\n }\n\n /// @notice encoded null value as cbor\n /// @return cbor encoded null\n function serializeNull() internal pure returns (bytes memory) {\n CBOR.CBORBuffer memory buf = CBOR.create(1);\n\n buf.writeNull();\n\n return buf.data();\n }\n\n /// @notice deserialize cbor encoded filecoin address to bytes\n /// @param ret cbor encoded filecoin address\n /// @return raw bytes representing a filecoin address\n function deserializeAddress(bytes memory ret) internal pure returns (bytes memory) {\n bytes memory addr;\n uint byteIdx = 0;\n\n (addr, byteIdx) = ret.readBytes(byteIdx);\n\n return addr;\n }\n\n /// @notice deserialize cbor encoded string\n /// @param ret cbor encoded string (in bytes)\n /// @return decoded string\n function deserializeString(bytes memory ret) internal pure returns (string memory) {\n string memory response;\n uint byteIdx = 0;\n\n (response, byteIdx) = ret.readString(byteIdx);\n\n return response;\n }\n\n /// @notice deserialize cbor encoded bool\n /// @param ret cbor encoded bool (in bytes)\n /// @return decoded bool\n function deserializeBool(bytes memory ret) internal pure returns (bool) {\n bool response;\n uint byteIdx = 0;\n\n (response, byteIdx) = ret.readBool(byteIdx);\n\n return response;\n }\n\n /// @notice deserialize cbor encoded BigInt\n /// @param ret cbor encoded BigInt (in bytes)\n /// @return decoded BigInt\n /// @dev BigInts are cbor encoded as bytes string first. That is why it unwraps the cbor encoded bytes first, and then parse the result into BigInt\n function deserializeBytesBigInt(bytes memory ret) internal pure returns (CommonTypes.BigInt memory) {\n bytes memory tmp;\n uint byteIdx = 0;\n\n if (ret.length > 0) {\n (tmp, byteIdx) = ret.readBytes(byteIdx);\n if (tmp.length > 0) {\n return tmp.deserializeBigInt();\n }\n }\n\n return CommonTypes.BigInt(new bytes(0), false);\n }\n\n /// @notice deserialize cbor encoded uint64\n /// @param rawResp cbor encoded uint64 (in bytes)\n /// @return decoded uint64\n function deserializeUint64(bytes memory rawResp) internal pure returns (uint64) {\n uint byteIdx = 0;\n uint64 value;\n\n (value, byteIdx) = rawResp.readUInt64(byteIdx);\n return value;\n }\n\n /// @notice deserialize cbor encoded int64\n /// @param rawResp cbor encoded int64 (in bytes)\n /// @return decoded int64\n function deserializeInt64(bytes memory rawResp) internal pure returns (int64) {\n uint byteIdx = 0;\n int64 value;\n\n (value, byteIdx) = rawResp.readInt64(byteIdx);\n return value;\n }\n}\n" + }, + "@zondax/filecoin-solidity/contracts/v0.8/cbor/FilecoinCbor.sol": { + "content": "/*******************************************************************************\n * (c) 2022 Zondax AG\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ********************************************************************************/\n//\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\n\n// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.17;\n\nimport \"solidity-cborutils/contracts/CBOR.sol\";\nimport \"@ensdomains/buffer/contracts/Buffer.sol\";\n\nimport \"../utils/CborDecode.sol\";\nimport \"../utils/Misc.sol\";\n\nimport \"../types/CommonTypes.sol\";\n\nimport \"../cbor/BigIntCbor.sol\";\n\n/// @title This library is a set of functions meant to handle CBOR serialization and deserialization for general data types on the filecoin network.\n/// @author Zondax AG\nlibrary FilecoinCBOR {\n using Buffer for Buffer.buffer;\n using CBOR for CBOR.CBORBuffer;\n using CBORDecoder for *;\n using BigIntCBOR for *;\n\n uint8 private constant MAJOR_TYPE_TAG = 6;\n uint8 private constant TAG_TYPE_CID_CODE = 42;\n uint8 private constant PAYLOAD_LEN_8_BITS = 24;\n\n /// @notice Write a CID into a CBOR buffer.\n /// @dev The CBOR major will be 6 (type 'tag') and the tag type value is 42, as per CBOR tag assignments.\n /// @dev https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml\n /// @param buf buffer containing the actual CBOR serialization process\n /// @param value CID value to serialize as CBOR\n function writeCid(CBOR.CBORBuffer memory buf, bytes memory value) internal pure {\n buf.buf.appendUint8(uint8(((MAJOR_TYPE_TAG << 5) | PAYLOAD_LEN_8_BITS)));\n buf.buf.appendUint8(TAG_TYPE_CID_CODE);\n // See https://ipld.io/specs/codecs/dag-cbor/spec/#links for explanation on 0x00 prefix.\n buf.writeBytes(bytes.concat(hex'00', value));\n }\n\n function readCid(bytes memory cborData, uint byteIdx) internal pure returns (CommonTypes.Cid memory, uint) {\n uint8 maj;\n uint value;\n\n (maj, value, byteIdx) = cborData.parseCborHeader(byteIdx);\n require(maj == MAJOR_TYPE_TAG, \"expected major type tag when parsing cid\");\n require(value == TAG_TYPE_CID_CODE, \"expected tag 42 when parsing cid\");\n\n bytes memory raw;\n (raw, byteIdx) = cborData.readBytes(byteIdx);\n require(raw[0] == 0x00, \"expected first byte to be 0 when parsing cid\");\n\n // Pop off the first byte, which corresponds to the historical multibase 0x00 byte.\n // https://ipld.io/specs/codecs/dag-cbor/spec/#links\n CommonTypes.Cid memory ret;\n ret.data = new bytes(raw.length - 1);\n for (uint256 i = 1; i < raw.length; i++) {\n ret.data[i-1] = raw[i];\n }\n\n return (ret, byteIdx);\n }\n\n /// @notice serialize filecoin address to cbor encoded\n /// @param addr filecoin address to serialize\n /// @return cbor serialized data as bytes\n function serializeAddress(CommonTypes.FilAddress memory addr) internal pure returns (bytes memory) {\n uint256 capacity = Misc.getBytesSize(addr.data);\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\n\n buf.writeBytes(addr.data);\n\n return buf.data();\n }\n\n /// @notice serialize a BigInt value wrapped in a cbor fixed array.\n /// @param value BigInt to serialize as cbor inside an\n /// @return cbor serialized data as bytes\n function serializeArrayBigInt(CommonTypes.BigInt memory value) internal pure returns (bytes memory) {\n uint256 capacity = 0;\n bytes memory valueBigInt = value.serializeBigInt();\n\n capacity += Misc.getPrefixSize(1);\n capacity += Misc.getBytesSize(valueBigInt);\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\n\n buf.startFixedArray(1);\n buf.writeBytes(value.serializeBigInt());\n\n return buf.data();\n }\n\n /// @notice serialize a FilAddress value wrapped in a cbor fixed array.\n /// @param addr FilAddress to serialize as cbor inside an\n /// @return cbor serialized data as bytes\n function serializeArrayFilAddress(CommonTypes.FilAddress memory addr) internal pure returns (bytes memory) {\n uint256 capacity = 0;\n\n capacity += Misc.getPrefixSize(1);\n capacity += Misc.getBytesSize(addr.data);\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\n\n buf.startFixedArray(1);\n buf.writeBytes(addr.data);\n\n return buf.data();\n }\n\n /// @notice deserialize a FilAddress wrapped on a cbor fixed array coming from a actor call\n /// @param rawResp cbor encoded response\n /// @return ret new instance of FilAddress created based on parsed data\n function deserializeArrayFilAddress(bytes memory rawResp) internal pure returns (CommonTypes.FilAddress memory ret) {\n uint byteIdx = 0;\n uint len;\n\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\n require(len == 1, \"Wrong numbers of parameters (should find 1)\");\n\n (ret.data, byteIdx) = rawResp.readBytes(byteIdx);\n\n return ret;\n }\n\n /// @notice deserialize a BigInt wrapped on a cbor fixed array coming from a actor call\n /// @param rawResp cbor encoded response\n /// @return ret new instance of BigInt created based on parsed data\n function deserializeArrayBigInt(bytes memory rawResp) internal pure returns (CommonTypes.BigInt memory) {\n uint byteIdx = 0;\n uint len;\n bytes memory tmp;\n\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\n assert(len == 1);\n\n (tmp, byteIdx) = rawResp.readBytes(byteIdx);\n return tmp.deserializeBigInt();\n }\n\n /// @notice serialize UniversalReceiverParams struct to cbor in order to pass as arguments to an actor\n /// @param params UniversalReceiverParams to serialize as cbor\n /// @return cbor serialized data as bytes\n function serializeUniversalReceiverParams(CommonTypes.UniversalReceiverParams memory params) internal pure returns (bytes memory) {\n uint256 capacity = 0;\n\n capacity += Misc.getPrefixSize(2);\n capacity += Misc.getPrefixSize(params.type_);\n capacity += Misc.getBytesSize(params.payload);\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\n\n buf.startFixedArray(2);\n buf.writeUInt64(params.type_);\n buf.writeBytes(params.payload);\n\n return buf.data();\n }\n\n /// @notice deserialize UniversalReceiverParams cbor to struct when receiving a message\n /// @param rawResp cbor encoded response\n /// @return ret new instance of UniversalReceiverParams created based on parsed data\n function deserializeUniversalReceiverParams(bytes memory rawResp) internal pure returns (CommonTypes.UniversalReceiverParams memory ret) {\n uint byteIdx = 0;\n uint len;\n\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\n require(len == 2, \"Wrong numbers of parameters (should find 2)\");\n\n (ret.type_, byteIdx) = rawResp.readUInt32(byteIdx);\n (ret.payload, byteIdx) = rawResp.readBytes(byteIdx);\n }\n\n /// @notice attempt to read a FilActorId value\n /// @param rawResp cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return a FilActorId decoded from input bytes and the byte index after moving past the value\n function readFilActorId(bytes memory rawResp, uint byteIdx) internal pure returns (CommonTypes.FilActorId, uint) {\n uint64 tmp = 0;\n\n (tmp, byteIdx) = rawResp.readUInt64(byteIdx);\n return (CommonTypes.FilActorId.wrap(tmp), byteIdx);\n }\n\n /// @notice write FilActorId into a cbor buffer\n /// @dev FilActorId is just wrapping a uint64\n /// @param buf buffer containing the actual cbor serialization process\n /// @param id FilActorId to serialize as cbor\n function writeFilActorId(CBOR.CBORBuffer memory buf, CommonTypes.FilActorId id) internal pure {\n buf.writeUInt64(CommonTypes.FilActorId.unwrap(id));\n }\n\n /// @notice attempt to read a ChainEpoch value\n /// @param rawResp cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return a ChainEpoch decoded from input bytes and the byte index after moving past the value\n function readChainEpoch(bytes memory rawResp, uint byteIdx) internal pure returns (CommonTypes.ChainEpoch, uint) {\n int64 tmp = 0;\n\n (tmp, byteIdx) = rawResp.readInt64(byteIdx);\n return (CommonTypes.ChainEpoch.wrap(tmp), byteIdx);\n }\n\n /// @notice write ChainEpoch into a cbor buffer\n /// @dev ChainEpoch is just wrapping a int64\n /// @param buf buffer containing the actual cbor serialization process\n /// @param id ChainEpoch to serialize as cbor\n function writeChainEpoch(CBOR.CBORBuffer memory buf, CommonTypes.ChainEpoch id) internal pure {\n buf.writeInt64(CommonTypes.ChainEpoch.unwrap(id));\n }\n\n /// @notice write DealLabel into a cbor buffer\n /// @param buf buffer containing the actual cbor serialization process\n /// @param label DealLabel to serialize as cbor\n function writeDealLabel(CBOR.CBORBuffer memory buf, CommonTypes.DealLabel memory label) internal pure {\n label.isString ? buf.writeString(string(label.data)) : buf.writeBytes(label.data);\n }\n\n /// @notice deserialize DealLabel cbor to struct when receiving a message\n /// @param rawResp cbor encoded response\n /// @return ret new instance of DealLabel created based on parsed data\n function deserializeDealLabel(bytes memory rawResp) internal pure returns (CommonTypes.DealLabel memory) {\n uint byteIdx = 0;\n CommonTypes.DealLabel memory label;\n\n (label, byteIdx) = readDealLabel(rawResp, byteIdx);\n return label;\n }\n\n /// @notice attempt to read a DealLabel value\n /// @param rawResp cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return a DealLabel decoded from input bytes and the byte index after moving past the value\n function readDealLabel(bytes memory rawResp, uint byteIdx) internal pure returns (CommonTypes.DealLabel memory, uint) {\n uint8 maj;\n uint len;\n\n (maj, len, byteIdx) = CBORDecoder.parseCborHeader(rawResp, byteIdx);\n require(maj == MajByteString || maj == MajTextString, \"invalid maj (expected MajByteString or MajTextString)\");\n\n uint max_len = byteIdx + len;\n bytes memory slice = new bytes(len);\n uint slice_index = 0;\n for (uint256 i = byteIdx; i < max_len; i++) {\n slice[slice_index] = rawResp[i];\n slice_index++;\n }\n\n return (CommonTypes.DealLabel(slice, maj == MajTextString), byteIdx + len);\n }\n}\n" + }, + "@zondax/filecoin-solidity/contracts/v0.8/cbor/MinerCbor.sol": { + "content": "/*******************************************************************************\n * (c) 2022 Zondax AG\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ********************************************************************************/\n//\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\n\n// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.17;\n\nimport \"solidity-cborutils/contracts/CBOR.sol\";\n\nimport \"./BigIntCbor.sol\";\nimport \"./FilecoinCbor.sol\";\n\nimport \"../types/MinerTypes.sol\";\nimport \"../types/CommonTypes.sol\";\n\nimport \"../utils/CborDecode.sol\";\nimport \"../utils/Misc.sol\";\n\n/// @title This library is a set of functions meant to handle CBOR parameters serialization and return values deserialization for Miner actor exported methods.\n/// @author Zondax AG\nlibrary MinerCBOR {\n using CBOR for CBOR.CBORBuffer;\n using CBORDecoder for bytes;\n using BigIntCBOR for *;\n using FilecoinCBOR for *;\n\n /// @notice serialize ChangeBeneficiaryParams struct to cbor in order to pass as arguments to the miner actor\n /// @param params ChangeBeneficiaryParams to serialize as cbor\n /// @return cbor serialized data as bytes\n function serializeChangeBeneficiaryParams(MinerTypes.ChangeBeneficiaryParams memory params) internal pure returns (bytes memory) {\n uint256 capacity = 0;\n bytes memory new_quota = params.new_quota.serializeBigInt();\n\n capacity += Misc.getPrefixSize(3);\n capacity += Misc.getBytesSize(params.new_beneficiary.data);\n capacity += Misc.getBytesSize(new_quota);\n capacity += Misc.getChainEpochSize(params.new_expiration);\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\n\n buf.startFixedArray(3);\n buf.writeBytes(params.new_beneficiary.data);\n buf.writeBytes(new_quota);\n buf.writeChainEpoch(params.new_expiration);\n\n return buf.data();\n }\n\n /// @notice deserialize GetOwnerReturn struct from cbor encoded bytes coming from a miner actor call\n /// @param rawResp cbor encoded response\n /// @return ret new instance of GetOwnerReturn created based on parsed data\n function deserializeGetOwnerReturn(bytes memory rawResp) internal pure returns (MinerTypes.GetOwnerReturn memory ret) {\n uint byteIdx = 0;\n uint len;\n\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\n assert(len == 2);\n\n (ret.owner.data, byteIdx) = rawResp.readBytes(byteIdx);\n\n if (!rawResp.isNullNext(byteIdx)) {\n (ret.proposed.data, byteIdx) = rawResp.readBytes(byteIdx);\n } else {\n ret.proposed.data = new bytes(0);\n }\n\n return ret;\n }\n\n /// @notice deserialize GetBeneficiaryReturn struct from cbor encoded bytes coming from a miner actor call\n /// @param rawResp cbor encoded response\n /// @return ret new instance of GetBeneficiaryReturn created based on parsed data\n function deserializeGetBeneficiaryReturn(bytes memory rawResp) internal pure returns (MinerTypes.GetBeneficiaryReturn memory ret) {\n bytes memory tmp;\n uint byteIdx = 0;\n uint len;\n\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\n assert(len == 2);\n\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\n assert(len == 2);\n\n (ret.active.beneficiary.data, byteIdx) = rawResp.readBytes(byteIdx);\n\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\n assert(len == 3);\n\n (tmp, byteIdx) = rawResp.readBytes(byteIdx);\n if (tmp.length > 0) {\n ret.active.term.quota = tmp.deserializeBigInt();\n } else {\n ret.active.term.quota = CommonTypes.BigInt(new bytes(0), false);\n }\n\n (tmp, byteIdx) = rawResp.readBytes(byteIdx);\n if (tmp.length > 0) {\n ret.active.term.used_quota = tmp.deserializeBigInt();\n } else {\n ret.active.term.used_quota = CommonTypes.BigInt(new bytes(0), false);\n }\n\n (ret.active.term.expiration, byteIdx) = rawResp.readChainEpoch(byteIdx);\n\n if (!rawResp.isNullNext(byteIdx)) {\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\n assert(len == 5);\n\n (ret.proposed.new_beneficiary.data, byteIdx) = rawResp.readBytes(byteIdx);\n\n (tmp, byteIdx) = rawResp.readBytes(byteIdx);\n if (tmp.length > 0) {\n ret.proposed.new_quota = tmp.deserializeBigInt();\n } else {\n ret.proposed.new_quota = CommonTypes.BigInt(new bytes(0), false);\n }\n\n (ret.proposed.new_expiration, byteIdx) = rawResp.readChainEpoch(byteIdx);\n (ret.proposed.approved_by_beneficiary, byteIdx) = rawResp.readBool(byteIdx);\n (ret.proposed.approved_by_nominee, byteIdx) = rawResp.readBool(byteIdx);\n }\n\n return ret;\n }\n\n /// @notice deserialize GetVestingFundsReturn struct from cbor encoded bytes coming from a miner actor call\n /// @param rawResp cbor encoded response\n /// @return ret new instance of GetVestingFundsReturn created based on parsed data\n function deserializeGetVestingFundsReturn(bytes memory rawResp) internal pure returns (MinerTypes.GetVestingFundsReturn memory ret) {\n CommonTypes.ChainEpoch epoch;\n CommonTypes.BigInt memory amount;\n bytes memory tmp;\n\n uint byteIdx = 0;\n uint len;\n uint leni;\n\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\n assert(len == 1);\n\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\n ret.vesting_funds = new MinerTypes.VestingFunds[](len);\n\n for (uint i = 0; i < len; i++) {\n (leni, byteIdx) = rawResp.readFixedArray(byteIdx);\n assert(leni == 2);\n\n (epoch, byteIdx) = rawResp.readChainEpoch(byteIdx);\n (tmp, byteIdx) = rawResp.readBytes(byteIdx);\n\n amount = tmp.deserializeBigInt();\n ret.vesting_funds[i] = MinerTypes.VestingFunds(epoch, amount);\n }\n\n return ret;\n }\n\n /// @notice serialize ChangeWorkerAddressParams struct to cbor in order to pass as arguments to the miner actor\n /// @param params ChangeWorkerAddressParams to serialize as cbor\n /// @return cbor serialized data as bytes\n function serializeChangeWorkerAddressParams(MinerTypes.ChangeWorkerAddressParams memory params) internal pure returns (bytes memory) {\n uint256 capacity = 0;\n\n capacity += Misc.getPrefixSize(2);\n capacity += Misc.getBytesSize(params.new_worker.data);\n capacity += Misc.getPrefixSize(uint256(params.new_control_addresses.length));\n for (uint64 i = 0; i < params.new_control_addresses.length; i++) {\n capacity += Misc.getBytesSize(params.new_control_addresses[i].data);\n }\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\n\n buf.startFixedArray(2);\n buf.writeBytes(params.new_worker.data);\n buf.startFixedArray(uint64(params.new_control_addresses.length));\n\n for (uint64 i = 0; i < params.new_control_addresses.length; i++) {\n buf.writeBytes(params.new_control_addresses[i].data);\n }\n\n return buf.data();\n }\n\n /// @notice serialize ChangeMultiaddrsParams struct to cbor in order to pass as arguments to the miner actor\n /// @param params ChangeMultiaddrsParams to serialize as cbor\n /// @return cbor serialized data as bytes\n function serializeChangeMultiaddrsParams(MinerTypes.ChangeMultiaddrsParams memory params) internal pure returns (bytes memory) {\n uint256 capacity = 0;\n\n capacity += Misc.getPrefixSize(1);\n capacity += Misc.getPrefixSize(uint256(params.new_multi_addrs.length));\n for (uint64 i = 0; i < params.new_multi_addrs.length; i++) {\n capacity += Misc.getBytesSize(params.new_multi_addrs[i].data);\n }\n CBOR.CBORBuffer memory buf = CBOR.create(capacity);\n\n buf.startFixedArray(1);\n buf.startFixedArray(uint64(params.new_multi_addrs.length));\n\n for (uint64 i = 0; i < params.new_multi_addrs.length; i++) {\n buf.writeBytes(params.new_multi_addrs[i].data);\n }\n\n return buf.data();\n }\n\n /// @notice deserialize GetMultiaddrsReturn struct from cbor encoded bytes coming from a miner actor call\n /// @param rawResp cbor encoded response\n /// @return ret new instance of GetMultiaddrsReturn created based on parsed data\n function deserializeGetMultiaddrsReturn(bytes memory rawResp) internal pure returns (MinerTypes.GetMultiaddrsReturn memory ret) {\n uint byteIdx = 0;\n uint len;\n\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\n assert(len == 1);\n\n (len, byteIdx) = rawResp.readFixedArray(byteIdx);\n ret.multi_addrs = new CommonTypes.FilAddress[](len);\n\n for (uint i = 0; i < len; i++) {\n (ret.multi_addrs[i].data, byteIdx) = rawResp.readBytes(byteIdx);\n }\n\n return ret;\n }\n}\n" + }, + "@zondax/filecoin-solidity/contracts/v0.8/MinerAPI.sol": { + "content": "/*******************************************************************************\n * (c) 2022 Zondax AG\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ********************************************************************************/\n//\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\n\n// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.17;\n\nimport \"./types/MinerTypes.sol\";\nimport \"./types/CommonTypes.sol\";\nimport \"./cbor/MinerCbor.sol\";\nimport \"./cbor/FilecoinCbor.sol\";\nimport \"./cbor/BytesCbor.sol\";\nimport \"./utils/Misc.sol\";\nimport \"./utils/Actor.sol\";\n\n/// @title This library is a proxy to a built-in Miner actor. Calling one of its methods will result in a cross-actor call being performed.\n/// @notice During miner initialization, a miner actor is created on the chain, and this actor gives the miner its ID f0.... The miner actor is in charge of collecting all the payments sent to the miner.\n/// @dev For more info about the miner actor, please refer to https://lotus.filecoin.io/storage-providers/operate/addresses/\n/// @author Zondax AG\nlibrary MinerAPI {\n using MinerCBOR for *;\n using FilecoinCBOR for *;\n using BytesCBOR for bytes;\n\n /// @notice Income and returned collateral are paid to this address\n /// @notice This address is also allowed to change the worker address for the miner\n /// @param target The miner actor id you want to interact with\n /// @return the owner address of a Miner\n function getOwner(CommonTypes.FilActorId target) internal returns (MinerTypes.GetOwnerReturn memory) {\n bytes memory raw_request = new bytes(0);\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetOwnerMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\n\n return result.deserializeGetOwnerReturn();\n }\n\n /// @param target The miner actor id you want to interact with\n /// @param addr New owner address\n /// @notice Proposes or confirms a change of owner address.\n /// @notice If invoked by the current owner, proposes a new owner address for confirmation. If the proposed address is the current owner address, revokes any existing proposal that proposed address.\n function changeOwnerAddress(CommonTypes.FilActorId target, CommonTypes.FilAddress memory addr) internal {\n bytes memory raw_request = addr.serializeAddress();\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.ChangeOwnerAddressMethodNum, Misc.CBOR_CODEC, raw_request, 0, false);\n if (result.length != 0) {\n revert Actor.InvalidResponseLength();\n }\n }\n\n /// @param target The miner actor id you want to interact with\n /// @param addr The \"controlling\" addresses are the Owner, the Worker, and all Control Addresses.\n /// @return Whether the provided address is \"controlling\".\n function isControllingAddress(CommonTypes.FilActorId target, CommonTypes.FilAddress memory addr) internal returns (bool) {\n bytes memory raw_request = addr.serializeAddress();\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.IsControllingAddressMethodNum, Misc.CBOR_CODEC, raw_request, 0, true);\n\n return result.deserializeBool();\n }\n\n /// @return the miner's sector size.\n /// @param target The miner actor id you want to interact with\n /// @dev For more information about sector sizes, please refer to https://spec.filecoin.io/systems/filecoin_mining/sector/#section-systems.filecoin_mining.sector\n function getSectorSize(CommonTypes.FilActorId target) internal returns (uint64) {\n bytes memory raw_request = new bytes(0);\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetSectorSizeMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\n\n return result.deserializeUint64();\n }\n\n /// @param target The miner actor id you want to interact with\n /// @notice This is calculated as actor balance - (vesting funds + pre-commit deposit + initial pledge requirement + fee debt)\n /// @notice Can go negative if the miner is in IP debt.\n /// @return the available balance of this miner.\n function getAvailableBalance(CommonTypes.FilActorId target) internal returns (CommonTypes.BigInt memory) {\n bytes memory raw_request = new bytes(0);\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetAvailableBalanceMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\n\n return result.deserializeBytesBigInt();\n }\n\n /// @param target The miner actor id you want to interact with\n /// @return the funds vesting in this miner as a list of (vesting_epoch, vesting_amount) tuples.\n function getVestingFunds(CommonTypes.FilActorId target) internal returns (MinerTypes.GetVestingFundsReturn memory) {\n bytes memory raw_request = new bytes(0);\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetVestingFundsMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\n\n return result.deserializeGetVestingFundsReturn();\n }\n\n /// @param target The miner actor id you want to interact with\n /// @notice Proposes or confirms a change of beneficiary address.\n /// @notice A proposal must be submitted by the owner, and takes effect after approval of both the proposed beneficiary and current beneficiary, if applicable, any current beneficiary that has time and quota remaining.\n /// @notice See FIP-0029, https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0029.md\n function changeBeneficiary(CommonTypes.FilActorId target, MinerTypes.ChangeBeneficiaryParams memory params) internal {\n bytes memory raw_request = params.serializeChangeBeneficiaryParams();\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.ChangeBeneficiaryMethodNum, Misc.CBOR_CODEC, raw_request, 0, false);\n if (result.length != 0) {\n revert Actor.InvalidResponseLength();\n }\n }\n\n /// @param target The miner actor id you want to interact with\n /// @notice This method is for use by other actors (such as those acting as beneficiaries), and to abstract the state representation for clients.\n /// @notice Retrieves the currently active and proposed beneficiary information.\n function getBeneficiary(CommonTypes.FilActorId target) internal returns (MinerTypes.GetBeneficiaryReturn memory) {\n bytes memory raw_request = new bytes(0);\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetBeneficiaryMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\n\n return result.deserializeGetBeneficiaryReturn();\n }\n\n /// @param target The miner actor id you want to interact with\n function changeWorkerAddress(CommonTypes.FilActorId target, MinerTypes.ChangeWorkerAddressParams memory params) internal {\n bytes memory raw_request = params.serializeChangeWorkerAddressParams();\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.ChangeWorkerAddressMethodNum, Misc.CBOR_CODEC, raw_request, 0, false);\n if (result.length != 0) {\n revert Actor.InvalidResponseLength();\n }\n }\n\n /// @param target The miner actor id you want to interact with\n function changePeerId(CommonTypes.FilActorId target, CommonTypes.FilAddress memory newId) internal {\n bytes memory raw_request = newId.serializeArrayFilAddress();\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.ChangePeerIDMethodNum, Misc.CBOR_CODEC, raw_request, 0, false);\n if (result.length != 0) {\n revert Actor.InvalidResponseLength();\n }\n }\n\n /// @param target The miner actor id you want to interact with\n function changeMultiaddresses(CommonTypes.FilActorId target, MinerTypes.ChangeMultiaddrsParams memory params) internal {\n bytes memory raw_request = params.serializeChangeMultiaddrsParams();\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.ChangeMultiaddrsMethodNum, Misc.CBOR_CODEC, raw_request, 0, false);\n if (result.length != 0) {\n revert Actor.InvalidResponseLength();\n }\n }\n\n /// @param target The miner actor id you want to interact with\n function repayDebt(CommonTypes.FilActorId target) internal {\n bytes memory raw_request = new bytes(0);\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.RepayDebtMethodNum, Misc.NONE_CODEC, raw_request, 0, false);\n if (result.length != 0) {\n revert Actor.InvalidResponseLength();\n }\n }\n\n /// @param target The miner actor id you want to interact with\n function confirmChangeWorkerAddress(CommonTypes.FilActorId target) internal {\n bytes memory raw_request = new bytes(0);\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.ConfirmChangeWorkerAddressMethodNum, Misc.NONE_CODEC, raw_request, 0, false);\n if (result.length != 0) {\n revert Actor.InvalidResponseLength();\n }\n }\n\n /// @param target The miner actor id you want to interact with\n function getPeerId(CommonTypes.FilActorId target) internal returns (CommonTypes.FilAddress memory) {\n bytes memory raw_request = new bytes(0);\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetPeerIDMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\n\n return result.deserializeArrayFilAddress();\n }\n\n /// @param target The miner actor id you want to interact with\n function getMultiaddresses(CommonTypes.FilActorId target) internal returns (MinerTypes.GetMultiaddrsReturn memory) {\n bytes memory raw_request = new bytes(0);\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.GetMultiaddrsMethodNum, Misc.NONE_CODEC, raw_request, 0, true);\n\n return result.deserializeGetMultiaddrsReturn();\n }\n\n /// @param target The miner actor id you want to interact with\n /// @param amount the amount you want to withdraw\n function withdrawBalance(CommonTypes.FilActorId target, CommonTypes.BigInt memory amount) internal returns (CommonTypes.BigInt memory) {\n bytes memory raw_request = amount.serializeArrayBigInt();\n\n bytes memory result = Actor.callNonSingletonByID(target, MinerTypes.WithdrawBalanceMethodNum, Misc.CBOR_CODEC, raw_request, 0, false);\n\n return result.deserializeBytesBigInt();\n }\n}\n" + }, + "@zondax/filecoin-solidity/contracts/v0.8/types/CommonTypes.sol": { + "content": "/*******************************************************************************\n * (c) 2022 Zondax AG\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ********************************************************************************/\n//\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\n\n// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.17;\n\n\n/// @title Filecoin actors' common types for Solidity.\n/// @author Zondax AG\nlibrary CommonTypes {\n uint constant UniversalReceiverHookMethodNum = 3726118371;\n\n /// @param idx index for the failure in batch\n /// @param code failure code\n struct FailCode {\n uint32 idx;\n uint32 code;\n }\n\n /// @param success_count total successes in batch\n /// @param fail_codes list of failures code and index for each failure in batch\n struct BatchReturn {\n uint32 success_count;\n FailCode[] fail_codes;\n }\n\n /// @param type_ asset type\n /// @param payload payload corresponding to asset type\n struct UniversalReceiverParams {\n uint32 type_;\n bytes payload;\n }\n\n /// @param val contains the actual arbitrary number written as binary\n /// @param neg indicates if val is negative or not\n struct BigInt {\n bytes val;\n bool neg;\n }\n\n /// @param data filecoin address in bytes format\n struct FilAddress {\n bytes data;\n }\n\n /// @param data cid in bytes format\n struct Cid {\n bytes data;\n }\n\n /// @param data deal proposal label in bytes format (it can be utf8 string or arbitrary bytes string).\n /// @param isString indicates if the data is string or raw bytes\n struct DealLabel {\n bytes data;\n bool isString;\n }\n\n type FilActorId is uint64;\n\n type ChainEpoch is int64;\n}\n" + }, + "@zondax/filecoin-solidity/contracts/v0.8/types/MinerTypes.sol": { + "content": "/*******************************************************************************\n * (c) 2022 Zondax AG\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ********************************************************************************/\n//\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\n\n// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.17;\n\nimport \"../cbor/BigIntCbor.sol\";\nimport \"./CommonTypes.sol\";\n\n/// @title Filecoin miner actor types for Solidity.\n/// @author Zondax AG\nlibrary MinerTypes {\n uint constant GetOwnerMethodNum = 3275365574;\n uint constant ChangeOwnerAddressMethodNum = 1010589339;\n uint constant IsControllingAddressMethodNum = 348244887;\n uint constant GetSectorSizeMethodNum = 3858292296;\n uint constant GetAvailableBalanceMethodNum = 4026106874;\n uint constant GetVestingFundsMethodNum = 1726876304;\n uint constant ChangeBeneficiaryMethodNum = 1570634796;\n uint constant GetBeneficiaryMethodNum = 4158972569;\n uint constant ChangeWorkerAddressMethodNum = 3302309124;\n uint constant ChangePeerIDMethodNum = 1236548004;\n uint constant ChangeMultiaddrsMethodNum = 1063480576;\n uint constant RepayDebtMethodNum = 3665352697;\n uint constant ConfirmChangeWorkerAddressMethodNum = 2354970453;\n uint constant GetPeerIDMethodNum = 2812875329;\n uint constant GetMultiaddrsMethodNum = 1332909407;\n uint constant WithdrawBalanceMethodNum = 2280458852;\n\n /// @param owner owner address.\n /// @param proposed owner address.\n struct GetOwnerReturn {\n CommonTypes.FilAddress owner;\n CommonTypes.FilAddress proposed;\n }\n\n /// @param vesting_funds funds\n struct GetVestingFundsReturn {\n VestingFunds[] vesting_funds;\n }\n\n /// @param new_beneficiary the new beneficiary address.\n /// @param new_quota the new quota token amount.\n /// @param new_expiration the epoch that the new quota will be expired.\n struct ChangeBeneficiaryParams {\n CommonTypes.FilAddress new_beneficiary;\n CommonTypes.BigInt new_quota;\n CommonTypes.ChainEpoch new_expiration;\n }\n\n /// @param active current active beneficiary.\n /// @param proposed the proposed and pending beneficiary.\n struct GetBeneficiaryReturn {\n ActiveBeneficiary active;\n PendingBeneficiaryChange proposed;\n }\n\n /// @param new_worker the new worker address.\n /// @param new_control_addresses the new controller addresses.\n struct ChangeWorkerAddressParams {\n CommonTypes.FilAddress new_worker;\n CommonTypes.FilAddress[] new_control_addresses;\n }\n\n /// @param new_multi_addrs the new multi-signature address.\n struct ChangeMultiaddrsParams {\n CommonTypes.FilAddress[] new_multi_addrs;\n }\n\n /// @param multi_addrs the multi-signature address.\n struct GetMultiaddrsReturn {\n CommonTypes.FilAddress[] multi_addrs;\n }\n\n /// @param epoch the epoch of funds vested.\n /// @param amount the amount of funds vested.\n struct VestingFunds {\n CommonTypes.ChainEpoch epoch;\n CommonTypes.BigInt amount;\n }\n\n /// @param quota the quota token amount.\n /// @param used_quota the used quota token amount.\n /// @param expiration the epoch that the quota will be expired.\n struct BeneficiaryTerm {\n CommonTypes.BigInt quota;\n CommonTypes.BigInt used_quota;\n CommonTypes.ChainEpoch expiration;\n }\n\n /// @param beneficiary the address of the beneficiary.\n /// @param term BeneficiaryTerm\n struct ActiveBeneficiary {\n CommonTypes.FilAddress beneficiary;\n BeneficiaryTerm term;\n }\n\n /// @param new_beneficiary the new beneficiary address.\n /// @param new_quota the new quota token amount.\n /// @param new_expiration the epoch that the new quota will be expired.\n /// @param approved_by_beneficiary if this proposal is approved by beneficiary or not.\n /// @param approved_by_nominee if this proposal is approved by nominee or not.\n struct PendingBeneficiaryChange {\n CommonTypes.FilAddress new_beneficiary;\n CommonTypes.BigInt new_quota;\n CommonTypes.ChainEpoch new_expiration;\n bool approved_by_beneficiary;\n bool approved_by_nominee;\n }\n\n enum SectorSize {\n _2KiB,\n _8MiB,\n _512MiB,\n _32GiB,\n _64GiB\n }\n}\n" + }, + "@zondax/filecoin-solidity/contracts/v0.8/utils/Actor.sol": { + "content": "/*******************************************************************************\n * (c) 2022 Zondax AG\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ********************************************************************************/\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\n\n// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.17;\n\nimport \"./Misc.sol\";\nimport \"../types/CommonTypes.sol\";\n\n/// @title Call actors utilities library, meant to interact with Filecoin builtin actors\n/// @author Zondax AG\nlibrary Actor {\n /// @notice precompile address for the call_actor precompile\n address constant CALL_ACTOR_ADDRESS = 0xfe00000000000000000000000000000000000003;\n\n /// @notice precompile address for the call_actor_id precompile\n address constant CALL_ACTOR_ID = 0xfe00000000000000000000000000000000000005;\n\n /// @notice flag used to indicate that the call_actor or call_actor_id should perform a static_call to the desired actor\n uint64 constant READ_ONLY_FLAG = 0x00000001;\n\n /// @notice flag used to indicate that the call_actor or call_actor_id should perform a call to the desired actor\n uint64 constant DEFAULT_FLAG = 0x00000000;\n\n /// @notice the provided address is not valid\n error InvalidAddress(bytes addr);\n\n /// @notice the smart contract has no enough balance to transfer\n error NotEnoughBalance(uint256 balance, uint256 value);\n\n /// @notice the provided actor id is not valid\n error InvalidActorID(CommonTypes.FilActorId actorId);\n\n /// @notice an error happened trying to call the actor\n error FailToCallActor();\n\n /// @notice the response received is not correct. In some case no response is expected and we received one, or a response was indeed expected and we received none.\n error InvalidResponseLength();\n\n /// @notice the codec received is not valid\n error InvalidCodec(uint64);\n\n /// @notice the called actor returned an error as part of its expected behaviour\n error ActorError(int256 errorCode);\n\n /// @notice the actor is not found\n error ActorNotFound();\n\n /// @notice allows to interact with an specific actor by its address (bytes format)\n /// @param actor_address actor address (bytes format) to interact with\n /// @param method_num id of the method from the actor to call\n /// @param codec how the request data passed as argument is encoded\n /// @param raw_request encoded arguments to be passed in the call\n /// @param value tokens to be transferred to the called actor\n /// @param static_call indicates if the call will be allowed to change the actor state or not (just read the state)\n /// @return payload (in bytes) with the actual response data (without codec or response code)\n function callByAddress(\n bytes memory actor_address,\n uint256 method_num,\n uint64 codec,\n bytes memory raw_request,\n uint256 value,\n bool static_call\n ) internal returns (bytes memory) {\n if (actor_address.length < 2) {\n revert InvalidAddress(actor_address);\n }\n\n validatePrecompileCall(CALL_ACTOR_ADDRESS, value);\n\n // We have to delegate-call the call-actor precompile because the call-actor precompile will\n // call the target actor on our behalf. This will _not_ delegate to the target `actor_address`.\n //\n // Specifically:\n //\n // - `static_call == false`: `CALLER (you) --(DELEGATECALL)-> CALL_ACTOR_PRECOMPILE --(CALL)-> actor_address\n // - `static_call == true`: `CALLER (you) --(DELEGATECALL)-> CALL_ACTOR_PRECOMPILE --(STATICCALL)-> actor_address\n (bool success, bytes memory data) = address(CALL_ACTOR_ADDRESS).delegatecall(\n abi.encode(uint64(method_num), value, static_call ? READ_ONLY_FLAG : DEFAULT_FLAG, codec, raw_request, actor_address)\n );\n if (!success) {\n revert FailToCallActor();\n }\n\n return readRespData(data);\n }\n\n /// @notice allows to interact with an specific actor by its id (uint64)\n /// @param target actor id (uint64) to interact with\n /// @param method_num id of the method from the actor to call\n /// @param codec how the request data passed as argument is encoded\n /// @param raw_request encoded arguments to be passed in the call\n /// @param value tokens to be transferred to the called actor\n /// @param static_call indicates if the call will be allowed to change the actor state or not (just read the state)\n /// @return payload (in bytes) with the actual response data (without codec or response code)\n function callByID(\n CommonTypes.FilActorId target,\n uint256 method_num,\n uint64 codec,\n bytes memory raw_request,\n uint256 value,\n bool static_call\n ) internal returns (bytes memory) {\n validatePrecompileCall(CALL_ACTOR_ID, value);\n\n (bool success, bytes memory data) = address(CALL_ACTOR_ID).delegatecall(\n abi.encode(uint64(method_num), value, static_call ? READ_ONLY_FLAG : DEFAULT_FLAG, codec, raw_request, target)\n );\n if (!success) {\n revert FailToCallActor();\n }\n\n return readRespData(data);\n }\n\n /// @notice allows to run some generic validations before calling the precompile actor\n /// @param addr precompile actor address to run check to\n /// @param value tokens to be transferred to the called actor\n function validatePrecompileCall(address addr, uint256 value) internal view {\n uint balance = address(this).balance;\n if (balance < value) {\n revert NotEnoughBalance(balance, value);\n }\n\n bool actorExists = Misc.addressExists(addr);\n if (!actorExists) {\n revert ActorNotFound();\n }\n }\n\n /// @notice allows to interact with an non-singleton actors by its id (uint64)\n /// @param target actor id (uint64) to interact with\n /// @param method_num id of the method from the actor to call\n /// @param codec how the request data passed as argument is encoded\n /// @param raw_request encoded arguments to be passed in the call\n /// @param value tokens to be transfered to the called actor\n /// @param static_call indicates if the call will be allowed to change the actor state or not (just read the state)\n /// @dev it requires the id to be bigger than 99, as singleton actors are smaller than that\n function callNonSingletonByID(\n CommonTypes.FilActorId target,\n uint256 method_num,\n uint64 codec,\n bytes memory raw_request,\n uint256 value,\n bool static_call\n ) internal returns (bytes memory) {\n if (CommonTypes.FilActorId.unwrap(target) < 100) {\n revert InvalidActorID(target);\n }\n\n return callByID(target, method_num, codec, raw_request, value, static_call);\n }\n\n /// @notice parse the response an actor returned\n /// @notice it will validate the return code (success) and the codec (valid one)\n /// @param raw_response raw data (bytes) the actor returned\n /// @return the actual raw data (payload, in bytes) to be parsed according to the actor and method called\n function readRespData(bytes memory raw_response) internal pure returns (bytes memory) {\n (int256 exit, uint64 return_codec, bytes memory return_value) = abi.decode(raw_response, (int256, uint64, bytes));\n\n if (return_codec == Misc.NONE_CODEC) {\n if (return_value.length != 0) {\n revert InvalidResponseLength();\n }\n } else if (return_codec == Misc.CBOR_CODEC || return_codec == Misc.DAG_CBOR_CODEC) {\n if (return_value.length == 0) {\n revert InvalidResponseLength();\n }\n } else {\n revert InvalidCodec(return_codec);\n }\n\n if (exit != 0) {\n revert ActorError(exit);\n }\n\n return return_value;\n }\n}\n" + }, + "@zondax/filecoin-solidity/contracts/v0.8/utils/CborDecode.sol": { + "content": "/*******************************************************************************\n * (c) 2022 Zondax AG\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ********************************************************************************/\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\n\n// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.17;\n\n// \tMajUnsignedInt = 0\n// \tMajSignedInt = 1\n// \tMajByteString = 2\n// \tMajTextString = 3\n// \tMajArray = 4\n// \tMajMap = 5\n// \tMajTag = 6\n// \tMajOther = 7\n\nuint8 constant MajUnsignedInt = 0;\nuint8 constant MajSignedInt = 1;\nuint8 constant MajByteString = 2;\nuint8 constant MajTextString = 3;\nuint8 constant MajArray = 4;\nuint8 constant MajMap = 5;\nuint8 constant MajTag = 6;\nuint8 constant MajOther = 7;\n\nuint8 constant TagTypeBigNum = 2;\nuint8 constant TagTypeNegativeBigNum = 3;\n\nuint8 constant True_Type = 21;\nuint8 constant False_Type = 20;\n\n/// @notice This library is a set a functions that allows anyone to decode cbor encoded bytes\n/// @dev methods in this library try to read the data type indicated from cbor encoded data stored in bytes at a specific index\n/// @dev if it successes, methods will return the read value and the new index (intial index plus read bytes)\n/// @author Zondax AG\nlibrary CBORDecoder {\n /// @notice check if next value on the cbor encoded data is null\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n function isNullNext(bytes memory cborData, uint byteIdx) internal pure returns (bool) {\n return cborData[byteIdx] == hex\"f6\";\n }\n\n /// @notice attempt to read a bool value\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return a bool decoded from input bytes and the byte index after moving past the value\n function readBool(bytes memory cborData, uint byteIdx) internal pure returns (bool, uint) {\n uint8 maj;\n uint value;\n\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajOther, \"invalid maj (expected MajOther)\");\n assert(value == True_Type || value == False_Type);\n\n return (value != False_Type, byteIdx);\n }\n\n /// @notice attempt to read the length of a fixed array\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return length of the fixed array decoded from input bytes and the byte index after moving past the value\n function readFixedArray(bytes memory cborData, uint byteIdx) internal pure returns (uint, uint) {\n uint8 maj;\n uint len;\n\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajArray, \"invalid maj (expected MajArray)\");\n\n return (len, byteIdx);\n }\n\n /// @notice attempt to read an arbitrary length string value\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return arbitrary length string decoded from input bytes and the byte index after moving past the value\n function readString(bytes memory cborData, uint byteIdx) internal pure returns (string memory, uint) {\n uint8 maj;\n uint len;\n\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajTextString, \"invalid maj (expected MajTextString)\");\n\n uint max_len = byteIdx + len;\n bytes memory slice = new bytes(len);\n uint slice_index = 0;\n for (uint256 i = byteIdx; i < max_len; i++) {\n slice[slice_index] = cborData[i];\n slice_index++;\n }\n\n return (string(slice), byteIdx + len);\n }\n\n /// @notice attempt to read an arbitrary byte string value\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return arbitrary byte string decoded from input bytes and the byte index after moving past the value\n function readBytes(bytes memory cborData, uint byteIdx) internal pure returns (bytes memory, uint) {\n uint8 maj;\n uint len;\n\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajTag || maj == MajByteString, \"invalid maj (expected MajTag or MajByteString)\");\n\n if (maj == MajTag) {\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\n assert(maj == MajByteString);\n }\n\n uint max_len = byteIdx + len;\n bytes memory slice = new bytes(len);\n uint slice_index = 0;\n for (uint256 i = byteIdx; i < max_len; i++) {\n slice[slice_index] = cborData[i];\n slice_index++;\n }\n\n return (slice, byteIdx + len);\n }\n\n /// @notice attempt to read a bytes32 value\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return a bytes32 decoded from input bytes and the byte index after moving past the value\n function readBytes32(bytes memory cborData, uint byteIdx) internal pure returns (bytes32, uint) {\n uint8 maj;\n uint len;\n\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajByteString, \"invalid maj (expected MajByteString)\");\n\n uint max_len = byteIdx + len;\n bytes memory slice = new bytes(32);\n uint slice_index = 32 - len;\n for (uint256 i = byteIdx; i < max_len; i++) {\n slice[slice_index] = cborData[i];\n slice_index++;\n }\n\n return (bytes32(slice), byteIdx + len);\n }\n\n /// @notice attempt to read a uint256 value encoded per cbor specification\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return an uint256 decoded from input bytes and the byte index after moving past the value\n function readUInt256(bytes memory cborData, uint byteIdx) internal pure returns (uint256, uint) {\n uint8 maj;\n uint256 value;\n\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajTag || maj == MajUnsignedInt, \"invalid maj (expected MajTag or MajUnsignedInt)\");\n\n if (maj == MajTag) {\n require(value == TagTypeBigNum, \"invalid tag (expected TagTypeBigNum)\");\n\n uint len;\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajByteString, \"invalid maj (expected MajByteString)\");\n\n require(cborData.length >= byteIdx + len, \"slicing out of range\");\n assembly {\n value := mload(add(cborData, add(len, byteIdx)))\n }\n\n return (value, byteIdx + len);\n }\n\n return (value, byteIdx);\n }\n\n /// @notice attempt to read a int256 value encoded per cbor specification\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return an int256 decoded from input bytes and the byte index after moving past the value\n function readInt256(bytes memory cborData, uint byteIdx) internal pure returns (int256, uint) {\n uint8 maj;\n uint value;\n\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajTag || maj == MajSignedInt, \"invalid maj (expected MajTag or MajSignedInt)\");\n\n if (maj == MajTag) {\n assert(value == TagTypeNegativeBigNum);\n\n uint len;\n (maj, len, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajByteString, \"invalid maj (expected MajByteString)\");\n\n require(cborData.length >= byteIdx + len, \"slicing out of range\");\n assembly {\n value := mload(add(cborData, add(len, byteIdx)))\n }\n\n return (int256(value), byteIdx + len);\n }\n\n return (int256(value), byteIdx);\n }\n\n /// @notice attempt to read a uint64 value\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return an uint64 decoded from input bytes and the byte index after moving past the value\n function readUInt64(bytes memory cborData, uint byteIdx) internal pure returns (uint64, uint) {\n uint8 maj;\n uint value;\n\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajUnsignedInt, \"invalid maj (expected MajUnsignedInt)\");\n\n return (uint64(value), byteIdx);\n }\n\n /// @notice attempt to read a uint32 value\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return an uint32 decoded from input bytes and the byte index after moving past the value\n function readUInt32(bytes memory cborData, uint byteIdx) internal pure returns (uint32, uint) {\n uint8 maj;\n uint value;\n\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajUnsignedInt, \"invalid maj (expected MajUnsignedInt)\");\n\n return (uint32(value), byteIdx);\n }\n\n /// @notice attempt to read a uint16 value\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return an uint16 decoded from input bytes and the byte index after moving past the value\n function readUInt16(bytes memory cborData, uint byteIdx) internal pure returns (uint16, uint) {\n uint8 maj;\n uint value;\n\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajUnsignedInt, \"invalid maj (expected MajUnsignedInt)\");\n\n return (uint16(value), byteIdx);\n }\n\n /// @notice attempt to read a uint8 value\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return an uint8 decoded from input bytes and the byte index after moving past the value\n function readUInt8(bytes memory cborData, uint byteIdx) internal pure returns (uint8, uint) {\n uint8 maj;\n uint value;\n\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajUnsignedInt, \"invalid maj (expected MajUnsignedInt)\");\n\n return (uint8(value), byteIdx);\n }\n\n /// @notice attempt to read a int64 value\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return an int64 decoded from input bytes and the byte index after moving past the value\n function readInt64(bytes memory cborData, uint byteIdx) internal pure returns (int64, uint) {\n uint8 maj;\n uint value;\n\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajSignedInt || maj == MajUnsignedInt, \"invalid maj (expected MajSignedInt or MajUnsignedInt)\");\n\n return (int64(uint64(value)), byteIdx);\n }\n\n /// @notice attempt to read a int32 value\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return an int32 decoded from input bytes and the byte index after moving past the value\n function readInt32(bytes memory cborData, uint byteIdx) internal pure returns (int32, uint) {\n uint8 maj;\n uint value;\n\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajSignedInt || maj == MajUnsignedInt, \"invalid maj (expected MajSignedInt or MajUnsignedInt)\");\n\n return (int32(uint32(value)), byteIdx);\n }\n\n /// @notice attempt to read a int16 value\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return an int16 decoded from input bytes and the byte index after moving past the value\n function readInt16(bytes memory cborData, uint byteIdx) internal pure returns (int16, uint) {\n uint8 maj;\n uint value;\n\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajSignedInt || maj == MajUnsignedInt, \"invalid maj (expected MajSignedInt or MajUnsignedInt)\");\n\n return (int16(uint16(value)), byteIdx);\n }\n\n /// @notice attempt to read a int8 value\n /// @param cborData cbor encoded bytes to parse from\n /// @param byteIdx current position to read on the cbor encoded bytes\n /// @return an int8 decoded from input bytes and the byte index after moving past the value\n function readInt8(bytes memory cborData, uint byteIdx) internal pure returns (int8, uint) {\n uint8 maj;\n uint value;\n\n (maj, value, byteIdx) = parseCborHeader(cborData, byteIdx);\n require(maj == MajSignedInt || maj == MajUnsignedInt, \"invalid maj (expected MajSignedInt or MajUnsignedInt)\");\n\n return (int8(uint8(value)), byteIdx);\n }\n\n /// @notice slice uint8 from bytes starting at a given index\n /// @param bs bytes to slice from\n /// @param start current position to slice from bytes\n /// @return uint8 sliced from bytes\n function sliceUInt8(bytes memory bs, uint start) internal pure returns (uint8) {\n require(bs.length >= start + 1, \"slicing out of range\");\n return uint8(bs[start]);\n }\n\n /// @notice slice uint16 from bytes starting at a given index\n /// @param bs bytes to slice from\n /// @param start current position to slice from bytes\n /// @return uint16 sliced from bytes\n function sliceUInt16(bytes memory bs, uint start) internal pure returns (uint16) {\n require(bs.length >= start + 2, \"slicing out of range\");\n bytes2 x;\n assembly {\n x := mload(add(bs, add(0x20, start)))\n }\n return uint16(x);\n }\n\n /// @notice slice uint32 from bytes starting at a given index\n /// @param bs bytes to slice from\n /// @param start current position to slice from bytes\n /// @return uint32 sliced from bytes\n function sliceUInt32(bytes memory bs, uint start) internal pure returns (uint32) {\n require(bs.length >= start + 4, \"slicing out of range\");\n bytes4 x;\n assembly {\n x := mload(add(bs, add(0x20, start)))\n }\n return uint32(x);\n }\n\n /// @notice slice uint64 from bytes starting at a given index\n /// @param bs bytes to slice from\n /// @param start current position to slice from bytes\n /// @return uint64 sliced from bytes\n function sliceUInt64(bytes memory bs, uint start) internal pure returns (uint64) {\n require(bs.length >= start + 8, \"slicing out of range\");\n bytes8 x;\n assembly {\n x := mload(add(bs, add(0x20, start)))\n }\n return uint64(x);\n }\n\n /// @notice Parse cbor header for major type and extra info.\n /// @param cbor cbor encoded bytes to parse from\n /// @param byteIndex current position to read on the cbor encoded bytes\n /// @return major type, extra info and the byte index after moving past header bytes\n function parseCborHeader(bytes memory cbor, uint byteIndex) internal pure returns (uint8, uint64, uint) {\n uint8 first = sliceUInt8(cbor, byteIndex);\n byteIndex += 1;\n uint8 maj = (first & 0xe0) >> 5;\n uint8 low = first & 0x1f;\n // We don't handle CBOR headers with extra > 27, i.e. no indefinite lengths\n require(low < 28, \"cannot handle headers with extra > 27\");\n\n // extra is lower bits\n if (low < 24) {\n return (maj, low, byteIndex);\n }\n\n // extra in next byte\n if (low == 24) {\n uint8 next = sliceUInt8(cbor, byteIndex);\n byteIndex += 1;\n require(next >= 24, \"invalid cbor\"); // otherwise this is invalid cbor\n return (maj, next, byteIndex);\n }\n\n // extra in next 2 bytes\n if (low == 25) {\n uint16 extra16 = sliceUInt16(cbor, byteIndex);\n byteIndex += 2;\n return (maj, extra16, byteIndex);\n }\n\n // extra in next 4 bytes\n if (low == 26) {\n uint32 extra32 = sliceUInt32(cbor, byteIndex);\n byteIndex += 4;\n return (maj, extra32, byteIndex);\n }\n\n // extra in next 8 bytes\n assert(low == 27);\n uint64 extra64 = sliceUInt64(cbor, byteIndex);\n byteIndex += 8;\n return (maj, extra64, byteIndex);\n }\n}\n" + }, + "@zondax/filecoin-solidity/contracts/v0.8/utils/Misc.sol": { + "content": "/*******************************************************************************\n * (c) 2022 Zondax AG\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n ********************************************************************************/\n// THIS CODE WAS SECURITY REVIEWED BY KUDELSKI SECURITY, BUT NOT FORMALLY AUDITED\n\n// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.17;\n\nimport \"../types/CommonTypes.sol\";\n\n/// @title Library containing miscellaneous functions used on the project\n/// @author Zondax AG\nlibrary Misc {\n uint64 constant DAG_CBOR_CODEC = 0x71;\n uint64 constant CBOR_CODEC = 0x51;\n uint64 constant NONE_CODEC = 0x00;\n\n // Code taken from Openzeppelin repo\n // Link: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/0320a718e8e07b1d932f5acb8ad9cec9d9eed99b/contracts/utils/math/SignedMath.sol#L37-L42\n /// @notice get the abs from a signed number\n /// @param n number to get abs from\n /// @return unsigned number\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n\n /// @notice validate if an address exists or not\n /// @dev read this article for more information https://blog.finxter.com/how-to-find-out-if-an-ethereum-address-is-a-contract/\n /// @param addr address to check\n /// @return whether the address exists or not\n function addressExists(address addr) internal view returns (bool) {\n bytes32 codehash;\n assembly {\n codehash := extcodehash(addr)\n }\n return codehash != 0x0;\n }\n\n /// Returns the data size required by CBOR.writeFixedNumeric\n function getPrefixSize(uint256 data_size) internal pure returns (uint256) {\n if (data_size <= 23) {\n return 1;\n } else if (data_size <= 0xFF) {\n return 2;\n } else if (data_size <= 0xFFFF) {\n return 3;\n } else if (data_size <= 0xFFFFFFFF) {\n return 5;\n }\n return 9;\n }\n\n function getBytesSize(bytes memory value) internal pure returns (uint256) {\n return getPrefixSize(value.length) + value.length;\n }\n\n function getCidSize(bytes memory value) internal pure returns (uint256) {\n return getPrefixSize(2) + value.length;\n }\n\n function getFilActorIdSize(CommonTypes.FilActorId value) internal pure returns (uint256) {\n uint64 val = CommonTypes.FilActorId.unwrap(value);\n return getPrefixSize(uint256(val));\n }\n\n function getChainEpochSize(CommonTypes.ChainEpoch value) internal pure returns (uint256) {\n int64 val = CommonTypes.ChainEpoch.unwrap(value);\n if (val >= 0) {\n return getPrefixSize(uint256(uint64(val)));\n } else {\n return getPrefixSize(uint256(uint64(-1 - val)));\n }\n }\n\n function getBoolSize() internal pure returns (uint256) {\n return getPrefixSize(1);\n }\n}\n" + }, + "contracts/MinerPeerIDMapping.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@zondax/filecoin-solidity/contracts/v0.8/MinerAPI.sol\";\nimport \"@zondax/filecoin-solidity/contracts/v0.8/types/CommonTypes.sol\";\n\ncontract MinerPeerIDMapping {\n struct PeerData {\n string peerID;\n bytes signedMessage;\n }\n\n mapping(uint64 => PeerData) public minerToPeerData;\n\n // Events\n event PeerDataAdded(uint64 indexed minerID, string peerID);\n event PeerDataUpdated(uint64 indexed minerID, string oldPeerID, string newPeerID);\n event PeerDataDeleted(uint64 indexed minerID);\n\n constructor() {\n // The contract is immutable from the owner now, no ownership transfer is possible\n }\n\n /**\n * @notice Add a new PeerID and signed message for a MinerID in the contract.\n * @param minerID The MinerID to associate with the new PeerID.\n * @param newPeerID The new PeerID to bind to the MinerID.\n * @param signedMessage The signed message to store.\n */\n function addPeerData(\n uint64 minerID,\n string memory newPeerID,\n bytes memory signedMessage\n ) public {\n require(bytes(minerToPeerData[minerID].peerID).length == 0, \"Peer data already exists for this MinerID\");\n\n require(isControllingAddress(msg.sender, minerID), \"Caller is not the controlling address\");\n\n minerToPeerData[minerID] = PeerData(newPeerID, signedMessage);\n\n emit PeerDataAdded(minerID, newPeerID);\n }\n\n /**\n * @notice Update an existing PeerID and signed message for a MinerID in the contract.\n * @param minerID The MinerID whose PeerID will be updated.\n * @param newPeerID The new PeerID to bind to the MinerID.\n * @param signedMessage The new signed message to store.\n */\n function updatePeerData(\n uint64 minerID,\n string memory newPeerID,\n bytes memory signedMessage\n ) public {\n require(bytes(minerToPeerData[minerID].peerID).length > 0, \"No peer data exists for this MinerID\");\n\n require(isControllingAddress(msg.sender, minerID), \"Caller is not the controlling address\");\n\n string memory oldPeerID = minerToPeerData[minerID].peerID;\n minerToPeerData[minerID] = PeerData(newPeerID, signedMessage);\n\n emit PeerDataUpdated(minerID, oldPeerID, newPeerID);\n }\n\n /**\n * @notice Delete an existing PeerID and signed message for a MinerID in the contract.\n * @param minerID The MinerID whose peer data will be deleted.\n */\n function deletePeerData(uint64 minerID) public {\n require(bytes(minerToPeerData[minerID].peerID).length > 0, \"No peer data exists for this MinerID\");\n\n require(isControllingAddress(msg.sender, minerID), \"Caller is not the controlling address\");\n\n delete minerToPeerData[minerID];\n\n emit PeerDataDeleted(minerID);\n }\n\n /**\n * @notice Fetch the PeerID and signed message associated with a MinerID.\n * @param minerID The MinerID to query.\n * @return The PeerID and signed message associated with the MinerID.\n */\n function getPeerData(uint64 minerID) public view returns (PeerData memory) {\n return minerToPeerData[minerID];\n }\n\n /**\n * @notice Check if the caller is the controlling address for the given MinerID.\n * @param caller The address of the caller.\n * @param minerID The MinerID to check.\n * @return True if the caller is the controlling address, false otherwise.\n */\n function isControllingAddress(address caller, uint64 minerID) internal returns (bool) {\n // Wrap the uint64 miner ID into a FilActorId\n CommonTypes.FilActorId minerActorID = CommonTypes.FilActorId.wrap(minerID);\n\n // Create a FilAddress for the caller\n CommonTypes.FilAddress memory callerAddress = CommonTypes.FilAddress({data: abi.encodePacked(caller)});\n\n // Call the MinerAPI function\n bool isControlling = MinerAPI.isControllingAddress(minerActorID, callerAddress);\n\n return isControlling;\n }\n}\n" + }, + "solidity-cborutils/contracts/CBOR.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nimport \"@ensdomains/buffer/contracts/Buffer.sol\";\n\n/**\n* @dev A library for populating CBOR encoded payload in Solidity.\n*\n* https://datatracker.ietf.org/doc/html/rfc7049\n*\n* The library offers various write* and start* methods to encode values of different types.\n* The resulted buffer can be obtained with data() method.\n* Encoding of primitive types is staightforward, whereas encoding of sequences can result\n* in an invalid CBOR if start/write/end flow is violated.\n* For the purpose of gas saving, the library does not verify start/write/end flow internally,\n* except for nested start/end pairs.\n*/\n\nlibrary CBOR {\n using Buffer for Buffer.buffer;\n\n struct CBORBuffer {\n Buffer.buffer buf;\n uint256 depth;\n }\n\n uint8 private constant MAJOR_TYPE_INT = 0;\n uint8 private constant MAJOR_TYPE_NEGATIVE_INT = 1;\n uint8 private constant MAJOR_TYPE_BYTES = 2;\n uint8 private constant MAJOR_TYPE_STRING = 3;\n uint8 private constant MAJOR_TYPE_ARRAY = 4;\n uint8 private constant MAJOR_TYPE_MAP = 5;\n uint8 private constant MAJOR_TYPE_TAG = 6;\n uint8 private constant MAJOR_TYPE_CONTENT_FREE = 7;\n\n uint8 private constant TAG_TYPE_BIGNUM = 2;\n uint8 private constant TAG_TYPE_NEGATIVE_BIGNUM = 3;\n\n uint8 private constant CBOR_FALSE = 20;\n uint8 private constant CBOR_TRUE = 21;\n uint8 private constant CBOR_NULL = 22;\n uint8 private constant CBOR_UNDEFINED = 23;\n\n function create(uint256 capacity) internal pure returns(CBORBuffer memory cbor) {\n Buffer.init(cbor.buf, capacity);\n cbor.depth = 0;\n return cbor;\n }\n\n function data(CBORBuffer memory buf) internal pure returns(bytes memory) {\n require(buf.depth == 0, \"Invalid CBOR\");\n return buf.buf.buf;\n }\n\n function writeUInt256(CBORBuffer memory buf, uint256 value) internal pure {\n buf.buf.appendUint8(uint8((MAJOR_TYPE_TAG << 5) | TAG_TYPE_BIGNUM));\n writeBytes(buf, abi.encode(value));\n }\n\n function writeInt256(CBORBuffer memory buf, int256 value) internal pure {\n if (value < 0) {\n buf.buf.appendUint8(\n uint8((MAJOR_TYPE_TAG << 5) | TAG_TYPE_NEGATIVE_BIGNUM)\n );\n writeBytes(buf, abi.encode(uint256(-1 - value)));\n } else {\n writeUInt256(buf, uint256(value));\n }\n }\n\n function writeUInt64(CBORBuffer memory buf, uint64 value) internal pure {\n writeFixedNumeric(buf, MAJOR_TYPE_INT, value);\n }\n\n function writeInt64(CBORBuffer memory buf, int64 value) internal pure {\n if(value >= 0) {\n writeFixedNumeric(buf, MAJOR_TYPE_INT, uint64(value));\n } else{\n writeFixedNumeric(buf, MAJOR_TYPE_NEGATIVE_INT, uint64(-1 - value));\n }\n }\n\n function writeBytes(CBORBuffer memory buf, bytes memory value) internal pure {\n writeFixedNumeric(buf, MAJOR_TYPE_BYTES, uint64(value.length));\n buf.buf.append(value);\n }\n\n function writeString(CBORBuffer memory buf, string memory value) internal pure {\n writeFixedNumeric(buf, MAJOR_TYPE_STRING, uint64(bytes(value).length));\n buf.buf.append(bytes(value));\n }\n\n function writeBool(CBORBuffer memory buf, bool value) internal pure {\n writeContentFree(buf, value ? CBOR_TRUE : CBOR_FALSE);\n }\n\n function writeNull(CBORBuffer memory buf) internal pure {\n writeContentFree(buf, CBOR_NULL);\n }\n\n function writeUndefined(CBORBuffer memory buf) internal pure {\n writeContentFree(buf, CBOR_UNDEFINED);\n }\n\n function startArray(CBORBuffer memory buf) internal pure {\n writeIndefiniteLengthType(buf, MAJOR_TYPE_ARRAY);\n buf.depth += 1;\n }\n\n function startFixedArray(CBORBuffer memory buf, uint64 length) internal pure {\n writeDefiniteLengthType(buf, MAJOR_TYPE_ARRAY, length);\n }\n\n function startMap(CBORBuffer memory buf) internal pure {\n writeIndefiniteLengthType(buf, MAJOR_TYPE_MAP);\n buf.depth += 1;\n }\n\n function startFixedMap(CBORBuffer memory buf, uint64 length) internal pure {\n writeDefiniteLengthType(buf, MAJOR_TYPE_MAP, length);\n }\n\n function endSequence(CBORBuffer memory buf) internal pure {\n writeIndefiniteLengthType(buf, MAJOR_TYPE_CONTENT_FREE);\n buf.depth -= 1;\n }\n\n function writeKVString(CBORBuffer memory buf, string memory key, string memory value) internal pure {\n writeString(buf, key);\n writeString(buf, value);\n }\n\n function writeKVBytes(CBORBuffer memory buf, string memory key, bytes memory value) internal pure {\n writeString(buf, key);\n writeBytes(buf, value);\n }\n\n function writeKVUInt256(CBORBuffer memory buf, string memory key, uint256 value) internal pure {\n writeString(buf, key);\n writeUInt256(buf, value);\n }\n\n function writeKVInt256(CBORBuffer memory buf, string memory key, int256 value) internal pure {\n writeString(buf, key);\n writeInt256(buf, value);\n }\n\n function writeKVUInt64(CBORBuffer memory buf, string memory key, uint64 value) internal pure {\n writeString(buf, key);\n writeUInt64(buf, value);\n }\n\n function writeKVInt64(CBORBuffer memory buf, string memory key, int64 value) internal pure {\n writeString(buf, key);\n writeInt64(buf, value);\n }\n\n function writeKVBool(CBORBuffer memory buf, string memory key, bool value) internal pure {\n writeString(buf, key);\n writeBool(buf, value);\n }\n\n function writeKVNull(CBORBuffer memory buf, string memory key) internal pure {\n writeString(buf, key);\n writeNull(buf);\n }\n\n function writeKVUndefined(CBORBuffer memory buf, string memory key) internal pure {\n writeString(buf, key);\n writeUndefined(buf);\n }\n\n function writeKVMap(CBORBuffer memory buf, string memory key) internal pure {\n writeString(buf, key);\n startMap(buf);\n }\n\n function writeKVArray(CBORBuffer memory buf, string memory key) internal pure {\n writeString(buf, key);\n startArray(buf);\n }\n\n function writeFixedNumeric(\n CBORBuffer memory buf,\n uint8 major,\n uint64 value\n ) private pure {\n if (value <= 23) {\n buf.buf.appendUint8(uint8((major << 5) | value));\n } else if (value <= 0xFF) {\n buf.buf.appendUint8(uint8((major << 5) | 24));\n buf.buf.appendInt(value, 1);\n } else if (value <= 0xFFFF) {\n buf.buf.appendUint8(uint8((major << 5) | 25));\n buf.buf.appendInt(value, 2);\n } else if (value <= 0xFFFFFFFF) {\n buf.buf.appendUint8(uint8((major << 5) | 26));\n buf.buf.appendInt(value, 4);\n } else {\n buf.buf.appendUint8(uint8((major << 5) | 27));\n buf.buf.appendInt(value, 8);\n }\n }\n\n function writeIndefiniteLengthType(CBORBuffer memory buf, uint8 major)\n private\n pure\n {\n buf.buf.appendUint8(uint8((major << 5) | 31));\n }\n\n function writeDefiniteLengthType(CBORBuffer memory buf, uint8 major, uint64 length)\n private\n pure\n {\n writeFixedNumeric(buf, major, length);\n }\n\n function writeContentFree(CBORBuffer memory buf, uint8 value) private pure {\n buf.buf.appendUint8(uint8((MAJOR_TYPE_CONTENT_FREE << 5) | value));\n }\n}" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 1000, + "details": { + "yul": false + } + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/market/ipni/spark/sol/hardhat.config.ts b/market/ipni/spark/sol/hardhat.config.ts index 39fe30dd2..dc22bf380 100644 --- a/market/ipni/spark/sol/hardhat.config.ts +++ b/market/ipni/spark/sol/hardhat.config.ts @@ -2,6 +2,7 @@ import { HardhatUserConfig } from "hardhat/config"; import "@nomicfoundation/hardhat-toolbox"; import "@nomicfoundation/hardhat-ethers"; import "dotenv/config"; // For .env variables +import "hardhat-deploy"; const PRIVATE_KEY = process.env.PRIVATE_KEY; diff --git a/market/ipni/spark/sol/package-lock.json b/market/ipni/spark/sol/package-lock.json index 739f8b7eb..381aad403 100644 --- a/market/ipni/spark/sol/package-lock.json +++ b/market/ipni/spark/sol/package-lock.json @@ -10,7 +10,6 @@ "license": "MIT", "dependencies": { "@zondax/filecoin-solidity": "^4.0.3", - "hardhat-deploy": "^0.12.4", "hardhat-deploy-ethers": "^0.4.2" }, "devDependencies": { @@ -22,6 +21,7 @@ "dotenv": "^16.4.5", "ethers": "^6.13.2", "hardhat": "^2.22.10", + "hardhat-deploy": "^0.14.0", "ts-mocha": "^10.0.0", "ts-node": "^10.9.2", "typescript": "^5.7.3" @@ -6993,9 +6993,9 @@ } }, "node_modules/hardhat-deploy": { - "version": "0.12.4", - "resolved": "https://registry.npmjs.org/hardhat-deploy/-/hardhat-deploy-0.12.4.tgz", - "integrity": "sha512-bYO8DIyeGxZWlhnMoCBon9HNZb6ji0jQn7ngP1t5UmGhC8rQYhji7B73qETMOFhzt5ECZPr+U52duj3nubsqdQ==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/hardhat-deploy/-/hardhat-deploy-0.14.0.tgz", + "integrity": "sha512-jZm0bJGHeH7dEyCzz69hsS8HlNNLJLjXDQVlStczulf54vYJUfRvZ+t3x20QsdXQoXUe6Qujlp8cKbx6JjFpZw==", "license": "MIT", "dependencies": { "@ethersproject/abi": "^5.7.0", diff --git a/market/ipni/spark/sol/package.json b/market/ipni/spark/sol/package.json index 27cfd83e3..1d2e97add 100644 --- a/market/ipni/spark/sol/package.json +++ b/market/ipni/spark/sol/package.json @@ -21,13 +21,13 @@ "dotenv": "^16.4.5", "ethers": "^6.13.2", "hardhat": "^2.22.10", + "hardhat-deploy": "^0.14.0", "ts-mocha": "^10.0.0", "ts-node": "^10.9.2", "typescript": "^5.7.3" }, "dependencies": { "@zondax/filecoin-solidity": "^4.0.3", - "hardhat-deploy": "^0.12.4", "hardhat-deploy-ethers": "^0.4.2" }, "keywords": [ diff --git a/market/ipni/spark/spark.go b/market/ipni/spark/spark.go index b09446e5e..43220da86 100644 --- a/market/ipni/spark/spark.go +++ b/market/ipni/spark/spark.go @@ -14,19 +14,12 @@ type SparkMessage struct { } func GetContractAddress() (string, error) { - if build.BuildType == build.BuildMainnet { - return "", nil - } - - if build.BuildType == build.BuildCalibnet { - return "0xE08bBc65aF1f1a40BD3cbaD290a23925F83b8BBB", nil - } - if build.BuildType == build.Build2k || build.BuildType == build.BuildDebug { - return "", errors.New("manual contract is required for debug build") + if build.BuildType != build.BuildMainnet { + return "", errors.New("not supported on this network") } - return "", errors.New("unknown build type") + return "0x599172a7654E47f070576ca7e56Ab9564FbD4041", nil } const AddPeerAbi = `[