diff --git a/layer/icons/wallet/okx-wallet.vue b/layer/icons/wallet/okx-wallet.vue
new file mode 100644
index 00000000..d679895b
--- /dev/null
+++ b/layer/icons/wallet/okx-wallet.vue
@@ -0,0 +1,42 @@
+
+
+
+
diff --git a/layer/nuxt-config/vite/index.ts b/layer/nuxt-config/vite/index.ts
index 38044e9f..4428556f 100644
--- a/layer/nuxt-config/vite/index.ts
+++ b/layer/nuxt-config/vite/index.ts
@@ -42,7 +42,7 @@ export default defineConfig({
optimizeDeps: {
exclude: ['fsevents'],
- include: ['@injectivelabs/sdk-ts']
+ include: []
}
}) as ViteConfig
diff --git a/layer/package.json b/layer/package.json
index cc4718bc..b4a5b825 100644
--- a/layer/package.json
+++ b/layer/package.json
@@ -10,10 +10,10 @@
"@injectivelabs/nuxt-bugsnag": "0.0.3",
"@injectivelabs/utils": "1.14.6-beta.10",
"@injectivelabs/networks": "1.14.6-beta.13",
- "@injectivelabs/sdk-ts": "1.14.6-beta.54",
- "@injectivelabs/sdk-ui-ts": "1.14.6-beta.61",
+ "@injectivelabs/sdk-ts": "1.14.6-beta.58",
+ "@injectivelabs/sdk-ui-ts": "1.14.6-beta.65",
"@injectivelabs/token-metadata": "1.14.6-beta.45",
- "@injectivelabs/wallet-ts": "1.14.6-beta.61",
+ "@injectivelabs/wallet-ts": "1.14.6-beta.65",
"@vueuse/integrations": "^10.7.1",
"floating-vue": "2.0.0-beta.24",
"vue-gtag": "^2.0.1",
diff --git a/layer/store/wallet.ts b/layer/store/wallet.ts
index ac1661d3..0049030e 100644
--- a/layer/store/wallet.ts
+++ b/layer/store/wallet.ts
@@ -15,6 +15,7 @@ import {
validateTrustWallet,
isTrustWalletInstalled
} from './../wallet/trust-wallet'
+import { validateOkxWallet, isOkxWalletInstalled } from './../wallet/okx-wallet'
import { isPhantomInstalled } from './../wallet/phantom'
import { IS_DEVNET } from './../utils/constant'
import {
@@ -35,6 +36,7 @@ type WalletStoreState = {
hwAddresses: string[]
phantomInstalled: boolean
metamaskInstalled: boolean
+ okxWalletInstalled: boolean
trustWalletInstalled: boolean
wallet: Wallet
queueStatus: StatusType
@@ -50,6 +52,7 @@ const initialStateFactory = (): WalletStoreState => ({
wallet: Wallet.Metamask,
phantomInstalled: false,
metamaskInstalled: false,
+ okxWalletInstalled: false,
trustWalletInstalled: false,
queueStatus: StatusType.Idle
})
@@ -94,6 +97,10 @@ export const useSharedWalletStore = defineStore('sharedWallet', {
await validateTrustWallet(walletStore.address)
}
+ if (walletStore.wallet === Wallet.OkxWallet) {
+ await validateOkxWallet(walletStore.address)
+ }
+
if (isCosmosBrowserWallet(walletStore.wallet)) {
await validateCosmosWallet({
wallet: walletStore.wallet,
@@ -157,6 +164,16 @@ export const useSharedWalletStore = defineStore('sharedWallet', {
})
},
+ async checkIsOkxWalletInstalled() {
+ const walletStore = useSharedWalletStore()
+
+ console.log('check okx', await isOkxWalletInstalled())
+
+ walletStore.$patch({
+ okxWalletInstalled: await isOkxWalletInstalled()
+ })
+ },
+
async checkIsPhantomWalletInstalled() {
const walletStore = useSharedWalletStore()
@@ -402,8 +419,26 @@ export const useSharedWalletStore = defineStore('sharedWallet', {
walletStore.$patch({
address,
addresses,
- injectiveAddress: getInjectiveAddress(address),
- addressConfirmation: await confirm(address)
+ addressConfirmation: await confirm(address),
+ injectiveAddress: getInjectiveAddress(address)
+ })
+
+ await walletStore.onConnect()
+ },
+
+ async connectOkxWallet() {
+ const walletStore = useSharedWalletStore()
+
+ await walletStore.connectWallet(Wallet.OkxWallet)
+
+ const addresses = await getAddresses()
+ const [address] = addresses
+
+ walletStore.$patch({
+ address,
+ addresses,
+ addressConfirmation: await confirm(address),
+ injectiveAddress: getInjectiveAddress(address)
})
await walletStore.onConnect()
@@ -417,6 +452,7 @@ export const useSharedWalletStore = defineStore('sharedWallet', {
walletStore.$patch({
...initialStateFactory(),
metamaskInstalled: walletStore.metamaskInstalled,
+ okxWalletInstalled: walletStore.okxWalletInstalled,
walletConnectStatus: WalletConnectStatus.disconnected
})
}
diff --git a/layer/wallet/metamask.ts b/layer/wallet/metamask.ts
index bd2ffdce..6a478e34 100644
--- a/layer/wallet/metamask.ts
+++ b/layer/wallet/metamask.ts
@@ -69,7 +69,11 @@ export const validateMetamask = async (address: string) => {
)
}
- if (!metamaskProvider.isMetaMask || metamaskProvider.isPhantom) {
+ if (
+ metamaskProvider.isPhantom ||
+ metamaskProvider.isOkxWallet ||
+ metamaskProvider.isTrustWallet
+ ) {
throw new GeneralException(
new Error('You are connected to the wrong wallet. Please use Metamask.'),
{
diff --git a/layer/wallet/okx-wallet.ts b/layer/wallet/okx-wallet.ts
new file mode 100644
index 00000000..476c071d
--- /dev/null
+++ b/layer/wallet/okx-wallet.ts
@@ -0,0 +1,75 @@
+import { EthereumChainId, AccountAddress } from '@injectivelabs/ts-types'
+import {
+ ErrorType,
+ GeneralException,
+ OkxWalletException,
+ UnspecifiedErrorCode
+} from '@injectivelabs/exceptions'
+import { UtilsWallets } from '@injectivelabs/wallet-ts'
+import { walletStrategy } from './wallet-strategy'
+import { ETHEREUM_CHAIN_ID } from './../utils/constant'
+
+export const isOkxWalletInstalled = async (): Promise => {
+ const provider = await UtilsWallets.getOkxWalletProvider()
+
+ return !!provider
+}
+
+export const validateOkxWallet = async (
+ address: AccountAddress,
+ chainId: EthereumChainId = ETHEREUM_CHAIN_ID
+) => {
+ const addresses = await walletStrategy.getAddresses()
+ const okxWalletIsLocked = addresses.length === 0
+
+ if (okxWalletIsLocked) {
+ throw new OkxWalletException(
+ new Error(
+ 'Your OkxWallet is currently locked. Please unlock your OkxWallet.'
+ ),
+ {
+ code: UnspecifiedErrorCode,
+ type: ErrorType.WalletError
+ }
+ )
+ }
+
+ const [okxWalletActiveAddress] = addresses
+ const okxWalletActiveAddressDoesntMatchTheActiveAddress =
+ address && okxWalletActiveAddress.toLowerCase() !== address.toLowerCase()
+
+ if (okxWalletActiveAddressDoesntMatchTheActiveAddress) {
+ throw new OkxWalletException(
+ new Error(
+ 'You are connected to the wrong address. Please logout and connect to OkxWallet again'
+ ),
+ {
+ code: UnspecifiedErrorCode,
+ type: ErrorType.WalletError
+ }
+ )
+ }
+
+ const okxWalletChainId = parseInt(
+ await walletStrategy.getEthereumChainId(),
+ 16
+ )
+ const okxWalletChainIdDoesntMatchTheActiveChainId =
+ chainId !== okxWalletChainId
+
+ if (okxWalletChainIdDoesntMatchTheActiveChainId) {
+ return await UtilsWallets.updateOkxWalletNetwork(chainId)
+ }
+
+ const okxProvider = await UtilsWallets.getOkxWalletProvider()
+
+ if (!okxProvider) {
+ throw new GeneralException(
+ new Error('You are connected to the wrong wallet. Please use Metamask.'),
+ {
+ code: UnspecifiedErrorCode,
+ type: ErrorType.WalletError
+ }
+ )
+ }
+}
diff --git a/layer/wallet/trust-wallet.ts b/layer/wallet/trust-wallet.ts
index a80abc39..6326eac6 100644
--- a/layer/wallet/trust-wallet.ts
+++ b/layer/wallet/trust-wallet.ts
@@ -1,4 +1,4 @@
-import { EthereumChainId, AccountAddress } from '@injectivelabs/ts-types'
+import { AccountAddress } from '@injectivelabs/ts-types'
import {
ErrorType,
UnspecifiedErrorCode,
diff --git a/layer/yarn.lock b/layer/yarn.lock
index dc28dd54..8c0465b1 100644
--- a/layer/yarn.lock
+++ b/layer/yarn.lock
@@ -1434,10 +1434,10 @@
protobufjs "^7.0.0"
rxjs "^7.4.0"
-"@injectivelabs/mito-proto-ts@1.0.59":
- version "1.0.59"
- resolved "https://registry.yarnpkg.com/@injectivelabs/mito-proto-ts/-/mito-proto-ts-1.0.59.tgz#7e842dd0893c04afad5984640347d9f6641e0ed5"
- integrity sha512-eQZ9unwCci6/OlL78k8WSAB8DWPjQJwLFAWr452UwenOYo1antqXuhdXrsRu09OMYy4Du2NXR7NpUZt0pF1mvg==
+"@injectivelabs/mito-proto-ts@1.0.62":
+ version "1.0.62"
+ resolved "https://registry.yarnpkg.com/@injectivelabs/mito-proto-ts/-/mito-proto-ts-1.0.62.tgz#45fc0746af7d1b283625816caeb9fff9887e050f"
+ integrity sha512-WtoO80Y597nZiAuE4H+L208I0i3ByWytR+HqABdCaA26uJ7F1LhXw8YXxh3pP9z0LAeW31T+N7bwtOMlVR4riA==
dependencies:
"@injectivelabs/grpc-web" "^0.0.1"
google-protobuf "^3.14.0"
@@ -1465,10 +1465,10 @@
"@bugsnag/source-maps" "^2.3.1"
"@nuxt/kit" "^3.0.0-rc.13"
-"@injectivelabs/sdk-ts@1.14.6-beta.53", "@injectivelabs/sdk-ts@^1.14.6-beta.53":
- version "1.14.6-beta.53"
- resolved "https://registry.npmjs.org/@injectivelabs/sdk-ts/-/sdk-ts-1.14.6-beta.53.tgz#d80c600ca8fcd5154721ef9b7ad0768938abb6f8"
- integrity sha512-j08Z2BQzdTCqdNYpk0pPS3k/iJ0o9ADtrjYsXUYbqcEEe+c4sKEunkK51Qn+5mFjuNdpaoXP+F/aaRR8M2XsEQ==
+"@injectivelabs/sdk-ts@1.14.6-beta.58", "@injectivelabs/sdk-ts@^1.14.6-beta.58":
+ version "1.14.6-beta.58"
+ resolved "https://registry.yarnpkg.com/@injectivelabs/sdk-ts/-/sdk-ts-1.14.6-beta.58.tgz#0700a705a467347d2cd5fd5f94c1a9aa716215d7"
+ integrity sha512-g1fu/OB3r63b+6uRthR3ekcuBK6E9CF3uJ7Qpl5k6UZkZ9NvhJGkbveEPs1hMCYHsbDGWl3iXZuEM7McTkMrdw==
dependencies:
"@apollo/client" "^3.5.8"
"@cosmjs/amino" "^0.32.2"
@@ -1484,7 +1484,7 @@
"@injectivelabs/grpc-web-node-http-transport" "^0.0.2"
"@injectivelabs/grpc-web-react-native-transport" "^0.0.2"
"@injectivelabs/indexer-proto-ts" "1.11.36"
- "@injectivelabs/mito-proto-ts" "1.0.59"
+ "@injectivelabs/mito-proto-ts" "1.0.62"
"@injectivelabs/networks" "^1.14.6-beta.13"
"@injectivelabs/test-utils" "^1.14.3"
"@injectivelabs/token-metadata" "^1.14.6-beta.45"
@@ -1508,15 +1508,15 @@
shx "^0.3.2"
snakecase-keys "^5.4.1"
-"@injectivelabs/sdk-ui-ts@1.14.6-beta.60":
- version "1.14.6-beta.60"
- resolved "https://registry.npmjs.org/@injectivelabs/sdk-ui-ts/-/sdk-ui-ts-1.14.6-beta.60.tgz#9d57267412519ff7f8bae4f2edfcb7d83a9fcb29"
- integrity sha512-fJ7/yToFpNK0T/oDWUDm4jK6xH6c5xSU7EwMtC1y2P58xS1XmIfjKYaiiQXm+Is0QvdzzUWkYuNHbwFcmdraVg==
+"@injectivelabs/sdk-ui-ts@1.14.6-beta.65":
+ version "1.14.6-beta.65"
+ resolved "https://registry.yarnpkg.com/@injectivelabs/sdk-ui-ts/-/sdk-ui-ts-1.14.6-beta.65.tgz#52b8a200896033ddcb4ed7779f8a44580fb05724"
+ integrity sha512-SByLhhaz62FgFHfbzJqzPOYnUOn1536Vailci6G7s42Sb0mROlxmW14BDQ9UaST75vDS1AnnYWDwWkKKmip7Gw==
dependencies:
"@injectivelabs/contracts" "^1.14.6-beta.13"
"@injectivelabs/exceptions" "^1.14.6-beta.9"
"@injectivelabs/networks" "^1.14.6-beta.13"
- "@injectivelabs/sdk-ts" "^1.14.6-beta.53"
+ "@injectivelabs/sdk-ts" "^1.14.6-beta.58"
"@injectivelabs/token-metadata" "^1.14.6-beta.45"
"@injectivelabs/token-utils" "^1.14.6-beta.10"
"@injectivelabs/ts-types" "^1.14.6-beta.5"
@@ -1588,10 +1588,10 @@
snakecase-keys "^5.1.2"
store2 "^2.12.0"
-"@injectivelabs/wallet-ts@1.14.6-beta.60":
- version "1.14.6-beta.60"
- resolved "https://registry.npmjs.org/@injectivelabs/wallet-ts/-/wallet-ts-1.14.6-beta.60.tgz#37c9b72c58d482cb4a463188db2b22ae1c224152"
- integrity sha512-mlsuLaB6vhhAoANu+AhJuAS5zSFfoSVRZSGOpBpjZaOMlNsreQLTQPqBLzeKHXP59Yt/VpwZe/x6rNgWLHGe9g==
+"@injectivelabs/wallet-ts@1.14.6-beta.65":
+ version "1.14.6-beta.65"
+ resolved "https://registry.yarnpkg.com/@injectivelabs/wallet-ts/-/wallet-ts-1.14.6-beta.65.tgz#78fb34bf40a159fda4bee20f3ab276db21f82e84"
+ integrity sha512-Sbds9TVXjD2EAxYDsaLpW5O7zyYhqHljz2gI67yv4i07WHuPUoVl/fOioNkbYmTuaAwgQN+8LV/FAbD7ErePXw==
dependencies:
"@cosmjs/launchpad" "0.27.1"
"@cosmjs/proto-signing" "0.32.2"
@@ -1601,7 +1601,7 @@
"@ethereumjs/tx" "^4.1.1"
"@injectivelabs/exceptions" "^1.14.6-beta.9"
"@injectivelabs/networks" "^1.14.6-beta.13"
- "@injectivelabs/sdk-ts" "^1.14.6-beta.53"
+ "@injectivelabs/sdk-ts" "^1.14.6-beta.58"
"@injectivelabs/ts-types" "^1.14.6-beta.5"
"@injectivelabs/utils" "^1.14.6-beta.10"
"@keplr-wallet/cosmos" "^0.11.58"