diff --git a/LICENSE b/LICENSE index 0540392a..1a5f9569 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 EMURGO +Copyright (c) 2020 MitchyCola Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index ad335f3a..d8d9a5df 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ This is a library, written in Rust, for serialization & deserialization of data ##### NPM packages -- [NodeJS WASM package](https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-nodejs) -- [Browser (chrome/firefox) WASM package](https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-browser) -- [Browser (pure JS - no WASM) ASM.js package](https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-asmjs) +- [NodeJS WASM package](https://www.npmjs.com/package/@mitchycola/cardano-serialization-lib-nodejs) +- [Browser (chrome/firefox) WASM package](https://www.npmjs.com/package/@mitchycola/cardano-serialization-lib-browser) +- [Browser (pure JS - no WASM) ASM.js package](https://www.npmjs.com/package/@mitchycola/cardano-serialization-lib-asmjs) ##### Rust crates diff --git a/README.rst b/README.rst index ba0b3ea3..3cf0fc40 100644 --- a/README.rst +++ b/README.rst @@ -118,9 +118,9 @@ To publish new versions to NPM (only needed if you are an admin of this project) npm run js:publish-browser npm run js:publish-asm -.. _NodeJS WASM package: https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-nodejs -.. _Browser (chrome/firefox) WASM package: https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-browser -.. _Browser (pure JS - no WASM) ASM.js package: https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-asmjs +.. _NodeJS WASM package: https://www.npmjs.com/package/@mitchycola/cardano-serialization-lib-nodejs +.. _Browser (chrome/firefox) WASM package: https://www.npmjs.com/package/@mitchycola/cardano-serialization-lib-browser +.. _Browser (pure JS - no WASM) ASM.js package: https://www.npmjs.com/package/@mitchycola/cardano-serialization-lib-asmjs .. _React-Native mobile bindings: https://github.com/Emurgo/react-native-haskell-shelley .. _cddl-codegen: https://github.com/Emurgo/cddl-codegen .. _Typescript: https://www.typescriptlang.org/ @@ -128,6 +128,6 @@ To publish new versions to NPM (only needed if you are an admin of this project) .. _here: /rust/pkg/cardano_serialization_lib.js.flow .. _example: /example .. _Byron WASM bindings: https://github.com/input-output-hk/js-cardano-wasm/tree/master/cardano-wallet -.. _Jormungandr WASM bindings: https://github.com/emurgo/js-chain-libs +.. _Jormungandr WASM bindings: https://github.com/mitchycola/js-chain-libs .. _CDDL: http://cbor.io/tools.html .. _link: https://github.com/input-output-hk/cardano-ledger-specs/tree/master/byron/cddl-spec diff --git a/doc/conf.py b/doc/conf.py index 6dc2f311..623ef299 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -22,8 +22,8 @@ # -- Project information ----------------------------------------------------- project = 'cardano-serialization-lib Documentation' -copyright = '2020, EMURGO' -author = 'EMURGO' +copyright = '2020, MitchyCola' +author = 'MitchyCola' # The full version, including alpha/beta/rc tags release = '1.0.0' diff --git a/doc/getting-started/minting-nfts.md b/doc/getting-started/minting-nfts.md index ff4dd6c8..ae4c6d16 100644 --- a/doc/getting-started/minting-nfts.md +++ b/doc/getting-started/minting-nfts.md @@ -6,7 +6,7 @@ This example mints nfts directly to an account on testnet. code taken from (here)[https://github.com/ozgrakkurt/cardano-mint-nft] ```javascript -import CardanoWasm from "@emurgo/cardano-serialization-lib-nodejs"; +import CardanoWasm from "@mitchycola/cardano-serialization-lib-nodejs"; import axios from "axios"; import cbor from "cbor"; diff --git a/example/package.json b/example/package.json index 15052617..a26c8f71 100644 --- a/example/package.json +++ b/example/package.json @@ -12,15 +12,15 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/Emurgo/cardano-serialization-lib.git" + "url": "git+https://github.comMitchyCola/cardano-serialization-lib.git" }, - "author": "EMURGO", + "author": "MitchyCola", "license": "MIT", "bugs": { - "url": "https://github.com/Emurgo/cardano-serialization-lib/issues" + "url": "https://github.comMitchyCola/cardano-serialization-lib/issues" }, "type": "module", - "homepage": "https://github.com/Emurgo/cardano-serialization-lib#readme", + "homepage": "https://github.comMitchyCola/cardano-serialization-lib#readme", "dependencies": {}, "devDependencies": { "@types/chai": "4.2.11", diff --git a/package.json b/package.json index 85b0d90d..2ee7190b 100644 --- a/package.json +++ b/package.json @@ -27,11 +27,11 @@ "pre-push": "npm run rust:test && npm run rust:build-nodejs" } }, - "author": "EMURGO", + "author": "MitchyCola", "license": "MIT", "repository": { "type": "git", - "url": "git+https://github.com/Emurgo/cardano-serialization-lib.git" + "url": "git+https://github.comMitchyCola/cardano-serialization-lib.git" }, "devDependencies": { "flowgen": "1.11.0", diff --git a/rust/Cargo.lock b/rust/Cargo.lock new file mode 100644 index 00000000..d37e1fc4 --- /dev/null +++ b/rust/Cargo.lock @@ -0,0 +1,736 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "autocfg" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" +dependencies = [ + "autocfg 1.1.0", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bech32" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dabbe35f96fb9507f7330793dc490461b2962659ac5d427181e451a623751d1" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + +[[package]] +name = "cardano-serialization-lib" +version = "11.2.1" +dependencies = [ + "bech32", + "cbor_event", + "cfg-if", + "clear_on_drop", + "cryptoxide", + "digest", + "ed25519-bip32", + "getrandom 0.2.8", + "hex", + "indexmap", + "itertools", + "js-sys", + "linked-hash-map", + "noop_proc_macro", + "num-bigint", + "num-integer", + "quickcheck", + "quickcheck_macros", + "rand 0.8.5", + "rand_chacha 0.1.1", + "rand_os", + "schemars", + "serde", + "serde-wasm-bindgen", + "serde_json", + "sha2", + "wasm-bindgen", +] + +[[package]] +name = "cbor_event" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52b3d8b289b6c7d6d8832c8e2bf151c7677126afa627f51e19a6320aec8237cb" + +[[package]] +name = "cc" +version = "1.0.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clear_on_drop" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38508a63f4979f0048febc9966fadbd48e5dab31fd0ec6a3f151bbf4a74f7423" +dependencies = [ + "cc", +] + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "cryptoxide" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "129eabb7b0b78644a3a7e7cf220714aba47463bb281f69fa7a71ca5d12564cca" + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "dyn-clone" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" + +[[package]] +name = "ed25519-bip32" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb588f93c0d91b2f668849fd6d030cddb0b2e31f105963be189da5acdf492a21" +dependencies = [ + "cryptoxide", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg 1.1.0", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg 1.1.0", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg 1.1.0", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg 1.1.0", +] + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quickcheck" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f" +dependencies = [ + "env_logger", + "log", + "rand 0.7.3", + "rand_core 0.5.1", +] + +[[package]] +name = "quickcheck_macros" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608c156fd8e97febc07dc9c2e2c80bf74cfc6ef26893eae3daf8bc2bc94a4b7f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +dependencies = [ + "autocfg 0.1.8", + "rand_core 0.3.1", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.8", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "regex" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "schemars" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a5fb6c61f29e723026dc8e923d94c694313212abbecbbe5f55a7748eec5b307" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f188d036977451159430f3b8dc82ec76364a42b7e289c2b18a9a18f4470058e9" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + +[[package]] +name = "serde" +version = "1.0.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e326c9ec8042f1b5da33252c8a37e9ffbd2c9bef0155215b6e6c80c790e05f91" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-wasm-bindgen" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b4c031cd0d9014307d82b8abf653c0290fbdaeb4c02d00c63cf52f728628bf" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "serde_derive" +version = "1.0.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42a3df25b0713732468deadad63ab9da1f1fd75a48a15024b50363f128db627e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_derive_internals" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer", + "cfg-if", + "cpufeatures", + "digest", + "opaque-debug", +] + +[[package]] +name = "syn" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 72f8118a..4d5f03bb 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -2,11 +2,11 @@ name = "cardano-serialization-lib" version = "11.2.1" edition = "2018" -authors = ["EMURGO"] +authors = ["MitchyCola"] license = "MIT" description = "(De)serialization functions for the Cardano blockchain along with related utility functions" documentation = "https://docs.cardano.org/cardano-components/cardano-serialization-lib" -repository = "https://github.com/Emurgo/cardano-serialization-lib" +repository = "https://github.comMitchyCola/cardano-serialization-lib" readme="../README.md" exclude = [ "pkg/*", @@ -35,6 +35,7 @@ itertools = "0.10.1" rand = "0.8.4" schemars = "0.8.8" serde = { version = "1.0", features = ["derive"] } +indexmap = "1.9.2" # non-wasm [target.'cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))'.dependencies] diff --git a/rust/json-gen/Cargo.toml b/rust/json-gen/Cargo.toml index 43a104e8..7f025871 100644 --- a/rust/json-gen/Cargo.toml +++ b/rust/json-gen/Cargo.toml @@ -2,7 +2,7 @@ name = "cardano-serialization-lib-json-schema-gen" version = "0.0.1" edition = "2018" -authors = ["EMURGO"] +authors = ["MitchyCola"] license = "MIT" diff --git a/rust/pkg/cardano_serialization_lib.js.flow b/rust/pkg/cardano_serialization_lib.js.flow index 4ba6668d..7c3266fd 100644 --- a/rust/pkg/cardano_serialization_lib.js.flow +++ b/rust/pkg/cardano_serialization_lib.js.flow @@ -1,7 +1,7 @@ /** * Flowtype definitions for cardano_serialization_lib * Generated by Flowgen from a Typescript Definition - * Flowgen v1.11.0 + * Flowgen v1.20.1 * @flow */ @@ -88,42 +88,6 @@ declare export function min_script_fee( ex_unit_prices: ExUnitPrices ): BigNum; -/** - * @param {string} password - * @param {string} salt - * @param {string} nonce - * @param {string} data - * @returns {string} - */ -declare export function encrypt_with_password( - password: string, - salt: string, - nonce: string, - data: string -): string; - -/** - * @param {string} password - * @param {string} data - * @returns {string} - */ -declare export function decrypt_with_password( - password: string, - data: string -): string; - -/** - * @param {Address} address - * @param {TransactionUnspentOutputs} utxos - * @param {TransactionBuilderConfig} config - * @returns {TransactionBatchList} - */ -declare export function create_send_all( - address: Address, - utxos: TransactionUnspentOutputs, - config: TransactionBuilderConfig -): TransactionBatchList; - /** * @param {TransactionHash} tx_body_hash * @param {ByronAddress} addr @@ -262,6 +226,42 @@ declare export function encode_json_str_to_native_script( schema: number ): NativeScript; +/** + * @param {string} password + * @param {string} salt + * @param {string} nonce + * @param {string} data + * @returns {string} + */ +declare export function encrypt_with_password( + password: string, + salt: string, + nonce: string, + data: string +): string; + +/** + * @param {string} password + * @param {string} data + * @returns {string} + */ +declare export function decrypt_with_password( + password: string, + data: string +): string; + +/** + * @param {Address} address + * @param {TransactionUnspentOutputs} utxos + * @param {TransactionBuilderConfig} config + * @returns {TransactionBatchList} + */ +declare export function create_send_all( + address: Address, + utxos: TransactionUnspentOutputs, + config: TransactionBuilderConfig +): TransactionBatchList; + /** */ @@ -370,8 +370,8 @@ declare export var RedeemerTagKind: {| * All methods here have the following restrictions due to limitations on dependencies: * * JSON numbers above u64::MAX (positive) or below i64::MIN (negative) will throw errors * * Hex strings for bytes don't accept odd-length (half-byte) strings. - * cardano-cli seems to support these however but it seems to be different than just 0-padding - * on either side when tested so proceed with caution + * cardano-cli seems to support these however but it seems to be different than just 0-padding + * on either side when tested so proceed with caution */ declare export var PlutusDatumSchema: {| @@ -443,9 +443,9 @@ declare export class Address { to_json(): string; /** - * @returns {AddressJSON} + * @returns {any} */ - to_js_value(): AddressJSON; + to_js_value(): any; /** * @param {string} json @@ -519,9 +519,9 @@ declare export class AssetName { to_json(): string; /** - * @returns {AssetNameJSON} + * @returns {any} */ - to_js_value(): AssetNameJSON; + to_js_value(): any; /** * @param {string} json @@ -573,9 +573,9 @@ declare export class AssetNames { to_json(): string; /** - * @returns {AssetNamesJSON} + * @returns {any} */ - to_js_value(): AssetNamesJSON; + to_js_value(): any; /** * @param {string} json @@ -637,9 +637,9 @@ declare export class Assets { to_json(): string; /** - * @returns {AssetsJSON} + * @returns {any} */ - to_js_value(): AssetsJSON; + to_js_value(): any; /** * @param {string} json @@ -708,9 +708,9 @@ declare export class AuxiliaryData { to_json(): string; /** - * @returns {AuxiliaryDataJSON} + * @returns {any} */ - to_js_value(): AuxiliaryDataJSON; + to_js_value(): any; /** * @param {string} json @@ -906,9 +906,9 @@ declare export class BigInt { to_json(): string; /** - * @returns {BigIntJSON} + * @returns {any} */ - to_js_value(): BigIntJSON; + to_js_value(): any; /** * @param {string} json @@ -1003,9 +1003,9 @@ declare export class BigNum { to_json(): string; /** - * @returns {BigNumJSON} + * @returns {any} */ - to_js_value(): BigNumJSON; + to_js_value(): any; /** * @param {string} json @@ -1316,9 +1316,9 @@ declare export class Block { to_json(): string; /** - * @returns {BlockJSON} + * @returns {any} */ - to_js_value(): BlockJSON; + to_js_value(): any; /** * @param {string} json @@ -1439,9 +1439,9 @@ declare export class BootstrapWitness { to_json(): string; /** - * @returns {BootstrapWitnessJSON} + * @returns {any} */ - to_js_value(): BootstrapWitnessJSON; + to_js_value(): any; /** * @param {string} json @@ -1613,9 +1613,9 @@ declare export class Certificate { to_json(): string; /** - * @returns {CertificateJSON} + * @returns {any} */ - to_js_value(): CertificateJSON; + to_js_value(): any; /** * @param {string} json @@ -1748,9 +1748,9 @@ declare export class Certificates { to_json(): string; /** - * @returns {CertificatesJSON} + * @returns {any} */ - to_js_value(): CertificatesJSON; + to_js_value(): any; /** * @param {string} json @@ -1856,9 +1856,9 @@ declare export class CostModel { to_json(): string; /** - * @returns {CostModelJSON} + * @returns {any} */ - to_js_value(): CostModelJSON; + to_js_value(): any; /** * @param {string} json @@ -1926,9 +1926,9 @@ declare export class Costmdls { to_json(): string; /** - * @returns {CostmdlsJSON} + * @returns {any} */ - to_js_value(): CostmdlsJSON; + to_js_value(): any; /** * @param {string} json @@ -2003,9 +2003,9 @@ declare export class DNSRecordAorAAAA { to_json(): string; /** - * @returns {DNSRecordAorAAAAJSON} + * @returns {any} */ - to_js_value(): DNSRecordAorAAAAJSON; + to_js_value(): any; /** * @param {string} json @@ -2057,9 +2057,9 @@ declare export class DNSRecordSRV { to_json(): string; /** - * @returns {DNSRecordSRVJSON} + * @returns {any} */ - to_js_value(): DNSRecordSRVJSON; + to_js_value(): any; /** * @param {string} json @@ -2230,9 +2230,9 @@ declare export class Ed25519KeyHashes { to_json(): string; /** - * @returns {Ed25519KeyHashesJSON} + * @returns {any} */ - to_js_value(): Ed25519KeyHashesJSON; + to_js_value(): any; /** * @param {string} json @@ -2365,9 +2365,9 @@ declare export class ExUnitPrices { to_json(): string; /** - * @returns {ExUnitPricesJSON} + * @returns {any} */ - to_js_value(): ExUnitPricesJSON; + to_js_value(): any; /** * @param {string} json @@ -2425,9 +2425,9 @@ declare export class ExUnits { to_json(): string; /** - * @returns {ExUnitsJSON} + * @returns {any} */ - to_js_value(): ExUnitsJSON; + to_js_value(): any; /** * @param {string} json @@ -2485,9 +2485,9 @@ declare export class GeneralTransactionMetadata { to_json(): string; /** - * @returns {GeneralTransactionMetadataJSON} + * @returns {any} */ - to_js_value(): GeneralTransactionMetadataJSON; + to_js_value(): any; /** * @param {string} json @@ -2634,9 +2634,9 @@ declare export class GenesisHashes { to_json(): string; /** - * @returns {GenesisHashesJSON} + * @returns {any} */ - to_js_value(): GenesisHashesJSON; + to_js_value(): any; /** * @param {string} json @@ -2698,9 +2698,9 @@ declare export class GenesisKeyDelegation { to_json(): string; /** - * @returns {GenesisKeyDelegationJSON} + * @returns {any} */ - to_js_value(): GenesisKeyDelegationJSON; + to_js_value(): any; /** * @param {string} json @@ -2768,9 +2768,9 @@ declare export class Header { to_json(): string; /** - * @returns {HeaderJSON} + * @returns {any} */ - to_js_value(): HeaderJSON; + to_js_value(): any; /** * @param {string} json @@ -2828,9 +2828,9 @@ declare export class HeaderBody { to_json(): string; /** - * @returns {HeaderBodyJSON} + * @returns {any} */ - to_js_value(): HeaderBodyJSON; + to_js_value(): any; /** * @param {string} json @@ -3068,9 +3068,9 @@ declare export class Int { to_json(): string; /** - * @returns {IntJSON} + * @returns {any} */ - to_js_value(): IntJSON; + to_js_value(): any; /** * @param {string} json @@ -3191,9 +3191,9 @@ declare export class Ipv4 { to_json(): string; /** - * @returns {Ipv4JSON} + * @returns {any} */ - to_js_value(): Ipv4JSON; + to_js_value(): any; /** * @param {string} json @@ -3245,9 +3245,9 @@ declare export class Ipv6 { to_json(): string; /** - * @returns {Ipv6JSON} + * @returns {any} */ - to_js_value(): Ipv6JSON; + to_js_value(): any; /** * @param {string} json @@ -3354,9 +3354,9 @@ declare export class Language { to_json(): string; /** - * @returns {LanguageJSON} + * @returns {any} */ - to_js_value(): LanguageJSON; + to_js_value(): any; /** * @param {string} json @@ -3486,9 +3486,9 @@ declare export class MIRToStakeCredentials { to_json(): string; /** - * @returns {MIRToStakeCredentialsJSON} + * @returns {any} */ - to_js_value(): MIRToStakeCredentialsJSON; + to_js_value(): any; /** * @param {string} json @@ -3701,9 +3701,9 @@ declare export class Mint { to_json(): string; /** - * @returns {MintJSON} + * @returns {any} */ - to_js_value(): MintJSON; + to_js_value(): any; /** * @param {string} json @@ -3920,9 +3920,9 @@ declare export class MoveInstantaneousReward { to_json(): string; /** - * @returns {MoveInstantaneousRewardJSON} + * @returns {any} */ - to_js_value(): MoveInstantaneousRewardJSON; + to_js_value(): any; /** * @param {string} json @@ -4000,9 +4000,9 @@ declare export class MoveInstantaneousRewardsCert { to_json(): string; /** - * @returns {MoveInstantaneousRewardsCertJSON} + * @returns {any} */ - to_js_value(): MoveInstantaneousRewardsCertJSON; + to_js_value(): any; /** * @param {string} json @@ -4056,9 +4056,9 @@ declare export class MultiAsset { to_json(): string; /** - * @returns {MultiAssetJSON} + * @returns {any} */ - to_js_value(): MultiAssetJSON; + to_js_value(): any; /** * @param {string} json @@ -4162,9 +4162,9 @@ declare export class MultiHostName { to_json(): string; /** - * @returns {MultiHostNameJSON} + * @returns {any} */ - to_js_value(): MultiHostNameJSON; + to_js_value(): any; /** * @param {string} json @@ -4216,9 +4216,9 @@ declare export class NativeScript { to_json(): string; /** - * @returns {NativeScriptJSON} + * @returns {any} */ - to_js_value(): NativeScriptJSON; + to_js_value(): any; /** * @param {string} json @@ -4369,9 +4369,9 @@ declare export class NetworkId { to_json(): string; /** - * @returns {NetworkIdJSON} + * @returns {any} */ - to_js_value(): NetworkIdJSON; + to_js_value(): any; /** * @param {string} json @@ -4471,9 +4471,9 @@ declare export class Nonce { to_json(): string; /** - * @returns {NonceJSON} + * @returns {any} */ - to_js_value(): NonceJSON; + to_js_value(): any; /** * @param {string} json @@ -4530,9 +4530,9 @@ declare export class OperationalCert { to_json(): string; /** - * @returns {OperationalCertJSON} + * @returns {any} */ - to_js_value(): OperationalCertJSON; + to_js_value(): any; /** * @param {string} json @@ -4622,6 +4622,12 @@ declare export class PlutusData { */ static new_map(map: PlutusMap): PlutusData; + /** + * @param {Uint8Array} cbor + * @returns {PlutusData} + */ + static new_datum_map(cbor: Uint8Array): PlutusData; + /** * @param {PlutusList} list * @returns {PlutusData} @@ -4670,6 +4676,11 @@ declare export class PlutusData { */ as_bytes(): Uint8Array | void; + /** + * @returns {Uint8Array | void} + */ + as_original_bytes(): Uint8Array | void; + /** * @param {number} schema * @returns {string} @@ -4683,6 +4694,61 @@ declare export class PlutusData { */ static from_json(json: string, schema: number): PlutusData; } +/** + */ +declare export class PlutusDatumMap { + free(): void; + + /** + * @returns {Uint8Array} + */ + to_bytes(): Uint8Array; + + /** + * @param {Uint8Array} bytes + * @returns {PlutusDatumMap} + */ + static from_bytes(bytes: Uint8Array): PlutusDatumMap; + + /** + * @returns {string} + */ + to_hex(): string; + + /** + * @param {string} hex_str + * @returns {PlutusDatumMap} + */ + static from_hex(hex_str: string): PlutusDatumMap; + + /** + * @returns {PlutusDatumMap} + */ + static new(): PlutusDatumMap; + + /** + * @returns {number} + */ + len(): number; + + /** + * @param {PlutusData} key + * @param {PlutusData} value + * @returns {PlutusData | void} + */ + insert(key: PlutusData, value: PlutusData): PlutusData | void; + + /** + * @param {PlutusData} key + * @returns {PlutusData | void} + */ + get(key: PlutusData): PlutusData | void; + + /** + * @returns {PlutusList} + */ + keys(): PlutusList; +} /** */ declare export class PlutusList { @@ -4814,6 +4880,7 @@ declare export class PlutusScript { static from_hex(hex_str: string): PlutusScript; /** + * * * Creates a new Plutus script from the RAW bytes of the compiled script. * * This does NOT include any CBOR encoding around these bytes (e.g. from "cborBytes" in cardano-cli) * * If you creating this from those you should use PlutusScript::from_bytes() instead. @@ -4823,6 +4890,7 @@ declare export class PlutusScript { static new(bytes: Uint8Array): PlutusScript; /** + * * * Creates a new Plutus script from the RAW bytes of the compiled script. * * This does NOT include any CBOR encoding around these bytes (e.g. from "cborBytes" in cardano-cli) * * If you creating this from those you should use PlutusScript::from_bytes() instead. @@ -4832,6 +4900,7 @@ declare export class PlutusScript { static new_v2(bytes: Uint8Array): PlutusScript; /** + * * * Creates a new Plutus script from the RAW bytes of the compiled script. * * This does NOT include any CBOR encoding around these bytes (e.g. from "cborBytes" in cardano-cli) * * If you creating this from those you should use PlutusScript::from_bytes() instead. @@ -4842,6 +4911,7 @@ declare export class PlutusScript { static new_with_version(bytes: Uint8Array, language: Language): PlutusScript; /** + * * * The raw bytes of this compiled Plutus script. * * If you need "cborBytes" for cardano-cli use PlutusScript::to_bytes() instead. * @returns {Uint8Array} @@ -4953,9 +5023,9 @@ declare export class PlutusScripts { to_json(): string; /** - * @returns {PlutusScriptsJSON} + * @returns {any} */ - to_js_value(): PlutusScriptsJSON; + to_js_value(): any; /** * @param {string} json @@ -5193,9 +5263,9 @@ declare export class PoolMetadata { to_json(): string; /** - * @returns {PoolMetadataJSON} + * @returns {any} */ - to_js_value(): PoolMetadataJSON; + to_js_value(): any; /** * @param {string} json @@ -5292,9 +5362,9 @@ declare export class PoolParams { to_json(): string; /** - * @returns {PoolParamsJSON} + * @returns {any} */ - to_js_value(): PoolParamsJSON; + to_js_value(): any; /** * @param {string} json @@ -5404,9 +5474,9 @@ declare export class PoolRegistration { to_json(): string; /** - * @returns {PoolRegistrationJSON} + * @returns {any} */ - to_js_value(): PoolRegistrationJSON; + to_js_value(): any; /** * @param {string} json @@ -5458,9 +5528,9 @@ declare export class PoolRetirement { to_json(): string; /** - * @returns {PoolRetirementJSON} + * @returns {any} */ - to_js_value(): PoolRetirementJSON; + to_js_value(): any; /** * @param {string} json @@ -5591,9 +5661,9 @@ declare export class ProposedProtocolParameterUpdates { to_json(): string; /** - * @returns {ProposedProtocolParameterUpdatesJSON} + * @returns {any} */ - to_js_value(): ProposedProtocolParameterUpdatesJSON; + to_js_value(): any; /** * @param {string} json @@ -5665,9 +5735,9 @@ declare export class ProtocolParamUpdate { to_json(): string; /** - * @returns {ProtocolParamUpdateJSON} + * @returns {any} */ - to_js_value(): ProtocolParamUpdateJSON; + to_js_value(): any; /** * @param {string} json @@ -5947,9 +6017,9 @@ declare export class ProtocolVersion { to_json(): string; /** - * @returns {ProtocolVersionJSON} + * @returns {any} */ - to_js_value(): ProtocolVersionJSON; + to_js_value(): any; /** * @param {string} json @@ -6088,9 +6158,9 @@ declare export class Redeemer { to_json(): string; /** - * @returns {RedeemerJSON} + * @returns {any} */ - to_js_value(): RedeemerJSON; + to_js_value(): any; /** * @param {string} json @@ -6165,9 +6235,9 @@ declare export class RedeemerTag { to_json(): string; /** - * @returns {RedeemerTagJSON} + * @returns {any} */ - to_js_value(): RedeemerTagJSON; + to_js_value(): any; /** * @param {string} json @@ -6233,9 +6303,9 @@ declare export class Redeemers { to_json(): string; /** - * @returns {RedeemersJSON} + * @returns {any} */ - to_js_value(): RedeemersJSON; + to_js_value(): any; /** * @param {string} json @@ -6302,9 +6372,9 @@ declare export class Relay { to_json(): string; /** - * @returns {RelayJSON} + * @returns {any} */ - to_js_value(): RelayJSON; + to_js_value(): any; /** * @param {string} json @@ -6383,9 +6453,9 @@ declare export class Relays { to_json(): string; /** - * @returns {RelaysJSON} + * @returns {any} */ - to_js_value(): RelaysJSON; + to_js_value(): any; /** * @param {string} json @@ -6475,9 +6545,9 @@ declare export class RewardAddresses { to_json(): string; /** - * @returns {RewardAddressesJSON} + * @returns {any} */ - to_js_value(): RewardAddressesJSON; + to_js_value(): any; /** * @param {string} json @@ -6539,9 +6609,9 @@ declare export class ScriptAll { to_json(): string; /** - * @returns {ScriptAllJSON} + * @returns {any} */ - to_js_value(): ScriptAllJSON; + to_js_value(): any; /** * @param {string} json @@ -6593,9 +6663,9 @@ declare export class ScriptAny { to_json(): string; /** - * @returns {ScriptAnyJSON} + * @returns {any} */ - to_js_value(): ScriptAnyJSON; + to_js_value(): any; /** * @param {string} json @@ -6725,9 +6795,9 @@ declare export class ScriptHashes { to_json(): string; /** - * @returns {ScriptHashesJSON} + * @returns {any} */ - to_js_value(): ScriptHashesJSON; + to_js_value(): any; /** * @param {string} json @@ -6789,9 +6859,9 @@ declare export class ScriptNOfK { to_json(): string; /** - * @returns {ScriptNOfKJSON} + * @returns {any} */ - to_js_value(): ScriptNOfKJSON; + to_js_value(): any; /** * @param {string} json @@ -6849,9 +6919,9 @@ declare export class ScriptPubkey { to_json(): string; /** - * @returns {ScriptPubkeyJSON} + * @returns {any} */ - to_js_value(): ScriptPubkeyJSON; + to_js_value(): any; /** * @param {string} json @@ -6903,9 +6973,9 @@ declare export class ScriptRef { to_json(): string; /** - * @returns {ScriptRefJSON} + * @returns {any} */ - to_js_value(): ScriptRefJSON; + to_js_value(): any; /** * @param {string} json @@ -6978,9 +7048,9 @@ declare export class SingleHostAddr { to_json(): string; /** - * @returns {SingleHostAddrJSON} + * @returns {any} */ - to_js_value(): SingleHostAddrJSON; + to_js_value(): any; /** * @param {string} json @@ -7044,9 +7114,9 @@ declare export class SingleHostName { to_json(): string; /** - * @returns {SingleHostNameJSON} + * @returns {any} */ - to_js_value(): SingleHostNameJSON; + to_js_value(): any; /** * @param {string} json @@ -7131,9 +7201,9 @@ declare export class StakeCredential { to_json(): string; /** - * @returns {StakeCredentialJSON} + * @returns {any} */ - to_js_value(): StakeCredentialJSON; + to_js_value(): any; /** * @param {string} json @@ -7174,9 +7244,9 @@ declare export class StakeCredentials { to_json(): string; /** - * @returns {StakeCredentialsJSON} + * @returns {any} */ - to_js_value(): StakeCredentialsJSON; + to_js_value(): any; /** * @param {string} json @@ -7238,9 +7308,9 @@ declare export class StakeDelegation { to_json(): string; /** - * @returns {StakeDelegationJSON} + * @returns {any} */ - to_js_value(): StakeDelegationJSON; + to_js_value(): any; /** * @param {string} json @@ -7301,9 +7371,9 @@ declare export class StakeDeregistration { to_json(): string; /** - * @returns {StakeDeregistrationJSON} + * @returns {any} */ - to_js_value(): StakeDeregistrationJSON; + to_js_value(): any; /** * @param {string} json @@ -7355,9 +7425,9 @@ declare export class StakeRegistration { to_json(): string; /** - * @returns {StakeRegistrationJSON} + * @returns {any} */ - to_js_value(): StakeRegistrationJSON; + to_js_value(): any; /** * @param {string} json @@ -7435,9 +7505,9 @@ declare export class TimelockExpiry { to_json(): string; /** - * @returns {TimelockExpiryJSON} + * @returns {any} */ - to_js_value(): TimelockExpiryJSON; + to_js_value(): any; /** * @param {string} json @@ -7503,9 +7573,9 @@ declare export class TimelockStart { to_json(): string; /** - * @returns {TimelockStartJSON} + * @returns {any} */ - to_js_value(): TimelockStartJSON; + to_js_value(): any; /** * @param {string} json @@ -7575,9 +7645,9 @@ declare export class Transaction { to_json(): string; /** - * @returns {TransactionJSON} + * @returns {any} */ - to_js_value(): TransactionJSON; + to_js_value(): any; /** * @param {string} json @@ -7687,9 +7757,9 @@ declare export class TransactionBodies { to_json(): string; /** - * @returns {TransactionBodiesJSON} + * @returns {any} */ - to_js_value(): TransactionBodiesJSON; + to_js_value(): any; /** * @param {string} json @@ -7751,9 +7821,9 @@ declare export class TransactionBody { to_json(): string; /** - * @returns {TransactionBodyJSON} + * @returns {any} */ - to_js_value(): TransactionBodyJSON; + to_js_value(): any; /** * @param {string} json @@ -8668,9 +8738,9 @@ declare export class TransactionInput { to_json(): string; /** - * @returns {TransactionInputJSON} + * @returns {any} */ - to_js_value(): TransactionInputJSON; + to_js_value(): any; /** * @param {string} json @@ -8728,9 +8798,9 @@ declare export class TransactionInputs { to_json(): string; /** - * @returns {TransactionInputsJSON} + * @returns {any} */ - to_js_value(): TransactionInputsJSON; + to_js_value(): any; /** * @param {string} json @@ -8932,9 +9002,9 @@ declare export class TransactionOutput { to_json(): string; /** - * @returns {TransactionOutputJSON} + * @returns {any} */ - to_js_value(): TransactionOutputJSON; + to_js_value(): any; /** * @param {string} json @@ -9135,9 +9205,9 @@ declare export class TransactionOutputs { to_json(): string; /** - * @returns {TransactionOutputsJSON} + * @returns {any} */ - to_js_value(): TransactionOutputsJSON; + to_js_value(): any; /** * @param {string} json @@ -9199,9 +9269,9 @@ declare export class TransactionUnspentOutput { to_json(): string; /** - * @returns {TransactionUnspentOutputJSON} + * @returns {any} */ - to_js_value(): TransactionUnspentOutputJSON; + to_js_value(): any; /** * @param {string} json @@ -9240,9 +9310,9 @@ declare export class TransactionUnspentOutputs { to_json(): string; /** - * @returns {TransactionUnspentOutputsJSON} + * @returns {any} */ - to_js_value(): TransactionUnspentOutputsJSON; + to_js_value(): any; /** * @param {string} json @@ -9304,9 +9374,9 @@ declare export class TransactionWitnessSet { to_json(): string; /** - * @returns {TransactionWitnessSetJSON} + * @returns {any} */ - to_js_value(): TransactionWitnessSetJSON; + to_js_value(): any; /** * @param {string} json @@ -9412,9 +9482,9 @@ declare export class TransactionWitnessSets { to_json(): string; /** - * @returns {TransactionWitnessSetsJSON} + * @returns {any} */ - to_js_value(): TransactionWitnessSetsJSON; + to_js_value(): any; /** * @param {string} json @@ -9674,9 +9744,9 @@ declare export class URL { to_json(): string; /** - * @returns {URLJSON} + * @returns {any} */ - to_js_value(): URLJSON; + to_js_value(): any; /** * @param {string} json @@ -9728,9 +9798,9 @@ declare export class UnitInterval { to_json(): string; /** - * @returns {UnitIntervalJSON} + * @returns {any} */ - to_js_value(): UnitIntervalJSON; + to_js_value(): any; /** * @param {string} json @@ -9788,9 +9858,9 @@ declare export class Update { to_json(): string; /** - * @returns {UpdateJSON} + * @returns {any} */ - to_js_value(): UpdateJSON; + to_js_value(): any; /** * @param {string} json @@ -9851,9 +9921,9 @@ declare export class VRFCert { to_json(): string; /** - * @returns {VRFCertJSON} + * @returns {any} */ - to_js_value(): VRFCertJSON; + to_js_value(): any; /** * @param {string} json @@ -9989,9 +10059,9 @@ declare export class Value { to_json(): string; /** - * @returns {ValueJSON} + * @returns {any} */ - to_js_value(): ValueJSON; + to_js_value(): any; /** * @param {string} json @@ -10106,9 +10176,9 @@ declare export class Vkey { to_json(): string; /** - * @returns {VkeyJSON} + * @returns {any} */ - to_js_value(): VkeyJSON; + to_js_value(): any; /** * @param {string} json @@ -10186,9 +10256,9 @@ declare export class Vkeywitness { to_json(): string; /** - * @returns {VkeywitnessJSON} + * @returns {any} */ - to_js_value(): VkeywitnessJSON; + to_js_value(): any; /** * @param {string} json @@ -10246,9 +10316,9 @@ declare export class Vkeywitnesses { to_json(): string; /** - * @returns {VkeywitnessesJSON} + * @returns {any} */ - to_js_value(): VkeywitnessesJSON; + to_js_value(): any; /** * @param {string} json @@ -10310,9 +10380,9 @@ declare export class Withdrawals { to_json(): string; /** - * @returns {WithdrawalsJSON} + * @returns {any} */ - to_js_value(): WithdrawalsJSON; + to_js_value(): any; /** * @param {string} json @@ -10348,501 +10418,3 @@ declare export class Withdrawals { */ keys(): RewardAddresses; } -export type AddressJSON = string; -export type AssetNameJSON = string; -export type AssetNamesJSON = string[]; -export interface AssetsJSON { - [k: string]: string; -} -export interface AuxiliaryDataJSON { - metadata?: { - [k: string]: string, - ... - } | null; - native_scripts?: NativeScriptsJSON | null; - plutus_scripts?: PlutusScriptsJSON | null; - prefer_alonzo_format: boolean; -} -export type AuxiliaryDataHashJSON = string; -export interface AuxiliaryDataSetJSON { - [k: string]: AuxiliaryDataJSON; -} -export type BigIntJSON = string; -export type BigNumJSON = string; -export interface BlockJSON { - auxiliary_data_set: { - [k: string]: AuxiliaryDataJSON, - ... - }; - header: HeaderJSON; - invalid_transactions: number[]; - transaction_bodies: TransactionBodiesJSON; - transaction_witness_sets: TransactionWitnessSetsJSON; -} -export type BlockHashJSON = string; -export interface BootstrapWitnessJSON { - attributes: number[]; - chain_code: number[]; - signature: string; - vkey: VkeyJSON; -} -export type BootstrapWitnessesJSON = BootstrapWitnessJSON[]; -export type CertificateJSON = CertificateEnumJSON; -export type CertificateEnumJSON = - | { - StakeRegistrationJSON: StakeRegistration, - ... - } - | { - StakeDeregistrationJSON: StakeDeregistration, - ... - } - | { - StakeDelegationJSON: StakeDelegation, - ... - } - | { - PoolRegistrationJSON: PoolRegistration, - ... - } - | { - PoolRetirementJSON: PoolRetirement, - ... - } - | { - GenesisKeyDelegationJSON: GenesisKeyDelegation, - ... - } - | { - MoveInstantaneousRewardsCertJSON: MoveInstantaneousRewardsCert, - ... - }; -export type CertificatesJSON = CertificateJSON[]; -export type CostModelJSON = string[]; -export interface CostmdlsJSON { - [k: string]: CostModelJSON; -} -export type DNSRecordAorAAAAJSON = string; -export type DNSRecordSRVJSON = string; -export type DataHashJSON = string; -export type DataOptionJSON = - | { - DataHashJSON: string, - ... - } - | { - Data: string, - ... - }; -export type Ed25519KeyHashJSON = string; -export type Ed25519KeyHashesJSON = string[]; -export type Ed25519SignatureJSON = string; -export interface ExUnitPricesJSON { - mem_price: UnitIntervalJSON; - step_price: UnitIntervalJSON; -} -export interface ExUnitsJSON { - mem: string; - steps: string; -} -export interface GeneralTransactionMetadataJSON { - [k: string]: string; -} -export type GenesisDelegateHashJSON = string; -export type GenesisHashJSON = string; -export type GenesisHashesJSON = string[]; -export interface GenesisKeyDelegationJSON { - genesis_delegate_hash: string; - genesishash: string; - vrf_keyhash: string; -} -export interface HeaderJSON { - body_signature: string; - header_body: HeaderBodyJSON; -} -export interface HeaderBodyJSON { - block_body_hash: string; - block_body_size: number; - block_number: number; - issuer_vkey: VkeyJSON; - leader_cert: HeaderLeaderCertEnumJSON; - operational_cert: OperationalCertJSON; - prev_hash?: string | null; - protocol_version: ProtocolVersionJSON; - slot: string; - vrf_vkey: string; -} -export type HeaderLeaderCertEnumJSON = - | { - NonceAndLeader: [VRFCertJSON, VRFCert], - ... - } - | { - VrfResult: VRFCertJSON, - ... - }; -export type IntJSON = string; -export type Ipv4JSON = [number, number, number, number]; -export type Ipv6JSON = [ - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number -]; -export type KESVKeyJSON = string; -export type LanguageJSON = LanguageKindJSON; -export type LanguageKindJSON = "PlutusV1" | "PlutusV2"; -export type LanguagesJSON = LanguageJSON[]; -export type MIREnumJSON = - | { - ToOtherPot: string, - ... - } - | { - ToStakeCredentials: { - [k: string]: ProtocolParamUpdateJSON, - ... - }, - ... - }; -export type MIRPotJSON = "Reserves" | "Treasury"; -export interface MIRToStakeCredentialsJSON { - [k: string]: ProtocolParamUpdateJSON; -} -export type MintJSON = [string, MintAssetsJSON][]; -export interface MintAssetsJSON { - [k: string]: string; -} -export interface MoveInstantaneousRewardJSON { - pot: MIRPotJSON; - variant: MIREnumJSON; -} -export interface MoveInstantaneousRewardsCertJSON { - move_instantaneous_reward: MoveInstantaneousRewardJSON; -} -export interface MultiAssetJSON { - [k: string]: AssetsJSON; -} -export interface MultiHostNameJSON { - dns_name: DNSRecordSRVJSON; -} -export type NativeScriptJSON = NativeScript1JSON; -export type NativeScript1JSON = - | { - ScriptPubkeyJSON: ScriptPubkey, - ... - } - | { - ScriptAllJSON: ScriptAll, - ... - } - | { - ScriptAnyJSON: ScriptAny, - ... - } - | { - ScriptNOfKJSON: ScriptNOfK, - ... - } - | { - TimelockStartJSON: TimelockStart, - ... - } - | { - TimelockExpiryJSON: TimelockExpiry, - ... - }; -export type NativeScriptsJSON = NativeScriptJSON[]; -export type NetworkIdJSON = NetworkIdKindJSON; -export type NetworkIdKindJSON = "Testnet" | "Mainnet"; -export interface NonceJSON { - hash?: - | [ - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number - ] - | null; -} -export interface OperationalCertJSON { - hot_vkey: string; - kes_period: number; - sequence_number: number; - sigma: string; -} -export type PlutusScriptJSON = string; -export type PlutusScriptsJSON = string[]; -export interface PoolMetadataJSON { - pool_metadata_hash: string; - url: URLJSON; -} -export type PoolMetadataHashJSON = string; -export interface PoolParamsJSON { - cost: string; - margin: UnitIntervalJSON; - operator: string; - pledge: string; - pool_metadata?: PoolMetadataJSON | null; - pool_owners: Ed25519KeyHashesJSON; - relays: RelaysJSON; - reward_account: string; - vrf_keyhash: string; -} -export interface PoolRegistrationJSON { - pool_params: PoolParamsJSON; -} -export interface PoolRetirementJSON { - epoch: number; - pool_keyhash: string; -} -export interface ProposedProtocolParameterUpdatesJSON { - [k: string]: ProtocolParamUpdateJSON; -} -export interface ProtocolParamUpdateJSON { - ada_per_utxo_byte?: string | null; - collateral_percentage?: number | null; - cost_models?: CostmdlsJSON | null; - d?: UnitIntervalJSON | null; - execution_costs?: ExUnitPricesJSON | null; - expansion_rate?: UnitIntervalJSON | null; - extra_entropy?: NonceJSON | null; - key_deposit?: string | null; - max_block_body_size?: number | null; - max_block_ex_units?: ExUnitsJSON | null; - max_block_header_size?: number | null; - max_collateral_inputs?: number | null; - max_epoch?: number | null; - max_tx_ex_units?: ExUnitsJSON | null; - max_tx_size?: number | null; - max_value_size?: number | null; - min_pool_cost?: string | null; - minfee_a?: string | null; - minfee_b?: string | null; - n_opt?: number | null; - pool_deposit?: string | null; - pool_pledge_influence?: UnitIntervalJSON | null; - protocol_version?: ProtocolVersionJSON | null; - treasury_growth_rate?: UnitIntervalJSON | null; -} -export interface ProtocolVersionJSON { - major: number; - minor: number; -} -export type PublicKeyJSON = string; -export interface RedeemerJSON { - data: string; - ex_units: ExUnitsJSON; - index: string; - tag: RedeemerTagJSON; -} -export type RedeemerTagJSON = RedeemerTagKindJSON; -export type RedeemerTagKindJSON = "Spend" | "MintJSON" | "Cert" | "Reward"; -export type RedeemersJSON = RedeemerJSON[]; -export type RelayJSON = RelayEnumJSON; -export type RelayEnumJSON = - | { - SingleHostAddrJSON: SingleHostAddr, - ... - } - | { - SingleHostNameJSON: SingleHostName, - ... - } - | { - MultiHostNameJSON: MultiHostName, - ... - }; -export type RelaysJSON = RelayJSON[]; -export type RewardAddressJSON = string; -export type RewardAddressesJSON = string[]; -export interface ScriptAllJSON { - native_scripts: NativeScriptsJSON; -} -export interface ScriptAnyJSON { - native_scripts: NativeScriptsJSON; -} -export type ScriptDataHashJSON = string; -export type ScriptHashJSON = string; -export type ScriptHashesJSON = string[]; -export interface ScriptNOfKJSON { - n: number; - native_scripts: NativeScriptsJSON; -} -export interface ScriptPubkeyJSON { - addr_keyhash: string; -} -export type ScriptRefJSON = ScriptRefEnumJSON; -export type ScriptRefEnumJSON = - | { - NativeScriptJSON: NativeScript, - ... - } - | { - PlutusScriptJSON: string, - ... - }; -export interface SingleHostAddrJSON { - ipv4?: Ipv4JSON | null; - ipv6?: Ipv6JSON | null; - port?: number | null; -} -export interface SingleHostNameJSON { - dns_name: DNSRecordAorAAAAJSON; - port?: number | null; -} -export type StakeCredTypeJSON = - | { - Key: string, - ... - } - | { - Script: string, - ... - }; -export type StakeCredentialJSON = StakeCredTypeJSON; -export type StakeCredentialsJSON = StakeCredTypeJSON[]; -export interface StakeDelegationJSON { - pool_keyhash: string; - stake_credential: StakeCredTypeJSON; -} -export interface StakeDeregistrationJSON { - stake_credential: StakeCredTypeJSON; -} -export interface StakeRegistrationJSON { - stake_credential: StakeCredTypeJSON; -} -export interface TimelockExpiryJSON { - slot: string; -} -export interface TimelockStartJSON { - slot: string; -} -export interface TransactionJSON { - auxiliary_data?: AuxiliaryDataJSON | null; - body: TransactionBodyJSON; - is_valid: boolean; - witness_set: TransactionWitnessSetJSON; -} -export type TransactionBodiesJSON = TransactionBodyJSON[]; -export interface TransactionBodyJSON { - auxiliary_data_hash?: string | null; - certs?: CertificatesJSON | null; - collateral?: TransactionInputsJSON | null; - collateral_return?: TransactionOutputJSON | null; - fee: string; - inputs: TransactionInputsJSON; - mint?: MintJSON | null; - network_id?: NetworkIdJSON | null; - outputs: TransactionOutputsJSON; - reference_inputs?: TransactionInputsJSON | null; - required_signers?: Ed25519KeyHashesJSON | null; - script_data_hash?: string | null; - total_collateral?: string | null; - ttl?: string | null; - update?: UpdateJSON | null; - validity_start_interval?: string | null; - withdrawals?: { - [k: string]: ProtocolParamUpdateJSON, - ... - } | null; -} -export type TransactionHashJSON = string; -export interface TransactionInputJSON { - index: number; - transaction_id: string; -} -export type TransactionInputsJSON = TransactionInputJSON[]; -export type TransactionMetadatumJSON = string; -export interface TransactionOutputJSON { - address: string; - amount: ValueJSON; - plutus_data?: DataOptionJSON | null; - script_ref?: ScriptRefJSON | null; -} -export type TransactionOutputsJSON = TransactionOutputJSON[]; -export interface TransactionUnspentOutputJSON { - input: TransactionInputJSON; - output: TransactionOutputJSON; -} -export type TransactionUnspentOutputsJSON = TransactionUnspentOutputJSON[]; -export interface TransactionWitnessSetJSON { - bootstraps?: BootstrapWitnessesJSON | null; - native_scripts?: NativeScriptsJSON | null; - plutus_data?: PlutusList | null; - plutus_scripts?: PlutusScriptsJSON | null; - redeemers?: RedeemersJSON | null; - vkeys?: VkeywitnessesJSON | null; -} -export type TransactionWitnessSetsJSON = TransactionWitnessSetJSON[]; -export type URLJSON = string; -export interface UnitIntervalJSON { - denominator: string; - numerator: string; -} -export interface UpdateJSON { - epoch: number; - proposed_protocol_parameter_updates: { - [k: string]: ProtocolParamUpdateJSON, - ... - }; -} -export interface VRFCertJSON { - output: number[]; - proof: number[]; -} -export type VRFKeyHashJSON = string; -export type VRFVKeyJSON = string; -export interface ValueJSON { - coin: string; - multiasset?: MultiAssetJSON | null; -} -export type VkeyJSON = string; -export interface VkeywitnessJSON { - signature: string; - vkey: VkeyJSON; -} -export type VkeywitnessesJSON = VkeywitnessJSON[]; -export interface WithdrawalsJSON { - [k: string]: ProtocolParamUpdateJSON; -} diff --git a/rust/src/plutus.rs b/rust/src/plutus.rs index 44a46a0a..c6a7d68e 100644 --- a/rust/src/plutus.rs +++ b/rust/src/plutus.rs @@ -12,6 +12,8 @@ use cbor_event::{ use schemars::JsonSchema; +use indexmap::{indexmap, IndexMap}; + #[wasm_bindgen] #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] pub struct PlutusScript { @@ -208,7 +210,7 @@ impl PlutusScripts { } #[wasm_bindgen] -#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd,)] +#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,)] pub struct ConstrPlutusData { alternative: BigNum, data: PlutusList, @@ -555,7 +557,7 @@ impl Languages { } #[wasm_bindgen] -#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd,)] +#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd,)] pub struct PlutusMap(std::collections::BTreeMap); to_from_bytes!(PlutusMap); @@ -586,6 +588,39 @@ impl PlutusMap { } } +#[wasm_bindgen] +#[derive(Clone, Debug, Eq, PartialEq)] + +pub struct PlutusDatumMap(IndexMap); + +to_from_bytes!(PlutusDatumMap); + +#[wasm_bindgen] +impl PlutusDatumMap { + pub fn new() -> Self { + Self(IndexMap::new()) + } + + pub fn len(&self) -> usize { + self.0.len() + } + + pub fn insert(&mut self, key: &PlutusData, value: &PlutusData) -> Option { + self.0.insert(key.clone(), value.clone()) + } + + pub fn get(&self, key: &PlutusData) -> Option { + self.0.get(key).map(|v| v.clone()) + } + + pub fn keys(&self) -> PlutusList { + PlutusList { + elems: self.0.iter().map(|(k, _v)| k.clone()).collect::>(), + definite_encoding: None, + } + } +} + #[wasm_bindgen] #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] pub enum PlutusDataKind { @@ -597,7 +632,7 @@ pub enum PlutusDataKind { } #[derive( - Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] + Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum PlutusDataEnum { ConstrPlutusData(ConstrPlutusData), Map(PlutusMap), @@ -607,7 +642,7 @@ pub enum PlutusDataEnum { } #[wasm_bindgen] -#[derive(Clone, Debug, Ord, PartialOrd)] +#[derive(Clone, Debug, Hash, Ord, PartialOrd)] pub struct PlutusData { datum: PlutusDataEnum, // We should always preserve the original datums when deserialized as this is NOT canonicized @@ -646,6 +681,14 @@ impl PlutusData { } } + // The input is expected to be a datum that has already been CBOR encoded. + pub fn new_datum_map(cbor: Vec) -> Self { + Self { + datum: PlutusDataEnum::Map(PlutusMap::new()), + original_bytes: Some(cbor), + } + } + pub fn new_list(list: &PlutusList) -> Self { Self { datum: PlutusDataEnum::List(list.clone()), @@ -712,6 +755,14 @@ impl PlutusData { } } + // Use a reference so that this function does not remove the data from memory. + pub fn as_original_bytes(&self) -> Option> { + match &self.original_bytes { + Some(x) => Some(x.clone()), + _ => None, + } + } + pub fn to_json(&self, schema: PlutusDatumSchema) -> Result { decode_plutus_datum_to_json_str(self, schema) } @@ -758,7 +809,7 @@ impl <'de> serde::de::Deserialize<'de> for PlutusData { } #[wasm_bindgen] -#[derive(Clone, Debug, Ord, PartialOrd, serde::Serialize, serde::Deserialize, JsonSchema)] +#[derive(Clone, Debug, Hash, Ord, PartialOrd, serde::Serialize, serde::Deserialize, JsonSchema)] pub struct PlutusList { elems: Vec, // We should always preserve the original datums when deserialized as this is NOT canonicized @@ -1622,6 +1673,20 @@ impl cbor_event::se::Serialize for PlutusMap { } } +impl cbor_event::se::Serialize for PlutusDatumMap { + fn serialize<'se, W: Write>( + &self, + serializer: &'se mut Serializer, + ) -> cbor_event::Result<&'se mut Serializer> { + serializer.write_map(cbor_event::Len::Len(self.0.len() as u64))?; + for (key, value) in &self.0 { + key.serialize(serializer)?; + value.serialize(serializer)?; + } + Ok(serializer) + } +} + impl Deserialize for PlutusMap { fn deserialize(raw: &mut Deserializer) -> Result { let mut table = std::collections::BTreeMap::new(); @@ -1651,6 +1716,35 @@ impl Deserialize for PlutusMap { } } +impl Deserialize for PlutusDatumMap { + fn deserialize(raw: &mut Deserializer) -> Result { + let mut table = IndexMap::new(); + (|| -> Result<_, DeserializeError> { + let len = raw.map()?; + while match len { + cbor_event::Len::Len(n) => table.len() < n as usize, + cbor_event::Len::Indefinite => true, + } { + if raw.cbor_type()? == CBORType::Special { + assert_eq!(raw.special()?, CBORSpecial::Break); + break; + } + let key = PlutusData::deserialize(raw)?; + let value = PlutusData::deserialize(raw)?; + if table.insert(key.clone(), value).is_some() { + return Err(DeserializeFailure::DuplicateKey(Key::Str(String::from( + "some complicated/unsupported type", + ))) + .into()); + } + } + Ok(()) + })() + .map_err(|e| e.annotate("PlutusDatumMap"))?; + Ok(Self(table)) + } +} + impl cbor_event::se::Serialize for PlutusDataEnum { fn serialize<'se, W: Write>( &self, @@ -1995,6 +2089,39 @@ mod tests { // assert_eq!(constr_1854, constr_1854_roundtrip); } + #[test] + pub fn map_in_datum_remains_unsorted_serialization() { + fn x(input: i32) -> PlutusData {PlutusData::new_integer(&BigInt::from(input))} + fn y(input: &str) -> PlutusData {PlutusData::new_bytes(input.as_bytes().to_vec())} + let datum_cbor = "a4024162044164014161034163"; + + let datum = PlutusDatumMap(indexmap! { + x(2) => y("b"), + x(4) => y("d"), + x(1) => y("a"), + x(3) => y("c"), + }); + + assert_eq!(datum_cbor, hex::encode(datum.to_bytes())); + } + + #[test] + pub fn map_in_datum_remains_unsorted_deserialization() { + let orig_bytes = Vec::from_hex("a4024162044164014161034163").unwrap(); + let datum = PlutusDatumMap::from_bytes(orig_bytes.clone()).unwrap(); + let new_bytes = datum.to_bytes(); + assert_eq!(orig_bytes, new_bytes); + } + + #[test] + pub fn map_in_datum_roundtrip_plutusdata() { + let orig_bytes = Vec::from_hex("a4024162044164014161034163").unwrap(); + let pd = PlutusData::from_bytes(PlutusData::new_datum_map(orig_bytes.clone()).to_bytes()).unwrap(); + let new_bytes = PlutusDatumMap::from_bytes(pd.original_bytes.unwrap()).unwrap().to_bytes(); + + assert_eq!(orig_bytes, new_bytes); + } + #[test] pub fn plutus_list_serialization_cli_compatibility() { // mimic cardano-cli array encoding, see https://github.com/Emurgo/cardano-serialization-lib/issues/227 diff --git a/rust/src/utils.rs b/rust/src/utils.rs index 9faa7b5f..2bf55729 100644 --- a/rust/src/utils.rs +++ b/rust/src/utils.rs @@ -881,7 +881,7 @@ pub(crate) fn read_bounded_bytes( } #[wasm_bindgen] -#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct BigInt(num_bigint::BigInt); impl_to_from!(BigInt); diff --git a/scripts/publish-helper.js b/scripts/publish-helper.js index 3a54acf6..a9e802c8 100644 --- a/scripts/publish-helper.js +++ b/scripts/publish-helper.js @@ -6,7 +6,7 @@ if (oldPkg.files.find(entry => entry === flowFile) == null) { oldPkg.files.push(flowFile); } if (oldPkg.name === 'cardano-serialization-lib') { - oldPkg.name = '@emurgo/' + oldPkg.name + process.argv.slice(2)[0]; + oldPkg.name = '@mitchycola/' + oldPkg.name + process.argv.slice(2)[0]; } if (process.argv.slice(2)[0] === '-browser' || process.argv.slice(2)[0] === '-asmjs') { // due to a bug in wasm-pack, this file is missing from browser builds @@ -26,9 +26,9 @@ if (process.argv.slice(2)[0] === '-asmjs') { oldPkg.repository = { type: "git", - url: "git+https://github.com/Emurgo/cardano-serialization-lib.git" + url: "git+https://github.comMitchyCola/cardano-serialization-lib.git" }; -oldPkg.author = "EMURGO"; +oldPkg.author = "MitchyCola"; oldPkg.license = "MIT"; console.log(oldPkg); fs.writeFileSync('./publish/package.json', JSON.stringify(oldPkg, null, 2));