sanitizeRecords
Usage
import { sanitizeRecords } from '@justaname.id/sdk'
// Sample subname response
const subnameResponse = {
name: 'alice.justaname.eth',
owner: '0x1234567890abcdef1234567890abcdef12345678',
records: {
texts: [
{ key: 'description', value: 'Web3 developer and designer' },
{ key: 'url', value: 'https://alice.eth' },
{ key: 'email', value: '[email protected]' },
{ key: 'avatar', value: 'https://example.com/avatar.jpg' },
{ key: 'com.twitter', value: '@alice_dev' },
{ key: 'com.github', value: 'alice-dev' }
],
coins: [
{ id: 60, name: 'ETH', value: '0x1234567890abcdef1234567890abcdef12345678' },
{ id: 0, name: 'BTC', value: '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa' }
],
contentHash: {
protocolType: 'ipfs',
decoded: 'QmHash1234567890abcdef'
}
}
}
const sanitized = sanitizeRecords(subnameResponse)
console.log(sanitized)
// {
// avatar: 'https://example.com/avatar.jpg',
// description: 'Web3 developer and designer',
// url: 'https://alice.eth',
// email: '[email protected]',
// ethAddress: { id: 60, name: 'ETH', value: '0x1234...', ... },
// generals: [
// { key: 'description', value: 'Web3 developer and designer' },
// { key: 'url', value: 'https://alice.eth' },
// { key: 'email', value: '[email protected]' },
// { key: 'avatar', value: 'https://example.com/avatar.jpg' }
// ],
// socials: [
// { key: 'com.twitter', value: '@alice_dev', name: 'Twitter' },
// { key: 'com.github', value: 'alice-dev', name: 'Github' }
// ],
// otherAddresses: [{ id: 0, name: 'BTC', value: '1A1z...', ... }],
// allAddresses: [...],
// allTexts: [...],
// contentHash: { protocolType: 'ipfs', decoded: 'QmHash1234567890abcdef' },
// contentHashUri: 'ipfs://QmHash1234567890abcdef'
// }Returns
Parameters
Defined in
Last updated