Skip to content

Commit

Permalink
Wrap RET - batch 3 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyonAlexRDX authored Feb 29, 2024
1 parent cee9a4c commit 20e16ab
Show file tree
Hide file tree
Showing 216 changed files with 8,990 additions and 4,439 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ repos:
name: uniffi bindgen tests
language: system
types: [file, rust]
entry: bash -c 'exec env CLASSPATH="$PWD/jna-5.13.0.jar"' && bash -c 'exec env JAVA_OPTS="-Xmx8g"' && cargo test --package sargon --test uniffi
entry: cargo test --package sargon --test uniffi
pass_filenames: false
3 changes: 2 additions & 1 deletion .tarpaulin.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[all]
exclude-files = [
"tests/*",
"src/wrapped_radix_engine_toolkit/*",
"src/bindgen/*",
"src/wrapped_radix_engine_toolkit/low_level/dummy_types.rs",
"example/*",
"target/*",
"apple/*",
Expand Down
15 changes: 11 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ crate-type = ["staticlib", "cdylib", "lib"]

[[bin]]
name = "uniffi-bindgen"
path = "src/bin.rs"
path = "src/bindgen/bin.rs"

[dependencies]
log = "0.4.20"
Expand All @@ -40,15 +40,21 @@ serde_repr = "0.1.17"
strum = { version = "0.25.0", features = ["derive"] }
strum_macros = { version = "0.26.1" }

# 587d5988cd4ca3c5193ddf37027ff4e4ecd637dc is the Scrypto commit that RET e0e79548e71066d7569f8871c5b002fd5805d9d5 uses
# 587d5988cd4ca3c5193ddf37027ff4e4ecd637dc is the Scrypto commit that RET 1cfe879c7370cfa497857ada7a8973f8a3388abc uses
radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "587d5988cd4ca3c5193ddf37027ff4e4ecd637dc", features = [
"serde",
] }
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "587d5988cd4ca3c5193ddf37027ff4e4ecd637dc" }
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "587d5988cd4ca3c5193ddf37027ff4e4ecd637dc" }
radix-engine-derive = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "587d5988cd4ca3c5193ddf37027ff4e4ecd637dc" }
radix-engine-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "587d5988cd4ca3c5193ddf37027ff4e4ecd637dc", features = [
"std",
] }
radix-engine-toolkit-json = { git = "https://github.com/radixdlt/radix-engine-toolkit", rev = "e0e79548e71066d7569f8871c5b002fd5805d9d5" }
radix-engine-toolkit = { git = "https://github.com/radixdlt/radix-engine-toolkit", rev = "e0e79548e71066d7569f8871c5b002fd5805d9d5" }
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", rev = "587d5988cd4ca3c5193ddf37027ff4e4ecd637dc", features = [
"std",
] }
radix-engine-toolkit-json = { git = "https://github.com/radixdlt/radix-engine-toolkit", rev = "1cfe879c7370cfa497857ada7a8973f8a3388abc" }
radix-engine-toolkit = { git = "https://github.com/radixdlt/radix-engine-toolkit", rev = "1cfe879c7370cfa497857ada7a8973f8a3388abc" }
enum-iterator = "1.4.1"
bip32 = "0.5.1" # only need Secp256k1, to do validation of PublicKey
ed25519-dalek = "1.0.1"
Expand All @@ -70,9 +76,12 @@ assert-json-diff = "2.0.2"
url = { version = "2.5.0", features = ["serde"] }
num-format = "0.4.4"
paste = "1.0.14"
clap = { version = "4", default-features = false, features = ["std", "derive"] }
camino = "1.0.8"

[build-dependencies]
uniffi = { version = "0.26.0", features = ["build"] }
cargo_toml = { version = "0.15.3" }

