-
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.
Make well known gateways identified (#124)
* Make well known gateways identified * Pr changes
- Loading branch information
1 parent
10e7e3f
commit 7c989cd
Showing
29 changed files
with
425 additions
and
347 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
apple/Sources/Sargon/Extensions/Methods/Profile/Collection/Gateways+Wrap+Functions.swift
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,45 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension Gateways { | ||
|
||
public init(_ elements: [Element]) { | ||
self = newGateways(gateways: elements) | ||
} | ||
|
||
public init(element: Element) { | ||
self = newGatewaysWithGateway(gateway: element) | ||
} | ||
|
||
public var elements: [Element] { | ||
gatewaysGetElements(gateways: self) | ||
} | ||
|
||
public func appending(_ element: Element) -> Self { | ||
newGatewaysByAppending(gateway: element, to: self) | ||
} | ||
|
||
public func updatingOrInserting(element gateway: Element, at index: Int) -> Self { | ||
newGatewaysByUpdatingOrInsertingAtIndex(gateway: gateway, to: self, index: UInt64(index)) | ||
} | ||
|
||
public func updatingOrAppending(_ element: Element) -> Self { | ||
newGatewaysByUpdatingOrAppending(gateway: element, to: self) | ||
} | ||
|
||
public func removing(_ id: Element.ID) -> Self { | ||
newGatewaysRemovedById(idOfGateway: id, from: self) | ||
} | ||
|
||
public func removing(element: Element) -> Self { | ||
newGatewaysRemovedElement(gateway: element, from: self) | ||
} | ||
|
||
public func get(id: Element.ID) -> Element? { | ||
gatewaysGetGatewayById(gateways: self, id: id) | ||
} | ||
|
||
public var count: Int { | ||
Int(gatewaysElementCount(gateways: self)) | ||
} | ||
} |
45 changes: 0 additions & 45 deletions
45
...e/Sources/Sargon/Extensions/Methods/Profile/Collection/OtherGateways+Wrap+Functions.swift
This file was deleted.
Oops, something went wrong.
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
10 changes: 9 additions & 1 deletion
10
...alues/Profile/Gateways+SampleValues.swift → ...le/Collection/Gateways+SampleValues.swift
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,8 +1,16 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Alexander Cyon on 2024-04-15. | ||
// | ||
|
||
import Foundation | ||
import SargonUniFFI | ||
|
||
#if DEBUG | ||
extension Gateways { | ||
public static let sample: Self = newGatewaysSample() | ||
public static let sampleOther: Self = newGatewaysSampleOther() | ||
} | ||
#endif | ||
#endif // DEBUG |
16 changes: 0 additions & 16 deletions
16
...ources/Sargon/Extensions/SampleValues/Profile/Collection/OtherGateways+SampleValues.swift
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
apple/Sources/Sargon/Extensions/SampleValues/Profile/SavedGateways+SampleValues.swift
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 @@ | ||
import SargonUniFFI | ||
|
||
#if DEBUG | ||
extension SavedGateways { | ||
public static let sample: Self = newSavedGatewaysSample() | ||
public static let sampleOther: Self = newSavedGatewaysSampleOther() | ||
} | ||
#endif |
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
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
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
72 changes: 47 additions & 25 deletions
72
jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/Gateways.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,30 +1,52 @@ | ||
@file:JvmName("GatewaysKt") | ||
|
||
package com.radixdlt.sargon.extensions | ||
|
||
import com.radixdlt.sargon.Gateway | ||
import com.radixdlt.sargon.Gateways | ||
import com.radixdlt.sargon.gatewaysGetAllElements | ||
import com.radixdlt.sargon.Url | ||
import com.radixdlt.sargon.gatewaysElementCount | ||
import com.radixdlt.sargon.gatewaysGetElements | ||
import com.radixdlt.sargon.gatewaysGetGatewayById | ||
import com.radixdlt.sargon.newGateways | ||
import com.radixdlt.sargon.newGatewaysChangingCurrent | ||
import com.radixdlt.sargon.newGatewaysDefault | ||
|
||
/** | ||
* Constructs [Gateways] with [current] set as active Gateway. | ||
*/ | ||
fun Gateways.Companion.init(current: Gateway) = newGateways(current = current) | ||
|
||
/** | ||
* The default configuration for each new user: | ||
* Current: mainnet | ||
* Other: [ stokenet ] | ||
*/ | ||
val Gateways.Companion.default | ||
get() = newGatewaysDefault() | ||
|
||
val Gateways.all: List<Gateway> | ||
get() = gatewaysGetAllElements(gateways = this) | ||
|
||
@Throws(SargonException::class) | ||
fun Gateways.changeCurrent(newCurrent: Gateway) = newGatewaysChangingCurrent( | ||
to = newCurrent, | ||
gateways = this | ||
) | ||
import com.radixdlt.sargon.newGatewaysByAppending | ||
import com.radixdlt.sargon.newGatewaysByUpdatingOrAppending | ||
import com.radixdlt.sargon.newGatewaysByUpdatingOrInsertingAtIndex | ||
import com.radixdlt.sargon.newGatewaysRemovedById | ||
import com.radixdlt.sargon.newGatewaysRemovedElement | ||
|
||
fun Gateways.Companion.init(vararg gateway: Gateway): Gateways = | ||
init(gateway.asList()) | ||
|
||
fun Gateways.Companion.init(gateways: List<Gateway>): Gateways = | ||
newGateways(gateways = gateways) | ||
|
||
operator fun Gateways.invoke() = gatewaysGetElements(gateways = this) | ||
|
||
operator fun Gateways.get(index: Int) = invoke().get(index = index) | ||
|
||
operator fun Gateways.contains(element: Gateway) = invoke().contains(element = element) | ||
|
||
val Gateways.size: Int | ||
get() = gatewaysElementCount(gateways = this).toInt() | ||
|
||
fun Gateways.append(gateway: Gateway): Gateways = | ||
newGatewaysByAppending(gateway = gateway, to = this) | ||
|
||
fun Gateways.updateOrInsert(gateway: Gateway, index: Int): Gateways = | ||
newGatewaysByUpdatingOrInsertingAtIndex( | ||
gateway = gateway, | ||
to = this, | ||
index = index.toULong() | ||
) | ||
|
||
fun Gateways.updateOrAppend(gateway: Gateway): Gateways = | ||
newGatewaysByUpdatingOrAppending(gateway = gateway, to = this) | ||
|
||
fun Gateways.removeByUrl(url: Url): Gateways = | ||
newGatewaysRemovedById(idOfGateway = url, from = this) | ||
|
||
fun Gateways.remove(gateway: Gateway): Gateways = | ||
newGatewaysRemovedElement(gateway = gateway, from = this) | ||
|
||
fun Gateways.getBy(url: Url): Gateway? = gatewaysGetGatewayById(gateways = this, id = url) |
55 changes: 0 additions & 55 deletions
55
jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/OtherGateways.kt
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/SavedGateways.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,31 @@ | ||
package com.radixdlt.sargon.extensions | ||
|
||
import com.radixdlt.sargon.Gateway | ||
import com.radixdlt.sargon.Gateways | ||
import com.radixdlt.sargon.SavedGateways | ||
import com.radixdlt.sargon.newSavedGateways | ||
import com.radixdlt.sargon.newSavedGatewaysChangingCurrent | ||
import com.radixdlt.sargon.newSavedGatewaysDefault | ||
import com.radixdlt.sargon.savedGatewaysGetAllElements | ||
|
||
/** | ||
* Constructs [Gateways] with [current] set as active Gateway. | ||
*/ | ||
fun SavedGateways.Companion.init(current: Gateway) = newSavedGateways(current = current) | ||
|
||
/** | ||
* The default configuration for each new user: | ||
* Current: mainnet | ||
* Other: [ stokenet ] | ||
*/ | ||
val SavedGateways.Companion.default | ||
get() = newSavedGatewaysDefault() | ||
|
||
val SavedGateways.all: List<Gateway> | ||
get() = savedGatewaysGetAllElements(gateways = this) | ||
|
||
@Throws(SargonException::class) | ||
fun SavedGateways.changeCurrent(newCurrent: Gateway) = newSavedGatewaysChangingCurrent( | ||
to = newCurrent, | ||
gateways = this | ||
) |
Oops, something went wrong.