@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
|
@@ -98,6 +98,11 @@ export interface ResultResolver {
|
|
|
98
98
|
result: boolean;
|
|
99
99
|
accounts: string[];
|
|
100
100
|
}
|
|
101
|
+
export interface RequestSwitchCurrentNetworkAuthorization {
|
|
102
|
+
url: string;
|
|
103
|
+
networkKey: string;
|
|
104
|
+
authSwitchNetworkType: AccountAuthType;
|
|
105
|
+
}
|
|
101
106
|
export declare enum StakingType {
|
|
102
107
|
NOMINATED = "nominated",
|
|
103
108
|
POOLED = "pooled",
|
|
@@ -903,6 +908,13 @@ export interface EvmSendTransactionRequest extends TransactionConfig, EvmSignReq
|
|
|
903
908
|
isToContract: boolean;
|
|
904
909
|
errors?: ErrorValidation[];
|
|
905
910
|
}
|
|
911
|
+
export interface SubmitApiRequest extends EvmSignRequest {
|
|
912
|
+
id: string;
|
|
913
|
+
type: string;
|
|
914
|
+
payload: unknown;
|
|
915
|
+
errors?: ErrorValidation[];
|
|
916
|
+
processId?: string;
|
|
917
|
+
}
|
|
906
918
|
export declare enum CardanoProviderErrorType {
|
|
907
919
|
INVALID_REQUEST = "INVALID_REQUEST",
|
|
908
920
|
REFUSED_REQUEST = "REFUSED_REQUEST",
|
|
@@ -1014,6 +1026,7 @@ export interface ConfirmationDefinitions {
|
|
|
1014
1026
|
evmSendTransactionRequest: [ConfirmationsQueueItem<EvmSendTransactionRequest>, ConfirmationResult<string>];
|
|
1015
1027
|
evmWatchTransactionRequest: [ConfirmationsQueueItem<EvmWatchTransactionRequest>, ConfirmationResult<string>];
|
|
1016
1028
|
errorConnectNetwork: [ConfirmationsQueueItem<ErrorNetworkConnection>, ConfirmationResult<null>];
|
|
1029
|
+
submitApiRequest: [ConfirmationsQueueItem<SubmitApiRequest>, ConfirmationResult<string>];
|
|
1017
1030
|
}
|
|
1018
1031
|
export interface ConfirmationDefinitionsTon {
|
|
1019
1032
|
tonSignatureRequest: [ConfirmationsQueueItem<TonSignatureRequest>, ConfirmationResult<string>];
|
package/background/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { KeyringPairs$Json } from '@subwallet/ui-keyring/types';
|
|
|
4
4
|
import type { JsonRpcResponse } from '@polkadot/rpc-provider/types';
|
|
5
5
|
import type { SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types';
|
|
6
6
|
import type { HexString } from '@polkadot/util/types';
|
|
7
|
-
import { KoniRequestSignatures, NetworkJson } from '@subwallet/extension-base/background/KoniTypes';
|
|
7
|
+
import { KoniRequestSignatures, NetworkJson, RequestSwitchCurrentNetworkAuthorization } from '@subwallet/extension-base/background/KoniTypes';
|
|
8
8
|
import { AuthUrls } from '@subwallet/extension-base/services/request-service/types';
|
|
9
9
|
import { AccountJson } from '@subwallet/extension-base/types';
|
|
10
10
|
import { TypeRegistry } from '@polkadot/types';
|
|
@@ -68,6 +68,7 @@ export interface RequestSignatures extends KoniRequestSignatures {
|
|
|
68
68
|
'pri(authorize.reject)': [RequestAuthorizeReject, boolean];
|
|
69
69
|
'pri(authorize.requests)': [RequestAuthorizeSubscribe, boolean, AuthorizeRequest[]];
|
|
70
70
|
'pri(authorize.toggle)': [string, ResponseAuthorizeList];
|
|
71
|
+
'pri(authorize.switchCurrentNetwork)': [RequestSwitchCurrentNetworkAuthorization, ResponseAuthorizeList];
|
|
71
72
|
'pri(derivation.create)': [RequestDeriveCreate, boolean];
|
|
72
73
|
'pri(derivation.validate)': [RequestDeriveValidate, ResponseDeriveValidate];
|
|
73
74
|
'pri(json.batchRestore)': [RequestBatchRestore, void];
|
|
@@ -24,6 +24,7 @@ var _TransactionError = require("@subwallet/extension-base/background/errors/Tra
|
|
|
24
24
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
25
25
|
var _types = require("@subwallet/extension-base/types");
|
|
26
26
|
var _utils = require("@subwallet/extension-base/utils");
|
|
27
|
+
var _cardano = require("@subwallet/extension-base/utils/cardano");
|
|
27
28
|
var _parseTransaction = require("@subwallet/extension-base/utils/eth/parseTransaction");
|
|
28
29
|
var _getId = require("@subwallet/extension-base/utils/getId");
|
|
29
30
|
var _keyring = require("@subwallet/keyring");
|
|
@@ -567,8 +568,10 @@ function validationAuthWCMiddleware(koni, url, payload, topic) {
|
|
|
567
568
|
async function validationCardanoSignDataMiddleware(koni, url, payload_) {
|
|
568
569
|
const {
|
|
569
570
|
address,
|
|
571
|
+
authInfo,
|
|
570
572
|
errors,
|
|
571
|
-
pair: pair_
|
|
573
|
+
pair: pair_,
|
|
574
|
+
type
|
|
572
575
|
} = payload_;
|
|
573
576
|
const payload = payload_.payloadAfterValidated;
|
|
574
577
|
const {
|
|
@@ -590,6 +593,15 @@ async function validationCardanoSignDataMiddleware(koni, url, payload_) {
|
|
|
590
593
|
if (!(0, _keyring.isCardanoAddress)(address)) {
|
|
591
594
|
handleError('Not found cardano address');
|
|
592
595
|
}
|
|
596
|
+
const currentCardanoNetwork = koni.requestService.getDAppChainInfo({
|
|
597
|
+
autoActive: true,
|
|
598
|
+
accessType: 'cardano',
|
|
599
|
+
defaultChain: authInfo === null || authInfo === void 0 ? void 0 : authInfo.currentNetworkMap[type],
|
|
600
|
+
url
|
|
601
|
+
});
|
|
602
|
+
if (!(0, _cardano.validateAddressNetwork)(address, currentCardanoNetwork)) {
|
|
603
|
+
handleError('Invalid address network');
|
|
604
|
+
}
|
|
593
605
|
const pair = pair_ || _uiKeyring.keyring.getPair(address);
|
|
594
606
|
if (!(pair !== null && pair !== void 0 && pair.meta.isExtneral)) {
|
|
595
607
|
canSign = true;
|