From e8f6e345d5c0defd0e81530d83dadc8ee3cf9cb3 Mon Sep 17 00:00:00 2001 From: srisankethu Date: Tue, 8 Jan 2019 01:22:54 +0530 Subject: [PATCH] WIP: Add ST-20 support --- .../PrecompiledContracts/Web3+ST20.swift | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 web3swift/PrecompiledContracts/Web3+ST20.swift diff --git a/web3swift/PrecompiledContracts/Web3+ST20.swift b/web3swift/PrecompiledContracts/Web3+ST20.swift new file mode 100644 index 000000000..2fbfcb43d --- /dev/null +++ b/web3swift/PrecompiledContracts/Web3+ST20.swift @@ -0,0 +1,79 @@ +import Foundation +import BigInt +import EthereumAddress +import PromiseKit + +protocol ISecurityToken: IERC20 { + + func decimals() throws -> UInt8 + func totalSupply() throws -> BigUInt + func getBalance(account: EthereumAddress) throws -> BigUInt + func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) throws -> BigUInt + func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) throws -> WriteTransaction + func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) throws -> WriteTransaction + func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) throws -> WriteTransaction + func decreasedApproval(from: EthereumAddress, spender: EthereumAddress, subtractedValue: String) throws -> WriteTransaction + func increasedApproval(from: EthereumAddress, spender: EthereumAddress, addedValue: String) throws -> WriteTransaction + + func verifyTransfer(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) throws -> WriteTransaction + func mint(investor: EthereumAddress, amount: String) + func mintWithData(investor: EthereumAddress, amount: String, data: Data) throws -> WriteTransaction + func burnFromWithData(from: EthereumAddress, burner: EthereumAddress, amount: String, data: Data) throws -> WriteTransaction + func burnWithData(burner: EthereumAddress, amount: String, data: Data) throws -> WriteTransaction + func checkPermission(delegate: EthereumAddress, module: EthereumAddress, perm: Data) throws -> WriteTransaction + func getModule(module: EthereumAddress) throws -> [Data, EthereumAddress, Bool, UInt8, BigUInt, BigUInt] + func getModulesByName(name: Data) throws -> EthereumAddress[] + func getModulesByType(type: UInt8) throws -> EthereumAddress[] + func totalSupplyAt(checkpointId: String) throws -> BigUInt + func getBalanceAt(investor: Ethereum, checkpointId: String) throws -> BigUInt + func createCheckpoint() throws -> BigUInt + func getInvestors() throws -> EthereumAddress[] + func getInvestorsAt(checkpointId: String) throws -> EthereumAddress[] + func iterateInvestors(start: String, end: String) throws -> EthereumAddress[] + func currentCheckpointId() throws -> BigUInt + func investors(index: String) throws -> EthereumAddress + func withdrawERC20(tokenContract: EthereumAddress, amount: String) throws -> WriteTransaction + func changeModuleBudget(module: EthereumAddress, budget: String) throws -> WriteTransaction + func updateTokenDetails(newTokenDetails: String) throws -> WriteTransaction + func changeGranularity(granularity: String) throws -> WriteTransaction + func pruneInvestors(start: String, iters: String) throws -> WriteTransaction + func freezeTransfers() throws -> WriteTransaction + func unfreezeTransfers() throws -> WriteTransaction + func freezeMinting() throws -> WriteTransaction + func mintMulti(investors: EthereumAddress[], amounts: String[]) throws -> WriteTransaction + func addModule(moduleFactory: EthereumAddress, data: Data, maxCost: String, budget: String) throws -> WriteTransaction + func archiveModule(module: EthereumAddress) throws -> WriteTransaction + func unarchiveModule(module: EthereumAddress) throws -> WriteTransaction + func removeModule(module: EthereumAddress) throws -> WriteTransaction + func setController(controller: EthereumAddress) throws -> WriteTransaction + func forceTransfer(from: EthereumAddress, to: EthereumAddress, amount: String, data: Data, log: Data) throws -> WriteTransaction + func forceBurn(from: EthereumAddress, amount: String, data: Data, log: Data) throws -> WriteTransaction + func disableController() throws -> WriteTransaction + func getVersion() throws -> UInt8[] + func getInvestorCount() throws -> BigUInt + func transferWithData(to: EthereumAddress, amount: String, data: Data) throws -> WriteTransaction + func transferFromWithData(from: EthereumAddress, to: EthereumAddress, amount: String, data: Data) throws -> WriteTransaction + func granularity() throws -> BigUInt + +} + +public class ST20: ISecurityToken { + func decimals() throws -> UInt8 { + } + func totalSupply() throws -> BigUInt { + } + func getBalance(account: EthereumAddress) throws -> BigUInt { + } + func getAllowance(originalOwner: EthereumAddress, delegate: EthereumAddress) throws -> BigUInt { + } + func transfer(from: EthereumAddress, to: EthereumAddress, amount: String) throws -> WriteTransaction { + } + func transferFrom(from: EthereumAddress, to: EthereumAddress, originalOwner: EthereumAddress, amount: String) throws -> WriteTransaction { + } + func approve(from: EthereumAddress, spender: EthereumAddress, amount: String) throws -> WriteTransaction { + } + func decreasedApproval(from: EthereumAddress, spender: EthereumAddress, subtractedValue: String) throws -> WriteTransaction { + } + func increasedApproval(from: EthereumAddress, spender: EthereumAddress, addedValue: String) throws -> WriteTransaction { + } +}