Closed aleeusgr closed 1 year ago
how do I get current time from the Emulator
Hello again! Than for the answer on GitHub. How can I find out what is the number of the current slot in the Emulator?
Now I have an error about slot being out of range.
I suspect it's about lines where I set validTo
and validAfter
.
What I did is just to look up last line in preprod.json
for the initial time,
https://github.com/aleeusgr/potential-robot/blob/ee83e60b62775bde4563e6cc4bb48c3f7c3296a7/tests/helios-vesting-cancel.test.ts#L114-L120 , but I have no way of knowing what time is now, since I advanced the emulator several times.
I looked in the doc pages but I found only slotToTime conversion.
+ { [100/1857]
+ collateral: [
+ {
+ origOutput: {
+ address: {
+ bech32: 'addr_test1vz2a83z0d5gceyghfrjqpaqu2f98evk8q6swje2c5ddqmaca2vhfl',
+ hex: '6095d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7',
+ },
+ datum: null,
+ refScript: null,
+ value: {
+ assets: {},
+ lovelace: '50000000',
+ },
+ },
+ txId: '0000000000000000000000000000000000000000000000000000000000000001',
+ utxoIdx: '0',
+ },
+ ],
+ collateralReturn: null,
+ fee: '210425',
+ firstValidSlot: '21425484',
+ inputs: [
+ {
+ origOutput: {
+ address: {
+ bech32: 'addr_test1wqzs96thkxedr0jpak4ar9qp6ew58uwexmuz99ah93ckv0q6z8ey4',
+ hex: '700502e977b1b2d1be41edabd19401d65d43f1d936f82297b72c71663c', [73/1857]
+ },
+ datum: {
+ inlineCbor: '9f581c95d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7581c3b61a40bc5872219ce830fb9c7
92d8d53fb87921f590287057e4e3b41b000001867b8b7b00ff',
+ inlineSchema: {
+ list: [
+ {
+ bytes: '95d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7',
+ },
+ {
+ bytes: '3b61a40bc5872219ce830fb9c792d8d53fb87921f590287057e4e3b4',
+ },
+ {
+ int: 1677109984000,
+ },
+ ],
+ },
+ },
+ refScript: null,
+ value: {
+ assets: {
+ '49b106e698de78171de2faf35932635e1085c12508ca87718a2d4487': {
+ '56657374696e67204b6579': '1',
+ },
+ },
+ lovelace: '10000000',
+ }, [46/1857]
+ },
+ txId: '21df94e55f1bd5a533db39be4b9cad35924ce60d4c0037aa64c35d028cd4a41f',
+ utxoIdx: '0',
+ },
+ {
+ origOutput: {
+ address: {
+ bech32: 'addr_test1vz2a83z0d5gceyghfrjqpaqu2f98evk8q6swje2c5ddqmaca2vhfl',
+ hex: '6095d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7',
+ },
+ datum: null,
+ refScript: null,
+ value: {
+ assets: {},
+ lovelace: '9753780',
+ },
+ },
+ txId: '21df94e55f1bd5a533db39be4b9cad35924ce60d4c0037aa64c35d028cd4a41f',
+ utxoIdx: '1',
+ },
+ ],
+ lastValidSlot: '21497784',
+ metadataHash: null,
+ minted: null,
+ outputs: [
+ {
+ address: {
+ bech32: 'addr_test1vz2a83z0d5gceyghfrjqpaqu2f98evk8q6swje2c5ddqmaca2vhfl',
+ hex: '6095d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7',
+ },
+ datum: null,
+ refScript: null,
+ value: {
+ assets: {
+ '49b106e698de78171de2faf35932635e1085c12508ca87718a2d4487': {
+ '56657374696e67204b6579': '1',
+ },
+ },
+ lovelace: '10000000',
+ },
+ },
+ {
+ address: {
+ bech32: 'addr_test1vz2a83z0d5gceyghfrjqpaqu2f98evk8q6swje2c5ddqmaca2vhfl',
+ hex: '6095d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7',
+ },
+ datum: null,
+ refScript: null,
+ value: {
+ assets: {},
+ lovelace: '9543355',
+ },
+ },
+ ],
+ refInputs: [],
+ scriptDataHash: 'd1baf438740aa9215d0c4ae329922803781c17d726b78555d1ca002af5c346cc',
+ signers: [
+ '95d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7',
+ ],
+ }
Have you tried omitting the validTo
and validFrom
calls, and then "initialize" the NetworkParams for emulator use? https://www.hyperion-bt.org/helios-book/api/reference/networkemulator.html#initnetworkparams
Currently the emulator starts at 0, and it's very hard to get it to correspond to real time
I've been trying to automate everything related to the tx validity time-range
removing validTo and validAfter:
Error: Trace: line 16
Trace: line 132 of IR in '__helios__common__field_0'
Trace: line 138 of IR in '__core__headList'
RuntimeError on line 138 of IR: empty list ```
I'm sorry, v0.13.14 of Helios doesn't support that feature yet. You have to upgrade to be able to do that.
@christianschmitz thank you for the heads up.
I bumped the version to 0.14.0, and it broke my lockAda tx. the problem is in the script that mints vesting key nft:
Have you tried omitting the
validTo
andvalidFrom
calls, and then "initialize" the NetworkParams for emulator use? https://www.hyperion-bt.org/helios-book/api/reference/networkemulator.html#initnetworkparamsCurrently the emulator starts at 0, and it's very hard to get it to correspond to real time
Based on docs, it's not clear to me how NetworkEmulator's initNetworkParams(networkParams: helios.NetworkParams): helios.NetworkParams
is supposed to work; it seems like it has a chicken/egg problem.
Once there is a NetworkParams object for it, slotToTime
and timeToSlot
💚
https://www.hyperion-bt.org/helios-book/api/reference/networkemulator.html#initnetworkparams https://www.hyperion-bt.org/helios-book/api/reference/networkparams.html#slottotime
❯ assert node_modules/@hyperionbt/helios/helios.js:282:9 ❯ NetworkEmulator.submitTx node_modules/@hyperionbt/helios/helios.js:38456:9 ❯ tests/helios-vesting-cancel.test.ts:137:30 135| 136| await tx.finalize(networkParams, ownerAddress, [spareUtxo]); 137| const txId = await network.submitTx(tx);
Originally posted by @aleeusgr in https://github.com/aleeusgr/potential-robot/issues/104#issuecomment-1560839916