@subwallet/extension-base 1.2.29-0 → 1.2.31-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 +34 -10
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/index.js +2 -2
- package/cjs/services/balance-service/helpers/subscribe/substrate/gear.js +6 -4
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +6 -6
- package/cjs/services/swap-service/handler/chainflip-handler.js +47 -19
- package/cjs/services/swap-service/utils.js +34 -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 +35 -11
- package/package.json +16 -10
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/index.js +2 -2
- package/services/balance-service/helpers/subscribe/substrate/gear.js +6 -4
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +6 -6
- package/services/swap-service/handler/chainflip-handler.d.ts +4 -2
- package/services/swap-service/handler/chainflip-handler.js +47 -20
- package/services/swap-service/utils.d.ts +12 -0
- package/services/swap-service/utils.js +32 -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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.termAndCondition = exports.staticData = exports.marketingCampaigns = exports.currencySymbol = exports.crowdloanFunds = exports.buyTokenConfigs = exports.buyServiceInfos = exports.StaticKey = void 0;
|
|
6
|
+
exports.termAndCondition = exports.staticData = exports.marketingCampaigns = exports.currencySymbol = exports.crowdloanFunds = exports.buyTokenConfigs = exports.buyServiceInfos = exports.blockedActionsFeatures = 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
|
|
@@ -27,7 +27,10 @@ const termAndCondition = require('./termAndCondition.json');
|
|
|
27
27
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
28
28
|
exports.termAndCondition = termAndCondition;
|
|
29
29
|
const currencySymbol = require('./currencySymbol.json');
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
30
31
|
exports.currencySymbol = currencySymbol;
|
|
32
|
+
const blockedActionsFeatures = require('./blockedActionsFeatures.json');
|
|
33
|
+
exports.blockedActionsFeatures = blockedActionsFeatures;
|
|
31
34
|
let StaticKey;
|
|
32
35
|
exports.StaticKey = StaticKey;
|
|
33
36
|
(function (StaticKey) {
|
|
@@ -38,6 +41,7 @@ exports.StaticKey = StaticKey;
|
|
|
38
41
|
StaticKey["CROWDLOAN_FUNDS"] = "crowdloan-funds";
|
|
39
42
|
StaticKey["TERM_AND_CONDITION"] = "term-and-condition";
|
|
40
43
|
StaticKey["BUY_TOKEN_CONFIGS"] = "buy-token-configs";
|
|
44
|
+
StaticKey["BLOCKED_ACTIONS_FEATURES"] = "blocked-actions-features";
|
|
41
45
|
})(StaticKey || (exports.StaticKey = StaticKey = {}));
|
|
42
46
|
const staticData = {
|
|
43
47
|
[StaticKey.CHAINS]: Object.values(_chainList.ChainInfoMap),
|
|
@@ -46,6 +50,7 @@ const staticData = {
|
|
|
46
50
|
[StaticKey.CROWDLOAN_FUNDS]: crowdloanFunds,
|
|
47
51
|
[StaticKey.MARKETING_CAMPAINGS]: marketingCampaigns,
|
|
48
52
|
[StaticKey.TERM_AND_CONDITION]: termAndCondition.default,
|
|
49
|
-
[StaticKey.BUY_TOKEN_CONFIGS]: buyTokenConfigs
|
|
53
|
+
[StaticKey.BUY_TOKEN_CONFIGS]: buyTokenConfigs,
|
|
54
|
+
[StaticKey.BLOCKED_ACTIONS_FEATURES]: blockedActionsFeatures
|
|
50
55
|
};
|
|
51
56
|
exports.staticData = staticData;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
|
+
interface BlockedActionsFeaturesMap {
|
|
3
|
+
blockedActionsMap: Record<ExtrinsicType, string[]>;
|
|
4
|
+
blockedFeaturesList: string[];
|
|
5
|
+
}
|
|
6
|
+
export declare const fetchLastestBlockedActionsAndFeatures: () => Promise<BlockedActionsFeaturesMap>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { fetchStaticData } from '@subwallet/extension-base/utils';
|
|
5
|
+
const BLOCKED_ACTIONS_AND_FEATURES_PROMISE = fetchStaticData('blocked-actions-features');
|
|
6
|
+
export const fetchLastestBlockedActionsAndFeatures = async () => {
|
|
7
|
+
return await BLOCKED_ACTIONS_AND_FEATURES_PROMISE;
|
|
8
|
+
};
|
package/constants/index.d.ts
CHANGED
package/constants/index.js
CHANGED
|
@@ -34,4 +34,5 @@ export const ORDINAL_COLLECTION = '__Ordinal__';
|
|
|
34
34
|
export const ORDINAL_METHODS = ['drc-20', 'pol-20'];
|
|
35
35
|
export const PERMISSIONS_TO_REVOKE = ['eth_accounts'];
|
|
36
36
|
export * from "./staking.js";
|
|
37
|
-
export * from "./storage.js";
|
|
37
|
+
export * from "./storage.js";
|
|
38
|
+
export * from "./blocked-actions-list.js";
|
|
@@ -10,6 +10,8 @@ export declare function validateTransferRequest(tokenInfo: _ChainAsset, from: _A
|
|
|
10
10
|
export declare function additionalValidateTransfer(tokenInfo: _ChainAsset, nativeTokenInfo: _ChainAsset, extrinsicType: ExtrinsicType, receiverTransferTokenFreeBalance: string, transferAmount: string, senderTransferTokenTransferable?: string, receiverNativeTransferable?: string): [TransactionWarning[], TransactionError[]];
|
|
11
11
|
export declare function validateXcmTransferRequest(destTokenInfo: _ChainAsset | undefined, sender: _Address, sendingValue: string): [TransactionError[], KeyringPair | undefined, BigN | undefined];
|
|
12
12
|
export declare function additionalValidateXcmTransfer(originTokenInfo: _ChainAsset, destinationTokenInfo: _ChainAsset, sendingAmount: string, senderTransferable: string, receiverNativeBalance: string, destChainInfo: _ChainInfo, isSnowBridge?: boolean): [TransactionWarning | undefined, TransactionError | undefined];
|
|
13
|
+
export declare function checkSupportForFeature(validationResponse: SWTransactionResponse, blockedFeaturesList: string[], chainInfo: _ChainInfo): void;
|
|
14
|
+
export declare function checkSupportForAction(validationResponse: SWTransactionResponse, blockedActionsMap: Record<ExtrinsicType, string[]>): void;
|
|
13
15
|
export declare function checkSupportForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction): void;
|
|
14
16
|
export declare function estimateFeeForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction, chainInfo: _ChainInfo, evmApi: _EvmApi): Promise<FeeData>;
|
|
15
17
|
export declare function checkSigningAccountForTransaction(validationResponse: SWTransactionResponse): void;
|
|
@@ -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
|
}
|
|
@@ -1940,8 +1964,9 @@ export default class KoniExtension {
|
|
|
1940
1964
|
const substrateApi = this.#koniState.chainService.getSubstrateApi(originTokenInfo.originChain);
|
|
1941
1965
|
const chainInfoMap = this.#koniState.chainService.getChainInfoMap();
|
|
1942
1966
|
const destinationTokenInfo = this.#koniState.getXcmEqualAssetByChain(destChain, originTokenInfo.slug);
|
|
1967
|
+
const existentialDeposit = originTokenInfo.minAmount || '0';
|
|
1943
1968
|
if (destinationTokenInfo) {
|
|
1944
|
-
const [
|
|
1969
|
+
const [bnMockExecutionFee, {
|
|
1945
1970
|
value
|
|
1946
1971
|
}] = await Promise.all([getXcmMockTxFee(substrateApi, chainInfoMap, originTokenInfo, destinationTokenInfo), this.getAddressTransferableBalance({
|
|
1947
1972
|
extrinsicType: ExtrinsicType.TRANSFER_XCM,
|
|
@@ -1950,8 +1975,7 @@ export default class KoniExtension {
|
|
|
1950
1975
|
token: originTokenInfo.slug
|
|
1951
1976
|
})]);
|
|
1952
1977
|
const bnMaxTransferable = new BigN(value);
|
|
1953
|
-
const estimatedFee =
|
|
1954
|
-
|
|
1978
|
+
const estimatedFee = bnMockExecutionFee.multipliedBy(XCM_FEE_RATIO).plus(new BigN(existentialDeposit));
|
|
1955
1979
|
return bnMaxTransferable.minus(estimatedFee);
|
|
1956
1980
|
}
|
|
1957
1981
|
return new BigN(0);
|
|
@@ -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.31-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.31-0",
|
|
2081
|
+
"@subwallet/extension-chains": "^1.2.31-0",
|
|
2082
|
+
"@subwallet/extension-dapp": "^1.2.31-0",
|
|
2083
|
+
"@subwallet/extension-inject": "^1.2.31-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.31-0'
|
|
11
11
|
};
|
|
@@ -109,10 +109,10 @@ export function subscribeBalance(addresses, chains, tokens, _chainAssetMap, _cha
|
|
|
109
109
|
evmApi
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
const substrateApi = await substrateApiMap[chainSlug].isReady;
|
|
113
|
+
if (!substrateApi.isApiReady) {
|
|
113
114
|
handleUnsupportedOrPendingAddresses(useAddresses, chainSlug, chainAssetMap, APIItemState.PENDING, callback);
|
|
114
115
|
}
|
|
115
|
-
const substrateApi = await substrateApiMap[chainSlug].isReady;
|
|
116
116
|
return subscribeSubstrateBalance(useAddresses, chainInfo, chainAssetMap, substrateApi, evmApi, callback, extrinsicType);
|
|
117
117
|
});
|
|
118
118
|
return () => {
|
|
@@ -16,7 +16,8 @@ export const subscribeGRC20Balance = ({
|
|
|
16
16
|
chainInfo,
|
|
17
17
|
substrateApi
|
|
18
18
|
}) => {
|
|
19
|
-
|
|
19
|
+
const apiPromise = substrateApi.api;
|
|
20
|
+
if (!(apiPromise instanceof GearApi)) {
|
|
20
21
|
console.warn('Cannot subscribe GRC20 balance without GearApi instance');
|
|
21
22
|
return noop;
|
|
22
23
|
}
|
|
@@ -24,7 +25,7 @@ export const subscribeGRC20Balance = ({
|
|
|
24
25
|
const grc20ContractMap = {};
|
|
25
26
|
const tokenList = filterAssetsByChainAndType(assetMap, chain, [_AssetType.GRC20]);
|
|
26
27
|
Object.entries(tokenList).forEach(([slug, tokenInfo]) => {
|
|
27
|
-
grc20ContractMap[slug] = getGRC20ContractPromise(
|
|
28
|
+
grc20ContractMap[slug] = getGRC20ContractPromise(apiPromise, _getContractAddressOfToken(tokenInfo));
|
|
28
29
|
});
|
|
29
30
|
const getTokenBalances = () => {
|
|
30
31
|
Object.values(tokenList).map(async tokenInfo => {
|
|
@@ -72,7 +73,8 @@ export const subscribeVftBalance = ({
|
|
|
72
73
|
chainInfo,
|
|
73
74
|
substrateApi
|
|
74
75
|
}) => {
|
|
75
|
-
|
|
76
|
+
const apiPromise = substrateApi.api;
|
|
77
|
+
if (!(apiPromise instanceof GearApi)) {
|
|
76
78
|
console.warn('Cannot subscribe VFT balance without GearApi instance');
|
|
77
79
|
return noop;
|
|
78
80
|
}
|
|
@@ -80,7 +82,7 @@ export const subscribeVftBalance = ({
|
|
|
80
82
|
const vftContractMap = {};
|
|
81
83
|
const tokenList = filterAssetsByChainAndType(assetMap, chain, [_AssetType.VFT]);
|
|
82
84
|
Object.entries(tokenList).forEach(([slug, tokenInfo]) => {
|
|
83
|
-
vftContractMap[slug] = getVFTContractPromise(
|
|
85
|
+
vftContractMap[slug] = getVFTContractPromise(apiPromise, _getContractAddressOfToken(tokenInfo));
|
|
84
86
|
});
|
|
85
87
|
const getTokenBalances = () => {
|
|
86
88
|
Object.values(tokenList).map(async tokenInfo => {
|
|
@@ -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,
|
|
@@ -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';
|
|
@@ -6,6 +7,7 @@ import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
|
6
7
|
import { SwapBaseInterface } from '@subwallet/extension-base/services/swap-service/handler/base-handler';
|
|
7
8
|
import { BaseStepDetail, CommonOptimalPath, CommonStepFeeInfo } from '@subwallet/extension-base/types/service-base';
|
|
8
9
|
import { OptimalSwapPathParams, SwapEarlyValidation, SwapProviderId, SwapQuote, SwapRequest, SwapSubmitParams, SwapSubmitStepData, ValidateSwapProcessParams } from '@subwallet/extension-base/types/swap';
|
|
10
|
+
export declare const CHAINFLIP_BROKER_API: string;
|
|
9
11
|
export declare class ChainflipSwapHandler implements SwapBaseInterface {
|
|
10
12
|
private swapSdk;
|
|
11
13
|
private readonly isTestnet;
|
|
@@ -17,8 +19,8 @@ export declare class ChainflipSwapHandler implements SwapBaseInterface {
|
|
|
17
19
|
get providerInfo(): import("@subwallet/extension-base/types/swap").SwapProvider;
|
|
18
20
|
get name(): string;
|
|
19
21
|
get slug(): string;
|
|
20
|
-
get assetMapping(): Record<string,
|
|
21
|
-
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>;
|
|
22
24
|
get intermediaryAssetSlug(): COMMON_ASSETS.USDC_ETHEREUM | COMMON_ASSETS.USDC_SEPOLIA;
|
|
23
25
|
validateSwapRequest(request: SwapRequest): Promise<SwapEarlyValidation>;
|
|
24
26
|
private parseSwapPath;
|