Skip to content

Commit

Permalink
add id field to delegation placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed Feb 15, 2024
1 parent 8c7849c commit f5e18fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Sources/KukaiCoreSwift/Models/BakingBad/TzKTTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,11 @@ public struct TzKTTransaction: Codable, CustomStringConvertible, Hashable, Ident
}

/// Used for createing a "Pending" delegation transaction
public static func placeholder(withStatus status: TransactionStatus, opHash: String, type: TransactionType, counter: Decimal, fromWallet: WalletMetadata, newDelegate: TzKTAddress?) -> TzKTTransaction {
public static func placeholder(withStatus status: TransactionStatus, id: Decimal, opHash: String, type: TransactionType, counter: Decimal, fromWallet: WalletMetadata, newDelegate: TzKTAddress?) -> TzKTTransaction {
let timestamp = TzKTTransaction.dateFormatter.string(from: Date())
let sender = TzKTAddress(alias: fromWallet.walletNickname ?? fromWallet.socialUsername ?? fromWallet.address, address: fromWallet.address)

var transaction = TzKTTransaction(type: .delegation, id: 0, level: 0, timestamp: timestamp, hash: opHash, counter: counter, initiater: nil, sender: sender, bakerFee: .zero(), storageFee: .zero(), allocationFee: .zero(), target: nil, prevDelegate: nil, newDelegate: newDelegate, amount: .zero(), parameter: nil, status: status, hasInternals: false, tokenTransfersCount: nil, errors: nil)
var transaction = TzKTTransaction(type: .delegation, id: id, level: id, timestamp: timestamp, hash: opHash, counter: counter, initiater: nil, sender: sender, bakerFee: .zero(), storageFee: .zero(), allocationFee: .zero(), target: nil, prevDelegate: nil, newDelegate: newDelegate, amount: .zero(), parameter: nil, status: status, hasInternals: false, tokenTransfersCount: nil, errors: nil)
transaction.processAdditionalData(withCurrentWalletAddress: fromWallet.address)

return transaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ final class TzKTTransactionTests: XCTestCase {

func testPlaceholders() {
let source = WalletMetadata(address: "tz1abc", hdWalletGroupName: nil, type: .hd, children: [], isChild: false, isWatchOnly: false, bas58EncodedPublicKey: "", backedUp: true)
let placeholder1 = TzKTTransaction.placeholder(withStatus: .unconfirmed, opHash: "abc123", type: .transaction, counter: 0, fromWallet: source, newDelegate: TzKTAddress(alias: "Baking Benjamins", address: "tz1YgDUQV2eXm8pUWNz3S5aWP86iFzNp4jnD"))
let placeholder1 = TzKTTransaction.placeholder(withStatus: .unconfirmed, id: 567, opHash: "abc123", type: .transaction, counter: 0, fromWallet: source, newDelegate: TzKTAddress(alias: "Baking Benjamins", address: "tz1YgDUQV2eXm8pUWNz3S5aWP86iFzNp4jnD"))

let placeholder2 = TzKTTransaction.placeholder(withStatus: .unconfirmed, id: 456, opHash: "def456", type: .transaction, counter: 1, fromWallet: source, destination: TzKTAddress(alias: nil, address: "tz1def"), xtzAmount: .init(fromNormalisedAmount: 4.17, decimalPlaces: 6), parameters: nil, primaryToken: nil)

Expand Down

0 comments on commit f5e18fe

Please sign in to comment.