(chainId, privateKey, apiKeyIndex, accountIndex, params = {})
| 374 | }); |
| 375 | } |
| 376 | async loadAccount(chainId, privateKey, apiKeyIndex, accountIndex, params = {}) { |
| 377 | this.initAuthObject(accountIndex, apiKeyIndex); |
| 378 | const cachedAuths = this.safeDict(this.options['auths'][accountIndex], apiKeyIndex); |
| 379 | let signer = this.safeValue(cachedAuths, 'signer'); |
| 380 | if (signer !== undefined) { |
| 381 | return signer; |
| 382 | } |
| 383 | let libraryPath = undefined; |
| 384 | [libraryPath, params] = this.handleOptionAndParams(params, 'loadAccount', 'libraryPath'); |
| 385 | const lighterPrivateKeyIsSet = (privateKey !== undefined) && (privateKey !== ''); |
| 386 | if (lighterPrivateKeyIsSet && (libraryPath !== undefined) && (apiKeyIndex !== undefined) && (accountIndex !== undefined)) { |
| 387 | // load lighter library, and create lighter client |
| 388 | signer = await this.loadLighterLibrary(libraryPath, chainId, privateKey, this.parseToInt(apiKeyIndex), this.parseToInt(accountIndex), true); |
| 389 | this.options['auths'][accountIndex][apiKeyIndex]['signer'] = signer; |
| 390 | return signer; |
| 391 | } |
| 392 | const privateKeyIsSet = (this.privateKey !== undefined) && (this.privateKey !== ''); |
| 393 | if (privateKeyIsSet && (apiKeyIndex !== undefined) && (accountIndex !== undefined)) { |
| 394 | if (this.privateKey.length > 66) { |
| 395 | throw new NotSupported(this.id + ' after the latest update (v4.5.50), CCXT now expects the l1 private key to be provided in the credentials. Please check for more details: https://github.com/ccxt/ccxt/wiki/FAQ#how-to-use-the-lighter-exchange-in-ccxt'); |
| 396 | } |
| 397 | // load lighter library without creating lighter client |
| 398 | signer = await this.loadLighterLibrary(libraryPath, chainId, '', this.parseToInt(apiKeyIndex), this.parseToInt(accountIndex), false); |
| 399 | this.options['auths'][accountIndex][apiKeyIndex]['signer'] = signer; |
| 400 | const res = await this.changeApiKey(); |
| 401 | await this.handleBuilderFeeApproval(this.parseToInt(accountIndex), this.parseToInt(apiKeyIndex)); |
| 402 | return res; |
| 403 | } |
| 404 | return signer; |
| 405 | } |
| 406 | initAuthObject(strAccountIndex, strApiKeyIndex) { |
| 407 | if (!('auths' in this.options)) { |
| 408 | this.options['auths'] = {}; |
no test coverage detected