@toruslabs/ethereum-controllers 7.0.1 → 7.1.0

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.
@@ -21673,7 +21673,7 @@ class src_NftsController extends src_base_controllers_namespaceObject.BaseContro
21673
21673
  }
21674
21674
  });
21675
21675
  }
21676
- async refreshNftBalances() {
21676
+ async refreshNftBalances(skipCache) {
21677
21677
  const userAddress = this.userSelectedAddress;
21678
21678
  if (userAddress === "") return;
21679
21679
  const oldNfts = [...this.userNfts];
@@ -21681,7 +21681,7 @@ class src_NftsController extends src_base_controllers_namespaceObject.BaseContro
21681
21681
  try {
21682
21682
  const currentChainId = this.config.chainId;
21683
21683
  if (src_SIMPLEHASH_SUPPORTED_CHAINS.includes(currentChainId)) {
21684
- const simpleHashBalances = await this.getSimpleHashNfts(userAddress, currentChainId);
21684
+ const simpleHashBalances = await this.getSimpleHashNfts(userAddress, currentChainId, skipCache);
21685
21685
  nonZeroNfts.push(...simpleHashBalances);
21686
21686
  this.update({
21687
21687
  nfts: {
@@ -21994,14 +21994,22 @@ class src_PreferencesController extends src_base_controllers_namespaceObject.Bas
21994
21994
  return [];
21995
21995
  }
21996
21996
  }
21997
- async getEtherScanTokens(address, chainId) {
21997
+ async getEtherScanTokens(address, chainId, skipCache) {
21998
21998
  const selectedAddress = address;
21999
- const result = await this.wsApiClient.authGet(`tokens?chainId=${chainId}&address=${selectedAddress}`, this.authCredentials());
21999
+ let path = `tokens?chainId=${chainId}&address=${selectedAddress}`;
22000
+ if (skipCache) {
22001
+ path += `&skipCache=true`;
22002
+ }
22003
+ const result = await this.wsApiClient.authGet(path, this.authCredentials());
22000
22004
  return result.data;
22001
22005
  }
22002
- async getSimpleHashNfts(address, chainId) {
22006
+ async getSimpleHashNfts(address, chainId, skipCache) {
22003
22007
  const selectedAddress = address;
22004
- const result = await this.wsApiClient.authGet(`nfts?chainId=${chainId}&address=${selectedAddress}`, this.authCredentials());
22008
+ let path = `nfts?chainId=${chainId}&address=${selectedAddress}`;
22009
+ if (skipCache) {
22010
+ path += `&skipCache=true`;
22011
+ }
22012
+ const result = await this.wsApiClient.authGet(path, this.authCredentials());
22005
22013
  return result.data;
22006
22014
  }
22007
22015
  getCustomTokens(address) {
@@ -22549,7 +22557,7 @@ class src_TokensController extends src_base_controllers_namespaceObject.BaseCont
22549
22557
  }
22550
22558
  });
22551
22559
  }
22552
- async refreshTokenBalances() {
22560
+ async refreshTokenBalances(skipCache) {
22553
22561
  const userAddress = this.userSelectedAddress;
22554
22562
  if (userAddress === "") return;
22555
22563
  const oldTokens = [...this.userTokens];
@@ -22558,7 +22566,7 @@ class src_TokensController extends src_base_controllers_namespaceObject.BaseCont
22558
22566
  try {
22559
22567
  const currentChainId = this.config.chainId;
22560
22568
  if (src_ETHERSCAN_SUPPORTED_CHAINS.includes(currentChainId)) {
22561
- const etherscanBalances = await this.getEtherScanTokens(userAddress, currentChainId);
22569
+ const etherscanBalances = await this.getEtherScanTokens(userAddress, currentChainId, skipCache);
22562
22570
  nonZeroTokens.push(...etherscanBalances);
22563
22571
  }
22564
22572
  if (tokenAddresses.length > 0) {
@@ -4077,7 +4077,7 @@ class NftsController extends BaseController {
4077
4077
  }
4078
4078
  });
4079
4079
  }
4080
- async refreshNftBalances() {
4080
+ async refreshNftBalances(skipCache) {
4081
4081
  const userAddress = this.userSelectedAddress;
4082
4082
  if (userAddress === "") return;
4083
4083
  const oldNfts = [...this.userNfts];
@@ -4085,7 +4085,7 @@ class NftsController extends BaseController {
4085
4085
  try {
4086
4086
  const currentChainId = this.config.chainId;
4087
4087
  if (SIMPLEHASH_SUPPORTED_CHAINS.includes(currentChainId)) {
4088
- const simpleHashBalances = await this.getSimpleHashNfts(userAddress, currentChainId);
4088
+ const simpleHashBalances = await this.getSimpleHashNfts(userAddress, currentChainId, skipCache);
4089
4089
  nonZeroNfts.push(...simpleHashBalances);
4090
4090
  this.update({
4091
4091
  nfts: {
@@ -4391,14 +4391,22 @@ class PreferencesController extends BasePreferencesController {
4391
4391
  return [];
4392
4392
  }
4393
4393
  }
4394
- async getEtherScanTokens(address, chainId) {
4394
+ async getEtherScanTokens(address, chainId, skipCache) {
4395
4395
  const selectedAddress = address;
4396
- const result = await this.wsApiClient.authGet(`tokens?chainId=${chainId}&address=${selectedAddress}`, this.authCredentials());
4396
+ let path = `tokens?chainId=${chainId}&address=${selectedAddress}`;
4397
+ if (skipCache) {
4398
+ path += `&skipCache=true`;
4399
+ }
4400
+ const result = await this.wsApiClient.authGet(path, this.authCredentials());
4397
4401
  return result.data;
4398
4402
  }
4399
- async getSimpleHashNfts(address, chainId) {
4403
+ async getSimpleHashNfts(address, chainId, skipCache) {
4400
4404
  const selectedAddress = address;
4401
- const result = await this.wsApiClient.authGet(`nfts?chainId=${chainId}&address=${selectedAddress}`, this.authCredentials());
4405
+ let path = `nfts?chainId=${chainId}&address=${selectedAddress}`;
4406
+ if (skipCache) {
4407
+ path += `&skipCache=true`;
4408
+ }
4409
+ const result = await this.wsApiClient.authGet(path, this.authCredentials());
4402
4410
  return result.data;
4403
4411
  }
4404
4412
  getCustomTokens(address) {
@@ -4926,7 +4934,7 @@ class TokensController extends BaseController {
4926
4934
  }
4927
4935
  });
4928
4936
  }
4929
- async refreshTokenBalances() {
4937
+ async refreshTokenBalances(skipCache) {
4930
4938
  const userAddress = this.userSelectedAddress;
4931
4939
  if (userAddress === "") return;
4932
4940
  const oldTokens = [...this.userTokens];
@@ -4935,7 +4943,7 @@ class TokensController extends BaseController {
4935
4943
  try {
4936
4944
  const currentChainId = this.config.chainId;
4937
4945
  if (ETHERSCAN_SUPPORTED_CHAINS.includes(currentChainId)) {
4938
- const etherscanBalances = await this.getEtherScanTokens(userAddress, currentChainId);
4946
+ const etherscanBalances = await this.getEtherScanTokens(userAddress, currentChainId, skipCache);
4939
4947
  nonZeroTokens.push(...etherscanBalances);
4940
4948
  }
4941
4949
  if (tokenAddresses.length > 0) {