Skip to content

Commit

Permalink
Fix code post review
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibautBremand committed Aug 14, 2023
1 parent 0139fd5 commit f7f5859
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
14 changes: 7 additions & 7 deletions packages/extension/cypress/e2e/NFT.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { formatFlags } from '../../src/utils';
describe('Mint', () => {
// deepcode ignore NoHardcodedPasswords: password used for testing purposes
const PASSWORD = 'SECRET_PASSWORD';
const MINT_NFT_URL = `http://localhost:3000/mint-nft?URI=4d696e746564207468726f7567682047656d57616c6c657421&flags=%7B%22tfOnlyXRP%22%3Afalse%2C%22tfTransferable%22%3Atrue%7D&fee=199&transferFee=3000&NFTokenTaxon=0&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210324818&requestMessage=undefined&transaction=mintNFT`;
const MINT_NFT_URL = `http://localhost:3000?URI=4d696e746564207468726f7567682047656d57616c6c657421&flags=%7B%22tfOnlyXRP%22%3Afalse%2C%22tfTransferable%22%3Atrue%7D&fee=199&transferFee=3000&NFTokenTaxon=0&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210324818&requestMessage=undefined&transaction=mintNFT`;

beforeEach(() => {
// Mock the localStorage with a wallet already loaded
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('Mint', () => {
});

it('Create NFT Offer (50 XRP)', function () {
const url = `http://localhost:3000/create-nft-offer?amount=50000000&NFTokenID=${this.NFTokenID}&fee=199&flags=%7B%22tfSellNFToken%22%3Atrue%7D&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210325582&requestMessage=undefined&transaction=createNFTOffer`;
const url = `http://localhost:3000?amount=50000000&NFTokenID=${this.NFTokenID}&fee=199&flags=%7B%22tfSellNFToken%22%3Atrue%7D&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210325582&requestMessage=undefined&transaction=createNFTOffer`;
navigate(url, PASSWORD);

// Confirm
Expand Down Expand Up @@ -214,7 +214,7 @@ describe('Mint', () => {
});

it('Accept NFT Offer', function () {
const url = `http://localhost:3000/accept-nft-offer?NFTokenSellOffer=${this.OfferID}&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210325959&requestMessage=undefined&transaction=acceptNFTOffer`;
const url = `http://localhost:3000?NFTokenSellOffer=${this.OfferID}&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210325959&requestMessage=undefined&transaction=acceptNFTOffer`;

navigate(url, PASSWORD);

Expand Down Expand Up @@ -245,7 +245,7 @@ describe('Mint', () => {
issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN',
value: '0.1'
});
const url = `http://localhost:3000/accept-nft-offer?NFTokenBrokerFee=${amount}&NFTokenSellOffer=${this.OfferID}&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210325959&requestMessage=undefined&transaction=acceptNFTOffer`;
const url = `http://localhost:3000?NFTokenBrokerFee=${amount}&NFTokenSellOffer=${this.OfferID}&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210325959&requestMessage=undefined&transaction=acceptNFTOffer`;

navigate(url, PASSWORD);

Expand All @@ -272,7 +272,7 @@ describe('Mint', () => {
issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN',
value: '0.1'
});
const url = `http://localhost:3000/accept-nft-offer?NFTokenBrokerFee=${amount}&NFTokenSellOffer=${this.OfferID}&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210325959&requestMessage=undefined&transaction=acceptNFTOffer`;
const url = `http://localhost:3000?NFTokenBrokerFee=${amount}&NFTokenSellOffer=${this.OfferID}&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210325959&requestMessage=undefined&transaction=acceptNFTOffer`;

navigate(url, PASSWORD);

Expand All @@ -294,7 +294,7 @@ describe('Mint', () => {
});

it('Cancel NFT Offer', function () {
const url = `http://localhost:3000/cancel-nft-offer?NFTokenOffers=%5B%22${this.OfferID}%22%5D&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210325959&requestMessage=undefined&transaction=cancelNFTOffer`;
const url = `http://localhost:3000?NFTokenOffers=%5B%22${this.OfferID}%22%5D&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210325959&requestMessage=undefined&transaction=cancelNFTOffer`;
navigate(url, PASSWORD);

// Confirm
Expand All @@ -318,7 +318,7 @@ describe('Mint', () => {
});

it('Burn NFT', function () {
const url = `http://localhost:3000/burn-nft?NFTokenID=${this.NFTokenID}&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210325959&requestMessage=undefined&transaction=burnNFT`;
const url = `http://localhost:3000?NFTokenID=${this.NFTokenID}&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210325959&requestMessage=undefined&transaction=burnNFT`;
navigate(url, PASSWORD);

// Confirm
Expand Down
12 changes: 6 additions & 6 deletions packages/extension/cypress/e2e/offers.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Offers', () => {
});

it('Create offer (XRP to ETH)', () => {
const url = `http://localhost:3000/create-offer?takerGets=10000000&takerPays=%7B%22currency%22%3A%22ETH%22%2C%22issuer%22%3A%22rnm76Qgz4G9G4gZBJVuXVvkbt7gVD7szey%22%2C%22value%22%3A%220.1%22%7D&flags=%7B%22tfPassive%22%3Atrue%7D&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210328024&requestMessage=undefined&transaction=createOffer`;
const url = `http://localhost:3000?takerGets=10000000&takerPays=%7B%22currency%22%3A%22ETH%22%2C%22issuer%22%3A%22rnm76Qgz4G9G4gZBJVuXVvkbt7gVD7szey%22%2C%22value%22%3A%220.1%22%7D&flags=%7B%22tfPassive%22%3Atrue%7D&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210328024&requestMessage=undefined&transaction=createOffer`;
navigate(url, PASSWORD);

cy.get('h1[data-testid="page-title"]').should('have.text', 'Create Offer');
Expand Down Expand Up @@ -54,7 +54,7 @@ describe('Offers', () => {
value: '0.1'
});

const url = `http://localhost:3000/create-offer?takerGets=10000000&takerPays=${amount}&flags=%7B%22tfPassive%22%3Atrue%7D&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210328024&requestMessage=undefined&transaction=createOffer`;
const url = `http://localhost:3000?takerGets=10000000&takerPays=${amount}&flags=%7B%22tfPassive%22%3Atrue%7D&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210328024&requestMessage=undefined&transaction=createOffer`;
navigate(url, PASSWORD);

cy.get('h1[data-testid="page-title"]').should('have.text', 'Create Offer');
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('Offers', () => {
value: '0.1'
});

const url = `http://localhost:3000/create-offer?takerPays=10000000&takerGets=${amount}&flags=%7B%22tfPassive%22%3Atrue%7D&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210328024&requestMessage=undefined&transaction=createOffer`;
const url = `http://localhost:3000?takerPays=10000000&takerGets=${amount}&flags=%7B%22tfPassive%22%3Atrue%7D&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210328024&requestMessage=undefined&transaction=createOffer`;
navigate(url, PASSWORD);

cy.get('h1[data-testid="page-title"]').should('have.text', 'Create Offer');
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('Offers', () => {
value: '0.1'
});

const url = `http://localhost:3000/create-offer?takerGets=10000000&takerPays=${amount}&flags=%7B%22tfPassive%22%3Atrue%7D&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210328024&requestMessage=undefined&transaction=createOffer`;
const url = `http://localhost:3000?takerGets=10000000&takerPays=${amount}&flags=%7B%22tfPassive%22%3Atrue%7D&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210328024&requestMessage=undefined&transaction=createOffer`;
navigate(url, PASSWORD);

cy.get('h1[data-testid="page-title"]').should('have.text', 'Create Offer');
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('Offers', () => {
value: '0.1'
});

const url = `http://localhost:3000/create-offer?takerPays=10000000&takerGets=${amount}&flags=%7B%22tfPassive%22%3Atrue%7D&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210328024&requestMessage=undefined&transaction=createOffer`;
const url = `http://localhost:3000?takerPays=10000000&takerGets=${amount}&flags=%7B%22tfPassive%22%3Atrue%7D&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210328024&requestMessage=undefined&transaction=createOffer`;
navigate(url, PASSWORD);

cy.get('h1[data-testid="page-title"]').should('have.text', 'Create Offer');
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('Offers', () => {

it('Cancel offer', function () {
navigate(
`http://localhost:3000/cancel-offer?offerSequence=${this.sequence}&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210328126&requestMessage=undefined&transaction=cancelOffer`,
`http://localhost:3000?offerSequence=${this.sequence}&fee=199&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210328126&requestMessage=undefined&transaction=cancelOffer`,
PASSWORD
);

Expand Down
2 changes: 1 addition & 1 deletion packages/extension/cypress/e2e/set_account.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Set Account', () => {

it('Set Account', () => {
cy.visit(
`http://localhost:3000/set-account?emailHash=1D1382344586ECFF844DACFF698C2EFB&fee=199&flags=%7B%22tfAllowXRP%22%3Atrue%7D&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210327555&requestMessage=undefined&transaction=setAccount`,
`http://localhost:3000?emailHash=1D1382344586ECFF844DACFF698C2EFB&fee=199&flags=%7B%22tfAllowXRP%22%3Atrue%7D&memos=%5B%7B%22memo%22%3A%7B%22memoType%22%3A%224465736372697074696f6e%22%2C%22memoData%22%3A%2254657374206d656d6f%22%7D%7D%5D&id=210327555&requestMessage=undefined&transaction=setAccount`,
{
onBeforeLoad(win) {
(win as any).chrome = (win as any).chrome || {};
Expand Down
4 changes: 2 additions & 2 deletions packages/extension/cypress/e2e/submit_transaction.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Submit Transaction', () => {
});

it('Submit Transaction', () => {
const url = `http://localhost:3000/submit-transaction?transaction=%7B%22TransactionType%22%3A%22Payment%22%2C%22Destination%22%3A%22rhikRdkFw28csKw9z7fVoBjWncz1HSoQij%22%2C%22Amount%22%3A%22100000%22%7D&id=210329246&requestMessage=undefined&submit=transaction`;
const url = `http://localhost:3000?transaction=%7B%22TransactionType%22%3A%22Payment%22%2C%22Destination%22%3A%22rhikRdkFw28csKw9z7fVoBjWncz1HSoQij%22%2C%22Amount%22%3A%22100000%22%7D&id=210329246&requestMessage=undefined&submit=transaction`;
navigate(url, PASSWORD);

cy.get('h1[data-testid="page-title"]').should('have.text', 'Confirm Transaction');
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('Submit Transaction', () => {
],
Fee: '199'
});
const url = `http://localhost:3000/submit-transaction?transaction=${transaction}&requestMessage=undefined&submit=transaction`;
const url = `http://localhost:3000?transaction=${transaction}&requestMessage=undefined&submit=transaction`;
navigate(url, PASSWORD);

cy.get('h1[data-testid="page-title"]').should('have.text', 'Confirm Transaction');
Expand Down
20 changes: 10 additions & 10 deletions packages/extension/src/components/molecules/NFTCard/NFTCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ export const NFTCard: FC<NFTCardProps> = ({ NFT }) => {
const [isLoading, setIsLoading] = useState(true);
const [dialogOpen, setDialogOpen] = useState(false);

const handleViewNFTClick = useCallback(() => {
setDialogOpen(true);
}, []);

const handleCloseDialog = useCallback(() => {
setDialogOpen(false);
}, []);

useEffect(() => {
const fetchNFTImg = async () => {
try {
Expand All @@ -58,9 +50,17 @@ export const NFTCard: FC<NFTCardProps> = ({ NFT }) => {
fetchNFTImg();
}, [getNFTData, NFT]);

const handleTokenIdClick = (tokenId: string) => {
const handleViewNFTClick = useCallback(() => {
setDialogOpen(true);
}, []);

const handleCloseDialog = useCallback(() => {
setDialogOpen(false);
}, []);

const handleTokenIdClick = useCallback((tokenId: string) => {
navigator.clipboard.writeText(tokenId);
};
}, []);

if (!NFTData) return null;

Expand Down

0 comments on commit f7f5859

Please sign in to comment.