Skip to content

Commit f3b80ae

Browse files
authored
Merge pull request #292 from kodadot/main
🔖 Speck v13
2 parents 96c6a99 + a2f2f46 commit f3b80ae

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

squid.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
manifestVersion: subsquid.io/v0.1
22
name: stick
3-
version: 11
3+
version: 13
44
description: 'SubSquid indexer for Uniques and Assets on Statemine'
55
build:
66
deploy:

src/mappings/nfts/setAttribute.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getOrFail as get } from '@kodadot1/metasquid/entity'
22
import { CollectionEntity, NFTEntity } from '../../model'
33
import { unwrap } from '../utils/extract'
44
import { Context, isNFT } from '../utils/types'
5-
import { addressOf, unHex } from '../utils/helper'
5+
import { addressOf, isAddress, unHex } from '../utils/helper'
66
import { getAttributeEvent } from './getters'
77
import { attributeFrom, tokenIdOf } from './types'
88

@@ -37,8 +37,11 @@ export async function handleAttributeSet(context: Context): Promise<void> {
3737
try {
3838
final.recipient = final.recipient || addressOf(event.value as string)
3939
} catch (error) {
40-
console.log(error)
41-
final.recipient = '' // final.recipient ?? (event.value as string)
40+
const human = unHex(event.value)
41+
final.recipient = isAddress(human) ? human : ''
42+
if (final.recipient === '') {
43+
console.log(error)
44+
}
4245
}
4346
}
4447

src/mappings/utils/helper.ts

+13
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ export function addressOf(address: Uint8Array | string): string {
5151
return ss58.codec(codec).encode(value)
5252
}
5353

54+
export function isAddress(value: Optional<string>): value is string {
55+
if (!value) {
56+
return false
57+
}
58+
59+
try {
60+
ss58.decode(value)
61+
return true
62+
} catch {
63+
return false
64+
}
65+
}
66+
5467
/**
5568
* Decode a hex value
5669
* @param value - the value to decode

0 commit comments

Comments
 (0)