Skip to content

Commit 439da5a

Browse files
authored
Update RPC spec for Octez v21.2 (#62)
1 parent 75fe417 commit 439da5a

File tree

6 files changed

+249
-60
lines changed

6 files changed

+249
-60
lines changed

Netezos.Tests/Rpc/TestContextQueries.cs

Lines changed: 108 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,26 @@ public async Task TestContextContractStakedBalance()
228228
Assert.True(res is DJsonValue);
229229
}
230230

231+
[Fact]
232+
public async Task TestContextContractSpendable()
233+
{
234+
var query = Rpc.Blocks.Head.Context.Contracts[TestContract].Spendable;
235+
Assert.Equal($"chains/main/blocks/head/context/contracts/{TestContract}/spendable/", query.ToString());
236+
237+
var res = await query.GetAsync();
238+
Assert.True(res is DJsonValue);
239+
}
240+
241+
[Fact]
242+
public async Task TestContextContractSpendableAndFrozenBonds()
243+
{
244+
var query = Rpc.Blocks.Head.Context.Contracts[TestContract].SpendableAndFrozenBonds;
245+
Assert.Equal($"chains/main/blocks/head/context/contracts/{TestContract}/spendable_and_frozen_bonds/", query.ToString());
246+
247+
var res = await query.GetAsync();
248+
Assert.True(res is DJsonValue);
249+
}
250+
231251
[Fact]
232252
public async Task TestContextContractStorage()
233253
{
@@ -383,73 +403,73 @@ public async Task TestContextDelegateActiveStakingParameters()
383403
}
384404

385405
[Fact]
386-
public async Task TestContextDelegateConsensusKey()
406+
public async Task TestContextDelegateBakingPower()
387407
{
388-
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].ConsensusKey;
389-
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/consensus_key/", query.ToString());
408+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].BakingPower;
409+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/baking_power/", query.ToString());
390410

391411
var res = await query.GetAsync();
392-
Assert.True(res is DJsonObject);
412+
Assert.True(res is DJsonValue);
393413
}
394414

395415
[Fact]
396-
public async Task TestContextDelegateCurrentBakingPower()
416+
public async Task TestContextDelegateDelegators()
397417
{
398-
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].CurrentBakingPower;
399-
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/current_baking_power/", query.ToString());
418+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].Delegators;
419+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/delegators/", query.ToString());
400420

401421
var res = await query.GetAsync();
402-
Assert.True(res is DJsonValue);
422+
Assert.True(res is DJsonArray);
403423
}
404424

405425
[Fact]
406-
public async Task TestContextDelegateCurrentFrozenDeposits()
426+
public async Task TestContextDelegateExternalDelegated()
407427
{
408-
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].CurrentFrozenDeposits;
409-
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/current_frozen_deposits/", query.ToString());
428+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].ExternalDelegated;
429+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/external_delegated/", query.ToString());
410430

411431
var res = await query.GetAsync();
412432
Assert.True(res is DJsonValue);
413433
}
414434

415435
[Fact]
416-
public async Task TestContextDelegateCurrentVotingPower()
436+
public async Task TestContextDelegateExternalStaked()
417437
{
418-
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].CurrentVotingPower;
419-
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/current_voting_power/", query.ToString());
438+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].ExternalStaked;
439+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/external_staked/", query.ToString());
420440

421441
var res = await query.GetAsync();
422442
Assert.True(res is DJsonValue);
423443
}
424444

425445
[Fact]
426-
public async Task TestContextDelegateDeactivated()
446+
public async Task TestContextDelegateConsensusKey()
427447
{
428-
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].Deactivated;
429-
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/deactivated/", query.ToString());
448+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].ConsensusKey;
449+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/consensus_key/", query.ToString());
430450

431451
var res = await query.GetAsync();
432-
Assert.True(res is DJsonValue);
452+
Assert.True(res is DJsonObject);
433453
}
434454

435455
[Fact]
436-
public async Task TestContextDelegateDelegatedBalance()
456+
public async Task TestContextDelegateCurrentVotingPower()
437457
{
438-
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].DelegatedBalance;
439-
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/delegated_balance/", query.ToString());
458+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].CurrentVotingPower;
459+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/current_voting_power/", query.ToString());
440460

441461
var res = await query.GetAsync();
442462
Assert.True(res is DJsonValue);
443463
}
444464

445465
[Fact]
446-
public async Task TestContextDelegateDelegatedContracts()
466+
public async Task TestContextDelegateDeactivated()
447467
{
448-
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].DelegatedContracts;
449-
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/delegated_contracts/", query.ToString());
468+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].Deactivated;
469+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/deactivated/", query.ToString());
450470

