Releases: ferrumnet/snap-hodl
v0.7.0
Release Notes - Version v0.7.0
New Features
-
New API Endpoint
getSnapShotBySnapShotIdAndAddress
:We have added a new endpoint that allows querying a snapshot by its ID and an Ethereum address. The URL pattern for the new API endpoint is:
rubyCopy code
/getSnapShotBySnapShotIdAndAddress/:snapShotId/:address
This new endpoint returns a JSON object containing the
snapShotConfigName
, the queriedaddress
, the associatedsnapShotBalance
, and theupdatedAt
timestamp of the snapshot.There is also a variant that allows for raw data retrieval:
rubyCopy code
/getSnapShotBySnapShotIdAndAddress/:snapShotId/:address/raw
This variant returns just the snapshot balance as a plain text.
Enhancements
-
Lowercase Ethereum Address Handling:
To improve the consistency and reliability of data retrieval, we have updated the
getSnapShotBySnapShotIdAndAddress
endpoint to convert Ethereum addresses to lowercase before querying the database. This change ensures that the endpoint functions correctly, regardless of the case of the Ethereum address in the URL.
Bug Fixes
-
Address Not Found Error:
In previous versions, the
getSnapShotBySnapShotIdAndAddress
endpoint could fail if the Ethereum address was not found in the snapshot. In v0.7.0, this issue has been addressed. The endpoint now returns a clear error message when the address is not found.
Summary
In this release, we have focused on improving the flexibility and reliability of our API by adding a new endpoint and enhancing the handling of Ethereum addresses. The new getSnapShotBySnapShotIdAndAddress
endpoint allows more precise querying of snapshots, while the change to lowercase Ethereum addresses ensures accurate data retrieval across all queries.
What's Changed
- getSnapShotBySnapShotIdAndAddress API and lowercase stakerAddresses by @taha-abbasi in #21
Full Changelog: v0.6.0...v0.7.0
v0.6.0
What's Changed
- added APIs for snapHodlConfig CRUD as well as optimization for saving… by @taha-abbasi in #20
Full Changelog: v0.5.0...v0.6.0
v0.5.0
Release v0.5.0
Overview
This release introduces significant code organization, performance enhancements, and introduces new features aimed at increasing the maintainability, scalability, and efficiency of the application. We have focused on environment configuration, separation of concerns, and optimization of the SnapHodl feature, including performance optimizations in the cron job scheduling.
Details
Enhancements
-
Environment Configuration: Moved environment setup to a separate
config.ts
file for better modularity and ease of use. It's now possible to import and use environment configurations from this centralized module. -
Cron Jobs: Introduced a dedicated module
cronJobs.ts
to handle cron job scheduling. This makes it easier to manage, schedule and organize different cron jobs that the application might have. We have optimized the execution of the cron job, reducing its execution time from 1 minute 45 seconds to 37 seconds, by running multiple queries concurrently usingPromise.all
. -
New Staking Functionality: We've introduced the
processStakingContractDataItem
andgetSnapHodlConfigBalance
functions, which have been moved to a newstaking.ts
file in thesrc/logic
directory.-
processStakingContractDataItem
: This function processes each staking contract data item to collect and return necessary data including staking contract address, token contract address, chain ID, and the total staked balance. -
getSnapHodlConfigBalance
: This function aggregates the data processed byprocessStakingContractDataItem
function, constructs the SnapHodlConfigBalance data structure, and returns it. This helps in tracking the total staked balance per contract address and maintaining a snapshot of the staking configuration.
-
Bug Fixes
No specific bugs were addressed in this release.
Concluding Remarks
Release v0.5.0 is a step forward in maintaining the quality and scalability of the codebase. With the new features and optimizations implemented, the project is now more organized, efficient, and ready to accommodate future enhancements and fixes. As always, feedback and contributions are warmly welcome.
What's Changed
- Preparing for deployment by @taha-abbasi in #17
- Created an express server by @taha-abbasi in #18
- Added parallel cron and saveSnapHodlBalanceData by @taha-abbasi in #19
Full Changelog: v0.2.0...v0.5.0
v0.2.0
Release Notes - v0.2.0
This release includes significant improvements and updates to the getUniqueStakers
and getUniqueStakersFromOpenStaking
functions, as well as the introduction of a new services
directory and stakingService.ts
file that contains the new getLatestStakingSnapshot
and saveStakingSnapshot
functions.
Updates to getUniqueStakers
and getUniqueStakersFromOpenStaking
- Improved error handling and logging for better clarity and easier debugging.
- Fixed an issue with the calculation of the
endBlock
variable, ensuring that it updates correctly with each iteration. - Implemented log iteration to overcome log size and rate limit issues. This new approach fetches logs in smaller, manageable chunks, ensuring that no logs are left out due to size and rate limits, providing more accurate and complete data.
New Services Directory and Functions
A new services
directory has been introduced to the project, which will contain service-related functions and utilities. In this release, a new file called stakingService.ts
has been added, which includes two new functions:
getLatestStakingSnapshot
This function retrieves the latest staking snapshot from the database for a specific staking contract and token contract on a specified chain. This enables the application to keep track of the latest staking data and avoid re-processing information that has already been captured.
saveStakingSnapshot
This function saves a staking snapshot to the database, including the staking pool name, staking and token contract addresses, chain ID, latest block captured, and the unique stakers list. This provides a convenient way to persist the staking data obtained during the processing of unique stakers and their staked balances.
These new functions help streamline the data processing and storage flow, making the application more efficient and easier to maintain.
Overall, these updates and additions to the application in v0.2.0 enhance its performance, reliability, and maintainability, setting a solid foundation for future improvements and features.
What's Changed
- added functionality to iterate over logs based on blockIterationSize by @taha-abbasi in #14
Full Changelog: v0.1.0...v0.2.0
v0.1.0
Release v0.1.0
In this release, we've introduced significant improvements to the code organization, refactored the codebase for better maintainability, and added new types and utility functions. Here are the detailed release notes:
Major Changes
Code Organization
- Created a new folder named
src
and moved all TypeScript files into thesrc
folder. - Created a new
types
folder inside thesrc
folder to store TypeScript types and interfaces. - Created a new
utils
folder inside thesrc
folder to store utility functions. - Created separate files for open staking and standard staking functions:
src/openStaking.ts
andsrc/standardStaking.ts
.
New Types
- Added a new type definition for
StakingContractDataItem
insrc/types.ts
.
Utility Functions
- Moved
getRpcUrl
,getTokenDecimals
, andupdateTotalStakedBalances
to separate files in thesrc/utils
folder. Each utility function now has its own file:getRpcUrl.ts
,getTokenDecimals.ts
, andupdateTotalStakedBalances.ts
.
Additional Functionality in src/index.ts
- Added functionality to sum the staked balances from all staking contracts, even if they are deployed across different blockchain networks.
- The main function now retrieves the appropriate RPC URL for each chain by calling the
getRpcUrl
function with the relevantchainId
.
Minor Changes
- Updated the
DataItem
type toStakingContractDataItem
and updated the rest of the code accordingly. - Renamed the
DataItem
type toStakingContractDataItem
. - Updated the function calls in
src/index.ts
to pass required additional parameters, such asDB_CONNECTION_STRING
,DB_NAME
, andDB_COLLECTION
.
Bug Fixes
- None
Known Issues
- None
This release represents a significant step towards a cleaner and more maintainable codebase. We encourage users to update to v0.1.0 and provide feedback on any issues or suggestions for improvement.
What's Changed
- Added functionality to get balances for contracts across chains and standard and open staking contracts along with structural changes by @taha-abbasi in #9
Full Changelog: v0.0.3...v0.1.0
v0.0.3
Release Notes for v0.0.3
This version includes significant improvements and new features since v0.0.26. Below are the highlights of the changes:
New Features
Environment Variables
- Added support for environment variables using
.env
file. The RPC URL is now stored in the.env
file instead of directly in thesrc/index.ts
file.
Staking Pool Name
- Added functionality to retrieve the name of the staking pool by calling the
name()
function on the staking contract.
Token Decimals
- Added support for tokens with different decimal values. Users can now provide the
tokenContractAddress
of the token they want to work with. - Updated the
getStakedBalances
function to receive the token contract address and use the decimals of the token to convert the balances accurately.
Improvements
Code Structure
- Updated the
tsconfig.json
to specify thesrc
directory as the base directory for TypeScript files. - Changed the output directory from
./dist
to./build
in thetsconfig.json
file. - Added the
erc20Abi
import to thesrc/index.ts
file for working with the token contract.
Bug Fixes
- Fixed an issue where the
tsc
was outputting the compiled code to the root directory instead of the specified output directory.
Please refer to the README.md file for instructions on how to build and run the project.
What's Changed
- updated RPC endpoint to be pulled from .env per resolves issue #3 by @taha-abbasi in #7
- Added functionality to check for decimals in a tokenContract address … by @taha-abbasi in #8
Full Changelog: v0.0.26...v0.0.3
v0.0.26
Release Notes for v0.0.26:
Overview
In this release, we have added the functionality to extract a unique list of stakers for a given staking pool by fetching and processing logs from the staking contract. The code is implemented using TypeScript, Web3.js, and a JSON ABI of the staking contract.
Key Features
- Web3 Instance Creation: A Web3 instance is created using an Ethereum RPC URL to connect to the blockchain network.
const rpcUrl = "https://nd-499-825-018.p2pify.com/5d8bab30e1462f48144c36f18d2ee958";
const web3 = new Web3(rpcUrl);
- Staking Contract Instance Creation: A staking contract instance is created using the Web3 instance, a staking contract address, and its ABI.
const stakingContractAddress = "0x2bE7904c81dd3535f31B2C7B524a6ed91FDb37EC";
const stakingContract = new web3.eth.Contract(
stakingContractAbi as unknown as AbiItem[],
stakingContractAddress
);
- Fetching Logs for
Staked
Event: Logs for theStaked
event are fetched usingweb3.eth.getPastLogs()
method, with a filter specifying the range of blocks and the event signature.
const stakedEventFilter = {
fromBlock: 70124014,
toBlock: "latest",
address: stakingContractAddress,
topics: [stakingContract.events.Staked.signature],
};
const logs = await web3.eth.getPastLogs(stakedEventFilter);
- Processing Logs: Each log is processed to extract the
staker_
address by decoding the log data using the ABI input definitions.
logs.forEach((log) => {
const eventInterface = stakingContract.options.jsonInterface.find(
(i: any) => i.signature === log.topics[0]
);
const inputs = eventInterface.inputs as AbiInput[];
const event = web3.eth.abi.decodeLog(
inputs,
log.data,
log.topics.slice(1)
);
const stakerAddress = event["staker_"];
uniqueStakers.add(stakerAddress);
});
- Get Unique Stakers:
getUniqueStakers()
function is implemented to fetch and process logs, and return a unique list of stakers.
async function getUniqueStakers(): Promise<string[]> {
// Fetching logs and processing them to extract unique stakers
// ...
return Array.from(uniqueStakers);
}
- Usage: The unique list of stakers can be obtained by calling the
getUniqueStakers()
function.
(async () => {
const stakers = await getUniqueStakers();
console.log("Unique staker addresses:", stakers);
})();
Staking Contract ABI
The JSON ABI of the staking contract is included in the ./stakingContractAbi.json
file.
What's Changed
- Get Unique list of stakers of a staking contract from transaction logs by @taha-abbasi in #1
- Updated file structure by @taha-abbasi in #2
New Contributors
- @taha-abbasi made their first contribution in #1
Full Changelog: https://github.com/ferrumnet/snapshot/commits/v0.0.26