@subwallet/extension-base 1.3.6-1 → 1.3.8-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.
Files changed (132) hide show
  1. package/background/KoniTypes.d.ts +20 -5
  2. package/background/KoniTypes.js +1 -1
  3. package/cjs/background/KoniTypes.js +1 -1
  4. package/cjs/constants/blocked-actions.js +108 -0
  5. package/cjs/constants/index.js +4 -4
  6. package/cjs/core/substrate/xcm-parser.js +20 -5
  7. package/cjs/koni/api/contract-handler/utils/index.js +15 -1
  8. package/cjs/koni/api/nft/config.js +6 -4
  9. package/cjs/koni/api/nft/index.js +9 -0
  10. package/cjs/koni/api/nft/story_odyssey_nft/index.js +126 -0
  11. package/cjs/koni/background/handlers/Extension.js +64 -4
  12. package/cjs/koni/background/handlers/State.js +23 -2
  13. package/cjs/packageInfo.js +1 -1
  14. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +2 -1
  15. package/cjs/services/balance-service/transfer/xcm/index.js +31 -1
  16. package/cjs/services/balance-service/transfer/xcm/polygonBridge.js +108 -0
  17. package/cjs/services/chain-online-service/constants.js +32 -0
  18. package/cjs/services/chain-online-service/index.js +190 -0
  19. package/cjs/services/chain-service/constants.js +2 -1
  20. package/cjs/services/chain-service/index.js +87 -127
  21. package/cjs/services/chain-service/utils/index.js +0 -2
  22. package/cjs/services/chain-service/utils/patch.js +7 -3
  23. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +20 -17
  24. package/cjs/services/environment-service/stores/Environment.js +19 -0
  25. package/cjs/services/fee-service/utils/index.js +14 -0
  26. package/cjs/services/inapp-notification-service/consts.js +6 -4
  27. package/cjs/services/inapp-notification-service/index.js +110 -6
  28. package/cjs/services/inapp-notification-service/interfaces.js +9 -1
  29. package/cjs/services/inapp-notification-service/utils/avail.js +88 -0
  30. package/cjs/services/inapp-notification-service/{utils.js → utils/common.js} +1 -84
  31. package/cjs/services/inapp-notification-service/utils/index.js +38 -0
  32. package/cjs/services/inapp-notification-service/utils/polygon.js +66 -0
  33. package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBridge.js +37 -0
  34. package/cjs/services/migration-service/scripts/index.js +3 -1
  35. package/cjs/services/setting-service/SettingService.js +21 -0
  36. package/cjs/services/setting-service/constants.js +2 -1
  37. package/cjs/services/storage-service/DatabaseService.js +3 -0
  38. package/cjs/services/transaction-service/index.js +13 -7
  39. package/cjs/services/transaction-service/utils.js +3 -0
  40. package/cjs/stores/ChainlistStore.js +18 -0
  41. package/cjs/stores/EnvironmentStore.js +18 -0
  42. package/cjs/stores/index.js +8 -1
  43. package/cjs/types/index.js +11 -0
  44. package/cjs/utils/account/transform.js +1 -1
  45. package/cjs/utils/environment.js +15 -1
  46. package/cjs/utils/staticData/index.js +7 -2
  47. package/constants/blocked-actions.d.ts +29 -0
  48. package/constants/blocked-actions.js +96 -0
  49. package/constants/index.d.ts +1 -1
  50. package/constants/index.js +1 -1
  51. package/core/substrate/xcm-parser.d.ts +2 -1
  52. package/core/substrate/xcm-parser.js +19 -5
  53. package/koni/api/contract-handler/utils/index.d.ts +2 -0
  54. package/koni/api/contract-handler/utils/index.js +12 -0
  55. package/koni/api/contract-handler/utils/polygon_bridge_abi.json +1004 -0
  56. package/koni/api/nft/config.d.ts +1 -1
  57. package/koni/api/nft/config.js +5 -2
  58. package/koni/api/nft/index.js +9 -0
  59. package/koni/api/nft/story_odyssey_nft/index.d.ts +40 -0
  60. package/koni/api/nft/story_odyssey_nft/index.js +119 -0
  61. package/koni/background/handlers/Extension.d.ts +5 -0
  62. package/koni/background/handlers/Extension.js +65 -5
  63. package/koni/background/handlers/State.d.ts +5 -0
  64. package/koni/background/handlers/State.js +23 -2
  65. package/package.json +76 -18
  66. package/packageInfo.js +1 -1
  67. package/services/balance-service/helpers/subscribe/substrate/index.js +2 -1
  68. package/services/balance-service/transfer/xcm/index.d.ts +1 -0
  69. package/services/balance-service/transfer/xcm/index.js +29 -1
  70. package/services/balance-service/transfer/xcm/polygonBridge.d.ts +22 -0
  71. package/services/balance-service/transfer/xcm/polygonBridge.js +95 -0
  72. package/services/chain-online-service/constants.d.ts +4 -0
  73. package/services/chain-online-service/constants.js +23 -0
  74. package/services/chain-online-service/index.d.ts +22 -0
  75. package/services/chain-online-service/index.js +182 -0
  76. package/services/chain-service/constants.d.ts +1 -0
  77. package/services/chain-service/constants.js +2 -1
  78. package/services/chain-service/index.d.ts +6 -7
  79. package/services/chain-service/index.js +78 -116
  80. package/services/chain-service/utils/index.js +0 -2
  81. package/services/chain-service/utils/patch.d.ts +16 -1
  82. package/services/chain-service/utils/patch.js +7 -3
  83. package/services/earning-service/handlers/native-staking/para-chain.js +20 -17
  84. package/services/environment-service/stores/Environment.d.ts +10 -0
  85. package/services/environment-service/stores/Environment.js +12 -0
  86. package/services/fee-service/utils/index.js +14 -0
  87. package/services/inapp-notification-service/consts.d.ts +3 -1
  88. package/services/inapp-notification-service/consts.js +6 -4
  89. package/services/inapp-notification-service/index.d.ts +10 -2
  90. package/services/inapp-notification-service/index.js +111 -7
  91. package/services/inapp-notification-service/interfaces.d.ts +27 -3
  92. package/services/inapp-notification-service/interfaces.js +7 -0
  93. package/services/inapp-notification-service/utils/avail.d.ts +40 -0
  94. package/services/inapp-notification-service/utils/avail.js +73 -0
  95. package/services/inapp-notification-service/utils/common.d.ts +11 -0
  96. package/services/inapp-notification-service/{utils.js → utils/common.js} +1 -72
  97. package/services/inapp-notification-service/utils/index.d.ts +3 -0
  98. package/services/inapp-notification-service/utils/index.js +6 -0
  99. package/services/inapp-notification-service/utils/polygon.d.ts +71 -0
  100. package/services/inapp-notification-service/utils/polygon.js +54 -0
  101. package/services/migration-service/scripts/MigrateTransactionHistoryBridge.d.ts +4 -0
  102. package/services/migration-service/scripts/MigrateTransactionHistoryBridge.js +29 -0
  103. package/services/migration-service/scripts/index.js +3 -1
  104. package/services/setting-service/SettingService.d.ts +9 -0
  105. package/services/setting-service/SettingService.js +21 -0
  106. package/services/setting-service/constants.js +2 -1
  107. package/services/storage-service/DatabaseService.d.ts +1 -0
  108. package/services/storage-service/DatabaseService.js +3 -0
  109. package/services/transaction-service/index.js +14 -8
  110. package/services/transaction-service/utils.js +3 -0
  111. package/stores/ChainlistStore.d.ts +7 -0
  112. package/stores/ChainlistStore.js +10 -0
  113. package/stores/EnvironmentStore.d.ts +5 -0
  114. package/stores/EnvironmentStore.js +10 -0
  115. package/stores/index.d.ts +1 -0
  116. package/stores/index.js +2 -1
  117. package/types/{avail-bridge → bridge}/index.d.ts +1 -1
  118. package/types/index.d.ts +1 -0
  119. package/types/index.js +1 -0
  120. package/types/notification/index.d.ts +5 -0
  121. package/utils/account/transform.js +1 -1
  122. package/utils/environment.d.ts +6 -0
  123. package/utils/environment.js +8 -0
  124. package/utils/staticData/blockedActions.json +1 -0
  125. package/utils/staticData/index.d.ts +7 -3
  126. package/utils/staticData/index.js +5 -1
  127. package/cjs/constants/blocked-actions-list.js +0 -14
  128. package/constants/blocked-actions-list.d.ts +0 -7
  129. package/constants/blocked-actions-list.js +0 -7
  130. package/services/inapp-notification-service/utils.d.ts +0 -55
  131. /package/cjs/types/{avail-bridge → bridge}/index.js +0 -0
  132. /package/types/{avail-bridge → bridge}/index.js +0 -0
