-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
emulate-something #38
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- create an emulator instance
- create minting policy
- transaction is created from minting policy
- transaction is submitted via the emulator
|
||
const emulator = new Emulator([{ address, assets: { lovelace: 3000000000n } }]); | ||
|
||
const lucid = await Lucid.new(emulator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emulator is a class;
new
means instantiation.
N.B. lucid
vs Lucid
https://deno.land/x/lucid@0.10.1/mod.ts?s=Lucid&p=new
https://deno.land/x/lucid@0.10.1/mod.ts?s=Emulator
}, | ||
{ type: "sig", keyHash: paymentCredential?.hash! }, | ||
], | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert a native script from Json to the Hex representation.
https://deno.land/x/lucid@0.10.1/mod.ts?s=nativeScriptFromJson
https://github.com/input-output-hk/cardano-node/blob/master/doc/reference/simple-scripts.md
const signedTx = await tx.sign().complete(); | ||
|
||
return signedTx.submit(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build and send a tx
https://deno.land/x/lucid@0.10.1/mod.ts?s=Lucid&p=prototype.newTx
validTo
it will be different if I am testing production code, ?
|
||
const lucid = await Lucid.new(emulator); | ||
|
||
lucid.selectWalletFromPrivateKey(privateKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
const policyId = lucid.utils.mintingPolicyToId(mintingPolicy); | ||
|
||
async function mint(): Promise<TxHash> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Promise<TxHash>
see L8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description on L12:17
Exports two functions: lockUtxo, redeemUtxo;
Shows how to interoperate with Helios.
how/where are these functions called?
"<project_id>", | ||
), | ||
"Preview", | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func main(datum : Datum, redeemer: Redeemer) -> Bool {datum.owner == redeemer.owner} | ||
`).compile().serialize(), | ||
).cborHex, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting uplc..
L34
const signedTx = await tx.sign().complete(); | ||
|
||
return signedTx.submit(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L52
Create and execute a lockUtxo transaction
For docs!
npm run dev
-> emulate-something.tsTypeError
npm test
-> vitest -> tests/emulator.test.ts#37