-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/add owallet #70
base: master
Are you sure you want to change the base?
Feat/add owallet #70
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script lang="ts" setup> | ||
const uuid = `${Math.random()}` | ||
</script> | ||
|
||
<template> | ||
<svg width="166" height="165" viewBox="0 0 166 165" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path opacity="0.51" d="M145.129 56.7787H94.4052C91.9231 56.7787 89.8652 54.7633 89.8652 52.2388V30.5363C89.8652 28.0542 91.8806 25.9963 94.4052 25.9963H147.399C148.672 25.9963 149.669 26.9934 149.669 28.2663V52.2812C149.627 54.7633 147.611 56.7787 145.129 56.7787Z" fill="#AD83FF"/> | ||
<path opacity="0.5" d="M132.442 46.2768H85.5575C84.1574 46.2768 83.0754 45.1312 83.0754 43.7947V17.9977C83.0754 16.5976 84.221 15.5156 85.5575 15.5156H132.484C133.884 15.5156 134.966 16.6612 134.966 17.9977V43.7947C134.987 45.1948 133.842 46.2768 132.442 46.2768Z" fill="#AD83FF"/> | ||
<path opacity="0.9" d="M163.352 68.5518H108.343C107.028 68.5518 105.946 67.5122 105.946 66.1545V39.4666C105.946 38.1513 106.985 37.0693 108.343 37.0693H163.352C164.668 37.0693 165.75 38.1088 165.75 39.4666V66.1333C165.771 67.4486 164.668 68.5518 163.352 68.5518Z" fill="#AD83FF"/> | ||
<path d="M145.32 129.311C130.809 149.698 106.985 163 80.0638 163C35.8526 163 0 127.147 0 82.9358C0 40.6552 32.7977 6.01179 74.3358 3.08418C74.6752 3.08418 74.9935 3.04175 75.3329 3.04175C77.9635 3.12661 80.0638 5.09956 80.0638 7.53924V36.4123C54.3305 36.4123 33.4978 57.2662 33.4978 82.9782C33.4978 108.69 54.3517 129.544 80.0638 129.544C105.776 129.544 126.63 108.69 126.63 82.9782C126.63 82.9782 152.66 93.734 145.32 129.311Z" fill="#925AFF"/> | ||
<path d="M159.916 89.1109C159.513 85.6529 156.415 82.9799 152.618 82.9799H85.474C82.5039 82.9799 80.0855 80.5826 80.0855 77.5914V7.54086C80.0855 5.10119 77.9852 3.12823 75.3546 3.04338C75.6516 3.04338 75.9698 3.00094 76.2668 3.00094C79.6824 2.95851 81.5068 4.35868 81.9948 4.80418L82.0372 4.84661L82.1221 4.93147L154.23 77.0398C160.34 83.192 159.916 89.1109 159.916 89.1109Z" fill="#AD83FF"/> | ||
<path opacity="0.91" d="M159.873 89.0451C159.831 89.9362 159.746 90.806 159.661 91.6333C158.155 105.571 153.063 118.449 145.32 129.31C152.66 93.7123 126.63 82.9778 126.63 82.9778H152.597C156.415 82.9778 159.513 85.6508 159.873 89.0451Z" fill="url(#paint0_linear_4242_32575)"/> | ||
<defs> | ||
<linearGradient id="paint0_linear_4242_32575" x1="143.252" y1="131.138" x2="143.252" y2="83.1802" gradientUnits="userSpaceOnUse"> | ||
<stop offset="8.52446e-08" stop-color="#925AFF"/> | ||
<stop offset="1" stop-color="#713BBB"/> | ||
</linearGradient> | ||
</defs> | ||
</svg> | ||
</template> |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,21 @@ | ||||||||||||||||
<script lang="ts" setup> | ||||||||||||||||
const uuid = `${Math.random()}` | ||||||||||||||||
</script> | ||||||||||||||||
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using a more robust UUID generation method. The current implementation uses Consider using a dedicated UUID library or a more robust method for generating UUIDs. Here's an example using the <script lang="ts" setup>
-const uuid = `${Math.random()}`
+import { v4 as uuidv4 } from 'uuid';
+const uuid = uuidv4();
</script> Make sure to install the
This approach will provide a more reliable and standardized way of generating UUIDs. 📝 Committable suggestion
Suggested change
|
||||||||||||||||
|
||||||||||||||||
<template> | ||||||||||||||||
<svg width="166" height="165" viewBox="0 0 166 165" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||||||||||||||||
<path opacity="0.51" d="M145.129 56.7787H94.4052C91.9231 56.7787 89.8652 54.7633 89.8652 52.2388V30.5363C89.8652 28.0542 91.8806 25.9963 94.4052 25.9963H147.399C148.672 25.9963 149.669 26.9934 149.669 28.2663V52.2812C149.627 54.7633 147.611 56.7787 145.129 56.7787Z" fill="#AD83FF"/> | ||||||||||||||||
<path opacity="0.5" d="M132.442 46.2768H85.5575C84.1574 46.2768 83.0754 45.1312 83.0754 43.7947V17.9977C83.0754 16.5976 84.221 15.5156 85.5575 15.5156H132.484C133.884 15.5156 134.966 16.6612 134.966 17.9977V43.7947C134.987 45.1948 133.842 46.2768 132.442 46.2768Z" fill="#AD83FF"/> | ||||||||||||||||
<path opacity="0.9" d="M163.352 68.5518H108.343C107.028 68.5518 105.946 67.5122 105.946 66.1545V39.4666C105.946 38.1513 106.985 37.0693 108.343 37.0693H163.352C164.668 37.0693 165.75 38.1088 165.75 39.4666V66.1333C165.771 67.4486 164.668 68.5518 163.352 68.5518Z" fill="#AD83FF"/> | ||||||||||||||||
<path d="M145.32 129.311C130.809 149.698 106.985 163 80.0638 163C35.8526 163 0 127.147 0 82.9358C0 40.6552 32.7977 6.01179 74.3358 3.08418C74.6752 3.08418 74.9935 3.04175 75.3329 3.04175C77.9635 3.12661 80.0638 5.09956 80.0638 7.53924V36.4123C54.3305 36.4123 33.4978 57.2662 33.4978 82.9782C33.4978 108.69 54.3517 129.544 80.0638 129.544C105.776 129.544 126.63 108.69 126.63 82.9782C126.63 82.9782 152.66 93.734 145.32 129.311Z" fill="#925AFF"/> | ||||||||||||||||
<path d="M159.916 89.1109C159.513 85.6529 156.415 82.9799 152.618 82.9799H85.474C82.5039 82.9799 80.0855 80.5826 80.0855 77.5914V7.54086C80.0855 5.10119 77.9852 3.12823 75.3546 3.04338C75.6516 3.04338 75.9698 3.00094 76.2668 3.00094C79.6824 2.95851 81.5068 4.35868 81.9948 4.80418L82.0372 4.84661L82.1221 4.93147L154.23 77.0398C160.34 83.192 159.916 89.1109 159.916 89.1109Z" fill="#AD83FF"/> | ||||||||||||||||
<path opacity="0.91" d="M159.873 89.0451C159.831 89.9362 159.746 90.806 159.661 91.6333C158.155 105.571 153.063 118.449 145.32 129.31C152.66 93.7123 126.63 82.9778 126.63 82.9778H152.597C156.415 82.9778 159.513 85.6508 159.873 89.0451Z" fill="url(#paint0_linear_4242_32575)"/> | ||||||||||||||||
<defs> | ||||||||||||||||
<linearGradient id="paint0_linear_4242_32575" x1="143.252" y1="131.138" x2="143.252" y2="83.1802" gradientUnits="userSpaceOnUse"> | ||||||||||||||||
<stop offset="8.52446e-08" stop-color="#925AFF"/> | ||||||||||||||||
<stop offset="1" stop-color="#713BBB"/> | ||||||||||||||||
</linearGradient> | ||||||||||||||||
</defs> | ||||||||||||||||
</svg> | ||||||||||||||||
|
||||||||||||||||
</template> | ||||||||||||||||
Comment on lines
+5
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider extracting the SVG to a separate file. While inline SVGs offer easy manipulation, they can impact performance if the component is frequently used. For a more optimized approach, consider extracting the SVG to a separate file.
<script lang="ts" setup>
const uuid = `${Math.random()}`
+import OWalletIcon from '@/assets/icons/owallet-icon.svg'
</script>
<template>
- <svg width="166" height="165" viewBox="0 0 166 165" fill="none" xmlns="http://www.w3.org/2000/svg">
- <!-- ... SVG content ... -->
- </svg>
+ <img :src="OWalletIcon" alt="OWallet Icon" width="166" height="165" />
</template> This approach can improve performance, especially if the icon is used in multiple places.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { | |
import { PublicKey } from '@injectivelabs/sdk-ts' | ||
import { CosmosWalletStrategy, Wallet } from '@injectivelabs/wallet-ts' | ||
import { KeplrWallet } from '@injectivelabs/wallet-ts/dist/esm/utils/wallets/keplr' | ||
import { OWalletBase } from '@injectivelabs/wallet-ts/dist/esm/utils/wallets/owallet' | ||
import { CHAIN_ID } from './../utils/constant' | ||
import { walletStrategy } from './wallet-strategy' | ||
|
||
|
@@ -31,6 +32,28 @@ export const confirmCorrectKeplrAddress = async (injectiveAddress: string) => { | |
) | ||
} | ||
} | ||
export const confirmCorrectOWalletAddress = async (injectiveAddress: string) => { | ||
// We only perform this check for OWallet addresses | ||
if (walletStrategy.getWallet() !== Wallet.OWallet) { | ||
return | ||
} | ||
|
||
const owallet = new OWalletBase(CHAIN_ID) | ||
const key = await owallet.getKey() | ||
const publicKey = PublicKey.fromBase64( | ||
Buffer.from(key.pubKey).toString('base64') | ||
) | ||
|
||
const { address: derivedAddress } = publicKey.toAddress() | ||
|
||
if (derivedAddress !== injectiveAddress) { | ||
throw new CosmosWalletException( | ||
new Error( | ||
'Connected OWallet address is wrong. Please update Injective on OWallet.' | ||
) | ||
) | ||
} | ||
} | ||
Comment on lines
+35
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve error handling and provide more informative error messages The
Consider refactoring the function as follows: export const confirmCorrectOWalletAddress = async (injectiveAddress: string) => {
if (walletStrategy.getWallet() !== Wallet.OWallet) {
return
}
try {
const owallet = new OWalletBase(CHAIN_ID)
const key = await owallet.getKey()
const publicKey = PublicKey.fromBase64(
Buffer.from(key.pubKey).toString('base64')
)
const { address: derivedAddress } = publicKey.toAddress()
if (derivedAddress !== injectiveAddress) {
throw new CosmosWalletException(
new Error(
`Connected OWallet address is incorrect. Expected: ${injectiveAddress}, Got: ${derivedAddress}`
)
)
}
} catch (error) {
if (error instanceof CosmosWalletException) {
throw error
}
throw new CosmosWalletException(
new Error(`Failed to validate OWallet address: ${error.message}`)
)
}
} This refactored version:
|
||
|
||
export const validateCosmosWallet = async ({ | ||
wallet, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1559,10 +1559,10 @@ | |
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz#4a2868d75d6d6963e423bcf90b7fd1be343409d3" | ||
integrity sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA== | ||
|
||
"@injectivelabs/[email protected].30": | ||
version "0.0.30" | ||
resolved "https://registry.yarnpkg.com/@injectivelabs/core-proto-ts/-/core-proto-ts-0.0.30.tgz#15427ecaa9006ba18df19b63dfe7113f5c7f9854" | ||
integrity sha512-NqE7W5NoyzUv1+AWZxffjjQcqXLFLdNWwf+0qdbWs4vnr90x2D8js10iqaDaipmFelemnFsjZ1VdX2155XkUkA== | ||
"@injectivelabs/[email protected].34": | ||
version "0.0.34" | ||
resolved "https://registry.yarnpkg.com/@injectivelabs/core-proto-ts/-/core-proto-ts-0.0.34.tgz#ea67e5c6ecafc5f0d95d04d53de6bfd09b4c6c27" | ||
integrity sha512-kg25j+aCFCR/zkfn6U7JlH4Be4VEHO77cjfSLCQfOavQZ2nrXy9pvc9X88OBTYTCL7wLngIqAe0edt39bDk3tQ== | ||
dependencies: | ||
"@injectivelabs/grpc-web" "^0.0.1" | ||
google-protobuf "^3.14.0" | ||
|
@@ -1607,10 +1607,10 @@ | |
dependencies: | ||
browser-headers "^0.4.1" | ||
|
||
"@injectivelabs/[email protected].54": | ||
version "1.11.54" | ||
resolved "https://registry.yarnpkg.com/@injectivelabs/indexer-proto-ts/-/indexer-proto-ts-1.11.54.tgz#ae2063909bb998da7fbf97acc141e9f2a64487fd" | ||
integrity sha512-G73Fel2ylP5EDSSEcVvWXPq0UrxL9+g7WvZst4tN5fGCTClvA7MYcl2fzcVg+G2pX+aE0zKsGWnNEol8ZkZdBw== | ||
"@injectivelabs/[email protected].55": | ||
version "1.11.55" | ||
resolved "https://registry.yarnpkg.com/@injectivelabs/indexer-proto-ts/-/indexer-proto-ts-1.11.55.tgz#06b15daf704373a96bca56257e1d65d8d9a84c08" | ||
integrity sha512-Z22cczdNVdQoFrkz0fkXE0mreJNOySFmwYTusHbR58YJ/bb+fyL5eePJCB2aH3m53AtzaqJE5DmAd8vG/Qf0fg== | ||
dependencies: | ||
"@injectivelabs/grpc-web" "^0.0.1" | ||
google-protobuf "^3.14.0" | ||
|
@@ -1627,10 +1627,10 @@ | |
protobufjs "^7.0.0" | ||
rxjs "^7.4.0" | ||
|
||
"@injectivelabs/[email protected].14", "@injectivelabs/networks@^1.14.14": | ||
version "1.14.14" | ||
resolved "https://registry.yarnpkg.com/@injectivelabs/networks/-/networks-1.14.14.tgz#99aac9fbf8e1d7144df1b19490fac957445534bb" | ||
integrity sha512-xeGCqLRFThQ6z86YHyhuzzeof4OR0VvFDdmrjznHfgq6AAAa8TfwF1Oz7iYyl3Skpg4qqMu5msO6MbxLHOptjA== | ||
"@injectivelabs/[email protected].15-beta.0", "@injectivelabs/networks@^1.14.15-beta.0": | ||
version "1.14.15-beta.0" | ||
resolved "https://registry.yarnpkg.com/@injectivelabs/networks/-/networks-1.14.15-beta.0.tgz#6b5015703bb7f9e0f4deb20aa32fb8bce2b5d229" | ||
integrity sha512-LARsjKbDgypJv5joKQu64eJaSlm9GeaSwJkdEPOkXYrzWMQf7L8ZAnFqyW90mCIf7Yx7lU5FIDGlqJSTTdayxA== | ||
dependencies: | ||
"@injectivelabs/exceptions" "^1.14.14" | ||
"@injectivelabs/ts-types" "^1.14.14" | ||
|
@@ -1648,25 +1648,25 @@ | |
"@bugsnag/source-maps" "^2.3.1" | ||
"@nuxt/kit" "^3.0.0-rc.13" | ||
|
||
"@injectivelabs/[email protected].3", "@injectivelabs/sdk-ts@^1.14.15-beta.3": | ||
version "1.14.15-beta.3" | ||
resolved "https://registry.yarnpkg.com/@injectivelabs/sdk-ts/-/sdk-ts-1.14.15-beta.3.tgz#1fc1622d1bd68fabb57e31791c4355a23534a0e4" | ||
integrity sha512-1LyRqlIszkNnMayeyzoQEnlXINeWLH6P1/xXX5/eoPPwcyf5sLUOCuSHc9JtwFXFBn2tk3GPNdenMx8LyiQIKA== | ||
"@injectivelabs/[email protected].9", "@injectivelabs/sdk-ts@^1.14.15-beta.9": | ||
version "1.14.15-beta.9" | ||
resolved "https://registry.yarnpkg.com/@injectivelabs/sdk-ts/-/sdk-ts-1.14.15-beta.9.tgz#9069effa890a0012f72784f221083fdb027ee1ac" | ||
integrity sha512-Rfo4xRwmpXywrE76bJRuXqazdRt4Xiqhur1yUcA+opIDQTvhLFxZOS9hG/Q0FMsb9mhkrIPbwMErVW5MW1iFIQ== | ||
dependencies: | ||
"@apollo/client" "^3.5.8" | ||
"@cosmjs/amino" "^0.32.3" | ||
"@cosmjs/proto-signing" "^0.32.3" | ||
"@cosmjs/stargate" "^0.32.3" | ||
"@ethersproject/bytes" "^5.7.0" | ||
"@injectivelabs/core-proto-ts" "0.0.30" | ||
"@injectivelabs/core-proto-ts" "0.0.34" | ||
"@injectivelabs/dmm-proto-ts" "1.0.20" | ||
"@injectivelabs/exceptions" "^1.14.14" | ||
"@injectivelabs/grpc-web" "^0.0.1" | ||
"@injectivelabs/grpc-web-node-http-transport" "^0.0.2" | ||
"@injectivelabs/grpc-web-react-native-transport" "^0.0.2" | ||
"@injectivelabs/indexer-proto-ts" "1.11.54" | ||
"@injectivelabs/indexer-proto-ts" "1.11.55" | ||
"@injectivelabs/mito-proto-ts" "1.0.65" | ||
"@injectivelabs/networks" "^1.14.14" | ||
"@injectivelabs/networks" "^1.14.15-beta.0" | ||
"@injectivelabs/test-utils" "^1.14.14" | ||
"@injectivelabs/ts-types" "^1.14.14" | ||
"@injectivelabs/utils" "^1.14.14" | ||
|
@@ -1724,10 +1724,10 @@ | |
snakecase-keys "^5.1.2" | ||
store2 "^2.12.0" | ||
|
||
"@injectivelabs/[email protected].6": | ||
version "1.14.15-beta.6" | ||
resolved "https://registry.yarnpkg.com/@injectivelabs/wallet-ts/-/wallet-ts-1.14.15-beta.6.tgz#c6fecc77108ba9685eb090060c3b040f46469cc8" | ||
integrity sha512-A+lKbgGPoSpGnWu8UHTFPE+lnCtUvxJPSYFuhlXcu1LyGDUn6FHC65wGUfKS6vPuMgMj7rynIAsqQlNGrMc0JA== | ||
"@injectivelabs/[email protected].13": | ||
version "1.14.15-beta.13" | ||
resolved "https://registry.yarnpkg.com/@injectivelabs/wallet-ts/-/wallet-ts-1.14.15-beta.13.tgz#a1196b77db2aee2cb062a2e40228aea8ed1d316b" | ||
integrity sha512-/fpXzJPgOF75kxJ/cIhRcM6ruMFWW5f8t8kgsEnzkztl3OanDonoFGfZzzW9cuS8EdVcR7Xt6u/znEtKzSK8Eg== | ||
dependencies: | ||
"@cosmjs/launchpad" "0.27.1" | ||
"@cosmjs/proto-signing" "0.32.2" | ||
|
@@ -1736,8 +1736,8 @@ | |
"@ethereumjs/common" "^3.1.1" | ||
"@ethereumjs/tx" "^4.1.1" | ||
"@injectivelabs/exceptions" "^1.14.14" | ||
"@injectivelabs/networks" "^1.14.14" | ||
"@injectivelabs/sdk-ts" "^1.14.15-beta.3" | ||
"@injectivelabs/networks" "^1.14.15-beta.0" | ||
"@injectivelabs/sdk-ts" "^1.14.15-beta.9" | ||
"@injectivelabs/ts-types" "^1.14.14" | ||
"@injectivelabs/utils" "^1.14.14" | ||
"@keplr-wallet/cosmos" "^0.12.71" | ||
|
@@ -10927,16 +10927,16 @@ sha.js@^2.4.0, sha.js@^2.4.11, sha.js@^2.4.8: | |
|
||
"shared-packages@https://github.com/InjectiveLabs/shared-packages#master": | ||
version "1.0.0" | ||
resolved "https://github.com/InjectiveLabs/shared-packages#e33edf98fd21428607ffedcc74fca95c0573c8bc" | ||
resolved "https://github.com/InjectiveLabs/shared-packages#6e9094ddb95d9f25f488288a55706ae0a42359ec" | ||
dependencies: | ||
"@bangjelkoski/ens-validation" "^0.1.1" | ||
"@injectivelabs/exceptions" "1.14.14" | ||
"@injectivelabs/networks" "1.14.14" | ||
"@injectivelabs/networks" "1.14.15-beta.0" | ||
"@injectivelabs/nuxt-bugsnag" "0.0.3" | ||
"@injectivelabs/sdk-ts" "1.14.15-beta.3" | ||
"@injectivelabs/sdk-ts" "1.14.15-beta.9" | ||
"@injectivelabs/ts-types" "1.14.14" | ||
"@injectivelabs/utils" "1.14.14" | ||
"@injectivelabs/wallet-ts" "1.14.15-beta.6" | ||
"@injectivelabs/wallet-ts" "1.14.15-beta.13" | ||
"@types/canvas-confetti" "^1.6.4" | ||
"@vuepic/vue-datepicker" "^5.4.0" | ||
"@vueuse/integrations" "^10.7.1" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a more robust UUID generation method.
The current implementation uses
Math.random()
to generate a UUID, which doesn't guarantee uniqueness or unpredictability. This could potentially lead to conflicts if multiple instances of the component are rendered.Consider using a dedicated UUID library or a more robust method for generating UUIDs. Here's an example using the
uuid
package:Make sure to install the
uuid
package:This approach ensures a more reliable and standardized UUID generation.
📝 Committable suggestion