From ec0da167850e40c6bf84c810f7ff2ab7bdd311c6 Mon Sep 17 00:00:00 2001 From: Dmitry Mirgaleev <35151170+dmirgaleev@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:09:33 +0300 Subject: [PATCH] Oxford (#59) * Init * Add RPC queries * Update SonarCloud * Add new built-in entrypoints encoding --------- Co-authored-by: Maksim Strebkov <257byte@gmail.com> --- .github/workflows/sonar.yml | 17 +- .../_smart_rollup_cement/forged.hex | 2 +- .../_smart_rollup_cement/unsigned.json | 3 +- Netezos.Tests/Netezos.Tests.csproj | 6 - Netezos.Tests/Rpc/SettingsFixture.cs | 2 + Netezos.Tests/Rpc/TestContextQueries.cs | 337 +++++++++++++++++- Netezos.Tests/Rpc/TestRawContextQueries.cs | 10 - Netezos.Tests/Rpc/settings.json | 1 + Netezos.Tests/Rpc/settings_oxford.json | 10 + Netezos/Forging/Local/ForgedReader.cs | 4 + .../Local/LocalForge.Forgers.Operations.cs | 3 +- Netezos/Forging/Local/LocalForge.Forgers.cs | 4 + .../Local/LocalForge.Unforgers.Operations.cs | 7 +- .../Operations/Content/SrCementContent.cs | 3 - Netezos/Rpc/Queries/ContextQuery.cs | 27 +- Netezos/Rpc/Queries/ContractQuery.cs | 49 +++ Netezos/Rpc/Queries/DelegateQuery.cs | 49 ++- Netezos/Rpc/Queries/IssuanceQuery.cs | 29 ++ .../Rpc/Queries/Post/TicketBalanceQuery.cs | 24 ++ Netezos/Rpc/Queries/RawContractQuery.cs | 1 + Netezos/Rpc/Queries/SmartRollupQuery.cs | 34 ++ Netezos/Rpc/Queries/SmartRollupsAllQuery.cs | 15 + Netezos/Rpc/Queries/SmartRollupsQuery.cs | 22 ++ Netezos/Rpc/Queries/StorageQuery.cs | 10 + 24 files changed, 614 insertions(+), 55 deletions(-) create mode 100644 Netezos.Tests/Rpc/settings_oxford.json create mode 100644 Netezos/Rpc/Queries/IssuanceQuery.cs create mode 100644 Netezos/Rpc/Queries/Post/TicketBalanceQuery.cs create mode 100644 Netezos/Rpc/Queries/SmartRollupQuery.cs create mode 100644 Netezos/Rpc/Queries/SmartRollupsAllQuery.cs create mode 100644 Netezos/Rpc/Queries/SmartRollupsQuery.cs diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml index ed8ff6c1..2aff9c22 100644 --- a/.github/workflows/sonar.yml +++ b/.github/workflows/sonar.yml @@ -12,22 +12,23 @@ jobs: runs-on: windows-latest if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} steps: - - name: Set up JDK 11 - uses: actions/setup-java@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: - java-version: 1.11 - - uses: actions/checkout@v2 + java-version: 17 + distribution: 'zulu' # Alternative distribution options are available. + - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Cache SonarCloud packages - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~\sonar\cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - name: Cache SonarCloud scanner id: cache-sonar-scanner - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: .\.sonar\scanner key: ${{ runner.os }}-sonar-scanner @@ -44,6 +45,6 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} shell: powershell run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"baking-bad_netezos" /o:"baking-bad" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + .\.sonar\scanner\dotnet-sonarscanner begin /k:"baking-bad_netezos" /o:"baking-bad" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" dotnet build - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ No newline at end of file + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" diff --git a/Netezos.Tests/Forging/operations/_smart_rollup_cement/forged.hex b/Netezos.Tests/Forging/operations/_smart_rollup_cement/forged.hex index dca9b456..4a0dd92b 100644 --- a/Netezos.Tests/Forging/operations/_smart_rollup_cement/forged.hex +++ b/Netezos.Tests/Forging/operations/_smart_rollup_cement/forged.hex @@ -1 +1 @@ -01e718a85baa15b9fe3b790c9243c7b6b30b2fba0c3ae9cf6f5b77bf1003d2b9ca00db887dcabb32df6cca7b1b9868a2c5c30b515930b205d20dd9270056c42edcfd8aa00947958add0ef0ff8dad2db54433fc3a7143ada987f9d9baa68f4a4aea7bc24eeb17bc6633185b5a03a00b70b3 \ No newline at end of file +01e718a85baa15b9fe3b790c9243c7b6b30b2fba0c3ae9cf6f5b77bf1003d2b9ca00db887dcabb32df6cca7b1b9868a2c5c30b515930b205d20dd9270056c42edcfd8aa00947958add0ef0ff8dad2db544 \ No newline at end of file diff --git a/Netezos.Tests/Forging/operations/_smart_rollup_cement/unsigned.json b/Netezos.Tests/Forging/operations/_smart_rollup_cement/unsigned.json index 43203cc8..164ab5ba 100644 --- a/Netezos.Tests/Forging/operations/_smart_rollup_cement/unsigned.json +++ b/Netezos.Tests/Forging/operations/_smart_rollup_cement/unsigned.json @@ -8,8 +8,7 @@ "counter": "1746", "gas_limit": "5081", "storage_limit": "0", - "rollup": "sr1Dx83Z5A5HtXqcyNeWWRSFNQsHrhnMEr9G", - "commitment": "src12sCt2773PKWveYdi4g16DcYNYEk3PPf5yFWV4vYMfvZek67Guo" + "rollup": "sr1Dx83Z5A5HtXqcyNeWWRSFNQsHrhnMEr9G" } ] } \ No newline at end of file diff --git a/Netezos.Tests/Netezos.Tests.csproj b/Netezos.Tests/Netezos.Tests.csproj index f8fc4c70..97bd6aa9 100644 --- a/Netezos.Tests/Netezos.Tests.csproj +++ b/Netezos.Tests/Netezos.Tests.csproj @@ -23,10 +23,4 @@ - - - PreserveNewest - - - diff --git a/Netezos.Tests/Rpc/SettingsFixture.cs b/Netezos.Tests/Rpc/SettingsFixture.cs index 8164a024..95d4990c 100644 --- a/Netezos.Tests/Rpc/SettingsFixture.cs +++ b/Netezos.Tests/Rpc/SettingsFixture.cs @@ -13,6 +13,7 @@ public class SettingsFixture : IDisposable public string TestEntrypoint { get; } public string TestDelegate { get; } public string TestInactive { get; } + public string TestSmartRollup { get; } public string KeyHash { get; } public int BigMapId { get; } @@ -27,6 +28,7 @@ public SettingsFixture() TestEntrypoint = settings.TestEntrypoint; TestDelegate = settings.TestDelegate; TestInactive = settings.TestInactive; + TestSmartRollup = settings.TestSmartRollup; KeyHash = settings.KeyHash; BigMapId = settings.BigMapId; } diff --git a/Netezos.Tests/Rpc/TestContextQueries.cs b/Netezos.Tests/Rpc/TestContextQueries.cs index 8a79f91d..0d7440f6 100644 --- a/Netezos.Tests/Rpc/TestContextQueries.cs +++ b/Netezos.Tests/Rpc/TestContextQueries.cs @@ -12,6 +12,7 @@ public class TestContextQueries : IClassFixture readonly string TestContract; readonly string TestEntrypoint; readonly string TestDelegate; + readonly string TestSmartRollup; readonly string KeyHash; readonly int BigMapId; @@ -21,10 +22,21 @@ public TestContextQueries(SettingsFixture settings) TestContract = settings.TestContract; TestEntrypoint = settings.TestEntrypoint; TestDelegate = settings.TestDelegate; + TestSmartRollup = settings.TestSmartRollup; KeyHash = settings.KeyHash; BigMapId = settings.BigMapId; } + [Fact] + public async Task TestContextAdaptiveIssuanceLaunch() + { + var query = Rpc.Blocks.Head.Context.AdaptiveIssuanceLaunch; + Assert.Equal($"chains/main/blocks/head/context/adaptive_issuance_launch_cycle/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + [Fact] public async Task TestContextBigMaps() { @@ -75,6 +87,16 @@ public async Task TestContextContract() Assert.True(res is DJsonObject); } + [Fact] + public async Task TestContextAllTicketBalances() + { + var query = Rpc.Blocks.Head.Context.Contracts[TestContract].AllTicketBalances; + Assert.Equal($"chains/main/blocks/head/context/contracts/{TestContract}/all_ticket_balances/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonArray); + } + [Fact] public async Task TestContextContractBalance() { @@ -85,6 +107,16 @@ public async Task TestContextContractBalance() Assert.True(res is DJsonValue); } + [Fact] + public async Task TestContextContractBalanceAndFrozenBonds() + { + var query = Rpc.Blocks.Head.Context.Contracts[TestContract].BalanceAndFrozenBonds; + Assert.Equal($"chains/main/blocks/head/context/contracts/{TestContract}/balance_and_frozen_bonds/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + [Fact] public async Task TestContextContractCounter() { @@ -98,8 +130,8 @@ public async Task TestContextContractCounter() [Fact] public async Task TestContextContractDelegate() { - var query = Rpc.Blocks.Head.Context.Contracts[TestContract].Delegate; - Assert.Equal($"chains/main/blocks/head/context/contracts/{TestContract}/delegate/", query.ToString()); + var query = Rpc.Blocks.Head.Context.Contracts[TestDelegate].Delegate; + Assert.Equal($"chains/main/blocks/head/context/contracts/{TestDelegate}/delegate/", query.ToString()); var res = await query.GetAsync(); Assert.True(res is DJsonValue); @@ -125,6 +157,26 @@ public async Task TestContextContractEntrypoint() Assert.True(res is DJsonObject); } + [Fact] + public async Task TestContextContractFrozenBonds() + { + var query = Rpc.Blocks.Head.Context.Contracts[TestContract].FrozenBonds; + Assert.Equal($"chains/main/blocks/head/context/contracts/{TestContract}/frozen_bonds/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + + [Fact] + public async Task TestContextContractFullBalance() + { + var query = Rpc.Blocks.Head.Context.Contracts[TestContract].FullBalance; + Assert.Equal($"chains/main/blocks/head/context/contracts/{TestContract}/full_balance/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + [Fact] public async Task TestContextContractManagerKey() { @@ -155,6 +207,16 @@ public async Task TestContextContractScriptNormalized() Assert.True(res is DJsonObject); } + [Fact] + public async Task TestContextContractStakedBalance() + { + var query = Rpc.Blocks.Head.Context.Contracts[TestDelegate].StakedBalance; + Assert.Equal($"chains/main/blocks/head/context/contracts/{TestDelegate}/staked_balance/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + [Fact] public async Task TestContextContractStorage() { @@ -175,6 +237,74 @@ public async Task TestContextContractStorageNormalized() Assert.True(res is DJsonObject); } + [Fact] + public async Task TestContextContractPaidSpace() + { + var query = Rpc.Blocks.Head.Context.Contracts[TestContract].Storage.PaidSpace; + Assert.Equal($"chains/main/blocks/head/context/contracts/{TestContract}/storage/paid_space/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + + [Fact] + public async Task TestContextContractUsedSpace() + { + var query = Rpc.Blocks.Head.Context.Contracts[TestContract].Storage.UsedSpace; + Assert.Equal($"chains/main/blocks/head/context/contracts/{TestContract}/storage/used_space/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + + [Fact] + public async Task TestContextContractTicketBalance() + { + var query = Rpc.Blocks.Head.Context.Contracts[TestContract].TicketBalance; + Assert.Equal($"chains/main/blocks/head/context/contracts/{TestContract}/ticket_balance/", query.ToString()); + + var res = await query.PostAsync("KT1XtHJBXF3aAwggHrZh1fUbzaHc5MmB6QDs", + new + { + prim = "int" + }, + new + { + @int = "1" + }); + Assert.True(res is DJsonValue); + } + + [Fact] + public async Task TestContextContractUnstakeRequests() + { + var query = Rpc.Blocks.Head.Context.Contracts[TestDelegate].UnstakeRequests; + Assert.Equal($"chains/main/blocks/head/context/contracts/{TestDelegate}/unstake_requests/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonObject); + } + + [Fact] + public async Task TestContextContractUnstakedFinalizableBalance() + { + var query = Rpc.Blocks.Head.Context.Contracts[TestDelegate].UnstakedFinalizableBalance; + Assert.Equal($"chains/main/blocks/head/context/contracts/{TestDelegate}/unstaked_finalizable_balance/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + + [Fact] + public async Task TestContextContractUnstakedFrozenBalance() + { + var query = Rpc.Blocks.Head.Context.Contracts[TestDelegate].UnstakedFrozenBalance; + Assert.Equal($"chains/main/blocks/head/context/contracts/{TestDelegate}/unstaked_frozen_balance/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + [Fact] public async Task TestContextDelegates() { @@ -201,6 +331,36 @@ public async Task TestContextDelegate() Assert.True(res is DJsonObject); } + [Fact] + public async Task TestContextDelegateActiveStakingParameters() + { + var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].ActiveStakingParameters; + Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/active_staking_parameters/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonObject); + } + + [Fact] + public async Task TestContextDelegateConsensusKey() + { + var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].ConsensusKey; + Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/consensus_key/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonObject); + } + + [Fact] + public async Task TestContextDelegateCurrentBakingPower() + { + var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].CurrentBakingPower; + Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/current_baking_power/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + [Fact] public async Task TestContextDelegateCurrentFrozenDeposits() { @@ -211,6 +371,16 @@ public async Task TestContextDelegateCurrentFrozenDeposits() Assert.True(res is DJsonValue); } + [Fact] + public async Task TestContextDelegateCurrentVotingPower() + { + var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].CurrentVotingPower; + Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/current_voting_power/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + [Fact] public async Task TestContextDelegateDeactivated() { @@ -250,17 +420,6 @@ public async Task TestContextDelegateFrozenDeposits() var res = await query.GetAsync(); Assert.True(res is DJsonValue); } - - [Fact] - public async Task TestContextDelegateFrozenDepositsLimit() - { - var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].FrozenDepositsLimit; - Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/frozen_deposits_limit/", query.ToString()); - - var res = await query.GetAsync(); - if (res != null) - Assert.True(res is DJsonValue); - } [Fact] public async Task TestContextDelegateFullBalance() @@ -283,7 +442,7 @@ public async Task TestContextDelegateGracePeriod() } [Fact] - public async Task TestContextDelegatParticipation() + public async Task TestContextDelegateParticipation() { var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].Participation; Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/participation/", query.ToString()); @@ -292,6 +451,16 @@ public async Task TestContextDelegatParticipation() Assert.True(res is DJsonObject); } + [Fact] + public async Task TestContextDelegatePendingStakingParameters() + { + var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].PendingStakingParameters; + Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/pending_staking_parameters/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonArray); + } + [Fact] public async Task TestContextDelegateStakingBalance() { @@ -302,6 +471,16 @@ public async Task TestContextDelegateStakingBalance() Assert.True(res is DJsonValue); } + [Fact] + public async Task TestContextDelegateUnstakedFrozenDeposits() + { + var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].UnstakedFrozenDeposits; + Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/unstaked_frozen_deposits/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonArray); + } + [Fact] public async Task TestContextDelegateVotingPower() { @@ -312,6 +491,56 @@ public async Task TestContextDelegateVotingPower() Assert.True(res is DJsonValue); } + [Fact] + public async Task TestContextDelegateVotingInfo() + { + var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].VotingInfo; + Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/voting_info/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonObject); + } + + [Fact] + public async Task TestContextIssuanceCurrentYearlyRate() + { + var query = Rpc.Blocks.Head.Context.Issuance.CurrentYearlyRate; + Assert.Equal($"chains/main/blocks/head/context/issuance/current_yearly_rate/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + + [Fact] + public async Task TestContextIssuanceCurrentYearlyRateExact() + { + var query = Rpc.Blocks.Head.Context.Issuance.CurrentYearlyRateExact; + Assert.Equal($"chains/main/blocks/head/context/issuance/current_yearly_rate_exact/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonObject); + } + + [Fact] + public async Task TestContextIssuanceExpectedIssuance() + { + var query = Rpc.Blocks.Head.Context.Issuance.ExpectedIssuance; + Assert.Equal($"chains/main/blocks/head/context/issuance/expected_issuance/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonArray); + } + + [Fact] + public async Task TestContextIssuanceIssuancePerMinute() + { + var query = Rpc.Blocks.Head.Context.Issuance.IssuancePerMinute; + Assert.Equal($"chains/main/blocks/head/context/issuance/issuance_per_minute/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + [Fact] public async Task TestContextNonces() { @@ -334,5 +563,85 @@ public async Task TestContextSeed() var res = await query.PostAsync(query); Assert.True(res is DJsonValue); } + + [Fact] + public async Task TestContextSmartRollupsAll() + { + var query = Rpc.Blocks.Head.Context.SmartRollups.All; + Assert.Equal($"chains/main/blocks/head/context/smart_rollups/all/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonArray); + } + + [Fact] + public async Task TestContextSmartRollupGenesisInfo() + { + var query = Rpc.Blocks.Head.Context.SmartRollups[TestSmartRollup].GenesisInfo; + Assert.Equal($"chains/main/blocks/head/context/smart_rollups/smart_rollup/{TestSmartRollup}/genesis_info/", query.ToString()); + + var res = await query.GetAsync(); + 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() + { + var query = Rpc.Blocks.Head.Context.SmartRollups[TestSmartRollup].Kind; + Assert.Equal($"chains/main/blocks/head/context/smart_rollups/smart_rollup/{TestSmartRollup}/kind/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + + [Fact] + public async Task TestContextSmartRollupLastCementedCommitmentHashWithLevel() + { + var query = Rpc.Blocks.Head.Context.SmartRollups[TestSmartRollup].LastCementedCommitmentHashWithLevel; + Assert.Equal($"chains/main/blocks/head/context/smart_rollups/smart_rollup/{TestSmartRollup}/last_cemented_commitment_hash_with_level/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonObject); + } + + [Fact] + public async Task TestContextSmartRollupStakers() + { + var query = Rpc.Blocks.Head.Context.SmartRollups[TestSmartRollup].Stakers; + Assert.Equal($"chains/main/blocks/head/context/smart_rollups/smart_rollup/{TestSmartRollup}/stakers/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonArray); + } + + [Fact] + public async Task TestContextTotalFrozenStake() + { + var query = Rpc.Blocks.Head.Context.TotalFrozenStake; + Assert.Equal($"chains/main/blocks/head/context/total_frozen_stake/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } + + [Fact] + public async Task TestContextTotalSupply() + { + var query = Rpc.Blocks.Head.Context.TotalSupply; + Assert.Equal($"chains/main/blocks/head/context/total_supply/", query.ToString()); + + var res = await query.GetAsync(); + Assert.True(res is DJsonValue); + } } } diff --git a/Netezos.Tests/Rpc/TestRawContextQueries.cs b/Netezos.Tests/Rpc/TestRawContextQueries.cs index 07f48eb4..d3355996 100644 --- a/Netezos.Tests/Rpc/TestRawContextQueries.cs +++ b/Netezos.Tests/Rpc/TestRawContextQueries.cs @@ -148,16 +148,6 @@ public async Task TestRawContextContractDelegateDesactivation() Assert.True(res is DJsonValue); } - [Fact] - public async Task TestRawContextContractInactiveDelegate() - { - var query = Rpc.Blocks.Head.Context.Raw.Contracts[TestInactive].InactiveDelegate; - Assert.Equal($"chains/main/blocks/head/context/raw/json/contracts/index/{TestInactive}/inactive_delegate/", query.ToString()); - - var res = await query.GetAsync(); - Assert.True(res is DJsonValue); - } - [Fact] public async Task TestRawContextContractDelegated() { diff --git a/Netezos.Tests/Rpc/settings.json b/Netezos.Tests/Rpc/settings.json index 646566d0..96fe026d 100644 --- a/Netezos.Tests/Rpc/settings.json +++ b/Netezos.Tests/Rpc/settings.json @@ -4,6 +4,7 @@ "testEntrypoint": "Action", "testDelegate": "tz3bvNMQ95vfAYtG8193ymshqjSvmxiCUuR5", "testInactive": "tz1bR8MFMyWSa428KRQcdShZFu9C4gEA4iFd", + "testSmartRollup": "sr1M8qwvJuzmB5fgu4JFS2gtUvC3CBGs7TQx", "keyHash": "exprujtiEkpbwKbqaTSdmCFqQDn7qeupsA1QijNmw2GHfVW5PexFvz", "bigMapId": "9563" } \ No newline at end of file diff --git a/Netezos.Tests/Rpc/settings_oxford.json b/Netezos.Tests/Rpc/settings_oxford.json new file mode 100644 index 00000000..dcdf5d95 --- /dev/null +++ b/Netezos.Tests/Rpc/settings_oxford.json @@ -0,0 +1,10 @@ +{ + "node": "https://rpc.tzkt.io/oxfordnet/", + "testContract": "KT1XtHJBXF3aAwggHrZh1fUbzaHc5MmB6QDs", + "testEntrypoint": "default", + "testDelegate": "tz1foXHgRzdYdaLgX6XhpZGxbBv42LZ6ubvE", + "testInactive": "tz2Wjf3XgkgxWF4nMJM2cKqbgTQ8as7agMM2", + "testSmartRollup": "sr1ANUAuGgaDVKhsjyWLNWYkyZ4U1HojZ15H", + "keyHash": "expruaHzyjwFcmFKHqR49qdxwJupAna6ygSKo2mFJQtqZQjid5t8GK", + "bigMapId": "99" +} \ No newline at end of file diff --git a/Netezos/Forging/Local/ForgedReader.cs b/Netezos/Forging/Local/ForgedReader.cs index 44160e84..0b087a98 100644 --- a/Netezos/Forging/Local/ForgedReader.cs +++ b/Netezos/Forging/Local/ForgedReader.cs @@ -285,6 +285,10 @@ public string ReadEntrypoint() 3 => "set_delegate", 4 => "remove_delegate", 5 => "deposit", + 6 => "stake", + 7 => "unstake", + 8 => "finalize_unstake", + 9 => "set_delegate_parameters", 255 => ReadString(), var ep => throw new ArgumentException($"Invalid entrypoint prefix {ep}") }; diff --git a/Netezos/Forging/Local/LocalForge.Forgers.Operations.cs b/Netezos/Forging/Local/LocalForge.Forgers.Operations.cs index 90fc04e1..76fbb7de 100644 --- a/Netezos/Forging/Local/LocalForge.Forgers.Operations.cs +++ b/Netezos/Forging/Local/LocalForge.Forgers.Operations.cs @@ -413,8 +413,7 @@ static byte[] ForgeSrCement(SrCementContent operation) ForgeMicheNat(operation.Counter), ForgeMicheNat(operation.GasLimit), ForgeMicheNat(operation.StorageLimit), - ForgeRollup(operation.Rollup), - ForgeCommitment(operation.Commitment)); + ForgeRollup(operation.Rollup)); } static byte[] ForgeSrTimeout(SrTmieoutContent operation) diff --git a/Netezos/Forging/Local/LocalForge.Forgers.cs b/Netezos/Forging/Local/LocalForge.Forgers.cs index 3c173583..de952ce3 100644 --- a/Netezos/Forging/Local/LocalForge.Forgers.cs +++ b/Netezos/Forging/Local/LocalForge.Forgers.cs @@ -186,6 +186,10 @@ public static byte[] ForgeEntrypoint(string value) "set_delegate" => new byte[] { 3 }, "remove_delegate" => new byte[] { 4 }, "deposit" => new byte[] { 5 }, + "stake" => new byte[] { 6 }, + "unstake" => new byte[] { 7 }, + "finalize_unstake" => new byte[] { 8 }, + "set_delegate_parameters" => new byte[] { 9 }, _ => new byte[] { 255 }.Concat(ForgeString(value, 1)) }; } diff --git a/Netezos/Forging/Local/LocalForge.Unforgers.Operations.cs b/Netezos/Forging/Local/LocalForge.Unforgers.Operations.cs index 0e0cecf7..8da614b6 100644 --- a/Netezos/Forging/Local/LocalForge.Unforgers.Operations.cs +++ b/Netezos/Forging/Local/LocalForge.Unforgers.Operations.cs @@ -436,8 +436,7 @@ static SrCementContent UnforgeSrCement(ForgedReader reader) Counter = (int)reader.ReadUBigInt(), GasLimit = (int)reader.ReadUBigInt(), StorageLimit = (int)reader.ReadUBigInt(), - Rollup = reader.ReadRollup(), - Commitment = reader.ReadCommitmentAddress() + Rollup = reader.ReadRollup() }; } @@ -608,6 +607,10 @@ static string UnforgeEntrypoint(ForgedReader reader) 3 => "set_delegate", 4 => "remove_delegate", 5 => "deposit", + 6 => "stake", + 7 => "unstake", + 8 => "finalize_unstake", + 9 => "set_delegate_parameters", 255 => reader.ReadString(1), var ep => throw new ArgumentException($"Unrecognized endpoint type {ep}") }; diff --git a/Netezos/Forging/Models/Operations/Content/SrCementContent.cs b/Netezos/Forging/Models/Operations/Content/SrCementContent.cs index fda8e806..016a1814 100644 --- a/Netezos/Forging/Models/Operations/Content/SrCementContent.cs +++ b/Netezos/Forging/Models/Operations/Content/SrCementContent.cs @@ -9,8 +9,5 @@ public class SrCementContent : ManagerOperationContent [JsonPropertyName("rollup")] public string Rollup { get; set; } = null!; - - [JsonPropertyName("commitment")] - public string Commitment { get; set; } = null!; } } \ No newline at end of file diff --git a/Netezos/Rpc/Queries/ContextQuery.cs b/Netezos/Rpc/Queries/ContextQuery.cs index 5010e1a3..f65ec94f 100644 --- a/Netezos/Rpc/Queries/ContextQuery.cs +++ b/Netezos/Rpc/Queries/ContextQuery.cs @@ -8,7 +8,12 @@ namespace Netezos.Rpc.Queries public class ContextQuery : RpcQuery { /// - /// Gets the query to the protocol's constants + /// Gets the query to get the cycle at which the launch of the Adaptive Issuance feature is set to happen. A result of None means that the feature is not yet set to launch. + /// + public RpcObject AdaptiveIssuanceLaunch => new(this, "adaptive_issuance_launch_cycle/"); + + /// + /// Gets the query to big maps. /// public RpcSimpleArray> BigMaps => new(this, "big_maps/"); @@ -27,6 +32,11 @@ public class ContextQuery : RpcQuery /// public DelegatesQuery Delegates => new(this, "delegates/"); + /// + /// Gets the query to the issuance data + /// + public IssuanceQuery Issuance => new(this, "issuance/"); + /// /// Gets the query to the info about the nonce of a previous block /// @@ -41,6 +51,21 @@ public class ContextQuery : RpcQuery /// Gets the query to the seed data /// public SeedQuery Seed => new(this, "seed"); + + /// + /// Gets the query to the smart rollup data + /// + public SmartRollupsQuery SmartRollups => new(this, "smart_rollups/"); + + /// + /// Returns the total stake (in mutez) frozen on the chain. + /// + public RpcObject TotalFrozenStake => new(this, "total_frozen_stake/"); + + /// + /// Returns the total supply (in mutez) available on the chain. + /// + public RpcObject TotalSupply => new(this, "total_supply/"); internal ContextQuery(RpcQuery baseQuery, string append) : base(baseQuery, append) { } } diff --git a/Netezos/Rpc/Queries/ContractQuery.cs b/Netezos/Rpc/Queries/ContractQuery.cs index bdc6ea0f..a924b7be 100644 --- a/Netezos/Rpc/Queries/ContractQuery.cs +++ b/Netezos/Rpc/Queries/ContractQuery.cs @@ -7,10 +7,20 @@ 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. + /// + public RpcObject AllTicketBalances => new(this, "all_ticket_balances/"); + /// /// Gets the query to the balance of a contract /// public RpcObject Balance => new(this, "balance/"); + + /// + /// Gets the query to the sum of the spendable balance and frozen bonds of a contract. + /// + public RpcObject BalanceAndFrozenBonds => new(this, "balance_and_frozen_bonds/"); /// /// Gets the query to the value associated with a key in the big map storage of the contract @@ -39,6 +49,16 @@ public class ContractQuery : RpcObject /// public EntrypointsQuery Entrypoints => new(this, "entrypoints/"); + /// + /// Gets the query to the frozen bonds of a contract. + /// + public RpcObject FrozenBonds => new(this, "frozen_bonds/"); + + /// + /// Gets the query to the full balance of a contract, including frozen bonds and stake. + /// + public RpcObject FullBalance => new(this, "full_balance/"); + /// /// Gets the query to the manager of a contract /// @@ -55,6 +75,11 @@ public class ContractQuery : RpcObject /// public ScriptQuery Script => new(this, "script/"); + /// + /// Gets the query to the staked balance of a contract. Returns None if the contract is originated, or neither delegated nor a delegate. + /// + public RpcObject StakedBalance => new(this, "staked_balance/"); + /// /// Gets the query to the flag, indicating if the contract tokens can be spent by the manager /// @@ -66,6 +91,30 @@ public class ContractQuery : RpcObject /// public StorageQuery Storage => new(this, "storage/"); + /// + /// Gets the contract's balance of ticket with specified ticketer, content type, and content. + /// + public TicketBalanceQuery TicketBalance => new(this, "ticket_balance/"); + + /// + /// Gets the unstake requests of the contract. The requests that appear in the finalizable field can be finalized, + /// which means that the contract can transfer these (no longer frozen) funds to their spendable balance with a [finalize_unstake] operation call. + /// + public RpcObject UnstakeRequests => new(this, "unstake_requests/"); + + /// + /// Gets the balance of a contract that was requested for an unstake operation, and is no longer frozen, + /// which means it will appear in the spendable balance of the contract after any stake/unstake/finalize_unstake operation. + /// Returns None if the contract is originated. + /// + public RpcObject UnstakedFinalizableBalance => new(this, "unstaked_finalizable_balance/"); + + /// + /// Gets the balance of a contract that was requested for an unstake operation, but is still frozen for the duration of the slashing period. + /// Returns None if the contract is originated. + /// + public RpcObject UnstakedFrozenBalance => new(this, "unstaked_frozen_balance/"); + internal ContractQuery(RpcQuery baseQuery, string append) : base(baseQuery, append) { } } } diff --git a/Netezos/Rpc/Queries/DelegateQuery.cs b/Netezos/Rpc/Queries/DelegateQuery.cs index 8df625ac..6355d635 100644 --- a/Netezos/Rpc/Queries/DelegateQuery.cs +++ b/Netezos/Rpc/Queries/DelegateQuery.cs @@ -6,20 +6,36 @@ public class DelegateQuery : RpcObject { /// - /// Returns the current amount of the frozen deposits (in mutez). + /// Returns the currently active staking parameters for the given delegate. /// - public RpcObject CurrentFrozenDeposits => new(this, "current_frozen_deposits/"); - + public RpcObject ActiveStakingParameters => new(this, "active_staking_parameters/"); + /// /// Gets the query to the full balance of a given delegate, including the frozen balances /// [Obsolete("This RPC query was removed. Use it on early protocols only.")] public RpcObject Balance => new(this, "balance/"); - + /// - /// Gets the query to the full balance of a given delegate, including the frozen balances + /// The active consensus key for a given delegate and the pending consensus keys. /// - public RpcObject FullBalance => new(this, "full_balance/"); + 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. + /// + public RpcObject CurrentBakingPower => new(this, "current_baking_power/"); + + /// + /// Returns the current amount of the frozen deposits (in mutez). + /// + public RpcObject CurrentFrozenDeposits => new(this, "current_frozen_deposits/"); + + /// + /// The voting power of a given delegate, as computed from its current stake. + /// + public RpcObject CurrentVotingPower => new(this, "current_voting_power/"); /// /// Gets the query to the flag, indicating whether the delegate is currently tagged as deactivated or not @@ -56,8 +72,14 @@ public class DelegateQuery : RpcObject /// /// Returns the frozen deposits limit for the given delegate or none if no limit is set. /// + [Obsolete("This RPC query was removed. Use it on early protocols only.")] public RpcObject FrozenDepositsLimit => new(this, "frozen_deposits_limit/"); + /// + /// Gets the query to the full balance of a given delegate, including the frozen balances + /// + public RpcObject FullBalance => new(this, "full_balance/"); + /// /// Gets the query to the cycle by the end of which the delegate might be deactivated if he fails to execute any delegate action /// @@ -72,11 +94,26 @@ public class DelegateQuery : RpcObject /// public RpcObject Participation => new(this, "participation/"); + /// + /// Returns the pending values for the given delegate's staking parameters. + /// + public RpcObject PendingStakingParameters => new(this, "pending_staking_parameters/"); + /// /// Gets the query to the total amount of tokens delegated to a given delegate, including the balance of the delegate itself and its frozen fees and deposits /// public RpcObject StakingBalance => new(this, "staking_balance/"); + /// + /// Returns, for each cycle, the sum of unstaked-but-frozen deposits for this cycle. Cycles go from the last unslashable cycle to the current cycle. + /// + public RpcObject UnstakedFrozenDeposits => new(this, "unstaked_frozen_deposits/"); + + /// + /// The number of rolls in the vote listings for a given delegate + /// + public RpcObject VotingInfo => new(this, "voting_info/"); + /// /// The number of rolls in the vote listings for a given delegate /// diff --git a/Netezos/Rpc/Queries/IssuanceQuery.cs b/Netezos/Rpc/Queries/IssuanceQuery.cs new file mode 100644 index 00000000..2b54c1af --- /dev/null +++ b/Netezos/Rpc/Queries/IssuanceQuery.cs @@ -0,0 +1,29 @@ +namespace Netezos.Rpc.Queries; + +/// +/// Rpc query to access issuance data +/// +public class IssuanceQuery : RpcQuery +{ + /// + /// Returns the current expected maximum yearly issuance rate (in %). + /// + public RpcObject CurrentYearlyRate => new(this, "current_yearly_rate/"); + + /// + /// Returns the current expected maximum yearly issuance rate (exact quotient). + /// + public RpcObject CurrentYearlyRateExact => new(this, "current_yearly_rate_exact/"); + + /// + /// Returns the expected issued tez for the provided block and the next five cycles. + /// + public RpcObject ExpectedIssuance => new(this, "expected_issuance/"); + + /// + /// Returns the current expected maximum issuance per minute (in mutez). + /// + public RpcObject IssuancePerMinute => new(this, "issuance_per_minute/"); + + internal IssuanceQuery(RpcQuery baseQuery, string append) : base(baseQuery, append) { } +} \ No newline at end of file diff --git a/Netezos/Rpc/Queries/Post/TicketBalanceQuery.cs b/Netezos/Rpc/Queries/Post/TicketBalanceQuery.cs new file mode 100644 index 00000000..737f9905 --- /dev/null +++ b/Netezos/Rpc/Queries/Post/TicketBalanceQuery.cs @@ -0,0 +1,24 @@ +namespace Netezos.Rpc.Queries.Post; + +/// +/// Rpc query to access the contract's balance of ticket with specified ticketer, content type, and content. +/// +public class TicketBalanceQuery : RpcMethod +{ + internal TicketBalanceQuery(RpcQuery baseQuery, string append) : base(baseQuery, append) { } + + /// + /// Gets the contract's balance of ticket with specified ticketer, content type, and content. + /// + /// Ticketer contract + /// Ticket content type + /// Ticket content + /// + public Task PostAsync(string ticketer, object contentType, object content) + => PostAsync(new + { + ticketer, + content_type = contentType, + content + }); +} \ No newline at end of file diff --git a/Netezos/Rpc/Queries/RawContractQuery.cs b/Netezos/Rpc/Queries/RawContractQuery.cs index bedab069..b40798d8 100644 --- a/Netezos/Rpc/Queries/RawContractQuery.cs +++ b/Netezos/Rpc/Queries/RawContractQuery.cs @@ -50,6 +50,7 @@ public class RawContractQuery : DeepRpcObject /// /// /// + [Obsolete("This RPC query was removed. Use it on early protocols only.")] public RpcObject InactiveDelegate => new(this, "inactive_delegate/"); /// diff --git a/Netezos/Rpc/Queries/SmartRollupQuery.cs b/Netezos/Rpc/Queries/SmartRollupQuery.cs new file mode 100644 index 00000000..46e7acd7 --- /dev/null +++ b/Netezos/Rpc/Queries/SmartRollupQuery.cs @@ -0,0 +1,34 @@ +namespace Netezos.Rpc.Queries; + +/// +/// Rpc query to access contract data +/// +public class SmartRollupQuery : RpcObject +{ + /// + /// Genesis information (level and commitment hash) for a smart rollup. + /// + public RpcObject GenesisInfo => new(this, "genesis_info/"); + + /// + /// Initial PVM state hash of smart rollup. + /// + public RpcObject InitialPvmStateHash => new(this, "initial_pvm_state_hash/"); + + /// + /// Kind of smart rollup. + /// + public RpcObject Kind => new(this, "kind/"); + + /// Level and hash of the last cemented commitment for a smart rollup. + /// + public RpcObject LastCementedCommitmentHashWithLevel => new(this, "last_cemented_commitment_hash_with_level/"); + + /// List of active stakers' public key hashes of a rollup. + /// + public RpcObject Stakers => new(this, "stakers/"); + + /// + + internal SmartRollupQuery(RpcQuery baseQuery, string append) : base(baseQuery, append) { } +} \ No newline at end of file diff --git a/Netezos/Rpc/Queries/SmartRollupsAllQuery.cs b/Netezos/Rpc/Queries/SmartRollupsAllQuery.cs new file mode 100644 index 00000000..56d83593 --- /dev/null +++ b/Netezos/Rpc/Queries/SmartRollupsAllQuery.cs @@ -0,0 +1,15 @@ +namespace Netezos.Rpc.Queries; + +/// +/// Rpc query to access to all smart rollups data +/// +public class SmartRollupsAllQuery : RpcObject +{ + /// + /// Returns the inbox for the smart rollups. + /// + public RpcObject Inbox => new(this, "inbox/"); + + internal SmartRollupsAllQuery(RpcQuery baseQuery, string append) : base(baseQuery, append) { } + +} \ No newline at end of file diff --git a/Netezos/Rpc/Queries/SmartRollupsQuery.cs b/Netezos/Rpc/Queries/SmartRollupsQuery.cs new file mode 100644 index 00000000..cfb0d4b8 --- /dev/null +++ b/Netezos/Rpc/Queries/SmartRollupsQuery.cs @@ -0,0 +1,22 @@ +namespace Netezos.Rpc.Queries; + +/// +/// Rpc query to access the smart rollups data +/// +public class SmartRollupsQuery : RpcQuery +{ + /// + /// Returns the currently active staking parameters for the given delegate. + /// + public SmartRollupsAllQuery All => new(this, "all/"); + + /// + /// Rpc query to access a smart rollup + /// + /// Address of the smart rollup + /// + public SmartRollupQuery this[string address] => new(this, $"smart_rollup/{address}/"); + + internal SmartRollupsQuery(RpcQuery baseQuery, string append) : base(baseQuery, append) { } + +} \ No newline at end of file diff --git a/Netezos/Rpc/Queries/StorageQuery.cs b/Netezos/Rpc/Queries/StorageQuery.cs index 4aab5cc1..57880ca9 100644 --- a/Netezos/Rpc/Queries/StorageQuery.cs +++ b/Netezos/Rpc/Queries/StorageQuery.cs @@ -11,6 +11,16 @@ public class StorageQuery : RpcObject /// Access the data of the contract and normalize it using the requested unparsing mode. /// public NormalizedQuery Normalized => new(this, "normalized/"); + + /// + /// Access the paid storage space of the contract. + /// + public RpcObject PaidSpace => new(this, "paid_space/"); + + /// + /// Access the used storage space of the contract. + /// + public RpcObject UsedSpace => new(this, "used_space/"); internal StorageQuery(RpcQuery baseQuery, string append) : base(baseQuery, append) { } }