Skip to content

Commit 2245d38

Browse files
committed
V4.2.0
- Fixed Solana simulate transaction model - Added helper methods to solana versioned messages for replacing blockchains
1 parent bcb3f29 commit 2245d38

File tree

6 files changed

+51
-8
lines changed

6 files changed

+51
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# 4.1.0
1+
## 4.2.0
2+
3+
- Fixed Solana simulate transaction model
4+
- Added helper methods to solana versioned messages for replacing blockchains
5+
6+
## 4.1.0
27

38
- Fix Solana pre-instruction serialization issues
49

lib/solana/src/rpc/models/models/simulate_transaction_response.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class SimulateTranasctionReturnDataResponse {
2020
}
2121

2222
class SimulateTranasctionResponse {
23-
final String? err;
23+
final dynamic err;
2424
final List<String>? logs;
25-
final List<SolanaAccountInfo>? accounts;
25+
final List<SolanaAccountInfo?>? accounts;
2626
final BigInt? unitsConsumed;
2727
final SimulateTranasctionReturnDataResponse? returnData;
2828
final CompiledInnerInstruction? innerInstructions;
@@ -31,7 +31,7 @@ class SimulateTranasctionResponse {
3131
return {
3232
"err": err,
3333
"logs": logs,
34-
"accounts": accounts?.map((e) => e.toJson()).toList(),
34+
"accounts": accounts?.map((e) => e?.toJson()).toList(),
3535
"unitsConsumed": unitsConsumed?.toString(),
3636
"returnData": returnData?.toJson(),
3737
"innerInstructions": innerInstructions?.toJson()
@@ -49,9 +49,10 @@ class SimulateTranasctionResponse {
4949
return SimulateTranasctionResponse(
5050
err: json["err"],
5151
logs: (json["logs"] as List?)?.map((e) => e.toString()).toList(),
52-
accounts: (json["accounts"] as List?)
53-
?.map((e) => SolanaAccountInfo.fromJson((e as Map).cast()))
54-
.toList(),
52+
accounts: (json["accounts"] as List?)?.map((e) {
53+
if (e == null) return null;
54+
return SolanaAccountInfo.fromJson((e as Map).cast());
55+
}).toList(),
5556
unitsConsumed: BigintUtils.tryParse(json["unitsConsumed"]),
5657
returnData: json["returnData"] == null
5758
? null

lib/solana/src/transaction/core/core.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ class TransactionType {
3939

4040
/// Abstract class representing a versioned message.
4141
abstract class VersionedMessage {
42+
VersionedMessage copyWith(
43+
{MessageHeader? header,
44+
List<SolAddress>? accountKeys,
45+
SolAddress? recentBlockhash,
46+
List<CompiledInstruction>? compiledInstructions,
47+
List<AddressTableLookup>? addressTableLookups});
48+
4249
/// The message header, identifying signed and read-only [accountKeys].
4350
abstract final MessageHeader header;
4451

lib/solana/src/transaction/message/legacy.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ class Message implements VersionedMessage {
3030
required this.compiledInstructions,
3131
});
3232

33+
@override
34+
Message copyWith(
35+
{MessageHeader? header,
36+
List<SolAddress>? accountKeys,
37+
SolAddress? recentBlockhash,
38+
List<CompiledInstruction>? compiledInstructions,
39+
List<AddressTableLookup>? addressTableLookups}) {
40+
return Message(
41+
header: header ?? this.header,
42+
accountKeys: accountKeys ?? this.accountKeys,
43+
recentBlockhash: recentBlockhash ?? this.recentBlockhash,
44+
compiledInstructions:
45+
compiledInstructions ?? this.compiledInstructions);
46+
}
47+
3348
/// Constructs a message from a serialized buffer.
3449
factory Message.fromBuffer(List<int> buffer) {
3550
return SolanaTransactionUtils.deserializeMessageLegacy(buffer);

lib/solana/src/transaction/message/message_v0.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ class MessageV0 implements VersionedMessage {
3434
required this.addressTableLookups,
3535
});
3636

37+
@override
38+
MessageV0 copyWith(
39+
{MessageHeader? header,
40+
List<SolAddress>? accountKeys,
41+
SolAddress? recentBlockhash,
42+
List<CompiledInstruction>? compiledInstructions,
43+
List<AddressTableLookup>? addressTableLookups}) {
44+
return MessageV0(
45+
header: header ?? this.header,
46+
accountKeys: accountKeys ?? this.accountKeys,
47+
recentBlockhash: recentBlockhash ?? this.recentBlockhash,
48+
compiledInstructions: compiledInstructions ?? this.compiledInstructions,
49+
addressTableLookups: addressTableLookups ?? this.addressTableLookups);
50+
}
51+
3752
/// Compiles a version 0 message from provided parameters.
3853
factory MessageV0.compile({
3954
required List<TransactionInstruction> transactionInstructions,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: on_chain
22
description: Streamline Ethereum, Tron, Solana and Cardano operations. Effortlessly create transactions, interact with smart contracts, sign, and send transactions.
3-
version: 4.1.0
3+
version: 4.2.0
44
homepage: "https://github.com/mrtnetwork/on_chain"
55
repository: "https://github.com/mrtnetwork/on_chain"
66

0 commit comments

Comments
 (0)