diff --git a/layer/icons/wallet-new/owallet.vue b/layer/icons/wallet-new/owallet.vue new file mode 100644 index 00000000..7c79ad8d --- /dev/null +++ b/layer/icons/wallet-new/owallet.vue @@ -0,0 +1,20 @@ + + + diff --git a/layer/icons/wallet/owallet.vue b/layer/icons/wallet/owallet.vue new file mode 100644 index 00000000..43375f29 --- /dev/null +++ b/layer/icons/wallet/owallet.vue @@ -0,0 +1,21 @@ + + + diff --git a/layer/store/wallet.ts b/layer/store/wallet.ts index 74165aaa..6ddbbe08 100644 --- a/layer/store/wallet.ts +++ b/layer/store/wallet.ts @@ -20,7 +20,7 @@ import { } from '@injectivelabs/wallet-ts' import { validateCosmosWallet, - confirmCorrectKeplrAddress + confirmCorrectKeplrAddress, confirmCorrectOWalletAddress } from '../wallet/cosmos' import { validateOkxWallet, isOkxWalletInstalled } from '../wallet/okx-wallet' import { @@ -435,6 +435,29 @@ export const useSharedWalletStore = defineStore('sharedWallet', { await walletStore.onConnect() }, + async connectOWallet() { + const walletStore = useSharedWalletStore() + + await walletStore.connectWallet(Wallet.OWallet) + + const injectiveAddresses = await getAddresses() + const [injectiveAddress] = injectiveAddresses + const session = await walletStrategy.getSessionOrConfirm() + + await confirmCorrectOWalletAddress(injectiveAddress) + + walletStore.$patch({ + injectiveAddress, + addresses: injectiveAddresses, + address: getEthereumAddress(injectiveAddress), + addressConfirmation: await walletStrategy.getSessionOrConfirm( + injectiveAddress + ), + session + }) + + await walletStore.onConnect() + }, async connectLedger({ wallet, diff --git a/layer/wallet/cosmos.ts b/layer/wallet/cosmos.ts index 4a4a619b..b16769e6 100644 --- a/layer/wallet/cosmos.ts +++ b/layer/wallet/cosmos.ts @@ -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.' + ) + ) + } +} export const validateCosmosWallet = async ({ wallet, diff --git a/layer/yarn.lock b/layer/yarn.lock index 1694e884..69ccf29e 100644 --- a/layer/yarn.lock +++ b/layer/yarn.lock @@ -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/core-proto-ts@0.0.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/core-proto-ts@0.0.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/indexer-proto-ts@1.11.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/indexer-proto-ts@1.11.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/networks@1.14.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/networks@1.14.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/sdk-ts@1.14.15-beta.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/sdk-ts@1.14.15-beta.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/wallet-ts@1.14.15-beta.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/wallet-ts@1.14.15-beta.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" diff --git a/packages/ui-shared/playground/icons.json b/packages/ui-shared/playground/icons.json index 346a1dc9..5bef45b6 100644 --- a/packages/ui-shared/playground/icons.json +++ b/packages/ui-shared/playground/icons.json @@ -139,6 +139,7 @@ "wallet/ethereum", "wallet/injective", "wallet/keplr", + "wallet/owallet", "wallet/leap", "wallet/ledger", "wallet/metamask", @@ -155,4 +156,4 @@ "youtube-circle", "youtube" ] -} \ No newline at end of file +}