Skip to content

Commit

Permalink
Bring ContractUpdate to parity
Browse files Browse the repository at this point in the history
  • Loading branch information
qtbeee committed Jan 6, 2020
1 parent 461e56f commit 0414bf4
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions Sources/Hedera/contract/ContractUpdateTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,45 @@ public class ContractUpdateTransaction: TransactionBuilder {
body.contractUpdateInstance = Proto_ContractUpdateTransactionBody()
}

/// Set a new admin Ed25519PublicKey
/// Set the contract id to be updated
@discardableResult
public func setContractId(_ id: ContractId) -> Self {
body.contractUpdateInstance.contractID = id.toProto()

return self
}

/// Set a new admin PublicKey
@discardableResult
public func setAdminKey(_ key: Ed25519PublicKey) -> Self {
public func setAdminKey(_ key: PublicKey) -> Self {
body.contractUpdateInstance.adminKey = key.toProto()

return self
}

/// Update or set the auto renew period in seconds
/// Update or set the proxy account id
///
/// - SeeAlso:
/// `ContractCreateTransaction::setProxyAccount`
@discardableResult
public func setAutoRenewPeriod(_ period: TimeInterval) -> Self {
body.contractUpdateInstance.autoRenewPeriod = period.toProto()
public func setProxyAccountId(_ id: AccountId) -> Self {
body.contractUpdateInstance.proxyAccountID = id.toProto()

return self
}

/// Update the solidity file to be used
@discardableResult
public func setBytecodeFile(_ id: FileId) -> Self {
public func setBytecodeFileId(_ id: FileId) -> Self {
body.contractUpdateInstance.fileID = id.toProto()

return self
}

/// Set the contract id to be updated
/// Update or set the auto renew period in seconds
@discardableResult
public func setContract(_ id: ContractId) -> Self {
body.contractUpdateInstance.contractID = id.toProto()
public func setAutoRenewPeriod(_ period: TimeInterval) -> Self {
body.contractUpdateInstance.autoRenewPeriod = period.toProto()

return self
}
Expand All @@ -51,18 +62,15 @@ public class ContractUpdateTransaction: TransactionBuilder {
/// (no effect if it already is this time or later)
@discardableResult
public func setExpirationTime(_ date: Date) -> Self {
body.fileCreate.expirationTime = date.toProto()
body.contractUpdateInstance.expirationTime = date.toProto()

return self
}

/// Update or set the proxy account id
///
/// - SeeAlso:
/// `ContractCreateTransaction::setProxyAccount`
/// Set or update the memo for the contract
@discardableResult
public func setProxyAccount(_ id: AccountId) -> Self {
body.contractUpdateInstance.proxyAccountID = id.toProto()
public func setContractMemo(_ memo: String) -> Self {
body.contractUpdateInstance.memo = memo

return self
}
Expand Down

0 comments on commit 0414bf4

Please sign in to comment.