@subwallet/extension-base 1.2.3-1 → 1.2.4-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 +0 -153
- package/background/KoniTypes.js +0 -21
- package/cjs/background/KoniTypes.js +1 -22
- package/cjs/core/logic-validation/earning.js +2 -2
- package/cjs/core/logic-validation/transfer.js +0 -7
- package/cjs/core/substrate/nominationpools-pallet.js +11 -1
- package/cjs/core/substrate/system-pallet.js +2 -3
- package/cjs/core/substrate/xcm-parser.js +190 -0
- package/cjs/koni/api/dotsama/transfer.js +10 -119
- package/cjs/koni/api/xcm/polkadotXcm.js +12 -20
- package/cjs/koni/api/xcm/utils.js +8 -126
- package/cjs/koni/api/xcm/xTokens.js +10 -8
- package/cjs/koni/api/xcm/xcmPallet.js +6 -6
- package/cjs/koni/background/handlers/Extension.js +90 -113
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +6 -3
- package/cjs/services/chain-service/constants.js +2 -2
- package/cjs/services/chain-service/utils/index.js +7 -2
- package/cjs/services/earning-service/handlers/special.js +3 -3
- package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol.js +2 -1
- package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting.js +2 -1
- package/cjs/services/migration-service/scripts/index.js +2 -2
- package/cjs/services/swap-service/handler/base-handler.js +5 -3
- package/cjs/services/swap-service/handler/hydradx-handler.js +1 -1
- package/core/logic-validation/earning.d.ts +1 -1
- package/core/logic-validation/earning.js +2 -2
- package/core/logic-validation/transfer.js +0 -7
- package/core/substrate/nominationpools-pallet.d.ts +4 -1
- package/core/substrate/nominationpools-pallet.js +8 -1
- package/core/substrate/system-pallet.js +2 -3
- package/core/substrate/xcm-parser.d.ts +49 -0
- package/core/substrate/xcm-parser.js +181 -0
- package/koni/api/dotsama/transfer.d.ts +0 -3
- package/koni/api/dotsama/transfer.js +12 -119
- package/koni/api/xcm/polkadotXcm.js +14 -22
- package/koni/api/xcm/utils.d.ts +3 -48
- package/koni/api/xcm/utils.js +5 -114
- package/koni/api/xcm/xTokens.js +12 -10
- package/koni/api/xcm/xcmPallet.js +7 -7
- package/koni/background/handlers/Extension.d.ts +1 -3
- package/koni/background/handlers/Extension.js +8 -28
- package/package.json +11 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +8 -5
- package/services/chain-service/constants.js +2 -2
- package/services/chain-service/utils/index.d.ts +3 -2
- package/services/chain-service/utils/index.js +5 -2
- package/services/earning-service/handlers/special.js +3 -3
- package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol.js +2 -1
- package/services/migration-service/scripts/databases/MigrateAssetSetting.js +2 -1
- package/services/migration-service/scripts/index.js +2 -2
- package/services/swap-service/handler/base-handler.js +5 -3
- package/services/swap-service/handler/hydradx-handler.js +1 -1
|
@@ -86,10 +86,6 @@ export interface ResultResolver {
|
|
|
86
86
|
result: boolean;
|
|
87
87
|
accounts: string[];
|
|
88
88
|
}
|
|
89
|
-
export interface RejectResolver {
|
|
90
|
-
error: Error;
|
|
91
|
-
accounts: string[];
|
|
92
|
-
}
|
|
93
89
|
export declare enum StakingType {
|
|
94
90
|
NOMINATED = "nominated",
|
|
95
91
|
POOLED = "pooled",
|
|
@@ -106,16 +102,6 @@ export interface StakingRewardItem {
|
|
|
106
102
|
totalSlash?: string;
|
|
107
103
|
unclaimedReward?: string;
|
|
108
104
|
}
|
|
109
|
-
export interface UnlockingStakeInfo {
|
|
110
|
-
chain: string;
|
|
111
|
-
address: string;
|
|
112
|
-
type: StakingType;
|
|
113
|
-
nextWithdrawal: number;
|
|
114
|
-
redeemable: number;
|
|
115
|
-
nextWithdrawalAmount: number;
|
|
116
|
-
nextWithdrawalAction?: string;
|
|
117
|
-
validatorAddress?: string;
|
|
118
|
-
}
|
|
119
105
|
export interface StakingItem {
|
|
120
106
|
name: string;
|
|
121
107
|
chain: string;
|
|
@@ -275,10 +261,6 @@ export interface DonateInfo {
|
|
|
275
261
|
icon: string;
|
|
276
262
|
link: string;
|
|
277
263
|
}
|
|
278
|
-
export interface DropdownTransformOptionType {
|
|
279
|
-
label: string;
|
|
280
|
-
value: string;
|
|
281
|
-
}
|
|
282
264
|
export interface NetWorkMetadataDef extends MetadataDefBase {
|
|
283
265
|
networkKey: string;
|
|
284
266
|
groups: NetWorkGroup[];
|
|
@@ -601,16 +583,6 @@ export declare type TransactionErrorType = BasicTxErrorType | TransferTxErrorTyp
|
|
|
601
583
|
export declare enum BasicTxWarningCode {
|
|
602
584
|
NOT_ENOUGH_EXISTENTIAL_DEPOSIT = "notEnoughExistentialDeposit"
|
|
603
585
|
}
|
|
604
|
-
export declare type BasicTxError = {
|
|
605
|
-
errorType: TxErrorCode;
|
|
606
|
-
data?: object;
|
|
607
|
-
message: string;
|
|
608
|
-
};
|
|
609
|
-
export declare type BasicTxWarning = {
|
|
610
|
-
warningType: TransactionWarningType;
|
|
611
|
-
data?: object;
|
|
612
|
-
message: string;
|
|
613
|
-
};
|
|
614
586
|
export interface TransactionResponse {
|
|
615
587
|
extrinsicHash?: string;
|
|
616
588
|
txError?: boolean;
|
|
@@ -623,7 +595,6 @@ export interface NftTransactionResponse extends SWTransactionResponse {
|
|
|
623
595
|
isSendingSelf: boolean;
|
|
624
596
|
}
|
|
625
597
|
export declare type HandleBasicTx = (data: TransactionResponse) => void;
|
|
626
|
-
export declare type TxErrorCode = TransferTxErrorType | TransactionErrorType;
|
|
627
598
|
export declare enum BalanceErrorType {
|
|
628
599
|
NETWORK_ERROR = "NETWORK_ERROR",
|
|
629
600
|
TOKEN_ERROR = "TOKEN_ERROR",
|
|
@@ -815,11 +786,6 @@ export interface ExternalRequestPromise {
|
|
|
815
786
|
message?: string;
|
|
816
787
|
createdAt: number;
|
|
817
788
|
}
|
|
818
|
-
export interface PrepareExternalRequest {
|
|
819
|
-
id: string;
|
|
820
|
-
setState: (promise: ExternalRequestPromise) => void;
|
|
821
|
-
updateState: (promise: Partial<ExternalRequestPromise>) => void;
|
|
822
|
-
}
|
|
823
789
|
export interface RequestRejectExternalRequest {
|
|
824
790
|
id: string;
|
|
825
791
|
message?: string;
|
|
@@ -853,16 +819,6 @@ export declare enum ThemeNames {
|
|
|
853
819
|
DARK = "dark",
|
|
854
820
|
SUBSPACE = "subspace"
|
|
855
821
|
}
|
|
856
|
-
export declare enum NETWORK_ERROR {
|
|
857
|
-
INVALID_INFO_TYPE = "invalidInfoType",
|
|
858
|
-
INJECT_SCRIPT_DETECTED = "injectScriptDetected",
|
|
859
|
-
EXISTED_NETWORK = "existedNetwork",
|
|
860
|
-
EXISTED_PROVIDER = "existedProvider",
|
|
861
|
-
INVALID_PROVIDER = "invalidProvider",
|
|
862
|
-
NONE = "none",
|
|
863
|
-
CONNECTION_FAILURE = "connectionFailure",
|
|
864
|
-
PROVIDER_NOT_SAME_NETWORK = "providerNotSameNetwork"
|
|
865
|
-
}
|
|
866
822
|
export declare enum NETWORK_STATUS {
|
|
867
823
|
CONNECTED = "connected",
|
|
868
824
|
CONNECTING = "connecting",
|
|
@@ -890,13 +846,6 @@ export interface NftTransactionRequest {
|
|
|
890
846
|
export interface EvmNftTransaction extends ValidateTransactionResponse {
|
|
891
847
|
tx: Record<string, any> | null;
|
|
892
848
|
}
|
|
893
|
-
export interface EvmNftSubmitTransaction extends BaseRequestSign {
|
|
894
|
-
senderAddress: string;
|
|
895
|
-
recipientAddress: string;
|
|
896
|
-
networkKey: string;
|
|
897
|
-
estimateGas: string;
|
|
898
|
-
rawTransaction: Record<string, any>;
|
|
899
|
-
}
|
|
900
849
|
export interface ValidateNetworkResponse {
|
|
901
850
|
success: boolean;
|
|
902
851
|
error?: _CHAIN_VALIDATION_ERROR;
|
|
@@ -919,10 +868,6 @@ export interface ApiMap {
|
|
|
919
868
|
substrate: Record<string, _SubstrateApi>;
|
|
920
869
|
evm: Record<string, _EvmApi>;
|
|
921
870
|
}
|
|
922
|
-
export interface SupportTransferResponse {
|
|
923
|
-
supportTransfer: boolean;
|
|
924
|
-
supportTransferAll: boolean;
|
|
925
|
-
}
|
|
926
871
|
export interface RequestFreeBalance {
|
|
927
872
|
address: string;
|
|
928
873
|
networkKey: string;
|
|
@@ -936,17 +881,6 @@ export interface RequestMaxTransferable {
|
|
|
936
881
|
isXcmTransfer?: boolean;
|
|
937
882
|
destChain: string;
|
|
938
883
|
}
|
|
939
|
-
export interface RequestTransferCheckReferenceCount {
|
|
940
|
-
address: string;
|
|
941
|
-
networkKey: string;
|
|
942
|
-
}
|
|
943
|
-
export interface RequestTransferCheckSupporting {
|
|
944
|
-
networkKey: string;
|
|
945
|
-
tokenSlug: string;
|
|
946
|
-
}
|
|
947
|
-
export interface RequestTransferExistentialDeposit {
|
|
948
|
-
tokenSlug: string;
|
|
949
|
-
}
|
|
950
884
|
export interface RequestSaveRecentAccount {
|
|
951
885
|
accountId: string;
|
|
952
886
|
chain?: string;
|
|
@@ -963,7 +897,6 @@ export interface SubstrateNftSubmitTransaction extends BaseRequestSign {
|
|
|
963
897
|
recipientAddress: string;
|
|
964
898
|
}
|
|
965
899
|
export declare type RequestSubstrateNftSubmitTransaction = InternalRequestSign<SubstrateNftSubmitTransaction>;
|
|
966
|
-
export declare type RequestEvmNftSubmitTransaction = InternalRequestSign<EvmNftSubmitTransaction>;
|
|
967
900
|
export interface RequestAccountMeta {
|
|
968
901
|
address: string | Uint8Array;
|
|
969
902
|
}
|
|
@@ -1046,14 +979,6 @@ export interface ConfirmationResult<T> extends ConfirmationRequestBase {
|
|
|
1046
979
|
isApproved: boolean;
|
|
1047
980
|
payload?: T;
|
|
1048
981
|
}
|
|
1049
|
-
export interface EvmRequestExternal {
|
|
1050
|
-
hashPayload: string;
|
|
1051
|
-
canSign: boolean;
|
|
1052
|
-
}
|
|
1053
|
-
export interface EvmSendTransactionRequestExternal extends EvmSendTransactionRequest, EvmRequestExternal {
|
|
1054
|
-
}
|
|
1055
|
-
export interface EvmSignatureRequestExternal extends EvmSignatureRequest, EvmRequestExternal {
|
|
1056
|
-
}
|
|
1057
982
|
export interface AddNetworkRequestExternal {
|
|
1058
983
|
chainId: string;
|
|
1059
984
|
rpcUrls: string[];
|
|
@@ -1066,13 +991,6 @@ export interface AddNetworkRequestExternal {
|
|
|
1066
991
|
decimals: number;
|
|
1067
992
|
};
|
|
1068
993
|
}
|
|
1069
|
-
export interface AddNetworkExternalRequest {
|
|
1070
|
-
chainId: string;
|
|
1071
|
-
rpcUrl: string;
|
|
1072
|
-
chainName: string;
|
|
1073
|
-
blockExplorerUrl: string;
|
|
1074
|
-
requestId: string;
|
|
1075
|
-
}
|
|
1076
994
|
export interface AddTokenRequestExternal {
|
|
1077
995
|
slug?: string;
|
|
1078
996
|
contractAddress: string;
|
|
@@ -1100,11 +1018,6 @@ export declare type RequestConfirmationsSubscribe = null;
|
|
|
1100
1018
|
export declare type RequestConfirmationComplete = {
|
|
1101
1019
|
[CT in ConfirmationType]?: ConfirmationDefinitions[CT][1];
|
|
1102
1020
|
};
|
|
1103
|
-
export interface BasicTxInfo {
|
|
1104
|
-
fee: string;
|
|
1105
|
-
balanceError: boolean;
|
|
1106
|
-
rawFee?: number;
|
|
1107
|
-
}
|
|
1108
1021
|
export interface BondingOptionParams {
|
|
1109
1022
|
chain: string;
|
|
1110
1023
|
type: StakingType;
|
|
@@ -1146,10 +1059,6 @@ export interface LedgerNetwork {
|
|
|
1146
1059
|
isDevMode: boolean;
|
|
1147
1060
|
isEthereum: boolean;
|
|
1148
1061
|
}
|
|
1149
|
-
export interface TransakNetwork {
|
|
1150
|
-
networks: string[];
|
|
1151
|
-
tokens?: string[];
|
|
1152
|
-
}
|
|
1153
1062
|
export interface FormattedMethod {
|
|
1154
1063
|
args?: ArgInfo[];
|
|
1155
1064
|
methodName: string;
|
|
@@ -1333,36 +1242,6 @@ export interface StakePoolingUnbondingParams extends BaseRequestSign {
|
|
|
1333
1242
|
amount: string;
|
|
1334
1243
|
}
|
|
1335
1244
|
export declare type RequestStakePoolingUnbonding = InternalRequestSign<StakePoolingUnbondingParams>;
|
|
1336
|
-
export interface DelegationItem {
|
|
1337
|
-
owner: string;
|
|
1338
|
-
amount: string;
|
|
1339
|
-
identity?: string;
|
|
1340
|
-
minBond: string;
|
|
1341
|
-
hasScheduledRequest: boolean;
|
|
1342
|
-
icon?: string;
|
|
1343
|
-
}
|
|
1344
|
-
export interface StakeDelegationRequest {
|
|
1345
|
-
address: string;
|
|
1346
|
-
networkKey: string;
|
|
1347
|
-
}
|
|
1348
|
-
export interface CheckExistingTuringCompoundParams {
|
|
1349
|
-
address: string;
|
|
1350
|
-
collatorAddress: string;
|
|
1351
|
-
networkKey: string;
|
|
1352
|
-
}
|
|
1353
|
-
export interface ExistingTuringCompoundTask {
|
|
1354
|
-
exist: boolean;
|
|
1355
|
-
taskId: string;
|
|
1356
|
-
accountMinimum: number;
|
|
1357
|
-
frequency: number;
|
|
1358
|
-
}
|
|
1359
|
-
export interface TuringStakeCompoundResp {
|
|
1360
|
-
txInfo: BasicTxInfo;
|
|
1361
|
-
optimalFrequency: string;
|
|
1362
|
-
initTime: number;
|
|
1363
|
-
compoundFee: string;
|
|
1364
|
-
rawCompoundFee?: number;
|
|
1365
|
-
}
|
|
1366
1245
|
export interface TuringStakeCompoundParams extends BaseRequestSign {
|
|
1367
1246
|
address: string;
|
|
1368
1247
|
collatorAddress: string;
|
|
@@ -1377,35 +1256,6 @@ export interface TuringCancelStakeCompoundParams extends BaseRequestSign {
|
|
|
1377
1256
|
address: string;
|
|
1378
1257
|
}
|
|
1379
1258
|
export declare type RequestTuringCancelStakeCompound = InternalRequestSign<TuringCancelStakeCompoundParams>;
|
|
1380
|
-
export declare type RequestTransferExternal = InternalRequestSign<RequestCheckTransfer>;
|
|
1381
|
-
export declare type RequestCrossChainTransferExternal = InternalRequestSign<RequestCheckCrossChainTransfer>;
|
|
1382
|
-
export declare type RequestNftTransferExternalSubstrate = InternalRequestSign<SubstrateNftSubmitTransaction>;
|
|
1383
|
-
export declare type RequestNftTransferExternalEvm = InternalRequestSign<EvmNftSubmitTransaction>;
|
|
1384
|
-
export declare enum ChainEditStandard {
|
|
1385
|
-
EVM = "EVM",
|
|
1386
|
-
SUBSTRATE = "SUBSTRATE",
|
|
1387
|
-
UNKNOWN = "UNKNOWN",
|
|
1388
|
-
MIXED = "MIXED"
|
|
1389
|
-
}
|
|
1390
|
-
export declare type ChainEditInfo = {
|
|
1391
|
-
slug: string;
|
|
1392
|
-
currentProvider: string;
|
|
1393
|
-
providers: Record<string, string>;
|
|
1394
|
-
name: string;
|
|
1395
|
-
chainType: ChainEditStandard;
|
|
1396
|
-
blockExplorer?: string;
|
|
1397
|
-
crowdloanUrl?: string;
|
|
1398
|
-
priceId?: string;
|
|
1399
|
-
symbol: string;
|
|
1400
|
-
};
|
|
1401
|
-
export interface ChainSpecInfo {
|
|
1402
|
-
addressPrefix: number;
|
|
1403
|
-
genesisHash: string;
|
|
1404
|
-
paraId: number | null;
|
|
1405
|
-
evmChainId: number | null;
|
|
1406
|
-
existentialDeposit: string;
|
|
1407
|
-
decimals: number;
|
|
1408
|
-
}
|
|
1409
1259
|
export interface KeyringState {
|
|
1410
1260
|
isReady: boolean;
|
|
1411
1261
|
hasMasterPassword: boolean;
|
|
@@ -1811,9 +1661,6 @@ export interface KoniRequestSignatures {
|
|
|
1811
1661
|
'pri(yield.claimReward.submit)': [RequestStakeClaimReward, SWTransactionResponse];
|
|
1812
1662
|
'pri(transaction.history.getSubscription)': [null, TransactionHistoryItem[], TransactionHistoryItem[]];
|
|
1813
1663
|
'pri(transaction.history.subscribe)': [RequestSubscribeHistory, ResponseSubscribeHistory, TransactionHistoryItem[]];
|
|
1814
|
-
'pri(transfer.checkReferenceCount)': [RequestTransferCheckReferenceCount, boolean];
|
|
1815
|
-
'pri(transfer.checkSupporting)': [RequestTransferCheckSupporting, SupportTransferResponse];
|
|
1816
|
-
'pri(transfer.getExistentialDeposit)': [RequestTransferExistentialDeposit, string];
|
|
1817
1664
|
'pri(transfer.getMaxTransferable)': [RequestMaxTransferable, AmountData];
|
|
1818
1665
|
'pri(subscription.cancel)': [string, boolean];
|
|
1819
1666
|
'pri(freeBalance.get)': [RequestFreeBalance, AmountData];
|
package/background/KoniTypes.js
CHANGED
|
@@ -199,17 +199,6 @@ export let ThemeNames;
|
|
|
199
199
|
ThemeNames["DARK"] = "dark";
|
|
200
200
|
ThemeNames["SUBSPACE"] = "subspace";
|
|
201
201
|
})(ThemeNames || (ThemeNames = {}));
|
|
202
|
-
export let NETWORK_ERROR;
|
|
203
|
-
(function (NETWORK_ERROR) {
|
|
204
|
-
NETWORK_ERROR["INVALID_INFO_TYPE"] = "invalidInfoType";
|
|
205
|
-
NETWORK_ERROR["INJECT_SCRIPT_DETECTED"] = "injectScriptDetected";
|
|
206
|
-
NETWORK_ERROR["EXISTED_NETWORK"] = "existedNetwork";
|
|
207
|
-
NETWORK_ERROR["EXISTED_PROVIDER"] = "existedProvider";
|
|
208
|
-
NETWORK_ERROR["INVALID_PROVIDER"] = "invalidProvider";
|
|
209
|
-
NETWORK_ERROR["NONE"] = "none";
|
|
210
|
-
NETWORK_ERROR["CONNECTION_FAILURE"] = "connectionFailure";
|
|
211
|
-
NETWORK_ERROR["PROVIDER_NOT_SAME_NETWORK"] = "providerNotSameNetwork";
|
|
212
|
-
})(NETWORK_ERROR || (NETWORK_ERROR = {}));
|
|
213
202
|
export let NETWORK_STATUS;
|
|
214
203
|
|
|
215
204
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -229,16 +218,6 @@ export let EvmProviderErrorType;
|
|
|
229
218
|
EvmProviderErrorType["INVALID_PARAMS"] = "INVALID_PARAMS";
|
|
230
219
|
EvmProviderErrorType["INTERNAL_ERROR"] = "INTERNAL_ERROR";
|
|
231
220
|
})(EvmProviderErrorType || (EvmProviderErrorType = {}));
|
|
232
|
-
export let ChainEditStandard;
|
|
233
|
-
|
|
234
|
-
// ChainService
|
|
235
|
-
// for custom network
|
|
236
|
-
(function (ChainEditStandard) {
|
|
237
|
-
ChainEditStandard["EVM"] = "EVM";
|
|
238
|
-
ChainEditStandard["SUBSTRATE"] = "SUBSTRATE";
|
|
239
|
-
ChainEditStandard["UNKNOWN"] = "UNKNOWN";
|
|
240
|
-
ChainEditStandard["MIXED"] = "MIXED";
|
|
241
|
-
})(ChainEditStandard || (ChainEditStandard = {}));
|
|
242
221
|
export let NotificationType;
|
|
243
222
|
(function (NotificationType) {
|
|
244
223
|
NotificationType["INFO"] = "info";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WalletUnlockType = exports.TransferTxErrorType = exports.TransactionDirection = exports.ThemeNames = exports.StakingType = exports.StakingTxErrorType = exports.RuntimeEnvironment = exports.RMRK_VER = exports.ProviderErrorType = exports.NotificationType = exports.NETWORK_STATUS = exports.
|
|
6
|
+
exports.WalletUnlockType = exports.TransferTxErrorType = exports.TransactionDirection = exports.ThemeNames = exports.StakingType = exports.StakingTxErrorType = exports.RuntimeEnvironment = exports.RMRK_VER = exports.ProviderErrorType = exports.NotificationType = exports.NETWORK_STATUS = exports.MobileOS = exports.MantaPayEnableMessage = exports.ExtrinsicType = exports.ExtrinsicStatus = exports.ExternalRequestPromiseStatus = exports.EvmProviderErrorType = exports.CrowdloanParaState = exports.ContractType = exports.ChainType = exports.CampaignDataType = exports.BasicTxWarningCode = exports.BasicTxErrorType = exports.BalanceErrorType = exports.AssetHubNftType = exports.AccountExternalErrorCode = exports.APIItemState = void 0;
|
|
7
7
|
// Copyright 2019-2022 @polkadot/extension-koni authors & contributors
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
let RuntimeEnvironment;
|
|
@@ -216,18 +216,6 @@ exports.ThemeNames = ThemeNames;
|
|
|
216
216
|
ThemeNames["DARK"] = "dark";
|
|
217
217
|
ThemeNames["SUBSPACE"] = "subspace";
|
|
218
218
|
})(ThemeNames || (exports.ThemeNames = ThemeNames = {}));
|
|
219
|
-
let NETWORK_ERROR;
|
|
220
|
-
exports.NETWORK_ERROR = NETWORK_ERROR;
|
|
221
|
-
(function (NETWORK_ERROR) {
|
|
222
|
-
NETWORK_ERROR["INVALID_INFO_TYPE"] = "invalidInfoType";
|
|
223
|
-
NETWORK_ERROR["INJECT_SCRIPT_DETECTED"] = "injectScriptDetected";
|
|
224
|
-
NETWORK_ERROR["EXISTED_NETWORK"] = "existedNetwork";
|
|
225
|
-
NETWORK_ERROR["EXISTED_PROVIDER"] = "existedProvider";
|
|
226
|
-
NETWORK_ERROR["INVALID_PROVIDER"] = "invalidProvider";
|
|
227
|
-
NETWORK_ERROR["NONE"] = "none";
|
|
228
|
-
NETWORK_ERROR["CONNECTION_FAILURE"] = "connectionFailure";
|
|
229
|
-
NETWORK_ERROR["PROVIDER_NOT_SAME_NETWORK"] = "providerNotSameNetwork";
|
|
230
|
-
})(NETWORK_ERROR || (exports.NETWORK_ERROR = NETWORK_ERROR = {}));
|
|
231
219
|
let NETWORK_STATUS; // eslint-disable-next-line @typescript-eslint/ban-types
|
|
232
220
|
exports.NETWORK_STATUS = NETWORK_STATUS;
|
|
233
221
|
(function (NETWORK_STATUS) {
|
|
@@ -247,15 +235,6 @@ exports.EvmProviderErrorType = EvmProviderErrorType;
|
|
|
247
235
|
EvmProviderErrorType["INVALID_PARAMS"] = "INVALID_PARAMS";
|
|
248
236
|
EvmProviderErrorType["INTERNAL_ERROR"] = "INTERNAL_ERROR";
|
|
249
237
|
})(EvmProviderErrorType || (exports.EvmProviderErrorType = EvmProviderErrorType = {}));
|
|
250
|
-
let ChainEditStandard; // ChainService
|
|
251
|
-
// for custom network
|
|
252
|
-
exports.ChainEditStandard = ChainEditStandard;
|
|
253
|
-
(function (ChainEditStandard) {
|
|
254
|
-
ChainEditStandard["EVM"] = "EVM";
|
|
255
|
-
ChainEditStandard["SUBSTRATE"] = "SUBSTRATE";
|
|
256
|
-
ChainEditStandard["UNKNOWN"] = "UNKNOWN";
|
|
257
|
-
ChainEditStandard["MIXED"] = "MIXED";
|
|
258
|
-
})(ChainEditStandard || (exports.ChainEditStandard = ChainEditStandard = {}));
|
|
259
238
|
let NotificationType;
|
|
260
239
|
exports.NotificationType = NotificationType;
|
|
261
240
|
(function (NotificationType) {
|
|
@@ -22,8 +22,8 @@ function _handleDisplayForEarningError(error) {
|
|
|
22
22
|
}
|
|
23
23
|
const INSUFFICIENT_MESSAGES = ['残高不足', 'Недостаточный баланс', 'Insufficient balance'];
|
|
24
24
|
exports.INSUFFICIENT_MESSAGES = INSUFFICIENT_MESSAGES;
|
|
25
|
-
function _handleDisplayInsufficientEarningError(error, availableBalance, amount, minJoinPool) {
|
|
26
|
-
if (!INSUFFICIENT_MESSAGES.some(v => error.message.includes(v))) {
|
|
25
|
+
function _handleDisplayInsufficientEarningError(error, isXCM, availableBalance, amount, minJoinPool) {
|
|
26
|
+
if (isXCM || !INSUFFICIENT_MESSAGES.some(v => error.message.includes(v))) {
|
|
27
27
|
return undefined;
|
|
28
28
|
}
|
|
29
29
|
const bnAvailableBalance = new _bignumber.default(availableBalance);
|
|
@@ -183,13 +183,6 @@ function checkBalanceWithTransactionFee(validationResponse, transactionInput, na
|
|
|
183
183
|
// todo: estimateFee should be must-have, need to refactor interface
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
|
-
|
|
187
|
-
// if (!nativeTokenAvailable.metadata) {
|
|
188
|
-
// validationResponse.errors.push(new TransactionError(BasicTxErrorType.INTERNAL_ERROR));
|
|
189
|
-
//
|
|
190
|
-
// return;
|
|
191
|
-
// }
|
|
192
|
-
|
|
193
186
|
const {
|
|
194
187
|
edAsWarning,
|
|
195
188
|
extrinsicType,
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports._getActiveStakeInNominationPool = _getActiveStakeInNominationPool;
|
|
8
|
+
exports._getTotalStakeInNominationPool = _getTotalStakeInNominationPool;
|
|
9
|
+
exports._getUnbondingStakeInNominationPool = _getUnbondingStakeInNominationPool;
|
|
10
|
+
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
7
11
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
12
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
13
|
|
|
10
14
|
function _getActiveStakeInNominationPool(memberInfo) {
|
|
11
|
-
return memberInfo.points.toString();
|
|
15
|
+
return new _bignumber.default(memberInfo.points.toString());
|
|
16
|
+
}
|
|
17
|
+
function _getUnbondingStakeInNominationPool(memberInfo) {
|
|
18
|
+
return new _bignumber.default(Object.values(memberInfo.unbondingEras).reduce((a, b) => a + b, 0));
|
|
19
|
+
}
|
|
20
|
+
function _getTotalStakeInNominationPool(memberInfo) {
|
|
21
|
+
return _getActiveStakeInNominationPool(memberInfo).plus(_getUnbondingStakeInNominationPool(memberInfo));
|
|
12
22
|
}
|
|
@@ -69,10 +69,9 @@ function _getSystemPalletTotalBalanceV2(accountInfo) {
|
|
|
69
69
|
function _getSystemPalletTransferableV1(accountInfo, existentialDeposit, strictMode) {
|
|
70
70
|
const bnAppliedExistentialDeposit = new _bignumber.default(_getAppliedExistentialDeposit(accountInfo, existentialDeposit, strictMode));
|
|
71
71
|
const bnAppliedFrozen = _bignumber.default.max(accountInfo.data.feeFrozen, accountInfo.data.miscFrozen);
|
|
72
|
-
const
|
|
73
|
-
const bnTransferableBalance = bnTotalBalance.minus(_bignumber.default.max(bnAppliedFrozen, accountInfo.data.reserved, bnAppliedExistentialDeposit));
|
|
72
|
+
const bnTransferableBalance = new _bignumber.default(accountInfo.data.free).minus(_bignumber.default.max(bnAppliedFrozen, bnAppliedExistentialDeposit));
|
|
74
73
|
return _bignumber.default.max(bnTransferableBalance, 0).toFixed();
|
|
75
74
|
}
|
|
76
75
|
function _getSystemPalletTotalBalanceV1(accountInfo) {
|
|
77
|
-
return new _bignumber.default(accountInfo.data.free).toFixed();
|
|
76
|
+
return new _bignumber.default(accountInfo.data.free).plus(accountInfo.data.reserved).toFixed();
|
|
78
77
|
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports._getXcmBeneficiary = _getXcmBeneficiary;
|
|
7
|
+
exports._getXcmDestWeight = _getXcmDestWeight;
|
|
8
|
+
exports._getXcmMultiAssets = _getXcmMultiAssets;
|
|
9
|
+
exports._getXcmMultiLocation = _getXcmMultiLocation;
|
|
10
|
+
var _chainList = require("@subwallet/chain-list");
|
|
11
|
+
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
12
|
+
var _utilCrypto = require("@polkadot/util-crypto");
|
|
13
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
14
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
15
|
+
|
|
16
|
+
const FOUR_INSTRUCTIONS_WEIGHT = 5000000000;
|
|
17
|
+
const UNLIMITED_WEIGHT = 'Unlimited';
|
|
18
|
+
function _getXcmDestWeight(originChainInfo) {
|
|
19
|
+
if (['pioneer'].includes(originChainInfo.slug)) {
|
|
20
|
+
return FOUR_INSTRUCTIONS_WEIGHT;
|
|
21
|
+
}
|
|
22
|
+
return UNLIMITED_WEIGHT;
|
|
23
|
+
}
|
|
24
|
+
function _getXcmBeneficiary(destChainInfo, recipient, version) {
|
|
25
|
+
const receiverLocation = version < 4 // from V4, X1 is also an array
|
|
26
|
+
? _getRecipientLocation(destChainInfo, recipient, version) : [_getRecipientLocation(destChainInfo, recipient, version)];
|
|
27
|
+
return {
|
|
28
|
+
[`V${version}`]: {
|
|
29
|
+
parents: 0,
|
|
30
|
+
interior: {
|
|
31
|
+
X1: receiverLocation
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function _getXcmMultiAssets(tokenInfo, value, version) {
|
|
37
|
+
const assetId = _getAssetIdentifier(tokenInfo, version);
|
|
38
|
+
return {
|
|
39
|
+
[`V${version}`]: [{
|
|
40
|
+
id: assetId,
|
|
41
|
+
fun: {
|
|
42
|
+
Fungible: value
|
|
43
|
+
}
|
|
44
|
+
}]
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function _getXcmMultiLocation(originChainInfo, destChainInfo, version, recipient) {
|
|
48
|
+
const isWithinSameConsensus = _isXcmWithinSameConsensus(originChainInfo, destChainInfo);
|
|
49
|
+
const parents = _getMultiLocationParent(originChainInfo, isWithinSameConsensus);
|
|
50
|
+
const interior = _getMultiLocationInterior(destChainInfo, isWithinSameConsensus, version, recipient);
|
|
51
|
+
return {
|
|
52
|
+
[`V${version}`]: {
|
|
53
|
+
parents,
|
|
54
|
+
interior
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
function _isXcmWithinSameConsensus(originChainInfo, destChainInfo) {
|
|
62
|
+
return (0, _utils._getSubstrateRelayParent)(originChainInfo) === destChainInfo.slug || (0, _utils._getSubstrateRelayParent)(destChainInfo) === originChainInfo.slug || (0, _utils._getSubstrateRelayParent)(originChainInfo) === (0, _utils._getSubstrateRelayParent)(destChainInfo);
|
|
63
|
+
}
|
|
64
|
+
function _getMultiLocationParent(originChainInfo, isWithinSameConsensus) {
|
|
65
|
+
let parent = 0; // how many hops up the hierarchy
|
|
66
|
+
|
|
67
|
+
if ((0, _utils._isSubstrateParaChain)(originChainInfo)) {
|
|
68
|
+
parent += 1;
|
|
69
|
+
}
|
|
70
|
+
if (!isWithinSameConsensus) {
|
|
71
|
+
parent += 1;
|
|
72
|
+
}
|
|
73
|
+
return parent;
|
|
74
|
+
}
|
|
75
|
+
function _getMultiLocationInterior(destChainInfo, isWithinSameConsensus, version, recipient) {
|
|
76
|
+
const junctions = [];
|
|
77
|
+
if (isWithinSameConsensus) {
|
|
78
|
+
if ((0, _utils._isSubstrateParaChain)(destChainInfo)) {
|
|
79
|
+
junctions.push({
|
|
80
|
+
Parachain: (0, _utils._getSubstrateParaId)(destChainInfo)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
junctions.push({
|
|
85
|
+
GlobalConsensus: _getGlobalConsensusJunction(destChainInfo, version)
|
|
86
|
+
});
|
|
87
|
+
if ((0, _utils._isSubstrateParaChain)(destChainInfo)) {
|
|
88
|
+
junctions.push({
|
|
89
|
+
Parachain: (0, _utils._getSubstrateParaId)(destChainInfo)
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (recipient) {
|
|
94
|
+
junctions.push(_getRecipientLocation(destChainInfo, recipient, version));
|
|
95
|
+
}
|
|
96
|
+
if (junctions.length === 0 && !recipient) {
|
|
97
|
+
return 'Here';
|
|
98
|
+
}
|
|
99
|
+
if (version < 4 && junctions.length === 1) {
|
|
100
|
+
return {
|
|
101
|
+
X1: junctions[0]
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
[`X${junctions.length}`]: junctions
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function _getGlobalConsensusJunction(destChainInfo, version) {
|
|
109
|
+
let chainSlug = destChainInfo.slug;
|
|
110
|
+
let evmChainId;
|
|
111
|
+
if ((0, _utils._isSubstrateParaChain)(destChainInfo)) {
|
|
112
|
+
const relaySlug = (0, _utils._getSubstrateRelayParent)(destChainInfo);
|
|
113
|
+
if (!relaySlug) {
|
|
114
|
+
throw Error('Parachain must have a parent chainSlug');
|
|
115
|
+
}
|
|
116
|
+
chainSlug = relaySlug;
|
|
117
|
+
} else {
|
|
118
|
+
evmChainId = (0, _utils._getEvmChainId)(destChainInfo);
|
|
119
|
+
}
|
|
120
|
+
if (evmChainId) {
|
|
121
|
+
return {
|
|
122
|
+
Ethereum: {
|
|
123
|
+
chainId: evmChainId
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
switch (chainSlug) {
|
|
128
|
+
case _chainList.COMMON_CHAIN_SLUGS.POLKADOT:
|
|
129
|
+
return version < 4 ? {
|
|
130
|
+
Polkadot: null
|
|
131
|
+
} : 'Polkadot';
|
|
132
|
+
case _chainList.COMMON_CHAIN_SLUGS.KUSAMA:
|
|
133
|
+
return version < 4 ? {
|
|
134
|
+
Kusama: null
|
|
135
|
+
} : 'Kusama';
|
|
136
|
+
default:
|
|
137
|
+
return version < 4 ? {
|
|
138
|
+
Rococo: null
|
|
139
|
+
} : 'Rococo';
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function _getRecipientLocation(destChainInfo, recipient, version) {
|
|
143
|
+
const network = _getNetworkByVersion(version);
|
|
144
|
+
if (destChainInfo.slug === _chainList.COMMON_CHAIN_SLUGS.ASTAR_EVM) {
|
|
145
|
+
const ss58Address = (0, _utilCrypto.evmToAddress)(recipient, (0, _utils._getChainSubstrateAddressPrefix)(destChainInfo)); // TODO: shouldn't pass addressPrefix directly
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
AccountId32: {
|
|
149
|
+
network,
|
|
150
|
+
id: (0, _utilCrypto.decodeAddress)(ss58Address)
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
if ((0, _utils._isChainEvmCompatible)(destChainInfo)) {
|
|
155
|
+
return {
|
|
156
|
+
AccountKey20: {
|
|
157
|
+
network,
|
|
158
|
+
key: recipient
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
AccountId32: {
|
|
164
|
+
network,
|
|
165
|
+
id: (0, _utilCrypto.decodeAddress)(recipient)
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function _getAssetIdentifier(tokenInfo, version) {
|
|
170
|
+
const assetIdentifier = (0, _utils._getXcmAssetMultilocation)(tokenInfo);
|
|
171
|
+
if (!assetIdentifier) {
|
|
172
|
+
throw new Error('Asset must have multilocation');
|
|
173
|
+
}
|
|
174
|
+
return version >= 4 // from V4, Concrete is removed
|
|
175
|
+
? assetIdentifier : {
|
|
176
|
+
Concrete: assetIdentifier
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function _getNetworkByVersion(version) {
|
|
180
|
+
switch (version) {
|
|
181
|
+
case 1:
|
|
182
|
+
case 2:
|
|
183
|
+
return 'Any';
|
|
184
|
+
case 3:
|
|
185
|
+
case 4:
|
|
186
|
+
return undefined;
|
|
187
|
+
default:
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
}
|