Skip to content

Commit

Permalink
Merge branch 'dev' into feat/sgt-create-strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
bangjelkoski authored Aug 10, 2023
2 parents 9e0eb14 + 60358c4 commit 011f58b
Show file tree
Hide file tree
Showing 57 changed files with 823 additions and 143 deletions.
16 changes: 16 additions & 0 deletions packages/bridge-ts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.12.0-beta.73](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-10)

**Note:** Version bump only for package @injectivelabs/bridge-ts

# [1.12.0-beta.72](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-09)

**Note:** Version bump only for package @injectivelabs/bridge-ts

# [1.12.0-beta.71](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-09)

**Note:** Version bump only for package @injectivelabs/bridge-ts

# [1.12.0-beta.70](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-08)

**Note:** Version bump only for package @injectivelabs/bridge-ts

# [1.12.0-beta.69](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-06)

**Note:** Version bump only for package @injectivelabs/bridge-ts
Expand Down
10 changes: 5 additions & 5 deletions packages/bridge-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/bridge-ts",
"description": "Bridge utilities and abstractions in TypeScript to be used in Injective products",
"version": "1.12.0-beta.69",
"version": "1.12.0-beta.73",
"sideEffects": false,
"author": {
"name": "Bojan Angjelkoski",
Expand Down Expand Up @@ -32,11 +32,11 @@
},
"dependencies": {
"@axelar-network/axelarjs-sdk": "^0.11.7",
"@injectivelabs/exceptions": "^1.12.0-beta.11",
"@injectivelabs/networks": "^1.12.0-beta.15",
"@injectivelabs/sdk-ts": "^1.12.0-beta.65",
"@injectivelabs/exceptions": "^1.12.0-beta.12",
"@injectivelabs/networks": "^1.12.0-beta.16",
"@injectivelabs/sdk-ts": "^1.12.0-beta.69",
"@injectivelabs/ts-types": "^1.12.0-beta.2",
"@injectivelabs/utils": "^1.12.0-beta.15",
"@injectivelabs/utils": "^1.12.0-beta.16",
"@injectivelabs/wormhole-sdk": "^1.12.0-beta.0",
"@solana/spl-token": "^0.3.6",
"@solana/wallet-adapter-base": "^0.9.18",
Expand Down
4 changes: 4 additions & 0 deletions packages/contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.12.0-beta.16](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-09)

**Note:** Version bump only for package @injectivelabs/contracts

# [1.12.0-beta.15](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-06)

**Note:** Version bump only for package @injectivelabs/contracts
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@injectivelabs/contracts",
"description": "Contracts wrapper that can be reused throughout Injective's projects.",
"version": "1.12.0-beta.15",
"version": "1.12.0-beta.16",
"sideEffects": false,
"license": "Apache-2.0",
"main": "dist/cjs/index.js",
Expand Down Expand Up @@ -31,10 +31,10 @@
"start": "node dist/index.js"
},
"dependencies": {
"@injectivelabs/exceptions": "^1.12.0-beta.11",
"@injectivelabs/networks": "^1.12.0-beta.15",
"@injectivelabs/exceptions": "^1.12.0-beta.12",
"@injectivelabs/networks": "^1.12.0-beta.16",
"@injectivelabs/ts-types": "^1.12.0-beta.2",
"@injectivelabs/utils": "^1.12.0-beta.15",
"@injectivelabs/utils": "^1.12.0-beta.16",
"ethers": "^5.7.2",
"link-module-alias": "^1.2.0",
"shx": "^0.3.3"
Expand Down
10 changes: 10 additions & 0 deletions packages/exceptions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.12.0-beta.12](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-09)

### Bug Fixes