@@ -3,9 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.NotificationTimePeriod = exports.NotificationTab = exports.NotificationActionType = void 0;
6
+ exports.NotificationTimePeriod = exports.NotificationTab = exports.NotificationActionType = exports.BridgeTransactionStatus = void 0;
7
7
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
8
8
  // SPDX-License-Identifier: Apache-2.0
9
+ let BridgeTransactionStatus;
10
+ exports.BridgeTransactionStatus = BridgeTransactionStatus;
11
+ (function (BridgeTransactionStatus) {
12
+ BridgeTransactionStatus["READY_TO_CLAIM"] = "READY_TO_CLAIM";
13
+ BridgeTransactionStatus["CLAIMED"] = "CLAIMED";
14
+ BridgeTransactionStatus["BRIDGED"] = "BRIDGED";
15
+ })(BridgeTransactionStatus || (exports.BridgeTransactionStatus = BridgeTransactionStatus = {}));
9
16
  let NotificationTimePeriod;
10
17
  exports.NotificationTimePeriod = NotificationTimePeriod;
11
18
  (function (NotificationTimePeriod) {
@@ -22,6 +29,7 @@ exports.NotificationActionType = NotificationActionType;
22
29
  NotificationActionType["CLAIM"] = "CLAIM";
23
30
  NotificationActionType["CLAIM_AVAIL_BRIDGE_ON_AVAIL"] = "CLAIM_AVAIL_BRIDGE_ON_AVAIL";
24
31
  NotificationActionType["CLAIM_AVAIL_BRIDGE_ON_ETHEREUM"] = "CLAIM_AVAIL_BRIDGE_ON_ETHEREUM";
32
+ NotificationActionType["CLAIM_POLYGON_BRIDGE"] = "CLAIM_POLYGON_BRIDGE";
25
33
  })(NotificationActionType || (exports.NotificationActionType = NotificationActionType = {}));