[dev-dependencies]
uniffi = { version = "0.26.0", features = ["bindgen-tests"] }
166 changes: 23 additions & 143 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,148 +11,16 @@
## Etymology
Named after [Sargon of Akkad](https://en.wikipedia.org/wiki/Sargon_of_Akkad) the first ruler of the Akkadian Empire, the first empire of Mesopotamia. Babylon was a city in southern Mesopotamia, and of course the name of the Radix milestone with which the Radix wallets was launched.

# Status

## LOGIC

`[======--------------------------------------------]`

### Hierarchal Deterministic

- [x] BIP39
- [x] Derivation
- [x] Hierarchal Deterministic `secp256k1`
- [x] Hierarchal Deterministic `Ed25519`
- [x] Signing
- [x] Hierarchal Deterministic ECDSA (`secp256k1`)
- [x] Hierarchal Deterministic EdDSA (`Ed25519`)
- [x] CAP26
- [x] CAP26 AccountPath
- [x] CAP26 IdentityPath
- [x] CAP26 GetID

### Profile Management

- [x] Create new Profile
- [x] Load active Profile
- [x] Import Profile

### Account Management

- [x] Create new account
- [x] Update account

### FactorSource Management

- [x] Create DeviceFactorSource
- [x] Save DeviceFactorSource
- [x] Create LedgerFactorSource
- [ ] Save LedgerFactorSource (trivially done)

### Dapp Interaction

- [ ] Map `AuthorizedPersonaSimple` -> `AuthorizedPersonaDetailed`
- [ ] Update `AuthorizedPersonaSimple` based on a Dapp request

## MODELS

**All models used by iOS/Android wallet is fully implemented in Sargon 🎉**

All models have JSON support and `Placeholder` with which "recursively" I've crafted two valid example Profiles.

All models have Swift/Kotlin bindings using [UniFFI](https://github.com/mozilla/uniffi-rs) generating mutable (so they can be updated in FFI and sent as a whole to Rust side) values types that are `Equatable` and `Hashable`!

### Hierarchal Deterministic

- [x] Mnemonic
- [x] MnemonicWithPassphrase
- [x] HDPath (BIP32)
- [x] BIP44 Like
- [x] CAP26
- [x] CAP26 AccountPath
- [x] CAP26 IdentityPath
- [x] CAP26 GetID
- [x] DerivationPath
- [x] HierarchicalDeterministicPrivateKey
- [x] HierarchicalDeterministicPublicKey

### Profile Snapshot

- [x] Header
- [x] ContentHint
- [x] DeviceInfo
- [x] Keys
- [x] PrivateKey
- [x] PrivateKey (enum)
- [x] Ed25519PrivateKey
- [x] Secp256k1PrivateKey
- [x] PublicKey
- [x] PublicKey (enum)
- [x] Ed25519PublicKey
- [x] Secp256k1PublicKey
- [x] FactorInstance
- [x] HierarchicalDeterministicFactorInstance
- [x] Addresses
- [x] AccountAddress
- [x] IdentityAddress
- [x] ResourceAddress
- [x] FactorSource
- [x] FactorSource
- [x] HierarchicalDeterministicFactorSource
- [x] PrivateHierarchicalDeterministicFactorSource
- [x] FactorSourceKind
- [x] FactorSourceID
- [x] DeviceFactorSource
- [x] LedgerFactorSource
- [x] FactorSources
- [x] Entity
- [x] EntityKind
- [x] SecurityState
- [x] UnsecuredEntityControl
- [x] EntityFlags
- [x] OnLedgerSettings
- [x] ThirdPartyDeposits
- [x] Account
- [x] AppearanceID
- [x] DisplayName
- [x] Networks
- [x] AppPreferences
- [x] Display
- [x] P2PLinks
- [x] P2PLink
- [x] Security
- [x] Transaction
- [x] Gateways
- [x] Gateway
- [x] RadixNetwork
- [x] Persona
- [x] Persona
- [x] PersonaData
- [x] Name
- [x] Email
- [x] Phone
- [ ] Credit Card (not used by Radix Wallet yet)
- [ ] URL (not used by Radix Wallet yet)
- [ ] Company name (not used by Radix Wallet yet)
- [ ] Postal Address (not used by Radix Wallet yet)
- [x] Authorized Dapp
- [x] Shared Accounts
- [x] Shared PersonaData
- [ ] Network
- [x] NetworkID
- [x] Accounts
- [x] Personas
- [x] Authorized Dapps
- [x] Profile

# Development

## Setup

We recommend installing the Radix [Transaction Manifest Extension for VS Code][vscodeext] if you use that IDE

### Swift

```sh
xcode-select install
xcode-select --install
```

Or install `Xcode` from App Store
Expand Down Expand Up @@ -237,6 +105,22 @@ Find [script here](scripts/ios/build-sargon.sh)
## Android
### Prerequisites
#### Java
```sh
brew install java
```
#### `ktlint`
```sh
brew install ktlint
```
#### `cargo-ndk`
```sh
cargo install cargo-ndk
```
#### Rust targets (Android)
```sh
rustup target add aarch64-linux-android armv7-linux-androideabi
Expand Down Expand Up @@ -355,13 +239,9 @@ Two modules are published in [Github's maven](https://github.com/radixdlt/sargon
# Example apps
## iOS

Find [script here](scripts/ios/run-example-app.sh)

```sh
./scripts/ios/run-example-app.sh
```

See iOS example app in [examples/iOS](examples/iOS)

## Android
Import the `/jvm` directory in Android Studio and run the `app` configuration.
Import the `/jvm` directory in Android Studio and run the `app` configuration.

[vscodeext]: https://github.com/radixdlt/radix-transaction-manifest-extension
1 change: 1 addition & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extend-exclude = [
[default.extend-identifiers]
inout = "inout"
pool_tdx_2_1c4ml86h8lvfk7jma0jy0vksh8srcxhmtax8nd3aur29qtd2k2wmlzk = "pool_tdx_2_1c4ml86h8lvfk7jma0jy0vksh8srcxhmtax8nd3aur29qtd2k2wmlzk"
account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr = "account_sim1c8s2hass5g62ckwpv78y8ykdqljtetv4ve6etcz64gveykxznj36tr"

[default.extend-words]
inout = "inout"
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
extension AccessControllerAddress: @unchecked Sendable {}


#if DEBUG
extension AccessControllerAddress {
/// Namespace for preview values of `AccessControllerAddress`
Expand All @@ -9,10 +8,10 @@ extension AccessControllerAddress: @unchecked Sendable {}
public static let of = Self()

public let first: AccessControllerAddress =
newAccessControllerAddressPlaceholder()
newAccessControllerAddressSample()

public let second: AccessControllerAddress =
newAccessControllerAddressPlaceholderOther()
newAccessControllerAddressSampleOther()

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
extension AccountAddress: @unchecked Sendable {}


#if DEBUG
extension AccountAddress {
/// Namespace for preview values of `AccountAddress`
public struct Preview {
fileprivate init() {}
public static let of = Self()

public let mainnet: AccountAddress = newAccountAddressPlaceholderMainnet()
public let mainnet: AccountAddress = newAccountAddressSampleMainnet()
public let mainnetOther: AccountAddress =
newAccountAddressPlaceholderMainnetOther()
newAccountAddressSampleMainnetOther()

public let stokenet: AccountAddress = newAccountAddressPlaceholderStokenet()
public let stokenet: AccountAddress = newAccountAddressSampleStokenet()
public let stokenetOther: AccountAddress =
newAccountAddressPlaceholderStokenetOther()
newAccountAddressSampleStokenetOther()
}

/// Preview values for `AccountAddress`, e.g.:
Expand Down
Loading

0 comments on commit 20e16ab

Please sign in to comment.