diff --git a/packages/wallet-ts/src/broadcaster/MsgBroadcaster.ts b/packages/wallet-ts/src/broadcaster/MsgBroadcaster.ts index 64cf88027..5b9da22db 100644 --- a/packages/wallet-ts/src/broadcaster/MsgBroadcaster.ts +++ b/packages/wallet-ts/src/broadcaster/MsgBroadcaster.ts @@ -32,6 +32,7 @@ import { } from '@injectivelabs/utils' import { GeneralException, + isThrownException, TransactionException, UnspecifiedErrorCode, } from '@injectivelabs/exceptions' @@ -151,11 +152,21 @@ export class MsgBroadcaster { ) } - return isCosmosWallet(walletStrategy.wallet) - ? this.broadcastCosmos(txWithAddresses) - : isEip712V2OnlyWallet(walletStrategy.wallet) - ? this.broadcastWeb3V2(txWithAddresses) - : this.broadcastWeb3(txWithAddresses) + try { + return isCosmosWallet(walletStrategy.wallet) + ? this.broadcastCosmos(txWithAddresses) + : isEip712V2OnlyWallet(walletStrategy.wallet) + ? this.broadcastWeb3V2(txWithAddresses) + : this.broadcastWeb3(txWithAddresses) + } catch (e) { + const error = e as any + + if (isThrownException(error)) { + throw error + } + + throw new TransactionException(new Error(error)) + } } /** @@ -185,9 +196,19 @@ export class MsgBroadcaster { ) } - return isCosmosWallet(walletStrategy.wallet) - ? this.broadcastCosmos(txWithAddresses) - : this.broadcastWeb3V2(txWithAddresses) + try { + return isCosmosWallet(walletStrategy.wallet) + ? this.broadcastCosmos(txWithAddresses) + : this.broadcastWeb3V2(txWithAddresses) + } catch (e) { + const error = e as any + + if (isThrownException(error)) { + throw error + } + + throw new TransactionException(new Error(error)) + } } /** @@ -250,9 +271,19 @@ export class MsgBroadcaster { ) } - return isCosmosWallet(walletStrategy.wallet) - ? this.broadcastCosmosWithFeeDelegation(txWithAddresses) - : this.broadcastWeb3WithFeeDelegation(txWithAddresses) + try { + return isCosmosWallet(walletStrategy.wallet) + ? this.broadcastCosmosWithFeeDelegation(txWithAddresses) + : this.broadcastWeb3WithFeeDelegation(txWithAddresses) + } catch (e) { + const error = e as any + + if (isThrownException(error)) { + throw error + } + + throw new TransactionException(new Error(error)) + } } /** diff --git a/packages/wallets/wallet-core/src/broadcaster/MsgBroadcaster.ts b/packages/wallets/wallet-core/src/broadcaster/MsgBroadcaster.ts index 25df382d2..4f8f41b7b 100644 --- a/packages/wallets/wallet-core/src/broadcaster/MsgBroadcaster.ts +++ b/packages/wallets/wallet-core/src/broadcaster/MsgBroadcaster.ts @@ -16,10 +16,10 @@ import { getEip712TypedData, createWeb3Extension, getEip712TypedDataV2, + IndexerGrpcWeb3GwApi, ChainGrpcTendermintApi, createTransactionWithSigners, createTxRawFromSigResponse, - IndexerGrpcWeb3GwApi, getGasPriceBasedOnMessage, recoverTypedSignaturePubKey, CreateTransactionWithSignersArgs, @@ -32,6 +32,7 @@ import { } from '@injectivelabs/utils' import { GeneralException, + isThrownException, TransactionException, UnspecifiedErrorCode, } from '@injectivelabs/exceptions' @@ -148,11 +149,21 @@ export class MsgBroadcaster { ) } - return isCosmosWallet(walletStrategy.wallet) - ? this.broadcastCosmos(txWithAddresses) - : isEip712V2OnlyWallet(walletStrategy.wallet) - ? this.broadcastWeb3V2(txWithAddresses) - : this.broadcastWeb3(txWithAddresses) + try { + return isCosmosWallet(walletStrategy.wallet) + ? this.broadcastCosmos(txWithAddresses) + : isEip712V2OnlyWallet(walletStrategy.wallet) + ? this.broadcastWeb3V2(txWithAddresses) + : this.broadcastWeb3(txWithAddresses) + } catch (e) { + const error = e as any + + if (isThrownException(error)) { + throw error + } + + throw new TransactionException(new Error(error)) + } } /** @@ -177,9 +188,19 @@ export class MsgBroadcaster { ) } - return isCosmosWallet(walletStrategy.wallet) - ? this.broadcastCosmos(txWithAddresses) - : this.broadcastWeb3V2(txWithAddresses) + try { + return isCosmosWallet(walletStrategy.wallet) + ? this.broadcastCosmos(txWithAddresses) + : this.broadcastWeb3V2(txWithAddresses) + } catch (e) { + const error = e as any + + if (isThrownException(error)) { + throw error + } + + throw new TransactionException(new Error(error)) + } } /** @@ -203,9 +224,19 @@ export class MsgBroadcaster { ) } - return isCosmosWallet(walletStrategy.wallet) - ? this.broadcastCosmosWithFeeDelegation(txWithAddresses) - : this.broadcastWeb3WithFeeDelegation(txWithAddresses) + try { + return isCosmosWallet(walletStrategy.wallet) + ? this.broadcastCosmosWithFeeDelegation(txWithAddresses) + : this.broadcastWeb3WithFeeDelegation(txWithAddresses) + } catch (e) { + const error = e as any + + if (isThrownException(error)) { + throw error + } + + throw new TransactionException(new Error(error)) + } } /** diff --git a/packages/wallets/wallet-wallet-connect/README.md b/packages/wallets/wallet-wallet-connect/README.md index b514cbfdf..eecee08ce 100644 --- a/packages/wallets/wallet-wallet-connect/README.md +++ b/packages/wallets/wallet-wallet-connect/README.md @@ -20,12 +20,12 @@ yarn add @injectivelabs/wallet-wallet-connect ## 📖 Documentation -Injective's wallet packages are intended to make it easy for developers to choose exactly what wallets - and subsequent dependencies - they -want to include in their projects. +Injective's wallet packages are intended to make it easy for developers to choose exactly what wallets - and subsequent dependencies - they want to include in their projects. -Regardless of which wallet package(s) you choose to use you must also have `@injectivelabs/wallet-core` and `@injectivelabs/wallet-base` -installed. These contain all of the types and core wallet functionality, with the separate wallet packages only providing the necessary -dependencies and implementations for their specific wallets. +Keep in mind to include specific wallet images in your public directory, right now we only have: +- Fireblocks (path: `wallet-connect/fireblocks.webp`) + +Regardless of which wallet package(s) you choose to use you must also have `@injectivelabs/wallet-core` and `@injectivelabs/wallet-base` installed. These contain all of the types and core wallet functionality, with the separate wallet packages only providing the necessary dependencies and implementations for their specific wallets. Here's a brief example of how to use this package to send 1 INJ.: @@ -58,21 +58,21 @@ const msgBroadcaster = new MsgBroadcaster({ }) const sendTX = async () => { - const injectiveAddress = 'someInjectiveAddress' - - const message = MsgSend.fromJSON({ - srcInjectiveAddress: injectiveAddress, - dstInjectiveAddress: injectiveAddress, - amount: { - amount: '1', - denom: 'inj', - }, - }) - - return await msgBroadcaster.broadcast({ msgs: message }) - } + const injectiveAddress = 'someInjectiveAddress' + + const message = MsgSend.fromJSON({ + srcInjectiveAddress: injectiveAddress, + dstInjectiveAddress: injectiveAddress, + amount: { + amount: '1', + denom: 'inj', + }, + }) + + return await msgBroadcaster.broadcast({ msgs: message }) +} - const result = await sendTX() +const result = await sendTX() ``` Read more and find example usages on our [WalletStrategy Docs](https://docs.ts.injective.network/wallet/wallet-wallet-strategy)