26
34
  let NotificationTab;
27
35
  exports.NotificationTab = NotificationTab;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AvailBridgeSourceChain = exports.AVAIL_BRIDGE_INDEXER = exports.AVAIL_BRIDGE_API = void 0;
7
+ exports.fetchAllAvailBridgeClaimable = fetchAllAvailBridgeClaimable;
8
+ exports.fetchAvailBridgeTransactions = fetchAvailBridgeTransactions;
9
+ exports.filterClaimableOfAddress = filterClaimableOfAddress;
10
+ exports.getAvailBridgeClaimDescription = getAvailBridgeClaimDescription;
11
+ var _interfaces = require("../interfaces");
12
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
13
+ // SPDX-License-Identifier: Apache-2.0
14
+
15
+ /* Description */
16
+ function getAvailBridgeClaimDescription(amount, symbol) {
17
+ return `${amount} ${symbol} ready to claim from ${symbol} cross-chain transfer. Click to claim now!`;
18
+ }
19
+ /* Description */
20
+
21
+ // todo: can refactor utils and const of avail bridge to a new file. Also check in /transfer/xcm/availBridge.ts file
22
+
23
+ const AVAIL_BRIDGE_INDEXER = {
24
+ AVAIL_MAINNET: 'https://bridge-indexer.avail.so',
25
+ AVAIL_TESTNET: 'https://turing-bridge-indexer.fra.avail.so'
26
+ };
27
+ exports.AVAIL_BRIDGE_INDEXER = AVAIL_BRIDGE_INDEXER;
28
+ const AVAIL_BRIDGE_API = {
29
+ AVAIL_MAINNET: 'https://bridge-api.avail.so',
30
+ AVAIL_TESTNET: 'https://turing-bridge-api.fra.avail.so'
31
+ };
32
+ exports.AVAIL_BRIDGE_API = AVAIL_BRIDGE_API;
33
+ let AvailBridgeSourceChain;
34
+ exports.AvailBridgeSourceChain = AvailBridgeSourceChain;
35
+ (function (AvailBridgeSourceChain) {
36
+ AvailBridgeSourceChain["AVAIL"] = "AVAIL";
37
+ AvailBridgeSourceChain["ETHEREUM"] = "ETHEREUM";
38
+ })(AvailBridgeSourceChain || (exports.AvailBridgeSourceChain = AvailBridgeSourceChain = {}));
39
+ async function fetchAllAvailBridgeClaimable(address, sourceChain, isTestnet) {
40
+ const transactions = [];
41
+ let isContinue = true;
42
+ let page = 0;
43
+ const pageSize = 100;
44
+ while (isContinue) {
45
+ const response = await fetchAvailBridgeTransactions(address, sourceChain, _interfaces.BridgeTransactionStatus.READY_TO_CLAIM, pageSize, page, isTestnet);
46
+ if (!response) {
47
+ break;
48
+ }
49
+ transactions.push(...filterClaimableOfAddress(address, response.data.result));
50
+ isContinue = response.data.paginationData.hasNextPage;
51
+ page = page + 1;
52
+ }
53
+ return transactions;
54
+ }
55
+ async function fetchAvailBridgeTransactions(userAddress, sourceChain, status) {
56
+ let pageSize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 100;
57
+ let page = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
58
+ let isTestnet = arguments.length > 5 ? arguments[5] : undefined;
59
+ const params = new URLSearchParams({
60
+ userAddress,
61
+ sourceChain,
62
+ status,
63
+ pageSize: pageSize.toString(),
64
+ page: page.toString()
65
+ });
66
+ try {
67
+ const api = isTestnet ? AVAIL_BRIDGE_INDEXER.AVAIL_TESTNET : AVAIL_BRIDGE_INDEXER.AVAIL_MAINNET;
68
+ const rawResponse = await fetch(`${api}/transactions?${params.toString()}`, {
69
+ method: 'GET',
70
+ headers: {
71
+ 'Content-Type': 'application/json',
72
+ 'Access-Control-Allow-Origin': '*'
73
+ },
74
+ credentials: 'omit'
75
+ });
76
+ if (!rawResponse.ok) {
77
+ console.error('Error fetching claimable bridge transactions');
78
+ return undefined;
79
+ }
80
+ return await rawResponse.json();
81
+ } catch (e) {
82
+ console.error(e);
83
+ return undefined;
84
+ }
85
+ }
86
+ function filterClaimableOfAddress(address, transactions) {
87
+ return transactions.filter(transaction => transaction.receiverAddress.toLowerCase() === address.toLowerCase());
88
+ }
@@ -3,13 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.AvailBridgeTransactionStatus = exports.AvailBridgeSourceChain = exports.AVAIL_BRIDGE_INDEXER = exports.AVAIL_BRIDGE_API = void 0;
7
6
  exports.createClaimNotification = createClaimNotification;
8
7
  exports.createWithdrawNotifications = createWithdrawNotifications;
9
- exports.fetchAllAvailBridgeClaimable = fetchAllAvailBridgeClaimable;
10
- exports.fetchAvailBridgeTransactions = fetchAvailBridgeTransactions;
11
- exports.filterClaimableOfAddress = filterClaimableOfAddress;
12
- exports.getAvailBridgeClaimDescription = getAvailBridgeClaimDescription;
13
8
  exports.getClaimDescription = getClaimDescription;
14
9
  exports.getIsTabRead = getIsTabRead;
