diff --git a/SharedBuildProperties.props b/SharedBuildProperties.props index c89c5565..16247395 100644 --- a/SharedBuildProperties.props +++ b/SharedBuildProperties.props @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> Solnet - 6.0.9 + 6.0.10 Copyright 2022 © Solnet blockmountain blockmountain diff --git a/src/Solnet.Rpc/Converters/TransactionErrorJsonConverter.cs b/src/Solnet.Rpc/Converters/TransactionErrorJsonConverter.cs index 79c81b6f..6074c5eb 100644 --- a/src/Solnet.Rpc/Converters/TransactionErrorJsonConverter.cs +++ b/src/Solnet.Rpc/Converters/TransactionErrorJsonConverter.cs @@ -29,7 +29,6 @@ public override TransactionError Read(ref Utf8JsonReader reader, Type typeToConv Enum.TryParse(enumValue, ignoreCase: false, out TransactionErrorType errorType); err.Type = errorType; - reader.Read(); return err; } diff --git a/src/Solnet.Rpc/Models/InstructionError.cs b/src/Solnet.Rpc/Models/InstructionError.cs index 39429ced..ee77ba68 100644 --- a/src/Solnet.Rpc/Models/InstructionError.cs +++ b/src/Solnet.Rpc/Models/InstructionError.cs @@ -232,6 +232,18 @@ public enum InstructionErrorType /// /// Unsupported sysvar /// - UnsupportedSysvar + UnsupportedSysvar, + /// + /// Illegal account owner. + /// + IllegalOwner, + /// + /// Account data allocation exceeded the maximum accounts data size limit. + /// + MaxAccountsDataSizeExceeded, + /// + /// Active vote account close. + /// + ActiveVoteAccountClose } } \ No newline at end of file diff --git a/src/Solnet.Rpc/Models/TransactionError.cs b/src/Solnet.Rpc/Models/TransactionError.cs index d065a431..7c53dea3 100644 --- a/src/Solnet.Rpc/Models/TransactionError.cs +++ b/src/Solnet.Rpc/Models/TransactionError.cs @@ -99,6 +99,54 @@ public enum TransactionErrorType /// /// Transaction processing left an account with an outstanding borrowed reference /// - AccountBorrowOutstanding + AccountBorrowOutstanding, + /// + /// Transaction would exceed max Block Cost Limit. + /// + WouldExceedMaxBlockCostLimit, + /// + /// Transaction version is unsupported. + /// + UnsupportedVersion, + /// + /// Transaction loads a writable account that cannot be written. + /// + InvalidWritableAccount, + /// + /// Transaction would exceed max account limit within the block. + /// + WouldExceedMaxAccountCostLimit, + /// + /// Transaction would exceed max account data limit within the block. + /// + WouldExceedMaxAccountDataCostLimit, + /// + /// Transaction locked too many accounts. + /// + TooManyAccountLocks, + /// + /// Address lookup table not found. + /// + AddressLookupTableNotFound, + /// + /// Attempted to lookup addresses from an account owned by the wrong program. + /// + InvalidAddressLookupTableOwner, + /// + /// Attempted to lookup addresses from an invalid account. + /// + InvalidAddressLookupTableData, + /// + /// Address table lookup uses an invalid index. + /// + InvalidAddressLookupTableIndex, + /// + /// Transaction leaves an account with a lower balance than rent-exempt minimum. + /// + InvalidRentPayingAccount, + /// + /// Transaction would exceed max Vote Cost Limit. + /// + WouldExceedMaxVoteCostLimit } } \ No newline at end of file diff --git a/test/Solnet.Rpc.Test/Resources/Http/Transaction/GetTransactionRequest2.json b/test/Solnet.Rpc.Test/Resources/Http/Transaction/GetTransactionRequest2.json new file mode 100644 index 00000000..43b9b7a7 --- /dev/null +++ b/test/Solnet.Rpc.Test/Resources/Http/Transaction/GetTransactionRequest2.json @@ -0,0 +1 @@ +{"method":"getTransaction","params":["3Q9mu4ePvtbtQzY1kpGmaViJKyBev6hgUppyXDF9hKgWHHnecwGLE2pSoFvNUF3h7acKyFwWd65bkwr9A1jN2CdT",{"encoding":"json"}],"jsonrpc":"2.0","id":0} \ No newline at end of file diff --git a/test/Solnet.Rpc.Test/Resources/Http/Transaction/GetTransactionResponse2.json b/test/Solnet.Rpc.Test/Resources/Http/Transaction/GetTransactionResponse2.json new file mode 100644 index 00000000..5ae25e47 --- /dev/null +++ b/test/Solnet.Rpc.Test/Resources/Http/Transaction/GetTransactionResponse2.json @@ -0,0 +1,70 @@ +{ + "jsonrpc": "2.0", + "result": { + "blockTime": 1651763621, + "meta": { + "err": "InvalidRentPayingAccount", + "fee": 10000, + "innerInstructions": [ + { + "index": 1, + "instructions": [ + { + "accounts": [ 0, 5 ], + "data": "1111cdZH8j1hhBYm8NusCzRNXkMPywbEQWh7ajL72yunGRac4kvcpsAEk5kwY5LSUdYz9", + "programIdIndex": 6 + } + ] + }, + { + "index": 2, + "instructions": [ + { + "accounts": [ 0, 2 ], + "data": "11119EY3pY6ic8YCxcYTfW2d4zG7J1os7p8ArhkwHR6Q1eSYdAYcgk4K5Smo7tPzP39fnM", + "programIdIndex": 6 + } + ] + } + ], + "logMessages": [ "Program 11111111111111111111111111111111 invoke [1]", "Program 11111111111111111111111111111111 success", "Program GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw invoke [1]", "Program log: VERSION:\"2.2.4\"", "Program log: GOVERNANCE-INSTRUCTION: CreateProposal { name: \"Test 7\", description_link: \"test\", vote_type: SingleChoice, options: [\"Approve\"], use_deny_option: true }", "Program 11111111111111111111111111111111 invoke [2]", "Program 11111111111111111111111111111111 success", "Program GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw consumed 34297 of 1400000 compute units", "Program GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw success", "Program GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw invoke [1]", "Program log: VERSION:\"2.2.4\"", "Program log: GOVERNANCE-INSTRUCTION: AddSignatory { signatory: H5pamkZhqFna6stoe79SUt71JiTt34GssgtqoztxX6py }", "Program 11111111111111111111111111111111 invoke [2]", "Program 11111111111111111111111111111111 success", "Program GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw consumed 33340 of 1365703 compute units", "Program GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw success" ], + "postBalances": [ 9342509480, 0, 0, 2533440, 2853600, 0, 1, 0, 1461600, 2804880, 1141440 ], + "postTokenBalances": [], + "preBalances": [ 9342519480, 0, 0, 2533440, 2853600, 0, 1, 0, 1461600, 2804880, 1141440 ], + "preTokenBalances": [], + "rewards": [], + "status": { "Err": "InvalidRentPayingAccount" } + }, + "slot": 132196637, + "transaction": { + "message": { + "accountKeys": [ "H5pamkZhqFna6stoe79SUt71JiTt34GssgtqoztxX6py", "7vESBnyT9te7ttTLsRnyijrtpZuC2EvR8t1ZazNy7Zx1", "3fsZJwjnGCDb2if1tpr1cRptXmwmJdAsRmf8XNJnVi8E", "9cbvyoAYdwM4eBzwDAgXdAWY5gh4StZr7EyJ8RxFZqeh", "FA9Fv1cLSsMcz22DbPJLKLf6onYjoD12gPJ2Fx4UoXk7", "Hup1keWQ661oxKtWukFGsXBE3Q8SxC4FYsS17MeuWuqj", "11111111111111111111111111111111", "37PCL91GdPRpVK22FLXSB25g8zt4Z4g6WF37RfXF3X3S", "4ZBkNCsFDTbi5hLqMGw5AKn54uXPR3P8Hd9QQ8KQfP5A", "61BnDwdR5DytKNHFVuk7HZ8suWRe3BXtJRuehLHrehxV", "GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw" ], + "header": { + "numReadonlySignedAccounts": 0, + "numReadonlyUnsignedAccounts": 5, + "numRequiredSignatures": 2 + }, + "instructions": [ + { + "accounts": [ 0, 1 ], + "data": "111184tZdEHhqyZiCTq5hAoWfNkcdCTdrZzybTVBSzbbe5ixfxFZVoqxaC99XuSFxWxM2A", + "programIdIndex": 6 + }, + { + "accounts": [ 9, 5, 3, 4, 8, 0, 0, 6, 7 ], + "data": "3erv9aqBLnJgmyNgaAc3mBzBdvNmQGZQq7eHW2Y7jWCyVvtM6", + "programIdIndex": 10 + }, + { + "accounts": [ 5, 4, 0, 2, 0, 6 ], + "data": "3Mh3BFGpuPawx6TNjELPWqRif4Ay9FWmYG3a7qStL8mYu", + "programIdIndex": 10 + } + ], + "recentBlockhash": "CxCWR5ecPFGjyYU3zsYQy6hHVwdTgzCDSpjxhde76pcW" + }, + "signatures": [ "3Q9mu4ePvtbtQzY1kpGmaViJKyBev6hgUppyXDF9hKgWHHnecwGLE2pSoFvNUF3h7acKyFwWd65bkwr9A1jN2CdT", "c9mVsH3N6NjC5QcBP3SFuuvYUYUjuFdVLuQMYces5ffksdodLiRc9GKHEj6TUNFNtYbCFQc8aeY2AMBSNVnmJS7" ] + } + }, + "id": 0 +} \ No newline at end of file diff --git a/test/Solnet.Rpc.Test/SolanaRpcClientBlockTests.cs b/test/Solnet.Rpc.Test/SolanaRpcClientBlockTests.cs index 6cbd31f8..f69f2bc2 100644 --- a/test/Solnet.Rpc.Test/SolanaRpcClientBlockTests.cs +++ b/test/Solnet.Rpc.Test/SolanaRpcClientBlockTests.cs @@ -524,6 +524,37 @@ public void TestGetTransaction() FinishTest(messageHandlerMock, TestnetUri); } + [TestMethod] + public void TestGetTransaction2() + { + var responseData = File.ReadAllText("Resources/Http/Transaction/GetTransactionResponse2.json"); + var requestData = File.ReadAllText("Resources/Http/Transaction/GetTransactionRequest2.json"); + var sentMessage = string.Empty; + var messageHandlerMock = SetupTest( + (s => sentMessage = s), responseData); + + var httpClient = new HttpClient(messageHandlerMock.Object) + { + BaseAddress = TestnetUri + }; + var sut = new SolanaRpcClient(TestnetUrl, null, httpClient); + + var res = sut.GetTransaction("3Q9mu4ePvtbtQzY1kpGmaViJKyBev6hgUppyXDF9hKgWHHnecwGLE2pSoFvNUF3h7acKyFwWd65bkwr9A1jN2CdT"); + + Assert.AreEqual(requestData, sentMessage); + Assert.IsNotNull(res.Result); + + Assert.AreEqual(132196637UL, res.Result.Slot); + + Assert.AreEqual(1651763621, res.Result.BlockTime); + + TransactionMetaInfo first = res.Result; + + Assert.IsNotNull(first.Meta.Error); + Assert.AreEqual(TransactionErrorType.InvalidRentPayingAccount, first.Meta.Error.Type); + FinishTest(messageHandlerMock, TestnetUri); + } + [TestMethod] public void TestGetTransactionProcessed() { diff --git a/test/Solnet.Rpc.Test/Solnet.Rpc.Test.csproj b/test/Solnet.Rpc.Test/Solnet.Rpc.Test.csproj index 634050fb..d8ea1901 100644 --- a/test/Solnet.Rpc.Test/Solnet.Rpc.Test.csproj +++ b/test/Solnet.Rpc.Test/Solnet.Rpc.Test.csproj @@ -177,6 +177,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -186,6 +189,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest