-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move things to a new models file * Add functionality that utilizes provided credentials * Try passing back nullable auth result object, but this seems to be falling short * Getting closer * Update authresult to be a getter with intential exception catching. Add creds providing sample code in sample app. * Start to implement special case "connect" method in mwa * Fix using wrong property for public key * Standup an attempt at testing the MWA ktx class * Get initial test completing by using appropriate mocks * Add more nice test stuff * Get more things ready for proper API and testing * Get a lot more unit tests in place * Finish up initial set of MWA tests * Some small UX rearrangements to make things a little more clear. * Some more cleanup * Some final small improvementws
- Loading branch information
1 parent
2b355a2
commit 1f30932
Showing
9 changed files
with
574 additions
and
198 deletions.
There are no files selected for viewing
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,2 +1,3 @@ | ||
# macOS finder | ||
.DS_Store | ||
.idea |
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
...ktx/src/main/java/com/solana/mobilewalletadapter/clientlib/AssociationScenarioProvider.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.solana.mobilewalletadapter.clientlib | ||
|
||
import com.solana.mobilewalletadapter.clientlib.scenario.LocalAssociationScenario | ||
|
||
class AssociationScenarioProvider { | ||
|
||
fun provideAssociationScenario(timeoutMs: Int): LocalAssociationScenario { | ||
return LocalAssociationScenario(timeoutMs) | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
android/clientlib-ktx/src/main/java/com/solana/mobilewalletadapter/clientlib/DataModels.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,50 @@ | ||
package com.solana.mobilewalletadapter.clientlib | ||
|
||
import android.net.Uri | ||
import com.solana.mobilewalletadapter.clientlib.protocol.MobileWalletAdapterClient.AuthorizationResult | ||
|
||
sealed class CredentialState { | ||
data class Provided( | ||
val credentials: ConnectionCredentials | ||
): CredentialState() | ||
|
||
object NotProvided: CredentialState() | ||
} | ||
|
||
data class ConnectionCredentials( | ||
val identityUri: Uri, | ||
val iconUri: Uri, | ||
val identityName: String, | ||
val rpcCluster: RpcCluster = RpcCluster.Devnet, | ||
val authToken: String? = null | ||
) | ||
|
||
/** | ||
* Convenience property to access success payload. Will be null if not successful. | ||
*/ | ||
val <T> TransactionResult<T>.successPayload: T? | ||
get() = (this as? TransactionResult.Success)?.payload | ||
|
||
sealed class TransactionResult<T> { | ||
class Success<T>( | ||
val payload: T, | ||
private val result: AuthorizationResult? = null | ||
): TransactionResult<T>() { | ||
|
||
val authResult: AuthorizationResult | ||
get() = try { | ||
result!! | ||
} catch (e: NullPointerException) { | ||
throw IllegalStateException("Auth result accessor is only available when connections credentials have been provided prior to authorize/reauthorize.") | ||
} | ||
} | ||
|
||
class Failure<T>( | ||
val message: String, | ||
val e: Exception | ||
): TransactionResult<T>() | ||
|
||
class NoWalletFound<T>( | ||
val message: String | ||
): TransactionResult<T>() | ||
} |
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.