Merge pull request #55 from input-output-hk/DAC-480
DAC-480 [FE] Modification within Transaction by customer
DAC-480 [FE] Modification within Transaction by customer
import Toast from "components/Toast/Toast";
import { fetchData } from "api/api";
export interface Run {
"certificationPrice": number,
"commitDate": string;
"commitHash": string;
"created": string;
"finishedAt": string;
"repoUrl": string;
"reportContentId": string;
"runId": string;
"runStatus": "queued" | "failed" | "succeeded" | "certified" | "ready-for-certification" | "aborted";
"syncedAt": string;
}
interface Certificate {
"createdAt": string;
"runId": string;
"transactionId": string;
}
const CreateCertificate = () => {
const { uuid } = useAppSelector((state) => state.certification);
const { address, wallet } = useAppSelector((state) => state.auth);
const onCloseModal = () => { setOpenModal(false) }
const convertAdaToLovelace = (fee_ada: number) => {
return BigNum.from_str((fee_ada * 1000000).toString())
}
const handleError = (errorObj: any) => {
let errorMsg = ''
if (typeof errorObj === 'string') {
}
}
const triggerSubmitCertificate = async (txnId: string) => {
const response: any = await fetchData.post('/run/' + uuid + '/certificate' + '?transactionid=' + txnId).catch(handleError)
try {
console.log('broadcasted tnx data ', response.data);
setTransactionId(response.data.transactionId)
setOpenModal(true)
setCertifying(false)
setCertified(true)
} catch(e) { }
const certificationBroadcasted = (data: Certificate) => {
console.log('broadcasted tnx data ', data);
setTransactionId(data.transactionId)
setOpenModal(true)
setCertifying(false)
setCertified(true)
}
const fetchRunDetails = async (txnId?: string) => {
fetchData.get('/run/' + uuid + '/details').then(response => {
const details: Run = response.data
if (details?.runStatus === 'ready-for-certification') {
const timeout = setTimeout(async ()=> {
clearTimeout(timeout)
fetchRunDetails()
}, 1000)
} else if (details?.runStatus === 'certified') {
fetchData.get('/run/' + uuid + '/certificate' + (txnId ? '?transactionid=' + txnId : ''))
.catch(handleError)
.then((response: any) => {
certificationBroadcasted(response.data)
})
}
})
}
const triggerSubmitCertificate = async (txnId?: string) => {
fetchData.post('/run/' + uuid + '/certificate' + (txnId ? '?transactionid=' + txnId : ''))
.catch(handleError)
.then((response: any) => {
fetchRunDetails(txnId)
})
}
const triggerGetCertificate = async () => {
setCertifying(true);
setShowError("")
fetchData.get('/profile/current/balance').then(response => {
const availableProfileBalance: number = response.data
fetchData.get('/run/' + uuid + '/details').then(res => {
const runDetails: Run = res.data
if ((availableProfileBalance - runDetails.certificationPrice) < 0) {
triggerTransactionFromWallet(runDetails.certificationPrice)
} else {
triggerSubmitCertificate()
}
})
})
}
const triggerTransactionFromWallet = async (cert_fee_in_lovelaces: number) => {
try {
const walletAddressRes: any = await fetchData.get('/wallet-address').catch(handleError)
const applicationWallet_receiveAddr = walletAddressRes.data;
const cert_fee_lovelace: BigNum = BigNum.from_str(cert_fee_in_lovelaces.toString())
/** For mock */
// const applicationWallet_receiveAddr = 'addr_test1qz2rzeqq8n82gajfp35enq3mxhaynx6zhuql2c7yaljr25mfaznfszxu8275k6v7n05w5azzmxahfzdq564xuuyg73pqnqtrrc'
/** To be replaced with API */
const cert_fee_ada = 3
const cert_fee_lovelace = BigNum.from_str((cert_fee_ada * 1000000).toString())
// const cert_fee_ada = 3
// const cert_fee_lovelace = convertAdaToLovelace(cert_fee_ada)
const protocolParams: any = {
linearFee: {
const renderRows = () => {
return coverageIndexFiles ? coverageIndexFiles.map((file: string, index) => {
return (
<>
<li className="coverage-file" key={index}>
<>
{/* To be changed to location of the file code coverage UI */}
<span className="link" onClick={(_) => onOpenModal(file)}>{file}</span>
<Modal id="coverageHtmlModal" open={isOpen===file} onCloseModal={onCloseModal}>
<div>{parseHTMLContents(file)}</div>
</Modal>
</>
<div>
<div className="meter-bar">
<div className="progress" style={{width: percentagePerFile[file] + "%"}}></div>
</div>
<span className="coverage-percentage">{percentagePerFile[file]}%</span>
<li className="coverage-file" key={index}>
<>
{/* To be changed to location of the file code coverage UI */}
<span className="link" onClick={(_) => onOpenModal(file)}>{file}</span>
<Modal id="coverageHtmlModal" open={isOpen===file} onCloseModal={onCloseModal}>
<div>{parseHTMLContents(file)}</div>
</Modal>
</>
<div>
<div className="meter-bar">
<div className="progress" style={{width: percentagePerFile[file] + "%"}}></div>
</div>
</li>
</>
<span className="coverage-percentage">{percentagePerFile[file]}%</span>
</div>
</li>
);
}) : null;
};
import { processFinishedJson } from "components/TimelineItem/timeline.helper";
import { isAnyTaskFailure } from "pages/certification/Certification.helper";
import "./TestHistory.scss";
interface ICampaign {
commitDate: string;
commitHash: string;
created: string;
finishedAt: string;
syncedAt: string;
repoUrl: string;
runStatus: "queued" | "failed" | "succeeded" | "certified" | "ready-for-certification" | "aborted";
runId: string;
}
import { Run } from 'components/CreateCertificate/CreateCertificate';
import { exportObjectToJsonFile } from "utils/utils";
interface ICampaignCertificate {
runId: string;
transactionId: string;
reportContentId: string;
createdAt: string;
}
interface IRunCertifications {
[key: string]: ICampaignCertificate
}
interface IRunReportData {
id: string;
raw: any; // finished result JSON
}
interface IRunReport {
[key: string]: IRunReportData
}
dayjs.extend(utc)
dayjs.extend(tz)
const TestHistory = () => {
const [data, setData] = useState<Array<ICampaign>>([]);
const [data, setData] = useState<Array<Run>>([]);
const [runningSpinner, setRunningSpinner] = useState("");
const [highlightLabelFor, setHighlightLabelFor] = useState("");
const [skipPageReset, setSkipPageReset] = useState(false);
const confirm = useConfirm();
const certificationData: IRunCertifications = {};
const reportData: IRunReport = {};
const timeZone = dayjs.tz.guess()
useEffect(() => {
return certificationData[runId] ? certificationData[runId] : null
}
const setReportData = (runId: string, type: 'id' | 'raw', response: any) => {
const data: any = { id: null, raw: null}
data[type] = response;
reportData[runId] = data;
}
const getReportData = (runId: string) => {
return reportData[runId] ? reportData[runId] : null
}
const handleError = (error: any) => {
if (error.response) {
setErrorToast({display: true, statusText: error.response.statusText, message: error.response.data || undefined})
}
};
const viewReportOrCertificate = async (type: string, runId: string) => {
const openReport = (reportData: IRunReportData | null) => {
if (reportData?.id) {
const url = `ipfs://${reportData.id}/`
window.open(url, "_blank");
} else if (reportData?.raw) {
exportObjectToJsonFile(reportData.raw);
}
}
const viewReport = async (runId: string) => {
const reportData: IRunReportData | null = getReportData(runId)
if (!reportData) {
fetchData.get("/run/" + runId + "/details").catch(handleError).then((response:any) => {
setErrorToast({display: false})
if (response.data.reportContentId && response.data.runStatus === "certified") {
setReportData(runId, 'id', response.data.reportContentId)
openReport(getReportData(runId))
} else {
// assuming campaign finished, but not certified; fetch report from result
fetchData.get("/run/" + runId).catch(handleError).then((res:any) => {
if (res.data.status === 'finished' && res.data.hasOwnProperty("result")) {
const resultJson = Array.isArray(res.data.result) ? res.data.result[0] : res.data.result
setReportData(runId, 'raw', resultJson)
openReport(getReportData(runId))
}
})
}
})
} else {
openReport(reportData)
}
}
const viewCertificate = async (runId: string) => {
const certData = getCertificationData(runId)
if (!certData) {
const response: any = await fetchData.get("/run/" + runId + "/certificate").catch(handleError);
if (response) {
setErrorToast({display: false})
setCertificationData(runId, response.data);
triggerNavigation(type, response.data);
openCertificate(response.data);
}
} else {
triggerNavigation(type, certData);
openCertificate(certData);
}
};
const triggerNavigation = (type: string, data: any) => {
const { reportContentId, transactionId } = data;
let url;
if (type === "report") {
// url = `https://${reportContentId}.ipfs.w3s.link/`;
url = `ipfs://${reportContentId}/`
} else {
url = `https://preprod.cardanoscan.io/transaction/${transactionId}`;
}
const openCertificate = (data: any) => {
const { transactionId } = data;
let url = `https://preprod.cardanoscan.io/transaction/${transactionId}`;
window.open(url, "_blank");
};
disableSortBy: true,
accessor: "viewReport",
Cell: (props: any) => {
if (props.row.original.runStatus === "succeeded" || props.row.original.runStatus === "ready-for-certification" || props.row.original.runStatus === "certified") {
const notCertified: boolean = props.row.original.runStatus === "succeeded" || props.row.original.runStatus === "ready-for-certification"
if (notCertified || props.row.original.runStatus === "certified") {
return (
<Button
size="small"
type="submit"
buttonLabel={"View Report"}
buttonLabel={`${notCertified ? 'Download' : 'View'} Report`}
onClick={() => {
viewReportOrCertificate("report", props.row.original.runId);
viewReport(props.row.original.runId);
}}
/>
);
type="submit"
buttonLabel={"View Certificate"}
onClick={() => {
viewReportOrCertificate("certificate", props.row.original.runId);
viewCertificate(props.row.original.runId);
}}
/>
);
Bumps [bech32](https://github.com/rust-bitcoin/rust-bech32) from 0.8.1 to 0.9.1. - [Changelog](https://github.com/rust-bitcoin/rust-bech32/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-bitcoin/rust-bech32/compare/v0.8.1...v0.9.1) --- updated-dependencies: - dependency-name: bech32 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
Bumps [log](https://github.com/rust-lang/log) from 0.4.17 to 0.4.18. - [Release notes](https://github.com/rust-lang/log/releases) - [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/log/compare/0.4.17...0.4.18) --- updated-dependencies: - dependency-name: log dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.28.1 to 1.28.2. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.28.1...tokio-1.28.2) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
PLT-5901 Implemented checks for valid network addresses.
fix: tuple clause must preserve previous clause properties state
fix: rearrange clauses and fill in gaps now handles nested patterns in a uniform way fix: discards in records was being sorted incorrectly leading to type issues chore: remove some filter maps in cases where None is impossible anyway chore: some refactoring on a couple functions to clean up
fix: tuple clause must preserve previous clause properties state