Skip to content

Commit

Permalink
fix: 🐛 refactor and update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignazio Bovo committed Oct 30, 2023
1 parent f6bbbd8 commit dd762ab
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 27 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 3.0.2
### Bug Fixes:
- Store membership handles both as utf-8 string and raw bytes - [#4950](https://github.com/Joystream/joystream/pull/4950)
# 3.0.1
### Misc
- add migration for the `Account` id field
Expand Down
20 changes: 1 addition & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"@subsquid/typeorm-migration": "^0.1.4",
"@subsquid/typeorm-store": "^0.2.0",
"@types/lodash": "^4.14.189",
"@types/utf-8-validate": "^5.0.1",
"@typescript/analyze-trace": "^0.9.1",
"ajv": "^6.11.0",
"async-lock": "^1.3.1",
Expand All @@ -67,8 +66,7 @@
"type-graphql": "^1.2.0-rc.1",
"typeorm": "^0.3.11",
"ua-parser-js": "^1.0.34",
"url-join": "^4",
"utf-8-validate": "^5.0.10"
"url-join": "^4"
},
"devDependencies": {
"@graphql-codegen/cli": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/mappings/membership/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export async function processMemberProfileUpdatedEvent({
}

function updateMemberHandle(member: Membership, newHandle: Uint8Array) {
member.handleRaw = '0x' + u8aToHex(newHandle)
member.handleRaw = u8aToHex(newHandle)
member.handle = bytesToString(newHandle)
}

Expand Down
5 changes: 1 addition & 4 deletions src/mappings/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { createType } from '@joystream/types'
import { u8aToHex } from '@polkadot/util'
import { CommentCountersManager } from '../utils/CommentsCountersManager'
import { VideoRelevanceManager } from '../utils/VideoRelevanceManager'
import isValidUTF8 from 'utf-8-validate'

export const commentCountersManager = new CommentCountersManager()
export const videoRelevanceManager = new VideoRelevanceManager()
Expand All @@ -25,9 +24,7 @@ videoRelevanceManager.init(1000 * 60 * 60)
export const JOYSTREAM_SS58_PREFIX = 126

export function bytesToString(b: Uint8Array): string {
const buffer = Buffer.from(b) // assumes default utf-8 encoding
// Use the utf-8-validate library to check if the Buffer contains valid UTF-8 data
return isValidUTF8(buffer) ? buffer.toString('utf-8') : '0x' + buffer.toString('hex')
return Buffer.from(b).toString()
}

export function deserializeMetadata<T>(
Expand Down

0 comments on commit dd762ab

Please sign in to comment.