Skip to content

Commit

Permalink
feat: retries on mempool full
Browse files Browse the repository at this point in the history
  • Loading branch information
bangjelkoski committed Jan 3, 2025
2 parents 309317a + b0a524c commit 0a271bd
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 115 deletions.
2 changes: 1 addition & 1 deletion packages/exceptions/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/exceptions",
"description": "List of exceptions that can be reused throughout Injective's projects.",
"version": "1.14.34-beta.3",
"version": "1.14.34-beta.4",
"sideEffects": false,
"license": "Apache-2.0",
"types": "dist/cjs/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/networks/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/networks",
"description": "Endpoints, networks, etc. Can be reused throughout Injective's projects.",
"version": "1.14.34-beta.3",
"version": "1.14.34-beta.4",
"sideEffects": false,
"license": "Apache-2.0",
"author": {
Expand Down Expand Up @@ -55,9 +55,9 @@
"start": "node dist/index.js"
},
"dependencies": {
"@injectivelabs/exceptions": "^1.14.34-beta.3",
"@injectivelabs/exceptions": "^1.14.34-beta.4",
"@injectivelabs/ts-types": "^1.14.34-beta.2",
"@injectivelabs/utils": "^1.14.34-beta.3",
"@injectivelabs/utils": "^1.14.34-beta.4",
"shx": "^0.3.2"
},
"gitHead": "6442ae377bbfb3459d2fb3a44c650630a5b7f445"
Expand Down
10 changes: 5 additions & 5 deletions packages/sdk-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/sdk-ts",
"description": "SDK in TypeScript for building Injective applications in a browser, node, and react native environment.",
"version": "1.14.34-beta.19",
"version": "1.14.34-beta.20",
"sideEffects": false,
"license": "Apache-2.0",
"author": {
Expand Down Expand Up @@ -123,17 +123,17 @@
"@ethersproject/bytes": "^5.7.0",
"@injectivelabs/abacus-proto-ts": "1.13.3",
"@injectivelabs/core-proto-ts": "1.13.4",
"@injectivelabs/exceptions": "^1.14.34-beta.3",
"@injectivelabs/exceptions": "^1.14.34-beta.4",
"@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.13.4",
"@injectivelabs/mito-proto-ts": "1.13.2",
"@injectivelabs/networks": "^1.14.34-beta.3",
"@injectivelabs/networks": "^1.14.34-beta.4",
"@injectivelabs/olp-proto-ts": "1.13.1",
"@injectivelabs/test-utils": "^1.14.34-beta.6",
"@injectivelabs/test-utils": "^1.14.34-beta.7",
"@injectivelabs/ts-types": "^1.14.34-beta.2",
"@injectivelabs/utils": "^1.14.34-beta.3",
"@injectivelabs/utils": "^1.14.34-beta.4",
"@metamask/eth-sig-util": "^4.0.0",
"@noble/curves": "^1.4.0",
"axios": "^1.6.4",
Expand Down
8 changes: 4 additions & 4 deletions packages/test-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/test-utils",
"description": "List of test-utils and helper functions that can be reused throughout Injective's projects.",
"version": "1.14.34-beta.6",
"version": "1.14.34-beta.7",
"sideEffects": false,
"author": {
"name": "InjectiveLabs",
Expand Down Expand Up @@ -55,10 +55,10 @@
"start": "node dist/index.js"
},
"dependencies": {
"@injectivelabs/exceptions": "^1.14.34-beta.3",
"@injectivelabs/networks": "^1.14.34-beta.3",
"@injectivelabs/exceptions": "^1.14.34-beta.4",
"@injectivelabs/networks": "^1.14.34-beta.4",
"@injectivelabs/ts-types": "^1.14.34-beta.2",
"@injectivelabs/utils": "^1.14.34-beta.3",
"@injectivelabs/utils": "^1.14.34-beta.4",
"axios": "^1.6.4",
"bignumber.js": "^9.0.1",
"shx": "^0.3.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/utils",
"description": "List of utils and helper functions that can be reused throughout Injective's projects.",
"version": "1.14.34-beta.3",
"version": "1.14.34-beta.4",
"sideEffects": false,
"author": {
"name": "InjectiveLabs",
Expand Down Expand Up @@ -55,7 +55,7 @@
"start": "node dist/index.js"
},
"dependencies": {
"@injectivelabs/exceptions": "^1.14.34-beta.3",
"@injectivelabs/exceptions": "^1.14.34-beta.4",
"@injectivelabs/ts-types": "^1.14.34-beta.2",
"axios": "^1.6.4",
"bignumber.js": "^9.0.1",
Expand Down
10 changes: 5 additions & 5 deletions packages/wallet-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/wallet-ts",
"description": "A convenient way to use and interact with different types of wallets on Injective.",
"version": "1.14.34-beta.19",
"version": "1.14.34-beta.20",
"sideEffects": false,
"author": {
"name": "InjectiveLabs",
Expand Down Expand Up @@ -81,11 +81,11 @@
"@cosmostation/extension-client": "^0.1.15",
"@ethereumjs/common": "^3.1.1",
"@ethereumjs/tx": "^4.1.1",
"@injectivelabs/exceptions": "^1.14.34-beta.3",
"@injectivelabs/networks": "^1.14.34-beta.3",
"@injectivelabs/sdk-ts": "^1.14.34-beta.19",
"@injectivelabs/exceptions": "^1.14.34-beta.4",
"@injectivelabs/networks": "^1.14.34-beta.4",
"@injectivelabs/sdk-ts": "^1.14.34-beta.20",
"@injectivelabs/ts-types": "^1.14.34-beta.2",
"@injectivelabs/utils": "^1.14.34-beta.3",
"@injectivelabs/utils": "^1.14.34-beta.4",
"@keplr-wallet/cosmos": "^0.12.71",
"@keplr-wallet/types": "^0.12.71",
"@ledgerhq/hw-app-cosmos": "^6.29.5",
Expand Down
43 changes: 29 additions & 14 deletions packages/wallet-ts/src/broadcaster/MsgBroadcaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -977,22 +977,37 @@ export class MsgBroadcaster {
endpoints.web3gw || endpoints.indexer,
)

const response = await transactionApi.broadcastCosmosTxRequest({
address: tx.injectiveAddress,
txRaw: createTxRawFromSigResponse(directSignResponse),
signature: directSignResponse.signature.signature,
pubKey: directSignResponse.signature.pub_key || {
value: pubKey,
type: '/injective.crypto.v1beta1.ethsecp256k1.PubKey',
},
})
const broadcast = async () =>
await transactionApi.broadcastCosmosTxRequest({
address: tx.injectiveAddress,
txRaw: createTxRawFromSigResponse(directSignResponse),
signature: directSignResponse.signature.signature,
pubKey: directSignResponse.signature.pub_key || {
value: pubKey,
type: '/injective.crypto.v1beta1.ethsecp256k1.PubKey',
},
})

// Re-enable tx gas check removed above
if (walletStrategy.wallet === Wallet.Keplr) {
new KeplrWallet(chainId).enableGasCheck()
}
try {
const response = await broadcast()

// Re-enable tx gas check removed above
if (walletStrategy.wallet === Wallet.Keplr) {
new KeplrWallet(chainId).enableGasCheck()
}

return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash)
return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash)
} catch (e) {
const error = e as any

if (isThrownException(error)) {
const exception = error as ThrownException

return await this.retryOnException(exception, broadcast)
}

throw e
}
}

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/wallets/wallet-base/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/wallet-base",
"description": "Base wallet strategy for use with @injectivelabs/wallet-core.",
"version": "1.14.34-beta.19",
"version": "1.14.34-beta.20",
"sideEffects": false,
"author": {
"name": "InjectiveLabs",
Expand Down Expand Up @@ -57,11 +57,11 @@
"dependencies": {
"@ethereumjs/common": "^3.1.1",
"@ethereumjs/tx": "^4.1.1",
"@injectivelabs/exceptions": "^1.14.34-beta.3",
"@injectivelabs/networks": "^1.14.34-beta.3",
"@injectivelabs/sdk-ts": "^1.14.34-beta.19",
"@injectivelabs/exceptions": "^1.14.34-beta.4",
"@injectivelabs/networks": "^1.14.34-beta.4",
"@injectivelabs/sdk-ts": "^1.14.34-beta.20",
"@injectivelabs/ts-types": "^1.14.34-beta.2",
"@injectivelabs/utils": "^1.14.34-beta.3",
"@injectivelabs/utils": "^1.14.34-beta.4",
"alchemy-sdk": "^3.4.7",
"eip1193-provider": "^1.0.1",
"eth-sig-util": "^3.0.1",
Expand Down
12 changes: 6 additions & 6 deletions packages/wallets/wallet-core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/wallet-core",
"description": "Core wallet strategy",
"version": "1.14.34-beta.20",
"version": "1.14.34-beta.21",
"sideEffects": false,
"author": {
"name": "InjectiveLabs",
Expand Down Expand Up @@ -55,12 +55,12 @@
"start": "node dist/index.js"
},
"dependencies": {
"@injectivelabs/exceptions": "^1.14.34-beta.3",
"@injectivelabs/networks": "^1.14.34-beta.3",
"@injectivelabs/sdk-ts": "^1.14.34-beta.19",
"@injectivelabs/exceptions": "^1.14.34-beta.4",
"@injectivelabs/networks": "^1.14.34-beta.4",
"@injectivelabs/sdk-ts": "^1.14.34-beta.20",
"@injectivelabs/ts-types": "^1.14.34-beta.2",
"@injectivelabs/utils": "^1.14.34-beta.3",
"@injectivelabs/wallet-base": "^1.14.34-beta.19",
"@injectivelabs/utils": "^1.14.34-beta.4",
"@injectivelabs/wallet-base": "^1.14.34-beta.20",
"eip1193-provider": "^1.0.1"
},
"devDependencies": {
Expand Down
15 changes: 13 additions & 2 deletions packages/wallets/wallet-core/src/broadcaster/MsgBroadcaster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -930,8 +930,8 @@ export class MsgBroadcaster {
endpoints.web3gw || endpoints.indexer,
)

try {
const response = await transactionApi.broadcastCosmosTxRequest({
const broadcast = async () =>
await transactionApi.broadcastCosmosTxRequest({
address: tx.injectiveAddress,
txRaw: createTxRawFromSigResponse(directSignResponse),
signature: directSignResponse.signature.signature,
Expand All @@ -941,13 +941,24 @@ export class MsgBroadcaster {
},
})

try {
const response = await broadcast()

// Re-enable tx gas check removed above
if (canDisableCosmosGasCheck && cosmosWallet.enableGasCheck) {
cosmosWallet.enableGasCheck(chainId)
}

return await new TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash)
} catch (e) {
const error = e as any

if (isThrownException(error)) {
const exception = error as ThrownException

return await this.retryOnException(exception, broadcast)
}

throw e
}
}
Expand Down
18 changes: 9 additions & 9 deletions packages/wallets/wallet-cosmos-strategy/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/wallet-cosmos-strategy",
"description": "Wallet Cosmos Strategy with instantiated wallets",
"version": "1.14.34-beta.20",
"version": "1.14.34-beta.21",
"sideEffects": false,
"author": {
"name": "InjectiveLabs",
Expand Down Expand Up @@ -57,15 +57,15 @@
"dependencies": {
"@ethereumjs/common": "^3.1.1",
"@ethereumjs/tx": "^4.1.1",
"@injectivelabs/exceptions": "^1.14.34-beta.3",
"@injectivelabs/networks": "^1.14.34-beta.3",
"@injectivelabs/sdk-ts": "^1.14.34-beta.19",
"@injectivelabs/exceptions": "^1.14.34-beta.4",
"@injectivelabs/networks": "^1.14.34-beta.4",
"@injectivelabs/sdk-ts": "^1.14.34-beta.20",
"@injectivelabs/ts-types": "^1.14.34-beta.2",
"@injectivelabs/utils": "^1.14.34-beta.3",
"@injectivelabs/wallet-base": "^1.14.34-beta.19",
"@injectivelabs/wallet-core": "^1.14.34-beta.20",
"@injectivelabs/wallet-cosmos": "^1.14.34-beta.19",
"@injectivelabs/wallet-cosmostation": "^1.14.34-beta.19",
"@injectivelabs/utils": "^1.14.34-beta.4",
"@injectivelabs/wallet-base": "^1.14.34-beta.20",
"@injectivelabs/wallet-core": "^1.14.34-beta.21",
"@injectivelabs/wallet-cosmos": "^1.14.34-beta.20",
"@injectivelabs/wallet-cosmostation": "^1.14.34-beta.20",
"alchemy-sdk": "^3.4.7",
"eip1193-provider": "^1.0.1",
"eth-sig-util": "^3.0.1",
Expand Down
12 changes: 6 additions & 6 deletions packages/wallets/wallet-cosmos/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/wallet-cosmos",
"description": "Cosmos wallet strategies for use with @injectivelabs/wallet-core.",
"version": "1.14.34-beta.19",
"version": "1.14.34-beta.20",
"sideEffects": false,
"author": {
"name": "InjectiveLabs",
Expand Down Expand Up @@ -59,12 +59,12 @@
"@cosmjs/launchpad": "0.27.1",
"@cosmjs/proto-signing": "^0.32.3",
"@cosmjs/stargate": "^0.32.3",
"@injectivelabs/exceptions": "^1.14.34-beta.3",
"@injectivelabs/networks": "^1.14.34-beta.3",
"@injectivelabs/sdk-ts": "^1.14.34-beta.19",
"@injectivelabs/exceptions": "^1.14.34-beta.4",
"@injectivelabs/networks": "^1.14.34-beta.4",
"@injectivelabs/sdk-ts": "^1.14.34-beta.20",
"@injectivelabs/ts-types": "^1.14.34-beta.2",
"@injectivelabs/utils": "^1.14.34-beta.3",
"@injectivelabs/wallet-base": "^1.14.34-beta.19",
"@injectivelabs/utils": "^1.14.34-beta.4",
"@injectivelabs/wallet-base": "^1.14.34-beta.20",
"@keplr-wallet/cosmos": "^0.12.71",
"@keplr-wallet/types": "^0.12.71",
"shx": "^0.3.3"
Expand Down
10 changes: 5 additions & 5 deletions packages/wallets/wallet-cosmostation/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/wallet-cosmostation",
"description": "Cosmostation strategy for use with @injectivelabs/wallet-core.",
"version": "1.14.34-beta.19",
"version": "1.14.34-beta.20",
"sideEffects": false,
"author": {
"name": "InjectiveLabs",
Expand Down Expand Up @@ -57,11 +57,11 @@
"dependencies": {
"@cosmjs/proto-signing": "^0.32.3",
"@cosmostation/extension-client": "^0.1.15",
"@injectivelabs/exceptions": "^1.14.34-beta.3",
"@injectivelabs/sdk-ts": "^1.14.34-beta.19",
"@injectivelabs/exceptions": "^1.14.34-beta.4",
"@injectivelabs/sdk-ts": "^1.14.34-beta.20",
"@injectivelabs/ts-types": "^1.14.34-beta.2",
"@injectivelabs/utils": "^1.14.34-beta.3",
"@injectivelabs/wallet-base": "^1.14.34-beta.19",
"@injectivelabs/utils": "^1.14.34-beta.4",
"@injectivelabs/wallet-base": "^1.14.34-beta.20",
"@walletconnect/ethereum-provider": "^2.12.2"
},
"gitHead": "6442ae377bbfb3459d2fb3a44c650630a5b7f445",
Expand Down
12 changes: 6 additions & 6 deletions packages/wallets/wallet-evm/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/wallet-evm",
"description": "EVM wallet strategies for use with @injectivelabs/wallet-core.",
"version": "1.14.34-beta.19",
"version": "1.14.34-beta.20",
"sideEffects": false,
"author": {
"name": "InjectiveLabs",
Expand Down Expand Up @@ -55,12 +55,12 @@
"start": "node dist/index.js"
},
"dependencies": {
"@injectivelabs/exceptions": "^1.14.34-beta.3",
"@injectivelabs/networks": "^1.14.34-beta.3",
"@injectivelabs/sdk-ts": "^1.14.34-beta.19",
"@injectivelabs/exceptions": "^1.14.34-beta.4",
"@injectivelabs/networks": "^1.14.34-beta.4",
"@injectivelabs/sdk-ts": "^1.14.34-beta.20",
"@injectivelabs/ts-types": "^1.14.34-beta.2",
"@injectivelabs/utils": "^1.14.34-beta.3",
"@injectivelabs/wallet-base": "^1.14.34-beta.19",
"@injectivelabs/utils": "^1.14.34-beta.4",
"@injectivelabs/wallet-base": "^1.14.34-beta.20",
"ethers": "^6.5.1",
"long": "^5.2.1",
"shx": "^0.3.3"
Expand Down
Loading

0 comments on commit 0a271bd

Please sign in to comment.