Skip to content

Commit

Permalink
fix: Solana v.2 tests (#1554)
Browse files Browse the repository at this point in the history
Co-authored-by: Kirill Bubochkin <[email protected]>
  • Loading branch information
Merculiar and ookami-kb authored Sep 2, 2024
1 parent 6f6c7fd commit ae92c4c
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 699 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ Future<void> main() async {
final message = Message.only(
MemoInstruction(signers: [sender.publicKey], memo: 'Sends tx'),
);
final bh = await client.rpcClient
final latestBlockhash = await client.rpcClient
.getLatestBlockhash(commitment: Commitment.confirmed)
.value;
final tx = await signTransaction(
RecentBlockhash(
blockhash: bh.blockhash,
feeCalculator: const FeeCalculator(lamportsPerSignature: 500),
),
latestBlockhash,
message,
[sender],
);
Expand All @@ -43,9 +40,9 @@ Future<void> main() async {
final message = Message.only(
MemoInstruction(signers: [sender.publicKey], memo: 'Invalid blockhash'),
);
const invalidBlockhash = RecentBlockhash(
const invalidBlockhash = LatestBlockhash(
blockhash: 'EkSnNWid2cvwEVnVx9aBqawnmiCNiDgp3gUdkDPTKN1N',
feeCalculator: FeeCalculator(lamportsPerSignature: 5000),
lastValidBlockHeight: 0,
);

final tx = await signTransaction(invalidBlockhash, message, [sender]);
Expand All @@ -59,14 +56,11 @@ Future<void> main() async {
final message = Message.only(
MemoInstruction(signers: [sender.publicKey], memo: 'Duplicate'),
);
final bh = await client.rpcClient
final latestBlockhash = await client.rpcClient
.getLatestBlockhash(commitment: Commitment.confirmed)
.value;
final tx = await signTransaction(
RecentBlockhash(
blockhash: bh.blockhash,
feeCalculator: const FeeCalculator(lamportsPerSignature: 500),
),
latestBlockhash,
message,
[sender],
);
Expand Down Expand Up @@ -108,14 +102,11 @@ Future<void> main() async {
memo: 'Wait for confirmation',
),
);
final bh = await client.rpcClient
final latestBlockhash = await client.rpcClient
.getLatestBlockhash(commitment: Commitment.confirmed)
.value;
final tx = await signTransaction(
RecentBlockhash(
blockhash: bh.blockhash,
feeCalculator: const FeeCalculator(lamportsPerSignature: 500),
),
latestBlockhash,
message,
[sender],
);
Expand All @@ -137,14 +128,11 @@ Future<void> main() async {
memo: 'Wait for confirmation if already confirmed',
),
);
final bh = await client.rpcClient
final latestBlockhash = await client.rpcClient
.getLatestBlockhash(commitment: Commitment.confirmed)
.value;
final tx = await signTransaction(
RecentBlockhash(
blockhash: bh.blockhash,
feeCalculator: const FeeCalculator(lamportsPerSignature: 500),
),
latestBlockhash,
message,
[sender],
);
Expand Down
4 changes: 2 additions & 2 deletions packages/solana/lib/src/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Future<Ed25519HDPublicKey> findAssociatedTokenAddress({
);

Future<SignedTx> signTransaction(
RecentBlockhash recentBlockhash,
LatestBlockhash latestBlockhash,
Message message,
List<Ed25519HDKeyPair> signers,
) {
Expand All @@ -52,7 +52,7 @@ Future<SignedTx> signTransaction(
}

final CompiledMessage compiledMessage = message.compile(
recentBlockhash: recentBlockhash.blockhash,
recentBlockhash: latestBlockhash.blockhash,
feePayer: signers.first.publicKey,
);

Expand Down
178 changes: 0 additions & 178 deletions packages/solana/lib/src/rpc/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -460,26 +460,6 @@ abstract class RpcClient {
int limit,
);

/// Returns epoch activation information for a stake account
///
/// [pubKey] Pubkey of stake account to query, as base-58 encoded string
///
/// [commitment] For [commitment] parameter description [see this document][see this document]
/// [Commitment.processed] is not supported as [commitment].
///
/// [see this document]: https://docs.solana.com/developing/clients/jsonrpc-api#configuring-state-commitment
///
/// [epoch] epoch for which to calculate activation details. If parameter not provided,
/// defaults to current epoch.
///
/// [minContextSlot] Set the minimum slot that the request can be evaluated at
Future<StakeActivation> getStakeActivation(
String pubKey, {
Commitment? commitment = Commitment.finalized,
int? epoch,
num? minContextSlot,
});

/// Returns the stake minimum delegation, in lamports.
///
/// [commitment] For [commitment] parameter description [see this document][see this document]
Expand Down Expand Up @@ -772,162 +752,4 @@ abstract class RpcClient {
SimulateTransactionAccounts? accounts,
num? minContextSlot,
});

/// Returns identity and transaction information about a confirmed block in the
/// ledger
///
/// [slot] slot, as u64 integer
///
/// [encoding]
///
/// [transactionDetails] Level of transaction detail to return.
///
/// [rewards] Whether to populate the rewards array. If parameter not provided, the default
/// includes rewards.
///
/// [commitment] For [commitment] parameter description [see this document][see this document]
/// [Commitment.processed] is not supported as [commitment].
///
/// [see this document]: https://docs.solana.com/developing/clients/jsonrpc-api#configuring-state-commitment
@Deprecated('Use getBlock instead')
Future<Block> getConfirmedBlock(
int slot, {
Encoding? encoding,
TransactionDetailLevel? transactionDetails,
bool? rewards = false,
Commitment? commitment = Commitment.finalized,
});

/// Returns a list of confirmed blocks between two slots
///
/// [startSlot] start_slot, as u64 integer
///
/// [endSlot] end_slot, as u64 integer
///
/// [commitment] For [commitment] parameter description [see this document][1]
///
/// [Commitment.processed] is not supported as [commitment].
///
/// [1]:
/// https://docs.solana.com/developing/clients/jsonrpc-api#configuring-state-commitment
@Deprecated('Use getBlocks instead')
Future<List<int>> getConfirmedBlocks(
int startSlot,
int? endSlot,
Commitment? commitment,
);

/// Returns a list of confirmed blocks starting at the given slot
///
/// [startSlot] start_slot, as u64 integer
///
/// [limit] limit, as u64 integer
///
/// [commitment] For [commitment] parameter description [see this document][1]
///
/// [Commitment.processed] is not supported as [commitment].
///
/// [1]:
/// https://docs.solana.com/developing/clients/jsonrpc-api#configuring-state-commitment
@Deprecated('Use getBlocksWithLimit instead')
Future<List<int>> getConfirmedBlocksWithLimit(
int startSlot,
int limit,
Commitment? commitment,
);

/// Returns confirmed signatures for transactions involving an address backwards in
/// time from the provided signature or most recent confirmed block
///
///
///
/// [pubKey] account address as base-58 encoded string
///
/// [limit] Maximum transaction signatures to return (between 1 and 1,000, default: 1,000).
///
/// [before] Start searching backwards from this transaction signature. If not provided the
/// search starts from the top of the highest max confirmed block.
///
/// [until] Search until this transaction signature, if found before limit reached.
///
/// [commitment] For [commitment] parameter description [see this document][see this document]
/// [Commitment.processed] is not supported as [commitment].
///
/// [see this document]: https://docs.solana.com/developing/clients/jsonrpc-api#configuring-state-commitment
@Deprecated('Use getSignaturesForAddress instead')
Future<List<TransactionSignatureInformation>>
getConfirmedSignaturesForAddress2(
String pubKey, {
int? limit,
String? before,
String? until,
Commitment? commitment = Commitment.finalized,
});

/// Returns transaction details for a confirmed transaction
///
/// [signature] transaction signature as base-58 encoded string
///
/// [encoding] This value is fixed because parsing occurs internally in the library
///
/// [commitment] For [commitment] parameter description [see this document][see this document]
/// [Commitment.processed] is not supported as [commitment].
///
/// [see this document]: https://docs.solana.com/developing/clients/jsonrpc-api#configuring-state-commitment
@Deprecated('Use getTransaction instead')
Future<TransactionDetails?> getConfirmedTransaction(
String signature, {
Encoding? encoding = Encoding.base64,
Commitment? commitment = Commitment.finalized,
});

/// Returns the fee calculator associated with the query blockhash, or null if the
/// blockhash has expired
///
/// [blockhash] query blockhash as a Base58 encoded string
///
/// [commitment] For [commitment] parameter description [see this document][see this document]
/// [Commitment.processed] is not supported as [commitment].
///
/// [see this document]: https://docs.solana.com/developing/clients/jsonrpc-api#configuring-state-commitment
@Deprecated('Please use isBlockhashValid or getFeeForMessage instead')
Future<FeeCalculatorForBlockhashResult> getFeeCalculatorForBlockhash(
String blockhash, {
Commitment? commitment,
});

/// Returns the fee rate governor information from the root bank
@Deprecated('')
Future<FeeRateGovernor> getFeeRateGovernor();

/// Returns a recent block hash from the ledger, a fee schedule that can be used to
/// compute the cost of submitting a transaction using it, and the last slot in
/// which the blockhash will be valid.
///
/// [commitment] For [commitment] parameter description [see this document][see this document]
/// [Commitment.processed] is not supported as [commitment].
///
/// [see this document]: https://docs.solana.com/developing/clients/jsonrpc-api#configuring-state-commitment
@Deprecated('Use getFeeForMessage instead')
Future<FeesResult> getFees({
Commitment? commitment,
});

/// Returns a recent block hash from the ledger, and a fee schedule that can
/// be used to compute the cost of submitting a transaction using it.
///
/// [commitment] For [commitment] parameter description [see this document][1]
///
/// [Commitment.processed] is not supported as [commitment].
///
/// [1]:
/// https://docs.solana.com/developing/clients/jsonrpc-api#configuring-state-commitment
@Deprecated('Please use getLatestBlockhash instead')
Future<RecentBlockhashResult> getRecentBlockhash({
Commitment? commitment,
});

/// Returns the highest slot that the node has a snapshot for
@Deprecated('Please use getHighestSnapshotSlot instead')
Future<int> getSnapshotSlot();
}
Loading

0 comments on commit ae92c4c

Please sign in to comment.