Skip to content

Commit 7713013

Browse files
committed
Fix empty string encoding in AssetCreateTransaction
Empty strings for url, unitName, and assetName were being encoded as "au": "", "un": "", "an": "" in MessagePack instead of being omitted. Algorand's canonical encoding requires empty/default values to be omitted entirely, causing signature verification failures. Added !isEmpty checks to properly omit empty strings from encoding.
1 parent c3ca935 commit 7713013

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/Algorand/AssetTransaction.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ public struct AssetCreateTransaction: Transaction {
128128
apar["df"] = .bool(true)
129129
}
130130

131-
if let unitName = assetParams.unitName {
131+
if let unitName = assetParams.unitName, !unitName.isEmpty {
132132
apar["un"] = .string(unitName)
133133
}
134-
if let assetName = assetParams.assetName {
134+
if let assetName = assetParams.assetName, !assetName.isEmpty {
135135
apar["an"] = .string(assetName)
136136
}
137-
if let url = assetParams.url {
137+
if let url = assetParams.url, !url.isEmpty {
138138
apar["au"] = .string(url)
139139
}
140140
if let metadataHash = assetParams.metadataHash {

0 commit comments

Comments
 (0)