@injectivelabs/wallet-turnkey 1.19.23 → 1.19.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -823,12 +823,25 @@ var TurnkeyWalletStrategy = class extends __injectivelabs_wallet_base.BaseConcre
823
823
  contextModule: __injectivelabs_wallet_base.WalletAction.SignTransaction
824
824
  });
825
825
  }
826
- async signArbitrary(_signer, _data) {
827
- throw new __injectivelabs_exceptions.WalletException(/* @__PURE__ */ new Error("This wallet does not support signArbitrary"), {
828
- code: __injectivelabs_exceptions.UnspecifiedErrorCode,
829
- type: __injectivelabs_exceptions.ErrorType.WalletError,
830
- contextModule: __injectivelabs_wallet_base.WalletAction.SignTransaction
831
- });
826
+ async signArbitrary(signer, data) {
827
+ try {
828
+ const turnkeyWallet = await this.getTurnkeyWallet();
829
+ const checksumAddress = (0, viem.getAddress)((0, __injectivelabs_sdk_ts_utils.getEthereumAddress)(signer));
830
+ return await (await getEip1193ProviderForTurnkey(await turnkeyWallet.getOrCreateAndGetAccount(checksumAddress), String(this.evmOptions.evmChainId), {
831
+ rpcUrl: this.evmOptions.rpcUrl,
832
+ rpcUrls: this.evmOptions.rpcUrls
833
+ })).request({
834
+ method: "personal_sign",
835
+ params: [(0, __injectivelabs_sdk_ts_utils.toUtf8)(data), checksumAddress]
836
+ });
837
+ } catch (e) {
838
+ const message = e instanceof Error ? e.message : String(e);
839
+ throw new __injectivelabs_exceptions.WalletException(new Error(message), {
840
+ code: __injectivelabs_exceptions.UnspecifiedErrorCode,
841
+ type: __injectivelabs_exceptions.ErrorType.WalletError,
842
+ contextModule: __injectivelabs_wallet_base.WalletAction.SignArbitrary
843
+ });
844
+ }
832
845
  }
833
846
  async getEthereumChainId() {
834
847
  throw new __injectivelabs_exceptions.CosmosWalletException(/* @__PURE__ */ new Error("getEthereumChainId is not supported on Turnkey wallet"), {
@@ -44,7 +44,7 @@ declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implements Conc
44
44
  address: string;
45
45
  signDoc: StdSignDoc;
46
46
  }): Promise<AminoSignResponse>;
47
- signArbitrary(_signer: AccountAddress, _data: string | Uint8Array): Promise<string>;
47
+ signArbitrary(signer: AccountAddress, data: string | Uint8Array): Promise<string>;
48
48
  getEthereumChainId(): Promise<string>;
49
49
  getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): Promise<Record<string, any>>;
50
50
  getPubKey(): Promise<string>;
@@ -44,7 +44,7 @@ declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implements Conc
44
44
  address: string;
45
45
  signDoc: StdSignDoc;
46
46
  }): Promise<AminoSignResponse>;
47
- signArbitrary(_signer: AccountAddress, _data: string | Uint8Array): Promise<string>;
47
+ signArbitrary(signer: AccountAddress, data: string | Uint8Array): Promise<string>;
48
48
  getEthereumChainId(): Promise<string>;
49
49
  getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): Promise<Record<string, any>>;
50
50
  getPubKey(): Promise<string>;
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getAddress, hashTypedData } from "viem";
2
2
  import { HttpRestClient } from "@injectivelabs/utils";
3
3
  import { TxGrpcApi } from "@injectivelabs/sdk-ts/core/tx";
4
- import { getEthereumAddress, getInjectiveAddress, sha256 } from "@injectivelabs/sdk-ts/utils";
4
+ import { getEthereumAddress, getInjectiveAddress, sha256, toUtf8 } from "@injectivelabs/sdk-ts/utils";
5
5
  import { CosmosWalletException, ErrorType, GeneralException, TransactionException, TurnkeyWalletSessionException, UnspecifiedErrorCode, WalletException } from "@injectivelabs/exceptions";
6
6
  import { BaseConcreteStrategy, TurnkeyProvider, WalletAction, WalletDeviceType, getEvmChainConfig, getViemPublicClient, getViemWalletClient } from "@injectivelabs/wallet-base";
7
7
  import { createAccount } from "@turnkey/viem";
@@ -823,12 +823,25 @@ var TurnkeyWalletStrategy = class extends BaseConcreteStrategy {
823
823
  contextModule: WalletAction.SignTransaction
824
824
  });
825
825
  }
826
- async signArbitrary(_signer, _data) {
827
- throw new WalletException(/* @__PURE__ */ new Error("This wallet does not support signArbitrary"), {
828
- code: UnspecifiedErrorCode,
829
- type: ErrorType.WalletError,
830
- contextModule: WalletAction.SignTransaction
831
- });
826
+ async signArbitrary(signer, data) {
827
+ try {
828
+ const turnkeyWallet = await this.getTurnkeyWallet();
829
+ const checksumAddress = getAddress(getEthereumAddress(signer));
830
+ return await (await getEip1193ProviderForTurnkey(await turnkeyWallet.getOrCreateAndGetAccount(checksumAddress), String(this.evmOptions.evmChainId), {
831
+ rpcUrl: this.evmOptions.rpcUrl,
832
+ rpcUrls: this.evmOptions.rpcUrls
833
+ })).request({
834
+ method: "personal_sign",
835
+ params: [toUtf8(data), checksumAddress]
836
+ });
837
+ } catch (e) {
838
+ const message = e instanceof Error ? e.message : String(e);
839
+ throw new WalletException(new Error(message), {
840
+ code: UnspecifiedErrorCode,
841
+ type: ErrorType.WalletError,
842
+ contextModule: WalletAction.SignArbitrary
843
+ });
844
+ }
832
845
  }
833
846
  async getEthereumChainId() {
834
847
  throw new CosmosWalletException(/* @__PURE__ */ new Error("getEthereumChainId is not supported on Turnkey wallet"), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-turnkey",
3
- "version": "1.19.23",
3
+ "version": "1.19.24",
4
4
  "description": "Turnkey wallet strategy for use with @injectivelabs/wallet-core.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -45,11 +45,11 @@
45
45
  "@turnkey/sdk-browser": "5.16.1",
46
46
  "@turnkey/viem": "0.13.1",
47
47
  "viem": "^2.41.2",
48
- "@injectivelabs/ts-types": "1.19.23",
49
- "@injectivelabs/utils": "1.19.23",
50
- "@injectivelabs/wallet-base": "1.19.23",
51
- "@injectivelabs/exceptions": "1.19.23",
52
- "@injectivelabs/sdk-ts": "1.19.23"
48
+ "@injectivelabs/exceptions": "1.19.24",
49
+ "@injectivelabs/sdk-ts": "1.19.24",
50
+ "@injectivelabs/wallet-base": "1.19.24",
51
+ "@injectivelabs/ts-types": "1.19.24",
52
+ "@injectivelabs/utils": "1.19.24"
53
53
  },
54
54
  "publishConfig": {
55
55
  "access": "public"