@subwallet/extension-base 1.0.4-1 → 1.0.5-2

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.
Files changed (140) hide show
  1. package/background/KoniTypes.d.ts +14 -1
  2. package/background/KoniTypes.js +1 -0
  3. package/background/errors/TransactionError.js +4 -0
  4. package/background/handlers/State.d.ts +1 -1
  5. package/background/handlers/State.js +2 -8
  6. package/background/handlers/subscriptions.js +0 -1
  7. package/background/types.d.ts +2 -2
  8. package/cjs/background/KoniTypes.js +1 -0
  9. package/cjs/background/errors/TransactionError.js +4 -0
  10. package/cjs/background/handlers/State.js +1 -7
  11. package/cjs/background/handlers/subscriptions.js +0 -1
  12. package/cjs/constants/index.js +6 -6
  13. package/cjs/koni/api/coingecko.js +1 -4
  14. package/cjs/koni/api/dotsama/balance.js +7 -5
  15. package/cjs/koni/api/dotsama/crowdloan.js +0 -4
  16. package/cjs/koni/api/dotsama/transfer.js +0 -4
  17. package/cjs/koni/api/nft/acala_nft/index.js +1 -1
  18. package/cjs/koni/api/nft/bit.country/index.js +1 -1
  19. package/cjs/koni/api/nft/evm_nft/index.js +2 -3
  20. package/cjs/koni/api/nft/index.js +1 -2
  21. package/cjs/koni/api/nft/karura_nft/index.js +1 -1
  22. package/cjs/koni/api/nft/quartz_nft/index.js +1 -1
  23. package/cjs/koni/api/nft/rmrk_nft/index.js +2 -3
  24. package/cjs/koni/api/nft/statemine_nft/index.js +1 -1
  25. package/cjs/koni/api/nft/transfer.js +5 -5
  26. package/cjs/koni/api/nft/unique_nft/index.js +1 -1
  27. package/cjs/koni/api/nft/unique_nft/uniqueNftV2.js +0 -1
  28. package/cjs/koni/api/nft/wasm_nft/index.js +1 -2
  29. package/cjs/koni/api/staking/bonding/astar.js +28 -12
  30. package/cjs/koni/api/staking/bonding/utils.js +4 -0
  31. package/cjs/koni/api/staking/relayChain.js +0 -1
  32. package/cjs/koni/api/staking/subsquidStaking.js +0 -2
  33. package/cjs/koni/api/tokens/wasm/index.js +0 -1
  34. package/cjs/koni/api/tokens/wasm/utils.js +0 -1
  35. package/cjs/koni/api/xcm/index.js +0 -1
  36. package/cjs/koni/background/cron.js +0 -45
  37. package/cjs/koni/background/handlers/Extension.js +164 -134
  38. package/cjs/koni/background/handlers/State.js +18 -3
  39. package/cjs/koni/background/handlers/Tabs.js +34 -2
  40. package/cjs/koni/background/handlers/index.js +3 -2
  41. package/cjs/koni/background/subscription.js +0 -26
  42. package/cjs/packageInfo.js +1 -1
  43. package/cjs/services/chain-service/handler/EvmChainHandler.js +1 -1
  44. package/cjs/services/chain-service/handler/SubstrateChainHandler.js +2 -9
  45. package/cjs/services/chain-service/handler/light-client/index.js +9 -6
  46. package/cjs/services/chain-service/index.js +0 -2
  47. package/cjs/services/chain-service/utils.js +3 -0
  48. package/cjs/services/history-service/helpers/recoverHistoryStatus.js +227 -0
  49. package/cjs/services/history-service/index.js +68 -6
  50. package/cjs/services/history-service/subsquid-multi-chain-history.js +3 -2
  51. package/cjs/services/history-service/testChainMap.js +724 -0
  52. package/cjs/services/keyring-service/index.js +0 -2
  53. package/cjs/services/migration-service/index.js +0 -3
  54. package/cjs/services/migration-service/scripts/MigrateAutoLock.js +30 -0
  55. package/cjs/services/migration-service/scripts/MigrateChainPatrol.js +30 -0
  56. package/cjs/services/migration-service/scripts/index.js +5 -1
  57. package/cjs/services/notification-service/NotificationService.js +1 -1
  58. package/cjs/services/price-service/coingecko.js +1 -1
  59. package/cjs/services/price-service/index.js +0 -3
  60. package/cjs/services/request-service/handler/AuthRequestHandler.js +1 -1
  61. package/cjs/services/setting-service/constants.js +8 -2
  62. package/cjs/services/storage-service/DatabaseService.js +3 -45
  63. package/cjs/services/transaction-service/constants.js +11 -0
  64. package/cjs/services/transaction-service/index.js +60 -20
  65. package/cjs/services/transaction-service/utils.js +25 -14
  66. package/cjs/utils/index.js +3 -0
  67. package/constants/index.d.ts +1 -1
  68. package/constants/index.js +1 -1
  69. package/koni/api/coingecko.js +1 -4
  70. package/koni/api/dotsama/balance.js +7 -5
  71. package/koni/api/dotsama/crowdloan.js +0 -4
  72. package/koni/api/dotsama/transfer.js +0 -4
  73. package/koni/api/nft/acala_nft/index.js +1 -1
  74. package/koni/api/nft/bit.country/index.js +1 -1
  75. package/koni/api/nft/evm_nft/index.js +2 -3
  76. package/koni/api/nft/index.js +1 -2
  77. package/koni/api/nft/karura_nft/index.js +1 -1
  78. package/koni/api/nft/quartz_nft/index.js +1 -1
  79. package/koni/api/nft/rmrk_nft/index.js +2 -3
  80. package/koni/api/nft/statemine_nft/index.js +1 -1
  81. package/koni/api/nft/transfer.js +5 -5
  82. package/koni/api/nft/unique_nft/index.js +1 -1
  83. package/koni/api/nft/unique_nft/uniqueNftV2.js +0 -1
  84. package/koni/api/nft/wasm_nft/index.js +1 -2
  85. package/koni/api/staking/bonding/astar.d.ts +2 -1
  86. package/koni/api/staking/bonding/astar.js +27 -12
  87. package/koni/api/staking/bonding/utils.js +4 -0
  88. package/koni/api/staking/relayChain.js +0 -1
  89. package/koni/api/staking/subsquidStaking.js +0 -2
  90. package/koni/api/tokens/wasm/index.js +0 -1
  91. package/koni/api/tokens/wasm/utils.js +0 -1
  92. package/koni/api/xcm/index.js +0 -1
  93. package/koni/background/cron.js +0 -45
  94. package/koni/background/handlers/Extension.d.ts +2 -0
  95. package/koni/background/handlers/Extension.js +79 -51
  96. package/koni/background/handlers/State.d.ts +3 -1
  97. package/koni/background/handlers/State.js +18 -3
  98. package/koni/background/handlers/Tabs.d.ts +1 -0
  99. package/koni/background/handlers/Tabs.js +32 -1
  100. package/koni/background/handlers/index.js +3 -2
  101. package/koni/background/subscription.d.ts +0 -1
  102. package/koni/background/subscription.js +0 -26
  103. package/package.json +55 -34
  104. package/packageInfo.js +1 -1
  105. package/services/chain-service/handler/EvmChainHandler.js +1 -1
  106. package/services/chain-service/handler/SubstrateChainHandler.js +2 -9
  107. package/services/chain-service/handler/light-client/index.js +8 -6
  108. package/services/chain-service/helper/api-helper/spec/acala.d.ts +3 -3
  109. package/services/chain-service/index.js +0 -2
  110. package/services/chain-service/utils.js +3 -0
  111. package/services/history-service/helpers/recoverHistoryStatus.d.ts +17 -0
  112. package/services/history-service/helpers/recoverHistoryStatus.js +214 -0
  113. package/services/history-service/index.d.ts +6 -0
  114. package/services/history-service/index.js +69 -7
  115. package/services/history-service/subsquid-multi-chain-history.js +3 -2
  116. package/services/history-service/testChainMap.d.ts +3 -0
  117. package/services/history-service/testChainMap.js +716 -0
  118. package/services/keyring-service/index.js +0 -2
  119. package/services/migration-service/index.js +0 -3
  120. package/services/migration-service/scripts/MigrateAutoLock.d.ts +4 -0
  121. package/services/migration-service/scripts/MigrateAutoLock.js +22 -0
  122. package/services/migration-service/scripts/MigrateChainPatrol.d.ts +4 -0
  123. package/services/migration-service/scripts/MigrateChainPatrol.js +22 -0
  124. package/services/migration-service/scripts/index.js +5 -1
  125. package/services/notification-service/NotificationService.js +1 -1
  126. package/services/price-service/coingecko.js +1 -1
  127. package/services/price-service/index.js +0 -3
  128. package/services/request-service/handler/AuthRequestHandler.js +1 -1
  129. package/services/setting-service/constants.d.ts +4 -2
  130. package/services/setting-service/constants.js +5 -1
  131. package/services/storage-service/DatabaseService.d.ts +1 -1
  132. package/services/storage-service/DatabaseService.js +3 -45
  133. package/services/transaction-service/constants.d.ts +1 -0
  134. package/services/transaction-service/constants.js +4 -0
  135. package/services/transaction-service/index.d.ts +1 -0
  136. package/services/transaction-service/index.js +61 -21
  137. package/services/transaction-service/types.d.ts +2 -0
  138. package/services/transaction-service/utils.d.ts +1 -1
  139. package/services/transaction-service/utils.js +24 -13
  140. package/utils/index.js +3 -0
