Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions frontend/src/app/[username]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default function Profile() {
severity: 'error',
message: 'Cannot send WST with frozen account.',
open: true,
link: ''
});
return;
}
Expand Down Expand Up @@ -73,10 +74,10 @@ export default function Profile() {
);
console.log('Send response:', response.data);
const tx = await lucid.fromTx(response.data.cborHex);
await signAndSentTx(lucid, tx);
const txId = await signAndSentTx(lucid, tx);
await updateAccountBalance(sendRecipientAddress);
await updateAccountBalance(accountInfo.address);
changeAlertInfo({severity: 'success', message: 'Transaction sent successfully!', open: true,});
changeAlertInfo({severity: 'success', message: 'Transaction sent successfully!', open: true, link: `https://preview.cardanoscan.io/transaction/${txId.inputs[0].transaction_id}`});
} catch (error) {
console.error('Send failed:', error);
}
Expand Down
15 changes: 14 additions & 1 deletion frontend/src/app/components/AlertBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,27 @@ const handleClose = () => {
};

return (
<Snackbar open={alertInfo.open} autoHideDuration={alertInfo.severity === 'success' ? 3000 : null} onClose={handleClose} anchorOrigin={{vertical: 'top', horizontal: 'center'}} >
<Snackbar open={alertInfo.open} anchorOrigin={{vertical: 'top', horizontal: 'center'}} >
<Alert
severity={alertInfo.severity}
variant="filled"
sx={{ width: '100%' }}
onClose={handleClose}
>
{alertInfo.message}
{alertInfo.link && (
<>
{" "}
<a
href={alertInfo.link}
target="_blank"
rel="noopener noreferrer"
>
{alertInfo.link}
</a>
{" "}
</>
)}
</Alert>
</Snackbar>
);
Expand Down
44 changes: 25 additions & 19 deletions frontend/src/app/mint-authority/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default function Home() {
console.error("Recipient Address not cleared.");
return;
}
changeAlertInfo({severity: 'info', message: 'Processing Mint Request', open: true,});
changeAlertInfo({severity: 'info', message: 'Processing Mint Request', open: true, link: ''});
lucid.selectWallet.fromSeed(mintAccount.mnemonic);
const requestData = {
asset_name: Buffer.from('WST', 'utf8').toString('hex'), // Convert "WST" to hex
Expand All @@ -109,22 +109,26 @@ export default function Home() {
// await signAndSentTx(lucid, tx);
const txBuilder = await makeTxSignBuilder(lucid.wallet(), tx.toTransaction()).complete();
const cmlTx = txBuilder.toTransaction()
console.log("TxBody: " + cmlTx.body().to_json());
// console.log("TxBody: " + cmlTx.body().to_json());
const witnessSet = txBuilder.toTransaction().witness_set();
const expectedScriptDataHash : CML.ScriptDataHash | undefined = CML.calc_script_data_hash(witnessSet.redeemers()!, CML.PlutusDataList.new(), lucid.config().costModels!, witnessSet.languages());
console.log('Calculated Script Data Hash:', expectedScriptDataHash?.to_hex());
// console.log('Calculated Script Data Hash:', expectedScriptDataHash?.to_hex());
const cmlTxBodyClone = CML.TransactionBody.from_cbor_hex(cmlTx!.body().to_cbor_hex());
console.log("TxBody: " + cmlTxBodyClone.to_json());
console.log('Preclone script hash:', cmlTxBodyClone.script_data_hash()?.to_hex());
// console.log("TxBody: " + cmlTxBodyClone.to_json());
const txIDinAlert = await cmlTxBodyClone.to_json();
const txIDObject = JSON.parse(txIDinAlert);
// console.log('Preclone script hash:', cmlTxBodyClone.script_data_hash()?.to_hex());
cmlTxBodyClone.set_script_data_hash(expectedScriptDataHash!);
console.log('Postclone script hash:', cmlTxBodyClone.script_data_hash()?.to_hex());
// console.log('Postclone script hash:', cmlTxBodyClone.script_data_hash()?.to_hex());
const cmlClonedTx = CML.Transaction.new(cmlTxBodyClone, cmlTx!.witness_set(), true, cmlTx!.auxiliary_data());
const cmlClonedSignedTx = await makeTxSignBuilder(lucid.wallet(), cmlClonedTx).sign.withWallet().complete();

const txId = await cmlClonedSignedTx.submit();
await lucid.awaitTx(txId);

changeAlertInfo({severity: 'success', message: 'Successful new WST mint', open: true,});
changeAlertInfo({severity: 'success', message: 'Successful new WST mint. View the transaction here:', open: true, link: `https://preview.cardanoscan.io/transaction/${txIDObject.inputs[0].transaction_id}`});


await fetchUserDetails();
} catch (error) {
console.error('Minting failed:', error);
Expand All @@ -134,7 +138,7 @@ export default function Home() {
const onSend = async () => {
lucid.selectWallet.fromSeed(mintAccount.mnemonic);
console.log('send tokens');
changeAlertInfo({severity: 'info', message: 'Transaction processing', open: true,});
changeAlertInfo({severity: 'info', message: 'Transaction processing', open: true, link: ''});
const requestData = {
asset_name: Buffer.from('WST', 'utf8').toString('hex'), // Convert "WST" to hex
issuer: mintAccount.address,
Expand All @@ -154,7 +158,7 @@ export default function Home() {
);
console.log('Send response:', response.data);
const tx = await lucid.fromTx(response.data.cborHex);
await signAndSentTx(lucid, tx);
const txId = await signAndSentTx(lucid, tx);
const newAccountBalance = await getWalletBalance(sendRecipientAddress);
const recipientWalletKey = (Object.keys(accounts) as (keyof Accounts)[]).find(
(key) => accounts[key].address === sendRecipientAddress
Expand All @@ -165,7 +169,7 @@ export default function Home() {
balance: newAccountBalance,
});
}
changeAlertInfo({severity: 'success', message: 'Transaction sent successfully!', open: true,});
changeAlertInfo({severity: 'success', message: 'Transaction sent successfully!', open: true, link: `https://preview.cardanoscan.io/transaction/${txId.inputs[0].transaction_id}`});
await fetchUserDetails();
} catch (error) {
console.error('Send failed:', error);
Expand All @@ -175,10 +179,11 @@ export default function Home() {
const onFreeze = async () => {
console.log('freeze an account');
lucid.selectWallet.fromSeed(mintAccount.mnemonic);
changeAlertInfo({severity: 'info', message: 'Freeze request processing', open: true,});
changeAlertInfo({severity: 'info', message: 'Freeze request processing', open: true, link: ''});
const requestData = {
issuer: mintAccount.address,
blacklist_address: freezeAccountNumber,
reason: freezeReason,
};
try {
const response = await axios.post(
Expand All @@ -192,8 +197,8 @@ export default function Home() {
);
console.log('Freeze response:', response.data);
const tx = await lucid.fromTx(response.data.cborHex);
await signAndSentTx(lucid, tx);
changeAlertInfo({severity: 'success', message: 'Account successfully frozen', open: true,});
const txId = await signAndSentTx(lucid, tx);
changeAlertInfo({severity: 'success', message: 'Account successfully frozen', open: true, link: `https://preview.cardanoscan.io/transaction/${txId.inputs[0].transaction_id}`});
const frozenWalletKey = (Object.keys(accounts) as (keyof Accounts)[]).find(
(key) => accounts[key].address === freezeAccountNumber
);
Expand All @@ -220,7 +225,7 @@ export default function Home() {
const onUnfreeze = async () => {
console.log('unfreeze an account');
lucid.selectWallet.fromSeed(mintAccount.mnemonic);
changeAlertInfo({severity: 'info', message: 'Unfreeze request processing', open: true,});
changeAlertInfo({severity: 'info', message: 'Unfreeze request processing', open: true, link: ''});
const requestData = {
issuer: mintAccount.address,
blacklist_address: unfreezeAccountNumber,
Expand All @@ -237,8 +242,8 @@ export default function Home() {
);
console.log('Unfreeze response:', response.data);
const tx = await lucid.fromTx(response.data.cborHex);
await signAndSentTx(lucid, tx);
changeAlertInfo({severity: 'success', message: 'Account successfully unfrozen', open: true,});
const txId = await signAndSentTx(lucid, tx);
changeAlertInfo({severity: 'success', message: 'Account successfully unfrozen', open: true, link: `https://preview.cardanoscan.io/transaction/${txId.inputs[0].transaction_id}`});
const unfrozenWalletKey = (Object.keys(accounts) as (keyof Accounts)[]).find(
(key) => accounts[key].address === freezeAccountNumber
);
Expand All @@ -265,10 +270,11 @@ export default function Home() {
const onSeize = async () => {
console.log('seize account funds');
lucid.selectWallet.fromSeed(mintAccount.mnemonic);
changeAlertInfo({severity: 'info', message: 'WST seizure processing', open: true,});
changeAlertInfo({severity: 'info', message: 'WST seizure processing', open: true, link: ''});
const requestData = {
issuer: mintAccount.address,
target: seizeAccountNumber,
reason: seizeReason,
};
try {
const response = await axios.post(
Expand All @@ -282,7 +288,7 @@ export default function Home() {
);
console.log('Seize response:', response.data);
const tx = await lucid.fromTx(response.data.cborHex);
await signAndSentTx(lucid, tx);
const txId = await signAndSentTx(lucid, tx);
const newAccountBalance = await getWalletBalance(seizeAccountNumber);
const seizeWalletKey = (Object.keys(accounts) as (keyof Accounts)[]).find(
(key) => accounts[key].address === seizeAccountNumber
Expand All @@ -293,7 +299,7 @@ export default function Home() {
balance: newAccountBalance,
});
}
changeAlertInfo({severity: 'success', message: 'Funds successfully seized', open: true,});
changeAlertInfo({severity: 'success', message: 'Funds successfully seized', open: true, link: `https://preview.cardanoscan.io/transaction/${txId.inputs[0].transaction_id}`});
await fetchUserDetails();
} catch (error) {
console.error('Seize failed:', error);
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type Accounts = {
export type Severity = 'success' | 'error' | 'info' | 'warning';
export type AlertInfo = {
open: boolean | undefined,
message: string,
severity: Severity,
message: string,
link?: string,
};
2 changes: 1 addition & 1 deletion frontend/src/app/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ main {

a {
color: inherit;
text-decoration: none;
/* text-decoration: none; */
}

.contentSection {
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/app/utils/walletUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,19 @@ export async function signAndSentTx(lucid: LucidEvolution, tx: TxSignBuilder) {
const cmlTx = txBuilder.toTransaction();
const witnessSet = txBuilder.toTransaction().witness_set();
const expectedScriptDataHash : CML.ScriptDataHash | undefined = CML.calc_script_data_hash(witnessSet.redeemers()!, CML.PlutusDataList.new(), lucid.config().costModels!, witnessSet.languages());
console.log('Calculated Script Data Hash:', expectedScriptDataHash?.to_hex());
// console.log('Calculated Script Data Hash:', expectedScriptDataHash?.to_hex());
const cmlTxBodyClone = CML.TransactionBody.from_cbor_hex(cmlTx!.body().to_cbor_hex());
console.log('Preclone script hash:', cmlTxBodyClone.script_data_hash()?.to_hex());
const txIDinAlert = await cmlTxBodyClone.to_json();
const txIDObject = JSON.parse(txIDinAlert);
// console.log('Preclone script hash:', cmlTxBodyClone.script_data_hash()?.to_hex());
cmlTxBodyClone.set_script_data_hash(expectedScriptDataHash!);
console.log('Postclone script hash:', cmlTxBodyClone.script_data_hash()?.to_hex());
// console.log('Postclone script hash:', cmlTxBodyClone.script_data_hash()?.to_hex());
const cmlClonedTx = CML.Transaction.new(cmlTxBodyClone, cmlTx!.witness_set(), true, cmlTx!.auxiliary_data());
const cmlClonedSignedTx = await makeTxSignBuilder(lucid.wallet(), cmlClonedTx).sign.withWallet().complete();
const txId = await cmlClonedSignedTx.submit();
await lucid.awaitTx(txId);
console.log(cmlClonedSignedTx);
return txIDObject
}

export type WalletType = "Lace" | "Eternl" | "Nami" | "Yoroi";
Expand Down
20 changes: 18 additions & 2 deletions generated/openapi/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,22 @@
},
"issuer": {
"$ref": "#/components/schemas/Address"
},
"reason": {
"$ref": "#/components/schemas/BlacklistReason"
}
},
"required": [
"issuer",
"blacklist_address"
"blacklist_address",
"reason"
],
"type": "object"
},
"BlacklistReason": {
"description": "Reason for adding an address to the blacklist",
"type": "string"
},
"Hash PaymentKey": {
"description": "Hash of a payment key",
"example": "f6ac5676b58d8ce280c1f09af4a2e82dd58c1aa2fb075aa005afa1da",
Expand Down Expand Up @@ -96,16 +104,24 @@
"issuer": {
"$ref": "#/components/schemas/Address"
},
"reason": {
"$ref": "#/components/schemas/SeizeReason"
},
"target": {
"$ref": "#/components/schemas/Address"
}
},
"required": [
"issuer",
"target"
"target",
"reason"
],
"type": "object"
},
"SeizeReason": {
"description": "Reason for seizing funds",
"type": "string"
},
"TextEnvelopeJSON": {
"description": "Text envelope",
"properties": {
Expand Down
Loading
Loading