diff --git a/src/generators/typescript/generator.ts b/src/generators/typescript/generator.ts index 9578a9b..f2508ba 100644 --- a/src/generators/typescript/generator.ts +++ b/src/generators/typescript/generator.ts @@ -709,15 +709,28 @@ export class TypescriptGenerator implements CodeGenerator { fieldStoreSuffix: "Address", }; } else if (fieldType.kind == "TLBHashmapType") { - if (fieldType.key.kind == 'TLBExprMathType' && fieldType.value.kind == 'TLBNumberType') { - result.loadExpr = tFunctionCall(tMemberExpression(id(currentSlice), id('loadDict')), [ - tFunctionCall(tMemberExpression(id('Dictionary.Keys'), id('Uint')), [convertToAST(fieldType.key.expr, ctx.constructor)]), - tFunctionCall(tMemberExpression(id('Dictionary.Values'), id('Uint')), [convertToAST(fieldType.value.bits, ctx.constructor)]), - ]) + let key: Expression | undefined + let value: Expression | undefined + let valueType: TypeExpression | undefined + if (fieldType.key.kind == 'TLBExprMathType') { + key = tFunctionCall(tMemberExpression(id('Dictionary.Keys'), id('Uint')), [convertToAST(fieldType.key.expr, ctx.constructor)]); + } else { + key = id('hello') + } + if (fieldType.value.kind == 'TLBNumberType') { + value = tFunctionCall(tMemberExpression(id('Dictionary.Values'), id('Uint')), [convertToAST(fieldType.value.bits, ctx.constructor)]); + valueType = id('number') + } else { + value = tFunctionCall(tMemberExpression(id('Dictionary.Values'), id('Cell')), []) + valueType = id('Cell') + } + if (key && value && valueType) { + result.loadExpr = tFunctionCall(tMemberExpression(id(currentSlice), id('loadDict')), [key, value]) + result.storeStmtInside = tExpressionStatement(tFunctionCall(tMemberExpression(id(currentCell), id('storeDict')), [tMemberExpression(id(ctx.typeName), id(fieldName)), key, value])) + result.storeStmtOutside = result.storeStmtInside + result.typeParamExpr = tTypeWithParameters(id('Dictionary'), tTypeParametersExpression([id('number'), valueType])) } - result.storeStmtInside = tExpressionStatement(tFunctionCall(tMemberExpression(id(currentCell), id('storeDict')), [tMemberExpression(id(ctx.typeName), id(fieldName))])) - result.storeStmtOutside = result.storeStmtInside - result.typeParamExpr = tTypeWithParameters(id('Dictionary'), tTypeParametersExpression([id('number'), id('number')])) + } else if (fieldType.kind == "TLBExprMathType") { result.loadExpr = convertToAST(fieldType.expr, ctx.constructor); result.storeStmtOutside = tExpressionStatement(result.loadExpr); diff --git a/test/generated_files/generated_block.ts b/test/generated_files/generated_block.ts index 4256363..600a4f9 100644 --- a/test/generated_files/generated_block.ts +++ b/test/generated_files/generated_block.ts @@ -316,7 +316,7 @@ export interface Coins { export interface ExtraCurrencyCollection { readonly kind: 'ExtraCurrencyCollection'; - readonly dict: Dictionary; + readonly dict: Dictionary; } export interface CurrencyCollection { @@ -401,7 +401,7 @@ export interface StateInitWithLibs { readonly special: Maybe; readonly code: Maybe; readonly data: Maybe; - readonly library: Dictionary; + readonly library: Dictionary; } export interface SimpleLib { @@ -596,7 +596,7 @@ export interface ProcessedUpto { export interface ProcessedInfo { readonly kind: 'ProcessedInfo'; - readonly anon0: Dictionary; + readonly anon0: Dictionary; } export interface IhrPendingSince { @@ -606,7 +606,7 @@ export interface IhrPendingSince { export interface IhrPendingInfo { readonly kind: 'IhrPendingInfo'; - readonly anon0: Dictionary; + readonly anon0: Dictionary; } export interface OutMsgQueueInfo { @@ -719,7 +719,7 @@ export interface Transaction { readonly orig_status: AccountStatus; readonly end_status: AccountStatus; readonly in_msg: Maybe>; - readonly out_msgs: Dictionary; + readonly out_msgs: Dictionary; readonly total_fees: CurrencyCollection; readonly state_update: HASH_UPDATE; readonly description: TransactionDescr; @@ -1050,7 +1050,7 @@ export interface ShardStateUnsplit { readonly underload_history: number; readonly total_balance: CurrencyCollection; readonly total_validator_fees: CurrencyCollection; - readonly libraries: Dictionary; + readonly libraries: Dictionary; readonly master_ref: Maybe; readonly custom: Maybe; } @@ -1245,7 +1245,7 @@ export interface ShardDescr_shard_descr_new { export interface ShardHashes { readonly kind: 'ShardHashes'; - readonly anon0: Dictionary; + readonly anon0: Dictionary; } export type BinTreeAug = BinTreeAug_bta_leaf | BinTreeAug_bta_fork; @@ -1328,7 +1328,7 @@ export type BlockCreateStats = BlockCreateStats_block_create_stats | BlockCreate export interface BlockCreateStats_block_create_stats { readonly kind: 'BlockCreateStats_block_create_stats'; - readonly counters: Dictionary; + readonly counters: Dictionary; } export interface BlockCreateStats_block_create_stats_ext { @@ -1402,7 +1402,7 @@ export interface McBlockExtra { readonly key_block: number; readonly shard_hashes: ShardHashes; readonly shard_fees: ShardFees; - readonly prev_blk_signatures: Dictionary; + readonly prev_blk_signatures: Dictionary; readonly recover_create_msg: Maybe; readonly mint_msg: Maybe; readonly config: ConfigParams | undefined; @@ -1441,7 +1441,7 @@ export interface ValidatorSet_validators_ext { readonly total: number; readonly main: number; readonly total_weight: number; - readonly list: Dictionary; + readonly list: Dictionary; } export type ConfigParam = ConfigParam__ | ConfigParam__1 | ConfigParam__2 | ConfigParam__3 | ConfigParam__4 | ConfigParam__5 | ConfigParam__6 | ConfigParam__7 | ConfigParam__8 | ConfigParam__9 | ConfigParam__10 | ConfigParam__11 | ConfigParam__12 | ConfigParam__13 | ConfigParam__14 | ConfigParam__15 | ConfigParam__16 | ConfigParam__17 | ConfigParam__18 | ConfigParam__19 | ConfigParam_config_mc_gas_prices | ConfigParam_config_gas_prices | ConfigParam_config_mc_block_limits | ConfigParam_config_block_limits | ConfigParam_config_mc_fwd_prices | ConfigParam_config_fwd_prices | ConfigParam__26 | ConfigParam__27 | ConfigParam__28 | ConfigParam__29 | ConfigParam__30 | ConfigParam__31 | ConfigParam__32 | ConfigParam__33 | ConfigParam__34 | ConfigParam__35 | ConfigParam__36 | ConfigParam__37 | ConfigParam__38 | ConfigParam__39 | ConfigParam__40 | ConfigParam__41 | ConfigParam__42 | ConfigParam__43 | ConfigParam__44; @@ -1509,7 +1509,7 @@ export interface ConfigParam__11 { export interface ConfigParam__12 { readonly kind: 'ConfigParam__12'; - readonly workchains: Dictionary; + readonly workchains: Dictionary; } export interface ConfigParam__13 { @@ -1597,7 +1597,7 @@ export interface ConfigParam__27 { export interface ConfigParam__28 { readonly kind: 'ConfigParam__28'; - readonly fundamental_smc_addr: Dictionary; + readonly fundamental_smc_addr: Dictionary; } export interface ConfigParam__29 { @@ -1632,7 +1632,7 @@ export interface ConfigParam__34 { export interface ConfigParam__35 { readonly kind: 'ConfigParam__35'; - readonly anon0: Dictionary; + readonly anon0: Dictionary; } export interface ConfigParam__36 { @@ -1723,7 +1723,7 @@ export interface ConfigProposalStatus { readonly expires: number; readonly proposal: ConfigProposal; readonly is_critical: boolean; - readonly voters: Dictionary; + readonly voters: Dictionary; readonly remaining_weight: number; readonly validator_set_id: bigint; readonly rounds_remaining: number; @@ -2001,7 +2001,7 @@ export interface SizeLimitsConfig_size_limits_config_v2 { export interface SuspendedAddressList { readonly kind: 'SuspendedAddressList'; - readonly addresses: Dictionary; + readonly addresses: Dictionary; readonly suspended_until: number; } @@ -2048,7 +2048,7 @@ export interface BlockSignaturesPure { readonly kind: 'BlockSignaturesPure'; readonly sig_count: number; readonly sig_weight: number; - readonly signatures: Dictionary; + readonly signatures: Dictionary; } export interface BlockSignatures { @@ -2087,7 +2087,7 @@ export interface TopBlockDescr { export interface TopBlockDescrSet { readonly kind: 'TopBlockDescrSet'; - readonly collection: Dictionary; + readonly collection: Dictionary; } export interface ProducerInfo { @@ -2127,7 +2127,7 @@ export interface ValidatorComplaint { export interface ValidatorComplaintStatus { readonly kind: 'ValidatorComplaintStatus'; readonly complaint: ValidatorComplaint; - readonly voters: Dictionary; + readonly voters: Dictionary; readonly vset_id: bigint; readonly weight_remaining: number; } @@ -2238,7 +2238,7 @@ export interface VmStackList_vm_stk_cons { export interface VmSaveList { readonly kind: 'VmSaveList'; - readonly cregs: Dictionary; + readonly cregs: Dictionary; } export interface VmGasLimits { @@ -2251,7 +2251,7 @@ export interface VmGasLimits { export interface VmLibraries { readonly kind: 'VmLibraries'; - readonly libraries: Dictionary; + readonly libraries: Dictionary; } export interface VmControlData { @@ -2325,7 +2325,7 @@ export interface VmCont_vmc_pushint { export interface DNS_RecordSet { readonly kind: 'DNS_RecordSet'; - readonly anon0: Dictionary; + readonly anon0: Dictionary; } export type TextChunkRef = TextChunkRef_chunk_ref_empty | TextChunkRef_chunk_ref; @@ -3776,15 +3776,17 @@ extra_currencies$_ dict:(HashmapE 32 (VarUInteger 32)) */ export function loadExtraCurrencyCollection(slice: Slice): ExtraCurrencyCollection { + let dict: Dictionary = slice.loadDict(Dictionary.Keys.Uint(32), Dictionary.Values.Cell()); return { kind: 'ExtraCurrencyCollection', + dict: dict, } } export function storeExtraCurrencyCollection(extraCurrencyCollection: ExtraCurrencyCollection): (builder: Builder) => void { return ((builder: Builder) => { - builder.storeDict(extraCurrencyCollection.dict); + builder.storeDict(extraCurrencyCollection.dict, Dictionary.Keys.Uint(32), Dictionary.Values.Cell()); }) } @@ -4137,12 +4139,14 @@ export function loadStateInitWithLibs(slice: Slice): StateInitWithLibs { return slice1 })); + let library: Dictionary = slice.loadDict(Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); return { kind: 'StateInitWithLibs', split_depth: split_depth, special: special, code: code, data: data, + library: library, } } @@ -4174,7 +4178,7 @@ export function storeStateInitWithLibs(stateInitWithLibs: StateInitWithLibs): (b }) }))(builder); - builder.storeDict(stateInitWithLibs.library); + builder.storeDict(stateInitWithLibs.library, Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); }) } @@ -5125,15 +5129,17 @@ export function storeProcessedUpto(processedUpto: ProcessedUpto): (builder: Buil // _ (HashmapE 96 ProcessedUpto) = ProcessedInfo; export function loadProcessedInfo(slice: Slice): ProcessedInfo { + let anon0: Dictionary = slice.loadDict(Dictionary.Keys.Uint(96), Dictionary.Values.Cell()); return { kind: 'ProcessedInfo', + anon0: anon0, } } export function storeProcessedInfo(processedInfo: ProcessedInfo): (builder: Builder) => void { return ((builder: Builder) => { - builder.storeDict(processedInfo.anon0); + builder.storeDict(processedInfo.anon0, Dictionary.Keys.Uint(96), Dictionary.Values.Cell()); }) } @@ -5159,15 +5165,17 @@ export function storeIhrPendingSince(ihrPendingSince: IhrPendingSince): (builder // _ (HashmapE 320 IhrPendingSince) = IhrPendingInfo; export function loadIhrPendingInfo(slice: Slice): IhrPendingInfo { + let anon0: Dictionary = slice.loadDict(Dictionary.Keys.Uint(320), Dictionary.Values.Cell()); return { kind: 'IhrPendingInfo', + anon0: anon0, } } export function storeIhrPendingInfo(ihrPendingInfo: IhrPendingInfo): (builder: Builder) => void { return ((builder: Builder) => { - builder.storeDict(ihrPendingInfo.anon0); + builder.storeDict(ihrPendingInfo.anon0, Dictionary.Keys.Uint(320), Dictionary.Values.Cell()); }) } @@ -5581,6 +5589,7 @@ export function loadTransaction(slice: Slice): Transaction { })) })); + let out_msgs: Dictionary = slice1.loadDict(Dictionary.Keys.Uint(15), Dictionary.Values.Cell()); let total_fees: CurrencyCollection = loadCurrencyCollection(slice); let slice2 = slice.loadRef().beginParse(); let state_update: HASH_UPDATE = loadHASH_UPDATE(slice2, loadAccount); @@ -5597,6 +5606,7 @@ export function loadTransaction(slice: Slice): Transaction { orig_status: orig_status, end_status: end_status, in_msg: in_msg, + out_msgs: out_msgs, total_fees: total_fees, state_update: state_update, description: description, @@ -5632,7 +5642,7 @@ export function storeTransaction(transaction: Transaction): (builder: Builder) = }) }))(cell1); - cell1.storeDict(transaction.out_msgs); + cell1.storeDict(transaction.out_msgs, Dictionary.Keys.Uint(15), Dictionary.Values.Cell()); builder.storeRef(cell1); storeCurrencyCollection(transaction.total_fees)(builder); let cell2 = beginCell(); @@ -7025,6 +7035,7 @@ export function loadShardStateUnsplit(slice: Slice): ShardStateUnsplit { let underload_history: number = slice3.loadUint(64); let total_balance: CurrencyCollection = loadCurrencyCollection(slice3); let total_validator_fees: CurrencyCollection = loadCurrencyCollection(slice3); + let libraries: Dictionary = slice3.loadDict(Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); let master_ref: Maybe = loadMaybe(slice3, loadBlkMasterInfo); let custom: Maybe = loadMaybe(slice, ((slice: Slice) => { let slice1 = slice.loadRef().beginParse(); @@ -7047,6 +7058,7 @@ export function loadShardStateUnsplit(slice: Slice): ShardStateUnsplit { underload_history: underload_history, total_balance: total_balance, total_validator_fees: total_validator_fees, + libraries: libraries, master_ref: master_ref, custom: custom, } @@ -7077,7 +7089,7 @@ export function storeShardStateUnsplit(shardStateUnsplit: ShardStateUnsplit): (b cell3.storeUint(shardStateUnsplit.underload_history, 64); storeCurrencyCollection(shardStateUnsplit.total_balance)(cell3); storeCurrencyCollection(shardStateUnsplit.total_validator_fees)(cell3); - cell3.storeDict(shardStateUnsplit.libraries); + cell3.storeDict(shardStateUnsplit.libraries, Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); storeMaybe(shardStateUnsplit.master_ref, storeBlkMasterInfo)(cell3); builder.storeRef(cell3); storeMaybe(shardStateUnsplit.custom, ((arg: McStateExtra) => { @@ -7937,15 +7949,17 @@ export function storeShardDescr(shardDescr: ShardDescr): (builder: Builder) => v // _ (HashmapE 32 ^(BinTree ShardDescr)) = ShardHashes; export function loadShardHashes(slice: Slice): ShardHashes { + let anon0: Dictionary = slice.loadDict(Dictionary.Keys.Uint(32), Dictionary.Values.Cell()); return { kind: 'ShardHashes', + anon0: anon0, } } export function storeShardHashes(shardHashes: ShardHashes): (builder: Builder) => void { return ((builder: Builder) => { - builder.storeDict(shardHashes.anon0); + builder.storeDict(shardHashes.anon0, Dictionary.Keys.Uint(32), Dictionary.Values.Cell()); }) } @@ -8266,8 +8280,10 @@ export function storeCreatorStats(creatorStats: CreatorStats): (builder: Builder export function loadBlockCreateStats(slice: Slice): BlockCreateStats { if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x17))) { slice.loadUint(8); + let counters: Dictionary = slice.loadDict(Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); return { kind: 'BlockCreateStats_block_create_stats', + counters: counters, } } @@ -8290,7 +8306,7 @@ export function storeBlockCreateStats(blockCreateStats: BlockCreateStats): (buil if ((blockCreateStats.kind == 'BlockCreateStats_block_create_stats')) { return ((builder: Builder) => { builder.storeUint(0x17, 8); - builder.storeDict(blockCreateStats.counters); + builder.storeDict(blockCreateStats.counters, Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); }) } @@ -8589,6 +8605,7 @@ export function loadMcBlockExtra(slice: Slice): McBlockExtra { let shard_hashes: ShardHashes = loadShardHashes(slice); let shard_fees: ShardFees = loadShardFees(slice); let slice1 = slice.loadRef().beginParse(); + let prev_blk_signatures: Dictionary = slice1.loadDict(Dictionary.Keys.Uint(16), Dictionary.Values.Cell()); let recover_create_msg: Maybe = loadMaybe(slice1, ((slice: Slice) => { let slice1 = slice.loadRef().beginParse(); return loadInMsg(slice1) @@ -8605,6 +8622,7 @@ export function loadMcBlockExtra(slice: Slice): McBlockExtra { key_block: key_block, shard_hashes: shard_hashes, shard_fees: shard_fees, + prev_blk_signatures: prev_blk_signatures, recover_create_msg: recover_create_msg, mint_msg: mint_msg, config: config, @@ -8621,7 +8639,7 @@ export function storeMcBlockExtra(mcBlockExtra: McBlockExtra): (builder: Builder storeShardHashes(mcBlockExtra.shard_hashes)(builder); storeShardFees(mcBlockExtra.shard_fees)(builder); let cell1 = beginCell(); - cell1.storeDict(mcBlockExtra.prev_blk_signatures); + cell1.storeDict(mcBlockExtra.prev_blk_signatures, Dictionary.Keys.Uint(16), Dictionary.Values.Cell()); storeMaybe(mcBlockExtra.recover_create_msg, ((arg: InMsg) => { return ((builder: Builder) => { let cell1 = beginCell(); @@ -8744,6 +8762,7 @@ export function loadValidatorSet(slice: Slice): ValidatorSet { let total: number = slice.loadUint(16); let main: number = slice.loadUint(16); let total_weight: number = slice.loadUint(64); + let list: Dictionary = slice.loadDict(Dictionary.Keys.Uint(16), Dictionary.Values.Cell()); if ((!(main <= total))) { throw new Error('Condition (main <= total) is not satisfied while loading "ValidatorSet_validators_ext" for type "ValidatorSet"'); } @@ -8757,6 +8776,7 @@ export function loadValidatorSet(slice: Slice): ValidatorSet { total: total, main: main, total_weight: total_weight, + list: list, } } @@ -8789,7 +8809,7 @@ export function storeValidatorSet(validatorSet: ValidatorSet): (builder: Builder builder.storeUint(validatorSet.total, 16); builder.storeUint(validatorSet.main, 16); builder.storeUint(validatorSet.total_weight, 64); - builder.storeDict(validatorSet.list); + builder.storeDict(validatorSet.list, Dictionary.Keys.Uint(16), Dictionary.Values.Cell()); if ((!(validatorSet.main <= validatorSet.total))) { throw new Error('Condition (validatorSet.main <= validatorSet.total) is not satisfied while loading "ValidatorSet_validators_ext" for type "ValidatorSet"'); } @@ -9002,8 +9022,10 @@ export function loadConfigParam(slice: Slice, arg0: number): ConfigParam { } if ((arg0 == 12)) { + let workchains: Dictionary = slice.loadDict(Dictionary.Keys.Uint(32), Dictionary.Values.Cell()); return { kind: 'ConfigParam__12', + workchains: workchains, } } @@ -9153,8 +9175,10 @@ export function loadConfigParam(slice: Slice, arg0: number): ConfigParam { } if ((arg0 == 31)) { + let fundamental_smc_addr: Dictionary = slice.loadDict(Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); return { kind: 'ConfigParam__28', + fundamental_smc_addr: fundamental_smc_addr, } } @@ -9207,8 +9231,10 @@ export function loadConfigParam(slice: Slice, arg0: number): ConfigParam { } if ((arg0 == 39)) { + let anon0: Dictionary = slice.loadDict(Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); return { kind: 'ConfigParam__35', + anon0: anon0, } } @@ -9363,7 +9389,7 @@ export function storeConfigParam(configParam: ConfigParam): (builder: Builder) = } if ((configParam.kind == 'ConfigParam__12')) { return ((builder: Builder) => { - builder.storeDict(configParam.workchains); + builder.storeDict(configParam.workchains, Dictionary.Keys.Uint(32), Dictionary.Values.Cell()); }) } @@ -9476,7 +9502,7 @@ export function storeConfigParam(configParam: ConfigParam): (builder: Builder) = } if ((configParam.kind == 'ConfigParam__28')) { return ((builder: Builder) => { - builder.storeDict(configParam.fundamental_smc_addr); + builder.storeDict(configParam.fundamental_smc_addr, Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); }) } @@ -9518,7 +9544,7 @@ export function storeConfigParam(configParam: ConfigParam): (builder: Builder) = } if ((configParam.kind == 'ConfigParam__35')) { return ((builder: Builder) => { - builder.storeDict(configParam.anon0); + builder.storeDict(configParam.anon0, Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); }) } @@ -9799,6 +9825,7 @@ export function loadConfigProposalStatus(slice: Slice): ConfigProposalStatus { let slice1 = slice.loadRef().beginParse(); let proposal: ConfigProposal = loadConfigProposal(slice1); let is_critical: boolean = slice.loadBoolean(); + let voters: Dictionary = slice.loadDict(Dictionary.Keys.Uint(16), Dictionary.Values.Cell()); let remaining_weight: number = slice.loadInt(64); let validator_set_id: bigint = slice.loadUintBig(256); let rounds_remaining: number = slice.loadUint(8); @@ -9809,6 +9836,7 @@ export function loadConfigProposalStatus(slice: Slice): ConfigProposalStatus { expires: expires, proposal: proposal, is_critical: is_critical, + voters: voters, remaining_weight: remaining_weight, validator_set_id: validator_set_id, rounds_remaining: rounds_remaining, @@ -9828,7 +9856,7 @@ export function storeConfigProposalStatus(configProposalStatus: ConfigProposalSt storeConfigProposal(configProposalStatus.proposal)(cell1); builder.storeRef(cell1); builder.storeBit(configProposalStatus.is_critical); - builder.storeDict(configProposalStatus.voters); + builder.storeDict(configProposalStatus.voters, Dictionary.Keys.Uint(16), Dictionary.Values.Cell()); builder.storeInt(configProposalStatus.remaining_weight, 64); builder.storeUint(configProposalStatus.validator_set_id, 256); builder.storeUint(configProposalStatus.rounds_remaining, 8); @@ -11000,9 +11028,11 @@ export function storeSizeLimitsConfig(sizeLimitsConfig: SizeLimitsConfig): (buil export function loadSuspendedAddressList(slice: Slice): SuspendedAddressList { if (((slice.remainingBits >= 8) && (slice.preloadUint(8) == 0x00))) { slice.loadUint(8); + let addresses: Dictionary = slice.loadDict(Dictionary.Keys.Uint(288), Dictionary.Values.Cell()); let suspended_until: number = slice.loadUint(32); return { kind: 'SuspendedAddressList', + addresses: addresses, suspended_until: suspended_until, } @@ -11013,7 +11043,7 @@ export function loadSuspendedAddressList(slice: Slice): SuspendedAddressList { export function storeSuspendedAddressList(suspendedAddressList: SuspendedAddressList): (builder: Builder) => void { return ((builder: Builder) => { builder.storeUint(0x00, 8); - builder.storeDict(suspendedAddressList.addresses); + builder.storeDict(suspendedAddressList.addresses, Dictionary.Keys.Uint(288), Dictionary.Values.Cell()); builder.storeUint(suspendedAddressList.suspended_until, 32); }) @@ -11040,7 +11070,7 @@ export function storeOracleBridgeParams(oracleBridgeParams: OracleBridgeParams): return ((builder: Builder) => { builder.storeBits(oracleBridgeParams.bridge_address); builder.storeBits(oracleBridgeParams.oracle_mutlisig_address); - builder.storeDict(oracleBridgeParams.oracles); + builder.storeDict(oracleBridgeParams.oracles, Dictionary.Keys.Uint(256), Dictionary.Values.Uint(256)); builder.storeBits(oracleBridgeParams.external_chain_address); }) @@ -11136,7 +11166,7 @@ export function storeJettonBridgeParams(jettonBridgeParams: JettonBridgeParams): builder.storeUint(0x00, 8); builder.storeBits(jettonBridgeParams.bridge_address); builder.storeBits(jettonBridgeParams.oracles_address); - builder.storeDict(jettonBridgeParams.oracles); + builder.storeDict(jettonBridgeParams.oracles, Dictionary.Keys.Uint(256), Dictionary.Values.Uint(256)); builder.storeUint(jettonBridgeParams.state_flags, 8); storeCoins(jettonBridgeParams.burn_bridge_fee)(builder); }) @@ -11147,7 +11177,7 @@ export function storeJettonBridgeParams(jettonBridgeParams: JettonBridgeParams): builder.storeUint(0x01, 8); builder.storeBits(jettonBridgeParams.bridge_address); builder.storeBits(jettonBridgeParams.oracles_address); - builder.storeDict(jettonBridgeParams.oracles); + builder.storeDict(jettonBridgeParams.oracles, Dictionary.Keys.Uint(256), Dictionary.Values.Uint(256)); builder.storeUint(jettonBridgeParams.state_flags, 8); let cell1 = beginCell(); storeJettonBridgePrices(jettonBridgeParams.prices)(cell1); @@ -11167,10 +11197,12 @@ block_signatures_pure#_ sig_count:uint32 sig_weight:uint64 export function loadBlockSignaturesPure(slice: Slice): BlockSignaturesPure { let sig_count: number = slice.loadUint(32); let sig_weight: number = slice.loadUint(64); + let signatures: Dictionary = slice.loadDict(Dictionary.Keys.Uint(16), Dictionary.Values.Cell()); return { kind: 'BlockSignaturesPure', sig_count: sig_count, sig_weight: sig_weight, + signatures: signatures, } } @@ -11179,7 +11211,7 @@ export function storeBlockSignaturesPure(blockSignaturesPure: BlockSignaturesPur return ((builder: Builder) => { builder.storeUint(blockSignaturesPure.sig_count, 32); builder.storeUint(blockSignaturesPure.sig_weight, 64); - builder.storeDict(blockSignaturesPure.signatures); + builder.storeDict(blockSignaturesPure.signatures, Dictionary.Keys.Uint(16), Dictionary.Values.Cell()); }) } @@ -11371,8 +11403,10 @@ export function storeTopBlockDescr(topBlockDescr: TopBlockDescr): (builder: Buil export function loadTopBlockDescrSet(slice: Slice): TopBlockDescrSet { if (((slice.remainingBits >= 32) && (slice.preloadUint(32) == 0x4ac789f3))) { slice.loadUint(32); + let collection: Dictionary = slice.loadDict(Dictionary.Keys.Uint(96), Dictionary.Values.Cell()); return { kind: 'TopBlockDescrSet', + collection: collection, } } @@ -11382,7 +11416,7 @@ export function loadTopBlockDescrSet(slice: Slice): TopBlockDescrSet { export function storeTopBlockDescrSet(topBlockDescrSet: TopBlockDescrSet): (builder: Builder) => void { return ((builder: Builder) => { builder.storeUint(0x4ac789f3, 32); - builder.storeDict(topBlockDescrSet.collection); + builder.storeDict(topBlockDescrSet.collection, Dictionary.Keys.Uint(96), Dictionary.Values.Cell()); }) } @@ -11541,11 +11575,13 @@ export function loadValidatorComplaintStatus(slice: Slice): ValidatorComplaintSt slice.loadUint(8); let slice1 = slice.loadRef().beginParse(); let complaint: ValidatorComplaint = loadValidatorComplaint(slice1); + let voters: Dictionary = slice.loadDict(Dictionary.Keys.Uint(16), Dictionary.Values.Cell()); let vset_id: bigint = slice.loadUintBig(256); let weight_remaining: number = slice.loadInt(64); return { kind: 'ValidatorComplaintStatus', complaint: complaint, + voters: voters, vset_id: vset_id, weight_remaining: weight_remaining, } @@ -11560,7 +11596,7 @@ export function storeValidatorComplaintStatus(validatorComplaintStatus: Validato let cell1 = beginCell(); storeValidatorComplaint(validatorComplaintStatus.complaint)(cell1); builder.storeRef(cell1); - builder.storeDict(validatorComplaintStatus.voters); + builder.storeDict(validatorComplaintStatus.voters, Dictionary.Keys.Uint(16), Dictionary.Values.Cell()); builder.storeUint(validatorComplaintStatus.vset_id, 256); builder.storeInt(validatorComplaintStatus.weight_remaining, 64); }) @@ -11960,15 +11996,17 @@ export function storeVmStackList(vmStackList: VmStackList): (builder: Builder) = // _ cregs:(HashmapE 4 VmStackValue) = VmSaveList; export function loadVmSaveList(slice: Slice): VmSaveList { + let cregs: Dictionary = slice.loadDict(Dictionary.Keys.Uint(4), Dictionary.Values.Cell()); return { kind: 'VmSaveList', + cregs: cregs, } } export function storeVmSaveList(vmSaveList: VmSaveList): (builder: Builder) => void { return ((builder: Builder) => { - builder.storeDict(vmSaveList.cregs); + builder.storeDict(vmSaveList.cregs, Dictionary.Keys.Uint(4), Dictionary.Values.Cell()); }) } @@ -12009,15 +12047,17 @@ export function storeVmGasLimits(vmGasLimits: VmGasLimits): (builder: Builder) = // _ libraries:(HashmapE 256 ^Cell) = VmLibraries; export function loadVmLibraries(slice: Slice): VmLibraries { + let libraries: Dictionary = slice.loadDict(Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); return { kind: 'VmLibraries', + libraries: libraries, } } export function storeVmLibraries(vmLibraries: VmLibraries): (builder: Builder) => void { return ((builder: Builder) => { - builder.storeDict(vmLibraries.libraries); + builder.storeDict(vmLibraries.libraries, Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); }) } @@ -12331,15 +12371,17 @@ export function storeVmCont(vmCont: VmCont): (builder: Builder) => void { // _ (HashmapE 256 ^DNSRecord) = DNS_RecordSet; export function loadDNS_RecordSet(slice: Slice): DNS_RecordSet { + let anon0: Dictionary = slice.loadDict(Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); return { kind: 'DNS_RecordSet', + anon0: anon0, } } export function storeDNS_RecordSet(dNS_RecordSet: DNS_RecordSet): (builder: Builder) => void { return ((builder: Builder) => { - builder.storeDict(dNS_RecordSet.anon0); + builder.storeDict(dNS_RecordSet.anon0, Dictionary.Keys.Uint(256), Dictionary.Values.Cell()); }) } diff --git a/test/generated_files/generated_test.ts b/test/generated_files/generated_test.ts index 481e0f4..446c4ab 100644 --- a/test/generated_files/generated_test.ts +++ b/test/generated_files/generated_test.ts @@ -501,6 +501,18 @@ export interface AddressUser { readonly src: Address; } +export interface VarUInteger { + readonly kind: 'VarUInteger'; + readonly n: number; + readonly len: number; + readonly value: bigint; +} + +export interface SomeUser { + readonly kind: 'SomeUser'; + readonly dict: Dictionary; +} + // tmpa$_ a:# b:# = Simple; export function loadSimple(slice: Slice): Simple { @@ -2553,3 +2565,46 @@ export function storeAddressUser(addressUser: AddressUser): (builder: Builder) = } +/* +var_uint$_ {n:#} len:(#< n) value:(uint (len * 8)) + = VarUInteger n; +*/ + +export function loadVarUInteger(slice: Slice, n: number): VarUInteger { + let len: number = slice.loadUint(bitLen((n - 1))); + let value: bigint = slice.loadUintBig((len * 8)); + return { + kind: 'VarUInteger', + n: n, + len: len, + value: value, + } + +} + +export function storeVarUInteger(varUInteger: VarUInteger): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeUint(varUInteger.len, bitLen((varUInteger.n - 1))); + builder.storeUint(varUInteger.value, (varUInteger.len * 8)); + }) + +} + +// extra_currencies$_ dict:(HashmapE 32 (VarUInteger 32)) = SomeUser; + +export function loadSomeUser(slice: Slice): SomeUser { + let dict: Dictionary = slice.loadDict(Dictionary.Keys.Uint(32), Dictionary.Values.Cell()); + return { + kind: 'SomeUser', + dict: dict, + } + +} + +export function storeSomeUser(someUser: SomeUser): (builder: Builder) => void { + return ((builder: Builder) => { + builder.storeDict(someUser.dict, Dictionary.Keys.Uint(32), Dictionary.Values.Cell()); + }) + +} + diff --git a/test/tlb/test.tlb b/test/tlb/test.tlb index 60cf64f..59126c2 100644 --- a/test/tlb/test.tlb +++ b/test/tlb/test.tlb @@ -137,4 +137,9 @@ addr_std$10 anycast:(Maybe Anycast) addr_var$11 anycast:(Maybe Anycast) addr_len:(## 9) workchain_id:int32 address:(bits addr_len) = MsgAddressInt; -_ src:MsgAddressInt = AddressUser; \ No newline at end of file +_ src:MsgAddressInt = AddressUser; + +var_uint$_ {n:#} len:(#< n) value:(uint (len * 8)) + = VarUInteger n; + +extra_currencies$_ dict:(HashmapE 32 (VarUInteger 32)) = SomeUser; \ No newline at end of file diff --git a/test/tlbgen.spec.ts b/test/tlbgen.spec.ts index 3317875..a90be60 100644 --- a/test/tlbgen.spec.ts +++ b/test/tlbgen.spec.ts @@ -5,7 +5,7 @@ import { Address, BitString, Builder, Cell, Dictionary, Slice } from 'ton'; import { describe, expect, test } from '@jest/globals'; import { beginCell } from 'ton'; import { loadBlock, storeBlock } from './generated_files/generated_block'; -import { AddressUser, AnonymousData, BitLenArg, BitLenArgUser, BitSelection, BoolUser, CellTypedField, CellsSimple, CheckCrc32, CheckKeyword, CombArgCellRefUser, ComplexTypedField, ConditionalField, ConditionalRef, ConstructorOrder, DollarTag, EmptyTag, EqualityExpression, ExprArgUser, FalseAnonField, HashmapE, HashmapEUser, ImplicitCondition, IntBitsOutside, IntBitsParametrizedOutside, LessThan, LoadFromNegationOutsideExpr, ManyComb, MathExprAsCombArg, MultipleEmptyConstructor, NegationFromImplicit, ParamConst, ParamDifNames, ParamDifNamesUser, ParamNamedArgInSecondConstr, RefCombinatorAny, RefCombinatorInRef, SharpConstructor, SharpTag, Simple, True, TupleCheck, TwoConstructors, TypedField, TypedParam, Unary, UnaryUserCheckOrder, loadAddressUser, loadAnonymousData, loadBitLenArg, loadBitLenArgUser, loadBitSelection, loadBoolUser, loadCellTypedField, loadCellsSimple, loadCheckCrc32, loadCheckKeyword, loadCombArgCellRefUser, loadComplexTypedField, loadConditionalField, loadConditionalRef, loadConstructorOrder, loadDollarTag, loadEmptyTag, loadEqualityExpression, loadExprArgUser, loadFalseAnonField, loadHashmapE, loadHashmapEUser, loadImplicitCondition, loadIntBitsOutside, loadIntBitsParametrizedOutside, loadLessThan, loadLoadFromNegationOutsideExpr, loadManyComb, loadMathExprAsCombArg, loadMultipleEmptyConstructor, loadNegationFromImplicit, loadParamConst, loadParamDifNames, loadParamDifNamesUser, loadParamNamedArgInSecondConstr, loadRefCombinatorAny, loadRefCombinatorInRef, loadSharpConstructor, loadSharpTag, loadSimple, loadTrue, loadTupleCheck, loadTwoConstructors, loadTypedField, loadTypedParam, loadUnary, loadUnaryUserCheckOrder, storeAddressUser, storeAnonymousData, storeBitLenArg, storeBitLenArgUser, storeBitSelection, storeBoolUser, storeCellTypedField, storeCellsSimple, storeCheckCrc32, storeCheckKeyword, storeCombArgCellRefUser, storeComplexTypedField, storeConditionalField, storeConditionalRef, storeConstructorOrder, storeDollarTag, storeEmptyTag, storeEqualityExpression, storeExprArgUser, storeFalseAnonField, storeHashmapE, storeHashmapEUser, storeImplicitCondition, storeIntBitsOutside, storeIntBitsParametrizedOutside, storeLessThan, storeLoadFromNegationOutsideExpr, storeManyComb, storeMathExprAsCombArg, storeMultipleEmptyConstructor, storeNegationFromImplicit, storeParamConst, storeParamDifNames, storeParamDifNamesUser, storeParamNamedArgInSecondConstr, storeRefCombinatorAny, storeRefCombinatorInRef, storeSharpConstructor, storeSharpTag, storeSimple, storeTrue, storeTupleCheck, storeTwoConstructors, storeTypedField, storeTypedParam, storeUnary, storeUnaryUserCheckOrder } from './generated_files/generated_test'; +import { AddressUser, AnonymousData, BitLenArg, BitLenArgUser, BitSelection, BoolUser, CellTypedField, CellsSimple, CheckCrc32, CheckKeyword, CombArgCellRefUser, ComplexTypedField, ConditionalField, ConditionalRef, ConstructorOrder, DollarTag, EmptyTag, EqualityExpression, ExprArgUser, FalseAnonField, HashmapE, HashmapEUser, ImplicitCondition, IntBitsOutside, IntBitsParametrizedOutside, LessThan, LoadFromNegationOutsideExpr, ManyComb, MathExprAsCombArg, MultipleEmptyConstructor, NegationFromImplicit, ParamConst, ParamDifNames, ParamDifNamesUser, ParamNamedArgInSecondConstr, RefCombinatorAny, RefCombinatorInRef, SharpConstructor, SharpTag, Simple, SomeUser, True, TupleCheck, TwoConstructors, TypedField, TypedParam, Unary, UnaryUserCheckOrder, loadAddressUser, loadAnonymousData, loadBitLenArg, loadBitLenArgUser, loadBitSelection, loadBoolUser, loadCellTypedField, loadCellsSimple, loadCheckCrc32, loadCheckKeyword, loadCombArgCellRefUser, loadComplexTypedField, loadConditionalField, loadConditionalRef, loadConstructorOrder, loadDollarTag, loadEmptyTag, loadEqualityExpression, loadExprArgUser, loadFalseAnonField, loadHashmapE, loadHashmapEUser, loadImplicitCondition, loadIntBitsOutside, loadIntBitsParametrizedOutside, loadLessThan, loadLoadFromNegationOutsideExpr, loadManyComb, loadMathExprAsCombArg, loadMultipleEmptyConstructor, loadNegationFromImplicit, loadParamConst, loadParamDifNames, loadParamDifNamesUser, loadParamNamedArgInSecondConstr, loadRefCombinatorAny, loadRefCombinatorInRef, loadSharpConstructor, loadSharpTag, loadSimple, loadTrue, loadTupleCheck, loadTwoConstructors, loadTypedField, loadTypedParam, loadUnary, loadUnaryUserCheckOrder, storeAddressUser, storeAnonymousData, storeBitLenArg, storeBitLenArgUser, storeBitSelection, storeBoolUser, storeCellTypedField, storeCellsSimple, storeCheckCrc32, storeCheckKeyword, storeCombArgCellRefUser, storeComplexTypedField, storeConditionalField, storeConditionalRef, storeConstructorOrder, storeDollarTag, storeEmptyTag, storeEqualityExpression, storeExprArgUser, storeFalseAnonField, storeHashmapE, storeHashmapEUser, storeImplicitCondition, storeIntBitsOutside, storeIntBitsParametrizedOutside, storeLessThan, storeLoadFromNegationOutsideExpr, storeManyComb, storeMathExprAsCombArg, storeMultipleEmptyConstructor, storeNegationFromImplicit, storeParamConst, storeParamDifNames, storeParamDifNamesUser, storeParamNamedArgInSecondConstr, storeRefCombinatorAny, storeRefCombinatorInRef, storeSharpConstructor, storeSharpTag, storeSimple, storeTrue, storeTupleCheck, storeTwoConstructors, storeTypedField, storeTypedParam, storeUnary, storeUnaryUserCheckOrder } from './generated_files/generated_test'; const fixturesDir = path.resolve(__dirname, 'fixtures'); @@ -260,6 +260,14 @@ describe('Generating tlb code', () => { } checkSameOnStoreLoad(hashmapUser, loadHashmapEUser, storeHashmapEUser); + + let theDict: Dictionary = Dictionary.empty(); + theDict.set() + + let someUser: SomeUser = { + kind: 'SomeUser', + dict: + } }) test('Constructor Tags', () => { @@ -432,3 +440,4 @@ describe('Generating tlb code', () => { // expect(deepEqual(cs.hash(), builder.endCell().hash())).toBeTruthy() }) }) +