Skip to content

Commit

Permalink
feat: add transaction by version function call
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoDotIO committed Aug 11, 2024
1 parent 99e7c70 commit 8ac59c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/AptosKit/Types/Structs/Client/ClientConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public struct ClientConfig {
public var transactionWaitInSeconds: Int
public var http2: Bool
public var apiKey: String?

public init(
expirationTtl: Int = 600,
gasUnitPrice: Int = 100,
Expand Down
12 changes: 10 additions & 2 deletions Sources/AptosKit/Types/Structs/Client/RestClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public struct RestClient: AptosKitProtocol {
clientConfig: ClientConfig = ClientConfig()
) async throws {
guard let url = URL(string: baseUrl) else { throw AptosError.invalidUrl(url: baseUrl) }

self.baseUrl = baseUrl
self.client = client
self.clientConfig = clientConfig
self.chainId = try await self.client.decodeUrl(with: url)["chain_id"].intValue

if clientConfig.apiKey != nil {
self.client.configuration.httpAdditionalHeaders = ["Authorization": clientConfig.apiKey!]
}
Expand Down Expand Up @@ -333,6 +333,14 @@ public struct RestClient: AptosKitProtocol {
return response
}

public func transactionByVersion(_ version: Int) async throws -> JSON {
guard let url = URL(string: "\(self.baseUrl)/transactions/by_version/\(version)") else {
throw NSError(domain: "Invalid URL", code: -1)
}
let response = try await self.client.decodeUrl(with: url)
return response
}

public func createMultiAgentBcsTransaction(
_ sender: Account,
_ secondaryAccounts: [Account],
Expand Down

0 comments on commit 8ac59c7

Please sign in to comment.