Skip to content

Commit

Permalink
Rename RentStructure to StorageScoreParameters in bindings (#1673)
Browse files Browse the repository at this point in the history
* Nodejs bindings

* Python bindings

* Fmt

* Update bindings/nodejs/lib/utils/utils.ts

Co-authored-by: Thoralf-M <[email protected]>

---------

Co-authored-by: Thoralf-M <[email protected]>
  • Loading branch information
thibault-martinez and Thoralf-M committed Nov 24, 2023
1 parent d4eb814 commit 276ef19
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 58 deletions.
2 changes: 1 addition & 1 deletion bindings/nodejs/lib/types/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export * from './gossip-metrics';
export * from './gossip-heartbeat';
export * from './native-token';
export * from './peer';
export * from './rent-structure';
export * from './storage-score';
export * from './state';
6 changes: 3 additions & 3 deletions bindings/nodejs/lib/types/models/info/node-info-protocol.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import type { RentStructure } from '../rent-structure';
import type { StorageScoreParameters } from '../storage-score';
import { EpochIndex } from '../../block/slot';
import { u64 } from '../../utils';

Expand Down Expand Up @@ -40,9 +40,9 @@ export interface ProtocolParameters {
*/
bech32Hrp: string;
/**
* The rent structure according to TIP-19.
* The storage score parameters used by given node/network.
*/
rentStructure: RentStructure;
storageScoreParameters: StorageScoreParameters;
/**
* Work Score Parameters lists the work score of each type, it is used to denote the computation costs of processing an object.
*/
Expand Down
32 changes: 0 additions & 32 deletions bindings/nodejs/lib/types/models/rent-structure.ts

This file was deleted.

34 changes: 34 additions & 0 deletions bindings/nodejs/lib/types/models/storage-score.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { u64 } from '../../utils';

/**
* Defines the parameters of storage score calculations on objects which take node resources.
*/
export interface StorageScoreParameters {
/**
* Defines the number of IOTA tokens required per unit of storage score.
*/
storageCost: u64;
/**
* Defines the factor to be used for data only fields.
*/
factorData: number;
/**
* Defines the offset to be applied to all outputs for the overhead of handling them in storage.
*/
offsetOutputOverhead: u64;
/**
* Defines the offset to be used for block issuer feature public keys.
*/
offsetEd25519BlockIssuerKey: u64;
/**
* Defines the offset to be used for staking feature.
*/
offsetStakingFeature: u64;
/**
* Defines the offset to be used for delegation output.
*/
offsetDelegation: u64;
}
4 changes: 2 additions & 2 deletions bindings/nodejs/lib/types/utils/bridge/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
TransactionId,
TokenSchemeType,
Output,
RentStructure,
StorageScoreParameters,
SignedBlock,
ProtocolParameters,
OutputId,
Expand Down Expand Up @@ -62,7 +62,7 @@ export interface __ComputeStorageDepositMethod__ {
name: 'computeStorageDeposit';
data: {
output: Output;
rent: RentStructure;
storageScoreParameters: StorageScoreParameters;
};
}

Expand Down
11 changes: 7 additions & 4 deletions bindings/nodejs/lib/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
TransactionId,
TokenSchemeType,
Output,
RentStructure,
StorageScoreParameters,
OutputId,
u64,
SignedBlock,
Expand Down Expand Up @@ -127,15 +127,18 @@ export class Utils {
* Compute the required storage deposit of an output.
*
* @param output The output.
* @param rent Rent cost of objects which take node resources.
* @param storageScoreParameters Storage score of objects which take node resources.
* @returns The required storage deposit.
*/
static computeStorageDeposit(output: Output, rent: RentStructure): u64 {
static computeStorageDeposit(
output: Output,
storageScoreParameters: StorageScoreParameters,
): u64 {
const minStorageDepositAmount = callUtilsMethod({
name: 'computeStorageDeposit',
data: {
output,
rent,
storageScoreParameters,
},
});
return BigInt(minStorageDepositAmount);
Expand Down
32 changes: 16 additions & 16 deletions bindings/python/iota_sdk/types/node_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,23 @@ class NodeInfoMetrics:

@json
@dataclass
class RentStructure:
"""Rent structure for the storage deposit.
class StorageScoreParameters:
"""Defines the parameters of storage score calculations on objects which take node resources.
Attributes:
v_byte_cost: Defines the rent of a single virtual byte denoted in IOTA tokens.
v_byte_factor_data: Defines the factor to be used for data only fields.
v_byte_factor_key: Defines the factor to be used for key/lookup generating fields.
v_byte_factor_block_issuer_key: Defines the factor to be used for block issuer feature public keys.
v_byte_factor_staking_feature: Defines the factor to be used for staking feature.
v_byte_factor_delegation: Defines the factor to be used for delegation output.
storage_cost: Defines the number of IOTA tokens required per unit of storage score.
factor_data: Defines the factor to be used for data only fields.
offset_output_overhead: Defines the offset to be applied to all outputs for the overhead of handling them in storage.
offset_ed25519_block_issuer_key: Defines the offset to be used for block issuer feature public keys.
offset_staking_feature: Defines the offset to be used for staking feature.
offset_delegation: Defines the offset to be used for delegation output.
"""
v_byte_cost: int
v_byte_factor_data: int
v_byte_factor_key: int
v_byte_factor_block_issuer_key: int
v_byte_factor_staking_feature: int
v_byte_factor_delegation: int
storage_cost: int
factor_data: int
offset_output_overhead: int
offset_ed25519_block_issuer_key: int
offset_staking_feature: int
offset_delegation: int


@json
Expand Down Expand Up @@ -222,7 +222,7 @@ class ProtocolParameters:
bech32_hrp: Tells whether the node supports mainnet or testnet addresses.
Value `iota` indicates that the node supports mainnet addresses.
Value `atoi` indicates that the node supports testnet addresses.
rent_structure: The rent structure used by a given node/network.
storage_score_parameters: The storage score parameters used by given node/network.
work_score_parameters: Work Score Parameters lists the work score of each type, it is used to denote the computation costs of processing an object.
token_supply: Current supply of the base token. Plain string encoded number.
genesis_unix_timestamp: The genesis timestamp at which the slots start to count.
Expand All @@ -244,7 +244,7 @@ class ProtocolParameters:
version: int
network_name: str
bech32_hrp: str
rent_structure: RentStructure
storage_score_parameters: StorageScoreParameters
work_score_parameters: WorkScoreParameters
token_supply: int = field(metadata=config(
encoder=str
Expand Down

0 comments on commit 276ef19

Please sign in to comment.