Skip to content

Commit

Permalink
query_global_state
Browse files Browse the repository at this point in the history
  • Loading branch information
ryo-casper committed Apr 18, 2024
1 parent dd9e76c commit 4aea966
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion e2e/services/CasperServiceByJsonRPC.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe('CasperServiceByJsonRPC', () => {
expect(balance.eq(faucetBalance)).to.be;
});

it('query_balance', async () => {
it.only('query_balance', async () => {
const faucetBalance = '1000000000000000000000000000000000';

const balanceByPublicKey = await client.queryBalance(
Expand Down
15 changes: 15 additions & 0 deletions src/services/CasperServiceByJsonRPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -918,4 +918,19 @@ export class CasperServiceByJsonRPC {
props?.timeout
);
}

public async queryGlobalState(
key: string,
stateIdentifier: StateIdentifier | null = null,
path: string[] = [],
props?: RpcRequestProps
) {
return this.client.request(
{
method: 'info_get_chainspec',
params: [stateIdentifier, key, path]
},
props?.timeout
);
}
}
27 changes: 26 additions & 1 deletion src/services/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,19 @@ export interface EraEndV2 {
next_era_gas_price: number;
}

export interface BlockHeaderV1 {
parent_hash: JsonBlockHash;
state_root_hash: string;
body_hash: string;
random_bit: boolean;
accumulated_seed: string;
era_end: EraEndV2 | null;
timestamp: string; //TODO this probably needs to be a class
era_id: number;
height: number;
protocol_version: string;
}

export interface BlockHeaderV2 {
parent_hash: JsonBlockHash;
state_root_hash: string;
Expand All @@ -351,7 +364,6 @@ export interface BlockHeaderV2 {
height: number;
protocol_version: string;
current_gas_price: number;
block_hash: string;
}
export interface TransactionHash {
Deploy: string | null;
Expand Down Expand Up @@ -446,3 +458,16 @@ export interface AddressableEntity {
action_thresholds: [];
message_topics: [];
}

export interface BlockHeader {
Version1: BlockHeaderV1;
Version2: BlockHeaderV2;
}

export type StoredValueJson = any;

export interface QueryGlobalStateResult extends RpcResult {
block_header: BlockHeader | null;
stored_value: StoredValueJson;
merkle_proof: string;
}

0 comments on commit 4aea966

Please sign in to comment.