451471
var res = await query.GetAsync();
452-
Assert.True(res is DJsonArray);
472+
Assert.True(res is DJsonValue);
453473
}
454474

455475
[Fact]
@@ -473,6 +493,16 @@ public async Task TestContextDelegateEstimatedSharedPendingSlashedAmount()
473493
Assert.True(res is DJsonValue);
474494
}
475495

496+
[Fact]
497+
public async Task TestContextDelegateGracePeriod()
498+
{
499+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].GracePeriod;
500+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/grace_period/", query.ToString());
501+
502+
var res = await query.GetAsync();
503+
Assert.True(res is DJsonValue);
504+
}
505+
476506
[Fact]
477507
public async Task TestContextDelegateIsForbidden()
478508
{
@@ -495,30 +525,30 @@ public async Task TestContextDelegateMinDelegatedInCurrentCycle()
495525
}
496526

497527
[Fact]
498-
public async Task TestContextDelegateFrozenDeposits()
528+
public async Task TestContextDelegateOwnDelegated()
499529
{
500-
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].FrozenDeposits;
501-
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/frozen_deposits/", query.ToString());
530+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].OwnDelegated;
531+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/own_delegated/", query.ToString());
502532

503533
var res = await query.GetAsync();
504534
Assert.True(res is DJsonValue);
505535
}
506-
536+
507537
[Fact]
508-
public async Task TestContextDelegateFullBalance()
538+
public async Task TestContextDelegateOwnFullBalance()
509539
{
510-
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].FullBalance;
511-
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/full_balance/", query.ToString());
540+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].OwnFullBalance;
541+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/own_full_balance/", query.ToString());
512542

513543
var res = await query.GetAsync();
514544
Assert.True(res is DJsonValue);
515545
}
516546

517547
[Fact]
518-
public async Task TestContextDelegateGracePeriod()
548+
public async Task TestContextDelegateOwnStaked()
519549
{
520-
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].GracePeriod;
521-
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/grace_period/", query.ToString());
550+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].OwnStaked;
551+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/own_staked/", query.ToString());
522552

523553
var res = await query.GetAsync();
524554
Assert.True(res is DJsonValue);
@@ -555,10 +585,30 @@ public async Task TestContextDelegateStakingBalance()
555585
}
556586

557587
[Fact]
558-
public async Task TestContextDelegateUnstakedFrozenDeposits()
588+
public async Task TestContextDelegateTotalDelegated()
589+
{
590+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].TotalDelegated;
591+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/total_delegated/", query.ToString());
592+
593+
var res = await query.GetAsync();
594+
Assert.True(res is DJsonValue);
595+
}
596+
597+
[Fact]
598+
public async Task TestContextDelegateTotalStaked()
559599
{
560-
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].UnstakedFrozenDeposits;
561-
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/unstaked_frozen_deposits/", query.ToString());
600+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].TotalStaked;
601+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/total_staked/", query.ToString());
602+
603+
var res = await query.GetAsync();
604+
Assert.True(res is DJsonValue);
605+
}
606+
607+
[Fact]
608+
public async Task TestContextDelegateTotalUnstakedPerCycle()
609+
{
610+
var query = Rpc.Blocks.Head.Context.Delegates[TestDelegate].TotalUnstakedPerCycle;
611+
Assert.Equal($"chains/main/blocks/head/context/delegates/{TestDelegate}/total_unstaked_per_cycle/", query.ToString());
562612

563613
var res = await query.GetAsync();
564614
Assert.True(res is DJsonArray);
@@ -594,6 +644,16 @@ public async Task TestContextIssuanceCurrentYearlyRate()
594644
Assert.True(res is DJsonValue);
595645
}
596646

647+
[Fact]
648+
public async Task TestContextIssuanceCurrentYearlyRateDetails()
649+
{
650+
var query = Rpc.Blocks.Head.Context.Issuance.CurrentYearlyRateDetails;
651+
Assert.Equal($"chains/main/blocks/head/context/issuance/current_yearly_rate_details/", query.ToString());
652+
653+
var res = await query.GetAsync();
654+
Assert.True(res is DJsonObject);
655+
}
656+
597657
[Fact]
598658
public async Task TestContextIssuanceCurrentYearlyRateExact()
599659
{
@@ -697,6 +757,16 @@ public async Task TestContextSmartRollupStakers()
697757
Assert.True(res is DJsonArray);
698758
}
699759

