diff --git a/integration-tests/rpc-get-protocol-constants.spec.ts b/integration-tests/rpc-get-protocol-constants.spec.ts index 347bed19f8..ea8d53437d 100644 --- a/integration-tests/rpc-get-protocol-constants.spec.ts +++ b/integration-tests/rpc-get-protocol-constants.spec.ts @@ -328,7 +328,7 @@ CONFIGS().forEach(({ lib, protocol, rpc }) => { }); it('Verify that rpc.getConstants successfully fetches Proto9 constants at level 1480000', async (done) => { - const constants: ConstantsResponseProto009 & ConstantsResponseCommon = await Tezos.rpc.getConstants({ block: "1480000" }); + const constants: ConstantsResponseProto009 = await Tezos.rpc.getConstants({ block: "1480000" }); expect(constants).toEqual({ proof_of_work_nonce_size: 8, @@ -367,7 +367,7 @@ CONFIGS().forEach(({ lib, protocol, rpc }) => { }); it('Verify that rpc.getConstants successfully fetches Proto10 constants at level 1589492', async (done) => { - const constants: ConstantsResponseProto010 & ConstantsResponseCommon = await Tezos.rpc.getConstants({ block: "1589492" }); + const constants: ConstantsResponseProto010 = await Tezos.rpc.getConstants({ block: "1589492" }); expect(constants).toEqual({ proof_of_work_nonce_size: 8, @@ -409,7 +409,7 @@ CONFIGS().forEach(({ lib, protocol, rpc }) => { }); it('successfully fetches Proto11 constants at level 1932041', async (done) => { - const constants: ConstantsResponseProto011 & ConstantsResponseCommon = await Tezos.rpc.getConstants({ block: "1932041" }); + const constants: ConstantsResponseProto011 = await Tezos.rpc.getConstants({ block: "1932041" }); expect(constants).toEqual({ proof_of_work_nonce_size: 8, @@ -455,7 +455,7 @@ CONFIGS().forEach(({ lib, protocol, rpc }) => { }); it('successfully fetches Proto12 constants at level 2354016', async (done) => { - const constants: ConstantsResponseProto012 & ConstantsResponseCommon = await Tezos.rpc.getConstants({ block: "2354016" }); + const constants: ConstantsResponseProto012 = await Tezos.rpc.getConstants({ block: "2354016" }); expect(constants).toEqual({ proof_of_work_nonce_size: 8, @@ -511,7 +511,7 @@ CONFIGS().forEach(({ lib, protocol, rpc }) => { }); it('successfully fetches Proto13 constants at level 2656071', async (done) => { - const constants: ConstantsResponseProto013 & ConstantsResponseCommon = await Tezos.rpc.getConstants({ block: "2656071" }); + const constants: ConstantsResponseProto013 = await Tezos.rpc.getConstants({ block: "2656071" }); expect(constants).toEqual({ proof_of_work_nonce_size: 8, @@ -593,7 +593,7 @@ CONFIGS().forEach(({ lib, protocol, rpc }) => { limanet(`successfully fetches all constants for limanet using ${rpc}`, async (done) => { Tezos.setRpcProvider(rpc); - const constants: ConstantsResponseProto015 & ConstantsResponseCommon = await Tezos.rpc.getConstants(); + const constants: ConstantsResponseProto015 = await Tezos.rpc.getConstants(); expect(constants).toEqual({ proof_of_work_nonce_size: 8, @@ -698,7 +698,7 @@ CONFIGS().forEach(({ lib, protocol, rpc }) => { kathmandunet(`successfully fetches all constants for kathmandunet using ${rpc}`, async (done) => { Tezos.setRpcProvider(rpc); - const constants: ConstantsResponseProto014 & ConstantsResponseCommon = await Tezos.rpc.getConstants(); + const constants: ConstantsResponseProto014 = await Tezos.rpc.getConstants(); expect(constants).toEqual({ proof_of_work_nonce_size: 8, nonce_length: 32, @@ -792,7 +792,7 @@ CONFIGS().forEach(({ lib, protocol, rpc }) => { alpha(`successfully fetches all constants for mondaynet using ${rpc}`, async (done) => { Tezos.setRpcProvider(rpc); - const constants: ConstantsResponseProto014 & ConstantsResponseCommon = await Tezos.rpc.getConstants(); + const constants: ConstantsResponseProto015 = await Tezos.rpc.getConstants(); expect(constants).toEqual({ proof_of_work_nonce_size: 8, diff --git a/packages/taquito-rpc/src/types.ts b/packages/taquito-rpc/src/types.ts index bc98445200..8a218b7323 100644 --- a/packages/taquito-rpc/src/types.ts +++ b/packages/taquito-rpc/src/types.ts @@ -412,7 +412,7 @@ export interface OperationContentsTxRollupRejection { message_result_path: string[]; previous_message_result: TxRollupPreviousMessageResult; previous_message_result_path: string[]; - proof: TxRollupProof; + proof: TxRollupProof | string; } export interface OperationContentsTxRollupDispatchTickets { @@ -509,12 +509,14 @@ export interface OperationContentsAndResultMetadataExtended { delegate: string; slots?: number[]; endorsement_power?: number; + consensus_key?: string; } export interface OperationContentsAndResultMetadataPreEndorsement { balance_updates?: OperationMetadataBalanceUpdates[]; delegate: string; preendorsement_power: number; + consensus_key?: string; } export interface OperationContentsAndResultMetadataReveal { @@ -839,7 +841,7 @@ export interface OperationContentsAndResultTxRollupRejection { message_result_path: string[]; previous_message_result: TxRollupPreviousMessageResult; previous_message_result_path: string[]; - proof: TxRollupProof; + proof: TxRollupProof | string; metadata: OperationContentsAndResultMetadataTxRollupRejection; } @@ -970,20 +972,15 @@ export type BakingRightsArgumentsDelegate = string | string[]; export type BakingRightsArgumentsCycle = number | number[]; export type BakingRightsArgumentsLevel = number | number[]; -export type BakingRightsQueryArguments = - | BakingRightsQueryArgumentsProto12 - | BakingRightsQueryArgumentsBase; +export type BakingRightsQueryArguments = BakingRightsQueryArgumentsBase; -export interface BakingRightsQueryArgumentsProto12 - extends Omit { - max_round?: string; -} export interface BakingRightsQueryArgumentsBase { level?: BakingRightsArgumentsLevel; cycle?: BakingRightsArgumentsCycle; delegate?: BakingRightsArgumentsDelegate; consensus_key?: string; max_priority?: number; + max_round?: string; all?: null; } @@ -1340,9 +1337,9 @@ export interface TicketUpdates { updates: { account: string; amount: string; - }[] + }[]; } -export type TicketReceipt = TicketUpdates +export type TicketReceipt = TicketUpdates; export interface OperationResultTransaction { status: OperationResultStatusEnum; @@ -1584,8 +1581,24 @@ export interface ConstantsResponseCommon { export type Ratio = { numerator: number; denominator: number }; -export interface ConstantsResponseProto015 extends ConstantsResponseProto014 { +export interface ConstantsResponseProto015 + extends Omit< + ConstantsResponseProto014, + | 'max_wrapped_proof_binary_size' + | 'tokens_per_roll' + | 'liquidity_baking_sunset_level' + | 'sc_rollup_max_available_messages' + > { minimal_stake: BigNumber; + sc_max_wrapped_proof_binary_size: number; + sc_rollup_message_size_limit: number; + sc_rollup_max_number_of_messages_per_commitment_period: number; + sc_rollup_number_of_sections_in_dissection: number; + sc_rollup_timeout_period_in_blocks: number; + sc_rollup_max_number_of_cemented_commitments: number; + zk_rollup_enable: number; + zk_rollup_origination_size: number; + zk_rollup_min_pending_to_process: number; } export interface DalParametric { @@ -1594,6 +1607,9 @@ export interface DalParametric { number_of_shards: number; endorsement_lag: number; availability_threshold: number; + slot_size?: number; + redundancy_factor?: number; + page_size?: number; } export interface ConstantsResponseProto014 extends ConstantsResponseProto013 { @@ -1721,7 +1737,7 @@ export interface ConstantsResponseProto003 max_proposals_per_delegate?: number; } -export interface ConstantsResponseProto001And002 { +export interface ConstantsResponseProto001And002 extends ConstantsResponseCommon { max_revelations_per_block?: number; origination_burn?: string; block_reward?: BigNumber; diff --git a/packages/taquito-rpc/test/taquito-rpc.spec.ts b/packages/taquito-rpc/test/taquito-rpc.spec.ts index 051ce392bb..9d17d7ed16 100644 --- a/packages/taquito-rpc/test/taquito-rpc.spec.ts +++ b/packages/taquito-rpc/test/taquito-rpc.spec.ts @@ -32,6 +32,8 @@ import { OperationContentsAndResultTxRollupReturnBond, OperationContentsAndResultUpdateConsensusKey, OperationContentsAndResultDrainDelegate, + TxRollupProof, + ConstantsResponseProto015, } from '../src/types'; import { blockIthacanetSample, @@ -669,40 +671,40 @@ describe('RpcClient test', () => { nonce_revelation_threshold: 256, blocks_per_stake_snapshot: 256, cycles_per_voting_period: 1, - hard_gas_limit_per_operation: "1040000", - hard_gas_limit_per_block: "5200000", - proof_of_work_threshold: "-1", - minimal_stake: "6000000000", - vdf_difficulty: "2000000000", - seed_nonce_revelation_tip: "125000", + hard_gas_limit_per_operation: '1040000', + hard_gas_limit_per_block: '5200000', + proof_of_work_threshold: '-1', + minimal_stake: '6000000000', + vdf_difficulty: '2000000000', + seed_nonce_revelation_tip: '125000', origination_size: 257, - baking_reward_fixed_portion: "10000000", - baking_reward_bonus_per_slot: "4286", - endorsing_reward_per_slot: "2857", - cost_per_byte: "250", - hard_storage_limit_per_operation: "60000", + baking_reward_fixed_portion: '10000000', + baking_reward_bonus_per_slot: '4286', + endorsing_reward_per_slot: '2857', + cost_per_byte: '250', + hard_storage_limit_per_operation: '60000', quorum_min: 2000, quorum_max: 7000, min_proposal_quorum: 500, - liquidity_baking_subsidy: "2500000", + liquidity_baking_subsidy: '2500000', liquidity_baking_toggle_ema_threshold: 1000000000, max_operations_time_to_live: 120, - minimal_block_delay: "15", - delay_increment_per_round: "5", + minimal_block_delay: '15', + delay_increment_per_round: '5', consensus_committee_size: 7000, consensus_threshold: 4667, minimal_participation_ratio: { numerator: 2, - denominator: 3 + denominator: 3, }, max_slashing_period: 2, frozen_deposits_percentage: 10, - double_baking_punishment: "640000000", + double_baking_punishment: '640000000', ratio_of_frozen_deposits_slashed_per_double_endorsement: { numerator: 1, - denominator: 2 + denominator: 2, }, - testnet_dictator: "tz1Xf8zdT3DbAX9cHw3c3CXh79rc4nK4gCe8", + testnet_dictator: 'tz1Xf8zdT3DbAX9cHw3c3CXh79rc4nK4gCe8', cache_script_size: 100000000, cache_stake_distribution_cycles: 8, cache_sampler_state_cycles: 8, @@ -711,7 +713,7 @@ describe('RpcClient test', () => { tx_rollup_hard_size_limit_per_inbox: 500000, tx_rollup_hard_size_limit_per_message: 5000, tx_rollup_max_withdrawals_per_batch: 15, - tx_rollup_commitment_bond: "10000000000", + tx_rollup_commitment_bond: '10000000000', tx_rollup_finality_period: 40000, tx_rollup_withdraw_period: 40000, tx_rollup_max_inboxes_count: 40100, @@ -729,13 +731,13 @@ describe('RpcClient test', () => { availability_threshold: 50, slot_size: 1048576, redundancy_factor: 16, - page_size: 4096 + page_size: 4096, }, sc_rollup_enable: false, sc_rollup_origination_size: 6314, sc_rollup_challenge_window_in_blocks: 20160, sc_rollup_max_number_of_messages_per_commitment_period: 300000000, - sc_rollup_stake_amount: "10000000000", + sc_rollup_stake_amount: '10000000000', sc_rollup_commitment_period_in_blocks: 30, sc_rollup_max_lookahead_in_blocks: 30000, sc_rollup_max_active_outbox_levels: 20160, @@ -745,10 +747,10 @@ describe('RpcClient test', () => { sc_rollup_max_number_of_cemented_commitments: 5, zk_rollup_enable: false, zk_rollup_origination_size: 4000, - zk_rollup_min_pending_to_process: 10 + zk_rollup_min_pending_to_process: 10, }); - const response = await client.getConstants(); + const response: ConstantsResponseProto015 = await client.getConstants(); expect(httpBackend.createRequest.mock.calls[0][0]).toEqual({ method: 'GET', @@ -797,16 +799,16 @@ describe('RpcClient test', () => { consensus_threshold: 4667, minimal_participation_ratio: { numerator: 2, - denominator: 3 + denominator: 3, }, max_slashing_period: 2, frozen_deposits_percentage: 10, double_baking_punishment: new BigNumber(640000000), ratio_of_frozen_deposits_slashed_per_double_endorsement: { numerator: 1, - denominator: 2 + denominator: 2, }, - testnet_dictator: "tz1Xf8zdT3DbAX9cHw3c3CXh79rc4nK4gCe8", + testnet_dictator: 'tz1Xf8zdT3DbAX9cHw3c3CXh79rc4nK4gCe8', cache_script_size: 100000000, cache_stake_distribution_cycles: 8, cache_sampler_state_cycles: 8, @@ -833,7 +835,7 @@ describe('RpcClient test', () => { availability_threshold: 50, slot_size: 1048576, redundancy_factor: 16, - page_size: 4096 + page_size: 4096, }, sc_rollup_enable: false, sc_rollup_origination_size: 6314, @@ -849,7 +851,7 @@ describe('RpcClient test', () => { sc_rollup_max_number_of_cemented_commitments: 5, zk_rollup_enable: false, zk_rollup_origination_size: 4000, - zk_rollup_min_pending_to_process: 10 + zk_rollup_min_pending_to_process: 10, }); done(); }); @@ -1712,7 +1714,6 @@ describe('RpcClient test', () => { 'sigmCS2nZquXi3vXX8p7iwc6TVYC87FsGYkxSgEMiQESbM5dnnP4SGe4YHLRFXuRwcs1VaNLsiFWzVQVnpbNDfAhYhPgRnCG', }, ], - ], }) ); @@ -3186,24 +3187,26 @@ describe('RpcClient test', () => { ); expect(content.proof).toBeDefined(); - expect(content.proof.version).toEqual(3); - expect((content.proof.before as { node: string; }).node).toEqual( + + const proof = content.proof as TxRollupProof; + expect(proof.version).toEqual(3); + expect((proof.before as { node: string }).node).toEqual( 'CoVUv68XdJts8f6Ysaoxm4jnt4JKXfqx8WYVFnkj2UFfgKHJUrLs' ); - expect((content.proof.after as { node: string; }).node).toEqual( + expect((proof.after as { node: string }).node).toEqual( 'CoUn3twa3TmvNby5VAGeN2jHvzbfpmJAXcyDHJuLLAuuLiaZZnzC' ); - expect(content.proof.state).toBeDefined(); + expect(proof.state).toBeDefined(); - const inodeState1 = (content.proof.state[0] as { inode: Inode; }).inode; + const inodeState1 = (proof.state[0] as { inode: Inode }).inode; expect(inodeState1.length).toEqual('14'); expect(inodeState1.proofs).toEqual([ 'CoVbQczQE6uDug4tWErtLgszzZBRDJKEGHgcQp8jGYSEfBLnsMXH', 'CoWZ31tY65qh38Sfgm64Ny8kDTLQQMr5xuRDkDkz1JopiBnPDu11', ]); - const inodeState2 = (content.proof.state[2] as { inode: Inode; }).inode; + const inodeState2 = (proof.state[2] as { inode: Inode }).inode; expect(inodeState2.length).toEqual('3'); expect(inodeState2.proofs).toEqual([ null, @@ -3211,8 +3214,8 @@ describe('RpcClient test', () => { ]); const otherEltsNode = ( - (content.proof.state[4] as { other_elts: OtherElts; }).other_elts as { - node: [string, { value: string; }][]; + (proof.state[4] as { other_elts: OtherElts }).other_elts as { + node: [string, { value: string }][]; } ).node; expect(otherEltsNode[0]).toEqual([ @@ -3221,8 +3224,8 @@ describe('RpcClient test', () => { ]); const otherEltsOtherElts = ( - (content.proof.state[5] as { other_elts: OtherElts; }).other_elts as { - other_elts: { value: any; }; + (proof.state[5] as { other_elts: OtherElts }).other_elts as { + other_elts: { value: any }; } ).other_elts; expect(otherEltsOtherElts).toEqual({ value: '00000000' }); @@ -3532,29 +3535,35 @@ describe('RpcClient test', () => { httpBackend.createRequest.mockReturnValue(Promise.resolve(ticketUpdatesSample)); const response = await client.getBlock(); - const content = response.operations[0][0].contents[0] as OperationContentsAndResultTransaction - const ticketUpdates = content.metadata.operation_result.ticket_updates && content.metadata.operation_result.ticket_updates[0] + const content = response.operations[0][0] + .contents[0] as OperationContentsAndResultTransaction; + const ticketUpdates = + content.metadata.operation_result.ticket_updates && + content.metadata.operation_result.ticket_updates[0]; expect(ticketUpdates).toBeDefined(); - expect(ticketUpdates?.ticket_token.ticketer).toEqual('KT1JGcC8DuWHcShu6XvtfgKVnV2zcYsZ4TVH') - expect(ticketUpdates?.updates[0].account).toEqual('KT1JoRgUcR6NApwMLnBZ2pehCzp8tR4HtkHj') - expect(ticketUpdates?.updates[0].amount).toEqual('-2') - done() + expect(ticketUpdates?.ticket_token.ticketer).toEqual('KT1JGcC8DuWHcShu6XvtfgKVnV2zcYsZ4TVH'); + expect(ticketUpdates?.updates[0].account).toEqual('KT1JoRgUcR6NApwMLnBZ2pehCzp8tR4HtkHj'); + expect(ticketUpdates?.updates[0].amount).toEqual('-2'); + done(); }); // may be removed it('should contain ticket_receipt for transactions updating ticket storage', async (done) => { httpBackend.createRequest.mockReturnValue(Promise.resolve(ticketUpdatesSample)); const response = await client.getBlock(); - const content = response.operations[0][0].contents[0] as OperationContentsAndResultTransaction - const internalContent = content.metadata.internal_operation_results && content.metadata.internal_operation_results[0].result as OperationResultTransaction - const ticketReceipt = internalContent?.ticket_receipt && internalContent.ticket_receipt[0] + const content = response.operations[0][0] + .contents[0] as OperationContentsAndResultTransaction; + const internalContent = + content.metadata.internal_operation_results && + (content.metadata.internal_operation_results[0].result as OperationResultTransaction); + const ticketReceipt = internalContent?.ticket_receipt && internalContent.ticket_receipt[0]; expect(ticketReceipt).toBeDefined(); - expect(ticketReceipt?.ticket_token.ticketer).toEqual('KT1JGcC8DuWHcShu6XvtfgKVnV2zcYsZ4TVH') - expect(ticketReceipt?.updates[0].account).toEqual('KT1JoRgUcR6NApwMLnBZ2pehCzp8tR4HtkHj') - expect(ticketReceipt?.updates[0].amount).toEqual('1') - done() + expect(ticketReceipt?.ticket_token.ticketer).toEqual('KT1JGcC8DuWHcShu6XvtfgKVnV2zcYsZ4TVH'); + expect(ticketReceipt?.updates[0].account).toEqual('KT1JoRgUcR6NApwMLnBZ2pehCzp8tR4HtkHj'); + expect(ticketReceipt?.updates[0].amount).toEqual('1'); + done(); }); });