From a78205075e5a2e05c4c43f0d74f8376a928fee12 Mon Sep 17 00:00:00 2001 From: HuanXiang Date: Thu, 18 Jul 2024 23:55:41 +0800 Subject: [PATCH] refact: blockchain api --- www/package.json | 2 +- www/pnpm-lock.yaml | 281 ++++++++++++++---------- www/src/apis/blockchain.ts | 166 +++++++++----- www/src/i18n/messages/en-us.json | 4 +- www/src/i18n/messages/zh-cn.json | 4 +- www/src/views/icons/Protect.vue | 33 ++- www/src/views/project/Setting.vue | 6 +- www/src/views/user/Assets.vue | 20 +- www/src/views/user/assets/drop/Init.vue | 6 +- 9 files changed, 310 insertions(+), 212 deletions(-) diff --git a/www/package.json b/www/package.json index f01b8b0..eca86fd 100644 --- a/www/package.json +++ b/www/package.json @@ -18,7 +18,7 @@ "license": "AGPLv3", "dependencies": { "@cosmjs/encoding": "^0.31.3", - "@iconlake/client": "^0.6.0", + "@iconlake/client": "^1.0.0", "axios": "^0.27.2", "crypto-js": "^4.1.1", "dexie": "^4.0.7", diff --git a/www/pnpm-lock.yaml b/www/pnpm-lock.yaml index f545dd2..6489848 100644 --- a/www/pnpm-lock.yaml +++ b/www/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: ^0.31.3 version: 0.31.3 '@iconlake/client': - specifier: ^0.6.0 - version: 0.6.0(@cosmjs/launchpad@0.27.1)(@cosmjs/proto-signing@0.31.1)(@cosmjs/stargate@0.31.1) + specifier: ^1.0.0 + version: 1.0.0(@cosmjs/launchpad@0.27.1)(@cosmjs/proto-signing@0.31.1)(@cosmjs/stargate@0.31.1) axios: specifier: ^0.27.2 version: 0.27.2 @@ -126,14 +126,14 @@ packages: '@cosmjs/amino@0.27.1': resolution: {integrity: sha512-w56ar/nK9+qlvWDpBPRmD0Blk2wfkkLqRi1COs1x7Ll1LF0AtkIBUjbRKplENLbNovK0T3h+w8bHiFm+GBGQOA==} - '@cosmjs/amino@0.31.1': - resolution: {integrity: sha512-kkB9IAkNEUFtjp/uwHv95TgM8VGJ4VWfZwrTyLNqBDD1EpSX2dsNrmUe7k8OMPzKlZUFcKmD4iA0qGvIwzjbGA==} + '@cosmjs/amino@0.31.3': + resolution: {integrity: sha512-36emtUq895sPRX8PTSOnG+lhJDCVyIcE0Tr5ct59sUbgQiI14y43vj/4WAlJ/utSOxy+Zhj9wxcs4AZfu0BHsw==} '@cosmjs/crypto@0.27.1': resolution: {integrity: sha512-vbcxwSt99tIYJg8Spp00wc3zx72qx+pY3ozGuBN8gAvySnagK9dQ/jHwtWQWdammmdD6oW+75WfIHZ+gNa+Ybg==} - '@cosmjs/crypto@0.31.1': - resolution: {integrity: sha512-4R/SqdzdVzd4E5dpyEh1IKm5GbTqwDogutyIyyb1bcOXiX/x3CrvPI9Tb4WSIMDLvlb5TVzu2YnUV51Q1+6mMA==} + '@cosmjs/crypto@0.31.3': + resolution: {integrity: sha512-vRbvM9ZKR2017TO73dtJ50KxoGcFzKtKI7C8iO302BQ5p+DuB+AirUg1952UpSoLfv5ki9O416MFANNg8UN/EQ==} '@cosmjs/encoding@0.27.1': resolution: {integrity: sha512-rayLsA0ojHeniaRfWWcqSsrE/T1rl1gl0OXVNtXlPwLJifKBeLEefGbOUiAQaT0wgJ8VNGBazVtAZBpJidfDhw==} @@ -141,8 +141,8 @@ packages: '@cosmjs/encoding@0.31.3': resolution: {integrity: sha512-6IRtG0fiVYwyP7n+8e54uTx2pLYijO48V3t9TLiROERm5aUAIzIlz6Wp0NYaI5he9nh1lcEGJ1lkquVKFw3sUg==} - '@cosmjs/json-rpc@0.31.1': - resolution: {integrity: sha512-gIkCj2mUDHAxvmJnHtybXtMLZDeXrkDZlujjzhvJlWsIuj1kpZbKtYqh+eNlfwhMkMMAlQa/y4422jDmizW+ng==} + '@cosmjs/json-rpc@0.31.3': + resolution: {integrity: sha512-7LVYerXjnm69qqYR3uA6LGCrBW2EO5/F7lfJxAmY+iII2C7xO3a0vAjMSt5zBBh29PXrJVS6c2qRP22W1Le2Wg==} '@cosmjs/launchpad@0.27.1': resolution: {integrity: sha512-DcFwGD/z5PK8CzO2sojDxa+Be9EIEtRZb2YawgVnw2Ht/p5FlNv+OVo8qlishpBdalXEN7FvQ1dVeDFEe9TuJw==} @@ -150,29 +150,29 @@ packages: '@cosmjs/math@0.27.1': resolution: {integrity: sha512-cHWVjmfIjtRc7f80n7x+J5k8pe+vTVTQ0lA82tIxUgqUvgS6rogPP/TmGtTiZ4+NxWxd11DUISY6gVpr18/VNQ==} - '@cosmjs/math@0.31.1': - resolution: {integrity: sha512-kiuHV6m6DSB8/4UV1qpFhlc4ul8SgLXTGRlYkYiIIP4l0YNeJ+OpPYaOlEgx4Unk2mW3/O2FWYj7Jc93+BWXng==} + '@cosmjs/math@0.31.3': + resolution: {integrity: sha512-kZ2C6glA5HDb9hLz1WrftAjqdTBb3fWQsRR+Us2HsjAYdeE6M3VdXMsYCP5M3yiihal1WDwAY2U7HmfJw7Uh4A==} '@cosmjs/proto-signing@0.31.1': resolution: {integrity: sha512-hipbBVrssPu+jnmRzQRP5hhS/mbz2nU7RvxG/B1ZcdNhr1AtZC5DN09OTUoEpMSRgyQvScXmk/NTbyf+xmCgYg==} - '@cosmjs/socket@0.31.1': - resolution: {integrity: sha512-XTtEr+x3WGbqkzoGX0sCkwVqf5n+bBqDwqNgb+DWaBABQxHVRuuainrTVp0Yc91D3Iy2twLQzeBA9OrRxDSerw==} + '@cosmjs/socket@0.31.3': + resolution: {integrity: sha512-aqrDGGi7os/hsz5p++avI4L0ZushJ+ItnzbqA7C6hamFSCJwgOkXaOUs+K9hXZdX4rhY7rXO4PH9IH8q09JkTw==} '@cosmjs/stargate@0.31.1': resolution: {integrity: sha512-TqOJZYOH5W3sZIjR6949GfjhGXO3kSHQ3/KmE+SuKyMMmQ5fFZ45beawiRtVF0/CJg5RyPFyFGJKhb1Xxv3Lcg==} - '@cosmjs/stream@0.31.1': - resolution: {integrity: sha512-xsIGD9bpBvYYZASajCyOevh1H5pDdbOWmvb4UwGZ78doGVz3IC3Kb9BZKJHIX2fjq9CMdGVJHmlM+Zp5aM8yZA==} + '@cosmjs/stream@0.31.3': + resolution: {integrity: sha512-8keYyI7X0RjsLyVcZuBeNjSv5FA4IHwbFKx7H60NHFXszN8/MvXL6aZbNIvxtcIHHsW7K9QSQos26eoEWlAd+w==} - '@cosmjs/tendermint-rpc@0.31.1': - resolution: {integrity: sha512-KX+wwi725sSePqIxfMPPOqg+xTETV8BHGOBhRhCZXEl5Fq48UlXXq3/yG1sn7K67ADC0kqHqcCF41Wn1GxNNPA==} + '@cosmjs/tendermint-rpc@0.31.3': + resolution: {integrity: sha512-s3TiWkPCW4QceTQjpYqn4xttUJH36mTPqplMl+qyocdqk5+X5mergzExU/pHZRWQ4pbby8bnR7kMvG4OC1aZ8g==} '@cosmjs/utils@0.27.1': resolution: {integrity: sha512-VG7QPDiMUzVPxRdJahDV8PXxVdnuAHiIuG56hldV4yPnOz/si/DLNd7VAUUA5923b6jS1Hhev0Hr6AhEkcxBMg==} - '@cosmjs/utils@0.31.1': - resolution: {integrity: sha512-n4Se1wu4GnKwztQHNFfJvUeWcpvx3o8cWhSbNs9JQShEuB3nv3R5lqFBtDCgHZF/emFQAP+ZjF8bTfCs9UBGhA==} + '@cosmjs/utils@0.31.3': + resolution: {integrity: sha512-VBhAgzrrYdIe0O5IbKRqwszbQa7ZyQLx9nEQuHQ3HUplQW7P44COG/ye2n6AzCudtqxmwdX7nyX8ta1J07GoqA==} '@ctrl/tinycolor@3.4.1': resolution: {integrity: sha512-ej5oVy6lykXsvieQtqZxCOaLT+xD4+QNarq78cIYISHmZXshCvROLudpQN3lfL8G0NL7plMSSK+zlyvCaIJ4Iw==} @@ -230,8 +230,8 @@ packages: '@humanwhocodes/object-schema@1.2.1': resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} - '@iconlake/client@0.6.0': - resolution: {integrity: sha512-wjbC7HuQ5u7FeGoq0fGpa66kDKW6jicOfTZQkKkcLZ5BJgK5r4+uQxRP7UI5ALPXGDGrJmL5QblIvLCQmW3IiQ==} + '@iconlake/client@1.0.0': + resolution: {integrity: sha512-zXXiRazXMMFyopBFrbQnk1nScjUY7iAWQeqPOYIvvDfo/oiE8PkN9du7LgfRySP69VkKwfKXCqzioAVzGOmVEQ==} peerDependencies: '@cosmjs/launchpad': 0.27.1 '@cosmjs/proto-signing': 0.31.1 @@ -263,8 +263,8 @@ packages: '@keplr-wallet/types@0.12.16': resolution: {integrity: sha512-13V/6swfg0jBaMamkt4X2nJ83l1y0WM81l3MMhfsDutumrENYnVqflGMvdu9RNNtn2VR8IwiAYLr8iS6/a+Q4Q==} - '@noble/hashes@1.3.1': - resolution: {integrity: sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==} + '@noble/hashes@1.4.0': + resolution: {integrity: sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==} engines: {node: '>= 16'} '@nodelib/fs.scandir@2.1.5': @@ -676,12 +676,16 @@ packages: deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} + define-data-property@1.1.4: + resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} + engines: {node: '>= 0.4'} + define-properties@1.1.4: resolution: {integrity: sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==} engines: {node: '>= 0.4'} - define-properties@1.2.0: - resolution: {integrity: sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA==} + define-properties@1.2.1: + resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} engines: {node: '>= 0.4'} delayed-stream@1.0.0: @@ -704,8 +708,8 @@ packages: peerDependencies: vue: ^3.2.0 - elliptic@6.5.4: - resolution: {integrity: sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==} + elliptic@6.5.6: + resolution: {integrity: sha512-mpzdtpeCLuS3BmE3pO3Cpp5bbjlOPY2Q0PgoF+Od1XZrHLYI28Xe3ossCmYCQt11FQKEYd9+PF8jymTvtWJSHQ==} error-ex@1.3.2: resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} @@ -714,6 +718,14 @@ packages: resolution: {integrity: sha512-WEm2oBhfoI2sImeM4OF2zE2V3BYdSF+KnSi9Sidz51fQHd7+JuF8Xgcj9/0o+OWeIeIS/MiuNnlruQrJf16GQA==} engines: {node: '>= 0.4'} + es-define-property@1.0.0: + resolution: {integrity: sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==} + engines: {node: '>= 0.4'} + + es-errors@1.3.0: + resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==} + engines: {node: '>= 0.4'} + es-module-lexer@0.10.5: resolution: {integrity: sha512-+7IwY/kiGAacQfY+YBhKMvEmyAJnw5grTUgjG85Pe7vcUI/6b7pZjZG8nQ7+48YhzEAEqrEgD2dCz/JIK+AYvw==} @@ -973,6 +985,9 @@ packages: function-bind@1.1.1: resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} + function-bind@1.1.2: + resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + function.prototype.name@1.1.5: resolution: {integrity: sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==} engines: {node: '>= 0.4'} @@ -983,6 +998,10 @@ packages: get-intrinsic@1.1.2: resolution: {integrity: sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==} + get-intrinsic@1.2.4: + resolution: {integrity: sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==} + engines: {node: '>= 0.4'} + get-symbol-description@1.0.0: resolution: {integrity: sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==} engines: {node: '>= 0.4'} @@ -1002,14 +1021,17 @@ packages: resolution: {integrity: sha512-dkQ957uSRWHw7CFXLUtUHQI3g3aWApYhfNR2O6jn/907riyTYKVBmxYVROkBcY614FSSeSJh7Xm7SrUWCxvJMQ==} engines: {node: '>=8'} - globalthis@1.0.3: - resolution: {integrity: sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==} + globalthis@1.0.4: + resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} engines: {node: '>= 0.4'} globby@11.1.0: resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} engines: {node: '>=10'} + gopd@1.0.1: + resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} + graceful-fs@4.2.10: resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} @@ -1033,6 +1055,10 @@ packages: has-property-descriptors@1.0.0: resolution: {integrity: sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==} + has-proto@1.0.3: + resolution: {integrity: sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==} + engines: {node: '>= 0.4'} + has-symbols@1.0.3: resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==} engines: {node: '>= 0.4'} @@ -1052,6 +1078,10 @@ packages: hash.js@1.1.7: resolution: {integrity: sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==} + hasown@2.0.2: + resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} + engines: {node: '>= 0.4'} + he@1.2.0: resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} hasBin: true @@ -1202,17 +1232,17 @@ packages: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} - libsodium-sumo@0.7.11: - resolution: {integrity: sha512-bY+7ph7xpk51Ez2GbE10lXAQ5sJma6NghcIDaSPbM/G9elfrjLa0COHl/7P6Wb/JizQzl5UQontOOP1z0VwbLA==} + libsodium-sumo@0.7.14: + resolution: {integrity: sha512-2nDge6qlAjcwyslAhWfVumlkeSNK5+WCfKa2/VEq9prvlT5vP2FR0m0o5hmKaYqfsZ4TQVj5czQsimZvXDB1CQ==} - libsodium-wrappers-sumo@0.7.11: - resolution: {integrity: sha512-DGypHOmJbB1nZn89KIfGOAkDgfv5N6SBGC3Qvmy/On0P0WD1JQvNRS/e3UL3aFF+xC0m+MYz5M+MnRnK2HMrKQ==} + libsodium-wrappers-sumo@0.7.14: + resolution: {integrity: sha512-0lm7ZwN5a95J2yUi8R1rgQeeaVDIWnvNzgVmXmZswis4mC+bQtbDrB+QpJlL4qklaKx3hVpJjoc6ubzJFiv64Q==} - libsodium-wrappers@0.7.11: - resolution: {integrity: sha512-SrcLtXj7BM19vUKtQuyQKiQCRJPgbpauzl3s0rSwD+60wtHqSUuqcoawlMDheCJga85nKOQwxNYQxf/CKAvs6Q==} + libsodium-wrappers@0.7.14: + resolution: {integrity: sha512-300TtsePizhJZ7HjLmWr6hLHAgJUxIGhapSw+EwfCtDuWaEmEdGXSQv6j6qFw0bs9l4vS2NH9BtOHfXAq6h5kQ==} - libsodium@0.7.11: - resolution: {integrity: sha512-WPfJ7sS53I2s4iM58QxY3Inb83/6mjlYgcmZs7DJsvDlnmVUwNinBCi5vBT43P6bHRy01O4zsMU2CoVR6xJ40A==} + libsodium@0.7.14: + resolution: {integrity: sha512-/pOd7eO6oZrfORquRTC4284OUJFcMi8F3Vnc9xtRBT0teLfOUxWIItaBFF3odYjZ7nlJNwnLdUVEUFHxVyX/Sw==} lie@3.3.0: resolution: {integrity: sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==} @@ -1437,12 +1467,12 @@ packages: process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} - protobufjs@6.11.3: - resolution: {integrity: sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==} + protobufjs@6.11.4: + resolution: {integrity: sha512-5kQWPaJHi1WoCpjTGszzQ32PG2F4+wRY6BmAT4Vfw56Q2FZ4YZzK20xUYQH4YkfehY1e6QSICrJquM6xXZNcrw==} hasBin: true - protobufjs@7.2.4: - resolution: {integrity: sha512-AT+RJgD2sH8phPmCf7OUZR8xGdcJRga4+1cOaXJ64hvcSkVhNcRHOwIxUatPH15+nj59WAGTDv3LSGZPEQbJaQ==} + protobufjs@7.3.2: + resolution: {integrity: sha512-RXyHaACeqXeqAKGLDl68rQKbmObRsTIn4TYVUUug1KfS47YWCo5MacGITEryugIgZqORCvJWEk4l449POg5Txg==} engines: {node: '>=12.0.0'} punycode@2.1.1: @@ -1601,9 +1631,6 @@ packages: string_decoder@1.1.1: resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} - string_decoder@1.3.0: - resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} - strip-ansi@6.0.1: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} @@ -1785,8 +1812,8 @@ packages: wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} - ws@7.5.9: - resolution: {integrity: sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==} + ws@7.5.10: + resolution: {integrity: sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==} engines: {node: '>=8.3.0'} peerDependencies: bufferutil: ^4.0.1 @@ -1831,8 +1858,8 @@ snapshots: '@confio/ics23@0.6.8': dependencies: - '@noble/hashes': 1.3.1 - protobufjs: 6.11.3 + '@noble/hashes': 1.4.0 + protobufjs: 6.11.4 '@cosmjs/amino@0.27.1': dependencies: @@ -1841,12 +1868,12 @@ snapshots: '@cosmjs/math': 0.27.1 '@cosmjs/utils': 0.27.1 - '@cosmjs/amino@0.31.1': + '@cosmjs/amino@0.31.3': dependencies: - '@cosmjs/crypto': 0.31.1 + '@cosmjs/crypto': 0.31.3 '@cosmjs/encoding': 0.31.3 - '@cosmjs/math': 0.31.1 - '@cosmjs/utils': 0.31.1 + '@cosmjs/math': 0.31.3 + '@cosmjs/utils': 0.31.3 '@cosmjs/crypto@0.27.1': dependencies: @@ -1855,21 +1882,21 @@ snapshots: '@cosmjs/utils': 0.27.1 bip39: 3.1.0 bn.js: 5.2.1 - elliptic: 6.5.4 + elliptic: 6.5.6 js-sha3: 0.8.0 - libsodium-wrappers: 0.7.11 + libsodium-wrappers: 0.7.14 ripemd160: 2.0.2 sha.js: 2.4.11 - '@cosmjs/crypto@0.31.1': + '@cosmjs/crypto@0.31.3': dependencies: '@cosmjs/encoding': 0.31.3 - '@cosmjs/math': 0.31.1 - '@cosmjs/utils': 0.31.1 - '@noble/hashes': 1.3.1 + '@cosmjs/math': 0.31.3 + '@cosmjs/utils': 0.31.3 + '@noble/hashes': 1.4.0 bn.js: 5.2.1 - elliptic: 6.5.4 - libsodium-wrappers-sumo: 0.7.11 + elliptic: 6.5.6 + libsodium-wrappers-sumo: 0.7.14 '@cosmjs/encoding@0.27.1': dependencies: @@ -1883,9 +1910,9 @@ snapshots: bech32: 1.1.4 readonly-date: 1.0.0 - '@cosmjs/json-rpc@0.31.1': + '@cosmjs/json-rpc@0.31.3': dependencies: - '@cosmjs/stream': 0.31.1 + '@cosmjs/stream': 0.31.3 xstream: 11.14.0 '@cosmjs/launchpad@0.27.1': @@ -1904,25 +1931,25 @@ snapshots: dependencies: bn.js: 5.2.1 - '@cosmjs/math@0.31.1': + '@cosmjs/math@0.31.3': dependencies: bn.js: 5.2.1 '@cosmjs/proto-signing@0.31.1': dependencies: - '@cosmjs/amino': 0.31.1 - '@cosmjs/crypto': 0.31.1 + '@cosmjs/amino': 0.31.3 + '@cosmjs/crypto': 0.31.3 '@cosmjs/encoding': 0.31.3 - '@cosmjs/math': 0.31.1 - '@cosmjs/utils': 0.31.1 + '@cosmjs/math': 0.31.3 + '@cosmjs/utils': 0.31.3 cosmjs-types: 0.8.0 long: 4.0.0 - '@cosmjs/socket@0.31.1': + '@cosmjs/socket@0.31.3': dependencies: - '@cosmjs/stream': 0.31.1 - isomorphic-ws: 4.0.1(ws@7.5.9) - ws: 7.5.9 + '@cosmjs/stream': 0.31.3 + isomorphic-ws: 4.0.1(ws@7.5.10) + ws: 7.5.10 xstream: 11.14.0 transitivePeerDependencies: - bufferutil @@ -1931,35 +1958,35 @@ snapshots: '@cosmjs/stargate@0.31.1': dependencies: '@confio/ics23': 0.6.8 - '@cosmjs/amino': 0.31.1 + '@cosmjs/amino': 0.31.3 '@cosmjs/encoding': 0.31.3 - '@cosmjs/math': 0.31.1 + '@cosmjs/math': 0.31.3 '@cosmjs/proto-signing': 0.31.1 - '@cosmjs/stream': 0.31.1 - '@cosmjs/tendermint-rpc': 0.31.1 - '@cosmjs/utils': 0.31.1 + '@cosmjs/stream': 0.31.3 + '@cosmjs/tendermint-rpc': 0.31.3 + '@cosmjs/utils': 0.31.3 cosmjs-types: 0.8.0 long: 4.0.0 - protobufjs: 6.11.3 + protobufjs: 6.11.4 xstream: 11.14.0 transitivePeerDependencies: - bufferutil - debug - utf-8-validate - '@cosmjs/stream@0.31.1': + '@cosmjs/stream@0.31.3': dependencies: xstream: 11.14.0 - '@cosmjs/tendermint-rpc@0.31.1': + '@cosmjs/tendermint-rpc@0.31.3': dependencies: - '@cosmjs/crypto': 0.31.1 + '@cosmjs/crypto': 0.31.3 '@cosmjs/encoding': 0.31.3 - '@cosmjs/json-rpc': 0.31.1 - '@cosmjs/math': 0.31.1 - '@cosmjs/socket': 0.31.1 - '@cosmjs/stream': 0.31.1 - '@cosmjs/utils': 0.31.1 + '@cosmjs/json-rpc': 0.31.3 + '@cosmjs/math': 0.31.3 + '@cosmjs/socket': 0.31.3 + '@cosmjs/stream': 0.31.3 + '@cosmjs/utils': 0.31.3 axios: 0.21.4 readonly-date: 1.0.0 xstream: 11.14.0 @@ -1970,7 +1997,7 @@ snapshots: '@cosmjs/utils@0.27.1': {} - '@cosmjs/utils@0.31.1': {} + '@cosmjs/utils@0.31.3': {} '@ctrl/tinycolor@3.4.1': {} @@ -2025,7 +2052,7 @@ snapshots: '@humanwhocodes/object-schema@1.2.1': {} - '@iconlake/client@0.6.0(@cosmjs/launchpad@0.27.1)(@cosmjs/proto-signing@0.31.1)(@cosmjs/stargate@0.31.1)': + '@iconlake/client@1.0.0(@cosmjs/launchpad@0.27.1)(@cosmjs/proto-signing@0.31.1)(@cosmjs/stargate@0.31.1)': dependencies: '@cosmjs/launchpad': 0.27.1 '@cosmjs/proto-signing': 0.31.1 @@ -2034,7 +2061,7 @@ snapshots: buffer: 6.0.3 events: 3.3.0 long: 5.2.3 - protobufjs: 7.2.4 + protobufjs: 7.3.2 transitivePeerDependencies: - debug @@ -2067,7 +2094,7 @@ snapshots: dependencies: long: 4.0.0 - '@noble/hashes@1.3.1': {} + '@noble/hashes@1.4.0': {} '@nodelib/fs.scandir@2.1.5': dependencies: @@ -2417,7 +2444,7 @@ snapshots: bip39@3.1.0: dependencies: - '@noble/hashes': 1.3.1 + '@noble/hashes': 1.4.0 bn.js@4.12.0: {} @@ -2498,7 +2525,7 @@ snapshots: cosmjs-types@0.8.0: dependencies: long: 4.0.0 - protobufjs: 6.11.3 + protobufjs: 6.11.4 cross-spawn@6.0.5: dependencies: @@ -2530,13 +2557,20 @@ snapshots: deep-is@0.1.4: {} + define-data-property@1.1.4: + dependencies: + es-define-property: 1.0.0 + es-errors: 1.3.0 + gopd: 1.0.1 + define-properties@1.1.4: dependencies: has-property-descriptors: 1.0.0 object-keys: 1.1.1 - define-properties@1.2.0: + define-properties@1.2.1: dependencies: + define-data-property: 1.1.4 has-property-descriptors: 1.0.0 object-keys: 1.1.1 @@ -2573,7 +2607,7 @@ snapshots: transitivePeerDependencies: - '@vue/composition-api' - elliptic@6.5.4: + elliptic@6.5.6: dependencies: bn.js: 4.12.0 brorand: 1.1.0 @@ -2613,6 +2647,12 @@ snapshots: string.prototype.trimstart: 1.0.5 unbox-primitive: 1.0.2 + es-define-property@1.0.0: + dependencies: + get-intrinsic: 1.2.4 + + es-errors@1.3.0: {} + es-module-lexer@0.10.5: {} es-to-primitive@1.2.1: @@ -2860,6 +2900,8 @@ snapshots: function-bind@1.1.1: {} + function-bind@1.1.2: {} + function.prototype.name@1.1.5: dependencies: call-bind: 1.0.2 @@ -2875,6 +2917,14 @@ snapshots: has: 1.0.3 has-symbols: 1.0.3 + get-intrinsic@1.2.4: + dependencies: + es-errors: 1.3.0 + function-bind: 1.1.2 + has-proto: 1.0.3 + has-symbols: 1.0.3 + hasown: 2.0.2 + get-symbol-description@1.0.0: dependencies: call-bind: 1.0.2 @@ -2901,9 +2951,10 @@ snapshots: dependencies: type-fest: 0.20.2 - globalthis@1.0.3: + globalthis@1.0.4: dependencies: - define-properties: 1.2.0 + define-properties: 1.2.1 + gopd: 1.0.1 globby@11.1.0: dependencies: @@ -2914,6 +2965,10 @@ snapshots: merge2: 1.4.1 slash: 3.0.0 + gopd@1.0.1: + dependencies: + get-intrinsic: 1.2.4 + graceful-fs@4.2.10: {} grapheme-splitter@1.0.4: {} @@ -2930,6 +2985,8 @@ snapshots: dependencies: get-intrinsic: 1.1.2 + has-proto@1.0.3: {} + has-symbols@1.0.3: {} has-tostringtag@1.0.0: @@ -2951,6 +3008,10 @@ snapshots: inherits: 2.0.4 minimalistic-assert: 1.0.1 + hasown@2.0.2: + dependencies: + function-bind: 1.1.2 + he@1.2.0: {} hmac-drbg@1.0.1: @@ -3057,9 +3118,9 @@ snapshots: isexe@2.0.0: {} - isomorphic-ws@4.0.1(ws@7.5.9): + isomorphic-ws@4.0.1(ws@7.5.10): dependencies: - ws: 7.5.9 + ws: 7.5.10 js-cookie@3.0.5: {} @@ -3087,17 +3148,17 @@ snapshots: prelude-ls: 1.2.1 type-check: 0.4.0 - libsodium-sumo@0.7.11: {} + libsodium-sumo@0.7.14: {} - libsodium-wrappers-sumo@0.7.11: + libsodium-wrappers-sumo@0.7.14: dependencies: - libsodium-sumo: 0.7.11 + libsodium-sumo: 0.7.14 - libsodium-wrappers@0.7.11: + libsodium-wrappers@0.7.14: dependencies: - libsodium: 0.7.11 + libsodium: 0.7.14 - libsodium@0.7.11: {} + libsodium@0.7.14: {} lie@3.3.0: dependencies: @@ -3300,7 +3361,7 @@ snapshots: process-nextick-args@2.0.1: {} - protobufjs@6.11.3: + protobufjs@6.11.4: dependencies: '@protobufjs/aspromise': 1.1.2 '@protobufjs/base64': 1.1.2 @@ -3316,7 +3377,7 @@ snapshots: '@types/node': 18.16.19 long: 4.0.0 - protobufjs@7.2.4: + protobufjs@7.3.2: dependencies: '@protobufjs/aspromise': 1.1.2 '@protobufjs/base64': 1.1.2 @@ -3354,7 +3415,7 @@ snapshots: readable-stream@3.6.2: dependencies: inherits: 2.0.4 - string_decoder: 1.3.0 + string_decoder: 1.1.1 util-deprecate: 1.0.2 readdirp@3.6.0: @@ -3425,7 +3486,7 @@ snapshots: sha.js@2.4.11: dependencies: inherits: 2.0.4 - safe-buffer: 5.2.1 + safe-buffer: 5.1.2 shebang-command@1.2.0: dependencies: @@ -3491,10 +3552,6 @@ snapshots: dependencies: safe-buffer: 5.1.2 - string_decoder@1.3.0: - dependencies: - safe-buffer: 5.2.1 - strip-ansi@6.0.1: dependencies: ansi-regex: 5.0.1 @@ -3662,13 +3719,13 @@ snapshots: wrappy@1.0.2: {} - ws@7.5.9: {} + ws@7.5.10: {} xml-name-validator@4.0.0: {} xstream@11.14.0: dependencies: - globalthis: 1.0.3 + globalthis: 1.0.4 symbol-observable: 2.0.3 yallist@4.0.0: {} diff --git a/www/src/apis/blockchain.ts b/www/src/apis/blockchain.ts index 5a84cdd..e677d12 100644 --- a/www/src/apis/blockchain.ts +++ b/www/src/apis/blockchain.ts @@ -1,11 +1,10 @@ import { CHAIN_ID, DROP_DENOM_MINI, IS_PRODUCTION } from '@/utils/const' -import request, { handleResponse } from '@/utils/request' +import request from '@/utils/request' import { Client } from '@iconlake/client' -import type { DropQueryGetInfoResponse } from '@iconlake/client/types/iconlake.drop/rest' import type { MsgMint as MsgMintIcon, MsgBurn as MsgBurnIcon, MsgUpdateClass } from '@iconlake/client/types/iconlake.icon/module' -import type { IconQueryHashResponse, IconlakeiconQueryClassResponse, IconlakeiconQueryNFTsResponse } from '@iconlake/client/types/iconlake.icon/rest' import { SHA256, lib } from 'crypto-js' import i18n from '@/i18n' +import { toast } from '@/utils' const baseURL = '/api/blockchain/' @@ -36,9 +35,12 @@ export const client = new Client(env) let isKeplrDetected = false export async function detectKeplr() { - if (isKeplrDetected) return + if (isKeplrDetected) { + return window.keplr + } if (!window.keplr) { - alert('Please install keplr extension'); + toast('Please install keplr extension'); + throw new Error('keplr extension not found') } else { const chainId = CHAIN_ID; try { @@ -53,27 +55,42 @@ export async function detectKeplr() { }) await window.keplr.enable(chainId) } - const offlineSigner = window.keplr.getOfflineSignerOnlyAmino(chainId); + const offlineSigner = window.keplr.getOfflineSigner(chainId); client.useSigner(offlineSigner) isKeplrDetected = true } + return window.keplr } export async function getBalance(address: string, denom: string) { const res = await fetch(`${apiURL}/cosmos/bank/v1beta1/balances/${address}?denom=${denom}`).then<{ - balance: { + balances: { amount: string; denom: string; - } - }>(res => res.json()) - return res.balance + }[] + }>(res => res.json()).catch((e) => { + console.error(e) + return { balances: [] } + }) + return res.balances.find(balance => balance.denom === denom) } -export async function getAccount() { - await detectKeplr() - if (!window.keplr) return - const offlineSigner = window.keplr.getOfflineSigner(CHAIN_ID) - const accounts = await offlineSigner.getAccounts() +export async function getAccount(address?: string) { + const keplr = await detectKeplr() + const offlineSigner = keplr.getOfflineSigner(CHAIN_ID) + const accounts = await offlineSigner.getAccounts().catch((e) => { + console.error(e) + toast.error(t('cannotGetKeplrAccount')) + return [] + }) + if (address) { + const account = accounts.find(account => account.address === address) + if (!account) { + toast.error(t('activeKeplrAccountAs', { addr: address })) + } else { + return account + } + } return accounts[0] } @@ -89,16 +106,18 @@ export async function getChainAccount(address: string) { account_number: string; sequence: string; } - }>(res => res.json()) + }>(res => res.json()).catch((e) => { + console.error(e) + return { account: undefined } + }) return res.account } export async function mintDrop(address: string, amount: string) { await detectKeplr() - if (!isKeplrDetected) return - const account = await getAccount() - if (!account || account.address !== address) { - return Promise.reject(new Error(t('activeKeplrAccountAs', { addr: address }))) + const account = await getAccount(address) + if (!account) { + return undefined } const res = await client.IconlakeDrop.tx.sendMsgMint({ value: { @@ -109,16 +128,25 @@ export async function mintDrop(address: string, amount: string) { } }, fee + }).catch((err) => { + console.error(err) + toast.error(err.message ?? t('fail')) + return undefined }) return res } export async function signMsg(msg: string) { - await detectKeplr() - if (!window.keplr) return + const keplr = await detectKeplr() const account = await getAccount() - if (!account) return - const res = await window.keplr.signArbitrary(CHAIN_ID, account.address, msg) + if (!account) { + return undefined + } + const res = await keplr.signArbitrary(CHAIN_ID, account.address, msg).catch((err) => { + console.error(err) + toast.error(err.message ?? t('fail')) + return undefined + }) return res } @@ -126,50 +154,61 @@ export async function getHash(uri: string) { const res = await client.IconlakeIcon.query.queryHash({ hash_type: 'p', uri + }).catch((err) => { + console.error(err) + return undefined }) - return await new Promise((resolve: (v: IconQueryHashResponse) => void, reject) => { - handleResponse(res as any, resolve, reject); - }) + return res?.data } export async function mintIcon(value: MsgMintIcon) { await detectKeplr() - if (!isKeplrDetected) return - const account = await getAccount() - if (!account || account.address !== value.creator) { - return Promise.reject(new Error(t('activeKeplrAccountAs', { addr: value.creator }))) + const account = await getAccount(value.creator) + if (!account) { + return undefined } const res = await client.IconlakeIcon.tx.sendMsgMint({ value, fee + }).catch((err) => { + console.error(err) + toast.error(err.message ?? t('fail')) + return undefined }) return res } export async function burnIcon(value: MsgBurnIcon) { await detectKeplr() - if (!isKeplrDetected) return - const account = await getAccount() - if (!account || account.address !== value.creator) { - return Promise.reject(new Error(t('activeKeplrAccountAs', { addr: value.creator }))) + const account = await getAccount(value.creator) + if (!account) { + return undefined } const res = await client.IconlakeIcon.tx.sendMsgBurn({ value, fee + }).catch((err) => { + console.error(err) + toast.error(err.message ?? t('fail')) + return undefined }) return res } export async function getTx(txHash: string) { - const res = await fetch(`${apiURL}/cosmos/tx/v1beta1/txs/${txHash}`).then(res => res.json()) + const res = await fetch(`${apiURL}/cosmos/tx/v1beta1/txs/${txHash}`).then(res => res.json()).catch((e) => { + console.error(e) + return { tx: undefined } + }) return res.tx } export async function getDropInfo(address: string) { - const res = await client.IconlakeDrop.query.queryInfo(address) - return await new Promise((resolve: (v: DropQueryGetInfoResponse) => void, reject) => { - handleResponse(res as any, resolve, reject); + const res = await client.IconlakeDrop.query.queryInfo(address).catch((e) => { + console.error(e) + return undefined }) + return res?.data.info } export async function initDrop(creator: string, address: string, isBackendService: boolean) { @@ -179,16 +218,19 @@ export async function initDrop(creator: string, address: string, isBackendServic }) } await detectKeplr() - if (!isKeplrDetected) return - const account = await getAccount() - if (!account || account.address !== creator) { - return Promise.reject(new Error(t('activeKeplrAccountAs', { addr: creator }))) + const account = await getAccount(creator) + if (!account) { + return undefined } return await client.IconlakeDrop.tx.sendMsgInit({ value: { creator, address, } + }).catch((err) => { + console.error(err) + toast.error(err.message ?? t('fail')) + return undefined }) } @@ -197,28 +239,33 @@ export async function getNFTs(q: { }) { const res = await client.IconlakeIcon.query.queryNFTs({ owner: q.owner + }).catch((e) => { + console.error(e) + return undefined }) - return await new Promise((resolve: (v: IconlakeiconQueryNFTsResponse) => void, reject) => { - handleResponse(res as any, resolve, reject); - }) + return res?.data } export async function getNftClass(id: string) { - const res = await client.IconlakeIcon.query.queryClass({ id }) - return await new Promise((resolve: (v: IconlakeiconQueryClassResponse) => void, reject) => { - handleResponse(res as any, resolve, reject); + const res = await client.IconlakeIcon.query.queryClass({ id }).catch((e) => { + console.error(e) + return undefined }) + return res?.data } export async function updateClass(value: MsgUpdateClass) { await detectKeplr() - if (!isKeplrDetected) return - const account = await getAccount() - if (!account || account.address !== value.creator) { - return Promise.reject(new Error(t('activeKeplrAccountAs', { addr: value.creator }))) + const account = await getAccount(value.creator) + if (!account) { + return undefined } const res = await client.IconlakeIcon.tx.sendMsgUpdateClass({ value + }).catch((err) => { + console.error(err) + toast.error(err.message ?? t('updateFailed')) + return undefined }) return res } @@ -234,18 +281,23 @@ export async function verifyUriHash(uri: string | undefined, hash: string | unde checked: false } } - const blob = await fetch(uri, { + const res = await fetch(uri, { headers: { "Cache-Control": "no-cache" } - }).then(e => e.blob()) - const file = await blob.arrayBuffer() + }).then(e => e.blob()).catch(() => undefined) + if (!res) { + return { + checked: false + } + } + const file = await res.arrayBuffer() const words = lib.WordArray.create() ;(words as any).init(file) const fileHash = SHA256(words) return { checked: hash === fileHash.toString(), - url: URL.createObjectURL(blob) + url: URL.createObjectURL(res) } } diff --git a/www/src/i18n/messages/en-us.json b/www/src/i18n/messages/en-us.json index 36f8eec..7859e91 100644 --- a/www/src/i18n/messages/en-us.json +++ b/www/src/i18n/messages/en-us.json @@ -176,5 +176,7 @@ "clearCacheDone&Reload": "Cache has been cleared, the page will be reloaded soon", "loggingOut": "Cleaning up data and logging out, please wait a moment", "userAuthError": "Your login information is incorrect, please log in again", - "permissionDenied": "You don't have permission to perform this operation" + "permissionDenied": "You don't have permission to perform this operation", + "cannotGetKeplrAccount": "Failed to get Keplr account, please authorize and try again", + "txNotFound": "Transaction not found" } diff --git a/www/src/i18n/messages/zh-cn.json b/www/src/i18n/messages/zh-cn.json index 08791b1..287edc9 100644 --- a/www/src/i18n/messages/zh-cn.json +++ b/www/src/i18n/messages/zh-cn.json @@ -176,5 +176,7 @@ "clearCacheDone&Reload": "清除缓存成功,页面即将刷新", "loggingOut": "正在清理数据并退出登录,请稍等片刻", "userAuthError": "你的登录信息有误,请重新登录!", - "permissionDenied": "你没有权限执行这个操作" + "permissionDenied": "你没有权限执行这个操作", + "cannotGetKeplrAccount": "无法通过Keplr获取iconLake账户,请授权后重试", + "txNotFound": "交易未找到" } diff --git a/www/src/views/icons/Protect.vue b/www/src/views/icons/Protect.vue index 0f0d489..be99205 100644 --- a/www/src/views/icons/Protect.vue +++ b/www/src/views/icons/Protect.vue @@ -1,6 +1,6 @@