Skip to content

Commit

Permalink
Merge pull request #80 from CudoVentures/CUDOS-2076-Implement-missing…
Browse files Browse the repository at this point in the history
…-TxMsg-parsing

CUDOS-2076 missing Msgs - Address book module
  • Loading branch information
mlukanova authored Jan 31, 2023
2 parents d991014 + 9e2ec6f commit 7a079f0
Show file tree
Hide file tree
Showing 77 changed files with 2,629 additions and 11 deletions.
17 changes: 16 additions & 1 deletion public/locales/en/message_contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,20 @@
"txMigrateContract": "<0>{{admin}}</0> migrated contract <1>{{contract}}</1> to <1>{{newCodeId}}</1>",
"txUpdateContractAdmin": "<0>{{admin}}</0> updated contract <1>{{contract}}</1> admin to <2>{{newAdmin}}</2>",
"txClearContractAdmin": "<0>{{admin}}</0> cleared admin on contract <1>{{contract}}</1>",
"MsgSendToCosmosClaim": "<0>{{ethSender}}</0> sent <1>{{amount}}</1> to <2>{{receiver}}</2>"
"MsgSendToCosmosClaim": "<0>{{ethSender}}</0> sent <1>{{amount}}</1> to <2>{{receiver}}</2>",
"txCreateAddress": "<0>{{creator}}</0> created an addressbook record with the following details - <1></1>",
"txUpdateAddress": "<0>{{creator}}</0> updated an addressbook record. New details - <1></1>",
"txDeleteAddress": "<0>{{creator}}</0> deleted the following addressbook record - <1></1>",
"txCreateCollection": "<0>{{creator}}</0> created '<3>{{collectionId}}</3>' collection. <1></1><2></2>",
"txPublishCollection": "<0>{{creator}}</0> published '<3>{{collectionId}}</3>' collection. <1></1><2></2>",
"txUpdateRoyalties": "<0>{{creator}}</0> updated royalties for collection with ID: '<3>{{collectionId}}</3>' <1></1><2></2>",
"txVerifyCollection": "Marketplace admin: <1>{{admin}}</1> verified collection with ID: <2>{{collectionId}}</2> created by: <0>{{creator}}</0>",
"txUnverifyCollection": "Marketplace admin: <1>{{admin}}</1> unverified collection with ID: <2>{{collectionId}}</2> created by: <0>{{creator}}</0>",
"txAddAdmin": "<0>{{creator}}</0> added <1>{{address}}</1> as marketplace admin",
"txRemoveAdmin": "<0>{{creator}}</0> removed <1>{{address}}</1> from marketplace admins",
"txMintNft": "<0>{{creator}}</0> minted an NFT to <1>{{recipient}}</1> <2></2>",
"txPublishNft": "<0>{{creator}}</0> published for sale NFT with ID: <3>{{tokenId}}</3> from collection ID: <2>{{denomId}}</2> for <1>{{price}}</1>",
"txRemoveNft": "<0>{{creator}}</0> removed from sale NFT with ID: <1>{{id}}</1>",
"txUpdatePrice": "<0>{{creator}}</0> updated the price of NFT with ID: <2>{{id}}</2>. New price: <1>{{price}}</1>",
"txBuyNft": "<0>{{buyer}}</0> purchased NFT with ID: <3>{{id}}</3> from <1>{{seller}}</1> for <2>{{price}}</2>"
}
17 changes: 16 additions & 1 deletion public/locales/en/message_labels.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,20 @@
"txMigrateContract": "Migrate Contract",
"txUpdateContractAdmin": "Update Contract Admin",
"txClearContractAdmin": "Clear Contract Admin",
"MsgSendToCosmosClaim": "Gravity Bridge - Ethereum to Cosmos"
"MsgSendToCosmosClaim": "Gravity Bridge - Ethereum to Cosmos",
"txCreateAddress": "New Address Book Record",
"txUpdateAddress": "Update Address Book Record",
"txDeleteAddress": "Delete Address Book Record",
"txCreateCollection": "Create NFT Collection",
"txPublishCollection": "Publish NFT Collection",
"txUpdateRoyalties": "Update NFT Collection Royalties",
"txVerifyCollection": "Verify NFT Collection",
"txUnverifyCollection": "Unverify NFT Collection",
"txAddAdmin": "Add Marketplace Admin",
"txRemoveAdmin": "Remove Marketplace Admin",
"txMintNft": "Mint NFT",
"txPublishNft": "Publish NFT for sale",
"txRemoveNft": "Remove NFT from sale",
"txUpdatePrice": "Update NFT price",
"txBuyNft": "Buy NFT"
}
15 changes: 15 additions & 0 deletions src/components/addressbook_details/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { AddressBookDetailsValue } from '@src/models/msg/types';
import StyledTypographyPair from '../styled_typography_pair';

