@injectivelabs/wallet-turnkey 1.15.43 → 1.16.1-alpha.1

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.
@@ -1,14 +1,14 @@
1
1
  import { TxRaw, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
2
- import { HttpRestClient } from '@injectivelabs/utils';
3
- import { AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
2
+ import { StdSignDoc, WalletDeviceType, type WalletMetadata, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, WalletStrategyEvmOptions, ConcreteEvmWalletStrategyArgs } from '@injectivelabs/wallet-base';
4
3
  import { TurnkeyIframeClient } from '@turnkey/sdk-browser';
5
- import { StdSignDoc, WalletDeviceType, type WalletMetadata, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, WalletStrategyEthereumOptions, ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
4
+ import { HttpRestClient } from '@injectivelabs/utils';
5
+ import { AccountAddress, EvmChainId } from '@injectivelabs/ts-types';
6
6
  import { TurnkeyWallet } from './turnkey/turnkey.js';
7
7
  export declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implements ConcreteWalletStrategy {
8
8
  turnkeyWallet?: TurnkeyWallet;
9
- ethereumOptions: WalletStrategyEthereumOptions;
9
+ evmOptions: WalletStrategyEvmOptions;
10
10
  client: HttpRestClient;
11
- constructor(args: ConcreteEthereumWalletStrategyArgs & {
11
+ constructor(args: ConcreteEvmWalletStrategyArgs & {
12
12
  apiServerEndpoint?: string;
13
13
  });
14
14
  getWalletDeviceType(): Promise<WalletDeviceType>;
@@ -22,7 +22,7 @@ export declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implemen
22
22
  getWalletClient<TurnkeyWallet>(): Promise<TurnkeyWallet>;
23
23
  sendEvmTransaction(transaction: unknown, args: {
24
24
  address: AccountAddress;
25
- ethereumChainId: EthereumChainId;
25
+ evmChainId: EvmChainId;
26
26
  }): Promise<string>;
27
27
  sendTransaction(transaction: TxRaw, options: SendTransactionOptions): Promise<any>;
28
28
  signEip712TypedData(eip712json: string, address: AccountAddress): Promise<string>;
@@ -38,7 +38,7 @@ export declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implemen
38
38
  }): Promise<AminoSignResponse>;
39
39
  signArbitrary(_signer: AccountAddress, _data: string | Uint8Array): Promise<string>;
40
40
  getEthereumChainId(): Promise<string>;
41
- getEvmTransactionReceipt(txHash: string, ethereumChainId?: EthereumChainId): Promise<Record<string, any>>;
41
+ getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): Promise<Record<string, any>>;
42
42
  getPubKey(): Promise<string>;
43
43
  getIframeClient(): Promise<TurnkeyIframeClient>;
44
44
  private getTurnkeyWallet;
@@ -5,15 +5,14 @@ exports.TurnkeyWalletStrategy = void 0;
5
5
  const sdk_ts_1 = require("@injectivelabs/sdk-ts");
6
6
  const exceptions_1 = require("@injectivelabs/exceptions");
7
7
  const viem_1 = require("viem");
8
- const utils_1 = require("@injectivelabs/utils");
9
- const viem_2 = require("viem");
10
8
  const wallet_base_1 = require("@injectivelabs/wallet-base");
9
+ const utils_1 = require("@injectivelabs/utils");
11
10
  const types_js_1 = require("./types.js");
12
11
  const turnkey_js_1 = require("./turnkey/turnkey.js");
13
12
  const consts_js_1 = require("./consts.js");
14
13
  class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
15
14
  turnkeyWallet;
16
- ethereumOptions;
15
+ evmOptions;
17
16
  client;
18
17
  constructor(args) {
19
18
  super(args);
@@ -22,7 +21,7 @@ class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
22
21
  throw new exceptions_1.WalletException(new Error('apiServerEndpoint is required'));
23
22
  }
24
23
  this.client = new utils_1.HttpRestClient(endpoint);
25
- this.ethereumOptions = args.ethereumOptions;
24
+ this.evmOptions = args.evmOptions;
26
25
  }
27
26
  async getWalletDeviceType() {
28
27
  return Promise.resolve(wallet_base_1.WalletDeviceType.Browser);
@@ -92,19 +91,19 @@ class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
92
91
  }
93
92
  async sendEvmTransaction(transaction, args) {
94
93
  try {
95
- const options = this.ethereumOptions;
94
+ const options = this.evmOptions;
96
95
  const turnkeyWallet = await this.getTurnkeyWallet();
97
96
  const organizationId = await this.getOrganizationId();
98
- const chainId = args.ethereumChainId || options.ethereumChainId;
99
- const url = options.rpcUrl || options.rpcUrls?.[args.ethereumChainId];
97
+ const chainId = args.evmChainId || options.evmChainId;
98
+ const url = options.rpcUrl || options.rpcUrls?.[args.evmChainId];
100
99
  if (!url) {
101
- throw new exceptions_1.WalletException(new Error('Please pass rpcUrl within the ethereumOptions'), {
100
+ throw new exceptions_1.WalletException(new Error('Please pass rpcUrl within the evmOptions'), {
102
101
  code: exceptions_1.UnspecifiedErrorCode,
103
102
  context: wallet_base_1.WalletAction.SendEvmTransaction,
104
103
  });
105
104
  }
106
105
  const account = await turnkeyWallet.getOrCreateAndGetAccount((0, viem_1.getAddress)(args.address), organizationId);
107
- const accountClient = (0, viem_2.createWalletClient)({
106
+ const accountClient = (0, viem_1.createWalletClient)({
108
107
  account: account,
109
108
  chain: {
110
109
  ...consts_js_1.DEFAULT_EVM_CHAIN_CONFIG,
@@ -115,7 +114,7 @@ class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
115
114
  },
116
115
  },
117
116
  },
118
- transport: (0, viem_2.http)(url),
117
+ transport: (0, viem_1.http)(url),
119
118
  });
120
119
  const preparedTransaction = await accountClient.prepareTransactionRequest(transaction);
121
120
  delete preparedTransaction.account;
@@ -199,19 +198,19 @@ class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
199
198
  context: wallet_base_1.WalletAction.GetChainId,
200
199
  });
201
200
  }
202
- async getEvmTransactionReceipt(txHash, ethereumChainId) {
203
- const options = this.ethereumOptions;
201
+ async getEvmTransactionReceipt(txHash, evmChainId) {
202
+ const options = this.evmOptions;
204
203
  const maxAttempts = 10;
205
204
  const interval = 3000;
206
- const chainId = ethereumChainId || options.ethereumChainId;
205
+ const chainId = evmChainId || options.evmChainId;
207
206
  const url = options.rpcUrl || options.rpcUrls?.[chainId];
208
207
  if (!url) {
209
- throw new exceptions_1.WalletException(new Error('Please pass rpcUrl within the ethereumOptions'), {
208
+ throw new exceptions_1.WalletException(new Error('Please pass rpcUrl within the evmOptions'), {
210
209
  code: exceptions_1.UnspecifiedErrorCode,
211
210
  context: wallet_base_1.WalletAction.GetEvmTransactionReceipt,
212
211
  });
213
212
  }
214
- const publicClient = (0, viem_2.createPublicClient)({
213
+ const publicClient = (0, viem_1.createPublicClient)({
215
214
  chain: {
216
215
  ...consts_js_1.DEFAULT_EVM_CHAIN_CONFIG,
217
216
  id: chainId,
@@ -221,7 +220,7 @@ class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
221
220
  },
222
221
  },
223
222
  },
224
- transport: (0, viem_2.http)(url),
223
+ transport: (0, viem_1.http)(url),
225
224
  });
226
225
  let attempts = 0;
227
226
  while (attempts < maxAttempts) {
@@ -19,7 +19,7 @@ export declare class TurnkeyWallet {
19
19
  getTurnkey(): Promise<Turnkey>;
20
20
  getIframeClient(): Promise<TurnkeyIframeClient>;
21
21
  getSession(existingCredentialBundle?: string): Promise<{
22
- session: import("@turnkey/sdk-types").Session | undefined;
22
+ session: import("@turnkey/sdk-browser").Session | undefined;
23
23
  organizationId: string;
24
24
  }>;
25
25
  getAccounts(): Promise<string[]>;
@@ -1,14 +1,14 @@
1
1
  import { TxRaw, AminoSignResponse, DirectSignResponse } from '@injectivelabs/sdk-ts';
2
- import { HttpRestClient } from '@injectivelabs/utils';
3
- import { AccountAddress, EthereumChainId } from '@injectivelabs/ts-types';
2
+ import { StdSignDoc, WalletDeviceType, type WalletMetadata, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, WalletStrategyEvmOptions, ConcreteEvmWalletStrategyArgs } from '@injectivelabs/wallet-base';
4
3
  import { TurnkeyIframeClient } from '@turnkey/sdk-browser';
5
- import { StdSignDoc, WalletDeviceType, type WalletMetadata, BaseConcreteStrategy, ConcreteWalletStrategy, SendTransactionOptions, WalletStrategyEthereumOptions, ConcreteEthereumWalletStrategyArgs } from '@injectivelabs/wallet-base';
4
+ import { HttpRestClient } from '@injectivelabs/utils';
5
+ import { AccountAddress, EvmChainId } from '@injectivelabs/ts-types';
6
6
  import { TurnkeyWallet } from './turnkey/turnkey.js';
7
7
  export declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implements ConcreteWalletStrategy {
8
8
  turnkeyWallet?: TurnkeyWallet;
9
- ethereumOptions: WalletStrategyEthereumOptions;
9
+ evmOptions: WalletStrategyEvmOptions;
10
10
  client: HttpRestClient;
11
- constructor(args: ConcreteEthereumWalletStrategyArgs & {
11
+ constructor(args: ConcreteEvmWalletStrategyArgs & {
12
12
  apiServerEndpoint?: string;
13
13
  });
14
14
  getWalletDeviceType(): Promise<WalletDeviceType>;
@@ -22,7 +22,7 @@ export declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implemen
22
22
  getWalletClient<TurnkeyWallet>(): Promise<TurnkeyWallet>;
23
23
  sendEvmTransaction(transaction: unknown, args: {
24
24
  address: AccountAddress;
25
- ethereumChainId: EthereumChainId;
25
+ evmChainId: EvmChainId;
26
26
  }): Promise<string>;
27
27
  sendTransaction(transaction: TxRaw, options: SendTransactionOptions): Promise<any>;
28
28
  signEip712TypedData(eip712json: string, address: AccountAddress): Promise<string>;
@@ -38,7 +38,7 @@ export declare class TurnkeyWalletStrategy extends BaseConcreteStrategy implemen
38
38
  }): Promise<AminoSignResponse>;
39
39
  signArbitrary(_signer: AccountAddress, _data: string | Uint8Array): Promise<string>;
40
40
  getEthereumChainId(): Promise<string>;
41
- getEvmTransactionReceipt(txHash: string, ethereumChainId?: EthereumChainId): Promise<Record<string, any>>;
41
+ getEvmTransactionReceipt(txHash: string, evmChainId?: EvmChainId): Promise<Record<string, any>>;
42
42
  getPubKey(): Promise<string>;
43
43
  getIframeClient(): Promise<TurnkeyIframeClient>;
44
44
  private getTurnkeyWallet;
@@ -1,16 +1,15 @@
1
1
  /* eslint-disable class-methods-use-this */
2
2
  import { TxGrpcApi, } from '@injectivelabs/sdk-ts';
3
3
  import { ErrorType, WalletException, UnspecifiedErrorCode, TransactionException, CosmosWalletException, } from '@injectivelabs/exceptions';
4
- import { getAddress } from 'viem';
5
- import { sleep, HttpRestClient } from '@injectivelabs/utils';
6
- import { http, createPublicClient, createWalletClient, } from 'viem';
4
+ import { http, getAddress, createPublicClient, createWalletClient, } from 'viem';
7
5
  import { WalletAction, WalletDeviceType, BaseConcreteStrategy, } from '@injectivelabs/wallet-base';
6
+ import { sleep, HttpRestClient } from '@injectivelabs/utils';
8
7
  import { TurnkeyErrorCodes } from './types.js';
9
8
  import { TurnkeyWallet } from './turnkey/turnkey.js';
10
9
  import { DEFAULT_EVM_CHAIN_CONFIG } from './consts.js';
11
10
  export class TurnkeyWalletStrategy extends BaseConcreteStrategy {
12
11
  turnkeyWallet;
13
- ethereumOptions;
12
+ evmOptions;
14
13
  client;
15
14
  constructor(args) {
16
15
  super(args);
@@ -19,7 +18,7 @@ export class TurnkeyWalletStrategy extends BaseConcreteStrategy {
19
18
  throw new WalletException(new Error('apiServerEndpoint is required'));
20
19
  }
21
20
  this.client = new HttpRestClient(endpoint);
22
- this.ethereumOptions = args.ethereumOptions;
21
+ this.evmOptions = args.evmOptions;
23
22
  }
24
23
  async getWalletDeviceType() {
25
24
  return Promise.resolve(WalletDeviceType.Browser);
@@ -89,13 +88,13 @@ export class TurnkeyWalletStrategy extends BaseConcreteStrategy {
89
88
  }
90
89
  async sendEvmTransaction(transaction, args) {
91
90
  try {
92
- const options = this.ethereumOptions;
91
+ const options = this.evmOptions;
93
92
  const turnkeyWallet = await this.getTurnkeyWallet();
94
93
  const organizationId = await this.getOrganizationId();
95
- const chainId = args.ethereumChainId || options.ethereumChainId;
96
- const url = options.rpcUrl || options.rpcUrls?.[args.ethereumChainId];
94
+ const chainId = args.evmChainId || options.evmChainId;
95
+ const url = options.rpcUrl || options.rpcUrls?.[args.evmChainId];
97
96
  if (!url) {
98
- throw new WalletException(new Error('Please pass rpcUrl within the ethereumOptions'), {
97
+ throw new WalletException(new Error('Please pass rpcUrl within the evmOptions'), {
99
98
  code: UnspecifiedErrorCode,
100
99
  context: WalletAction.SendEvmTransaction,
101
100
  });
@@ -196,14 +195,14 @@ export class TurnkeyWalletStrategy extends BaseConcreteStrategy {
196
195
  context: WalletAction.GetChainId,
197
196
  });
198
197
  }
199
- async getEvmTransactionReceipt(txHash, ethereumChainId) {
200
- const options = this.ethereumOptions;
198
+ async getEvmTransactionReceipt(txHash, evmChainId) {
199
+ const options = this.evmOptions;
201
200
  const maxAttempts = 10;
202
201
  const interval = 3000;
203
- const chainId = ethereumChainId || options.ethereumChainId;
202
+ const chainId = evmChainId || options.evmChainId;
204
203
  const url = options.rpcUrl || options.rpcUrls?.[chainId];
205
204
  if (!url) {
206
- throw new WalletException(new Error('Please pass rpcUrl within the ethereumOptions'), {
205
+ throw new WalletException(new Error('Please pass rpcUrl within the evmOptions'), {
207
206
  code: UnspecifiedErrorCode,
208
207
  context: WalletAction.GetEvmTransactionReceipt,
209
208
  });
@@ -19,7 +19,7 @@ export declare class TurnkeyWallet {
19
19
  getTurnkey(): Promise<Turnkey>;
20
20
  getIframeClient(): Promise<TurnkeyIframeClient>;
21
21
  getSession(existingCredentialBundle?: string): Promise<{
22
- session: import("@turnkey/sdk-types").Session | undefined;
22
+ session: import("@turnkey/sdk-browser").Session | undefined;
23
23
  organizationId: string;
24
24
  }>;
25
25
  getAccounts(): Promise<string[]>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/wallet-turnkey",
3
3
  "description": "Turnkey wallet strategy for use with @injectivelabs/wallet-core.",
4
- "version": "1.15.43",
4
+ "version": "1.16.1-alpha.1",
5
5
  "sideEffects": false,
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -44,10 +44,10 @@
44
44
  }
45
45
  },
46
46
  "scripts": {
47
- "build": "yarn build:esm && yarn build:cjs && yarn build:post",
47
+ "build": "pnpm build:esm && pnpm build:cjs && pnpm build:post",
48
48
  "build:cjs": "tsc --build --force tsconfig.build.json",
49
49
  "build:esm": "tsc --build --force tsconfig.build.esm.json",
50
- "build:watch": "tsc --build -w tsconfig.build.json && tsc -w --build tsconfig.build.esm.json && yarn build:post",
50
+ "build:watch": "tsc --build -w tsconfig.build.json && tsc -w --build tsconfig.build.esm.json && pnpm build:post",
51
51
  "build:post": "shx cp ../../../etc/stub/package.json.stub dist/cjs/package.json && shx cp ../../../etc/stub/package.esm.json.stub dist/esm/package.json",
52
52
  "clean": "tsc --build tsconfig.build.json --clean && tsc --build tsconfig.build.esm.json --clean && shx rm -rf coverage *.log junit.xml dist && jest --clearCache && shx mkdir -p dist",
53
53
  "test": "jest",
@@ -59,13 +59,13 @@
59
59
  "start": "node dist/index.js"
60
60
  },
61
61
  "dependencies": {
62
- "@injectivelabs/exceptions": "^1.15.40",
63
- "@injectivelabs/sdk-ts": "^1.15.43",
64
- "@injectivelabs/ts-types": "^1.15.41",
65
- "@injectivelabs/utils": "^1.15.41",
66
- "@injectivelabs/wallet-base": "^1.15.43",
62
+ "@injectivelabs/exceptions": "1.16.1-alpha.1",
63
+ "@injectivelabs/sdk-ts": "1.16.1-alpha.1",
64
+ "@injectivelabs/ts-types": "1.16.1-alpha.1",
65
+ "@injectivelabs/utils": "1.16.1-alpha.1",
66
+ "@injectivelabs/wallet-base": "1.16.1-alpha.1",
67
67
  "@turnkey/sdk-browser": "5.2.3",
68
- "@turnkey/viem": "^0.9.9",
68
+ "@turnkey/viem": "0.9.9",
69
69
  "viem": "^2.31.3"
70
70
  },
71
71
  "devDependencies": {
@@ -77,5 +77,5 @@
77
77
  "tsconfig-paths": "^4.2.0",
78
78
  "typescript": "^5.0.0"
79
79
  },
80
- "gitHead": "18294bf4c22a7a832c8466ec0a825ea6c3e0a2f3"
80
+ "gitHead": "aa24a5ba96800b6daea85666f7030619d3c18d91"
81
81
  }