From c67f9a731ca3c68bd00d2aba125a08ab815f7335 Mon Sep 17 00:00:00 2001 From: Chung Tran Date: Wed, 24 Jan 2024 22:00:36 +0700 Subject: [PATCH] feat: rename TokenAccountState & TokenMintState --- CHANGELOG.md | 4 ++-- .../SolanaSwift/APIClient/APIClient+Extension.swift | 10 +++++----- .../APIClient/Networking/JSONRPCAPIClient.swift | 4 ++-- Sources/SolanaSwift/APIClient/SolanaAPIClient.swift | 4 ++-- .../BlockchainClient+Extensions.swift | 4 ++-- .../Token2022Program/Token2022AccountState.swift | 4 ++-- .../Token2022Program/Token2022MintState.swift | 2 +- ...ountState.swift => TokenAccountLayoutState.swift} | 4 ++-- ...kenAccountState.swift => TokenAccountState.swift} | 4 ++-- .../SolanaAPIClient+getAccountBalances.swift | 12 ++++++------ .../APIClient/APIClientExtensionsTests.swift | 8 ++++---- .../APIClient/APIClientTests.swift | 8 ++++---- .../BlockchainClientWithNativeSOLTests.swift | 6 +++--- .../BlockchainClientWithTokenProgramTests.swift | 6 +++--- .../BufferLayout/BufferLayoutDecodingTests.swift | 12 ++++++------ .../BufferLayout/BufferLayoutEncodingTests.swift | 8 ++++---- 16 files changed, 50 insertions(+), 50 deletions(-) rename Sources/SolanaSwift/Programs/TokenPrograms/{TokenAccountState.swift => TokenAccountLayoutState.swift} (94%) rename Sources/SolanaSwift/Programs/TokenPrograms/TokenProgram/{SPLTokenAccountState.swift => TokenAccountState.swift} (96%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2995b6535..dd06f4e62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,8 @@ - Remove deprecated PublicKey.programId, use SystemProgram.id instead. - Remove deprecated PublicKey.ownerValidationProgramId, use OwnerValidationProgram.id instead. - Remove deprecated PublicKey.splAssociatedTokenAccountProgramId, use AssociatedTokenProgram.id instead. -- Remove deprecated typealias AccountInfo, use SPLTokenAccountState or Token2022AccountState instead. -- Remove deprecated typealias Mint, use SPLTokenMintState or Token2022MintState instead. +- Remove deprecated typealias AccountInfo, use TokenAccountState or Token2022AccountState instead. +- Remove deprecated typealias Mint, use TokenMintState or Token2022MintState instead. - Remove deprecated typealias Wallet, use AccountBalance instead. - Support token 2022 via method getAccountBalances (See GetAccountBalancesTests). - Support token 2022 and Token2022Program. diff --git a/Sources/SolanaSwift/APIClient/APIClient+Extension.swift b/Sources/SolanaSwift/APIClient/APIClient+Extension.swift index be3c9e06a..27fec1fd3 100644 --- a/Sources/SolanaSwift/APIClient/APIClient+Extension.swift +++ b/Sources/SolanaSwift/APIClient/APIClient+Extension.swift @@ -9,12 +9,12 @@ public extension SolanaAPIClient { pubkey: String, params: OwnerInfoParams?, configs: RequestConfiguration? - ) async throws -> [TokenAccount] { + ) async throws -> [TokenAccount] { try await getTokenAccountsByOwner( pubkey: pubkey, params: params, configs: configs, - decodingTo: SPLTokenAccountState.self + decodingTo: TokenAccountState.self ) } @@ -99,7 +99,7 @@ public extension SolanaAPIClient { tokenProgramId: tokenProgramId ) - let bufferInfo: BufferInfo? = try await getAccountInfo(account: associatedTokenAccount + let bufferInfo: BufferInfo? = try await getAccountInfo(account: associatedTokenAccount .base58EncodedString) return bufferInfo?.data.mint == mintAddress } @@ -120,7 +120,7 @@ public extension SolanaAPIClient { tokenProgramId: PublicKey ) async throws -> SPLTokenDestinationAddress { var address: String - var accountInfo: BufferInfo? + var accountInfo: BufferInfo? do { accountInfo = try await getAccountInfoThrowable(account: destinationAddress) let toTokenMint = accountInfo?.data.mint.base58EncodedString @@ -159,7 +159,7 @@ public extension SolanaAPIClient { var isUnregisteredAsocciatedToken = false if destinationAddress != toPublicKey.base58EncodedString { // check if associated address is already registered - let info: BufferInfo? + let info: BufferInfo? do { info = try await getAccountInfoThrowable(account: toPublicKey.base58EncodedString) } catch { diff --git a/Sources/SolanaSwift/APIClient/Networking/JSONRPCAPIClient.swift b/Sources/SolanaSwift/APIClient/Networking/JSONRPCAPIClient.swift index 525a7c7a9..c1cb2841e 100644 --- a/Sources/SolanaSwift/APIClient/Networking/JSONRPCAPIClient.swift +++ b/Sources/SolanaSwift/APIClient/Networking/JSONRPCAPIClient.swift @@ -143,7 +143,7 @@ public class JSONRPCAPIClient: SolanaAPIClient { return result.value } - public func getTokenAccountsByDelegate( + public func getTokenAccountsByDelegate( pubkey: String, mint: String? = nil, programId: String? = nil, @@ -161,7 +161,7 @@ public class JSONRPCAPIClient: SolanaAPIClient { return result.value } - public func getTokenAccountsByOwner( + public func getTokenAccountsByOwner( pubkey: String, params: OwnerInfoParams?, configs: RequestConfiguration?, diff --git a/Sources/SolanaSwift/APIClient/SolanaAPIClient.swift b/Sources/SolanaSwift/APIClient/SolanaAPIClient.swift index 9229b0519..d8faa89b2 100644 --- a/Sources/SolanaSwift/APIClient/SolanaAPIClient.swift +++ b/Sources/SolanaSwift/APIClient/SolanaAPIClient.swift @@ -166,7 +166,7 @@ public protocol SolanaAPIClient { /// - Returns The result will be an array of TokenAccount /// - SeeAlso https://docs.solana.com/developing/clients/jsonrpc-api#gettokenaccountsbydelegate /// - func getTokenAccountsByDelegate( + func getTokenAccountsByDelegate( pubkey: String, mint: String?, programId: String?, @@ -183,7 +183,7 @@ public protocol SolanaAPIClient { /// - Returns The result will be an array of TokenAccount /// - SeeAlso https://docs.solana.com/developing/clients/jsonrpc-api#gettokenaccountsbyowner /// - func getTokenAccountsByOwner( + func getTokenAccountsByOwner( pubkey: String, params: OwnerInfoParams?, configs: RequestConfiguration?, diff --git a/Sources/SolanaSwift/BlockchainClient/BlockchainClient+Extensions.swift b/Sources/SolanaSwift/BlockchainClient/BlockchainClient+Extensions.swift index 018829bea..95b4ecb8b 100644 --- a/Sources/SolanaSwift/BlockchainClient/BlockchainClient+Extensions.swift +++ b/Sources/SolanaSwift/BlockchainClient/BlockchainClient+Extensions.swift @@ -24,7 +24,7 @@ public extension SolanaBlockchainClient { from: owner, toNewPubkey: newAccount.publicKey, lamports: amount + minRentExemption, - space: SPLTokenAccountState.BUFFER_LENGTH, + space: TokenAccountState.BUFFER_LENGTH, programId: TokenProgram.id ), TokenProgram.initializeAccountInstruction( @@ -69,7 +69,7 @@ public extension SolanaBlockchainClient { let isAssociatedTokenAddressRegistered: Bool do { - let info: BufferInfo? = try await apiClient + let info: BufferInfo? = try await apiClient .getAccountInfo(account: associatedAddress.base58EncodedString) if PublicKey.isSPLTokenProgram(info?.owner), info?.data.owner == owner diff --git a/Sources/SolanaSwift/Programs/TokenPrograms/Token2022Program/Token2022AccountState.swift b/Sources/SolanaSwift/Programs/TokenPrograms/Token2022Program/Token2022AccountState.swift index 0d51c3a9d..675bba53b 100644 --- a/Sources/SolanaSwift/Programs/TokenPrograms/Token2022Program/Token2022AccountState.swift +++ b/Sources/SolanaSwift/Programs/TokenPrograms/Token2022Program/Token2022AccountState.swift @@ -1,6 +1,6 @@ import Foundation -public struct Token2022AccountState: TokenAccountState { +public struct Token2022AccountState: TokenAccountLayoutState { static var ACCOUNT_TYPE: UInt8 { 2 } public let mint: PublicKey @@ -68,7 +68,7 @@ extension Token2022AccountState: BorshCodable { } public init(from reader: inout BinaryReader) throws { - let oldTokenProgramData = try SPLTokenAccountState(from: &reader) + let oldTokenProgramData = try TokenAccountState(from: &reader) mint = oldTokenProgramData.mint owner = oldTokenProgramData.owner lamports = oldTokenProgramData.lamports diff --git a/Sources/SolanaSwift/Programs/TokenPrograms/Token2022Program/Token2022MintState.swift b/Sources/SolanaSwift/Programs/TokenPrograms/Token2022Program/Token2022MintState.swift index 77a3b52a9..f62348e89 100644 --- a/Sources/SolanaSwift/Programs/TokenPrograms/Token2022Program/Token2022MintState.swift +++ b/Sources/SolanaSwift/Programs/TokenPrograms/Token2022Program/Token2022MintState.swift @@ -21,7 +21,7 @@ public struct Token2022MintState: MintLayoutState { extension Token2022MintState: BorshCodable { public init(from reader: inout BinaryReader) throws { - let oldTokenMintState = try SPLTokenMintState(from: &reader) + let oldTokenMintState = try TokenMintState(from: &reader) mintAuthorityOption = oldTokenMintState.mintAuthorityOption mintAuthority = oldTokenMintState.mintAuthority supply = oldTokenMintState.supply diff --git a/Sources/SolanaSwift/Programs/TokenPrograms/TokenAccountState.swift b/Sources/SolanaSwift/Programs/TokenPrograms/TokenAccountLayoutState.swift similarity index 94% rename from Sources/SolanaSwift/Programs/TokenPrograms/TokenAccountState.swift rename to Sources/SolanaSwift/Programs/TokenPrograms/TokenAccountLayoutState.swift index d07b54759..8850296aa 100644 --- a/Sources/SolanaSwift/Programs/TokenPrograms/TokenAccountState.swift +++ b/Sources/SolanaSwift/Programs/TokenPrograms/TokenAccountLayoutState.swift @@ -1,6 +1,6 @@ import Foundation -public protocol TokenAccountState: BufferLayout { +public protocol TokenAccountLayoutState: BufferLayout { var mint: PublicKey { get } var owner: PublicKey { get } var lamports: UInt64 { get } @@ -18,7 +18,7 @@ public protocol TokenAccountState: BufferLayout { var closeAuthority: PublicKey? { get set } } -extension TokenAccountState { +extension TokenAccountLayoutState { func serializeCommonProperties(to writer: inout Data) throws { try mint.serialize(to: &writer) try owner.serialize(to: &writer) diff --git a/Sources/SolanaSwift/Programs/TokenPrograms/TokenProgram/SPLTokenAccountState.swift b/Sources/SolanaSwift/Programs/TokenPrograms/TokenProgram/TokenAccountState.swift similarity index 96% rename from Sources/SolanaSwift/Programs/TokenPrograms/TokenProgram/SPLTokenAccountState.swift rename to Sources/SolanaSwift/Programs/TokenPrograms/TokenProgram/TokenAccountState.swift index 31981ca52..5c6c2969d 100644 --- a/Sources/SolanaSwift/Programs/TokenPrograms/TokenProgram/SPLTokenAccountState.swift +++ b/Sources/SolanaSwift/Programs/TokenPrograms/TokenProgram/TokenAccountState.swift @@ -1,6 +1,6 @@ import Foundation -public struct SPLTokenAccountState: TokenAccountState { +public struct TokenAccountState: TokenAccountLayoutState { public static let BUFFER_LENGTH: UInt64 = 165 public let mint: PublicKey @@ -54,7 +54,7 @@ public struct SPLTokenAccountState: TokenAccountState { } } -extension SPLTokenAccountState: BorshCodable { +extension TokenAccountState: BorshCodable { public func serialize(to writer: inout Data) throws { try serializeCommonProperties(to: &writer) } diff --git a/Sources/SolanaSwift/SolanaTokenMetadata/SolanaAPIClient+getAccountBalances.swift b/Sources/SolanaSwift/SolanaTokenMetadata/SolanaAPIClient+getAccountBalances.swift index db565ec3b..456e975cf 100644 --- a/Sources/SolanaSwift/SolanaTokenMetadata/SolanaAPIClient+getAccountBalances.swift +++ b/Sources/SolanaSwift/SolanaTokenMetadata/SolanaAPIClient+getAccountBalances.swift @@ -14,8 +14,8 @@ public extension SolanaAPIClient { tokensRepository: tokensRepository, commitment: commitment, programId: TokenProgram.id.base58EncodedString, - accountStateType: SPLTokenAccountState.self, - mintType: SPLTokenMintState.self + accountStateType: TokenAccountState.self, + mintType: TokenMintState.self ) // token 2022 @@ -45,8 +45,8 @@ public extension SolanaAPIClient { // MARK: - Helpers private func getAccountBalances< - T: TokenAccountState, - M: TokenMintState + T: TokenAccountLayoutState, + M: MintLayoutState >( for address: String, tokensRepository: TokenRepository, @@ -80,8 +80,8 @@ public extension SolanaAPIClient { } private func convertResult< - T: TokenAccountState, - M: TokenMintState + T: TokenAccountLayoutState, + M: MintLayoutState >( tokenAccounts: [TokenAccount], tokensRepository: TokenRepository, diff --git a/Tests/SolanaSwiftUnitTests/APIClient/APIClientExtensionsTests.swift b/Tests/SolanaSwiftUnitTests/APIClient/APIClientExtensionsTests.swift index 7ce4ee5a3..d13b775c5 100644 --- a/Tests/SolanaSwiftUnitTests/APIClient/APIClientExtensionsTests.swift +++ b/Tests/SolanaSwiftUnitTests/APIClient/APIClientExtensionsTests.swift @@ -70,7 +70,7 @@ class APIClientExtensionsTests: XCTestCase { let apiClient = BaseAPIClientMock(endpoint: endpoint, networkManager: mock) do { - let _: BufferInfo = try await apiClient + let _: BufferInfo = try await apiClient .getAccountInfoThrowable(account: "djfijijasdf") } catch { XCTAssertTrue(error.isEqualTo(.couldNotRetrieveAccountInfo)) @@ -105,11 +105,11 @@ class BaseAPIClientMock: JSONRPCAPIClient { pubkey _: String, params _: OwnerInfoParams? = nil, configs _: RequestConfiguration? = nil - ) async throws -> [TokenAccount] { + ) async throws -> [TokenAccount] { let json = "[{\"account\":{\"data\":[\"ppdSk884LShYnHoHm7XiDlZ28iJVm9BHPgrAEfxU44AJ7HiGa7fztefqNjU2MSBOZ3HPlRmb0eAXj0bEanmyfAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\",\"base64\"],\"executable\":false,\"lamports\":2039280,\"owner\":\"So11111111111111111111111111111111111111112\",\"rentEpoch\":309},\"pubkey\":\"9bNJ7AF8w1Ms4BsqpqbUPZ16vCSePYJpgSBUTRqd8ph4\"}]" let decoder = try JSONDecoder().decode( - [TokenAccount].self, + [TokenAccount].self, from: json.data(using: .utf8)! ) return decoder @@ -122,7 +122,7 @@ class BaseAPIClientMock: JSONRPCAPIClient { let json = "{\"context\":{\"slot\":132420615},\"value\":[{\"data\":[\"APoAh5MDAAAAAAKLjuya35R64GfrOPbupmMcxJ1pmaH2fciYq9DxSQ88FioLlNul6FnDNF06/RKhMFBVI8fFQKRYcqukjYZitosKxZBjjg9hLR2AsDm2e/itloPtlrPeVDPIVdnO4+dmM2JiSZHdhsj7+Fn94OTNte9elt1ek0p487C2fLrFA9CvUPerjZvfP97EqlF9OXbPSzaGJzdmfWhk4jRnThsg5scAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAObFpMVhxY3CRrzEcywhYTa4a4SsovPp4wKPRTbTJVtzAfQBZAAAAABDU47UFrGnHMTsb0EaE1TBoVQGvCIHKJ4/EvpK3zvIfwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACsWQY44PYS0dgLA5tnv4rZaD7Zaz3lQzyFXZzuPnZjMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\",\"base64\"],\"executable\":false,\"lamports\":1345194,\"owner\":\"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA\",\"rentEpoch\":306}]}" let decoder = try JSONDecoder() - .decode(Rpc<[BufferInfo]>.self, from: json.data(using: .utf8)!) as! Rpc<[BufferInfo]> + .decode(Rpc<[BufferInfo]>.self, from: json.data(using: .utf8)!) as! Rpc<[BufferInfo]> return decoder.value } diff --git a/Tests/SolanaSwiftUnitTests/APIClient/APIClientTests.swift b/Tests/SolanaSwiftUnitTests/APIClient/APIClientTests.swift index 8f61620d8..6c8a7b4c3 100644 --- a/Tests/SolanaSwiftUnitTests/APIClient/APIClientTests.swift +++ b/Tests/SolanaSwiftUnitTests/APIClient/APIClientTests.swift @@ -17,7 +17,7 @@ class APIClientTests: XCTestCase { func testGetAccountInfo() async throws { let mock = NetworkManagerMock(NetworkManagerMockJSON["getAccountInfo"]!) let apiClient = JSONRPCAPIClient(endpoint: endpoint, networkManager: mock) - let result: BufferInfo? = try! await apiClient + let result: BufferInfo? = try! await apiClient .getAccountInfo(account: "HWbsF542VSCxdGKcHrXuvJJnpwCEewmzdsG6KTxXMRRk") XCTAssert(result?.owner == "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA") XCTAssert(result?.lamports == 2_039_280) @@ -28,7 +28,7 @@ class APIClientTests: XCTestCase { let mock = NetworkManagerMock(NetworkManagerMockJSON["getAccountInfo_2"]!) let apiClient = JSONRPCAPIClient(endpoint: endpoint, networkManager: mock) do { - let _: BufferInfo? = try await apiClient + let _: BufferInfo? = try await apiClient .getAccountInfo(account: "HWbsF542VSCxdGKcHrXuvJJnpwCEewmzdsG6KTxXMRRk") } catch let error as APIClientError { XCTAssertTrue(error == .couldNotRetrieveAccountInfo) @@ -221,7 +221,7 @@ class APIClientTests: XCTestCase { func testGetMultipleAccounts() async throws { let mock = NetworkManagerMock(NetworkManagerMockJSON["getMultipleAccounts"]!) let apiClient = JSONRPCAPIClient(endpoint: endpoint, networkManager: mock) - let result: [BufferInfo?] = try await apiClient + let result: [BufferInfo?] = try await apiClient .getMultipleAccounts(pubkeys: ["DkZzno16JLXYda4eHZzM9J8Vxet9StJJ5mimrtjbK5V3"], commitment: "confirm") XCTAssertNotNil(result) } @@ -236,7 +236,7 @@ class APIClientTests: XCTestCase { "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", ], commitment: "confirm", - mintType: SPLTokenMintState.self + mintType: TokenMintState.self ) XCTAssertNotNil(result) diff --git a/Tests/SolanaSwiftUnitTests/BlockchainClient/BlockchainClientWithNativeSOLTests.swift b/Tests/SolanaSwiftUnitTests/BlockchainClient/BlockchainClientWithNativeSOLTests.swift index 59df41eb5..acea5e369 100644 --- a/Tests/SolanaSwiftUnitTests/BlockchainClient/BlockchainClientWithNativeSOLTests.swift +++ b/Tests/SolanaSwiftUnitTests/BlockchainClient/BlockchainClientWithNativeSOLTests.swift @@ -113,7 +113,7 @@ private class MockAPIClient: SolanaAPIClient { switch testCase { case "testPrepareSendingSPLTokens()#2", "testPrepareSendingSPLTokens()#4", "testPrepareSendingSPLTokens()#5": - data = SPLTokenAccountState( + data = TokenAccountState( mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", owner: "6QuXb6mB6WmRASP2y8AavXh6aabBXEH5ZzrSH5xRrgSm", lamports: 100, @@ -261,7 +261,7 @@ private class MockAPIClient: SolanaAPIClient { fatalError() } - func getTokenAccountsByDelegate( + func getTokenAccountsByDelegate( pubkey _: String, mint _: String?, programId _: String?, @@ -270,7 +270,7 @@ private class MockAPIClient: SolanaAPIClient { fatalError() } - func getTokenAccountsByOwner( + func getTokenAccountsByOwner( pubkey _: String, params _: OwnerInfoParams?, configs _: RequestConfiguration?, diff --git a/Tests/SolanaSwiftUnitTests/BlockchainClient/BlockchainClientWithTokenProgramTests.swift b/Tests/SolanaSwiftUnitTests/BlockchainClient/BlockchainClientWithTokenProgramTests.swift index 4e16369ea..f9952b914 100644 --- a/Tests/SolanaSwiftUnitTests/BlockchainClient/BlockchainClientWithTokenProgramTests.swift +++ b/Tests/SolanaSwiftUnitTests/BlockchainClient/BlockchainClientWithTokenProgramTests.swift @@ -150,7 +150,7 @@ private class MockAPIClient: SolanaAPIClient { switch testCase { case "testPrepareSendingSPLTokens()#2", "testPrepareSendingSPLTokens()#4", "testPrepareSendingSPLTokens()#5": - data = SPLTokenAccountState( + data = TokenAccountState( mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", owner: "6QuXb6mB6WmRASP2y8AavXh6aabBXEH5ZzrSH5xRrgSm", lamports: 100, @@ -298,7 +298,7 @@ private class MockAPIClient: SolanaAPIClient { fatalError() } - func getTokenAccountsByDelegate( + func getTokenAccountsByDelegate( pubkey _: String, mint _: String?, programId _: String?, @@ -307,7 +307,7 @@ private class MockAPIClient: SolanaAPIClient { fatalError() } - func getTokenAccountsByOwner( + func getTokenAccountsByOwner( pubkey _: String, params _: OwnerInfoParams?, configs _: RequestConfiguration?, diff --git a/Tests/SolanaSwiftUnitTests/Other/BufferLayout/BufferLayoutDecodingTests.swift b/Tests/SolanaSwiftUnitTests/Other/BufferLayout/BufferLayoutDecodingTests.swift index 8b73a489c..4c831faed 100644 --- a/Tests/SolanaSwiftUnitTests/Other/BufferLayout/BufferLayoutDecodingTests.swift +++ b/Tests/SolanaSwiftUnitTests/Other/BufferLayout/BufferLayoutDecodingTests.swift @@ -44,7 +44,7 @@ class BufferLayoutDecodingTests: XCTestCase { // MARK: - Mint func testDecodingMint() throws { - XCTAssertEqual(SPLTokenMintState.BUFFER_LENGTH, 82) + XCTAssertEqual(TokenMintState.BUFFER_LENGTH, 82) let string = "AQAAAAYa2dBThxVIU37ePiYYSaPft/0C+rx1siPI5GrbhT0MABCl1OgAAAAGAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" @@ -52,7 +52,7 @@ class BufferLayoutDecodingTests: XCTestCase { let data = Data(base64Encoded: string)! var binaryReader = BinaryReader(bytes: data.bytes) - let mintLayout = try SPLTokenMintState(from: &binaryReader) + let mintLayout = try TokenMintState(from: &binaryReader) XCTAssertEqual(mintLayout.mintAuthorityOption, 1) XCTAssertEqual(mintLayout.mintAuthority?.base58EncodedString, "QqCCvshxtqMAL2CVALqiJB7uEeE5mjSPsseQdDzsRUo") @@ -66,7 +66,7 @@ class BufferLayoutDecodingTests: XCTestCase { // MARK: - Account info func testDecodingAccountInfo() throws { - XCTAssertEqual(SPLTokenAccountState.BUFFER_LENGTH, 165) + XCTAssertEqual(TokenAccountState.BUFFER_LENGTH, 165) let string = "BhrZ0FOHFUhTft4+JhhJo9+3/QL6vHWyI8jkatuFPQwCqmOzhzy1ve5l2AqL0ottCChJZ1XSIW3k3C7TaBQn7aCGAQAAAAAAAQAAAOt6vNDYdevCbaGxgaMzmz7yoxaVu3q9vGeCc7ytzeWqAQAAAAAAAAAAAAAAAGQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" @@ -74,7 +74,7 @@ class BufferLayoutDecodingTests: XCTestCase { let data = Data(base64Encoded: string)! var binaryReader = BinaryReader(bytes: data.bytes) - let accountInfo = try SPLTokenAccountState(from: &binaryReader) + let accountInfo = try TokenAccountState(from: &binaryReader) XCTAssertEqual("QqCCvshxtqMAL2CVALqiJB7uEeE5mjSPsseQdDzsRUo", accountInfo.mint.base58EncodedString) XCTAssertEqual("BQWWFhzBdw2vKKBUX17NHeFbCoFQHfRARpdztPE2tDJ", accountInfo.owner.base58EncodedString) @@ -100,7 +100,7 @@ class BufferLayoutDecodingTests: XCTestCase { let data = Data(base64Encoded: string)! var binaryReader = BinaryReader(bytes: data.bytes) - let accountInfo = try SPLTokenAccountState(from: &binaryReader) + let accountInfo = try TokenAccountState(from: &binaryReader) XCTAssertEqual("11111111111111111111111111111111", accountInfo.mint.base58EncodedString) XCTAssertEqual("11111111111111111111111111111111", accountInfo.owner.base58EncodedString) @@ -123,7 +123,7 @@ class BufferLayoutDecodingTests: XCTestCase { let data2 = Data(base64Encoded: string2)! var binaryReader2 = BinaryReader(bytes: data2.bytes) - let accountInfo2 = try SPLTokenAccountState(from: &binaryReader2) + let accountInfo2 = try TokenAccountState(from: &binaryReader2) XCTAssertEqual("11111111111111111111111111111111", accountInfo2.mint.base58EncodedString) XCTAssertEqual("11111111111111111111111111111111", accountInfo2.owner.base58EncodedString) diff --git a/Tests/SolanaSwiftUnitTests/Other/BufferLayout/BufferLayoutEncodingTests.swift b/Tests/SolanaSwiftUnitTests/Other/BufferLayout/BufferLayoutEncodingTests.swift index f181924cc..c99884e5a 100644 --- a/Tests/SolanaSwiftUnitTests/Other/BufferLayout/BufferLayoutEncodingTests.swift +++ b/Tests/SolanaSwiftUnitTests/Other/BufferLayout/BufferLayoutEncodingTests.swift @@ -5,7 +5,7 @@ final class BufferLayoutEncodingTests: XCTestCase { // MARK: - Mint func testEncodingMint() throws { - let mintLayout = SPLTokenMintState( + let mintLayout = TokenMintState( mintAuthorityOption: 1, mintAuthority: "QqCCvshxtqMAL2CVALqiJB7uEeE5mjSPsseQdDzsRUo", supply: 1_000_000_000_000, @@ -44,9 +44,9 @@ final class BufferLayoutEncodingTests: XCTestCase { // MARK: - Account info func testEncodingAccountInfo() throws { - XCTAssertEqual(SPLTokenAccountState.BUFFER_LENGTH, 165) + XCTAssertEqual(TokenAccountState.BUFFER_LENGTH, 165) - let accountInfo = SPLTokenAccountState( + let accountInfo = TokenAccountState( mint: "QqCCvshxtqMAL2CVALqiJB7uEeE5mjSPsseQdDzsRUo", owner: "BQWWFhzBdw2vKKBUX17NHeFbCoFQHfRARpdztPE2tDJ", lamports: 100_000, @@ -74,7 +74,7 @@ final class BufferLayoutEncodingTests: XCTestCase { } func testEncodingAccountInfo2() throws { - let accountInfo = SPLTokenAccountState( + let accountInfo = TokenAccountState( mint: "11111111111111111111111111111111", owner: "11111111111111111111111111111111", lamports: 0,