-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP Batch 1 * WIP Batch 2 * Rename methods and provide encrypt/decrypt for profile
- Loading branch information
1 parent
11a069e
commit 5498570
Showing
55 changed files
with
986 additions
and
110 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/AppPreferences.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.radixdlt.sargon.extensions | ||
|
||
import com.radixdlt.sargon.AppPreferences | ||
import com.radixdlt.sargon.newAppPreferencesDefault | ||
|
||
fun AppPreferences.Companion.default() = newAppPreferencesDefault() |
55 changes: 55 additions & 0 deletions
55
jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/AssetsExceptionList.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.radixdlt.sargon.extensions | ||
|
||
import com.radixdlt.sargon.AssetException | ||
import com.radixdlt.sargon.AssetsExceptionList | ||
import com.radixdlt.sargon.ResourceAddress | ||
import com.radixdlt.sargon.assetsExceptionListElementCount | ||
import com.radixdlt.sargon.assetsExceptionListGetAssetExceptionById | ||
import com.radixdlt.sargon.assetsExceptionListGetElements | ||
import com.radixdlt.sargon.newAssetsExceptionList | ||
import com.radixdlt.sargon.newAssetsExceptionListByAppending | ||
import com.radixdlt.sargon.newAssetsExceptionListByUpdatingOrAppending | ||
import com.radixdlt.sargon.newAssetsExceptionListByUpdatingOrInsertingAtIndex | ||
import com.radixdlt.sargon.newAssetsExceptionListRemovedById | ||
import com.radixdlt.sargon.newAssetsExceptionListRemovedElement | ||
|
||
fun AssetsExceptionList.Companion.init(vararg assetException: AssetException): AssetsExceptionList = | ||
init(assetsExceptions = assetException.asList()) | ||
|
||
fun AssetsExceptionList.Companion.init(assetsExceptions: List<AssetException>): AssetsExceptionList = | ||
newAssetsExceptionList(assetsExceptionList = assetsExceptions) | ||
|
||
operator fun AssetsExceptionList.invoke() = | ||
assetsExceptionListGetElements(assetsExceptionList = this) | ||
|
||
operator fun AssetsExceptionList.get(index: Int) = invoke().get(index = index) | ||
|
||
operator fun AssetsExceptionList.contains(element: AssetException) = | ||
invoke().contains(element = element) | ||
|
||
val AssetsExceptionList.size: Int | ||
get() = assetsExceptionListElementCount(assetsExceptionList = this).toInt() | ||
|
||
fun AssetsExceptionList.append(assetException: AssetException): AssetsExceptionList = | ||
newAssetsExceptionListByAppending(assetException = assetException, to = this) | ||
|
||
fun AssetsExceptionList.updateOrInsert( | ||
assetException: AssetException, | ||
index: Int | ||
): AssetsExceptionList = newAssetsExceptionListByUpdatingOrInsertingAtIndex( | ||
assetException = assetException, | ||
to = this, | ||
index = index.toULong() | ||
) | ||
|
||
fun AssetsExceptionList.updateOrAppend(assetException: AssetException): AssetsExceptionList = | ||
newAssetsExceptionListByUpdatingOrAppending(assetException = assetException, to = this) | ||
|
||
fun AssetsExceptionList.removeByAddress(address: ResourceAddress): AssetsExceptionList = | ||
newAssetsExceptionListRemovedById(idOfAssetException = address, from = this) | ||
|
||
fun AssetsExceptionList.remove(assetException: AssetException): AssetsExceptionList = | ||
newAssetsExceptionListRemovedElement(assetException = assetException, from = this) | ||
|
||
fun AssetsExceptionList.getBy(address: ResourceAddress): AssetException? = | ||
assetsExceptionListGetAssetExceptionById(assetsExceptionList = this, id = address) |
12 changes: 3 additions & 9 deletions
12
jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/AuthorisedDapp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
package com.radixdlt.sargon.extensions | ||
|
||
import com.radixdlt.sargon.AuthorizedDapp | ||
import com.radixdlt.sargon.BagOfBytes | ||
import com.radixdlt.sargon.authorizedDappToJsonBytes | ||
import com.radixdlt.sargon.newAuthorizedDappFromJsonBytes | ||
|
||
@Throws(SargonException::class) | ||
fun AuthorizedDapp.Companion.deserializeFromJsonBytes(jsonBytes: BagOfBytes) = | ||
newAuthorizedDappFromJsonBytes(jsonBytes = jsonBytes) | ||
fun AuthorizedDapp.Companion.fromJson(jsonString: String) = | ||
newAuthorizedDappFromJsonBytes(jsonBytes = bagOfBytes(fromString = jsonString)) | ||
|
||
@Throws(SargonException::class) | ||
fun AuthorizedDapp.Companion.deserializeFromJsonString(jsonString: String) = | ||
deserializeFromJsonBytes(jsonBytes = bagOfBytes(fromString = jsonString)) | ||
|
||
fun AuthorizedDapp.serializedJsonBytes(): BagOfBytes = authorizedDappToJsonBytes(authorizedDapp = this) | ||
fun AuthorizedDapp.serializedJsonString(): String = serializedJsonBytes().string | ||
fun AuthorizedDapp.toJson(): String = authorizedDappToJsonBytes(authorizedDapp = this).string |
8 changes: 8 additions & 0 deletions
8
jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/Bip39Language.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.radixdlt.sargon.extensions | ||
|
||
import com.radixdlt.sargon.Bip39Language | ||
import com.radixdlt.sargon.Bip39Word | ||
import com.radixdlt.sargon.bip39LanguageWordlist | ||
|
||
val Bip39Language.wordList: List<Bip39Word> | ||
get() = bip39LanguageWordlist(language = this) |
9 changes: 9 additions & 0 deletions
9
jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/Bip39WordCount.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.radixdlt.sargon.extensions | ||
|
||
import com.radixdlt.sargon.Bip39WordCount | ||
import com.radixdlt.sargon.CommonException | ||
|
||
@Throws(SargonException::class) | ||
fun Bip39WordCount.Companion.init(wordCount: Int) = Bip39WordCount.entries.find { | ||
it.value == wordCount.toUByte() | ||
} ?: throw CommonException.InvalidBip39WordCount(badValue = wordCount.toULong()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/DepositorsAllowList.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.radixdlt.sargon.extensions | ||
|
||
import com.radixdlt.sargon.DepositorsAllowList | ||
import com.radixdlt.sargon.ResourceOrNonFungible | ||
import com.radixdlt.sargon.depositorsAllowListElementCount | ||
import com.radixdlt.sargon.depositorsAllowListGetElements | ||
import com.radixdlt.sargon.depositorsAllowListGetResourceOrNonFungibleById | ||
import com.radixdlt.sargon.newDepositorsAllowList | ||
import com.radixdlt.sargon.newDepositorsAllowListByAppending | ||
import com.radixdlt.sargon.newDepositorsAllowListByUpdatingOrAppending | ||
import com.radixdlt.sargon.newDepositorsAllowListByUpdatingOrInsertingAtIndex | ||
import com.radixdlt.sargon.newDepositorsAllowListRemovedElement | ||
|
||
fun DepositorsAllowList.Companion.init(vararg resourceOrNonFungible: ResourceOrNonFungible): DepositorsAllowList = | ||
init(depositorsAllowList = resourceOrNonFungible.asList()) | ||
|
||
fun DepositorsAllowList.Companion.init(depositorsAllowList: List<ResourceOrNonFungible>): DepositorsAllowList = | ||
newDepositorsAllowList(depositorsAllowList = depositorsAllowList) | ||
|
||
operator fun DepositorsAllowList.invoke() = | ||
depositorsAllowListGetElements(depositorsAllowList = this) | ||
|
||
operator fun DepositorsAllowList.get(index: Int) = invoke().get(index = index) | ||
|
||
operator fun DepositorsAllowList.contains(element: ResourceOrNonFungible) = | ||
invoke().contains(element = element) | ||
|
||
val DepositorsAllowList.size: Int | ||
get() = depositorsAllowListElementCount(depositorsAllowList = this).toInt() | ||
|
||
fun DepositorsAllowList.append(resourceOrNonFungible: ResourceOrNonFungible): DepositorsAllowList = | ||
newDepositorsAllowListByAppending(resourceOrNonFungible = resourceOrNonFungible, to = this) | ||
|
||
fun DepositorsAllowList.updateOrInsert( | ||
resourceOrNonFungible: ResourceOrNonFungible, | ||
index: Int | ||
): DepositorsAllowList = newDepositorsAllowListByUpdatingOrInsertingAtIndex( | ||
resourceOrNonFungible = resourceOrNonFungible, | ||
to = this, | ||
index = index.toULong() | ||
) | ||
|
||
fun DepositorsAllowList.updateOrAppend( | ||
resourceOrNonFungible: ResourceOrNonFungible | ||
): DepositorsAllowList = newDepositorsAllowListByUpdatingOrAppending( | ||
resourceOrNonFungible = resourceOrNonFungible, | ||
to = this | ||
) | ||
|
||
fun DepositorsAllowList.remove( | ||
resourceOrNonFungible: ResourceOrNonFungible | ||
): DepositorsAllowList = newDepositorsAllowListRemovedElement( | ||
resourceOrNonFungible = resourceOrNonFungible, | ||
from = this | ||
) | ||
|
||
fun DepositorsAllowList.getBy( | ||
resourceOrNonFungible: ResourceOrNonFungible | ||
): ResourceOrNonFungible? = depositorsAllowListGetResourceOrNonFungibleById( | ||
depositorsAllowList = this, | ||
id = resourceOrNonFungible | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/FactorSourceKind.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.radixdlt.sargon.extensions | ||
|
||
import com.radixdlt.sargon.FactorSourceKind | ||
import com.radixdlt.sargon.factorSourceKindToString | ||
import com.radixdlt.sargon.newFactorSourceKindFromString | ||
|
||
@Throws(SargonException::class) | ||
fun FactorSourceKind.Companion.init(string: String) = newFactorSourceKindFromString(string = string) | ||
|
||
val FactorSourceKind.string: String | ||
get() = factorSourceKindToString(kind = this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/LedgerWardwareWalletModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.radixdlt.sargon.extensions | ||
|
||
import com.radixdlt.sargon.LedgerHardwareWalletModel | ||
import com.radixdlt.sargon.ledgerHwWalletModelToString | ||
import com.radixdlt.sargon.newLedgerHwWalletModelFromString | ||
|
||
@Throws(SargonException::class) | ||
fun LedgerHardwareWalletModel.Companion.init(string: String) = | ||
newLedgerHwWalletModelFromString(string = string) | ||
|
||
val LedgerHardwareWalletModel.string: String | ||
get() = ledgerHwWalletModelToString(model = this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.