@injectivelabs/wallet-turnkey 1.16.32 → 1.16.33
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,41 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.getEip1193ProviderForTurnkey = void 0;
|
|
37
|
-
const
|
|
38
|
-
const viem_1 = require("viem");
|
|
4
|
+
const wallet_base_1 = require("@injectivelabs/wallet-base");
|
|
39
5
|
const getEip1193ProviderForTurnkey = async (account, chainId) => {
|
|
40
6
|
const provider = new CustomEip1193Provider({
|
|
41
7
|
chainId: parseInt(chainId, 16),
|
|
@@ -67,17 +33,13 @@ class CustomEip1193Provider {
|
|
|
67
33
|
return [this.address];
|
|
68
34
|
}
|
|
69
35
|
getClient() {
|
|
70
|
-
return (0,
|
|
71
|
-
|
|
72
|
-
|
|
36
|
+
return (0, wallet_base_1.getViemWalletClient)({
|
|
37
|
+
chainId: this.chainId,
|
|
38
|
+
account: this.account,
|
|
73
39
|
});
|
|
74
40
|
}
|
|
75
41
|
getChain() {
|
|
76
|
-
|
|
77
|
-
id: this.chainId,
|
|
78
|
-
chains: Object.values(viemChains),
|
|
79
|
-
});
|
|
80
|
-
return chain;
|
|
42
|
+
return (0, wallet_base_1.getEvmChainConfig)(this.chainId);
|
|
81
43
|
}
|
|
82
44
|
on(_event, _listener) {
|
|
83
45
|
throw new Error('Not implemented');
|
|
@@ -116,10 +78,9 @@ class CustomEip1193Provider {
|
|
|
116
78
|
if (!args.params) {
|
|
117
79
|
throw new Error('params is required');
|
|
118
80
|
}
|
|
119
|
-
const accountClient = (0,
|
|
81
|
+
const accountClient = (0, wallet_base_1.getViemWalletClient)({
|
|
82
|
+
chainId: this.chainId,
|
|
120
83
|
account: this.account,
|
|
121
|
-
chain: this.getChain(),
|
|
122
|
-
transport: (0, viem_1.http)(),
|
|
123
84
|
});
|
|
124
85
|
const client = this.getClient();
|
|
125
86
|
const parseHexValue = (value) => {
|
|
@@ -155,10 +116,7 @@ class CustomEip1193Provider {
|
|
|
155
116
|
if (!args.params) {
|
|
156
117
|
throw new Error('params is required');
|
|
157
118
|
}
|
|
158
|
-
const client = (0,
|
|
159
|
-
chain: this.getChain(),
|
|
160
|
-
transport: (0, viem_1.http)(),
|
|
161
|
-
});
|
|
119
|
+
const client = (0, wallet_base_1.getViemPublicClient)(this.chainId);
|
|
162
120
|
const count = await client.getTransactionCount({
|
|
163
121
|
address: this.address,
|
|
164
122
|
blockTag: 'pending',
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TurnkeyWalletStrategy = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
4
5
|
const sdk_ts_1 = require("@injectivelabs/sdk-ts");
|
|
5
6
|
const sdk_ts_2 = require("@injectivelabs/sdk-ts");
|
|
6
7
|
const utils_1 = require("@injectivelabs/utils");
|
|
7
|
-
const viem_1 = require("viem");
|
|
8
|
-
const wallet_base_1 = require("@injectivelabs/wallet-base");
|
|
9
8
|
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
9
|
+
const wallet_base_1 = require("@injectivelabs/wallet-base");
|
|
10
10
|
const types_js_1 = require("./types.js");
|
|
11
11
|
const turnkey_js_1 = require("./turnkey/turnkey.js");
|
|
12
|
-
const consts_js_1 = require("./consts.js");
|
|
13
12
|
const Eip1193Provider_js_1 = require("./Eip1193Provider.js");
|
|
14
13
|
class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
15
14
|
turnkeyWallet;
|
|
@@ -103,18 +102,10 @@ class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
|
103
102
|
});
|
|
104
103
|
}
|
|
105
104
|
const account = await turnkeyWallet.getOrCreateAndGetAccount((0, viem_1.getAddress)(args.address));
|
|
106
|
-
const accountClient = (0,
|
|
105
|
+
const accountClient = (0, wallet_base_1.getViemWalletClient)({
|
|
106
|
+
chainId,
|
|
107
107
|
account: account,
|
|
108
|
-
|
|
109
|
-
...consts_js_1.DEFAULT_EVM_CHAIN_CONFIG,
|
|
110
|
-
id: chainId,
|
|
111
|
-
rpcUrls: {
|
|
112
|
-
default: {
|
|
113
|
-
http: [url],
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
transport: (0, viem_1.http)(url),
|
|
108
|
+
rpcUrl: url,
|
|
118
109
|
});
|
|
119
110
|
const parseHexValue = (value) => {
|
|
120
111
|
if (typeof value === 'string') {
|
|
@@ -230,18 +221,7 @@ class TurnkeyWalletStrategy extends wallet_base_1.BaseConcreteStrategy {
|
|
|
230
221
|
context: wallet_base_1.WalletAction.GetEvmTransactionReceipt,
|
|
231
222
|
});
|
|
232
223
|
}
|
|
233
|
-
const publicClient = (0,
|
|
234
|
-
chain: {
|
|
235
|
-
...consts_js_1.DEFAULT_EVM_CHAIN_CONFIG,
|
|
236
|
-
id: chainId,
|
|
237
|
-
rpcUrls: {
|
|
238
|
-
default: {
|
|
239
|
-
http: [url],
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
},
|
|
243
|
-
transport: (0, viem_1.http)(url),
|
|
244
|
-
});
|
|
224
|
+
const publicClient = (0, wallet_base_1.getViemPublicClient)(chainId, url);
|
|
245
225
|
let attempts = 0;
|
|
246
226
|
while (attempts < maxAttempts) {
|
|
247
227
|
attempts++;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { extractChain, createWalletClient, http, createPublicClient, } from 'viem';
|
|
1
|
+
import { getEvmChainConfig, getViemPublicClient, getViemWalletClient, } from '@injectivelabs/wallet-base';
|
|
3
2
|
export const getEip1193ProviderForTurnkey = async (account, chainId) => {
|
|
4
3
|
const provider = new CustomEip1193Provider({
|
|
5
4
|
chainId: parseInt(chainId, 16),
|
|
@@ -30,17 +29,13 @@ class CustomEip1193Provider {
|
|
|
30
29
|
return [this.address];
|
|
31
30
|
}
|
|
32
31
|
getClient() {
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
return getViemWalletClient({
|
|
33
|
+
chainId: this.chainId,
|
|
34
|
+
account: this.account,
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
37
|
getChain() {
|
|
39
|
-
|
|
40
|
-
id: this.chainId,
|
|
41
|
-
chains: Object.values(viemChains),
|
|
42
|
-
});
|
|
43
|
-
return chain;
|
|
38
|
+
return getEvmChainConfig(this.chainId);
|
|
44
39
|
}
|
|
45
40
|
on(_event, _listener) {
|
|
46
41
|
throw new Error('Not implemented');
|
|
@@ -79,10 +74,9 @@ class CustomEip1193Provider {
|
|
|
79
74
|
if (!args.params) {
|
|
80
75
|
throw new Error('params is required');
|
|
81
76
|
}
|
|
82
|
-
const accountClient =
|
|
77
|
+
const accountClient = getViemWalletClient({
|
|
78
|
+
chainId: this.chainId,
|
|
83
79
|
account: this.account,
|
|
84
|
-
chain: this.getChain(),
|
|
85
|
-
transport: http(),
|
|
86
80
|
});
|
|
87
81
|
const client = this.getClient();
|
|
88
82
|
const parseHexValue = (value) => {
|
|
@@ -118,10 +112,7 @@ class CustomEip1193Provider {
|
|
|
118
112
|
if (!args.params) {
|
|
119
113
|
throw new Error('params is required');
|
|
120
114
|
}
|
|
121
|
-
const client =
|
|
122
|
-
chain: this.getChain(),
|
|
123
|
-
transport: http(),
|
|
124
|
-
});
|
|
115
|
+
const client = getViemPublicClient(this.chainId);
|
|
125
116
|
const count = await client.getTransactionCount({
|
|
126
117
|
address: this.address,
|
|
127
118
|
blockTag: 'pending',
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { getAddress } from 'viem';
|
|
1
2
|
import { TxGrpcApi } from '@injectivelabs/sdk-ts';
|
|
2
3
|
import { getEthereumAddress } from '@injectivelabs/sdk-ts';
|
|
3
4
|
import { sleep, HttpRestClient } from '@injectivelabs/utils';
|
|
4
|
-
import { http, getAddress, createPublicClient, createWalletClient } from 'viem';
|
|
5
|
-
import { WalletAction, WalletDeviceType, BaseConcreteStrategy, } from '@injectivelabs/wallet-base';
|
|
6
5
|
import { ErrorType, WalletException, UnspecifiedErrorCode, TransactionException, CosmosWalletException, } from '@injectivelabs/exceptions';
|
|
6
|
+
import { WalletAction, WalletDeviceType, getViemWalletClient, getViemPublicClient, BaseConcreteStrategy, } from '@injectivelabs/wallet-base';
|
|
7
7
|
import { TurnkeyErrorCodes } from './types.js';
|
|
8
8
|
import { TurnkeyWallet } from './turnkey/turnkey.js';
|
|
9
|
-
import { DEFAULT_EVM_CHAIN_CONFIG } from './consts.js';
|
|
10
9
|
import { getEip1193ProviderForTurnkey } from './Eip1193Provider.js';
|
|
11
10
|
export class TurnkeyWalletStrategy extends BaseConcreteStrategy {
|
|
12
11
|
turnkeyWallet;
|
|
@@ -100,18 +99,10 @@ export class TurnkeyWalletStrategy extends BaseConcreteStrategy {
|
|
|
100
99
|
});
|
|
101
100
|
}
|
|
102
101
|
const account = await turnkeyWallet.getOrCreateAndGetAccount(getAddress(args.address));
|
|
103
|
-
const accountClient =
|
|
102
|
+
const accountClient = getViemWalletClient({
|
|
103
|
+
chainId,
|
|
104
104
|
account: account,
|
|
105
|
-
|
|
106
|
-
...DEFAULT_EVM_CHAIN_CONFIG,
|
|
107
|
-
id: chainId,
|
|
108
|
-
rpcUrls: {
|
|
109
|
-
default: {
|
|
110
|
-
http: [url],
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
transport: http(url),
|
|
105
|
+
rpcUrl: url,
|
|
115
106
|
});
|
|
116
107
|
const parseHexValue = (value) => {
|
|
117
108
|
if (typeof value === 'string') {
|
|
@@ -227,18 +218,7 @@ export class TurnkeyWalletStrategy extends BaseConcreteStrategy {
|
|
|
227
218
|
context: WalletAction.GetEvmTransactionReceipt,
|
|
228
219
|
});
|
|
229
220
|
}
|
|
230
|
-
const publicClient =
|
|
231
|
-
chain: {
|
|
232
|
-
...DEFAULT_EVM_CHAIN_CONFIG,
|
|
233
|
-
id: chainId,
|
|
234
|
-
rpcUrls: {
|
|
235
|
-
default: {
|
|
236
|
-
http: [url],
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
transport: http(url),
|
|
241
|
-
});
|
|
221
|
+
const publicClient = getViemPublicClient(chainId, url);
|
|
242
222
|
let attempts = 0;
|
|
243
223
|
while (attempts < maxAttempts) {
|
|
244
224
|
attempts++;
|
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.16.
|
|
4
|
+
"version": "1.16.33",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"start": "node dist/index.js"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@injectivelabs/exceptions": "1.16.
|
|
63
|
-
"@injectivelabs/sdk-ts": "1.16.
|
|
64
|
-
"@injectivelabs/ts-types": "1.16.
|
|
65
|
-
"@injectivelabs/utils": "1.16.
|
|
66
|
-
"@injectivelabs/wallet-base": "1.16.
|
|
62
|
+
"@injectivelabs/exceptions": "1.16.33",
|
|
63
|
+
"@injectivelabs/sdk-ts": "1.16.33",
|
|
64
|
+
"@injectivelabs/ts-types": "1.16.33",
|
|
65
|
+
"@injectivelabs/utils": "1.16.33",
|
|
66
|
+
"@injectivelabs/wallet-base": "1.16.33",
|
|
67
67
|
"@turnkey/sdk-browser": "5.2.3",
|
|
68
68
|
"@turnkey/viem": "^0.9.10",
|
|
69
|
-
"viem": "^2.
|
|
69
|
+
"viem": "^2.40.3"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"jest": "^29.0.0",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"tsconfig-paths": "^4.2.0",
|
|
78
78
|
"typescript": "^5.0.0"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "7e822b65b56c486c03bede8c0eb024fd34a7657b"
|
|
81
81
|
}
|