@rss3/js-sdk
Advanced tools
Comparing version 0.6.47 to 0.6.48
import { components } from '../../types/data.js'; | ||
/** | ||
* it will add the basic wallet address to profile as the default profile | ||
* also sort the profile list and fix the avatar logic, the ens registrar profile will be the first | ||
* sort the profile list and fix the avatar logic, the ens registrar profile will be the first | ||
*/ | ||
export declare function formatProfiles(profiles: components['schemas']['Profile'][] | undefined, address: string | undefined): { | ||
export declare function formatProfiles(profiles: components['schemas']['Profile'][] | undefined, account: string | undefined): { | ||
action?: "create" | "update" | "renew" | "unwrap" | "wrap" | undefined; | ||
@@ -8,0 +7,0 @@ address?: string | undefined; |
import { EMPTY_ADDRESS } from '../../constants.js'; | ||
import { addressToAvatarURL, formatAddress, isAddress } from '../address/index.js'; | ||
import { addressToAvatarURL } from '../address/index.js'; | ||
/** | ||
* it will add the basic wallet address to profile as the default profile | ||
* also sort the profile list and fix the avatar logic, the ens registrar profile will be the first | ||
* sort the profile list and fix the avatar logic, the ens registrar profile will be the first | ||
*/ | ||
export function formatProfiles(profiles, address) { | ||
export function formatProfiles(profiles, account) { | ||
if (!profiles) | ||
return profiles; | ||
let res = profiles || []; | ||
// add the basic wallet address to profile | ||
let wallet = address; | ||
if (wallet && !isAddress(wallet)) { | ||
wallet = res.find((item) => !!item.address)?.address; | ||
} | ||
if (wallet && isAddress(wallet)) { | ||
res.push({ | ||
address: wallet, | ||
bio: '', | ||
handle: wallet, | ||
name: formatAddress(wallet), | ||
network: 'Ethereum', | ||
platform: 'Ethereum', | ||
profileURI: [addressToAvatarURL(wallet, 100)], | ||
socialURI: [], | ||
}); | ||
} | ||
// sort the matched profile first | ||
res = res?.sort((a) => (a?.handle === address ? -1 : 1)); | ||
res = res?.sort((a) => (a?.handle === account ? -1 : 1)); | ||
// ens registrar first | ||
@@ -31,0 +13,0 @@ res = res?.sort((a) => (a?.platform === 'ENS Registrar' ? -1 : 1)); |
@@ -66,2 +66,7 @@ import { isAddress, isSupportedNS } from '../address/index.js'; | ||
: undefined; | ||
// remove the first media, which is the avatar of the author | ||
// this case only happens in mastodon | ||
if (target && target.media && data.network?.toLowerCase() === 'mastodon') { | ||
target.media = target.media.slice(1); | ||
} | ||
const res = { | ||
@@ -76,3 +81,7 @@ author_url: undefined, | ||
}; | ||
// the same as the target | ||
if (res.media && data.network?.toLowerCase() === 'mastodon') { | ||
res.media = res.media.slice(1); | ||
} | ||
return res; | ||
} |
{ | ||
"name": "@rss3/js-sdk", | ||
"description": "RSS3 JavaScript SDK, the Turbocharger🌪️ for Your Next Open Web Development.", | ||
"version": "0.6.47", | ||
"version": "0.6.48", | ||
"author": "Natural Selection Labs and RSS3 Contributors", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
345254
9117