Skip to content

Commit

Permalink
Bring CryptoTransfer to parity
Browse files Browse the repository at this point in the history
  • Loading branch information
qtbeee committed Jan 6, 2020
1 parent 0ce344e commit 4e59f0d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Examples/TransferCrypto/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ let client = clientFromEnvironment(eventLoopGroup: eventLoopGroup)
.setMaxTransactionFee(100_000_000)

let tx = CryptoTransferTransaction()
.add(sender: AccountId("0.0.3")!, amount: 10000)
.add(recipient: AccountId("0.0.2")!, amount: 10000)
.addSender(AccountId("0.0.3")!, amount: 10000)
.addRecipient(AccountId("0.0.2")!, amount: 10000)
.setMemo("Transfer Crypto Example - Swift SDK")
.build(client: client)

Expand Down
8 changes: 4 additions & 4 deletions Sources/Hedera/QueryBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public class QueryBuilder<Response> {

header.responseType = Proto_ResponseType.costAnswer
header.payment = CryptoTransferTransaction()
.add(sender: client.operator!.id, amount: 0)
.add(recipient: node.accountId, amount: 0)
.addSender(client.operator!.id, amount: 0)
.addRecipient(node.accountId, amount: 0)
.build(client: client)
.addSigPair(publicKey: client.operator!.publicKey, signer: client.operator!.signer)
.toProto()
Expand Down Expand Up @@ -142,8 +142,8 @@ public class QueryBuilder<Response> {
func generateQueryPaymentTransaction(client: Client, node: Node, amount: UInt64) {
let tx = CryptoTransferTransaction()
.setNodeAccount(node.accountId)
.add(sender: client.operator!.id, amount: amount)
.add(recipient: node.accountId, amount: amount)
.addSender(client.operator!.id, amount: amount)
.addRecipient(node.accountId, amount: amount)
.setMaxTransactionFee(defaultMaxTransactionFee)
.build(client: client)
.addSigPair(publicKey: client.operator!.publicKey, signer: client.operator!.signer)
Expand Down
10 changes: 5 additions & 5 deletions Sources/Hedera/account/CryptoTransferTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ public final class CryptoTransferTransaction: TransactionBuilder {
}

@discardableResult
public func add(sender: AccountId, amount: UInt64) -> Self {
add(account: sender, amount: -Int64(amount))
public func addSender(_ sender: AccountId, amount: UInt64) -> Self {
addTransfer(account: sender, amount: -Int64(amount))
}

@discardableResult
public func add(recipient: AccountId, amount: UInt64) -> Self {
add(account: recipient, amount: Int64(amount))
public func addRecipient(_ recipient: AccountId, amount: UInt64) -> Self {
addTransfer(account: recipient, amount: Int64(amount))
}

@discardableResult
public func add(account: AccountId, amount: Int64) -> Self {
public func addTransfer(account: AccountId, amount: Int64) -> Self {
var accountAmount = Proto_AccountAmount()
accountAmount.accountID = account.toProto()
accountAmount.amount = amount
Expand Down

0 comments on commit 4e59f0d

Please sign in to comment.