Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update To Fig #661

Merged
merged 15 commits into from
Aug 14, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/combine-schedulers",
"state" : {
"revision" : "0625932976b3ae23949f6b816d13bd97f3b40b7c",
"version" : "0.10.0"
"revision" : "ec62f32d21584214a4b27c8cee2b2ad70ab2c38a",
"version" : "0.11.0"
}
},
{
Expand Down Expand Up @@ -158,8 +158,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-clocks",
"state" : {
"revision" : "f9acfa1a45f4483fe0f2c434a74e6f68f865d12d",
"version" : "0.3.0"
"revision" : "0fbaebfc013715dab44d715a4d350ba37f297e4d",
"version" : "0.4.0"
}
},
{
Expand All @@ -168,7 +168,7 @@
"location" : "https://github.com/apple/swift-collections",
"state" : {
"branch" : "main",
"revision" : "53a8adc54374f620002a3b6401d39e0feb3c57ae"
"revision" : "939cfd25234472b4dc91c3caeab304d15bca9a73"
}
},
{
Expand All @@ -180,31 +180,40 @@
"revision" : "eb29ed75d29ac326cc469b9126a4a571b700d152"
}
},
{
"identity" : "swift-concurrency-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
"state" : {
"revision" : "479750bd98fac2e813fffcf2af0728b5b0085795",
"version" : "0.1.1"
}
},
{
"identity" : "swift-custom-dump",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-custom-dump",
"state" : {
"revision" : "3a35f7892e7cf6ba28a78cd46a703c0be4e0c6dc",
"version" : "0.11.0"
"revision" : "4a87bb75be70c983a9548597e8783236feb3401e",
"version" : "0.11.1"
}
},
{
"identity" : "swift-dependencies",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-dependencies",
"state" : {
"revision" : "de1a984a71e51f6e488e98ce3652035563eb8acb",
"version" : "0.5.1"
"revision" : "16fd42ae04c6e7f74a6a86395d04722c641cccee",
"version" : "0.6.0"
}
},
{
"identity" : "swift-dependencies-additions",
"kind" : "remoteSourceControl",
"location" : "https://github.com/tgrapperon/swift-dependencies-additions",
"state" : {
"revision" : "9b483d46caa12ff425521cddf3a988d0c5515927",
"version" : "0.5.1"
"revision" : "9fa2e7eeaa9b3de663ad68acffdfbed3c598408a",
"version" : "0.5.2"
}
},
{
Expand All @@ -221,8 +230,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/radixdlt/swift-engine-toolkit",
"state" : {
"revision" : "7dfe68d7c8cdc38b7455344757f0b228672cc5be",
"version" : "0.11.0-7dd27a8"
"revision" : "18a46a297894aef8ea0dcfb03877a6d56e2842f4",
"version" : "0.12.0-fig.1-f6c4402"
}
},
{
Expand Down Expand Up @@ -288,6 +297,15 @@
"version" : "1.0.2"
}
},
{
"identity" : "swift-overture",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-overture",
"state" : {
"revision" : "7977acd7597f413717058acc1e080731249a1d7e",
"version" : "0.5.0"
}
},
{
"identity" : "swift-tagged",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -320,8 +338,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect",
"state" : {
"revision" : "730ab9e6cdbb3122ad88277b295c4cecd284a311",
"version" : "0.9.1"
"revision" : "ccb973cfff703cba53fb88197413485c060eb26b",
"version" : "0.10.0"
}
},
{
Expand Down Expand Up @@ -374,8 +392,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : {
"revision" : "4af50b38daf0037cfbab15514a241224c3f62f98",
"version" : "0.8.5"
"revision" : "50843cbb8551db836adec2290bb4bc6bac5c1865",
"version" : "0.9.0"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct ManageSecurityStructurePreviewApp: SwiftUI.App {
import FactorSourcesClient
extension FactorSourcesClient {
static let previewApp: Self =
with(noop) {
update(noop) {
$0.saveFactorSource = { _ in }
$0.getFactorSources = { @Sendable in
let device = try! DeviceFactorSource.babylon(
Expand All @@ -57,7 +57,7 @@ extension FactorSourcesClient {

import AppPreferencesClient
extension AppPreferencesClient {
static let previewApp: Self = with(noop) {
static let previewApp: Self = update(noop) {
$0.updatePreferences = { _ in }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct AddTrustedContactPreviewApp: SwiftUI.App {
import FactorSourcesClient
extension FactorSourcesClient {
static let previewApp: Self =
with(noop) {
update(noop) {
$0.saveFactorSource = { _ in }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct PersonaDetailsPreviewApp: App {
$0
.dependency(
\.personasClient,
with(.noop) {
update(.noop) {
$0.updatePersona = { @Sendable _ in }
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct SecurityStructureConfigurationListPreviewApp: SwiftUI.App {

extension FactorSourcesClient {
static let previewApp: Self =
with(noop) {
update(noop) {
$0.saveFactorSource = { _ in }
$0.getFactorSources = { @Sendable in
let device = try! DeviceFactorSource.babylon(
Expand All @@ -55,7 +55,7 @@ extension FactorSourcesClient {

import AppPreferencesClient
extension AppPreferencesClient {
static let previewApp: Self = with(noop) {
static let previewApp: Self = update(noop) {
$0.updatePreferences = { _ in }
$0.getPreferences = {
var appPreferences = AppPreferences()
Expand Down
6 changes: 5 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ package.addModules([
dependencies: [
"Cryptography",
.product(name: "EngineToolkit", package: "swift-engine-toolkit") {
.package(url: "https://github.com/radixdlt/swift-engine-toolkit", exact: "0.11.0-7dd27a8")
.package(url: "https://github.com/radixdlt/swift-engine-toolkit", exact: "0.12.0-fig.1-f6c4402")
},
],
tests: .no
Expand Down Expand Up @@ -1086,6 +1086,10 @@ package.addModules([
.product(name: "Validated", package: "swift-validated") {
.package(url: "https://github.com/pointfreeco/swift-validated", exact: "0.2.1")
},
.product(name: "Overture", package: "swift-overture") {
.package(url: "https://github.com/pointfreeco/swift-overture", exact: "0.5.0")
},

],
tests: .yes(dependencies: [])
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ extension AccountPortfoliosClient {
.nonFungibleIds
.map { item in
let details = item.details
let canBeClaimed = details.claimEpoch.map { UInt64(ledgerState.epoch) >= $0.rawValue } ?? false
let canBeClaimed = details.claimEpoch.map { UInt64(ledgerState.epoch) >= $0 } ?? false
return try AccountPortfolio.NonFungibleResource.NonFungibleToken(
id: .fromParts(
resourceAddress: .init(address: resource.resourceAddress),
Expand All @@ -301,7 +301,7 @@ extension AccountPortfoliosClient {
description: nil,
keyImageURL: details.keyImageURL,
metadata: [],
stakeClaimAmount: details.stakeClaim,
stakeClaimAmount: details.claimAmount,
canBeClaimed: canBeClaimed
)
}
Expand Down Expand Up @@ -771,3 +771,22 @@ extension AccountPortfolio.PoolUnitResources {
radixNetworkStakes.compactMap(\.stakeClaimResource?.resourceAddress.address)
}
}

// FIXME: Temporary hack to extract the key_image_url, until we have a proper schema
extension GatewayAPI.StateNonFungibleDetailsResponseItem {
public typealias NFTData = AccountPortfolio.NonFungibleResource.NonFungibleToken.NFTData
public var details: [NFTData] {
data?.programmaticJson.dictionary?["fields"]?.array?.compactMap {
guard let dict = $0.dictionary,
let value = dict["value"],
let typeName = dict["kind"]?.string,
let field = dict["field_name"]?.string.flatMap(NFTData.Field.init),
let value = NFTData.Value(typeName: typeName, value: value)
else {
return nil
}

return .init(field: field, value: value)
} ?? []
}
}
65 changes: 36 additions & 29 deletions Sources/Clients/FaucetClient/FaucetClient+Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extension FaucetClient: DependencyKey {
}

let networkID = await gatewaysClient.getCurrentNetworkID()
let manifest = try TransactionManifest.manifestForFaucet(
let manifest = try ManifestBuilder.manifestForFaucet(
includeLockFeeInstruction: true,
networkID: networkID,
componentAddress: accountAddress.asGeneral()
Expand All @@ -117,39 +117,46 @@ extension FaucetClient: DependencyKey {
let createFungibleToken: CreateFungibleToken = { request in
let networkID = await gatewaysClient.getCurrentNetworkID()
let manifest = try {
if request.numberOfTokens == 1 {
return try TransactionManifest.manifestForCreateFungibleToken(
account: request.recipientAccountAddress,
network: networkID
)
} else {
return try TransactionManifest.manifestForCreateMultipleFungibleTokens(
account: request.recipientAccountAddress,
network: networkID
)
}
try ManifestBuilder.manifestForCreateFungibleToken(
account: request.recipientAccountAddress,
networkID: networkID
)
// TODO: Re-enable. With new manifest builder that is not easy to handle.
// if request.numberOfTokens == 1 {
// return try ManifestBuilder.manifestForCreateFungibleToken(
// account: request.recipientAccountAddress,
// networkID: networkID
// )
// } else {
// return try TransactionManifest.manifestForCreateMultipleFungibleTokens(
// account: request.recipientAccountAddress,
// network: networkID
// )
// }
}()

try await signSubmitTX(manifest: manifest)
}

let createNonFungibleToken: CreateNonFungibleToken = { request in
let networkID = await gatewaysClient.getCurrentNetworkID()
let manifest = try {
if request.numberOfTokens == 1 {
return try TransactionManifest.manifestForCreateNonFungibleToken(
account: request.recipientAccountAddress,
network: networkID
)
} else {
return try TransactionManifest.manifestForCreateMultipleNonFungibleTokens(
account: request.recipientAccountAddress,
network: networkID
)
}
}()

try await signSubmitTX(manifest: manifest)
let createNonFungibleToken: CreateNonFungibleToken = { _ in
fatalError()
// TODO: Re-enable. With new manifest builder that is not easy to handle.
// let networkID = await gatewaysClient.getCurrentNetworkID()
// let manifest = try {
// if request.numberOfTokens == 1 {
// return try TransactionManifest.manifestForCreateNonFungibleToken(
// account: request.recipientAccountAddress,
// network: networkID
// )
// } else {
// return try TransactionManifest.manifestForCreateMultipleNonFungibleTokens(
// account: request.recipientAccountAddress,
// network: networkID
// )
// }
// }()

// try await signSubmitTX(manifest: manifest)
GhenadieVP marked this conversation as resolved.
Show resolved Hide resolved
}

return Self(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// ComponentEntityRoleAssignmentEntry.swift
//
// Generated by openapi-generator
// https://openapi-generator.tech
//

import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif

@available(*, deprecated, renamed: "GatewayAPI.ComponentEntityRoleAssignmentEntry")
public typealias ComponentEntityRoleAssignmentEntry = GatewayAPI.ComponentEntityRoleAssignmentEntry

extension GatewayAPI {

public struct ComponentEntityRoleAssignmentEntry: Codable, Hashable {

public private(set) var roleKey: RoleKey
public private(set) var assignment: ComponentEntityRoleAssignmentEntryAssignment
public private(set) var updaterRoles: [RoleKey]?

public init(roleKey: RoleKey, assignment: ComponentEntityRoleAssignmentEntryAssignment, updaterRoles: [RoleKey]? = nil) {
self.roleKey = roleKey
self.assignment = assignment
self.updaterRoles = updaterRoles
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case roleKey = "role_key"
case assignment
case updaterRoles = "updater_roles"
}

// Encodable protocol methods

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(roleKey, forKey: .roleKey)
try container.encode(assignment, forKey: .assignment)
try container.encodeIfPresent(updaterRoles, forKey: .updaterRoles)
}
}

}
Loading