@subwallet/extension-base 1.2.15-0 → 1.2.17-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 +6 -1
- package/cjs/constants/staking.js +2 -1
- package/cjs/koni/api/staking/bonding/utils.js +15 -0
- package/cjs/koni/background/handlers/Extension.js +33 -7
- package/cjs/koni/background/handlers/State.js +11 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/index.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/gear.js +135 -0
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +9 -62
- package/cjs/services/balance-service/transfer/token.js +4 -3
- package/cjs/services/chain-service/handler/SubstrateApi.js +3 -1
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +21 -26
- package/cjs/services/chain-service/index.js +48 -3
- package/cjs/services/chain-service/types.js +1 -1
- package/cjs/services/chain-service/utils/index.js +18 -12
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +38 -4
- package/cjs/services/earning-service/service.js +3 -0
- package/cjs/services/migration-service/scripts/databases/ClearMetadataDatabase.js +16 -0
- package/cjs/services/migration-service/scripts/index.js +7 -7
- package/cjs/services/transaction-service/index.js +12 -7
- package/cjs/utils/gear/combine.js +28 -0
- package/cjs/utils/gear/grc20.js +56 -49
- package/cjs/utils/gear/index.js +22 -0
- package/cjs/utils/gear/vft.js +173 -0
- package/cjs/utils/metadata.js +45 -34
- package/constants/staking.js +2 -1
- package/koni/api/staking/bonding/utils.d.ts +1 -0
- package/koni/api/staking/bonding/utils.js +14 -0
- package/koni/background/handlers/Extension.d.ts +2 -0
- package/koni/background/handlers/Extension.js +25 -1
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +11 -1
- package/package.json +24 -8
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/index.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/gear.d.ts +4 -0
- package/services/balance-service/helpers/subscribe/substrate/gear.js +123 -0
- package/services/balance-service/helpers/subscribe/substrate/index.js +10 -61
- package/services/balance-service/transfer/token.js +5 -4
- package/services/chain-service/handler/SubstrateApi.d.ts +1 -1
- package/services/chain-service/handler/SubstrateApi.js +3 -1
- package/services/chain-service/handler/SubstrateChainHandler.d.ts +1 -0
- package/services/chain-service/handler/SubstrateChainHandler.js +22 -27
- package/services/chain-service/index.d.ts +4 -0
- package/services/chain-service/index.js +49 -4
- package/services/chain-service/types.d.ts +1 -0
- package/services/chain-service/types.js +1 -1
- package/services/chain-service/utils/index.d.ts +1 -0
- package/services/chain-service/utils/index.js +16 -12
- package/services/earning-service/handlers/native-staking/relay-chain.js +39 -5
- package/services/earning-service/service.js +3 -0
- package/services/migration-service/scripts/databases/ClearMetadataDatabase.js +16 -0
- package/services/migration-service/scripts/index.js +7 -7
- package/services/transaction-service/index.js +13 -8
- package/types/metadata.d.ts +9 -2
- package/utils/gear/combine.d.ts +10 -0
- package/utils/gear/combine.js +18 -0
- package/utils/gear/grc20.d.ts +18 -20
- package/utils/gear/grc20.js +53 -45
- package/utils/gear/index.d.ts +2 -0
- package/utils/gear/index.js +3 -1
- package/utils/gear/vft.d.ts +36 -0
- package/utils/gear/vft.js +162 -0
- package/utils/metadata.d.ts +7 -2
- package/utils/metadata.js +41 -31
|
@@ -28,7 +28,7 @@ const filterChainInfoMap = (data, ignoredChains) => {
|
|
|
28
28
|
return !info.bitcoinInfo && !ignoredChains.includes(slug);
|
|
29
29
|
}));
|
|
30
30
|
};
|
|
31
|
-
const ignoredList = ['bevm', 'bevmTest', 'bevm_testnet', 'layerEdge_testnet', 'merlinEvm', 'botanixEvmTest', 'syscoin_evm', 'syscoin_evm_testnet', 'rollux_evm', 'rollux_testnet', 'boolAlpha', 'boolBeta_testnet'];
|
|
31
|
+
const ignoredList = ['bevm', 'bevmTest', 'bevm_testnet', 'layerEdge_testnet', 'merlinEvm', 'botanixEvmTest', 'syscoin_evm', 'syscoin_evm_testnet', 'rollux_evm', 'rollux_testnet', 'boolAlpha', 'boolBeta_testnet', 'core', 'satoshivm', 'satoshivm_testnet'];
|
|
32
32
|
const filterAssetInfoMap = (chainInfo, assets) => {
|
|
33
33
|
return Object.fromEntries(Object.entries(assets).filter(_ref2 => {
|
|
34
34
|
let [, info] = _ref2;
|
|
@@ -254,7 +254,7 @@ class ChainService {
|
|
|
254
254
|
});
|
|
255
255
|
}
|
|
256
256
|
getSupportedSmartContractTypes() {
|
|
257
|
-
return [_types._AssetType.ERC20, _types._AssetType.ERC721, _types._AssetType.PSP22, _types._AssetType.PSP34, _types._AssetType.GRC20, _types._AssetType.GRC721];
|
|
257
|
+
return [_types._AssetType.ERC20, _types._AssetType.ERC721, _types._AssetType.PSP22, _types._AssetType.PSP34, _types._AssetType.GRC20, _types._AssetType.GRC721, _types._AssetType.VFT];
|
|
258
258
|
}
|
|
259
259
|
getActiveChainInfoMap() {
|
|
260
260
|
const result = {};
|
|
@@ -1479,7 +1479,7 @@ class ChainService {
|
|
|
1479
1479
|
async getSmartContractTokenInfo(contractAddress, tokenType, originChain, contractCaller) {
|
|
1480
1480
|
if ([_types._AssetType.ERC721, _types._AssetType.ERC20].includes(tokenType)) {
|
|
1481
1481
|
return await this.evmChainHandler.getEvmContractTokenInfo(contractAddress, tokenType, originChain);
|
|
1482
|
-
} else if ([_types._AssetType.PSP34, _types._AssetType.PSP22, _types._AssetType.GRC20].includes(tokenType)) {
|
|
1482
|
+
} else if ([_types._AssetType.PSP34, _types._AssetType.PSP22, _types._AssetType.GRC20, _types._AssetType.VFT].includes(tokenType)) {
|
|
1483
1483
|
return await this.substrateChainHandler.getSubstrateContractTokenInfo(contractAddress, tokenType, originChain, contractCaller);
|
|
1484
1484
|
}
|
|
1485
1485
|
return {
|
|
@@ -1698,6 +1698,9 @@ class ChainService {
|
|
|
1698
1698
|
this.deleteCustomAssets(customToken);
|
|
1699
1699
|
}
|
|
1700
1700
|
}
|
|
1701
|
+
|
|
1702
|
+
/* Metadata */
|
|
1703
|
+
|
|
1701
1704
|
getMetadata(chain) {
|
|
1702
1705
|
return this.dbService.stores.metadata.getMetadata(chain);
|
|
1703
1706
|
}
|
|
@@ -1707,6 +1710,48 @@ class ChainService {
|
|
|
1707
1710
|
getMetadataByHash(hash) {
|
|
1708
1711
|
return this.dbService.stores.metadata.getMetadataByGenesisHash(hash);
|
|
1709
1712
|
}
|
|
1713
|
+
getExtraInfo(chain) {
|
|
1714
|
+
var _chainInfo$substrateI2, _chainInfo$substrateI3, _chainInfo$substrateI4, _chainInfo$substrateI5, _chainInfo$substrateI6, _chainInfo$substrateI7;
|
|
1715
|
+
const chainInfo = this.getChainInfoByKey(chain);
|
|
1716
|
+
return {
|
|
1717
|
+
decimals: (_chainInfo$substrateI2 = (_chainInfo$substrateI3 = chainInfo.substrateInfo) === null || _chainInfo$substrateI3 === void 0 ? void 0 : _chainInfo$substrateI3.decimals) !== null && _chainInfo$substrateI2 !== void 0 ? _chainInfo$substrateI2 : 0,
|
|
1718
|
+
tokenSymbol: (_chainInfo$substrateI4 = (_chainInfo$substrateI5 = chainInfo.substrateInfo) === null || _chainInfo$substrateI5 === void 0 ? void 0 : _chainInfo$substrateI5.symbol) !== null && _chainInfo$substrateI4 !== void 0 ? _chainInfo$substrateI4 : 'Unit',
|
|
1719
|
+
base58Prefix: (_chainInfo$substrateI6 = (_chainInfo$substrateI7 = chainInfo.substrateInfo) === null || _chainInfo$substrateI7 === void 0 ? void 0 : _chainInfo$substrateI7.addressPrefix) !== null && _chainInfo$substrateI6 !== void 0 ? _chainInfo$substrateI6 : 42
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1722
|
+
async calculateMetadataHash(chain) {
|
|
1723
|
+
const metadata = await this.getMetadata(chain);
|
|
1724
|
+
if (!metadata || !metadata.hexV15) {
|
|
1725
|
+
return undefined;
|
|
1726
|
+
}
|
|
1727
|
+
const extraInfo = this.getExtraInfo(chain);
|
|
1728
|
+
const specVersion = parseInt(metadata.specVersion);
|
|
1729
|
+
const specName = metadata.specName;
|
|
1730
|
+
const hexV15 = metadata.hexV15;
|
|
1731
|
+
return (0, _utils2.calculateMetadataHash)({
|
|
1732
|
+
...extraInfo,
|
|
1733
|
+
specVersion,
|
|
1734
|
+
specName
|
|
1735
|
+
}, hexV15);
|
|
1736
|
+
}
|
|
1737
|
+
async shortenMetadata(chain, txBlob) {
|
|
1738
|
+
const metadata = await this.getMetadata(chain);
|
|
1739
|
+
if (!metadata || !metadata.hexV15) {
|
|
1740
|
+
return undefined;
|
|
1741
|
+
}
|
|
1742
|
+
const extraInfo = this.getExtraInfo(chain);
|
|
1743
|
+
const specVersion = parseInt(metadata.specVersion);
|
|
1744
|
+
const specName = metadata.specName;
|
|
1745
|
+
const hexV15 = metadata.hexV15;
|
|
1746
|
+
return (0, _utils2.getShortMetadata)(txBlob, {
|
|
1747
|
+
...extraInfo,
|
|
1748
|
+
specVersion,
|
|
1749
|
+
specName
|
|
1750
|
+
}, hexV15);
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
/* Metadata */
|
|
1754
|
+
|
|
1710
1755
|
getSubscanChainMap(reverse) {
|
|
1711
1756
|
const result = {};
|
|
1712
1757
|
const chainInfoMap = this.getChainInfoMap();
|
|
@@ -18,7 +18,7 @@ exports._ChainConnectionStatus = _ChainConnectionStatus;
|
|
|
18
18
|
})(_ChainConnectionStatus || (exports._ChainConnectionStatus = _ChainConnectionStatus = {}));
|
|
19
19
|
const _CUSTOM_PREFIX = 'custom-';
|
|
20
20
|
exports._CUSTOM_PREFIX = _CUSTOM_PREFIX;
|
|
21
|
-
const _FUNGIBLE_CONTRACT_STANDARDS = [_types._AssetType.ERC20, _types._AssetType.PSP22, _types._AssetType.GRC20];
|
|
21
|
+
const _FUNGIBLE_CONTRACT_STANDARDS = [_types._AssetType.ERC20, _types._AssetType.PSP22, _types._AssetType.GRC20, _types._AssetType.VFT];
|
|
22
22
|
exports._FUNGIBLE_CONTRACT_STANDARDS = _FUNGIBLE_CONTRACT_STANDARDS;
|
|
23
23
|
const _NFT_CONTRACT_STANDARDS = [_types._AssetType.PSP34, _types._AssetType.ERC721];
|
|
24
24
|
exports._NFT_CONTRACT_STANDARDS = _NFT_CONTRACT_STANDARDS;
|
|
@@ -38,6 +38,7 @@ var _exportNames = {
|
|
|
38
38
|
_isChainSupportEvmERC20: true,
|
|
39
39
|
_isChainSupportWasmPSP22: true,
|
|
40
40
|
_isChainSupportGRC20: true,
|
|
41
|
+
_isChainSupportVFT: true,
|
|
41
42
|
_isSupportOrdinal: true,
|
|
42
43
|
_getNftTypesSupportedByChain: true,
|
|
43
44
|
_getTokenTypesSupportedByChain: true,
|
|
@@ -131,6 +132,7 @@ exports._isChainSupportEvmNft = _isChainSupportEvmNft;
|
|
|
131
132
|
exports._isChainSupportGRC20 = _isChainSupportGRC20;
|
|
132
133
|
exports._isChainSupportNativeNft = _isChainSupportNativeNft;
|
|
133
134
|
exports._isChainSupportSubstrateStaking = _isChainSupportSubstrateStaking;
|
|
135
|
+
exports._isChainSupportVFT = _isChainSupportVFT;
|
|
134
136
|
exports._isChainSupportWasmNft = _isChainSupportWasmNft;
|
|
135
137
|
exports._isChainSupportWasmPSP22 = _isChainSupportWasmPSP22;
|
|
136
138
|
exports._isChainTestNet = _isChainTestNet;
|
|
@@ -357,6 +359,10 @@ function _isChainSupportGRC20(chainInfo) {
|
|
|
357
359
|
var _chainInfo$substrateI12, _chainInfo$substrateI13;
|
|
358
360
|
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;
|
|
359
361
|
}
|
|
362
|
+
function _isChainSupportVFT(chainInfo) {
|
|
363
|
+
var _chainInfo$substrateI14, _chainInfo$substrateI15;
|
|
364
|
+
return ((_chainInfo$substrateI14 = chainInfo.substrateInfo) === null || _chainInfo$substrateI14 === void 0 ? void 0 : (_chainInfo$substrateI15 = _chainInfo$substrateI14.supportSmartContract) === null || _chainInfo$substrateI15 === void 0 ? void 0 : _chainInfo$substrateI15.includes(_types._AssetType.VFT)) || false;
|
|
365
|
+
}
|
|
360
366
|
const _isSupportOrdinal = chain => {
|
|
361
367
|
const chains = ['polkadot', 'astar', 'bifrost_dot', 'moonbeam'];
|
|
362
368
|
return chains.includes(chain);
|
|
@@ -384,7 +390,7 @@ function _getTokenTypesSupportedByChain(chainInfo) {
|
|
|
384
390
|
const result = [];
|
|
385
391
|
if (chainInfo.substrateInfo && chainInfo.substrateInfo.supportSmartContract) {
|
|
386
392
|
chainInfo.substrateInfo.supportSmartContract.forEach(assetType => {
|
|
387
|
-
if ([_types._AssetType.PSP22, _types._AssetType.GRC20].includes(assetType)) {
|
|
393
|
+
if ([_types._AssetType.PSP22, _types._AssetType.GRC20, _types._AssetType.VFT].includes(assetType)) {
|
|
388
394
|
result.push(assetType);
|
|
389
395
|
}
|
|
390
396
|
});
|
|
@@ -441,7 +447,7 @@ function _isAssetSmartContractNft(assetInfo) {
|
|
|
441
447
|
return [_types._AssetType.PSP34, _types._AssetType.ERC721].includes(assetInfo.assetType);
|
|
442
448
|
}
|
|
443
449
|
function _isTokenGearSmartContract(tokenInfo) {
|
|
444
|
-
return [_types._AssetType.GRC20, _types._AssetType.GRC721].includes(tokenInfo.assetType);
|
|
450
|
+
return [_types._AssetType.GRC20, _types._AssetType.GRC721, _types._AssetType.VFT].includes(tokenInfo.assetType);
|
|
445
451
|
}
|
|
446
452
|
function _parseAssetRefKey(originTokenSlug, destinationTokenSlug) {
|
|
447
453
|
return `${originTokenSlug}___${destinationTokenSlug}`;
|
|
@@ -473,12 +479,12 @@ function _isRelayChain(chainInfo) {
|
|
|
473
479
|
return _isSubstrateRelayChain(chainInfo) || _isPureEvmChain(chainInfo);
|
|
474
480
|
}
|
|
475
481
|
function _isSubstrateRelayChain(chainInfo) {
|
|
476
|
-
var _chainInfo$
|
|
477
|
-
return ((_chainInfo$
|
|
482
|
+
var _chainInfo$substrateI16;
|
|
483
|
+
return ((_chainInfo$substrateI16 = chainInfo.substrateInfo) === null || _chainInfo$substrateI16 === void 0 ? void 0 : _chainInfo$substrateI16.chainType) === _types._SubstrateChainType.RELAYCHAIN;
|
|
478
484
|
}
|
|
479
485
|
function _isSubstrateParaChain(chainInfo) {
|
|
480
|
-
var _chainInfo$
|
|
481
|
-
return chainInfo.substrateInfo !== null && chainInfo.substrateInfo.paraId !== null && ((_chainInfo$
|
|
486
|
+
var _chainInfo$substrateI17;
|
|
487
|
+
return chainInfo.substrateInfo !== null && chainInfo.substrateInfo.paraId !== null && ((_chainInfo$substrateI17 = chainInfo.substrateInfo) === null || _chainInfo$substrateI17 === void 0 ? void 0 : _chainInfo$substrateI17.chainType) === _types._SubstrateChainType.PARACHAIN;
|
|
482
488
|
}
|
|
483
489
|
function _getEvmAbiExplorer(chainInfo) {
|
|
484
490
|
var _chainInfo$evmInfo4;
|
|
@@ -523,8 +529,8 @@ function _getBlockExplorerFromChain(chainInfo) {
|
|
|
523
529
|
var _chainInfo$evmInfo5;
|
|
524
530
|
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$evmInfo5 = chainInfo.evmInfo) === null || _chainInfo$evmInfo5 === void 0 ? void 0 : _chainInfo$evmInfo5.blockExplorer;
|
|
525
531
|
} else {
|
|
526
|
-
var _chainInfo$
|
|
527
|
-
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
532
|
+
var _chainInfo$substrateI18;
|
|
533
|
+
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI18 = chainInfo.substrateInfo) === null || _chainInfo$substrateI18 === void 0 ? void 0 : _chainInfo$substrateI18.blockExplorer;
|
|
528
534
|
}
|
|
529
535
|
if (!blockExplorer) {
|
|
530
536
|
return undefined;
|
|
@@ -551,8 +557,8 @@ const _isAssetAutoEnable = chainAsset => {
|
|
|
551
557
|
};
|
|
552
558
|
exports._isAssetAutoEnable = _isAssetAutoEnable;
|
|
553
559
|
function _getCrowdloanUrlFromChain(chainInfo) {
|
|
554
|
-
var _chainInfo$
|
|
555
|
-
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
560
|
+
var _chainInfo$substrateI19;
|
|
561
|
+
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI19 = chainInfo.substrateInfo) === null || _chainInfo$substrateI19 === void 0 ? void 0 : _chainInfo$substrateI19.crowdloanUrl) || '';
|
|
556
562
|
}
|
|
557
563
|
function _isCustomProvider(providerKey) {
|
|
558
564
|
return providerKey.startsWith(_types2._CUSTOM_PREFIX);
|
|
@@ -590,8 +596,8 @@ function _isMantaZkAsset(chainAsset) {
|
|
|
590
596
|
return _constants._MANTA_ZK_CHAIN_GROUP.includes(chainAsset.originChain) && chainAsset.symbol.startsWith(_constants._ZK_ASSET_PREFIX);
|
|
591
597
|
}
|
|
592
598
|
function _getChainExistentialDeposit(chainInfo) {
|
|
593
|
-
var _chainInfo$
|
|
594
|
-
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
599
|
+
var _chainInfo$substrateI20;
|
|
600
|
+
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI20 = chainInfo.substrateInfo) === null || _chainInfo$substrateI20 === void 0 ? void 0 : _chainInfo$substrateI20.existentialDeposit) || '0';
|
|
595
601
|
}
|
|
596
602
|
function randomizeProvider(providers, excludedKeys) {
|
|
597
603
|
if (Object.keys(providers).length === 0) {
|
|
@@ -320,11 +320,20 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
320
320
|
const topValidatorList = (0, _utils.getRelayTopValidatorByPoints)(validatorPointsMap);
|
|
321
321
|
const validators = _validators;
|
|
322
322
|
const blockedValidatorList = (0, _utils.getRelayBlockedValidatorList)(validators);
|
|
323
|
+
const waitingValidatorList = (0, _utils.getRelayWaitingValidatorList)(validators);
|
|
324
|
+
const _waitingValidatorLedger = await chainApi.api.query.staking.ledger.multi(waitingValidatorList);
|
|
325
|
+
const waitingValidatorLedger = {};
|
|
326
|
+
if (_waitingValidatorLedger) {
|
|
327
|
+
waitingValidatorList.forEach((validator, i) => {
|
|
328
|
+
const validatorLedger = _waitingValidatorLedger[i].toPrimitive();
|
|
329
|
+
waitingValidatorLedger[validator] = new _bignumber.default(validatorLedger.total).toFixed();
|
|
330
|
+
});
|
|
331
|
+
}
|
|
323
332
|
const unlimitedNominatorRewarded = chainApi.api.consts.staking.maxExposurePageSize !== undefined;
|
|
324
333
|
const maxNominatorRewarded = (chainApi.api.consts.staking.maxNominatorRewardedPerValidator || 0).toString();
|
|
325
334
|
const bnTotalEraStake = new _util.BN(_totalEraStake.toString());
|
|
326
335
|
const minBond = _minBond.toPrimitive();
|
|
327
|
-
const [totalStakeMap, allValidatorAddresses, validatorInfoList] = this.parseEraStakerData(_eraStakers, blockedValidatorList, topValidatorList, validatorPointsMap, minBond, maxNominatorRewarded, unlimitedNominatorRewarded);
|
|
336
|
+
const [totalStakeMap, allValidatorAddresses, validatorInfoList] = this.parseEraStakerData(_eraStakers, blockedValidatorList, waitingValidatorLedger, topValidatorList, validatorPointsMap, minBond, maxNominatorRewarded, unlimitedNominatorRewarded);
|
|
328
337
|
const extraInfoMap = {};
|
|
329
338
|
await Promise.all(allValidatorAddresses.map(async address => {
|
|
330
339
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
@@ -359,11 +368,15 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
359
368
|
const validatorStake = (0, _utils3.applyDecimal)(totalStakeMap[validator.address], decimals).toNumber();
|
|
360
369
|
return (0, _utils.calculateTernoaValidatorReturn)(rewardPerValidator.toNumber(), validatorStake, commission);
|
|
361
370
|
} else {
|
|
362
|
-
|
|
363
|
-
|
|
371
|
+
if (!totalStakeMap[validator.address]) {
|
|
372
|
+
return totalApy;
|
|
373
|
+
} else {
|
|
374
|
+
const bnValidatorStake = (0, _utils3.applyDecimal)(totalStakeMap[validator.address], decimals);
|
|
375
|
+
return (0, _utils.calculateValidatorStakedReturn)(totalApy, bnValidatorStake, bnAvgStake, commission);
|
|
376
|
+
}
|
|
364
377
|
}
|
|
365
378
|
}
|
|
366
|
-
parseEraStakerData(_eraStakers, blockedValidatorList, topValidatorList, validatorPointsMap, minBond, maxNominatorRewarded, unlimitedNominatorRewarded) {
|
|
379
|
+
parseEraStakerData(_eraStakers, blockedValidatorList, waitingValidatorList, topValidatorList, validatorPointsMap, minBond, maxNominatorRewarded, unlimitedNominatorRewarded) {
|
|
367
380
|
const totalStakeMap = {};
|
|
368
381
|
const allValidatorAddresses = [];
|
|
369
382
|
const validatorInfoList = [];
|
|
@@ -413,6 +426,27 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
413
426
|
});
|
|
414
427
|
}
|
|
415
428
|
}
|
|
429
|
+
for (const waitingValidator of Object.keys(waitingValidatorList)) {
|
|
430
|
+
if (!allValidatorAddresses.includes(waitingValidator)) {
|
|
431
|
+
allValidatorAddresses.push(waitingValidator);
|
|
432
|
+
validatorInfoList.push({
|
|
433
|
+
address: waitingValidator,
|
|
434
|
+
totalStake: waitingValidatorList[waitingValidator],
|
|
435
|
+
ownStake: waitingValidatorList[waitingValidator],
|
|
436
|
+
otherStake: '0',
|
|
437
|
+
nominatorCount: 0,
|
|
438
|
+
// to be added later
|
|
439
|
+
commission: 0,
|
|
440
|
+
expectedReturn: 0,
|
|
441
|
+
blocked: false,
|
|
442
|
+
isVerified: false,
|
|
443
|
+
minBond: minBond.toString(),
|
|
444
|
+
isCrowded: false,
|
|
445
|
+
eraRewardPoint: '0',
|
|
446
|
+
topQuartile: false
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
}
|
|
416
450
|
return [totalStakeMap, allValidatorAddresses, validatorInfoList];
|
|
417
451
|
}
|
|
418
452
|
/* Get pool targets */
|
|
@@ -144,6 +144,9 @@ class EarningService {
|
|
|
144
144
|
if (event.type === 'account.remove') {
|
|
145
145
|
removedAddresses.push(event.data[0]);
|
|
146
146
|
}
|
|
147
|
+
if (event.type === 'account.add') {
|
|
148
|
+
delayReload = true;
|
|
149
|
+
}
|
|
147
150
|
if (event.type === 'chain.updateState') {
|
|
148
151
|
const chainState = this.state.getChainStateByKey(event.data[0]);
|
|
149
152
|
if (chainState && !(0, _utils._isChainEnabled)(chainState)) {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _Base = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/Base"));
|
|
9
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
9
10
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
10
11
|
// SPDX-License-Identifier: Apache-2.0
|
|
11
12
|
|
|
@@ -13,6 +14,21 @@ class ClearMetadataDatabase extends _Base.default {
|
|
|
13
14
|
async run() {
|
|
14
15
|
// Clear all old metadata data
|
|
15
16
|
await this.state.dbService.stores.metadata.clear();
|
|
17
|
+
const activeChains = this.state.chainService.getActiveChains();
|
|
18
|
+
const chainInfoMap = this.state.chainService.getChainInfoMap();
|
|
19
|
+
const reloadChains = activeChains.filter(chain => {
|
|
20
|
+
var _chainInfoMap$chain$s;
|
|
21
|
+
return !!((_chainInfoMap$chain$s = chainInfoMap[chain].substrateInfo) !== null && _chainInfoMap$chain$s !== void 0 && _chainInfoMap$chain$s.genesisHash);
|
|
22
|
+
});
|
|
23
|
+
for (const chain of reloadChains) {
|
|
24
|
+
const substrateApi = this.state.chainService.getSubstrateApi(chain);
|
|
25
|
+
const callback = substrateApi => {
|
|
26
|
+
(0, _utils.cacheMetadata)(chain, substrateApi, this.state.chainService);
|
|
27
|
+
};
|
|
28
|
+
Promise.race([substrateApi.isReady, (0, _utils.waitTimeout)(2000)]).finally(() => {
|
|
29
|
+
substrateApi === null || substrateApi === void 0 ? void 0 : substrateApi.connect(callback);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
16
32
|
return Promise.resolve();
|
|
17
33
|
}
|
|
18
34
|
}
|
|
@@ -5,14 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.EVERYTIME = void 0;
|
|
8
|
-
var _AutoEnableSomeTokens = _interopRequireDefault(require("
|
|
9
|
-
var _ReloadMetadata = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/scripts/databases/ReloadMetadata"));
|
|
10
|
-
var _DeleteEarningData = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/scripts/DeleteEarningData"));
|
|
11
|
-
var _MigrateRemoveGenesisHash = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/scripts/MigrateRemoveGenesisHash"));
|
|
12
|
-
var _MigrateTransactionHistoryBySymbol = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service/scripts/MigrateTransactionHistoryBySymbol"));
|
|
8
|
+
var _AutoEnableSomeTokens = _interopRequireDefault(require("./databases/AutoEnableSomeTokens"));
|
|
13
9
|
var _ClearMetadataDatabase = _interopRequireDefault(require("./databases/ClearMetadataDatabase"));
|
|
14
10
|
var _MigrateAssetSetting = _interopRequireDefault(require("./databases/MigrateAssetSetting"));
|
|
15
11
|
var _MigrateEarningVersion = _interopRequireDefault(require("./databases/MigrateEarningVersion"));
|
|
12
|
+
var _ReloadMetadata = _interopRequireDefault(require("./databases/ReloadMetadata"));
|
|
16
13
|
var _MigrateEthProvider = _interopRequireDefault(require("./providers/MigrateEthProvider"));
|
|
17
14
|
var _MigratePioneerProvider = _interopRequireDefault(require("./providers/MigratePioneerProvider"));
|
|
18
15
|
var _MigrateProvidersV1M1P = _interopRequireDefault(require("./providers/MigrateProvidersV1M1P24"));
|
|
@@ -20,6 +17,7 @@ var _MigratePolygonUSDCProvider = _interopRequireDefault(require("./tokens/Migra
|
|
|
20
17
|
var _AutoEnableChainsTokens = _interopRequireDefault(require("./AutoEnableChainsTokens"));
|
|
21
18
|
var _DeleteChain = _interopRequireDefault(require("./DeleteChain"));
|
|
22
19
|
var _DeleteChainStaking = _interopRequireDefault(require("./DeleteChainStaking"));
|
|
20
|
+
var _DeleteEarningData = _interopRequireDefault(require("./DeleteEarningData"));
|
|
23
21
|
var _EnableVaraChain = _interopRequireDefault(require("./EnableVaraChain"));
|
|
24
22
|
var _MigrateAuthUrls = _interopRequireDefault(require("./MigrateAuthUrls"));
|
|
25
23
|
var _MigrateAutoLock = _interopRequireDefault(require("./MigrateAutoLock"));
|
|
@@ -28,9 +26,11 @@ var _MigrateImportedToken = _interopRequireDefault(require("./MigrateImportedTok
|
|
|
28
26
|
var _MigrateLedgerAccount = _interopRequireDefault(require("./MigrateLedgerAccount"));
|
|
29
27
|
var _MigrateLedgerAccountV = _interopRequireDefault(require("./MigrateLedgerAccountV2"));
|
|
30
28
|
var _MigrateNetworkSettings = _interopRequireDefault(require("./MigrateNetworkSettings"));
|
|
29
|
+
var _MigrateRemoveGenesisHash = _interopRequireDefault(require("./MigrateRemoveGenesisHash"));
|
|
31
30
|
var _MigrateSettings = _interopRequireDefault(require("./MigrateSettings"));
|
|
32
31
|
var _MigrateTokenDecimals = _interopRequireDefault(require("./MigrateTokenDecimals"));
|
|
33
32
|
var _MigrateTransactionHistory = _interopRequireDefault(require("./MigrateTransactionHistory"));
|
|
33
|
+
var _MigrateTransactionHistoryBySymbol = _interopRequireDefault(require("./MigrateTransactionHistoryBySymbol"));
|
|
34
34
|
var _MigrateWalletReference = _interopRequireDefault(require("./MigrateWalletReference"));
|
|
35
35
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
36
36
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -64,8 +64,8 @@ var _default = {
|
|
|
64
64
|
'1.1.69-03': _MigrateAssetSetting.default,
|
|
65
65
|
'1.1.69-02': _MigrateTransactionHistoryBySymbol.default,
|
|
66
66
|
'1.2.69-01': _MigrateRemoveGenesisHash.default,
|
|
67
|
-
'1.2.
|
|
68
|
-
'1.2.
|
|
67
|
+
'1.2.13-01': _ReloadMetadata.default,
|
|
68
|
+
'1.2.14-01': _ClearMetadataDatabase.default
|
|
69
69
|
// [`${EVERYTIME}-1.1.42-02`]: MigrateTransactionHistoryBySymbol
|
|
70
70
|
// [`${EVERYTIME}-1`]: AutoEnableChainsTokens
|
|
71
71
|
};
|
|
@@ -1047,20 +1047,25 @@ class TransactionService {
|
|
|
1047
1047
|
const signerOption = {
|
|
1048
1048
|
signer: {
|
|
1049
1049
|
signPayload: async payload => {
|
|
1050
|
-
const
|
|
1050
|
+
const {
|
|
1051
|
+
signature,
|
|
1052
|
+
signedTransaction
|
|
1053
|
+
} = await this.state.requestService.signInternalTransaction(id, address, url || _constants2.EXTENSION_REQUEST_URL, payload);
|
|
1051
1054
|
return {
|
|
1052
1055
|
id: new Date().getTime(),
|
|
1053
|
-
signature
|
|
1056
|
+
signature,
|
|
1057
|
+
signedTransaction
|
|
1054
1058
|
};
|
|
1055
1059
|
}
|
|
1056
|
-
}
|
|
1060
|
+
},
|
|
1061
|
+
withSignedTransaction: true
|
|
1057
1062
|
};
|
|
1058
1063
|
if ((0, _utils3._isRuntimeUpdated)(signedExtensions)) {
|
|
1059
|
-
|
|
1060
|
-
|
|
1064
|
+
const metadataHash = await this.state.chainService.calculateMetadataHash(chain);
|
|
1065
|
+
if (metadataHash) {
|
|
1061
1066
|
signerOption.mode = 1;
|
|
1062
|
-
signerOption.metadataHash =
|
|
1063
|
-
}
|
|
1067
|
+
signerOption.metadataHash = metadataHash;
|
|
1068
|
+
}
|
|
1064
1069
|
}
|
|
1065
1070
|
extrinsic.signAsync(address, signerOption).then(async rs => {
|
|
1066
1071
|
// Emit signed event
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GEAR_DEFAULT_ADDRESS = exports.DEFAULT_GEAR_ADDRESS = void 0;
|
|
7
|
+
exports.getGRC20ContractPromise = getGRC20ContractPromise;
|
|
8
|
+
exports.getVFTContractPromise = getVFTContractPromise;
|
|
9
|
+
var _grc = require("./grc20");
|
|
10
|
+
var _vft = require("./vft");
|
|
11
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
12
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
13
|
+
|
|
14
|
+
const DEFAULT_GEAR_ADDRESS = {
|
|
15
|
+
ALICE: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
|
|
16
|
+
BOB: '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty'
|
|
17
|
+
};
|
|
18
|
+
exports.DEFAULT_GEAR_ADDRESS = DEFAULT_GEAR_ADDRESS;
|
|
19
|
+
const GEAR_DEFAULT_ADDRESS = '5EYCAe5ijiYfAXEth5DGRKiKuVjTXQKr877tUPz6eLz2t9aG';
|
|
20
|
+
exports.GEAR_DEFAULT_ADDRESS = GEAR_DEFAULT_ADDRESS;
|
|
21
|
+
function getGRC20ContractPromise(apiPromise, contractAddress) {
|
|
22
|
+
const gearApi = apiPromise;
|
|
23
|
+
return new _grc.GRC20(gearApi, contractAddress);
|
|
24
|
+
}
|
|
25
|
+
function getVFTContractPromise(apiPromise, contractAddress) {
|
|
26
|
+
const gearApi = apiPromise;
|
|
27
|
+
return new _vft.VFT(gearApi, contractAddress);
|
|
28
|
+
}
|
package/cjs/utils/gear/grc20.js
CHANGED
|
@@ -3,21 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.getGRC20ContractPromise = getGRC20ContractPromise;
|
|
6
|
+
exports.Grc20Service = exports.GRC20 = void 0;
|
|
8
7
|
var _api = require("@gear-js/api");
|
|
9
8
|
var _sailsJs = require("sails-js");
|
|
10
9
|
var _types = require("@polkadot/types");
|
|
11
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
10
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
12
11
|
// SPDX-License-Identifier: Apache-2.0
|
|
13
12
|
|
|
14
|
-
// https://github.com/breathx/gear-erc20/blob/master/js/src/lib.ts
|
|
15
|
-
|
|
16
|
-
const DEFAULT_GEAR_ADDRESS = {
|
|
17
|
-
ALICE: '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
|
|
18
|
-
BOB: '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty'
|
|
19
|
-
};
|
|
20
|
-
exports.DEFAULT_GEAR_ADDRESS = DEFAULT_GEAR_ADDRESS;
|
|
21
13
|
class GRC20 {
|
|
22
14
|
constructor(api) {
|
|
23
15
|
let programId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0x';
|
|
@@ -32,6 +24,7 @@ class GRC20 {
|
|
|
32
24
|
types
|
|
33
25
|
});
|
|
34
26
|
this.registry.register(types);
|
|
27
|
+
this.service = new Grc20Service(this);
|
|
35
28
|
}
|
|
36
29
|
newCtorFromCode(code, name, symbol, decimals) {
|
|
37
30
|
const builder = new _sailsJs.TransactionBuilder(this.api, this.registry, 'upload_program', ['New', name, symbol, decimals], '(String, String, String, u8)', 'String', code);
|
|
@@ -43,99 +36,113 @@ class GRC20 {
|
|
|
43
36
|
this.programId = builder.programId;
|
|
44
37
|
return builder;
|
|
45
38
|
}
|
|
39
|
+
}
|
|
40
|
+
exports.GRC20 = GRC20;
|
|
41
|
+
class Grc20Service {
|
|
42
|
+
constructor(_program) {
|
|
43
|
+
this._program = _program;
|
|
44
|
+
}
|
|
46
45
|
approve(spender, value) {
|
|
47
|
-
|
|
46
|
+
if (!this._program.programId) {
|
|
47
|
+
throw new Error('Program ID is not set');
|
|
48
|
+
}
|
|
49
|
+
return new _sailsJs.TransactionBuilder(this._program.api, this._program.registry, 'send_message', ['Approve', spender, value], '(String, ActorId, U256)', 'bool', this._program.programId);
|
|
48
50
|
}
|
|
49
51
|
fromTransfer(from, to, value) {
|
|
50
|
-
|
|
52
|
+
if (!this._program.programId) {
|
|
53
|
+
throw new Error('Program ID is not set');
|
|
54
|
+
}
|
|
55
|
+
return new _sailsJs.TransactionBuilder(this._program.api, this._program.registry, 'send_message', ['FromTransfer', from, to, value], '(String, ActorId, ActorId, U256)', 'bool', this._program.programId);
|
|
51
56
|
}
|
|
52
57
|
setBalance(newBalance) {
|
|
53
|
-
|
|
58
|
+
if (!this._program.programId) {
|
|
59
|
+
throw new Error('Program ID is not set');
|
|
60
|
+
}
|
|
61
|
+
return new _sailsJs.TransactionBuilder(this._program.api, this._program.registry, 'send_message', ['SetBalance', newBalance], '(String, U256)', 'bool', this._program.programId);
|
|
54
62
|
}
|
|
55
63
|
transfer(to, value) {
|
|
56
|
-
|
|
64
|
+
if (!this._program.programId) {
|
|
65
|
+
throw new Error('Program ID is not set');
|
|
66
|
+
}
|
|
67
|
+
return new _sailsJs.TransactionBuilder(this._program.api, this._program.registry, 'send_message', ['Transfer', to, value], '(String, ActorId, U256)', 'bool', this._program.programId);
|
|
57
68
|
}
|
|
58
69
|
async allowance(owner, spender, originAddress, value, atBlock) {
|
|
59
|
-
const payload = this.registry.createType('(String, ActorId, ActorId)', ['Allowance', owner, spender]).
|
|
60
|
-
const reply = await this.api.message.calculateReply({
|
|
61
|
-
destination: this.programId,
|
|
70
|
+
const payload = this._program.registry.createType('(String, ActorId, ActorId)', ['Allowance', owner, spender]).toHex();
|
|
71
|
+
const reply = await this._program.api.message.calculateReply({
|
|
72
|
+
destination: this._program.programId,
|
|
62
73
|
origin: (0, _api.decodeAddress)(originAddress),
|
|
63
74
|
payload,
|
|
64
75
|
value: value || 0,
|
|
65
|
-
gasLimit: this.api.blockGasLimit.toBigInt(),
|
|
76
|
+
gasLimit: this._program.api.blockGasLimit.toBigInt(),
|
|
66
77
|
at: atBlock
|
|
67
78
|
});
|
|
68
|
-
const result = this.registry.createType('(String, U256)', reply.payload);
|
|
79
|
+
const result = this._program.registry.createType('(String, U256)', reply.payload);
|
|
69
80
|
return result[1].toBigInt();
|
|
70
81
|
}
|
|
71
82
|
async balanceOf(owner, originAddress, value, atBlock) {
|
|
72
|
-
const payload = this.registry.createType('(String, ActorId)', ['BalanceOf', owner]).
|
|
73
|
-
const reply = await this.api.message.calculateReply({
|
|
74
|
-
destination: this.programId,
|
|
83
|
+
const payload = this._program.registry.createType('(String, ActorId)', ['BalanceOf', owner]).toHex();
|
|
84
|
+
const reply = await this._program.api.message.calculateReply({
|
|
85
|
+
destination: this._program.programId,
|
|
75
86
|
origin: (0, _api.decodeAddress)(originAddress),
|
|
76
87
|
payload,
|
|
77
88
|
value: value || 0,
|
|
78
|
-
gasLimit: this.api.blockGasLimit.toBigInt(),
|
|
89
|
+
gasLimit: this._program.api.blockGasLimit.toBigInt(),
|
|
79
90
|
at: atBlock
|
|
80
91
|
});
|
|
81
|
-
const result = this.registry.createType('(String, U256)', reply.payload);
|
|
92
|
+
const result = this._program.registry.createType('(String, U256)', reply.payload);
|
|
82
93
|
return result[1].toBigInt();
|
|
83
94
|
}
|
|
84
95
|
async decimals(originAddress, value, atBlock) {
|
|
85
|
-
const payload = this.registry.createType('String', 'Decimals').
|
|
86
|
-
const reply = await this.api.message.calculateReply({
|
|
87
|
-
destination: this.programId,
|
|
96
|
+
const payload = this._program.registry.createType('String', 'Decimals').toHex();
|
|
97
|
+
const reply = await this._program.api.message.calculateReply({
|
|
98
|
+
destination: this._program.programId,
|
|
88
99
|
origin: (0, _api.decodeAddress)(originAddress),
|
|
89
100
|
payload,
|
|
90
101
|
value: value || 0,
|
|
91
|
-
gasLimit: this.api.blockGasLimit.toBigInt(),
|
|
102
|
+
gasLimit: this._program.api.blockGasLimit.toBigInt(),
|
|
92
103
|
at: atBlock
|
|
93
104
|
});
|
|
94
|
-
const result = this.registry.createType('(String, u8)', reply.payload);
|
|
105
|
+
const result = this._program.registry.createType('(String, u8)', reply.payload);
|
|
95
106
|
return result[1].toNumber();
|
|
96
107
|
}
|
|
97
108
|
async name(originAddress, value, atBlock) {
|
|
98
|
-
const payload = this.registry.createType('String', 'Name').
|
|
99
|
-
const reply = await this.api.message.calculateReply({
|
|
100
|
-
destination: this.programId,
|
|
109
|
+
const payload = this._program.registry.createType('String', 'Name').toHex();
|
|
110
|
+
const reply = await this._program.api.message.calculateReply({
|
|
111
|
+
destination: this._program.programId,
|
|
101
112
|
origin: (0, _api.decodeAddress)(originAddress),
|
|
102
113
|
payload,
|
|
103
114
|
value: value || 0,
|
|
104
|
-
gasLimit: this.api.blockGasLimit.toBigInt(),
|
|
115
|
+
gasLimit: this._program.api.blockGasLimit.toBigInt(),
|
|
105
116
|
at: atBlock
|
|
106
117
|
});
|
|
107
|
-
const result = this.registry.createType('(String, String)', reply.payload);
|
|
118
|
+
const result = this._program.registry.createType('(String, String)', reply.payload);
|
|
108
119
|
return result[1].toString();
|
|
109
120
|
}
|
|
110
121
|
async symbol(originAddress, value, atBlock) {
|
|
111
|
-
const payload = this.registry.createType('String', 'Symbol').
|
|
112
|
-
const reply = await this.api.message.calculateReply({
|
|
113
|
-
destination: this.programId,
|
|
122
|
+
const payload = this._program.registry.createType('String', 'Symbol').toHex();
|
|
123
|
+
const reply = await this._program.api.message.calculateReply({
|
|
124
|
+
destination: this._program.programId,
|
|
114
125
|
origin: (0, _api.decodeAddress)(originAddress),
|
|
115
126
|
payload,
|
|
116
127
|
value: value || 0,
|
|
117
|
-
gasLimit: this.api.blockGasLimit.toBigInt(),
|
|
128
|
+
gasLimit: this._program.api.blockGasLimit.toBigInt(),
|
|
118
129
|
at: atBlock
|
|
119
130
|
});
|
|
120
|
-
const result = this.registry.createType('(String, String)', reply.payload);
|
|
131
|
+
const result = this._program.registry.createType('(String, String)', reply.payload);
|
|
121
132
|
return result[1].toString();
|
|
122
133
|
}
|
|
123
134
|
async totalSupply(originAddress, value, atBlock) {
|
|
124
|
-
const payload = this.registry.createType('String', 'TotalSupply').
|
|
125
|
-
const reply = await this.api.message.calculateReply({
|
|
126
|
-
destination: this.programId,
|
|
135
|
+
const payload = this._program.registry.createType('String', 'TotalSupply').toHex();
|
|
136
|
+
const reply = await this._program.api.message.calculateReply({
|
|
137
|
+
destination: this._program.programId,
|
|
127
138
|
origin: (0, _api.decodeAddress)(originAddress),
|
|
128
139
|
payload,
|
|
129
140
|
value: value || 0,
|
|
130
|
-
gasLimit: this.api.blockGasLimit.toBigInt(),
|
|
141
|
+
gasLimit: this._program.api.blockGasLimit.toBigInt(),
|
|
131
142
|
at: atBlock
|
|
132
143
|
});
|
|
133
|
-
const result = this.registry.createType('(String, U256)', reply.payload);
|
|
144
|
+
const result = this._program.registry.createType('(String, U256)', reply.payload);
|
|
134
145
|
return result[1].toBigInt();
|
|
135
146
|
}
|
|
136
147
|
}
|
|
137
|
-
exports.
|
|
138
|
-
function getGRC20ContractPromise(apiPromise, contractAddress) {
|
|
139
|
-
const gearApi = apiPromise;
|
|
140
|
-
return new GRC20(gearApi, contractAddress);
|
|
141
|
-
}
|
|
148
|
+
exports.Grc20Service = Grc20Service;
|
package/cjs/utils/gear/index.js
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _combine = require("./combine");
|
|
7
|
+
Object.keys(_combine).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _combine[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _combine[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
6
17
|
var _grc = require("./grc20");
|
|
7
18
|
Object.keys(_grc).forEach(function (key) {
|
|
8
19
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -13,4 +24,15 @@ Object.keys(_grc).forEach(function (key) {
|
|
|
13
24
|
return _grc[key];
|
|
14
25
|
}
|
|
15
26
|
});
|
|
27
|
+
});
|
|
28
|
+
var _vft = require("./vft");
|
|
29
|
+
Object.keys(_vft).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _vft[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _vft[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
16
38
|
});
|