Skip to content

Commit

Permalink
fix: decode the issigner int type
Browse files Browse the repository at this point in the history
  • Loading branch information
zanyfly committed Aug 15, 2024
1 parent 2f67249 commit ec9de9b
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions Sources/SolanaSwift/Models/AccountMeta.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,28 @@ public struct AccountMeta: Equatable, Codable, CustomDebugStringConvertible {
public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
publicKey = try PublicKey(string: values.decode(String.self, forKey: .pubkey))
isSigner = if values.contains(.isSigner) {
try values.decode(Bool.self, forKey: .isSigner)
} else {
try values.decode(Bool.self, forKey: .signer)
}
isWritable = if values.contains(.isWritable) {
try values.decode(Bool.self, forKey: .isWritable)
} else {
try values.decode(Bool.self, forKey: .writable)
do {
isSigner = if values.contains(.isSigner) {
try values.decode(Bool.self, forKey: .isSigner)
} else {
try values.decode(Bool.self, forKey: .signer)
}
isWritable = if values.contains(.isWritable) {
try values.decode(Bool.self, forKey: .isWritable)
} else {
try values.decode(Bool.self, forKey: .writable)
}
}catch{
isSigner = if values.contains(.isSigner) {
try values.decode(Int.self, forKey: .isSigner) == 1
} else {
try values.decode(Int.self, forKey: .signer) == 1
}
isWritable = if values.contains(.isWritable) {
try values.decode(Int.self, forKey: .isWritable) == 1
} else {
try values.decode(Int.self, forKey: .writable) == 1
}
}
}

Expand Down

0 comments on commit ec9de9b

Please sign in to comment.