-
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.
- Loading branch information
1 parent
b50a976
commit cae532f
Showing
15 changed files
with
132 additions
and
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,41 @@ | ||
package com.metaplex.lib | ||
|
||
import com.metaplex.lib.drivers.indenty.KeypairIdentityDriver | ||
import com.metaplex.lib.drivers.indenty.ReadOnlyIdentityDriver | ||
import com.metaplex.lib.drivers.rpc.JdkRpcDriver | ||
import com.metaplex.lib.drivers.solana.Commitment | ||
import com.metaplex.lib.drivers.solana.Connection | ||
import com.metaplex.lib.drivers.solana.SolanaConnectionDriver | ||
import com.metaplex.lib.drivers.solana.TransactionOptions | ||
import com.metaplex.lib.drivers.storage.MemoryStorageDriver | ||
import com.metaplex.lib.drivers.storage.StorageDriver | ||
import com.solana.core.Account | ||
import com.solana.core.PublicKey | ||
import com.solana.networking.RPCEndpoint | ||
import java.net.URL | ||
|
||
object MetaplexTestUtils { | ||
const val RPC_URL = BuildConfig.RPC_URL | ||
|
||
val DEFAULT_TRANSACTION_OPTIONS = TransactionOptions(Commitment.CONFIRMED, skipPreflight = true) | ||
|
||
val TEST_ACCOUNT_PUBLICKEY = PublicKey(SolanaTestData.TEST_ACCOUNT_PUBLICKEY_STRING) | ||
} | ||
|
||
fun MetaplexTestUtils.generateMetaplexInstance(accountPublicKey: PublicKey = TEST_ACCOUNT_PUBLICKEY, | ||
storageDriver: StorageDriver = MemoryStorageDriver()) | ||
: Metaplex { | ||
fun MetaplexTestUtils.generateConnectionDriver( | ||
rpcURL: URL = URL(RPC_URL), txOptions: TransactionOptions = DEFAULT_TRANSACTION_OPTIONS | ||
) = SolanaConnectionDriver(JdkRpcDriver(rpcURL), txOptions) | ||
|
||
fun MetaplexTestUtils.generateMetaplexInstance( | ||
account: Account = Account(), connectionDriver: Connection = generateConnectionDriver(), | ||
storageDriver: StorageDriver = MemoryStorageDriver() | ||
): Metaplex { | ||
val identityDriver = KeypairIdentityDriver(account, connectionDriver) | ||
return Metaplex(connectionDriver, identityDriver, storageDriver) | ||
} | ||
|
||
val MetaplexTestUtils.readOnlyMainnetMetaplexInstance: Metaplex get() { | ||
val solanaConnection = SolanaConnectionDriver(RPCEndpoint.mainnetBetaSolana) | ||
val solanaIdentityDriver = ReadOnlyIdentityDriver(accountPublicKey, solanaConnection) | ||
return Metaplex(solanaConnection, solanaIdentityDriver, storageDriver) | ||
val solanaIdentityDriver = ReadOnlyIdentityDriver(TEST_ACCOUNT_PUBLICKEY, solanaConnection) | ||
return Metaplex(solanaConnection, solanaIdentityDriver, MemoryStorageDriver()) | ||
} |
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
Oops, something went wrong.