760+
[Fact]
761+
public async Task TestContextTotalCurrentlyStaked()
762+
{
763+
var query = Rpc.Blocks.Head.Context.TotalCurrentlyStaked;
764+
Assert.Equal($"chains/main/blocks/head/context/total_currently_staked/", query.ToString());
765+
766+
var res = await query.GetAsync();
767+
Assert.True(res is DJsonObject);
768+
}
769+
700770
[Fact]
701771
public async Task TestContextTotalFrozenStake()
702772
{

Netezos.Tests/Rpc/settings_ithaca.json renamed to Netezos.Tests/Rpc/settings_ghostnet.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"node": "https://rpc.tzkt.io/ithacanet/",
2+
"node": "https://rpc.tzkt.io/ghostnet/",
33
"testContract": "KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5",
44
"testEntrypoint": "default",
55
"testDelegate": "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",

Netezos/Rpc/Queries/ContextQuery.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public class ContextQuery : RpcQuery
6363
/// </summary>
6464
public SmartRollupsQuery SmartRollups => new(this, "smart_rollups/");
6565

66+
/// <summary>
67+
/// Returns the amount of staked tez by delegates, delegators or overstaked.
68+
/// </summary>
69+
public RpcObject TotalCurrentlyStaked => new(this, "total_currently_staked/");
70+
6671
/// <summary>
6772
/// Returns the total stake (in mutez) frozen on the chain.
6873
/// </summary>

Netezos/Rpc/Queries/ContractQuery.cs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ public class ContractQuery : RpcObject
1313
public RpcObject AllTicketBalances => new(this, "all_ticket_balances/");
1414

1515
/// <summary>
16-
/// Gets the query to the balance of a contract
16+
/// Gets the query to the spendable balance of a contract (in mutez), also known as liquid balance. Corresponds
17+
/// to tez owned by the contract that are neither staked, nor in unstaked requests, nor in frozen bonds.
18+
/// Identical to the 'spendable' RPC.
1719
/// </summary>
1820
public RpcObject Balance => new(this, "balance/");
1921

2022
/// <summary>
21-
/// Gets the query to the sum of the spendable balance and frozen bonds of a contract.
23+
/// Gets the query to the sum (in mutez) of the spendable balance and frozen bonds of a contract. Corresponds
24+
/// to the contract's full balance from which staked funds and unstake requests have been excluded. Identical
25+
/// to the 'spendable_and_frozen_bonds' RPC.
2226
/// </summary>
2327
public RpcObject BalanceAndFrozenBonds => new(this, "balance_and_frozen_bonds/");
2428

@@ -60,7 +64,9 @@ public class ContractQuery : RpcObject
6064
public RpcObject FrozenBonds => new(this, "frozen_bonds/");
6165

6266
/// <summary>
63-
/// Gets the query to the full balance of a contract, including frozen bonds and stake.
67+
/// Gets the query to the full balance (in mutez) of the contract. Includes its spendable balance, staked tez,
68+
/// unstake requests, and frozen bonds. Even if the contract is a delegate, it does not include any staked or
69+
/// delegated tez owned by external delegators.
6470
/// </summary>
6571
public RpcObject FullBalance => new(this, "full_balance/");
6672

@@ -81,15 +87,24 @@ public class ContractQuery : RpcObject
8187
public ScriptQuery Script => new(this, "script/");
8288

8389
/// <summary>
84-
/// Gets the query to the staked balance of a contract. Returns None if the contract is originated, or neither delegated nor a delegate.
90+
/// Gets the query to the staked balance of a contract (in mutez). Returns None if the contract is originated,
91+
/// or neither delegated nor a delegate.
8592
/// </summary>
8693
public RpcObject StakedBalance => new(this, "staked_balance/");
8794

8895
/// <summary>
89-
/// Gets the query to the flag, indicating if the contract tokens can be spent by the manager
96+
/// Gets the query to the spendable balance of a contract (in mutez), also known as liquid balance. Corresponds
97+
/// to tez owned by the contract that are neither staked, nor in unstaked requests, nor in frozen bonds.
98+
/// Identical to the 'balance' RPC.
9099
/// </summary>
91-
[Obsolete("This RPC query was removed. Use it on early protocols only.")]
92100
public RpcObject Spendable => new(this, "spendable/");
101+
102+
/// <summary>
103+
/// Gets the query to the sum (in mutez) of the spendable balance and frozen bonds of a contract. Corresponds
104+
/// to the contract's full balance from which staked funds and unstake requests have been excluded. Identical
105+
/// to the 'balance_and_frozen_bonds' RPC.
106+
/// </summary>
107+
public RpcObject SpendableAndFrozenBonds => new(this, "spendable_and_frozen_bonds/");
93108

94109
/// <summary>
95110
/// Gets the query to the data of the contract's storage

0 commit comments

Comments
 (0)