Skip to content

Commit

Permalink
feat: add marketplace logos (#840)
Browse files Browse the repository at this point in the history
* feat: marketplace-logos add logos

* feat: add marketplace-logos

* feat: marketplace-logos update styles

* feat/marketplace-logos add heading

* feat: marketplace-logos update magic eden logo

* feat: marketplace-logos decapitalize by in trusted by
  • Loading branch information
Codigo-Fuentes authored Nov 24, 2021
1 parent d4a650c commit f02ee96
Show file tree
Hide file tree
Showing 37 changed files with 409 additions and 165 deletions.
10 changes: 5 additions & 5 deletions packages/api/src/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function addDirectory(files, options = {}) {
metadata: { size: size.toString() },
...options,
})
return results.map(result => ({
return results.map((result) => ({
cid: result.cid,
size: Number(result.size),
}))
Expand All @@ -78,7 +78,7 @@ export const importAsset = async (file, options = {}) => {
if (result.length < 2) {
throw new Error(
`Expected response with at least two entries, but instead got: ${result.map(
$ => $.cid
($) => $.cid
)}`
)
}
Expand All @@ -103,8 +103,8 @@ export function delegates() {
*/
export function toPSAStatus(status) {
const pinInfos = Object.values(status.peerMap)
if (pinInfos.some(i => i.status === 'pinned')) return 'pinned'
if (pinInfos.some(i => i.status === 'pinning')) return 'pinning'
if (pinInfos.some(i => i.status === 'pin_queued')) return 'queued'
if (pinInfos.some((i) => i.status === 'pinned')) return 'pinned'
if (pinInfos.some((i) => i.status === 'pinning')) return 'pinning'
if (pinInfos.some((i) => i.status === 'pin_queued')) return 'queued'
return 'failed'
}
6 changes: 3 additions & 3 deletions packages/api/src/routes/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function getUserMetrics() {
export async function getNftMetrics() {
const types = ['Car', 'Blob', 'Multipart', 'Remote', 'Nft']
const totals = await Promise.all(
types.map(async t => {
types.map(async (t) => {
const query = db.client.from('upload')
const res = await query
.select('*', { head: true, count: 'exact' })
Expand All @@ -36,9 +36,9 @@ export async function getPinMetrics() {
const services = ['Pinata', 'IpfsCluster', 'IpfsCluster2']
const statuses = ['PinQueued', 'Pinning', 'Pinned', 'PinError']
const totals = await Promise.all(
services.map(async service => {
services.map(async (service) => {
const totals = await Promise.all(
statuses.map(async status => {
statuses.map(async (status) => {
const query = db.client.from('pin')
const res = await query
.select('*', { head: true, count: 'exact' })
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/routes/nfts-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ export async function nftList(event, ctx) {

return new JSONResponse({
ok: true,
value: nfts?.map(n => toNFTResponse(n)),
value: nfts?.map((n) => toNFTResponse(n)),
})
}
2 changes: 1 addition & 1 deletion packages/api/src/routes/nfts-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function nftUpload(event, ctx) {
dag_size: size,
mime_type: contentType,
type: 'Multipart',
files: files.map(f => ({
files: files.map((f) => ({
name: f.name,
type: f.type,
})),
Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/routes/pins-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ function parseSearchParams(params) {
const statusParam = params.get('status')
if (statusParam) {
// Note: undefined statuses from toDbPinStatus will fail validation below
out.status = /** @type {ListUploadsOptions["status"]}*/ (statusParam
.split(',')
.map(toDbPinStatus))
out.status = /** @type {ListUploadsOptions["status"]}*/ (
statusParam.split(',').map(toDbPinStatus)
)
}

const afterParam = params.get('after')
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/utils/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function validate(event, { sentry }) {
}

if (user.data) {
const key = user.data.keys.find(k => k?.secret === token)
const key = user.data.keys.find((k) => k?.secret === token)
if (key) {
return {
user: user.data,
Expand Down
2 changes: 1 addition & 1 deletion packages/api/test/maintenance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('maintenance middleware', () => {
}

const invalidModes = ['', null, undefined, ['r', '-'], 'rwx']
invalidModes.forEach(m => {
invalidModes.forEach((m) => {
// @ts-expect-error purposely passing invalid mode
setMaintenanceModeGetter(() => m)
assert.throws(block, /invalid maintenance mode/)
Expand Down
6 changes: 2 additions & 4 deletions packages/api/test/nfts-store.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ describe('NFT store', () => {
result,
{
ipnft: 'bafyreicnwbboevx6g6fykitf4nebz2kqgkqz35qvlnlcgfulhrris66m6i',
url:
'ipfs://bafyreicnwbboevx6g6fykitf4nebz2kqgkqz35qvlnlcgfulhrris66m6i/metadata.json',
url: 'ipfs://bafyreicnwbboevx6g6fykitf4nebz2kqgkqz35qvlnlcgfulhrris66m6i/metadata.json',
data: {
name: 'name',
description: 'stuff',
Expand Down Expand Up @@ -116,8 +115,7 @@ describe('NFT store', () => {
result,
{
ipnft: 'bafyreihihnpztkkjaegm2cldghihv4otaa23v2lf6uhmbm2avoolgkfynm',
url:
'ipfs://bafyreihihnpztkkjaegm2cldghihv4otaa23v2lf6uhmbm2avoolgkfynm/metadata.json',
url: 'ipfs://bafyreihihnpztkkjaegm2cldghihv4otaa23v2lf6uhmbm2avoolgkfynm/metadata.json',
data: {
name: 'name',
description: 'stuff',
Expand Down
2 changes: 1 addition & 1 deletion packages/client/examples/node.js/encodeBlob.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function main() {

console.log('Sending file...')
await storage.storeCar(car, {
onStoredChunk: size => console.log(`Stored a chunk of ${size} bytes`),
onStoredChunk: (size) => console.log(`Stored a chunk of ${size} bytes`),
})

console.log('✅ Done')
Expand Down
67 changes: 34 additions & 33 deletions packages/client/src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,38 +125,39 @@ class NFTStorage {
? await TreewalkCarSplitter.fromBlob(car, targetSize, { decoders })
: new TreewalkCarSplitter(car, targetSize, { decoders })

const upload = transform(MAX_CONCURRENT_UPLOADS, async function(
/** @type {AsyncIterable<Uint8Array>} */ car
) {
const carParts = []
for await (const part of car) {
carParts.push(part)
}
const carFile = new Blob(carParts, { type: 'application/car' })
const cid = await pRetry(
async () => {
const response = await fetch(url.toString(), {
method: 'POST',
headers,
body: carFile,
})
const result = await response.json()
if (!result.ok) {
// do not retry if unauthorized - will not succeed
if (response.status === 401) {
throw new AbortError(result.error.message)
const upload = transform(
MAX_CONCURRENT_UPLOADS,
async function (/** @type {AsyncIterable<Uint8Array>} */ car) {
const carParts = []
for await (const part of car) {
carParts.push(part)
}
const carFile = new Blob(carParts, { type: 'application/car' })
const cid = await pRetry(
async () => {
const response = await fetch(url.toString(), {
method: 'POST',
headers,
body: carFile,
})
const result = await response.json()
if (!result.ok) {
// do not retry if unauthorized - will not succeed
if (response.status === 401) {
throw new AbortError(result.error.message)
}
throw new Error(result.error.message)
}
throw new Error(result.error.message)
return result.value.cid
},
{
retries: maxRetries == null ? MAX_STORE_RETRIES : maxRetries,
}
return result.value.cid
},
{
retries: maxRetries == null ? MAX_STORE_RETRIES : maxRetries,
}
)
onStoredChunk && onStoredChunk(carFile.size)
return cid
})
)
onStoredChunk && onStoredChunk(carFile.size)
return cid
}
)

let root
for await (const cid of upload(splitter.cars())) {
Expand Down Expand Up @@ -616,8 +617,8 @@ const packCar = async (input, wrapWithDirectory) => {
* @param {Deal[]} deals
* @returns {Deal[]}
*/
const decodeDeals = deals =>
deals.map(deal => {
const decodeDeals = (deals) =>
deals.map((deal) => {
const { dealActivation, dealExpiration, lastChanged } = {
dealExpiration: null,
dealActivation: null,
Expand All @@ -636,6 +637,6 @@ const decodeDeals = deals =>
* @param {Pin} pin
* @returns {Pin}
*/
const decodePin = pin => ({ ...pin, created: new Date(pin.created) })
const decodePin = (pin) => ({ ...pin, created: new Date(pin.created) })

export { NFTStorage, File, Blob, FormData, toGatewayURL, Token }
13 changes: 7 additions & 6 deletions packages/client/src/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const decode = ({ ipnft, url, data }, paths) =>
* @param {any} value
* @returns {value is URL}
*/
const isURL = value => value instanceof URL
const isURL = (value) => value instanceof URL

/**
* @template State
Expand All @@ -191,7 +191,7 @@ const embedURL = (context, url) => [context, toGatewayURL(url, context)]
* @param {any} value
* @returns {value is object}
*/
const isObject = value => typeof value === 'object' && value != null
const isObject = (value) => typeof value === 'object' && value != null

/**
* @param {any} value
Expand Down Expand Up @@ -238,7 +238,7 @@ const isEncodedURL = (value, assetPaths, path) =>
* @param {EncodedBlobBlob<T>} input
* @returns {FormData}
*/
export const encode = input => {
export const encode = (input) => {
const [map, meta] = mapValueWith(input, isBlob, encodeBlob, new Map(), [])
const form = new FormData()
for (const [k, v] of map.entries()) {
Expand All @@ -263,13 +263,13 @@ const encodeBlob = (data, blob, path) => {
* @param {any} value
* @returns {value is Blob}
*/
const isBlob = value => value instanceof Blob
const isBlob = (value) => value instanceof Blob

/**
* @template {TokenInput} T
* @param {EncodedBlobBlob<T>} input
*/
const mapTokenInputBlobs = input => {
const mapTokenInputBlobs = (input) => {
return mapValueWith(input, isBlob, encodeBlob, new Map(), [])
}

Expand Down Expand Up @@ -328,7 +328,8 @@ const mapValueWith = (input, p, f, state, path) =>
*/
const mapObjectWith = (input, p, f, init, path) => {
let state = init
const output = /** @type {import('./lib/interface.js').Encoded<T, [[I, O]]>} */ ({})
const output =
/** @type {import('./lib/interface.js').Encoded<T, [[I, O]]>} */ ({})
for (const [key, value] of Object.entries(input)) {
const [next, out] = mapValueWith(value, p, f, state, [...path, key])
// @ts-ignore
Expand Down
4 changes: 2 additions & 2 deletions packages/client/test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ export async function randomCar(targetSize) {
blocks.push({ cid, bytes })
size += bytes.length
}
const rootBytes = dagCbor.encode(blocks.map(b => b.cid))
const rootBytes = dagCbor.encode(blocks.map((b) => b.cid))
const rootHash = await sha256.digest(rootBytes)
const rootCid = CID.create(1, dagCbor.code, rootHash)
const { writer, out } = CarWriter.create([rootCid])
writer.put({ cid: rootCid, bytes: rootBytes })
blocks.forEach(b => writer.put(b))
blocks.forEach((b) => writer.put(b))
writer.close()
return out
}
2 changes: 1 addition & 1 deletion packages/client/test/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CarReader } from '@ipld/car'
/**
* @param {Uint8Array} content
*/
export const importCar = async content => {
export const importCar = async (content) => {
const car = await CarReader.fromBytes(content)
const [cid] = await car.getRoots()
if (!cid) {
Expand Down
8 changes: 4 additions & 4 deletions packages/client/test/lib.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe('client', () => {
assert.equal(cid, expectedCid)
})

it('upload large CAR with a CarReader', async function() {
it('upload large CAR with a CarReader', async function () {
this.timeout(130e3)
let uploadedChunks = 0

Expand Down Expand Up @@ -332,7 +332,7 @@ describe('client', () => {
const warn = console.warn
try {
let warnings = ['']
console.warn = msg => {
console.warn = (msg) => {
warnings.push(msg)
}

Expand Down Expand Up @@ -551,7 +551,7 @@ describe('client', () => {
})

afterEach(async () => {
await Promise.all(preloaded.map(cid => client.delete(cid)))
await Promise.all(preloaded.map((cid) => client.delete(cid)))
})

it('found', async () => {
Expand Down Expand Up @@ -703,7 +703,7 @@ describe('client', () => {
})

afterEach(async () => {
await Promise.all(preloaded.map(cid => client.delete(cid)))
await Promise.all(preloaded.map((cid) => client.delete(cid)))
})

it('found', async () => {
Expand Down
Loading

0 comments on commit f02ee96

Please sign in to comment.