15
10
  exports.getReceiveDescription = getReceiveDescription;
@@ -41,9 +36,7 @@ function getSendDescription(amount, symbol) {
41
36
  function getReceiveDescription(amount, symbol) {
42
37
  return `You have just received ${amount} ${symbol}`;
43
38
  }
44
- function getAvailBridgeClaimDescription(amount, symbol) {
45
- return `${amount} ${symbol} ready to claim from ${symbol} cross-chain transfer. Click to claim now!`;
46
- }
39
+
47
40
  /* Description */
48
41
 
49
42
  function getIsTabRead(notificationTab) {
@@ -116,82 +109,6 @@ function createClaimNotification(claimItemInfo, tokenInfo) {
116
109
  }
117
110
  };
118
111
  }
119
-
120
- // todo: can refactor utils and const of avail bridge to a new file. Also check in /transfer/xcm/availBridge.ts file
121
-
122
- const AVAIL_BRIDGE_INDEXER = {
123
- AVAIL_MAINNET: 'https://bridge-indexer.avail.so',
124
- AVAIL_TESTNET: 'https://turing-bridge-indexer.fra.avail.so'
125
- };
126
- exports.AVAIL_BRIDGE_INDEXER = AVAIL_BRIDGE_INDEXER;
127
- const AVAIL_BRIDGE_API = {
128
- AVAIL_MAINNET: 'https://bridge-api.avail.so',
129
- AVAIL_TESTNET: 'https://turing-bridge-api.fra.avail.so'
130
- };
131
- exports.AVAIL_BRIDGE_API = AVAIL_BRIDGE_API;
132
- let AvailBridgeTransactionStatus;
133
- exports.AvailBridgeTransactionStatus = AvailBridgeTransactionStatus;
134
- (function (AvailBridgeTransactionStatus) {
135
- AvailBridgeTransactionStatus["READY_TO_CLAIM"] = "READY_TO_CLAIM";
136
- AvailBridgeTransactionStatus["CLAIMED"] = "CLAIMED";
137
- AvailBridgeTransactionStatus["BRIDGED"] = "BRIDGED";
138
- })(AvailBridgeTransactionStatus || (exports.AvailBridgeTransactionStatus = AvailBridgeTransactionStatus = {}));
139
- let AvailBridgeSourceChain;
140
- exports.AvailBridgeSourceChain = AvailBridgeSourceChain;
141
- (function (AvailBridgeSourceChain) {
142
- AvailBridgeSourceChain["AVAIL"] = "AVAIL";
143
- AvailBridgeSourceChain["ETHEREUM"] = "ETHEREUM";
144
- })(AvailBridgeSourceChain || (exports.AvailBridgeSourceChain = AvailBridgeSourceChain = {}));
145
- async function fetchAllAvailBridgeClaimable(address, sourceChain, isTestnet) {
146
- const transactions = [];
147
- let isContinue = true;
148
- let page = 0;
149
- const pageSize = 100;
150
- while (isContinue) {
151
- const response = await fetchAvailBridgeTransactions(address, sourceChain, AvailBridgeTransactionStatus.READY_TO_CLAIM, pageSize, page, isTestnet);
152
- if (!response) {
153
- break;
154
- }
155
- transactions.push(...filterClaimableOfAddress(address, response.data.result));
156
- isContinue = response.data.paginationData.hasNextPage;
157
- page = page + 1;
158
- }
159
- return transactions;
160
- }
161
- async function fetchAvailBridgeTransactions(userAddress, sourceChain, status) {
162
- let pageSize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 100;
163
- let page = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
164
- let isTestnet = arguments.length > 5 ? arguments[5] : undefined;
165
- const params = new URLSearchParams({
166
- userAddress,
167
- sourceChain,
168
- status,
169
- pageSize: pageSize.toString(),
170
- page: page.toString()
171
- });
172
- try {
173
- const api = isTestnet ? AVAIL_BRIDGE_INDEXER.AVAIL_TESTNET : AVAIL_BRIDGE_INDEXER.AVAIL_MAINNET;
174
- const rawResponse = await fetch(`${api}/transactions?${params.toString()}`, {
175
- method: 'GET',
176
- headers: {
177
- 'Content-Type': 'application/json',
178
- 'Access-Control-Allow-Origin': '*'
179
- },
180
- credentials: 'omit'
181
- });
182
- if (!rawResponse.ok) {
183
- console.error('Error fetching claimable bridge transactions');
184
- return undefined;
185
- }
186
- return await rawResponse.json();
187
- } catch (e) {
188
- console.error(e);
189
- return undefined;
190
- }
191
- }
192
- function filterClaimableOfAddress(address, transactions) {
193
- return transactions.filter(transaction => transaction.receiverAddress.toLowerCase() === address.toLowerCase());
194
- }
195
112
  function hrsToMillisecond(hours) {
196
113
  return hours * 60 * 60 * 1000;
197
114
  }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _avail = require("./avail");
