-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* new branch w/refactor * use solanakt master branch snapshot * update with solana kt sockets/remove moshi branch * fix up issues from auction house merge, remove deprecations * switch to solana 2.0 release
- Loading branch information
1 parent
6c5fb1d
commit ababae2
Showing
60 changed files
with
494 additions
and
1,624 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
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
35 changes: 35 additions & 0 deletions
35
lib/src/main/java/com/metaplex/lib/extensions/Result+Extensions.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,35 @@ | ||
/* | ||
* Connection+Extensions | ||
* Metaplex | ||
* | ||
* Created by Funkatronics on 10/19/2022 | ||
*/ | ||
|
||
package com.metaplex.lib.extensions | ||
|
||
import com.metaplex.lib.drivers.solana.Connection | ||
import com.metaplex.lib.drivers.solana.TransactionOptions | ||
import kotlinx.coroutines.isActive | ||
import kotlinx.coroutines.withTimeout | ||
|
||
suspend fun Result<String>.confirmTransaction( | ||
connection: Connection, transactionOptions: TransactionOptions = connection.transactionOptions | ||
): Result<String> = withTimeout(transactionOptions.timeout.toMillis()) { | ||
|
||
suspend fun confirmationStatus() = | ||
connection.getSignatureStatuses(listOf(getOrThrow()), null) | ||
.getOrNull()?.first()?.confirmationStatus | ||
|
||
// wait for desired transaction status | ||
while(confirmationStatus() != transactionOptions.commitment.toString()) { | ||
|
||
// wait a bit before retrying | ||
val millis = System.currentTimeMillis() | ||
var inc = 0 | ||
while(System.currentTimeMillis() - millis < 300 && isActive) { inc++ } | ||
|
||
if (!isActive) break // breakout after timeout | ||
} | ||
|
||
this@confirmTransaction // return result | ||
} |
Oops, something went wrong.