MCPcopy Index your code
hub / github.com/ccxt/ccxt / loadAccount

Method loadAccount

js/src/lighter.js:376–405  ·  view source on GitHub ↗
(chainId, privateKey, apiKeyIndex, accountIndex, params = {})

Source from the content-addressed store, hash-verified

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'] = {};

Callers 15

preLoadLighterLibraryMethod · 0.95
createSubAccountMethod · 0.95
approveBuilderFeeMethod · 0.95
createOrderMethod · 0.95
editOrderMethod · 0.95
fetchOpenOrdersMethod · 0.95
fetchClosedOrdersMethod · 0.95
transferMethod · 0.95
fetchTransfersMethod · 0.95
fetchDepositsMethod · 0.95
fetchWithdrawalsMethod · 0.95
withdrawMethod · 0.95

Calls 8

initAuthObjectMethod · 0.95
changeApiKeyMethod · 0.95
safeDictMethod · 0.45
safeValueMethod · 0.45
handleOptionAndParamsMethod · 0.45
loadLighterLibraryMethod · 0.45
parseToIntMethod · 0.45

Tested by

no test coverage detected