@onekeyfe/inpage-providers-hub 2.1.21 → 2.1.23

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.
@@ -62,15 +62,15 @@ function findWalletIconByParent(parent, constraints) {
62
62
  utils_1.universalLog.warn(`no icon node found for parent`, parent);
63
63
  return null;
64
64
  }
65
- if (iconNodes.length > 1) {
65
+ const filteredIconNodes = iconNodes.filter((icon) => constraints.every((f) => f(icon)));
66
+ if (filteredIconNodes.length === 0) {
67
+ throw new Error('it doesnt satisfy the constraints');
68
+ }
69
+ if (filteredIconNodes.length > 1) {
66
70
  utils_1.universalLog.warn(`more than one icon node found`, iconNodes.length, iconNodes);
67
71
  throw new Error('more than one icon node found');
68
72
  }
69
- const icon = iconNodes[0];
70
- if (constraints.some((f) => !f(icon))) {
71
- throw new Error('it doesnt satisfy the constraints');
72
- }
73
- return icon;
73
+ return filteredIconNodes[0];
74
74
  }
75
75
  //NOTE: use function isWalletIconLessEqualThan with lazy loading image
76
76
  function isWalletIconSizeMatch(walletIcon, min = consts_1.ICON_MIN_SIZE, max = consts_1.ICON_MAX_SIZE) {
@@ -56,10 +56,16 @@ function hackWalletConnectButton(sites) {
56
56
  continue;
57
57
  }
58
58
  const { textNode, iconNode } = result;
59
- if (textNode && iconNode) {
60
- const newText = updateName(textNode, updatedName);
61
- const newIconElement = updateIcon(iconNode, updatedIcon);
59
+ let newText = null;
60
+ let newIconElement = null;
61
+ if (textNode) {
62
+ newText = updateName(textNode, updatedName);
63
+ }
64
+ if (iconNode) {
65
+ newIconElement = updateIcon(iconNode, updatedIcon);
62
66
  walletId.updateFlag(newIconElement);
67
+ }
68
+ if (newText || newIconElement) {
63
69
  afterUpdate === null || afterUpdate === void 0 ? void 0 : afterUpdate(newText, newIconElement);
64
70
  }
65
71
  }
@@ -115,7 +115,7 @@ export type WalletInfo = {
115
115
  findIconAndName?: (this: null, wallet: WalletInfo) => FindResultType | null;
116
116
  updateIcon?: (this: void, img: HTMLElement, iconStr: string) => HTMLImageElement;
117
117
  updateName?: (this: void, textNode: Text, text: string) => Text;
118
- afterUpdate?: (this: void, textNode: Text, img: HTMLImageElement) => void;
118
+ afterUpdate?: (this: void, textNode: Text | null, img: HTMLImageElement | null) => void;
119
119
  /**
120
120
  * used when there is only one icon or name element(not both) and other special cases
121
121
  */