Skip to content
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

Closed
wants to merge 4 commits into from
Closed

emulate-something #38

wants to merge 4 commits into from

Conversation

aleeusgr
Copy link
Owner

@aleeusgr aleeusgr commented Apr 17, 2023

For docs!

npm run dev -> emulate-something.ts

TypeError

09:36 $ npm run dev

> potential-robot@1.0.0 dev
> node emulate-something.ts

node:internal/errors:484
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/alex/workshop/potential-robot/emulate-something.ts
    at new NodeError (node:internal/errors:393:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:121:38)
    at defaultLoad (node:internal/modules/esm/load:81:20)
    at nextLoad (node:internal/modules/esm/loader:163:28)
    at ESMLoader.load (node:internal/modules/esm/loader:605:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
    at new ModuleJob (node:internal/modules/esm/module_job:63:26)
    at #createModuleJob (node:internal/modules/esm/loader:480:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

Node.js v18.12.1

  • npm test -> vitest -> tests/emulator.test.ts

#37

Copy link
Owner Author

@aleeusgr aleeusgr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. create an emulator instance
  2. create minting policy
  3. transaction is created from minting policy
  4. transaction is submitted via the emulator

emulate-something.ts Outdated Show resolved Hide resolved

const emulator = new Emulator([{ address, assets: { lovelace: 3000000000n } }]);

const lucid = await Lucid.new(emulator);
Copy link
Owner Author

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! },
],
});
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const signedTx = await tx.sign().complete();

return signedTx.submit();
}
Copy link
Owner Author

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);
Copy link
Owner Author

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> {
Copy link
Owner Author

@aleeusgr aleeusgr Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Promise<TxHash>

see L8

@aleeusgr aleeusgr mentioned this pull request Apr 17, 2023
5 tasks
Copy link
Owner Author

@aleeusgr aleeusgr left a 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",
);
Copy link
Owner Author

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,
};
Copy link
Owner Author

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();
}
Copy link
Owner Author

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

@aleeusgr aleeusgr mentioned this pull request Apr 19, 2023
1 task
@aleeusgr aleeusgr closed this Apr 19, 2023
This was referenced Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant