@subwallet/extension-base 1.2.30-0 → 1.2.32-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.
- package/background/KoniTypes.d.ts +2 -2
- package/cjs/constants/blocked-actions-list.js +15 -0
- package/cjs/constants/index.js +12 -0
- package/cjs/core/logic-validation/transfer.js +166 -0
- package/cjs/koni/background/handlers/Extension.js +31 -7
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/index.js +0 -3
- package/cjs/services/chain-service/handler/SubstrateApi.js +1 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +6 -6
- package/cjs/services/swap-service/handler/chainflip-handler.js +35 -13
- package/cjs/services/swap-service/utils.js +5 -3
- package/cjs/services/transaction-service/index.js +7 -1
- package/cjs/utils/staticData/index.js +7 -2
- package/constants/blocked-actions-list.d.ts +7 -0
- package/constants/blocked-actions-list.js +8 -0
- package/constants/index.d.ts +1 -0
- package/constants/index.js +2 -1
- package/core/logic-validation/transfer.d.ts +2 -0
- package/core/logic-validation/transfer.js +164 -0
- package/koni/background/handlers/Extension.js +32 -8
- package/package.json +16 -10
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/index.js +0 -3
- package/services/chain-service/handler/SubstrateApi.js +1 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +6 -6
- package/services/mkt-campaign-service/types.d.ts +4 -0
- package/services/swap-service/handler/chainflip-handler.d.ts +3 -2
- package/services/swap-service/handler/chainflip-handler.js +36 -14
- package/services/swap-service/utils.js +5 -3
- package/services/transaction-service/index.js +9 -3
- package/utils/staticData/blockedActionsFeatures.json +39 -0
- package/utils/staticData/index.d.ts +4 -1
- package/utils/staticData/index.js +5 -1
|
@@ -138,6 +138,170 @@ export function additionalValidateXcmTransfer(originTokenInfo, destinationTokenI
|
|
|
138
138
|
}
|
|
139
139
|
return [warning, error];
|
|
140
140
|
}
|
|
141
|
+
export function checkSupportForFeature(validationResponse, blockedFeaturesList, chainInfo) {
|
|
142
|
+
const extrinsicType = validationResponse.extrinsicType;
|
|
143
|
+
const chain = validationResponse.chain;
|
|
144
|
+
const currentFeature = `${extrinsicType}___${chain}`;
|
|
145
|
+
if (blockedFeaturesList.includes(currentFeature)) {
|
|
146
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.UNSUPPORTED, t(`Feature under maintenance on ${chainInfo.name} network. Try again later`)));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
export function checkSupportForAction(validationResponse, blockedActionsMap) {
|
|
150
|
+
const extrinsicType = validationResponse.extrinsicType;
|
|
151
|
+
let currentAction = '';
|
|
152
|
+
switch (extrinsicType) {
|
|
153
|
+
case ExtrinsicType.TRANSFER_BALANCE:
|
|
154
|
+
|
|
155
|
+
// eslint-disable-next-line no-fallthrough
|
|
156
|
+
case ExtrinsicType.TRANSFER_TOKEN:
|
|
157
|
+
{
|
|
158
|
+
const data = validationResponse.data;
|
|
159
|
+
const tokenSlug = data.tokenSlug;
|
|
160
|
+
currentAction = `${extrinsicType}___${tokenSlug}`;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
case ExtrinsicType.TRANSFER_XCM:
|
|
164
|
+
{
|
|
165
|
+
const data = validationResponse.data;
|
|
166
|
+
const tokenSlug = data.tokenSlug;
|
|
167
|
+
const destinationNetworkKey = data.destinationNetworkKey;
|
|
168
|
+
currentAction = `${extrinsicType}___${tokenSlug}___${destinationNetworkKey}`;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
case ExtrinsicType.SEND_NFT:
|
|
172
|
+
{
|
|
173
|
+
const data = validationResponse.data;
|
|
174
|
+
const networkKey = data.networkKey;
|
|
175
|
+
const collectionId = data.nftItem.collectionId;
|
|
176
|
+
currentAction = `${extrinsicType}___${networkKey}___${collectionId}`;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case ExtrinsicType.SWAP:
|
|
180
|
+
{
|
|
181
|
+
const data = validationResponse.data;
|
|
182
|
+
const pairSlug = data.quote.pair.slug;
|
|
183
|
+
const providerId = data.provider.id;
|
|
184
|
+
currentAction = `${extrinsicType}___${pairSlug}___${providerId}`;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
case ExtrinsicType.STAKING_BOND:
|
|
188
|
+
{
|
|
189
|
+
const data = validationResponse.data;
|
|
190
|
+
const chain = data.chain;
|
|
191
|
+
currentAction = `${extrinsicType}___${chain}`;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
case ExtrinsicType.STAKING_LEAVE_POOL:
|
|
195
|
+
{
|
|
196
|
+
const data = validationResponse.data;
|
|
197
|
+
const slug = data.slug;
|
|
198
|
+
currentAction = `${extrinsicType}___${slug}`;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
case ExtrinsicType.STAKING_UNBOND:
|
|
202
|
+
{
|
|
203
|
+
const data = validationResponse.data;
|
|
204
|
+
const chain = data.chain;
|
|
205
|
+
currentAction = `${extrinsicType}___${chain}`;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
case ExtrinsicType.STAKING_CLAIM_REWARD:
|
|
209
|
+
{
|
|
210
|
+
const data = validationResponse.data;
|
|
211
|
+
const slug = data.slug;
|
|
212
|
+
currentAction = `${extrinsicType}___${slug}`;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
case ExtrinsicType.STAKING_WITHDRAW:
|
|
216
|
+
{
|
|
217
|
+
const data = validationResponse.data;
|
|
218
|
+
const slug = data.slug;
|
|
219
|
+
currentAction = `${extrinsicType}___${slug}`;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
case ExtrinsicType.STAKING_COMPOUNDING:
|
|
223
|
+
{
|
|
224
|
+
const data = validationResponse.data;
|
|
225
|
+
const networkKey = data.networkKey;
|
|
226
|
+
currentAction = `${extrinsicType}___${networkKey}`;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
case ExtrinsicType.STAKING_CANCEL_COMPOUNDING:
|
|
230
|
+
{
|
|
231
|
+
const data = validationResponse.data;
|
|
232
|
+
const networkKey = data.networkKey;
|
|
233
|
+
currentAction = `${extrinsicType}___${networkKey}`;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
case ExtrinsicType.STAKING_CANCEL_UNSTAKE:
|
|
237
|
+
{
|
|
238
|
+
const data = validationResponse.data;
|
|
239
|
+
const slug = data.slug;
|
|
240
|
+
currentAction = `${extrinsicType}___${slug}`;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
case ExtrinsicType.JOIN_YIELD_POOL:
|
|
244
|
+
{
|
|
245
|
+
const data = validationResponse.data;
|
|
246
|
+
const slug = data.data.slug;
|
|
247
|
+
currentAction = `${extrinsicType}___${slug}`;
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
case ExtrinsicType.MINT_VDOT:
|
|
251
|
+
case ExtrinsicType.MINT_LDOT:
|
|
252
|
+
case ExtrinsicType.MINT_SDOT:
|
|
253
|
+
case ExtrinsicType.MINT_QDOT:
|
|
254
|
+
case ExtrinsicType.MINT_STDOT:
|
|
255
|
+
|
|
256
|
+
// eslint-disable-next-line no-fallthrough
|
|
257
|
+
case ExtrinsicType.MINT_VMANTA:
|
|
258
|
+
{
|
|
259
|
+
const data = validationResponse.data;
|
|
260
|
+
const slug = data.slug;
|
|
261
|
+
currentAction = `${extrinsicType}___${slug}`;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
case ExtrinsicType.REDEEM_VDOT:
|
|
265
|
+
case ExtrinsicType.REDEEM_LDOT:
|
|
266
|
+
case ExtrinsicType.REDEEM_SDOT:
|
|
267
|
+
case ExtrinsicType.REDEEM_QDOT:
|
|
268
|
+
case ExtrinsicType.REDEEM_STDOT:
|
|
269
|
+
|
|
270
|
+
// eslint-disable-next-line no-fallthrough
|
|
271
|
+
case ExtrinsicType.REDEEM_VMANTA:
|
|
272
|
+
{
|
|
273
|
+
const data = validationResponse.data;
|
|
274
|
+
const slug = data.slug;
|
|
275
|
+
currentAction = `${extrinsicType}___${slug}`;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
case ExtrinsicType.UNSTAKE_VDOT:
|
|
279
|
+
case ExtrinsicType.UNSTAKE_LDOT:
|
|
280
|
+
case ExtrinsicType.UNSTAKE_SDOT:
|
|
281
|
+
case ExtrinsicType.UNSTAKE_QDOT:
|
|
282
|
+
case ExtrinsicType.UNSTAKE_STDOT:
|
|
283
|
+
|
|
284
|
+
// eslint-disable-next-line no-fallthrough
|
|
285
|
+
case ExtrinsicType.UNSTAKE_VMANTA:
|
|
286
|
+
{
|
|
287
|
+
const data = validationResponse.data;
|
|
288
|
+
const slug = data.slug;
|
|
289
|
+
currentAction = `${extrinsicType}___${slug}`;
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
case ExtrinsicType.TOKEN_SPENDING_APPROVAL:
|
|
293
|
+
{
|
|
294
|
+
const data = validationResponse.data;
|
|
295
|
+
const chain = data.chain;
|
|
296
|
+
currentAction = `${extrinsicType}___${chain}`;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
const blockedActionsList = Object.values(blockedActionsMap).flat();
|
|
301
|
+
if (blockedActionsList.includes(currentAction)) {
|
|
302
|
+
validationResponse.errors.push(new TransactionError(BasicTxErrorType.UNSUPPORTED, t('Feature under maintenance. Try again later')));
|
|
303
|
+
}
|
|
304
|
+
}
|
|
141
305
|
|
|
142
306
|
// general validations
|
|
143
307
|
export function checkSupportForTransaction(validationResponse, transaction) {
|
|
@@ -34,7 +34,7 @@ import { isProposalExpired, isSupportWalletConnectChain, isSupportWalletConnectN
|
|
|
34
34
|
import { SWStorage } from '@subwallet/extension-base/storage';
|
|
35
35
|
import { AccountsStore } from '@subwallet/extension-base/stores';
|
|
36
36
|
import { YieldPoolType } from '@subwallet/extension-base/types';
|
|
37
|
-
import { BN_ZERO, convertSubjectInfoToAddresses, createTransactionFromRLP, isSameAddress, MODULE_SUPPORT, reformatAddress, signatureToHex, uniqueStringArray } from '@subwallet/extension-base/utils';
|
|
37
|
+
import { BN_ZERO, convertSubjectInfoToAddresses, createPromiseHandler, createTransactionFromRLP, isSameAddress, MODULE_SUPPORT, reformatAddress, signatureToHex, uniqueStringArray } from '@subwallet/extension-base/utils';
|
|
38
38
|
import { parseContractInput, parseEvmRlp } from '@subwallet/extension-base/utils/eth/parseTransaction';
|
|
39
39
|
import { metadataExpand } from '@subwallet/extension-chains';
|
|
40
40
|
import { createPair } from '@subwallet/keyring';
|
|
@@ -1375,6 +1375,10 @@ export default class KoniExtension {
|
|
|
1375
1375
|
withMasterPassword
|
|
1376
1376
|
}) {
|
|
1377
1377
|
const isPasswordValidated = this.validatePassword(file, password);
|
|
1378
|
+
const {
|
|
1379
|
+
promise,
|
|
1380
|
+
resolve
|
|
1381
|
+
} = createPromiseHandler();
|
|
1378
1382
|
if (isPasswordValidated) {
|
|
1379
1383
|
try {
|
|
1380
1384
|
this._saveCurrentAccountAddress(address, () => {
|
|
@@ -1389,10 +1393,12 @@ export default class KoniExtension {
|
|
|
1389
1393
|
});
|
|
1390
1394
|
}
|
|
1391
1395
|
this._addAddressToAuthList(address, isAllowed);
|
|
1396
|
+
resolve([address]);
|
|
1392
1397
|
});
|
|
1393
1398
|
if (this.#alwaysLock) {
|
|
1394
1399
|
this.keyringLock();
|
|
1395
1400
|
}
|
|
1401
|
+
return promise;
|
|
1396
1402
|
} catch (error) {
|
|
1397
1403
|
throw new Error(error.message);
|
|
1398
1404
|
}
|
|
@@ -1408,17 +1414,35 @@ export default class KoniExtension {
|
|
|
1408
1414
|
}) {
|
|
1409
1415
|
const addressList = accountsInfo.map(acc => acc.address);
|
|
1410
1416
|
const isPasswordValidated = this.validatedAccountsPassword(file, password);
|
|
1417
|
+
const {
|
|
1418
|
+
promise,
|
|
1419
|
+
resolve
|
|
1420
|
+
} = createPromiseHandler();
|
|
1411
1421
|
if (isPasswordValidated) {
|
|
1412
1422
|
try {
|
|
1413
1423
|
this._saveCurrentAccountAddress(ALL_ACCOUNT_KEY, () => {
|
|
1414
1424
|
keyring.restoreAccounts(file, password);
|
|
1415
1425
|
this.#koniState.keyringService.removeNoneHardwareGenesisHash();
|
|
1416
|
-
|
|
1426
|
+
const successAddressList = addressList.reduce((addressList, address) => {
|
|
1427
|
+
try {
|
|
1428
|
+
const account = keyring.getPair(address);
|
|
1429
|
+
if (account) {
|
|
1430
|
+
addressList.push(address);
|
|
1431
|
+
}
|
|
1432
|
+
} catch (error) {
|
|
1433
|
+
console.log(error);
|
|
1434
|
+
}
|
|
1435
|
+
return addressList;
|
|
1436
|
+
}, []);
|
|
1437
|
+
this._addAddressesToAuthList(successAddressList, isAllowed);
|
|
1438
|
+
resolve(successAddressList);
|
|
1417
1439
|
});
|
|
1418
1440
|
|
|
1419
1441
|
// if (this.#alwaysLock) {
|
|
1420
1442
|
// this.keyringLock();
|
|
1421
1443
|
// }
|
|
1444
|
+
|
|
1445
|
+
return promise;
|
|
1422
1446
|
} catch (error) {
|
|
1423
1447
|
throw new Error(error.message);
|
|
1424
1448
|
}
|
|
@@ -2968,14 +2992,14 @@ export default class KoniExtension {
|
|
|
2968
2992
|
} else {
|
|
2969
2993
|
metadata = await this.#koniState.chainService.getMetadataByHash(payload.genesisHash);
|
|
2970
2994
|
if (metadata) {
|
|
2971
|
-
var _chainInfo$substrateI, _chainInfo$substrateI2, _chainInfo$substrateI3;
|
|
2995
|
+
var _chainInfo$substrateI, _chainInfo$substrateI2, _chainInfo$substrateI3, _chainInfo$substrateI4;
|
|
2972
2996
|
registry = new TypeRegistry();
|
|
2973
2997
|
const _metadata = new Metadata(registry, metadata.hexValue);
|
|
2974
2998
|
registry.register(metadata.types);
|
|
2975
2999
|
registry.setChainProperties(registry.createType('ChainProperties', {
|
|
2976
|
-
ss58Format: (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
2977
|
-
tokenDecimals: chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
2978
|
-
tokenSymbol: chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
3000
|
+
ss58Format: (_chainInfo$substrateI = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI2 = chainInfo.substrateInfo) === null || _chainInfo$substrateI2 === void 0 ? void 0 : _chainInfo$substrateI2.addressPrefix) !== null && _chainInfo$substrateI !== void 0 ? _chainInfo$substrateI : 42,
|
|
3001
|
+
tokenDecimals: chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI3 = chainInfo.substrateInfo) === null || _chainInfo$substrateI3 === void 0 ? void 0 : _chainInfo$substrateI3.decimals,
|
|
3002
|
+
tokenSymbol: chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI4 = chainInfo.substrateInfo) === null || _chainInfo$substrateI4 === void 0 ? void 0 : _chainInfo$substrateI4.symbol
|
|
2979
3003
|
}));
|
|
2980
3004
|
registry.setMetadata(_metadata, payload.signedExtensions, metadata.userExtensions);
|
|
2981
3005
|
} else {
|
|
@@ -4301,9 +4325,9 @@ export default class KoniExtension {
|
|
|
4301
4325
|
case 'pri(accounts.batchExportV2)':
|
|
4302
4326
|
return this.batchExportV2(request);
|
|
4303
4327
|
case 'pri(json.restoreV2)':
|
|
4304
|
-
return this.jsonRestoreV2(request);
|
|
4328
|
+
return await this.jsonRestoreV2(request);
|
|
4305
4329
|
case 'pri(json.batchRestoreV2)':
|
|
4306
|
-
return this.batchRestoreV2(request);
|
|
4330
|
+
return await this.batchRestoreV2(request);
|
|
4307
4331
|
case 'pri(nft.getNft)':
|
|
4308
4332
|
return await this.getNft();
|
|
4309
4333
|
case 'pri(nft.getSubscription)':
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.2.
|
|
20
|
+
"version": "1.2.32-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -114,6 +114,11 @@
|
|
|
114
114
|
"require": "./cjs/constants/index.js",
|
|
115
115
|
"default": "./constants/index.js"
|
|
116
116
|
},
|
|
117
|
+
"./constants/blocked-actions-list": {
|
|
118
|
+
"types": "./constants/blocked-actions-list.d.ts",
|
|
119
|
+
"require": "./cjs/constants/blocked-actions-list.js",
|
|
120
|
+
"default": "./constants/blocked-actions-list.js"
|
|
121
|
+
},
|
|
117
122
|
"./constants/i18n": {
|
|
118
123
|
"types": "./constants/i18n.d.ts",
|
|
119
124
|
"require": "./cjs/constants/i18n.js",
|
|
@@ -2016,6 +2021,7 @@
|
|
|
2016
2021
|
"require": "./cjs/utils/staticData/index.js",
|
|
2017
2022
|
"default": "./utils/staticData/index.js"
|
|
2018
2023
|
},
|
|
2024
|
+
"./utils/staticData/blockedActionsFeatures.json": "./utils/staticData/blockedActionsFeatures.json",
|
|
2019
2025
|
"./utils/staticData/buyServiceInfos.json": "./utils/staticData/buyServiceInfos.json",
|
|
2020
2026
|
"./utils/staticData/buyTokenConfigs.json": "./utils/staticData/buyTokenConfigs.json",
|
|
2021
2027
|
"./utils/staticData/chains.json": "./utils/staticData/chains.json",
|
|
@@ -2038,12 +2044,12 @@
|
|
|
2038
2044
|
"@acala-network/api": "^5.0.2",
|
|
2039
2045
|
"@apollo/client": "^3.7.14",
|
|
2040
2046
|
"@azns/resolver-core": "^1.4.0",
|
|
2041
|
-
"@chainflip/sdk": "^1.
|
|
2047
|
+
"@chainflip/sdk": "^1.6.0",
|
|
2042
2048
|
"@equilab/api": "~1.14.25",
|
|
2043
2049
|
"@ethereumjs/common": "^4.1.0",
|
|
2044
2050
|
"@ethereumjs/tx": "^5.1.0",
|
|
2045
2051
|
"@ethersproject/abi": "^5.7.0",
|
|
2046
|
-
"@galacticcouncil/sdk": "^4.2.
|
|
2052
|
+
"@galacticcouncil/sdk": "^4.2.1",
|
|
2047
2053
|
"@gear-js/api": "^0.38.1",
|
|
2048
2054
|
"@json-rpc-tools/utils": "^1.7.6",
|
|
2049
2055
|
"@metamask/eth-sig-util": "^7.0.3",
|
|
@@ -2070,13 +2076,13 @@
|
|
|
2070
2076
|
"@reduxjs/toolkit": "^1.9.1",
|
|
2071
2077
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
2072
2078
|
"@substrate/connect": "^0.8.9",
|
|
2073
|
-
"@subwallet/chain-list": "0.2.
|
|
2074
|
-
"@subwallet/extension-base": "^1.2.
|
|
2075
|
-
"@subwallet/extension-chains": "^1.2.
|
|
2076
|
-
"@subwallet/extension-dapp": "^1.2.
|
|
2077
|
-
"@subwallet/extension-inject": "^1.2.
|
|
2078
|
-
"@subwallet/keyring": "^0.1.
|
|
2079
|
-
"@subwallet/ui-keyring": "^0.1.
|
|
2079
|
+
"@subwallet/chain-list": "0.2.88",
|
|
2080
|
+
"@subwallet/extension-base": "^1.2.32-0",
|
|
2081
|
+
"@subwallet/extension-chains": "^1.2.32-0",
|
|
2082
|
+
"@subwallet/extension-dapp": "^1.2.32-0",
|
|
2083
|
+
"@subwallet/extension-inject": "^1.2.32-0",
|
|
2084
|
+
"@subwallet/keyring": "^0.1.7",
|
|
2085
|
+
"@subwallet/ui-keyring": "^0.1.7",
|
|
2080
2086
|
"@walletconnect/keyvaluestorage": "^1.1.1",
|
|
2081
2087
|
"@walletconnect/sign-client": "^2.14.0",
|
|
2082
2088
|
"@walletconnect/types": "^2.14.0",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.2.
|
|
10
|
+
version: '1.2.32-0'
|
|
11
11
|
};
|
|
@@ -110,9 +110,6 @@ export function subscribeBalance(addresses, chains, tokens, _chainAssetMap, _cha
|
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
const substrateApi = await substrateApiMap[chainSlug].isReady;
|
|
113
|
-
if (!substrateApi.isApiReady) {
|
|
114
|
-
handleUnsupportedOrPendingAddresses(useAddresses, chainSlug, chainAssetMap, APIItemState.PENDING, callback);
|
|
115
|
-
}
|
|
116
113
|
return subscribeSubstrateBalance(useAddresses, chainInfo, chainAssetMap, substrateApi, evmApi, callback, extrinsicType);
|
|
117
114
|
});
|
|
118
115
|
return () => {
|
|
@@ -64,16 +64,16 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
64
64
|
const tvlCall = stakingContract.methods.fundRaisedBalance();
|
|
65
65
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
66
66
|
const exchangeRateCall = stakingContract.methods.getPooledTokenByShares(sampleTokenShare);
|
|
67
|
-
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
69
|
-
const [aprObject, tvl, equivalentTokenShare] = await Promise.all([aprPromise,
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
71
|
-
tvlCall.call(),
|
|
72
67
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
73
|
-
exchangeRateCall.call()
|
|
68
|
+
const equivalentTokenShare = await exchangeRateCall.call();
|
|
74
69
|
const rate = equivalentTokenShare;
|
|
75
70
|
const exchangeRate = rate / 10 ** _getAssetDecimals(derivativeTokenInfo);
|
|
76
71
|
this.updateExchangeRate(rate);
|
|
72
|
+
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
74
|
+
const [aprObject, tvl] = await Promise.all([aprPromise,
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
76
|
+
tvlCall.call()]);
|
|
77
77
|
return {
|
|
78
78
|
...this.baseInfo,
|
|
79
79
|
type: this.type,
|
|
@@ -92,12 +92,16 @@ export interface AppPopupData extends AppCommonData {
|
|
|
92
92
|
media: string;
|
|
93
93
|
buttons: AppContentButton[];
|
|
94
94
|
repeat_every_x_days: number | null;
|
|
95
|
+
ios_version_range: string;
|
|
96
|
+
app_version_range: string;
|
|
95
97
|
}
|
|
96
98
|
export interface AppBannerData extends AppCommonData {
|
|
97
99
|
priority: number;
|
|
98
100
|
media: string;
|
|
99
101
|
action: AppContentButtonAction;
|
|
100
102
|
instruction: AppContentButtonInstruction | null;
|
|
103
|
+
ios_version_range: string;
|
|
104
|
+
app_version_range: string;
|
|
101
105
|
}
|
|
102
106
|
export interface AppConfirmationData extends AppCommonData {
|
|
103
107
|
name: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Asset } from '@chainflip/sdk/swap';
|
|
1
2
|
import { COMMON_ASSETS } from '@subwallet/chain-list';
|
|
2
3
|
import { SwapError } from '@subwallet/extension-base/background/errors/SwapError';
|
|
3
4
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
@@ -18,8 +19,8 @@ export declare class ChainflipSwapHandler implements SwapBaseInterface {
|
|
|
18
19
|
get providerInfo(): import("@subwallet/extension-base/types/swap").SwapProvider;
|
|
19
20
|
get name(): string;
|
|
20
21
|
get slug(): string;
|
|
21
|
-
get assetMapping(): Record<string,
|
|
22
|
-
get chainMapping(): Record<string, import("@chainflip/sdk/dist/contracts-
|
|
22
|
+
get assetMapping(): Record<string, Asset>;
|
|
23
|
+
get chainMapping(): Record<string, import("@chainflip/sdk/dist/contracts-DmShvHR7").C>;
|
|
23
24
|
get intermediaryAssetSlug(): COMMON_ASSETS.USDC_ETHEREUM | COMMON_ASSETS.USDC_SEPOLIA;
|
|
24
25
|
validateSwapRequest(request: SwapRequest): Promise<SwapEarlyValidation>;
|
|
25
26
|
private parseSwapPath;
|
|
@@ -9,7 +9,7 @@ import { BasicTxErrorType, ChainType, ExtrinsicType } from '@subwallet/extension
|
|
|
9
9
|
import { _getChainflipEarlyValidationError } from '@subwallet/extension-base/core/logic-validation/swap';
|
|
10
10
|
import { getERC20TransactionObject, getEVMTransactionObject } from '@subwallet/extension-base/services/balance-service/transfer/smart-contract';
|
|
11
11
|
import { createTransferExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/token';
|
|
12
|
-
import { _getAssetDecimals, _getChainNativeTokenSlug, _getContractAddressOfToken, _isNativeToken, _isSubstrateChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
12
|
+
import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenSlug, _getContractAddressOfToken, _isNativeToken, _isSmartContractToken, _isSubstrateChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
13
13
|
import { SwapBaseHandler } from '@subwallet/extension-base/services/swap-service/handler/base-handler';
|
|
14
14
|
import { calculateSwapRate, CHAIN_FLIP_SUPPORTED_MAINNET_ASSET_MAPPING, CHAIN_FLIP_SUPPORTED_MAINNET_MAPPING, CHAIN_FLIP_SUPPORTED_TESTNET_ASSET_MAPPING, CHAIN_FLIP_SUPPORTED_TESTNET_MAPPING, getChainflipOptions, SWAP_QUOTE_TIMEOUT_MAP } from '@subwallet/extension-base/services/swap-service/utils';
|
|
15
15
|
import { CommonStepType } from '@subwallet/extension-base/types/service-base';
|
|
@@ -90,11 +90,12 @@ export class ChainflipSwapHandler {
|
|
|
90
90
|
const toAsset = this.chainService.getAssetBySlug(request.pair.to);
|
|
91
91
|
const srcChain = fromAsset.originChain;
|
|
92
92
|
const destChain = toAsset.originChain;
|
|
93
|
+
const isSwapCrossChain = srcChain !== destChain;
|
|
93
94
|
const srcChainInfo = this.chainService.getChainInfoByKey(srcChain);
|
|
94
95
|
const srcChainId = this.chainMapping[srcChain];
|
|
95
96
|
const destChainId = this.chainMapping[destChain];
|
|
96
|
-
const fromAssetId =
|
|
97
|
-
const toAssetId =
|
|
97
|
+
const fromAssetId = _getAssetSymbol(fromAsset);
|
|
98
|
+
const toAssetId = _getAssetSymbol(toAsset);
|
|
98
99
|
if (!srcChainId || !destChainId || !fromAssetId || !toAssetId) {
|
|
99
100
|
return {
|
|
100
101
|
error: SwapErrorType.ASSET_NOT_SUPPORTED
|
|
@@ -102,9 +103,21 @@ export class ChainflipSwapHandler {
|
|
|
102
103
|
}
|
|
103
104
|
const [supportedDestChains, srcAssets, destAssets] = await Promise.all([this.swapSdk.getChains(srcChainId), this.swapSdk.getAssets(srcChainId), this.swapSdk.getAssets(destChainId)]);
|
|
104
105
|
const supportedDestChainId = supportedDestChains.find(c => c.chain === destChainId);
|
|
105
|
-
const srcAssetData = srcAssets.find(a =>
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
const srcAssetData = srcAssets.find(a => {
|
|
107
|
+
if (_isSmartContractToken(fromAsset)) {
|
|
108
|
+
var _a$contractAddress;
|
|
109
|
+
return (a === null || a === void 0 ? void 0 : (_a$contractAddress = a.contractAddress) === null || _a$contractAddress === void 0 ? void 0 : _a$contractAddress.toLowerCase()) === _getContractAddressOfToken(fromAsset).toLowerCase() && a.asset === fromAssetId;
|
|
110
|
+
}
|
|
111
|
+
return a.asset === fromAssetId;
|
|
112
|
+
});
|
|
113
|
+
const destAssetData = destAssets.find(a => {
|
|
114
|
+
if (_isSmartContractToken(toAsset)) {
|
|
115
|
+
var _a$contractAddress2;
|
|
116
|
+
return (a === null || a === void 0 ? void 0 : (_a$contractAddress2 = a.contractAddress) === null || _a$contractAddress2 === void 0 ? void 0 : _a$contractAddress2.toLowerCase()) === _getContractAddressOfToken(toAsset).toLowerCase() && a.asset === toAssetId;
|
|
117
|
+
}
|
|
118
|
+
return a.asset === toAssetId;
|
|
119
|
+
});
|
|
120
|
+
if (!destAssetData || !srcAssetData || isSwapCrossChain && !supportedDestChainId) {
|
|
108
121
|
return {
|
|
109
122
|
error: SwapErrorType.UNKNOWN
|
|
110
123
|
};
|
|
@@ -200,8 +213,8 @@ export class ChainflipSwapHandler {
|
|
|
200
213
|
}
|
|
201
214
|
const srcChainId = this.chainMapping[fromAsset.originChain];
|
|
202
215
|
const destChainId = this.chainMapping[toAsset.originChain];
|
|
203
|
-
const fromAssetId =
|
|
204
|
-
const toAssetId =
|
|
216
|
+
const fromAssetId = _getAssetSymbol(fromAsset);
|
|
217
|
+
const toAssetId = _getAssetSymbol(toAsset);
|
|
205
218
|
try {
|
|
206
219
|
var _metadata$maxSwap;
|
|
207
220
|
const quoteResponse = await this.swapSdk.getQuote({
|
|
@@ -215,13 +228,22 @@ export class ChainflipSwapHandler {
|
|
|
215
228
|
quoteResponse.quote.includedFees.forEach(fee => {
|
|
216
229
|
switch (fee.type) {
|
|
217
230
|
case ChainflipFeeType.INGRESS:
|
|
231
|
+
{
|
|
232
|
+
console.log('ingress', fee);
|
|
233
|
+
feeComponent.push({
|
|
234
|
+
tokenSlug: fromAsset.slug,
|
|
235
|
+
amount: fee.amount,
|
|
236
|
+
feeType: SwapFeeType.NETWORK_FEE
|
|
237
|
+
});
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
218
240
|
|
|
219
241
|
// eslint-disable-next-line no-fallthrough
|
|
220
242
|
case ChainflipFeeType.EGRESS:
|
|
221
243
|
{
|
|
222
|
-
|
|
244
|
+
console.log('egress', fee);
|
|
223
245
|
feeComponent.push({
|
|
224
|
-
tokenSlug,
|
|
246
|
+
tokenSlug: toAsset.slug,
|
|
225
247
|
amount: fee.amount,
|
|
226
248
|
feeType: SwapFeeType.NETWORK_FEE
|
|
227
249
|
});
|
|
@@ -235,9 +257,9 @@ export class ChainflipSwapHandler {
|
|
|
235
257
|
// eslint-disable-next-line no-fallthrough
|
|
236
258
|
case ChainflipFeeType.BROKER:
|
|
237
259
|
{
|
|
238
|
-
|
|
260
|
+
console.log('broker fee', fee);
|
|
239
261
|
feeComponent.push({
|
|
240
|
-
tokenSlug,
|
|
262
|
+
tokenSlug: this.intermediaryAssetSlug,
|
|
241
263
|
amount: fee.amount,
|
|
242
264
|
feeType: SwapFeeType.PLATFORM_FEE
|
|
243
265
|
});
|
|
@@ -322,8 +344,8 @@ export class ChainflipSwapHandler {
|
|
|
322
344
|
const receiver = recipient !== null && recipient !== void 0 ? recipient : address;
|
|
323
345
|
const srcChainId = this.chainMapping[fromAsset.originChain];
|
|
324
346
|
const destChainId = this.chainMapping[toAsset.originChain];
|
|
325
|
-
const fromAssetId =
|
|
326
|
-
const toAssetId =
|
|
347
|
+
const fromAssetId = _getAssetSymbol(fromAsset);
|
|
348
|
+
const toAssetId = _getAssetSymbol(toAsset);
|
|
327
349
|
const depositAddressResponse = await this.swapSdk.requestDepositAddress({
|
|
328
350
|
srcChain: srcChainId,
|
|
329
351
|
destChain: destChainId,
|
|
@@ -11,7 +11,8 @@ export const CHAIN_FLIP_TESTNET_EXPLORER = 'https://blocks-perseverance.chainfli
|
|
|
11
11
|
export const CHAIN_FLIP_MAINNET_EXPLORER = 'https://scan.chainflip.io';
|
|
12
12
|
export const CHAIN_FLIP_SUPPORTED_MAINNET_MAPPING = {
|
|
13
13
|
[COMMON_CHAIN_SLUGS.POLKADOT]: Chains.Polkadot,
|
|
14
|
-
[COMMON_CHAIN_SLUGS.ETHEREUM]: Chains.Ethereum
|
|
14
|
+
[COMMON_CHAIN_SLUGS.ETHEREUM]: Chains.Ethereum,
|
|
15
|
+
[COMMON_CHAIN_SLUGS.ARBITRUM]: Chains.Arbitrum
|
|
15
16
|
};
|
|
16
17
|
export const CHAIN_FLIP_SUPPORTED_TESTNET_MAPPING = {
|
|
17
18
|
[COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA]: Chains.Ethereum,
|
|
@@ -20,7 +21,8 @@ export const CHAIN_FLIP_SUPPORTED_TESTNET_MAPPING = {
|
|
|
20
21
|
export const CHAIN_FLIP_SUPPORTED_MAINNET_ASSET_MAPPING = {
|
|
21
22
|
[COMMON_ASSETS.DOT]: Assets.DOT,
|
|
22
23
|
[COMMON_ASSETS.ETH]: Assets.ETH,
|
|
23
|
-
[COMMON_ASSETS.USDC_ETHEREUM]: Assets.USDC
|
|
24
|
+
[COMMON_ASSETS.USDC_ETHEREUM]: Assets.USDC,
|
|
25
|
+
[COMMON_ASSETS.USDT_ETHEREUM]: Assets.USDT
|
|
24
26
|
};
|
|
25
27
|
export const CHAIN_FLIP_SUPPORTED_TESTNET_ASSET_MAPPING = {
|
|
26
28
|
[COMMON_ASSETS.PDOT]: Assets.DOT,
|
|
@@ -36,7 +38,7 @@ export const SWAP_QUOTE_TIMEOUT_MAP = {
|
|
|
36
38
|
export const _PROVIDER_TO_SUPPORTED_PAIR_MAP = {
|
|
37
39
|
[SwapProviderId.HYDRADX_MAINNET]: [COMMON_CHAIN_SLUGS.HYDRADX],
|
|
38
40
|
[SwapProviderId.HYDRADX_TESTNET]: [COMMON_CHAIN_SLUGS.HYDRADX_TESTNET],
|
|
39
|
-
[SwapProviderId.CHAIN_FLIP_MAINNET]: [COMMON_CHAIN_SLUGS.POLKADOT, COMMON_CHAIN_SLUGS.ETHEREUM],
|
|
41
|
+
[SwapProviderId.CHAIN_FLIP_MAINNET]: [COMMON_CHAIN_SLUGS.POLKADOT, COMMON_CHAIN_SLUGS.ETHEREUM, COMMON_CHAIN_SLUGS.ARBITRUM],
|
|
40
42
|
[SwapProviderId.CHAIN_FLIP_TESTNET]: [COMMON_CHAIN_SLUGS.CHAINFLIP_POLKADOT, COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA],
|
|
41
43
|
[SwapProviderId.POLKADOT_ASSET_HUB]: [COMMON_CHAIN_SLUGS.POLKADOT_ASSET_HUB],
|
|
42
44
|
[SwapProviderId.KUSAMA_ASSET_HUB]: [COMMON_CHAIN_SLUGS.KUSAMA_ASSET_HUB],
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import { EvmProviderError } from '@subwallet/extension-base/background/errors/EvmProviderError';
|
|
5
5
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
6
6
|
import { BasicTxErrorType, ChainType, EvmProviderErrorType, ExtrinsicStatus, ExtrinsicType, NotificationType, TransactionDirection } from '@subwallet/extension-base/background/KoniTypes';
|
|
7
|
-
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
8
|
-
import { checkBalanceWithTransactionFee, checkSigningAccountForTransaction, checkSupportForTransaction, estimateFeeForTransaction } from '@subwallet/extension-base/core/logic-validation/transfer';
|
|
7
|
+
import { ALL_ACCOUNT_KEY, fetchLastestBlockedActionsAndFeatures } from '@subwallet/extension-base/constants';
|
|
8
|
+
import { checkBalanceWithTransactionFee, checkSigningAccountForTransaction, checkSupportForAction, checkSupportForFeature, checkSupportForTransaction, estimateFeeForTransaction } from '@subwallet/extension-base/core/logic-validation/transfer';
|
|
9
9
|
import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getEvmChainId, _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
10
10
|
import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
|
|
11
11
|
import { TRANSACTION_TIMEOUT } from '@subwallet/extension-base/services/transaction-service/constants';
|
|
@@ -68,6 +68,13 @@ export default class TransactionService {
|
|
|
68
68
|
chain,
|
|
69
69
|
extrinsicType
|
|
70
70
|
} = validationResponse;
|
|
71
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
72
|
+
const {
|
|
73
|
+
blockedActionsMap,
|
|
74
|
+
blockedFeaturesList
|
|
75
|
+
} = await fetchLastestBlockedActionsAndFeatures();
|
|
76
|
+
checkSupportForFeature(validationResponse, blockedFeaturesList, chainInfo);
|
|
77
|
+
checkSupportForAction(validationResponse, blockedActionsMap);
|
|
71
78
|
const transaction = transactionInput.transaction;
|
|
72
79
|
|
|
73
80
|
// Check duplicated transaction
|
|
@@ -75,7 +82,6 @@ export default class TransactionService {
|
|
|
75
82
|
|
|
76
83
|
// Check support for transaction
|
|
77
84
|
checkSupportForTransaction(validationResponse, transaction);
|
|
78
|
-
const chainInfo = this.state.chainService.getChainInfoByKey(chain);
|
|
79
85
|
if (!chainInfo) {
|
|
80
86
|
validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR, t('Cannot find network')));
|
|
81
87
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"blockedFeaturesList": [],
|
|
3
|
+
"blockedActionsMap": {
|
|
4
|
+
"transfer.balance": [],
|
|
5
|
+
"transfer.token": [],
|
|
6
|
+
"transfer.xcm": [],
|
|
7
|
+
"send_nft": [],
|
|
8
|
+
"swap": [],
|
|
9
|
+
"staking.join_pool": [],
|
|
10
|
+
"staking.leave_pool": [],
|
|
11
|
+
"staking.bond": [],
|
|
12
|
+
"staking.unbond": [],
|
|
13
|
+
"staking.claim_reward": [],
|
|
14
|
+
"staking.withdraw": [],
|
|
15
|
+
"staking.compounding": [],
|
|
16
|
+
"staking.cancel_compounding": [],
|
|
17
|
+
"staking.cancel_unstake": [],
|
|
18
|
+
"earn.join_pool": [],
|
|
19
|
+
"earn.mint_vdot": [],
|
|
20
|
+
"earn.mint_ldot": [],
|
|
21
|
+
"earn.mint_sdot": [],
|
|
22
|
+
"earn.mint_qdot": [],
|
|
23
|
+
"earn.mint_stdot": [],
|
|
24
|
+
"earn.mint_vmanta": [],
|
|
25
|
+
"earn.redeem_qdot": [],
|
|
26
|
+
"earn.redeem_vdot": [],
|
|
27
|
+
"earn.redeem_ldot": [],
|
|
28
|
+
"earn.redeem_sdot": [],
|
|
29
|
+
"earn.redeem_stdot": [],
|
|
30
|
+
"earn.redeem_vmanta": [],
|
|
31
|
+
"earn.unstake_qdot": [],
|
|
32
|
+
"earn.unstake_vdot": [],
|
|
33
|
+
"earn.unstake_ldot": [],
|
|
34
|
+
"earn.unstake_sdot": [],
|
|
35
|
+
"earn.unstake_stdot": [],
|
|
36
|
+
"earn.unstake_vmanta": [],
|
|
37
|
+
"token.spending_approval": []
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -4,6 +4,7 @@ export declare const crowdloanFunds: Record<string, unknown>[];
|
|
|
4
4
|
export declare const marketingCampaigns: Record<string, unknown>;
|
|
5
5
|
export declare const termAndCondition: Record<string, unknown>;
|
|
6
6
|
export declare const currencySymbol: Record<string, unknown>;
|
|
7
|
+
export declare const blockedActionsFeatures: Record<string, unknown>;
|
|
7
8
|
export declare enum StaticKey {
|
|
8
9
|
BUY_SERVICE_INFOS = "buy-service-infos",
|
|
9
10
|
CHAINS = "chains",
|
|
@@ -11,7 +12,8 @@ export declare enum StaticKey {
|
|
|
11
12
|
MARKETING_CAMPAINGS = "marketing-campaigns",
|
|
12
13
|
CROWDLOAN_FUNDS = "crowdloan-funds",
|
|
13
14
|
TERM_AND_CONDITION = "term-and-condition",
|
|
14
|
-
BUY_TOKEN_CONFIGS = "buy-token-configs"
|
|
15
|
+
BUY_TOKEN_CONFIGS = "buy-token-configs",
|
|
16
|
+
BLOCKED_ACTIONS_FEATURES = "blocked-actions-features"
|
|
15
17
|
}
|
|
16
18
|
export declare const staticData: {
|
|
17
19
|
chains: import("@subwallet/chain-list/types")._ChainInfo[];
|
|
@@ -21,4 +23,5 @@ export declare const staticData: {
|
|
|
21
23
|
"marketing-campaigns": Record<string, unknown>;
|
|
22
24
|
"term-and-condition": unknown;
|
|
23
25
|
"buy-token-configs": Record<string, unknown>[];
|
|
26
|
+
"blocked-actions-features": Record<string, unknown>;
|
|
24
27
|
};
|