Skip to content

Commit

Permalink
Day 2 - Offchain (Deposit & Withdraw)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ariady Putra committed Jun 9, 2024
1 parent 850f1fb commit d814c5b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions offchain/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function App() {

useEffect(() => {
async function initLucid() {
// Create `.env.local` file and set your Blockfrost Project ID as `NEXT_PUBLIC_BF_PID`
const blockfrost = new Blockfrost("https://cardano-preview.blockfrost.io/api/v0", process.env.NEXT_PUBLIC_BF_PID);
const lucid = await Lucid.new(blockfrost, "Preview");
setLucid(lucid);
Expand Down Expand Up @@ -63,8 +64,7 @@ export default function App() {
}, [userAddress]);

function WalletsConnector(props: { lucid: Lucid; wallets: Wallet[] }) {
const lucid = props.lucid;
const wallets = props.wallets;
const { lucid, wallets } = props;

async function connectWallet(wallet: Wallet) {
const api = await wallet.enable();
Expand All @@ -91,7 +91,7 @@ export default function App() {
}

function Dashboard(props: { lucid: Lucid }) {
const lucid = props.lucid;
const { lucid } = props;

type Action = {
actionName: string;
Expand All @@ -104,7 +104,7 @@ export default function App() {
const tx = await lucid
.newTx()
.payToContract(scriptAddress, Data.void(), {
lovelace: 42_000000n,
lovelace: 42_000000n, // tsconfig.json => target: ESNext
})
.complete();
return tx;
Expand All @@ -114,7 +114,7 @@ export default function App() {
actionName: "Withdraw",
constructTx: async () => {
if (!spendingValidator) {
throw "Unitialized Spending Validator";
throw "Uninitialized Spending Validator";
}

const utxos = await lucid.utxosAt(scriptAddress);
Expand Down Expand Up @@ -165,7 +165,7 @@ export default function App() {
userAddress ? ( // when wallet connected:
<Dashboard lucid={lucid} />
) : wallets ? (
wallets.length ? ( // no wallet connected yet, show wallet list:
wallets.length ? ( // when no wallet connected yet, show wallet list:
<WalletsConnector lucid={lucid} wallets={wallets} />
) : (
<>NO CARDANO WALLET</>
Expand Down

0 comments on commit d814c5b

Please sign in to comment.