@@ -8,19 +8,30 @@ export function parseTransactionData(data) {
8
8
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
9
9
  return data;
10
10
  }
11
- export function getTransactionLink(chainInfo, extrinsicHash) {
12
- if (extrinsicHash.startsWith('0x')) {
13
- const explorerLink = _getBlockExplorerFromChain(chainInfo);
14
- if (_isPureEvmChain(chainInfo)) {
15
- if (explorerLink) {
16
- return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}tx/${extrinsicHash}`;
17
- }
18
- } else {
19
- const explorerLink = _getBlockExplorerFromChain(chainInfo);
20
- if (explorerLink) {
21
- return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}extrinsic/${extrinsicHash}`;
22
- }
23
- }
11
+ function getBlockExplorerAccountRoute(explorerLink) {
12
+ if (explorerLink.includes('explorer.subspace.network')) {
13
+ return 'accounts';
14
+ }
15
+ if (explorerLink.includes('subscan.io')) {
16
+ return 'account';
17
+ }
18
+ return 'address';
19
+ }
20
+ function getBlockExplorerTxRoute(chainInfo) {
21
+ if (_isPureEvmChain(chainInfo)) {
22
+ return 'tx';
23
+ }
24
+ return 'extrinsic';
25
+ }
26
+ export function getExplorerLink(chainInfo, value, type) {
27
+ const explorerLink = _getBlockExplorerFromChain(chainInfo);
28
+ if (explorerLink && type === 'account') {
29
+ const route = getBlockExplorerAccountRoute(explorerLink);
30
+ return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${value}`;
31
+ }
32
+ if (explorerLink && value.startsWith('0x')) {
33
+ const route = getBlockExplorerTxRoute(chainInfo);
34
+ return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${value}`;
24
35
  }
25
36
  return undefined;
26
37
  }
package/utils/index.js CHANGED
@@ -15,6 +15,9 @@ export function isAccountAll(address) {
15
15
  }
16
16
  export function reformatAddress(address, networkPrefix = 42, isEthereum = false) {
17
17
  try {
18
+ if (!address || address === '') {
19
+ return '';
20
+ }
18
21
  if (isEthereumAddress(address)) {
19
22
  return address;
20
23
  }