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

Introduce Sargon: Radix Engine Toolkit (RET) removed #1032

Merged
merged 155 commits into from
Apr 12, 2024

Conversation

CyonAlexRDX
Copy link
Contributor

@CyonAlexRDX CyonAlexRDX commented Feb 9, 2024

STATUS: Ready for review

Do not merge yet, we must test it more! Initial testing looks good, I've tried all various "standard transactions" which seems to be working:

  • Single Fungible token transfer
  • Non Fungible token transfer
  • Multiple Fungible
  • Multiple Non Fungible
  • Stake
  • Unstake
  • Claim stake
  • Use Gumball Club Dapp with Membership
  • Mint Fungible
  • Update Third Party Deposits
  • Mint Non Fungible

(Creating MANY NonFungible and MANY Fungible - from Dev Preferences for DEBUG builds does not work, so I will look into that, but at least mint many NFTs is commented out currently in main anyway.)

Changes

This PR removes RET: Radix Engine Toolkit (which is Swifty wrapper around Rust impl), and the extensions we had on those types which reside in the EngineKit folder in this repo - they are all replaces with Sargon, specifically the Swift Package / target with the same name, which is a non-trivial Swift wrapper around the UniFFI bindgen "hot garbage" generated file with 22,000 lines of Swift code.

Sargon also contains a full implementation of Profile, this PR does NOT make use of that here in iOS wallet land, instead we keep using the iOS wallets Profile impl for now, but at a later point in time (hopefully this month) we will remove iOS profile and use Sargon profile instead.

RETDecimal is now known as Decimal192 (Not named Decimal to avoid naming collision with Foundation.Decimal) - and should be identical to what we have today (with a few extra improvements, such asDecimal is not a throwing method but a computed property. And more initializers)

Sendable

All types in Sargon are value types - not references types like they were in RET - with mutable stored properties. All types are Hashable (thus Equatable) and Sendable.

Samples Values

ALL types in Sargon (in Rust) have sample values. Self.sample() and Self.sample_other(), almost all types in Swift have got those a exported as static vars, Self.sample and Self.sampleOther - if you miss one, let me know and I will export it from Rust and "swiftify it".

RET API's have been upgraded to:

  • Not be unnecessarily throwing (e.g. hash and compile and intent_hash etc)
  • To not return Address (tagged union) but rather use specific addresses, e.g. AccountAddress for accountsWithdrawnFrom
  • Not require networkID unnecessarily - instead we read it out from the provided addresses
  • ALL manifest building has been moved into, and fully isolated in Sargon - Sargon does NOT provide any ManifestBuilder at all
  • All addresses have been upgraded with nice shiny API's such as networkID, poolKind, isLegacyAddress, isFungible etc
  • All Address, IntentHashes, NF-LocalID and NF-GlobalID have got the formatted(_ addressFormat: AddressFormat) -> String methods

BROKEN / UNTESTED

Most likely broken are:

  • RET errors - they have not yet been migrated - but note that some of them cannot happen any more.

Test it out

Pre-Alpha 1.5.1 (2)

@CyonAlexRDX
Copy link
Contributor Author

supersedes #1031

@CyonAlexRDX CyonAlexRDX closed this Feb 9, 2024
@CyonAlexRDX CyonAlexRDX reopened this Feb 9, 2024
@@ -150,7 +150,7 @@ extension OnLedgerEntitiesClient {
guard let xrdResource = item
.fungibleResources?
.items
.first(where: { $0.resourceAddress == xrdAddress })
.first(where: { $0.resourceAddress == xrdAddress.address })

This comment was marked as resolved.

@@ -10,23 +10,23 @@ public struct SubmitTransactionClient: Sendable {
}

extension SubmitTransactionClient {
public typealias SubmitTransaction = @Sendable (SubmitTXRequest) async throws -> TXID
public typealias HasTXBeenCommittedSuccessfully = @Sendable (TXID) async throws -> Void
public typealias SubmitTransaction = @Sendable (SubmitTXRequest) async throws -> IntentHash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we then also replace the txID property names?

Copy link
Contributor

@GhenadieVP GhenadieVP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tremendous work, bravo 💯 🥇!!! So many months of work finally come to fruition, and in what a nice clean way 👏.
Can't wait to have 90% of the codebase in Sargon 😄

Copy link
Contributor

@kugel3 kugel3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work, many great improvements. Most comments are style related. Regarding all the new debug strings, shouldn't they be returned by Sargon, or are they all on types that only exist on iOS?

@CyonAlexRDX CyonAlexRDX changed the title [DO NOT MERGE] Sargon Integration Introduce Sargon: Radix Engine Toolkit (RET) removed Apr 9, 2024
@CyonAlexRDX CyonAlexRDX removed DO NOT MERGE Merging is blocked or prohibited due to missing specs or other higher priority PRs ENGINE 🧰 labels Apr 9, 2024
@GhenadieVP GhenadieVP merged commit c69a5d9 into main Apr 12, 2024
6 checks passed
@GhenadieVP GhenadieVP deleted the ret_extraction_second_attempt branch April 12, 2024 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants