From 9f659b9f7c18198a1511c0ccb28d3ef57bd7b2bc Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 5 Nov 2024 14:14:17 +0900 Subject: [PATCH 01/12] use saturating sub --- target_chains/ton/contracts/contracts/Pyth.fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_chains/ton/contracts/contracts/Pyth.fc b/target_chains/ton/contracts/contracts/Pyth.fc index 463a392c3f..fb08ceabf0 100644 --- a/target_chains/ton/contracts/contracts/Pyth.fc +++ b/target_chains/ton/contracts/contracts/Pyth.fc @@ -119,7 +119,7 @@ int get_is_valid_data_source(cell data_source) method_id { load_data(); (int price, int conf, int expo, int publish_time) = get_price_unsafe(price_feed_id); int current_time = now(); - throw_if(ERROR_OUTDATED_PRICE, current_time - publish_time > time_period); + throw_if(ERROR_OUTDATED_PRICE, max(0, current_time - publish_time) > time_period); return (price, conf, expo, publish_time); } From f7778654857e62718381feee5b20d3475052a66e Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 5 Nov 2024 14:14:50 +0900 Subject: [PATCH 02/12] use saturating sub for ema price --- target_chains/ton/contracts/contracts/Pyth.fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_chains/ton/contracts/contracts/Pyth.fc b/target_chains/ton/contracts/contracts/Pyth.fc index fb08ceabf0..31242abe01 100644 --- a/target_chains/ton/contracts/contracts/Pyth.fc +++ b/target_chains/ton/contracts/contracts/Pyth.fc @@ -137,7 +137,7 @@ int get_is_valid_data_source(cell data_source) method_id { load_data(); (int price, int conf, int expo, int publish_time) = get_ema_price_unsafe(price_feed_id); int current_time = now(); - throw_if(ERROR_OUTDATED_PRICE, current_time - publish_time > time_period); + throw_if(ERROR_OUTDATED_PRICE, max(0, current_time - publish_time) > time_period); return (price, conf, expo, publish_time); } From d314988e81e37ea894770d0cfcf73bb7b64ab629 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 5 Nov 2024 14:21:56 +0900 Subject: [PATCH 03/12] validate data sources length --- target_chains/ton/contracts/contracts/Pyth.fc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target_chains/ton/contracts/contracts/Pyth.fc b/target_chains/ton/contracts/contracts/Pyth.fc index 31242abe01..5f9e97cd9e 100644 --- a/target_chains/ton/contracts/contracts/Pyth.fc +++ b/target_chains/ton/contracts/contracts/Pyth.fc @@ -334,6 +334,9 @@ int apply_decimal_expo(int value, int expo) { new_data_sources~udict_set(256, data_source_key, begin_cell().store_int(true, 1).end_cell().begin_parse()); } + ;; Verify that all data in the payload was processed + throw_unless(ERROR_INVALID_UPDATE_DATA_LENGTH, payload.slice_empty?()); + is_valid_data_source = new_data_sources; } From be2358fc0cb93b4c6d3791c3e106e3063003c932 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 5 Nov 2024 14:23:14 +0900 Subject: [PATCH 04/12] use the right error type --- target_chains/ton/contracts/contracts/Pyth.fc | 2 +- target_chains/ton/contracts/contracts/common/errors.fc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/target_chains/ton/contracts/contracts/Pyth.fc b/target_chains/ton/contracts/contracts/Pyth.fc index 5f9e97cd9e..a3d2d3fa82 100644 --- a/target_chains/ton/contracts/contracts/Pyth.fc +++ b/target_chains/ton/contracts/contracts/Pyth.fc @@ -335,7 +335,7 @@ int apply_decimal_expo(int value, int expo) { } ;; Verify that all data in the payload was processed - throw_unless(ERROR_INVALID_UPDATE_DATA_LENGTH, payload.slice_empty?()); + throw_unless(ERROR_INVALID_PAYLOAD_LENGTH, payload.slice_empty?()); is_valid_data_source = new_data_sources; } diff --git a/target_chains/ton/contracts/contracts/common/errors.fc b/target_chains/ton/contracts/contracts/common/errors.fc index 514928f8ac..0d08b75472 100644 --- a/target_chains/ton/contracts/contracts/common/errors.fc +++ b/target_chains/ton/contracts/contracts/common/errors.fc @@ -42,6 +42,7 @@ const int ERROR_INVALID_GOVERNANCE_TARGET = 2015; const int ERROR_INVALID_GOVERNANCE_MAGIC = 2016; const int ERROR_INVALID_GOVERNANCE_MODULE = 2017; const int ERROR_INVALID_CODE_HASH = 2018; +const int ERROR_INVALID_PAYLOAD_LENGTH = 2019; ;; Common const int ERROR_INSUFFICIENT_GAS = 3000; From 7832e3865f7eb57ce9d2ec3b5aa1dc19e71bd2eb Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 5 Nov 2024 14:32:27 +0900 Subject: [PATCH 05/12] fix magic number --- target_chains/ton/contracts/contracts/Pyth.fc | 2 +- target_chains/ton/contracts/contracts/Wormhole.fc | 4 ++-- target_chains/ton/contracts/contracts/common/constants.fc | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/target_chains/ton/contracts/contracts/Pyth.fc b/target_chains/ton/contracts/contracts/Pyth.fc index a3d2d3fa82..14a22b80b9 100644 --- a/target_chains/ton/contracts/contracts/Pyth.fc +++ b/target_chains/ton/contracts/contracts/Pyth.fc @@ -39,7 +39,7 @@ slice read_and_verify_header(slice data) { slice cs = read_and_verify_proof(root_digest, message, cs); int message_type = message~load_uint(8); - throw_unless(ERROR_INVALID_MESSAGE_TYPE, message_type == 0); ;; 0 corresponds to PriceFeed + throw_unless(ERROR_INVALID_MESSAGE_TYPE, message_type == PRICE_FEED_MESSAGE_TYPE); int price_id = message~load_uint(256); int price = message~load_int(64); diff --git a/target_chains/ton/contracts/contracts/Wormhole.fc b/target_chains/ton/contracts/contracts/Wormhole.fc index 5978e51192..1b99801d19 100644 --- a/target_chains/ton/contracts/contracts/Wormhole.fc +++ b/target_chains/ton/contracts/contracts/Wormhole.fc @@ -130,7 +130,7 @@ int governance_action_is_consumed(int hash) method_id { load_data(); ;; Parse VM fields int version = in_msg_body~load_uint(8); - throw_unless(ERROR_INVALID_VERSION, version == 1); + throw_unless(ERROR_INVALID_VERSION, version == WORMHOLE_VM_VERSION); int vm_guardian_set_index = in_msg_body~load_uint(32); ;; Verify and check if guardian set is valid (int expiration_time, cell keys_dict, int key_count) = get_guardian_set_internal(vm_guardian_set_index); @@ -194,7 +194,7 @@ int governance_action_is_consumed(int hash) method_id { throw_unless(ERROR_INVALID_MODULE, module == UPGRADE_MODULE); int action = payload~load_uint(8); - throw_unless(ERROR_INVALID_GOVERNANCE_ACTION, action == 2); + throw_unless(ERROR_INVALID_GOVERNANCE_ACTION, action == GUARDIAN_SET_UPGRADE_ACTION); int chain = payload~load_uint(16); int new_guardian_set_index = payload~load_uint(32); diff --git a/target_chains/ton/contracts/contracts/common/constants.fc b/target_chains/ton/contracts/contracts/common/constants.fc index 1408d43a21..6da733475f 100644 --- a/target_chains/ton/contracts/contracts/common/constants.fc +++ b/target_chains/ton/contracts/contracts/common/constants.fc @@ -5,11 +5,16 @@ const int GOVERNANCE_MODULE = 1; const int MAJOR_VERSION = 1; const int MINIMUM_ALLOWED_MINOR_VERSION = 0; +const int WORMHOLE_VM_VERSION = 1; + const int GUARDIAN_SET_EXPIRY = 86400; ;; 1 day in seconds const int UPGRADE_MODULE = 0x0000000000000000000000000000000000000000000000000000000000436f7265; ;; "Core" (left-padded to 256 bits) in hex +const int GUARDIAN_SET_UPGRADE_ACTION = 2; const int WORMHOLE_MERKLE_UPDATE_TYPE = 0; +const int PRICE_FEED_MESSAGE_TYPE = 0; + {- The main workchain ID in TON. Currently, TON has two blockchains: 1. Masterchain: Used for system-level operations and consensus. From 8494812065e3257d178c956d5de46e6124de8f22 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 5 Nov 2024 14:42:21 +0900 Subject: [PATCH 06/12] add impure to functions that throw --- target_chains/ton/contracts/contracts/Pyth.fc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target_chains/ton/contracts/contracts/Pyth.fc b/target_chains/ton/contracts/contracts/Pyth.fc index 14a22b80b9..951cdcf1f1 100644 --- a/target_chains/ton/contracts/contracts/Pyth.fc +++ b/target_chains/ton/contracts/contracts/Pyth.fc @@ -17,7 +17,7 @@ cell store_price(int price, int conf, int expo, int publish_time) { .end_cell(); } -slice read_and_verify_header(slice data) { +slice read_and_verify_header(slice data) impure { int magic = data~load_uint(32); throw_unless(ERROR_INVALID_MAGIC, magic == ACCUMULATOR_MAGIC); int major_version = data~load_uint(8); @@ -240,7 +240,7 @@ int parse_pyth_payload_in_wormhole_vm(slice payload) impure { last_executed_governance_sequence = sequence; } -(int, int, slice) parse_governance_instruction(slice payload) { +(int, int, slice) parse_governance_instruction(slice payload) impure { int magic = payload~load_uint(32); throw_unless(ERROR_INVALID_GOVERNANCE_MAGIC, magic == GOVERNANCE_MAGIC); From 0b2895d6eb9b7372a172e3a16aae3273404151f4 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 5 Nov 2024 14:48:33 +0900 Subject: [PATCH 07/12] dont redefine global vars --- target_chains/ton/contracts/contracts/Wormhole.fc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target_chains/ton/contracts/contracts/Wormhole.fc b/target_chains/ton/contracts/contracts/Wormhole.fc index 1b99801d19..6d1cf019c4 100644 --- a/target_chains/ton/contracts/contracts/Wormhole.fc +++ b/target_chains/ton/contracts/contracts/Wormhole.fc @@ -189,7 +189,7 @@ int governance_action_is_consumed(int hash) method_id { ); } -(int, int, int, cell, int) parse_encoded_upgrade(int current_guardian_set_index, slice payload) impure { +(int, int, int, cell, int) parse_encoded_upgrade(int guardian_set_index, slice payload) impure { int module = payload~load_uint(256); throw_unless(ERROR_INVALID_MODULE, module == UPGRADE_MODULE); @@ -198,7 +198,7 @@ int governance_action_is_consumed(int hash) method_id { int chain = payload~load_uint(16); int new_guardian_set_index = payload~load_uint(32); - throw_unless(ERROR_NEW_GUARDIAN_SET_INDEX_IS_INVALID, new_guardian_set_index == (current_guardian_set_index + 1)); + throw_unless(ERROR_NEW_GUARDIAN_SET_INDEX_IS_INVALID, new_guardian_set_index == (guardian_set_index + 1)); int guardian_length = payload~load_uint(8); throw_unless(ERROR_INVALID_GUARDIAN_SET_KEYS_LENGTH, guardian_length > 0); @@ -232,10 +232,10 @@ int governance_action_is_consumed(int hash) method_id { (int version, int vm_guardian_set_index, int timestamp, int nonce, int emitter_chain_id, int emitter_address, int sequence, int consistency_level, slice payload, int hash) = parse_and_verify_wormhole_vm(in_msg_body); ;; Verify the emitter chain and address - int governance_chain_id = get_governance_chain_id(); - throw_unless(ERROR_INVALID_GOVERNANCE_CHAIN, emitter_chain_id == governance_chain_id); - int governance_contract_address = get_governance_contract(); - throw_unless(ERROR_INVALID_GOVERNANCE_CONTRACT, emitter_address == governance_contract_address); + int chain_id = get_governance_chain_id(); + throw_unless(ERROR_INVALID_GOVERNANCE_CHAIN, emitter_chain_id == chain_id); + int contract_address = get_governance_contract(); + throw_unless(ERROR_INVALID_GOVERNANCE_CONTRACT, emitter_address == contract_address); ;; Check if the governance action has already been consumed throw_if(ERROR_GOVERNANCE_ACTION_ALREADY_CONSUMED, governance_action_is_consumed(hash)); From cd331bf0dabc0c01818473da95d76cd6cef146c6 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 5 Nov 2024 14:49:58 +0900 Subject: [PATCH 08/12] use global var directly --- target_chains/ton/contracts/contracts/Wormhole.fc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/target_chains/ton/contracts/contracts/Wormhole.fc b/target_chains/ton/contracts/contracts/Wormhole.fc index 6d1cf019c4..399675d833 100644 --- a/target_chains/ton/contracts/contracts/Wormhole.fc +++ b/target_chains/ton/contracts/contracts/Wormhole.fc @@ -232,10 +232,8 @@ int governance_action_is_consumed(int hash) method_id { (int version, int vm_guardian_set_index, int timestamp, int nonce, int emitter_chain_id, int emitter_address, int sequence, int consistency_level, slice payload, int hash) = parse_and_verify_wormhole_vm(in_msg_body); ;; Verify the emitter chain and address - int chain_id = get_governance_chain_id(); - throw_unless(ERROR_INVALID_GOVERNANCE_CHAIN, emitter_chain_id == chain_id); - int contract_address = get_governance_contract(); - throw_unless(ERROR_INVALID_GOVERNANCE_CONTRACT, emitter_address == contract_address); + throw_unless(ERROR_INVALID_GOVERNANCE_CHAIN, emitter_chain_id == governance_chain_id); + throw_unless(ERROR_INVALID_GOVERNANCE_CONTRACT, emitter_address == governance_contract); ;; Check if the governance action has already been consumed throw_if(ERROR_GOVERNANCE_ACTION_ALREADY_CONSUMED, governance_action_is_consumed(hash)); From 3faa97fee147f874c3fa1254a5c80267dd56b310 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 5 Nov 2024 14:53:33 +0900 Subject: [PATCH 09/12] remove unused variables --- target_chains/ton/contracts/contracts/Pyth.fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_chains/ton/contracts/contracts/Pyth.fc b/target_chains/ton/contracts/contracts/Pyth.fc index 951cdcf1f1..7e3bc8e043 100644 --- a/target_chains/ton/contracts/contracts/Pyth.fc +++ b/target_chains/ton/contracts/contracts/Pyth.fc @@ -202,7 +202,7 @@ int parse_pyth_payload_in_wormhole_vm(slice payload) impure { int root_digest = parse_pyth_payload_in_wormhole_vm(payload); repeat(num_updates) { - (int price_id, int price, int conf, int expo, int publish_time, int prev_publish_time, int ema_price, int ema_conf, slice new_cs) = read_and_verify_message(cs, root_digest); + (int price_id, int price, int conf, int expo, int publish_time, _, int ema_price, int ema_conf, slice new_cs) = read_and_verify_message(cs, root_digest); cs = new_cs; (slice latest_price_info, int found?) = latest_price_feeds.udict_get?(256, price_id); From 1583bf19227cb3281c3f9a174d391e3877c85430 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 5 Nov 2024 14:53:57 +0900 Subject: [PATCH 10/12] remove debugging code --- target_chains/ton/contracts/contracts/Wormhole.fc | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/target_chains/ton/contracts/contracts/Wormhole.fc b/target_chains/ton/contracts/contracts/Wormhole.fc index 399675d833..283559e046 100644 --- a/target_chains/ton/contracts/contracts/Wormhole.fc +++ b/target_chains/ton/contracts/contracts/Wormhole.fc @@ -14,19 +14,6 @@ "NULLSWAPIFNOT" ;; If recovery failed, insert null under the top of the stack "NULLSWAPIFNOT2"; ;; If recovery failed, insert two more nulls under the top of the stack -;; For troubleshooting purposes -() dump_guardian_sets(cell keys_dict) impure { - int key = -1; - do { - (key, slice value, int found) = keys_dict.udict_get_next?(32, key); - if (found) { - ~dump(key); - ~dump(value); - } - } until (~ found); -} - - ;; Internal helper methods (int, cell, int) parse_guardian_set(slice guardian_set) { slice cs = guardian_set~load_ref().begin_parse(); From 040b7662791c3a90b52aebc2c80c79e645e20345 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 5 Nov 2024 15:20:32 +0900 Subject: [PATCH 11/12] remove unused variable num_data_sources --- target_chains/ton/contracts/contracts/common/storage.fc | 3 --- target_chains/ton/contracts/wrappers/BaseWrapper.ts | 1 - 2 files changed, 4 deletions(-) diff --git a/target_chains/ton/contracts/contracts/common/storage.fc b/target_chains/ton/contracts/contracts/common/storage.fc index e7e947b656..0e8eed52c0 100644 --- a/target_chains/ton/contracts/contracts/common/storage.fc +++ b/target_chains/ton/contracts/contracts/common/storage.fc @@ -9,7 +9,6 @@ global int single_update_fee; ;; emitter_chain_id is a 16-bit unsigned integer ;; emitter_address is a 256-bit unsigned integer global cell data_sources; ;; Dictionary of DataSource tuples, keyed by u8 -global int num_data_sources; global cell is_valid_data_source; ;; Dictionary of int (0 as false, -1 as true), keyed by DataSource cell_hash global int upgrade_code_hash; ;; 256-bit unsigned integer @@ -38,7 +37,6 @@ global int governance_data_source_index; ;; u32 cell data_sources_cell = begin_cell() .store_dict(data_sources) - .store_uint(num_data_sources, 32) .store_dict(is_valid_data_source) .end_cell(); @@ -79,7 +77,6 @@ global int governance_data_source_index; ;; u32 cell data_sources_cell = ds~load_ref(); slice data_sources_slice = data_sources_cell.begin_parse(); data_sources = data_sources_slice~load_dict(); - num_data_sources = data_sources_slice~load_uint(32); is_valid_data_source = data_sources_slice~load_dict(); cell guardian_set_cell = ds~load_ref(); diff --git a/target_chains/ton/contracts/wrappers/BaseWrapper.ts b/target_chains/ton/contracts/wrappers/BaseWrapper.ts index 65008df410..911532e5cf 100644 --- a/target_chains/ton/contracts/wrappers/BaseWrapper.ts +++ b/target_chains/ton/contracts/wrappers/BaseWrapper.ts @@ -111,7 +111,6 @@ export class BaseWrapper implements Contract { // Group data sources information const dataSourcesCell = beginCell() .storeDict(dataSourcesDict) - .storeUint(config.dataSources ? config.dataSources.length : 0, 32) .storeDict(isValidDataSourceDict) .endCell(); From 2b26e0750a870c6a7f6c6b5a93e7fc003fa21f95 Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Tue, 5 Nov 2024 16:33:24 +0900 Subject: [PATCH 12/12] remove unused variable data_sources --- target_chains/ton/contracts/contracts/Pyth.fc | 5 ----- target_chains/ton/contracts/contracts/common/storage.fc | 3 --- target_chains/ton/contracts/contracts/tests/PythTest.fc | 4 ---- target_chains/ton/contracts/tests/PythTest.spec.ts | 7 ------- target_chains/ton/contracts/wrappers/BaseWrapper.ts | 9 +-------- 5 files changed, 1 insertion(+), 27 deletions(-) diff --git a/target_chains/ton/contracts/contracts/Pyth.fc b/target_chains/ton/contracts/contracts/Pyth.fc index 7e3bc8e043..ddee6141ef 100644 --- a/target_chains/ton/contracts/contracts/Pyth.fc +++ b/target_chains/ton/contracts/contracts/Pyth.fc @@ -80,11 +80,6 @@ int get_governance_data_source_index() method_id { return governance_data_source_index; } -cell get_data_sources() method_id { - load_data(); - return data_sources; -} - cell get_governance_data_source() method_id { load_data(); return governance_data_source; diff --git a/target_chains/ton/contracts/contracts/common/storage.fc b/target_chains/ton/contracts/contracts/common/storage.fc index 0e8eed52c0..5084596ad0 100644 --- a/target_chains/ton/contracts/contracts/common/storage.fc +++ b/target_chains/ton/contracts/contracts/common/storage.fc @@ -8,7 +8,6 @@ global int single_update_fee; ;; DataSource struct: (emitter_chain_id: int, emitter_address: int) ;; emitter_chain_id is a 16-bit unsigned integer ;; emitter_address is a 256-bit unsigned integer -global cell data_sources; ;; Dictionary of DataSource tuples, keyed by u8 global cell is_valid_data_source; ;; Dictionary of int (0 as false, -1 as true), keyed by DataSource cell_hash global int upgrade_code_hash; ;; 256-bit unsigned integer @@ -36,7 +35,6 @@ global int governance_data_source_index; ;; u32 .end_cell(); cell data_sources_cell = begin_cell() - .store_dict(data_sources) .store_dict(is_valid_data_source) .end_cell(); @@ -76,7 +74,6 @@ global int governance_data_source_index; ;; u32 cell data_sources_cell = ds~load_ref(); slice data_sources_slice = data_sources_cell.begin_parse(); - data_sources = data_sources_slice~load_dict(); is_valid_data_source = data_sources_slice~load_dict(); cell guardian_set_cell = ds~load_ref(); diff --git a/target_chains/ton/contracts/contracts/tests/PythTest.fc b/target_chains/ton/contracts/contracts/tests/PythTest.fc index 008f2cc535..d65bab5c40 100644 --- a/target_chains/ton/contracts/contracts/tests/PythTest.fc +++ b/target_chains/ton/contracts/contracts/tests/PythTest.fc @@ -77,7 +77,3 @@ (int) test_get_is_valid_data_source(cell data_source) method_id { return get_is_valid_data_source(data_source); } - -(cell) test_get_data_sources() method_id { - return get_data_sources(); -} diff --git a/target_chains/ton/contracts/tests/PythTest.spec.ts b/target_chains/ton/contracts/tests/PythTest.spec.ts index fad4c21a8f..0312f2af76 100644 --- a/target_chains/ton/contracts/tests/PythTest.spec.ts +++ b/target_chains/ton/contracts/tests/PythTest.spec.ts @@ -974,11 +974,4 @@ describe("PythTest", () => { // Verify that the contract has not been upgraded by attempting to call the new method await expect(pythTest.getNewFunction()).rejects.toThrow(); }); - - it("should correctly get data sources", async () => { - await deployContract(); - - const dataSources = await pythTest.getDataSources(); - expect(dataSources).toEqual(DATA_SOURCES); - }); }); diff --git a/target_chains/ton/contracts/wrappers/BaseWrapper.ts b/target_chains/ton/contracts/wrappers/BaseWrapper.ts index 911532e5cf..e21ff376f7 100644 --- a/target_chains/ton/contracts/wrappers/BaseWrapper.ts +++ b/target_chains/ton/contracts/wrappers/BaseWrapper.ts @@ -79,11 +79,6 @@ export class BaseWrapper implements Contract { priceDict.set(BigInt(config.priceFeedId), priceFeedCell); } - // Create a dictionary for data sources - const dataSourcesDict = Dictionary.empty( - Dictionary.Keys.Uint(8), - Dictionary.Values.Cell() - ); // Create a dictionary for valid data sources const isValidDataSourceDict = Dictionary.empty( Dictionary.Keys.BigUint(256), @@ -91,12 +86,11 @@ export class BaseWrapper implements Contract { ); if (config.dataSources) { - config.dataSources.forEach((source, index) => { + config.dataSources.forEach((source) => { const sourceCell = beginCell() .storeUint(source.emitterChain, 16) .storeBuffer(Buffer.from(source.emitterAddress, "hex")) .endCell(); - dataSourcesDict.set(index, sourceCell); const cellHash = BigInt("0x" + sourceCell.hash().toString("hex")); isValidDataSourceDict.set(cellHash, true); }); @@ -110,7 +104,6 @@ export class BaseWrapper implements Contract { // Group data sources information const dataSourcesCell = beginCell() - .storeDict(dataSourcesDict) .storeDict(isValidDataSourceDict) .endCell();