@subwallet/extension-base 1.3.3-0 → 1.3.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 +13 -0
- package/background/KoniTypes.js +1 -0
- package/cjs/background/KoniTypes.js +1 -0
- package/cjs/constants/blocked-actions-list.js +1 -2
- package/cjs/constants/index.js +16 -1
- package/cjs/constants/remind-notification-time.js +14 -0
- package/cjs/core/logic-validation/transfer.js +12 -6
- package/cjs/core/substrate/xcm-parser.js +13 -1
- package/cjs/koni/api/contract-handler/utils/index.js +20 -1
- package/cjs/koni/background/handlers/Extension.js +110 -23
- package/cjs/koni/background/handlers/State.js +5 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/process.js +2 -1
- package/cjs/services/balance-service/transfer/xcm/availBridge.js +198 -0
- package/cjs/services/balance-service/transfer/xcm/index.js +50 -5
- package/cjs/services/chain-service/handler/EvmApi.js +12 -21
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +29 -0
- package/cjs/services/chain-service/index.js +44 -13
- package/cjs/services/chain-service/utils/index.js +20 -0
- package/cjs/services/earning-service/handlers/base.js +12 -3
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +10 -2
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +2 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +2 -0
- package/cjs/services/earning-service/handlers/native-staking/tao.js +10 -2
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +9 -4
- package/cjs/services/earning-service/service.js +5 -0
- package/cjs/services/inapp-notification-service/consts.js +31 -0
- package/cjs/services/inapp-notification-service/index.js +260 -0
- package/cjs/services/inapp-notification-service/interfaces.js +32 -0
- package/cjs/services/inapp-notification-service/utils.js +197 -0
- package/cjs/services/keyring-service/context/account-context.js +9 -0
- package/cjs/services/keyring-service/context/state.js +4 -0
- package/cjs/services/setting-service/SettingService.js +9 -1
- package/cjs/services/setting-service/constants.js +16 -1
- package/cjs/services/storage-service/DatabaseService.js +42 -3
- package/cjs/services/storage-service/databases/index.js +3 -0
- package/cjs/services/storage-service/db-stores/InappNotification.js +81 -0
- package/cjs/services/transaction-service/index.js +13 -0
- package/cjs/types/avail-bridge/index.js +1 -0
- package/cjs/types/notification/index.js +1 -0
- package/cjs/utils/account/transform.js +9 -5
- package/cjs/utils/staticData/index.js +7 -2
- package/constants/blocked-actions-list.js +1 -2
- package/constants/index.d.ts +2 -0
- package/constants/index.js +3 -1
- package/constants/remind-notification-time.d.ts +2 -0
- package/constants/remind-notification-time.js +7 -0
- package/core/logic-validation/transfer.js +12 -6
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +12 -1
- package/koni/api/contract-handler/utils/avail_bridge_abi.json +1659 -0
- package/koni/api/contract-handler/utils/avail_test_bridge_abi.json +1692 -0
- package/koni/api/contract-handler/utils/index.d.ts +4 -0
- package/koni/api/contract-handler/utils/index.js +15 -0
- package/koni/background/handlers/Extension.d.ts +7 -0
- package/koni/background/handlers/Extension.js +112 -25
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +5 -2
- package/package.json +54 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/process.js +2 -1
- package/services/balance-service/transfer/xcm/availBridge.d.ts +45 -0
- package/services/balance-service/transfer/xcm/availBridge.js +186 -0
- package/services/balance-service/transfer/xcm/index.d.ts +8 -8
- package/services/balance-service/transfer/xcm/index.js +46 -5
- package/services/chain-service/handler/EvmApi.js +12 -21
- package/services/chain-service/handler/SubstrateChainHandler.d.ts +2 -0
- package/services/chain-service/handler/SubstrateChainHandler.js +29 -0
- package/services/chain-service/index.d.ts +2 -0
- package/services/chain-service/index.js +45 -14
- package/services/chain-service/types.d.ts +2 -1
- package/services/chain-service/utils/index.d.ts +3 -0
- package/services/chain-service/utils/index.js +14 -0
- package/services/earning-service/handlers/base.d.ts +2 -0
- package/services/earning-service/handlers/base.js +9 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +10 -2
- package/services/earning-service/handlers/native-staking/para-chain.js +2 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +2 -0
- package/services/earning-service/handlers/native-staking/tao.d.ts +4 -0
- package/services/earning-service/handlers/native-staking/tao.js +5 -1
- package/services/earning-service/handlers/nomination-pool/index.d.ts +1 -1
- package/services/earning-service/handlers/nomination-pool/index.js +9 -4
- package/services/earning-service/service.d.ts +2 -0
- package/services/earning-service/service.js +5 -0
- package/services/inapp-notification-service/consts.d.ts +18 -0
- package/services/inapp-notification-service/consts.js +22 -0
- package/services/inapp-notification-service/index.d.ts +37 -0
- package/services/inapp-notification-service/index.js +252 -0
- package/services/inapp-notification-service/interfaces.d.ts +77 -0
- package/services/inapp-notification-service/interfaces.js +24 -0
- package/services/inapp-notification-service/utils.d.ts +55 -0
- package/services/inapp-notification-service/utils.js +173 -0
- package/services/keyring-service/context/account-context.d.ts +3 -0
- package/services/keyring-service/context/account-context.js +9 -0
- package/services/keyring-service/context/state.d.ts +1 -0
- package/services/keyring-service/context/state.js +4 -0
- package/services/setting-service/SettingService.js +9 -1
- package/services/setting-service/constants.d.ts +2 -0
- package/services/setting-service/constants.js +15 -0
- package/services/storage-service/DatabaseService.d.ts +15 -0
- package/services/storage-service/DatabaseService.js +42 -3
- package/services/storage-service/databases/index.d.ts +2 -0
- package/services/storage-service/databases/index.js +3 -0
- package/services/storage-service/db-stores/InappNotification.d.ts +14 -0
- package/services/storage-service/db-stores/InappNotification.js +73 -0
- package/services/transaction-service/index.js +13 -0
- package/types/avail-bridge/index.d.ts +6 -0
- package/types/avail-bridge/index.js +1 -0
- package/types/notification/index.d.ts +9 -0
- package/types/notification/index.js +1 -0
- package/utils/account/transform.js +9 -5
- package/utils/staticData/index.d.ts +5 -1
- package/utils/staticData/index.js +5 -2
- package/utils/staticData/remindNotificationTime.json +1 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AvailBridgeConfig = void 0;
|
|
7
|
+
exports.getAvailBridgeExtrinsicFromAvail = getAvailBridgeExtrinsicFromAvail;
|
|
8
|
+
exports.getAvailBridgeTxFromEth = getAvailBridgeTxFromEth;
|
|
9
|
+
exports.getClaimTxOnAvail = getClaimTxOnAvail;
|
|
10
|
+
exports.getClaimTxOnEthereum = getClaimTxOnEthereum;
|
|
11
|
+
exports.isAvailChainBridge = isAvailChainBridge;
|
|
12
|
+
var _chainList = require("@subwallet/chain-list");
|
|
13
|
+
var _web = require("@subwallet/extension-base/koni/api/contract-handler/evm/web3");
|
|
14
|
+
var _utils = require("@subwallet/extension-base/koni/api/contract-handler/utils");
|
|
15
|
+
var _utils2 = require("@subwallet/extension-base/services/fee-service/utils");
|
|
16
|
+
var _utils3 = require("@subwallet/extension-base/services/inapp-notification-service/utils");
|
|
17
|
+
var _keyring = require("@subwallet/keyring");
|
|
18
|
+
var _util = require("@polkadot/util");
|
|
19
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
20
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
21
|
+
|
|
22
|
+
const AvailBridgeConfig = {
|
|
23
|
+
ASSET_ID: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
24
|
+
ETHEREUM_DOMAIN: 2,
|
|
25
|
+
// todo: check if these config can change later
|
|
26
|
+
AVAIL_DOMAIN: 1
|
|
27
|
+
};
|
|
28
|
+
exports.AvailBridgeConfig = AvailBridgeConfig;
|
|
29
|
+
async function getAvailBridgeTxFromEth(originChainInfo, sender, recipient, value, evmApi) {
|
|
30
|
+
var _priority$maxFeePerGa, _priority$maxPriority;
|
|
31
|
+
const availBridgeContractAddress = (0, _utils.getAvailBridgeGatewayContract)(originChainInfo.slug);
|
|
32
|
+
const ABI = getAvailBridgeAbi(originChainInfo.slug);
|
|
33
|
+
const availBridgeContract = (0, _web.getWeb3Contract)(availBridgeContractAddress, evmApi, ABI);
|
|
34
|
+
const _address = (0, _util.u8aToHex)((0, _keyring.decodeAddress)(recipient));
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
36
|
+
const sendAvail = availBridgeContract.methods.sendAVAIL(_address, value);
|
|
37
|
+
const transferData = sendAvail.encodeABI();
|
|
38
|
+
const priority = await (0, _utils2.calculateGasFeeParams)(evmApi, evmApi.chainSlug);
|
|
39
|
+
const gasLimit = await sendAvail.estimateGas({
|
|
40
|
+
from: sender
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
from: sender,
|
|
44
|
+
to: availBridgeContractAddress,
|
|
45
|
+
value: '0',
|
|
46
|
+
data: transferData,
|
|
47
|
+
gasPrice: priority.gasPrice,
|
|
48
|
+
maxFeePerGas: (_priority$maxFeePerGa = priority.maxFeePerGas) === null || _priority$maxFeePerGa === void 0 ? void 0 : _priority$maxFeePerGa.toString(),
|
|
49
|
+
maxPriorityFeePerGas: (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString(),
|
|
50
|
+
gas: gasLimit
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
async function getAvailBridgeExtrinsicFromAvail(recipient, sendingValue, substrateApi) {
|
|
54
|
+
const data = {
|
|
55
|
+
message: {
|
|
56
|
+
FungibleToken: {
|
|
57
|
+
assetId: AvailBridgeConfig.ASSET_ID,
|
|
58
|
+
amount: BigInt(sendingValue)
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
to: `${recipient.padEnd(66, '0')}`,
|
|
62
|
+
domain: AvailBridgeConfig.ETHEREUM_DOMAIN
|
|
63
|
+
};
|
|
64
|
+
const chainApi = await substrateApi.isReady;
|
|
65
|
+
return chainApi.api.tx.vector.sendMessage(data.message, data.to, data.domain);
|
|
66
|
+
}
|
|
67
|
+
async function getClaimTxOnAvail(notification, substrateApi) {
|
|
68
|
+
const chainApi = await substrateApi.isReady;
|
|
69
|
+
const chainSlug = chainApi.chainSlug;
|
|
70
|
+
const metadata = notification.metadata;
|
|
71
|
+
const lastestEthHeadSlot = await getLastestEthHeadSlot(chainSlug);
|
|
72
|
+
const lastestBlockHash = await getLastestBlockHash(chainSlug, lastestEthHeadSlot);
|
|
73
|
+
const proof = await getClaimProofOnAvail(chainSlug, lastestBlockHash, metadata.messageId);
|
|
74
|
+
return chainApi.api.tx.vector.execute(lastestEthHeadSlot, getAddressMessage(notification), proof.accountProof, proof.storageProof);
|
|
75
|
+
}
|
|
76
|
+
async function getLastestEthHeadSlot(chainSlug) {
|
|
77
|
+
try {
|
|
78
|
+
const api = getAvailBridgeApi(chainSlug);
|
|
79
|
+
const rawResponse = await fetch(`${api}/eth/head`);
|
|
80
|
+
const response = await rawResponse.json();
|
|
81
|
+
return response.slot;
|
|
82
|
+
} catch (e) {
|
|
83
|
+
console.error(e);
|
|
84
|
+
throw e;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async function getLastestBlockHash(chainSlug, slot) {
|
|
88
|
+
try {
|
|
89
|
+
const api = getAvailBridgeApi(chainSlug);
|
|
90
|
+
const rawResponse = await fetch(`${api}/beacon/slot/${slot}`);
|
|
91
|
+
const response = await rawResponse.json();
|
|
92
|
+
return response.blockHash;
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.error(e);
|
|
95
|
+
throw e;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function getClaimProofOnAvail(chainSlug, blockHash, messageId) {
|
|
99
|
+
try {
|
|
100
|
+
const api = getAvailBridgeApi(chainSlug);
|
|
101
|
+
const rawResponse = await fetch(`${api}/avl/proof/${blockHash}/${messageId}`);
|
|
102
|
+
return await rawResponse.json();
|
|
103
|
+
} catch (e) {
|
|
104
|
+
console.error(e);
|
|
105
|
+
throw e;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function getClaimProofOnEthereum(chainSlug, blockHash, transactionIndex) {
|
|
109
|
+
try {
|
|
110
|
+
const api = getAvailBridgeApi(chainSlug);
|
|
111
|
+
const rawResponse = await fetch(`${api}/eth/proof/${blockHash}?index=${transactionIndex}`);
|
|
112
|
+
return await rawResponse.json();
|
|
113
|
+
} catch (e) {
|
|
114
|
+
console.error(e);
|
|
115
|
+
throw e;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function getAvailBridgeApi(chainSlug) {
|
|
119
|
+
if (chainSlug === 'avail_mainnet' || chainSlug === _chainList.COMMON_CHAIN_SLUGS.ETHEREUM) {
|
|
120
|
+
// todo: add COMMON_CHAIN_SLUGS for AVAIL, AVAIL TURING
|
|
121
|
+
return _utils3.AVAIL_BRIDGE_API.AVAIL_MAINNET;
|
|
122
|
+
}
|
|
123
|
+
return _utils3.AVAIL_BRIDGE_API.AVAIL_TESTNET;
|
|
124
|
+
}
|
|
125
|
+
async function getClaimTxOnEthereum(chainSlug, notification, evmApi) {
|
|
126
|
+
var _priority$maxFeePerGa2, _priority$maxPriority2;
|
|
127
|
+
const availBridgeContractAddress = (0, _utils.getAvailBridgeGatewayContract)(chainSlug);
|
|
128
|
+
const ABI = getAvailBridgeAbi(chainSlug);
|
|
129
|
+
const availBridgeContract = (0, _web.getWeb3Contract)(availBridgeContractAddress, evmApi, ABI);
|
|
130
|
+
const metadata = notification.metadata;
|
|
131
|
+
const merkleProof = await getClaimProofOnEthereum(chainSlug, metadata.sourceBlockHash, metadata.sourceTransactionIndex);
|
|
132
|
+
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
134
|
+
const transfer = availBridgeContract.methods.receiveAVAIL({
|
|
135
|
+
messageType: '0x02',
|
|
136
|
+
from: merkleProof.message.from,
|
|
137
|
+
to: merkleProof.message.to,
|
|
138
|
+
originDomain: merkleProof.message.originDomain,
|
|
139
|
+
destinationDomain: merkleProof.message.destinationDomain,
|
|
140
|
+
data: evmApi.api.eth.abi.encodeParameters([{
|
|
141
|
+
name: 'assetId',
|
|
142
|
+
type: 'bytes32'
|
|
143
|
+
}, {
|
|
144
|
+
name: 'amount',
|
|
145
|
+
type: 'uint256'
|
|
146
|
+
}], [merkleProof.message.message.fungibleToken.asset_id, BigInt(merkleProof.message.message.fungibleToken.amount)]),
|
|
147
|
+
messageId: merkleProof.message.id
|
|
148
|
+
}, {
|
|
149
|
+
dataRootProof: merkleProof.dataRootProof,
|
|
150
|
+
leafProof: merkleProof.leafProof,
|
|
151
|
+
rangeHash: merkleProof.rangeHash,
|
|
152
|
+
dataRootIndex: merkleProof.dataRootIndex,
|
|
153
|
+
blobRoot: merkleProof.blobRoot,
|
|
154
|
+
bridgeRoot: merkleProof.bridgeRoot,
|
|
155
|
+
leaf: merkleProof.leaf,
|
|
156
|
+
leafIndex: merkleProof.leafIndex
|
|
157
|
+
});
|
|
158
|
+
const transferData = transfer.encodeABI();
|
|
159
|
+
const gasLimit = await transfer.estimateGas({
|
|
160
|
+
from: metadata.receiverAddress
|
|
161
|
+
});
|
|
162
|
+
const priority = await (0, _utils2.calculateGasFeeParams)(evmApi, evmApi.chainSlug);
|
|
163
|
+
return {
|
|
164
|
+
from: metadata.receiverAddress,
|
|
165
|
+
to: availBridgeContractAddress,
|
|
166
|
+
value: '0',
|
|
167
|
+
data: transferData,
|
|
168
|
+
gasPrice: priority.gasPrice,
|
|
169
|
+
maxFeePerGas: (_priority$maxFeePerGa2 = priority.maxFeePerGas) === null || _priority$maxFeePerGa2 === void 0 ? void 0 : _priority$maxFeePerGa2.toString(),
|
|
170
|
+
maxPriorityFeePerGas: (_priority$maxPriority2 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority2 === void 0 ? void 0 : _priority$maxPriority2.toString(),
|
|
171
|
+
gas: gasLimit
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function getAddressMessage(notification) {
|
|
175
|
+
const metadata = notification.metadata;
|
|
176
|
+
return {
|
|
177
|
+
message: {
|
|
178
|
+
FungibleToken: {
|
|
179
|
+
assetId: AvailBridgeConfig.ASSET_ID,
|
|
180
|
+
amount: metadata.amount
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
from: `${metadata.depositorAddress.padEnd(66, '0')}`,
|
|
184
|
+
to: (0, _util.u8aToHex)((0, _keyring.decodeAddress)(metadata.receiverAddress)),
|
|
185
|
+
originDomain: AvailBridgeConfig.ETHEREUM_DOMAIN,
|
|
186
|
+
destinationDomain: AvailBridgeConfig.AVAIL_DOMAIN,
|
|
187
|
+
id: metadata.messageId
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function getAvailBridgeAbi(chainSlug) {
|
|
191
|
+
if (chainSlug === _chainList.COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
|
|
192
|
+
return _utils._AVAIL_TEST_BRIDGE_GATEWAY_ABI;
|
|
193
|
+
}
|
|
194
|
+
return _utils._AVAIL_BRIDGE_GATEWAY_ABI;
|
|
195
|
+
}
|
|
196
|
+
function isAvailChainBridge(chainSlug) {
|
|
197
|
+
return ['avail_mainnet', 'availTuringTest'].includes(chainSlug);
|
|
198
|
+
}
|
|
@@ -4,8 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getXcmMockTxFee = exports.createXcmExtrinsic = exports.createSnowBridgeExtrinsic = void 0;
|
|
7
|
+
exports.getXcmMockTxFee = exports.createXcmExtrinsic = exports.createSnowBridgeExtrinsic = exports.createAvailBridgeTxFromEth = exports.createAvailBridgeExtrinsicFromAvail = void 0;
|
|
8
8
|
var _xcmParser = require("@subwallet/extension-base/core/substrate/xcm-parser");
|
|
9
|
+
var _availBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge");
|
|
9
10
|
var _polkadotXcm = require("@subwallet/extension-base/services/balance-service/transfer/xcm/polkadotXcm");
|
|
10
11
|
var _snowBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/snowBridge");
|
|
11
12
|
var _xcmPallet = require("@subwallet/extension-base/services/balance-service/transfer/xcm/xcmPallet");
|
|
@@ -33,6 +34,12 @@ const createSnowBridgeExtrinsic = async _ref => {
|
|
|
33
34
|
if (!(0, _xcmParser._isSnowBridgeXcm)(originChainInfo, destinationChainInfo)) {
|
|
34
35
|
throw new Error('This is not a valid SnowBridge transfer');
|
|
35
36
|
}
|
|
37
|
+
if (!evmApi) {
|
|
38
|
+
throw Error('Evm API is not available');
|
|
39
|
+
}
|
|
40
|
+
if (!sender) {
|
|
41
|
+
throw Error('Sender is required');
|
|
42
|
+
}
|
|
36
43
|
return (0, _snowBridge.getSnowBridgeEvmTransfer)(originTokenInfo, originChainInfo, destinationChainInfo, sender, recipient, sendingValue, evmApi);
|
|
37
44
|
};
|
|
38
45
|
exports.createSnowBridgeExtrinsic = createSnowBridgeExtrinsic;
|
|
@@ -47,6 +54,9 @@ const createXcmExtrinsic = async _ref2 => {
|
|
|
47
54
|
} = _ref2;
|
|
48
55
|
const originChainInfo = chainInfoMap[originTokenInfo.originChain];
|
|
49
56
|
const destinationChainInfo = chainInfoMap[destinationTokenInfo.originChain];
|
|
57
|
+
if (!substrateApi) {
|
|
58
|
+
throw Error('Substrate API is not available');
|
|
59
|
+
}
|
|
50
60
|
const chainApi = await substrateApi.isReady;
|
|
51
61
|
const api = chainApi.api;
|
|
52
62
|
const polkadotXcmSpecialCases = _constants._XCM_CHAIN_GROUP.polkadotXcmSpecialCases.includes(originChainInfo.slug) && (0, _utils._isNativeToken)(originTokenInfo);
|
|
@@ -59,24 +69,59 @@ const createXcmExtrinsic = async _ref2 => {
|
|
|
59
69
|
return (0, _xTokens.getExtrinsicByXtokensPallet)(originTokenInfo, originChainInfo, destinationChainInfo, recipient, sendingValue, api);
|
|
60
70
|
};
|
|
61
71
|
exports.createXcmExtrinsic = createXcmExtrinsic;
|
|
72
|
+
const createAvailBridgeTxFromEth = _ref3 => {
|
|
73
|
+
let {
|
|
74
|
+
chainInfoMap,
|
|
75
|
+
evmApi,
|
|
76
|
+
originTokenInfo,
|
|
77
|
+
recipient,
|
|
78
|
+
sender,
|
|
79
|
+
sendingValue
|
|
80
|
+
} = _ref3;
|
|
81
|
+
const originChainInfo = chainInfoMap[originTokenInfo.originChain];
|
|
82
|
+
if (!evmApi) {
|
|
83
|
+
throw Error('Evm API is not available');
|
|
84
|
+
}
|
|
85
|
+
if (!sender) {
|
|
86
|
+
throw Error('Sender is required');
|
|
87
|
+
}
|
|
88
|
+
return (0, _availBridge.getAvailBridgeTxFromEth)(originChainInfo, sender, recipient, sendingValue, evmApi);
|
|
89
|
+
};
|
|
90
|
+
exports.createAvailBridgeTxFromEth = createAvailBridgeTxFromEth;
|
|
91
|
+
const createAvailBridgeExtrinsicFromAvail = async _ref4 => {
|
|
92
|
+
let {
|
|
93
|
+
recipient,
|
|
94
|
+
sendingValue,
|
|
95
|
+
substrateApi
|
|
96
|
+
} = _ref4;
|
|
97
|
+
if (!substrateApi) {
|
|
98
|
+
throw Error('Substrate API is not available');
|
|
99
|
+
}
|
|
100
|
+
return await (0, _availBridge.getAvailBridgeExtrinsicFromAvail)(recipient, sendingValue, substrateApi);
|
|
101
|
+
};
|
|
102
|
+
exports.createAvailBridgeExtrinsicFromAvail = createAvailBridgeExtrinsicFromAvail;
|
|
62
103
|
const getXcmMockTxFee = async (substrateApi, chainInfoMap, originTokenInfo, destinationTokenInfo) => {
|
|
63
104
|
try {
|
|
64
105
|
var _paymentInfo$partialF;
|
|
65
106
|
const destChainInfo = chainInfoMap[destinationTokenInfo.originChain];
|
|
66
107
|
const originChainInfo = chainInfoMap[originTokenInfo.originChain];
|
|
67
|
-
const
|
|
108
|
+
const fakeAddress = '5DRewsYzhJqZXU3SRaWy1FSt5iDr875ao91aw5fjrJmDG4Ap'; // todo: move this
|
|
109
|
+
const substrateAddress = fakeAddress; // todo: move this
|
|
110
|
+
const evmAddress = (0, _util.u8aToHex)((0, _utilCrypto.addressToEvm)(fakeAddress)); // todo: move this
|
|
68
111
|
|
|
69
112
|
// mock receiving account from sender
|
|
70
|
-
const
|
|
113
|
+
const sender = (0, _utils._isChainEvmCompatible)(originChainInfo) ? evmAddress : substrateAddress;
|
|
114
|
+
const recipient = (0, _utils._isChainEvmCompatible)(destChainInfo) ? evmAddress : substrateAddress;
|
|
71
115
|
const mockTx = await createXcmExtrinsic({
|
|
72
116
|
chainInfoMap,
|
|
73
117
|
destinationTokenInfo,
|
|
74
118
|
originTokenInfo,
|
|
75
|
-
|
|
119
|
+
sender,
|
|
120
|
+
recipient,
|
|
76
121
|
sendingValue: '1000000000000000000',
|
|
77
122
|
substrateApi
|
|
78
123
|
});
|
|
79
|
-
const paymentInfo = await mockTx.paymentInfo(
|
|
124
|
+
const paymentInfo = await mockTx.paymentInfo(fakeAddress);
|
|
80
125
|
return new _bignumber.default((paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF = paymentInfo.partialFee) === null || _paymentInfo$partialF === void 0 ? void 0 : _paymentInfo$partialF.toString()) || '0');
|
|
81
126
|
} catch (e) {
|
|
82
127
|
console.error('error mocking xcm tx fee', e);
|
|
@@ -80,15 +80,11 @@ class EvmApi {
|
|
|
80
80
|
createIntervalCheckApi() {
|
|
81
81
|
this.clearIntervalCheckApi();
|
|
82
82
|
return setInterval(() => {
|
|
83
|
-
|
|
84
|
-
this.api.eth.net.isListening().then(() => {
|
|
85
|
-
this.onConnect();
|
|
86
|
-
}).catch(() => {
|
|
87
|
-
this.onDisconnect();
|
|
88
|
-
});
|
|
89
|
-
} else {
|
|
83
|
+
this.api.eth.getChainId().then(() => {
|
|
90
84
|
this.onConnect();
|
|
91
|
-
}
|
|
85
|
+
}).catch(() => {
|
|
86
|
+
this.onDisconnect();
|
|
87
|
+
});
|
|
92
88
|
}, 10000);
|
|
93
89
|
}
|
|
94
90
|
clearIntervalCheckApi() {
|
|
@@ -101,21 +97,16 @@ class EvmApi {
|
|
|
101
97
|
this.updateConnectionStatus(_types._ChainConnectionStatus.CONNECTING);
|
|
102
98
|
|
|
103
99
|
// Check if api is ready
|
|
104
|
-
|
|
105
|
-
this.api.eth.net.isListening().then(() => {
|
|
106
|
-
this.isApiReadyOnce = true;
|
|
107
|
-
this.onConnect();
|
|
108
|
-
}).catch(error => {
|
|
109
|
-
this.isApiReadyOnce = false;
|
|
110
|
-
this.isApiReady = false;
|
|
111
|
-
this.isReadyHandler.reject(error);
|
|
112
|
-
this.updateConnectionStatus(_types._ChainConnectionStatus.DISCONNECTED);
|
|
113
|
-
console.warn(`Can not connect to ${this.chainSlug} (EVM) at ${this.apiUrl}`);
|
|
114
|
-
});
|
|
115
|
-
} else {
|
|
100
|
+
this.api.eth.getChainId().then(() => {
|
|
116
101
|
this.isApiReadyOnce = true;
|
|
117
102
|
this.onConnect();
|
|
118
|
-
}
|
|
103
|
+
}).catch(error => {
|
|
104
|
+
this.isApiReadyOnce = false;
|
|
105
|
+
this.isApiReady = false;
|
|
106
|
+
this.isReadyHandler.reject(error);
|
|
107
|
+
this.updateConnectionStatus(_types._ChainConnectionStatus.DISCONNECTED);
|
|
108
|
+
console.warn(`Can not connect to ${this.chainSlug} (EVM) at ${this.apiUrl}`);
|
|
109
|
+
});
|
|
119
110
|
|
|
120
111
|
// Interval to check connecting status
|
|
121
112
|
this.intervalCheckApi = this.createIntervalCheckApi();
|
|
@@ -186,6 +186,15 @@ class SubstrateChainHandler extends _AbstractChainHandler.AbstractChainHandler {
|
|
|
186
186
|
}
|
|
187
187
|
return [nameRes, decimals, symbolRes, contractError];
|
|
188
188
|
}
|
|
189
|
+
async getLocalTokenInfo(apiPromise, assetId) {
|
|
190
|
+
const _metadata = await apiPromise.query.assets.metadata(assetId);
|
|
191
|
+
const metadata = _metadata.toPrimitive();
|
|
192
|
+
let idError = false;
|
|
193
|
+
if (!metadata.name || !metadata.symbol) {
|
|
194
|
+
idError = true;
|
|
195
|
+
}
|
|
196
|
+
return [metadata.name, metadata.decimals, metadata.symbol, idError];
|
|
197
|
+
}
|
|
189
198
|
async getSubstrateContractTokenInfo(contractAddress, tokenType, originChain, contractCaller) {
|
|
190
199
|
// todo: improve this funtion later
|
|
191
200
|
|
|
@@ -225,6 +234,26 @@ class SubstrateChainHandler extends _AbstractChainHandler.AbstractChainHandler {
|
|
|
225
234
|
};
|
|
226
235
|
}
|
|
227
236
|
}
|
|
237
|
+
async getSubstrateAssetIdTokenInfo(assetId, originChain) {
|
|
238
|
+
const apiPromise = this.getSubstrateApiByChain(originChain).api;
|
|
239
|
+
try {
|
|
240
|
+
const [name, decimals, symbol, contractError] = await this.getLocalTokenInfo(apiPromise, assetId);
|
|
241
|
+
return {
|
|
242
|
+
name,
|
|
243
|
+
decimals,
|
|
244
|
+
symbol,
|
|
245
|
+
contractError
|
|
246
|
+
};
|
|
247
|
+
} catch (e) {
|
|
248
|
+
this.logger.error(e);
|
|
249
|
+
return {
|
|
250
|
+
name: '',
|
|
251
|
+
decimals: -1,
|
|
252
|
+
symbol: '',
|
|
253
|
+
contractError: true
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
}
|
|
228
257
|
setSubstrateApi(chainSlug, substrateApi) {
|
|
229
258
|
this.substrateApiMap[chainSlug] = substrateApi;
|
|
230
259
|
}
|
|
@@ -201,6 +201,15 @@ class ChainService {
|
|
|
201
201
|
});
|
|
202
202
|
return filteredAssetRegistry;
|
|
203
203
|
}
|
|
204
|
+
getAssetHubToken() {
|
|
205
|
+
const assetHubToken = {};
|
|
206
|
+
Object.values(this.getAssetRegistry()).forEach(asset => {
|
|
207
|
+
if (['statemint', 'statemine'].includes(asset.originChain)) {
|
|
208
|
+
assetHubToken[asset.slug] = asset;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
return assetHubToken;
|
|
212
|
+
}
|
|
204
213
|
getChainInfoMap() {
|
|
205
214
|
return this.dataMap.chainInfoMap;
|
|
206
215
|
}
|
|
@@ -458,7 +467,7 @@ class ChainService {
|
|
|
458
467
|
upsertCustomToken(token) {
|
|
459
468
|
if (token.slug.length === 0) {
|
|
460
469
|
// new token
|
|
461
|
-
if (token.assetType === _types._AssetType.NATIVE) {
|
|
470
|
+
if (token.assetType === _types._AssetType.NATIVE || token.assetType === _types._AssetType.LOCAL) {
|
|
462
471
|
const defaultSlug = this.generateSlugForNativeToken(token.originChain, token.assetType, token.symbol);
|
|
463
472
|
token.slug = `${_types3._CUSTOM_PREFIX}${defaultSlug}`;
|
|
464
473
|
} else {
|
|
@@ -467,7 +476,7 @@ class ChainService {
|
|
|
467
476
|
token.slug = `${_types3._CUSTOM_PREFIX}${defaultSlug}`;
|
|
468
477
|
}
|
|
469
478
|
}
|
|
470
|
-
if (token.originChain && (0, _utils._isAssetFungibleToken)(token)) {
|
|
479
|
+
if (token.originChain && ((0, _utils._isAssetFungibleToken)(token) || (0, _utils._isLocalToken)(token))) {
|
|
471
480
|
var _this$getChainInfoByK;
|
|
472
481
|
token.hasValue = !((_this$getChainInfoByK = this.getChainInfoByKey(token.originChain)) !== null && _this$getChainInfoByK !== void 0 && _this$getChainInfoByK.isTestnet);
|
|
473
482
|
}
|
|
@@ -1540,13 +1549,35 @@ class ChainService {
|
|
|
1540
1549
|
contractError: false
|
|
1541
1550
|
};
|
|
1542
1551
|
}
|
|
1552
|
+
async getAssetIdTokenInfo(assetId, tokenType, chain) {
|
|
1553
|
+
if ([_types._AssetType.LOCAL].includes(tokenType) && assetId) {
|
|
1554
|
+
return await this.substrateChainHandler.getSubstrateAssetIdTokenInfo(assetId, chain);
|
|
1555
|
+
}
|
|
1556
|
+
return {
|
|
1557
|
+
decimals: -1,
|
|
1558
|
+
name: '',
|
|
1559
|
+
symbol: '',
|
|
1560
|
+
contractError: false
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1543
1563
|
async validateCustomToken(data) {
|
|
1544
1564
|
const assetRegistry = this.getSmartContractTokens();
|
|
1565
|
+
const asset = this.getAssetHubToken();
|
|
1545
1566
|
let existedToken;
|
|
1546
1567
|
for (const token of Object.values(assetRegistry)) {
|
|
1547
1568
|
var _token$metadata2;
|
|
1548
1569
|
const contractAddress = token === null || token === void 0 ? void 0 : (_token$metadata2 = token.metadata) === null || _token$metadata2 === void 0 ? void 0 : _token$metadata2.contractAddress;
|
|
1549
|
-
if (
|
|
1570
|
+
if (data.contractAddress) {
|
|
1571
|
+
if ((0, _utils._isEqualContractAddress)(contractAddress, data.contractAddress) && token.assetType === data.type && token.originChain === data.originChain) {
|
|
1572
|
+
existedToken = token;
|
|
1573
|
+
break;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
for (const token of Object.values(asset)) {
|
|
1578
|
+
var _token$metadata3;
|
|
1579
|
+
const assetId = token === null || token === void 0 ? void 0 : (_token$metadata3 = token.metadata) === null || _token$metadata3 === void 0 ? void 0 : _token$metadata3.assetId;
|
|
1580
|
+
if (assetId === data.assetId && token.assetType === data.type && token.originChain === data.originChain) {
|
|
1550
1581
|
existedToken = token;
|
|
1551
1582
|
break;
|
|
1552
1583
|
}
|
|
@@ -1562,18 +1593,18 @@ class ChainService {
|
|
|
1562
1593
|
contractError: false
|
|
1563
1594
|
};
|
|
1564
1595
|
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
}
|
|
1596
|
+
let info;
|
|
1597
|
+
if (data.contractAddress) {
|
|
1598
|
+
info = await this.getSmartContractTokenInfo(data.contractAddress, data.type, data.originChain, data.contractCaller);
|
|
1599
|
+
} else {
|
|
1600
|
+
info = await this.getAssetIdTokenInfo(data.assetId, data.type, data.originChain);
|
|
1601
|
+
}
|
|
1571
1602
|
return {
|
|
1572
|
-
name,
|
|
1573
|
-
decimals,
|
|
1574
|
-
symbol,
|
|
1603
|
+
name: info.name,
|
|
1604
|
+
decimals: info.decimals,
|
|
1605
|
+
symbol: info.symbol,
|
|
1575
1606
|
isExist: !!existedToken,
|
|
1576
|
-
contractError
|
|
1607
|
+
contractError: info.contractError
|
|
1577
1608
|
};
|
|
1578
1609
|
}
|
|
1579
1610
|
generateSlugForSmartContractAsset(originChain, assetType, symbol, contractAddress) {
|
|
@@ -42,6 +42,8 @@ var _exportNames = {
|
|
|
42
42
|
_isChainSupportWasmNft: true,
|
|
43
43
|
_isChainSupportEvmERC20: true,
|
|
44
44
|
_isChainSupportWasmPSP22: true,
|
|
45
|
+
_isAssetHubChain: true,
|
|
46
|
+
_isAssetHubToken: true,
|
|
45
47
|
_isChainSupportGRC20: true,
|
|
46
48
|
_isChainSupportVFT: true,
|
|
47
49
|
_isSupportOrdinal: true,
|
|
@@ -77,6 +79,7 @@ var _exportNames = {
|
|
|
77
79
|
_getAssetDecimals: true,
|
|
78
80
|
_getBlockExplorerFromChain: true,
|
|
79
81
|
_parseMetadataForSmartContractAsset: true,
|
|
82
|
+
_parseMetadataForAssetId: true,
|
|
80
83
|
_isChainTestNet: true,
|
|
81
84
|
_isAssetFungibleToken: true,
|
|
82
85
|
_isAssetAutoEnable: true,
|
|
@@ -132,6 +135,8 @@ exports._getXcmTransferType = _getXcmTransferType;
|
|
|
132
135
|
exports._isAssetAutoEnable = void 0;
|
|
133
136
|
exports._isAssetCanPayTxFee = _isAssetCanPayTxFee;
|
|
134
137
|
exports._isAssetFungibleToken = _isAssetFungibleToken;
|
|
138
|
+
exports._isAssetHubChain = _isAssetHubChain;
|
|
139
|
+
exports._isAssetHubToken = _isAssetHubToken;
|
|
135
140
|
exports._isAssetSmartContractNft = _isAssetSmartContractNft;
|
|
136
141
|
exports._isAssetValuable = _isAssetValuable;
|
|
137
142
|
exports._isBridgedToken = _isBridgedToken;
|
|
@@ -176,6 +181,7 @@ exports._isTokenTransferredByTon = _isTokenTransferredByTon;
|
|
|
176
181
|
exports._isTokenWasmSmartContract = _isTokenWasmSmartContract;
|
|
177
182
|
exports._isXcmPathSupported = _isXcmPathSupported;
|
|
178
183
|
exports._parseAssetRefKey = _parseAssetRefKey;
|
|
184
|
+
exports._parseMetadataForAssetId = _parseMetadataForAssetId;
|
|
179
185
|
exports._parseMetadataForSmartContractAsset = _parseMetadataForSmartContractAsset;
|
|
180
186
|
exports.findChainInfoByHalfGenesisHash = exports.findChainInfoByChainId = void 0;
|
|
181
187
|
exports.randomizeProvider = randomizeProvider;
|
|
@@ -388,6 +394,12 @@ function _isChainSupportWasmPSP22(chainInfo) {
|
|
|
388
394
|
var _chainInfo$substrateI10, _chainInfo$substrateI11;
|
|
389
395
|
return ((_chainInfo$substrateI10 = chainInfo.substrateInfo) === null || _chainInfo$substrateI10 === void 0 ? void 0 : (_chainInfo$substrateI11 = _chainInfo$substrateI10.supportSmartContract) === null || _chainInfo$substrateI11 === void 0 ? void 0 : _chainInfo$substrateI11.includes(_types._AssetType.PSP22)) || false;
|
|
390
396
|
}
|
|
397
|
+
function _isAssetHubChain(chainInfo) {
|
|
398
|
+
return ['statemint', 'statemine'].includes(chainInfo.slug);
|
|
399
|
+
}
|
|
400
|
+
function _isAssetHubToken(token) {
|
|
401
|
+
return ['statemint', 'statemine'].includes(token.originChain);
|
|
402
|
+
}
|
|
391
403
|
function _isChainSupportGRC20(chainInfo) {
|
|
392
404
|
var _chainInfo$substrateI12, _chainInfo$substrateI13;
|
|
393
405
|
return ((_chainInfo$substrateI12 = chainInfo.substrateInfo) === null || _chainInfo$substrateI12 === void 0 ? void 0 : (_chainInfo$substrateI13 = _chainInfo$substrateI12.supportSmartContract) === null || _chainInfo$substrateI13 === void 0 ? void 0 : _chainInfo$substrateI13.includes(_types._AssetType.GRC20)) || false;
|
|
@@ -435,6 +447,9 @@ function _getTokenTypesSupportedByChain(chainInfo) {
|
|
|
435
447
|
}
|
|
436
448
|
});
|
|
437
449
|
}
|
|
450
|
+
if (['statemint', 'statemine'].includes(chainInfo.slug)) {
|
|
451
|
+
result.push(_types._AssetType.LOCAL);
|
|
452
|
+
}
|
|
438
453
|
return result;
|
|
439
454
|
}
|
|
440
455
|
function _getChainNativeTokenBasicInfo(chainInfo) {
|
|
@@ -588,6 +603,11 @@ function _parseMetadataForSmartContractAsset(contractAddress) {
|
|
|
588
603
|
contractAddress
|
|
589
604
|
};
|
|
590
605
|
}
|
|
606
|
+
function _parseMetadataForAssetId(assetId) {
|
|
607
|
+
return {
|
|
608
|
+
assetId
|
|
609
|
+
};
|
|
610
|
+
}
|
|
591
611
|
function _isChainTestNet(chainInfo) {
|
|
592
612
|
return chainInfo.isTestnet || false;
|
|
593
613
|
}
|
|
@@ -7,7 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
8
8
|
var _constants = require("@subwallet/extension-base/constants");
|
|
9
9
|
var _constants2 = require("@subwallet/extension-base/services/earning-service/constants");
|
|
10
|
-
var _utils = require("@subwallet/extension-base/utils");
|
|
10
|
+
var _utils = require("@subwallet/extension-base/services/inapp-notification-service/utils");
|
|
11
|
+
var _utils2 = require("@subwallet/extension-base/utils");
|
|
11
12
|
var _util = require("@polkadot/util");
|
|
12
13
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
13
14
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -98,6 +99,14 @@ class BasePoolHandler {
|
|
|
98
99
|
availableMethod: this.availableMethod
|
|
99
100
|
};
|
|
100
101
|
}
|
|
102
|
+
async createWithdrawNotifications(unstakingInfos, tokenInfo, address) {
|
|
103
|
+
const notifications = (0, _utils.createWithdrawNotifications)(unstakingInfos, tokenInfo, address, this.baseInfo.slug, this.type);
|
|
104
|
+
await this.state.inappNotificationService.validateAndWriteNotificationsToDB(notifications, address);
|
|
105
|
+
}
|
|
106
|
+
async createClaimNotification(claimItemInfo, tokenInfo) {
|
|
107
|
+
const notification = (0, _utils.createClaimNotification)(claimItemInfo, tokenInfo);
|
|
108
|
+
await this.state.inappNotificationService.validateAndWriteNotificationsToDB([notification], claimItemInfo.address);
|
|
109
|
+
}
|
|
101
110
|
|
|
102
111
|
/** Can mint when haven't enough native token (use input token for fee) */
|
|
103
112
|
get isPoolSupportAlternativeFee() {
|
|
@@ -107,7 +116,7 @@ class BasePoolHandler {
|
|
|
107
116
|
return await this.state.earningService.getYieldPool(this.slug);
|
|
108
117
|
}
|
|
109
118
|
async getPoolPosition(address) {
|
|
110
|
-
const originAddress = (0,
|
|
119
|
+
const originAddress = (0, _utils2.reformatAddress)(address);
|
|
111
120
|
return await this.state.earningService.getYieldPosition(originAddress, this.slug);
|
|
112
121
|
}
|
|
113
122
|
|
|
@@ -140,7 +149,7 @@ class BasePoolHandler {
|
|
|
140
149
|
const bnNativeTokenBalance = new _util.BN(nativeTokenBalance.value);
|
|
141
150
|
const bnMinBalanceToJoin = new _util.BN(((_poolInfo$statistic2 = poolInfo.statistic) === null || _poolInfo$statistic2 === void 0 ? void 0 : (_poolInfo$statistic2$ = _poolInfo$statistic2.earningThreshold) === null || _poolInfo$statistic2$ === void 0 ? void 0 : _poolInfo$statistic2$.join) || '0').add(new _util.BN(poolInfo.metadata.maintainBalance));
|
|
142
151
|
if (bnNativeTokenBalance.lte(bnMinBalanceToJoin)) {
|
|
143
|
-
const minJoin = (0,
|
|
152
|
+
const minJoin = (0, _utils2.formatNumber)(bnMinBalanceToJoin.toString(), this.nativeToken.decimals || 0);
|
|
144
153
|
const originChain = this.state.getChainInfo(nativeTokenInfo.originChain);
|
|
145
154
|
return {
|
|
146
155
|
passed: false,
|
|
@@ -166,6 +166,7 @@ class AmplitudeNativeStakingPoolHandler extends _basePara.default {
|
|
|
166
166
|
}
|
|
167
167
|
const totalBalance = new _util.BN(activeStake).add(new _util.BN(unstakingBalance));
|
|
168
168
|
const stakingStatus = (0, _utils.getEarningStatusByNominations)(new _util.BN(activeStake), nominationList);
|
|
169
|
+
await this.createWithdrawNotifications(unstakingList, this.nativeToken, address);
|
|
169
170
|
return {
|
|
170
171
|
status: stakingStatus,
|
|
171
172
|
balanceToken: this.nativeToken.slug,
|
|
@@ -251,13 +252,20 @@ class AmplitudeNativeStakingPoolHandler extends _basePara.default {
|
|
|
251
252
|
if (cancel) {
|
|
252
253
|
return;
|
|
253
254
|
}
|
|
254
|
-
|
|
255
|
+
const earningRewardItem = {
|
|
255
256
|
...this.baseInfo,
|
|
256
257
|
address: address,
|
|
257
258
|
type: this.type,
|
|
258
259
|
unclaimedReward: _unclaimedReward.toString(),
|
|
259
260
|
state: _KoniTypes.APIItemState.READY
|
|
260
|
-
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// TODO: Enable this when claim action is ready
|
|
264
|
+
// if (_unclaimedReward.toString() !== '0') {
|
|
265
|
+
// await this.createClaimNotification(earningRewardItem, this.nativeToken);
|
|
266
|
+
// }
|
|
267
|
+
|
|
268
|
+
callBack(earningRewardItem);
|
|
261
269
|
}));
|
|
262
270
|
}
|
|
263
271
|
return () => {
|
|
@@ -216,6 +216,8 @@ class ParaNativeStakingPoolHandler extends _basePara.default {
|
|
|
216
216
|
const totalStake = bnTotalStake.toString();
|
|
217
217
|
const activeStake = bnTotalActiveStake.toString();
|
|
218
218
|
const unstakingBalance = bnTotalUnstaking.toString();
|
|
219
|
+
const tokenInfo = this.state.chainService.getAssetBySlug(this.nativeToken.slug);
|
|
220
|
+
await this.createWithdrawNotifications(Object.values(unstakingMap), tokenInfo, address);
|
|
219
221
|
return {
|
|
220
222
|
status: stakingStatus,
|
|
221
223
|
totalStake,
|
|
@@ -178,6 +178,8 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
178
178
|
targetTimestampMs: targetTimestampMs
|
|
179
179
|
});
|
|
180
180
|
});
|
|
181
|
+
const tokenInfo = this.state.chainService.getAssetBySlug(this.nativeToken.slug);
|
|
182
|
+
await this.createWithdrawNotifications(unstakingList, tokenInfo, address);
|
|
181
183
|
return {
|
|
182
184
|
status: stakingStatus,
|
|
183
185
|
balanceToken: this.nativeToken.slug,
|