feat(one_shot): actually getting properly applied contracts
Co-authored-by: Kasey White <kwhitemsg@gmail.com>
This commit is contained in:
parent
a82cedbd92
commit
79fd6b4828
|
@ -13,6 +13,9 @@ export interface AppProps {
|
|||
export default function App({ validators }: AppProps) {
|
||||
const [lucid, setLucid] = useState<Lucid | null>(null);
|
||||
const [tokenName, setTokenName] = useState<string>("");
|
||||
const [parameterizedContracts, setParameterizedContracts] = useState<
|
||||
{ lock: string; mint: string } | null
|
||||
>(null);
|
||||
|
||||
const setupLucid = async (blockfrostApiKey: string) => {
|
||||
const lucid = await Lucid.new(
|
||||
|
@ -42,15 +45,22 @@ export default function App({ validators }: AppProps) {
|
|||
|
||||
const utxos = await lucid?.wallet.getUtxos()!;
|
||||
|
||||
console.log(utxos);
|
||||
|
||||
const utxo = utxos[0];
|
||||
const outputReference = {
|
||||
txHash: utxo.txHash,
|
||||
outputIndex: utxo.outputIndex,
|
||||
};
|
||||
|
||||
const { lock, mint } = applyParams(tokenName, outputReference, validators);
|
||||
const contracts = applyParams(
|
||||
tokenName,
|
||||
outputReference,
|
||||
validators,
|
||||
lucid!,
|
||||
);
|
||||
|
||||
console.log(lock, mint);
|
||||
setParameterizedContracts(contracts);
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -90,6 +100,19 @@ export default function App({ validators }: AppProps) {
|
|||
)}
|
||||
</form>
|
||||
)}
|
||||
{parameterizedContracts && (
|
||||
<>
|
||||
<h3 class="mt-4 mb-2">Lock</h3>
|
||||
<pre class="bg-gray-200 p-2 rounded overflow-x-scroll">
|
||||
{parameterizedContracts.lock}
|
||||
</pre>
|
||||
|
||||
<h3 class="mt-4 mb-2">Mint</h3>
|
||||
<pre class="bg-gray-200 p-2 rounded overflow-x-scroll">
|
||||
{parameterizedContracts.mint}
|
||||
</pre>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import {
|
||||
applyDoubleCborEncoding,
|
||||
applyParamsToScript,
|
||||
C,
|
||||
Constr,
|
||||
Data,
|
||||
fromText,
|
||||
Lucid,
|
||||
MintingPolicy,
|
||||
OutRef,
|
||||
|
@ -48,18 +51,22 @@ export function applyParams(
|
|||
tokenName: string,
|
||||
outputReference: OutRef,
|
||||
validators: Validators,
|
||||
lucid: Lucid,
|
||||
): { lock: string; mint: string } {
|
||||
const mint = applyParamsToScript(validators.mint.script, [
|
||||
tokenName,
|
||||
outputReference,
|
||||
const outRef = new Constr(0, [
|
||||
new Constr(0, [outputReference.txHash]),
|
||||
BigInt(outputReference.outputIndex),
|
||||
]);
|
||||
|
||||
const lucid = new Lucid();
|
||||
const mint = applyParamsToScript(validators.mint.script, [
|
||||
fromText(tokenName),
|
||||
outRef,
|
||||
]);
|
||||
|
||||
const policyId = lucid.utils.validatorToScriptHash(validators.mint);
|
||||
|
||||
const lock = applyParamsToScript(validators.lock.script, [
|
||||
tokenName,
|
||||
fromText(tokenName),
|
||||
policyId,
|
||||
]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue