diff --git a/packages/bridge-ts/CHANGELOG.md b/packages/bridge-ts/CHANGELOG.md index 9e9a18979..952268d35 100644 --- a/packages/bridge-ts/CHANGELOG.md +++ b/packages/bridge-ts/CHANGELOG.md @@ -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/bridge-ts@1.12.0-beta.72...@injectivelabs/bridge-ts@1.12.0-beta.73) (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/bridge-ts@1.12.0-beta.71...@injectivelabs/bridge-ts@1.12.0-beta.72) (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/bridge-ts@1.12.0-beta.70...@injectivelabs/bridge-ts@1.12.0-beta.71) (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/bridge-ts@1.12.0-beta.69...@injectivelabs/bridge-ts@1.12.0-beta.70) (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/bridge-ts@1.12.0-beta.68...@injectivelabs/bridge-ts@1.12.0-beta.69) (2023-08-06) **Note:** Version bump only for package @injectivelabs/bridge-ts diff --git a/packages/bridge-ts/package.json b/packages/bridge-ts/package.json index 20d795fde..17051003e 100644 --- a/packages/bridge-ts/package.json +++ b/packages/bridge-ts/package.json @@ -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", @@ -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", diff --git a/packages/contracts/CHANGELOG.md b/packages/contracts/CHANGELOG.md index 06ca607f3..b3fd8f73f 100644 --- a/packages/contracts/CHANGELOG.md +++ b/packages/contracts/CHANGELOG.md @@ -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/contracts@1.12.0-beta.15...@injectivelabs/contracts@1.12.0-beta.16) (2023-08-09) + +**Note:** Version bump only for package @injectivelabs/contracts + # [1.12.0-beta.15](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/contracts@1.12.0-beta.14...@injectivelabs/contracts@1.12.0-beta.15) (2023-08-06) **Note:** Version bump only for package @injectivelabs/contracts diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 01593341e..7267b26a3 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -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", @@ -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" diff --git a/packages/exceptions/CHANGELOG.md b/packages/exceptions/CHANGELOG.md index 4989c2057..8d0b57fea 100644 --- a/packages/exceptions/CHANGELOG.md +++ b/packages/exceptions/CHANGELOG.md @@ -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/exceptions@1.12.0-beta.11...@injectivelabs/exceptions@1.12.0-beta.12) (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/exceptions@1.12.0-beta.10...@injectivelabs/exceptions@1.12.0-beta.11) (2023-08-06) ### Features diff --git a/packages/exceptions/package.json b/packages/exceptions/package.json index 4e2cac9b5..59a6f0bb7 100644 --- a/packages/exceptions/package.json +++ b/packages/exceptions/package.json @@ -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", diff --git a/packages/exceptions/src/exceptions/TrustWalletException.ts b/packages/exceptions/src/exceptions/TrustWalletException.ts new file mode 100644 index 000000000..b843ca1ba --- /dev/null +++ b/packages/exceptions/src/exceptions/TrustWalletException.ts @@ -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)), + ) + } +} diff --git a/packages/exceptions/src/exceptions/index.ts b/packages/exceptions/src/exceptions/index.ts index 1ceb2dc60..1356059dc 100644 --- a/packages/exceptions/src/exceptions/index.ts +++ b/packages/exceptions/src/exceptions/index.ts @@ -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' @@ -18,6 +19,7 @@ export type ThrownException = | GeneralException | LedgerException | MetamaskException + | TrustWalletException | TrezorException | CosmosWalletException | TransactionException @@ -40,6 +42,7 @@ export const isThrownException = (exception: Error | Exception): boolean => { 'CosmosWalletException', 'TransactionException', 'WalletException', + 'TrustWalletException', ].includes(exception.constructor.name) ) { return true @@ -56,6 +59,7 @@ export { LedgerException, MetamaskException, TrezorException, + TrustWalletException, CosmosWalletException, TransactionException, WalletException, diff --git a/packages/networks/CHANGELOG.md b/packages/networks/CHANGELOG.md index 2ba4fb86c..4df75059d 100644 --- a/packages/networks/CHANGELOG.md +++ b/packages/networks/CHANGELOG.md @@ -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/networks@1.12.0-beta.15...@injectivelabs/networks@1.12.0-beta.16) (2023-08-09) + +**Note:** Version bump only for package @injectivelabs/networks + # [1.12.0-beta.15](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/networks@1.12.0-beta.14...@injectivelabs/networks@1.12.0-beta.15) (2023-08-06) **Note:** Version bump only for package @injectivelabs/networks diff --git a/packages/networks/package.json b/packages/networks/package.json index 1ea1697b5..562c68ea3 100644 --- a/packages/networks/package.json +++ b/packages/networks/package.json @@ -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": { @@ -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" }, diff --git a/packages/sdk-ts/CHANGELOG.md b/packages/sdk-ts/CHANGELOG.md index becec15f3..5f3ec0bb8 100644 --- a/packages/sdk-ts/CHANGELOG.md +++ b/packages/sdk-ts/CHANGELOG.md @@ -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/sdk-ts@1.12.0-beta.68...@injectivelabs/sdk-ts@1.12.0-beta.69) (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/sdk-ts@1.12.0-beta.67...@injectivelabs/sdk-ts@1.12.0-beta.68) (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/sdk-ts@1.12.0-beta.66...@injectivelabs/sdk-ts@1.12.0-beta.67) (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/sdk-ts@1.12.0-beta.65...@injectivelabs/sdk-ts@1.12.0-beta.66) (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/sdk-ts@1.12.0-beta.64...@injectivelabs/sdk-ts@1.12.0-beta.65) (2023-08-06) ### Features diff --git a/packages/sdk-ts/package.json b/packages/sdk-ts/package.json index 3154c1a15..c1d055529 100644 --- a/packages/sdk-ts/package.json +++ b/packages/sdk-ts/package.json @@ -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": { @@ -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", diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcAuthZApi.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcAuthZApi.ts new file mode 100644 index 000000000..bb4088314 --- /dev/null +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcAuthZApi.ts @@ -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(() => + 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, + }) + } + } +} diff --git a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcAuthzApi.ts b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcAuthzApi.ts index 093612c0e..6deb77d44 100644 --- a/packages/sdk-ts/src/client/chain/grpc/ChainGrpcAuthzApi.ts +++ b/packages/sdk-ts/src/client/chain/grpc/ChainGrpcAuthzApi.ts @@ -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 @@ -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()), { diff --git a/packages/sdk-ts/src/client/chain/grpc/index.ts b/packages/sdk-ts/src/client/chain/grpc/index.ts index 16664e450..ff7769df7 100644 --- a/packages/sdk-ts/src/client/chain/grpc/index.ts +++ b/packages/sdk-ts/src/client/chain/grpc/index.ts @@ -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' diff --git a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcAuthZTransformer.ts b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcAuthZTransformer.ts new file mode 100644 index 000000000..d3c695651 --- /dev/null +++ b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcAuthZTransformer.ts @@ -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), + } + } +} diff --git a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcAuthzTransformer.ts b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcAuthzTransformer.ts index c8807482c..d3c695651 100644 --- a/packages/sdk-ts/src/client/chain/transformers/ChainGrpcAuthzTransformer.ts +++ b/packages/sdk-ts/src/client/chain/transformers/ChainGrpcAuthzTransformer.ts @@ -7,7 +7,7 @@ import { /** * @category Chain Grpc Transformer */ -export class ChainGrpcAuthzTransformer { +export class ChainGrpcAuthZTransformer { static grpcGrantToGrant(grant: CosmosAuthzV1Beta1Authz.Grant) { return { authorization: grant.authorization @@ -22,7 +22,7 @@ export class ChainGrpcAuthzTransformer { ) { return { pagination: grpcPaginationToPagination(response.pagination!), - grants: response.grants.map(ChainGrpcAuthzTransformer.grpcGrantToGrant), + grants: response.grants.map(ChainGrpcAuthZTransformer.grpcGrantToGrant), } } } diff --git a/packages/sdk-ts/src/client/chain/transformers/index.ts b/packages/sdk-ts/src/client/chain/transformers/index.ts index eacce628c..0fe89735f 100644 --- a/packages/sdk-ts/src/client/chain/transformers/index.ts +++ b/packages/sdk-ts/src/client/chain/transformers/index.ts @@ -1,4 +1,6 @@ export * from './ChainGrpcAuctionTransformer' +export * from './ChainGrpcAuthTransformer' +export * from './ChainGrpcAuthZTransformer' export * from './ChainGrpcBankTransformer' export * from './ChainGrpcDistributionTransformer' export * from './ChainGrpcExchangeTransformer' diff --git a/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcMitoApi.ts b/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcMitoApi.ts index d5d6ac7cb..cc6a58a6d 100644 --- a/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcMitoApi.ts +++ b/packages/sdk-ts/src/client/indexer/grpc/IndexerGrpcMitoApi.ts @@ -626,9 +626,13 @@ export class IndexerGrpcMitoApi extends BaseGrpcConsumer { } } - async fetchMissionLeaderboard() { + async fetchMissionLeaderboard(userAddress?: string) { const request = MitoApi.MissionLeaderboardRequest.create() + if (userAddress) { + request.userAddress = userAddress + } + try { const response = await this.retry( () => this.client.MissionLeaderboard(request), diff --git a/packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcMitoTransformer.ts b/packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcMitoTransformer.ts index 85a7d78bc..60cb00d9f 100644 --- a/packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcMitoTransformer.ts +++ b/packages/sdk-ts/src/client/indexer/transformers/IndexerGrpcMitoTransformer.ts @@ -412,6 +412,7 @@ export class IndexerGrpcMitoTransformer { IndexerGrpcMitoTransformer.mitoMissionLeaderboardEntryToMissionLeaderboardEntry, ), updatedAt: parseInt(response.updatedAt, 10), + rank: response.userRank, } } } diff --git a/packages/sdk-ts/src/client/indexer/types/explorer-rest.ts b/packages/sdk-ts/src/client/indexer/types/explorer-rest.ts index b151b203c..445f9bac6 100644 --- a/packages/sdk-ts/src/client/indexer/types/explorer-rest.ts +++ b/packages/sdk-ts/src/client/indexer/types/explorer-rest.ts @@ -10,6 +10,7 @@ export enum AccessTypeCode { AccessTypeNobody = 1, AccessTypeOnlyAddress = 2, AccessTypeEverybody = 3, + AccessTypeAnyOfAddresses = 4, } export enum AccessType { @@ -17,6 +18,7 @@ export enum AccessType { AccessTypeNobody = 'Nobody', AccessTypeOnlyAddress = 'Only Address', AccessTypeEverybody = 'Everybody', + AccessTypeAnyOfAddresses = 'Any of Addresses', } export interface Paging { diff --git a/packages/sdk-ts/src/client/indexer/types/mito.ts b/packages/sdk-ts/src/client/indexer/types/mito.ts index a082abda2..1cba05a81 100644 --- a/packages/sdk-ts/src/client/indexer/types/mito.ts +++ b/packages/sdk-ts/src/client/indexer/types/mito.ts @@ -166,6 +166,7 @@ export interface MitoMissionLeaderboardEntry { export interface MitoMissionLeaderboard { entries: MitoMissionLeaderboardEntry[] updatedAt: number + rank?: string } export type GrpcMitoVault = MitoApi.Vault diff --git a/packages/sdk-ts/src/utils/pagination.ts b/packages/sdk-ts/src/utils/pagination.ts index d0780ba70..a132e94d5 100644 --- a/packages/sdk-ts/src/utils/pagination.ts +++ b/packages/sdk-ts/src/utils/pagination.ts @@ -55,11 +55,15 @@ export const generatePagination = ( } export const paginationUint8ArrayToString = (key: any) => { + if (!key) { + return '' + } + if (key.constructor !== Uint8Array) { return key as string } - return new TextDecoder().decode(key) + return Buffer.from(key).toString('base64') } export const pageResponseToPagination = ({ diff --git a/packages/sdk-ui-ts/CHANGELOG.md b/packages/sdk-ui-ts/CHANGELOG.md index 146c185b6..883005ce0 100644 --- a/packages/sdk-ui-ts/CHANGELOG.md +++ b/packages/sdk-ui-ts/CHANGELOG.md @@ -3,6 +3,30 @@ 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.76](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/sdk-ui-ts@1.12.0-beta.75...@injectivelabs/sdk-ui-ts@1.12.0-beta.76) (2023-08-10) + +**Note:** Version bump only for package @injectivelabs/sdk-ui-ts + +# [1.12.0-beta.75](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/sdk-ui-ts@1.12.0-beta.74...@injectivelabs/sdk-ui-ts@1.12.0-beta.75) (2023-08-09) + +**Note:** Version bump only for package @injectivelabs/sdk-ui-ts + +# [1.12.0-beta.74](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/sdk-ui-ts@1.12.0-beta.73...@injectivelabs/sdk-ui-ts@1.12.0-beta.74) (2023-08-09) + +**Note:** Version bump only for package @injectivelabs/sdk-ui-ts + +# [1.12.0-beta.73](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/sdk-ui-ts@1.12.0-beta.72...@injectivelabs/sdk-ui-ts@1.12.0-beta.73) (2023-08-08) + +**Note:** Version bump only for package @injectivelabs/sdk-ui-ts + +# [1.12.0-beta.72](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/sdk-ui-ts@1.12.0-beta.71...@injectivelabs/sdk-ui-ts@1.12.0-beta.72) (2023-08-08) + +**Note:** Version bump only for package @injectivelabs/sdk-ui-ts + +# [1.12.0-beta.71](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/sdk-ui-ts@1.12.0-beta.70...@injectivelabs/sdk-ui-ts@1.12.0-beta.71) (2023-08-08) + +**Note:** Version bump only for package @injectivelabs/sdk-ui-ts + # [1.12.0-beta.70](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/sdk-ui-ts@1.12.0-beta.69...@injectivelabs/sdk-ui-ts@1.12.0-beta.70) (2023-08-06) **Note:** Version bump only for package @injectivelabs/sdk-ui-ts diff --git a/packages/sdk-ui-ts/package.json b/packages/sdk-ui-ts/package.json index a9459e3ab..20ef79219 100644 --- a/packages/sdk-ui-ts/package.json +++ b/packages/sdk-ui-ts/package.json @@ -1,7 +1,7 @@ { "name": "@injectivelabs/sdk-ui-ts", "description": "SDK in TypeScript for building Injective UI applications in a browser environment.", - "version": "1.12.0-beta.70", + "version": "1.12.0-beta.76", "sideEffects": false, "license": "Apache-2.0", "author": { @@ -34,14 +34,14 @@ "validators-logo:update-all": "ts-node-dev --ignore-watch=validators-logo ./src/validators-logo --update:all && yarn copy-files" }, "dependencies": { - "@injectivelabs/contracts": "^1.12.0-beta.15", - "@injectivelabs/exceptions": "^1.12.0-beta.11", - "@injectivelabs/networks": "^1.12.0-beta.15", - "@injectivelabs/sdk-ts": "^1.12.0-beta.65", - "@injectivelabs/token-metadata": "^1.12.0-beta.34", - "@injectivelabs/token-utils": "^1.12.0-beta.15", + "@injectivelabs/contracts": "^1.12.0-beta.16", + "@injectivelabs/exceptions": "^1.12.0-beta.12", + "@injectivelabs/networks": "^1.12.0-beta.16", + "@injectivelabs/sdk-ts": "^1.12.0-beta.69", + "@injectivelabs/token-metadata": "^1.12.0-beta.35", + "@injectivelabs/token-utils": "^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", "alchemy-sdk": "^2.6.3", "copyfiles": "^2.4.1", "link-module-alias": "^1.2.0", diff --git a/packages/sdk-ui-ts/src/utils/helpers.ts b/packages/sdk-ui-ts/src/utils/helpers.ts index 8f77d37cd..d59e2b71b 100644 --- a/packages/sdk-ui-ts/src/utils/helpers.ts +++ b/packages/sdk-ui-ts/src/utils/helpers.ts @@ -51,6 +51,6 @@ export const getValidatorLogoWithVendorPathPrefix = ( 'vendor', '@injectivelabs', 'sdk-ui-ts', - validatorLogoPath ? validatorLogoPath : 'injective.webp', + validatorLogoPath ? validatorLogoPath : 'untracked.png', ) } diff --git a/packages/sdk-ui-ts/src/utils/mappings.ts b/packages/sdk-ui-ts/src/utils/mappings.ts index ecd4d3170..1bc87703d 100644 --- a/packages/sdk-ui-ts/src/utils/mappings.ts +++ b/packages/sdk-ui-ts/src/utils/mappings.ts @@ -319,4 +319,6 @@ export const validatorAddressToPathMap = { 'injvaloper19a77dzm2lrxt2gehqca3nyzq077kq7qsgvmrp4.webp', injvaloper19a77dzm2lrxt2gehqca3nyzq077kq7qsgvmrp4: 'injvaloper19a77dzm2lrxt2gehqca3nyzq077kq7qsgvmrp4.webp', + injvaloper1axd525a65ly3p878g3hcqw7ykhas0rmk8ws3na: + 'injvaloper1axd525a65ly3p878g3hcqw7ykhas0rmk8ws3na.jpeg', } as Record diff --git a/packages/sdk-ui-ts/src/validators-logo/images/injvaloper10pe4avat38u38yzj5hvnw235uecfff6c73s8fn.jpg b/packages/sdk-ui-ts/src/validators-logo/images/injvaloper10pe4avat38u38yzj5hvnw235uecfff6c73s8fn.jpg new file mode 100644 index 000000000..c53223a3e Binary files /dev/null and b/packages/sdk-ui-ts/src/validators-logo/images/injvaloper10pe4avat38u38yzj5hvnw235uecfff6c73s8fn.jpg differ diff --git a/packages/sdk-ui-ts/src/validators-logo/images/injvaloper19a77dzm2lrxt2gehqca3nyzq077kq7qsgvmrp4.jpg b/packages/sdk-ui-ts/src/validators-logo/images/injvaloper19a77dzm2lrxt2gehqca3nyzq077kq7qsgvmrp4.jpg index c14585cc1..f10200185 100644 Binary files a/packages/sdk-ui-ts/src/validators-logo/images/injvaloper19a77dzm2lrxt2gehqca3nyzq077kq7qsgvmrp4.jpg and b/packages/sdk-ui-ts/src/validators-logo/images/injvaloper19a77dzm2lrxt2gehqca3nyzq077kq7qsgvmrp4.jpg differ diff --git a/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1axd525a65ly3p878g3hcqw7ykhas0rmk8ws3na.jpeg b/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1axd525a65ly3p878g3hcqw7ykhas0rmk8ws3na.jpeg new file mode 100644 index 000000000..e02b85b6b Binary files /dev/null and b/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1axd525a65ly3p878g3hcqw7ykhas0rmk8ws3na.jpeg differ diff --git a/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1fqrdtx7pyps6eytn3356j9cs4f8zl0eevlt3rt.jpg b/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1fqrdtx7pyps6eytn3356j9cs4f8zl0eevlt3rt.jpg index 2d13bc5ce..d2d1419db 100644 Binary files a/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1fqrdtx7pyps6eytn3356j9cs4f8zl0eevlt3rt.jpg and b/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1fqrdtx7pyps6eytn3356j9cs4f8zl0eevlt3rt.jpg differ diff --git a/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1r4lvwh0pmkmjewa76rem7ndr0z8zg3pseyfpux.jpg b/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1r4lvwh0pmkmjewa76rem7ndr0z8zg3pseyfpux.jpg index fc08aa323..6a6500068 100644 Binary files a/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1r4lvwh0pmkmjewa76rem7ndr0z8zg3pseyfpux.jpg and b/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1r4lvwh0pmkmjewa76rem7ndr0z8zg3pseyfpux.jpg differ diff --git a/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1zjjw8p4llg4uee4hqwe04kat4haf734wegcr24.jpg b/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1zjjw8p4llg4uee4hqwe04kat4haf734wegcr24.jpg index ebffc575e..682eebadc 100644 Binary files a/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1zjjw8p4llg4uee4hqwe04kat4haf734wegcr24.jpg and b/packages/sdk-ui-ts/src/validators-logo/images/injvaloper1zjjw8p4llg4uee4hqwe04kat4haf734wegcr24.jpg differ diff --git a/packages/sdk-ui-ts/src/validators-logo/images/untracked.png b/packages/sdk-ui-ts/src/validators-logo/images/untracked.png new file mode 100644 index 000000000..ac9f27cbe Binary files /dev/null and b/packages/sdk-ui-ts/src/validators-logo/images/untracked.png differ diff --git a/packages/sdk-ui-ts/src/validators-logo/mappings.json b/packages/sdk-ui-ts/src/validators-logo/mappings.json index 47b21fa0c..89a4ed2bf 100644 --- a/packages/sdk-ui-ts/src/validators-logo/mappings.json +++ b/packages/sdk-ui-ts/src/validators-logo/mappings.json @@ -74,5 +74,11 @@ "injvaloper1x5y65hgngh77sxta6s2vpjnfjep3ltllkh44le": "injvaloper1x5y65hgngh77sxta6s2vpjnfjep3ltllkh44le.jpg", "injvaloper1wh9a7f05yf4nqkmh7d9lyletzhefaa53txynrj": "injvaloper1wh9a7f05yf4nqkmh7d9lyletzhefaa53txynrj.jpg", "injvaloper1hkjsxadg0a0dj5pwdyfnf8qm0az6wcxcwhdnry": "injvaloper1hkjsxadg0a0dj5pwdyfnf8qm0az6wcxcwhdnry.jpg", - "injvaloper1p66ez0ywzssuq26f7056mx3ydgvkfqw8lf93e8": "injvaloper1p66ez0ywzssuq26f7056mx3ydgvkfqw8lf93e8.jpg" + "injvaloper1p66ez0ywzssuq26f7056mx3ydgvkfqw8lf93e8": "injvaloper1p66ez0ywzssuq26f7056mx3ydgvkfqw8lf93e8.jpg", + "injvaloper1x2k4l6k57c2rqhyzdef6y9galutn7psegeqylz": "injvaloper1x2k4l6k57c2rqhyzdef6y9galutn7psegeqylz.jpg", + "injvaloper10pe4avat38u38yzj5hvnw235uecfff6c73s8fn": "injvaloper10pe4avat38u38yzj5hvnw235uecfff6c73s8fn.jpg", + "injvaloper1sgcawjmfm7q7rmfdwfuaxxpk806jq96kqswv83": "injvaloper1sgcawjmfm7q7rmfdwfuaxxpk806jq96kqswv83.jpg", + "injvaloper13gq4msx4z03ye5gef35yjz9nqtg6ja2yqj6csq": "injvaloper13gq4msx4z03ye5gef35yjz9nqtg6ja2yqj6csq.jpg", + "injvaloper1hq35mlvs2z6j9vz743fyj8krk4rfm929mus55p": "injvaloper1hq35mlvs2z6j9vz743fyj8krk4rfm929mus55p.jpg", + "injvaloper1e8gk2jyfn0vwr3ewk02lfjluvxhxsd7k9qn7nx": "injvaloper1e8gk2jyfn0vwr3ewk02lfjluvxhxsd7k9qn7nx.jpg" } \ No newline at end of file diff --git a/packages/token-metadata/CHANGELOG.md b/packages/token-metadata/CHANGELOG.md index 1dfdf10ad..fdfa914e8 100644 --- a/packages/token-metadata/CHANGELOG.md +++ b/packages/token-metadata/CHANGELOG.md @@ -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.35](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/token-metadata@1.12.0-beta.34...@injectivelabs/token-metadata@1.12.0-beta.35) (2023-08-09) + +**Note:** Version bump only for package @injectivelabs/token-metadata + # [1.12.0-beta.34](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/token-metadata@1.12.0-beta.33...@injectivelabs/token-metadata@1.12.0-beta.34) (2023-08-06) **Note:** Version bump only for package @injectivelabs/token-metadata diff --git a/packages/token-metadata/package.json b/packages/token-metadata/package.json index 80d983dd8..5d01ab8fa 100644 --- a/packages/token-metadata/package.json +++ b/packages/token-metadata/package.json @@ -1,7 +1,7 @@ { "name": "@injectivelabs/token-metadata", "description": "ERC20 token metadata. Name, symbol, decimals, etc.", - "version": "1.12.0-beta.34", + "version": "1.12.0-beta.35", "sideEffects": false, "license": "Apache-2.0", "author": { @@ -32,10 +32,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", "@types/lodash.values": "^4.3.6", "copyfiles": "^2.4.1", "jsonschema": "^1.4.0", diff --git a/packages/token-utils/CHANGELOG.md b/packages/token-utils/CHANGELOG.md index 44ae54aec..fffe80c6f 100644 --- a/packages/token-utils/CHANGELOG.md +++ b/packages/token-utils/CHANGELOG.md @@ -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/token-utils@1.12.0-beta.15...@injectivelabs/token-utils@1.12.0-beta.16) (2023-08-09) + +**Note:** Version bump only for package @injectivelabs/token-utils + # [1.12.0-beta.15](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/token-utils@1.12.0-beta.14...@injectivelabs/token-utils@1.12.0-beta.15) (2023-08-06) **Note:** Version bump only for package @injectivelabs/token-utils diff --git a/packages/token-utils/package.json b/packages/token-utils/package.json index 16d394f22..c04899b8c 100644 --- a/packages/token-utils/package.json +++ b/packages/token-utils/package.json @@ -1,6 +1,6 @@ { "name": "@injectivelabs/token-utils", - "version": "1.12.0-beta.15", + "version": "1.12.0-beta.16", "description": "Token Utils is a package for querying different data about tokens", "sideEffects": false, "author": { @@ -30,8 +30,8 @@ "start": "node dist/index.js" }, "dependencies": { - "@injectivelabs/exceptions": "^1.12.0-beta.11", - "@injectivelabs/utils": "^1.12.0-beta.15", + "@injectivelabs/exceptions": "^1.12.0-beta.12", + "@injectivelabs/utils": "^1.12.0-beta.16", "link-module-alias": "^1.2.0", "shx": "^0.3.2" }, diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 5287f4c95..3691ef6a7 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -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/utils@1.12.0-beta.15...@injectivelabs/utils@1.12.0-beta.16) (2023-08-09) + +**Note:** Version bump only for package @injectivelabs/utils + # [1.12.0-beta.15](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/utils@1.12.0-beta.14...@injectivelabs/utils@1.12.0-beta.15) (2023-08-06) **Note:** Version bump only for package @injectivelabs/utils diff --git a/packages/utils/package.json b/packages/utils/package.json index 32fb0273c..f00d60129 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,7 +1,7 @@ { "name": "@injectivelabs/utils", "description": "List of utils and helper functions that can be reused throughout Injective's projects.", - "version": "1.12.0-beta.15", + "version": "1.12.0-beta.16", "sideEffects": false, "author": { "name": "Bojan Angjelkoski", @@ -31,7 +31,7 @@ "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", "axios": "^0.21.1", "bignumber.js": "^9.0.1", diff --git a/packages/wallet-ts/CHANGELOG.md b/packages/wallet-ts/CHANGELOG.md index 52cc8e77e..ab712ab01 100644 --- a/packages/wallet-ts/CHANGELOG.md +++ b/packages/wallet-ts/CHANGELOG.md @@ -3,6 +3,44 @@ 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.76](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/wallet-ts@1.12.0-beta.75...@injectivelabs/wallet-ts@1.12.0-beta.76) (2023-08-10) + +**Note:** Version bump only for package @injectivelabs/wallet-ts + +# [1.12.0-beta.75](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/wallet-ts@1.12.0-beta.74...@injectivelabs/wallet-ts@1.12.0-beta.75) (2023-08-09) + +**Note:** Version bump only for package @injectivelabs/wallet-ts + +# [1.12.0-beta.74](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/wallet-ts@1.12.0-beta.73...@injectivelabs/wallet-ts@1.12.0-beta.74) (2023-08-09) + +### Bug Fixes + +- provider init for trust and metamask ([ed11db1](https://github.com/InjectiveLabs/injective-ts/commit/ed11db151df8bf71dbf01058410256e6eb5b2379)) + +# [1.12.0-beta.73](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/wallet-ts@1.12.0-beta.72...@injectivelabs/wallet-ts@1.12.0-beta.73) (2023-08-09) + +### Bug Fixes + +- import path on window object ([28463b0](https://github.com/InjectiveLabs/injective-ts/commit/28463b0f55beb6a5e1706e33e63afdd24911fefd)) + +# [1.12.0-beta.72](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/wallet-ts@1.12.0-beta.71...@injectivelabs/wallet-ts@1.12.0-beta.72) (2023-08-09) + +**Note:** Version bump only for package @injectivelabs/wallet-ts + +# [1.12.0-beta.71](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/wallet-ts@1.12.0-beta.70...@injectivelabs/wallet-ts@1.12.0-beta.71) (2023-08-09) + +**Note:** Version bump only for package @injectivelabs/wallet-ts + +# [1.12.0-beta.70](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/wallet-ts@1.12.0-beta.69...@injectivelabs/wallet-ts@1.12.0-beta.70) (2023-08-09) + +### Features + +- added trust wallet ([47bae16](https://github.com/InjectiveLabs/injective-ts/commit/47bae16f3a49f075a5733d5170c315c2f411bef3)) + +# [1.12.0-beta.69](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/wallet-ts@1.12.0-beta.68...@injectivelabs/wallet-ts@1.12.0-beta.69) (2023-08-08) + +**Note:** Version bump only for package @injectivelabs/wallet-ts + # [1.12.0-beta.68](https://github.com/InjectiveLabs/injective-ts/compare/@injectivelabs/wallet-ts@1.12.0-beta.67...@injectivelabs/wallet-ts@1.12.0-beta.68) (2023-08-06) **Note:** Version bump only for package @injectivelabs/wallet-ts diff --git a/packages/wallet-ts/package.json b/packages/wallet-ts/package.json index 796820abf..7a28830dd 100644 --- a/packages/wallet-ts/package.json +++ b/packages/wallet-ts/package.json @@ -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.12.0-beta.68", + "version": "1.12.0-beta.76", "sideEffects": false, "author": { "name": "Bojan Angjelkoski", @@ -37,18 +37,17 @@ "@cosmostation/extension-client": "^0.1.15", "@ethereumjs/common": "^3.1.1", "@ethereumjs/tx": "^4.1.1", - "@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", "@keplr-wallet/cosmos": "^0.11.58", "@keplr-wallet/types": "^0.11.58", "@ledgerhq/hw-app-eth": "6.33.2", "@ledgerhq/hw-transport": "6.28.3", "@ledgerhq/hw-transport-webhid": "6.27.14", "@ledgerhq/hw-transport-webusb": "6.27.14", - "@metamask/detect-provider": "^2.0.0", "@metamask/eth-sig-util": "^4.0.0", "@solana/wallet-adapter-wallets": "^0.19.5", "@toruslabs/torus-embed": "^1.39.0", diff --git a/packages/wallet-ts/src/strategies/wallet-strategy/WalletStrategy.ts b/packages/wallet-ts/src/strategies/wallet-strategy/WalletStrategy.ts index 7d6959f36..9eee90430 100644 --- a/packages/wallet-ts/src/strategies/wallet-strategy/WalletStrategy.ts +++ b/packages/wallet-ts/src/strategies/wallet-strategy/WalletStrategy.ts @@ -7,6 +7,7 @@ import { DirectSignResponse } from '@cosmjs/proto-signing' import { GeneralException, WalletException } from '@injectivelabs/exceptions' import { TxRaw, TxResponse } from '@injectivelabs/sdk-ts' import Metamask from './strategies/Metamask' +import TrustWallet from './strategies/TrustWallet' import { ConcreteWalletStrategy, onAccountChangeCallback, @@ -83,6 +84,8 @@ const createStrategy = ({ switch (wallet) { case Wallet.Metamask: return new Metamask(ethWalletArgs) + case Wallet.TrustWallet: + return new TrustWallet(ethWalletArgs) case Wallet.Ledger: return new LedgerLive(ethWalletArgs) case Wallet.LedgerLegacy: @@ -239,7 +242,10 @@ export default class WalletStrategy { return this.getStrategy().signCosmosTransaction(transaction) } - public async signArbitrary(signer: string, data: string | Uint8Array): Promise { + public async signArbitrary( + signer: string, + data: string | Uint8Array, + ): Promise { if (this.getStrategy().signArbitrary) { return this.getStrategy().signArbitrary!(signer, data) } diff --git a/packages/wallet-ts/src/strategies/wallet-strategy/strategies/Metamask.ts b/packages/wallet-ts/src/strategies/wallet-strategy/strategies/Metamask/index.ts similarity index 79% rename from packages/wallet-ts/src/strategies/wallet-strategy/strategies/Metamask.ts rename to packages/wallet-ts/src/strategies/wallet-strategy/strategies/Metamask/index.ts index 6c3f251e5..3e0c14f97 100644 --- a/packages/wallet-ts/src/strategies/wallet-strategy/strategies/Metamask.ts +++ b/packages/wallet-ts/src/strategies/wallet-strategy/strategies/Metamask/index.ts @@ -1,46 +1,34 @@ /* eslint-disable class-methods-use-this */ import { sleep } from '@injectivelabs/utils' import { - AccountAddress, ChainId, + AccountAddress, EthereumChainId, } from '@injectivelabs/ts-types' import { - WalletException, ErrorType, + WalletException, MetamaskException, UnspecifiedErrorCode, TransactionException, } from '@injectivelabs/exceptions' import { DirectSignResponse } from '@cosmjs/proto-signing' +import { TxRaw, toUtf8, TxGrpcApi, TxResponse } from '@injectivelabs/sdk-ts' import { - TxGrpcApi, - TxRaw, - TxResponse, - isServerSide, - toUtf8, -} from '@injectivelabs/sdk-ts' -import { ConcreteWalletStrategy, EthereumWalletStrategyArgs } from '../../types' -import { - Eip1993ProviderWithMetamask, - WindowWithEip1193Provider, -} from '../types' -import BaseConcreteStrategy from './Base' -import { WalletAction, WalletDeviceType } from '../../../types/enums' - -const $window = (isServerSide() - ? {} - : window) as unknown as WindowWithEip1193Provider + ConcreteWalletStrategy, + EthereumWalletStrategyArgs, +} from '../../../types' +import { BrowserEip1993Provider } from '../../types' +import BaseConcreteStrategy from '../Base' +import { WalletAction, WalletDeviceType } from '../../../../types/enums' +import { getMetamaskProvider } from './utils' export default class Metamask extends BaseConcreteStrategy implements ConcreteWalletStrategy { - private ethereum: Eip1993ProviderWithMetamask - constructor(args: EthereumWalletStrategyArgs) { super(args) - this.ethereum = $window.ethereum } async getWalletDeviceType(): Promise { @@ -48,7 +36,7 @@ export default class Metamask } async getAddresses(): Promise { - const ethereum = this.getEthereum() + const ethereum = await this.getEthereum() try { return await ethereum.request({ @@ -76,7 +64,7 @@ export default class Metamask transaction: unknown, _options: { address: AccountAddress; ethereumChainId: EthereumChainId }, ): Promise { - const ethereum = this.getEthereum() + const ethereum = await this.getEthereum() try { return await ethereum.request({ @@ -140,7 +128,7 @@ export default class Metamask eip712json: string, address: AccountAddress, ): Promise { - const ethereum = this.getEthereum() + const ethereum = await this.getEthereum() try { return await ethereum.request({ @@ -177,7 +165,7 @@ export default class Metamask signer: AccountAddress, data: string | Uint8Array, ): Promise { - const ethereum = this.getEthereum() + const ethereum = await this.getEthereum() try { const signature = await ethereum.request({ @@ -196,7 +184,7 @@ export default class Metamask } async getEthereumChainId(): Promise { - const ethereum = this.getEthereum() + const ethereum = await this.getEthereum() try { return ethereum.request({ method: 'eth_chainId' }) @@ -210,7 +198,7 @@ export default class Metamask } async getEthereumTransactionReceipt(txHash: string): Promise { - const ethereum = this.getEthereum() + const ethereum = await this.getEthereum() const interval = 1000 const transactionReceiptRetry = async () => { @@ -245,54 +233,30 @@ export default class Metamask ) } - onChainIdChanged(callback: () => void): void { - const { ethereum } = this - - if (!ethereum) { - return - } - - ethereum.on('chainChanged', callback) + onChainIdChanged(_callback: () => void): void { + // } - onAccountChange(callback: (account: AccountAddress) => void): void { - const { ethereum } = this - - if (!ethereum) { - return - } - - ethereum.on('accountsChanged', callback) + onAccountChange(_callback: (account: AccountAddress) => void): void { + // } cancelOnChainIdChange(): void { - const { ethereum } = this - - if (ethereum) { - // ethereum.removeListener('chainChanged', handler) - } + // } cancelOnAccountChange(): void { - const { ethereum } = this - - if (ethereum) { - // ethereum.removeListener('chainChanged', handler) - } + // } cancelAllEvents(): void { - const { ethereum } = this - - if (ethereum) { - ethereum.removeAllListeners() - } + // } - private getEthereum(): Eip1993ProviderWithMetamask { - const { ethereum } = this + private async getEthereum(): Promise { + const provider = await getMetamaskProvider() - if (!ethereum) { + if (!provider) { throw new MetamaskException( new Error('Please install the Metamask wallet extension.'), { @@ -303,6 +267,6 @@ export default class Metamask ) } - return ethereum + return provider } } diff --git a/packages/wallet-ts/src/strategies/wallet-strategy/strategies/Metamask/utils.ts b/packages/wallet-ts/src/strategies/wallet-strategy/strategies/Metamask/utils.ts new file mode 100644 index 000000000..a9872eed4 --- /dev/null +++ b/packages/wallet-ts/src/strategies/wallet-strategy/strategies/Metamask/utils.ts @@ -0,0 +1,62 @@ +import { isServerSide } from '@injectivelabs/sdk-ts' +import { BrowserEip1993Provider, WindowWithEip1193Provider } from '../../types' + +const $window = (isServerSide() + ? {} + : window) as unknown as WindowWithEip1193Provider + +export async function getMetamaskProvider({ timeout } = { timeout: 3000 }) { + const provider = getMetamaskFromWindow() + + if (provider) { + return provider + } + + return listenForMetamaskInitialized({ + timeout, + }) as Promise +} + +async function listenForMetamaskInitialized({ timeout } = { timeout: 3000 }) { + return new Promise((resolve) => { + const handleInitialization = () => { + resolve(getMetamaskFromWindow()) + } + + $window.addEventListener('ethereum#initialized', handleInitialization, { + once: true, + }) + + setTimeout(() => { + $window.removeEventListener('ethereum#initialized', handleInitialization) + resolve(null) + }, timeout) + }) +} + +function getMetamaskFromWindow() { + const isMetamask = (ethereum: BrowserEip1993Provider) => { + // Identify if Metamask Wallet injected provider is present. + const metamask = !!ethereum.isMetaMask + + return metamask + } + + const injectedProviderExist = + typeof window !== 'undefined' && typeof $window.ethereum !== 'undefined' + + // No injected providers exist. + if (!injectedProviderExist) { + return null + } + + if (isMetamask($window.ethereum)) { + return $window.ethereum + } + + if ($window.providers) { + return $window.providers.find(isMetamask) ?? null + } + + return null +} diff --git a/packages/wallet-ts/src/strategies/wallet-strategy/strategies/TrustWallet/index.ts b/packages/wallet-ts/src/strategies/wallet-strategy/strategies/TrustWallet/index.ts new file mode 100644 index 000000000..983662f18 --- /dev/null +++ b/packages/wallet-ts/src/strategies/wallet-strategy/strategies/TrustWallet/index.ts @@ -0,0 +1,272 @@ +/* eslint-disable class-methods-use-this */ +import { sleep } from '@injectivelabs/utils' +import { + ChainId, + AccountAddress, + EthereumChainId, +} from '@injectivelabs/ts-types' +import { + ErrorType, + WalletException, + TrustWalletException, + UnspecifiedErrorCode, + TransactionException, +} from '@injectivelabs/exceptions' +import { DirectSignResponse } from '@cosmjs/proto-signing' +import { TxRaw, toUtf8, TxGrpcApi, TxResponse } from '@injectivelabs/sdk-ts' +import { + ConcreteWalletStrategy, + EthereumWalletStrategyArgs, +} from '../../../types' +import { BrowserEip1993Provider } from '../../types' +import BaseConcreteStrategy from './../Base' +import { WalletAction, WalletDeviceType } from '../../../../types/enums' +import { getTrustWalletProvider } from './utils' + +export default class TrustWallet + extends BaseConcreteStrategy + implements ConcreteWalletStrategy +{ + constructor(args: EthereumWalletStrategyArgs) { + super(args) + } + + async getWalletDeviceType(): Promise { + return Promise.resolve(WalletDeviceType.Browser) + } + + async getAddresses(): Promise { + const ethereum = await this.getEthereum() + + try { + return await ethereum.request({ + method: 'eth_requestAccounts', + }) + } catch (e: unknown) { + throw new TrustWalletException(new Error((e as any).message), { + code: UnspecifiedErrorCode, + type: ErrorType.WalletError, + contextModule: WalletAction.GetAccounts, + }) + } + } + + // eslint-disable-next-line class-methods-use-this + async confirm(address: AccountAddress): Promise { + return Promise.resolve( + `0x${Buffer.from( + `Confirmation for ${address} at time: ${Date.now()}`, + ).toString('hex')}`, + ) + } + + async sendEthereumTransaction( + transaction: unknown, + _options: { address: AccountAddress; ethereumChainId: EthereumChainId }, + ): Promise { + const ethereum = await this.getEthereum() + + try { + return await ethereum.request({ + method: 'eth_sendTransaction', + params: [transaction], + }) + } catch (e: unknown) { + throw new TrustWalletException(new Error((e as any).message), { + code: UnspecifiedErrorCode, + type: ErrorType.WalletError, + contextModule: WalletAction.SendEthereumTransaction, + }) + } + } + + async sendTransaction( + transaction: TxRaw, + options: { + address: AccountAddress + chainId: ChainId + endpoints?: { + rest: string + grpc: string + tm?: string + } + }, + ): Promise { + const { endpoints } = options + + if (!endpoints) { + throw new WalletException( + new Error( + 'You have to pass endpoints within the options for using Ethereum native wallets', + ), + ) + } + + const txApi = new TxGrpcApi(endpoints.grpc) + const response = await txApi.broadcast(transaction) + + if (response.code !== 0) { + throw new TransactionException(new Error(response.rawLog), { + code: UnspecifiedErrorCode, + contextCode: response.code, + contextModule: response.codespace, + }) + } + + return response + } + + /** @deprecated */ + async signTransaction( + eip712json: string, + address: AccountAddress, + ): Promise { + return this.signEip712TypedData(eip712json, address) + } + + async signEip712TypedData( + eip712json: string, + address: AccountAddress, + ): Promise { + const ethereum = await this.getEthereum() + + try { + return await ethereum.request({ + method: 'eth_signTypedData_v4', + params: [address, eip712json], + }) + } catch (e: unknown) { + throw new TrustWalletException(new Error((e as any).message), { + code: UnspecifiedErrorCode, + type: ErrorType.WalletError, + contextModule: WalletAction.SignTransaction, + }) + } + } + + // eslint-disable-next-line class-methods-use-this + async signCosmosTransaction(_transaction: { + txRaw: TxRaw + accountNumber: number + chainId: string + address: string + }): Promise { + throw new WalletException( + new Error('This wallet does not support signing Cosmos transactions'), + { + code: UnspecifiedErrorCode, + type: ErrorType.WalletError, + contextModule: WalletAction.SendTransaction, + }, + ) + } + + async signArbitrary( + signer: AccountAddress, + data: string | Uint8Array, + ): Promise { + const ethereum = await this.getEthereum() + + try { + const signature = await ethereum.request({ + method: 'personal_sign', + params: [toUtf8(data), signer], + }) + + return signature + } catch (e: unknown) { + throw new TrustWalletException(new Error((e as any).message), { + code: UnspecifiedErrorCode, + type: ErrorType.WalletError, + contextModule: WalletAction.SignArbitrary, + }) + } + } + + async getEthereumChainId(): Promise { + const ethereum = await this.getEthereum() + + try { + return ethereum.request({ method: 'eth_chainId' }) + } catch (e: unknown) { + throw new TrustWalletException(new Error((e as any).message), { + code: UnspecifiedErrorCode, + type: ErrorType.WalletError, + contextModule: WalletAction.GetChainId, + }) + } + } + + async getEthereumTransactionReceipt(txHash: string): Promise { + const ethereum = await this.getEthereum() + + const interval = 1000 + const transactionReceiptRetry = async () => { + const receipt = await ethereum.request({ + method: 'eth_getTransactionReceipt', + params: [txHash], + }) + + if (!receipt) { + await sleep(interval) + await transactionReceiptRetry() + } + + return receipt + } + + try { + return await transactionReceiptRetry() + } catch (e: unknown) { + throw new TrustWalletException(new Error((e as any).message), { + code: UnspecifiedErrorCode, + type: ErrorType.WalletError, + contextModule: WalletAction.GetEthereumTransactionReceipt, + }) + } + } + + // eslint-disable-next-line class-methods-use-this + async getPubKey(): Promise { + throw new WalletException( + new Error('You can only fetch PubKey from Cosmos native wallets'), + ) + } + + onChainIdChanged(_callback: () => void): void { + // + } + + onAccountChange(_callback: (account: AccountAddress) => void): void { + // + } + + cancelOnChainIdChange(): void { + // + } + + cancelOnAccountChange(): void { + // + } + + cancelAllEvents(): void { + // + } + + private async getEthereum(): Promise { + const provider = await getTrustWalletProvider() + + if (!provider) { + throw new TrustWalletException( + new Error('Please install the TrustWallet wallet extension.'), + { + code: UnspecifiedErrorCode, + type: ErrorType.WalletNotInstalledError, + contextModule: WalletAction.GetAccounts, + }, + ) + } + + return provider + } +} diff --git a/packages/wallet-ts/src/strategies/wallet-strategy/strategies/TrustWallet/utils.ts b/packages/wallet-ts/src/strategies/wallet-strategy/strategies/TrustWallet/utils.ts new file mode 100644 index 000000000..b8e29dfd1 --- /dev/null +++ b/packages/wallet-ts/src/strategies/wallet-strategy/strategies/TrustWallet/utils.ts @@ -0,0 +1,74 @@ +import { isServerSide } from '@injectivelabs/sdk-ts' +import { BrowserEip1993Provider, WindowWithEip1193Provider } from '../../types' + +const $window = (isServerSide() + ? {} + : window) as unknown as WindowWithEip1193Provider + +export async function getTrustWalletProvider({ timeout } = { timeout: 3000 }) { + const provider = getTrustWalletFromWindow() + + if (provider) { + return provider + } + + return listenForTrustWalletInitialized({ + timeout, + }) as Promise +} + +async function listenForTrustWalletInitialized( + { timeout } = { timeout: 3000 }, +) { + return new Promise((resolve) => { + const handleInitialization = () => { + resolve(getTrustWalletFromWindow()) + } + + $window.addEventListener('trustwallet#initialized', handleInitialization, { + once: true, + }) + + setTimeout(() => { + $window.removeEventListener( + 'trustwallet#initialized', + handleInitialization, + ) + resolve(null) + }, timeout) + }) +} + +function getTrustWalletFromWindow() { + const isTrustWallet = (ethereum: BrowserEip1993Provider) => { + // Identify if Trust Wallet injected provider is present. + const trustWallet = !!ethereum.isTrust + + return trustWallet + } + + const injectedProviderExist = + typeof window !== 'undefined' && + (typeof $window.ethereum !== 'undefined' || + typeof $window.trustWallet !== 'undefined') + + // No injected providers exist. + if (!injectedProviderExist) { + return null + } + + if ($window.trustWallet) { + return $window.trustWallet + } + + if (isTrustWallet($window.ethereum)) { + // Trust Wallet was injected into $window.ethereum. + return $window.ethereum + } + + if ($window.providers) { + return $window.providers.find(isTrustWallet) ?? null + } + + return null +} diff --git a/packages/wallet-ts/src/strategies/wallet-strategy/types.ts b/packages/wallet-ts/src/strategies/wallet-strategy/types.ts index 07bf97978..3c8aeaf8c 100644 --- a/packages/wallet-ts/src/strategies/wallet-strategy/types.ts +++ b/packages/wallet-ts/src/strategies/wallet-strategy/types.ts @@ -1,13 +1,16 @@ import Eip1993Provider from 'eip1193-provider' import HDNode from 'hdkey' -export interface Eip1993ProviderWithMetamask extends Eip1993Provider { +export interface BrowserEip1993Provider extends Eip1993Provider { removeAllListeners(): void isMetaMask: boolean + isTrust: boolean } export interface WindowWithEip1193Provider extends Window { - ethereum: Eip1993ProviderWithMetamask + ethereum: BrowserEip1993Provider + providers: BrowserEip1993Provider[] + trustWallet?: BrowserEip1993Provider } export interface WindowWithLedgerSupport extends Window { diff --git a/packages/wallet-ts/src/strategies/wallet-strategy/utils.ts b/packages/wallet-ts/src/strategies/wallet-strategy/utils.ts index 3e2fe9c52..74f39cd52 100644 --- a/packages/wallet-ts/src/strategies/wallet-strategy/utils.ts +++ b/packages/wallet-ts/src/strategies/wallet-strategy/utils.ts @@ -2,9 +2,10 @@ import { Wallet } from '../../types/enums' export const isEthWallet = (wallet: Wallet): boolean => [ - Wallet.Metamask, + Wallet.Trezor, Wallet.Torus, Wallet.Ledger, - Wallet.Trezor, + Wallet.Metamask, + Wallet.TrustWallet, Wallet.CosmostationEth, ].includes(wallet) diff --git a/packages/wallet-ts/src/types/enums.ts b/packages/wallet-ts/src/types/enums.ts index b79fba631..68a5ea661 100644 --- a/packages/wallet-ts/src/types/enums.ts +++ b/packages/wallet-ts/src/types/enums.ts @@ -1,22 +1,23 @@ import { WalletErrorActionModule } from '@injectivelabs/exceptions' export enum Wallet { - Metamask = 'metamask', - Ledger = 'ledger', - LedgerLegacy = 'ledger-legacy', - Trezor = 'trezor', + Leap = 'leap', Keplr = 'keplr', Torus = 'torus', - WalletConnect = 'wallet-connect', - Leap = 'leap', + Ledger = 'ledger', + Trezor = 'trezor', + Metamask = 'metamask', + TrustWallet = 'trust-wallet', Cosmostation = 'cosmostation', + LedgerLegacy = 'ledger-legacy', + WalletConnect = 'wallet-connect', CosmostationEth = 'cosmostation-eth', } export enum WalletDeviceType { + Mobile = 'mobile', Browser = 'browser', Hardware = 'hardware', - Mobile = 'mobile', } export const WalletAction = { ...WalletErrorActionModule } diff --git a/packages/wallet-ts/src/utils/wallets/index.ts b/packages/wallet-ts/src/utils/wallets/index.ts index 474367efb..0676838f1 100644 --- a/packages/wallet-ts/src/utils/wallets/index.ts +++ b/packages/wallet-ts/src/utils/wallets/index.ts @@ -2,3 +2,4 @@ export * from './keplr' export * from './leap' export * from './phantom' export * from './metamask' +export * from './trust-wallet' diff --git a/packages/wallet-ts/src/utils/wallets/metamask/Metamask.ts b/packages/wallet-ts/src/utils/wallets/metamask/Metamask.ts index 95d3a9c85..b555c681c 100644 --- a/packages/wallet-ts/src/utils/wallets/metamask/Metamask.ts +++ b/packages/wallet-ts/src/utils/wallets/metamask/Metamask.ts @@ -1,14 +1,12 @@ import { ethers } from 'ethers' -import detectEthereumProvider from '@metamask/detect-provider' import { WalletException } from '@injectivelabs/exceptions' import { EthereumChainId } from '@injectivelabs/ts-types' -import { Eip1993ProviderWithMetamask } from '../../../strategies/wallet-strategy/types' +import { BrowserEip1993Provider } from '../../../strategies/wallet-strategy/types' +import { getMetamaskProvider } from '../../../strategies/wallet-strategy/strategies/Metamask/utils' export const getEthersProviderFromMetamask = async () => { try { - const provider = await detectEthereumProvider({ - mustBeMetaMask: true, - }) + const provider = (await getMetamaskProvider()) as BrowserEip1993Provider if (!provider) { throw new WalletException(new Error('Please install Metamask Extension')) @@ -22,9 +20,7 @@ export const getEthersProviderFromMetamask = async () => { export const updateMetamaskNetwork = async (chainId: EthereumChainId) => { try { - const provider = (await detectEthereumProvider({ - mustBeMetaMask: true, - })) as Eip1993ProviderWithMetamask + const provider = (await getMetamaskProvider()) as BrowserEip1993Provider if (!provider) { throw new WalletException(new Error('Please install Metamask Extension')) diff --git a/packages/wallet-ts/src/utils/wallets/metamask/index.ts b/packages/wallet-ts/src/utils/wallets/metamask/index.ts index a8bb125ea..b1fc73f52 100644 --- a/packages/wallet-ts/src/utils/wallets/metamask/index.ts +++ b/packages/wallet-ts/src/utils/wallets/metamask/index.ts @@ -1 +1,2 @@ export * from './Metamask' +export * from './../../../strategies/wallet-strategy/strategies/Metamask/utils' diff --git a/packages/wallet-ts/src/utils/wallets/trust-wallet/TrustWallet.ts b/packages/wallet-ts/src/utils/wallets/trust-wallet/TrustWallet.ts new file mode 100644 index 000000000..84778435f --- /dev/null +++ b/packages/wallet-ts/src/utils/wallets/trust-wallet/TrustWallet.ts @@ -0,0 +1,36 @@ +import { WalletException } from '@injectivelabs/exceptions' +import { EthereumChainId } from '@injectivelabs/ts-types' +import { BrowserEip1993Provider } from '../../../strategies/wallet-strategy/types' +import { getTrustWalletProvider } from '../../../strategies/wallet-strategy/strategies/TrustWallet/utils' + +export const updateTrustWalletNetwork = async (chainId: EthereumChainId) => { + try { + const provider = (await getTrustWalletProvider()) as BrowserEip1993Provider + + if (!provider) { + throw new WalletException( + new Error('Please install Trust Wallet Extension'), + ) + } + + const chainIdToHex = chainId.toString(16) + + return await Promise.race([ + provider.request({ + method: 'wallet_switchEthereumChain', + params: [{ chainId: `0x${chainIdToHex}` }], + }), + new Promise((resolve) => + provider.on('change', ({ chain }: any) => { + if (chain?.id === chainIdToHex) { + resolve() + } + }), + ), + ]) + } catch (e) { + throw new WalletException( + new Error('Please update your Trust Wallet network'), + ) + } +} diff --git a/packages/wallet-ts/src/utils/wallets/trust-wallet/index.ts b/packages/wallet-ts/src/utils/wallets/trust-wallet/index.ts new file mode 100644 index 000000000..f86a25706 --- /dev/null +++ b/packages/wallet-ts/src/utils/wallets/trust-wallet/index.ts @@ -0,0 +1,2 @@ +export * from './TrustWallet' +export * from './../../../strategies/wallet-strategy/strategies/TrustWallet/utils' diff --git a/yarn.lock b/yarn.lock index c4e4676de..2f987b9f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2166,10 +2166,10 @@ protobufjs "^7.0.0" rxjs "^7.4.0" -"@injectivelabs/mito-proto-ts@1.0.28": - version "1.0.28" - resolved "https://registry.yarnpkg.com/@injectivelabs/mito-proto-ts/-/mito-proto-ts-1.0.28.tgz#32e55773dee01c6d5ec728666ae05b9bbf4139c7" - integrity sha512-zehX9H7wJZoFNyXeJsCi0Y+cFuhNt5YbAmA7Lj4GmRH/OIRxNvrscI4V5/N/T6BkWd4M/6ZK8ADPCNfkIGtY9Q== +"@injectivelabs/mito-proto-ts@1.0.32": + version "1.0.32" + resolved "https://registry.yarnpkg.com/@injectivelabs/mito-proto-ts/-/mito-proto-ts-1.0.32.tgz#cc7e7a568e7414bd02b49603919ce8490cf934b8" + integrity sha512-g6yFFpPDGnw7E2cY22cexyAV0cNw0uaU2Xf43JXCvSVklA8ibq+DsCJ89fOXt19Juje+0rrWDmkmFLFXGIhVlA== dependencies: "@injectivelabs/grpc-web" "^0.0.1" google-protobuf "^3.14.0" @@ -2870,11 +2870,6 @@ write-pkg "4.0.0" yargs "16.2.0" -"@metamask/detect-provider@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@metamask/detect-provider/-/detect-provider-2.0.0.tgz#4bc2795e5e6f7d8b84b2e845058d2f222c99917d" - integrity sha512-sFpN+TX13E9fdBDh9lvQeZdJn4qYoRb/6QF2oZZK/Pn559IhCFacPMU1rMuqyXoFQF3JSJfii2l98B87QDPeCQ== - "@metamask/eth-sig-util@^4.0.0": version "4.0.1" resolved "https://registry.npmjs.org/@metamask/eth-sig-util/-/eth-sig-util-4.0.1.tgz#3ad61f6ea9ad73ba5b19db780d40d9aae5157088"