From 604733903341724d2003f04793779b2caa565ed3 Mon Sep 17 00:00:00 2001 From: Davis Sawali Date: Tue, 16 Apr 2024 15:44:07 -0700 Subject: [PATCH] updated protocol constants test (#2918) * updated protocol constants test * updated constants response for proto20 * updated missing properties and estimation values * removed duplicate property --- .../contract/estimation-tests.spec.ts | 8 +- .../rpc/get-protocol-constants.spec.ts | 165 +++++++- ...tadata-on-HTTPS-and-fetch-metadata.spec.ts | 387 +++++++++--------- package-lock.json | 2 +- packages/taquito-rpc/src/types.ts | 115 +++++- 5 files changed, 455 insertions(+), 222 deletions(-) diff --git a/integration-tests/__tests__/contract/estimation-tests.spec.ts b/integration-tests/__tests__/contract/estimation-tests.spec.ts index e82d62dc22..d52fcaec73 100644 --- a/integration-tests/__tests__/contract/estimation-tests.spec.ts +++ b/integration-tests/__tests__/contract/estimation-tests.spec.ts @@ -102,7 +102,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => { expect(estimate.minimalFeeMutez).toEqual(374); expect(estimate.totalCost).toEqual(374); expect(estimate.usingBaseFeeMutez).toEqual(374); - expect(estimate.consumedMilligas).toEqual(1456056); + expect(estimate.consumedMilligas).toEqual(1456142); }); it('Verify .estimate.transfer for multiple internal transfers to unallocated account', async () => { @@ -119,7 +119,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => { expect(estimate.minimalFeeMutez).toEqual(445); expect(estimate.totalCost).toEqual(133945); expect(estimate.usingBaseFeeMutez).toEqual(445); - expect(estimate.consumedMilligas).toEqual(1570585); + expect(estimate.consumedMilligas).toEqual(1570671); }); it('Verify .estimate.transfer for internal origination', async () => { @@ -132,7 +132,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => { expect(estimate.minimalFeeMutez).toEqual(421); expect(estimate.totalCost).toEqual(84671); expect(estimate.usingBaseFeeMutez).toEqual(421); - expect(estimate.consumedMilligas).toEqual(1866680); + expect(estimate.consumedMilligas).toEqual(1866766); }); it('Verify .estimate.transfer for multiple internal originations', async () => { @@ -145,7 +145,7 @@ CONFIGS().forEach(({ lib, setup, knownBaker, createAddress, rpc }) => { expect(estimate.minimalFeeMutez).toEqual(539); expect(estimate.totalCost).toEqual(164039); expect(estimate.usingBaseFeeMutez).toEqual(539); - expect(estimate.consumedMilligas).toEqual(2391833); + expect(estimate.consumedMilligas).toEqual(2391919); // Do the actual operation const op2 = await contract.methods.do(originate2()).send(); await op2.confirmation(); diff --git a/integration-tests/__tests__/rpc/get-protocol-constants.spec.ts b/integration-tests/__tests__/rpc/get-protocol-constants.spec.ts index a3ac693227..575054d59c 100644 --- a/integration-tests/__tests__/rpc/get-protocol-constants.spec.ts +++ b/integration-tests/__tests__/rpc/get-protocol-constants.spec.ts @@ -1,16 +1,17 @@ import { Protocols } from "@taquito/taquito"; import { CONFIGS, NetworkType } from "../../config"; import BigNumber from 'bignumber.js'; -import { ConstantsResponseProto019 } from '@taquito/rpc'; +import { ConstantsResponseProto019, ConstantsResponseProto020 } from '@taquito/rpc'; CONFIGS().forEach(({ lib, protocol, rpc, networkType }) => { const Tezos = lib; const oxfordnet = (networkType == NetworkType.TESTNET && protocol === Protocols.ProxfordY) ? test : test.skip; + const parisnet = (networkType == NetworkType.TESTNET && protocol === Protocols.PtParisBQ) ? test : test.skip; const weeklynet = (networkType == NetworkType.TESTNET && protocol === Protocols.ProtoALpha) ? test : test.skip; describe('Test fetching constants for all protocols on Mainnet', () => { const rpcUrl = 'https://mainnet.ecadinfra.com/'; Tezos.setRpcProvider(rpcUrl); - it(`successfully fetches Proto19(oxford2) constants at head`, async () => { + it(`should successfully fetch Proto19(oxford2) constants at head`, async () => { const constants: ConstantsResponseProto019 = await Tezos.rpc.getConstants(); expect(constants).toEqual({ adaptive_issuance_activation_vote_enable: false, @@ -140,7 +141,155 @@ CONFIGS().forEach(({ lib, protocol, rpc, networkType }) => { }); describe(`Fetch constants for testnet`, () => { - oxfordnet(`successfully fetches all constants for oxfordnet using ${rpc}`, async () => { + parisnet(`should successfully fetch all constants for Parisnet using ${rpc}`, async () => { + Tezos.setRpcProvider(rpc); + const constants: ConstantsResponseProto020 = await Tezos.rpc.getConstants(); + expect(constants).toEqual({ + adaptive_issuance_activation_vote_enable: true, + adaptive_issuance_force_activation: false, + adaptive_issuance_launch_ema_threshold: 0, + adaptive_rewards_params: { + center_dz: { + denominator: "2", + numerator: "1", + }, + growth_rate: { + denominator: "25", + numerator: "1", + }, + issuance_ratio_final_max: { + denominator: "10", + numerator: "1", + }, + issuance_ratio_final_min: { + denominator: "400", + numerator: "1", + }, + issuance_ratio_initial_max: { + denominator: "200", + numerator: "11", + }, + issuance_ratio_initial_min: { + denominator: "200", + numerator: "9" + }, + max_bonus: "50000000000000", + radius_dz: { + denominator: "50", + numerator: "1", + }, + initial_period: 10, + transition_period: 50 + }, + autostaking_enable: true, + proof_of_work_nonce_size: 8, + nonce_length: 32, + max_anon_ops_per_block: 132, + max_operation_data_length: 32768, + max_proposals_per_delegate: 20, + max_micheline_node_count: 50000, + max_micheline_bytes_limit: 50000, + max_allowed_global_constants_depth: 10000, + cache_layout_size: 3, + michelson_maximum_type_size: 2001, + smart_rollup_max_wrapped_proof_binary_size: 30000, + smart_rollup_max_number_of_messages_per_level: '1000000', + blocks_per_cycle: 12288, + blocks_per_commitment: 96, + blocks_preservation_cycles: 1, + nonce_revelation_threshold: 768, + ns_enable: true, + cycles_per_voting_period: 1, + hard_gas_limit_per_operation: new BigNumber(1040000), + hard_gas_limit_per_block: new BigNumber(1733333), + proof_of_work_threshold: new BigNumber(-1), + minimal_stake: new BigNumber(6000000000), + origination_size: 257, + cost_per_byte: new BigNumber(250), + hard_storage_limit_per_operation: new BigNumber(60000), + percentage_of_frozen_deposits_slashed_per_double_attestation: 5000, + percentage_of_frozen_deposits_slashed_per_double_baking: 500, + minimal_frozen_stake: '600000000', + limit_of_delegation_over_baking: 9, + liquidity_baking_subsidy: new BigNumber(5000000), + issuance_weights: { + attesting_reward_weight: 10240, + baking_reward_bonus_weight: 5120, + baking_reward_fixed_portion_weight: 5120, + base_total_issued_per_minute: "80007812", + seed_nonce_revelation_tip_weight: 1, + vdf_revelation_tip_weight: 1, + }, + min_proposal_quorum: 500, + edge_of_staking_over_delegation: 2, + global_limit_of_staking_over_baking: 5, + liquidity_baking_toggle_ema_threshold: 1000000000, + max_operations_time_to_live: 360, + minimal_block_delay: new BigNumber(5), + delay_increment_per_round: new BigNumber(2), + delegate_parameters_activation_delay: 5, + direct_ticket_spending_enable: false, + consensus_committee_size: 7000, + consensus_threshold: 4667, + consensus_rights_delay: 2, + minimal_participation_ratio: { + numerator: 2, + denominator: 3 + }, + max_slashing_period: 2, + max_slashing_per_block: 10000, + max_slashing_threshold: 2334, + cache_script_size: 100000000, + cache_stake_distribution_cycles: 8, + cache_sampler_state_cycles: 8, + dal_parametric: { + attestation_lag: 8, + attestation_threshold: 66, + feature_enable: true, + incentives_enable: false, + number_of_shards: 512, + number_of_slots: 32, + page_size: 3967, + redundancy_factor: 8, + slot_size: 126944, + }, + quorum_max: 7000, + quorum_min: 2000, + smart_rollup_arith_pvm_enable: false, + smart_rollup_challenge_window_in_blocks: 241920, + smart_rollup_commitment_period_in_blocks: 180, + smart_rollup_max_lookahead_in_blocks: 518400, + smart_rollup_max_active_outbox_levels: 241920, + smart_rollup_max_outbox_messages_per_level: 100, + smart_rollup_max_number_of_cemented_commitments: 5, + smart_rollup_max_number_of_parallel_games: 32, + smart_rollup_message_size_limit: 4096, + smart_rollup_number_of_sections_in_dissection: 32, + smart_rollup_origination_size: 6314, + smart_rollup_private_enable: true, + smart_rollup_reveal_activation_level: { + dal_attested_slots_validity_lag: 241920, + dal_page: 8193, + dal_parameters: 8193, + metadata: 0, + raw_data: { + Blake2B: 0, + }, + }, + smart_rollup_riscv_pvm_enable: false, + smart_rollup_stake_amount: '10000000000', + smart_rollup_timeout_period_in_blocks: 120960, + testnet_dictator: 'tz1Xf8zdT3DbAX9cHw3c3CXh79rc4nK4gCe8', + vdf_difficulty: new BigNumber(10000000000), + zk_rollup_enable: false, + zk_rollup_max_ticket_payload_size: 2048, + zk_rollup_min_pending_to_process: 10, + zk_rollup_origination_size: 4000, + }); + }); + + + oxfordnet(`should successfully fetch all constants for Oxfordnet using ${rpc}`, async () => { Tezos.setRpcProvider(rpc); const constants: ConstantsResponseProto019 = await Tezos.rpc.getConstants(); expect(constants).toEqual({ @@ -185,8 +334,8 @@ CONFIGS().forEach(({ lib, protocol, rpc, networkType }) => { preserved_cycles: 3, blocks_per_cycle: 8192, blocks_per_commitment: 64, - nonce_revelation_threshold: 512, blocks_per_stake_snapshot: 512, + nonce_revelation_threshold: 512, cycles_per_voting_period: 1, hard_gas_limit_per_operation: new BigNumber(1040000), hard_gas_limit_per_block: new BigNumber(2600000), @@ -227,14 +376,14 @@ CONFIGS().forEach(({ lib, protocol, rpc, networkType }) => { cache_sampler_state_cycles: 8, dal_parametric: { feature_enable: false, - number_of_slots: 256, + blocks_per_epoch: 1, attestation_lag: 4, attestation_threshold: 50, - blocks_per_epoch: 1, redundancy_factor: 16, page_size: 4096, slot_size: 1048576, - number_of_shards: 2048 + number_of_shards: 2048, + number_of_slots: 256, }, quorum_max: 7000, quorum_min: 2000, @@ -270,7 +419,7 @@ CONFIGS().forEach(({ lib, protocol, rpc, networkType }) => { }); }); - weeklynet(`successfully fetches all constants for weeklynet using ${rpc}`, async () => { + weeklynet(`should successfully fetch all constants for weeklynet using ${rpc}`, async () => { Tezos.setRpcProvider(rpc); const constants: ConstantsResponseProto019 = await Tezos.rpc.getConstants(); diff --git a/integration-tests/__tests__/tzip-metadata/tzip16-originate-contracts-with-metadata-on-HTTPS-and-fetch-metadata.spec.ts b/integration-tests/__tests__/tzip-metadata/tzip16-originate-contracts-with-metadata-on-HTTPS-and-fetch-metadata.spec.ts index 54db9cd4b8..bdeaa260cf 100644 --- a/integration-tests/__tests__/tzip-metadata/tzip16-originate-contracts-with-metadata-on-HTTPS-and-fetch-metadata.spec.ts +++ b/integration-tests/__tests__/tzip-metadata/tzip16-originate-contracts-with-metadata-on-HTTPS-and-fetch-metadata.spec.ts @@ -4,198 +4,197 @@ import { MichelsonMap } from "@taquito/taquito"; import { tzip16, Tzip16Module, stringToBytes } from '@taquito/tzip16'; CONFIGS().forEach(({ lib, rpc, setup }) => { - const Tezos = lib; - Tezos.addExtension(new Tzip16Module()); - - let contractAddressEmptyMetadata: string; - let contractAddressEmoji: string; - let contractAddressInvalidMetadata: string; - - describe(`Test contract origination having metadata stored at HTTPS URL through contract api using: ${rpc}`, () => { - - beforeEach(async () => { - await setup() - }) - test('Verify contract.originate for a contract having empty metadata stored at an HTTPS URL', async () => { - - // location of the contract metadata - const url = 'https://storage.googleapis.com/tzip-16/empty-metadata.json'; - const bytesUrl = stringToBytes(url); - - const metadataBigMAp = new MichelsonMap(); - metadataBigMAp.set("", bytesUrl); - - // Ligo Taco shop contract modified to include metadata in storage - // https://ide.ligolang.org/p/-uS469slzUlSm1zwNqHl1A - - const tacoShopStorageMap = new MichelsonMap(); - tacoShopStorageMap.set("1", { current_stock: "10000", max_price: "50" }); - tacoShopStorageMap.set("2", { current_stock: "120", max_price: "20" }); - tacoShopStorageMap.set("3", { current_stock: "50", max_price: "60" }); - - const op = await Tezos.contract.originate({ - code: tacoContractTzip16, - storage: { - metadata: metadataBigMAp, - taco_shop_storage: tacoShopStorageMap - }, - }); - await op.confirmation(); - contractAddressEmptyMetadata = (await op.contract()).address; - expect(op.hash).toBeDefined(); - expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); - }); - - test('Verify that the metadata for the contract having empty metadata stored at an HTTPS URL can be fetched', async () => { - - const contract = await Tezos.contract.at(contractAddressEmptyMetadata, tzip16); - const metadata = await contract.tzip16().getMetadata(); - - expect(metadata.uri).toEqual('https://storage.googleapis.com/tzip-16/empty-metadata.json'); - expect(metadata.integrityCheckResult).toBeUndefined(); - expect(metadata.sha256Hash).toBeUndefined(); - expect(metadata.metadata).toEqual({}); - }); - - test('Verify contract.originate for a contract having valid metadata stored at an HTTPS URL', async () => { - - // location of the contract metadata - const url = 'https://storage.googleapis.com/tzip-16/taco-shop-metadata.json'; - const bytesUrl = stringToBytes(url); - - const metadataBigMap = new MichelsonMap(); - metadataBigMap.set("", bytesUrl); - - // Ligo Taco shop contract modified to include metadata in storage - // https://ide.ligolang.org/p/-uS469slzUlSm1zwNqHl1A - - const tacoShopStorageMap = new MichelsonMap(); - tacoShopStorageMap.set("1", { current_stock: "10000", max_price: "50" }); - - const op = await Tezos.contract.originate({ - code: tacoContractTzip16, - storage: { - metadata: metadataBigMap, - taco_shop_storage: tacoShopStorageMap - }, - }); - await op.confirmation(); - expect(op.hash).toBeDefined(); - expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); - }); - - test('Verify contract.originate for a contract having valid metadata which contains emoji stored at an HTTPS URL', async () => { - - // location of the contract metadata - const url = 'https://storage.googleapis.com/tzip-16/emoji-in-metadata.json'; - const bytesUrl = stringToBytes(url); - - const metadataBigMAp = new MichelsonMap(); - metadataBigMAp.set("", bytesUrl); - - // Ligo Taco shop contract modified to include metadata in storage - // https://ide.ligolang.org/p/-uS469slzUlSm1zwNqHl1A - - const tacoShopStorageMap = new MichelsonMap(); - tacoShopStorageMap.set("1", { current_stock: "10000", max_price: "50" }); - - const op = await Tezos.contract.originate({ - code: tacoContractTzip16, - storage: { - metadata: metadataBigMAp, - taco_shop_storage: tacoShopStorageMap - }, - }); - await op.confirmation(); - contractAddressEmoji = (await op.contract()).address; - expect(op.hash).toBeDefined(); - expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); - }); - - test('Verify that the metadata for the contract which contains emoji can be fetched', async () => { - - const contract = await Tezos.contract.at(contractAddressEmoji, tzip16); - const metadata = await contract.tzip16().getMetadata(); - - expect(metadata.uri).toEqual('https://storage.googleapis.com/tzip-16/emoji-in-metadata.json'); - expect(metadata.integrityCheckResult).toBeUndefined(); - expect(metadata.sha256Hash).toBeUndefined(); - expect(metadata.metadata).toEqual({ - "name": "Taquito test with valid metadata containing emoji 😀 🤩", - "description": "👋 This is metadata test for Taquito integration tests 🧐 with the Ligo Taco shop contract modified to include metadata URI in the storage", - "version": "7.1.0-beta.0", - "license": { - "name": "MIT", - "details": "The MIT License" - }, - "homepage": "https://github.com/ecadlabs/taquito", - "source": { - "tools": [ - "Ligo", - "https://ide.ligolang.org/p/-uS469slzUlSm1zwNqHl1A" - ], - "location": "https://ligolang.org/docs/tutorials/get-started/tezos-taco-shop-payout" - } - }); - - expect(await (await contract.tzip16()).metadataName()).toBe('Taquito test with valid metadata containing emoji 😀 🤩') - expect(await (await contract.tzip16()).metadataDescription()).toBe('👋 This is metadata test for Taquito integration tests 🧐 with the Ligo Taco shop contract modified to include metadata URI in the storage') - expect(await (await contract.tzip16()).metadataVersion()).toBe('7.1.0-beta.0') - expect(await (await contract.tzip16()).metadataLicense()).toEqual({ - "name": "MIT", - "details": "The MIT License" - }) - expect(await (await contract.tzip16()).metadataAuthors()).toBeUndefined() - expect(await (await contract.tzip16()).metadataHomepage()).toBe('https://github.com/ecadlabs/taquito') - expect(await (await contract.tzip16()).metadataSource()).toEqual({ - "tools": [ - "Ligo", - "https://ide.ligolang.org/p/-uS469slzUlSm1zwNqHl1A" - ], - "location": "https://ligolang.org/docs/tutorials/get-started/tezos-taco-shop-payout" - }) - expect(await (await contract.tzip16()).metadataInterfaces()).toBeUndefined() - expect(await (await contract.tzip16()).metadataErrors()).toBeUndefined() - expect(await (await contract.tzip16()).metadataViews()).toEqual({}); - }); - - test('Verify contract.originate for a contract having invalid metadata stored at an HTTPS URL', async () => { - - // location of the contract metadata - const url = 'https://storage.googleapis.com/tzip-16/invalid.json'; - const bytesUrl = stringToBytes(url); - - const metadataBigMAp = new MichelsonMap(); - metadataBigMAp.set("", bytesUrl); - - // Ligo Taco shop contract modified to include metadata in storage - // https://ide.ligolang.org/p/-uS469slzUlSm1zwNqHl1A - - const tacoShopStorageMap = new MichelsonMap(); - tacoShopStorageMap.set("1", { current_stock: "10000", max_price: "50" }); - - const op = await Tezos.contract.originate({ - code: tacoContractTzip16, - storage: { - metadata: metadataBigMAp, - taco_shop_storage: tacoShopStorageMap - }, - }); - await op.confirmation(); - contractAddressInvalidMetadata = (await op.contract()).address; - expect(op.hash).toBeDefined(); - expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); - }); - - test('Verify that the invalid metadata of the contract failed to fetch', async () => { - - const contract = await Tezos.contract.at(contractAddressInvalidMetadata, tzip16); - try { - await contract.tzip16().getMetadata(); - } catch (error: any) { - expect(error.message).toContain(`Invalid metadata`); - } - - }); + const Tezos = lib; + Tezos.addExtension(new Tzip16Module()); + + let contractAddressEmptyMetadata: string; + let contractAddressEmoji: string; + let contractAddressInvalidMetadata: string; + + describe(`Test contract origination having metadata stored at HTTPS URL through contract api using: ${rpc}`, () => { + + beforeEach(async () => { + await setup() + }) + test('Verify contract.originate for a contract having empty metadata stored at an HTTPS URL', async () => { + + // location of the contract metadata + const url = 'https://storage.googleapis.com/tzip-16/empty-metadata.json'; + const bytesUrl = stringToBytes(url); + + const metadataBigMAp = new MichelsonMap(); + metadataBigMAp.set("", bytesUrl); + + // Ligo Taco shop contract modified to include metadata in storage + // https://ide.ligolang.org/p/-uS469slzUlSm1zwNqHl1A + + const tacoShopStorageMap = new MichelsonMap(); + tacoShopStorageMap.set("1", { current_stock: "10000", max_price: "50" }); + tacoShopStorageMap.set("2", { current_stock: "120", max_price: "20" }); + tacoShopStorageMap.set("3", { current_stock: "50", max_price: "60" }); + + const op = await Tezos.contract.originate({ + code: tacoContractTzip16, + storage: { + metadata: metadataBigMAp, + taco_shop_storage: tacoShopStorageMap + }, + }); + await op.confirmation(); + contractAddressEmptyMetadata = (await op.contract()).address; + expect(op.hash).toBeDefined(); + expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); }); -}) + + test('Verify that the metadata for the contract having empty metadata stored at an HTTPS URL can be fetched', async () => { + + const contract = await Tezos.contract.at(contractAddressEmptyMetadata, tzip16); + const metadata = await contract.tzip16().getMetadata(); + + expect(metadata.uri).toEqual('https://storage.googleapis.com/tzip-16/empty-metadata.json'); + expect(metadata.integrityCheckResult).toBeUndefined(); + expect(metadata.sha256Hash).toBeUndefined(); + expect(metadata.metadata).toEqual({}); + }); + + test('Verify contract.originate for a contract having valid metadata stored at an HTTPS URL', async () => { + + // location of the contract metadata + const url = 'https://storage.googleapis.com/tzip-16/taco-shop-metadata.json'; + const bytesUrl = stringToBytes(url); + + const metadataBigMap = new MichelsonMap(); + metadataBigMap.set("", bytesUrl); + + // Ligo Taco shop contract modified to include metadata in storage + // https://ide.ligolang.org/p/-uS469slzUlSm1zwNqHl1A + + const tacoShopStorageMap = new MichelsonMap(); + tacoShopStorageMap.set("1", { current_stock: "10000", max_price: "50" }); + + const op = await Tezos.contract.originate({ + code: tacoContractTzip16, + storage: { + metadata: metadataBigMap, + taco_shop_storage: tacoShopStorageMap + }, + }); + await op.confirmation(); + expect(op.hash).toBeDefined(); + expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); + }); + + test('Verify contract.originate for a contract having valid metadata which contains emoji stored at an HTTPS URL', async () => { + + // location of the contract metadata + const url = 'https://storage.googleapis.com/tzip-16/emoji-in-metadata.json'; + const bytesUrl = stringToBytes(url); + + const metadataBigMAp = new MichelsonMap(); + metadataBigMAp.set("", bytesUrl); + + // Ligo Taco shop contract modified to include metadata in storage + // https://ide.ligolang.org/p/-uS469slzUlSm1zwNqHl1A + + const tacoShopStorageMap = new MichelsonMap(); + tacoShopStorageMap.set("1", { current_stock: "10000", max_price: "50" }); + + const op = await Tezos.contract.originate({ + code: tacoContractTzip16, + storage: { + metadata: metadataBigMAp, + taco_shop_storage: tacoShopStorageMap + }, + }); + await op.confirmation(); + contractAddressEmoji = (await op.contract()).address; + expect(op.hash).toBeDefined(); + expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); + }); + + test('Verify that the metadata for the contract which contains emoji can be fetched', async () => { + + const contract = await Tezos.contract.at(contractAddressEmoji, tzip16); + const metadata = await contract.tzip16().getMetadata(); + + expect(metadata.uri).toEqual('https://storage.googleapis.com/tzip-16/emoji-in-metadata.json'); + expect(metadata.integrityCheckResult).toBeUndefined(); + expect(metadata.sha256Hash).toBeUndefined(); + expect(metadata.metadata).toEqual({ + "name": "Taquito test with valid metadata containing emoji 😀 🤩", + "description": "👋 This is metadata test for Taquito integration tests 🧐 with the Ligo Taco shop contract modified to include metadata URI in the storage", + "version": "7.1.0-beta.0", + "license": { + "name": "MIT", + "details": "The MIT License" + }, + "homepage": "https://github.com/ecadlabs/taquito", + "source": { + "tools": [ + "Ligo", + "https://ide.ligolang.org/p/-uS469slzUlSm1zwNqHl1A" + ], + "location": "https://ligolang.org/docs/tutorials/get-started/tezos-taco-shop-payout" + } + }); + + expect(await (await contract.tzip16()).metadataName()).toBe('Taquito test with valid metadata containing emoji 😀 🤩') + expect(await (await contract.tzip16()).metadataDescription()).toBe('👋 This is metadata test for Taquito integration tests 🧐 with the Ligo Taco shop contract modified to include metadata URI in the storage') + expect(await (await contract.tzip16()).metadataVersion()).toBe('7.1.0-beta.0') + expect(await (await contract.tzip16()).metadataLicense()).toEqual({ + "name": "MIT", + "details": "The MIT License" + }) + expect(await (await contract.tzip16()).metadataAuthors()).toBeUndefined() + expect(await (await contract.tzip16()).metadataHomepage()).toBe('https://github.com/ecadlabs/taquito') + expect(await (await contract.tzip16()).metadataSource()).toEqual({ + "tools": [ + "Ligo", + "https://ide.ligolang.org/p/-uS469slzUlSm1zwNqHl1A" + ], + "location": "https://ligolang.org/docs/tutorials/get-started/tezos-taco-shop-payout" + }) + expect(await (await contract.tzip16()).metadataInterfaces()).toBeUndefined() + expect(await (await contract.tzip16()).metadataErrors()).toBeUndefined() + expect(await (await contract.tzip16()).metadataViews()).toEqual({}); + }); + + test('Verify contract.originate for a contract having invalid metadata stored at an HTTPS URL', async () => { + + // location of the contract metadata + const url = 'https://storage.googleapis.com/tzip-16/invalid.json'; + const bytesUrl = stringToBytes(url); + + const metadataBigMAp = new MichelsonMap(); + metadataBigMAp.set("", bytesUrl); + + // Ligo Taco shop contract modified to include metadata in storage + // https://ide.ligolang.org/p/-uS469slzUlSm1zwNqHl1A + + const tacoShopStorageMap = new MichelsonMap(); + tacoShopStorageMap.set("1", { current_stock: "10000", max_price: "50" }); + + const op = await Tezos.contract.originate({ + code: tacoContractTzip16, + storage: { + metadata: metadataBigMAp, + taco_shop_storage: tacoShopStorageMap + }, + }); + await op.confirmation(); + contractAddressInvalidMetadata = (await op.contract()).address; + expect(op.hash).toBeDefined(); + expect(op.includedInBlock).toBeLessThan(Number.POSITIVE_INFINITY); + }); + + test('Verify that the invalid metadata of the contract failed to fetch', async () => { + + const contract = await Tezos.contract.at(contractAddressInvalidMetadata, tzip16); + try { + await contract.tzip16().getMetadata(); + } catch (error: any) { + expect(error.message).toContain(`Invalid metadata`); + } + }); + }); +}); diff --git a/package-lock.json b/package-lock.json index fadffed0cb..29ea6dcfb9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -87,7 +87,7 @@ "name": "@taquito/example", "version": "19.2.0", "dependencies": { - "@ledgerhq/hw-transport-node-hid": "^6.28.5", + "@ledgerhq/hw-transport-node-hid": "^6.27.21", "@taquito/ledger-signer": "^19.2.0", "@taquito/local-forging": "^19.2.0", "@taquito/michel-codec": "^19.2.0", diff --git a/packages/taquito-rpc/src/types.ts b/packages/taquito-rpc/src/types.ts index 9ee0e59cbf..16d880da8f 100644 --- a/packages/taquito-rpc/src/types.ts +++ b/packages/taquito-rpc/src/types.ts @@ -19,19 +19,19 @@ interface INodeExtender { type OtherEltsInner = | { - value: any; - } + value: any; + } | { - inode_extender: INodeExtender; - }; + inode_extender: INodeExtender; + }; export type OtherElts = | { - node: [string, { value: string } | { node: string }][]; - } + node: [string, { value: string } | { node: string }][]; + } | { - other_elts: OtherEltsInner; - }; + other_elts: OtherEltsInner; + }; export interface Inode { length: string; @@ -1676,6 +1676,7 @@ export interface OperationContentsAndResultMetadataOrigination { } export type ConstantsResponse = ConstantsResponseCommon & + ConstantsResponseProto020 & ConstantsResponseProto019 & ConstantsResponseProto017 & ConstantsResponseProto016 & @@ -1720,6 +1721,89 @@ export interface ConstantsResponseCommon { export type Ratio = { numerator: number; denominator: number }; +export interface ConstantsResponseProto020 + extends Omit< + ConstantsResponseProto019, + | 'adaptive_rewards_params' + | 'blocks_per_stake_snapshot' + | 'dal_parametric' + | 'issuance_weights' + | 'liquidity_baking_subsidy_weight' + | 'preserved_cycles' + | 'smart_rollup_reveal_activation_level' + > { + adaptive_issuance_force_activation: boolean; + adaptive_rewards_params: { + center_dz: { + denominator: string; + numerator: string; + }; + growth_rate: { + denominator: string; + numerator: string; + }; + issuance_ratio_final_max: { + denominator: string; + numerator: string; + }; + issuance_ratio_final_min: { + denominator: string; + numerator: string; + }; + issuance_ratio_initial_max: { + denominator: string; + numerator: string; + }; + issuance_ratio_initial_min: { + denominator: string; + numerator: string; + }; + max_bonus: string; + radius_dz: { + denominator: string; + numerator: string; + }; + initial_period: number; + transition_period: number; + }; + blocks_preservation_cycles: number; + consensus_rights_delay: number; + dal_parametric: { + attestation_lag: number; + attestation_threshold: number; + feature_enable: boolean; + incentives_enable: boolean; + number_of_shards: number; + number_of_slots: number; + page_size: number; + redundancy_factor: number; + slot_size: number; + }; + delegate_parameters_activation_delay: number; + direct_ticket_spending_enable: boolean; + issuance_weights: { + attesting_reward_weight: number; + baking_reward_bonus_weight: number; + baking_reward_fixed_portion_weight: number; + base_total_issued_per_minute: string; + seed_nonce_revelation_tip_weight: number; + vdf_revelation_tip_weight: number; + }; + liquidity_baking_subsidy: string; + max_slashing_per_block: number; + max_slashing_threshold: number; + ns_enable: boolean; + smart_rollup_reveal_activation_level: { + dal_attested_slots_validity_lag: number; + dal_page: number; + dal_parameters: number; + metadata: number; + raw_data: { + Blake2B: number; + }; + }; +} + export interface ConstantsResponseProto019 extends Omit< ConstantsResponseProto017, @@ -1801,6 +1885,7 @@ export interface ConstantsResponseProto019 smart_rollup_riscv_pvm_enable: boolean; zk_rollup_max_ticket_payload_size: number; } + export type ConstantsResponseProto017 = ConstantsResponseProto016; export interface ConstantsResponseProto016 @@ -1966,10 +2051,10 @@ export interface ConstantsResponseProto010 extends ConstantsResponseProto009 { } // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface ConstantsResponseProto009 extends ConstantsResponseProto008 { } +export interface ConstantsResponseProto009 extends ConstantsResponseProto008 {} // eslint-disable-next-line @typescript-eslint/no-empty-interface -export interface ConstantsResponseProto008 extends ConstantsResponseProto007 { } +export interface ConstantsResponseProto008 extends ConstantsResponseProto007 {} export interface ConstantsResponseProto007 extends Omit { @@ -2177,12 +2262,12 @@ export type ProtocolsResponse = { export type Next = | { - next: number; - } + next: number; + } | { - newest: number; - oldest: number; - }; + newest: number; + oldest: number; + }; export type LastRemovedCommitmentHashes = { last_message_hash: string;