diff --git a/Netezos.Tests/Rpc/TestContextQueries.cs b/Netezos.Tests/Rpc/TestContextQueries.cs index 0d7440f6..3c15e478 100644 --- a/Netezos.Tests/Rpc/TestContextQueries.cs +++ b/Netezos.Tests/Rpc/TestContextQueries.cs @@ -147,6 +147,17 @@ public async Task TestContextContractEntrypoints() Assert.True(res is DJsonObject); } + [Fact] + public async Task TestContextContractEstimatedOwnPendingSlashedAmount() + { + var query = Rpc.Blocks.Head.Context.Contracts[TestContract].EstimatedOwnPendingSlashedAmount; + Assert.Equal($"chains/main/blocks/head/context/contracts/{TestContract}/estimated_own_pending_slashed_amount/", + query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + [Fact] public async Task TestContextContractEntrypoint() { @@ -282,7 +293,7 @@ public async Task TestContextContractUnstakeRequests() Assert.Equal($"chains/main/blocks/head/context/contracts/{TestDelegate}/unstake_requests/", query.ToString()); var res = await query.GetAsync(); - Assert.True(res is DJsonObject); + Assert.True(res is DJsonObject || res == null); } [Fact] @@ -305,6 +316,36 @@ public async Task TestContextContractUnstakedFrozenBalance() Assert.True(res is DJsonValue); } + [Fact] + public async Task TestContextDalCommitmentsHistory() + { + var query = Rpc.Blocks.Head.Context.Dal.CommitmentsHistory; + Assert.Equal("chains/main/blocks/head/context/dal/commitments_history/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonObject); + } + + [Fact] + public async Task TestContextDalPublishedSlotHeaders() + { + var query = Rpc.Blocks.Head.Context.Dal.PublishedSlotHeaders; + Assert.Equal("chains/main/blocks/head/context/dal/published_slot_headers/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonArray); + } + + [Fact] + public async Task TestContextDalShards() + { + var query = Rpc.Blocks.Head.Context.Dal.Shards; + Assert.Equal("chains/main/blocks/head/context/dal/shards/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonArray); + } + [Fact] public async Task TestContextDelegates() { @@ -314,8 +355,8 @@ public async Task TestContextDelegates() var res = await query.GetAsync(); Assert.True(res is DJsonArray); - var deleegateActiveRes = await query.GetAsync(DelegateStatus.Active); - Assert.True(deleegateActiveRes is DJsonArray); + var delegateActiveRes = await query.GetAsync(DelegateStatus.Active); + Assert.True(delegateActiveRes is DJsonArray); var delegateInactiveRes = await query.GetAsync(DelegateStatus.Inactive); Assert.True(delegateInactiveRes is DJsonArray); @@ -410,7 +451,49 @@ public async Task TestContextDelegateDelegatedContracts() var res = await query.GetAsync(); Assert.True(res is DJsonArray); } - + + [Fact] + public async Task TestContextDelegateDenunciations() + { + var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].Denunciations; + Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/denunciations/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonArray); + } + + [Fact] + public async Task TestContextDelegateEstimatedSharedPendingSlashedAmount() + { + var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].EstimatedSharedPendingSlashedAmount; + Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/estimated_shared_pending_slashed_amount/", + query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + + [Fact] + public async Task TestContextDelegateIsForbidden() + { + var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].IsForbidden; + Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/is_forbidden/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + + [Fact] + public async Task TestContextDelegateMinDelegatedInCurrentCycle() + { + var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].MinDelegatedInCurrentCycle; + Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/min_delegated_in_current_cycle/", + query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonObject); + } + [Fact] public async Task TestContextDelegateFrozenDeposits() { @@ -584,16 +667,6 @@ public async Task TestContextSmartRollupGenesisInfo() Assert.True(res is DJsonObject); } - [Fact] - public async Task TestContextSmartRollupInitialPvmStateHash() - { - var query = Rpc.Blocks.Head.Context.SmartRollups[TestSmartRollup].InitialPvmStateHash; - Assert.Equal($"chains/main/blocks/head/context/smart_rollups/smart_rollup/{TestSmartRollup}/initial_pvm_state_hash/", query.ToString()); - - var res = await query.GetAsync(); - Assert.True(res is DJsonValue); - } - [Fact] public async Task TestContextSmartRollupKind() { diff --git a/Netezos.Tests/Rpc/TestHelpersQueries.cs b/Netezos.Tests/Rpc/TestHelpersQueries.cs index 3e1099c1..e81adf7f 100644 --- a/Netezos.Tests/Rpc/TestHelpersQueries.cs +++ b/Netezos.Tests/Rpc/TestHelpersQueries.cs @@ -36,16 +36,6 @@ public async Task TestHelpersCurrentLevel() Assert.True(res is DJsonObject); } - [Fact] - public async Task TestHelpersEndorsingRights() - { - var query = Rpc.Blocks.Head.Helpers.EndorsingRights; - Assert.Equal($"chains/main/blocks/head/helpers/endorsing_rights", query.ToString()); - - var res = await query.GetAsync(); - Assert.True(res is DJsonArray); - } - [Fact] public void TestHelpersForgeBlockHeader() { diff --git a/Netezos.Tests/Rpc/TestRawContextQueries.cs b/Netezos.Tests/Rpc/TestRawContextQueries.cs index d3355996..8e148f07 100644 --- a/Netezos.Tests/Rpc/TestRawContextQueries.cs +++ b/Netezos.Tests/Rpc/TestRawContextQueries.cs @@ -158,16 +158,6 @@ public async Task TestRawContextContractDelegated() Assert.True(res is DJsonArray); } - [Fact] - public async Task TestRawContextContractFrozenDeposits() - { - var query = Rpc.Blocks.Head.Context.Raw.Contracts[TestDelegate].FrozenDeposits; - Assert.Equal($"chains/main/blocks/head/context/raw/json/contracts/index/{TestDelegate}/frozen_deposits/", query.ToString()); - - var res = await query.GetAsync(); - Assert.True(res is DJsonObject); - } - [Fact] public async Task TestRawContextContractManager() { @@ -195,7 +185,7 @@ public async Task TestRawContextContractStorage() Assert.Equal($"chains/main/blocks/head/context/raw/json/contracts/index/{TestContract}/storage/", query.ToString()); var res = await query.GetAsync(); - Assert.True(res is DJsonObject); + Assert.True(res is DJsonArray); } [Fact] diff --git a/Netezos.Tests/Rpc/settings.json b/Netezos.Tests/Rpc/settings.json index 96fe026d..3a981439 100644 --- a/Netezos.Tests/Rpc/settings.json +++ b/Netezos.Tests/Rpc/settings.json @@ -1,7 +1,7 @@ { "node": "https://rpc.tzkt.io/mainnet/", - "testContract": "KT1WPEis2WhAc2FciM2tZVn8qe6pCBe9HkDp", - "testEntrypoint": "Action", + "testContract": "KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5", + "testEntrypoint": "default", "testDelegate": "tz3bvNMQ95vfAYtG8193ymshqjSvmxiCUuR5", "testInactive": "tz1bR8MFMyWSa428KRQcdShZFu9C4gEA4iFd", "testSmartRollup": "sr1M8qwvJuzmB5fgu4JFS2gtUvC3CBGs7TQx", diff --git a/Netezos.Tests/Rpc/settings_ithaca.json b/Netezos.Tests/Rpc/settings_ithaca.json index 0b91a7ec..800c7ed8 100644 --- a/Netezos.Tests/Rpc/settings_ithaca.json +++ b/Netezos.Tests/Rpc/settings_ithaca.json @@ -1,7 +1,7 @@ { "node": "https://rpc.tzkt.io/ithacanet/", - "testContract": "KT1GHz4zehbss9hxsYsTbppRgozXxaLJLM2R", - "testEntrypoint": "do", + "testContract": "KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5", + "testEntrypoint": "default", "testDelegate": "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9", "testInactive": "tz1Wn7JnLVf7PpTbaLQNzmNaF9z9UudWHGBR", "keyHash": "expru2dKqDfZG8hu4wNGkiyunvq2hdSKuVYtcKta7BWP6Q18oNxKjS", diff --git a/Netezos.Tests/Rpc/settings_oxford.json b/Netezos.Tests/Rpc/settings_oxford.json index dcdf5d95..1b03681a 100644 --- a/Netezos.Tests/Rpc/settings_oxford.json +++ b/Netezos.Tests/Rpc/settings_oxford.json @@ -1,6 +1,6 @@ { "node": "https://rpc.tzkt.io/oxfordnet/", - "testContract": "KT1XtHJBXF3aAwggHrZh1fUbzaHc5MmB6QDs", + "testContract": "KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5", "testEntrypoint": "default", "testDelegate": "tz1foXHgRzdYdaLgX6XhpZGxbBv42LZ6ubvE", "testInactive": "tz2Wjf3XgkgxWF4nMJM2cKqbgTQ8as7agMM2", diff --git a/Netezos.Tests/Rpc/settings_parisnet.json b/Netezos.Tests/Rpc/settings_parisnet.json new file mode 100644 index 00000000..df5eef3f --- /dev/null +++ b/Netezos.Tests/Rpc/settings_parisnet.json @@ -0,0 +1,10 @@ +{ + "node": "https://rpc.tzkt.io/parisnet/", + "testContract": "KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5", + "testEntrypoint": "default", + "testDelegate": "tz1gBnaS1n7LKqpaRnyBX5MSmamadXXfzNpt", + "testInactive": "tz2Vs8rfURNu4fQpQwhWc1sWgTqzZ9TW8mc8", + "testSmartRollup": "sr1QurxjyVCePny7i5kHWq1w8W95LsFLxUUk", + "keyHash": "exprvBfbrdZVCjkmcsJRpioTnZdos3RLMZUDTK2AyFURY423xuWX4N", + "bigMapId": "2" +} diff --git a/Netezos/Rpc/Queries/ContextQuery.cs b/Netezos/Rpc/Queries/ContextQuery.cs index f65ec94f..6656f189 100644 --- a/Netezos/Rpc/Queries/ContextQuery.cs +++ b/Netezos/Rpc/Queries/ContextQuery.cs @@ -1,4 +1,5 @@ -using Netezos.Rpc.Queries.Post; +using Netezos.Rpc.Queries.Dal; +using Netezos.Rpc.Queries.Post; namespace Netezos.Rpc.Queries { @@ -27,6 +28,11 @@ public class ContextQuery : RpcQuery /// public ContractsQuery Contracts => new(this, "contracts/"); + /// + /// Gets the query to Data-Availability Layer + /// + public DalQuery Dal => new(this, "dal/"); + /// /// Gets the query to all registered delegates /// diff --git a/Netezos/Rpc/Queries/ContractQuery.cs b/Netezos/Rpc/Queries/ContractQuery.cs index a924b7be..c454907f 100644 --- a/Netezos/Rpc/Queries/ContractQuery.cs +++ b/Netezos/Rpc/Queries/ContractQuery.cs @@ -8,7 +8,7 @@ namespace Netezos.Rpc.Queries public class ContractQuery : RpcObject { /// - /// Gets the query to the the complete list of tickets owned by the given contract by scanning the contract's storage. + /// Gets the query to the complete list of tickets owned by the given contract by scanning the contract's storage. /// public RpcObject AllTicketBalances => new(this, "all_ticket_balances/"); @@ -49,6 +49,11 @@ public class ContractQuery : RpcObject /// public EntrypointsQuery Entrypoints => new(this, "entrypoints/"); + /// + /// Gets the query to the estimated own pending slashed amount (in mutez) of a contract. + /// + public RpcObject EstimatedOwnPendingSlashedAmount => new(this, "estimated_own_pending_slashed_amount/"); + /// /// Gets the query to the frozen bonds of a contract. /// diff --git a/Netezos/Rpc/Queries/Dal/DalQuery.cs b/Netezos/Rpc/Queries/Dal/DalQuery.cs new file mode 100644 index 00000000..40d06f4f --- /dev/null +++ b/Netezos/Rpc/Queries/Dal/DalQuery.cs @@ -0,0 +1,23 @@ +namespace Netezos.Rpc.Queries.Dal +{ + public class DalQuery : RpcQuery + { + /// + /// Gets the query to the (currently last) DAL skip list cell if DAL is enabled, or [None] otherwise. + /// + public RpcObject CommitmentsHistory => new(this, "commitments_history/"); + + /// + /// Gets the query to the published slots headers for the given level. + /// + public PublishedSlotHeadersQuery PublishedSlotHeaders => new(this, "published_slot_headers/"); + + /// + /// Gets the query to the shards assignment for a given level (the default is the current level) and given + /// delegates (the default is all delegates) + /// + public ShardsQuery Shards => new(this, "shards/"); + + internal DalQuery(RpcQuery baseQuery, string append) : base(baseQuery, append) { } + } +} diff --git a/Netezos/Rpc/Queries/Dal/PublishedSlotHeadersQuery.cs b/Netezos/Rpc/Queries/Dal/PublishedSlotHeadersQuery.cs new file mode 100644 index 00000000..f2201922 --- /dev/null +++ b/Netezos/Rpc/Queries/Dal/PublishedSlotHeadersQuery.cs @@ -0,0 +1,19 @@ +namespace Netezos.Rpc.Queries.Dal; + +public class PublishedSlotHeadersQuery : RpcObject +{ + /// + /// Get the published slots headers for the current level. + /// + /// + public new Task GetAsync() => Client.GetJson(Query); + + /// + /// Get the published slots headers for the given level + /// + /// Level of the block + /// + public Task GetAsync(int level) => Client.GetJson($"{Query}?level={level}"); + + internal PublishedSlotHeadersQuery(RpcQuery baseQuery, string append) : base(baseQuery, append) { } +} diff --git a/Netezos/Rpc/Queries/Dal/ShardsQuery.cs b/Netezos/Rpc/Queries/Dal/ShardsQuery.cs new file mode 100644 index 00000000..c9c0a520 --- /dev/null +++ b/Netezos/Rpc/Queries/Dal/ShardsQuery.cs @@ -0,0 +1,19 @@ +namespace Netezos.Rpc.Queries.Dal; + +public class ShardsQuery : RpcObject +{ + /// + /// Get the shards assignment for a current level and all delegates. + /// + public new Task GetAsync() => Client.GetJson(Query); + + /// + /// Get the shards assignment for a given level and given delegates. + /// + /// Level of the block + /// A Secp256k1 or an Ed25519 public key hash (Base58Check-encoded) + public new Task GetAsync(int level, string delegates) + => Client.GetJson($"{Query}?level={level}&delegates={delegates}"); + + internal ShardsQuery(RpcQuery baseQuery, string append) : base(baseQuery, append) { } +} diff --git a/Netezos/Rpc/Queries/DelegateQuery.cs b/Netezos/Rpc/Queries/DelegateQuery.cs index 6355d635..c9c04938 100644 --- a/Netezos/Rpc/Queries/DelegateQuery.cs +++ b/Netezos/Rpc/Queries/DelegateQuery.cs @@ -22,8 +22,8 @@ public class DelegateQuery : RpcObject public RpcObject ConsensusKey => new(this, "consensus_key/"); /// - /// The baking power of a delegate, as computed from its current stake. This value is not used for computing baking rights - /// but only reflects the baking power that the delegate would have if a snapshot was taken at the current block. + /// The baking power of a delegate, as computed from its current stake. This value is not used for computing baking + /// rights but only reflects the baking power that the delegate would have if the cycle ended at the current block. /// public RpcObject CurrentBakingPower => new(this, "current_baking_power/"); @@ -52,6 +52,16 @@ public class DelegateQuery : RpcObject /// public RpcObject DelegatedContracts => new(this, "delegated_contracts/"); + /// + /// Gets the query to the pending denunciations for the given delegate. + /// + public RpcObject Denunciations => new(this, "denunciations/"); + + /// + /// Gets the query to the estimated shared pending slashed amount (in mutez) of a given delegate. + /// + public RpcObject EstimatedSharedPendingSlashedAmount => new(this, "estimated_shared_pending_slashed_amount/"); + /// /// Gets the query to the total frozen balances of a given delegate, this includes the frozen deposits, rewards and fees /// @@ -85,6 +95,17 @@ public class DelegateQuery : RpcObject /// public RpcObject GracePeriod => new(this, "grace_period/"); + /// + /// Gets the query that returns true if the delegate is forbidden to participate in consensus. + /// + public RpcObject IsForbidden => new(this, "is_forbidden/"); + + /// + /// Gets the query to the minimum of delegated tez (in mutez) over the current cycle and the block level where + /// this value was last updated. + /// + public RpcObject MinDelegatedInCurrentCycle => new(this, "min_delegated_in_current_cycle/"); + /// /// Returns cycle and level participation information. In particular this indicates, in the field 'expected_cycle_activity', /// the number of slots the delegate is expected to have in the cycle based on its active stake. The field 'minimal_cycle_activity' indicates the minimal endorsing slots in the cycle required to get endorsing rewards. diff --git a/Netezos/Rpc/Queries/HelpersQuery.cs b/Netezos/Rpc/Queries/HelpersQuery.cs index c7a2c7f7..39eb1486 100644 --- a/Netezos/Rpc/Queries/HelpersQuery.cs +++ b/Netezos/Rpc/Queries/HelpersQuery.cs @@ -18,6 +18,7 @@ public class HelpersQuery : RpcQuery /// /// Gets the query to the endorsing rights /// + [Obsolete("This RPC query is deprecated. Use it on early protocols only.")] public EndorsingRightsQuery EndorsingRights => new(this, "endorsing_rights"); /// diff --git a/Netezos/Rpc/Queries/IssuanceQuery.cs b/Netezos/Rpc/Queries/IssuanceQuery.cs index 2b54c1af..68a02c1c 100644 --- a/Netezos/Rpc/Queries/IssuanceQuery.cs +++ b/Netezos/Rpc/Queries/IssuanceQuery.cs @@ -16,7 +16,7 @@ public class IssuanceQuery : RpcQuery public RpcObject CurrentYearlyRateExact => new(this, "current_yearly_rate_exact/"); /// - /// Returns the expected issued tez for the provided block and the next five cycles. + /// Returns the expected issued tez for the provided block and the next 'consensus_rights_delay' cycles. /// public RpcObject ExpectedIssuance => new(this, "expected_issuance/"); diff --git a/Netezos/Rpc/Queries/RawContractQuery.cs b/Netezos/Rpc/Queries/RawContractQuery.cs index b40798d8..b3afbed1 100644 --- a/Netezos/Rpc/Queries/RawContractQuery.cs +++ b/Netezos/Rpc/Queries/RawContractQuery.cs @@ -67,6 +67,7 @@ public class RawContractQuery : DeepRpcObject /// /// Gets the query to the frozen deposits /// + [Obsolete("This RPC query was removed. Use it on early protocols only.")] public RpcObject FrozenDeposits => new(this, "frozen_deposits/"); /// diff --git a/Netezos/Rpc/Queries/SmartRollupQuery.cs b/Netezos/Rpc/Queries/SmartRollupQuery.cs index 46e7acd7..bb082f68 100644 --- a/Netezos/Rpc/Queries/SmartRollupQuery.cs +++ b/Netezos/Rpc/Queries/SmartRollupQuery.cs @@ -13,6 +13,7 @@ public class SmartRollupQuery : RpcObject /// /// Initial PVM state hash of smart rollup. /// + [Obsolete("This RPC query is deprecated. Use it on early protocols only.")] public RpcObject InitialPvmStateHash => new(this, "initial_pvm_state_hash/"); ///