From cb3879c76d2f342751c730b6b3ddd55b96abc177 Mon Sep 17 00:00:00 2001 From: seyeon22 Date: Sat, 22 Mar 2025 20:21:29 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Refactor:=20=EC=A7=80=EA=B0=91=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- poetry.lock | 209 +++++++++++++++++++- pyproject.toml | 1 + src/main/users/dto/UserWalletDto.py | 6 +- src/main/users/repository/UserRepository.py | 14 +- src/main/users/router/UserAPIRouter.py | 6 +- src/main/users/service/UserService.py | 13 +- src/tests/users/test_users_api_router.py | 78 ++++---- 7 files changed, 269 insertions(+), 58 deletions(-) diff --git a/poetry.lock b/poetry.lock index 550562b..9aece73 100644 --- a/poetry.lock +++ b/poetry.lock @@ -34,6 +34,21 @@ doc = ["Sphinx (>=8.2,<9.0)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", test = ["anyio[trio]", "blockbuster (>=1.5.23)", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "trustme", "truststore (>=0.9.1) ; python_version >= \"3.10\"", "uvloop (>=0.21) ; platform_python_implementation == \"CPython\" and platform_system != \"Windows\" and python_version < \"3.14\""] trio = ["trio (>=0.26.1)"] +[[package]] +name = "base58" +version = "2.1.1" +description = "Base58 and Base58Check implementation." +optional = false +python-versions = ">=3.5" +groups = ["main"] +files = [ + {file = "base58-2.1.1-py3-none-any.whl", hash = "sha256:11a36f4d3ce51dfc1043f3218591ac4eb1ceb172919cebe05b52a5bcc8d245c2"}, + {file = "base58-2.1.1.tar.gz", hash = "sha256:c5d0cb3f5b6e81e8e35da5754388ddcc6d0d14b6c6a132cb93d69ed580a7278c"}, +] + +[package.extras] +tests = ["PyHamcrest (>=2.0.2)", "mypy", "pytest (>=4.6)", "pytest-benchmark", "pytest-cov", "pytest-flake8"] + [[package]] name = "boto3" version = "1.37.16" @@ -216,6 +231,24 @@ files = [ ] markers = {main = "platform_system == \"Windows\" or sys_platform == \"win32\"", dev = "sys_platform == \"win32\""} +[[package]] +name = "deprecated" +version = "1.2.18" +description = "Python @deprecated decorator to deprecate old python classes, functions or methods." +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" +groups = ["main"] +files = [ + {file = "Deprecated-1.2.18-py2.py3-none-any.whl", hash = "sha256:bd5011788200372a32418f888e326a09ff80d0214bd961147cfed01b5c018eec"}, + {file = "deprecated-1.2.18.tar.gz", hash = "sha256:422b6f6d859da6f2ef57857761bfb392480502a64c3028ca9bbe86085d72115d"}, +] + +[package.dependencies] +wrapt = ">=1.10,<2" + +[package.extras] +dev = ["PyTest", "PyTest-Cov", "bump2version (<1)", "setuptools ; python_version >= \"3.12\"", "tox"] + [[package]] name = "dnspython" version = "2.7.0" @@ -251,6 +284,18 @@ files = [ [package.dependencies] python-dotenv = "*" +[[package]] +name = "ecpy" +version = "1.2.5" +description = "Pure Pyhton Elliptic Curve Library" +optional = false +python-versions = "*" +groups = ["main"] +files = [ + {file = "ECPy-1.2.5-py3-none-any.whl", hash = "sha256:559c92e42406d9d1a6b2b8fc26e6ad7bc985f33903b72f426a56cb1073a25ce3"}, + {file = "ECPy-1.2.5.tar.gz", hash = "sha256:9635cffb9b6ecf7fd7f72aea1665829ac74a1d272006d0057d45a621aae20228"}, +] + [[package]] name = "fastapi" version = "0.115.11" @@ -454,6 +499,45 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] +[[package]] +name = "pycryptodome" +version = "3.22.0" +description = "Cryptographic library for Python" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +groups = ["main"] +files = [ + {file = "pycryptodome-3.22.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:96e73527c9185a3d9b4c6d1cfb4494f6ced418573150be170f6580cb975a7f5a"}, + {file = "pycryptodome-3.22.0-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:9e1bb165ea1dc83a11e5dbbe00ef2c378d148f3a2d3834fb5ba4e0f6fd0afe4b"}, + {file = "pycryptodome-3.22.0-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:d4d1174677855c266eed5c4b4e25daa4225ad0c9ffe7584bb1816767892545d0"}, + {file = "pycryptodome-3.22.0-cp27-cp27m-win32.whl", hash = "sha256:9dbb749cef71c28271484cbef684f9b5b19962153487735411e1020ca3f59cb1"}, + {file = "pycryptodome-3.22.0-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:f1ae7beb64d4fc4903a6a6cca80f1f448e7a8a95b77d106f8a29f2eb44d17547"}, + {file = "pycryptodome-3.22.0-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:a26bcfee1293b7257c83b0bd13235a4ee58165352be4f8c45db851ba46996dc6"}, + {file = "pycryptodome-3.22.0-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:009e1c80eea42401a5bd5983c4bab8d516aef22e014a4705622e24e6d9d703c6"}, + {file = "pycryptodome-3.22.0-cp37-abi3-macosx_10_9_x86_64.whl", hash = "sha256:3b76fa80daeff9519d7e9f6d9e40708f2fce36b9295a847f00624a08293f4f00"}, + {file = "pycryptodome-3.22.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a31fa5914b255ab62aac9265654292ce0404f6b66540a065f538466474baedbc"}, + {file = "pycryptodome-3.22.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a0092fd476701eeeb04df5cc509d8b739fa381583cda6a46ff0a60639b7cd70d"}, + {file = "pycryptodome-3.22.0-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:18d5b0ddc7cf69231736d778bd3ae2b3efb681ae33b64b0c92fb4626bb48bb89"}, + {file = "pycryptodome-3.22.0-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:f6cf6aa36fcf463e622d2165a5ad9963b2762bebae2f632d719dfb8544903cf5"}, + {file = "pycryptodome-3.22.0-cp37-abi3-musllinux_1_2_i686.whl", hash = "sha256:aec7b40a7ea5af7c40f8837adf20a137d5e11a6eb202cde7e588a48fb2d871a8"}, + {file = "pycryptodome-3.22.0-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:d21c1eda2f42211f18a25db4eaf8056c94a8563cd39da3683f89fe0d881fb772"}, + {file = "pycryptodome-3.22.0-cp37-abi3-win32.whl", hash = "sha256:f02baa9f5e35934c6e8dcec91fcde96612bdefef6e442813b8ea34e82c84bbfb"}, + {file = "pycryptodome-3.22.0-cp37-abi3-win_amd64.whl", hash = "sha256:d086aed307e96d40c23c42418cbbca22ecc0ab4a8a0e24f87932eeab26c08627"}, + {file = "pycryptodome-3.22.0-pp27-pypy_73-manylinux2010_x86_64.whl", hash = "sha256:98fd9da809d5675f3a65dcd9ed384b9dc67edab6a4cda150c5870a8122ec961d"}, + {file = "pycryptodome-3.22.0-pp27-pypy_73-win32.whl", hash = "sha256:37ddcd18284e6b36b0a71ea495a4c4dca35bb09ccc9bfd5b91bfaf2321f131c1"}, + {file = "pycryptodome-3.22.0-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:b4bdce34af16c1dcc7f8c66185684be15f5818afd2a82b75a4ce6b55f9783e13"}, + {file = "pycryptodome-3.22.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2988ffcd5137dc2d27eb51cd18c0f0f68e5b009d5fec56fbccb638f90934f333"}, + {file = "pycryptodome-3.22.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e653519dedcd1532788547f00eeb6108cc7ce9efdf5cc9996abce0d53f95d5a9"}, + {file = "pycryptodome-3.22.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f5810bc7494e4ac12a4afef5a32218129e7d3890ce3f2b5ec520cc69eb1102ad"}, + {file = "pycryptodome-3.22.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:e7514a1aebee8e85802d154fdb261381f1cb9b7c5a54594545145b8ec3056ae6"}, + {file = "pycryptodome-3.22.0-pp39-pypy39_pp73-macosx_10_15_x86_64.whl", hash = "sha256:56c6f9342fcb6c74e205fbd2fee568ec4cdbdaa6165c8fde55dbc4ba5f584464"}, + {file = "pycryptodome-3.22.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:87a88dc543b62b5c669895caf6c5a958ac7abc8863919e94b7a6cafd2f64064f"}, + {file = "pycryptodome-3.22.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f7a683bc9fa585c0dfec7fa4801c96a48d30b30b096e3297f9374f40c2fedafc"}, + {file = "pycryptodome-3.22.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8f4f6f47a7f411f2c157e77bbbda289e0c9f9e1e9944caa73c1c2e33f3f92d6e"}, + {file = "pycryptodome-3.22.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a6cf9553b29624961cab0785a3177a333e09e37ba62ad22314ebdbb01ca79840"}, + {file = "pycryptodome-3.22.0.tar.gz", hash = "sha256:fd7ab568b3ad7b77c908d7c3f7e167ec5a8f035c64ff74f10d47a4edd043d723"}, +] + [[package]] name = "pydantic" version = "2.10.6" @@ -864,6 +948,18 @@ anyio = ">=3.6.2,<5" [package.extras] full = ["httpx (>=0.27.0,<0.29.0)", "itsdangerous", "jinja2", "python-multipart (>=0.0.18)", "pyyaml"] +[[package]] +name = "types-deprecated" +version = "1.2.15.20250304" +description = "Typing stubs for Deprecated" +optional = false +python-versions = ">=3.9" +groups = ["main"] +files = [ + {file = "types_deprecated-1.2.15.20250304-py3-none-any.whl", hash = "sha256:86a65aa550ea8acf49f27e226b8953288cd851de887970fbbdf2239c116c3107"}, + {file = "types_deprecated-1.2.15.20250304.tar.gz", hash = "sha256:c329030553029de5cc6cb30f269c11f4e00e598c4241290179f63cda7d33f719"}, +] + [[package]] name = "typing-extensions" version = "4.12.2" @@ -1136,7 +1232,118 @@ files = [ {file = "websockets-15.0.1.tar.gz", hash = "sha256:82544de02076bafba038ce055ee6412d68da13ab47f0c60cab827346de828dee"}, ] +[[package]] +name = "wrapt" +version = "1.17.2" +description = "Module for decorators, wrappers and monkey patching." +optional = false +python-versions = ">=3.8" +groups = ["main"] +files = [ + {file = "wrapt-1.17.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:3d57c572081fed831ad2d26fd430d565b76aa277ed1d30ff4d40670b1c0dd984"}, + {file = "wrapt-1.17.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b5e251054542ae57ac7f3fba5d10bfff615b6c2fb09abeb37d2f1463f841ae22"}, + {file = "wrapt-1.17.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:80dd7db6a7cb57ffbc279c4394246414ec99537ae81ffd702443335a61dbf3a7"}, + {file = "wrapt-1.17.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0a6e821770cf99cc586d33833b2ff32faebdbe886bd6322395606cf55153246c"}, + {file = "wrapt-1.17.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b60fb58b90c6d63779cb0c0c54eeb38941bae3ecf7a73c764c52c88c2dcb9d72"}, + {file = "wrapt-1.17.2-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b870b5df5b71d8c3359d21be8f0d6c485fa0ebdb6477dda51a1ea54a9b558061"}, + {file = "wrapt-1.17.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:4011d137b9955791f9084749cba9a367c68d50ab8d11d64c50ba1688c9b457f2"}, + {file = "wrapt-1.17.2-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:1473400e5b2733e58b396a04eb7f35f541e1fb976d0c0724d0223dd607e0f74c"}, + {file = "wrapt-1.17.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:3cedbfa9c940fdad3e6e941db7138e26ce8aad38ab5fe9dcfadfed9db7a54e62"}, + {file = "wrapt-1.17.2-cp310-cp310-win32.whl", hash = "sha256:582530701bff1dec6779efa00c516496968edd851fba224fbd86e46cc6b73563"}, + {file = "wrapt-1.17.2-cp310-cp310-win_amd64.whl", hash = "sha256:58705da316756681ad3c9c73fd15499aa4d8c69f9fd38dc8a35e06c12468582f"}, + {file = "wrapt-1.17.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:ff04ef6eec3eee8a5efef2401495967a916feaa353643defcc03fc74fe213b58"}, + {file = "wrapt-1.17.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4db983e7bca53819efdbd64590ee96c9213894272c776966ca6306b73e4affda"}, + {file = "wrapt-1.17.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9abc77a4ce4c6f2a3168ff34b1da9b0f311a8f1cfd694ec96b0603dff1c79438"}, + {file = "wrapt-1.17.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0b929ac182f5ace000d459c59c2c9c33047e20e935f8e39371fa6e3b85d56f4a"}, + {file = "wrapt-1.17.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f09b286faeff3c750a879d336fb6d8713206fc97af3adc14def0cdd349df6000"}, + {file = "wrapt-1.17.2-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1a7ed2d9d039bd41e889f6fb9364554052ca21ce823580f6a07c4ec245c1f5d6"}, + {file = "wrapt-1.17.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:129a150f5c445165ff941fc02ee27df65940fcb8a22a61828b1853c98763a64b"}, + {file = "wrapt-1.17.2-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:1fb5699e4464afe5c7e65fa51d4f99e0b2eadcc176e4aa33600a3df7801d6662"}, + {file = "wrapt-1.17.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:9a2bce789a5ea90e51a02dfcc39e31b7f1e662bc3317979aa7e5538e3a034f72"}, + {file = "wrapt-1.17.2-cp311-cp311-win32.whl", hash = "sha256:4afd5814270fdf6380616b321fd31435a462019d834f83c8611a0ce7484c7317"}, + {file = "wrapt-1.17.2-cp311-cp311-win_amd64.whl", hash = "sha256:acc130bc0375999da18e3d19e5a86403667ac0c4042a094fefb7eec8ebac7cf3"}, + {file = "wrapt-1.17.2-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:d5e2439eecc762cd85e7bd37161d4714aa03a33c5ba884e26c81559817ca0925"}, + {file = "wrapt-1.17.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:3fc7cb4c1c744f8c05cd5f9438a3caa6ab94ce8344e952d7c45a8ed59dd88392"}, + {file = "wrapt-1.17.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8fdbdb757d5390f7c675e558fd3186d590973244fab0c5fe63d373ade3e99d40"}, + {file = "wrapt-1.17.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5bb1d0dbf99411f3d871deb6faa9aabb9d4e744d67dcaaa05399af89d847a91d"}, + {file = "wrapt-1.17.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d18a4865f46b8579d44e4fe1e2bcbc6472ad83d98e22a26c963d46e4c125ef0b"}, + {file = "wrapt-1.17.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc570b5f14a79734437cb7b0500376b6b791153314986074486e0b0fa8d71d98"}, + {file = "wrapt-1.17.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:6d9187b01bebc3875bac9b087948a2bccefe464a7d8f627cf6e48b1bbae30f82"}, + {file = "wrapt-1.17.2-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:9e8659775f1adf02eb1e6f109751268e493c73716ca5761f8acb695e52a756ae"}, + {file = "wrapt-1.17.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:e8b2816ebef96d83657b56306152a93909a83f23994f4b30ad4573b00bd11bb9"}, + {file = "wrapt-1.17.2-cp312-cp312-win32.whl", hash = "sha256:468090021f391fe0056ad3e807e3d9034e0fd01adcd3bdfba977b6fdf4213ea9"}, + {file = "wrapt-1.17.2-cp312-cp312-win_amd64.whl", hash = "sha256:ec89ed91f2fa8e3f52ae53cd3cf640d6feff92ba90d62236a81e4e563ac0e991"}, + {file = "wrapt-1.17.2-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:6ed6ffac43aecfe6d86ec5b74b06a5be33d5bb9243d055141e8cabb12aa08125"}, + {file = "wrapt-1.17.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:35621ae4c00e056adb0009f8e86e28eb4a41a4bfa8f9bfa9fca7d343fe94f998"}, + {file = "wrapt-1.17.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a604bf7a053f8362d27eb9fefd2097f82600b856d5abe996d623babd067b1ab5"}, + {file = "wrapt-1.17.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5cbabee4f083b6b4cd282f5b817a867cf0b1028c54d445b7ec7cfe6505057cf8"}, + {file = "wrapt-1.17.2-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:49703ce2ddc220df165bd2962f8e03b84c89fee2d65e1c24a7defff6f988f4d6"}, + {file = "wrapt-1.17.2-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8112e52c5822fc4253f3901b676c55ddf288614dc7011634e2719718eaa187dc"}, + {file = "wrapt-1.17.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:9fee687dce376205d9a494e9c121e27183b2a3df18037f89d69bd7b35bcf59e2"}, + {file = "wrapt-1.17.2-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:18983c537e04d11cf027fbb60a1e8dfd5190e2b60cc27bc0808e653e7b218d1b"}, + {file = "wrapt-1.17.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:703919b1633412ab54bcf920ab388735832fdcb9f9a00ae49387f0fe67dad504"}, + {file = "wrapt-1.17.2-cp313-cp313-win32.whl", hash = "sha256:abbb9e76177c35d4e8568e58650aa6926040d6a9f6f03435b7a522bf1c487f9a"}, + {file = "wrapt-1.17.2-cp313-cp313-win_amd64.whl", hash = "sha256:69606d7bb691b50a4240ce6b22ebb319c1cfb164e5f6569835058196e0f3a845"}, + {file = "wrapt-1.17.2-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:4a721d3c943dae44f8e243b380cb645a709ba5bd35d3ad27bc2ed947e9c68192"}, + {file = "wrapt-1.17.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:766d8bbefcb9e00c3ac3b000d9acc51f1b399513f44d77dfe0eb026ad7c9a19b"}, + {file = "wrapt-1.17.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:e496a8ce2c256da1eb98bd15803a79bee00fc351f5dfb9ea82594a3f058309e0"}, + {file = "wrapt-1.17.2-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:40d615e4fe22f4ad3528448c193b218e077656ca9ccb22ce2cb20db730f8d306"}, + {file = "wrapt-1.17.2-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a5aaeff38654462bc4b09023918b7f21790efb807f54c000a39d41d69cf552cb"}, + {file = "wrapt-1.17.2-cp313-cp313t-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9a7d15bbd2bc99e92e39f49a04653062ee6085c0e18b3b7512a4f2fe91f2d681"}, + {file = "wrapt-1.17.2-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:e3890b508a23299083e065f435a492b5435eba6e304a7114d2f919d400888cc6"}, + {file = "wrapt-1.17.2-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:8c8b293cd65ad716d13d8dd3624e42e5a19cc2a2f1acc74b30c2c13f15cb61a6"}, + {file = "wrapt-1.17.2-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:4c82b8785d98cdd9fed4cac84d765d234ed3251bd6afe34cb7ac523cb93e8b4f"}, + {file = "wrapt-1.17.2-cp313-cp313t-win32.whl", hash = "sha256:13e6afb7fe71fe7485a4550a8844cc9ffbe263c0f1a1eea569bc7091d4898555"}, + {file = "wrapt-1.17.2-cp313-cp313t-win_amd64.whl", hash = "sha256:eaf675418ed6b3b31c7a989fd007fa7c3be66ce14e5c3b27336383604c9da85c"}, + {file = "wrapt-1.17.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:5c803c401ea1c1c18de70a06a6f79fcc9c5acfc79133e9869e730ad7f8ad8ef9"}, + {file = "wrapt-1.17.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f917c1180fdb8623c2b75a99192f4025e412597c50b2ac870f156de8fb101119"}, + {file = "wrapt-1.17.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:ecc840861360ba9d176d413a5489b9a0aff6d6303d7e733e2c4623cfa26904a6"}, + {file = "wrapt-1.17.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bb87745b2e6dc56361bfde481d5a378dc314b252a98d7dd19a651a3fa58f24a9"}, + {file = "wrapt-1.17.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:58455b79ec2661c3600e65c0a716955adc2410f7383755d537584b0de41b1d8a"}, + {file = "wrapt-1.17.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b4e42a40a5e164cbfdb7b386c966a588b1047558a990981ace551ed7e12ca9c2"}, + {file = "wrapt-1.17.2-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:91bd7d1773e64019f9288b7a5101f3ae50d3d8e6b1de7edee9c2ccc1d32f0c0a"}, + {file = "wrapt-1.17.2-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:bb90fb8bda722a1b9d48ac1e6c38f923ea757b3baf8ebd0c82e09c5c1a0e7a04"}, + {file = "wrapt-1.17.2-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:08e7ce672e35efa54c5024936e559469436f8b8096253404faeb54d2a878416f"}, + {file = "wrapt-1.17.2-cp38-cp38-win32.whl", hash = "sha256:410a92fefd2e0e10d26210e1dfb4a876ddaf8439ef60d6434f21ef8d87efc5b7"}, + {file = "wrapt-1.17.2-cp38-cp38-win_amd64.whl", hash = "sha256:95c658736ec15602da0ed73f312d410117723914a5c91a14ee4cdd72f1d790b3"}, + {file = "wrapt-1.17.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:99039fa9e6306880572915728d7f6c24a86ec57b0a83f6b2491e1d8ab0235b9a"}, + {file = "wrapt-1.17.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2696993ee1eebd20b8e4ee4356483c4cb696066ddc24bd70bcbb80fa56ff9061"}, + {file = "wrapt-1.17.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:612dff5db80beef9e649c6d803a8d50c409082f1fedc9dbcdfde2983b2025b82"}, + {file = "wrapt-1.17.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:62c2caa1585c82b3f7a7ab56afef7b3602021d6da34fbc1cf234ff139fed3cd9"}, + {file = "wrapt-1.17.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c958bcfd59bacc2d0249dcfe575e71da54f9dcf4a8bdf89c4cb9a68a1170d73f"}, + {file = "wrapt-1.17.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fc78a84e2dfbc27afe4b2bd7c80c8db9bca75cc5b85df52bfe634596a1da846b"}, + {file = "wrapt-1.17.2-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:ba0f0eb61ef00ea10e00eb53a9129501f52385c44853dbd6c4ad3f403603083f"}, + {file = "wrapt-1.17.2-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:1e1fe0e6ab7775fd842bc39e86f6dcfc4507ab0ffe206093e76d61cde37225c8"}, + {file = "wrapt-1.17.2-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:c86563182421896d73858e08e1db93afdd2b947a70064b813d515d66549e15f9"}, + {file = "wrapt-1.17.2-cp39-cp39-win32.whl", hash = "sha256:f393cda562f79828f38a819f4788641ac7c4085f30f1ce1a68672baa686482bb"}, + {file = "wrapt-1.17.2-cp39-cp39-win_amd64.whl", hash = "sha256:36ccae62f64235cf8ddb682073a60519426fdd4725524ae38874adf72b5f2aeb"}, + {file = "wrapt-1.17.2-py3-none-any.whl", hash = "sha256:b18f2d1533a71f069c7f82d524a52599053d4c7166e9dd374ae2136b7f40f7c8"}, + {file = "wrapt-1.17.2.tar.gz", hash = "sha256:41388e9d4d1522446fe79d3213196bd9e3b301a336965b9e27ca2788ebd122f3"}, +] + +[[package]] +name = "xrpl-py" +version = "4.1.0" +description = "A complete Python library for interacting with the XRP ledger" +optional = false +python-versions = "<4.0,>=3.8.1" +groups = ["main"] +files = [ + {file = "xrpl_py-4.1.0-py3-none-any.whl", hash = "sha256:4cbe6eef92b78813713d5029518b16ee8e826389056a2e6a8b3866cb5c332fa4"}, + {file = "xrpl_py-4.1.0.tar.gz", hash = "sha256:be07189dfaaf0472a9d12919a5985329b588eb33f4c9ec099d7c3e470e735d1c"}, +] + +[package.dependencies] +base58 = ">=2.1.0,<3.0.0" +Deprecated = ">=1.2.13,<2.0.0" +ECPy = ">=1.2.5,<2.0.0" +httpx = ">=0.18.1,<0.29.0" +pycryptodome = ">=3.16.0,<4.0.0" +types-Deprecated = ">=1.2.9,<2.0.0" +typing-extensions = ">=4.2.0,<5.0.0" +websockets = ">=11" + [metadata] lock-version = "2.1" python-versions = "^3.12" -content-hash = "7bfd13a31091b296b41239466d441159bdeb6d079af0ce7e19012ea123725ce4" +content-hash = "617547022a1052846b9b289b25f2f1b9d0c3f6ba39aff59ca8a46bd34da21ccd" diff --git a/pyproject.toml b/pyproject.toml index 1159da7..3e6a38b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ dotenv = "^0.9.9" httpx = "^0.28.1" pymongo = "^4.11.3" requests = "^2.32.3" +xrpl-py = "^4.1.0" [tool.poetry.group.dev.dependencies] pytest = "^8.3.5" diff --git a/src/main/users/dto/UserWalletDto.py b/src/main/users/dto/UserWalletDto.py index bce8be3..1b0a01d 100644 --- a/src/main/users/dto/UserWalletDto.py +++ b/src/main/users/dto/UserWalletDto.py @@ -1,4 +1,6 @@ from pydantic import BaseModel -class WalletRequest(BaseModel): - wallet_address: str \ No newline at end of file +class WalletResponse(BaseModel): + wallet_address: str + user_id: str + message: str \ No newline at end of file diff --git a/src/main/users/repository/UserRepository.py b/src/main/users/repository/UserRepository.py index 70547a8..044474e 100644 --- a/src/main/users/repository/UserRepository.py +++ b/src/main/users/repository/UserRepository.py @@ -11,14 +11,14 @@ def find_wallets_by_user_id(self, user_id: str) -> list: wallets = list(self.wallets_collection.find({"user_id": user_id}, {"_id": 0})) return wallets if wallets else [] - def create_or_update_wallet(self, user_id: str, wallet_address: str) -> dict: - existing_wallet = self.wallets_collection.find_one({"user_id": user_id}) - - if existing_wallet: - self.wallets_collection.update_one({"user_id": user_id}, - {"$set": {"address": wallet_address}}) + def save_wallet(self, user_id: str, wallet_address: str): + existing = self.wallets_collection.find_one({"user_id": user_id}) + if existing: + self.wallets_collection.update_one( + {"user_id": user_id}, + {"$set": {"address": wallet_address}} + ) return {"message": "Wallet updated", "user_id": user_id, "wallet_address": wallet_address} - else: self.wallets_collection.insert_one({"user_id": user_id, "address": wallet_address}) return {"message": "Wallet created", "user_id": user_id, "wallet_address": wallet_address} \ No newline at end of file diff --git a/src/main/users/router/UserAPIRouter.py b/src/main/users/router/UserAPIRouter.py index 3e6d4bc..9ad7398 100644 --- a/src/main/users/router/UserAPIRouter.py +++ b/src/main/users/router/UserAPIRouter.py @@ -2,7 +2,6 @@ from fastapi import APIRouter, Depends from src.main.auth.dependencies import get_current_user from src.main.users.service.UserService import UserService -from src.main.users.dto.UserWalletDto import WalletRequest router = APIRouter( prefix="/users", @@ -19,9 +18,8 @@ async def get_user_wallets( # 유저의 XPRL 지갑 주소 저장 또는 업데이트 하는 API @router.post("/wallets") -async def create_or_update_wallet( - wallet_data: WalletRequest, +async def create_wallet( user_id: uuid.UUID = Depends(get_current_user), user_service: UserService = Depends() ): - return user_service.add_wallet(str(user_id), wallet_data.wallet_address) \ No newline at end of file + return await user_service.generate_wallet(str(user_id)) \ No newline at end of file diff --git a/src/main/users/service/UserService.py b/src/main/users/service/UserService.py index 269b946..5c60d2f 100644 --- a/src/main/users/service/UserService.py +++ b/src/main/users/service/UserService.py @@ -1,16 +1,21 @@ +from xrpl.clients import JsonRpcClient +from xrpl.asyncio.wallet import generate_faucet_wallet from src.main.users.repository.UserRepository import UserRepository +TESTNET_URL = "https://s.altnet.rippletest.net:51234" +client = JsonRpcClient(TESTNET_URL) class UserService: def __init__(self): self.user_repository = UserRepository() def get_wallets(self, user_id: str): wallets = self.user_repository.find_wallets_by_user_id(user_id) - if not wallets: return {"message": "No wallets found for this user"} - return wallets - def add_wallet(self, user_id: str, wallet_address: str): - return self.user_repository.create_or_update_wallet(user_id, wallet_address) \ No newline at end of file + async def generate_wallet(self, user_id: str): + wallet = await generate_faucet_wallet(client=client, debug=True) + wallet_address = wallet.classic_address + result = self.user_repository.save_wallet(user_id, wallet_address) + return result \ No newline at end of file diff --git a/src/tests/users/test_users_api_router.py b/src/tests/users/test_users_api_router.py index 10fe0dc..94afe4f 100644 --- a/src/tests/users/test_users_api_router.py +++ b/src/tests/users/test_users_api_router.py @@ -1,40 +1,38 @@ -# import requests -# import uuid - -# BASE_URL = "http://localhost:8081" #"https://5erhg0u08g.execute-api.ap-northeast-2.amazonaws.com" - -# TEST_USER_ID = "11111111-2222-3333-4444-555555555555" # str(uuid.uuid4()) -# TEST_WALLET_ADDRESS = "rEXTERNALTESTWALLET123" - -# headers = { -# "x-auth-sub": TEST_USER_ID # 추후에 삭제할 부분 -# } - -# # 지갑 생성 또는 업데이트 (POST /users/wallets) -# def test_create_or_update_wallet(): -# response = requests.post( -# f"{BASE_URL}/users/wallets", -# json={"wallet_address": TEST_WALLET_ADDRESS}, -# headers=headers -# ) - -# print("POST response:", response.status_code, response.text) # 로그 출력용 - -# assert response.status_code == 200, f"Unexpected status: {response.status_code}, response: {response.text}" -# data = response.json() -# assert data["wallet_address"] == TEST_WALLET_ADDRESS -# assert data["user_id"] == TEST_USER_ID -# assert data["message"] in ["Wallet created", "Wallet updated"] - -# # 유저 지갑 목록 조회 (GET /users/wallets) -# def test_get_wallets(): -# response = requests.get(f"{BASE_URL}/users/wallets", headers=headers) - -# assert response.status_code == 200, f"Unexpected status: {response.status_code}, response: {response.text}" -# data = response.json() - -# if isinstance(data, dict) and "message" in data: -# assert data["message"] == "No wallets found for this user" -# else: -# assert isinstance(data, list) -# assert any(wallet["address"] == TEST_WALLET_ADDRESS for wallet in data) \ No newline at end of file +import requests +import uuid + +BASE_URL = "http://localhost:8081" #"https://5erhg0u08g.execute-api.ap-northeast-2.amazonaws.com" + +TEST_USER_ID = "11111111-2222-3333-4444-555555555555" # str(uuid.uuid4()) + +headers = { + "x-auth-sub": TEST_USER_ID # 추후에 삭제할 부분 +} + +# 지갑 생성 또는 업데이트 (POST /users/wallets) +def test_create_wallet(): + response = requests.post( + f"{BASE_URL}/users/wallets", + headers=headers + ) + + print("POST response:", response.status_code, response.text) # 로그 출력용 + + assert response.status_code == 200, f"Unexpected status: {response.status_code}, response: {response.text}" + data = response.json() + assert "wallet_address" in data + assert data["user_id"] == TEST_USER_ID + assert data["message"] in ["Wallet created", "Wallet updated"] + +# 유저 지갑 목록 조회 (GET /users/wallets) +def test_get_wallets(): + response = requests.get(f"{BASE_URL}/users/wallets", headers=headers) + + assert response.status_code == 200, f"Unexpected status: {response.status_code}, response: {response.text}" + data = response.json() + + if isinstance(data, dict) and "message" in data: + assert data["message"] == "No wallets found for this user" + else: + assert isinstance(data, list) + assert any("address" in wallet and wallet["address"].startswith("r") for wallet in data) \ No newline at end of file From f49a0801b878dc67b225b4725a2f648a3e0c7298 Mon Sep 17 00:00:00 2001 From: seyeon22 Date: Sat, 22 Mar 2025 20:22:01 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Refactor:=20=EC=A7=80=EA=B0=91=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=ED=96=88=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/tests/users/test_users_api_router.py | 58 ++++++++++++------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/tests/users/test_users_api_router.py b/src/tests/users/test_users_api_router.py index 94afe4f..c554368 100644 --- a/src/tests/users/test_users_api_router.py +++ b/src/tests/users/test_users_api_router.py @@ -1,38 +1,38 @@ -import requests -import uuid +# import requests +# import uuid -BASE_URL = "http://localhost:8081" #"https://5erhg0u08g.execute-api.ap-northeast-2.amazonaws.com" +# BASE_URL = "http://localhost:8081" #"https://5erhg0u08g.execute-api.ap-northeast-2.amazonaws.com" -TEST_USER_ID = "11111111-2222-3333-4444-555555555555" # str(uuid.uuid4()) +# TEST_USER_ID = "11111111-2222-3333-4444-555555555555" # str(uuid.uuid4()) -headers = { - "x-auth-sub": TEST_USER_ID # 추후에 삭제할 부분 -} +# headers = { +# "x-auth-sub": TEST_USER_ID # 추후에 삭제할 부분 +# } -# 지갑 생성 또는 업데이트 (POST /users/wallets) -def test_create_wallet(): - response = requests.post( - f"{BASE_URL}/users/wallets", - headers=headers - ) +# # 지갑 생성 또는 업데이트 (POST /users/wallets) +# def test_create_wallet(): +# response = requests.post( +# f"{BASE_URL}/users/wallets", +# headers=headers +# ) - print("POST response:", response.status_code, response.text) # 로그 출력용 +# print("POST response:", response.status_code, response.text) # 로그 출력용 - assert response.status_code == 200, f"Unexpected status: {response.status_code}, response: {response.text}" - data = response.json() - assert "wallet_address" in data - assert data["user_id"] == TEST_USER_ID - assert data["message"] in ["Wallet created", "Wallet updated"] +# assert response.status_code == 200, f"Unexpected status: {response.status_code}, response: {response.text}" +# data = response.json() +# assert "wallet_address" in data +# assert data["user_id"] == TEST_USER_ID +# assert data["message"] in ["Wallet created", "Wallet updated"] -# 유저 지갑 목록 조회 (GET /users/wallets) -def test_get_wallets(): - response = requests.get(f"{BASE_URL}/users/wallets", headers=headers) +# # 유저 지갑 목록 조회 (GET /users/wallets) +# def test_get_wallets(): +# response = requests.get(f"{BASE_URL}/users/wallets", headers=headers) - assert response.status_code == 200, f"Unexpected status: {response.status_code}, response: {response.text}" - data = response.json() +# assert response.status_code == 200, f"Unexpected status: {response.status_code}, response: {response.text}" +# data = response.json() - if isinstance(data, dict) and "message" in data: - assert data["message"] == "No wallets found for this user" - else: - assert isinstance(data, list) - assert any("address" in wallet and wallet["address"].startswith("r") for wallet in data) \ No newline at end of file +# if isinstance(data, dict) and "message" in data: +# assert data["message"] == "No wallets found for this user" +# else: +# assert isinstance(data, list) +# assert any("address" in wallet and wallet["address"].startswith("r") for wallet in data) \ No newline at end of file