Skip to content

Commit

Permalink
Lock works
Browse files Browse the repository at this point in the history
  • Loading branch information
coddeys committed Jun 22, 2024
1 parent bba97bf commit 67c065f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
7 changes: 3 additions & 4 deletions islands/InvestorLock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import {
applyParams,
LocalCache,
lock,
Validators,
Vlidators,
} from "../utils.ts";

export interface AppProps {
blockfrost: string;
validators: Validators;
bid: Bid;
}

Expand Down Expand Up @@ -67,14 +66,14 @@ export default function PlatformLock(props: AppProps) {
);

const txLock = await lock(lovelace, {
into: props.validators.propertyFunds,
into: props.bid.contract,
datum: datum,
lucid: lucid,
});

await lucid.awaitTx(txLock);

console.log(`100 tADA locked into the contract
console.log(`${lovelace} lovelace locked into the contract
Tx ID: ${txLock}
Datum: ${datum}
`);
Expand Down
14 changes: 2 additions & 12 deletions routes/bids/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,27 @@ import { BidView } from "../../components/Bid.tsx";
import { env } from "../../config.ts";
import { Bid } from "../../types.ts";

import { readValidators, Validators } from "../../utils.ts";

interface Data {
validators: Validators;
bid: Bid;
}

export const handler: Handlers<Data> = {
async GET(_req, ctx) {
const validators = readValidators();

const scriptAddress = ctx.params.id;
const kv = await Deno.openKv(
"https://api.deno.com/databases/824bd08c-5681-4772-947f-b1ef806f3747/connect",
);
// const kv = await Deno.openKv();
const resp = await kv.get(["bid", scriptAddress]);
const bid = resp.value;
return ctx.render({ bid, validators });
return ctx.render({ bid });
},
};

export default function Home({ data }: PageProps<Data>) {
const { bid, validators } = data;
const { bid } = data;

const blockfrost = env["BLOCKFROST"] || Deno.env.get("BLOCKFROST");
const policyId = env["POLICY_ID"] || Deno.env.get("POLICY_ID");
const asset = env["ASSET"] || Deno.env.get("ASSET");

return (
<div>
Expand All @@ -49,9 +42,6 @@ export default function Home({ data }: PageProps<Data>) {

<InvestorLock
blockfrost={blockfrost}
validators={validators}
policyId={policyId}
asset={asset}
bid={bid}
/>

Expand Down
7 changes: 0 additions & 7 deletions utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,6 @@ export function applyParamsPropertyFunds(
};
}


export async function lock_(lovelace, { into, datum, lucid }): Promise<String> {
const contractAddress = lucid.utils.validatorToAddress(into);

return contractAddress;
}

export async function lock(lovelace, { into, datum, lucid }): Promise<TxHash> {
const contractAddress = lucid.utils.validatorToAddress(into);

Expand Down

0 comments on commit 67c065f

Please sign in to comment.