Skip to content

Commit

Permalink
chore(transfer): fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
jessevanmuijden committed Jul 21, 2023
1 parent 399647c commit 5daf4b1
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 155 deletions.
5 changes: 5 additions & 0 deletions packages/apps/transfer/src/constants/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getClient } from "@kadena/client";

const client = getClient();

export default client;
2 changes: 1 addition & 1 deletion packages/apps/transfer/src/pages/faucet/existing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const ExistingAccountFaucetPage: FC = () => {
leftIcon: SystemIcon.KIcon,
}}
/>
<ChainSelect onChange={onChainSelectChange} value={chainID} />
<ChainSelect onChange={onChainSelectChange} value={chainID} ariaLabel={'hello'} />
</StyledAccountForm>
<StyledFormButton>
<Button.Root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const CheckTransactions: FC = () => {
<StyledContent>
<form className={formStyle} onSubmit={checkTransactionsEvent}>
<StyledSmallField>
<ChainSelect onChange={onChainSelectChange} value={chainID} />
<ChainSelect onChange={onChainSelectChange} value={chainID} ariaLabel={'hello'} />
</StyledSmallField>
<StyledMediumField>
<TextField
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IPollResponse } from '@kadena/chainweb-node-client';
import { ContCommand } from '@kadena/client';
import {
Breadcrumbs,
Button,
Expand Down Expand Up @@ -49,6 +48,7 @@ import React, {
useEffect,
useState,
} from 'react';
import client from '@/constants/client';

interface IPactResultError {
status: 'failure';
Expand Down Expand Up @@ -121,19 +121,21 @@ const CrossChainTransferFinisher: FC = () => {
return;
}

const host = getKadenaConstantByNetwork(network).apiHost({
const proof = await client.pollCreateSpv(requestKey, pollResults.tx.receiver.chain, {
networkId: chainNetwork[network].network,
chainId: pollResults.tx.receiver.chain,
chainId: pollResults.tx.sender.chain,
});

const contCommand = await finishXChainTransfer(
requestKey,
pollResults.tx.step,
pollResults.tx.rollback,
network,
pollResults.tx.receiver.chain,
kadenaXChainGas,
);
console.log(proof);

// const contCommand = await finishXChainTransfer(
// requestKey,
// pollResults.tx.step,
// pollResults.tx.rollback,
// network,
// pollResults.tx.receiver.chain,
// kadenaXChainGas,
// );

// if (!(contCommand instanceof ContCommand) && contCommand.error) {
// setTxError(contCommand.error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,6 @@ const ModuleExplorer: FC = () => {
[modules, moduleSearch],
);

useEffect(() => {
if (!moduleName) {
return;
}

const fetchModule = async (): Promise<void> => {
const data = await describeModule(
moduleName,
chainID,
network,
kadenaConstants.DEFAULT_SENDER,
kadenaConstants.GAS_PRICE,
1000,
);

setResults(data);
};

fetchModule().catch(console.error);
}, [chainID, moduleName, network]);

const onModuleNameChange = useCallback<ChangeEventHandler<HTMLInputElement>>(
(e) => {
setModuleSearch(e.target.value);
Expand All @@ -94,7 +73,7 @@ const ModuleExplorer: FC = () => {
</Breadcrumbs.Root>
<StyledForm>
<StyledAccountForm>
<ChainSelect onChange={onChainSelectChange} value={chainID} />
<ChainSelect onChange={onChainSelectChange} value={chainID} ariaLabel={'hello'} />
<TextField
label={t('Module Name')}
inputProps={{
Expand All @@ -111,7 +90,7 @@ const ModuleExplorer: FC = () => {
{filteredModules?.map((module) => (
<StyledListItem key={module} data-module-name={module}>
<a
href={`/transfer/module-explorer/networks/${network}/chains/${moduleChain}/modules/${module}`}
href={`/transfer/module-explorer/networks/${network}/chains/${chainID}/modules/${module}`}
>
{module}
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ const ModulePage = () => {

console.log(pactModule);

setCapabilities(pactModule._raw[moduleName].defcaps);
setFunctions(pactModule._raw[moduleName].defuns);
// setCapabilities(pactModule._raw[moduleName].defcaps);
// setFunctions(pactModule._raw[moduleName].defuns);
};

fetchModule().catch(console.error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
ChainwebChainId,
ChainwebNetworkId,
} from '@kadena/chainweb-node-client';
import { ContCommand, getContCommand } from '@kadena/client';
import { getClient, Pact } from '@kadena/client';

import {
getKadenaConstantByNetwork,
Expand All @@ -28,47 +28,49 @@ export async function finishXChainTransfer(
network: Network,
chainId: ChainwebChainId,
sender: string,
): Promise<ContCommand | { error: string }> {
): Promise<any | { error: string }> {
debug(finishXChainTransfer.name);
const host = getKadenaConstantByNetwork(network).apiHost({
networkId: chainNetwork[network].network,
chainId,
});

const { pollStatus } = getClient();

try {
const contCommand = await getContCommand(
requestKey,
chainId,
host,
step + 1,
rollback,
);
// const contCommand = await getContCommand(
// chainId,
// host,
// step + 1,
// rollback,
// );

contCommand.setMeta(
{
chainId,
sender,
gasLimit,
gasPrice,
},
chainNetwork[network].network as ChainwebNetworkId,
);
// contCommand.setMeta(
// {
// chainId,
// sender,
// gasLimit,
// gasPrice,
// },
// chainNetwork[network].network as ChainwebNetworkId,
// );

contCommand.createCommand();
// contCommand.createCommand();

const localResult = await contCommand.local(host, {
preflight: false,
signatureVerification: false,
});
// const localResult = await contCommand.local(host, {
// preflight: false,
// signatureVerification: false,
// });

if (localResult.result.status !== 'success') {
debug(localResult.result.error.message);
return { error: localResult.result.error.message };
}
// if (localResult.result.status !== 'success') {
// debug(localResult.result.error.message);
// return { error: localResult.result.error.message };
// }

await contCommand.send(host);
// await contCommand.send(host);

return contCommand;
// return contCommand;
throw new Error('testing');
} catch (e) {
debug(e.message);
return { error: e.message };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ export async function getTransferData({

const { events, result } = found;

const errorMessage = result.error?.message;

if (errorMessage) {
return { error: errorMessage };
if ('error' in result) {
return result.error;
// return { error: ('message' in result.error ? (result.error.message as string) : 'An error occurred.' };
}

const [senderAccount, receiverAccount, guard, targetChain, amount] =
Expand Down
22 changes: 4 additions & 18 deletions packages/apps/transfer/src/services/modules/describe-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ export const describeModule = async (
}),
);

const modules: any = Pact.modules;
const describe: any = modules['describe-module'];
const transaction = Pact.builder
.execution(Pact.modules['describe-module'](moduleName))
.execution(describe(moduleName))
.setMeta({ gasLimit, gasPrice, ttl, sender, chainId })
.setNetworkId(networkId)
.createTransaction();
Expand All @@ -47,27 +49,11 @@ export const describeModule = async (
signatureVerification: false,
});

// const pactCommand = new PactCommand();
// pactCommand.code = createExp(`describe-module "${moduleName}"`);

// pactCommand.setMeta({ gasLimit, gasPrice, ttl, sender, chainId });

// const response = await pactCommand.local(
// getKadenaConstantByNetwork(network).apiHost({
// networkId: chainNetwork[network].network,
// chainId,
// }),
// {
// signatureVerification: false,
// preflight: false,
// },
// );

const { reqKey, result } = response;

return {
reqKey,
status: result.status,
code: result.data?.code,
code: ('data' in result) ? (result.data as string) : '',
};
};
6 changes: 3 additions & 3 deletions packages/apps/transfer/src/services/modules/list-module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ChainwebChainId } from '@kadena/chainweb-node-client';
import { getClient, Pact } from '@kadena/client';
import { createExp } from '@kadena/pactjs';

import {
getKadenaConstantByNetwork,
Expand Down Expand Up @@ -34,8 +33,9 @@ export const listModules = async (
}),
);

const modules: any = Pact.modules;
const transaction = Pact.builder
.execution(Pact.modules['list-modules']())
.execution(modules['list-modules']())
.setMeta({ gasLimit, gasPrice, ttl, sender, chainId })
.setNetworkId(networkId)
.createTransaction();
Expand All @@ -49,6 +49,6 @@ export const listModules = async (

return {
status: result.status,
data: result.data,
data: 'data' in result ? (result.data as string[]) : [],
};
};
Loading

0 comments on commit 5daf4b1

Please sign in to comment.