Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add metadata field for tokens #331

Merged
merged 23 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: change memo to optional
Signed-off-by: Ricky Saechao <[email protected]>
  • Loading branch information
RickyLB committed May 1, 2024
commit 12d29cb45f6c2ba21f7e6a003d9dd28f707bb6c3
12 changes: 7 additions & 5 deletions Sources/Hedera/Token/TokenUpdateTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class TokenUpdateTransaction: Transaction {
autoRenewAccountId: AccountId? = nil,
autoRenewPeriod: Duration? = nil,
expirationTime: Timestamp? = nil,
tokenMemo: String = "",
tokenMemo: String? = nil,
feeScheduleKey: Key? = nil,
pauseKey: Key? = nil,
metadata: Data = .init(),
Expand Down Expand Up @@ -271,7 +271,7 @@ public final class TokenUpdateTransaction: Transaction {
}

/// The new memo associated with the token (UTF-8 encoding max 100 bytes).
public var tokenMemo: String {
public var tokenMemo: String? {
willSet {
ensureNotFrozen()
}
Expand All @@ -287,7 +287,7 @@ public final class TokenUpdateTransaction: Transaction {

@discardableResult
public func clearMemo() -> Self {
tokenMemo = ""
tokenMemo = nil

return self
}
Expand Down Expand Up @@ -376,7 +376,7 @@ extension TokenUpdateTransaction: ToProtobuf {
internal typealias Protobuf = Proto_TokenUpdateTransactionBody

internal func toProtobuf() -> Protobuf {
.with { proto in
return .with { proto in
tokenId?.toProtobufInto(&proto.token)
proto.name = tokenName
proto.symbol = tokenSymbol
Expand All @@ -389,11 +389,13 @@ extension TokenUpdateTransaction: ToProtobuf {
autoRenewAccountId?.toProtobufInto(&proto.autoRenewAccount)
autoRenewPeriod?.toProtobufInto(&proto.autoRenewPeriod)
expirationTime?.toProtobufInto(&proto.expiry)
proto.memo = Google_Protobuf_StringValue(tokenMemo)
feeScheduleKey?.toProtobufInto(&proto.feeScheduleKey)
pauseKey?.toProtobufInto(&proto.pauseKey)
proto.metadata = Google_Protobuf_BytesValue(metadata)
metadataKey?.toProtobufInto(&proto.metadataKey)
if let tokenMemo = tokenMemo {
proto.memo = .init(tokenMemo)
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion Tests/HederaE2ETests/Token/TokenUpdate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ internal final class TokenUpdate: XCTestCase {
.initialSupply(100000)
.expirationTime(Timestamp.now + .hours(2))
.metadata(initialMetadata)
.adminKey(.single(testEnv.operator.privateKey.publicKey))
.metadataKey(.single(metadataKey.publicKey))
.execute(testEnv.client)
.getReceipt(testEnv.client)
Expand Down
Loading