const AddressBookDetails = ({ content }: { content: AddressBookDetailsValue }) => {
return (
<>
{content.network ? <StyledTypographyPair text="Network:" content={content.network} /> : null}
{content.label ? <StyledTypographyPair text="Label:" content={content.label} /> : null}
{content.value ? <StyledTypographyPair text="Value:" content={content.value} /> : null}
</>
);
};

export default AddressBookDetails;
5 changes: 5 additions & 0 deletions src/components/addressbook_details/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const addressBookDetails = {
gap: '10px',
width: '100%',
display: 'flex',
};
6 changes: 6 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import AvatarNameListMsg from './avatar_name_list_msg';
import {
ContractOverview, ContractMessages, ContractMessagesList, SingleContractMessageMobile,
} from './cosmwasm';
import AddressBookDetails from './addressbook_details';
import RoyaltiesDetails from './royalties_details';
import NftDetails from './nft_details';

export {
Layout,
Expand Down Expand Up @@ -71,4 +74,7 @@ export {
ContractMessages,
ContractMessagesList,
SingleContractMessageMobile,
AddressBookDetails,
RoyaltiesDetails,
NftDetails,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`screen: TransactionDetails/MsgCreateAddress matches snapshot 1`] = `
<p
className="MuiTypography-root MuiTypography-body1"
>
message_contents:txCreateAddress
</p>
`;
45 changes: 45 additions & 0 deletions src/components/msg/addressbook/create_address/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';
import { RecoilRoot } from 'recoil';
import renderer from 'react-test-renderer';
import { MockTheme } from '@tests/utils';
import { MsgCreateAddress } from '@models';
import CreateAddress from '.';

// ==================================
// mocks
// ==================================

jest.mock('@components', () => ({
Name: (props) => <div id="Name" {...props} />,
}));

// ==================================
// unit tests
// ==================================
describe('screen: TransactionDetails/MsgCreateAddress', () => {
it('matches snapshot', () => {
const message = new MsgCreateAddress({
category: 'addressbook',
type: 'MsgCreateAddress',
creator: 'creatorAddress',
network: 'testNetwork',
label: 'testLabel',
value: 'testValue',
});
const component = renderer.create(
<RecoilRoot>
<MockTheme>
<CreateAddress
message={message}
/>
</MockTheme>
</RecoilRoot>,
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
});

afterEach(() => {
jest.clearAllMocks();
});
});
42 changes: 42 additions & 0 deletions src/components/msg/addressbook/create_address/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import Trans from 'next-translate/Trans';
import { Typography } from '@material-ui/core';
import {
Name,
AddressBookDetails,
} from '@components';
import { MsgCreateAddress } from '@models';

const CreateAddress = (props: {
message: MsgCreateAddress;
}) => {
const { message } = props;
const { creator } = message;

return (
<Typography>
<Trans
i18nKey="message_contents:txCreateAddress"
components={[
(
<Name
address={creator}
name={creator}
/>
),
(
<AddressBookDetails
content={{
network: message.network,
label: message.label,
value: message.value,
}}
/>
),
]}
/>
</Typography>
);
};

export default CreateAddress;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`screen: TransactionDetails/MsgDeleteAddress matches snapshot 1`] = `
<p
className="MuiTypography-root MuiTypography-body1"
>
message_contents:txDeleteAddress
</p>
`;
45 changes: 45 additions & 0 deletions src/components/msg/addressbook/delete_address/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';
import { RecoilRoot } from 'recoil';
import renderer from 'react-test-renderer';
import { MockTheme } from '@tests/utils';
import { MsgDeleteAddress } from '@models';
import CreateAddress from '.';

// ==================================
// mocks
// ==================================

jest.mock('@components', () => ({
Name: (props) => <div id="Name" {...props} />,
}));

// ==================================
// unit tests
// ==================================
describe('screen: TransactionDetails/MsgDeleteAddress', () => {
it('matches snapshot', () => {
const message = new MsgDeleteAddress({
category: 'addressbook',
type: 'MsgDeleteAddress',
creator: 'creatorAddress',
network: 'testNetwork',
label: 'testLabel',
value: 'testValue',
});
const component = renderer.create(
<RecoilRoot>
<MockTheme>
<CreateAddress
message={message}
/>
</MockTheme>
</RecoilRoot>,
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
});

afterEach(() => {
jest.clearAllMocks();
});
});
42 changes: 42 additions & 0 deletions src/components/msg/addressbook/delete_address/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import Trans from 'next-translate/Trans';
import { Typography } from '@material-ui/core';
import {
Name,
AddressBookDetails,
} from '@components';
import { MsgDeleteAddress } from '@models';

const DeleteAddress = (props: {
message: MsgDeleteAddress;
}) => {
const { message } = props;
const { creator } = message;

return (
<Typography>
<Trans
i18nKey="message_contents:txDeleteAddress"
components={[
(
<Name
address={creator}
name={creator}
/>
),
(
<AddressBookDetails
content={{
network: message.network,
label: message.label,
value: message.value,
}}
/>
),
]}
/>
</Typography>
);
};

export default DeleteAddress;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`screen: TransactionDetails/MsgUpdateAddress matches snapshot 1`] = `
<p
className="MuiTypography-root MuiTypography-body1"
>
message_contents:txUpdateAddress
</p>
`;
45 changes: 45 additions & 0 deletions src/components/msg/addressbook/update_address/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';
import { RecoilRoot } from 'recoil';
import renderer from 'react-test-renderer';
import { MockTheme } from '@tests/utils';
import { MsgUpdateAddress } from '@models';
import CreateAddress from '.';

// ==================================
// mocks
// ==================================

jest.mock('@components', () => ({
Name: (props) => <div id="Name" {...props} />,
}));

// ==================================
// unit tests
// ==================================
describe('screen: TransactionDetails/MsgUpdateAddress', () => {
it('matches snapshot', () => {
const message = new MsgUpdateAddress({
category: 'addressbook',
type: 'MsgUpdateAddress',
creator: 'creatorAddress',
network: 'testNetwork',
label: 'testLabel',
value: 'testValue',
});
const component = renderer.create(
<RecoilRoot>
<MockTheme>
<CreateAddress
message={message}
/>
</MockTheme>
</RecoilRoot>,
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
});

afterEach(() => {
jest.clearAllMocks();
});
});
42 changes: 42 additions & 0 deletions src/components/msg/addressbook/update_address/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import Trans from 'next-translate/Trans';
import { Typography } from '@material-ui/core';
import {
Name,
AddressBookDetails,
} from '@components';
import { MsgUpdateAddress } from '@models';

const UpdateAddress = (props: {
message: MsgUpdateAddress;
}) => {
const { message } = props;
const { creator } = message;

return (
<Typography>
<Trans
i18nKey="message_contents:txUpdateAddress"
components={[
(
<Name
address={creator}
name={creator}
/>
),
(
<AddressBookDetails
content={{
network: message.network,
label: message.label,
value: message.value,
}}
/>
),
]}
/>
</Typography>
);
};

export default UpdateAddress;
Loading

0 comments on commit 7a079f0

Please sign in to comment.