Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dmosites committed Dec 21, 2023
2 parents 5cba9ac + fc6cb56 commit 0803728
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 47 deletions.
4 changes: 2 additions & 2 deletions source/balances/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"@openzeppelin/contracts": "^4.8.3"
},
"devDependencies": {
"@airswap/constants": "4.1.7",
"@airswap/utils": "4.1.10",
"@airswap/constants": "4.1.8",
"@airswap/utils": "4.1.11",
"prompt-confirm": "^2.0.4"
},
"publishConfig": {
Expand Down
8 changes: 4 additions & 4 deletions source/pool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"@openzeppelin/contracts": "^4.8.3"
},
"devDependencies": {
"@airswap/constants": "4.1.7",
"@airswap/metadata": "4.1.14",
"@airswap/types": "4.1.2",
"@airswap/utils": "4.1.10",
"@airswap/constants": "4.1.8",
"@airswap/metadata": "4.1.15",
"@airswap/types": "4.1.3",
"@airswap/utils": "4.1.11",
"prompt-confirm": "^2.0.4"
},
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions source/registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"access": "public"
},
"devDependencies": {
"@airswap/constants": "4.1.7",
"@airswap/utils": "4.1.10",
"@airswap/constants": "4.1.8",
"@airswap/utils": "4.1.11",
"prompt-confirm": "^2.0.4"
}
}
2 changes: 1 addition & 1 deletion source/staking/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"access": "public"
},
"devDependencies": {
"@airswap/utils": "4.1.10",
"@airswap/utils": "4.1.11",
"prompt-confirm": "^2.0.4"
}
}
6 changes: 3 additions & 3 deletions source/swap-erc20/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
"@openzeppelin/contracts": "^4.8.3"
},
"devDependencies": {
"@airswap/constants": "4.1.7",
"@airswap/constants": "4.1.8",
"@airswap/staking": "4.0.5",
"@airswap/types": "4.1.2",
"@airswap/utils": "4.1.10",
"@airswap/types": "4.1.3",
"@airswap/utils": "4.1.11",
"prompt-confirm": "^2.0.4"
},
"publishConfig": {
Expand Down
6 changes: 3 additions & 3 deletions source/swap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"@openzeppelin/contracts": "^4.8.3"
},
"devDependencies": {
"@airswap/constants": "4.1.7",
"@airswap/types": "4.1.2",
"@airswap/utils": "4.1.10",
"@airswap/constants": "4.1.8",
"@airswap/types": "4.1.3",
"@airswap/utils": "4.1.11",
"@nomicfoundation/hardhat-network-helpers": "^1.0.7"
},
"publishConfig": {
Expand Down
6 changes: 3 additions & 3 deletions source/wrapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"@openzeppelin/contracts": "^4.8.3"
},
"devDependencies": {
"@airswap/constants": "4.1.7",
"@airswap/utils": "4.1.10",
"@airswap/types": "4.1.2",
"@airswap/constants": "4.1.8",
"@airswap/utils": "4.1.11",
"@airswap/types": "4.1.3",
"@uniswap/v2-periphery": "^1.1.0-beta.0",
"prompt-confirm": "^2.0.4"
},
Expand Down
2 changes: 1 addition & 1 deletion tools/constants/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/constants",
"version": "4.1.7",
"version": "4.1.8",
"description": "AirSwap: Constants for Developers",
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions tools/libraries/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/libraries",
"version": "4.1.15",
"version": "4.1.16",
"description": "AirSwap: Libraries for Developers",
"repository": {
"type": "git",
Expand All @@ -27,15 +27,15 @@
},
"dependencies": {
"@airswap/balances": "4.0.4",
"@airswap/constants": "4.1.7",
"@airswap/constants": "4.1.8",
"@airswap/jsonrpc-client-websocket": "0.0.1",
"@airswap/registry": "4.1.3",
"@airswap/pool": "4.1.4",
"@airswap/staking": "4.0.5",
"@airswap/swap": "4.1.2",
"@airswap/swap-erc20": "4.1.6",
"@airswap/types": "4.1.2",
"@airswap/utils": "4.1.10",
"@airswap/types": "4.1.3",
"@airswap/utils": "4.1.11",
"@airswap/wrapper": "4.1.5",
"browser-or-node": "^2.1.1",
"ethers": "^5.6.9",
Expand Down
30 changes: 14 additions & 16 deletions tools/metadata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const AIRSWAP_LOGO_URI =
'https://storage.googleapis.com/subgraph-images/158680119781426823563.png'
const AIRSWAP_SYMBOL = 'AST'
const DEFAULT_NAME = 'Unknown NFT'
const DEFAULT_IPFS_URI = 'https://ipfs.io/ipfs/'

import { abi as ERC165_ABI } from '@openzeppelin/contracts/build/contracts/ERC165.json'
import { abi as ERC20_ABI } from '@openzeppelin/contracts/build/contracts/ERC20.json'
Expand Down Expand Up @@ -224,19 +225,16 @@ export async function getCollectionTokenInfo(
address: string,
id: string
): Promise<CollectionTokenInfo> {
const tokenKind = await getTokenKind(provider, address)
const kind = await getTokenKind(provider, address)

let uri = null
let metadata = null

if (!ethers.utils.isAddress(address)) {
throw new Error(`Invalid address: ${address}`)
}
if (isNaN(Number(id))) {
throw new Error(`Invalid id: ${id}`)
}
try {
switch (tokenKind) {
switch (kind) {
case TokenKinds.ERC721:
uri = await new ethers.Contract(address, ERC721_ABI, provider).tokenURI(
id
Expand All @@ -253,18 +251,18 @@ export async function getCollectionTokenInfo(
}
return {
chainId: (await provider.getNetwork()).chainId,
kind: tokenKind,
address: address.toLowerCase(),
id: Number(id),
kind,
id,
uri,
...metadata,
}
}

async function fetchMetaData(url: string) {
async function fetchMetaData(url: string, ipfsUri = DEFAULT_IPFS_URI) {
if (validUrl.isUri(url)) {
if (url.startsWith('ipfs')) {
url = `https://cloudflare-ipfs.com/${url.replace('://', '/')}`
url = url.replace('ipfs://', ipfsUri)
}
const data = await (await fetch(url)).json()
if (typeof data === 'string')
Expand All @@ -286,11 +284,12 @@ const transformErc721TokenAttributeToCollectionTokenAttribute = (
})

const transformERC721ToCollectionToken = (
metadata: any
metadata: any,
ipfsUri = DEFAULT_IPFS_URI
): CollectionTokenMetadata => ({
name: metadata.name || DEFAULT_NAME,
description: metadata.description,
image: metadata.image?.replace('ipfs://', 'https://ipfs.io/ipfs/'),
image: metadata.image?.replace('ipfs://', ipfsUri),
attributes: (metadata.attributes || []).map(
transformErc721TokenAttributeToCollectionTokenAttribute
),
Expand All @@ -304,15 +303,14 @@ const transformErc1155TokenAttributeToCollectionTokenAttribute = (
})

const transformERC1155ToCollectionToken = (
metadata: any
metadata: any,
ipfsUri = DEFAULT_IPFS_URI
): CollectionTokenMetadata => ({
name: metadata.name || DEFAULT_NAME,
description: metadata.description,
image:
(metadata.image_url || metadata.image || '').replace(
'ipfs://',
'https://ipfs.io/ipfs/'
) || undefined,
(metadata.image_url || metadata.image || '').replace('ipfs://', ipfsUri) ||
undefined,
attributes: (metadata.attributes || []).map(
transformErc1155TokenAttributeToCollectionTokenAttribute
),
Expand Down
6 changes: 3 additions & 3 deletions tools/metadata/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/metadata",
"version": "4.1.14",
"version": "4.1.15",
"description": "AirSwap: Token Metadata for Developers",
"repository": {
"type": "git",
Expand All @@ -20,8 +20,8 @@
"test": "TS_NODE_COMPILER_OPTIONS='{\"strict\":false}' yarn mocha -r ts-node/esm test/*.ts"
},
"dependencies": {
"@airswap/constants": "4.1.7",
"@airswap/types": "4.1.2",
"@airswap/constants": "4.1.8",
"@airswap/types": "4.1.3",
"@airswap/wrapper": "4.1.5",
"@openzeppelin/contracts": "^4.8.3",
"@uniswap/token-lists": "^1.0.0-beta.24",
Expand Down
2 changes: 1 addition & 1 deletion tools/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/types",
"version": "4.1.2",
"version": "4.1.3",
"description": "AirSwap: Types for Developers",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion tools/types/src/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ export type CollectionTokenInfo = {
chainId: number
kind: string
address: string
id: number
id: string
uri: string
} & CollectionTokenMetadata
6 changes: 3 additions & 3 deletions tools/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airswap/utils",
"version": "4.1.10",
"version": "4.1.11",
"description": "AirSwap: Utilities for Developers",
"repository": {
"type": "git",
Expand All @@ -21,8 +21,8 @@
"test:ci": "yarn test"
},
"dependencies": {
"@airswap/constants": "4.1.7",
"@airswap/types": "4.1.2",
"@airswap/constants": "4.1.8",
"@airswap/types": "4.1.3",
"@metamask/eth-sig-util": "^5.0.2",
"bignumber.js": "^9.0.1",
"ethereumjs-util": "^7.1.5",
Expand Down

0 comments on commit 0803728

Please sign in to comment.