diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml
new file mode 100644
index 00000000..90099987
--- /dev/null
+++ b/.github/workflows/basic.yml
@@ -0,0 +1,64 @@
+on: [pull_request]
+
+name: Basic
+
+jobs:
+ build:
+ name: Build binaries
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ rust-version: [1.78.0]
+ steps:
+ - name: Checkout sources
+ uses: actions/checkout@v3
+ - name: Install stable toolchain
+ uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: ${{ matrix.rust-version }}
+ target: wasm32-unknown-unknown
+ override: true
+ - name: Build
+ run: make build
+
+ test:
+ needs: build
+ name: Test Suite
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ rust-version: [1.78.0]
+ steps:
+ - name: Checkout sources
+ uses: actions/checkout@v3
+ - name: Install stable toolchain
+ uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: ${{ matrix.rust-version }}
+ target: wasm32-unknown-unknown
+ override: true
+ - name: Run tests
+ run: make test
+
+ lints:
+ needs: build
+ name: Lints
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ rust-version: [1.78.0]
+ steps:
+ - name: Checkout sources
+ uses: actions/checkout@v3
+ - name: Install stable toolchain
+ uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: ${{ matrix.rust-version }}
+ override: true
+ target: wasm32-unknown-unknown
+ components: rustfmt, clippy
+ - name: Run lints
+ run: make lints
diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml
new file mode 100644
index 00000000..da8bb577
--- /dev/null
+++ b/.github/workflows/codecov.yml
@@ -0,0 +1,42 @@
+on:
+ push:
+ branches:
+ - main
+
+name: Code coverage check
+
+jobs:
+
+ coverage:
+ name: Code Coverage
+ # https://github.com/actions/virtual-environments
+ runs-on: ubuntu-20.04
+ strategy:
+ matrix:
+ rust-version: [1.78.0]
+ steps:
+ - name: Checkout sources
+ uses: actions/checkout@v3
+ - name: Install stable toolchain
+ uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: ${{ matrix.rust-version }}
+ target: wasm32-unknown-unknown
+ override: true
+ - name: Install tarpaulin
+ uses: actions-rs/cargo@v1
+ with:
+ command: install
+ args: cargo-tarpaulin --version 0.30.0
+ - run: make build
+ - name: Run code coverage check with tarpaulin
+ uses: actions-rs/cargo@v1
+ with:
+ command: tarpaulin
+ args: --all-features --workspace --timeout 120 --out Xml --exclude soroban-token-contract
+ - name: Upload coverage to Codecov
+ uses: codecov/codecov-action@v1
+ with:
+ token: ${{ secrets.CODECOV_TOKEN }}
+ file: ./cobertura.xml
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 00000000..73e7cbe6
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,39 @@
+name: Release Artifacts
+on:
+ push:
+ tags:
+ - "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. 1.0, 20.15.10
+ - "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. 1.0-rc1, 20.15.10-rc5
+
+jobs:
+ release-artifacts:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ rust-version: [1.78.0]
+ steps:
+ - name: Checkout sources
+ uses: actions/checkout@v3
+ - name: Install stable toolchain
+ uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: ${{ matrix.rust-version }}
+ target: wasm32-unknown-unknown
+ override: true
+ - name: Build artifacts
+ run: make build
+ - name: Generate checksums
+ run: |
+ cd target/wasm32-unknown-unknown/release/
+ sha256sum *.wasm > checksums.txt
+ - name: Release
+ env:
+ GH_TOKEN: ${{ secrets.JAKUB_SECRET_CI }}
+ run: >-
+ gh release create ${{ github.ref_name }}
+ target/wasm32-unknown-unknown/release/*.wasm
+ target/wasm32-unknown-unknown/release/checksums.txt
+ --generate-notes
+ --title "${{ github.ref_name }}"
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..29304db2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,21 @@
+# macOS
+.DS_Store
+
+# Text file backups
+**/*.rs.bk
+
+# Build results
+target/
+
+# IDEs
+.vscode/
+.idea/
+*.iml
+
+# Auto-gen
+.cargo-ok
+/artifacts/
+
+cobertura.xml
+
+**/test_snapshots
diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644
index 00000000..44113772
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,1441 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "addr2line"
+version = "0.21.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
+dependencies = [
+ "gimli",
+]
+
+[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
+[[package]]
+name = "android-tzdata"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
+
+[[package]]
+name = "android_system_properties"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "arbitrary"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110"
+dependencies = [
+ "derive_arbitrary",
+]
+
+[[package]]
+name = "autocfg"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
+
+[[package]]
+name = "backtrace"
+version = "0.3.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
+dependencies = [
+ "addr2line",
+ "cc",
+ "cfg-if",
+ "libc",
+ "miniz_oxide",
+ "object",
+ "rustc-demangle",
+]
+
+[[package]]
+name = "base16ct"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
+
+[[package]]
+name = "base32"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa"
+
+[[package]]
+name = "base64"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
+
+[[package]]
+name = "base64"
+version = "0.22.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
+
+[[package]]
+name = "base64ct"
+version = "1.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
+
+[[package]]
+name = "block-buffer"
+version = "0.10.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
+dependencies = [
+ "generic-array",
+]
+
+[[package]]
+name = "bumpalo"
+version = "3.16.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
+
+[[package]]
+name = "bytes-lit"
+version = "0.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0adabf37211a5276e46335feabcbb1530c95eb3fdf85f324c7db942770aa025d"
+dependencies = [
+ "num-bigint",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "cc"
+version = "1.0.100"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c891175c3fb232128f48de6590095e59198bbeb8620c310be349bfc3afd12c7b"
+
+[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
+name = "chrono"
+version = "0.4.38"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
+dependencies = [
+ "android-tzdata",
+ "iana-time-zone",
+ "num-traits",
+ "serde",
+ "windows-targets",
+]
+
+[[package]]
+name = "const-oid"
+version = "0.9.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
+
+[[package]]
+name = "core-foundation-sys"
+version = "0.8.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
+
+[[package]]
+name = "cpufeatures"
+version = "0.2.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "crate-git-revision"
+version = "0.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c521bf1f43d31ed2f73441775ed31935d77901cb3451e44b38a1c1612fcbaf98"
+dependencies = [
+ "serde",
+ "serde_derive",
+ "serde_json",
+]
+
+[[package]]
+name = "crypto-bigint"
+version = "0.5.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76"
+dependencies = [
+ "generic-array",
+ "rand_core",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "crypto-common"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
+dependencies = [
+ "generic-array",
+ "typenum",
+]
+
+[[package]]
+name = "ctor"
+version = "0.2.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f"
+dependencies = [
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "curve25519-dalek"
+version = "4.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "curve25519-dalek-derive",
+ "digest",
+ "fiat-crypto",
+ "platforms",
+ "rustc_version",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "curve25519-dalek-derive"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "darling"
+version = "0.20.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1"
+dependencies = [
+ "darling_core",
+ "darling_macro",
+]
+
+[[package]]
+name = "darling_core"
+version = "0.20.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120"
+dependencies = [
+ "fnv",
+ "ident_case",
+ "proc-macro2",
+ "quote",
+ "strsim",
+ "syn",
+]
+
+[[package]]
+name = "darling_macro"
+version = "0.20.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178"
+dependencies = [
+ "darling_core",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "der"
+version = "0.7.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0"
+dependencies = [
+ "const-oid",
+ "zeroize",
+]
+
+[[package]]
+name = "deranged"
+version = "0.3.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4"
+dependencies = [
+ "powerfmt",
+ "serde",
+]
+
+[[package]]
+name = "derive_arbitrary"
+version = "1.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "digest"
+version = "0.10.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
+dependencies = [
+ "block-buffer",
+ "const-oid",
+ "crypto-common",
+ "subtle",
+]
+
+[[package]]
+name = "downcast-rs"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
+
+[[package]]
+name = "ecdsa"
+version = "0.16.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca"
+dependencies = [
+ "der",
+ "digest",
+ "elliptic-curve",
+ "rfc6979",
+ "signature",
+ "spki",
+]
+
+[[package]]
+name = "ed25519"
+version = "2.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53"
+dependencies = [
+ "pkcs8",
+ "signature",
+]
+
+[[package]]
+name = "ed25519-dalek"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980"
+dependencies = [
+ "curve25519-dalek",
+ "ed25519",
+ "rand_core",
+ "serde",
+ "sha2",
+ "zeroize",
+]
+
+[[package]]
+name = "either"
+version = "1.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b"
+
+[[package]]
+name = "elliptic-curve"
+version = "0.13.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47"
+dependencies = [
+ "base16ct",
+ "crypto-bigint",
+ "digest",
+ "ff",
+ "generic-array",
+ "group",
+ "pkcs8",
+ "rand_core",
+ "sec1",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "equivalent"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
+
+[[package]]
+name = "escape-bytes"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2bfcf67fea2815c2fc3b90873fae90957be12ff417335dfadc7f52927feb03b2"
+
+[[package]]
+name = "ethnum"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b90ca2580b73ab6a1f724b76ca11ab632df820fd6040c336200d2c1df7b3c82c"
+
+[[package]]
+name = "ff"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449"
+dependencies = [
+ "rand_core",
+ "subtle",
+]
+
+[[package]]
+name = "fiat-crypto"
+version = "0.2.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d"
+
+[[package]]
+name = "fnv"
+version = "1.0.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
+
+[[package]]
+name = "generic-array"
+version = "0.14.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
+dependencies = [
+ "typenum",
+ "version_check",
+ "zeroize",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.2.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
+dependencies = [
+ "cfg-if",
+ "js-sys",
+ "libc",
+ "wasi",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "gimli"
+version = "0.28.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
+
+[[package]]
+name = "group"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63"
+dependencies = [
+ "ff",
+ "rand_core",
+ "subtle",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.12.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
+
+[[package]]
+name = "hashbrown"
+version = "0.14.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
+
+[[package]]
+name = "hex"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "hex-literal"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46"
+
+[[package]]
+name = "hmac"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
+dependencies = [
+ "digest",
+]
+
+[[package]]
+name = "iana-time-zone"
+version = "0.1.60"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
+dependencies = [
+ "android_system_properties",
+ "core-foundation-sys",
+ "iana-time-zone-haiku",
+ "js-sys",
+ "wasm-bindgen",
+ "windows-core",
+]
+
+[[package]]
+name = "iana-time-zone-haiku"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "ident_case"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
+
+[[package]]
+name = "indexmap"
+version = "1.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
+dependencies = [
+ "autocfg",
+ "hashbrown 0.12.3",
+ "serde",
+]
+
+[[package]]
+name = "indexmap"
+version = "2.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
+dependencies = [
+ "equivalent",
+ "hashbrown 0.14.5",
+ "serde",
+]
+
+[[package]]
+name = "indexmap-nostd"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590"
+
+[[package]]
+name = "itertools"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"
+dependencies = [
+ "either",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
+
+[[package]]
+name = "js-sys"
+version = "0.3.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d"
+dependencies = [
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "k256"
+version = "0.13.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc"
+dependencies = [
+ "cfg-if",
+ "ecdsa",
+ "elliptic-curve",
+ "once_cell",
+ "sha2",
+ "signature",
+]
+
+[[package]]
+name = "keccak"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654"
+dependencies = [
+ "cpufeatures",
+]
+
+[[package]]
+name = "libc"
+version = "0.2.155"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
+
+[[package]]
+name = "libm"
+version = "0.2.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
+
+[[package]]
+name = "log"
+version = "0.4.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
+
+[[package]]
+name = "memchr"
+version = "2.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
+
+[[package]]
+name = "miniz_oxide"
+version = "0.7.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08"
+dependencies = [
+ "adler",
+]
+
+[[package]]
+name = "num-bigint"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0"
+dependencies = [
+ "autocfg",
+ "num-integer",
+ "num-traits",
+]
+
+[[package]]
+name = "num-conv"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
+
+[[package]]
+name = "num-derive"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cfb77679af88f8b125209d354a202862602672222e7f2313fdd6dc349bad4712"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "num-integer"
+version = "0.1.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
+dependencies = [
+ "autocfg",
+ "num-traits",
+]
+
+[[package]]
+name = "num-traits"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "object"
+version = "0.32.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.19.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
+
+[[package]]
+name = "paste"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
+
+[[package]]
+name = "phoenix-nft"
+version = "1.0.0"
+dependencies = [
+ "soroban-sdk",
+]
+
+[[package]]
+name = "pkcs8"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7"
+dependencies = [
+ "der",
+ "spki",
+]
+
+[[package]]
+name = "platforms"
+version = "3.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0e4c7666f2019727f9e8e14bf14456e99c707d780922869f1ba473eee101fa49"
+
+[[package]]
+name = "powerfmt"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
+
+[[package]]
+name = "ppv-lite86"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
+
+[[package]]
+name = "prettyplease"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d"
+dependencies = [
+ "proc-macro2",
+ "syn",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.33"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "rand"
+version = "0.8.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
+dependencies = [
+ "libc",
+ "rand_chacha",
+ "rand_core",
+]
+
+[[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",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
+dependencies = [
+ "getrandom",
+]
+
+[[package]]
+name = "rfc6979"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2"
+dependencies = [
+ "hmac",
+ "subtle",
+]
+
+[[package]]
+name = "rustc-demangle"
+version = "0.1.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
+
+[[package]]
+name = "rustc_version"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
+dependencies = [
+ "semver",
+]
+
+[[package]]
+name = "ryu"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
+
+[[package]]
+name = "sec1"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc"
+dependencies = [
+ "base16ct",
+ "der",
+ "generic-array",
+ "pkcs8",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "semver"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
+
+[[package]]
+name = "serde"
+version = "1.0.192"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.192"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.108"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b"
+dependencies = [
+ "itoa",
+ "ryu",
+ "serde",
+]
+
+[[package]]
+name = "serde_with"
+version = "3.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20"
+dependencies = [
+ "base64 0.22.1",
+ "chrono",
+ "hex",
+ "indexmap 1.9.3",
+ "indexmap 2.2.6",
+ "serde",
+ "serde_derive",
+ "serde_json",
+ "serde_with_macros",
+ "time",
+]
+
+[[package]]
+name = "serde_with_macros"
+version = "3.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2"
+dependencies = [
+ "darling",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "sha2"
+version = "0.10.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "digest",
+]
+
+[[package]]
+name = "sha3"
+version = "0.10.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60"
+dependencies = [
+ "digest",
+ "keccak",
+]
+
+[[package]]
+name = "signature"
+version = "2.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
+dependencies = [
+ "digest",
+ "rand_core",
+]
+
+[[package]]
+name = "smallvec"
+version = "1.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
+
+[[package]]
+name = "soroban-builtin-sdk-macros"
+version = "20.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7cc32c6e817f3ca269764ec0d7d14da6210b74a5bf14d4e745aa3ee860558900"
+dependencies = [
+ "itertools",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "soroban-env-common"
+version = "20.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c14e18d879c520ff82612eaae0590acaf6a7f3b977407e1abb1c9e31f94c7814"
+dependencies = [
+ "arbitrary",
+ "crate-git-revision",
+ "ethnum",
+ "num-derive",
+ "num-traits",
+ "serde",
+ "soroban-env-macros",
+ "soroban-wasmi",
+ "static_assertions",
+ "stellar-xdr",
+]
+
+[[package]]
+name = "soroban-env-guest"
+version = "20.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5122ca2abd5ebcc1e876a96b9b44f87ce0a0e06df8f7c09772ddb58b159b7454"
+dependencies = [
+ "soroban-env-common",
+ "static_assertions",
+]
+
+[[package]]
+name = "soroban-env-host"
+version = "20.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "114a0fa0d0cc39d0be16b1ee35b6e5f4ee0592ddcf459bde69391c02b03cf520"
+dependencies = [
+ "backtrace",
+ "curve25519-dalek",
+ "ed25519-dalek",
+ "getrandom",
+ "hex-literal",
+ "hmac",
+ "k256",
+ "num-derive",
+ "num-integer",
+ "num-traits",
+ "rand",
+ "rand_chacha",
+ "sha2",
+ "sha3",
+ "soroban-builtin-sdk-macros",
+ "soroban-env-common",
+ "soroban-wasmi",
+ "static_assertions",
+ "stellar-strkey",
+]
+
+[[package]]
+name = "soroban-env-macros"
+version = "20.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b13e3f8c86f812e0669e78fcb3eae40c385c6a9dd1a4886a1de733230b4fcf27"
+dependencies = [
+ "itertools",
+ "proc-macro2",
+ "quote",
+ "serde",
+ "serde_json",
+ "stellar-xdr",
+ "syn",
+]
+
+[[package]]
+name = "soroban-ledger-snapshot"
+version = "20.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61a54708f44890e0546180db6b4f530e2a88d83b05a9b38a131caa21d005e25a"
+dependencies = [
+ "serde",
+ "serde_json",
+ "serde_with",
+ "soroban-env-common",
+ "soroban-env-host",
+ "thiserror",
+]
+
+[[package]]
+name = "soroban-sdk"
+version = "20.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "84fc8be9068dd4e0212d8b13ad61089ea87e69ac212c262914503a961c8dc3a3"
+dependencies = [
+ "arbitrary",
+ "bytes-lit",
+ "ctor",
+ "ed25519-dalek",
+ "rand",
+ "serde",
+ "serde_json",
+ "soroban-env-guest",
+ "soroban-env-host",
+ "soroban-ledger-snapshot",
+ "soroban-sdk-macros",
+ "stellar-strkey",
+]
+
+[[package]]
+name = "soroban-sdk-macros"
+version = "20.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db20def4ead836663633f58d817d0ed8e1af052c9650a04adf730525af85b964"
+dependencies = [
+ "crate-git-revision",
+ "darling",
+ "itertools",
+ "proc-macro2",
+ "quote",
+ "rustc_version",
+ "sha2",
+ "soroban-env-common",
+ "soroban-spec",
+ "soroban-spec-rust",
+ "stellar-xdr",
+ "syn",
+]
+
+[[package]]
+name = "soroban-spec"
+version = "20.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3eefeb5d373b43f6828145d00f0c5cc35e96db56a6671ae9614f84beb2711cab"
+dependencies = [
+ "base64 0.13.1",
+ "stellar-xdr",
+ "thiserror",
+ "wasmparser",
+]
+
+[[package]]
+name = "soroban-spec-rust"
+version = "20.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3152bca4737ef734ac37fe47b225ee58765c9095970c481a18516a2b287c7a33"
+dependencies = [
+ "prettyplease",
+ "proc-macro2",
+ "quote",
+ "sha2",
+ "soroban-spec",
+ "stellar-xdr",
+ "syn",
+ "thiserror",
+]
+
+[[package]]
+name = "soroban-wasmi"
+version = "0.31.1-soroban.20.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "710403de32d0e0c35375518cb995d4fc056d0d48966f2e56ea471b8cb8fc9719"
+dependencies = [
+ "smallvec",
+ "spin",
+ "wasmi_arena",
+ "wasmi_core",
+ "wasmparser-nostd",
+]
+
+[[package]]
+name = "spin"
+version = "0.9.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
+
+[[package]]
+name = "spki"
+version = "0.7.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d"
+dependencies = [
+ "base64ct",
+ "der",
+]
+
+[[package]]
+name = "static_assertions"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
+
+[[package]]
+name = "stellar-strkey"
+version = "0.0.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "12d2bf45e114117ea91d820a846fd1afbe3ba7d717988fee094ce8227a3bf8bd"
+dependencies = [
+ "base32",
+ "crate-git-revision",
+ "thiserror",
+]
+
+[[package]]
+name = "stellar-xdr"
+version = "20.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e59cdf3eb4467fb5a4b00b52e7de6dca72f67fac6f9b700f55c95a5d86f09c9d"
+dependencies = [
+ "arbitrary",
+ "base64 0.13.1",
+ "crate-git-revision",
+ "escape-bytes",
+ "hex",
+ "serde",
+ "serde_with",
+ "stellar-strkey",
+]
+
+[[package]]
+name = "strsim"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
+
+[[package]]
+name = "subtle"
+version = "2.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
+
+[[package]]
+name = "syn"
+version = "2.0.39"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "thiserror"
+version = "1.0.55"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e3de26b0965292219b4287ff031fcba86837900fe9cd2b34ea8ad893c0953d2"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "1.0.55"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "268026685b2be38d7103e9e507c938a1fcb3d7e6eb15e87870b617bf37b6d581"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "time"
+version = "0.3.36"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885"
+dependencies = [
+ "deranged",
+ "itoa",
+ "num-conv",
+ "powerfmt",
+ "serde",
+ "time-core",
+ "time-macros",
+]
+
+[[package]]
+name = "time-core"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
+
+[[package]]
+name = "time-macros"
+version = "0.2.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf"
+dependencies = [
+ "num-conv",
+ "time-core",
+]
+
+[[package]]
+name = "typenum"
+version = "1.17.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
+
+[[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.11.0+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
+
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.92"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
+dependencies = [
+ "cfg-if",
+ "wasm-bindgen-macro",
+]
+
+[[package]]
+name = "wasm-bindgen-backend"
+version = "0.2.92"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
+dependencies = [
+ "bumpalo",
+ "log",
+ "once_cell",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-macro"
+version = "0.2.92"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
+dependencies = [
+ "quote",
+ "wasm-bindgen-macro-support",
+]
+
+[[package]]
+name = "wasm-bindgen-macro-support"
+version = "0.2.92"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+ "wasm-bindgen-backend",
+ "wasm-bindgen-shared",
+]
+
+[[package]]
+name = "wasm-bindgen-shared"
+version = "0.2.92"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
+
+[[package]]
+name = "wasmi_arena"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "104a7f73be44570cac297b3035d76b169d6599637631cf37a1703326a0727073"
+
+[[package]]
+name = "wasmi_core"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dcf1a7db34bff95b85c261002720c00c3a6168256dcb93041d3fa2054d19856a"
+dependencies = [
+ "downcast-rs",
+ "libm",
+ "num-traits",
+ "paste",
+]
+
+[[package]]
+name = "wasmparser"
+version = "0.88.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fb8cf7dd82407fe68161bedcd57fde15596f32ebf6e9b3bdbf3ae1da20e38e5e"
+dependencies = [
+ "indexmap 1.9.3",
+]
+
+[[package]]
+name = "wasmparser-nostd"
+version = "0.100.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d5a015fe95f3504a94bb1462c717aae75253e39b9dd6c3fb1062c934535c64aa"
+dependencies = [
+ "indexmap-nostd",
+]
+
+[[package]]
+name = "windows-core"
+version = "0.52.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.52.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
+dependencies = [
+ "windows_aarch64_gnullvm",
+ "windows_aarch64_msvc",
+ "windows_i686_gnu",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc",
+ "windows_x86_64_gnu",
+ "windows_x86_64_gnullvm",
+ "windows_x86_64_msvc",
+]
+
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.52.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
+
+[[package]]
+name = "zeroize"
+version = "1.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 00000000..621caaeb
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,33 @@
+[workspace]
+members = ["contracts/*"]
+resolver = "2"
+
+[workspace.package]
+version = "1.0.0"
+edition = "2021"
+license = "GPL-3.0"
+repository = "https://github.com/Phoenix-Protocol-Group/phoenix-nft-marketplace"
+
+[workspace.dependencies]
+ed25519-dalek = "1.0.1"
+num-integer = { version = "0.1.45", default-features = false, features = [
+ "i128",
+] }
+soroban-sdk = "20.5.0"
+soroban-auth = "20.5.0"
+soroban-token-sdk = "20.5.0"
+test-case = "3.3"
+
+[profile.release]
+opt-level = "z"
+overflow-checks = true
+debug = 0
+strip = "symbols"
+debug-assertions = false
+panic = "abort"
+codegen-units = 1
+lto = true
+
+[profile.release-with-logs]
+inherits = "release"
+debug-assertions = true
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..f288702d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..1c534be2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,31 @@
+SUBDIRS := contracts/nft
+BUILD_FLAGS ?=
+
+default: build
+
+all: test
+
+build:
+ @for dir in $(SUBDIRS) ; do \
+ $(MAKE) -C $$dir build BUILD_FLAGS=$(BUILD_FLAGS) || exit 1; \
+ done
+
+test: build
+ @for dir in $(SUBDIRS) ; do \
+ $(MAKE) -C $$dir test BUILD_FLAGS=$(BUILD_FLAGS) || exit 1; \
+ done
+
+fmt:
+ @for dir in $(SUBDIRS) ; do \
+ $(MAKE) -C $$dir fmt || exit 1; \
+ done
+
+lints: fmt
+ @for dir in $(SUBDIRS) ; do \
+ $(MAKE) -C $$dir clippy || exit 1; \
+ done
+
+clean:
+ @for dir in $(SUBDIRS) ; do \
+ $(MAKE) -C $$dir clean || exit 1; \
+ done
diff --git a/contracts/nft/Cargo.toml b/contracts/nft/Cargo.toml
new file mode 100644
index 00000000..226700e4
--- /dev/null
+++ b/contracts/nft/Cargo.toml
@@ -0,0 +1,19 @@
+[package]
+name = "phoenix-nft"
+version = { workspace = true }
+authors = ["Jakub "]
+repository = { workspace = true }
+edition = { workspace = true }
+license = { workspace = true }
+
+[lib]
+crate-type = ["cdylib"]
+
+[features]
+testutils = ["soroban-sdk/testutils"]
+
+[dependencies]
+soroban-sdk = { workspace = true }
+
+[dev_dependencies]
+soroban-sdk = { workspace = true, features = ["testutils"] }
diff --git a/contracts/nft/Makefile b/contracts/nft/Makefile
new file mode 100644
index 00000000..1e1e69be
--- /dev/null
+++ b/contracts/nft/Makefile
@@ -0,0 +1,20 @@
+default: all
+
+all: lint build test
+
+test: build # because of token dependency
+ cargo test
+
+build:
+ cargo build --target wasm32-unknown-unknown --release
+
+lint: fmt clippy
+
+fmt:
+ cargo fmt --all
+
+clippy: build
+ cargo clippy --all-targets -- -D warnings
+
+clean:
+ cargo clean
diff --git a/contracts/nft/src/admin.rs b/contracts/nft/src/admin.rs
new file mode 100644
index 00000000..bc5220b2
--- /dev/null
+++ b/contracts/nft/src/admin.rs
@@ -0,0 +1,26 @@
+use crate::storage_types::DataKey;
+use soroban_auth::{Identifier, Signature};
+use soroban_sdk::Env;
+
+pub fn has_administrator(env: &Env) -> bool {
+ let key = DataKey::Admin;
+ env.storage().has(key)
+}
+
+pub fn read_administrator(env: &Env) -> Identifier {
+ let key = DataKey::Admin;
+ env.storage().get_unchecked(key).unwrap()
+}
+
+pub fn write_administrator(env: &Env, id: Identifier) {
+ let key = DataKey::Admin;
+ env.storage().set(key, id);
+}
+
+pub fn check_admin(env: &Env, auth: &Signature) {
+ let auth_id = auth.identifier(env);
+ assert!(
+ auth_id == read_administrator(env),
+ "not authorized by admin"
+ );
+}
diff --git a/contracts/nft/src/approval.rs b/contracts/nft/src/approval.rs
new file mode 100644
index 00000000..a58e0266
--- /dev/null
+++ b/contracts/nft/src/approval.rs
@@ -0,0 +1,33 @@
+use crate::owner::zero_address;
+use crate::storage_types::DataKey;
+use crate::storage_types::{ApprovalAll, ApprovalKey};
+use soroban_auth::Identifier;
+use soroban_sdk::Env;
+
+pub fn read_approval(env: &Env, id: i128) -> Identifier {
+ let key = DataKey::Approval(ApprovalKey::ID(id));
+ if let Some(approval) = env.storage().get(key) {
+ approval.unwrap()
+ } else {
+ zero_address(&env)
+ }
+}
+
+pub fn read_approval_all(env: &Env, owner: Identifier, operator: Identifier) -> bool {
+ let key = DataKey::Approval(ApprovalKey::All(ApprovalAll { operator, owner }));
+ if let Some(approval) = env.storage().get(key) {
+ approval.unwrap()
+ } else {
+ false
+ }
+}
+
+pub fn write_approval(env: &Env, id: i128, operator: Identifier) {
+ let key = DataKey::Approval(ApprovalKey::ID(id));
+ env.storage().set(key, operator);
+}
+
+pub fn write_approval_all(env: &Env, owner: Identifier, operator: Identifier, approved: bool) {
+ let key = DataKey::Approval(ApprovalKey::All(ApprovalAll { operator, owner }));
+ env.storage().set(key, approved);
+}
diff --git a/contracts/nft/src/balance.rs b/contracts/nft/src/balance.rs
new file mode 100644
index 00000000..e1dcd56e
--- /dev/null
+++ b/contracts/nft/src/balance.rs
@@ -0,0 +1,51 @@
+use crate::{interface::WriteType, storage_types::DataKey};
+use soroban_auth::Identifier;
+use soroban_sdk::Env;
+
+pub fn read_balance(env: &Env, owner: Identifier) -> i128 {
+ let key = DataKey::Balance(owner);
+ match env.storage().get(key) {
+ Some(balance) => balance.unwrap(),
+ None => 0,
+ }
+}
+
+pub fn write_balance(env: &Env, owner: Identifier, write_type: WriteType) {
+ let key = DataKey::Balance(owner.clone());
+ let balance = read_balance(env, owner);
+
+ match write_type {
+ WriteType::Add => env.storage().set(key, balance + 1),
+ WriteType::Remove => env.storage().set(key, balance - 1),
+ }
+}
+
+pub fn read_supply(env: &Env) -> i128 {
+ let key = DataKey::Supply;
+ match env.storage().get(key) {
+ Some(balance) => balance.unwrap(),
+ None => 0,
+ }
+}
+
+pub fn increment_supply(env: &Env) {
+ let key = DataKey::Supply;
+ env.storage().set(key, read_supply(&env) + 1);
+}
+
+pub fn read_minted(env: &Env, owner: Identifier) -> bool {
+ let key = DataKey::Minted(owner);
+ match env.storage().get(key) {
+ Some(minted) => minted.unwrap(),
+ None => false,
+ }
+}
+
+pub fn write_minted(env: &Env, owner: Identifier) {
+ let key = DataKey::Minted(owner);
+ env.storage().set(key, true);
+}
+
+pub fn check_minted(env: &Env, owner: Identifier) {
+ assert!(!read_minted(&env, owner), "already minted");
+}
diff --git a/contracts/nft/src/contract.rs b/contracts/nft/src/contract.rs
new file mode 100644
index 00000000..c23eb8c2
--- /dev/null
+++ b/contracts/nft/src/contract.rs
@@ -0,0 +1,197 @@
+use crate::admin::{check_admin, has_administrator, read_administrator, write_administrator};
+use crate::approval::{read_approval, read_approval_all, write_approval, write_approval_all};
+use crate::balance::{
+ check_minted, increment_supply, read_balance, read_supply, write_balance, write_minted,
+};
+use crate::event;
+use crate::interface::{NonFungibleTokenTrait, WriteType};
+use crate::metadata::{
+ read_name, read_symbol, read_token_uri, write_name, write_symbol, write_token_uri,
+};
+use crate::owner::{check_owner, read_owner, write_owner, zero_address};
+use crate::storage_types::DataKey;
+use soroban_auth::verify;
+use soroban_auth::{Identifier, Signature};
+use soroban_sdk::{contractimpl, symbol, Bytes, Env};
+
+pub struct NonFungibleToken;
+
+fn read_nonce(env: &Env, id: &Identifier) -> i128 {
+ let key = DataKey::Nonce(id.clone());
+ env.storage().get(key).unwrap_or(Ok(0)).unwrap()
+}
+
+fn verify_and_consume_nonce(env: &Env, auth: &Signature, expected_nonce: i128) {
+ match auth {
+ Signature::Invoker => {
+ if expected_nonce != 0 {
+ panic!("nonce should be zero for Invoker")
+ }
+ return;
+ }
+ _ => {}
+ }
+
+ let id = auth.identifier(env);
+ let key = DataKey::Nonce(id.clone());
+ let nonce = read_nonce(env, &id);
+
+ assert!(nonce == expected_nonce, "incorrect nonce");
+
+ env.storage().set(key, &nonce + 1);
+}
+
+#[contractimpl]
+impl NonFungibleTokenTrait for NonFungibleToken {
+ fn initialize(env: Env, admin: Identifier, name: Bytes, symbol: Bytes) {
+ assert!(!has_administrator(&env), "already initialized");
+
+ write_administrator(&env, admin);
+ write_name(&env, name);
+ write_symbol(&env, symbol);
+ }
+
+ fn nonce(env: Env, id: Identifier) -> i128 {
+ read_nonce(&env, &id)
+ }
+
+ fn admin(env: Env) -> Identifier {
+ read_administrator(&env)
+ }
+
+ fn set_admin(env: Env, admin: Signature, nonce: i128, new_admin: Identifier) {
+ check_admin(&env, &admin);
+
+ verify_and_consume_nonce(&env, &admin, nonce);
+
+ let admin_id = admin.identifier(&env);
+
+ verify(
+ &env,
+ &admin,
+ symbol!("set_admin"),
+ (&admin_id, nonce, &new_admin),
+ );
+ write_administrator(&env, new_admin.clone());
+ event::set_admin(&env, admin_id, new_admin);
+ }
+
+ fn name(env: Env) -> Bytes {
+ read_name(&env)
+ }
+
+ fn symbol(env: Env) -> Bytes {
+ read_symbol(&env)
+ }
+
+ fn token_uri(env: Env, id: i128) -> Bytes {
+ read_token_uri(&env, id)
+ }
+
+ fn appr(env: Env, owner: Signature, nonce: i128, operator: Identifier, id: i128) {
+ check_owner(&env, &owner.identifier(&env), id);
+ verify_and_consume_nonce(&env, &owner, nonce);
+
+ write_approval(&env, id, operator.clone());
+
+ event::approve(&env, operator, id);
+ }
+
+ fn appr_all(env: Env, owner: Signature, nonce: i128, operator: Identifier, approved: bool) {
+ verify_and_consume_nonce(&env, &owner, nonce);
+
+ write_approval_all(&env, owner.identifier(&env), operator.clone(), approved);
+ event::approve_all(&env, operator, owner.identifier(&env))
+ }
+
+ fn get_appr(env: Env, id: i128) -> Identifier {
+ read_approval(&env, id)
+ }
+
+ fn is_appr(env: Env, owner: Identifier, operator: Identifier) -> bool {
+ read_approval_all(&env, owner, operator)
+ }
+
+ fn balance(env: Env, owner: Identifier) -> i128 {
+ read_balance(&env, owner)
+ }
+
+ fn owner(env: Env, id: i128) -> Identifier {
+ read_owner(&env, id)
+ }
+
+ fn xfer(env: Env, from: Signature, nonce: i128, to: Identifier, id: i128) {
+ check_owner(&env, &from.identifier(&env), id);
+ verify_and_consume_nonce(&env, &from, nonce);
+
+ write_owner(&env, id, to.clone());
+ write_balance(&env, from.identifier(&env), WriteType::Remove);
+ write_balance(&env, to.clone(), WriteType::Add);
+
+ event::transfer(&env, from.identifier(&env), to, id);
+ }
+
+ fn xfer_from(
+ env: Env,
+ spender: Signature,
+ from: Identifier,
+ to: Identifier,
+ nonce: i128,
+ id: i128,
+ ) {
+ check_owner(&env, &from, id);
+ verify_and_consume_nonce(&env, &spender, nonce);
+
+ if spender.identifier(&env) == read_approval(&env, id)
+ || read_approval_all(&env, from.clone(), spender.identifier(&env))
+ {
+ write_approval(&env, id, zero_address(&env));
+
+ write_owner(&env, id, to.clone());
+ write_balance(&env, from.clone(), WriteType::Remove);
+ write_balance(&env, to.clone(), WriteType::Add);
+
+ event::transfer(&env, from, to, id);
+ } else {
+ panic!("not approved")
+ }
+ }
+
+ fn mint(env: Env, admin: Signature, nonce: i128, to: Identifier, id: i128, uri:Bytes ) {
+ check_admin(&env, &admin);
+ verify_and_consume_nonce(&env, &admin, nonce);
+
+ write_balance(&env, to.clone(), WriteType::Add);
+ write_owner(&env, id, to.clone());
+ increment_supply(&env);
+ write_token_uri(&env, id, uri);
+
+ event::mint(&env, to, id)
+ }
+
+ fn mint_next(env: Env,uri:Bytes) {
+ let to = Identifier::from(env.invoker());
+ check_minted(&env, to.clone());
+ write_minted(&env, to.clone());
+
+ let next_id = read_supply(&env) + 1;
+
+ write_balance(&env, to.clone(), WriteType::Add);
+ write_owner(&env, next_id, to.clone());
+ increment_supply(&env);
+ write_token_uri(&env, next_id, uri);
+
+ event::mint(&env, to, next_id)
+ }
+
+ fn burn(env: Env, admin: Signature, nonce: i128, id: i128) {
+ check_admin(&env, &admin);
+ verify_and_consume_nonce(&env, &admin, nonce);
+
+ let from = read_owner(&env, id);
+ write_owner(&env, id, zero_address(&env));
+ write_balance(&env, from.clone(), WriteType::Remove);
+
+ event::burn(&env, from, id);
+ }
+}
diff --git a/contracts/nft/src/event.rs b/contracts/nft/src/event.rs
new file mode 100644
index 00000000..8d527005
--- /dev/null
+++ b/contracts/nft/src/event.rs
@@ -0,0 +1,32 @@
+use soroban_auth::Identifier;
+use soroban_sdk::{symbol, Env};
+
+pub(crate) fn transfer(e: &Env, from: Identifier, to: Identifier, id: i128) {
+ let topics = (symbol!("transfer"), from, to);
+ e.events().publish(topics, id);
+}
+
+pub(crate) fn set_admin(e: &Env, admin: Identifier, new_admin: Identifier) {
+ let topics = (symbol!("set_admin"), admin);
+ e.events().publish(topics, new_admin);
+}
+
+pub(crate) fn mint(e: &Env, to: Identifier, id: i128) {
+ let topics = (symbol!("mint"), to);
+ e.events().publish(topics, id);
+}
+
+pub(crate) fn burn(e: &Env, from: Identifier, id: i128) {
+ let topics = (symbol!("burn"), from);
+ e.events().publish(topics, id);
+}
+
+pub(crate) fn approve(e: &Env, operator: Identifier, id: i128) {
+ let topics = (symbol!("appr"), operator);
+ e.events().publish(topics, id);
+}
+
+pub(crate) fn approve_all(e: &Env, operator: Identifier, owner: Identifier) {
+ let topics = (symbol!("appr_all"), operator);
+ e.events().publish(topics, owner);
+}
diff --git a/contracts/nft/src/interface.rs b/contracts/nft/src/interface.rs
new file mode 100644
index 00000000..f690f4ca
--- /dev/null
+++ b/contracts/nft/src/interface.rs
@@ -0,0 +1,135 @@
+pub trait NonFungibleTokenTrait {
+ // --------------------------------------------------------------------------------
+ // Authentication interface
+ // --------------------------------------------------------------------------------
+
+ // Returns the current nonce for "id".
+ fn nonce(env: soroban_sdk::Env, id: soroban_auth::Identifier) -> i128;
+
+ // --------------------------------------------------------------------------------
+ // Admin interface
+ // --------------------------------------------------------------------------------
+
+ /// Returns the current administrator
+ fn admin(env: soroban_sdk::Env) -> soroban_auth::Identifier;
+
+ /// If "admin" is the administrator, set the administrator to "new_admin".
+ /// Emit event with topics = ["set_admin", admin: Identifier], data = [new_admin: Identifier]
+ fn set_admin(
+ env: soroban_sdk::Env,
+ admin: soroban_auth::Signature,
+ nonce: i128,
+ new_admin: soroban_auth::Identifier,
+ );
+
+ // --------------------------------------------------------------------------------
+ // Metadata interface
+ // --------------------------------------------------------------------------------
+
+ // Get the name for this token.
+ fn name(env: soroban_sdk::Env) -> soroban_sdk::Bytes;
+
+ // Get the symbol for this token.
+ fn symbol(env: soroban_sdk::Env) -> soroban_sdk::Bytes;
+
+ // Get the uniform resource identifier for token "id".
+ fn token_uri(env: soroban_sdk::Env, id: i128) -> soroban_sdk::Bytes;
+
+ // --------------------------------------------------------------------------------
+ // Token interface
+ // --------------------------------------------------------------------------------
+
+ /// Allows "operator" to manage token "id" if "owner" is the current owner of token "id".
+ /// Emit event with topics = ["appr", operator: Identifier], data = [id: i128]
+ fn appr(
+ env: soroban_sdk::Env,
+ owner: soroban_auth::Signature,
+ nonce: i128,
+ operator: soroban_auth::Identifier,
+ id: i128,
+ );
+
+ /// If "approved", allows "operator" to manage all tokens of "owner"
+ /// Emit event with topics = ["appr_all", operator: Identifier], data = [owner: Identifier]
+ fn appr_all(
+ env: soroban_sdk::Env,
+ owner: soroban_auth::Signature,
+ nonce: i128,
+ operator: soroban_auth::Identifier,
+ approved: bool,
+ );
+
+ /// Returns the identifier approved for token "id".
+ fn get_appr(env: soroban_sdk::Env, id: i128) -> soroban_auth::Identifier;
+
+ /// If "operator" is allowed to manage assets of "owner", return true.
+ fn is_appr(
+ env: soroban_sdk::Env,
+ owner: soroban_auth::Identifier,
+ operator: soroban_auth::Identifier,
+ ) -> bool;
+
+ /// Get the balance of "id".
+ fn balance(env: soroban_sdk::Env, owner: soroban_auth::Identifier) -> i128;
+
+ /// Get the owner of "id" token.
+ fn owner(env: soroban_sdk::Env, id: i128) -> soroban_auth::Identifier;
+
+ /// Transfer token "id" from "from" to "to.
+ /// Emit event with topics = ["transfer", from: Identifier, to: Identifier], data = [id: i128]
+ fn xfer(
+ env: soroban_sdk::Env,
+ from: soroban_auth::Signature,
+ nonce: i128,
+ to: soroban_auth::Identifier,
+ id: i128,
+ );
+
+ /// Transfer token "id" from "from" to "to", consuming the allowance of "spender".
+ /// Emit event with topics = ["transfer", from: Identifier, to: Identifier], data = [id: i128]
+ fn xfer_from(
+ env: soroban_sdk::Env,
+ spender: soroban_auth::Signature,
+ from: soroban_auth::Identifier,
+ to: soroban_auth::Identifier,
+ nonce: i128,
+ id: i128,
+ );
+
+ /// If "admin" is the administrator, mint token "id" to "to".
+ /// Emit event with topics = ["mint", to: Identifier], data = [id: i128]
+ fn mint(
+ env: soroban_sdk::Env,
+ admin: soroban_auth::Signature,
+ nonce: i128,
+ to: soroban_auth::Identifier,
+ id: i128,
+ uri:soroban_sdk::Bytes
+ );
+
+ /// Mint the next token to "to" for demonstration.
+ /// Emit event with topics = ["mint", to: Identifier], data = [id: i128]
+ fn mint_next(env: soroban_sdk::Env, uri:soroban_sdk::Bytes);
+
+ /// If "admin" is the administrator or the token owner, burn token "id" from "from".
+ /// Emit event with topics = ["burn", from: Identifier], data = [id: i128]
+ fn burn(env: soroban_sdk::Env, admin: soroban_auth::Signature, nonce: i128, id: i128);
+
+ // --------------------------------------------------------------------------------
+ // Implementation Interface
+ // --------------------------------------------------------------------------------
+
+ /// Initialize the contract with "admin" as administrator, "name" as the name, and
+ /// "symbol" as the symbol.
+ fn initialize(
+ e: soroban_sdk::Env,
+ admin: soroban_auth::Identifier,
+ name: soroban_sdk::Bytes,
+ symbol: soroban_sdk::Bytes,
+ );
+}
+
+pub enum WriteType {
+ Add,
+ Remove,
+}
diff --git a/contracts/nft/src/lib.rs b/contracts/nft/src/lib.rs
new file mode 100644
index 00000000..6f3b789c
--- /dev/null
+++ b/contracts/nft/src/lib.rs
@@ -0,0 +1,13 @@
+#![no_std]
+
+mod admin;
+mod approval;
+mod balance;
+mod contract;
+mod event;
+mod interface;
+mod metadata;
+mod owner;
+mod storage_types;
+
+pub use crate::contract::NonFungibleTokenClient;
diff --git a/contracts/nft/src/metadata.rs b/contracts/nft/src/metadata.rs
new file mode 100644
index 00000000..82964c7b
--- /dev/null
+++ b/contracts/nft/src/metadata.rs
@@ -0,0 +1,34 @@
+use crate::{ storage_types::DataKey};
+use soroban_sdk::{Bytes, Env};
+
+pub fn read_name(env: &Env) -> Bytes {
+ let key = DataKey::Name;
+ env.storage().get_unchecked(key).unwrap()
+}
+
+pub fn write_name(env: &Env, name: Bytes) {
+ let key = DataKey::Name;
+ env.storage().set(key, name)
+}
+
+pub fn read_symbol(env: &Env) -> Bytes {
+ let key = DataKey::Symbol;
+ env.storage().get_unchecked(key).unwrap()
+}
+
+pub fn write_symbol(env: &Env, symbol: Bytes) {
+ let key = DataKey::Symbol;
+ env.storage().set(key, symbol)
+}
+
+pub fn read_token_uri(env: &Env, id: i128) -> Bytes {
+ let key = DataKey::URI(id);
+ env.storage().get_unchecked(key).unwrap()
+}
+
+pub fn write_token_uri(env: &Env, id: i128, uri: Bytes) {
+ let key = DataKey::URI(id);
+ env.storage().set(key, uri)
+}
+
+
diff --git a/contracts/nft/src/owner.rs b/contracts/nft/src/owner.rs
new file mode 100644
index 00000000..5f112462
--- /dev/null
+++ b/contracts/nft/src/owner.rs
@@ -0,0 +1,28 @@
+use crate::storage_types::DataKey;
+use soroban_auth::Identifier;
+use soroban_sdk::{BytesN, Env};
+
+pub fn zero_address(env: &Env) -> Identifier {
+ Identifier::Ed25519(BytesN::from_array(env, &[0u8; 32]))
+}
+
+pub fn read_owner(env: &Env, id: i128) -> Identifier {
+ let key = DataKey::Owner(id);
+ match env.storage().get(key) {
+ Some(balance) => balance.unwrap(),
+ None => zero_address(&env),
+ }
+}
+
+pub fn write_owner(env: &Env, id: i128, owner: Identifier) {
+ let key = DataKey::Owner(id);
+ env.storage().set(key, owner);
+}
+
+pub fn check_owner(env: &Env, auth: &Identifier, id: i128) {
+ assert!(
+ auth == &read_owner(env, id),
+ "not the owner for token {}",
+ id
+ );
+}
diff --git a/contracts/nft/src/storage_types.rs b/contracts/nft/src/storage_types.rs
new file mode 100644
index 00000000..7acad1b1
--- /dev/null
+++ b/contracts/nft/src/storage_types.rs
@@ -0,0 +1,31 @@
+use soroban_auth::Identifier;
+use soroban_sdk::contracttype;
+
+#[derive(Clone)]
+#[contracttype]
+pub struct ApprovalAll {
+ pub operator: Identifier,
+ pub owner: Identifier,
+}
+
+#[derive(Clone)]
+#[contracttype]
+pub enum ApprovalKey {
+ All(ApprovalAll),
+ ID(i128),
+}
+
+#[derive(Clone)]
+#[contracttype]
+pub enum DataKey {
+ Balance(Identifier),
+ Nonce(Identifier),
+ Minted(Identifier),
+ Admin,
+ Name,
+ Symbol,
+ URI(i128),
+ Approval(ApprovalKey),
+ Owner(i128),
+ Supply,
+}
diff --git a/contracts/nft/src/test.rs b/contracts/nft/src/test.rs
new file mode 100644
index 00000000..c4abcf94
--- /dev/null
+++ b/contracts/nft/src/test.rs
@@ -0,0 +1,264 @@
+#![cfg(test)]
+use crate::interface::NftURIs;
+use crate::metadata::to_bytes;
+use crate::owner::zero_address;
+use crate::testutils::{to_ed25519, Token, TOKEN_NAME, TOKEN_SYMBOL};
+use ed25519_dalek::Keypair;
+use rand::thread_rng;
+use soroban_sdk::testutils::Accounts;
+
+fn generate_keypair() -> Keypair {
+ Keypair::generate(&mut thread_rng())
+}
+
+#[test]
+fn test_mint() {
+ let (env, token) = Token::create();
+
+ let admin = generate_keypair();
+ let admin_id = to_ed25519(&env, &admin);
+ let user = generate_keypair();
+ let user_id = to_ed25519(&env, &user);
+
+ token.initialize(&admin_id);
+ assert_eq!(token.name(), to_bytes(&env, TOKEN_NAME));
+ assert_eq!(token.symbol(), to_bytes(&env, TOKEN_SYMBOL));
+
+ token.mint(&admin, &user_id, &1);
+ assert_eq!(token.balance(&user_id), 1);
+ assert_eq!(token.nonce(&admin_id), 1);
+ assert_eq!(token.owner(&1), user_id);
+
+ let uri = token.token_uri(&1);
+ assert!(
+ uri == to_bytes(&env, NftURIs::Bacon.value())
+ || uri == to_bytes(&env, NftURIs::Bailey.value())
+ || uri == to_bytes(&env, NftURIs::Coco.value())
+ || uri == to_bytes(&env, NftURIs::Frankie.value())
+ || uri == to_bytes(&env, NftURIs::Marley.value())
+ || uri == to_bytes(&env, NftURIs::Noir.value())
+ || uri == to_bytes(&env, NftURIs::Riley.value())
+ || uri == to_bytes(&env, NftURIs::Scout.value())
+ || uri == to_bytes(&env, NftURIs::Shadow.value())
+ );
+}
+
+#[test]
+fn test_mint_next() {
+ let (env, token) = Token::create();
+
+ let admin = generate_keypair();
+ let admin_id = to_ed25519(&env, &admin);
+
+ token.initialize(&admin_id);
+
+ let user1 = env.accounts().generate();
+ token.mint_next(&user1);
+ assert_eq!(token.balance(&(&user1).into()), 1);
+ assert_eq!(token.owner(&1), (&user1).into());
+
+ let user2 = env.accounts().generate();
+ token.mint_next(&user2);
+ assert_eq!(token.balance(&(&user2).into()), 1);
+ assert_eq!(token.owner(&2), (&user2).into());
+}
+
+#[test]
+#[should_panic(expected = "already minted")]
+fn test_mint_next_twice() {
+ let (env, token) = Token::create();
+
+ let admin = generate_keypair();
+ let admin_id = to_ed25519(&env, &admin);
+
+ token.initialize(&admin_id);
+
+ let user1 = env.accounts().generate();
+ token.mint_next(&user1);
+ assert_eq!(token.balance(&(&user1).into()), 1);
+ assert_eq!(token.owner(&1), (&user1).into());
+
+ token.mint_next(&user1);
+ token.mint_next(&user1);
+}
+
+#[test]
+fn test_burn() {
+ let (env, token) = Token::create();
+
+ let admin = generate_keypair();
+ let admin_id = to_ed25519(&env, &admin);
+ let user = generate_keypair();
+ let user_id = to_ed25519(&env, &user);
+
+ token.initialize(&admin_id);
+
+ token.mint(&admin, &user_id, &1);
+ assert_eq!(token.balance(&user_id), 1);
+ assert_eq!(token.nonce(&admin_id), 1);
+ assert_eq!(token.owner(&1), user_id);
+
+ token.burn(&admin, &1);
+ assert_eq!(token.balance(&user_id), 0);
+ assert_eq!(token.owner(&1), zero_address(&env));
+}
+
+#[test]
+fn test_xfer() {
+ let (env, token) = Token::create();
+
+ let admin = generate_keypair();
+ let admin_id = to_ed25519(&env, &admin);
+ let user1 = generate_keypair();
+ let user1_id = to_ed25519(&env, &user1);
+ let user2 = generate_keypair();
+ let user2_id = to_ed25519(&env, &user2);
+
+ token.initialize(&admin_id);
+
+ token.mint(&admin, &user1_id, &1);
+ assert_eq!(token.balance(&user1_id), 1);
+ assert_eq!(token.balance(&user2_id), 0);
+ assert_eq!(token.nonce(&admin_id), 1);
+ assert_eq!(token.owner(&1), user1_id);
+
+ token.xfer(&user1, &user2_id, &1);
+ assert_eq!(token.balance(&user1_id), 0);
+ assert_eq!(token.balance(&user2_id), 1);
+ assert_eq!(token.nonce(&user1_id), 1);
+ assert_eq!(token.owner(&1), user2_id);
+}
+
+#[test]
+#[should_panic(expected = "not the owner for token 2")]
+fn test_xfer_non_owner() {
+ let (env, token) = Token::create();
+
+ let admin = generate_keypair();
+ let admin_id = to_ed25519(&env, &admin);
+ let user1 = generate_keypair();
+ let user1_id = to_ed25519(&env, &user1);
+ let user2 = generate_keypair();
+ let user2_id = to_ed25519(&env, &user2);
+
+ token.initialize(&admin_id);
+
+ token.mint(&admin, &user1_id, &1);
+ assert_eq!(token.balance(&user1_id), 1);
+ assert_eq!(token.nonce(&admin_id), 1);
+ assert_eq!(token.owner(&1), user1_id);
+
+ token.xfer(&user1, &user2_id, &2);
+}
+
+#[test]
+fn test_xfer_from_appr_id() {
+ let (env, token) = Token::create();
+
+ let admin = generate_keypair();
+ let user1 = generate_keypair();
+ let user2 = generate_keypair();
+ let user3 = generate_keypair();
+ let admin_id = to_ed25519(&env, &admin);
+ let user1_id = to_ed25519(&env, &user1);
+ let user2_id = to_ed25519(&env, &user2);
+ let user3_id = to_ed25519(&env, &user3);
+
+ token.initialize(&admin_id);
+
+ token.mint(&admin, &user1_id, &1);
+ assert_eq!(token.balance(&user1_id), 1);
+ assert_eq!(token.nonce(&admin_id), 1);
+ assert_eq!(token.owner(&1), user1_id);
+
+ token.appr(&user1, &user3_id, &1);
+ assert_eq!(token.get_appr(&1), user3_id);
+
+ token.xfer_from(&user3, &user1_id, &user2_id, &1);
+ assert_eq!(token.balance(&user2_id), 1);
+ assert_eq!(token.balance(&user1_id), 0);
+ assert_eq!(token.nonce(&admin_id), 1);
+ assert_eq!(token.owner(&1), user2_id);
+ assert_eq!(token.get_appr(&1), zero_address(&env));
+}
+
+#[test]
+fn test_xfer_from_appr_all() {
+ let (env, token) = Token::create();
+
+ let admin = generate_keypair();
+ let user1 = generate_keypair();
+ let user2 = generate_keypair();
+ let user3 = generate_keypair();
+ let admin_id = to_ed25519(&env, &admin);
+ let user1_id = to_ed25519(&env, &user1);
+ let user2_id = to_ed25519(&env, &user2);
+ let user3_id = to_ed25519(&env, &user3);
+
+ token.initialize(&admin_id);
+
+ token.mint(&admin, &user1_id, &1);
+ assert_eq!(token.balance(&user1_id), 1);
+ assert_eq!(token.nonce(&admin_id), 1);
+ assert_eq!(token.owner(&1), user1_id);
+
+ token.appr_all(&user1, &user3_id);
+ assert!(token.is_appr(&user1_id, &user3_id));
+
+ token.xfer_from(&user3, &user1_id, &user2_id, &1);
+ assert_eq!(token.balance(&user2_id), 1);
+ assert_eq!(token.balance(&user1_id), 0);
+ assert_eq!(token.nonce(&admin_id), 1);
+ assert_eq!(token.owner(&1), user2_id);
+ assert_eq!(token.get_appr(&1), zero_address(&env));
+}
+
+#[test]
+#[should_panic(expected = "not approved")]
+fn test_xfer_from_non_approved() {
+ let (env, token) = Token::create();
+
+ let admin1 = generate_keypair();
+ let user1 = generate_keypair();
+ let user2 = generate_keypair();
+ let user3 = generate_keypair();
+ let admin1_id = to_ed25519(&env, &admin1);
+ let user1_id = to_ed25519(&env, &user1);
+ let user2_id = to_ed25519(&env, &user2);
+
+ token.initialize(&admin1_id);
+
+ token.mint(&admin1, &user1_id, &1);
+ assert_eq!(token.balance(&user1_id), 1);
+ assert_eq!(token.nonce(&admin1_id), 1);
+ assert_eq!(token.owner(&1), user1_id);
+
+ token.xfer_from(&user3, &user1_id, &user2_id, &1);
+}
+
+#[test]
+#[should_panic(expected = "already initialized")]
+fn test_initialize_already_initialized() {
+ let (env, token) = Token::create();
+
+ let admin1 = generate_keypair();
+ let admin1_id = to_ed25519(&env, &admin1);
+
+ token.initialize(&admin1_id);
+ token.initialize(&admin1_id);
+}
+
+#[test]
+#[should_panic(expected = "not authorized by admin")]
+fn test_set_admin_bad_actor() {
+ let (env, token) = Token::create();
+
+ let admin = generate_keypair();
+ let user = generate_keypair();
+ let admin_id = to_ed25519(&env, &admin);
+ let user_id = to_ed25519(&env, &user);
+
+ token.initialize(&admin_id);
+
+ token.set_admin(&user, &user_id);
+}
diff --git a/contracts/nft/src/testutils.rs b/contracts/nft/src/testutils.rs
new file mode 100644
index 00000000..230a9f62
--- /dev/null
+++ b/contracts/nft/src/testutils.rs
@@ -0,0 +1,215 @@
+#![cfg(any(test, feature = "testutils"))]
+
+use crate::contract::{NonFungibleToken, NonFungibleTokenClient};
+use ed25519_dalek::Keypair;
+use soroban_auth::{Ed25519Signature, Identifier, Signature, SignaturePayload, SignaturePayloadV0};
+use soroban_sdk::testutils::ed25519::Sign;
+use soroban_sdk::{symbol, AccountId, Bytes, BytesN, Env, IntoVal};
+
+pub const TOKEN_NAME: &str = "Non Fungible Dogs";
+pub const TOKEN_SYMBOL: &str = "NFD";
+
+pub fn register_contract(env: &Env) -> BytesN<32> {
+ env.register_contract(None, NonFungibleToken {})
+}
+
+pub fn to_ed25519(env: &Env, kp: &Keypair) -> Identifier {
+ Identifier::Ed25519(kp.public.to_bytes().into_val(env))
+}
+
+pub struct Token {
+ env: Env,
+ contract_id: BytesN<32>,
+}
+
+impl Token {
+ pub fn new(env: &Env, contract_id: &BytesN<32>) -> Self {
+ Self {
+ env: env.clone(),
+ contract_id: contract_id.clone(),
+ }
+ }
+
+ pub fn create() -> (Env, Token) {
+ let env: Env = Default::default();
+ let contract_id = register_contract(&env);
+ let token = Token::new(&env, &contract_id);
+ (env, token)
+ }
+
+ pub fn initialize(&self, admin: &Identifier) {
+ let name: Bytes = TOKEN_NAME.into_val(&self.env);
+ let symbol: Bytes = TOKEN_SYMBOL.into_val(&self.env);
+ NonFungibleTokenClient::new(&self.env, &self.contract_id).initialize(admin, &name, &symbol);
+ }
+
+ pub fn nonce(&self, owner: &Identifier) -> i128 {
+ NonFungibleTokenClient::new(&self.env, &self.contract_id).nonce(owner)
+ }
+
+ pub fn balance(&self, owner: &Identifier) -> i128 {
+ NonFungibleTokenClient::new(&self.env, &self.contract_id).balance(owner)
+ }
+
+ pub fn owner(&self, id: &i128) -> Identifier {
+ NonFungibleTokenClient::new(&self.env, &self.contract_id).owner(id)
+ }
+
+ pub fn token_uri(&self, id: &i128) -> Bytes {
+ NonFungibleTokenClient::new(&self.env, &self.contract_id).token_uri(id)
+ }
+
+ pub fn get_appr(&self, id: &i128) -> Identifier {
+ NonFungibleTokenClient::new(&self.env, &self.contract_id).get_appr(id)
+ }
+
+ pub fn is_appr(&self, owner: &Identifier, operator: &Identifier) -> bool {
+ NonFungibleTokenClient::new(&self.env, &self.contract_id).is_appr(&owner, &operator)
+ }
+
+ pub fn appr(&self, owner: &Keypair, operator: &Identifier, id: &i128) {
+ let owner_id = to_ed25519(&self.env, owner);
+ let nonce = self.nonce(&owner_id);
+
+ let msg = SignaturePayload::V0(SignaturePayloadV0 {
+ name: symbol!("appr"),
+ contract: self.contract_id.clone(),
+ network: self.env.ledger().network_passphrase(),
+ args: (owner_id, &nonce, operator, id).into_val(&self.env),
+ });
+
+ let auth = Signature::Ed25519(Ed25519Signature {
+ public_key: BytesN::from_array(&self.env, &owner.public.to_bytes()),
+ signature: owner.sign(msg).unwrap().into_val(&self.env),
+ });
+
+ NonFungibleTokenClient::new(&self.env, &self.contract_id).appr(&auth, &nonce, operator, id);
+ }
+
+ pub fn appr_all(&self, owner: &Keypair, operator: &Identifier) {
+ let owner_id = to_ed25519(&self.env, owner);
+ let nonce = self.nonce(&owner_id);
+
+ let msg = SignaturePayload::V0(SignaturePayloadV0 {
+ name: symbol!("appr_all"),
+ contract: self.contract_id.clone(),
+ network: self.env.ledger().network_passphrase(),
+ args: (owner_id, &nonce, operator).into_val(&self.env),
+ });
+
+ let auth = Signature::Ed25519(Ed25519Signature {
+ public_key: BytesN::from_array(&self.env, &owner.public.to_bytes()),
+ signature: owner.sign(msg).unwrap().into_val(&self.env),
+ });
+
+ NonFungibleTokenClient::new(&self.env, &self.contract_id)
+ .appr_all(&auth, &nonce, operator, &true);
+ }
+
+ pub fn xfer(&self, from: &Keypair, to: &Identifier, id: &i128) {
+ let from_id = to_ed25519(&self.env, from);
+ let nonce = self.nonce(&from_id);
+
+ let msg = SignaturePayload::V0(SignaturePayloadV0 {
+ name: symbol!("xfer"),
+ contract: self.contract_id.clone(),
+ network: self.env.ledger().network_passphrase(),
+ args: (from_id, &nonce, to, id).into_val(&self.env),
+ });
+
+ let auth = Signature::Ed25519(Ed25519Signature {
+ public_key: BytesN::from_array(&self.env, &from.public.to_bytes()),
+ signature: from.sign(msg).unwrap().into_val(&self.env),
+ });
+
+ NonFungibleTokenClient::new(&self.env, &self.contract_id).xfer(&auth, &nonce, to, id);
+ }
+
+ pub fn xfer_from(&self, spender: &Keypair, from: &Identifier, to: &Identifier, id: &i128) {
+ let spender_id = to_ed25519(&self.env, spender);
+ let nonce = self.nonce(&spender_id);
+
+ let msg = SignaturePayload::V0(SignaturePayloadV0 {
+ name: symbol!("xfer_from"),
+ contract: self.contract_id.clone(),
+ network: self.env.ledger().network_passphrase(),
+ args: (spender_id, &nonce, from, to, id).into_val(&self.env),
+ });
+
+ let auth = Signature::Ed25519(Ed25519Signature {
+ public_key: spender.public.to_bytes().into_val(&self.env),
+ signature: spender.sign(msg).unwrap().into_val(&self.env),
+ });
+
+ NonFungibleTokenClient::new(&self.env, &self.contract_id)
+ .xfer_from(&auth, &from, &to, &nonce, id);
+ }
+
+ pub fn mint(&self, admin: &Keypair, to: &Identifier, id: &i128) {
+ let admin_id = to_ed25519(&self.env, admin);
+ let nonce = self.nonce(&admin_id);
+
+ let msg = SignaturePayload::V0(SignaturePayloadV0 {
+ name: symbol!("mint"),
+ contract: self.contract_id.clone(),
+ network: self.env.ledger().network_passphrase(),
+ args: (admin_id, &nonce, to, id).into_val(&self.env),
+ });
+ let auth = Signature::Ed25519(Ed25519Signature {
+ public_key: admin.public.to_bytes().into_val(&self.env),
+ signature: admin.sign(msg).unwrap().into_val(&self.env),
+ });
+ NonFungibleTokenClient::new(&self.env, &self.contract_id).mint(&auth, &nonce, to, id);
+ }
+
+ pub fn mint_next(&self, source_account: &AccountId) {
+ NonFungibleTokenClient::new(&self.env, &self.contract_id)
+ .with_source_account(source_account)
+ .mint_next();
+ }
+
+ pub fn burn(&self, admin: &Keypair, id: &i128) {
+ let from_id = to_ed25519(&self.env, admin);
+ let nonce = self.nonce(&from_id);
+
+ let msg = SignaturePayload::V0(SignaturePayloadV0 {
+ name: symbol!("burn"),
+ contract: self.contract_id.clone(),
+ network: self.env.ledger().network_passphrase(),
+ args: (from_id, &nonce, id).into_val(&self.env),
+ });
+
+ let auth = Signature::Ed25519(Ed25519Signature {
+ public_key: BytesN::from_array(&self.env, &admin.public.to_bytes()),
+ signature: admin.sign(msg).unwrap().into_val(&self.env),
+ });
+
+ NonFungibleTokenClient::new(&self.env, &self.contract_id).burn(&auth, &nonce, id);
+ }
+
+ pub fn set_admin(&self, admin: &Keypair, new_admin: &Identifier) {
+ let admin_id = to_ed25519(&self.env, admin);
+ let nonce = self.nonce(&admin_id);
+
+ let msg = SignaturePayload::V0(SignaturePayloadV0 {
+ name: symbol!("set_admin"),
+ contract: self.contract_id.clone(),
+ network: self.env.ledger().network_passphrase(),
+ args: (admin_id, &nonce, new_admin).into_val(&self.env),
+ });
+ let auth = Signature::Ed25519(Ed25519Signature {
+ public_key: admin.public.to_bytes().into_val(&self.env),
+ signature: admin.sign(msg).unwrap().into_val(&self.env),
+ });
+ NonFungibleTokenClient::new(&self.env, &self.contract_id)
+ .set_admin(&auth, &nonce, new_admin);
+ }
+
+ pub fn name(&self) -> Bytes {
+ NonFungibleTokenClient::new(&self.env, &self.contract_id).name()
+ }
+
+ pub fn symbol(&self) -> Bytes {
+ NonFungibleTokenClient::new(&self.env, &self.contract_id).symbol()
+ }
+}