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

RET hotfix update #653

Merged
merged 4 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/radixdlt/swift-engine-toolkit",
"state" : {
"revision" : "a0a087b4136d99102a0ca245fd00bf099e9255c7",
"version" : "0.11.0-b68ff8d"
"revision" : "7dfe68d7c8cdc38b7455344757f0b228672cc5be",
"version" : "0.11.0-7dd27a8"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion App/Config/Common.xcconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// MARK: - Custom flags

/// Application version shared across all targets and flavours
APP_VERSION = 0.3.0
APP_VERSION = 0.3.1

/// App Icon base name
APP_ICON = AppIcon
Expand Down
2 changes: 1 addition & 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-b68ff8d")
.package(url: "https://github.com/radixdlt/swift-engine-toolkit", exact: "0.11.0-7dd27a8")
},
],
tests: .no
Expand Down
12 changes: 8 additions & 4 deletions Sources/EngineKit/HashableExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -484,23 +484,26 @@ extension TransactionType: Hashable {
lhsAccountDeposits,
lhsAddressesInManifest,
lhsMetadataOfNewlyCreatedEntities,
lhsDataOfNewlyMintedNonFungibles
lhsDataOfNewlyMintedNonFungibles,
lhsAddressesOfNewlyCreatedEntities
),
.generalTransaction(
rhsAccountProofs,
rhsAccountWithdraws,
rhsAccountDeposits,
rhsAddressesInManifest,
rhsMetadataOfNewlyCreatedEntities,
rhsDataOfNewlyMintedNonFungibles
rhsDataOfNewlyMintedNonFungibles,
rhsAddressesOfNewlyCreatedEntities
)
):
return lhsAccountProofs == rhsAccountProofs &&
lhsAccountWithdraws == rhsAccountWithdraws &&
lhsAccountDeposits == rhsAccountDeposits &&
lhsAddressesInManifest == rhsAddressesInManifest &&
lhsMetadataOfNewlyCreatedEntities == rhsMetadataOfNewlyCreatedEntities &&
lhsDataOfNewlyMintedNonFungibles == rhsDataOfNewlyMintedNonFungibles
lhsDataOfNewlyMintedNonFungibles == rhsDataOfNewlyMintedNonFungibles &&
lhsAddressesOfNewlyCreatedEntities == rhsAddressesOfNewlyCreatedEntities
case (.nonConforming, .nonConforming):
return true
default:
Expand All @@ -519,14 +522,15 @@ extension TransactionType: Hashable {
hasher.combine("transfer")
hasher.combine(from)
hasher.combine(transfers)
case let .generalTransaction(accountProofs, accountWithdraws, accountDeposits, addressesInManifest, metadataOfNewlyCreatedEntities, dataOfNewlyMintedNonFungibles):
case let .generalTransaction(accountProofs, accountWithdraws, accountDeposits, addressesInManifest, metadataOfNewlyCreatedEntities, dataOfNewlyMintedNonFungibles, addressesOfNewlyCreatedEntities):
hasher.combine("generalTransaction")
hasher.combine(accountProofs)
hasher.combine(accountWithdraws)
hasher.combine(accountDeposits)
hasher.combine(addressesInManifest)
hasher.combine(metadataOfNewlyCreatedEntities)
hasher.combine(dataOfNewlyMintedNonFungibles)
hasher.combine(addressesOfNewlyCreatedEntities)
case .nonConforming:
hasher.combine("nonConforming")
}
Expand Down
25 changes: 16 additions & 9 deletions Sources/Features/TransactionReviewFeature/TransactionReview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,8 @@ extension TransactionReview {
let transfers = try await resources.asyncFlatMap {
try await transferInfo(
resourceQuantifier: $0,
createdEntities: transaction.metadataOfNewlyCreatedEntities,
metadataOfCreatedEntities: transaction.metadataOfNewlyCreatedEntities,
createdEntities: transaction.addressesOfNewlyCreatedEntities,
networkID: networkID,
type: .exact
)
Expand Down Expand Up @@ -633,7 +634,8 @@ extension TransactionReview {
let transfers = try await accountDeposits.asyncFlatMap {
try await transferInfo(
resourceQuantifier: $0,
createdEntities: transaction.metadataOfNewlyCreatedEntities,
metadataOfCreatedEntities: transaction.metadataOfNewlyCreatedEntities,
createdEntities: transaction.addressesOfNewlyCreatedEntities,
networkID: networkID,
type: $0.transferType
)
Expand All @@ -657,15 +659,16 @@ extension TransactionReview {

func transferInfo(
resourceQuantifier: ResourceTracker,
createdEntities: [String: [String: MetadataValue?]]?,
metadataOfCreatedEntities: [String: [String: MetadataValue?]]?,
createdEntities: [EngineToolkit.Address],
networkID: NetworkID,
type: TransferType
) async throws -> [Transfer] {
let resourceAddress: ResourceAddress = try resourceQuantifier.resourceAddress.asSpecific()
let isNewResource = createdEntities?[resourceAddress.address] != nil
let isNewResource = createdEntities.contains(resourceQuantifier.resourceAddress)

let metadata: (name: String?, symbol: String?, thumbnail: URL?) = await {
if let newResourceMetadata = createdEntities?[resourceAddress.address] {
if let newResourceMetadata = metadataOfCreatedEntities?[resourceAddress.address] {
return (
newResourceMetadata["name"]??.string,
newResourceMetadata["symbol"]??.string,
Expand Down Expand Up @@ -1178,6 +1181,7 @@ extension TransactionType {
let addressesInManifest: [EngineToolkit.EntityType: [EngineToolkit.Address]]
let metadataOfNewlyCreatedEntities: [String: [String: MetadataValue?]]
let dataOfNewlyMintedNonFungibles: [String: [NonFungibleLocalId: [UInt8]]]
let addressesOfNewlyCreatedEntities: [EngineToolkit.Address]

var allAddress: [EngineToolkit.Address] {
addressesInManifest.flatMap(\.value)
Expand All @@ -1202,7 +1206,8 @@ extension TransactionType {
accountDeposits: [to.addressString(): [transferred.toResourceTracker]],
addressesInManifest: addressesInManifest,
metadataOfNewlyCreatedEntities: [:],
dataOfNewlyMintedNonFungibles: [:]
dataOfNewlyMintedNonFungibles: [:],
addressesOfNewlyCreatedEntities: []
)
)

Expand Down Expand Up @@ -1270,18 +1275,20 @@ extension TransactionType {
accountDeposits: deposits,
addressesInManifest: addressesInManifest,
metadataOfNewlyCreatedEntities: [:],
dataOfNewlyMintedNonFungibles: [:]
dataOfNewlyMintedNonFungibles: [:],
addressesOfNewlyCreatedEntities: []
)
)
case let .generalTransaction(accountProofs, accountWithdraws, accountDeposits, addressesInManifest, metadataOfNewlyCreatedEntities, dataOfNewlyMintedNonFungibles):
case let .generalTransaction(accountProofs, accountWithdraws, accountDeposits, addressesInManifest, metadataOfNewlyCreatedEntities, dataOfNewlyMintedNonFungibles, addressesOfNewlyCreatedEntities):
return .conforming(
.init(
accountProofs: accountProofs,
accountWithdraws: accountWithdraws,
accountDeposits: accountDeposits,
addressesInManifest: addressesInManifest,
metadataOfNewlyCreatedEntities: metadataOfNewlyCreatedEntities,
dataOfNewlyMintedNonFungibles: dataOfNewlyMintedNonFungibles
dataOfNewlyMintedNonFungibles: dataOfNewlyMintedNonFungibles,
addressesOfNewlyCreatedEntities: addressesOfNewlyCreatedEntities
)
)
case .nonConforming:
Expand Down