argentlabs / web3.swift

Ethereum Swift API with support for smart contracts, ENS & ERC20
MIT License
668 stars 168 forks source link

Ocean protocol's startOrder method #334

Closed aburashima closed 1 year ago

aburashima commented 1 year ago

Hello, Does the library have a method corresponding to startOrder method in the Ocean protocol? Please see for reference: https://github.com/oceanprotocol/contracts/blob/9e29194d910f28a4f0ef17ce6dc8a70741f63309/contracts/templates/ERC20Template.sol#L519 Can ABIFunction subclass be used as a substitute for it? For example: public struct StartOrder: ABIFunction { public static let name = "startOrder" public let gasPrice: BigUInt? = nil public let gasLimit: BigUInt? = nil public var contract: EthereumAddress public let consumer: EthereumAddress public let serviceIndex: BigInt public let providerFee: <it's struct type in smart contract> public let consumeMarketFee: <it's struct type in smart contract>

public init(contract: EthereumAddress,
            consumer: EthereumAddress,
            serviceIndex: BigInt,
            providerFee: <>,
            consumeMarketFee: <>) {
    self.contract = contract
    self.consumer = consumer
    self.serviceIndex = serviceIndex
    self.consumeMarketFee = consumeMarketFee 
    self.providerFee = providerFee
}

public func encode(to encoder: ABIFunctionEncoder) throws {
    try encoder.encode(to)
    try encoder.encode(value)
}

}

let function = StartOrder(contract: "0xtokenaddress", <params,...>) let transaction = try function.transaction()

client.eth_sendRawTransaction(transaction, withAccount: account) { (error, txHash) in print("TX Hash: (txHash)") }

Thank you in advance!

DarthMike commented 1 year ago

No you can create it yourself, that's why it supports user-created ABIs with native types in Swift