Skip to content

Commit

Permalink
fix(transfer): get pact capabilities & functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jessevanmuijden committed Jul 24, 2023
1 parent eb5da65 commit cb6d203
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const ModulePage: FC = () => {
Debug('kadena-transfer:pages:transfer:module-explorer:module');
const { t } = useTranslation('common');
const [pactCode, setPactCode] = useState('');
const [functions, setFunctions] = useState({});
const [capabilities, setCapabilities] = useState({});
const [interfaces, setInterfaces] = useState([]);
const [functions, setFunctions] = useState<Record<string, { method: string }> | undefined>({});
const [capabilities, setCapabilities] = useState<Record<string, { defcap: string }> | undefined>({});
const [interfaces, setInterfaces] = useState<string[]>([]);
const router = useRouter();
const { network, chain, module } = router.query;

Expand All @@ -50,20 +50,20 @@ const ModulePage: FC = () => {
1000,
);

setPactCode(data?.code.code || '');
setPactCode(data.code?.code || '');

const moduleNameParts = moduleName.split('.');
const namespace =
moduleNameParts.length > 1 ? moduleNameParts[0] : undefined;

const pactModule = new StringContractDefinition({
contract: data?.code.code || '',
contract: data?.code?.code || '',
namespace,
});

setCapabilities(pactModule._raw[moduleName].defcaps);
setFunctions(pactModule._raw[moduleName].defuns);
setInterfaces(data?.code.interfaces);
setCapabilities(pactModule.getCapabilities(moduleName));
setFunctions(pactModule.getMethods(moduleName));
setInterfaces(data.code?.interfaces || []);
};

fetchModule().catch(console.error);
Expand All @@ -88,9 +88,9 @@ const ModulePage: FC = () => {
<h3>{t('Details')}</h3>
<Details>
<h4>{t('Functions')}</h4>
{!Object.keys(functions)?.length &&
{!Object.keys(functions || {})?.length &&
t('No functions in this module.')}
{Object.keys(functions)?.map((key) => (
{Object.keys(functions || {})?.map((key) => (
<StyledListItem key={key}>
<a
href={`/transfer/module-explorer/networks/${network}/chains/${chain}/modules/${module}/functions/${key}`}
Expand All @@ -100,9 +100,9 @@ const ModulePage: FC = () => {
</StyledListItem>
))}
<h4>{t('Capabilities')}</h4>
{!Object.keys(capabilities)?.length &&
{!Object.keys(capabilities || {})?.length &&
t('No capabilities in this module.')}
{Object.keys(capabilities)?.map((key) => (
{Object.keys(capabilities || {})?.map((key) => (
<StyledListItem key={key}>
<a
href={`/transfer/module-explorer/networks/${network}/chains/${chain}/modules/${module}/capabilities/${key}`}
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/transfer/src/services/faucet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const fundExistingAccount = async (
new PactNumber(amount).toPactDecimal(),
),
)
.addSigner(FAUCET_PUBLIC_KEY, (withCap) => [withCap('coin.GAS')])
.addSigner(keyPair.publicKey, (withCap) => [
.addSigner(FAUCET_PUBLIC_KEY, (withCap: any) => [withCap('coin.GAS')])
.addSigner(keyPair.publicKey, (withCap: any) => [
withCap(
'coin.TRANSFER',
SENDER_ACCOUNT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import Debug from 'debug';
export interface IModuleResult {
reqKey?: string;
status?: string;
code?: string;
code?: {
code: string;
interfaces: string[];
};
}

const debug = Debug('kadena-transfer:services:describe-module');
Expand Down

0 comments on commit cb6d203

Please sign in to comment.