Skip to content

Commit

Permalink
Merge pull request #692 from alleslabs/fix/module-verify
Browse files Browse the repository at this point in the history
feat: mahalo module verify
  • Loading branch information
songwongtp committed Dec 21, 2023
2 parents 746734c + e239dfb commit f143f26
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#692](https://github.com/alleslabs/celatone-frontend/pull/692) Add verify link for mahalo
- [#675](https://github.com/alleslabs/celatone-frontend/pull/675) Make module links clickable with command/ctrl and add copier for struct names
- [#674](https://github.com/alleslabs/celatone-frontend/pull/674) Adjust contract list card and microcopies
- [#672](https://github.com/alleslabs/celatone-frontend/pull/672) Refactor balances
Expand Down
3 changes: 3 additions & 0 deletions src/config/chain/initia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = {
enabled: true,
moduleMaxFileSize: 1_048_576,
decodeApi: INITIA_DECODER,
verify: "https://compiler.mahalo-1.initia.xyz/contracts/verify",
},
pool: {
enabled: false,
Expand Down Expand Up @@ -74,6 +75,7 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = {
enabled: true,
moduleMaxFileSize: 1_048_576,
decodeApi: INITIA_DECODER,
verify: "",
},
pool: {
enabled: false,
Expand Down Expand Up @@ -171,6 +173,7 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = {
enabled: true,
moduleMaxFileSize: 1_048_576,
decodeApi: INITIA_DECODER,
verify: "https://stone-compiler.initia.tech/contracts/verify",
},
pool: {
enabled: false,
Expand Down
1 change: 1 addition & 0 deletions src/config/chain/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type MoveConfig =
enabled: true;
moduleMaxFileSize: number;
decodeApi: string;
verify: string;
}
| { enabled: false };

Expand Down
7 changes: 6 additions & 1 deletion src/lib/components/module/ModuleSourceCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ export const ModuleSourceCode = ({ sourceCode }: ModuleSourceCodeProps) => {
<Text fontWeight={600} variant="body1" color="text.main">
Module Source Code
</Text>
<Text fontWeight={600} variant="body2" color="text.dark">
<Text
fontWeight={600}
variant="body2"
color="text.dark"
textAlign="start"
>
The source code is uploaded by the deployer and pulled from
Initia API
</Text>
Expand Down
4 changes: 3 additions & 1 deletion src/lib/pages/module-details/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Flex, Tabs, TabList, TabPanel, TabPanels } from "@chakra-ui/react";
import { isUndefined } from "lodash";
import { useRouter } from "next/router";
import { useState, useCallback, useEffect } from "react";

Expand Down Expand Up @@ -185,7 +186,8 @@ export const ModuleDetailsBody = ({ moduleData }: ModuleDetailsBodyProps) => {
viewFns={moduleData.viewFunctions.length}
executeFns={moduleData.executeFunctions.length}
allTxsCount={
moduleTxsCount && moduleHistoriesCount
!isUndefined(moduleTxsCount) &&
!isUndefined(moduleHistoriesCount)
? moduleTxsCount + moduleHistoriesCount
: undefined
}
Expand Down
6 changes: 2 additions & 4 deletions src/lib/services/move/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,12 @@ export interface ModuleVerificationInternal
}

export const getModuleVerificationStatus = async (
endpoint: string,
address: MoveAccountAddr,
moduleName: string
): Promise<Nullable<ModuleVerificationInternal>> =>
// TODO: move url to base api route? wait for celatone api implementation?
axios
.get<ModuleVerificationReturn>(
`https://stone-compiler.initia.tech/contracts/verify/${address}/${moduleName}`
)
.get<ModuleVerificationReturn>(`${endpoint}/${address}/${moduleName}`)
.then(({ data }) => ({
...snakeToCamel(data),
moduleAddress: data.module_address,
Expand Down
14 changes: 9 additions & 5 deletions src/lib/services/move/moduleService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,15 @@ export const useVerifyModule = ({
}: {
address: Option<MoveAccountAddr>;
moduleName: Option<string>;
}): UseQueryResult<Nullable<ModuleVerificationInternal>> =>
useQuery(
[CELATONE_QUERY_KEYS.MODULE_VERIFICATION, address, moduleName],
}): UseQueryResult<Nullable<ModuleVerificationInternal>> => {
const move = useMoveConfig({ shouldRedirect: false });
const endpoint = move.enabled ? move.verify : "";

return useQuery(
[CELATONE_QUERY_KEYS.MODULE_VERIFICATION, endpoint, address, moduleName],
() => {
if (!address || !moduleName) return null;
return getModuleVerificationStatus(address, moduleName);
if (!endpoint || !address || !moduleName) return null;
return getModuleVerificationStatus(endpoint, address, moduleName);
},
{
enabled: Boolean(address && moduleName),
Expand All @@ -155,6 +158,7 @@ export const useVerifyModule = ({
keepPreviousData: true,
}
);
};

export const useFunctionView = ({
moduleAddress,
Expand Down

2 comments on commit f143f26

@vercel
Copy link

@vercel vercel bot commented on f143f26 Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on f143f26 Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.