@subwallet/extension-base 1.1.18-1 → 1.1.19-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/cjs/koni/api/dotsama/transfer.js +1 -1
- package/cjs/koni/background/handlers/Extension.js +11 -7
- package/cjs/koni/background/handlers/State.js +3 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/index.js +27 -5
- package/cjs/services/storage-service/db-stores/Crowdloan.js +14 -0
- package/koni/api/dotsama/transfer.js +1 -1
- package/koni/background/handlers/Extension.js +11 -7
- package/koni/background/handlers/State.js +3 -0
- package/package.json +6 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/index.js +28 -6
- package/services/storage-service/db-stores/Crowdloan.d.ts +1 -0
- package/services/storage-service/db-stores/Crowdloan.js +14 -0
|
@@ -190,7 +190,7 @@ const createTransferExtrinsic = async _ref => {
|
|
|
190
190
|
if (transferAll) {
|
|
191
191
|
transfer = api.tx.balances.transferAll(to, false);
|
|
192
192
|
} else if (value) {
|
|
193
|
-
transfer = api.tx.balances.
|
|
193
|
+
transfer = api.tx.balances.transferKeepAlive(to, new _util.BN(value));
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
return [transfer, transferAmount || value];
|
|
@@ -1625,7 +1625,7 @@ class KoniExtension {
|
|
|
1625
1625
|
if (new _bignumber.default(receiverBalance).plus(transferAmount.value).lt(minAmount)) {
|
|
1626
1626
|
const atLeast = new _bignumber.default(minAmount).minus(receiverBalance).plus((tokenInfo.decimals || 0) === 0 ? 0 : 1);
|
|
1627
1627
|
const atLeastStr = (0, _number.formatNumber)(atLeast, tokenInfo.decimals || 0, _number.balanceFormatter);
|
|
1628
|
-
inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}}{{symbol}} to keep the destination account alive', {
|
|
1628
|
+
inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
|
|
1629
1629
|
replace: {
|
|
1630
1630
|
amount: atLeastStr,
|
|
1631
1631
|
symbol: tokenInfo.symbol
|
|
@@ -1694,7 +1694,7 @@ class KoniExtension {
|
|
|
1694
1694
|
// Check ed for receiver
|
|
1695
1695
|
if (new _bignumber.default(value).lt(atLeast)) {
|
|
1696
1696
|
const atLeastStr = (0, _number.formatNumber)(atLeast, destinationTokenInfo.decimals || 0, _number.balanceFormatter);
|
|
1697
|
-
inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}}{{symbol}} to keep the destination account alive', {
|
|
1697
|
+
inputTransaction.errors.push(new _TransactionError.TransactionError(_KoniTypes.TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, (0, _i18next.t)('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
|
|
1698
1698
|
replace: {
|
|
1699
1699
|
amount: atLeastStr,
|
|
1700
1700
|
symbol: originTokenInfo.symbol
|
|
@@ -1884,7 +1884,6 @@ class KoniExtension {
|
|
|
1884
1884
|
if (!destinationTokenInfo) {
|
|
1885
1885
|
estimatedFee = '0';
|
|
1886
1886
|
} else {
|
|
1887
|
-
var _paymentInfo$partialF;
|
|
1888
1887
|
maxTransferable = maxTransferable.sub(new _util.BN(tokenInfo.minAmount || '0'));
|
|
1889
1888
|
const desChainInfo = chainInfoMap[destChain];
|
|
1890
1889
|
const orgChainInfo = chainInfoMap[networkKey];
|
|
@@ -1894,11 +1893,16 @@ class KoniExtension {
|
|
|
1894
1893
|
destinationTokenInfo,
|
|
1895
1894
|
originTokenInfo: tokenInfo,
|
|
1896
1895
|
recipient: recipient,
|
|
1897
|
-
sendingValue: '
|
|
1896
|
+
sendingValue: '1000000000000000000',
|
|
1898
1897
|
substrateApi
|
|
1899
1898
|
});
|
|
1900
|
-
|
|
1901
|
-
|
|
1899
|
+
try {
|
|
1900
|
+
var _paymentInfo$partialF;
|
|
1901
|
+
const paymentInfo = await mockTx.paymentInfo(address);
|
|
1902
|
+
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF = paymentInfo.partialFee) === null || _paymentInfo$partialF === void 0 ? void 0 : _paymentInfo$partialF.toString()) || '0';
|
|
1903
|
+
} catch (e) {
|
|
1904
|
+
estimatedFee = tokenInfo.minAmount || '0';
|
|
1905
|
+
}
|
|
1902
1906
|
}
|
|
1903
1907
|
} else {
|
|
1904
1908
|
const chainInfo = this.#koniState.chainService.getChainInfoByKey(networkKey);
|
|
@@ -1922,7 +1926,7 @@ class KoniExtension {
|
|
|
1922
1926
|
to: address,
|
|
1923
1927
|
tokenInfo,
|
|
1924
1928
|
transferAll: true,
|
|
1925
|
-
value: '
|
|
1929
|
+
value: '1000000000000000000'
|
|
1926
1930
|
});
|
|
1927
1931
|
const paymentInfo = await (mockTx === null || mockTx === void 0 ? void 0 : mockTx.paymentInfo(address));
|
|
1928
1932
|
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF2 = paymentInfo.partialFee) === null || _paymentInfo$partialF2 === void 0 ? void 0 : _paymentInfo$partialF2.toString()) || '0';
|
|
@@ -212,6 +212,9 @@ class KoniState {
|
|
|
212
212
|
this.onReady();
|
|
213
213
|
this.onAccountAdd();
|
|
214
214
|
this.onAccountRemove();
|
|
215
|
+
|
|
216
|
+
// TODO: consider moving this to a separate service
|
|
217
|
+
await this.dbService.stores.crowdloan.removeEndedCrowdloans();
|
|
215
218
|
await this.startSubscription();
|
|
216
219
|
}
|
|
217
220
|
async initMantaPay(password) {
|
package/cjs/packageInfo.js
CHANGED
|
@@ -647,12 +647,34 @@ class ChainService {
|
|
|
647
647
|
for (const [storedSlug, storedChainInfo] of Object.entries(storedChainSettingMap)) {
|
|
648
648
|
if (storedSlug in latestChainInfoMap) {
|
|
649
649
|
// check predefined chains first, keep setting for providers and currentProvider
|
|
650
|
-
|
|
651
|
-
|
|
650
|
+
// TODO: review merging providers
|
|
651
|
+
// Keep customer provider only
|
|
652
|
+
const providers = {
|
|
652
653
|
...mergedChainInfoMap[storedSlug].providers
|
|
653
|
-
};
|
|
654
|
+
};
|
|
655
|
+
for (const [key, value] of Object.entries(storedChainInfo.providers)) {
|
|
656
|
+
if ((0, _utils._isCustomProvider)(key)) {
|
|
657
|
+
if (!Object.values(providers).includes(value)) {
|
|
658
|
+
providers[key] = value;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
mergedChainInfoMap[storedSlug].providers = providers;
|
|
663
|
+
|
|
664
|
+
// Merge current provider
|
|
665
|
+
let currentProvider = storedChainInfo.currentProvider;
|
|
666
|
+
const providerValue = storedChainInfo.providers[currentProvider] || '';
|
|
667
|
+
if (!providers[currentProvider]) {
|
|
668
|
+
currentProvider = Object.keys(providers)[0];
|
|
669
|
+
for (const [key, value] of Object.entries(providers)) {
|
|
670
|
+
if (providerValue === value) {
|
|
671
|
+
currentProvider = key;
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
654
676
|
this.dataMap.chainStateMap[storedSlug] = {
|
|
655
|
-
currentProvider:
|
|
677
|
+
currentProvider: currentProvider,
|
|
656
678
|
slug: storedSlug,
|
|
657
679
|
connectionStatus: _types3._ChainConnectionStatus.DISCONNECTED,
|
|
658
680
|
active: storedChainInfo.active
|
|
@@ -660,7 +682,7 @@ class ChainService {
|
|
|
660
682
|
newStorageData.push({
|
|
661
683
|
...mergedChainInfoMap[storedSlug],
|
|
662
684
|
active: storedChainInfo.active,
|
|
663
|
-
currentProvider:
|
|
685
|
+
currentProvider: currentProvider
|
|
664
686
|
});
|
|
665
687
|
} else {
|
|
666
688
|
var _storedChainInfo$subs, _storedChainInfo$evmI;
|
|
@@ -10,6 +10,20 @@ var _BaseStoreWithAddressAndChain = _interopRequireDefault(require("@subwallet/e
|
|
|
10
10
|
// SPDX-License-Identifier: Apache-2.0
|
|
11
11
|
|
|
12
12
|
class CrowdloanStore extends _BaseStoreWithAddressAndChain.default {
|
|
13
|
+
async removeEndedCrowdloans() {
|
|
14
|
+
const now = new Date();
|
|
15
|
+
const removeList = [];
|
|
16
|
+
await this.table.each((obj, cursor) => {
|
|
17
|
+
try {
|
|
18
|
+
if (!obj.endTime || new Date(obj.endTime) < now) {
|
|
19
|
+
removeList.push(cursor.primaryKey);
|
|
20
|
+
}
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.error(e);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
await this.table.bulkDelete(removeList);
|
|
26
|
+
}
|
|
13
27
|
getCrowdloan(address) {
|
|
14
28
|
return this.table.where('address').equals(address).toArray();
|
|
15
29
|
}
|
|
@@ -181,7 +181,7 @@ export const createTransferExtrinsic = async ({
|
|
|
181
181
|
if (transferAll) {
|
|
182
182
|
transfer = api.tx.balances.transferAll(to, false);
|
|
183
183
|
} else if (value) {
|
|
184
|
-
transfer = api.tx.balances.
|
|
184
|
+
transfer = api.tx.balances.transferKeepAlive(to, new BN(value));
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
return [transfer, transferAmount || value];
|
|
@@ -1572,7 +1572,7 @@ export default class KoniExtension {
|
|
|
1572
1572
|
if (new BigN(receiverBalance).plus(transferAmount.value).lt(minAmount)) {
|
|
1573
1573
|
const atLeast = new BigN(minAmount).minus(receiverBalance).plus((tokenInfo.decimals || 0) === 0 ? 0 : 1);
|
|
1574
1574
|
const atLeastStr = formatNumber(atLeast, tokenInfo.decimals || 0, balanceFormatter);
|
|
1575
|
-
inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, t('You must transfer at least {{amount}}{{symbol}} to keep the destination account alive', {
|
|
1575
|
+
inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, t('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
|
|
1576
1576
|
replace: {
|
|
1577
1577
|
amount: atLeastStr,
|
|
1578
1578
|
symbol: tokenInfo.symbol
|
|
@@ -1641,7 +1641,7 @@ export default class KoniExtension {
|
|
|
1641
1641
|
// Check ed for receiver
|
|
1642
1642
|
if (new BigN(value).lt(atLeast)) {
|
|
1643
1643
|
const atLeastStr = formatNumber(atLeast, destinationTokenInfo.decimals || 0, balanceFormatter);
|
|
1644
|
-
inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, t('You must transfer at least {{amount}}{{symbol}} to keep the destination account alive', {
|
|
1644
|
+
inputTransaction.errors.push(new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, t('You must transfer at least {{amount}} {{symbol}} to keep the destination account alive', {
|
|
1645
1645
|
replace: {
|
|
1646
1646
|
amount: atLeastStr,
|
|
1647
1647
|
symbol: originTokenInfo.symbol
|
|
@@ -1827,7 +1827,6 @@ export default class KoniExtension {
|
|
|
1827
1827
|
if (!destinationTokenInfo) {
|
|
1828
1828
|
estimatedFee = '0';
|
|
1829
1829
|
} else {
|
|
1830
|
-
var _paymentInfo$partialF;
|
|
1831
1830
|
maxTransferable = maxTransferable.sub(new BN(tokenInfo.minAmount || '0'));
|
|
1832
1831
|
const desChainInfo = chainInfoMap[destChain];
|
|
1833
1832
|
const orgChainInfo = chainInfoMap[networkKey];
|
|
@@ -1837,11 +1836,16 @@ export default class KoniExtension {
|
|
|
1837
1836
|
destinationTokenInfo,
|
|
1838
1837
|
originTokenInfo: tokenInfo,
|
|
1839
1838
|
recipient: recipient,
|
|
1840
|
-
sendingValue: '
|
|
1839
|
+
sendingValue: '1000000000000000000',
|
|
1841
1840
|
substrateApi
|
|
1842
1841
|
});
|
|
1843
|
-
|
|
1844
|
-
|
|
1842
|
+
try {
|
|
1843
|
+
var _paymentInfo$partialF;
|
|
1844
|
+
const paymentInfo = await mockTx.paymentInfo(address);
|
|
1845
|
+
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF = paymentInfo.partialFee) === null || _paymentInfo$partialF === void 0 ? void 0 : _paymentInfo$partialF.toString()) || '0';
|
|
1846
|
+
} catch (e) {
|
|
1847
|
+
estimatedFee = tokenInfo.minAmount || '0';
|
|
1848
|
+
}
|
|
1845
1849
|
}
|
|
1846
1850
|
} else {
|
|
1847
1851
|
const chainInfo = this.#koniState.chainService.getChainInfoByKey(networkKey);
|
|
@@ -1865,7 +1869,7 @@ export default class KoniExtension {
|
|
|
1865
1869
|
to: address,
|
|
1866
1870
|
tokenInfo,
|
|
1867
1871
|
transferAll: true,
|
|
1868
|
-
value: '
|
|
1872
|
+
value: '1000000000000000000'
|
|
1869
1873
|
});
|
|
1870
1874
|
const paymentInfo = await (mockTx === null || mockTx === void 0 ? void 0 : mockTx.paymentInfo(address));
|
|
1871
1875
|
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF2 = paymentInfo.partialFee) === null || _paymentInfo$partialF2 === void 0 ? void 0 : _paymentInfo$partialF2.toString()) || '0';
|
|
@@ -204,6 +204,9 @@ export default class KoniState {
|
|
|
204
204
|
this.onReady();
|
|
205
205
|
this.onAccountAdd();
|
|
206
206
|
this.onAccountRemove();
|
|
207
|
+
|
|
208
|
+
// TODO: consider moving this to a separate service
|
|
209
|
+
await this.dbService.stores.crowdloan.removeEndedCrowdloans();
|
|
207
210
|
await this.startSubscription();
|
|
208
211
|
}
|
|
209
212
|
async initMantaPay(password) {
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.1.
|
|
20
|
+
"version": "1.1.19-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -1277,11 +1277,11 @@
|
|
|
1277
1277
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1278
1278
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1279
1279
|
"@substrate/connect": "^0.7.26",
|
|
1280
|
-
"@subwallet/chain-list": "0.2.18-beta.
|
|
1281
|
-
"@subwallet/extension-base": "^1.1.
|
|
1282
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1283
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1284
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1280
|
+
"@subwallet/chain-list": "0.2.18-beta.3",
|
|
1281
|
+
"@subwallet/extension-base": "^1.1.19-0",
|
|
1282
|
+
"@subwallet/extension-chains": "^1.1.19-0",
|
|
1283
|
+
"@subwallet/extension-dapp": "^1.1.19-0",
|
|
1284
|
+
"@subwallet/extension-inject": "^1.1.19-0",
|
|
1285
1285
|
"@subwallet/keyring": "^0.1.1",
|
|
1286
1286
|
"@subwallet/ui-keyring": "^0.1.1",
|
|
1287
1287
|
"@walletconnect/sign-client": "^2.8.4",
|
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.1.
|
|
10
|
+
version: '1.1.19-0'
|
|
11
11
|
};
|
|
@@ -9,7 +9,7 @@ import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-se
|
|
|
9
9
|
import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler';
|
|
10
10
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
11
11
|
import { _ChainConnectionStatus, _CUSTOM_PREFIX, _NFT_CONTRACT_STANDARDS, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
|
|
12
|
-
import { _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isEqualContractAddress, _isEqualSmartContractAsset, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey } from '@subwallet/extension-base/services/chain-service/utils';
|
|
12
|
+
import { _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey } from '@subwallet/extension-base/services/chain-service/utils';
|
|
13
13
|
import AssetSettingStore from '@subwallet/extension-base/stores/AssetSetting';
|
|
14
14
|
import { MODULE_SUPPORT } from '@subwallet/extension-base/utils';
|
|
15
15
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
@@ -631,12 +631,34 @@ export class ChainService {
|
|
|
631
631
|
for (const [storedSlug, storedChainInfo] of Object.entries(storedChainSettingMap)) {
|
|
632
632
|
if (storedSlug in latestChainInfoMap) {
|
|
633
633
|
// check predefined chains first, keep setting for providers and currentProvider
|
|
634
|
-
|
|
635
|
-
|
|
634
|
+
// TODO: review merging providers
|
|
635
|
+
// Keep customer provider only
|
|
636
|
+
const providers = {
|
|
636
637
|
...mergedChainInfoMap[storedSlug].providers
|
|
637
|
-
};
|
|
638
|
+
};
|
|
639
|
+
for (const [key, value] of Object.entries(storedChainInfo.providers)) {
|
|
640
|
+
if (_isCustomProvider(key)) {
|
|
641
|
+
if (!Object.values(providers).includes(value)) {
|
|
642
|
+
providers[key] = value;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
mergedChainInfoMap[storedSlug].providers = providers;
|
|
647
|
+
|
|
648
|
+
// Merge current provider
|
|
649
|
+
let currentProvider = storedChainInfo.currentProvider;
|
|
650
|
+
const providerValue = storedChainInfo.providers[currentProvider] || '';
|
|
651
|
+
if (!providers[currentProvider]) {
|
|
652
|
+
currentProvider = Object.keys(providers)[0];
|
|
653
|
+
for (const [key, value] of Object.entries(providers)) {
|
|
654
|
+
if (providerValue === value) {
|
|
655
|
+
currentProvider = key;
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
638
660
|
this.dataMap.chainStateMap[storedSlug] = {
|
|
639
|
-
currentProvider:
|
|
661
|
+
currentProvider: currentProvider,
|
|
640
662
|
slug: storedSlug,
|
|
641
663
|
connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
642
664
|
active: storedChainInfo.active
|
|
@@ -644,7 +666,7 @@ export class ChainService {
|
|
|
644
666
|
newStorageData.push({
|
|
645
667
|
...mergedChainInfoMap[storedSlug],
|
|
646
668
|
active: storedChainInfo.active,
|
|
647
|
-
currentProvider:
|
|
669
|
+
currentProvider: currentProvider
|
|
648
670
|
});
|
|
649
671
|
} else {
|
|
650
672
|
var _storedChainInfo$subs, _storedChainInfo$evmI;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import BaseStoreWithAddressAndChain from '@subwallet/extension-base/services/storage-service/db-stores/BaseStoreWithAddressAndChain';
|
|
2
2
|
import { ICrowdloanItem } from '../databases';
|
|
3
3
|
export default class CrowdloanStore extends BaseStoreWithAddressAndChain<ICrowdloanItem> {
|
|
4
|
+
removeEndedCrowdloans(): Promise<void>;
|
|
4
5
|
getCrowdloan(address: string): import("dexie").PromiseExtended<ICrowdloanItem[]>;
|
|
5
6
|
deleteByChainAndAddress(chain: string, address: string): import("dexie").PromiseExtended<number>;
|
|
6
7
|
}
|
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
|
|
4
4
|
import BaseStoreWithAddressAndChain from '@subwallet/extension-base/services/storage-service/db-stores/BaseStoreWithAddressAndChain';
|
|
5
5
|
export default class CrowdloanStore extends BaseStoreWithAddressAndChain {
|
|
6
|
+
async removeEndedCrowdloans() {
|
|
7
|
+
const now = new Date();
|
|
8
|
+
const removeList = [];
|
|
9
|
+
await this.table.each((obj, cursor) => {
|
|
10
|
+
try {
|
|
11
|
+
if (!obj.endTime || new Date(obj.endTime) < now) {
|
|
12
|
+
removeList.push(cursor.primaryKey);
|
|
13
|
+
}
|
|
14
|
+
} catch (e) {
|
|
15
|
+
console.error(e);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
await this.table.bulkDelete(removeList);
|
|
19
|
+
}
|
|
6
20
|
getCrowdloan(address) {
|
|
7
21
|
return this.table.where('address').equals(address).toArray();
|
|
8
22
|
}
|