diff --git a/Cargo.lock b/Cargo.lock index 65545558..68500ab9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,18 +34,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "ahash" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" -dependencies = [ - "cfg-if 1.0.0", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "aho-corasick" version = "1.1.2" @@ -87,9 +75,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "arrayvec" @@ -126,36 +114,49 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 2.5.3", + "futures-core", +] + +[[package]] +name = "async-channel" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +dependencies = [ + "concurrent-queue", + "event-listener 4.0.3", + "event-listener-strategy", "futures-core", + "pin-project-lite", ] [[package]] name = "async-executor" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" +checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" dependencies = [ - "async-lock", + "async-lock 3.3.0", "async-task", "concurrent-queue", "fastrand 2.0.1", - "futures-lite", + "futures-lite 2.2.0", "slab", ] [[package]] name = "async-global-executor" -version = "2.3.1" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" +checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" dependencies = [ - "async-channel", + "async-channel 2.1.1", "async-executor", - "async-io", - "async-lock", + "async-io 2.3.1", + "async-lock 3.3.0", "blocking", - "futures-lite", + "futures-lite 2.2.0", "once_cell", "tokio", ] @@ -166,27 +167,57 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ - "async-lock", + "async-lock 2.8.0", "autocfg", "cfg-if 1.0.0", "concurrent-queue", - "futures-lite", + "futures-lite 1.13.0", "log", "parking", - "polling", + "polling 2.8.0", "rustix 0.37.27", "slab", "socket2 0.4.10", "waker-fn", ] +[[package]] +name = "async-io" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f97ab0c5b00a7cdbe5a371b9a782ee7be1316095885c8a4ea1daf490eb0ef65" +dependencies = [ + "async-lock 3.3.0", + "cfg-if 1.0.0", + "concurrent-queue", + "futures-io", + "futures-lite 2.2.0", + "parking", + "polling 3.3.2", + "rustix 0.38.30", + "slab", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "async-lock" version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ - "event-listener", + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" +dependencies = [ + "event-listener 4.0.3", + "event-listener-strategy", + "pin-project-lite", ] [[package]] @@ -196,15 +227,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" dependencies = [ "async-attributes", - "async-channel", + "async-channel 1.9.0", "async-global-executor", - "async-io", - "async-lock", + "async-io 1.13.0", + "async-lock 2.8.0", "crossbeam-utils", "futures-channel", "futures-core", "futures-io", - "futures-lite", + "futures-lite 1.13.0", "gloo-timers", "kv-log-macro", "log", @@ -235,24 +266,24 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] name = "async-task" -version = "4.5.0" +version = "4.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" +checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" [[package]] name = "async-trait" -version = "0.1.74" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -335,9 +366,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.5" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "bech32" @@ -379,9 +410,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "bitmaps" @@ -421,63 +452,42 @@ dependencies = [ [[package]] name = "blocking" -version = "1.4.1" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c36a4d0d48574b3dd360b4b7d95cc651d2b6557b6402848a27d4b228a473e2a" +checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel", - "async-lock", + "async-channel 2.1.1", + "async-lock 3.3.0", "async-task", "fastrand 2.0.1", "futures-io", - "futures-lite", + "futures-lite 2.2.0", "piper", "tracing", ] [[package]] name = "borsh" -version = "0.10.3" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +checksum = "f58b559fd6448c6e2fd0adb5720cd98a2506594cafa4737ff98c396f3e82f667" dependencies = [ "borsh-derive", - "hashbrown 0.13.2", + "cfg_aliases", ] [[package]] name = "borsh-derive" -version = "0.10.3" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +checksum = "7aadb5b6ccbd078890f6d7003694e33816e6b784358f18e15e7e6d9f065a57cd" dependencies = [ - "borsh-derive-internal", - "borsh-schema-derive-internal", + "once_cell", "proc-macro-crate", - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "borsh-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "borsh-schema-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" -dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", + "syn_derive", ] [[package]] @@ -535,6 +545,22 @@ dependencies = [ "trust-dns-resolver", ] +[[package]] +name = "cardano-projected-nft" +version = "0.1.0" +source = "git+https://github.com/dcSpark/projected-nft-whirlpool.git?rev=7ba9a2f7a613f38bbce8f48a7d8575739e9caee0#7ba9a2f7a613f38bbce8f48a7d8575739e9caee0" +dependencies = [ + "cbor_event", + "cml-chain 0.1.0", + "cml-core 0.1.0", + "cml-crypto 0.1.0", + "hex", + "schemars", + "serde", + "serde_derive", + "serde_json", +] + [[package]] name = "cardano-sdk" version = "0.2.5" @@ -553,15 +579,14 @@ dependencies = [ [[package]] name = "carp" -version = "2.2.3" +version = "2.4.1" dependencies = [ "anyhow", "async-trait", - "base64 0.21.5", "clap 3.2.25", - "cml-chain", - "cml-core", - "cml-crypto", + "cml-chain 4.0.2", + "cml-core 4.0.2", + "cml-crypto 4.0.2", "cml-multi-era", "ctrlc", "dcspark-blockchain-source", @@ -599,9 +624,9 @@ dependencies = [ [[package]] name = "cbored-derive" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b022e0f030c53dd61dd217b64e663d348004f598361d6a9ff6db2faf0584578e" +checksum = "2b6c2917d304b928214344fdbda3cfe5ccaea066ef3fc047e6fabb65cce982d1" dependencies = [ "proc-macro2", "quote", @@ -629,11 +654,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb" dependencies = [ "android-tzdata", "iana-time-zone", @@ -641,14 +672,14 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets", + "windows-targets 0.52.0", ] [[package]] name = "chunked_transfer" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cca491388666e04d7248af3f60f0c40cfb0991c72205595d7c396e3510207d1a" +checksum = "6e4de3bc4ea267985becf712dc6d9eed8b04c953b3fcfb339ebc87acd9804901" [[package]] name = "clap" @@ -707,13 +738,14 @@ dependencies = [ [[package]] name = "cml-chain" version = "0.1.0" -source = "git+https://github.com/dcSpark/cardano-multiplatform-lib?rev=e231f1eab743b3cb7c5464cd8ed9ffda29631b97#e231f1eab743b3cb7c5464cd8ed9ffda29631b97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a94cfb4c3837a0cc97323ec281cc6ede491279f8d80faf69005902023807d" dependencies = [ - "base64 0.21.5", + "base64 0.21.7", "bech32 0.7.3", "cbor_event", - "cml-core", - "cml-crypto", + "cml-core 0.1.0", + "cml-crypto 0.1.0", "derivative", "fraction", "getrandom", @@ -728,13 +760,68 @@ dependencies = [ "serde", "serde_json", "thiserror", + "unicode-segmentation", + "wasm-bindgen", +] + +[[package]] +name = "cml-chain" +version = "4.0.2" +source = "git+https://github.com/dcSpark/cardano-multiplatform-lib?rev=c5740393f10b7a68aa4719fbbef5a49170501ef6#c5740393f10b7a68aa4719fbbef5a49170501ef6" +dependencies = [ + "base64 0.21.7", + "bech32 0.7.3", + "cbor_event", + "cml-core 4.0.2", + "cml-crypto 4.0.2", + "derivative", + "fraction", + "getrandom", + "hex", + "itertools", + "linked-hash-map", + "num 0.4.1", + "num-bigint 0.4.4", + "num-integer", + "rand", + "schemars", + "serde", + "serde_json", + "thiserror", + "unicode-segmentation", "wasm-bindgen", ] [[package]] name = "cml-core" version = "0.1.0" -source = "git+https://github.com/dcSpark/cardano-multiplatform-lib?rev=e231f1eab743b3cb7c5464cd8ed9ffda29631b97#e231f1eab743b3cb7c5464cd8ed9ffda29631b97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34899789d0bf57c079c0a77f7f6bdd6428d52bdeb1ec466b132802dbd46ebc15" +dependencies = [ + "base64 0.13.1", + "bech32 0.7.3", + "cbor_event", + "cfg-if 1.0.0", + "derivative", + "fraction", + "getrandom", + "hex", + "itertools", + "linked-hash-map", + "num-bigint 0.4.4", + "num-integer", + "rand", + "schemars", + "serde", + "serde_json", + "thiserror", + "wasm-bindgen", +] + +[[package]] +name = "cml-core" +version = "4.0.2" +source = "git+https://github.com/dcSpark/cardano-multiplatform-lib?rev=c5740393f10b7a68aa4719fbbef5a49170501ef6#c5740393f10b7a68aa4719fbbef5a49170501ef6" dependencies = [ "base64 0.13.1", "bech32 0.7.3", @@ -759,13 +846,37 @@ dependencies = [ [[package]] name = "cml-crypto" version = "0.1.0" -source = "git+https://github.com/dcSpark/cardano-multiplatform-lib?rev=e231f1eab743b3cb7c5464cd8ed9ffda29631b97#e231f1eab743b3cb7c5464cd8ed9ffda29631b97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02775162430e97004d49882d64a095b055dd28052bc88fc8978e7155ee7ec603" +dependencies = [ + "base64 0.21.7", + "bech32 0.7.3", + "cbor_event", + "cfg-if 1.0.0", + "cml-core 0.1.0", + "cryptoxide", + "derivative", + "digest 0.9.0", + "ed25519-bip32", + "hex", + "rand", + "schemars", + "serde", + "serde_json", + "sha2 0.9.9", + "thiserror", +] + +[[package]] +name = "cml-crypto" +version = "4.0.2" +source = "git+https://github.com/dcSpark/cardano-multiplatform-lib?rev=c5740393f10b7a68aa4719fbbef5a49170501ef6#c5740393f10b7a68aa4719fbbef5a49170501ef6" dependencies = [ - "base64 0.21.5", + "base64 0.21.7", "bech32 0.7.3", "cbor_event", "cfg-if 1.0.0", - "cml-core", + "cml-core 4.0.2", "cryptoxide", "derivative", "digest 0.9.0", @@ -781,14 +892,14 @@ dependencies = [ [[package]] name = "cml-multi-era" -version = "0.1.0" -source = "git+https://github.com/dcSpark/cardano-multiplatform-lib?rev=e231f1eab743b3cb7c5464cd8ed9ffda29631b97#e231f1eab743b3cb7c5464cd8ed9ffda29631b97" +version = "4.0.2" +source = "git+https://github.com/dcSpark/cardano-multiplatform-lib?rev=c5740393f10b7a68aa4719fbbef5a49170501ef6#c5740393f10b7a68aa4719fbbef5a49170501ef6" dependencies = [ "bech32 0.7.3", "cbor_event", - "cml-chain", - "cml-core", - "cml-crypto", + "cml-chain 4.0.2", + "cml-core 4.0.2", + "cml-crypto 4.0.2", "derivative", "hex", "linked-hash-map", @@ -800,18 +911,18 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" dependencies = [ "crossbeam-utils", ] [[package]] name = "config" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d379af7f68bfc21714c6c7dea883544201741d2ce8274bb12fa54f89507f52a7" +checksum = "23738e11972c7643e4ec947840fc463b6a571afcd3e735bdfce7d03c7a784aca" dependencies = [ "async-trait", "lazy_static", @@ -831,15 +942,15 @@ checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -870,46 +981,37 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if 1.0.0", "crossbeam-utils", - "memoffset", - "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.3.8" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" dependencies = [ - "cfg-if 1.0.0", "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if 1.0.0", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "crossterm" @@ -964,24 +1066,24 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.4.1" +version = "3.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e95fbd621905b854affdc67943b043a0fbb6ed7385fd5a25650d19a8a6cfdf" +checksum = "b467862cc8610ca6fc9a1532d7777cee0804e678ab45410897b9396495994a0b" dependencies = [ "nix", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "data-encoding" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" [[package]] name = "dcspark-blockchain-source" version = "0.1.0" -source = "git+https://github.com/dcSpark/dcspark-core.git?rev=837b0135462ff7a1018942dca7198ad9c808a84c#837b0135462ff7a1018942dca7198ad9c808a84c" +source = "git+https://github.com/dcSpark/dcspark-core.git?rev=572af17e3e22101dee64e0999049a571aea26e0f#572af17e3e22101dee64e0999049a571aea26e0f" dependencies = [ "anyhow", "async-trait", @@ -1003,7 +1105,7 @@ dependencies = [ [[package]] name = "dcspark-core" version = "0.1.0" -source = "git+https://github.com/dcSpark/dcspark-core.git?rev=837b0135462ff7a1018942dca7198ad9c808a84c#837b0135462ff7a1018942dca7198ad9c808a84c" +source = "git+https://github.com/dcSpark/dcspark-core.git?rev=572af17e3e22101dee64e0999049a571aea26e0f#572af17e3e22101dee64e0999049a571aea26e0f" dependencies = [ "anyhow", "async-trait", @@ -1020,7 +1122,7 @@ dependencies = [ [[package]] name = "deps" version = "0.1.0" -source = "git+https://github.com/dcSpark/dcspark-core.git?rev=837b0135462ff7a1018942dca7198ad9c808a84c#837b0135462ff7a1018942dca7198ad9c808a84c" +source = "git+https://github.com/dcSpark/dcspark-core.git?rev=572af17e3e22101dee64e0999049a571aea26e0f#572af17e3e22101dee64e0999049a571aea26e0f" dependencies = [ "bigdecimal", "serde_json", @@ -1028,9 +1130,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.9" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", ] @@ -1147,9 +1249,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ "humantime", "is-terminal", @@ -1166,12 +1268,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1180,6 +1282,27 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "event-listener" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" +dependencies = [ + "event-listener 4.0.3", + "pin-project-lite", +] + [[package]] name = "fastrand" version = "1.9.0" @@ -1209,9 +1332,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -1244,9 +1367,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -1259,9 +1382,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -1269,15 +1392,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -1297,9 +1420,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" @@ -1316,34 +1439,47 @@ dependencies = [ "waker-fn", ] +[[package]] +name = "futures-lite" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" +dependencies = [ + "fastrand 2.0.1", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + [[package]] name = "futures-macro" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -1378,9 +1514,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -1391,20 +1527,20 @@ dependencies = [ [[package]] name = "ghost" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef81e7cedce6ab54cd5dc7b3400c442c8d132fe03200a1be0637db7ef308ff17" +checksum = "b0e085ded9f1267c32176b40921b9754c474f7dd96f7e808d4a982e48aa1e854" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "gloo-timers" @@ -1430,7 +1566,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash 0.7.7", + "ahash", ] [[package]] @@ -1439,23 +1575,14 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.7", -] - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash 0.8.6", + "ahash", ] [[package]] name = "hashbrown" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "hashlink" @@ -1495,9 +1622,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" [[package]] name = "hex" @@ -1507,9 +1634,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hkdf" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" dependencies = [ "hmac", ] @@ -1542,9 +1669,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "iana-time-zone" -version = "0.1.58" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1576,9 +1703,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1599,9 +1726,9 @@ dependencies = [ [[package]] name = "imbl-sized-chunks" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6957ea0b2541c5ca561d3ef4538044af79f8a05a1eb3a3b148936aaceaa1076" +checksum = "144006fb58ed787dcae3f54575ff4349755b00ccc99f4b4873860b654be1ed63" dependencies = [ "bitmaps", ] @@ -1618,12 +1745,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b" dependencies = [ "equivalent", - "hashbrown 0.14.2", + "hashbrown 0.14.3", ] [[package]] @@ -1651,9 +1778,9 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi 0.3.4", "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1664,7 +1791,7 @@ checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ "socket2 0.5.5", "widestring", - "windows-sys", + "windows-sys 0.48.0", "winreg", ] @@ -1676,13 +1803,13 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" dependencies = [ - "hermit-abi 0.3.3", - "rustix 0.38.21", - "windows-sys", + "hermit-abi 0.3.4", + "rustix 0.38.30", + "windows-sys 0.52.0", ] [[package]] @@ -1696,9 +1823,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" @@ -1726,9 +1853,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.150" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "libredox" @@ -1736,7 +1863,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libc", "redox_syscall 0.4.1", ] @@ -1755,9 +1882,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.10" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" @@ -1825,18 +1952,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "memoffset" -version = "0.9.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "merge" @@ -1906,14 +2024,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "log", "wasi", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1925,7 +2043,7 @@ checksum = "a785740271256c230f57462d3b83e52f998433a7062fc18f96d5999474a9f915" [[package]] name = "multiverse" version = "0.1.0" -source = "git+https://github.com/dcSpark/dcspark-core.git?rev=837b0135462ff7a1018942dca7198ad9c808a84c#837b0135462ff7a1018942dca7198ad9c808a84c" +source = "git+https://github.com/dcSpark/dcspark-core.git?rev=572af17e3e22101dee64e0999049a571aea26e0f#572af17e3e22101dee64e0999049a571aea26e0f" dependencies = [ "dcspark-core", "deps", @@ -1958,7 +2076,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "cfg-if 1.0.0", "libc", ] @@ -2123,24 +2241,24 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi 0.3.4", "libc", ] [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -2370,7 +2488,7 @@ dependencies = [ "libc", "redox_syscall 0.4.1", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -2387,9 +2505,9 @@ checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" @@ -2442,7 +2560,21 @@ dependencies = [ "libc", "log", "pin-project-lite", - "windows-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "polling" +version = "3.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "545c980a3880efd47b2e262f6a4bb6daad6555cf3367aa9c4e52895f69537a41" +dependencies = [ + "cfg-if 1.0.0", + "concurrent-queue", + "pin-project-lite", + "rustix 0.38.30", + "tracing", + "windows-sys 0.52.0", ] [[package]] @@ -2459,11 +2591,11 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro-crate" -version = "0.1.5" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml", + "toml_edit", ] [[package]] @@ -2498,9 +2630,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -2559,9 +2691,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -2613,9 +2745,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" dependencies = [ "either", "rayon-core", @@ -2623,9 +2755,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -2662,13 +2794,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.3", + "regex-automata 0.4.5", "regex-syntax 0.8.2", ] @@ -2683,9 +2815,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -2718,9 +2850,10 @@ name = "reparse" version = "0.1.0" dependencies = [ "anyhow", - "cml-chain", - "cml-core", - "cml-crypto", + "cml-chain 4.0.2", + "cml-core 4.0.2", + "cml-crypto 4.0.2", + "cml-multi-era", "dotenv", "entity", "futures", @@ -2758,26 +2891,27 @@ dependencies = [ [[package]] name = "rkyv" -version = "0.7.42" +version = "0.7.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" +checksum = "527a97cdfef66f65998b5f3b637c26f5a5ec09cc52a3f9932313ac645f4190f5" dependencies = [ "bitvec", "bytecheck", + "bytes", "hashbrown 0.12.3", "ptr_meta", "rend", "rkyv_derive", "seahash", "tinyvec", - "uuid 1.5.0", + "uuid 1.7.0", ] [[package]] name = "rkyv_derive" -version = "0.7.42" +version = "0.7.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2e06b915b5c230a17d7a736d1e2e63ee753c256a8614ef3f5147b13a4f5541d" +checksum = "b5c462a1328c8e67e4d6dbad1eb0355dd43e8ab432c6e227a43657f16ade5033" dependencies = [ "proc-macro2", "quote", @@ -2800,9 +2934,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.32.0" +version = "1.33.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c4216490d5a413bc6d10fa4742bd7d4955941d062c0ef873141d6b0e7b30fd" +checksum = "06676aec5ccb8fc1da723cc8c0f9a46549f21ebb8753d3915c6c41db1e7f1dc4" dependencies = [ "arrayvec 0.7.4", "borsh", @@ -2840,20 +2974,20 @@ dependencies = [ "io-lifetimes", "libc", "linux-raw-sys 0.3.8", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "rustix" -version = "0.38.21" +version = "0.38.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "libc", - "linux-raw-sys 0.4.10", - "windows-sys", + "linux-raw-sys 0.4.13", + "windows-sys 0.52.0", ] [[package]] @@ -2877,15 +3011,15 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "schemars" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f7b0ce13155372a76ee2e1c5ffba1fe61ede73fbea5630d61eee6fac4929c0c" +checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" dependencies = [ "dyn-clone", "schemars_derive", @@ -2895,9 +3029,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e85e2a16b12bdb763244c69ab79363d71db2b4b918a2def53f80b02e0574b13c" +checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" dependencies = [ "proc-macro2", "quote", @@ -3070,22 +3204,22 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -3101,9 +3235,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "itoa", "ryu", @@ -3112,11 +3246,11 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.27" +version = "0.9.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cc7a1570e38322cfe4154732e5110f887ea57e22b76f4bfd32b5bdd3368666c" +checksum = "adf8a49373e98a4c5f0ceb5d05aa7c648d75f63774981ed95b7c7443bbd50c6e" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.1", "itoa", "ryu", "serde", @@ -3269,9 +3403,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "socket2" @@ -3290,7 +3424,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -3326,7 +3460,7 @@ version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48c61941ccf5ddcada342cd59e3e5173b007c509e1e8e990dafc830294d9dc5" dependencies = [ - "ahash 0.7.7", + "ahash", "atoi", "base64 0.13.1", "bitflags 1.3.2", @@ -3337,7 +3471,7 @@ dependencies = [ "crossbeam-queue", "dirs", "either", - "event-listener", + "event-listener 2.5.3", "futures-channel", "futures-core", "futures-intrusive", @@ -3530,15 +3664,27 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.39" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "syn_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "tap" version = "1.0.1" @@ -3563,12 +3709,15 @@ name = "tasks" version = "0.0.0" dependencies = [ "anyhow", + "cardano-projected-nft", "cfg-if 0.1.10", - "cml-chain", - "cml-core", - "cml-crypto", + "cml-chain 4.0.2", + "cml-core 4.0.2", + "cml-crypto 4.0.2", "cml-multi-era", "cryptoxide", + "dcspark-blockchain-source", + "dcspark-core", "entity", "hex", "inventory", @@ -3588,9 +3737,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.3.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -3612,22 +3761,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -3657,16 +3806,16 @@ dependencies = [ [[package]] name = "time" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" dependencies = [ "deranged", "itoa", "powerfmt", "serde", "time-core", - "time-macros 0.2.15", + "time-macros 0.2.16", ] [[package]] @@ -3687,9 +3836,9 @@ dependencies = [ [[package]] name = "time-macros" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" dependencies = [ "time-core", ] @@ -3716,7 +3865,7 @@ dependencies = [ "ascii", "chunked_transfer", "log", - "time 0.3.30", + "time 0.3.31", "url", ] @@ -3737,9 +3886,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.35.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" dependencies = [ "backtrace", "bytes", @@ -3751,18 +3900,18 @@ dependencies = [ "signal-hook-registry", "socket2 0.5.5", "tokio-macros", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -3797,6 +3946,23 @@ dependencies = [ "serde", ] +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" + +[[package]] +name = "toml_edit" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +dependencies = [ + "indexmap 2.2.1", + "toml_datetime", + "winnow", +] + [[package]] name = "tracing" version = "0.1.40" @@ -3817,7 +3983,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -3832,9 +3998,9 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" dependencies = [ "log", "once_cell", @@ -3843,9 +4009,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.17" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ "matchers", "nu-ansi-term", @@ -3921,9 +4087,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -3969,9 +4135,9 @@ checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" [[package]] name = "unsafe-libyaml" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa" +checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" [[package]] name = "untrusted" @@ -3981,12 +4147,12 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", - "idna 0.4.0", + "idna 0.5.0", "percent-encoding", ] @@ -4008,9 +4174,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.5.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" +checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" [[package]] name = "valuable" @@ -4020,9 +4186,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "value-bag" -version = "1.4.2" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a72e1902dde2bd6441347de2b70b7f5d59bf157c6c62f0c44572607a1d55bbe" +checksum = "7cdbaf5e132e593e9fc1de6a15bbec912395b11fb9719e061cf64f804524c503" [[package]] name = "vec_map" @@ -4194,11 +4360,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-core" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.0", ] [[package]] @@ -4207,7 +4373,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -4216,13 +4391,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -4231,42 +4421,93 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "winnow" +version = "0.5.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -4274,7 +4515,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ "cfg-if 1.0.0", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -4294,23 +4535,3 @@ checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" dependencies = [ "linked-hash-map", ] - -[[package]] -name = "zerocopy" -version = "0.7.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] diff --git a/indexer/Cargo.toml b/indexer/Cargo.toml index 26d9b8f3..c88f99bd 100644 --- a/indexer/Cargo.toml +++ b/indexer/Cargo.toml @@ -21,10 +21,10 @@ tasks = { path = "tasks" } # [indexer] anyhow = { version = "1.0.69" } async-trait = { version = "0.1.64" } -cml-core = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "e231f1eab743b3cb7c5464cd8ed9ffda29631b97" } -cml-chain = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "e231f1eab743b3cb7c5464cd8ed9ffda29631b97" } -cml-crypto = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "e231f1eab743b3cb7c5464cd8ed9ffda29631b97" } -cml-multi-era = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "e231f1eab743b3cb7c5464cd8ed9ffda29631b97" } +cml-chain = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "c5740393f10b7a68aa4719fbbef5a49170501ef6" } +cml-core = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "c5740393f10b7a68aa4719fbbef5a49170501ef6" } +cml-crypto = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "c5740393f10b7a68aa4719fbbef5a49170501ef6" } +cml-multi-era = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "c5740393f10b7a68aa4719fbbef5a49170501ef6" } clap = { version = "3.1", features = ["derive"] } ctrlc = { version = "3.2.4", features = ["termination"] } dotenv = { version = "0.15.0" } diff --git a/indexer/reparse/Cargo.toml b/indexer/reparse/Cargo.toml index 0c1f0cda..ca1e6f1a 100644 --- a/indexer/reparse/Cargo.toml +++ b/indexer/reparse/Cargo.toml @@ -10,9 +10,10 @@ entity = { path = "../entity" } # [reparse] anyhow = { version = "1.0.69" } -cml-core = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "e231f1eab743b3cb7c5464cd8ed9ffda29631b97" } -cml-chain = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "e231f1eab743b3cb7c5464cd8ed9ffda29631b97" } -cml-crypto = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "e231f1eab743b3cb7c5464cd8ed9ffda29631b97" } +cml-chain = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "c5740393f10b7a68aa4719fbbef5a49170501ef6" } +cml-core = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "c5740393f10b7a68aa4719fbbef5a49170501ef6" } +cml-crypto = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "c5740393f10b7a68aa4719fbbef5a49170501ef6" } +cml-multi-era = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "c5740393f10b7a68aa4719fbbef5a49170501ef6" } dotenv = { version = "0.15.0" } futures = { version = "0.3.21" } hex = { version = "0.4.0" } diff --git a/indexer/src/benchmark.rs b/indexer/src/benchmark.rs deleted file mode 100644 index 6a79c050..00000000 --- a/indexer/src/benchmark.rs +++ /dev/null @@ -1,63 +0,0 @@ -use entity::{ - prelude::*, - sea_orm::{prelude::*, ColumnTrait, DatabaseTransaction, TransactionTrait}, -}; -use migration::DbErr; -use oura::pipelining::StageReceiver; - -pub struct Config<'a> { - pub conn: &'a DatabaseConnection, -} - -impl<'a> Config<'a> { - pub async fn bootstrap(&self, _input: StageReceiver) -> anyhow::Result<()> { - tracing::info!("{}", "Starting to process blocks"); - - self.conn - .transaction::<_, (), DbErr>(|txn| Box::pin(benchmark(txn))) - .await?; - - Ok(()) - } -} - -async fn benchmark(txn: &DatabaseTransaction) -> Result<(), DbErr> { - println!( - "{:?}", - "8200581cff57a0bbcaaada72b6e3d6d9044c420d1a8dd97794884d39021f1e".to_owned() - + &format!("{:02}", 0) - ); - - let creds = (0..100).map(|i| { - hex::decode( - "8200581cff57a0bbcaaada72b6e3d6d9044c420d1a8dd97794884d39021f1e".to_owned() - + &format!("{:02}", i), - ) - .unwrap() - }); - - let time_counter = std::time::Instant::now(); - - // for i in 0..100 { - // StakeCredential::find() - // .filter( - // StakeCredentialColumn::Credential.eq(hex::decode( - // "8200581cff57a0bbcaaada72b6e3d6d9044c420d1a8dd97794884d39021f1ea3", - // ) - // .unwrap()), - // ) - // // note: we know this exists ("credential" is unique) and "all" is faster than "one" if we know the result exists - // .all(txn) - // .await?; - // } - - let mut base = StakeCredential::find(); - for cred in creds { - base = base.filter(StakeCredentialColumn::Credential.eq(cred)) - } - base.all(txn).await?; - - println!("{:?}", time_counter.elapsed()); - // ~38 - Ok(()) -} diff --git a/indexer/src/sinks/cardano.rs b/indexer/src/sinks/cardano.rs index ba1e8654..7b45cc64 100644 --- a/indexer/src/sinks/cardano.rs +++ b/indexer/src/sinks/cardano.rs @@ -4,6 +4,7 @@ use crate::sink::Sink; use crate::types::{MultiEraBlock, StoppableService}; use crate::{genesis, DbConfig, SinkConfig}; use async_trait::async_trait; + use dcspark_blockchain_source::cardano::Point; use dcspark_core::{BlockId, SlotNumber}; use entity::sea_orm::Database; @@ -18,7 +19,6 @@ use entity::{ }; use std::sync::Arc; use std::sync::Mutex; -use cml_core::serialization::FromBytes; use tasks::byron::byron_executor::process_byron_block; use tasks::dsl::database_task::BlockGlobalInfo; use tasks::execution_plan::ExecutionPlan; @@ -280,10 +280,10 @@ async fn insert_block( let block_parse_counter = std::time::Instant::now(); let block_payload = hex::decode(cbor_hex.clone()).unwrap(); - let multi_block = MultiEraBlock::from_bytes(block_payload).unwrap(); + let multi_block = MultiEraBlock::from_explicit_network_cbor_bytes(&block_payload).unwrap(); let block_global_info = BlockGlobalInfo { - era: to_era_value(multi_block), + era: to_era_value(&multi_block), epoch, epoch_slot, }; @@ -291,7 +291,7 @@ async fn insert_block( perf_aggregator.block_parse += block_parse_counter.elapsed(); match &multi_block { - MultiEraBlock::Byron(byron) => { + MultiEraBlock::Byron(_byron) => { process_byron_block( txn, (&cbor_hex, &multi_block, &block_global_info), diff --git a/indexer/tasks/Cargo.toml b/indexer/tasks/Cargo.toml index 03748e87..41362417 100644 --- a/indexer/tasks/Cargo.toml +++ b/indexer/tasks/Cargo.toml @@ -7,16 +7,19 @@ edition = "2021" name = "tasks" [dependencies] +dcspark-core = { git = "https://github.com/dcSpark/dcspark-core.git", rev = "572af17e3e22101dee64e0999049a571aea26e0f" } +dcspark-blockchain-source = { git = "https://github.com/dcSpark/dcspark-core.git", rev = "572af17e3e22101dee64e0999049a571aea26e0f" } + # [local] entity = { path = "../entity" } # [tasks] anyhow = { version = "1.0.69" } -cml-core = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "e231f1eab743b3cb7c5464cd8ed9ffda29631b97" } -cml-chain = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "e231f1eab743b3cb7c5464cd8ed9ffda29631b97" } -cml-crypto = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "e231f1eab743b3cb7c5464cd8ed9ffda29631b97" } -cml-multi-era = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "e231f1eab743b3cb7c5464cd8ed9ffda29631b97" } -projected-nft-sdk = { git = "https://github.com/dcSpark/projected-nft-whirlpool.git", rev = "a350ccfcbdef22b73c93561c6816bd42b13f00ff" } +cml-chain = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "c5740393f10b7a68aa4719fbbef5a49170501ef6" } +cml-core = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "c5740393f10b7a68aa4719fbbef5a49170501ef6" } +cml-crypto = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "c5740393f10b7a68aa4719fbbef5a49170501ef6" } +cml-multi-era = { git = "https://github.com/dcSpark/cardano-multiplatform-lib", rev = "c5740393f10b7a68aa4719fbbef5a49170501ef6" } +cardano-projected-nft = { git = "https://github.com/dcSpark/projected-nft-whirlpool.git", rev = "7ba9a2f7a613f38bbce8f48a7d8575739e9caee0" } cfg-if = { version = "0.1.10" } cryptoxide = { version = "0.4.2" } hex = { version = "0.4.3" } diff --git a/indexer/tasks/src/byron/byron_address.rs b/indexer/tasks/src/byron/byron_address.rs index 20c7e68f..7b1f1704 100644 --- a/indexer/tasks/src/byron/byron_address.rs +++ b/indexer/tasks/src/byron/byron_address.rs @@ -1,7 +1,6 @@ -use pallas::ledger::primitives::{ - byron::{self}, - Fragment, -}; +use cml_core::serialization::ToBytes; +use cml_multi_era::byron::block::ByronBlock; +use cml_multi_era::MultiEraBlock; use super::byron_txs::ByronTransactionTask; use crate::config::EmptyConfig::EmptyConfig; @@ -18,14 +17,7 @@ carp_task! { write [byron_addresses]; should_add_task |block, _properties| { // recall: txs may have no outputs if they just burn all inputs as fee - match block.1 { - MultiEraBlock::Byron(main_block) => { - main_block - .body - .tx_payload.iter().any(|payload| payload.transaction.outputs.len() > 0) - } - _ => false, - } + block.1.transaction_bodies().iter().any(|tx| !tx.outputs().is_empty()) }; execute |previous_data, task| handle_addresses( task.db_tx, @@ -44,11 +36,16 @@ async fn handle_addresses( ) -> Result, AddressInBlock>, DbErr> { match &block.1 { MultiEraBlock::Byron(main_block) => { - let tx_outputs: Vec<_> = main_block - .body - .tx_payload + let payload = match main_block { + ByronBlock::Main(main) => main.body.tx_payload.clone(), + ByronBlock::EpochBoundary(_) => { + return Ok(BTreeMap::, AddressInBlock>::default()); + } + }; + + let tx_outputs: Vec<_> = payload .iter() - .map(|payload| &payload.transaction.outputs) + .map(|payload| &payload.byron_tx.outputs) .zip(byron_txs) .collect(); @@ -60,7 +57,7 @@ async fn handle_addresses( for (address, tx_id) in tx_outputs .iter() .flat_map(|pair| pair.0.iter().zip(std::iter::repeat(pair.1.id))) - .map(|(output, tx_id)| (output.address.encode_fragment().unwrap(), tx_id)) + .map(|(output, tx_id)| (output.address.to_bytes(), tx_id)) { // we want to keep track of the first tx for each address queued_address.entry(address).or_insert(tx_id); diff --git a/indexer/tasks/src/byron/byron_block.rs b/indexer/tasks/src/byron/byron_block.rs index 75478370..f758d387 100644 --- a/indexer/tasks/src/byron/byron_block.rs +++ b/indexer/tasks/src/byron/byron_block.rs @@ -1,9 +1,13 @@ use crate::config::PayloadAndReadonlyConfig::PayloadAndReadonlyConfig; use crate::dsl::task_macro::*; use crate::era_common::block_from_hash; +use cml_core::serialization::ToBytes; +use cml_crypto::{blake2b256, RawBytesEncoding}; +use cml_multi_era::byron::block::ByronBlock; +use cml_multi_era::MultiEraBlock; use entity::{block::EraValue, sea_orm::Set}; use hex::ToHex; -use pallas::ledger::primitives::{byron, Fragment}; +use sea_orm::sea_query::all; carp_task! { name ByronBlockTask; @@ -33,11 +37,22 @@ async fn handle_block( readonly: bool, include_payload: bool, ) -> Result { - let hash = block.1.hash().to_vec(); + let hash = block.1.hash(); + if readonly { return block_from_hash(db_tx, &hash).await; } + let block_epoch = match block.1 { + MultiEraBlock::Byron(byron) => match byron { + ByronBlock::EpochBoundary(byron) => byron.header.consensus_data.epoch_id, + ByronBlock::Main(byron) => byron.header.consensus_data.byron_slot_id.epoch, + }, + _ => { + return Err(DbErr::Custom("Non-byron block in byron task".to_string())); + } + }; + let block_payload = if include_payload { hex::decode(block.0).unwrap() } else { @@ -45,10 +60,10 @@ async fn handle_block( }; let block = BlockActiveModel { era: Set(EraValue::Byron.into()), - hash: Set(hash), - height: Set(block.1.number() as i32), - epoch: Set(block.1.header().as_byron().unwrap().consensus_data.0.epoch as i32), - slot: Set(block.1.slot() as i32), + hash: Set(hash.to_vec()), + height: Set(block.1.header().block_number() as i32), + epoch: Set(block_epoch as i32), + slot: Set(block.1.header().slot() as i32), payload: Set(Some(block_payload)), ..Default::default() }; diff --git a/indexer/tasks/src/byron/byron_executor.rs b/indexer/tasks/src/byron/byron_executor.rs index 62f3af1b..3cf1e91a 100644 --- a/indexer/tasks/src/byron/byron_executor.rs +++ b/indexer/tasks/src/byron/byron_executor.rs @@ -6,7 +6,6 @@ use crate::execution_plan::ExecutionPlan; use crate::utils::find_task_registry_entry; use crate::utils::TaskPerfAggregator; use entity::sea_orm::{prelude::*, DatabaseTransaction}; -use pallas::ledger::primitives::byron::{self}; use shred::{DispatcherBuilder, World}; use tokio::runtime::Handle; diff --git a/indexer/tasks/src/byron/byron_inputs.rs b/indexer/tasks/src/byron/byron_inputs.rs index b587c262..26021502 100644 --- a/indexer/tasks/src/byron/byron_inputs.rs +++ b/indexer/tasks/src/byron/byron_inputs.rs @@ -1,8 +1,8 @@ +use crate::dsl::task_macro::*; use cml_multi_era::byron::block::ByronBlock; use cml_multi_era::byron::transaction::{ByronTx, ByronTxIn}; +use cml_multi_era::utils::MultiEraTransactionInput; use cml_multi_era::MultiEraBlock; -use crate::dsl::task_macro::*; -use pallas::ledger::primitives::byron::{self, TxIn}; use super::byron_outputs::ByronOutputTask; use crate::config::EmptyConfig::EmptyConfig; @@ -35,56 +35,22 @@ async fn handle_inputs( block: BlockInfo<'_, MultiEraBlock, BlockGlobalInfo>, byron_txs: &[TransactionModel], ) -> Result, DbErr> { - match block.1 { - MultiEraBlock::Byron(ByronBlock::Main(block)) => { - block - .body - .tx_payload - .iter() - .map(|tx| { - tx - .byron_tx - .inputs - .iter() - .map(|input| { - match input { - ByronTxIn::ByronTxInRegular(regular) => { - (regular.index_1.byron_tx_id, regular.index_1.u32) - } - ByronTxIn::ByronTxInGenesis(genesis) => { - genesis. - } - } - }) - }) - } - MultiEraBlock::Shelley(block) => { - block.transaction_bodies + let txs = match block.1 { + MultiEraBlock::Byron(ByronBlock::Main(block)) => block.body.tx_payload.iter().map(|tx| { + tx.byron_tx + .inputs .iter() - .flat_map(|tx| tx.inputs - .iter() - .map(|input| - (input.transaction_id, input.index) - ) - ) + .cloned() + .map(MultiEraTransactionInput::Byron) + }), + _ => { + return Ok(vec![]); } - MultiEraBlock::Allegra(_) => {} - MultiEraBlock::Mary(_) => {} - MultiEraBlock::Alonzo(_) => {} - MultiEraBlock::Babbage(_) => {} - MultiEraBlock::Conway(_) => {} - } - let flattened_inputs: Vec<(Vec, i64)> = block - .1 - .txs() - .iter() - .zip(byron_txs) - .map(|(tx, cardano_tx_in_db)| { - let inputs: Vec = - tx.inputs().iter().map(|x| x.output_ref()).collect(); + }; - (inputs, cardano_tx_in_db.id) - }) + let flattened_inputs: Vec<(Vec<_>, i64)> = txs + .zip(byron_txs) + .map(|(inputs, cardano_tx_in_db)| (inputs.collect::>(), cardano_tx_in_db.id)) .collect(); let outputs_for_inputs = diff --git a/indexer/tasks/src/byron/byron_outputs.rs b/indexer/tasks/src/byron/byron_outputs.rs index d4ae6583..8a73d50d 100644 --- a/indexer/tasks/src/byron/byron_outputs.rs +++ b/indexer/tasks/src/byron/byron_outputs.rs @@ -2,15 +2,11 @@ use super::byron_address::ByronAddressTask; use crate::config::EmptyConfig::EmptyConfig; use crate::dsl::database_task::BlockGlobalInfo; use crate::{dsl::task_macro::*, era_common::get_truncated_address}; +use cml_chain::byron::ByronTxOut; +use cml_core::serialization::ToBytes; +use cml_multi_era::byron::block::ByronBlock; +use cml_multi_era::MultiEraBlock; use entity::sea_orm::Set; -use pallas::ledger::traverse::MultiEraOutput; -use pallas::{ - codec::utils::MaybeIndefArray, - ledger::primitives::{ - byron::{self, TxOut}, - Fragment, - }, -}; carp_task! { name ByronOutputTask; @@ -22,7 +18,7 @@ carp_task! { write [byron_outputs]; should_add_task |block, _properties| { // recall: txs may have no outputs if they just burn all inputs as fee - block.1.txs().iter().any(|tx| tx.outputs().len() > 0) + block.1.transaction_bodies().iter().any(|tx| !tx.outputs().is_empty()) }; execute |previous_data, task| handle_outputs( task.db_tx, @@ -41,16 +37,16 @@ async fn handle_outputs( byron_txs: &[TransactionModel], byron_addresses: &BTreeMap, AddressInBlock>, ) -> Result, DbErr> { - let tx_outputs: Vec<_> = block - .1 - .as_byron() - .unwrap() - .body - .tx_payload - .iter() - .map(|payload| &payload.transaction.outputs) - .zip(byron_txs) - .collect(); + let tx_outputs: Vec<_> = match block.1 { + MultiEraBlock::Byron(ByronBlock::Main(block)) => block + .body + .tx_payload + .iter() + .map(|payload| &payload.byron_tx.outputs) + .zip(byron_txs) + .collect(), + _ => return Ok(vec![]), + }; if tx_outputs.is_empty() { return Ok(vec![]); @@ -63,7 +59,7 @@ async fn handle_outputs( async fn insert_byron_outputs( txn: &DatabaseTransaction, address_map: &BTreeMap, AddressInBlock>, - outputs: &[(&MaybeIndefArray, &TransactionModel)], + outputs: &[(&Vec, &TransactionModel)], ) -> Result, DbErr> { let result = TransactionOutput::insert_many( outputs @@ -71,11 +67,9 @@ async fn insert_byron_outputs( .flat_map(|pair| pair.0.iter().enumerate().zip(std::iter::repeat(pair.1))) .map( |((output_index, output), tx_id)| TransactionOutputActiveModel { - payload: Set(output.encode_fragment().unwrap()), + payload: Set(output.to_bytes()), address_id: Set(address_map - .get(get_truncated_address( - &output.address.encode_fragment().unwrap(), - )) + .get(get_truncated_address(&output.address.to_bytes())) .unwrap() .model .id), diff --git a/indexer/tasks/src/byron/byron_txs.rs b/indexer/tasks/src/byron/byron_txs.rs index 0f0b0acf..aef93c48 100644 --- a/indexer/tasks/src/byron/byron_txs.rs +++ b/indexer/tasks/src/byron/byron_txs.rs @@ -1,6 +1,8 @@ use crate::{dsl::task_macro::*, era_common::transactions_from_hashes, utils::blake2b256}; +use cml_core::serialization::ToBytes; +use cml_multi_era::byron::block::ByronBlock; +use cml_multi_era::MultiEraBlock; use entity::sea_orm::Set; -use pallas::ledger::primitives::{byron, Fragment}; use super::byron_block::ByronBlockTask; use crate::config::PayloadAndReadonlyConfig::PayloadAndReadonlyConfig; @@ -41,22 +43,34 @@ async fn handle_tx( } if readonly { - let tx_hashes = block - .1 - .txs() - .iter() - .map(|tx| tx.hash().to_vec()) - .collect::>(); + let tx_hashes = match block.1 { + MultiEraBlock::Byron(ByronBlock::Main(main)) => main + .body + .tx_payload + .iter() + .map(|tx| tx.byron_tx.hash().to_vec()) + .collect::>>(), + _ => vec![], + }; let txs = transactions_from_hashes(db_tx, &tx_hashes).await; return txs; } + let transactions = match block.1 { + MultiEraBlock::Byron(ByronBlock::Main(main)) => main.body.tx_payload.clone(), + _ => vec![], + }; + let transaction_inserts = - Transaction::insert_many(block.1.txs().iter().enumerate().map(|(idx, tx)| { - let tx_payload = if include_payload { tx.encode() } else { vec![] }; + Transaction::insert_many(transactions.iter().enumerate().map(|(idx, tx)| { + let tx_payload = if include_payload { + tx.to_bytes() + } else { + vec![] + }; TransactionActiveModel { - hash: Set(tx.hash().to_vec()), + hash: Set(tx.byron_tx.hash().to_vec()), block_id: Set(database_block.id), tx_index: Set(idx as i32), payload: Set(tx_payload), diff --git a/indexer/tasks/src/config/AddressConfig.rs b/indexer/tasks/src/config/AddressConfig.rs index 3648a934..150ad401 100644 --- a/indexer/tasks/src/config/AddressConfig.rs +++ b/indexer/tasks/src/config/AddressConfig.rs @@ -1,7 +1,3 @@ -use pallas::ledger::addresses::Address; -use pallas::ledger::primitives::alonzo::PlutusScript; -use pallas::ledger::primitives::babbage::PlutusV2Script; - #[derive(Debug, Clone, serde::Deserialize, serde::Serialize)] pub struct AddressConfig { pub address: String, diff --git a/indexer/tasks/src/dsl/database_task.rs b/indexer/tasks/src/dsl/database_task.rs index 4bdfa5be..0cb81b13 100644 --- a/indexer/tasks/src/dsl/database_task.rs +++ b/indexer/tasks/src/dsl/database_task.rs @@ -66,12 +66,14 @@ pub struct GenesisTaskRegistryEntry { #[derive(Copy, Clone)] pub struct ByronTaskRegistryEntry { - pub builder: &'static (dyn for<'a> TaskBuilder<'a, cml_multi_era::MultiEraBlock, BlockGlobalInfo> + Sync), + pub builder: &'static (dyn for<'a> TaskBuilder<'a, cml_multi_era::MultiEraBlock, BlockGlobalInfo> + + Sync), } #[derive(Copy, Clone)] pub struct MultieraTaskRegistryEntry { - pub builder: &'static (dyn for<'a> TaskBuilder<'a, cml_multi_era::MultiEraBlock, BlockGlobalInfo> + Sync), + pub builder: &'static (dyn for<'a> TaskBuilder<'a, cml_multi_era::MultiEraBlock, BlockGlobalInfo> + + Sync), } inventory::collect!(TaskRegistryEntry); diff --git a/indexer/tasks/src/era_common.rs b/indexer/tasks/src/era_common.rs index 14cf86f6..50997d1a 100644 --- a/indexer/tasks/src/era_common.rs +++ b/indexer/tasks/src/era_common.rs @@ -1,5 +1,7 @@ use std::collections::BTreeSet; +use cml_crypto::RawBytesEncoding; +use cml_multi_era::byron::transaction::ByronTxIn; use entity::{ block::EraValue, prelude::*, @@ -123,7 +125,7 @@ pub struct OutputWithTxData { } pub async fn get_outputs_for_inputs( - inputs: &[(Vec, i64)], + inputs: &[(Vec, i64)], txn: &DatabaseTransaction, ) -> Result, DbErr> { // avoid querying the DB if there were no inputs @@ -139,10 +141,18 @@ pub async fn get_outputs_for_inputs( // so we know all these pairs are disjoint amongst all transactions // https://github.com/dcSpark/carp/issues/46 for input in inputs.iter().flat_map(|inputs| inputs.0.iter()) { + let index = match input.index() { + None => return Err(DbErr::Custom("no output index".to_string())), + Some(index) => index, + }; + let hash = match input.hash() { + None => return Err(DbErr::Custom("no output hash".to_string())), + Some(hash) => *hash, + }; output_conditions = output_conditions.add( Condition::all() - .add(TransactionOutputColumn::OutputIndex.eq(input.index())) - .add(TransactionColumn::Hash.eq(input.hash().to_vec())), + .add(TransactionOutputColumn::OutputIndex.eq(index)) + .add(TransactionColumn::Hash.eq(hash.to_raw_bytes().to_vec())), ); } @@ -193,9 +203,7 @@ pub async fn get_outputs_for_inputs( output_index: output.output_index, }, tx_hash: output.tx_hash.clone(), - era: >::try_into(output.era) - .unwrap() - .into(), + era: >::try_into(output.era).unwrap(), }) .collect::>()) } @@ -223,7 +231,7 @@ pub fn gen_input_to_output_map( } pub async fn insert_inputs( - inputs: &[(Vec, i64)], + inputs: &[(Vec, i64)], input_to_output_map: &BTreeMap, BTreeMap>, txn: &DatabaseTransaction, ) -> Result, DbErr> { @@ -238,11 +246,13 @@ pub async fn insert_inputs( .iter() .flat_map(|pair| pair.0.iter().enumerate().zip(std::iter::repeat(pair.1))) .map(|((idx, input), tx_id)| { - let tx_outputs = match input_to_output_map.get(&input.hash().to_vec()) { + let input_hash = input.hash().unwrap().to_raw_bytes().to_vec(); + let input_index = input.index().unwrap() as i64; + let tx_outputs = match input_to_output_map.get(&input_hash) { Some(outputs) => outputs, - None => panic!("Failed to find transaction {}", &hex::encode(input.hash())), + None => panic!("Failed to find transaction {}", &hex::encode(input_hash)), }; - let output = &tx_outputs[&(input.index() as i64)]; + let output = &tx_outputs[&input_index]; TransactionInputActiveModel { utxo_id: Set(output.model.id), address_id: Set(output.model.address_id), diff --git a/indexer/tasks/src/multiera/dex/common.rs b/indexer/tasks/src/multiera/dex/common.rs index 082cdc0e..aa847d66 100644 --- a/indexer/tasks/src/multiera/dex/common.rs +++ b/indexer/tasks/src/multiera/dex/common.rs @@ -7,22 +7,18 @@ use crate::{ }; use entity::dex_swap::Operation; use entity::sea_orm::{DatabaseTransaction, Set}; -use pallas::{ - codec::utils::KeepRaw, - ledger::{ - primitives::alonzo, - traverse::{MultiEraBlock, MultiEraOutput, MultiEraTx}, - }, -}; use std::collections::{BTreeMap, BTreeSet}; /// Returns an output and it's datum only if the output's payment hash is in `payment_hashes` /// and the plutus datum is known. -pub fn filter_outputs_and_datums_by_hash<'b>( - outputs: &[MultiEraOutput<'b>], +pub fn filter_outputs_and_datums_by_hash( + outputs: &[cml_multi_era::utils::MultiEraTransactionOutput], payment_hashes: &[&str], - plutus_data: &[&KeepRaw], -) -> Vec<(MultiEraOutput<'b>, alonzo::PlutusData)> { + plutus_data: &[cml_chain::plutus::PlutusData], +) -> Vec<( + cml_multi_era::utils::MultiEraTransactionOutput, + cml_chain::plutus::PlutusData, +)> { let payment_hashes = payment_hashes.iter().map(|&s| Some(s)).collect::>(); outputs .iter() @@ -38,16 +34,20 @@ pub fn filter_outputs_and_datums_by_hash<'b>( /// Returns an output and it's datum only if the output's address is in `addresses` /// and the plutus datum is known. -pub fn filter_outputs_and_datums_by_address<'b>( - outputs: &[MultiEraOutput<'b>], +pub fn filter_outputs_and_datums_by_address( + outputs: &[cml_multi_era::utils::MultiEraTransactionOutput], addresses: &[&str], - plutus_data: &[&KeepRaw], -) -> Vec<(MultiEraOutput<'b>, alonzo::PlutusData)> { - let addresses = addresses.iter().map(|&s| Some(s)).collect::>(); + plutus_data: &[cml_chain::plutus::PlutusData], +) -> Vec<( + cml_multi_era::utils::MultiEraTransactionOutput, + cml_chain::plutus::PlutusData, +)> { + let addresses = addresses.to_vec(); outputs .iter() .filter_map(|o| { - if addresses.contains(&o.address().ok().and_then(|a| a.to_bech32().ok()).as_deref()) { + let address_string = o.address().to_bech32(None).unwrap_or_default(); + if addresses.contains(&address_string.as_str()) { get_plutus_datum_for_output(o, plutus_data).map(|datum| (o.clone(), datum)) } else { None @@ -82,7 +82,8 @@ pub trait Dex { fn queue_mean_price( &self, queued_prices: &mut Vec, - tx: &MultiEraTx, + tx: &cml_multi_era::MultiEraTransactionBody, + tx_witness: &cml_chain::transaction::TransactionWitnessSet, tx_id: i64, ) -> Result<(), String>; @@ -90,7 +91,8 @@ pub trait Dex { fn queue_swap( &self, queued_swaps: &mut Vec, - tx: &MultiEraTx, + tx: &cml_multi_era::MultiEraTransactionBody, + tx_witness: &cml_chain::transaction::TransactionWitnessSet, tx_id: i64, multiera_used_inputs_to_outputs_map: &BTreeMap, BTreeMap>, ) -> Result<(), String>; @@ -109,7 +111,8 @@ impl Dex for Empty { fn queue_mean_price( &self, _queued_prices: &mut Vec, - _tx: &MultiEraTx, + _tx: &cml_multi_era::MultiEraTransactionBody, + _tx_witness: &cml_chain::transaction::TransactionWitnessSet, _tx_id: i64, ) -> Result<(), String> { unimplemented!(); @@ -118,7 +121,8 @@ impl Dex for Empty { fn queue_swap( &self, _queued_swaps: &mut Vec, - _tx: &MultiEraTx, + _tx: &cml_multi_era::MultiEraTransactionBody, + _tx_witness: &cml_chain::transaction::TransactionWitnessSet, _tx_id: i64, _multiera_used_inputs_to_outputs_map: &BTreeMap, BTreeMap>, ) -> Result<(), String> { @@ -167,11 +171,18 @@ pub async fn handle_mean_price( let pool = pool_type; let mean_value_trait = pool.as_trait(); let mut queued_prices = Vec::::default(); - for (tx_body, cardano_transaction) in block.1.txs().iter().zip(multiera_txs) { + for ((tx_body, tx_witness_set), cardano_transaction) in block + .1 + .transaction_bodies() + .iter() + .zip(block.1.transaction_witness_sets()) + .zip(multiera_txs) + { if cardano_transaction.is_valid { let result = mean_value_trait.queue_mean_price( &mut queued_prices, tx_body, + &tx_witness_set, cardano_transaction.id, ); if result.is_err() { @@ -269,11 +280,18 @@ pub async fn handle_swap( // 1) Parse swaps let swap_trait = dex_type.as_trait(); let mut queued_swaps = Vec::::default(); - for (tx_body, cardano_transaction) in block.1.txs().iter().zip(multiera_txs) { + for ((tx_body, tx_witness_set), cardano_transaction) in block + .1 + .transaction_bodies() + .iter() + .zip(block.1.transaction_witness_sets()) + .zip(multiera_txs) + { if cardano_transaction.is_valid { let result = swap_trait.queue_swap( &mut queued_swaps, tx_body, + &tx_witness_set, cardano_transaction.id, multiera_used_inputs_to_outputs_map, ); diff --git a/indexer/tasks/src/multiera/dex/minswap_v1.rs b/indexer/tasks/src/multiera/dex/minswap_v1.rs index 141bfc12..3da6e031 100644 --- a/indexer/tasks/src/multiera/dex/minswap_v1.rs +++ b/indexer/tasks/src/multiera/dex/minswap_v1.rs @@ -1,15 +1,16 @@ +use cml_chain::byron::ByronTxOut; +use cml_core::serialization::{FromBytes, Serialize}; +use cml_crypto::RawBytesEncoding; +use entity::block::EraValue; +use pallas::ledger::primitives::{Fragment, ToCanonicalJson}; +use sea_orm::DbErr; use std::collections::BTreeMap; -use pallas::ledger::{ - addresses::Address, - primitives::ToCanonicalJson, - traverse::{MultiEraOutput, MultiEraTx}, -}; - use super::common::{ build_asset, filter_outputs_and_datums_by_address, filter_outputs_and_datums_by_hash, reduce_ada_amount, Dex, DexType, MinSwapV1, QueuedMeanPrice, QueuedSwap, }; +use crate::multiera::utils::common::output_from_bytes; use crate::{era_common::OutputWithTxData, multiera::utils::common::get_asset_amount}; use entity::dex_swap::Operation; @@ -24,18 +25,23 @@ impl Dex for MinSwapV1 { fn queue_mean_price( &self, queued_prices: &mut Vec, - tx: &MultiEraTx, + tx: &cml_multi_era::MultiEraTransactionBody, + tx_witness: &cml_chain::transaction::TransactionWitnessSet, tx_id: i64, ) -> Result<(), String> { // Note: there should be at most one pool output if let Some((output, datum)) = filter_outputs_and_datums_by_hash( &tx.outputs(), &[POOL_SCRIPT_HASH1, POOL_SCRIPT_HASH2], - &tx.plutus_data(), + &tx_witness.plutus_datums.clone().unwrap_or_default(), ) .first() { - let datum = datum.to_json(); + let pallas_datum = pallas::ledger::primitives::alonzo::PlutusData::decode_fragment( + &datum.to_canonical_cbor_bytes(), + ) + .map_err(|err| format!("can't decode datum: {err}"))?; + let datum = pallas_datum.to_json(); let parse_asset_item = |i, j| -> Result, &str> { let item = datum["fields"][i]["fields"][j]["bytes"] @@ -52,7 +58,7 @@ impl Dex for MinSwapV1 { queued_prices.push(QueuedMeanPrice { tx_id, - address: output.address().unwrap().to_vec(), + address: output.address().to_raw_bytes().to_vec(), dex_type: DexType::MinSwapV1, asset1, asset2, @@ -66,7 +72,8 @@ impl Dex for MinSwapV1 { fn queue_swap( &self, queued_swaps: &mut Vec, - tx: &MultiEraTx, + tx: &cml_multi_era::MultiEraTransactionBody, + tx_witness: &cml_chain::transaction::TransactionWitnessSet, tx_id: i64, multiera_used_inputs_to_outputs_map: &BTreeMap, BTreeMap>, ) -> Result<(), String> { @@ -74,12 +81,17 @@ impl Dex for MinSwapV1 { if let Some((main_output, main_datum)) = filter_outputs_and_datums_by_hash( &tx.outputs(), &[POOL_SCRIPT_HASH1, POOL_SCRIPT_HASH2], - &tx.plutus_data(), + &tx_witness.plutus_datums.clone().unwrap_or_default(), ) .first() { - let main_datum = main_datum.to_json(); - let mut free_utxos: Vec = tx.outputs(); + let pallas_datum = pallas::ledger::primitives::alonzo::PlutusData::decode_fragment( + &main_datum.to_canonical_cbor_bytes(), + ) + .map_err(|err| format!("can't decode datum: {err}"))?; + let main_datum = pallas_datum.to_json(); + + let mut free_utxos: Vec = tx.outputs(); // Extract asset information from plutus data of pool input let parse_asset_item = |i, j| -> Result, &str> { @@ -92,21 +104,26 @@ impl Dex for MinSwapV1 { let asset1 = build_asset(parse_asset_item(0, 0)?, parse_asset_item(0, 1)?); let asset2 = build_asset(parse_asset_item(1, 0)?, parse_asset_item(1, 1)?); - let inputs: Vec = tx + let inputs: Vec = tx .inputs() .iter() .map(|i| { - let output = &multiera_used_inputs_to_outputs_map[&i.hash().to_vec()] - [&(i.index() as i64)]; - MultiEraOutput::decode(output.era, &output.model.payload).unwrap() + let output = &multiera_used_inputs_to_outputs_map + [&i.hash().unwrap().to_raw_bytes().to_vec()] + [&(i.index().unwrap() as i64)]; + output_from_bytes(output).unwrap() }) .collect::>(); for (input, input_datum) in filter_outputs_and_datums_by_address( &inputs, &[BATCH_ORDER_ADDRESS1, BATCH_ORDER_ADDRESS2], - &tx.plutus_data(), + &tx_witness.plutus_datums.clone().unwrap_or_default(), ) { - let input_datum = input_datum.to_json(); + let pallas_datum = pallas::ledger::primitives::alonzo::PlutusData::decode_fragment( + &input_datum.to_canonical_cbor_bytes(), + ) + .map_err(|err| format!("can't decode datum: {err}"))?; + let input_datum = pallas_datum.to_json(); // identify operation: 0 = swap let operation = input_datum["fields"][3]["constructor"] @@ -139,13 +156,14 @@ impl Dex for MinSwapV1 { .ok_or("Failed to parse output address item")? .to_string(), ]; - let output_address = Address::from_hex(&output_address_items.join("")) - .map_err(|_e| "Failed to parse output address")?; + let output_address = + cml_chain::address::Address::from_hex(&output_address_items.join("")) + .map_err(|_e| "Failed to parse output address")?; // Get coresponding UTxO with result let utxo_pos = free_utxos .iter() - .position(|o| o.address().ok() == Some(output_address.clone())) + .position(|o| o.address() == output_address.clone()) .ok_or("Failed to find utxo")?; let utxo = free_utxos[utxo_pos].clone(); free_utxos.remove(utxo_pos); @@ -169,7 +187,7 @@ impl Dex for MinSwapV1 { } queued_swaps.push(QueuedSwap { tx_id, - address: main_output.address().unwrap().to_vec(), + address: main_output.address().to_raw_bytes().to_vec(), dex_type: DexType::MinSwapV1, asset1: asset1.clone(), asset2: asset2.clone(), diff --git a/indexer/tasks/src/multiera/dex/sundaeswap_v1.rs b/indexer/tasks/src/multiera/dex/sundaeswap_v1.rs index 76ef1eaa..1d9ae941 100644 --- a/indexer/tasks/src/multiera/dex/sundaeswap_v1.rs +++ b/indexer/tasks/src/multiera/dex/sundaeswap_v1.rs @@ -1,15 +1,18 @@ +use cml_chain::byron::ByronTxOut; +use cml_core::serialization::{FromBytes, Serialize}; +use cml_crypto::RawBytesEncoding; +use cml_multi_era::utils::MultiEraTransactionOutput; use std::collections::BTreeMap; -use pallas::ledger::{ - addresses::Address, - primitives::ToCanonicalJson, - traverse::{MultiEraOutput, MultiEraTx}, -}; +use entity::block::EraValue; +use pallas::ledger::primitives::{Fragment, ToCanonicalJson}; +use sea_orm::DbErr; use super::common::{ build_asset, filter_outputs_and_datums_by_address, filter_outputs_and_datums_by_hash, reduce_ada_amount, Dex, DexType, QueuedMeanPrice, QueuedSwap, SundaeSwapV1, }; +use crate::multiera::utils::common::output_from_bytes; use crate::{era_common::OutputWithTxData, multiera::utils::common::get_asset_amount}; use entity::dex_swap::Operation; @@ -22,15 +25,23 @@ impl Dex for SundaeSwapV1 { fn queue_mean_price( &self, queued_prices: &mut Vec, - tx: &MultiEraTx, + tx: &cml_multi_era::MultiEraTransactionBody, + tx_witness: &cml_chain::transaction::TransactionWitnessSet, tx_id: i64, ) -> Result<(), String> { // Note: there should be at most one pool output - if let Some((output, datum)) = - filter_outputs_and_datums_by_hash(&tx.outputs(), &[POOL_SCRIPT_HASH], &tx.plutus_data()) - .first() + if let Some((output, datum)) = filter_outputs_and_datums_by_hash( + &tx.outputs(), + &[POOL_SCRIPT_HASH], + &tx_witness.plutus_datums.clone().unwrap_or_default(), + ) + .first() { - let datum = datum.to_json(); + let pallas_datum = pallas::ledger::primitives::alonzo::PlutusData::decode_fragment( + &datum.to_canonical_cbor_bytes(), + ) + .map_err(|err| format!("can't decode datum: {err}"))?; + let datum = pallas_datum.to_json(); let parse_asset_item = |i, j| -> Result, &str> { let item = datum["fields"][0]["fields"][i]["fields"][j]["bytes"] @@ -47,7 +58,7 @@ impl Dex for SundaeSwapV1 { queued_prices.push(QueuedMeanPrice { tx_id, - address: output.address().unwrap().to_vec(), + address: output.address().to_raw_bytes().to_vec(), dex_type: DexType::SundaeSwapV1, asset1, asset2, @@ -61,17 +72,25 @@ impl Dex for SundaeSwapV1 { fn queue_swap( &self, queued_swaps: &mut Vec, - tx: &MultiEraTx, + tx: &cml_multi_era::MultiEraTransactionBody, + tx_witness: &cml_chain::transaction::TransactionWitnessSet, tx_id: i64, multiera_used_inputs_to_outputs_map: &BTreeMap, BTreeMap>, ) -> Result<(), String> { // Note: there should be at most one pool output - if let Some((main_output, main_datum)) = - filter_outputs_and_datums_by_hash(&tx.outputs(), &[POOL_SCRIPT_HASH], &tx.plutus_data()) - .first() + if let Some((main_output, main_datum)) = filter_outputs_and_datums_by_hash( + &tx.outputs(), + &[POOL_SCRIPT_HASH], + &tx_witness.plutus_datums.clone().unwrap_or_default(), + ) + .first() { - let main_datum = main_datum.to_json(); - let mut free_utxos: Vec = tx.outputs(); + let pallas_datum = pallas::ledger::primitives::alonzo::PlutusData::decode_fragment( + &main_datum.to_canonical_cbor_bytes(), + ) + .map_err(|err| format!("can't decode datum: {err}"))?; + let main_datum = pallas_datum.to_json(); + let mut free_utxos: Vec = tx.outputs(); // Extract asset information from plutus data of pool input let parse_asset_item = |i, j| -> Result, &str> { @@ -84,21 +103,26 @@ impl Dex for SundaeSwapV1 { let asset1 = build_asset(parse_asset_item(0, 0)?, parse_asset_item(0, 1)?); let asset2 = build_asset(parse_asset_item(1, 0)?, parse_asset_item(1, 1)?); - let inputs: Vec = tx + let inputs: Vec = tx .inputs() .iter() .map(|i| { - let output = &multiera_used_inputs_to_outputs_map[&i.hash().to_vec()] - [&(i.index() as i64)]; - MultiEraOutput::decode(output.era, &output.model.payload).unwrap() + let output = &multiera_used_inputs_to_outputs_map + [&i.hash().unwrap().to_raw_bytes().to_vec()] + [&(i.index().unwrap() as i64)]; + output_from_bytes(output).unwrap() }) .collect::>(); for (input, input_datum) in filter_outputs_and_datums_by_hash( &inputs, &[REQUEST_SCRIPT_HASH], - &tx.plutus_data(), + &tx_witness.plutus_datums.clone().unwrap_or_default(), ) { - let input_datum = input_datum.to_json(); + let pallas_datum = pallas::ledger::primitives::alonzo::PlutusData::decode_fragment( + &input_datum.to_canonical_cbor_bytes(), + ) + .map_err(|err| format!("can't decode datum: {err}"))?; + let input_datum = pallas_datum.to_json(); // identify operation: 0 = swap let operation = input_datum["fields"][3]["constructor"] @@ -123,13 +147,14 @@ impl Dex for SundaeSwapV1 { .ok_or("Failed to parse output address item")? .to_string(), ]; - let output_address = Address::from_hex(&output_address_items.join("")) - .map_err(|_e| "Failed to parse output address")?; + let output_address = + cml_chain::address::Address::from_hex(&output_address_items.join("")) + .map_err(|_e| "Failed to parse output address")?; // Get coresponding UTxO with result let utxo_pos = free_utxos .iter() - .position(|o| o.address().ok() == Some(output_address.clone())) + .position(|o| o.address() == output_address.clone()) .ok_or("Failed to find utxo")?; let utxo = free_utxos[utxo_pos].clone(); free_utxos.remove(utxo_pos); @@ -154,7 +179,7 @@ impl Dex for SundaeSwapV1 { } queued_swaps.push(QueuedSwap { tx_id, - address: main_output.address().unwrap().to_vec(), + address: main_output.address().to_raw_bytes().to_vec(), dex_type: DexType::SundaeSwapV1, asset1: asset1.clone(), asset2: asset2.clone(), diff --git a/indexer/tasks/src/multiera/dex/wingriders_v1.rs b/indexer/tasks/src/multiera/dex/wingriders_v1.rs index 3f24ac8e..192c14be 100644 --- a/indexer/tasks/src/multiera/dex/wingriders_v1.rs +++ b/indexer/tasks/src/multiera/dex/wingriders_v1.rs @@ -1,14 +1,18 @@ +use cml_chain::byron::ByronTxOut; +use cml_core::serialization::{FromBytes, Serialize}; +use cml_crypto::RawBytesEncoding; +use cml_multi_era::utils::MultiEraTransactionOutput; use std::collections::BTreeMap; -use pallas::ledger::{ - primitives::ToCanonicalJson, - traverse::{MultiEraOutput, MultiEraTx}, -}; +use entity::block::EraValue; +use pallas::ledger::primitives::{Fragment, ToCanonicalJson}; +use sea_orm::DbErr; use super::common::{ build_asset, filter_outputs_and_datums_by_hash, reduce_ada_amount, Dex, DexType, QueuedMeanPrice, QueuedSwap, WingRidersV1, }; +use crate::multiera::utils::common::output_from_bytes; use crate::{ era_common::OutputWithTxData, multiera::utils::common::{get_asset_amount, get_plutus_datum_for_output}, @@ -24,15 +28,23 @@ impl Dex for WingRidersV1 { fn queue_mean_price( &self, queued_prices: &mut Vec, - tx: &MultiEraTx, + tx: &cml_multi_era::MultiEraTransactionBody, + tx_witness: &cml_chain::transaction::TransactionWitnessSet, tx_id: i64, ) -> Result<(), String> { // Note: there should be at most one pool output - if let Some((output, datum)) = - filter_outputs_and_datums_by_hash(&tx.outputs(), &[POOL_SCRIPT_HASH], &tx.plutus_data()) - .first() + if let Some((output, datum)) = filter_outputs_and_datums_by_hash( + &tx.outputs(), + &[POOL_SCRIPT_HASH], + &tx_witness.plutus_datums.clone().unwrap_or_default(), + ) + .first() { - let datum = datum.to_json(); + let pallas_datum = pallas::ledger::primitives::alonzo::PlutusData::decode_fragment( + &datum.to_canonical_cbor_bytes(), + ) + .map_err(|err| format!("can't decode datum: {err}"))?; + let datum = pallas_datum.to_json(); let treasury1 = datum["fields"][1]["fields"][2]["int"] .as_u64() @@ -60,7 +72,7 @@ impl Dex for WingRidersV1 { queued_prices.push(QueuedMeanPrice { tx_id, - address: output.address().unwrap().to_vec(), + address: output.address().to_raw_bytes().to_vec(), dex_type: DexType::WingRidersV1, asset1, asset2, @@ -74,20 +86,29 @@ impl Dex for WingRidersV1 { fn queue_swap( &self, queued_swaps: &mut Vec, - tx: &MultiEraTx, + tx: &cml_multi_era::MultiEraTransactionBody, + tx_witness: &cml_chain::transaction::TransactionWitnessSet, tx_id: i64, multiera_used_inputs_to_outputs_map: &BTreeMap, BTreeMap>, ) -> Result<(), String> { // Note: there should be at most one pool output - if let Some((pool_output, _)) = - filter_outputs_and_datums_by_hash(&tx.outputs(), &[POOL_SCRIPT_HASH], &tx.plutus_data()) - .first() + if let Some((pool_output, _)) = filter_outputs_and_datums_by_hash( + &tx.outputs(), + &[POOL_SCRIPT_HASH], + &tx_witness.plutus_datums.clone().unwrap_or_default(), + ) + .first() { - let redeemers = tx.redeemers().ok_or("No redeemers")?; + let redeemers = tx_witness.redeemers.clone().ok_or("No redeemers")?; // Get pool input from redemeers let pool_input_redeemer = redeemers.first().ok_or("No redeemers")?; - let pool_input = pool_input_redeemer.data.to_json()["fields"][0]["int"] + let pallas_datum = pallas::ledger::primitives::alonzo::PlutusData::decode_fragment( + &pool_input_redeemer.data.to_canonical_cbor_bytes(), + ) + .map_err(|err| format!("can't decode datum: {err}"))?; + + let pool_input = pallas_datum.to_json()["fields"][0]["int"] .as_i64() .ok_or("Failed to parse pool input index")?; @@ -96,7 +117,12 @@ impl Dex for WingRidersV1 { .iter() .find(|&r| r.index as i64 == pool_input) .ok_or("Failed to find main redeemer")?; - let redeemer = redeemer.data.to_json(); + let redeemer = redeemer.data.clone(); + let pallas_datum = pallas::ledger::primitives::alonzo::PlutusData::decode_fragment( + &redeemer.to_canonical_cbor_bytes(), + ) + .map_err(|err| format!("can't decode redeemer datum: {err}"))?; + let redeemer = pallas_datum.to_json(); // Extract input list from redemeer let redeemer_map: Vec = redeemer["fields"][2]["list"] @@ -110,13 +136,14 @@ impl Dex for WingRidersV1 { .as_i64() .ok_or("Failed to parse main transaction")? as usize; // Restore inputs - let inputs: Vec = tx + let inputs: Vec = tx .inputs() .iter() .map(|i| { - let output = &multiera_used_inputs_to_outputs_map[&i.hash().to_vec()] - [&(i.index() as i64)]; - MultiEraOutput::decode(output.era, &output.model.payload).unwrap() + let output = &multiera_used_inputs_to_outputs_map + [&i.hash().unwrap().to_raw_bytes().to_vec()] + [&(i.index().unwrap() as i64)]; + output_from_bytes(output).unwrap() }) .collect::>(); // Zip outputs with redemeer index @@ -125,9 +152,18 @@ impl Dex for WingRidersV1 { let input = inputs.get(redeemer).ok_or("Failed to pair output")?.clone(); // get information about swap from pool plutus data - let parent_datum = get_plutus_datum_for_output(&inputs[parent], &tx.plutus_data()) - .unwrap() - .to_json(); + let parent_datum = get_plutus_datum_for_output( + &inputs[parent], + &tx_witness.plutus_datums.clone().unwrap_or_default(), + ) + .unwrap(); + + let parent_datum = pallas::ledger::primitives::alonzo::PlutusData::decode_fragment( + &parent_datum.to_canonical_cbor_bytes(), + ) + .map_err(|err| format!("can't decode datum: {err}"))? + .to_json(); + let parse_asset_item = |i, j| -> Result, &str> { let item = parent_datum["fields"][1]["fields"][0]["fields"][i]["fields"][j] ["bytes"] @@ -140,9 +176,16 @@ impl Dex for WingRidersV1 { let asset2 = build_asset(parse_asset_item(1, 0)?, parse_asset_item(1, 1)?); // get actual plutus datum - let input_datum = get_plutus_datum_for_output(&input, &tx.plutus_data()) - .unwrap() - .to_json(); + let input_datum = get_plutus_datum_for_output( + &input, + &tx_witness.plutus_datums.clone().unwrap_or_default(), + ) + .unwrap(); + let input_datum = pallas::ledger::primitives::alonzo::PlutusData::decode_fragment( + &input_datum.to_canonical_cbor_bytes(), + ) + .map_err(|err| format!("can't decode redeemer datum: {err}"))? + .to_json(); // identify operation: 0 = swap let operation = input_datum["fields"][1]["constructor"] .as_i64() @@ -170,7 +213,7 @@ impl Dex for WingRidersV1 { } queued_swaps.push(QueuedSwap { tx_id, - address: pool_output.address().unwrap().to_vec(), + address: pool_output.address().to_raw_bytes().to_vec(), dex_type: DexType::WingRidersV1, asset1, asset2, diff --git a/indexer/tasks/src/multiera/multiera_address.rs b/indexer/tasks/src/multiera/multiera_address.rs index e96856d6..144cc3e6 100644 --- a/indexer/tasks/src/multiera/multiera_address.rs +++ b/indexer/tasks/src/multiera/multiera_address.rs @@ -7,14 +7,14 @@ use cml_chain::{ }; use cml_core::serialization::{FromBytes, Serialize, ToBytes}; use cml_crypto::RawBytesEncoding; +use cml_multi_era::allegra::MIRAction; +use cml_multi_era::byron::block::ByronBlock; +use cml_multi_era::utils::MultiEraCertificate; +use cml_multi_era::MultiEraBlock; use entity::{ prelude::*, sea_orm::{prelude::*, DatabaseTransaction}, }; -use pallas::ledger::{ - primitives::{alonzo::Certificate, Fragment}, - traverse::{MultiEraBlock, MultiEraCert, MultiEraOutput, MultiEraTx}, -}; use std::ops::Deref; use crate::types::{AddressCredentialRelationValue, TxCredentialRelationValue}; @@ -27,6 +27,7 @@ use crate::config::EmptyConfig::EmptyConfig; use crate::dsl::database_task::BlockGlobalInfo; use crate::dsl::task_macro::*; +use crate::utils::blake2b256; carp_task! { name MultieraAddressTask; @@ -68,15 +69,17 @@ async fn handle_addresses( let mut queued_address_credential = BTreeSet::::default(); let mut queued_address = BTreeMap::, i64>::default(); - for (tx_body, cardano_transaction) in block.1.txs().iter().zip(multiera_txs) { - for cert in tx_body.certs() { - queue_certificate( - vkey_relation_map, - &mut queued_address_credential, - &mut queued_address, - cardano_transaction.id, - &cert, - ); + for (tx_body, cardano_transaction) in block.1.transaction_bodies().iter().zip(multiera_txs) { + if let Some(certs) = tx_body.certs() { + for cert in certs { + queue_certificate( + vkey_relation_map, + &mut queued_address_credential, + &mut queued_address, + cardano_transaction.id, + &cert, + ); + } } for output in tx_body.outputs() { @@ -105,18 +108,14 @@ async fn handle_addresses( ); } - for withdrawal in tx_body.withdrawals().collect::>() { - let reward_addr = RewardAddress::from_address( - &cml_chain::address::Address::from_bytes(withdrawal.0.into()).unwrap(), - ) - .unwrap(); + for (reward_addr, _) in tx_body.withdrawals().cloned().unwrap_or_default().iter() { queue_address_credential( vkey_relation_map, &mut queued_address_credential, &mut queued_address, cardano_transaction.id, &reward_addr.clone().to_address().to_raw_bytes(), - reward_addr.payment, + reward_addr.payment.clone(), TxCredentialRelationValue::Withdrawal, AddressCredentialRelationValue::PaymentKey, ); @@ -133,15 +132,15 @@ fn queue_certificate( queued_address_credential: &mut BTreeSet, queued_address: &mut BTreeMap, i64>, tx_id: i64, - cert: &MultiEraCert, + cert: &MultiEraCertificate, ) { // TODO: what's the policy for handling options? At the moment of writing, all certificates // are "alonzo-compatible", but that might change in a future HF. Should Carp skip data that // it doesn't understand or instead panic? For now, opting to panic as it seems to be what's // used for other options. - match cert.as_alonzo().unwrap() { - Certificate::StakeDelegation(credential, pool) => { - let credential = credential.encode_fragment().unwrap(); + match cert { + MultiEraCertificate::StakeDelegation(delegation) => { + let credential = delegation.stake_credential.to_canonical_cbor_bytes(); vkey_relation_map.add_relation( tx_id, @@ -151,15 +150,12 @@ fn queue_certificate( vkey_relation_map.add_relation( tx_id, - RelationMap::keyhash_to_pallas( - cml_chain::crypto::Ed25519KeyHash::from_raw_bytes(pool.as_slice()).unwrap(), - ) - .as_slice(), + delegation.pool.to_raw_bytes(), TxCredentialRelationValue::DelegationTarget, ); } - Certificate::StakeRegistration(credential) => { - let credential = credential.encode_fragment().unwrap(); + MultiEraCertificate::StakeRegistration(registration) => { + let credential = registration.stake_credential.to_canonical_cbor_bytes(); vkey_relation_map.add_relation( tx_id, @@ -167,8 +163,8 @@ fn queue_certificate( TxCredentialRelationValue::StakeRegistration, ); } - Certificate::StakeDeregistration(credential) => { - let credential = credential.encode_fragment().unwrap(); + MultiEraCertificate::StakeDeregistration(deregistration) => { + let credential = deregistration.stake_credential.to_canonical_cbor_bytes(); vkey_relation_map.add_relation( tx_id, @@ -176,16 +172,8 @@ fn queue_certificate( TxCredentialRelationValue::StakeDeregistration, ); } - Certificate::PoolRegistration { - operator, - pool_owners, - reward_account, - .. - } => { - let operator_credential = - pallas::ledger::primitives::alonzo::StakeCredential::AddrKeyhash(*operator) - .encode_fragment() - .unwrap(); + MultiEraCertificate::PoolRegistration(registration) => { + let operator_credential = registration.pool_params.operator.to_raw_bytes().to_vec(); vkey_relation_map.add_relation( tx_id, @@ -193,10 +181,7 @@ fn queue_certificate( TxCredentialRelationValue::PoolOperator, ); - let reward_addr = RewardAddress::from_address( - &cml_chain::address::Address::from_bytes(reward_account.to_vec()).unwrap(), - ) - .unwrap(); + let reward_addr = registration.pool_params.reward_account.clone(); queue_address_credential( vkey_relation_map, @@ -209,11 +194,8 @@ fn queue_certificate( AddressCredentialRelationValue::PaymentKey, ); - for &owner in pool_owners.iter() { - let owner_credential = - pallas::ledger::primitives::alonzo::StakeCredential::AddrKeyhash(owner) - .encode_fragment() - .unwrap(); + for &owner in registration.pool_params.pool_owners.iter() { + let owner_credential = owner.to_raw_bytes().to_vec(); vkey_relation_map.add_relation( tx_id, @@ -222,27 +204,25 @@ fn queue_certificate( ); } } - Certificate::PoolRetirement(key_hash, _) => { - let operator_credential = - pallas::ledger::primitives::alonzo::StakeCredential::AddrKeyhash(*key_hash) - .encode_fragment() - .unwrap(); + MultiEraCertificate::PoolRetirement(retirement) => { + let operator_credential = retirement.pool.to_raw_bytes().to_vec(); vkey_relation_map.add_relation( tx_id, &operator_credential, TxCredentialRelationValue::PoolOperator, ); } - Certificate::GenesisKeyDelegation(_, _, _) => { + MultiEraCertificate::GenesisKeyDelegation(_) => { // genesis keys aren't stake credentials } - Certificate::MoveInstantaneousRewardsCert(mir) => { - if let pallas::ledger::primitives::alonzo::InstantaneousRewardTarget::StakeCredentials( - credential_pairs, - ) = &mir.target + MultiEraCertificate::MoveInstantaneousRewardsCert(mir) => { + if let MIRAction::ToStakeCredentials { + to_stake_credentials, + .. + } = &mir.move_instantaneous_reward.action { - for pair in credential_pairs.deref() { - let credential = pair.0.encode_fragment().unwrap(); + for pair in to_stake_credentials.deref() { + let credential = pair.0.to_canonical_cbor_bytes(); vkey_relation_map.add_relation( tx_id, @@ -252,6 +232,18 @@ fn queue_certificate( } } } + MultiEraCertificate::RegCert(_) => {} + MultiEraCertificate::UnregCert(_) => {} + MultiEraCertificate::VoteDelegCert(_) => {} + MultiEraCertificate::StakeVoteDelegCert(_) => {} + MultiEraCertificate::StakeRegDelegCert(_) => {} + MultiEraCertificate::VoteRegDelegCert(_) => {} + MultiEraCertificate::StakeVoteRegDelegCert(_) => {} + MultiEraCertificate::AuthCommitteeHotCert(_) => {} + MultiEraCertificate::ResignCommitteeColdCert(_) => {} + MultiEraCertificate::RegDrepCert(_) => {} + MultiEraCertificate::UnregDrepCert(_) => {} + MultiEraCertificate::UpdateDrepCert(_) => {} }; } @@ -260,21 +252,15 @@ fn queue_output( queued_credentials: &mut RelationMap, queued_address_credential: &mut BTreeSet, queued_address: &mut BTreeMap, i64>, - tx_body: &MultiEraTx, + _tx_body: &cml_multi_era::MultiEraTransactionBody, tx_id: i64, - output: &MultiEraOutput, + output: &cml_multi_era::utils::MultiEraTransactionOutput, output_relation: TxCredentialRelationValue, output_stake_relation: TxCredentialRelationValue, ) { use cml_chain::address::Address; - let pallas_address = output - .address() - .map_err(|e| panic!("{:?} {:?}", e, hex::encode(tx_body.hash()))) - .unwrap(); - let addr = Address::from_bytes(pallas_address.to_vec()) - .map_err(|e| panic!("{:?} {:?}", e, hex::encode(tx_body.hash()))) - .unwrap(); + let addr = output.address(); let address_relation = AddressCredentialRelationValue::PaymentKey; diff --git a/indexer/tasks/src/multiera/multiera_address_delegation.rs b/indexer/tasks/src/multiera/multiera_address_delegation.rs index a74faaae..fd9204fd 100644 --- a/indexer/tasks/src/multiera/multiera_address_delegation.rs +++ b/indexer/tasks/src/multiera/multiera_address_delegation.rs @@ -2,18 +2,13 @@ use crate::{ multiera::multiera_stake_credentials::MultieraStakeCredentialTask, types::{AddressCredentialRelationValue, TxCredentialRelationValue}, }; -use cardano_multiplatform_lib::{ - address::{BaseAddress, EnterpriseAddress, PointerAddress, RewardAddress}, - byron::ByronAddress, -}; +use cml_core::serialization::Serialize; +use cml_crypto::RawBytesEncoding; +use cml_multi_era::utils::MultiEraCertificate; use entity::{ prelude::*, sea_orm::{prelude::*, DatabaseTransaction}, }; -use pallas::ledger::{ - primitives::{alonzo::Certificate, Fragment}, - traverse::{MultiEraBlock, MultiEraCert, MultiEraOutput, MultiEraTx}, -}; use sea_orm::{Order, QueryOrder, Set}; use std::collections::{BTreeMap, BTreeSet}; use std::ops::Deref; @@ -50,22 +45,30 @@ carp_task! { async fn handle( db_tx: &DatabaseTransaction, - block: BlockInfo<'_, MultiEraBlock<'_>, BlockGlobalInfo>, + block: BlockInfo<'_, cml_multi_era::MultiEraBlock, BlockGlobalInfo>, multiera_txs: &[TransactionModel], multiera_stake_credential: &BTreeMap, StakeCredentialModel>, ) -> Result<(), DbErr> { - for (tx_body, cardano_transaction) in block.1.txs().iter().zip(multiera_txs) { - for cert in tx_body.certs() { + for (tx_body, cardano_transaction) in block.1.transaction_bodies().iter().zip(multiera_txs) { + let certs = match tx_body.certs() { + None => continue, + Some(certs) => certs, + }; + for cert in certs { { let tx_id = cardano_transaction.id; let cert = &cert; - let (credential, pool) = match cert.as_alonzo().unwrap() { - Certificate::StakeDelegation(credential, pool) => (credential, Some(pool)), - Certificate::StakeDeregistration(credential) => (credential, None), + let (credential, pool) = match cert { + MultiEraCertificate::StakeDelegation(delegation) => { + (delegation.stake_credential.clone(), Some(delegation.pool)) + } + MultiEraCertificate::StakeDeregistration(deregistration) => { + (deregistration.stake_credential.clone(), None) + } _ => continue, }; - let credential = credential.encode_fragment().unwrap(); + let credential = credential.to_canonical_cbor_bytes(); let stake_credential_id = multiera_stake_credential .get(&credential.to_vec()) @@ -80,7 +83,7 @@ async fn handle( .one(db_tx) .await?; - let pool = pool.map(|pool| pool.to_vec()); + let pool = pool.map(|pool| pool.to_raw_bytes().to_vec()); if let Some((previous, pool)) = previous_entry .as_ref() diff --git a/indexer/tasks/src/multiera/multiera_asset_mint.rs b/indexer/tasks/src/multiera/multiera_asset_mint.rs index 61e9f20a..b55f3fac 100644 --- a/indexer/tasks/src/multiera/multiera_asset_mint.rs +++ b/indexer/tasks/src/multiera/multiera_asset_mint.rs @@ -1,3 +1,4 @@ +use cml_chain::assets::Mint; use std::collections::{BTreeMap, BTreeSet}; use super::utils::common::asset_from_pair; @@ -6,17 +7,13 @@ use crate::config::ReadonlyConfig::ReadonlyConfig; use crate::dsl::database_task::BlockGlobalInfo; use crate::utils::blake2b160; use cml_chain::crypto::ScriptHash; +use cml_core::serialization::Serialize; +use cml_crypto::RawBytesEncoding; use entity::sea_orm::QueryOrder; use entity::{ prelude::*, sea_orm::{prelude::*, Condition, DatabaseTransaction, Set}, }; -use pallas::ledger::primitives::Fragment; -use pallas::ledger::traverse::MultiEraBlock; -use pallas::{ - codec::utils::KeyValuePairs, - ledger::primitives::alonzo::{self, AuxiliaryData, Metadatum, MetadatumLabel}, -}; use crate::dsl::task_macro::*; @@ -29,7 +26,7 @@ carp_task! { read [multiera_block, multiera_txs]; write [multiera_assets]; should_add_task |block, _properties| { - block.1.txs().iter().any(|tx| tx.mint().len() > 0) + block.1.transaction_bodies().iter().any(|tx| tx.mint().map(|mint| mint.len() > 0).unwrap_or(false)) }; execute |previous_data, task| handle_mints( task.db_tx, @@ -49,12 +46,16 @@ async fn handle_mints( readonly: bool, ) -> Result, DbErr> { let mut queued_mints = Vec::<(i64, (Vec, Vec), i64)>::default(); - for (tx_body, cardano_transaction) in block.1.txs().iter().zip(multiera_txs) { - for (policy_id, assets) in tx_body.mint().as_alonzo().iter().flat_map(|x| x.iter()) { + for (tx_body, cardano_transaction) in block.1.transaction_bodies().iter().zip(multiera_txs) { + let mint = match tx_body.mint() { + None => continue, + Some(mint) => mint, + }; + for (policy_id, assets) in mint.iter() { for (asset_name, amount) in assets.iter() { queued_mints.push(( cardano_transaction.id, - (policy_id.to_vec(), asset_name.to_vec()), + (policy_id.to_raw_bytes().to_vec(), asset_name.get().clone()), *amount, )); } diff --git a/indexer/tasks/src/multiera/multiera_asset_utxo.rs b/indexer/tasks/src/multiera/multiera_asset_utxo.rs index 3d12be5d..36e5eaec 100644 --- a/indexer/tasks/src/multiera/multiera_asset_utxo.rs +++ b/indexer/tasks/src/multiera/multiera_asset_utxo.rs @@ -7,20 +7,18 @@ use crate::multiera::dex::common::filter_outputs_and_datums_by_address; use crate::multiera::multiera_txs::MultieraTransactionTask; use crate::multiera::multiera_used_inputs::MultieraUsedInputTask; use crate::multiera::multiera_used_outputs::MultieraOutputTask; +use crate::multiera::utils::common::output_from_bytes; use crate::types::AddressCredentialRelationValue; -use cardano_multiplatform_lib::error::DeserializeError; -use cml_core::serialization::{FromBytes, ToBytes}; +use cml_core::serialization::{Deserialize, FromBytes, Serialize, ToBytes}; use cml_crypto::RawBytesEncoding; +use cml_multi_era::utils::{MultiEraTransactionInput, MultiEraTransactionOutput}; +use entity::block::EraValue; use entity::sea_orm::Condition; use entity::transaction_output::Model; use entity::{ prelude::*, sea_orm::{prelude::*, DatabaseTransaction, Set}, }; -use pallas::ledger::primitives::babbage::DatumOption; -use pallas::ledger::primitives::Fragment; -use pallas::ledger::traverse::{Asset, MultiEraInput, MultiEraOutput}; -use projected_nft_sdk::{Owner, State, Status}; use sea_orm::{FromQueryResult, JoinType, QuerySelect, QueryTrait}; use std::collections::{BTreeSet, HashMap}; @@ -48,7 +46,7 @@ carp_task! { async fn handle( db_tx: &DatabaseTransaction, - block: BlockInfo<'_, MultiEraBlock<'_>, BlockGlobalInfo>, + block: BlockInfo<'_, cml_multi_era::MultiEraBlock, BlockGlobalInfo>, multiera_txs: &[TransactionModel], multiera_outputs: &[TransactionOutputModel], multiera_used_inputs_to_outputs_map: &BTreeMap, BTreeMap>, @@ -71,11 +69,28 @@ async fn handle( .map(|output| ((output.tx_id, output.output_index), output)) .collect(); - for (tx_body, cardano_transaction) in block.1.txs().iter().zip(multiera_txs) { - for input in tx_body.inputs().iter().chain(tx_body.collateral().iter()) { + for (tx_body, cardano_transaction) in block.1.transaction_bodies().iter().zip(multiera_txs) { + let collateral_inputs = tx_body + .collateral_inputs() + .cloned() + .unwrap_or_default() + .into_iter() + .map(MultiEraTransactionInput::Shelley) + .collect::>(); + + for input in tx_body.inputs().iter().chain(collateral_inputs.iter()) { let utxo = multiera_used_inputs_to_outputs_map - .get(input.hash().as_ref()) - .and_then(|by_index| by_index.get(&(input.index() as i64))); + .get( + input + .hash() + .ok_or(DbErr::Custom("can't get hash of input".to_string()))? + .to_raw_bytes(), + ) + .and_then(|by_index| { + input + .index() + .and_then(|index| by_index.get(&(index as i64))) + }); let utxo = if let Some(utxo) = utxo { utxo @@ -94,34 +109,46 @@ async fn handle( continue; }; - let output = MultiEraOutput::decode(utxo.era, &utxo.model.payload).unwrap(); - - for asset in output.non_ada_assets() { - let (policy_id, asset_name, value) = match asset { - Asset::Ada(_) => continue, - Asset::NativeAsset(policy_id, asset_name, value) => { - (policy_id, asset_name, value) - } - }; + let output = output_from_bytes(utxo)?; + let output = match output { + MultiEraTransactionOutput::Byron(_) => { + continue; + } + MultiEraTransactionOutput::Shelley(shelley) => shelley, + }; + for (policy_id, asset_name, value) in + output + .amount() + .multiasset + .iter() + .flat_map(|(policy_id, assets)| { + assets + .iter() + .map(|(asset_name, value)| (*policy_id, asset_name, value)) + }) + { // 0 values were allowed in the serialization of multiassets // before conway. We need to filter these here, because the // asset may not actually be in the assets table. - if value == 0 { + if *value == 0 { continue; } condition = condition.add( Condition::all() - .add(entity::native_asset::Column::PolicyId.eq(policy_id.as_ref())) - .add(entity::native_asset::Column::AssetName.eq(asset_name.clone())), + .add( + entity::native_asset::Column::PolicyId + .eq(policy_id.to_raw_bytes().to_vec()), + ) + .add(entity::native_asset::Column::AssetName.eq(asset_name.get().clone())), ); queued_inserts.push(PartialEntry { utxo_id: utxo.model.id, amount: None, tx_id: cardano_transaction.id, - asset: (policy_id.as_ref().to_vec(), asset_name), + asset: (policy_id.to_raw_bytes().to_vec(), asset_name.get().clone()), }); } } @@ -132,13 +159,7 @@ async fn handle( .chain(tx_body.collateral_return().iter()) .enumerate() { - let address = output - .address() - .map_err(|err| DbErr::Custom(format!("invalid pallas address: {}", err)))? - .to_vec(); - - let address = cardano_multiplatform_lib::address::Address::from_bytes(address) - .map_err(|err| DbErr::Custom(format!("cml can't parse address: {}", err)))?; + let address = output.address(); if address.payment_cred().is_none() { continue; @@ -152,32 +173,45 @@ async fn handle( Some(output) => output, }; - for asset in output.non_ada_assets() { - let (policy_id, asset_name, value) = match asset { - Asset::Ada(_) => continue, - Asset::NativeAsset(policy_id, asset_name, value) => { - (policy_id, asset_name, value) - } - }; + let output = match output { + MultiEraTransactionOutput::Byron(_) => { + continue; + } + MultiEraTransactionOutput::Shelley(shelley) => shelley, + }; + for (policy_id, asset_name, value) in + output + .amount() + .multiasset + .iter() + .flat_map(|(policy_id, assets)| { + assets + .iter() + .map(|(asset_name, value)| (*policy_id, asset_name, value)) + }) + { // 0 values were allowed in the serialization of multiassets // before conway. We need to filter these here, because the // asset may not actually be in the assets table. - if value == 0 { + if *value == 0 { continue; } condition = condition.add( Condition::all() - .add(entity::native_asset::Column::PolicyId.eq(policy_id.as_ref())) - .add(entity::native_asset::Column::AssetName.eq(asset_name.clone())), + .add( + entity::native_asset::Column::PolicyId + .eq(policy_id.to_raw_bytes().to_vec()), + ) + .add(entity::native_asset::Column::AssetName.eq(asset_name.get().clone())), ); queued_inserts.push(PartialEntry { utxo_id: output_model.id, - amount: Some(value as i64), + amount: Some(*value as i64), tx_id: cardano_transaction.id, - asset: (policy_id.as_ref().to_vec(), asset_name), + asset: (policy_id.to_raw_bytes().to_vec(), asset_name.get().clone()), }); } } diff --git a/indexer/tasks/src/multiera/multiera_block.rs b/indexer/tasks/src/multiera/multiera_block.rs index 1b9a5aeb..5f74d611 100644 --- a/indexer/tasks/src/multiera/multiera_block.rs +++ b/indexer/tasks/src/multiera/multiera_block.rs @@ -4,9 +4,6 @@ use crate::dsl::task_macro::*; use crate::era_common::block_from_hash; use crate::utils::blake2b256; use entity::sea_orm::{DatabaseTransaction, Set}; -use pallas::ledger::primitives::alonzo::{self}; -use pallas::ledger::primitives::Fragment; -use pallas::ledger::traverse::MultiEraBlock; carp_task! { name MultieraBlockTask; @@ -36,7 +33,7 @@ async fn handle_block( readonly: bool, include_payload: bool, ) -> Result { - let hash = blake2b256(block.1.header().cbor()); + let hash = block.1.hash(); if readonly { return block_from_hash(db_tx, &hash).await; } @@ -48,9 +45,9 @@ async fn handle_block( let block = BlockActiveModel { era: Set(block.2.era.into()), hash: Set(hash.to_vec()), - height: Set(block.1.number() as i32), + height: Set(block.1.header().block_number() as i32), epoch: Set(block.2.epoch.unwrap() as i32), - slot: Set(block.1.slot() as i32), + slot: Set(block.1.header().slot() as i32), payload: Set(Some(block_payload)), ..Default::default() }; diff --git a/indexer/tasks/src/multiera/multiera_cip25entry.rs b/indexer/tasks/src/multiera/multiera_cip25entry.rs index 5999aa62..84815f1f 100644 --- a/indexer/tasks/src/multiera/multiera_cip25entry.rs +++ b/indexer/tasks/src/multiera/multiera_cip25entry.rs @@ -6,11 +6,8 @@ use entity::{ prelude::*, sea_orm::{prelude::*, Condition, DatabaseTransaction, Set}, }; +use pallas::ledger::primitives::alonzo::Metadatum; use pallas::ledger::primitives::Fragment; -use pallas::{ - codec::utils::KeyValuePairs, - ledger::primitives::alonzo::{self, AuxiliaryData, Metadatum, MetadatumLabel}, -}; use super::{ multiera_asset_mint::MultieraAssetMintTask, @@ -30,7 +27,7 @@ carp_task! { read [multiera_assets, multiera_metadata]; write []; should_add_task |block, _properties| { - block.1.has_aux_data() + !block.1.auxiliary_data_set().is_empty() }; execute |previous_data, task| handle_entries( task.db_tx, diff --git a/indexer/tasks/src/multiera/multiera_datum.rs b/indexer/tasks/src/multiera/multiera_datum.rs index 090213df..58bbe5e5 100644 --- a/indexer/tasks/src/multiera/multiera_datum.rs +++ b/indexer/tasks/src/multiera/multiera_datum.rs @@ -1,3 +1,7 @@ +use cml_chain::transaction::DatumOption; +use cml_core::serialization::Serialize; +use cml_crypto::{DatumHash, RawBytesEncoding}; +use cml_multi_era::utils::MultiEraTransactionOutput; use std::collections::BTreeSet; use super::multiera_txs::MultieraTransactionTask; @@ -12,12 +16,6 @@ use entity::{ prelude::*, sea_orm::{prelude::*, Condition, DatabaseTransaction, JoinType, Set}, }; -use pallas::ledger::primitives::Fragment; -use pallas::ledger::traverse::ComputeHash; -use pallas::ledger::{ - primitives::babbage::{DatumHash, DatumOption}, - traverse::{MultiEraBlock, OutputRef}, -}; use crate::dsl::task_macro::*; @@ -30,9 +28,16 @@ dependencies [MultieraTransactionTask]; read [multiera_txs]; write []; should_add_task |block, _properties| { - block.1.txs().iter().any(|tx| { - !tx.plutus_data().is_empty() || tx.outputs().iter().any(|output| output.datum().is_some()) - }) + block.1.transaction_bodies().iter().any(|tx| { + tx.outputs().iter().any(|output| match output { + MultiEraTransactionOutput::Shelley(output) => output.datum().is_some(), + _ => false, + }) + }) || block.1.transaction_witness_sets().iter().any(|tx| { + tx.plutus_datums.clone() + .map(|datums| !datums.is_empty()) + .unwrap_or(false) + }) }; execute |previous_data, task| handle_datum( task.db_tx, @@ -50,41 +55,58 @@ async fn handle_datum( multiera_txs: &[TransactionModel], readonly: bool, ) -> Result<(), DbErr> { - let mut hash_to_tx = BTreeMap::::new(); + let mut hash_to_tx = BTreeMap::::new(); // recall: tx may contain datum hash only w/ datum only appearing in a later tx - let mut hash_to_data = BTreeMap::>::new(); - for (tx_body, cardano_transaction) in block.1.txs().iter().zip(multiera_txs) { - for datum in tx_body.plutus_data() { - let hash = datum.compute_hash(); + let mut hash_to_data = BTreeMap::>::new(); + for ((tx_body, tx_witness_set), cardano_transaction) in block + .1 + .transaction_bodies() + .iter() + .zip(block.1.transaction_witness_sets().iter()) + .zip(multiera_txs) + { + for datum in tx_witness_set + .plutus_datums + .clone() + .unwrap_or_default() + .iter() + { + let hash = datum.hash(); hash_to_tx .entry(hash) .or_insert_with(|| cardano_transaction.id); hash_to_data .entry(hash) - .or_insert_with(|| datum.encode_fragment().unwrap()); + .or_insert_with(|| datum.to_canonical_cbor_bytes()); } for output in tx_body.outputs().iter() { + let output = match output { + MultiEraTransactionOutput::Byron(_) => { + continue; + } + MultiEraTransactionOutput::Shelley(shelley) => shelley, + }; let datum_option = match output.datum() { - Some(datum) => DatumOption::from(datum.clone()), + Some(datum) => datum, None => { continue; } }; match datum_option { - DatumOption::Hash(hash) => { + DatumOption::Hash { datum_hash, .. } => { hash_to_tx - .entry(hash) + .entry(datum_hash) .or_insert_with(|| cardano_transaction.id); } - DatumOption::Data(datum) => { - let hash = datum.compute_hash(); + DatumOption::Datum { datum, .. } => { + let hash = datum.hash(); hash_to_tx .entry(hash) .or_insert_with(|| cardano_transaction.id); hash_to_data .entry(hash) - .or_insert_with(|| datum.0.encode_fragment().unwrap()); + .or_insert_with(|| datum.to_canonical_cbor_bytes()); } }; } @@ -98,17 +120,16 @@ async fn handle_datum( let mut existing_full_datums = BTreeSet::::new(); // 1) Get hashes that were already in the DB { - let mut found_hashes = - PlutusDataHash::find() - .join(JoinType::LeftJoin, PlutusDataHashRelation::PlutusData.def()) - .filter(Condition::any().add( - PlutusDataHashColumn::Hash.is_in(hash_to_tx.keys().map(|hash| hash.as_ref())), - )) - // TODO: would be more efficient to just select the ID field of PlutusData - // to avoid having to return large datum objects that we just ignore in the SQL query - .select_with(PlutusData) - .all(db_tx) - .await?; + let mut found_hashes = PlutusDataHash::find() + .join(JoinType::LeftJoin, PlutusDataHashRelation::PlutusData.def()) + .filter(Condition::any().add( + PlutusDataHashColumn::Hash.is_in(hash_to_tx.keys().map(|hash| hash.to_raw_bytes())), + )) + // TODO: would be more efficient to just select the ID field of PlutusData + // to avoid having to return large datum objects that we just ignore in the SQL query + .select_with(PlutusData) + .all(db_tx) + .await?; for (datum_hash, datums) in found_hashes.iter() { if !datums.is_empty() { @@ -125,12 +146,12 @@ async fn handle_datum( { let keys_to_add: Vec<&DatumHash> = hash_to_tx .keys() - .filter(|key| !hash_to_id.contains_key(key.as_ref())) + .filter(|key| !hash_to_id.contains_key(key.to_raw_bytes())) .collect(); let to_add: Vec = keys_to_add .iter() .map(|key| PlutusDataHashActiveModel { - hash: Set(key.to_vec()), + hash: Set(key.to_raw_bytes().to_vec()), first_tx: Set(*hash_to_tx.get(key).unwrap()), ..Default::default() }) @@ -141,7 +162,9 @@ async fn handle_datum( panic!( "{} in readonly mode, but unknown Plutus datum hashes were found: {:?}", "MultieraDatumTask", - keys_to_add.iter().map(|key| hex::encode(key.as_ref())) + keys_to_add + .iter() + .map(|key| hex::encode(key.to_raw_bytes())) ); } let mut new_entries = PlutusDataHash::insert_many(to_add) @@ -155,12 +178,12 @@ async fn handle_datum( // 3) Add datum { let to_add = hash_to_data.iter().fold(vec![], |mut acc, next| { - let datum_hash_id = hash_to_id.get(next.0.as_ref()).unwrap(); + let datum_hash_id = hash_to_id.get(next.0.to_raw_bytes()).unwrap(); match existing_full_datums.get(datum_hash_id) { None => { acc.push(PlutusDataActiveModel { id: Set(*datum_hash_id), - data: Set(next.1.encode_fragment().unwrap()), + data: Set(next.1.clone()), }); acc } diff --git a/indexer/tasks/src/multiera/multiera_executor.rs b/indexer/tasks/src/multiera/multiera_executor.rs index 075ba28e..1d26b9f9 100644 --- a/indexer/tasks/src/multiera/multiera_executor.rs +++ b/indexer/tasks/src/multiera/multiera_executor.rs @@ -7,8 +7,6 @@ use crate::execution_plan::ExecutionPlan; use crate::utils::find_task_registry_entry; use crate::utils::TaskPerfAggregator; use entity::sea_orm::{prelude::*, DatabaseTransaction}; -use pallas::ledger::primitives::alonzo; -use pallas::ledger::traverse::MultiEraBlock; use shred::{DispatcherBuilder, World}; use tokio::runtime::Handle; diff --git a/indexer/tasks/src/multiera/multiera_metadata.rs b/indexer/tasks/src/multiera/multiera_metadata.rs index 0a58f211..b4d229bf 100644 --- a/indexer/tasks/src/multiera/multiera_metadata.rs +++ b/indexer/tasks/src/multiera/multiera_metadata.rs @@ -1,3 +1,6 @@ +use cml_chain::auxdata::AuxiliaryData; +use cml_core::metadata::Metadata; +use cml_core::serialization::Serialize; use std::collections::BTreeMap; use crate::config::ReadonlyConfig::ReadonlyConfig; @@ -7,12 +10,6 @@ use entity::{ prelude::*, sea_orm::{prelude::*, DatabaseTransaction, Set}, }; -use pallas::ledger::primitives::Fragment; -use pallas::ledger::traverse::{MultiEraBlock, MultiEraMeta}; -use pallas::{ - codec::utils::KeyValuePairs, - ledger::primitives::alonzo::{self, AuxiliaryData, Metadatum, MetadatumLabel}, -}; use super::multiera_txs::MultieraTransactionTask; @@ -27,7 +24,7 @@ carp_task! { read [multiera_txs]; write [multiera_metadata]; should_add_task |block, _properties| { - block.1.has_aux_data() + !block.1.auxiliary_data_set().is_empty() }; execute |previous_data, task| handle_metadata( task.db_tx, @@ -54,13 +51,20 @@ async fn handle_metadata( .await; } - let mut metadata_map = BTreeMap::::default(); + let mut metadata_map = BTreeMap::::default(); - let txs = block.1.txs(); + let tx_aux_data = block.1.auxiliary_data_set(); - for (idx, tx) in txs.iter().enumerate() { - let tx_id = &multiera_txs[idx].id; - let meta = tx.metadata(); + for (idx, metadata) in tx_aux_data.iter() { + let tx_id = &multiera_txs[*idx as usize].id; + let meta = match metadata { + AuxiliaryData::Conway(data) => match &data.metadata { + None => continue, + Some(metadata) => metadata.clone(), + }, + AuxiliaryData::Shelley(data) => data.clone(), + AuxiliaryData::ShelleyMA(data) => data.transaction_metadata.clone(), + }; if !meta.is_empty() { metadata_map.insert(*tx_id, meta); @@ -74,18 +78,12 @@ async fn handle_metadata( TransactionMetadata::insert_many( metadata_map .iter() - .flat_map(|(tx_id, metadata)| { - metadata - .as_alonzo() - .unwrap() - .iter() - .zip(std::iter::repeat(tx_id)) - }) + .flat_map(|(tx_id, metadata)| metadata.entries.iter().zip(std::iter::repeat(tx_id))) .map( |((label, metadata), tx_id)| TransactionMetadataActiveModel { tx_id: Set(*tx_id), label: Set(label.to_le_bytes().to_vec()), - payload: Set(metadata.encode_fragment().unwrap()), + payload: Set(metadata.to_canonical_cbor_bytes()), ..Default::default() }, ), diff --git a/indexer/tasks/src/multiera/multiera_minswap_v1_mean_price.rs b/indexer/tasks/src/multiera/multiera_minswap_v1_mean_price.rs index 47f16713..ba741232 100644 --- a/indexer/tasks/src/multiera/multiera_minswap_v1_mean_price.rs +++ b/indexer/tasks/src/multiera/multiera_minswap_v1_mean_price.rs @@ -12,7 +12,7 @@ carp_task! { read [multiera_txs, multiera_addresses]; write []; should_add_task |block, _properties| { - block.1.txs().iter().any(|tx| tx.outputs().len() > 0) + block.1.transaction_bodies().iter().any(|tx| !tx.outputs().is_empty()) }; execute |previous_data, task| handle_mean_price( task.db_tx, diff --git a/indexer/tasks/src/multiera/multiera_minswap_v1_swap.rs b/indexer/tasks/src/multiera/multiera_minswap_v1_swap.rs index 807db920..ae4c3496 100644 --- a/indexer/tasks/src/multiera/multiera_minswap_v1_swap.rs +++ b/indexer/tasks/src/multiera/multiera_minswap_v1_swap.rs @@ -12,7 +12,7 @@ carp_task! { read [multiera_txs, multiera_addresses, multiera_used_inputs_to_outputs_map]; write []; should_add_task |block, _properties| { - block.1.txs().iter().any(|tx| tx.outputs().len() > 0) + block.1.transaction_bodies().iter().any(|tx| !tx.outputs().is_empty()) }; execute |previous_data, task| handle_swap( task.db_tx, diff --git a/indexer/tasks/src/multiera/multiera_projected_nft.rs b/indexer/tasks/src/multiera/multiera_projected_nft.rs index 4f5b363e..5fcfa9ef 100644 --- a/indexer/tasks/src/multiera/multiera_projected_nft.rs +++ b/indexer/tasks/src/multiera/multiera_projected_nft.rs @@ -1,11 +1,10 @@ -use cardano_multiplatform_lib::error::DeserializeError; -use cml_core::serialization::FromBytes; -use cml_crypto::RawBytesEncoding; -use pallas::ledger::primitives::alonzo::{Redeemer, RedeemerTag}; -use pallas::ledger::primitives::babbage::DatumOption; -use pallas::ledger::primitives::Fragment; -use pallas::ledger::traverse::{Asset, MultiEraOutput, MultiEraTx}; -use projected_nft_sdk::{Owner, Redeem, State, Status}; +use cardano_projected_nft::{Owner, Redeem, State, Status}; +use cml_chain::plutus::{Redeemer, RedeemerTag}; +use cml_chain::transaction::DatumOption; +use cml_core::serialization::{FromBytes, Serialize}; +use cml_crypto::{Ed25519KeyHash, RawBytesEncoding, TransactionHash}; +use cml_multi_era::utils::MultiEraTransactionOutput; +use cml_multi_era::MultiEraTransactionBody; use sea_orm::{FromQueryResult, JoinType, QuerySelect, QueryTrait}; use std::cmp::Ordering; use std::collections::{BTreeSet, HashMap, HashSet}; @@ -115,7 +114,7 @@ impl ProjectedNftInputsQueryOutputResult { async fn handle_projected_nft( db_tx: &DatabaseTransaction, - block: BlockInfo<'_, MultiEraBlock<'_>, BlockGlobalInfo>, + block: BlockInfo<'_, cml_multi_era::MultiEraBlock, BlockGlobalInfo>, multiera_txs: &[TransactionModel], multiera_outputs: &[TransactionOutputModel], multiera_used_inputs_to_outputs_map: &BTreeMap, BTreeMap>, @@ -129,11 +128,17 @@ async fn handle_projected_nft( let mut queued_projected_nft_records = vec![]; - for (tx_body, cardano_transaction) in block.1.txs().iter().zip(multiera_txs) { + for ((tx_body, tx_witness), cardano_transaction) in block + .1 + .transaction_bodies() + .iter() + .zip(block.1.transaction_witness_sets()) + .zip(multiera_txs) + { // redeemers are needed to identify which of the projected nfts are partial withdrawals - let redeemers = tx_body - .redeemers() - .map(get_projected_nft_redeemers) + let redeemers = tx_witness + .redeemers + .map(|redeemers| get_projected_nft_redeemers(&redeemers)) .unwrap_or(Ok(BTreeMap::new()))?; // partial withdrawals inputs -- inputs which have partial withdraw = true in the redeemer @@ -153,17 +158,11 @@ async fn handle_projected_nft( let mut projected_nft_outputs = Vec::::new(); for (output_index, output) in tx_body.outputs().iter().enumerate() { - let output_address = output - .address() - .map_err(|err| DbErr::Custom(format!("invalid pallas address: {}", err)))? - .to_vec(); + let output_address = output.address(); - let output_address = - cardano_multiplatform_lib::address::Address::from_bytes(output_address) - .map_err(|err| DbErr::Custom(format!("cml can't parse address: {}", err)))?; let output_payment_cred = match output_address.payment_cred() { None => continue, - Some(pk) => pk, + Some(pk) => pk.clone(), }; if output_payment_cred != projected_nft_contract_payment_cred { @@ -182,7 +181,7 @@ async fn handle_projected_nft( // parse the state and fetch projected nft details let projected_nft_data = - extract_operation_and_datum(output, output_model, &partial_withdrawals_inputs); + extract_operation_and_datum(output, output_model, &partial_withdrawals_inputs)?; // if projected nft data is unlocking output that is created via partial withdrawal // then we reduce associated partial withdrawal input balance by the amounts that are being unlocked @@ -351,9 +350,7 @@ fn handle_partial_withdraw( Ok(()) } -fn get_payment_cred( - address: String, -) -> Result { +fn get_payment_cred(address: String) -> Result { let config_address = hex::decode(address).map_err(|err| { DbErr::Custom(format!( "can't decode projected nft config address hex: {:?}", @@ -361,13 +358,13 @@ fn get_payment_cred( )) })?; - let config_address = cardano_multiplatform_lib::address::Address::from_bytes(config_address) + let config_address = cml_chain::address::Address::from_bytes(config_address) .map_err(|err| DbErr::Custom(format!("cml can't parse config address: {:?}", err)))?; match config_address.payment_cred() { None => Err(DbErr::Custom( "provided projected nft config address contains no payment cred".to_string(), )), - Some(pk) => Ok(pk), + Some(pk) => Ok(pk.clone()), } } @@ -426,7 +423,7 @@ async fn get_projected_nft_inputs( } fn handle_claims_and_partial_withdraws( - tx_body: &MultiEraTx, + tx_body: &MultiEraTransactionBody, cardano_transaction: &TransactionModel, redeemers: &BTreeMap, used_projected_nfts: &BTreeMap< @@ -438,20 +435,28 @@ fn handle_claims_and_partial_withdraws( let mut partially_withdrawn = BTreeMap::new(); let mut sorted_inputs = tx_body.inputs(); - sorted_inputs.sort_by(|left, right| match left.hash().cmp(right.hash()) { + sorted_inputs.sort_by(|left, right| match left.hash().cmp(&right.hash()) { Ordering::Less => Ordering::Less, Ordering::Equal => left.index().cmp(&right.index()), Ordering::Greater => Ordering::Greater, }); - for (input_index, input) in sorted_inputs.iter().enumerate() { - let entry = if let Some(entry) = used_projected_nfts.get(&input.hash().to_vec()) { + for (sorted_input_index, input) in sorted_inputs.iter().enumerate() { + let input_hash = match input.hash() { + None => continue, + Some(hash) => hash.to_raw_bytes().to_vec(), + }; + let input_index = match input.index() { + None => continue, + Some(index) => index, + }; + let entry = if let Some(entry) = used_projected_nfts.get(&input_hash) { entry } else { continue; }; - let projected_nfts = if let Some(projected_nfts) = entry.get(&(input.index() as i64)) { + let projected_nfts = if let Some(projected_nfts) = entry.get(&(input_index as i64)) { projected_nfts } else { continue; @@ -477,12 +482,12 @@ fn handle_claims_and_partial_withdraws( }); } if projected_nft.operation == i32::from(ProjectedNftOperation::Lock) { - let redeemer = match redeemers.get(&(input_index as i64)) { + let redeemer = match redeemers.get(&(sorted_input_index as i64)) { None => { tracing::warn!( "No redeemer found for {}, {}", hex::encode(cardano_transaction.hash.clone()), - input_index + sorted_input_index ); continue; } @@ -497,9 +502,9 @@ fn handle_claims_and_partial_withdraws( if !current_input_partial_withrawal.is_empty() { *partially_withdrawn - .entry(input.hash().to_vec()) + .entry(input_hash) .or_insert(BTreeMap::new()) - .entry(input.index() as i64) + .entry(input_index as i64) .or_default() = current_input_partial_withrawal; } } @@ -578,83 +583,81 @@ struct ProjectedNftData { } fn extract_operation_and_datum( - output: &MultiEraOutput, + output: &MultiEraTransactionOutput, output_model: entity::transaction_output::Model, partial_withdrawals: &BTreeMap< Vec, BTreeMap>, >, -) -> ProjectedNftData { +) -> Result { + let output = match output { + MultiEraTransactionOutput::Byron(_) => { + return Err(DbErr::Custom( + "got byron block in projected nft task".to_string(), + )); + } + MultiEraTransactionOutput::Shelley(shelley) => shelley.clone(), + }; let datum_option = match output.datum() { - Some(datum) => DatumOption::from(datum.clone()), + Some(datum) => datum, None => { - return ProjectedNftData { + return Ok(ProjectedNftData { operation: ProjectedNftOperation::NoDatum, ..Default::default() - }; + }); } }; let datum = match datum_option { - DatumOption::Hash(hash) => { - return ProjectedNftData { - plutus_data: hash.to_vec(), + DatumOption::Hash { datum_hash, .. } => { + return Ok(ProjectedNftData { + plutus_data: datum_hash.to_raw_bytes().to_vec(), // the contract expects inline datums only operation: ProjectedNftOperation::NotInlineDatum, ..Default::default() - }; + }); } - DatumOption::Data(datum) => datum.0.encode_fragment().unwrap(), + DatumOption::Datum { datum, .. } => datum, }; - let parsed = match cml_chain::plutus::PlutusData::from_bytes(datum.clone()) { - Ok(parsed) => parsed, - Err(_) => { - return ProjectedNftData { - plutus_data: datum, - operation: ProjectedNftOperation::ParseError, - ..Default::default() - } - } - }; + let datum_bytes = datum.to_cbor_bytes(); - let parsed = match projected_nft_sdk::State::try_from(parsed) { + let parsed = match cardano_projected_nft::State::try_from(datum_bytes.as_slice()) { Ok(parsed) => parsed, Err(_) => { - return ProjectedNftData { - plutus_data: datum, + return Ok(ProjectedNftData { + plutus_data: datum_bytes, operation: ProjectedNftOperation::ParseError, ..Default::default() - } + }); } }; let owner_address = match parsed.owner { - Owner::PKH(pkh) => pkh.to_raw_bytes().to_vec(), + Owner::PKH(pkh) => Ed25519KeyHash::from_hex(&pkh.to_hex()) + .map_err(|_err| DbErr::Custom("can't parse pkh".to_string()))? + .to_raw_bytes() + .to_vec(), Owner::NFT(_, _) => vec![], Owner::Receipt(_) => vec![], }; let non_ada_assets = output - .non_ada_assets() + .amount() + .multiasset .iter() - .map(|asset| match asset { - Asset::Ada(value) => AssetData { - policy_id: "".to_string(), - asset_name: "".to_string(), - amount: *value as i64, - }, - Asset::NativeAsset(policy_id, asset_name, value) => AssetData { - policy_id: hex::encode(policy_id), - asset_name: hex::encode(asset_name.clone()), + .flat_map(|(policy_id, assets)| { + assets.iter().map(|(asset_name, value)| AssetData { + policy_id: policy_id.to_hex(), + asset_name: hex::encode(asset_name.get()), amount: *value as i64, - }, + }) }) .collect::>(); - match parsed.status { + let result = match parsed.status { Status::Locked => ProjectedNftData { address: owner_address, - plutus_data: datum, + plutus_data: datum_bytes, operation: ProjectedNftOperation::Lock, hololocker_utxo_id: output_model.id, non_ada_assets, @@ -664,7 +667,10 @@ fn extract_operation_and_datum( out_ref, for_how_long, } => { - let out_ref_tx_id = out_ref.tx_id.to_raw_bytes().to_vec(); + let out_ref_tx_id = TransactionHash::from_hex(&out_ref.tx_id.to_hex()) + .map_err(|_err| DbErr::Custom("can't parse tx hash".to_string()))? + .to_raw_bytes() + .to_vec(); let partial_withdrawn_from = partial_withdrawals.get(&out_ref_tx_id).and_then(|inner| { if inner.contains_key(&(out_ref.index as i64)) { @@ -678,15 +684,25 @@ fn extract_operation_and_datum( previous_utxo_tx_hash: out_ref_tx_id, previous_utxo_tx_output_index: Some(out_ref.index as i64), address: owner_address, - plutus_data: datum, + plutus_data: datum_bytes, operation: ProjectedNftOperation::Unlocking, - for_how_long: Some(for_how_long as i64), + for_how_long: Some(match for_how_long.as_u64() { + None => { + return Err(DbErr::Custom(format!( + "for how long does not fit into u64 {}", + for_how_long + ))) + } + Some(ok) => ok as i64, + }), hololocker_utxo_id: output_model.id, partial_withdrawn_from_input: partial_withdrawn_from, non_ada_assets, } } - } + }; + + Ok(result) } fn get_projected_nft_redeemers(redeemers: &[Redeemer]) -> Result, DbErr> { @@ -697,11 +713,7 @@ fn get_projected_nft_redeemers(redeemers: &[Redeemer]) -> Result { result.insert(redeemer.index as i64, redeem); } diff --git a/indexer/tasks/src/multiera/multiera_reference_inputs.rs b/indexer/tasks/src/multiera/multiera_reference_inputs.rs index a63a22fc..33b5faed 100644 --- a/indexer/tasks/src/multiera/multiera_reference_inputs.rs +++ b/indexer/tasks/src/multiera/multiera_reference_inputs.rs @@ -7,12 +7,13 @@ use cml_chain::{ address::{BaseAddress, EnterpriseAddress, PointerAddress, RewardAddress}, byron::ByronAddress, }; +use cml_crypto::RawBytesEncoding; +use cml_multi_era::utils::MultiEraTransactionInput; use entity::sea_orm::QueryOrder; use entity::{ prelude::*, sea_orm::{prelude::*, Condition, DatabaseTransaction, Set}, }; -use pallas::ledger::traverse::{MultiEraBlock, MultiEraInput, OutputRef}; use super::{ multiera_used_inputs::add_input_relations, multiera_used_outputs::MultieraOutputTask, @@ -30,7 +31,7 @@ carp_task! { read [multiera_txs]; write [vkey_relation_map]; should_add_task |block, _properties| { - block.1.txs().iter().any(|tx| !tx.reference_inputs().is_empty()) + block.1.transaction_bodies().iter().any(|tx| !tx.reference_inputs().cloned().unwrap_or_default().is_empty()) }; execute |previous_data, task| handle_input( task.db_tx, @@ -44,7 +45,7 @@ carp_task! { } type QueuedInputs = Vec<( - Vec, + Vec, i64, // tx_id )>; @@ -56,13 +57,15 @@ async fn handle_input( readonly: bool, ) -> Result, DbErr> { let mut queued_inputs = QueuedInputs::default(); - let txs = block.1.txs(); + let txs = block.1.transaction_bodies(); for (tx_body, cardano_transaction) in txs.iter().zip(multiera_txs) { let refs = tx_body .reference_inputs() - .iter() - .map(|x| x.output_ref()) + .cloned() + .unwrap_or_default() + .into_iter() + .map(MultiEraTransactionInput::Shelley) .collect(); queued_inputs.push((refs, cardano_transaction.id)); } @@ -106,7 +109,7 @@ async fn handle_input( } pub async fn insert_reference_inputs( - inputs: &[(Vec, i64)], + inputs: &[(Vec, i64)], input_to_output_map: &BTreeMap, BTreeMap>, txn: &DatabaseTransaction, ) -> Result, DbErr> { @@ -121,7 +124,8 @@ pub async fn insert_reference_inputs( .iter() .flat_map(|pair| pair.0.iter().enumerate().zip(std::iter::repeat(pair.1))) .map(|((idx, input), tx_id)| { - let output = &input_to_output_map[&input.hash().to_vec()][&(input.index() as i64)]; + let output = &input_to_output_map[&input.hash().unwrap().to_raw_bytes().to_vec()] + [&(input.index().unwrap() as i64)]; TransactionReferenceInputActiveModel { utxo_id: Set(output.model.id), address_id: Set(output.model.address_id), diff --git a/indexer/tasks/src/multiera/multiera_stake_credentials.rs b/indexer/tasks/src/multiera/multiera_stake_credentials.rs index efcbae06..62f1127b 100644 --- a/indexer/tasks/src/multiera/multiera_stake_credentials.rs +++ b/indexer/tasks/src/multiera/multiera_stake_credentials.rs @@ -1,6 +1,7 @@ use cml_chain::transaction::utils::RequiredSignersSet; use cml_chain::transaction::TransactionWitnessSet; use cml_core::serialization::FromBytes; +use cml_crypto::RawBytesEncoding; use std::collections::{BTreeMap, BTreeSet}; use std::hash::Hash; @@ -18,10 +19,6 @@ use super::{ use crate::config::EmptyConfig::EmptyConfig; use crate::dsl::database_task::BlockGlobalInfo; use crate::dsl::task_macro::*; -use pallas::ledger::{ - primitives::Fragment, - traverse::{MultiEraBlock, MultiEraTx}, -}; carp_task! { name MultieraStakeCredentialTask; @@ -47,45 +44,32 @@ carp_task! { }; } -pub fn to_witness_cbor(tx: &MultiEraTx) -> Vec { - match tx { - MultiEraTx::AlonzoCompatible(x, _) => x.transaction_witness_set.encode_fragment().unwrap(), - MultiEraTx::Babbage(x) => x.transaction_witness_set.encode_fragment().unwrap(), - MultiEraTx::Byron(x) => x.witness.encode_fragment().unwrap(), - _ => panic!("to_witness_cbor - Unhandled tx type"), - } -} - async fn handle_stake_credentials( db_tx: &DatabaseTransaction, block: BlockInfo<'_, cml_multi_era::MultiEraBlock, BlockGlobalInfo>, multiera_txs: &[TransactionModel], vkey_relation_map: &mut RelationMap, ) -> Result, StakeCredentialModel>, DbErr> { - for (tx_body, cardano_transaction) in block.1.txs().iter().zip(multiera_txs) { + for ((tx_body, tx_witness), cardano_transaction) in block + .1 + .transaction_bodies() + .iter() + .zip(block.1.transaction_witness_sets().iter()) + .zip(multiera_txs) + { queue_witness( vkey_relation_map, cardano_transaction.id, - TransactionWitnessSet::from_bytes(to_witness_cbor(tx_body)) - .map_err(|e| { - panic!( - "{:?} {:?} {:?}", - e, - hex::encode(tx_body.hash()), - hex::encode(to_witness_cbor(tx_body)) - ) - }) - .unwrap(), + tx_witness.clone(), ); - for signer in tx_body.required_signers().collect::>() { - let owner_credential = - pallas::ledger::primitives::alonzo::StakeCredential::AddrKeyhash(*signer) - .encode_fragment() - .unwrap(); + for signer in tx_body.required_signers().cloned().unwrap_or_default() { + let owner_credential = cml_chain::certs::Credential::new_pub_key(signer) + .to_raw_bytes() + .to_vec(); vkey_relation_map.add_relation( cardano_transaction.id, - &owner_credential.clone(), + &owner_credential, TxCredentialRelationValue::RequiredSigner, ); } @@ -168,7 +152,7 @@ fn queue_witness( for vkey in vkeys { vkey_relation_map.add_relation( tx_id, - RelationMap::keyhash_to_pallas(vkey.vkey.hash()).as_slice(), + vkey.vkey.hash().to_raw_bytes(), TxCredentialRelationValue::Witness, ); } @@ -177,7 +161,7 @@ fn queue_witness( for script in scripts { vkey_relation_map.add_relation( tx_id, - RelationMap::scripthash_to_pallas(script.hash()).as_slice(), + script.hash().to_raw_bytes(), TxCredentialRelationValue::Witness, ); @@ -185,7 +169,7 @@ fn queue_witness( for vkey_in_script in vkeys_in_script { vkey_relation_map.add_relation( tx_id, - RelationMap::keyhash_to_pallas(vkey_in_script).as_slice(), + vkey_in_script.to_raw_bytes(), TxCredentialRelationValue::InNativeScript, ); } @@ -196,7 +180,7 @@ fn queue_witness( for script in scripts { vkey_relation_map.add_relation( tx_id, - RelationMap::scripthash_to_pallas(script.hash()).as_slice(), + script.hash().to_raw_bytes(), TxCredentialRelationValue::Witness, ); } @@ -205,7 +189,7 @@ fn queue_witness( for script in scripts { vkey_relation_map.add_relation( tx_id, - RelationMap::scripthash_to_pallas(script.hash()).as_slice(), + script.hash().to_raw_bytes(), TxCredentialRelationValue::Witness, ); } diff --git a/indexer/tasks/src/multiera/multiera_sundaeswap_v1_mean_price.rs b/indexer/tasks/src/multiera/multiera_sundaeswap_v1_mean_price.rs index e3e458f2..87d6c179 100644 --- a/indexer/tasks/src/multiera/multiera_sundaeswap_v1_mean_price.rs +++ b/indexer/tasks/src/multiera/multiera_sundaeswap_v1_mean_price.rs @@ -12,7 +12,7 @@ carp_task! { read [multiera_txs, multiera_addresses]; write []; should_add_task |block, _properties| { - block.1.txs().iter().any(|tx| tx.outputs().len() > 0) + block.1.transaction_bodies().iter().any(|tx| !tx.outputs().is_empty()) }; execute |previous_data, task| handle_mean_price( task.db_tx, diff --git a/indexer/tasks/src/multiera/multiera_sundaeswap_v1_swap.rs b/indexer/tasks/src/multiera/multiera_sundaeswap_v1_swap.rs index 2481b02c..7fcdfe20 100644 --- a/indexer/tasks/src/multiera/multiera_sundaeswap_v1_swap.rs +++ b/indexer/tasks/src/multiera/multiera_sundaeswap_v1_swap.rs @@ -12,7 +12,7 @@ carp_task! { read [multiera_txs, multiera_addresses, multiera_used_inputs_to_outputs_map]; write []; should_add_task |block, _properties| { - block.1.txs().iter().any(|tx| tx.outputs().len() > 0) + block.1.transaction_bodies().iter().any(|tx| !tx.outputs().is_empty()) }; execute |previous_data, task| handle_swap( task.db_tx, diff --git a/indexer/tasks/src/multiera/multiera_txs.rs b/indexer/tasks/src/multiera/multiera_txs.rs index c75f23d0..cba8d224 100644 --- a/indexer/tasks/src/multiera/multiera_txs.rs +++ b/indexer/tasks/src/multiera/multiera_txs.rs @@ -1,4 +1,5 @@ -use std::collections::BTreeSet; +use cml_core::serialization::Serialize; +use std::collections::{BTreeSet, HashSet}; use super::multiera_block::MultieraBlockTask; use crate::config::PayloadAndReadonlyConfig::PayloadAndReadonlyConfig; @@ -6,9 +7,6 @@ use crate::dsl::database_task::BlockGlobalInfo; use crate::dsl::task_macro::*; use crate::era_common::transactions_from_hashes; use entity::sea_orm::{DatabaseTransaction, QueryOrder, Set}; -use pallas::ledger::primitives::alonzo::{self}; -use pallas::ledger::primitives::Fragment; -use pallas::ledger::traverse::MultiEraBlock; carp_task! { name MultieraTransactionTask; @@ -45,7 +43,7 @@ async fn handle_tx( db_tx, block .1 - .txs() + .transaction_bodies() .iter() .map(|tx_body| tx_body.hash().to_vec()) .collect::>() @@ -55,19 +53,30 @@ async fn handle_tx( return txs; } + let invalid_txs: HashSet = HashSet::from_iter( + block + .1 + .invalid_transactions() + .into_iter() + .map(|index| index as usize), + ); let txs: Vec = block .1 - .txs() + .transaction_bodies() .iter() .enumerate() .map(|(idx, tx)| { - let tx_payload = if include_payload { tx.encode() } else { vec![] }; + let tx_payload = if include_payload { + tx.to_canonical_cbor_bytes() + } else { + vec![] + }; TransactionActiveModel { hash: Set(tx.hash().to_vec()), block_id: Set(database_block.id), tx_index: Set(idx as i32), payload: Set(tx_payload), - is_valid: Set(tx.is_valid()), + is_valid: Set(!invalid_txs.contains(&idx)), ..Default::default() } }) diff --git a/indexer/tasks/src/multiera/multiera_unused_input.rs b/indexer/tasks/src/multiera/multiera_unused_input.rs index ae726fef..9bddc303 100644 --- a/indexer/tasks/src/multiera/multiera_unused_input.rs +++ b/indexer/tasks/src/multiera/multiera_unused_input.rs @@ -4,11 +4,11 @@ use super::{ }; use crate::dsl::database_task::BlockGlobalInfo; use crate::{config::EmptyConfig::EmptyConfig, types::TxCredentialRelationValue}; +use cml_multi_era::utils::MultiEraTransactionInput; use entity::{ prelude::*, sea_orm::{prelude::*, DatabaseTransaction}, }; -use pallas::ledger::traverse::{MultiEraBlock, OutputRef}; use crate::dsl::task_macro::*; @@ -22,7 +22,7 @@ carp_task! { write [vkey_relation_map]; should_add_task |block, _properties| { // if any txs has collateral defined, then it has some unused input (either collateral or main inputs if tx failed) - block.1.txs().iter().any(|tx| tx.collateral().len() > 0) + block.1.transaction_bodies().iter().any(|tx| !tx.collateral_inputs().cloned().unwrap_or_default().is_empty()) }; execute |previous_data, task| handle_unused_input( task.db_tx, @@ -34,7 +34,7 @@ carp_task! { }; } -type QueuedInputs = Vec<(Vec, i64)>; +type QueuedInputs = Vec<(Vec, i64)>; async fn handle_unused_input( db_tx: &DatabaseTransaction, @@ -43,11 +43,11 @@ async fn handle_unused_input( vkey_relation_map: &mut RelationMap, ) -> Result<(), DbErr> { let mut queued_unused_inputs = QueuedInputs::default(); - let txs = block.1.txs(); + let txs = block.1.transaction_bodies(); for (tx_body, cardano_transaction) in txs.iter().zip(multiera_txs) { if !cardano_transaction.is_valid { - let refs = tx_body.inputs().iter().map(|x| x.output_ref()).collect(); + let refs = tx_body.inputs(); queued_unused_inputs.push((refs, cardano_transaction.id)) } @@ -55,9 +55,11 @@ async fn handle_unused_input( // note: we consider collateral as just another kind of input instead of a separate table // you can use the is_valid field to know what kind of input it actually is let refs = tx_body - .collateral() - .iter() - .map(|x| x.output_ref()) + .collateral_inputs() + .cloned() + .unwrap_or_default() + .into_iter() + .map(MultiEraTransactionInput::Shelley) .collect(); queued_unused_inputs.push((refs, cardano_transaction.id)) } diff --git a/indexer/tasks/src/multiera/multiera_used_inputs.rs b/indexer/tasks/src/multiera/multiera_used_inputs.rs index 88fbca3b..83a3fe43 100644 --- a/indexer/tasks/src/multiera/multiera_used_inputs.rs +++ b/indexer/tasks/src/multiera/multiera_used_inputs.rs @@ -9,11 +9,12 @@ use cml_chain::{ byron::ByronAddress, }; use cml_core::serialization::{FromBytes, ToBytes}; +use cml_crypto::RawBytesEncoding; +use cml_multi_era::utils::MultiEraTransactionInput; use entity::{ prelude::*, sea_orm::{prelude::*, DatabaseTransaction}, }; -use pallas::ledger::traverse::{MultiEraBlock, MultiEraInput, OutputRef}; use super::{multiera_used_outputs::MultieraOutputTask, relation_map::RelationMap}; @@ -45,7 +46,7 @@ carp_task! { } type QueuedInputs = Vec<( - Vec, + Vec, i64, // tx_id )>; @@ -63,19 +64,21 @@ async fn handle_input( DbErr, > { let mut queued_inputs = QueuedInputs::default(); - let txs = block.1.txs(); + let txs = block.1.transaction_bodies(); for (tx_body, cardano_transaction) in txs.iter().zip(multiera_txs) { if cardano_transaction.is_valid { - let refs = tx_body.inputs().iter().map(|x| x.output_ref()).collect(); + let refs = tx_body.inputs(); queued_inputs.push((refs, cardano_transaction.id)); } if !cardano_transaction.is_valid { let refs = tx_body - .collateral() - .iter() - .map(|x| x.output_ref()) + .collateral_inputs() + .cloned() + .unwrap_or_default() + .into_iter() + .map(MultiEraTransactionInput::Shelley) .collect(); queued_inputs.push((refs, cardano_transaction.id)) } @@ -130,7 +133,7 @@ async fn handle_input( pub fn add_input_relations( vkey_relation_map: &mut RelationMap, - inputs: &[(Vec, i64)], + inputs: &[(Vec, i64)], outputs: &[&TransactionOutputModel], input_to_output_map: &BTreeMap, BTreeMap>, input_relation: TxCredentialRelationValue, @@ -139,13 +142,17 @@ pub fn add_input_relations( let mut output_to_input_tx = BTreeMap::::default(); for input_tx_pair in inputs.iter() { for input in input_tx_pair.0.iter() { - match input_to_output_map.get(&input.hash().to_vec()) { + match input_to_output_map.get(&input.hash().unwrap().to_raw_bytes().to_vec()) { Some(entry_for_tx) => { - let output = &entry_for_tx[&(input.index() as i64)]; + let output = &entry_for_tx[&(input.index().unwrap() as i64)]; output_to_input_tx.insert(output.model.id, input_tx_pair.1); } None => { - panic!("tx: {} index:{}", input.hash(), input.index()); + panic!( + "tx: {} index:{}", + input.hash().unwrap().to_hex(), + input.index().unwrap() + ); } } } diff --git a/indexer/tasks/src/multiera/multiera_used_outputs.rs b/indexer/tasks/src/multiera/multiera_used_outputs.rs index 658d5198..fa16a6ce 100644 --- a/indexer/tasks/src/multiera/multiera_used_outputs.rs +++ b/indexer/tasks/src/multiera/multiera_used_outputs.rs @@ -1,13 +1,12 @@ +use cml_core::serialization::{Serialize, ToBytes}; +use cml_multi_era::utils::MultiEraTransactionOutput; +use cml_multi_era::MultiEraTransactionBody; use std::collections::BTreeMap; use entity::{ prelude::*, sea_orm::{prelude::*, DatabaseTransaction, Set}, }; -use pallas::ledger::{ - primitives::Fragment, - traverse::{MultiEraBlock, MultiEraOutput, MultiEraTx}, -}; use super::multiera_address::MultieraAddressTask; use crate::config::ReadonlyConfig::ReadonlyConfig; @@ -26,7 +25,7 @@ carp_task! { write [multiera_outputs]; should_add_task |block, _properties| { // recall: txs may have no outputs if they just burn all inputs as fee - block.1.txs().iter().any(|tx| tx.outputs().len() > 0) + block.1.transaction_bodies().iter().any(|tx| !tx.outputs().is_empty()) }; execute |previous_data, task| handle_output( task.db_tx, @@ -58,7 +57,7 @@ async fn handle_output( ) -> Result, DbErr> { let mut queued_output = Vec::::default(); - for (tx_body, cardano_transaction) in block.1.txs().iter().zip(multiera_txs) { + for (tx_body, cardano_transaction) in block.1.transaction_bodies().iter().zip(multiera_txs) { let outputs = tx_body.outputs(); if cardano_transaction.is_valid { for (idx, output) in outputs.iter().enumerate() { @@ -72,12 +71,12 @@ async fn handle_output( } } if !cardano_transaction.is_valid { - if let Some(output) = tx_body.collateral_return().as_ref() { + if let Some(output) = tx_body.collateral_return() { queue_output( &mut queued_output, tx_body, cardano_transaction.id, - output, + &output, // only one collateral output is allowed // and its index is output.len() outputs.len(), @@ -103,19 +102,19 @@ async fn handle_output( fn queue_output( queued_output: &mut Vec, - tx_body: &MultiEraTx<'_>, + _tx_body: &MultiEraTransactionBody, tx_id: i64, - output: &MultiEraOutput, + output: &MultiEraTransactionOutput, idx: usize, ) { - let addr = output - .address() - .map_err(|e| panic!("{:?} {:?}", e, hex::encode(tx_body.hash()))) - .unwrap(); + let addr = output.address(); queued_output.push(QueuedOutput { - payload: output.encode(), - address: addr.to_vec(), + payload: match output { + MultiEraTransactionOutput::Byron(byron) => byron.to_bytes(), + MultiEraTransactionOutput::Shelley(shelley) => shelley.to_canonical_cbor_bytes(), + }, + address: addr.to_raw_bytes().to_vec(), tx_id, idx, }); diff --git a/indexer/tasks/src/multiera/multiera_wingriders_v1_mean_price.rs b/indexer/tasks/src/multiera/multiera_wingriders_v1_mean_price.rs index 2ccb0828..de7199ed 100644 --- a/indexer/tasks/src/multiera/multiera_wingriders_v1_mean_price.rs +++ b/indexer/tasks/src/multiera/multiera_wingriders_v1_mean_price.rs @@ -4,13 +4,8 @@ use super::utils::common::{ use super::{multiera_address::MultieraAddressTask, utils::common::asset_from_pair}; use crate::config::EmptyConfig::EmptyConfig; use crate::multiera::dex::common::{handle_mean_price, DexType}; -use pallas::ledger::primitives::alonzo; use crate::dsl::task_macro::*; -use pallas::ledger::{ - primitives::{alonzo::Certificate, Fragment}, - traverse::{MultiEraBlock, MultiEraCert, MultiEraOutput, MultiEraTx}, -}; carp_task! { name MultieraWingRidersV1MeanPriceTask; @@ -21,7 +16,7 @@ carp_task! { read [multiera_txs, multiera_addresses]; write []; should_add_task |block, _properties| { - block.1.txs().iter().any(|tx| tx.outputs().len() > 0) + block.1.transaction_bodies().iter().any(|tx| !tx.outputs().is_empty()) }; execute |previous_data, task| handle_mean_price( task.db_tx, diff --git a/indexer/tasks/src/multiera/multiera_wingriders_v1_swap.rs b/indexer/tasks/src/multiera/multiera_wingriders_v1_swap.rs index a856e50f..6fd1ba22 100644 --- a/indexer/tasks/src/multiera/multiera_wingriders_v1_swap.rs +++ b/indexer/tasks/src/multiera/multiera_wingriders_v1_swap.rs @@ -12,7 +12,7 @@ carp_task! { read [multiera_txs, multiera_addresses, multiera_used_inputs_to_outputs_map]; write []; should_add_task |block, _properties| { - block.1.txs().iter().any(|tx| tx.outputs().len() > 0) + block.1.transaction_bodies().iter().any(|tx| !tx.outputs().is_empty()) }; execute |previous_data, task| handle_swap( task.db_tx, diff --git a/indexer/tasks/src/multiera/relation_map.rs b/indexer/tasks/src/multiera/relation_map.rs index 086c5ba7..0f105899 100644 --- a/indexer/tasks/src/multiera/relation_map.rs +++ b/indexer/tasks/src/multiera/relation_map.rs @@ -1,27 +1,13 @@ use crate::types::TxCredentialRelationValue; use cml_chain::certs::Credential; use cml_core::serialization::ToBytes; -use pallas::crypto::hash::Hash; use std::collections::BTreeMap; #[derive(Default)] -pub struct RelationMap(pub BTreeMap, i32>>); +pub struct RelationMap(pub BTreeMap, i32>>); impl RelationMap { - pub fn bytes_to_pallas(bytes: &[u8]) -> Hash<32> { - let bytes: [u8; 32] = bytes.try_into().unwrap(); - Hash::<32>::from(bytes) - } - - pub fn keyhash_to_pallas(keyhash: cml_chain::crypto::Ed25519KeyHash) -> Hash<32> { - RelationMap::bytes_to_pallas(Credential::new_pub_key(keyhash).to_raw_bytes()) - } - - pub fn scripthash_to_pallas(script_hash: cml_chain::crypto::ScriptHash) -> Hash<32> { - RelationMap::bytes_to_pallas(Credential::new_script(script_hash).to_raw_bytes()) - } - - pub fn for_transaction(&mut self, tx_id: i64) -> &mut BTreeMap, i32> { + pub fn for_transaction(&mut self, tx_id: i64) -> &mut BTreeMap, i32> { self.0.entry(tx_id).or_default() } @@ -34,7 +20,7 @@ impl RelationMap { let relation_int = i32::from(relation); let credential_map = self.for_transaction(tx_id); credential_map - .entry(RelationMap::bytes_to_pallas(stake_credential)) + .entry(stake_credential.to_vec()) .and_modify(|val| *val |= relation_int) .or_insert(relation_int); } diff --git a/indexer/tasks/src/multiera/utils/common.rs b/indexer/tasks/src/multiera/utils/common.rs index e0742fe1..59a7c566 100644 --- a/indexer/tasks/src/multiera/utils/common.rs +++ b/indexer/tasks/src/multiera/utils/common.rs @@ -1,64 +1,84 @@ +use cml_chain::certs::Credential; +use cml_chain::transaction::DatumOption; +use cml_core::serialization::{Deserialize, Serialize, ToBytes}; +use cml_crypto::RawBytesEncoding; +use cml_multi_era::utils::{MultiEraTransactionInput, MultiEraTransactionOutput}; use std::collections::BTreeSet; +use crate::era_common::OutputWithTxData; +use entity::block::EraValue; use entity::{ prelude::*, sea_orm::{entity::*, prelude::*, Condition, DatabaseTransaction}, }; -use pallas::{ - codec::utils::KeepRaw, - crypto::hash::Hasher, - ledger::{ - addresses, - primitives::{alonzo, babbage::DatumOption}, - traverse::{Asset, MultiEraOutput}, - }, -}; use crate::types::AssetPair; +use crate::utils::blake2b256; + +pub fn get_shelley_payment_hash(address: cml_chain::address::Address) -> Option { + let payment = match address { + cml_chain::address::Address::Base(address) => address.payment, + // idk whether we should parse it here or not + cml_chain::address::Address::Ptr(address) => address.payment, + cml_chain::address::Address::Enterprise(address) => address.payment, + // reward address is a staking address + cml_chain::address::Address::Reward(_) => return None, + cml_chain::address::Address::Byron(_) => return None, + }; -pub fn get_shelley_payment_hash( - address: Result, -) -> Option { - if let Ok(addresses::Address::Shelley(shelley_address)) = address { - Some(hex::encode(shelley_address.payment().as_hash())) - } else { - None + match payment { + Credential::PubKey { hash, .. } => Some(hash.to_hex()), + Credential::Script { hash, .. } => Some(hash.to_hex()), } } -pub fn get_asset_amount(output: &MultiEraOutput, pair: &AssetPair) -> u64 { - output - .assets() - .iter() - .filter(|asset| match &asset { - Asset::Ada(_quantity) => pair.is_none(), - Asset::NativeAsset(policy_id, asset_name, _quantity) => { - pair == &Some((policy_id.to_vec(), asset_name.to_vec())) - } - }) - .map(|asset| match &asset { - Asset::Ada(quantity) => quantity, - Asset::NativeAsset(_, _, quantity) => quantity, - }) - .sum() +pub fn get_asset_amount( + output: &cml_multi_era::utils::MultiEraTransactionOutput, + pair: &AssetPair, +) -> u64 { + match pair { + None => output.amount().coin, + Some((pair_policy_id, pair_asset_name)) => output + .amount() + .multiasset + .iter() + .flat_map(|(policy_id, assets)| { + assets + .iter() + .map(|(asset_name, value)| (*policy_id, asset_name, value)) + }) + .filter(|(policy_id, asset_name, _value)| { + policy_id.to_raw_bytes() == pair_policy_id && asset_name.get() == pair_asset_name + }) + .map(|(_policy_id, _asset_name, value)| value) + .sum(), + } } pub fn get_plutus_datum_for_output( - output: &MultiEraOutput, - plutus_data: &[&KeepRaw], -) -> Option { + output: &cml_multi_era::utils::MultiEraTransactionOutput, + plutus_data: &[cml_chain::plutus::PlutusData], +) -> Option { + let output = match output { + MultiEraTransactionOutput::Byron(_) => { + return None; + } + MultiEraTransactionOutput::Shelley(output) => output, + }; + let datum_option = match output.datum() { - Some(datum) => DatumOption::from(datum), + Some(datum) => datum, None => { return None; } }; + match datum_option { - DatumOption::Data(datum) => Some(datum.0), - DatumOption::Hash(hash) => plutus_data + DatumOption::Datum { datum, .. } => Some(datum), + DatumOption::Hash { datum_hash, .. } => plutus_data .iter() - .find(|datum| Hasher::<256>::hash_cbor(datum) == hash) - .map(|&d| d.clone().unwrap()), + .find(|datum| datum.hash() == datum_hash) + .cloned(), } } @@ -82,3 +102,21 @@ pub async fn asset_from_pair( .await?; Ok(assets) } + +pub fn output_from_bytes(utxo: &OutputWithTxData) -> Result { + let output = match utxo.era { + EraValue::Byron => MultiEraTransactionOutput::Byron( + cml_chain::byron::ByronTxOut::from_cbor_bytes(&utxo.model.payload).map_err(|err| { + DbErr::Custom(format!("can't decode byron output payload: {err}")) + })?, + ), + _ => MultiEraTransactionOutput::Shelley( + cml_chain::transaction::TransactionOutput::from_cbor_bytes(&utxo.model.payload) + .map_err(|err| { + DbErr::Custom(format!("can't decode shelley output payload: {err}")) + })?, + ), + }; + + Ok(output) +}