From 810ca3844546a7a216dd6f3c8a76f802a2d3821e Mon Sep 17 00:00:00 2001 From: evilpeach Date: Wed, 27 Dec 2023 09:38:53 +0700 Subject: [PATCH 1/9] feat: add initia wallet --- CHANGELOG.md | 2 + package.json | 11 ++- src/config/chain/initia.ts | 3 +- yarn.lock | 181 ++++++++++++++++++++----------------- 4 files changed, 110 insertions(+), 87 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7e9e3caa..cf1fff6e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features +- [#681](https://github.com/alleslabs/celatone-frontend/pull/681) Add Initia wallet + ### Improvements - [#696](https://github.com/alleslabs/celatone-frontend/pull/696) api v1 - block details diff --git a/package.json b/package.json index d437d7696..91bd0c2b5 100644 --- a/package.json +++ b/package.json @@ -55,11 +55,12 @@ "@cosmjs/encoding": "0.31.3", "@cosmjs/proto-signing": "0.31.3", "@cosmjs/stargate": "0.31.3", - "@cosmos-kit/compass": "2.4.5", - "@cosmos-kit/core": "2.7.4", - "@cosmos-kit/keplr": "2.4.6", - "@cosmos-kit/react": "2.9.5", - "@cosmos-kit/station": "2.4.4", + "@cosmos-kit/compass": "2.5.1", + "@cosmos-kit/core": "2.7.11", + "@cosmos-kit/initia": "^0.1.0", + "@cosmos-kit/keplr": "2.5.1", + "@cosmos-kit/react": "2.9.15", + "@cosmos-kit/station": "2.4.11", "@emotion/react": "^11", "@emotion/styled": "^11", "@graphql-codegen/cli": "^2.13.12", diff --git a/src/config/chain/initia.ts b/src/config/chain/initia.ts index 8a3c29113..985438627 100644 --- a/src/config/chain/initia.ts +++ b/src/config/chain/initia.ts @@ -1,3 +1,4 @@ +import { wallets as initiaWallets } from "@cosmos-kit/initia"; import { wallets as keplrWallets } from "@cosmos-kit/keplr"; import type { ChainConfigs } from "./types"; @@ -13,7 +14,7 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = { lcd: "https://lcd.mahalo-1.initia.xyz", rpc: "https://rpc.mahalo-1.initia.xyz:443", indexer: "https://mahalo-1-graphql.alleslabs.dev/v1/graphql", - wallets: [...keplrWallets], + wallets: [...initiaWallets, ...keplrWallets], features: { faucet: { enabled: true, diff --git a/yarn.lock b/yarn.lock index 736eac7e0..784bf29b7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -658,10 +658,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@chain-registry/keplr@1.25.0": - version "1.25.0" - resolved "https://registry.yarnpkg.com/@chain-registry/keplr/-/keplr-1.25.0.tgz#581a10760951c1d1185c6874199df08283a21d46" - integrity sha512-mEr5HypYEaQnYcuGp3PBTqo67WV0MQyBP2dOtl+ab2fkyB5PYa01D5B2Yu5V6V7eXLmKDvvvfiRO23NWQzFHxg== +"@chain-registry/keplr@1.28.0": + version "1.28.0" + resolved "https://registry.yarnpkg.com/@chain-registry/keplr/-/keplr-1.28.0.tgz#c53d52ff0487eb6798722eb1cf5bd4dc82a141be" + integrity sha512-MRAEgUpafyGLRDQc4SPB+R/If4CL2SREqdbxZMKHX9aeqzKXhJlEM5IPjJTZCWTbUP/eGXC9JNjxPNUYd92PqQ== dependencies: "@babel/runtime" "^7.21.0" "@chain-registry/types" "^0.17.0" @@ -1836,102 +1836,118 @@ resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.31.3.tgz#f97bbfda35ad69e80cd5c7fe0a270cbda16db1ed" integrity sha512-VBhAgzrrYdIe0O5IbKRqwszbQa7ZyQLx9nEQuHQ3HUplQW7P44COG/ye2n6AzCudtqxmwdX7nyX8ta1J07GoqA== -"@cosmos-kit/compass-extension@^2.4.5": - version "2.4.5" - resolved "https://registry.yarnpkg.com/@cosmos-kit/compass-extension/-/compass-extension-2.4.5.tgz#27f812e85f3e952efed5ae6ae0bd1714b0bbba7e" - integrity sha512-Krz8qfz/Tp/KEEhMIMvCQrEMePo2rW5vT7BWPwIPRcRcZ0FdpbWS2tNk+gW1P8mMk9wnO1te0dYg09pCXswc6Q== +"@cosmos-kit/compass-extension@^2.5.1": + version "2.5.1" + resolved "https://registry.yarnpkg.com/@cosmos-kit/compass-extension/-/compass-extension-2.5.1.tgz#5ac69f9862519bf69ef5de63ff1c3b0be6197caa" + integrity sha512-iSX3Jzugve8MxzYhy0JM/MCSPtpwATrFdsR+cZ92+UILIh/K3eznl+akmI6nBMfBBZWdSo8ijsD9jkSkyY+nAQ== dependencies: - "@chain-registry/keplr" "1.25.0" - "@cosmos-kit/core" "^2.7.4" + "@chain-registry/keplr" "1.28.0" + "@cosmos-kit/core" "^2.7.11" -"@cosmos-kit/compass@2.4.5": - version "2.4.5" - resolved "https://registry.yarnpkg.com/@cosmos-kit/compass/-/compass-2.4.5.tgz#faecb19b61630f558a51230c63721bcf8799104d" - integrity sha512-lOrDDBpkq21TkjytmRf0Q7462ZuX2Bcx+IJ6d8PFCMYFzvtNlTpXhFCejcqzEy0hAXdKIlG6F59rSaGnVjfjIA== +"@cosmos-kit/compass@2.5.1": + version "2.5.1" + resolved "https://registry.yarnpkg.com/@cosmos-kit/compass/-/compass-2.5.1.tgz#71e3872752ddd04cc7dae4c1e28704d356f30763" + integrity sha512-9F8iHz7oFkvwyn8exQgWpt/Ep11t5YxIfCl0XdTuvNv3LSXFJlK5U3K5DOrsV5FySIvtF0LQh0+x48qvNdLQvA== dependencies: - "@cosmos-kit/compass-extension" "^2.4.5" + "@cosmos-kit/compass-extension" "^2.5.1" -"@cosmos-kit/core@2.7.4", "@cosmos-kit/core@^2.7.4": - version "2.7.4" - resolved "https://registry.yarnpkg.com/@cosmos-kit/core/-/core-2.7.4.tgz#8d028c3b99ab4d11aed47bf5d1c22d0157bca694" - integrity sha512-/G2ucBgEooSzKYBzwNC7/NksDVuXGorEgP8dPTR7iAxfFLSg0j/lDPFH4tezVJSV/NZxbw4Suptk+KyUGDEzNw== +"@cosmos-kit/core@2.7.11", "@cosmos-kit/core@^2.7.11": + version "2.7.11" + resolved "https://registry.yarnpkg.com/@cosmos-kit/core/-/core-2.7.11.tgz#f213985ba7af37b5a1fa50181ed29d35e0f64430" + integrity sha512-WlUbrFMtLvtZ2O9h81wQ7nJMLkCCc0iqY6owgxAvUIvFIoCvhl7P49TIfeni7+jIuVLpcU8CYO8sdjMfPMUOoA== dependencies: "@chain-registry/types" "0.17.0" - "@walletconnect/types" "2.7.2" + "@walletconnect/types" "2.10.4" bowser "2.11.0" events "3.3.0" uuid "^9.0.1" -"@cosmos-kit/keplr-extension@^2.5.6": - version "2.5.6" - resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr-extension/-/keplr-extension-2.5.6.tgz#f918e9f1cd4d29ca89c8764cf6314bfb41d22329" - integrity sha512-RAnoYJVeufGb9wxknMimqhkntxZKofSeHW6ChjpzGLE2WScHTmWBdgcdxtGxdNe2Yua3wtjAzyiGSuUq64b1OA== +"@cosmos-kit/initia-extension@^0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@cosmos-kit/initia-extension/-/initia-extension-0.1.0.tgz#b89a860ebb23262533972800847ae31cb70c5700" + integrity sha512-4hXvSvS4xheCExL+XXNYdHV9aCFI5wD6Ab2/+vA+UPQQcachj50P0vxJM4SFy7GtDZXEm8XF3hGB+9Rw/NcgFw== + dependencies: + "@chain-registry/keplr" "1.28.0" + "@cosmos-kit/core" "^2.7.11" + "@initia/initia.proto" "^0.1.20" + "@initia/shared" "^0.6.0" + +"@cosmos-kit/initia@^0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@cosmos-kit/initia/-/initia-0.1.0.tgz#89df2da569dca4a7a2e187a5d1309839d238d25a" + integrity sha512-bK2ppQ/Jg/4PCU+w2CK3fzIytyQ7+GBbb7ts+4QsEEAS7HAz7oqTU0mwxORK/wmh+umBUJahN8iH+C+5BQ1Zlw== + dependencies: + "@cosmos-kit/initia-extension" "^0.1.0" + +"@cosmos-kit/keplr-extension@^2.6.1": + version "2.6.1" + resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr-extension/-/keplr-extension-2.6.1.tgz#2d149591e90d6d05ee20ca449047529c46f99984" + integrity sha512-lTxYCWyoO3Vy5DEoUEkICgi37CkQm2MFfftNY6llRLz0uq89hNcDZfF9a9g6KKNtwwxriNN+X1ppYDbOlG80Ow== dependencies: - "@chain-registry/keplr" "1.25.0" - "@cosmos-kit/core" "^2.7.4" + "@chain-registry/keplr" "1.28.0" + "@cosmos-kit/core" "^2.7.11" -"@cosmos-kit/keplr-mobile@^2.4.5": - version "2.4.5" - resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr-mobile/-/keplr-mobile-2.4.5.tgz#407b8c31afd1ec49cb4e600e84dbfe8224f59ab2" - integrity sha512-4cF0MfcJEGvWqL31YVMoahP4WlSSe5Nyj2NMGCzuMsOdRWCSpdB06c9RJ+erI0JyVDXjam7tTA9WTlyT+dgAKg== +"@cosmos-kit/keplr-mobile@^2.5.1": + version "2.5.1" + resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr-mobile/-/keplr-mobile-2.5.1.tgz#8d573e3ab445912c8e670299e0d08f51fa7412b1" + integrity sha512-1oELwcnYkMxuxwQPXetoI/E5QCot6BWnwccNA9G20u+TG7gjv2H1TjHeWyuSop2tNiYFnszMa0ws2R4FF0UtFA== dependencies: - "@chain-registry/keplr" "1.25.0" - "@cosmos-kit/core" "^2.7.4" - "@cosmos-kit/walletconnect" "^2.4.5" + "@chain-registry/keplr" "1.28.0" + "@cosmos-kit/core" "^2.7.11" + "@cosmos-kit/walletconnect" "^2.4.14" -"@cosmos-kit/keplr@2.4.6": - version "2.4.6" - resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr/-/keplr-2.4.6.tgz#be323aeb4ad9165b397dd57847b6bb1bf0dd2161" - integrity sha512-bUjgEePB0u2jbWJ7oZfr5J9O/00pRbyMeZQHN1TWh3KIcxBLMZcQdeglWMwep8V/ETond0Mr5hKR8S/ZsLgCuA== +"@cosmos-kit/keplr@2.5.1": + version "2.5.1" + resolved "https://registry.yarnpkg.com/@cosmos-kit/keplr/-/keplr-2.5.1.tgz#e188927070705c94036e4c8001137681b76dd210" + integrity sha512-DwAk+QWX/VOqADfBkgTD98zHOsgVVV0z7EgQUnyDBKTcLrGhZ4cs/02WK0EO4huG20bheUFnD8YTQmASHESsLQ== dependencies: - "@cosmos-kit/keplr-extension" "^2.5.6" - "@cosmos-kit/keplr-mobile" "^2.4.5" + "@cosmos-kit/keplr-extension" "^2.6.1" + "@cosmos-kit/keplr-mobile" "^2.5.1" -"@cosmos-kit/react-lite@^2.5.5": - version "2.5.5" - resolved "https://registry.yarnpkg.com/@cosmos-kit/react-lite/-/react-lite-2.5.5.tgz#905107aadcc87ae268ea7d8927ff74601b6df8f7" - integrity sha512-i1FTkMMLDOUkO+lPbUS3RRQoewgX79ux+gTctB/6wJqBhZkzoINCCn2XHYrKioXqhe2a1xn5n+EUWkBEPsZK8w== +"@cosmos-kit/react-lite@^2.5.13": + version "2.5.13" + resolved "https://registry.yarnpkg.com/@cosmos-kit/react-lite/-/react-lite-2.5.13.tgz#b053df94faad8a76f3421c1cd148e74b0c086854" + integrity sha512-CSnySfwcTBWYpmBaewKPz0hjvmIFeKnXi2GW6eaKR2LqUPuXVQCkx8biUpYKYsvQghlLmnL2+7+tmvZI5sTnmQ== dependencies: "@chain-registry/types" "0.17.0" - "@cosmos-kit/core" "^2.7.4" + "@cosmos-kit/core" "^2.7.11" -"@cosmos-kit/react@2.9.5": - version "2.9.5" - resolved "https://registry.yarnpkg.com/@cosmos-kit/react/-/react-2.9.5.tgz#937ee4f5b9f4071d5c5efba2f170eb8c03213b59" - integrity sha512-AYtDY5bC1OUMMyfNbwRzxIfx6aqpdRWMxrsZApQBLaVvzbQwwfZx0FUwWLN4BZ+CaSOm7F1RssbysF+6S405hg== +"@cosmos-kit/react@2.9.15": + version "2.9.15" + resolved "https://registry.yarnpkg.com/@cosmos-kit/react/-/react-2.9.15.tgz#a532c712ef79d7a8a990b04e4e94c5c1dcb074fd" + integrity sha512-EwH5T6/joNJUALFvGLQfMjjvAbxuAlSke5/tXB5yzY6trFhJXPIJ9mJqC/r6GxgNKIwxAlXfWnOStflC0wwjXg== dependencies: "@chain-registry/types" "0.17.0" - "@cosmos-kit/core" "^2.7.4" - "@cosmos-kit/react-lite" "^2.5.5" - "@interchain-ui/react" "^1.11.0" + "@cosmos-kit/core" "^2.7.11" + "@cosmos-kit/react-lite" "^2.5.13" "@react-icons/all-files" "^4.1.0" -"@cosmos-kit/station-extension@^2.5.4": - version "2.5.4" - resolved "https://registry.yarnpkg.com/@cosmos-kit/station-extension/-/station-extension-2.5.4.tgz#8fbb42cacf0c8664f2b2e4ae2a121417eb0e63b4" - integrity sha512-o5mbbHMqYnTI+4R/C07j4Ys2PUnIadymA4gjPfhXyR+Y5e8dlP95prPiX4L+0ZJ3Y381mvAsDzHTouQA6Myavg== +"@cosmos-kit/station-extension@^2.5.11": + version "2.5.11" + resolved "https://registry.yarnpkg.com/@cosmos-kit/station-extension/-/station-extension-2.5.11.tgz#95176e53155a00c60b010076570130aa60627a75" + integrity sha512-Ca0fDDZ8hy9d455fHOdAmisiDEkrdcJqPMSqlszfIqx/aYen663jpKZdOLDuvHcZhQrjep/y+roZ3Z5PA8tx/Q== dependencies: "@chain-registry/types" "0.17.0" - "@cosmos-kit/core" "^2.7.4" + "@cosmos-kit/core" "^2.7.11" "@terra-money/feather.js" "^1.0.8" "@terra-money/station-connector" "^1.0.5" "@terra-money/wallet-types" "^3.11.2" -"@cosmos-kit/station@2.4.4": - version "2.4.4" - resolved "https://registry.yarnpkg.com/@cosmos-kit/station/-/station-2.4.4.tgz#026aaf0defc81ff77c760640d828ea810b3f4615" - integrity sha512-53IbnLslmWbqgkgqb2FVXvP0XMV/HEbnQSfxu9goKdvcoOb3nsnst/roKQNeAtEqPcDOVfhNCUaDnCZ7sSJG6A== +"@cosmos-kit/station@2.4.11": + version "2.4.11" + resolved "https://registry.yarnpkg.com/@cosmos-kit/station/-/station-2.4.11.tgz#503655e3587622622e6abd5c1910f48d4fbb7781" + integrity sha512-CyXXNsSXjPHMSTk5dz0ozxZOUBYjtp69z1NGHmJDA0/gXqD36Kt67iZQpkY0xA724Vs/Y2Z6JC8LSk8PLttiAQ== dependencies: - "@cosmos-kit/station-extension" "^2.5.4" + "@cosmos-kit/station-extension" "^2.5.11" -"@cosmos-kit/walletconnect@^2.4.5": - version "2.4.5" - resolved "https://registry.yarnpkg.com/@cosmos-kit/walletconnect/-/walletconnect-2.4.5.tgz#b9119ba09f88a18e229ccdb5a8907d0fa2bbbc64" - integrity sha512-ZTE8xh1yKJjqpQDI1wux2Sda1lMxr0Zx/iT4ZDaVuFr1pSzlIoM8SKqAySCr43JNCwF/Y9Uq1HAwLs1vq8lS6w== +"@cosmos-kit/walletconnect@^2.4.14": + version "2.4.14" + resolved "https://registry.yarnpkg.com/@cosmos-kit/walletconnect/-/walletconnect-2.4.14.tgz#60146a5e055893d3411e94c741fafbeabfa31752" + integrity sha512-wIWfx0KiW+QNJDfMVNv6M5ZWR+/NMZrOMqJ4Nqy3y87h4ce/BPatuASRFvcYsFnJQ19hbgzzKWzAtYMit0ML8w== dependencies: - "@cosmos-kit/core" "^2.7.4" + "@cosmos-kit/core" "^2.7.11" "@walletconnect/sign-client" "^2.9.0" - "@walletconnect/types" "^2.9.0" + "@walletconnect/types" "2.10.4" "@walletconnect/utils" "^2.9.0" events "3.3.0" @@ -2999,7 +3015,22 @@ long "^5.2.0" protobufjs "^7.1.1" -"@interchain-ui/react@1.11.4", "@interchain-ui/react@^1.11.0": +"@initia/initia.proto@^0.1.20": + version "0.1.20" + resolved "https://registry.yarnpkg.com/@initia/initia.proto/-/initia.proto-0.1.20.tgz#5b91f75ead7b4c4ecdf893bfa338cb8c95a47189" + integrity sha512-J57d5o1ikF37D2T3TEsPU+pMe1c7U+qD8nASPUfa33Fv1V/AAJV1j2OnM/QbQChxlqDaOsEmxmvlo7+1TRU38w== + dependencies: + "@improbable-eng/grpc-web" "^0.15.0" + google-protobuf "^3.21.0" + long "^5.2.0" + protobufjs "^7.1.1" + +"@initia/shared@^0.6.0": + version "0.6.0" + resolved "https://registry.yarnpkg.com/@initia/shared/-/shared-0.6.0.tgz#e537c1ff24e84505b36cd2a3f55a54dc5a986a4d" + integrity sha512-qU4VDt6u14heaMA+YuUBFatLkMs9/F1kGs2ddhLxkFIBV/Nu1+s2Nz4EEf5+5UpLtEs3EwSLMzTCUuLNH2jrPQ== + +"@interchain-ui/react@1.11.4": version "1.11.4" resolved "https://registry.yarnpkg.com/@interchain-ui/react/-/react-1.11.4.tgz#62ec06ebed6e9f434f1f406962565e86c34b9b6c" integrity sha512-jUx02LyyUjSKANcpNJ9DPOkVlD2nERmQZsqEnUeJQ6wsG4rgO5yd0jHDUgqotvwxkRisYSy8jqDGe3r4pYsNBw== @@ -4641,7 +4672,7 @@ dependencies: tslib "1.14.1" -"@walletconnect/types@2.10.4", "@walletconnect/types@^2.9.0": +"@walletconnect/types@2.10.4": version "2.10.4" resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.10.4.tgz#23f6e4bd785671812dc6ea96848a6bd7ea78f038" integrity sha512-eQpOElyiwJp3tepuOS3TS9dXTl9jVVlrC3iVA8bytnbLagkAUxmiv/s7PyDFx+ndXwQVh8PFBkWg1oxGwgCSBA== @@ -4653,18 +4684,6 @@ "@walletconnect/logger" "^2.0.1" events "^3.3.0" -"@walletconnect/types@2.7.2": - version "2.7.2" - resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.7.2.tgz#508d1755110864dee294f955e09b7da3f8ee0064" - integrity sha512-1O2UefakZpT0ErRfEAXY7Ls3qdUrKDky/DsK088xR6klyfkQOx+aSVH0fJYLhmnqPTuvp3lrqNbsDc0s6/6nvg== - dependencies: - "@walletconnect/events" "^1.0.1" - "@walletconnect/heartbeat" "1.2.1" - "@walletconnect/jsonrpc-types" "^1.0.2" - "@walletconnect/keyvaluestorage" "^1.0.2" - "@walletconnect/logger" "^2.0.1" - events "^3.3.0" - "@walletconnect/utils@2.10.4", "@walletconnect/utils@^2.9.0": version "2.10.4" resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.10.4.tgz#5f17938e7ea481541ec2dbae0df5cd494c72523f" From 423640ba6a812f4bc61342665b797259343ebfa0 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Wed, 27 Dec 2023 10:54:47 +0700 Subject: [PATCH 2/9] feat: add other networks --- src/config/chain/initia.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/config/chain/initia.ts b/src/config/chain/initia.ts index 985438627..d8e01e2ad 100644 --- a/src/config/chain/initia.ts +++ b/src/config/chain/initia.ts @@ -64,7 +64,7 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = { lcd: "https://lcd.minimove-1.initia.xyz", rpc: "https://rpc.minimove-1.initia.xyz:443", indexer: "https://minimove-1-graphql.alleslabs.dev/v1/graphql", - wallets: [...keplrWallets], + wallets: [...initiaWallets, ...keplrWallets], features: { faucet: { enabled: false, @@ -113,7 +113,7 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = { lcd: "https://lcd.miniwasm-1.initia.xyz", rpc: "https://rpc.miniwasm-1.initia.xyz:443", indexer: "https://miniwasm-1-graphql.alleslabs.dev/v1/graphql", - wallets: [...keplrWallets], + wallets: [...initiaWallets, ...keplrWallets], features: { faucet: { enabled: false, @@ -161,7 +161,7 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = { lcd: "https://next-stone-rest.initia.tech", rpc: "https://next-stone-rpc.initia.tech:443", indexer: "https://stone-12-1-nft-graphql.alleslabs.dev/v1/graphql", - wallets: [...keplrWallets], + wallets: [...initiaWallets, ...keplrWallets], features: { faucet: { enabled: true, From 58a8e2341fa58d3ca89bbcb4e4e7c80928a3d371 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Wed, 27 Dec 2023 18:57:16 +0700 Subject: [PATCH 3/9] chore: fixed version --- package.json | 2 +- yarn.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 91bd0c2b5..19ed5c453 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@cosmjs/stargate": "0.31.3", "@cosmos-kit/compass": "2.5.1", "@cosmos-kit/core": "2.7.11", - "@cosmos-kit/initia": "^0.1.0", + "@cosmos-kit/initia": "0.1.0", "@cosmos-kit/keplr": "2.5.1", "@cosmos-kit/react": "2.9.15", "@cosmos-kit/station": "2.4.11", diff --git a/yarn.lock b/yarn.lock index 784bf29b7..9c2a0f1b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1872,7 +1872,7 @@ "@initia/initia.proto" "^0.1.20" "@initia/shared" "^0.6.0" -"@cosmos-kit/initia@^0.1.0": +"@cosmos-kit/initia@0.1.0": version "0.1.0" resolved "https://registry.yarnpkg.com/@cosmos-kit/initia/-/initia-0.1.0.tgz#89df2da569dca4a7a2e187a5d1309839d238d25a" integrity sha512-bK2ppQ/Jg/4PCU+w2CK3fzIytyQ7+GBbb7ts+4QsEEAS7HAz7oqTU0mwxORK/wmh+umBUJahN8iH+C+5BQ1Zlw== From 0cda582250d72a430c1aff7b8385e5cae170503a Mon Sep 17 00:00:00 2001 From: evilpeach Date: Wed, 27 Dec 2023 19:21:55 +0700 Subject: [PATCH 4/9] fix: change fee denom --- src/config/chain/initia.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/config/chain/initia.ts b/src/config/chain/initia.ts index d8e01e2ad..84635df2e 100644 --- a/src/config/chain/initia.ts +++ b/src/config/chain/initia.ts @@ -94,7 +94,8 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = { gas: { gasPrice: { tokenPerGas: 0.151, - denom: "umin", + denom: + "l2/4b66eb60bf9f503ea97fe4dc96d5c604c1dca14ee988e21510ac4b087bf72671", }, gasAdjustment: 1.5, maxGasLimit: 25_000_000, @@ -142,7 +143,8 @@ export const INITIA_CHAIN_CONFIGS: ChainConfigs = { gas: { gasPrice: { tokenPerGas: 0.151, - denom: "umin", + denom: + "l2/926dab95dc14918344374867b8576adee2c6cfca69b968fdb08c5280390cd1a7", }, gasAdjustment: 1.5, maxGasLimit: 25_000_000, From b8db9d7835fe4209016606f368f671b272973585 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Thu, 28 Dec 2023 08:13:01 +0700 Subject: [PATCH 5/9] fix: change base denom for l2 --- src/lib/chain-registry/initiatestnet.ts | 37 ++++++++++++++----------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/lib/chain-registry/initiatestnet.ts b/src/lib/chain-registry/initiatestnet.ts index cca8aaa83..5ba7139fe 100644 --- a/src/lib/chain-registry/initiatestnet.ts +++ b/src/lib/chain-registry/initiatestnet.ts @@ -1,3 +1,4 @@ +/* eslint-disable sonarjs/no-duplicate-string */ import type { AssetList, Chain } from "@chain-registry/types"; const CHAIN_SCHEMA = "../chain.schema.json"; @@ -66,7 +67,8 @@ export const initiatestnet: Chain[] = [ fees: { fee_tokens: [ { - denom: "umin", + denom: + "l2/4b66eb60bf9f503ea97fe4dc96d5c604c1dca14ee988e21510ac4b087bf72671", fixed_min_gas_price: 0, low_gas_price: 0.151, average_gas_price: 0.151, @@ -107,7 +109,8 @@ export const initiatestnet: Chain[] = [ fees: { fee_tokens: [ { - denom: "umin", + denom: + "l2/926dab95dc14918344374867b8576adee2c6cfca69b968fdb08c5280390cd1a7", fixed_min_gas_price: 0, low_gas_price: 0.151, average_gas_price: 0.151, @@ -213,21 +216,22 @@ export const initiatestnetAssets: AssetList[] = [ chain_name: "minitiamovedevnet1", assets: [ { - description: "The native staking token of Minitia.", + description: "The native staking token of Initia.", denom_units: [ { - denom: "umin", + denom: + "l2/4b66eb60bf9f503ea97fe4dc96d5c604c1dca14ee988e21510ac4b087bf72671", exponent: 0, }, { - denom: "min", + denom: "init", exponent: 6, }, ], - base: "umin", - name: "Min", - display: "min", - symbol: "MIN", + base: "l2/4b66eb60bf9f503ea97fe4dc96d5c604c1dca14ee988e21510ac4b087bf72671", + name: "Init", + display: "init", + symbol: "INIT", }, ], }, @@ -236,21 +240,22 @@ export const initiatestnetAssets: AssetList[] = [ chain_name: "minitiawasmdevnet1", assets: [ { - description: "The native staking token of Minitia.", + description: "The native staking token of Initia.", denom_units: [ { - denom: "umin", + denom: + "l2/926dab95dc14918344374867b8576adee2c6cfca69b968fdb08c5280390cd1a7", exponent: 0, }, { - denom: "min", + denom: "init", exponent: 6, }, ], - base: "umin", - name: "Min", - display: "min", - symbol: "MIN", + base: "l2/926dab95dc14918344374867b8576adee2c6cfca69b968fdb08c5280390cd1a7", + name: "Init", + display: "init", + symbol: "INIT", }, ], }, From 3ab11ec5a5e01e1c257fa726575869054de1e372 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Thu, 28 Dec 2023 09:10:49 +0700 Subject: [PATCH 6/9] feat: use estimatedFeeRender in sending modal --- src/lib/app-fns/tx/common/sending.tsx | 4 ++-- src/lib/services/assetService.ts | 3 ++- src/lib/utils/formatter/denom.ts | 11 +---------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/lib/app-fns/tx/common/sending.tsx b/src/lib/app-fns/tx/common/sending.tsx index be2052d89..3b716e896 100644 --- a/src/lib/app-fns/tx/common/sending.tsx +++ b/src/lib/app-fns/tx/common/sending.tsx @@ -1,9 +1,9 @@ import { Spinner } from "@chakra-ui/react"; import type { StdFee } from "@cosmjs/stargate"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import type { TxResultRendering } from "lib/types"; import { TxStreamPhase } from "lib/types"; -import { formatStdFee } from "lib/utils/formatter/denom"; export const sendingTx = (fee: StdFee) => { // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -14,7 +14,7 @@ export const sendingTx = (fee: StdFee) => { receipts: [ { title: "Estimated Tx Fee", - value: formatStdFee(fee), + html: , }, ], receiptInfo: { diff --git a/src/lib/services/assetService.ts b/src/lib/services/assetService.ts index 27393c871..9310c4bef 100644 --- a/src/lib/services/assetService.ts +++ b/src/lib/services/assetService.ts @@ -1,6 +1,7 @@ import { useQuery } from "@tanstack/react-query"; -import { CELATONE_QUERY_KEYS, useBaseApiRoute } from "lib/app-provider"; +import { CELATONE_QUERY_KEYS } from "lib/app-provider/env"; +import { useBaseApiRoute } from "lib/app-provider/hooks/useBaseApiRoute"; import { getAssetInfos } from "lib/services/asset"; import type { AssetInfo, Option } from "lib/types"; diff --git a/src/lib/utils/formatter/denom.ts b/src/lib/utils/formatter/denom.ts index fb7726dd5..821d53119 100644 --- a/src/lib/utils/formatter/denom.ts +++ b/src/lib/utils/formatter/denom.ts @@ -1,7 +1,5 @@ -import type { StdFee } from "@cosmjs/stargate"; - import { truncate } from "../truncate"; -import type { Fee, Token, U } from "lib/types"; +import type { Token, U } from "lib/types"; import { formatToken } from "./currency.format"; @@ -24,10 +22,3 @@ export const formatUFee = (uFee: string) => { denom )}`; }; - -export const formatStdFee = (fee: StdFee | Fee) => { - return `${formatToken( - fee.amount[0].amount as U, - fee.amount[0].denom - )} ${getTokenLabelByDenom(fee.amount[0].denom)}`; -}; From ab05ef048d270a74a5e4b3674fc509a9a382be41 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Thu, 28 Dec 2023 13:18:47 +0700 Subject: [PATCH 7/9] fix: remove formatUFee --- src/lib/app-fns/tx/clearAdmin.tsx | 10 ++++++++-- src/lib/app-fns/tx/common/post.tsx | 16 +++++++++++----- src/lib/app-fns/tx/execute.tsx | 10 ++++++++-- src/lib/app-fns/tx/migrate.tsx | 10 ++++++++-- src/lib/app-fns/tx/move/executeModule.tsx | 10 ++++++++-- src/lib/app-fns/tx/resend.tsx | 10 ++++++++-- src/lib/app-fns/tx/script.tsx | 10 ++++++++-- src/lib/app-fns/tx/submitProposal.tsx | 17 ++++++++++++++--- src/lib/app-fns/tx/updateAdmin.tsx | 10 ++++++++-- src/lib/app-fns/tx/upload.tsx | 3 +-- src/lib/pages/instantiate/completed.tsx | 11 ++++++++--- src/lib/utils/fee.ts | 16 ++++++++++++++++ src/lib/utils/index.ts | 1 + 13 files changed, 107 insertions(+), 27 deletions(-) create mode 100644 src/lib/utils/fee.ts diff --git a/src/lib/app-fns/tx/clearAdmin.tsx b/src/lib/app-fns/tx/clearAdmin.tsx index c5c8cb641..27fd04919 100644 --- a/src/lib/app-fns/tx/clearAdmin.tsx +++ b/src/lib/app-fns/tx/clearAdmin.tsx @@ -6,11 +6,12 @@ import type { StdFee } from "@cosmjs/stargate"; import { pipe } from "@rx-stream/pipe"; import type { Observable } from "rxjs"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; import { TxStreamPhase } from "lib/types"; import type { TxResultRendering, ContractAddr, HumanAddr } from "lib/types"; -import { formatUFee } from "lib/utils"; +import { feeFromStr } from "lib/utils"; import { catchTxError } from "./common"; import { postTx } from "./common/post"; @@ -59,7 +60,12 @@ export const clearAdminTx = ({ }, { title: "Tx Fee", - value: txFee ? formatUFee(txFee) : "N/A", + html: ( + + ), }, ], receiptInfo: { diff --git a/src/lib/app-fns/tx/common/post.tsx b/src/lib/app-fns/tx/common/post.tsx index 5c4acc326..8c7bbab6a 100644 --- a/src/lib/app-fns/tx/common/post.tsx +++ b/src/lib/app-fns/tx/common/post.tsx @@ -6,10 +6,11 @@ import type { } from "@cosmjs/cosmwasm-stargate"; import { isDeliverTxFailure } from "@cosmjs/stargate"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ExplorerLink } from "lib/components/ExplorerLink"; import type { TxResultRendering } from "lib/types"; import { TxStreamPhase } from "lib/types"; -import { formatUFee } from "lib/utils/formatter/denom"; +import { feeFromStr } from "lib/utils"; // TODO: We'll use only DeliverTxResponse later. type TxResult = @@ -56,10 +57,15 @@ export const postTx = ({ postFn }: PostTxParams) => { { title: "Tx Fee", // TODO: Implement event/rawlog attribute picker - value: `${formatUFee( - txResult.events.find((e) => e.type === "tx")?.attributes[0] - .value ?? "0" - )}`, + html: ( + e.type === "tx")?.attributes[0] + .value ?? "0" + )} + loading={false} + /> + ), }, ], receiptInfo: { diff --git a/src/lib/app-fns/tx/execute.tsx b/src/lib/app-fns/tx/execute.tsx index 4ff161e90..e2ff15067 100644 --- a/src/lib/app-fns/tx/execute.tsx +++ b/src/lib/app-fns/tx/execute.tsx @@ -6,12 +6,13 @@ import type { Coin, StdFee } from "@cosmjs/stargate"; import { pipe } from "@rx-stream/pipe"; import type { Observable } from "rxjs"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; import type { Activity } from "lib/stores/contract"; import type { ContractAddr, HumanAddr, TxResultRendering } from "lib/types"; import { TxStreamPhase } from "lib/types"; -import { encode, formatUFee, getCurrentDate } from "lib/utils"; +import { encode, feeFromStr, getCurrentDate } from "lib/utils"; import { catchTxError, postTx, sendingTx } from "./common"; @@ -75,7 +76,12 @@ export const executeContractTx = ({ }, { title: "Tx Fee", - value: txFee ? formatUFee(txFee) : "N/A", + html: ( + + ), }, ], receiptInfo: { diff --git a/src/lib/app-fns/tx/migrate.tsx b/src/lib/app-fns/tx/migrate.tsx index 1b4fa2d0e..f23f833ae 100644 --- a/src/lib/app-fns/tx/migrate.tsx +++ b/src/lib/app-fns/tx/migrate.tsx @@ -6,11 +6,12 @@ import type { StdFee } from "@cosmjs/stargate"; import { pipe } from "@rx-stream/pipe"; import type { Observable } from "rxjs"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; import type { ContractAddr, HumanAddr, TxResultRendering } from "lib/types"; import { TxStreamPhase } from "lib/types"; -import { formatUFee } from "lib/utils"; +import { feeFromStr } from "lib/utils"; import { catchTxError } from "./common"; import { postTx } from "./common/post"; @@ -71,7 +72,12 @@ export const migrateContractTx = ({ }, { title: "Tx Fee", - value: txFee ? formatUFee(txFee) : "N/A", + html: ( + + ), }, ], receiptInfo: { diff --git a/src/lib/app-fns/tx/move/executeModule.tsx b/src/lib/app-fns/tx/move/executeModule.tsx index fb8f3cd67..9ca17f8e1 100644 --- a/src/lib/app-fns/tx/move/executeModule.tsx +++ b/src/lib/app-fns/tx/move/executeModule.tsx @@ -7,11 +7,12 @@ import type { Observable } from "rxjs"; import { catchTxError } from "../common"; import { postTx } from "../common/post"; import { sendingTx } from "../common/sending"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; import { TxStreamPhase } from "lib/types"; import type { HumanAddr, TxResultRendering } from "lib/types"; -import { formatUFee } from "lib/utils/formatter/denom"; +import { feeFromStr } from "lib/utils"; interface ExecuteModuleTxParams { address: HumanAddr; @@ -56,7 +57,12 @@ export const executeModuleTx = ({ }, { title: "Tx Fee", - value: txFee ? formatUFee(txFee) : "N/A", + html: ( + + ), }, ], receiptInfo: { diff --git a/src/lib/app-fns/tx/resend.tsx b/src/lib/app-fns/tx/resend.tsx index 9a652adbc..21f5c7f40 100644 --- a/src/lib/app-fns/tx/resend.tsx +++ b/src/lib/app-fns/tx/resend.tsx @@ -5,11 +5,12 @@ import type { StdFee } from "@cosmjs/stargate"; import { pipe } from "@rx-stream/pipe"; import type { Observable } from "rxjs"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; import type { HumanAddr, TxResultRendering } from "lib/types"; import { TxStreamPhase } from "lib/types"; -import { formatUFee } from "lib/utils"; +import { feeFromStr } from "lib/utils"; import { catchTxError, postTx, sendingTx } from "./common"; @@ -56,7 +57,12 @@ export const resendTx = ({ }, { title: "Tx Fee", - value: txFee ? formatUFee(txFee) : "N/A", + html: ( + + ), }, ], receiptInfo: { diff --git a/src/lib/app-fns/tx/script.tsx b/src/lib/app-fns/tx/script.tsx index 11111b760..07eb5dd3a 100644 --- a/src/lib/app-fns/tx/script.tsx +++ b/src/lib/app-fns/tx/script.tsx @@ -4,11 +4,12 @@ import type { StdFee } from "@cosmjs/stargate"; import { pipe } from "@rx-stream/pipe"; import type { Observable } from "rxjs"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; import type { HumanAddr, TxResultRendering } from "lib/types"; import { TxStreamPhase } from "lib/types"; -import { formatUFee } from "lib/utils"; +import { feeFromStr } from "lib/utils"; import { catchTxError, postTx, sendingTx } from "./common"; @@ -55,7 +56,12 @@ export const deployScriptTx = ({ }, { title: "Tx Fee", - value: txFee ? formatUFee(txFee) : "N/A", + html: ( + + ), }, ], receiptInfo: { diff --git a/src/lib/app-fns/tx/submitProposal.tsx b/src/lib/app-fns/tx/submitProposal.tsx index 678db085a..5eff7edf3 100644 --- a/src/lib/app-fns/tx/submitProposal.tsx +++ b/src/lib/app-fns/tx/submitProposal.tsx @@ -5,11 +5,12 @@ import { pipe } from "@rx-stream/pipe"; import { capitalize } from "lodash"; import type { Observable } from "rxjs"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; import type { HumanAddr, Nullable, TxResultRendering } from "lib/types"; import { TxStreamPhase } from "lib/types"; -import { findAttr, formatUFee } from "lib/utils"; +import { feeFromStr, findAttr } from "lib/utils"; import { catchTxError, postTx, sendingTx } from "./common"; @@ -73,7 +74,12 @@ export const submitWhitelistProposalTx = ({ }, { title: "Tx Fee", - value: txFee ? formatUFee(txFee) : "N/A", + html: ( + + ), }, ], receiptInfo: { @@ -155,7 +161,12 @@ export const submitStoreCodeProposalTx = ({ }, { title: "Tx Fee", - value: txFee ? formatUFee(txFee) : "N/A", + html: ( + + ), }, ], receiptInfo: { diff --git a/src/lib/app-fns/tx/updateAdmin.tsx b/src/lib/app-fns/tx/updateAdmin.tsx index 5b9678b86..cc85c0065 100644 --- a/src/lib/app-fns/tx/updateAdmin.tsx +++ b/src/lib/app-fns/tx/updateAdmin.tsx @@ -6,6 +6,7 @@ import type { StdFee } from "@cosmjs/stargate"; import { pipe } from "@rx-stream/pipe"; import type { Observable } from "rxjs"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; import type { @@ -15,7 +16,7 @@ import type { TxResultRendering, } from "lib/types"; import { TxStreamPhase } from "lib/types"; -import { formatUFee } from "lib/utils"; +import { feeFromStr } from "lib/utils"; import { catchTxError, postTx, sendingTx } from "./common"; @@ -65,7 +66,12 @@ export const updateAdminTx = ({ }, { title: "Tx Fee", - value: txFee ? formatUFee(txFee) : "N/A", + html: ( + + ), }, ], receiptInfo: { diff --git a/src/lib/app-fns/tx/upload.tsx b/src/lib/app-fns/tx/upload.tsx index 37ef8e831..61ec58b42 100644 --- a/src/lib/app-fns/tx/upload.tsx +++ b/src/lib/app-fns/tx/upload.tsx @@ -8,8 +8,7 @@ import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; import { TxStreamPhase } from "lib/types"; import type { HumanAddr, TxResultRendering, ComposedMsg } from "lib/types"; -import { findAttr } from "lib/utils"; -import { formatUFee } from "lib/utils/formatter/denom"; +import { findAttr, formatUFee } from "lib/utils"; import { catchTxError } from "./common"; import { postTx } from "./common/post"; diff --git a/src/lib/pages/instantiate/completed.tsx b/src/lib/pages/instantiate/completed.tsx index aa08474d1..af40e9189 100644 --- a/src/lib/pages/instantiate/completed.tsx +++ b/src/lib/pages/instantiate/completed.tsx @@ -1,12 +1,13 @@ import { Flex, Heading, Button } from "@chakra-ui/react"; import { useInternalNavigate } from "lib/app-provider"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; import { TxReceiptRender } from "lib/components/tx"; import WasmPageContainer from "lib/components/WasmPageContainer"; import type { ContractAddr } from "lib/types"; -import { formatUFee } from "lib/utils"; +import { feeFromStr } from "lib/utils"; import type { InstantiateTxInfo } from "."; import { InstantiateOffChainForm } from "./component"; @@ -43,8 +44,12 @@ const Completed = ({ txInfo }: CompletedProps) => { }, { title: "Tx Fee", - // TODO: Implement event/rawlog attribute picker - value: txFee ? formatUFee(txFee) : "N/A", + html: ( + + ), }, ]} variant="full" diff --git a/src/lib/utils/fee.ts b/src/lib/utils/fee.ts new file mode 100644 index 000000000..a8ec05c77 --- /dev/null +++ b/src/lib/utils/fee.ts @@ -0,0 +1,16 @@ +import type { StdFee } from "@cosmjs/stargate"; + +import type { Option } from "lib/types"; + +import { coinsFromStr } from "./funds"; + +export const feeFromStr = (uFee: Option) => { + if (!uFee) return undefined; + + const fee: StdFee = { + amount: coinsFromStr(uFee), + gas: "0", + }; + + return fee; +}; diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index ed88ab6b6..bed80fcfc 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -12,6 +12,7 @@ export * from "./descriptionAndName"; export * from "./executeTags"; export * from "./extractActionValue"; export * from "./extractMsgType"; +export * from "./fee"; export * from "./format"; export * from "./formatter"; export * from "./funds"; From 1e142d4ab83fdfbc3cf26ade99b78eb42b35928a Mon Sep 17 00:00:00 2001 From: evilpeach Date: Thu, 28 Dec 2023 13:29:38 +0700 Subject: [PATCH 8/9] fix: use feeFromStr --- src/lib/app-fns/tx/publish.tsx | 4 +--- src/lib/app-fns/tx/upload.tsx | 13 ++++++++---- src/lib/app-provider/tx/publish.tsx | 4 ++-- src/lib/app-provider/tx/upload.ts | 2 +- src/lib/pages/publish-module/completed.tsx | 11 ++++++++-- src/lib/pages/publish-module/index.tsx | 2 +- src/lib/pages/upload/completed.tsx | 9 +++++++- src/lib/pages/upload/index.tsx | 2 +- src/lib/utils/fee.ts | 2 +- src/lib/utils/formatter/denom.ts | 24 ---------------------- src/lib/utils/formatter/index.ts | 1 - 11 files changed, 33 insertions(+), 41 deletions(-) delete mode 100644 src/lib/utils/formatter/denom.ts diff --git a/src/lib/app-fns/tx/publish.tsx b/src/lib/app-fns/tx/publish.tsx index e613418e4..7c5281d64 100644 --- a/src/lib/app-fns/tx/publish.tsx +++ b/src/lib/app-fns/tx/publish.tsx @@ -6,7 +6,6 @@ import type { Observable } from "rxjs"; import type { PublishSucceedCallback } from "lib/app-provider/tx/publish"; import type { HumanAddr, TxResultRendering } from "lib/types"; -import { formatUFee } from "lib/utils"; import { catchTxError, postTx, sendingTx } from "./common"; @@ -35,8 +34,7 @@ export const publishModuleTx = ({ ({ value: txInfo }) => { const txFee = txInfo.events.find((e) => e.type === "tx")?.attributes[0] .value; - const formattedFee = txFee ? formatUFee(txFee) : "N/A"; - onTxSucceed?.({ txHash: txInfo.transactionHash, formattedFee }); + onTxSucceed?.({ txHash: txInfo.transactionHash, txFee }); return null as unknown as TxResultRendering; } )().pipe(catchTxError(onTxFailed)); diff --git a/src/lib/app-fns/tx/upload.tsx b/src/lib/app-fns/tx/upload.tsx index 61ec58b42..4a471e8cd 100644 --- a/src/lib/app-fns/tx/upload.tsx +++ b/src/lib/app-fns/tx/upload.tsx @@ -4,11 +4,12 @@ import { pipe } from "@rx-stream/pipe"; import type { Observable } from "rxjs"; import type { UploadSucceedCallback } from "lib/app-provider"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; import { TxStreamPhase } from "lib/types"; import type { HumanAddr, TxResultRendering, ComposedMsg } from "lib/types"; -import { findAttr, formatUFee } from "lib/utils"; +import { feeFromStr, findAttr } from "lib/utils"; import { catchTxError } from "./common"; import { postTx } from "./common/post"; @@ -53,14 +54,13 @@ export const uploadContractTx = ({ const codeHash = findAttr(mimicLog, "store_code", "code_checksum") ?? ""; const txFee = txInfo.events.find((e) => e.type === "tx")?.attributes[0] .value; - const formattedFee = txFee ? formatUFee(txFee) : "N/A"; onTxSucceed({ codeId: parseInt(codeId, 10).toString(), codeHash, codeDisplayName: codeName || `${wasmFileName}(${codeId})`, txHash: txInfo.transactionHash, - formattedFee, + txFee, }); return isMigrate @@ -90,7 +90,12 @@ export const uploadContractTx = ({ }, { title: "Tx Fee", - value: formattedFee, + html: ( + + ), }, ], receiptInfo: { diff --git a/src/lib/app-provider/tx/publish.tsx b/src/lib/app-provider/tx/publish.tsx index 199cc3cac..2c751b37e 100644 --- a/src/lib/app-provider/tx/publish.tsx +++ b/src/lib/app-provider/tx/publish.tsx @@ -5,11 +5,11 @@ import { useCallback } from "react"; import { useCurrentChain, useGetSigningClient } from "../hooks"; import { trackTxSucceed } from "lib/amplitude"; import { publishModuleTx } from "lib/app-fns/tx/publish"; -import type { HumanAddr } from "lib/types"; +import type { HumanAddr, Option } from "lib/types"; export interface PublishTxInternalResult { txHash: string; - formattedFee: string; + txFee: Option; } export type PublishSucceedCallback = ( diff --git a/src/lib/app-provider/tx/upload.ts b/src/lib/app-provider/tx/upload.ts index 21d311b29..a97706869 100644 --- a/src/lib/app-provider/tx/upload.ts +++ b/src/lib/app-provider/tx/upload.ts @@ -13,7 +13,7 @@ export interface UploadTxInternalResult { codeId: string; codeHash: string; txHash: string; - formattedFee: string; + txFee: Option; } export type UploadSucceedCallback = (txResult: UploadTxInternalResult) => void; diff --git a/src/lib/pages/publish-module/completed.tsx b/src/lib/pages/publish-module/completed.tsx index 84c57b6b8..98d0da66c 100644 --- a/src/lib/pages/publish-module/completed.tsx +++ b/src/lib/pages/publish-module/completed.tsx @@ -3,10 +3,12 @@ import { capitalize } from "lodash"; import plur from "plur"; import { AmpEvent, track } from "lib/amplitude"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; import { TxReceiptRender } from "lib/components/tx"; import WasmPageContainer from "lib/components/WasmPageContainer"; +import { feeFromStr } from "lib/utils"; import type { PublishCompleteState } from "."; import { ModulePublishCard } from "./components/ModulePublishCard"; @@ -17,7 +19,7 @@ interface PublishCompletedProps { } export const PublishCompleted = ({ - publishTxInfo: { txHash, formattedFee, upgradePolicy, modules }, + publishTxInfo: { txHash, txFee, upgradePolicy, modules }, resetState, }: PublishCompletedProps) => ( @@ -36,7 +38,12 @@ export const PublishCompleted = ({ }, { title: "Tx Fee", - value: formattedFee, + html: ( + + ), }, { title: "Upgrade Policy", diff --git a/src/lib/pages/publish-module/index.tsx b/src/lib/pages/publish-module/index.tsx index b583d4526..96df6d1d3 100644 --- a/src/lib/pages/publish-module/index.tsx +++ b/src/lib/pages/publish-module/index.tsx @@ -10,7 +10,7 @@ import { PublishModule } from "./publish"; const DEFAULT_STATE: PublishCompleteState = { txHash: "", - formattedFee: "", + txFee: undefined, upgradePolicy: UpgradePolicy.ARBITRARY, modules: [], }; diff --git a/src/lib/pages/upload/completed.tsx b/src/lib/pages/upload/completed.tsx index c63cbd8ff..51b9642b8 100644 --- a/src/lib/pages/upload/completed.tsx +++ b/src/lib/pages/upload/completed.tsx @@ -4,6 +4,7 @@ import { observer } from "mobx-react-lite"; import type { UploadTxInternalResult } from "lib/app-provider"; import { useInternalNavigate } from "lib/app-provider"; import { ConnectingLine } from "lib/components/ConnectingLine"; +import { EstimatedFeeRender } from "lib/components/EstimatedFeeRender"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; import { UploadSchema } from "lib/components/json-schema"; @@ -11,6 +12,7 @@ import { Stepper } from "lib/components/stepper"; import { TxReceiptRender } from "lib/components/tx"; import WasmPageContainer from "lib/components/WasmPageContainer"; import { useSchemaStore } from "lib/providers/store"; +import { feeFromStr } from "lib/utils"; interface UploadCompleteProps { txResult: UploadTxInternalResult; @@ -60,7 +62,12 @@ export const UploadComplete = observer(({ txResult }: UploadCompleteProps) => { }, { title: "Tx Fee", - value: txResult.formattedFee, + html: ( + + ), }, ]} variant="full" diff --git a/src/lib/pages/upload/index.tsx b/src/lib/pages/upload/index.tsx index 3156aef77..8ca8d2848 100644 --- a/src/lib/pages/upload/index.tsx +++ b/src/lib/pages/upload/index.tsx @@ -14,7 +14,7 @@ const UploadIndex = () => { codeId: "", codeHash: "", txHash: "", - formattedFee: "", + txFee: undefined, }); const [completed, setCompleted] = useState(false); diff --git a/src/lib/utils/fee.ts b/src/lib/utils/fee.ts index a8ec05c77..0ee34d5ae 100644 --- a/src/lib/utils/fee.ts +++ b/src/lib/utils/fee.ts @@ -4,7 +4,7 @@ import type { Option } from "lib/types"; import { coinsFromStr } from "./funds"; -export const feeFromStr = (uFee: Option) => { +export const feeFromStr = (uFee: Option): Option => { if (!uFee) return undefined; const fee: StdFee = { diff --git a/src/lib/utils/formatter/denom.ts b/src/lib/utils/formatter/denom.ts deleted file mode 100644 index 821d53119..000000000 --- a/src/lib/utils/formatter/denom.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { truncate } from "../truncate"; -import type { Token, U } from "lib/types"; - -import { formatToken } from "./currency.format"; - -// NOTE: revisit this if some chain is not using "u"denom -const getTokenLabelByDenom = (denom: string) => { - if (denom[0] === "u") { - return denom.replace("u", "").toUpperCase(); - } - const splitId = denom.split("/"); - if (splitId[1]) { - splitId[1] = truncate(splitId[1]); - } - return splitId.length === 1 ? denom : splitId.join("/"); -}; - -export const formatUFee = (uFee: string) => { - const regex = /([0-9]+)|([a-zA-Z]+)/g; - const [fee, denom] = uFee.match(regex) as RegExpMatchArray; - return `${formatToken(fee as U, denom)} ${getTokenLabelByDenom( - denom - )}`; -}; diff --git a/src/lib/utils/formatter/index.ts b/src/lib/utils/formatter/index.ts index 31c589ba3..cc5e9aa9f 100644 --- a/src/lib/utils/formatter/index.ts +++ b/src/lib/utils/formatter/index.ts @@ -1,6 +1,5 @@ export * from "./currency"; export * from "./currency.format"; -export * from "./denom"; export * from "./convertTitle"; export * from "./camelToSnake"; export * from "./snakeToCamel"; From c9508ee0bbe10ac16dcd2586db131f5ee70722fa Mon Sep 17 00:00:00 2001 From: evilpeach Date: Thu, 28 Dec 2023 15:33:48 +0700 Subject: [PATCH 9/9] fix: as comments --- src/lib/app-fns/tx/common/post.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/app-fns/tx/common/post.tsx b/src/lib/app-fns/tx/common/post.tsx index 8c7bbab6a..b78e34ae3 100644 --- a/src/lib/app-fns/tx/common/post.tsx +++ b/src/lib/app-fns/tx/common/post.tsx @@ -39,6 +39,8 @@ export const postTx = ({ postFn }: PostTxParams) => { if ("code" in txResult && isDeliverTxFailure(txResult)) { throw new Error(createDeliverTxResponseErrorMessage(txResult)); } + const txFee = txResult.events.find((e) => e.type === "tx") + ?.attributes[0].value; return { value: txResult, @@ -59,10 +61,7 @@ export const postTx = ({ postFn }: PostTxParams) => { // TODO: Implement event/rawlog attribute picker html: ( e.type === "tx")?.attributes[0] - .value ?? "0" - )} + estimatedFee={feeFromStr(txFee)} loading={false} /> ),