- export ([c3491fa](https://github.com/InjectiveLabs/injective-ts/commit/c3491fa4f400eadd59a232535dd11993ce4a82f4))

### Features

- added trust wallet ([47bae16](https://github.com/InjectiveLabs/injective-ts/commit/47bae16f3a49f075a5733d5170c315c2f411bef3))

# [1.12.0-beta.11](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-06)

### Features
Expand Down
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.12.0-beta.11",
"version": "1.12.0-beta.12",
"sideEffects": false,
"license": "Apache-2.0",
"main": "dist/cjs/index.js",
Expand Down
29 changes: 29 additions & 0 deletions packages/exceptions/src/exceptions/TrustWalletException.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ConcreteException } from '../exception'
import { ErrorContext, ErrorType } from '../types'
import { mapMetamaskMessage } from '../utils/maps'

const removeTrustWalletFromErrorString = (message: string): string =>
message
.replaceAll('TrustWallet', '')
.replaceAll('Trust Wallet', '')
.replaceAll('Trustwallet', '')
.replaceAll('TrustWallet:', '')
.replaceAll('Trust Wallet:', '')

export class TrustWalletException extends ConcreteException {
public errorClass: string = 'TrustWalletException'

constructor(error: Error, context?: ErrorContext) {
super(error, context)

this.type = ErrorType.WalletError
}

public parseMessage(): void {
const { message } = this

this.setMessage(
mapMetamaskMessage(removeTrustWalletFromErrorString(message)),
)
}
}
4 changes: 4 additions & 0 deletions packages/exceptions/src/exceptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Web3Exception } from './Web3Exception'
import { GeneralException } from './GeneralException'
import { LedgerException } from './LedgerException'
import { MetamaskException } from './MetamaskException'
import { TrustWalletException } from './TrustWalletException'
import { TrezorException } from './TrezorException'
import { CosmosWalletException } from './CosmosWalletException'
import { TransactionException } from './TransactionException'
Expand All @@ -18,6 +19,7 @@ export type ThrownException =
| GeneralException
| LedgerException
| MetamaskException
| TrustWalletException
| TrezorException
| CosmosWalletException
| TransactionException
Expand All @@ -40,6 +42,7 @@ export const isThrownException = (exception: Error | Exception): boolean => {
'CosmosWalletException',
'TransactionException',
'WalletException',
'TrustWalletException',
].includes(exception.constructor.name)
) {
return true
Expand All @@ -56,6 +59,7 @@ export {
LedgerException,
MetamaskException,
TrezorException,
TrustWalletException,
CosmosWalletException,
TransactionException,
WalletException,
Expand Down
4 changes: 4 additions & 0 deletions packages/networks/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.12.0-beta.16](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-09)

**Note:** Version bump only for package @injectivelabs/networks

# [1.12.0-beta.15](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-06)

**Note:** Version bump only for package @injectivelabs/networks
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.12.0-beta.15",
"version": "1.12.0-beta.16",
"sideEffects": false,
"license": "Apache-2.0",
"author": {
Expand Down Expand Up @@ -31,9 +31,9 @@
"start": "node dist/index.js"
},
"dependencies": {
"@injectivelabs/exceptions": "^1.12.0-beta.11",
"@injectivelabs/exceptions": "^1.12.0-beta.12",
"@injectivelabs/ts-types": "^1.12.0-beta.2",
"@injectivelabs/utils": "^1.12.0-beta.15",
"@injectivelabs/utils": "^1.12.0-beta.16",
"link-module-alias": "^1.2.0",
"shx": "^0.3.2"
},
Expand Down
16 changes: 16 additions & 0 deletions packages/sdk-ts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.12.0-beta.69](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-10)

**Note:** Version bump only for package @injectivelabs/sdk-ts

# [1.12.0-beta.68](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-09)

**Note:** Version bump only for package @injectivelabs/sdk-ts

# [1.12.0-beta.67](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-09)

**Note:** Version bump only for package @injectivelabs/sdk-ts

# [1.12.0-beta.66](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-08)

**Note:** Version bump only for package @injectivelabs/sdk-ts

# [1.12.0-beta.65](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/[email protected]...@injectivelabs/[email protected]) (2023-08-06)

### Features
Expand Down
12 changes: 6 additions & 6 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.12.0-beta.65",
"version": "1.12.0-beta.69",
"sideEffects": false,
"license": "Apache-2.0",
"author": {
Expand Down Expand Up @@ -38,17 +38,17 @@
"@ethersproject/bytes": "^5.7.0",
"@injectivelabs/core-proto-ts": "^0.0.18",
"@injectivelabs/dmm-proto-ts": "1.0.16",
"@injectivelabs/exceptions": "^1.12.0-beta.11",
"@injectivelabs/exceptions": "^1.12.0-beta.12",
"@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.6",
"@injectivelabs/mito-proto-ts": "1.0.28",
"@injectivelabs/networks": "^1.12.0-beta.15",
"@injectivelabs/mito-proto-ts": "1.0.32",
"@injectivelabs/networks": "^1.12.0-beta.16",
"@injectivelabs/test-utils": "^1.12.0-beta.1",
"@injectivelabs/token-metadata": "^1.12.0-beta.34",
"@injectivelabs/token-metadata": "^1.12.0-beta.35",
"@injectivelabs/ts-types": "^1.12.0-beta.2",
"@injectivelabs/utils": "^1.12.0-beta.15",
"@injectivelabs/utils": "^1.12.0-beta.16",
"@metamask/eth-sig-util": "^4.0.0",
"axios": "^0.27.2",
"bech32": "^2.0.0",
Expand Down
60 changes: 60 additions & 0 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcAuthZApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import {
GrpcUnaryRequestException,
UnspecifiedErrorCode,
} from '@injectivelabs/exceptions'
import { CosmosAuthzV1Beta1Query } from '@injectivelabs/core-proto-ts'
import BaseGrpcConsumer from '../../BaseGrpcConsumer'
import { ChainModule } from '../types'
import { PaginationOption } from '../../../types/pagination'
import { paginationRequestFromPagination } from '../../../utils/pagination'
import { ChainGrpcAuthZTransformer } from '../transformers/ChainGrpcAuthZTransformer'

/**
* @category Chain Grpc API
*/
export class ChainGrpcAuthZApi extends BaseGrpcConsumer {
protected module: string = ChainModule.Authz

protected client: CosmosAuthzV1Beta1Query.QueryClientImpl

constructor(endpoint: string) {
super(endpoint)

this.client = new CosmosAuthzV1Beta1Query.QueryClientImpl(
this.getGrpcWebImpl(endpoint),
)
}

async fetchGrants(pagination?: PaginationOption) {
const request = CosmosAuthzV1Beta1Query.QueryGrantsRequest.create()

const paginationForRequest = paginationRequestFromPagination(pagination)

if (paginationForRequest) {
request.pagination = paginationForRequest
}

try {
const response =
await this.retry<CosmosAuthzV1Beta1Query.QueryGrantsResponse>(() =>
this.client.Grants(request),
)

return ChainGrpcAuthZTransformer.grpcGrantsToGrants(response)
} catch (e: unknown) {
if (e instanceof CosmosAuthzV1Beta1Query.GrpcWebError) {
throw new GrpcUnaryRequestException(new Error(e.toString()), {
code: e.code,
context: 'Params',
contextModule: this.module,
})
}

throw new GrpcUnaryRequestException(e as Error, {
code: UnspecifiedErrorCode,
context: 'Grants',
contextModule: this.module,
})
}
}
}
4 changes: 2 additions & 2 deletions packages/sdk-ts/src/client/chain/grpc/ChainGrpcAuthzApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import BaseGrpcConsumer from '../../BaseGrpcConsumer'
import { ChainModule } from '../types'
import { PaginationOption } from '../../../types/pagination'
import { paginationRequestFromPagination } from '../../../utils/pagination'
import { ChainGrpcAuthzTransformer } from '../transformers/ChainGrpcAuthzTransformer'
import { ChainGrpcAuthZTransformer } from '../transformers/ChainGrpcAuthZTransformer'

/**
* @category Chain Grpc API
Expand Down Expand Up @@ -50,7 +50,7 @@ export class ChainGrpcAuthZApi extends BaseGrpcConsumer {
this.client.Grants(request),
)

return ChainGrpcAuthzTransformer.grpcGrantsToGrants(response)
return ChainGrpcAuthZTransformer.grpcGrantsToGrants(response)
} catch (e: unknown) {
if (e instanceof CosmosAuthzV1Beta1Query.GrpcWebError) {
throw new GrpcUnaryRequestException(new Error(e.toString()), {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-ts/src/client/chain/grpc/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { ChainGrpcAuctionApi } from './ChainGrpcAuctionApi'
export { ChainGrpcAuthApi } from './ChainGrpcAuthApi'
export { ChainGrpcAuthZApi } from './ChainGrpcAuthzApi'
export { ChainGrpcAuthZApi } from './ChainGrpcAuthZApi'
export { ChainGrpcBankApi } from './ChainGrpcBankApi'
export { ChainGrpcDistributionApi } from './ChainGrpcDistributionApi'
export { ChainGrpcExchangeApi } from './ChainGrpcExchangeApi'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { grpcPaginationToPagination } from '../../../utils/pagination'
import {
CosmosAuthzV1Beta1Authz,
CosmosAuthzV1Beta1Query,
} from '@injectivelabs/core-proto-ts'

/**
* @category Chain Grpc Transformer
*/
export class ChainGrpcAuthZTransformer {
static grpcGrantToGrant(grant: CosmosAuthzV1Beta1Authz.Grant) {
return {
authorization: grant.authorization
? Buffer.from(grant.authorization.value).toString('utf-8')
: '',
expiration: grant.expiration,
}
}

static grpcGrantsToGrants(
response: CosmosAuthzV1Beta1Query.QueryGrantsResponse,
) {
return {
pagination: grpcPaginationToPagination(response.pagination!),
grants: response.grants.map(ChainGrpcAuthZTransformer.grpcGrantToGrant),
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
/**
* @category Chain Grpc Transformer
*/
export class ChainGrpcAuthzTransformer {
export class ChainGrpcAuthZTransformer {
static grpcGrantToGrant(grant: CosmosAuthzV1Beta1Authz.Grant) {
return {
authorization: grant.authorization
Expand All @@ -22,7 +22,7 @@ export class ChainGrpcAuthzTransformer {
) {
return {
pagination: grpcPaginationToPagination(response.pagination!),
grants: response.grants.map(ChainGrpcAuthzTransformer.grpcGrantToGrant),
grants: response.grants.map(ChainGrpcAuthZTransformer.grpcGrantToGrant),
}
}
}
2 changes: 2 additions & 0 deletions packages/sdk-ts/src/client/chain/transformers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './ChainGrpcAuctionTransformer'
export * from './ChainGrpcAuthTransformer'
export * from './ChainGrpcAuthZTransformer'
export * from './ChainGrpcBankTransformer'
export * from './ChainGrpcDistributionTransformer'
export * from './ChainGrpcExchangeTransformer'
Expand Down
Loading

0 comments on commit 011f58b

Please sign in to comment.