From 9db84339fcced4bcca61cd4596a280ec981f76d0 Mon Sep 17 00:00:00 2001 From: Chad Ostrowski <221614+chadoh@users.noreply.github.com> Date: Sat, 13 Jul 2024 13:09:26 -0400 Subject: [PATCH] use example contracts from loam-sdk --- Cargo.lock | 351 ++++++--- contracts/atomic_swap/Cargo.toml | 15 - contracts/atomic_swap/src/lib.rs | 77 -- contracts/atomic_swap/src/test.rs | 112 --- contracts/auth/Cargo.toml | 14 - contracts/auth/src/lib.rs | 65 -- contracts/auth/src/test.rs | 57 -- contracts/core/Cargo.toml | 24 + contracts/core/src/lib.rs | 6 + contracts/errors/Cargo.toml | 15 - contracts/errors/src/lib.rs | 43 - contracts/errors/src/test.rs | 37 - contracts/hello_world/Cargo.toml | 15 - contracts/hello_world/src/lib.rs | 14 - contracts/hello_world/src/test.rs | 17 - contracts/increment/Cargo.toml | 15 - contracts/increment/src/lib.rs | 34 - contracts/increment/src/test.rs | 19 - contracts/status_message/Cargo.toml | 18 + contracts/status_message/src/lib.rs | 10 + .../status_message/src/status_message.rs | 42 + contracts/token/Cargo.toml | 15 - contracts/token/src/admin.rs | 18 - contracts/token/src/allowance.rs | 65 -- contracts/token/src/balance.rs | 35 - contracts/token/src/contract.rs | 176 ----- contracts/token/src/lib.rs | 11 - contracts/token/src/metadata.rs | 22 - contracts/token/src/storage_types.rs | 30 - contracts/token/src/test.rs | 266 ------- package-lock.json | 733 ++++++------------ package.json | 4 +- src/pages/index.astro | 246 +++--- 33 files changed, 731 insertions(+), 1890 deletions(-) delete mode 100644 contracts/atomic_swap/Cargo.toml delete mode 100644 contracts/atomic_swap/src/lib.rs delete mode 100644 contracts/atomic_swap/src/test.rs delete mode 100644 contracts/auth/Cargo.toml delete mode 100644 contracts/auth/src/lib.rs delete mode 100644 contracts/auth/src/test.rs create mode 100644 contracts/core/Cargo.toml create mode 100644 contracts/core/src/lib.rs delete mode 100644 contracts/errors/Cargo.toml delete mode 100644 contracts/errors/src/lib.rs delete mode 100644 contracts/errors/src/test.rs delete mode 100644 contracts/hello_world/Cargo.toml delete mode 100644 contracts/hello_world/src/lib.rs delete mode 100644 contracts/hello_world/src/test.rs delete mode 100644 contracts/increment/Cargo.toml delete mode 100644 contracts/increment/src/lib.rs delete mode 100644 contracts/increment/src/test.rs create mode 100644 contracts/status_message/Cargo.toml create mode 100644 contracts/status_message/src/lib.rs create mode 100644 contracts/status_message/src/status_message.rs delete mode 100644 contracts/token/Cargo.toml delete mode 100644 contracts/token/src/admin.rs delete mode 100644 contracts/token/src/allowance.rs delete mode 100644 contracts/token/src/balance.rs delete mode 100644 contracts/token/src/contract.rs delete mode 100644 contracts/token/src/lib.rs delete mode 100644 contracts/token/src/metadata.rs delete mode 100644 contracts/token/src/storage_types.rs delete mode 100644 contracts/token/src/test.rs diff --git a/Cargo.lock b/Cargo.lock index 8aa41a4..3e76c1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" + [[package]] name = "addr2line" version = "0.21.0" @@ -92,6 +98,15 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bitmaps" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" +dependencies = [ + "typenum", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -119,6 +134,38 @@ dependencies = [ "syn", ] +[[package]] +name = "camino" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceed8ef69d8518a5dda55c07425450b58a4e1946f4951eab6d7191ee86c2443d" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "cc" version = "1.0.83" @@ -241,9 +288,9 @@ dependencies = [ [[package]] name = "darling" -version = "0.20.3" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ "darling_core", "darling_macro", @@ -251,9 +298,9 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.3" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", @@ -265,9 +312,9 @@ dependencies = [ [[package]] name = "darling_macro" -version = "0.20.3" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", @@ -334,7 +381,6 @@ dependencies = [ "elliptic-curve", "rfc6979", "signature", - "spki", ] [[package]] @@ -349,15 +395,16 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.0.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ "curve25519-dalek", "ed25519", "rand_core", "serde", "sha2", + "subtle", "zeroize", ] @@ -379,7 +426,6 @@ dependencies = [ "ff", "generic-array", "group", - "pkcs8", "rand_core", "sec1", "subtle", @@ -404,6 +450,23 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b90ca2580b73ab6a1f724b76ca11ab632df820fd6040c336200d2c1df7b3c82c" +[[package]] +name = "example-core" +version = "0.0.0" +dependencies = [ + "loam-sdk", + "loam-soroban-sdk", + "loam-subcontract-core", +] + +[[package]] +name = "example-status-message" +version = "0.0.0" +dependencies = [ + "loam-sdk", + "loam-subcontract-core", +] + [[package]] name = "ff" version = "0.13.0" @@ -479,13 +542,6 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" -[[package]] -name = "hello-world" -version = "0.0.0" -dependencies = [ - "soroban-sdk", -] - [[package]] name = "hex" version = "0.4.3" @@ -539,6 +595,20 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "im-rc" +version = "15.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af1955a75fa080c677d3972822ec4bad316169ab1cfc6c257a942c2265dbe5fe" +dependencies = [ + "bitmaps", + "rand_core", + "rand_xoshiro", + "sized-chunks", + "typenum", + "version_check", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -567,6 +637,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.11.0" @@ -576,6 +655,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.10" @@ -600,9 +688,7 @@ dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "once_cell", "sha2", - "signature", ] [[package]] @@ -626,6 +712,54 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +[[package]] +name = "loam-build" +version = "0.7.1" +dependencies = [ + "cargo_metadata", + "thiserror", + "topological-sort", +] + +[[package]] +name = "loam-sdk" +version = "0.6.11" +dependencies = [ + "loam-sdk-macro", + "loam-soroban-sdk", +] + +[[package]] +name = "loam-sdk-macro" +version = "0.8.1" +dependencies = [ + "Inflector", + "cargo_metadata", + "darling", + "itertools 0.12.1", + "loam-build", + "proc-macro2", + "quote", + "syn", + "syn-file-expand", + "thiserror", +] + +[[package]] +name = "loam-soroban-sdk" +version = "0.6.11" +dependencies = [ + "loam-sdk-macro", + "soroban-sdk", +] + +[[package]] +name = "loam-subcontract-core" +version = "0.7.3" +dependencies = [ + "loam-sdk", +] + [[package]] name = "log" version = "0.4.20" @@ -703,6 +837,18 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] + [[package]] name = "paste" version = "1.0.14" @@ -747,6 +893,15 @@ dependencies = [ "syn", ] +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "proc-macro2" version = "1.0.69" @@ -795,6 +950,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_xoshiro" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" +dependencies = [ + "rand_core", +] + [[package]] name = "rfc6979" version = "0.4.0" @@ -835,16 +999,18 @@ dependencies = [ "base16ct", "der", "generic-array", - "pkcs8", "subtle", "zeroize", ] [[package]] name = "semver" -version = "1.0.21" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +dependencies = [ + "serde", +] [[package]] name = "serde" @@ -938,32 +1104,28 @@ dependencies = [ ] [[package]] -name = "smallvec" -version = "1.13.1" +name = "sized-chunks" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" - -[[package]] -name = "soroban-atomic-swap-contract" -version = "0.0.0" +checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" dependencies = [ - "soroban-sdk", + "bitmaps", + "typenum", ] [[package]] -name = "soroban-auth-contract" -version = "0.0.0" -dependencies = [ - "soroban-sdk", -] +name = "smallvec" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "soroban-builtin-sdk-macros" -version = "20.3.0" +version = "21.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc32c6e817f3ca269764ec0d7d14da6210b74a5bf14d4e745aa3ee860558900" +checksum = "4aa78f4b1c752f5471b033fe54279ef0617ace342be7be11acc7d90e5677790e" dependencies = [ - "itertools", + "itertools 0.11.0", "proc-macro2", "quote", "syn", @@ -971,9 +1133,9 @@ dependencies = [ [[package]] name = "soroban-env-common" -version = "20.3.0" +version = "21.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c14e18d879c520ff82612eaae0590acaf6a7f3b977407e1abb1c9e31f94c7814" +checksum = "9acd7dbf8fc4222f62a4f06c5b32c3e097de97f5ff48218c8d77676d3424f363" dependencies = [ "arbitrary", "crate-git-revision", @@ -985,13 +1147,14 @@ dependencies = [ "soroban-wasmi", "static_assertions", "stellar-xdr", + "wasmparser", ] [[package]] name = "soroban-env-guest" -version = "20.3.0" +version = "21.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5122ca2abd5ebcc1e876a96b9b44f87ce0a0e06df8f7c09772ddb58b159b7454" +checksum = "558a69d53d543a4b1ac60681332594dc1417080cffd2a6851bb6e0a376ebc76f" dependencies = [ "soroban-env-common", "static_assertions", @@ -999,13 +1162,16 @@ dependencies = [ [[package]] name = "soroban-env-host" -version = "20.3.0" +version = "21.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "114a0fa0d0cc39d0be16b1ee35b6e5f4ee0592ddcf459bde69391c02b03cf520" +checksum = "956beee1e959b7b8ac7bea8396454d1534927276830430bf015eafdc756d84ae" dependencies = [ "backtrace", "curve25519-dalek", + "ecdsa", "ed25519-dalek", + "elliptic-curve", + "generic-array", "getrandom", "hex-literal", "hmac", @@ -1013,8 +1179,10 @@ dependencies = [ "num-derive", "num-integer", "num-traits", + "p256", "rand", "rand_chacha", + "sec1", "sha2", "sha3", "soroban-builtin-sdk-macros", @@ -1022,15 +1190,16 @@ dependencies = [ "soroban-wasmi", "static_assertions", "stellar-strkey", + "wasmparser", ] [[package]] name = "soroban-env-macros" -version = "20.3.0" +version = "21.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13e3f8c86f812e0669e78fcb3eae40c385c6a9dd1a4886a1de733230b4fcf27" +checksum = "e04b96c8cf73c941ca134eefd00aa5085c4bcae5d534dd3937f4d69b401a838b" dependencies = [ - "itertools", + "itertools 0.11.0", "proc-macro2", "quote", "serde", @@ -1039,25 +1208,11 @@ dependencies = [ "syn", ] -[[package]] -name = "soroban-errors-contract" -version = "0.0.0" -dependencies = [ - "soroban-sdk", -] - -[[package]] -name = "soroban-increment-contract" -version = "0.0.0" -dependencies = [ - "soroban-sdk", -] - [[package]] name = "soroban-ledger-snapshot" -version = "20.5.0" +version = "21.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a54708f44890e0546180db6b4f530e2a88d83b05a9b38a131caa21d005e25a" +checksum = "79e99e474b9faf76142348780651b0129747d004818447a71c44325152d3ec71" dependencies = [ "serde", "serde_json", @@ -1069,9 +1224,9 @@ dependencies = [ [[package]] name = "soroban-sdk" -version = "20.5.0" +version = "21.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84fc8be9068dd4e0212d8b13ad61089ea87e69ac212c262914503a961c8dc3a3" +checksum = "056d762146fba4d5c0798920484f0120526b3e019b021e6efff6ad7dd62cdcbb" dependencies = [ "arbitrary", "bytes-lit", @@ -1089,13 +1244,13 @@ dependencies = [ [[package]] name = "soroban-sdk-macros" -version = "20.5.0" +version = "21.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db20def4ead836663633f58d817d0ed8e1af052c9650a04adf730525af85b964" +checksum = "8b7d4d78936704cc2e686e1bb77fb5e9075adc392756aea74a3eb47aab74dd7e" dependencies = [ "crate-git-revision", "darling", - "itertools", + "itertools 0.11.0", "proc-macro2", "quote", "rustc_version", @@ -1109,9 +1264,9 @@ dependencies = [ [[package]] name = "soroban-spec" -version = "20.5.0" +version = "21.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eefeb5d373b43f6828145d00f0c5cc35e96db56a6671ae9614f84beb2711cab" +checksum = "b5c72bb3677167ba79c8f0f307b3a5b6469c40fd3ff01599298b3eff5c3f6e19" dependencies = [ "base64 0.13.1", "stellar-xdr", @@ -1121,9 +1276,9 @@ dependencies = [ [[package]] name = "soroban-spec-rust" -version = "20.5.0" +version = "21.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3152bca4737ef734ac37fe47b225ee58765c9095970c481a18516a2b287c7a33" +checksum = "9c6ca7570c91f2a54120269e6a7edb2f968b1661c54d0faca40b0f727fbc24b7" dependencies = [ "prettyplease", "proc-macro2", @@ -1135,23 +1290,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "soroban-token-contract" -version = "0.0.6" -dependencies = [ - "soroban-sdk", - "soroban-token-sdk", -] - -[[package]] -name = "soroban-token-sdk" -version = "20.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee8ed0ae2e5d5e67b7939200bba3712b4c81dcf87b2ccd68bba049bec64c780f" -dependencies = [ - "soroban-sdk", -] - [[package]] name = "soroban-wasmi" version = "0.31.1-soroban.20.0.1" @@ -1200,9 +1338,9 @@ dependencies = [ [[package]] name = "stellar-xdr" -version = "20.1.0" +version = "21.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e59cdf3eb4467fb5a4b00b52e7de6dca72f67fac6f9b700f55c95a5d86f09c9d" +checksum = "ec43c9c5ae7ec7b6ac9e263b6d5b9e3781aa05ba3a1c05f6e70701c5c6600665" dependencies = [ "arbitrary", "base64 0.13.1", @@ -1216,9 +1354,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" @@ -1237,6 +1375,20 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn-file-expand" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7af40d2da901c8c24077520fbf09848d38ddb4856a83d661892007836489fdb0" +dependencies = [ + "im-rc", + "itertools 0.10.5", + "proc-macro2", + "quote", + "syn", + "thiserror", +] + [[package]] name = "thiserror" version = "1.0.55" @@ -1286,6 +1438,12 @@ dependencies = [ "time-core", ] +[[package]] +name = "topological-sort" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" + [[package]] name = "typenum" version = "1.17.0" @@ -1384,11 +1542,12 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.88.0" +version = "0.116.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8cf7dd82407fe68161bedcd57fde15596f32ebf6e9b3bdbf3ae1da20e38e5e" +checksum = "a58e28b80dd8340cb07b8242ae654756161f6fc8d0038123d679b7b99964fa50" dependencies = [ - "indexmap 1.9.3", + "indexmap 2.1.0", + "semver", ] [[package]] diff --git a/contracts/atomic_swap/Cargo.toml b/contracts/atomic_swap/Cargo.toml deleted file mode 100644 index f1f7189..0000000 --- a/contracts/atomic_swap/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "soroban-atomic-swap-contract" -version = "0.0.0" -edition = "2021" -publish = false - -[lib] -crate-type = ["cdylib"] -doctest = false - -[dependencies] -soroban-sdk = { workspace = true } - -[dev-dependencies] -soroban-sdk = { workspace = true, features = ["testutils"] } diff --git a/contracts/atomic_swap/src/lib.rs b/contracts/atomic_swap/src/lib.rs deleted file mode 100644 index b5f644a..0000000 --- a/contracts/atomic_swap/src/lib.rs +++ /dev/null @@ -1,77 +0,0 @@ -//! This contract performs an atomic token swap between two parties. -//! Parties don't need to know each other and their signatures may be matched -//! off-chain. -//! This example demonstrates how multi-party authorization can be implemented. -#![no_std] - -use soroban_sdk::{contract, contractimpl, token, Address, Env, IntoVal}; - -#[contract] -pub struct AtomicSwapContract; - -#[contractimpl] -impl AtomicSwapContract { - // Swap token A for token B atomically. Settle for the minimum requested price - // for each party (this is an arbitrary choice; both parties could have - // received the full amount as well). - pub fn swap( - env: Env, - a: Address, - b: Address, - token_a: Address, - token_b: Address, - amount_a: i128, - min_b_for_a: i128, - amount_b: i128, - min_a_for_b: i128, - ) { - // Verify preconditions on the minimum price for both parties. - if amount_b < min_b_for_a { - panic!("not enough token B for token A"); - } - if amount_a < min_a_for_b { - panic!("not enough token A for token B"); - } - // Require authorization for a subset of arguments specific to a party. - // Notice, that arguments are symmetric - there is no difference between - // `a` and `b` in the call and hence their signatures can be used - // either for `a` or for `b` role. - a.require_auth_for_args( - (token_a.clone(), token_b.clone(), amount_a, min_b_for_a).into_val(&env), - ); - b.require_auth_for_args( - (token_b.clone(), token_a.clone(), amount_b, min_a_for_b).into_val(&env), - ); - - // Perform the swap by moving tokens from a to b and from b to a. - move_token(&env, &token_a, &a, &b, amount_a, min_a_for_b); - move_token(&env, &token_b, &b, &a, amount_b, min_b_for_a); - } -} - -fn move_token( - env: &Env, - token: &Address, - from: &Address, - to: &Address, - max_spend_amount: i128, - transfer_amount: i128, -) { - let token = token::Client::new(env, token); - let contract_address = env.current_contract_address(); - // This call needs to be authorized by `from` address. It transfers the - // maximum spend amount to the swap contract's address in order to decouple - // the signature from `to` address (so that parties don't need to know each - // other). - token.transfer(from, &contract_address, &max_spend_amount); - // Transfer the necessary amount to `to`. - token.transfer(&contract_address, to, &transfer_amount); - // Refund the remaining balance to `from`. - token.transfer( - &contract_address, - from, - &(max_spend_amount - transfer_amount), - ); -} - -mod test; diff --git a/contracts/atomic_swap/src/test.rs b/contracts/atomic_swap/src/test.rs deleted file mode 100644 index cf7929e..0000000 --- a/contracts/atomic_swap/src/test.rs +++ /dev/null @@ -1,112 +0,0 @@ -#![cfg(test)] -extern crate std; - -use super::*; -use soroban_sdk::{ - symbol_short, - testutils::{Address as _, AuthorizedFunction, AuthorizedInvocation}, - token, Address, Env, IntoVal, -}; -use token::Client as TokenClient; -use token::StellarAssetClient as TokenAdminClient; - -fn create_token_contract<'a>(e: &Env, admin: &Address) -> (TokenClient<'a>, TokenAdminClient<'a>) { - let contract_address = e.register_stellar_asset_contract(admin.clone()); - ( - TokenClient::new(e, &contract_address), - TokenAdminClient::new(e, &contract_address), - ) -} - -fn create_atomic_swap_contract(e: &Env) -> AtomicSwapContractClient { - AtomicSwapContractClient::new(e, &e.register_contract(None, AtomicSwapContract {})) -} - -#[test] -fn test_atomic_swap() { - let env = Env::default(); - env.mock_all_auths(); - - let a = Address::generate(&env); - let b = Address::generate(&env); - - let token_admin = Address::generate(&env); - - let (token_a, token_a_admin) = create_token_contract(&env, &token_admin); - let (token_b, token_b_admin) = create_token_contract(&env, &token_admin); - token_a_admin.mint(&a, &1000); - token_b_admin.mint(&b, &5000); - - let contract = create_atomic_swap_contract(&env); - - contract.swap( - &a, - &b, - &token_a.address, - &token_b.address, - &1000, - &4500, - &5000, - &950, - ); - - assert_eq!( - env.auths(), - std::vec![ - ( - a.clone(), - AuthorizedInvocation { - function: AuthorizedFunction::Contract(( - contract.address.clone(), - symbol_short!("swap"), - ( - token_a.address.clone(), - token_b.address.clone(), - 1000_i128, - 4500_i128 - ) - .into_val(&env), - )), - sub_invocations: std::vec![AuthorizedInvocation { - function: AuthorizedFunction::Contract(( - token_a.address.clone(), - symbol_short!("transfer"), - (a.clone(), contract.address.clone(), 1000_i128,).into_val(&env), - )), - sub_invocations: std::vec![] - }] - } - ), - ( - b.clone(), - AuthorizedInvocation { - function: AuthorizedFunction::Contract(( - contract.address.clone(), - symbol_short!("swap"), - ( - token_b.address.clone(), - token_a.address.clone(), - 5000_i128, - 950_i128 - ) - .into_val(&env), - )), - sub_invocations: std::vec![AuthorizedInvocation { - function: AuthorizedFunction::Contract(( - token_b.address.clone(), - symbol_short!("transfer"), - (b.clone(), contract.address.clone(), 5000_i128,).into_val(&env), - )), - sub_invocations: std::vec![] - }] - } - ), - ] - ); - - assert_eq!(token_a.balance(&a), 50); - assert_eq!(token_a.balance(&b), 950); - - assert_eq!(token_b.balance(&a), 4500); - assert_eq!(token_b.balance(&b), 500); -} diff --git a/contracts/auth/Cargo.toml b/contracts/auth/Cargo.toml deleted file mode 100644 index 115cbb3..0000000 --- a/contracts/auth/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "soroban-auth-contract" -version = "0.0.0" -edition = "2021" -publish = false - -[lib] -crate-type = ["cdylib"] - -[dependencies] -soroban-sdk = { workspace = true } - -[dev-dependencies] -soroban-sdk = { workspace = true, features = ["testutils"] } diff --git a/contracts/auth/src/lib.rs b/contracts/auth/src/lib.rs deleted file mode 100644 index 9ed671e..0000000 --- a/contracts/auth/src/lib.rs +++ /dev/null @@ -1,65 +0,0 @@ -//! This contract demonstrates how to implement authorization using -//! Soroban-managed auth framework for a simple case (a single user that needs -//! to authorize a single contract invocation). -//! -//! See `timelock` and `single_offer` examples for demonstration of performing -//! authorized token operations on behalf of the user. -//! -//! See `atomic_swap` and `atomic_multiswap` examples for demonstration of -//! multi-party authorizaton. -//! -//! See `account` example for demonstration of an acount contract with -//! a custom authentication scheme and a custom authorization policy. -#![no_std] -use soroban_sdk::{contract, contractimpl, contracttype, Address, Env}; - -#[contracttype] -pub enum DataKey { - Counter(Address), -} - -#[contract] -pub struct IncrementContract; - -#[contractimpl] -impl IncrementContract { - /// Increment increments a counter for the user, and returns the value. - pub fn increment(env: Env, user: Address, value: u32) -> u32 { - // Requires `user` to have authorized call of the `increment` of this - // contract with all the arguments passed to `increment`, i.e. `user` - // and `value`. This will panic if auth fails for any reason. - // When this is called, Soroban host performs the necessary - // authentication, manages replay prevention and enforces the user's - // authorization policies. - // The contracts normally shouldn't worry about these details and just - // write code in generic fashion using `Address` and `require_auth` (or - // `require_auth_for_args`). - user.require_auth(); - - // This call is equilvalent to the above: - // user.require_auth_for_args((&user, value).into_val(&env)); - - // The following has less arguments but is equivalent in authorization - // scope to the above calls (the user address doesn't have to be - // included in args as it's guaranteed to be authenticated). - // user.require_auth_for_args((value,).into_val(&env)); - - // Construct a key for the data being stored. Use an enum to set the - // contract up well for adding other types of data to be stored. - let key = DataKey::Counter(user.clone()); - - // Get the current count for the invoker. - let mut count: u32 = env.storage().persistent().get(&key).unwrap_or_default(); - - // Increment the count. - count += value; - - // Save the count. - env.storage().persistent().set(&key, &count); - - // Return the count to the caller. - count - } -} - -mod test; diff --git a/contracts/auth/src/test.rs b/contracts/auth/src/test.rs deleted file mode 100644 index dd8f879..0000000 --- a/contracts/auth/src/test.rs +++ /dev/null @@ -1,57 +0,0 @@ -#![cfg(test)] -extern crate std; - -use soroban_sdk::{ - symbol_short, - testutils::{Address as _, AuthorizedFunction, AuthorizedInvocation}, - Address, Env, IntoVal, -}; - -use crate::{IncrementContract, IncrementContractClient}; - -#[test] -fn test() { - let env = Env::default(); - env.mock_all_auths(); - - let contract_id = env.register_contract(None, IncrementContract); - let client = IncrementContractClient::new(&env, &contract_id); - - let user_1 = Address::generate(&env); - let user_2 = Address::generate(&env); - - assert_eq!(client.increment(&user_1, &5), 5); - // Verify that the user indeed had to authorize a call of `increment` with - // the expected arguments: - assert_eq!( - env.auths(), - std::vec![( - // Address for which authorization check is performed - user_1.clone(), - // Invocation tree that needs to be authorized - AuthorizedInvocation { - // Function that is authorized. Can be a contract function or - // a host function that requires authorization. - function: AuthorizedFunction::Contract(( - // Address of the called contract - contract_id.clone(), - // Name of the called function - symbol_short!("increment"), - // Arguments used to call `increment` (converted to the env-managed vector via `into_val`) - (user_1.clone(), 5_u32).into_val(&env), - )), - // The contract doesn't call any other contracts that require - // authorization, - sub_invocations: std::vec![] - } - )] - ); - - // Do more `increment` calls. It's not necessary to verify authorizations - // for every one of them as we don't expect the auth logic to change from - // call to call. - assert_eq!(client.increment(&user_1, &2), 7); - assert_eq!(client.increment(&user_2, &1), 1); - assert_eq!(client.increment(&user_1, &3), 10); - assert_eq!(client.increment(&user_2, &4), 5); -} diff --git a/contracts/core/Cargo.toml b/contracts/core/Cargo.toml new file mode 100644 index 0000000..ab5fe82 --- /dev/null +++ b/contracts/core/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "example-core" +description = "Smallest Redeployable Contract" +version = "0.0.0" +authors = ["Stellar Development Foundation "] +license = "Apache-2.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] +doctest = false + +[dependencies] +loam-sdk = { workspace = true, features = ["loam-soroban-sdk"] } +loam-subcontract-core = { workspace = true } +loam-soroban-sdk = { workspace = true } + + +[dev_dependencies] +loam-sdk = { workspace = true, features = ["soroban-sdk-testutils"] } + +[package.metadata.loam] +contract = true diff --git a/contracts/core/src/lib.rs b/contracts/core/src/lib.rs new file mode 100644 index 0000000..0d63a5d --- /dev/null +++ b/contracts/core/src/lib.rs @@ -0,0 +1,6 @@ +#![no_std] +use loam_sdk::derive_contract; +use loam_subcontract_core::{admin::Admin, Core}; + +#[derive_contract(Core(Admin))] +pub struct Contract; diff --git a/contracts/errors/Cargo.toml b/contracts/errors/Cargo.toml deleted file mode 100644 index b950afb..0000000 --- a/contracts/errors/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "soroban-errors-contract" -version = "0.0.0" -edition = "2021" -publish = false - -[lib] -crate-type = ["cdylib"] -doctest = false - -[dependencies] -soroban-sdk = { workspace = true } - -[dev-dependencies] -soroban-sdk = { workspace = true, features = ["testutils"] } diff --git a/contracts/errors/src/lib.rs b/contracts/errors/src/lib.rs deleted file mode 100644 index b21e0ec..0000000 --- a/contracts/errors/src/lib.rs +++ /dev/null @@ -1,43 +0,0 @@ -#![no_std] -use soroban_sdk::{contract, contracterror, contractimpl, log, symbol_short, Env, Symbol}; - -#[contracterror] -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -#[repr(u32)] -pub enum Error { - LimitReached = 1, -} - -const COUNTER: Symbol = symbol_short!("COUNTER"); -const MAX: u32 = 5; - -#[contract] -pub struct IncrementContract; - -#[contractimpl] -impl IncrementContract { - /// Increment increments an internal counter, and returns the value. Errors - /// if the value is attempted to be incremented past 5. - pub fn increment(env: Env) -> Result { - // Get the current count. - let mut count: u32 = env.storage().instance().get(&COUNTER).unwrap_or(0); // If no value set, assume 0. - log!(&env, "count: {}", count); - - // Increment the count. - count += 1; - - // Check if the count exceeds the max. - if count <= MAX { - // Save the count. - env.storage().instance().set(&COUNTER, &count); - - // Return the count to the caller. - Ok(count) - } else { - // Return an error if the max is exceeded. - Err(Error::LimitReached) - } - } -} - -mod test; diff --git a/contracts/errors/src/test.rs b/contracts/errors/src/test.rs deleted file mode 100644 index f16bc61..0000000 --- a/contracts/errors/src/test.rs +++ /dev/null @@ -1,37 +0,0 @@ -#![cfg(test)] - -use super::*; -use soroban_sdk::{testutils::Logs, Env}; - -extern crate std; - -#[test] -fn test() { - let env = Env::default(); - let contract_id = env.register_contract(None, IncrementContract); - let client = IncrementContractClient::new(&env, &contract_id); - - assert_eq!(client.try_increment(), Ok(Ok(1))); - assert_eq!(client.try_increment(), Ok(Ok(2))); - assert_eq!(client.try_increment(), Ok(Ok(3))); - assert_eq!(client.try_increment(), Ok(Ok(4))); - assert_eq!(client.try_increment(), Ok(Ok(5))); - assert_eq!(client.try_increment(), Err(Ok(Error::LimitReached))); - - std::println!("{}", env.logs().all().join("\n")); -} - -#[test] -#[should_panic(expected = "HostError: Error(Contract, #1)")] -fn test_panic() { - let env = Env::default(); - let contract_id = env.register_contract(None, IncrementContract); - let client = IncrementContractClient::new(&env, &contract_id); - - assert_eq!(client.increment(), 1); - assert_eq!(client.increment(), 2); - assert_eq!(client.increment(), 3); - assert_eq!(client.increment(), 4); - assert_eq!(client.increment(), 5); - client.increment(); -} diff --git a/contracts/hello_world/Cargo.toml b/contracts/hello_world/Cargo.toml deleted file mode 100644 index 2d8b3ac..0000000 --- a/contracts/hello_world/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "hello-world" -version = "0.0.0" -edition = "2021" -publish = false - -[lib] -crate-type = ["cdylib"] -doctest = false - -[dependencies] -soroban-sdk = { workspace = true } - -[dev-dependencies] -soroban-sdk = { workspace = true, features = ["testutils"] } diff --git a/contracts/hello_world/src/lib.rs b/contracts/hello_world/src/lib.rs deleted file mode 100644 index fb23e50..0000000 --- a/contracts/hello_world/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![no_std] -use soroban_sdk::{contract, contractimpl, symbol_short, vec, Env, Symbol, Vec}; - -#[contract] -pub struct HelloContract; - -#[contractimpl] -impl HelloContract { - pub fn hello(env: Env, to: Symbol) -> Vec { - vec![&env, symbol_short!("Hello"), to] - } -} - -mod test; diff --git a/contracts/hello_world/src/test.rs b/contracts/hello_world/src/test.rs deleted file mode 100644 index e72c6bb..0000000 --- a/contracts/hello_world/src/test.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![cfg(test)] - -use super::*; -use soroban_sdk::{symbol_short, vec, Env}; - -#[test] -fn test() { - let env = Env::default(); - let contract_id = env.register_contract(None, HelloContract); - let client = HelloContractClient::new(&env, &contract_id); - - let words = client.hello(&symbol_short!("Dev")); - assert_eq!( - words, - vec![&env, symbol_short!("Hello"), symbol_short!("Dev"),] - ); -} diff --git a/contracts/increment/Cargo.toml b/contracts/increment/Cargo.toml deleted file mode 100644 index b922631..0000000 --- a/contracts/increment/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "soroban-increment-contract" -version = "0.0.0" -edition = "2021" -publish = false - -[lib] -crate-type = ["cdylib"] -doctest = false - -[dependencies] -soroban-sdk = { workspace = true } - -[dev-dependencies] -soroban-sdk = { workspace = true, features = ["testutils"] } diff --git a/contracts/increment/src/lib.rs b/contracts/increment/src/lib.rs deleted file mode 100644 index 0a0d0f8..0000000 --- a/contracts/increment/src/lib.rs +++ /dev/null @@ -1,34 +0,0 @@ -#![no_std] -use soroban_sdk::{contract, contractimpl, log, symbol_short, Env, Symbol}; - -const COUNTER: Symbol = symbol_short!("COUNTER"); - -#[contract] -pub struct IncrementContract; - -#[contractimpl] -impl IncrementContract { - /// Increment increments an internal counter, and returns the value. - pub fn increment(env: Env) -> u32 { - // Get the current count. - let mut count: u32 = env.storage().instance().get(&COUNTER).unwrap_or(0); // If no value set, assume 0. - log!(&env, "count: {}", count); - - // Increment the count. - count += 1; - - // Save the count. - env.storage().instance().set(&COUNTER, &count); - - // The contract instance will be bumped to have a lifetime of at least 100 ledgers if the current expiration lifetime at most 50. - // If the lifetime is already more than 100 ledgers, this is a no-op. Otherwise, - // the lifetime is extended to 100 ledgers. This lifetime bump includes the contract - // instance itself and all entries in storage().instance(), i.e, COUNTER. - env.storage().instance().extend_ttl(50, 100); - - // Return the count to the caller. - count - } -} - -mod test; diff --git a/contracts/increment/src/test.rs b/contracts/increment/src/test.rs deleted file mode 100644 index 29ec9dc..0000000 --- a/contracts/increment/src/test.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![cfg(test)] - -use super::{IncrementContract, IncrementContractClient}; -use soroban_sdk::{testutils::Logs, Env}; - -extern crate std; - -#[test] -fn test() { - let env = Env::default(); - let contract_id = env.register_contract(None, IncrementContract); - let client = IncrementContractClient::new(&env, &contract_id); - - assert_eq!(client.increment(), 1); - assert_eq!(client.increment(), 2); - assert_eq!(client.increment(), 3); - - std::println!("{}", env.logs().all().join("\n")); -} diff --git a/contracts/status_message/Cargo.toml b/contracts/status_message/Cargo.toml new file mode 100644 index 0000000..b92f38e --- /dev/null +++ b/contracts/status_message/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "example-status-message" +version = "0.0.0" +authors = ["Stellar Development Foundation "] +license = "Apache-2.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] +doctest = false + +[dependencies] +loam-sdk = { workspace = true, features = ["loam-soroban-sdk"] } +loam-subcontract-core = { workspace = true } + +[dev_dependencies] +loam-sdk = { workspace = true, features = ["soroban-sdk-testutils"] } diff --git a/contracts/status_message/src/lib.rs b/contracts/status_message/src/lib.rs new file mode 100644 index 0000000..9d9e3b1 --- /dev/null +++ b/contracts/status_message/src/lib.rs @@ -0,0 +1,10 @@ +#![no_std] +// // Currently need to import `self` because `contracttype` expects it in the namespace +use loam_sdk::derive_contract; +use loam_subcontract_core::{admin::Admin, Core}; + +mod status_message; +pub use status_message::*; + +#[derive_contract(Core(Admin), Postable(StatusMessage))] +pub struct Contract; diff --git a/contracts/status_message/src/status_message.rs b/contracts/status_message/src/status_message.rs new file mode 100644 index 0000000..55d3920 --- /dev/null +++ b/contracts/status_message/src/status_message.rs @@ -0,0 +1,42 @@ +// Currently need to import `self` because `contracttype` expects it in the namespace +use loam_sdk::{ + soroban_sdk::{self, contracttype, env, Address, IntoKey, Lazy, Map, String}, + subcontract, +}; + +#[contracttype] +#[derive(IntoKey)] +pub struct StatusMessage(Map); + +impl Default for StatusMessage { + fn default() -> Self { + Self(Map::new(env())) + } +} + +#[subcontract] +pub trait IsPostable { + /// Documentation ends up in the contract's metadata and thus the CLI, etc + fn messages_get( + &self, + author: loam_sdk::soroban_sdk::Address, + ) -> Option; + + /// Only the author can set the message + fn messages_set( + &mut self, + author: loam_sdk::soroban_sdk::Address, + text: loam_sdk::soroban_sdk::String, + ); +} + +impl IsPostable for StatusMessage { + fn messages_get(&self, author: Address) -> Option { + self.0.get(author) + } + + fn messages_set(&mut self, author: Address, text: String) { + author.require_auth(); + self.0.set(author, text); + } +} diff --git a/contracts/token/Cargo.toml b/contracts/token/Cargo.toml deleted file mode 100644 index 3877f08..0000000 --- a/contracts/token/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "soroban-token-contract" -description = "Soroban standard token contract" -version = "0.0.6" -edition = "2021" - -[lib] -crate-type = ["cdylib"] - -[dependencies] -soroban-sdk = { workspace = true } -soroban-token-sdk = { version = "20.3.1" } - -[dev-dependencies] -soroban-sdk = { workspace = true, features = ["testutils"] } diff --git a/contracts/token/src/admin.rs b/contracts/token/src/admin.rs deleted file mode 100644 index a820bf0..0000000 --- a/contracts/token/src/admin.rs +++ /dev/null @@ -1,18 +0,0 @@ -use soroban_sdk::{Address, Env}; - -use crate::storage_types::DataKey; - -pub fn has_administrator(e: &Env) -> bool { - let key = DataKey::Admin; - e.storage().instance().has(&key) -} - -pub fn read_administrator(e: &Env) -> Address { - let key = DataKey::Admin; - e.storage().instance().get(&key).unwrap() -} - -pub fn write_administrator(e: &Env, id: &Address) { - let key = DataKey::Admin; - e.storage().instance().set(&key, id); -} diff --git a/contracts/token/src/allowance.rs b/contracts/token/src/allowance.rs deleted file mode 100644 index c70e2bc..0000000 --- a/contracts/token/src/allowance.rs +++ /dev/null @@ -1,65 +0,0 @@ -use crate::storage_types::{AllowanceDataKey, AllowanceValue, DataKey}; -use soroban_sdk::{Address, Env}; - -pub fn read_allowance(e: &Env, from: Address, spender: Address) -> AllowanceValue { - let key = DataKey::Allowance(AllowanceDataKey { from, spender }); - if let Some(allowance) = e.storage().temporary().get::<_, AllowanceValue>(&key) { - if allowance.expiration_ledger < e.ledger().sequence() { - AllowanceValue { - amount: 0, - expiration_ledger: allowance.expiration_ledger, - } - } else { - allowance - } - } else { - AllowanceValue { - amount: 0, - expiration_ledger: 0, - } - } -} - -pub fn write_allowance( - e: &Env, - from: Address, - spender: Address, - amount: i128, - expiration_ledger: u32, -) { - let allowance = AllowanceValue { - amount, - expiration_ledger, - }; - - if amount > 0 && expiration_ledger < e.ledger().sequence() { - panic!("expiration_ledger is less than ledger seq when amount > 0") - } - - let key = DataKey::Allowance(AllowanceDataKey { from, spender }); - e.storage().temporary().set(&key.clone(), &allowance); - - if amount > 0 { - let live_for = expiration_ledger - .checked_sub(e.ledger().sequence()) - .unwrap(); - - e.storage().temporary().extend_ttl(&key, live_for, live_for) - } -} - -pub fn spend_allowance(e: &Env, from: Address, spender: Address, amount: i128) { - let allowance = read_allowance(e, from.clone(), spender.clone()); - if allowance.amount < amount { - panic!("insufficient allowance"); - } - if amount > 0 { - write_allowance( - e, - from, - spender, - allowance.amount - amount, - allowance.expiration_ledger, - ); - } -} diff --git a/contracts/token/src/balance.rs b/contracts/token/src/balance.rs deleted file mode 100644 index 76134e8..0000000 --- a/contracts/token/src/balance.rs +++ /dev/null @@ -1,35 +0,0 @@ -use crate::storage_types::{DataKey, BALANCE_BUMP_AMOUNT, BALANCE_LIFETIME_THRESHOLD}; -use soroban_sdk::{Address, Env}; - -pub fn read_balance(e: &Env, addr: Address) -> i128 { - let key = DataKey::Balance(addr); - if let Some(balance) = e.storage().persistent().get::(&key) { - e.storage() - .persistent() - .extend_ttl(&key, BALANCE_LIFETIME_THRESHOLD, BALANCE_BUMP_AMOUNT); - balance - } else { - 0 - } -} - -fn write_balance(e: &Env, addr: Address, amount: i128) { - let key = DataKey::Balance(addr); - e.storage().persistent().set(&key, &amount); - e.storage() - .persistent() - .extend_ttl(&key, BALANCE_LIFETIME_THRESHOLD, BALANCE_BUMP_AMOUNT); -} - -pub fn receive_balance(e: &Env, addr: Address, amount: i128) { - let balance = read_balance(e, addr.clone()); - write_balance(e, addr, balance + amount); -} - -pub fn spend_balance(e: &Env, addr: Address, amount: i128) { - let balance = read_balance(e, addr.clone()); - if balance < amount { - panic!("insufficient balance"); - } - write_balance(e, addr, balance - amount); -} diff --git a/contracts/token/src/contract.rs b/contracts/token/src/contract.rs deleted file mode 100644 index 7062609..0000000 --- a/contracts/token/src/contract.rs +++ /dev/null @@ -1,176 +0,0 @@ -//! This contract demonstrates a sample implementation of the Soroban token -//! interface. -use crate::admin::{has_administrator, read_administrator, write_administrator}; -use crate::allowance::{read_allowance, spend_allowance, write_allowance}; -use crate::balance::{read_balance, receive_balance, spend_balance}; -use crate::metadata::{read_decimal, read_name, read_symbol, write_metadata}; -#[cfg(test)] -use crate::storage_types::{AllowanceDataKey, AllowanceValue, DataKey}; -use crate::storage_types::{INSTANCE_BUMP_AMOUNT, INSTANCE_LIFETIME_THRESHOLD}; -use soroban_sdk::token::{self, Interface as _}; -use soroban_sdk::{contract, contractimpl, Address, Env, String}; -use soroban_token_sdk::metadata::TokenMetadata; -use soroban_token_sdk::TokenUtils; - -fn check_nonnegative_amount(amount: i128) { - if amount < 0 { - panic!("negative amount is not allowed: {}", amount) - } -} - -#[contract] -pub struct Token; - -#[contractimpl] -impl Token { - pub fn initialize(e: Env, admin: Address, decimal: u32, name: String, symbol: String) { - if has_administrator(&e) { - panic!("already initialized") - } - write_administrator(&e, &admin); - if decimal > 18 { - panic!("Decimal must not be greater than 18"); - } - - write_metadata( - &e, - TokenMetadata { - decimal, - name, - symbol, - }, - ) - } - - pub fn mint(e: Env, to: Address, amount: i128) { - check_nonnegative_amount(amount); - let admin = read_administrator(&e); - admin.require_auth(); - - e.storage() - .instance() - .extend_ttl(INSTANCE_LIFETIME_THRESHOLD, INSTANCE_BUMP_AMOUNT); - - receive_balance(&e, to.clone(), amount); - TokenUtils::new(&e).events().mint(admin, to, amount); - } - - pub fn set_admin(e: Env, new_admin: Address) { - let admin = read_administrator(&e); - admin.require_auth(); - - e.storage() - .instance() - .extend_ttl(INSTANCE_LIFETIME_THRESHOLD, INSTANCE_BUMP_AMOUNT); - - write_administrator(&e, &new_admin); - TokenUtils::new(&e).events().set_admin(admin, new_admin); - } - - #[cfg(test)] - pub fn get_allowance(e: Env, from: Address, spender: Address) -> Option { - let key = DataKey::Allowance(AllowanceDataKey { from, spender }); - let allowance = e.storage().temporary().get::<_, AllowanceValue>(&key); - allowance - } -} - -#[contractimpl] -impl token::Interface for Token { - fn allowance(e: Env, from: Address, spender: Address) -> i128 { - e.storage() - .instance() - .extend_ttl(INSTANCE_LIFETIME_THRESHOLD, INSTANCE_BUMP_AMOUNT); - read_allowance(&e, from, spender).amount - } - - fn approve(e: Env, from: Address, spender: Address, amount: i128, expiration_ledger: u32) { - from.require_auth(); - - check_nonnegative_amount(amount); - - e.storage() - .instance() - .extend_ttl(INSTANCE_LIFETIME_THRESHOLD, INSTANCE_BUMP_AMOUNT); - - write_allowance(&e, from.clone(), spender.clone(), amount, expiration_ledger); - TokenUtils::new(&e) - .events() - .approve(from, spender, amount, expiration_ledger); - } - - fn balance(e: Env, id: Address) -> i128 { - e.storage() - .instance() - .extend_ttl(INSTANCE_LIFETIME_THRESHOLD, INSTANCE_BUMP_AMOUNT); - read_balance(&e, id) - } - - fn transfer(e: Env, from: Address, to: Address, amount: i128) { - from.require_auth(); - - check_nonnegative_amount(amount); - - e.storage() - .instance() - .extend_ttl(INSTANCE_LIFETIME_THRESHOLD, INSTANCE_BUMP_AMOUNT); - - spend_balance(&e, from.clone(), amount); - receive_balance(&e, to.clone(), amount); - TokenUtils::new(&e).events().transfer(from, to, amount); - } - - fn transfer_from(e: Env, spender: Address, from: Address, to: Address, amount: i128) { - spender.require_auth(); - - check_nonnegative_amount(amount); - - e.storage() - .instance() - .extend_ttl(INSTANCE_LIFETIME_THRESHOLD, INSTANCE_BUMP_AMOUNT); - - spend_allowance(&e, from.clone(), spender, amount); - spend_balance(&e, from.clone(), amount); - receive_balance(&e, to.clone(), amount); - TokenUtils::new(&e).events().transfer(from, to, amount) - } - - fn burn(e: Env, from: Address, amount: i128) { - from.require_auth(); - - check_nonnegative_amount(amount); - - e.storage() - .instance() - .extend_ttl(INSTANCE_LIFETIME_THRESHOLD, INSTANCE_BUMP_AMOUNT); - - spend_balance(&e, from.clone(), amount); - TokenUtils::new(&e).events().burn(from, amount); - } - - fn burn_from(e: Env, spender: Address, from: Address, amount: i128) { - spender.require_auth(); - - check_nonnegative_amount(amount); - - e.storage() - .instance() - .extend_ttl(INSTANCE_LIFETIME_THRESHOLD, INSTANCE_BUMP_AMOUNT); - - spend_allowance(&e, from.clone(), spender, amount); - spend_balance(&e, from.clone(), amount); - TokenUtils::new(&e).events().burn(from, amount) - } - - fn decimals(e: Env) -> u32 { - read_decimal(&e) - } - - fn name(e: Env) -> String { - read_name(&e) - } - - fn symbol(e: Env) -> String { - read_symbol(&e) - } -} diff --git a/contracts/token/src/lib.rs b/contracts/token/src/lib.rs deleted file mode 100644 index b5f04e4..0000000 --- a/contracts/token/src/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![no_std] - -mod admin; -mod allowance; -mod balance; -mod contract; -mod metadata; -mod storage_types; -mod test; - -pub use crate::contract::TokenClient; diff --git a/contracts/token/src/metadata.rs b/contracts/token/src/metadata.rs deleted file mode 100644 index 715feee..0000000 --- a/contracts/token/src/metadata.rs +++ /dev/null @@ -1,22 +0,0 @@ -use soroban_sdk::{Env, String}; -use soroban_token_sdk::{metadata::TokenMetadata, TokenUtils}; - -pub fn read_decimal(e: &Env) -> u32 { - let util = TokenUtils::new(e); - util.metadata().get_metadata().decimal -} - -pub fn read_name(e: &Env) -> String { - let util = TokenUtils::new(e); - util.metadata().get_metadata().name -} - -pub fn read_symbol(e: &Env) -> String { - let util = TokenUtils::new(e); - util.metadata().get_metadata().symbol -} - -pub fn write_metadata(e: &Env, metadata: TokenMetadata) { - let util = TokenUtils::new(e); - util.metadata().set_metadata(&metadata); -} diff --git a/contracts/token/src/storage_types.rs b/contracts/token/src/storage_types.rs deleted file mode 100644 index 038562f..0000000 --- a/contracts/token/src/storage_types.rs +++ /dev/null @@ -1,30 +0,0 @@ -use soroban_sdk::{contracttype, Address}; - -pub(crate) const DAY_IN_LEDGERS: u32 = 17280; -pub(crate) const INSTANCE_BUMP_AMOUNT: u32 = 7 * DAY_IN_LEDGERS; -pub(crate) const INSTANCE_LIFETIME_THRESHOLD: u32 = INSTANCE_BUMP_AMOUNT - DAY_IN_LEDGERS; - -pub(crate) const BALANCE_BUMP_AMOUNT: u32 = 30 * DAY_IN_LEDGERS; -pub(crate) const BALANCE_LIFETIME_THRESHOLD: u32 = BALANCE_BUMP_AMOUNT - DAY_IN_LEDGERS; - -#[derive(Clone)] -#[contracttype] -pub struct AllowanceDataKey { - pub from: Address, - pub spender: Address, -} - -#[contracttype] -pub struct AllowanceValue { - pub amount: i128, - pub expiration_ledger: u32, -} - -#[derive(Clone)] -#[contracttype] -pub enum DataKey { - Allowance(AllowanceDataKey), - Balance(Address), - State(Address), - Admin, -} diff --git a/contracts/token/src/test.rs b/contracts/token/src/test.rs deleted file mode 100644 index c3718c0..0000000 --- a/contracts/token/src/test.rs +++ /dev/null @@ -1,266 +0,0 @@ -#![cfg(test)] -extern crate std; - -use crate::{contract::Token, TokenClient}; -use soroban_sdk::{ - symbol_short, - testutils::{Address as _, AuthorizedFunction, AuthorizedInvocation}, - Address, Env, IntoVal, Symbol, -}; - -fn create_token<'a>(e: &Env, admin: &Address) -> TokenClient<'a> { - let token = TokenClient::new(e, &e.register_contract(None, Token {})); - token.initialize(admin, &7, &"name".into_val(e), &"symbol".into_val(e)); - token -} - -#[test] -fn test() { - let e = Env::default(); - e.mock_all_auths(); - - let admin1 = Address::generate(&e); - let admin2 = Address::generate(&e); - let user1 = Address::generate(&e); - let user2 = Address::generate(&e); - let user3 = Address::generate(&e); - let token = create_token(&e, &admin1); - - token.mint(&user1, &1000); - assert_eq!( - e.auths(), - std::vec![( - admin1.clone(), - AuthorizedInvocation { - function: AuthorizedFunction::Contract(( - token.address.clone(), - symbol_short!("mint"), - (&user1, 1000_i128).into_val(&e), - )), - sub_invocations: std::vec![] - } - )] - ); - assert_eq!(token.balance(&user1), 1000); - - token.approve(&user2, &user3, &500, &200); - assert_eq!( - e.auths(), - std::vec![( - user2.clone(), - AuthorizedInvocation { - function: AuthorizedFunction::Contract(( - token.address.clone(), - symbol_short!("approve"), - (&user2, &user3, 500_i128, 200_u32).into_val(&e), - )), - sub_invocations: std::vec![] - } - )] - ); - assert_eq!(token.allowance(&user2, &user3), 500); - - token.transfer(&user1, &user2, &600); - assert_eq!( - e.auths(), - std::vec![( - user1.clone(), - AuthorizedInvocation { - function: AuthorizedFunction::Contract(( - token.address.clone(), - symbol_short!("transfer"), - (&user1, &user2, 600_i128).into_val(&e), - )), - sub_invocations: std::vec![] - } - )] - ); - assert_eq!(token.balance(&user1), 400); - assert_eq!(token.balance(&user2), 600); - - token.transfer_from(&user3, &user2, &user1, &400); - assert_eq!( - e.auths(), - std::vec![( - user3.clone(), - AuthorizedInvocation { - function: AuthorizedFunction::Contract(( - token.address.clone(), - Symbol::new(&e, "transfer_from"), - (&user3, &user2, &user1, 400_i128).into_val(&e), - )), - sub_invocations: std::vec![] - } - )] - ); - assert_eq!(token.balance(&user1), 800); - assert_eq!(token.balance(&user2), 200); - - token.transfer(&user1, &user3, &300); - assert_eq!(token.balance(&user1), 500); - assert_eq!(token.balance(&user3), 300); - - token.set_admin(&admin2); - assert_eq!( - e.auths(), - std::vec![( - admin1.clone(), - AuthorizedInvocation { - function: AuthorizedFunction::Contract(( - token.address.clone(), - symbol_short!("set_admin"), - (&admin2,).into_val(&e), - )), - sub_invocations: std::vec![] - } - )] - ); - - // Increase to 500 - token.approve(&user2, &user3, &500, &200); - assert_eq!(token.allowance(&user2, &user3), 500); - token.approve(&user2, &user3, &0, &200); - assert_eq!( - e.auths(), - std::vec![( - user2.clone(), - AuthorizedInvocation { - function: AuthorizedFunction::Contract(( - token.address.clone(), - symbol_short!("approve"), - (&user2, &user3, 0_i128, 200_u32).into_val(&e), - )), - sub_invocations: std::vec![] - } - )] - ); - assert_eq!(token.allowance(&user2, &user3), 0); -} - -#[test] -fn test_burn() { - let e = Env::default(); - e.mock_all_auths(); - - let admin = Address::generate(&e); - let user1 = Address::generate(&e); - let user2 = Address::generate(&e); - let token = create_token(&e, &admin); - - token.mint(&user1, &1000); - assert_eq!(token.balance(&user1), 1000); - - token.approve(&user1, &user2, &500, &200); - assert_eq!(token.allowance(&user1, &user2), 500); - - token.burn_from(&user2, &user1, &500); - assert_eq!( - e.auths(), - std::vec![( - user2.clone(), - AuthorizedInvocation { - function: AuthorizedFunction::Contract(( - token.address.clone(), - symbol_short!("burn_from"), - (&user2, &user1, 500_i128).into_val(&e), - )), - sub_invocations: std::vec![] - } - )] - ); - - assert_eq!(token.allowance(&user1, &user2), 0); - assert_eq!(token.balance(&user1), 500); - assert_eq!(token.balance(&user2), 0); - - token.burn(&user1, &500); - assert_eq!( - e.auths(), - std::vec![( - user1.clone(), - AuthorizedInvocation { - function: AuthorizedFunction::Contract(( - token.address.clone(), - symbol_short!("burn"), - (&user1, 500_i128).into_val(&e), - )), - sub_invocations: std::vec![] - } - )] - ); - - assert_eq!(token.balance(&user1), 0); - assert_eq!(token.balance(&user2), 0); -} - -#[test] -#[should_panic(expected = "insufficient balance")] -fn transfer_insufficient_balance() { - let e = Env::default(); - e.mock_all_auths(); - - let admin = Address::generate(&e); - let user1 = Address::generate(&e); - let user2 = Address::generate(&e); - let token = create_token(&e, &admin); - - token.mint(&user1, &1000); - assert_eq!(token.balance(&user1), 1000); - - token.transfer(&user1, &user2, &1001); -} - -#[test] -#[should_panic(expected = "insufficient allowance")] -fn transfer_from_insufficient_allowance() { - let e = Env::default(); - e.mock_all_auths(); - - let admin = Address::generate(&e); - let user1 = Address::generate(&e); - let user2 = Address::generate(&e); - let user3 = Address::generate(&e); - let token = create_token(&e, &admin); - - token.mint(&user1, &1000); - assert_eq!(token.balance(&user1), 1000); - - token.approve(&user1, &user3, &100, &200); - assert_eq!(token.allowance(&user1, &user3), 100); - - token.transfer_from(&user3, &user1, &user2, &101); -} - -#[test] -#[should_panic(expected = "already initialized")] -fn initialize_already_initialized() { - let e = Env::default(); - let admin = Address::generate(&e); - let token = create_token(&e, &admin); - - token.initialize(&admin, &10, &"name".into_val(&e), &"symbol".into_val(&e)); -} - -#[test] -#[should_panic(expected = "Decimal must not be greater than 18")] -fn decimal_is_over_eighteen() { - let e = Env::default(); - let admin = Address::generate(&e); - let token = TokenClient::new(&e, &e.register_contract(None, Token {})); - token.initialize(&admin, &19, &"name".into_val(&e), &"symbol".into_val(&e)); -} - -#[test] -fn test_zero_allowance() { - // Here we test that transfer_from with a 0 amount does not create an empty allowance - let e = Env::default(); - e.mock_all_auths(); - - let admin = Address::generate(&e); - let spender = Address::generate(&e); - let from = Address::generate(&e); - let token = create_token(&e, &admin); - - token.transfer_from(&spender, &from, &spender, &0); - assert!(token.get_allowance(&from, &spender).is_none()); -} diff --git a/package-lock.json b/package-lock.json index a621325..2f2e5d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,10 +13,9 @@ "devDependencies": { "@astrojs/check": "^0.4.1", "astro": "^4.2.4", + "concurrently": "^8.2.2", "dotenv": "^16.4.1", "glob": "^10.4.1", - "loam-cli": "0.9.4", - "parallelshell": "^3.0.2", "typescript": "^5.3.3" } }, @@ -484,6 +483,18 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/runtime": { + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.8.tgz", + "integrity": "sha512-5F7SDGs1T72ZczbRwbGO9lQi0NLjQxzl6i4lJxLxfW9U5UluCSyEJeniWvnhl3/euNiqQVbo8zruhsDfid0esA==", + "dev": true, + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/template": { "version": "7.23.9", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.23.9.tgz", @@ -1270,35 +1281,17 @@ "win32" ] }, - "node_modules/@sindresorhus/is": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-4.6.0.tgz", - "integrity": "sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sindresorhus/is?sponsor=1" - } - }, - "node_modules/@stellar/freighter-api": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/@stellar/freighter-api/-/freighter-api-1.7.1.tgz", - "integrity": "sha512-XvPO+XgEbkeP0VhP0U1edOkds+rGS28+y8GRGbCVXeZ9ZslbWqRFQoETAdX8IXGuykk2ib/aPokiLc5ZaWYP7w==" - }, "node_modules/@stellar/js-xdr": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/@stellar/js-xdr/-/js-xdr-3.1.1.tgz", "integrity": "sha512-3gnPjAz78htgqsNEDkEsKHKosV2BF2iZkoHCNxpmZwUxiPsw+2VaXMed8RRMe0rGk3d5GZe7RrSba8zV80J3Ag==" }, "node_modules/@stellar/stellar-base": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/@stellar/stellar-base/-/stellar-base-10.0.1.tgz", - "integrity": "sha512-BDbx7VHOEQh+4J3Q+gStNXgPaNckVFmD4aOlBBGwxlF6vPFmVnW8IoJdkX7T58zpX55eWI6DXvEhDBlrqTlhAQ==", + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/@stellar/stellar-base/-/stellar-base-12.0.1.tgz", + "integrity": "sha512-g6c27MNsDgEdUmoNQJn7zCWoCY50WHt0OIIOq3PhWaJRtUaT++qs1Jpb8+1bny2GmhtfRGOfPUFSyQBuHT9Mvg==", "dependencies": { - "@stellar/js-xdr": "^3.0.1", + "@stellar/js-xdr": "^3.1.1", "base32.js": "^0.1.0", "bignumber.js": "^9.1.2", "buffer": "^6.0.3", @@ -1306,16 +1299,16 @@ "tweetnacl": "^1.0.3" }, "optionalDependencies": { - "sodium-native": "^4.0.1" + "sodium-native": "^4.1.1" } }, "node_modules/@stellar/stellar-sdk": { - "version": "11.2.0", - "resolved": "https://registry.npmjs.org/@stellar/stellar-sdk/-/stellar-sdk-11.2.0.tgz", - "integrity": "sha512-qInRR+mLLl9O/AI6Q+Sr19RZeYJtlNoJQJi3pch5BYoMvVhjO8IU8AhHADP//Zmc2osyogwPuqXBiFdaGlfHWA==", + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/@stellar/stellar-sdk/-/stellar-sdk-12.1.0.tgz", + "integrity": "sha512-Va0hu9SaPezmMbO5eMwL5D15Wrx1AGWRtxayUDRWV2Fr3ynY58mvCZS1vsgNQ4kE8MZe3nBVKv6T9Kzqwgx1PQ==", "dependencies": { - "@stellar/stellar-base": "10.0.1", - "axios": "^1.6.5", + "@stellar/stellar-base": "^12.0.1", + "axios": "^1.7.2", "bignumber.js": "^9.1.2", "eventsource": "^2.0.2", "randombytes": "^2.1.0", @@ -1323,19 +1316,6 @@ "urijs": "^1.19.1" } }, - "node_modules/@szmarczak/http-timer": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz", - "integrity": "sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==", - "dev": true, - "license": "MIT", - "dependencies": { - "defer-to-connect": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -1377,19 +1357,6 @@ "@babel/types": "^7.20.7" } }, - "node_modules/@types/cacheable-request": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz", - "integrity": "sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/http-cache-semantics": "*", - "@types/keyv": "^3.1.4", - "@types/node": "*", - "@types/responselike": "^1.0.0" - } - }, "node_modules/@types/debug": { "version": "4.1.12", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", @@ -1414,23 +1381,6 @@ "@types/unist": "*" } }, - "node_modules/@types/http-cache-semantics": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz", - "integrity": "sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/keyv": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/@types/keyv/-/keyv-3.1.4.tgz", - "integrity": "sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/mdast": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.3.tgz", @@ -1467,20 +1417,12 @@ "integrity": "sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==", "dev": true, "license": "MIT", + "optional": true, + "peer": true, "dependencies": { "undici-types": "~5.26.4" } }, - "node_modules/@types/responselike": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.3.tgz", - "integrity": "sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/unist": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.2.tgz", @@ -2040,51 +1982,6 @@ "ieee754": "^1.2.1" } }, - "node_modules/cacheable-lookup": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz", - "integrity": "sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10.6.0" - } - }, - "node_modules/cacheable-request": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-7.0.4.tgz", - "integrity": "sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg==", - "dev": true, - "license": "MIT", - "dependencies": { - "clone-response": "^1.0.2", - "get-stream": "^5.1.0", - "http-cache-semantics": "^4.0.0", - "keyv": "^4.0.0", - "lowercase-keys": "^2.0.0", - "normalize-url": "^6.0.1", - "responselike": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cacheable-request/node_modules/get-stream": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", - "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", - "dev": true, - "license": "MIT", - "dependencies": { - "pump": "^3.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/camelcase": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-7.0.1.tgz", @@ -2364,29 +2261,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/clone-response": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.3.tgz", - "integrity": "sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA==", - "dev": true, - "license": "MIT", - "dependencies": { - "mimic-response": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/clone-response/node_modules/mimic-response": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", - "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, "node_modules/clsx": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.0.tgz", @@ -2483,6 +2357,118 @@ "integrity": "sha512-L3sHRo1pXXEqX8VU28kfgUY+YGsk09hPqZiZmLacNib6XNTCM8ubYeT7ryXQw8asB1sKgcU5lkB7ONug08aB8w==", "dev": true }, + "node_modules/concurrently": { + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-8.2.2.tgz", + "integrity": "sha512-1dP4gpXFhei8IOtlXRE/T/4H88ElHgTiUzh71YUmtjTEHMSRS2Z/fgOxHSxxusGHogsRfxNq1vyAwxSC+EVyDg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.2", + "date-fns": "^2.30.0", + "lodash": "^4.17.21", + "rxjs": "^7.8.1", + "shell-quote": "^1.8.1", + "spawn-command": "0.0.2", + "supports-color": "^8.1.1", + "tree-kill": "^1.2.2", + "yargs": "^17.7.2" + }, + "bin": { + "conc": "dist/bin/concurrently.js", + "concurrently": "dist/bin/concurrently.js" + }, + "engines": { + "node": "^14.13.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/concurrently/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/concurrently/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/concurrently/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/concurrently/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", @@ -2512,6 +2498,22 @@ "node": ">= 8" } }, + "node_modules/date-fns": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", + "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.21.0" + }, + "engines": { + "node": ">=0.11" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/date-fns" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -2547,6 +2549,7 @@ "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", "dev": true, + "optional": true, "dependencies": { "mimic-response": "^3.1.0" }, @@ -2567,16 +2570,6 @@ "node": ">=4.0.0" } }, - "node_modules/defer-to-connect": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", - "integrity": "sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - } - }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -2704,6 +2697,7 @@ "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", "dev": true, + "optional": true, "dependencies": { "once": "^1.4.0" } @@ -2818,6 +2812,14 @@ "node": ">=12.0.0" } }, + "node_modules/example_core": { + "resolved": "packages/example_core", + "link": true + }, + "node_modules/example_status_message": { + "resolved": "packages/example_status_message", + "link": true + }, "node_modules/execa": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", @@ -3004,39 +3006,6 @@ "dev": true, "optional": true }, - "node_modules/fs-minipass": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", - "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", - "dev": true, - "license": "ISC", - "dependencies": { - "minipass": "^3.0.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/fs-minipass/node_modules/minipass": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", - "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", - "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/fs-minipass/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true, - "license": "ISC" - }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -3157,32 +3126,6 @@ "node": ">=4" } }, - "node_modules/got": { - "version": "11.8.6", - "resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz", - "integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@sindresorhus/is": "^4.0.0", - "@szmarczak/http-timer": "^4.0.5", - "@types/cacheable-request": "^6.0.1", - "@types/responselike": "^1.0.0", - "cacheable-lookup": "^5.0.3", - "cacheable-request": "^7.0.2", - "decompress-response": "^6.0.0", - "http2-wrapper": "^1.0.0-beta.5.2", - "lowercase-keys": "^2.0.0", - "p-cancelable": "^2.0.0", - "responselike": "^2.0.0" - }, - "engines": { - "node": ">=10.19.0" - }, - "funding": { - "url": "https://github.com/sindresorhus/got?sponsor=1" - } - }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -3418,20 +3361,6 @@ "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==", "dev": true }, - "node_modules/http2-wrapper": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/http2-wrapper/-/http2-wrapper-1.0.3.tgz", - "integrity": "sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg==", - "dev": true, - "license": "MIT", - "dependencies": { - "quick-lru": "^5.1.1", - "resolve-alpn": "^1.0.0" - }, - "engines": { - "node": ">=10.19.0" - } - }, "node_modules/human-signals": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", @@ -3744,13 +3673,6 @@ "node": ">=4" } }, - "node_modules/json-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", - "dev": true, - "license": "MIT" - }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -3769,16 +3691,6 @@ "integrity": "sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg==", "dev": true }, - "node_modules/keyv": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", - "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", - "dev": true, - "license": "MIT", - "dependencies": { - "json-buffer": "3.0.1" - } - }, "node_modules/kind-of": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", @@ -3834,21 +3746,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/loam-cli": { - "version": "0.9.4", - "resolved": "https://registry.npmjs.org/loam-cli/-/loam-cli-0.9.4.tgz", - "integrity": "sha512-36QcRLJrdSBepIfextN1yey8z+lTpMOcjc0TNXK9NUYOLzndZuTMHW2kbsOHpOC4auK2xXlfuLDpozhWItWHAg==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "got": "^11.8.2", - "tar": "^6.1.0" - }, - "bin": { - "loam": "run.js" - } - }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -3864,6 +3761,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -3908,16 +3811,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/lowercase-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", - "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -4823,6 +4716,7 @@ "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", "dev": true, + "optional": true, "engines": { "node": ">=10" }, @@ -4866,53 +4760,6 @@ "node": ">=16 || 14 >=14.17" } }, - "node_modules/minizlib": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", - "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", - "dev": true, - "license": "MIT", - "dependencies": { - "minipass": "^3.0.0", - "yallist": "^4.0.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/minizlib/node_modules/minipass": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", - "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", - "dev": true, - "license": "ISC", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/minizlib/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true, - "license": "ISC" - }, - "node_modules/mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true, - "license": "MIT", - "bin": { - "mkdirp": "bin/cmd.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/mkdirp-classic": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", @@ -5042,19 +4889,6 @@ "node": ">=0.10.0" } }, - "node_modules/normalize-url": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz", - "integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/npm-run-path": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.2.0.tgz", @@ -5087,6 +4921,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, + "optional": true, "dependencies": { "wrappy": "1" } @@ -5158,16 +4993,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/p-cancelable": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-2.1.1.tgz", - "integrity": "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/p-limit": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-5.0.0.tgz", @@ -5269,15 +5094,6 @@ "dev": true, "license": "BlueOak-1.0.0" }, - "node_modules/parallelshell": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/parallelshell/-/parallelshell-3.0.2.tgz", - "integrity": "sha512-aW73W8tmYiFZtQi41pweV3WWT6o/EvSxAVQHbumOhN53H47OuWQwrRc11xQ2i44GFvR5AjtzhD92r8Kv9X+7Iw==", - "dev": true, - "bin": { - "parallelshell": "index.js" - } - }, "node_modules/parse-latin": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/parse-latin/-/parse-latin-5.0.1.tgz", @@ -5668,6 +5484,7 @@ "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", "dev": true, + "optional": true, "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" @@ -5700,19 +5517,6 @@ "dev": true, "optional": true }, - "node_modules/quick-lru": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", - "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -5763,6 +5567,12 @@ "node": ">=8.10.0" } }, + "node_modules/regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", + "dev": true + }, "node_modules/rehype": { "version": "13.0.1", "resolved": "https://registry.npmjs.org/rehype/-/rehype-13.0.1.tgz", @@ -5936,26 +5746,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/resolve-alpn": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz", - "integrity": "sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==", - "dev": true, - "license": "MIT" - }, - "node_modules/responselike": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/responselike/-/responselike-2.0.1.tgz", - "integrity": "sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==", - "dev": true, - "license": "MIT", - "dependencies": { - "lowercase-keys": "^2.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/restore-cursor": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-4.0.0.tgz", @@ -6447,6 +6237,15 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/rxjs": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "dev": true, + "dependencies": { + "tslib": "^2.1.0" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -6587,6 +6386,15 @@ "node": ">=8" } }, + "node_modules/shell-quote": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz", + "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/shikiji": { "version": "0.9.19", "resolved": "https://registry.npmjs.org/shikiji/-/shikiji-0.9.19.tgz", @@ -6687,30 +6495,6 @@ "node-gyp-build": "^4.8.0" } }, - "node_modules/soroban_atomic_swap_contract": { - "resolved": "packages/soroban_atomic_swap_contract", - "link": true - }, - "node_modules/soroban_auth_contract": { - "resolved": "packages/soroban_auth_contract", - "link": true - }, - "node_modules/soroban_errors_contract": { - "resolved": "packages/soroban_errors_contract", - "link": true - }, - "node_modules/soroban_hello_world_contract": { - "resolved": "packages/soroban_hello_world_contract", - "link": true - }, - "node_modules/soroban_increment_contract": { - "resolved": "packages/soroban_increment_contract", - "link": true - }, - "node_modules/soroban_token_contract": { - "resolved": "packages/soroban_token_contract", - "link": true - }, "node_modules/source-map-js": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", @@ -6730,6 +6514,12 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/spawn-command": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2.tgz", + "integrity": "sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==", + "dev": true + }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -6975,24 +6765,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/tar": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", - "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", - "dev": true, - "license": "ISC", - "dependencies": { - "chownr": "^2.0.0", - "fs-minipass": "^2.0.0", - "minipass": "^5.0.0", - "minizlib": "^2.1.1", - "mkdirp": "^1.0.3", - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/tar-fs": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.4.tgz", @@ -7017,33 +6789,6 @@ "streamx": "^2.15.0" } }, - "node_modules/tar/node_modules/chownr": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", - "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=10" - } - }, - "node_modules/tar/node_modules/minipass": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", - "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=8" - } - }, - "node_modules/tar/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true, - "license": "ISC" - }, "node_modules/to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", @@ -7070,6 +6815,15 @@ "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "bin": { + "tree-kill": "cli.js" + } + }, "node_modules/trim-lines": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", @@ -7110,6 +6864,12 @@ } } }, + "node_modules/tslib": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz", + "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==", + "dev": true + }, "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -7173,7 +6933,9 @@ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true, - "license": "MIT" + "license": "MIT", + "optional": true, + "peer": true }, "node_modules/unherit": { "version": "3.0.1", @@ -8311,7 +8073,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true + "dev": true, + "optional": true }, "node_modules/y18n": { "version": "5.0.8", @@ -8427,19 +8190,17 @@ "url": "https://github.com/sponsors/wooorm" } }, - "packages/soroban_account_contract": { + "packages/example_core": { "version": "0.0.0", - "extraneous": true, "dependencies": { - "@stellar/freighter-api": "1.7.1", - "@stellar/stellar-sdk": "11.2.0", + "@stellar/stellar-sdk": "12.1.0", "buffer": "6.0.3" }, "devDependencies": { "typescript": "5.3.3" } }, - "packages/soroban_atomic_swap_contract": { + "packages/example_status_message": { "version": "0.0.0", "dependencies": { "@stellar/stellar-sdk": "12.1.0", @@ -8449,38 +8210,32 @@ "typescript": "5.3.3" } }, - "packages/soroban_atomic_swap_contract/node_modules/@stellar/stellar-base": { - "version": "12.0.1", - "resolved": "https://registry.npmjs.org/@stellar/stellar-base/-/stellar-base-12.0.1.tgz", - "integrity": "sha512-g6c27MNsDgEdUmoNQJn7zCWoCY50WHt0OIIOq3PhWaJRtUaT++qs1Jpb8+1bny2GmhtfRGOfPUFSyQBuHT9Mvg==", + "packages/soroban_account_contract": { + "version": "0.0.0", + "extraneous": true, "dependencies": { - "@stellar/js-xdr": "^3.1.1", - "base32.js": "^0.1.0", - "bignumber.js": "^9.1.2", - "buffer": "^6.0.3", - "sha.js": "^2.3.6", - "tweetnacl": "^1.0.3" + "@stellar/freighter-api": "1.7.1", + "@stellar/stellar-sdk": "11.2.0", + "buffer": "6.0.3" }, - "optionalDependencies": { - "sodium-native": "^4.1.1" + "devDependencies": { + "typescript": "5.3.3" } }, - "packages/soroban_atomic_swap_contract/node_modules/@stellar/stellar-sdk": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/@stellar/stellar-sdk/-/stellar-sdk-12.1.0.tgz", - "integrity": "sha512-Va0hu9SaPezmMbO5eMwL5D15Wrx1AGWRtxayUDRWV2Fr3ynY58mvCZS1vsgNQ4kE8MZe3nBVKv6T9Kzqwgx1PQ==", + "packages/soroban_atomic_swap_contract": { + "version": "0.0.0", + "extraneous": true, "dependencies": { - "@stellar/stellar-base": "^12.0.1", - "axios": "^1.7.2", - "bignumber.js": "^9.1.2", - "eventsource": "^2.0.2", - "randombytes": "^2.1.0", - "toml": "^3.0.0", - "urijs": "^1.19.1" + "@stellar/stellar-sdk": "12.1.0", + "buffer": "6.0.3" + }, + "devDependencies": { + "typescript": "5.3.3" } }, "packages/soroban_auth_contract": { "version": "0.0.0", + "extraneous": true, "dependencies": { "@stellar/freighter-api": "1.7.1", "@stellar/stellar-sdk": "11.2.0", @@ -8492,6 +8247,7 @@ }, "packages/soroban_errors_contract": { "version": "0.0.0", + "extraneous": true, "dependencies": { "@stellar/freighter-api": "1.7.1", "@stellar/stellar-sdk": "11.2.0", @@ -8503,6 +8259,7 @@ }, "packages/soroban_hello_world_contract": { "version": "0.0.0", + "extraneous": true, "dependencies": { "@stellar/freighter-api": "1.7.1", "@stellar/stellar-sdk": "11.2.0", @@ -8514,6 +8271,7 @@ }, "packages/soroban_increment_contract": { "version": "0.0.0", + "extraneous": true, "dependencies": { "@stellar/freighter-api": "1.7.1", "@stellar/stellar-sdk": "11.2.0", @@ -8525,6 +8283,7 @@ }, "packages/soroban_token_contract": { "version": "0.0.0", + "extraneous": true, "dependencies": { "@stellar/freighter-api": "1.7.1", "@stellar/stellar-sdk": "11.2.0", diff --git a/package.json b/package.json index 3321c68..eae3802 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "type": "module", "version": "0.0.1", "scripts": { - "dev": "concurrently \"loam dev\" \"astro dev\"", - "start": "concurrently \"loam dev\" \"astro dev\"", + "dev": "concurrently \"loam dev --build-clients\" \"astro dev\"", + "start": "concurrently \"loam dev --build-clients\" \"astro dev\"", "build": "astro check && astro build", "preview": "astro preview", "astro": "astro" diff --git a/src/pages/index.astro b/src/pages/index.astro index 2b47da7..5275a71 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,127 +1,137 @@ --- import Layout from "../layouts/Layout.astro"; import Card from "../components/Card.astro"; -import helloWorld from "../contracts/hello_world"; -const { result } = await helloWorld.hello({ to: "you" }); -const greeting = result.join(" "); +import coreExample from "../contracts/example_core"; +import statusMessage from "../contracts/example_status_message"; + +const coreMethods = Object.keys(coreExample); +const statusMessageMethods = Object.keys(statusMessage); + +console.log({ coreMethods, statusMessageMethods }); --- - - -
- -

{greeting}

-

- To get started, open the directory src/pages in your project.
- Code Challenge: Tweak the "Welcome to Astro" message above. -

- -
+ + +
+ +

Hello Loam

+

+ To get started, open the directory src/pages in your project.
+ Code Challenge: Tweak the "Welcome to Astro" message above. +

+ +