7
+ Object.keys(_avail).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _avail[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _avail[key];
14
+ }
15
+ });
16
+ });
17
+ var _common = require("./common");
18
+ Object.keys(_common).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _common[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _common[key];
25
+ }
26
+ });
27
+ });
28
+ var _polygon = require("./polygon");
29
+ Object.keys(_polygon).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _polygon[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _polygon[key];
36
+ }
37
+ });
38
+ });
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.POLYGON_BRIDGE_INDEXER = void 0;
7
+ exports.fetchAndFilterPolygonTransactionById = fetchAndFilterPolygonTransactionById;
8
+ exports.fetchPolygonBridgeTransactions = fetchPolygonBridgeTransactions;
9
+ exports.getPolygonBridgeClaimDescription = getPolygonBridgeClaimDescription;
10
+ var _interfaces = require("../interfaces");
11
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
12
+ // SPDX-License-Identifier: Apache-2.0
13
+
14
+ const POLYGON_BRIDGE_INDEXER = {
15
+ MAINNET: 'https://api-gateway.polygon.technology/api/v3/transactions/mainnet',
16
+ TESTNET: 'https://api-gateway.polygon.technology/api/v3/transactions/testnet'
17
+ };
18
+ exports.POLYGON_BRIDGE_INDEXER = POLYGON_BRIDGE_INDEXER;
19
+ /* Description */
20
+ function getPolygonBridgeClaimDescription(amount, symbol) {
21
+ return `${amount} ${symbol} ready to claim from ${symbol} cross-chain transfer. Click to claim now!`;
22
+ }
23
+ /* Description */
24
+
25
+ async function fetchPolygonBridgeTransactions(userAddress, isTestnet) {
26
+ let pageSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 500;
27
+ let page = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
28
+ const params = new URLSearchParams({
29
+ userAddress,
30
+ pageSize: pageSize.toString(),
31
+ page: page.toString()
32
+ });
33
+ const networkIds = [0, 1];
34
+ networkIds.forEach(networkId => {
35
+ params.append('destinationNetworkIds', networkId.toString());
36
+ params.append('sourceNetworkIds', networkId.toString());
37
+ params.append('status', _interfaces.BridgeTransactionStatus.READY_TO_CLAIM);
38
+ });
39
+ try {
40
+ const domain = isTestnet ? POLYGON_BRIDGE_INDEXER.TESTNET : POLYGON_BRIDGE_INDEXER.MAINNET;
41
+ const rawResponse = await fetch(`${domain}?${params.toString()}`, {
42
+ method: 'GET',
43
+ headers: {
44
+ 'Content-Type': 'application/json',
45
+ 'Access-Control-Allow-Origin': '*',
46
+ 'x-api-key': 'polygonag_4RFN-g_wt2o12GmK9WWOWrGf-4Hamhtd'
47
+ },
48
+ credentials: 'omit'
49
+ });
50
+ if (!rawResponse.ok) {
51
+ console.error('Error fetching claimable bridge transactions');
52
+ return undefined;
53
+ }
54
+ return await rawResponse.json();
55
+ } catch (e) {
56
+ console.error(e);
57
+ return undefined;
58
+ }
59
+ }
60
+ async function fetchAndFilterPolygonTransactionById(transactionId, userAddress, isTestnet) {
61
+ const response = await fetchPolygonBridgeTransactions(userAddress, isTestnet);
62
+ if (!response || !response.success) {
63
+ return undefined;
64
+ }
65
+ return response.result.find(tx => tx._id === transactionId);
66
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
9
+ var _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
10
+ var _dexie = _interopRequireDefault(require("dexie"));
11
+ // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
12
+ // SPDX-License-Identifier: Apache-2.0
13
+
14
+ class MigrateTransactionHistoryBridge extends _Base.default {
15
+ async run() {
16
+ const state = this.state;
17
+ const newTransactionItems = [];
18
+ try {
19
+ const db = new _dexie.default('SubWalletDB_v2');
20
+ const dexieDB = await db.open();
21
+ const transactionTable = dexieDB.table('transactions');
22
+ const oldTransactionData = await transactionTable.toArray();
23
+ const claimAvailBridgeTransactions = oldTransactionData.filter(item => item.type === 'claim.claim_avail_bridge');
24
+ claimAvailBridgeTransactions.forEach(item => {
25
+ const newItem = {
26
+ ...item,
27
+ type: _KoniTypes.ExtrinsicType.CLAIM_BRIDGE
28
+ };
29
+ newTransactionItems.push(newItem);
30
+ });
31
+ await state.dbService.upsertHistory(newTransactionItems);
32
+ } catch (e) {
33
+ this.logger.error(e);
34
+ }
35
+ }
36
+ }
37
+ exports.default = MigrateTransactionHistoryBridge;
@@ -31,6 +31,7 @@ var _MigrateNetworkSettings = _interopRequireDefault(require("./MigrateNetworkSe
31
31
  var _MigrateSettings = _interopRequireDefault(require("./MigrateSettings"));
32
32
  var _MigrateTokenDecimals = _interopRequireDefault(require("./MigrateTokenDecimals"));
33
33
  var _MigrateTransactionHistory = _interopRequireDefault(require("./MigrateTransactionHistory"));
34
+ var _MigrateTransactionHistoryBridge = _interopRequireDefault(require("./MigrateTransactionHistoryBridge"));
34
35
  var _MigrateTransactionHistoryBySymbol = _interopRequireDefault(require("./MigrateTransactionHistoryBySymbol"));
35
36
  var _MigrateWalletReference = _interopRequireDefault(require("./MigrateWalletReference"));
36
37
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
@@ -67,7 +68,8 @@ var _default = {
67
68
  '1.2.69-01': _MigrateRemoveGenesisHash.default,
68
69
  '1.2.13-01': _ReloadMetadata.default,
69
70
  '1.2.14-01': _ClearMetadataDatabase.default,
70
- '1.2.32-01': _MigratePairData.default
71
+ '1.2.32-01': _MigratePairData.default,
72
+ '1.3.6-01': _MigrateTransactionHistoryBridge.default
71
73
  // [`${EVERYTIME}-1.1.42-02`]: MigrateTransactionHistoryBySymbol
72
74
  // [`${EVERYTIME}-1`]: AutoEnableChainsTokens
73
75
  };
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _constants = require("@subwallet/extension-base/constants");
9
+ var _Environment = require("@subwallet/extension-base/services/environment-service/stores/Environment");
9
10
  var _storage = require("@subwallet/extension-base/storage");
11
+ var _ChainlistStore = _interopRequireDefault(require("@subwallet/extension-base/stores/ChainlistStore"));
10
12
  var _PassPhishingStore = _interopRequireDefault(require("@subwallet/extension-base/stores/PassPhishingStore"));
11
13
  var _Settings = _interopRequireDefault(require("@subwallet/extension-base/stores/Settings"));
12
14
  var _i18n = _interopRequireDefault(require("./i18n/i18n"));
@@ -17,6 +19,8 @@ var _constants2 = require("./constants");
17
19
  class SettingService {
18
20
  settingsStore = new _Settings.default();
19
21
  passPhishingStore = new _PassPhishingStore.default();
22
+ chainlistStore = new _ChainlistStore.default();
23
+ environmentStore = new _Environment.EnvironmentStoreSubject();
20
24
  constructor() {
21
25
  this.initSetting().catch(console.error);
22
26
  }
@@ -69,6 +73,23 @@ class SettingService {
69
73
  setPassPhishing(data, callback) {
70
74
  this.passPhishingStore.set('PassPhishing', data, callback);
71
75
  }
76
+ getChainlistSetting() {
77
+ return this.chainlistStore.asyncGet('Chainlist');
78
+ }
79
+ setChainlist(data, callback) {
80
+ this.chainlistStore.set('Chainlist', data, callback);
81
+ }
82
+ getEnvironmentSetting() {
83
+ return this.environmentStore.subject.value;
84
+ }
85
+ getEnvironmentList(update) {
86
+ this.environmentStore.store.get('Environment', value => {
87
+ update(value || {});
88
+ });
89
+ }
90
+ setEnvironment(data) {
91
+ this.environmentStore.upsertData(data);
92
+ }
72
93
 
73
94
  // Use for mobile only
74
95
  get isAlwaysRequired() {
@@ -38,7 +38,8 @@ const DEFAULT_NOTIFICATION_SETUP = {
38
38
  // receive: true,
39
39
  earningClaim: true,
40
40
  earningWithdraw: true,
41
- availBridgeClaim: true
41
+ availBridgeClaim: true,
42
+ polygonBridgeClaim: true
42
43
  // isHideWithdraw: false, // todo: just for test, remove later
43
44
  // isHideMarketing: false,
44
45
  // isHideAnnouncement: false
@@ -343,6 +343,9 @@ class DatabaseService {
343
343
  async updateAssetStore(item) {
344
344
  return this.stores.asset.upsert(item);
345
345
  }
346
+ async bulkUpdateAssetsStore(items) {
347
+ return this.stores.asset.bulkUpsert(items);
348
+ }
346
349
  async getAllAssetStore() {
347
350
  return this.stores.asset.getAll();
348
351
  }
@@ -77,12 +77,18 @@ class TransactionService {
77
77
  extrinsicType
78
78
  } = validationResponse;
79
79
  const chainInfo = this.state.chainService.getChainInfoByKey(chain);
80
- const {
81
- blockedActionsMap,
82
- blockedFeaturesList
83
- } = await (0, _constants.fetchLastestBlockedActionsAndFeatures)();
84
- (0, _transfer.checkSupportForFeature)(validationResponse, blockedFeaturesList, chainInfo);
85
- (0, _transfer.checkSupportForAction)(validationResponse, blockedActionsMap);
80
+ const blockedConfigObjects = await (0, _constants.fetchBlockedConfigObjects)();
81
+ const currentConfig = this.state.settingService.getEnvironmentSetting();
82
+ const passBlockedConfigId = (0, _constants.getPassConfigId)(currentConfig, blockedConfigObjects);
83
+ const blockedActionsFeaturesMaps = await (0, _constants.fetchLastestBlockedActionsAndFeatures)(passBlockedConfigId);
84
+ for (const blockedActionsFeaturesMap of blockedActionsFeaturesMaps) {
85
+ const {
86
+ blockedActionsMap,
87
+ blockedFeaturesList
88
+ } = blockedActionsFeaturesMap;
89
+ (0, _transfer.checkSupportForFeature)(validationResponse, blockedFeaturesList, chainInfo);
90
+ (0, _transfer.checkSupportForAction)(validationResponse, blockedActionsMap);
91
+ }
86
92
  const transaction = transactionInput.transaction;
87
93
 
88
94
  // Check duplicated transaction
@@ -586,7 +592,7 @@ class TransactionService {
586
592
  historyItem.additionalInfo = data;
587
593
  break;
588
594
  }
589
- case _KoniTypes.ExtrinsicType.CLAIM_AVAIL_BRIDGE:
595
+ case _KoniTypes.ExtrinsicType.CLAIM_BRIDGE:
590
596
  {
591
597
  const data = (0, _utils3.parseTransactionData)(transaction.data); // TODO: switch by provider
592
598
  const metadata = data.notification.metadata;
@@ -42,6 +42,9 @@ function getBlockExplorerAccountRoute(explorerLink) {
42
42
  if (explorerLink.includes('explorer.zkverify.io')) {
43
43
  return 'account';
44
44
  }
45
+ if (explorerLink.includes('astral.autonomys')) {
46
+ return 'accounts';
47
+ }
45
48
  return 'address';
46
49
  }
47
50
  function getBlockExplorerTxRoute(chainInfo) {
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _defaults = require("@subwallet/extension-base/defaults");
9
+ var _SubscribableStore = _interopRequireDefault(require("@subwallet/extension-base/stores/SubscribableStore"));
10
+ // Copyright 2019-2022 @subwallet/extension-base
11
+ // SPDX-License-Identifier: Apache-2.0
12
+
13
+ class ChainlistStore extends _SubscribableStore.default {
14
+ constructor() {
15
+ super(_defaults.EXTENSION_PREFIX ? `${_defaults.EXTENSION_PREFIX}chainlist` : null);
16
+ }
17
+ }
18
+ exports.default = ChainlistStore;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _defaults = require("@subwallet/extension-base/defaults");
9
+ var _SubscribableStore = _interopRequireDefault(require("@subwallet/extension-base/stores/SubscribableStore"));
10
+ // Copyright 2019-2022 @subwallet/extension-base
11
+ // SPDX-License-Identifier: Apache-2.0
12
+
13
+ class EnvironmentStore extends _SubscribableStore.default {
14
+ constructor() {
15
+ super(_defaults.EXTENSION_PREFIX ? `${_defaults.EXTENSION_PREFIX}environment` : null);
16
+ }
17
+ }
18
+ exports.default = EnvironmentStore;
@@ -34,6 +34,12 @@ Object.defineProperty(exports, "CurrentCurrencyStore", {
34
34
  return _CurrentCurrencyStore.default;
35
35
  }
36
36
  });
37
+ Object.defineProperty(exports, "EnvironmentStore", {
38
+ enumerable: true,
39
+ get: function () {
40
+ return _EnvironmentStore.default;
41
+ }
42
+ });
37
43
  Object.defineProperty(exports, "MetadataStore", {
38
44
  enumerable: true,
39
45
  get: function () {
@@ -52,4 +58,5 @@ var _Accounts = _interopRequireDefault(require("./Accounts"));
52
58
  var _CurrentAccountStore = _interopRequireDefault(require("./CurrentAccountStore"));
53
59
  var _CurrentCurrencyStore = _interopRequireDefault(require("./CurrentCurrencyStore"));
54
60
  var _Metadata = _interopRequireDefault(require("./Metadata"));
55
- var _ModifyPairStore = _interopRequireDefault(require("./ModifyPairStore"));
61
+ var _ModifyPairStore = _interopRequireDefault(require("./ModifyPairStore"));
62
+ var _EnvironmentStore = _interopRequireDefault(require("./EnvironmentStore"));
@@ -25,6 +25,17 @@ Object.keys(_balance).forEach(function (key) {
25
25
  }
26
26
  });
27
27
  });
28
+ var _bridge = require("./bridge");
29
+ Object.keys(_bridge).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _bridge[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _bridge[key];
36
+ }
37
+ });
38
+ });
28
39
  var _buy = require("./buy");
29
40
  Object.keys(_buy).forEach(function (key) {
30
41
  if (key === "default" || key === "__esModule") return;
@@ -145,7 +145,7 @@ const EARN_QDOT_ACTIONS = [_KoniTypes.ExtrinsicType.MINT_QDOT, _KoniTypes.Extrin
145
145
  const EARN_STDOT_ACTIONS = [_KoniTypes.ExtrinsicType.MINT_STDOT, _KoniTypes.ExtrinsicType.REDEEM_STDOT, _KoniTypes.ExtrinsicType.UNSTAKE_STDOT];
146
146
  const EARN_VMANTA_ACTIONS = [_KoniTypes.ExtrinsicType.MINT_VMANTA, _KoniTypes.ExtrinsicType.REDEEM_VMANTA, _KoniTypes.ExtrinsicType.UNSTAKE_VMANTA];
147
147
  const EVM_ACTIONS = [_KoniTypes.ExtrinsicType.TOKEN_SPENDING_APPROVAL, _KoniTypes.ExtrinsicType.EVM_EXECUTE];
148
- const CLAIM_AVAIL_BRIDGE = [_KoniTypes.ExtrinsicType.CLAIM_AVAIL_BRIDGE];
148
+ const CLAIM_AVAIL_BRIDGE = [_KoniTypes.ExtrinsicType.CLAIM_BRIDGE];
149
149
  const OTHER_ACTIONS = [_KoniTypes.ExtrinsicType.TRANSFER_XCM, _KoniTypes.ExtrinsicType.SEND_NFT, _KoniTypes.ExtrinsicType.SWAP, _KoniTypes.ExtrinsicType.CROWDLOAN];
150
150
  const getAccountTransactionActions = (signMode, networkType, type, _meta, _specialNetwork) => {
151
151
  if ([_types2.AccountSignMode.PASSWORD, _types2.AccountSignMode.INJECTED].includes(signMode)) {
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.targetIsWeb = exports.targetIsMobile = exports.targetIsExtension = exports.osName = exports.isMobile = exports.isFirefox = exports.TARGET_ENV = exports.RuntimeInfo = exports.MODULE_SUPPORT = exports.BowserParser = void 0;
7
+ exports.targetIsWeb = exports.targetIsMobile = exports.targetIsExtension = exports.platformType = exports.platformModel = exports.osVersion = exports.osName = exports.isMobile = exports.isFirefox = exports.isBrave = exports.browserVersion = exports.browserName = exports.TARGET_ENV = exports.RuntimeInfo = exports.MODULE_SUPPORT = exports.BowserParser = void 0;
8
8
  var _mv = require("@subwallet/extension-base/utils/mv3");
9
9
  var _bowser = _interopRequireDefault(require("bowser"));
10
10
  var _KoniTypes = require("../background/KoniTypes");
@@ -72,13 +72,27 @@ const RuntimeInfo = detectRuntimeEnvironment();
72
72
  // Todo: Support more in backend case
73
73
  exports.RuntimeInfo = RuntimeInfo;
74
74
  const BowserParser = _bowser.default.getParser(typeof navigator !== 'undefined' ? ((_navigator3 = navigator) === null || _navigator3 === void 0 ? void 0 : _navigator3.userAgent) + '' : '');
75
+ // @ts-ignore
76
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
75
77
  exports.BowserParser = BowserParser;
78
+ const isBrave = navigator.brave !== undefined && navigator.brave.isBrave.name === 'isBrave';
79
+ exports.isBrave = isBrave;
76
80
  const isFirefox = BowserParser.getBrowserName(true) === 'firefox';
77
81
  exports.isFirefox = isFirefox;
82
+ const browserName = isBrave ? 'brave' : BowserParser.getBrowserName(true);
83
+ exports.browserName = browserName;
84
+ const browserVersion = BowserParser.getBrowserVersion();
85
+ exports.browserVersion = browserVersion;
78
86
  const osName = BowserParser.getOSName();
79
87
  exports.osName = osName;
88
+ const osVersion = BowserParser.getOSVersion();
89
+ exports.osVersion = osVersion;
80
90
  const isMobile = BowserParser.getPlatform().type === 'mobile';
81
91
  exports.isMobile = isMobile;
92
+ const platformType = BowserParser.getPlatform().type;
93
+ exports.platformType = platformType;
94
+ const platformModel = BowserParser.getPlatform().model;
95
+ exports.platformModel = platformModel;
82
96
  const TARGET_ENV = process.env.TARGET_ENV || 'extension';
83
97
  exports.TARGET_ENV = TARGET_ENV;
84
98
  const targetIsExtension = TARGET_ENV === 'extension';
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.termAndCondition = exports.staticData = exports.remindNotificationTime = exports.marketingCampaigns = exports.currencySymbol = exports.crowdloanFunds = exports.buyTokenConfigs = exports.buyServiceInfos = exports.blockedActionsFeatures = exports.StaticKey = void 0;
6
+ exports.termAndCondition = exports.staticData = exports.remindNotificationTime = exports.marketingCampaigns = exports.currencySymbol = exports.crowdloanFunds = exports.buyTokenConfigs = exports.buyServiceInfos = exports.blockedActionsFeatures = exports.blockedActions = exports.StaticKey = void 0;
7
7
  var _chainList = require("@subwallet/chain-list");
8
8
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
9
9
  // SPDX-License-Identifier: Apache-2.0
@@ -33,7 +33,10 @@ const blockedActionsFeatures = require('./blockedActionsFeatures.json');
33
33
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
34
34
  exports.blockedActionsFeatures = blockedActionsFeatures;
35
35
  const remindNotificationTime = require('./remindNotificationTime.json');
36
+ // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
36
37
  exports.remindNotificationTime = remindNotificationTime;
38
+ const blockedActions = require('./blockedActions.json');
39
+ exports.blockedActions = blockedActions;
37
40
  let StaticKey;
38
41
  exports.StaticKey = StaticKey;
39
42
  (function (StaticKey) {
@@ -46,6 +49,7 @@ exports.StaticKey = StaticKey;
46
49
  StaticKey["BUY_TOKEN_CONFIGS"] = "buy-token-configs";
47
50
  StaticKey["BLOCKED_ACTIONS_FEATURES"] = "blocked-actions-features";
48
51
  StaticKey["REMIND_NOTIFICATION_TIME"] = "remind-notification-time";
52
+ StaticKey["BLOCKED_ACTIONS"] = "blocked-actions";
49
53
  })(StaticKey || (exports.StaticKey = StaticKey = {}));
50
54
  const staticData = {
51
55
  [StaticKey.CHAINS]: Object.values(_chainList.ChainInfoMap),
@@ -56,6 +60,7 @@ const staticData = {
56
60
  [StaticKey.TERM_AND_CONDITION]: termAndCondition.default,
57
61
  [StaticKey.BUY_TOKEN_CONFIGS]: buyTokenConfigs,
58
62
  [StaticKey.BLOCKED_ACTIONS_FEATURES]: blockedActionsFeatures,
59
- [StaticKey.REMIND_NOTIFICATION_TIME]: remindNotificationTime
63
+ [StaticKey.REMIND_NOTIFICATION_TIME]: remindNotificationTime,
64
+ [StaticKey.BLOCKED_ACTIONS]: blockedActions
60
65
  };
61
66
  exports.staticData = staticData;