|
| 1 | +// |
| 2 | +// Web3+ERC1400.swift |
| 3 | +// web3swift-iOS |
| 4 | +// |
| 5 | +// Created by Anton Grigorev on 14/12/2018. |
| 6 | +// Copyright © 2018 The Matter Inc. All rights reserved. |
| 7 | +// |
| 8 | + |
| 9 | +import Foundation |
| 10 | +import BigInt |
| 11 | +import EthereumAddress |
| 12 | +import PromiseKit |
| 13 | + |
| 14 | +// ERC1400 = ERC20 + IERC1400 |
| 15 | +protocol IERC1400 { |
| 16 | + |
| 17 | + // Document Management |
| 18 | + func getDocument(name: Data) throws -> (String, Data) |
| 19 | + func setDocument(name: Data, uri: String, documentHash: Data) throws -> WriteTransaction |
| 20 | + |
| 21 | + // Token Information |
| 22 | + func balanceOfByPartition(partition: Data, tokenHolder: EthereumAddress) throws -> BigUInt |
| 23 | + func partitionsOf(tokenHolder: EthereumAddress) throws -> [Data] |
| 24 | + |
| 25 | + // Transfers |
| 26 | + func transferWithData(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) throws -> WriteTransaction |
| 27 | + func transferFromWithData(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8]) throws -> WriteTransaction |
| 28 | + |
| 29 | + // Partition Token Transfers |
| 30 | + func transferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) throws -> WriteTransaction |
| 31 | + func operatorTransferByPartition(partition: Data, from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8]) throws -> WriteTransaction |
| 32 | + |
| 33 | + // Controller Operation |
| 34 | + func isControllable() throws -> Bool |
| 35 | + func controllerTransfer(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) throws -> WriteTransaction |
| 36 | + func controllerRedeem(from: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8], operatorData: [UInt8]) throws -> WriteTransaction |
| 37 | + |
| 38 | + // Operator Management |
| 39 | + func authorizeOperator(operator: EthereumAddress) throws -> WriteTransaction |
| 40 | + func revokeOperator(operator: EthereumAddress) throws -> WriteTransaction |
| 41 | + func authorizeOperatorByPartition(partition: Data, operator: EthereumAddress) throws -> WriteTransaction |
| 42 | + func revokeOperatorByPartition(partition: Data, operator: EthereumAddress) throws -> WriteTransaction |
| 43 | + |
| 44 | + // Operator Information |
| 45 | + func isOperator(operator: EthereumAddress, tokenHolder: EthereumAddress) throws -> Bool |
| 46 | + func isOperatorForPartition(partition: Data, operator: EthereumAddress, tokenHolder: EthereumAddress) throws -> Bool |
| 47 | + |
| 48 | + // Token Issuance |
| 49 | + func isIssuable() throws -> Bool |
| 50 | + func issue(from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) -> WriteTransaction |
| 51 | + func issueByPartition(partition: Data, from: EthereumAddress, tokenHolder: EthereumAddress, amount: String, data: [UInt8]) -> WriteTransaction |
| 52 | + |
| 53 | + // Token Redemption |
| 54 | + func redeem(from: EthereumAddress, amount: String, data: [UInt8]) throws -> WriteTransaction |
| 55 | + func redeemFrom(tokenHolder: EthereumAddress, from: EthereumAddress, amount: String, data: [UInt8]) throws -> WriteTransaction |
| 56 | + func redeemByPartition(partition: Data, from: EthereumAddress, amount: String, data: [UInt8]) throws -> WriteTransaction |
| 57 | + func operatorRedeemByPartition(partition: Data, tokenHolder: EthereumAddress, from: EthereumAddress, amount: String, operatorData: [UInt8]) throws -> WriteTransaction |
| 58 | + |
| 59 | + // Transfer Validity |
| 60 | + func canTransfer(to: EthereumAddress, amount: String, data: [UInt8]) throws -> ([UInt8], Data) |
| 61 | + func canTransferFrom(originalOwner: EthereumAddress, to: EthereumAddress, amount: String, data: [UInt8]) throws -> ([UInt8], Data) |
| 62 | + func canTransferByPartition(originalOwner: EthereumAddress, to: EthereumAddress, partition: Data, amount: String, data: [UInt8]) throws -> ([UInt8], Data, Data) |
| 63 | +} |
| 64 | + |
| 65 | +// This namespace contains functions to work with ERC1400 tokens. |
| 66 | +// variables are lazyly evaluated or global token information (name, ticker, total supply) |
| 67 | +// can be imperatively read and saved |
0 commit comments