Skip to content

Commit

Permalink
Merge pull request #468 from Cryptonomic/as-features
Browse files Browse the repository at this point in the history
NFT update
  • Loading branch information
anonymoussprocket authored Mar 29, 2022
2 parents a7cc98b + a9831f6 commit 68a1c8d
Show file tree
Hide file tree
Showing 23 changed files with 148 additions and 37 deletions.
14 changes: 10 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tezori",
"version": "1.3.0-beta",
"version": "1.3.1-beta",
"description": "An open-source wallet framework for the Tezos blockchain.",
"main": "./src/main.prod.js",
"scripts": {
Expand Down Expand Up @@ -194,6 +194,7 @@
"node-sass": "4.14.1",
"opencollective-postinstall": "2.0.2",
"optimize-css-assets-webpack-plugin": "5.0.3",
"pngjs": "^6.0.0",
"prettier": "2.0.5",
"react-hot-loader": "4.12.21",
"react-test-renderer": "16.13.1",
Expand Down
3 changes: 2 additions & 1 deletion src/components/Media/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const ModalBox = styled.div`
& img,
& video,
div {
width: max-content;
width: auto;
height: auto;
max-width: 90vw;
max-height: 90vh;
Expand Down Expand Up @@ -81,6 +81,7 @@ export const PreviewIcon = styled.span`
export const StyledImage = styled(Image)`
& > img {
border-radius: 8px;
image-rendering: pixelated;
}
`;

Expand Down
4 changes: 2 additions & 2 deletions src/config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "Tezori",
"version": "1.3.0-beta",
"version": "1.3.1-beta",
"blockExplorerHost": "https://arronax.io/tezos",
"logo": "tezosLogo.png",
"logoLink": "https://github.com/Cryptonomic/T2",
"termsService": "https://github.com/Cryptonomic/T2",
"privacyPolicy": "https://github.com/Cryptonomic/T2",
"tagline": "containers.loginHome.tagline",
"LocalVersionIndex": "56",
"LocalVersionIndex": "57",
"helpUrl": "https://github.com/Cryptonomic/T2",
"aboutUrl": "",
"ledgerAppUrl": "https://support.ledger.com/hc/en-us/articles/360016057774-Tezos-XTZ-",
Expand Down
66 changes: 64 additions & 2 deletions src/constants/Token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export const knownTokenContracts: (Token | VaultToken | ArtToken)[] = [
network: 'mainnet',
address: 'KT1K6TyRSsAxukmjDWik1EoExSKsTg9wGEEX',
displayName: 'Tezos Degen Club',
symbol: 'TBC',
symbol: 'TDC',
balance: 0,
transactions: [],
activeTab: COLLECTION,
Expand Down Expand Up @@ -587,6 +587,24 @@ export const knownTokenContracts: (Token | VaultToken | ArtToken)[] = [
provider: NFT_PROVIDERS.OBJKT_GENERIC,
hideOnLanding: true,
},
{
network: 'mainnet',
address: 'KT1QYVvQb1NCMWLLSAT7YcYtmmuEiKtTHmwd',
displayName: 'Ottez Oysters',
symbol: 'Ottez Oysters',
balance: 0,
transactions: [],
activeTab: COLLECTION,
kind: TokenKind.objkt,
scale: 0,
precision: 0,
round: 0,
mapid: 137098,
nftMetadataMap: 137100,
holderLocation: 'key',
provider: NFT_PROVIDERS.OBJKT_GENERIC,
hideOnLanding: true,
},
{
network: 'mainnet',
address: 'KT1Qm7MHmbdiBzoRs7xqBiqoRxw7T2cxTTJN',
Expand Down Expand Up @@ -774,6 +792,27 @@ export const knownTokenContracts: (Token | VaultToken | ArtToken)[] = [
helpLink: 'https://tzdropz.com',
displayHelpLink: 'tzdropz.com/',
},
{
network: 'mainnet',
address: 'KT1MxDwChiDwd6WBVs24g1NjERUoK622ZEFp',
displayName: '8bidou',
symbol: '8B',
balance: 0,
transactions: [],
activeTab: COLLECTION,
kind: TokenKind.objkt,
scale: 0,
precision: 0,
round: 0,
mapid: 113213,
nftMetadataMap: 113218,
holderLocation: 'key',
balancePath: '$.args[1].int',
provider: NFT_PROVIDERS.EIGHTB,
hideOnLanding: true,
helpLink: 'https://www.8bidou.com',
displayHelpLink: '8bidou.com',
},
{
network: 'mainnet',
address: 'KT1VYsVfmobT7rsMVivvZ4J8i3bPiqz12NaH',
Expand Down Expand Up @@ -824,9 +863,29 @@ export const knownTokenContracts: (Token | VaultToken | ArtToken)[] = [
round: 2,
mapid: 103270,
balancePath: '$.args[1].int',
helpLink: 'https://objkt.com/',
helpLink: 'https://objkt.com',
displayHelpLink: 'objkt.com',
},
{
network: 'mainnet',
address: 'KT1AWoUQAuUudqpc75cGukWufbfim3GRn8h6',
displayName: 'Flex Fashion',
symbol: 'FF',
balance: 0,
transactions: [],
activeTab: COLLECTION,
kind: TokenKind.objkt,
scale: 0,
precision: 0,
round: 0,
mapid: 124575,
nftMetadataMap: 124577,
holderLocation: 'key',
provider: NFT_PROVIDERS.OBJKT_GENERIC,
helpLink: 'https://flex.fashion',
displayHelpLink: 'flex.fashion',
hideOnLanding: true,
},
{
network: 'mainnet',
address: 'KT1XpYoPCxQnpgxLM22dkLDXBmTsDLc1S8nZ',
Expand Down Expand Up @@ -1634,6 +1693,9 @@ export const knownContractNames = {
KT1NVXxerB7NFi12CGP79fwoLHhuaxPBV2tQ: 'Dogami Auction',

KT1NkWx47WzJeHCSyB62WjLtFn4tRf3uXBur: 'Tezos Degen Club coin flip',

KT1BvWGFENd4CXW5F3u4n31xKfJhmBGipoqF: '8bidou Market',
KT1MxDwChiDwd6WBVs24g1NjERUoK622ZEFp: '8bidou NFT',
};

export const knownMarketMetadata = [
Expand Down
2 changes: 2 additions & 0 deletions src/contracts/NFT/components/NFTMoreInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export const NFTMoreInfo: FunctionComponent<NFTMoreInfoProps> = ({ nftObject })
openArtifactLink(`https://objkt.com/asset/${nftObject.tokenAddress}/${nftObject.objectId}`);
} else if (nftObject?.provider === NFT_PROVIDERS.DOGAMI) {
openArtifactLink(`https://marketplace.dogami.com/dog/${nftObject.objectId}`);
} else if (nftObject?.provider === NFT_PROVIDERS.EIGHTB) {
openArtifactLink(`https://www.8bidou.com/listing/?id=${nftObject.objectId}`);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/contracts/NFT/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const NFT_PROVIDERS = {
FXHASH: 'FXHASH',
VERSUM: 'VERSUM',
RARIBLE: 'RARIBLE',
EIGHTB: 'EIGHTB',
IPFS: 'IPFS',

OBJKT_GENERIC: 'OBJKT_GENERIC',
Expand Down
35 changes: 34 additions & 1 deletion src/contracts/NFT/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ConseilQueryBuilder, ConseilOperator, KeyStore, MultiAssetTokenHelper,
import { BigNumber } from 'bignumber.js';
import { JSONPath } from 'jsonpath-plus';
import { proxyFetch, ImageProxyServer, ImageProxyDataType } from 'nft-image-proxy';
import * as png from 'pngjs';

import { NFT_ACTION_TYPES, NFT_ERRORS, NFT_PROVIDERS } from './constants';
import { TransferNFTError } from './exceptions';
Expand Down Expand Up @@ -580,9 +581,38 @@ export async function getObjktNFTDetails(tezosUrl: string, objectId: number | st
};
}

export async function get8bidouDetails(tezosUrl: string, objectId: number | string, metadataMap: number) {
const packedNftId = TezosMessageUtils.encodeBigMapKey(Buffer.from(TezosMessageUtils.writePackedData(objectId, 'int'), 'hex'));
const nftInfo = await TezosNodeReader.getValueForBigMapKey(tezosUrl, metadataMap, packedNftId);

const creatorBytes = JSONPath({ path: '$.args[2].bytes', json: nftInfo })[0]; // $.args[1].string
const descriptionBytes = JSONPath({ path: '$.args[4].bytes', json: nftInfo })[0];
const nameBytes = JSONPath({ path: '$.args[3].bytes', json: nftInfo })[0];
const imageDataBytes = JSONPath({ path: '$.args[5].string', json: nftInfo })[0];

const nftCreators = Buffer.from(creatorBytes, 'hex').toString();
const nftDescription = Buffer.from(descriptionBytes, 'hex').toString();
const nftName = Buffer.from(nameBytes, 'hex').toString();

const image = new png.PNG({ width: 8, height: 8, bitDepth: 8, colorType: 2, inputColorType: 2, inputHasAlpha: false });
image.data = Buffer.from(imageDataBytes, 'hex');
const buffer = png.PNG.sync.write(image, { width: 8, height: 8, bitDepth: 8, colorType: 2, inputColorType: 2, inputHasAlpha: false });
const artifactUrl = `data:image/png;base64,${buffer.toString('base64')}`;

return {
name: nftName,
description: nftDescription,
creators: nftCreators,
artifactUrl,
artifactType: 'image/png',
artifactModerationMessage: undefined,
thumbnailUri: artifactUrl,
};
}

export async function getDogamiDetails(tezosUrl: string, objectId: number | string, metadataMap: number) {
const packedNftId = TezosMessageUtils.encodeBigMapKey(Buffer.from(TezosMessageUtils.writePackedData(objectId, 'int'), 'hex'));
const nftInfo = await TezosNodeReader.getValueForBigMapKey(tezosUrl, metadataMap, packedNftId); // TODO: store in token definition
const nftInfo = await TezosNodeReader.getValueForBigMapKey(tezosUrl, metadataMap, packedNftId);

const artifactUrlBytes = JSONPath({ path: '$.args[1][0].args[1].bytes', json: nftInfo })[0];
const creatorBytes = JSONPath({ path: '$.args[1][2].args[1].bytes', json: nftInfo })[0];
Expand Down Expand Up @@ -855,6 +885,9 @@ export async function getCollection(tokenAddress: string, tokenMapId: number, qu
if (metadataMapId === 115420) {
// HACK: dogami
objectDetails = await getDogamiDetails(node.tezosUrl, objectId, metadataMapId);
} else if (metadataMapId === 113218) {
// HACK 8bidou
objectDetails = await get8bidouDetails(node.tezosUrl, objectId, metadataMapId);
} else {
objectDetails = await getObjktNFTDetails(node.tezosUrl, objectId, metadataMapId, urlPath);
}
Expand Down
27 changes: 6 additions & 21 deletions src/featureModals/Beacon/BeaconAuthorization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,9 @@ import { createMessageAction } from '../../reduxContent/message/actions';
import { ModalWrapper, ModalContainer, Container, ButtonContainer, InvokeButton, WhiteBtn, Footer } from '../style';

import { estimateOperationGroupFee, sendOperations, queryHicEtNuncSwap } from './thunks';
import { WrapPassword, OperationDetailHeader } from './style';
import { WrapPassword, OperationDetailHeader, LabelText } from './style';
import { beaconClient } from './BeaconMessageRouter';

const AddCircleWrapper = styled(AddCircle)<{ active: number }>`
&&& {
fill: #7b91c0;
width: ${ms(1)};
height: ${ms(1)};
opacity: ${({ active }) => (active ? 1 : 0.5)};
cursor: ${({ active }) => (active ? 'pointer' : 'default')};
}
`;

export const LabelText = styled.span`
display: block;
margin-bottom: 0px;
font-size: 12px;
color: ${({ theme: { colors } }) => colors.gray5};
font-weight: 400;
`;

interface Props {
open: boolean;
managerBalance: number;
Expand Down Expand Up @@ -149,12 +131,15 @@ const BeaconAuthorize = ({ open, managerBalance, onClose }: Props) => {
useEffect(() => {
if (!estimates.estimatedFee) {
setFee('0');
} else if (typeof estimates.estimatedFee === 'string') {
setFeeError(estimates.estimatedFee);
setFeeError('');
} else if (estimates.feeError && estimates.feeError.length > 0) {
setFeeError(estimates.feeError);
} else {
setFeeError('');
setFee(formatAmount(estimates.estimatedFee));
setCustomFee(formatAmount(estimates.estimatedFee));
}

if (typeof estimates.estimatedStorage === 'number') {
setCustomStorageLimit(estimates.estimatedStorage);
}
Expand Down
8 changes: 8 additions & 0 deletions src/featureModals/Beacon/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ export const OperationDetailHeader = styled.div`
font-size: 12px;
float: left;
`;

export const LabelText = styled.span`
display: block;
margin-bottom: 0px;
font-size: 12px;
color: ${({ theme: { colors } }) => colors.gray5};
font-weight: 400;
`;
7 changes: 4 additions & 3 deletions src/featureModals/Beacon/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getMainNode } from '../../utils/settings';
export function estimateOperationGroupFee(publicKeyHash: string, operations: any[]): any {
// TODO: type
const store = useStore<RootState>();
const [fee, setFee] = useState({ estimatedFee: 0, estimatedGas: 0, estimatedStorage: 0 });
const [fee, setFee] = useState({ estimatedFee: 0, estimatedGas: 0, estimatedStorage: 0, feeError: '' });

useEffect(() => {
const estimateInvocation = async () => {
Expand All @@ -31,10 +31,11 @@ export function estimateOperationGroupFee(publicKeyHash: string, operations: any
const estimate = await TezosNodeWriter.estimateOperationGroup(tezosUrl, 'main', formedOperations);
const estimatedGas = estimate.operationResources.reduce((a, c) => (a += c.gas), 0);
const estimatedStorage = estimate.operationResources.reduce((a, c) => (a += c.storageCost), 0);
setFee({ estimatedFee: estimate.estimatedFee, estimatedGas, estimatedStorage });
setFee({ estimatedFee: estimate.estimatedFee, estimatedGas, estimatedStorage, feeError: '' });
} catch (e) {
const err = e as Error;
console.log('estimateInvocation failed with ', e);
setFee(e.message);
setFee({ estimatedFee: -1, estimatedGas: -1, estimatedStorage: -1, feeError: err.message });
}
};

Expand Down
1 change: 1 addition & 0 deletions src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@
"ONEOF": "oneof.com",
"FXHASH": "fxhash.xyz",
"RARIBLE": "rarible.com",
"EIGHTB": "8bidou.com",
"IPFS": "IPFS"
}
},
Expand Down
1 change: 1 addition & 0 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@
"ONEOF": "oneof.com",
"FXHASH": "fxhash.xyz",
"RARIBLE": "rarible.com",
"EIGHTB": "8bidou.com",
"IPFS": "IPFS"
}
},
Expand Down
1 change: 1 addition & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@
"ONEOF": "oneof.com",
"FXHASH": "fxhash.xyz",
"RARIBLE": "rarible.com",
"EIGHTB": "8bidou.com",
"IPFS": "IPFS"
}
},
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@
"ONEOF": "oneof.com",
"FXHASH": "fxhash.xyz",
"RARIBLE": "rarible.com",
"EIGHTB": "8bidou.com",
"IPFS": "IPFS"
}
},
Expand Down
1 change: 1 addition & 0 deletions src/locales/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@
"ONEOF": "oneof.com",
"FXHASH": "fxhash.xyz",
"RARIBLE": "rarible.com",
"EIGHTB": "8bidou.com",
"IPFS": "IPFS"
}
},
Expand Down
1 change: 1 addition & 0 deletions src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@
"ONEOF": "oneof.com",
"FXHASH": "fxhash.xyz",
"RARIBLE": "rarible.com",
"EIGHTB": "8bidou.com",
"IPFS": "IPFS"
}
},
Expand Down
1 change: 1 addition & 0 deletions src/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@
"ONEOF": "oneof.com",
"FXHASH": "fxhash.xyz",
"RARIBLE": "rarible.com",
"EIGHTB": "8bidou.com",
"IPFS": "IPFS"
}
},
Expand Down
Loading

0 comments on commit 68a1c8d

Please sign in to comment.