Skip to content

Commit

Permalink
Merge pull request #301 from umbrella-network/hotfix/5.12.5
Browse files Browse the repository at this point in the history
fix bytes32 to string conversion
  • Loading branch information
DZariusz authored Nov 4, 2024
2 parents ade5272 + d1da4f1 commit 9255238
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

## [5.12.5] - 2024-11-04
### Fixed
- Fix bytes32 to string conversion

## [5.12.4] - 2024-11-04
### Added
- added more logs to tx fetcher
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sanctuary",
"version": "5.12.4",
"version": "5.12.5",
"repository": {
"type": "git",
"url": "git+https://github.com/umbrella-network/sanctuary.git"
Expand Down
11 changes: 10 additions & 1 deletion src/services/ContractSynchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,22 @@ export class ContractSynchronizer {
return Promise.all(
events.map((logRegistered) => {
const { destination, anchor, bytes32 } = logRegistered;
const [name] = Buffer.from(bytes32.replace('0x', ''), 'hex').toString().split(']x00');
const name = this.clearName(bytes32);
this.logger.info(`${this.logPrefix}[${chainId}] Detected new ${name}: ${destination} at ${anchor}`);
return this.contractRepository.save(chainId, anchor, name, destination);
})
);
};

private clearName = (bytes32: string): string => {
const b = Buffer.from(bytes32.replace('0x', ''), 'hex');
let i = 0;

while (b[i] != 0) i++;

return b.slice(0, i).toString('utf-8');
};

private calculateBlockNumberRange = async (
chainId: ChainsIds,
startBlockNumber: number,
Expand Down

0 comments on commit 9255238

Please sign in to comment.