Skip to content

Commit

Permalink
Adds fetching of legacy profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-toth committed Sep 3, 2023
1 parent 16996e7 commit 38b25cc
Show file tree
Hide file tree
Showing 3 changed files with 242 additions and 147 deletions.
11 changes: 11 additions & 0 deletions src/legacy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@ export type LegacyPublicationManifest = {
model?: string
license?: LegacyPublicationManifestLicense
}

export type LegacyProfile = {
displayName?: string
bio?: string,
twitter?: string
x?: string
instagram?: string
twitch?: string
soundcloud?: string
linkedin?: string
}
38 changes: 38 additions & 0 deletions src/legacy/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ArtByCityEnvironment } from '../config'
import VerifiedCreators from './verified-creators.json'
import LegacyTransactions from './transactions'
import {
LegacyProfile,
LegacyPublicationFeed,
LegacyPublicationManifest,
LegacyPublicationManifestLicense
Expand Down Expand Up @@ -206,4 +207,41 @@ export default class ArtByCityLegacy {

return publication
}

async fetchProfile(address: string): Promise<LegacyProfile | null> {
const {
transactions
} = await this.transactions.query('profile', { from: address, limit: 1 })

if (transactions.length > 0) {
const profileId = transactions[0].id
const { data, ok } = await this.transactions.fetchData(profileId)

if (!ok) {
return null
}

if (
typeof data === 'string'
|| data instanceof ArrayBuffer
|| data instanceof ReadableStream
) {
return null
}

const profile: LegacyProfile = data

if (profile.twitter) {
profile.x = profile.twitter
}

if (profile.x) {
profile.twitter = profile.x
}

return profile
}

return null
}
}
Loading

0 comments on commit 38b25cc

Please sign in to comment.