@subwallet/extension-base 1.3.35-0 → 1.3.37-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/types.d.ts +2 -1
- package/cjs/core/logic-validation/request.js +13 -1
- package/cjs/koni/background/handlers/Extension.js +189 -108
- package/cjs/koni/background/handlers/State.js +14 -9
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/request-service/handler/AuthRequestHandler.js +4 -1
- package/cjs/services/request-service/handler/EvmRequestHandler.js +4 -1
- package/cjs/services/swap-service/handler/kyber-handler.js +355 -0
- package/cjs/services/swap-service/handler/uniswap-handler.js +209 -40
- package/cjs/services/swap-service/index.js +28 -2
- package/cjs/services/swap-service/utils.js +4 -1
- package/cjs/services/transaction-service/index.js +252 -28
- package/cjs/types/swap/index.js +2 -1
- package/cjs/utils/cardano.js +10 -2
- package/core/logic-validation/request.js +13 -1
- package/koni/background/handlers/Extension.d.ts +1 -0
- package/koni/background/handlers/Extension.js +82 -2
- package/koni/background/handlers/State.js +15 -10
- package/package.json +14 -9
- package/packageInfo.js +1 -1
- package/services/chain-service/types.d.ts +1 -1
- package/services/event-service/types.d.ts +6 -6
- package/services/request-service/handler/AuthRequestHandler.js +4 -1
- package/services/request-service/handler/EvmRequestHandler.js +4 -1
- package/services/swap-service/handler/kyber-handler.d.ts +28 -0
- package/services/swap-service/handler/kyber-handler.js +346 -0
- package/services/swap-service/handler/uniswap-handler.d.ts +48 -0
- package/services/swap-service/handler/uniswap-handler.js +209 -40
- package/services/swap-service/index.js +28 -2
- package/services/swap-service/utils.js +4 -1
- package/services/transaction-service/helpers/index.d.ts +5 -5
- package/services/transaction-service/index.d.ts +10 -5
- package/services/transaction-service/index.js +234 -12
- package/services/transaction-service/types.d.ts +23 -10
- package/types/swap/index.d.ts +4 -1
- package/types/swap/index.js +2 -1
- package/utils/cardano.d.ts +2 -0
- package/utils/cardano.js +7 -0
|
@@ -682,6 +682,64 @@ class KoniExtension {
|
|
|
682
682
|
});
|
|
683
683
|
});
|
|
684
684
|
}
|
|
685
|
+
async switchCurrentNetworkAuthorization(_ref19) {
|
|
686
|
+
let {
|
|
687
|
+
authSwitchNetworkType,
|
|
688
|
+
networkKey,
|
|
689
|
+
url
|
|
690
|
+
} = _ref19;
|
|
691
|
+
const authUrls = await this.#koniState.getAuthList();
|
|
692
|
+
const chainInfo = this.#koniState.chainService.getChainInfoByKey(networkKey);
|
|
693
|
+
const chainState = this.#koniState.getChainStateByKey(networkKey);
|
|
694
|
+
const {
|
|
695
|
+
promise,
|
|
696
|
+
resolve
|
|
697
|
+
} = (0, _utils7.createPromiseHandler)();
|
|
698
|
+
const typeInfoMap = {
|
|
699
|
+
substrate: 'substrateInfo',
|
|
700
|
+
evm: 'evmInfo',
|
|
701
|
+
cardano: 'cardanoInfo',
|
|
702
|
+
ton: 'tonInfo'
|
|
703
|
+
};
|
|
704
|
+
const typeInfoKey = typeInfoMap[authSwitchNetworkType];
|
|
705
|
+
if (!typeInfoKey || !chainInfo[typeInfoKey]) {
|
|
706
|
+
throw new Error((0, _i18next.t)('Network {{networkKey}} is not {{authSwitchNetworkType}}', {
|
|
707
|
+
replace: {
|
|
708
|
+
networkKey,
|
|
709
|
+
authSwitchNetworkType
|
|
710
|
+
}
|
|
711
|
+
}));
|
|
712
|
+
}
|
|
713
|
+
const authUrl = authUrls[url];
|
|
714
|
+
if (!authUrl) {
|
|
715
|
+
throw new Error((0, _i18next.t)('Not found {{url}} in auth list', {
|
|
716
|
+
replace: {
|
|
717
|
+
url
|
|
718
|
+
}
|
|
719
|
+
}));
|
|
720
|
+
}
|
|
721
|
+
if (chainInfo && !(0, _utils5._isChainEnabled)(chainState)) {
|
|
722
|
+
await this.enableChainWithPriorityAssets({
|
|
723
|
+
chainSlug: networkKey,
|
|
724
|
+
enableTokens: true
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
if (!authUrl.accountAuthTypes.includes(authSwitchNetworkType)) {
|
|
728
|
+
throw new Error((0, _i18next.t)('Network {{networkKey}} is not supported by {{authSwitchNetworkType}}', {
|
|
729
|
+
replace: {
|
|
730
|
+
networkKey,
|
|
731
|
+
authSwitchNetworkType
|
|
732
|
+
}
|
|
733
|
+
}));
|
|
734
|
+
}
|
|
735
|
+
authUrl.currentNetworkMap[authSwitchNetworkType] = networkKey;
|
|
736
|
+
this.#koniState.setAuthorize(authUrls, () => {
|
|
737
|
+
resolve({
|
|
738
|
+
list: authUrls
|
|
739
|
+
});
|
|
740
|
+
});
|
|
741
|
+
return promise;
|
|
742
|
+
}
|
|
685
743
|
changeAuthorization(data, id, port) {
|
|
686
744
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
687
745
|
this._changeAuthorization(data.url, data.connectValue, items => {
|
|
@@ -778,10 +836,10 @@ class KoniExtension {
|
|
|
778
836
|
this.#koniState.updateSetting('theme', data);
|
|
779
837
|
return true;
|
|
780
838
|
}
|
|
781
|
-
setCamera(
|
|
839
|
+
setCamera(_ref20) {
|
|
782
840
|
let {
|
|
783
841
|
camera
|
|
784
|
-
} =
|
|
842
|
+
} = _ref20;
|
|
785
843
|
this.#koniState.updateSetting('camera', camera);
|
|
786
844
|
return true;
|
|
787
845
|
}
|
|
@@ -789,17 +847,17 @@ class KoniExtension {
|
|
|
789
847
|
this.#koniState.updateSetting('browserConfirmationType', data);
|
|
790
848
|
return true;
|
|
791
849
|
}
|
|
792
|
-
setAutoLockTime(
|
|
850
|
+
setAutoLockTime(_ref21) {
|
|
793
851
|
let {
|
|
794
852
|
autoLockTime
|
|
795
|
-
} =
|
|
853
|
+
} = _ref21;
|
|
796
854
|
this.#koniState.updateSetting('timeAutoLock', autoLockTime);
|
|
797
855
|
return true;
|
|
798
856
|
}
|
|
799
|
-
setUnlockType(
|
|
857
|
+
setUnlockType(_ref22) {
|
|
800
858
|
let {
|
|
801
859
|
unlockType
|
|
802
|
-
} =
|
|
860
|
+
} = _ref22;
|
|
803
861
|
this.#koniState.updateSetting('unlockType', unlockType);
|
|
804
862
|
return true;
|
|
805
863
|
}
|
|
@@ -816,10 +874,10 @@ class KoniExtension {
|
|
|
816
874
|
});
|
|
817
875
|
return await this.getSettings();
|
|
818
876
|
}
|
|
819
|
-
setEnableChainPatrol(
|
|
877
|
+
setEnableChainPatrol(_ref23) {
|
|
820
878
|
let {
|
|
821
879
|
enable
|
|
822
|
-
} =
|
|
880
|
+
} = _ref23;
|
|
823
881
|
this.#koniState.updateSetting('enableChainPatrol', enable);
|
|
824
882
|
return true;
|
|
825
883
|
}
|
|
@@ -827,17 +885,17 @@ class KoniExtension {
|
|
|
827
885
|
this.#koniState.updateSetting('notificationSetup', request);
|
|
828
886
|
return true;
|
|
829
887
|
}
|
|
830
|
-
saveMigrationAcknowledgedStatus(
|
|
888
|
+
saveMigrationAcknowledgedStatus(_ref24) {
|
|
831
889
|
let {
|
|
832
890
|
isAcknowledgedUnifiedAccountMigration
|
|
833
|
-
} =
|
|
891
|
+
} = _ref24;
|
|
834
892
|
this.#koniState.updateSetting('isAcknowledgedUnifiedAccountMigration', isAcknowledgedUnifiedAccountMigration);
|
|
835
893
|
return true;
|
|
836
894
|
}
|
|
837
|
-
saveUnifiedAccountMigrationInProgress(
|
|
895
|
+
saveUnifiedAccountMigrationInProgress(_ref25) {
|
|
838
896
|
let {
|
|
839
897
|
isUnifiedAccountMigrationInProgress
|
|
840
|
-
} =
|
|
898
|
+
} = _ref25;
|
|
841
899
|
this.#koniState.updateSetting('isUnifiedAccountMigrationInProgress', isUnifiedAccountMigrationInProgress);
|
|
842
900
|
return true;
|
|
843
901
|
}
|
|
@@ -845,31 +903,31 @@ class KoniExtension {
|
|
|
845
903
|
this.#koniState.updateSetting('isUnifiedAccountMigrationInProgress', false);
|
|
846
904
|
return true;
|
|
847
905
|
}
|
|
848
|
-
setShowZeroBalance(
|
|
906
|
+
setShowZeroBalance(_ref26) {
|
|
849
907
|
let {
|
|
850
908
|
show
|
|
851
|
-
} =
|
|
909
|
+
} = _ref26;
|
|
852
910
|
this.#koniState.updateSetting('isShowZeroBalance', show);
|
|
853
911
|
return true;
|
|
854
912
|
}
|
|
855
|
-
setLanguage(
|
|
913
|
+
setLanguage(_ref27) {
|
|
856
914
|
let {
|
|
857
915
|
language
|
|
858
|
-
} =
|
|
916
|
+
} = _ref27;
|
|
859
917
|
this.#koniState.updateSetting('language', language);
|
|
860
918
|
return true;
|
|
861
919
|
}
|
|
862
|
-
setShowBalance(
|
|
920
|
+
setShowBalance(_ref28) {
|
|
863
921
|
let {
|
|
864
922
|
enable
|
|
865
|
-
} =
|
|
923
|
+
} = _ref28;
|
|
866
924
|
this.#koniState.updateSetting('isShowBalance', enable);
|
|
867
925
|
return true;
|
|
868
926
|
}
|
|
869
|
-
setAllowOneSign(
|
|
927
|
+
setAllowOneSign(_ref29) {
|
|
870
928
|
let {
|
|
871
929
|
allowOneSign
|
|
872
|
-
} =
|
|
930
|
+
} = _ref29;
|
|
873
931
|
this.#koniState.updateSetting('allowOneSign', allowOneSign);
|
|
874
932
|
return true;
|
|
875
933
|
}
|
|
@@ -918,11 +976,11 @@ class KoniExtension {
|
|
|
918
976
|
async getPrice() {
|
|
919
977
|
return this.#koniState.priceService.getPrice();
|
|
920
978
|
}
|
|
921
|
-
async getHistoryTokenPrice(
|
|
979
|
+
async getHistoryTokenPrice(_ref30) {
|
|
922
980
|
let {
|
|
923
981
|
priceId,
|
|
924
982
|
timeframe
|
|
925
|
-
} =
|
|
983
|
+
} = _ref30;
|
|
926
984
|
return this.#koniState.priceService.getHistoryTokenPriceData(priceId, timeframe);
|
|
927
985
|
}
|
|
928
986
|
checkCoinGeckoPriceSupport(priceId) {
|
|
@@ -943,10 +1001,10 @@ class KoniExtension {
|
|
|
943
1001
|
price: currentPrice
|
|
944
1002
|
};
|
|
945
1003
|
}
|
|
946
|
-
async setPriceCurrency(
|
|
1004
|
+
async setPriceCurrency(_ref31) {
|
|
947
1005
|
let {
|
|
948
1006
|
currency
|
|
949
|
-
} =
|
|
1007
|
+
} = _ref31;
|
|
950
1008
|
return await this.#koniState.priceService.setPriceCurrency(currency);
|
|
951
1009
|
}
|
|
952
1010
|
subscribePrice(id, port) {
|
|
@@ -1154,11 +1212,11 @@ class KoniExtension {
|
|
|
1154
1212
|
// Re-filter
|
|
1155
1213
|
return historySubject.getValue().filter(item => addresses.some(address => (0, _utils7.isSameAddress)(item.address, address)));
|
|
1156
1214
|
}
|
|
1157
|
-
subscribeHistoryByChainAndAddress(
|
|
1215
|
+
subscribeHistoryByChainAndAddress(_ref32, id, port) {
|
|
1158
1216
|
let {
|
|
1159
1217
|
address,
|
|
1160
1218
|
chain
|
|
1161
|
-
} =
|
|
1219
|
+
} = _ref32;
|
|
1162
1220
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
1163
1221
|
const subscribeHistoriesResponse = this.#koniState.historyService.subscribeHistories(chain, address, cb);
|
|
1164
1222
|
this.createUnsubscriptionHandle(id, subscribeHistoriesResponse.unsubscribe);
|
|
@@ -1726,28 +1784,28 @@ class KoniExtension {
|
|
|
1726
1784
|
disableChain(networkKey) {
|
|
1727
1785
|
return this.#koniState.disableChain(networkKey);
|
|
1728
1786
|
}
|
|
1729
|
-
async enableChain(
|
|
1787
|
+
async enableChain(_ref33) {
|
|
1730
1788
|
let {
|
|
1731
1789
|
chainSlug,
|
|
1732
1790
|
enableTokens
|
|
1733
|
-
} =
|
|
1791
|
+
} = _ref33;
|
|
1734
1792
|
return await this.#koniState.enableChain(chainSlug, enableTokens);
|
|
1735
1793
|
}
|
|
1736
|
-
async enableChainWithPriorityAssets(
|
|
1794
|
+
async enableChainWithPriorityAssets(_ref34) {
|
|
1737
1795
|
let {
|
|
1738
1796
|
chainSlug,
|
|
1739
1797
|
enableTokens
|
|
1740
|
-
} =
|
|
1798
|
+
} = _ref34;
|
|
1741
1799
|
return await this.#koniState.enableChainWithPriorityAssets(chainSlug, enableTokens);
|
|
1742
1800
|
}
|
|
1743
1801
|
async reconnectChain(chainSlug) {
|
|
1744
1802
|
return this.#koniState.chainService.reconnectChain(chainSlug);
|
|
1745
1803
|
}
|
|
1746
|
-
async validateNetwork(
|
|
1804
|
+
async validateNetwork(_ref35) {
|
|
1747
1805
|
let {
|
|
1748
1806
|
existedChainSlug,
|
|
1749
1807
|
provider
|
|
1750
|
-
} =
|
|
1808
|
+
} = _ref35;
|
|
1751
1809
|
return await this.#koniState.validateCustomChain(provider, existedChainSlug);
|
|
1752
1810
|
}
|
|
1753
1811
|
resetDefaultNetwork() {
|
|
@@ -1819,13 +1877,13 @@ class KoniExtension {
|
|
|
1819
1877
|
async validateCustomAsset(data) {
|
|
1820
1878
|
return await this.#koniState.validateCustomAsset(data);
|
|
1821
1879
|
}
|
|
1822
|
-
async getAddressTransferableBalance(
|
|
1880
|
+
async getAddressTransferableBalance(_ref36) {
|
|
1823
1881
|
let {
|
|
1824
1882
|
address,
|
|
1825
1883
|
extrinsicType,
|
|
1826
1884
|
networkKey,
|
|
1827
1885
|
token
|
|
1828
|
-
} =
|
|
1886
|
+
} = _ref36;
|
|
1829
1887
|
if (token && _constants2._MANTA_ZK_CHAIN_GROUP.includes(networkKey)) {
|
|
1830
1888
|
const tokenInfo = this.#koniState.chainService.getAssetBySlug(token);
|
|
1831
1889
|
if (tokenInfo.symbol.startsWith(_constants2._ZK_ASSET_PREFIX)) {
|
|
@@ -1834,13 +1892,13 @@ class KoniExtension {
|
|
|
1834
1892
|
}
|
|
1835
1893
|
return await this.#koniState.balanceService.getTransferableBalance(address, networkKey, token, extrinsicType);
|
|
1836
1894
|
}
|
|
1837
|
-
async getAddressTotalBalance(
|
|
1895
|
+
async getAddressTotalBalance(_ref37) {
|
|
1838
1896
|
let {
|
|
1839
1897
|
address,
|
|
1840
1898
|
extrinsicType,
|
|
1841
1899
|
networkKey,
|
|
1842
1900
|
token
|
|
1843
|
-
} =
|
|
1901
|
+
} = _ref37;
|
|
1844
1902
|
return await this.#koniState.balanceService.getTotalBalance(address, networkKey, token, extrinsicType);
|
|
1845
1903
|
}
|
|
1846
1904
|
async subscribeMaxTransferable(request, id, port) {
|
|
@@ -1892,11 +1950,11 @@ class KoniExtension {
|
|
|
1892
1950
|
freeBalance: freeBalanceSubject,
|
|
1893
1951
|
fee: feeSubject
|
|
1894
1952
|
}).subscribe({
|
|
1895
|
-
next:
|
|
1953
|
+
next: _ref38 => {
|
|
1896
1954
|
let {
|
|
1897
1955
|
fee,
|
|
1898
1956
|
freeBalance
|
|
1899
|
-
} =
|
|
1957
|
+
} = _ref38;
|
|
1900
1958
|
(0, _utils7.calculateMaxTransferable)(id, _request, freeBalance, fee).then(cb).catch(console.error);
|
|
1901
1959
|
}
|
|
1902
1960
|
});
|
|
@@ -1930,13 +1988,13 @@ class KoniExtension {
|
|
|
1930
1988
|
});
|
|
1931
1989
|
return (0, _utils7.calculateMaxTransferable)(id, _request, freeBalance, fee);
|
|
1932
1990
|
}
|
|
1933
|
-
async subscribeAddressTransferableBalance(
|
|
1991
|
+
async subscribeAddressTransferableBalance(_ref39, id, port) {
|
|
1934
1992
|
let {
|
|
1935
1993
|
address,
|
|
1936
1994
|
extrinsicType,
|
|
1937
1995
|
networkKey,
|
|
1938
1996
|
token
|
|
1939
|
-
} =
|
|
1997
|
+
} = _ref39;
|
|
1940
1998
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
1941
1999
|
const convertData = data => {
|
|
1942
2000
|
return {
|
|
@@ -1987,11 +2045,11 @@ class KoniExtension {
|
|
|
1987
2045
|
isSendingSelf
|
|
1988
2046
|
};
|
|
1989
2047
|
}
|
|
1990
|
-
async enableChains(
|
|
2048
|
+
async enableChains(_ref40) {
|
|
1991
2049
|
let {
|
|
1992
2050
|
chainSlugs,
|
|
1993
2051
|
enableTokens
|
|
1994
|
-
} =
|
|
2052
|
+
} = _ref40;
|
|
1995
2053
|
try {
|
|
1996
2054
|
await Promise.all(chainSlugs.map(chainSlug => this.enableChain({
|
|
1997
2055
|
chainSlug,
|
|
@@ -2124,30 +2182,30 @@ class KoniExtension {
|
|
|
2124
2182
|
|
|
2125
2183
|
// Parse transaction
|
|
2126
2184
|
|
|
2127
|
-
parseSubstrateTransaction(
|
|
2185
|
+
parseSubstrateTransaction(_ref41) {
|
|
2128
2186
|
let {
|
|
2129
2187
|
data,
|
|
2130
2188
|
networkKey
|
|
2131
|
-
} =
|
|
2189
|
+
} = _ref41;
|
|
2132
2190
|
const apiProps = this.#koniState.getSubstrateApi(networkKey);
|
|
2133
2191
|
const apiPromise = apiProps.api;
|
|
2134
2192
|
return (0, _parseTransaction.parseSubstrateTransaction)(data, apiPromise);
|
|
2135
2193
|
}
|
|
2136
|
-
async parseEVMRLP(
|
|
2194
|
+
async parseEVMRLP(_ref42) {
|
|
2137
2195
|
let {
|
|
2138
2196
|
data
|
|
2139
|
-
} =
|
|
2197
|
+
} = _ref42;
|
|
2140
2198
|
return await (0, _parseTransaction2.parseEvmRlp)(data, this.#koniState.getChainInfoMap(), this.#koniState.getEvmApiMap());
|
|
2141
2199
|
}
|
|
2142
2200
|
|
|
2143
2201
|
// Sign
|
|
2144
2202
|
|
|
2145
|
-
qrSignSubstrate(
|
|
2203
|
+
qrSignSubstrate(_ref43) {
|
|
2146
2204
|
let {
|
|
2147
2205
|
address,
|
|
2148
2206
|
data,
|
|
2149
2207
|
networkKey
|
|
2150
|
-
} =
|
|
2208
|
+
} = _ref43;
|
|
2151
2209
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
2152
2210
|
(0, _util.assert)(pair, (0, _i18next.t)('Unable to find account'));
|
|
2153
2211
|
if (pair.isLocked) {
|
|
@@ -2164,13 +2222,13 @@ class KoniExtension {
|
|
|
2164
2222
|
signature: signed
|
|
2165
2223
|
};
|
|
2166
2224
|
}
|
|
2167
|
-
async qrSignEVM(
|
|
2225
|
+
async qrSignEVM(_ref44) {
|
|
2168
2226
|
let {
|
|
2169
2227
|
address,
|
|
2170
2228
|
chainId,
|
|
2171
2229
|
message,
|
|
2172
2230
|
type
|
|
2173
|
-
} =
|
|
2231
|
+
} = _ref44;
|
|
2174
2232
|
let signed;
|
|
2175
2233
|
const network = this.getNetworkJsonByChainId(chainId);
|
|
2176
2234
|
if (!network) {
|
|
@@ -2254,11 +2312,11 @@ class KoniExtension {
|
|
|
2254
2312
|
});
|
|
2255
2313
|
return this.#koniState.getNominatorMetadata();
|
|
2256
2314
|
}
|
|
2257
|
-
async getBondingOptions(
|
|
2315
|
+
async getBondingOptions(_ref45) {
|
|
2258
2316
|
let {
|
|
2259
2317
|
chain,
|
|
2260
2318
|
type
|
|
2261
|
-
} =
|
|
2319
|
+
} = _ref45;
|
|
2262
2320
|
const apiProps = this.#koniState.getSubstrateApi(chain);
|
|
2263
2321
|
const chainInfo = this.#koniState.getChainInfo(chain);
|
|
2264
2322
|
const chainStakingMetadata = await this.#koniState.getStakingMetadataByChain(chain, type);
|
|
@@ -2448,12 +2506,12 @@ class KoniExtension {
|
|
|
2448
2506
|
}
|
|
2449
2507
|
|
|
2450
2508
|
// EVM Transaction
|
|
2451
|
-
async parseContractInput(
|
|
2509
|
+
async parseContractInput(_ref46) {
|
|
2452
2510
|
let {
|
|
2453
2511
|
chainId,
|
|
2454
2512
|
contract,
|
|
2455
2513
|
data
|
|
2456
|
-
} =
|
|
2514
|
+
} = _ref46;
|
|
2457
2515
|
const network = this.getNetworkJsonByChainId(chainId);
|
|
2458
2516
|
return await (0, _parseTransaction2.parseContractInput)(data, contract, network);
|
|
2459
2517
|
}
|
|
@@ -2553,10 +2611,10 @@ class KoniExtension {
|
|
|
2553
2611
|
|
|
2554
2612
|
// Unlock wallet
|
|
2555
2613
|
|
|
2556
|
-
keyringUnlock(
|
|
2614
|
+
keyringUnlock(_ref47) {
|
|
2557
2615
|
let {
|
|
2558
2616
|
password
|
|
2559
|
-
} =
|
|
2617
|
+
} = _ref47;
|
|
2560
2618
|
try {
|
|
2561
2619
|
_uiKeyring.keyring.unlockKeyring(password);
|
|
2562
2620
|
// this.#koniState.initMantaPay(password)
|
|
@@ -2587,11 +2645,11 @@ class KoniExtension {
|
|
|
2587
2645
|
|
|
2588
2646
|
// Export mnemonic
|
|
2589
2647
|
|
|
2590
|
-
keyringExportMnemonic(
|
|
2648
|
+
keyringExportMnemonic(_ref48) {
|
|
2591
2649
|
let {
|
|
2592
2650
|
address,
|
|
2593
2651
|
password
|
|
2594
|
-
} =
|
|
2652
|
+
} = _ref48;
|
|
2595
2653
|
const pair = _uiKeyring.keyring.getPair(address);
|
|
2596
2654
|
const result = pair.exportMnemonic(password);
|
|
2597
2655
|
return {
|
|
@@ -2601,10 +2659,10 @@ class KoniExtension {
|
|
|
2601
2659
|
|
|
2602
2660
|
// Reset wallet
|
|
2603
2661
|
|
|
2604
|
-
async resetWallet(
|
|
2662
|
+
async resetWallet(_ref49) {
|
|
2605
2663
|
let {
|
|
2606
2664
|
resetAll
|
|
2607
|
-
} =
|
|
2665
|
+
} = _ref49;
|
|
2608
2666
|
try {
|
|
2609
2667
|
await this.#koniState.resetWallet(resetAll);
|
|
2610
2668
|
return {
|
|
@@ -2620,10 +2678,10 @@ class KoniExtension {
|
|
|
2620
2678
|
}
|
|
2621
2679
|
|
|
2622
2680
|
// Signing substrate request
|
|
2623
|
-
async signingApprovePasswordV2(
|
|
2681
|
+
async signingApprovePasswordV2(_ref50) {
|
|
2624
2682
|
let {
|
|
2625
2683
|
id
|
|
2626
|
-
} =
|
|
2684
|
+
} = _ref50;
|
|
2627
2685
|
const queued = this.#koniState.getSignRequest(id);
|
|
2628
2686
|
(0, _util.assert)(queued, (0, _i18next.t)('Unable to proceed. Please try again'));
|
|
2629
2687
|
const {
|
|
@@ -2782,10 +2840,11 @@ class KoniExtension {
|
|
|
2782
2840
|
getSupportedSmartContractTypes() {
|
|
2783
2841
|
return this.#koniState.getSupportedSmartContractTypes();
|
|
2784
2842
|
}
|
|
2785
|
-
getTransaction(
|
|
2843
|
+
getTransaction(_ref51) {
|
|
2786
2844
|
let {
|
|
2787
2845
|
id
|
|
2788
|
-
} =
|
|
2846
|
+
} = _ref51;
|
|
2847
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
2789
2848
|
const {
|
|
2790
2849
|
transaction,
|
|
2791
2850
|
...transactionResult
|
|
@@ -2795,8 +2854,9 @@ class KoniExtension {
|
|
|
2795
2854
|
async subscribeTransactions(id, port) {
|
|
2796
2855
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
2797
2856
|
function convertRs(rs, processMap) {
|
|
2798
|
-
return Object.fromEntries(Object.entries(rs).map(
|
|
2799
|
-
let [key, value] =
|
|
2857
|
+
return Object.fromEntries(Object.entries(rs).map(_ref52 => {
|
|
2858
|
+
let [key, value] = _ref52;
|
|
2859
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
2800
2860
|
const {
|
|
2801
2861
|
additionalValidator,
|
|
2802
2862
|
eventsHandler,
|
|
@@ -2820,11 +2880,11 @@ class KoniExtension {
|
|
|
2820
2880
|
const subscription = (0, _rxjs.combineLatest)({
|
|
2821
2881
|
transactions: transactionsObservable,
|
|
2822
2882
|
processMap: processTransactionObservable
|
|
2823
|
-
}).subscribe(
|
|
2883
|
+
}).subscribe(_ref53 => {
|
|
2824
2884
|
let {
|
|
2825
2885
|
processMap,
|
|
2826
2886
|
transactions
|
|
2827
|
-
} =
|
|
2887
|
+
} = _ref53;
|
|
2828
2888
|
cb(convertRs(transactions, processMap));
|
|
2829
2889
|
});
|
|
2830
2890
|
port.onDisconnect.addListener(() => {
|
|
@@ -2845,10 +2905,10 @@ class KoniExtension {
|
|
|
2845
2905
|
});
|
|
2846
2906
|
return notificationSubject.value;
|
|
2847
2907
|
}
|
|
2848
|
-
async reloadCron(
|
|
2908
|
+
async reloadCron(_ref54) {
|
|
2849
2909
|
let {
|
|
2850
2910
|
data
|
|
2851
|
-
} =
|
|
2911
|
+
} = _ref54;
|
|
2852
2912
|
if (data === 'nft') {
|
|
2853
2913
|
return await this.#koniState.reloadNft();
|
|
2854
2914
|
} else if (data === 'staking') {
|
|
@@ -2891,10 +2951,10 @@ class KoniExtension {
|
|
|
2891
2951
|
}
|
|
2892
2952
|
|
|
2893
2953
|
// Phishing detect
|
|
2894
|
-
async passPhishingPage(
|
|
2954
|
+
async passPhishingPage(_ref55) {
|
|
2895
2955
|
let {
|
|
2896
2956
|
url
|
|
2897
|
-
} =
|
|
2957
|
+
} = _ref55;
|
|
2898
2958
|
return await this.#koniState.approvePassPhishingPage(url);
|
|
2899
2959
|
}
|
|
2900
2960
|
|
|
@@ -2915,10 +2975,10 @@ class KoniExtension {
|
|
|
2915
2975
|
/// Wallet connect
|
|
2916
2976
|
|
|
2917
2977
|
// Connect
|
|
2918
|
-
async connectWalletConnect(
|
|
2978
|
+
async connectWalletConnect(_ref56) {
|
|
2919
2979
|
let {
|
|
2920
2980
|
uri
|
|
2921
|
-
} =
|
|
2981
|
+
} = _ref56;
|
|
2922
2982
|
await this.#koniState.walletConnectService.connect(uri);
|
|
2923
2983
|
return true;
|
|
2924
2984
|
}
|
|
@@ -2931,11 +2991,11 @@ class KoniExtension {
|
|
|
2931
2991
|
});
|
|
2932
2992
|
return this.#koniState.requestService.allConnectWCRequests;
|
|
2933
2993
|
}
|
|
2934
|
-
async approveWalletConnectSession(
|
|
2994
|
+
async approveWalletConnectSession(_ref57) {
|
|
2935
2995
|
let {
|
|
2936
2996
|
accounts: selectedAccounts,
|
|
2937
2997
|
id
|
|
2938
|
-
} =
|
|
2998
|
+
} = _ref57;
|
|
2939
2999
|
const request = this.#koniState.requestService.getConnectWCRequest(id);
|
|
2940
3000
|
if ((0, _helpers2.isProposalExpired)(request.request.params)) {
|
|
2941
3001
|
throw new Error('The proposal has been expired');
|
|
@@ -2947,8 +3007,8 @@ class KoniExtension {
|
|
|
2947
3007
|
const availableNamespaces = {};
|
|
2948
3008
|
const namespaces = {};
|
|
2949
3009
|
const chainInfoMap = this.#koniState.getChainInfoMap();
|
|
2950
|
-
Object.entries(requiredNamespaces).forEach(
|
|
2951
|
-
let [key, namespace] =
|
|
3010
|
+
Object.entries(requiredNamespaces).forEach(_ref58 => {
|
|
3011
|
+
let [key, namespace] = _ref58;
|
|
2952
3012
|
if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
|
|
2953
3013
|
if (namespace.chains) {
|
|
2954
3014
|
const unSupportChains = namespace.chains.filter(chain => !(0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap));
|
|
@@ -2961,8 +3021,8 @@ class KoniExtension {
|
|
|
2961
3021
|
throw new Error((0, _utils8.getSdkError)('UNSUPPORTED_NAMESPACE_KEY').message + ' ' + key);
|
|
2962
3022
|
}
|
|
2963
3023
|
});
|
|
2964
|
-
Object.entries(optionalNamespaces).forEach(
|
|
2965
|
-
let [key, namespace] =
|
|
3024
|
+
Object.entries(optionalNamespaces).forEach(_ref59 => {
|
|
3025
|
+
let [key, namespace] = _ref59;
|
|
2966
3026
|
if ((0, _helpers2.isSupportWalletConnectNamespace)(key)) {
|
|
2967
3027
|
if (namespace.chains) {
|
|
2968
3028
|
const supportChains = namespace.chains.filter(chain => (0, _helpers2.isSupportWalletConnectChain)(chain, chainInfoMap)) || [];
|
|
@@ -2986,8 +3046,8 @@ class KoniExtension {
|
|
|
2986
3046
|
}
|
|
2987
3047
|
}
|
|
2988
3048
|
});
|
|
2989
|
-
Object.entries(availableNamespaces).forEach(
|
|
2990
|
-
let [key, namespace] =
|
|
3049
|
+
Object.entries(availableNamespaces).forEach(_ref60 => {
|
|
3050
|
+
let [key, namespace] = _ref60;
|
|
2991
3051
|
if (namespace.chains) {
|
|
2992
3052
|
const accounts = selectedAccounts.filter(address => {
|
|
2993
3053
|
const [_namespace] = address.split(':');
|
|
@@ -3011,10 +3071,10 @@ class KoniExtension {
|
|
|
3011
3071
|
request.resolve();
|
|
3012
3072
|
return true;
|
|
3013
3073
|
}
|
|
3014
|
-
async rejectWalletConnectSession(
|
|
3074
|
+
async rejectWalletConnectSession(_ref61) {
|
|
3015
3075
|
let {
|
|
3016
3076
|
id
|
|
3017
|
-
} =
|
|
3077
|
+
} = _ref61;
|
|
3018
3078
|
const request = this.#koniState.requestService.getConnectWCRequest(id);
|
|
3019
3079
|
const wcId = request.request.id;
|
|
3020
3080
|
if ((0, _helpers2.isProposalExpired)(request.request.params)) {
|
|
@@ -3036,10 +3096,10 @@ class KoniExtension {
|
|
|
3036
3096
|
});
|
|
3037
3097
|
return this.#koniState.walletConnectService.sessions;
|
|
3038
3098
|
}
|
|
3039
|
-
async disconnectWalletConnectSession(
|
|
3099
|
+
async disconnectWalletConnectSession(_ref62) {
|
|
3040
3100
|
let {
|
|
3041
3101
|
topic
|
|
3042
|
-
} =
|
|
3102
|
+
} = _ref62;
|
|
3043
3103
|
await this.#koniState.walletConnectService.disconnect(topic);
|
|
3044
3104
|
return true;
|
|
3045
3105
|
}
|
|
@@ -3052,18 +3112,18 @@ class KoniExtension {
|
|
|
3052
3112
|
});
|
|
3053
3113
|
return this.#koniState.requestService.allNotSupportWCRequests;
|
|
3054
3114
|
}
|
|
3055
|
-
approveWalletConnectNotSupport(
|
|
3115
|
+
approveWalletConnectNotSupport(_ref63) {
|
|
3056
3116
|
let {
|
|
3057
3117
|
id
|
|
3058
|
-
} =
|
|
3118
|
+
} = _ref63;
|
|
3059
3119
|
const request = this.#koniState.requestService.getNotSupportWCRequest(id);
|
|
3060
3120
|
request.resolve();
|
|
3061
3121
|
return true;
|
|
3062
3122
|
}
|
|
3063
|
-
rejectWalletConnectNotSupport(
|
|
3123
|
+
rejectWalletConnectNotSupport(_ref64) {
|
|
3064
3124
|
let {
|
|
3065
3125
|
id
|
|
3066
|
-
} =
|
|
3126
|
+
} = _ref64;
|
|
3067
3127
|
const request = this.#koniState.requestService.getNotSupportWCRequest(id);
|
|
3068
3128
|
request.reject(new Error('USER_REJECTED'));
|
|
3069
3129
|
return true;
|
|
@@ -3071,11 +3131,11 @@ class KoniExtension {
|
|
|
3071
3131
|
|
|
3072
3132
|
/// Manta
|
|
3073
3133
|
|
|
3074
|
-
async enableMantaPay(
|
|
3134
|
+
async enableMantaPay(_ref65) {
|
|
3075
3135
|
let {
|
|
3076
3136
|
address,
|
|
3077
3137
|
password
|
|
3078
|
-
} =
|
|
3138
|
+
} = _ref65;
|
|
3079
3139
|
// always takes the current account
|
|
3080
3140
|
function timeout() {
|
|
3081
3141
|
return new Promise(resolve => setTimeout(resolve, 1500));
|
|
@@ -3165,11 +3225,11 @@ class KoniExtension {
|
|
|
3165
3225
|
async disableMantaPay(address) {
|
|
3166
3226
|
return this.#koniState.disableMantaPay(address);
|
|
3167
3227
|
}
|
|
3168
|
-
async isTonBounceableAddress(
|
|
3228
|
+
async isTonBounceableAddress(_ref66) {
|
|
3169
3229
|
let {
|
|
3170
3230
|
address,
|
|
3171
3231
|
chain
|
|
3172
|
-
} =
|
|
3232
|
+
} = _ref66;
|
|
3173
3233
|
try {
|
|
3174
3234
|
const tonApi = this.#koniState.getTonApi(chain);
|
|
3175
3235
|
const state = await tonApi.getAccountState(address);
|
|
@@ -3215,10 +3275,10 @@ class KoniExtension {
|
|
|
3215
3275
|
|
|
3216
3276
|
/* Metadata */
|
|
3217
3277
|
|
|
3218
|
-
async findRawMetadata(
|
|
3278
|
+
async findRawMetadata(_ref67) {
|
|
3219
3279
|
let {
|
|
3220
3280
|
genesisHash
|
|
3221
|
-
} =
|
|
3281
|
+
} = _ref67;
|
|
3222
3282
|
const {
|
|
3223
3283
|
metadata,
|
|
3224
3284
|
specVersion,
|
|
@@ -3232,20 +3292,20 @@ class KoniExtension {
|
|
|
3232
3292
|
userExtensions
|
|
3233
3293
|
};
|
|
3234
3294
|
}
|
|
3235
|
-
async calculateMetadataHash(
|
|
3295
|
+
async calculateMetadataHash(_ref68) {
|
|
3236
3296
|
let {
|
|
3237
3297
|
chain
|
|
3238
|
-
} =
|
|
3298
|
+
} = _ref68;
|
|
3239
3299
|
const hash = await this.#koniState.calculateMetadataHash(chain);
|
|
3240
3300
|
return {
|
|
3241
3301
|
metadataHash: hash || ''
|
|
3242
3302
|
};
|
|
3243
3303
|
}
|
|
3244
|
-
async shortenMetadata(
|
|
3304
|
+
async shortenMetadata(_ref69) {
|
|
3245
3305
|
let {
|
|
3246
3306
|
chain,
|
|
3247
3307
|
txBlob
|
|
3248
|
-
} =
|
|
3308
|
+
} = _ref69;
|
|
3249
3309
|
const shorten = await this.#koniState.shortenMetadata(chain, txBlob);
|
|
3250
3310
|
return {
|
|
3251
3311
|
txMetadata: shorten || ''
|
|
@@ -3598,18 +3658,18 @@ class KoniExtension {
|
|
|
3598
3658
|
|
|
3599
3659
|
/* Campaign */
|
|
3600
3660
|
|
|
3601
|
-
unlockDotCheckCanMint(
|
|
3661
|
+
unlockDotCheckCanMint(_ref70) {
|
|
3602
3662
|
let {
|
|
3603
3663
|
address,
|
|
3604
3664
|
network,
|
|
3605
3665
|
slug
|
|
3606
|
-
} =
|
|
3666
|
+
} = _ref70;
|
|
3607
3667
|
return this.#koniState.mintCampaignService.unlockDotCampaign.canMint(address, slug, network);
|
|
3608
3668
|
}
|
|
3609
|
-
unlockDotSubscribeMintedData(id, port,
|
|
3669
|
+
unlockDotSubscribeMintedData(id, port, _ref71) {
|
|
3610
3670
|
let {
|
|
3611
3671
|
transactionId
|
|
3612
|
-
} =
|
|
3672
|
+
} = _ref71;
|
|
3613
3673
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3614
3674
|
const subscription = this.#koniState.mintCampaignService.unlockDotCampaign.subscribeMintedNft(transactionId, cb);
|
|
3615
3675
|
this.createUnsubscriptionHandle(id, subscription.unsubscribe);
|
|
@@ -3641,10 +3701,10 @@ class KoniExtension {
|
|
|
3641
3701
|
});
|
|
3642
3702
|
return filterBanner(await this.#koniState.campaignService.getProcessingCampaign());
|
|
3643
3703
|
}
|
|
3644
|
-
async completeCampaignBanner(
|
|
3704
|
+
async completeCampaignBanner(_ref72) {
|
|
3645
3705
|
let {
|
|
3646
3706
|
slug
|
|
3647
|
-
} =
|
|
3707
|
+
} = _ref72;
|
|
3648
3708
|
const campaign = await this.#koniState.dbService.getCampaign(slug);
|
|
3649
3709
|
if (campaign) {
|
|
3650
3710
|
await this.#koniState.dbService.upsertCampaign({
|
|
@@ -3854,6 +3914,7 @@ class KoniExtension {
|
|
|
3854
3914
|
chainType,
|
|
3855
3915
|
extrinsic,
|
|
3856
3916
|
extrinsicType,
|
|
3917
|
+
isDutch,
|
|
3857
3918
|
isPermit,
|
|
3858
3919
|
transferNativeAmount,
|
|
3859
3920
|
txChain,
|
|
@@ -3910,6 +3971,24 @@ class KoniExtension {
|
|
|
3910
3971
|
step
|
|
3911
3972
|
});
|
|
3912
3973
|
}
|
|
3974
|
+
if (isDutch) {
|
|
3975
|
+
return await this.#koniState.transactionService.handleDutchTransaction({
|
|
3976
|
+
address,
|
|
3977
|
+
chain: txChain,
|
|
3978
|
+
transaction: extrinsic,
|
|
3979
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
3980
|
+
data: txData,
|
|
3981
|
+
extrinsicType,
|
|
3982
|
+
// change this depends on step
|
|
3983
|
+
chainType,
|
|
3984
|
+
resolveOnDone: !isLastStep,
|
|
3985
|
+
transferNativeAmount,
|
|
3986
|
+
...this.createPassConfirmationParams(isPassConfirmation),
|
|
3987
|
+
errorOnTimeOut,
|
|
3988
|
+
eventsHandler,
|
|
3989
|
+
step
|
|
3990
|
+
});
|
|
3991
|
+
}
|
|
3913
3992
|
return await this.#koniState.transactionService.handleTransaction({
|
|
3914
3993
|
address,
|
|
3915
3994
|
chain: txChain,
|
|
@@ -4160,8 +4239,8 @@ class KoniExtension {
|
|
|
4160
4239
|
resolve();
|
|
4161
4240
|
}
|
|
4162
4241
|
};
|
|
4163
|
-
this.#koniState.balanceService.subscribeTransferableBalance(address, waitXcmData.chain, waitXcmData.token, waitXcmData.nextTxType, onRs).then(
|
|
4164
|
-
let [_unsub, rs] =
|
|
4242
|
+
this.#koniState.balanceService.subscribeTransferableBalance(address, waitXcmData.chain, waitXcmData.token, waitXcmData.nextTxType, onRs).then(_ref73 => {
|
|
4243
|
+
let [_unsub, rs] = _ref73;
|
|
4165
4244
|
unsub = _unsub;
|
|
4166
4245
|
onRs(rs);
|
|
4167
4246
|
}).catch(console.error);
|
|
@@ -4323,6 +4402,8 @@ class KoniExtension {
|
|
|
4323
4402
|
return this.getAuthListV2();
|
|
4324
4403
|
case 'pri(authorize.toggle)':
|
|
4325
4404
|
return this.toggleAuthorization2(request);
|
|
4405
|
+
case 'pri(authorize.switchCurrentNetwork)':
|
|
4406
|
+
return this.switchCurrentNetworkAuthorization(request);
|
|
4326
4407
|
case 'pri(settings.changeBalancesVisibility)':
|
|
4327
4408
|
return await this.toggleBalancesVisibility();
|
|
4328
4409
|
|