From 8a58f3a3a7b6bccbccbb583cfb485b8226dc952b Mon Sep 17 00:00:00 2001 From: xueyuejie <358838943@qq.com> Date: Thu, 27 Oct 2022 14:06:40 +0800 Subject: [PATCH] fix errorReuslt --- .../AptosSwift/Clients/AptosClient+Models.swift | 2 +- Tests/AptosSwiftTests/AptosSwiftTests.swift | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Sources/AptosSwift/Clients/AptosClient+Models.swift b/Sources/AptosSwift/Clients/AptosClient+Models.swift index 49ff3fc..69f9dd8 100644 --- a/Sources/AptosSwift/Clients/AptosClient+Models.swift +++ b/Sources/AptosSwift/Clients/AptosClient+Models.swift @@ -10,7 +10,7 @@ import AnyCodable extension AptosClient { public struct Error: Decodable { - public let code: Int + public let errorCode: String public let message: String } diff --git a/Tests/AptosSwiftTests/AptosSwiftTests.swift b/Tests/AptosSwiftTests/AptosSwiftTests.swift index d13db25..695bb8b 100644 --- a/Tests/AptosSwiftTests/AptosSwiftTests.swift +++ b/Tests/AptosSwiftTests/AptosSwiftTests.swift @@ -293,4 +293,21 @@ final class AptosSwiftTests: XCTestCase { } wait(for: [reqeustExpectation], timeout: 30) } + func testGetResourceExamples() throws { + let reqeustExpectation = expectation(description: "Tests") + let client = AptosClient(url: self.nodeUrl) + let account = try! AptosAddress("0xa2e71c2e63610a0483b9e2dacec2d3072ee9a0dd8f9cd62df5a2298b44ead2c7") + let usdtResource = "0x1::coin::CoinStore<0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT>" + DispatchQueue.global().async { + do { + let accountResource = try client.getAccountResource(address: account, resourceType: usdtResource).wait() + print(accountResource.type) + reqeustExpectation.fulfill() + } catch let error { + print(error.localizedDescription) + reqeustExpectation.fulfill() + } + } + wait(for: [reqeustExpectation], timeout: 30) + } }