@subwallet/extension-base 0.4.5-0 → 0.4.7-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 +185 -5
- package/background/handlers/State.d.ts +3 -1
- package/background/handlers/State.js +28 -6
- package/background/types.d.ts +11 -4
- package/cjs/background/handlers/State.js +28 -6
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/Accounts.js +5 -2
- package/package.json +7 -5
- package/packageInfo.js +1 -1
- package/page/Accounts.js +5 -2
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { AuthUrls, Resolver } from '@subwallet/extension-base/background/handlers/State';
|
|
2
|
-
import { AccountJson, AuthorizeRequest, RequestAccountList, RequestAccountSubscribe, RequestAuthorizeReject, RequestAuthorizeSubscribe, RequestAuthorizeTab, RequestCurrentAccountAddress, ResponseAuthorizeList, ResponseJsonGetAccountInfo, SeedLengths } from '@subwallet/extension-base/background/types';
|
|
2
|
+
import { AccountAuthType, AccountJson, AuthorizeRequest, RequestAccountList, RequestAccountSubscribe, RequestAuthorizeCancel, RequestAuthorizeReject, RequestAuthorizeSubscribe, RequestAuthorizeTab, RequestCurrentAccountAddress, ResponseAuthorizeList, ResponseJsonGetAccountInfo, SeedLengths } from '@subwallet/extension-base/background/types';
|
|
3
3
|
import { InjectedAccount, MetadataDefBase } from '@subwallet/extension-inject/types';
|
|
4
4
|
import Web3 from 'web3';
|
|
5
|
+
import { RequestArguments, TransactionConfig } from 'web3-core';
|
|
6
|
+
import { JsonRpcPayload, JsonRpcResponse } from 'web3-core-helpers';
|
|
5
7
|
import { ApiPromise } from '@polkadot/api';
|
|
6
8
|
import { SubmittableExtrinsicFunction } from '@polkadot/api/promise/types';
|
|
7
9
|
import { KeyringPair$Json } from '@polkadot/keyring/types';
|
|
@@ -30,6 +32,7 @@ export interface AuthRequestV2 extends Resolver<ResultResolver> {
|
|
|
30
32
|
idStr: string;
|
|
31
33
|
request: RequestAuthorizeTab;
|
|
32
34
|
url: string;
|
|
35
|
+
accountAuthType: AccountAuthType;
|
|
33
36
|
}
|
|
34
37
|
export interface RequestAuthorizeApproveV2 {
|
|
35
38
|
id: string;
|
|
@@ -72,6 +75,8 @@ export interface StakingItem {
|
|
|
72
75
|
name: string;
|
|
73
76
|
chainId: string;
|
|
74
77
|
balance?: string;
|
|
78
|
+
activeBalance?: string;
|
|
79
|
+
unlockingBalance?: string;
|
|
75
80
|
nativeToken: string;
|
|
76
81
|
unit?: string;
|
|
77
82
|
state: APIItemState;
|
|
@@ -243,7 +248,9 @@ export interface NetworkJson {
|
|
|
243
248
|
blockExplorer?: string;
|
|
244
249
|
dependencies?: string[];
|
|
245
250
|
getStakingOnChain?: boolean;
|
|
251
|
+
supportBonding?: boolean;
|
|
246
252
|
apiStatus?: NETWORK_STATUS;
|
|
253
|
+
requestId?: string;
|
|
247
254
|
}
|
|
248
255
|
export interface DonateInfo {
|
|
249
256
|
key: string;
|
|
@@ -295,6 +302,7 @@ export declare type TokenInfo = {
|
|
|
295
302
|
export interface AccountsWithCurrentAddress {
|
|
296
303
|
accounts: AccountJson[];
|
|
297
304
|
currentAddress?: string;
|
|
305
|
+
currentGenesisHash?: string | null;
|
|
298
306
|
isShowBalance?: boolean;
|
|
299
307
|
allAccountLogo?: string;
|
|
300
308
|
}
|
|
@@ -303,6 +311,7 @@ export interface OptionInputAddress {
|
|
|
303
311
|
}
|
|
304
312
|
export interface CurrentAccountInfo {
|
|
305
313
|
address: string;
|
|
314
|
+
currentGenesisHash: string | null;
|
|
306
315
|
}
|
|
307
316
|
export interface RequestSettingsType {
|
|
308
317
|
isShowBalance: boolean;
|
|
@@ -570,6 +579,7 @@ export interface CustomEvmToken {
|
|
|
570
579
|
type: 'erc20' | 'erc721';
|
|
571
580
|
isCustom?: boolean;
|
|
572
581
|
isDeleted?: boolean;
|
|
582
|
+
image?: string;
|
|
573
583
|
}
|
|
574
584
|
export interface EvmTokenJson {
|
|
575
585
|
erc20: CustomEvmToken[];
|
|
@@ -641,7 +651,171 @@ export interface CrossChainRelation {
|
|
|
641
651
|
type: ChainRelationType;
|
|
642
652
|
relationMap: Record<string, ChainRelationInfo>;
|
|
643
653
|
}
|
|
654
|
+
export declare type RequestEvmEvents = null;
|
|
655
|
+
export declare type EvmEventType = 'connect' | 'disconnect' | 'accountsChanged' | 'chainChanged' | 'message' | 'data' | 'reconnect' | 'error';
|
|
656
|
+
export declare type EvmAccountsChangedPayload = string[];
|
|
657
|
+
export declare type EvmChainChangedPayload = string;
|
|
658
|
+
export declare type EvmConnectPayload = {
|
|
659
|
+
chainId: EvmChainChangedPayload;
|
|
660
|
+
};
|
|
661
|
+
export declare type EvmDisconnectPayload = unknown;
|
|
662
|
+
export interface EvmEvent {
|
|
663
|
+
type: EvmEventType;
|
|
664
|
+
payload: EvmAccountsChangedPayload | EvmChainChangedPayload | EvmConnectPayload | EvmDisconnectPayload;
|
|
665
|
+
}
|
|
666
|
+
export interface EvmAppState {
|
|
667
|
+
networkKey?: string;
|
|
668
|
+
chainId?: string;
|
|
669
|
+
isConnected?: boolean;
|
|
670
|
+
web3?: Web3;
|
|
671
|
+
listenEvents?: string[];
|
|
672
|
+
}
|
|
673
|
+
export declare type RequestEvmProviderSend = JsonRpcPayload;
|
|
674
|
+
export interface ResponseEvmProviderSend {
|
|
675
|
+
error: (Error | null);
|
|
676
|
+
result?: JsonRpcResponse;
|
|
677
|
+
}
|
|
678
|
+
export interface EvmProviderRpcErrorInterface extends Error {
|
|
679
|
+
message: string;
|
|
680
|
+
code: number;
|
|
681
|
+
data?: unknown;
|
|
682
|
+
}
|
|
683
|
+
export declare type EvmRpcErrorHelperMap = Record<'USER_REJECTED_REQUEST' | 'UNAUTHORIZED' | 'UNSUPPORTED_METHOD' | 'DISCONNECTED' | 'CHAIN_DISCONNECTED' | 'INVALID_PARAMS' | 'INTERNAL_ERROR', [number, string]>;
|
|
684
|
+
export interface EvmSendTransactionParams {
|
|
685
|
+
from: string;
|
|
686
|
+
to?: string;
|
|
687
|
+
value?: string | number;
|
|
688
|
+
gasLimit?: string | number;
|
|
689
|
+
maxPriorityFeePerGas?: string | number;
|
|
690
|
+
maxFeePerGas?: string | number;
|
|
691
|
+
gasPrice?: string | number;
|
|
692
|
+
data?: string;
|
|
693
|
+
}
|
|
694
|
+
export interface SwitchNetworkRequest {
|
|
695
|
+
networkKey: string;
|
|
696
|
+
address?: string;
|
|
697
|
+
}
|
|
698
|
+
export interface EvmSignatureRequest {
|
|
699
|
+
address: string;
|
|
700
|
+
type: string;
|
|
701
|
+
payload: unknown;
|
|
702
|
+
}
|
|
703
|
+
export interface ConfirmationsQueueItemOptions {
|
|
704
|
+
requiredPassword?: boolean;
|
|
705
|
+
address?: string;
|
|
706
|
+
networkKey?: string;
|
|
707
|
+
}
|
|
708
|
+
export interface ConfirmationsQueueItem<T> extends ConfirmationsQueueItemOptions {
|
|
709
|
+
id: string;
|
|
710
|
+
url: string;
|
|
711
|
+
payload: T;
|
|
712
|
+
payloadJson: string;
|
|
713
|
+
}
|
|
714
|
+
export interface ConfirmationResult<T> {
|
|
715
|
+
id: string;
|
|
716
|
+
isApproved: boolean;
|
|
717
|
+
url?: string;
|
|
718
|
+
payload?: T;
|
|
719
|
+
password?: string;
|
|
720
|
+
}
|
|
721
|
+
export interface EvmSendTransactionRequest extends TransactionConfig {
|
|
722
|
+
estimateGas: string;
|
|
723
|
+
}
|
|
724
|
+
export interface ConfirmationDefinitions {
|
|
725
|
+
addNetworkRequest: [ConfirmationsQueueItem<NetworkJson>, ConfirmationResult<NetworkJson>];
|
|
726
|
+
addTokenRequest: [ConfirmationsQueueItem<CustomEvmToken>, ConfirmationResult<boolean>];
|
|
727
|
+
switchNetworkRequest: [ConfirmationsQueueItem<SwitchNetworkRequest>, ConfirmationResult<boolean>];
|
|
728
|
+
evmSignatureRequest: [ConfirmationsQueueItem<EvmSignatureRequest>, ConfirmationResult<string>];
|
|
729
|
+
evmSendTransactionRequest: [ConfirmationsQueueItem<EvmSendTransactionRequest>, ConfirmationResult<boolean>];
|
|
730
|
+
}
|
|
731
|
+
export declare type ConfirmationType = keyof ConfirmationDefinitions;
|
|
732
|
+
export declare type ConfirmationsQueue = {
|
|
733
|
+
[ConfirmationType in keyof ConfirmationDefinitions]: Record<string, ConfirmationDefinitions[ConfirmationType][0]>;
|
|
734
|
+
};
|
|
735
|
+
export declare type RequestConfirmationsSubscribe = null;
|
|
736
|
+
export declare type RequestConfirmationComplete = {
|
|
737
|
+
[ConfirmationType in keyof ConfirmationDefinitions]?: ConfirmationDefinitions[ConfirmationType][1];
|
|
738
|
+
};
|
|
739
|
+
export interface ValidatorInfo {
|
|
740
|
+
address: string;
|
|
741
|
+
totalStake: number;
|
|
742
|
+
ownStake: number;
|
|
743
|
+
otherStake: number;
|
|
744
|
+
nominatorCount: number;
|
|
745
|
+
commission: number;
|
|
746
|
+
expectedReturn: number;
|
|
747
|
+
blocked: boolean;
|
|
748
|
+
identity?: string;
|
|
749
|
+
isVerified: boolean;
|
|
750
|
+
minBond: number;
|
|
751
|
+
isNominated: boolean;
|
|
752
|
+
}
|
|
753
|
+
export interface BondingOptionInfo {
|
|
754
|
+
isBondedBefore: boolean;
|
|
755
|
+
era: number;
|
|
756
|
+
maxNominations: number;
|
|
757
|
+
maxNominatorPerValidator: number;
|
|
758
|
+
validators: ValidatorInfo[];
|
|
759
|
+
bondedValidators: string[];
|
|
760
|
+
}
|
|
761
|
+
export interface ChainBondingBasics {
|
|
762
|
+
stakedReturn: number;
|
|
763
|
+
isMaxNominators: boolean;
|
|
764
|
+
}
|
|
765
|
+
export interface BasicTxInfo {
|
|
766
|
+
fee: string;
|
|
767
|
+
balanceError: boolean;
|
|
768
|
+
}
|
|
769
|
+
export interface BondingSubmitParams {
|
|
770
|
+
networkKey: string;
|
|
771
|
+
nominatorAddress: string;
|
|
772
|
+
amount: number;
|
|
773
|
+
validatorInfo: ValidatorInfo;
|
|
774
|
+
password?: string;
|
|
775
|
+
isBondedBefore: boolean;
|
|
776
|
+
bondedValidators: string[];
|
|
777
|
+
}
|
|
778
|
+
export interface BasicTxResponse {
|
|
779
|
+
passwordError?: string | null;
|
|
780
|
+
callHash?: string;
|
|
781
|
+
status?: boolean;
|
|
782
|
+
transactionHash?: string;
|
|
783
|
+
txError?: boolean;
|
|
784
|
+
}
|
|
785
|
+
export interface BondingOptionParams {
|
|
786
|
+
networkKey: string;
|
|
787
|
+
address: string;
|
|
788
|
+
}
|
|
789
|
+
export interface UnbondingSubmitParams {
|
|
790
|
+
amount: number;
|
|
791
|
+
networkKey: string;
|
|
792
|
+
address: string;
|
|
793
|
+
password?: string;
|
|
794
|
+
}
|
|
795
|
+
export interface UnlockingStakeParams {
|
|
796
|
+
address: string;
|
|
797
|
+
networkKey: string;
|
|
798
|
+
}
|
|
799
|
+
export interface UnlockingStakeInfo {
|
|
800
|
+
nextWithdrawal: number;
|
|
801
|
+
redeemable: number;
|
|
802
|
+
nextWithdrawalAmount: number;
|
|
803
|
+
}
|
|
804
|
+
export interface StakeWithdrawalParams {
|
|
805
|
+
address: string;
|
|
806
|
+
networkKey: string;
|
|
807
|
+
password?: string;
|
|
808
|
+
}
|
|
644
809
|
export interface KoniRequestSignatures {
|
|
810
|
+
'pri(unbonding.submitWithdrawal)': [StakeWithdrawalParams, BasicTxResponse, BasicTxResponse];
|
|
811
|
+
'pri(unbonding.withdrawalTxInfo)': [StakeWithdrawalParams, BasicTxInfo];
|
|
812
|
+
'pri(unbonding.unlockingInfo)': [UnlockingStakeParams, UnlockingStakeInfo];
|
|
813
|
+
'pri(unbonding.submitTransaction)': [UnbondingSubmitParams, BasicTxResponse, BasicTxResponse];
|
|
814
|
+
'pri(unbonding.txInfo)': [UnbondingSubmitParams, BasicTxInfo];
|
|
815
|
+
'pri(bonding.txInfo)': [BondingSubmitParams, BasicTxInfo];
|
|
816
|
+
'pri(bonding.submitTransaction)': [BondingSubmitParams, BasicTxResponse, BasicTxResponse];
|
|
817
|
+
'pri(bonding.getChainBondingBasics)': [NetworkJson[], Record<string, ChainBondingBasics>];
|
|
818
|
+
'pri(bonding.getBondingOptions)': [BondingOptionParams, BondingOptionInfo];
|
|
645
819
|
'pri(networkMap.recoverDotSama)': [string, boolean];
|
|
646
820
|
'pri(substrateNft.submitTransaction)': [SubstrateNftSubmitTransaction, NftTransactionResponse, NftTransactionResponse];
|
|
647
821
|
'pri(substrateNft.getTransaction)': [SubstrateNftTransactionRequest, SubstrateNftTransaction];
|
|
@@ -690,6 +864,7 @@ export interface KoniRequestSignatures {
|
|
|
690
864
|
'pri(authorize.forgetSite)': [RequestForgetSite, boolean, AuthUrls];
|
|
691
865
|
'pri(authorize.forgetAllSite)': [null, boolean, AuthUrls];
|
|
692
866
|
'pri(authorize.rejectV2)': [RequestAuthorizeReject, boolean];
|
|
867
|
+
'pri(authorize.cancelV2)': [RequestAuthorizeCancel, boolean];
|
|
693
868
|
'pri(seed.createV2)': [RequestSeedCreateV2, ResponseSeedCreateV2];
|
|
694
869
|
'pri(seed.validateV2)': [RequestSeedValidateV2, ResponseSeedValidateV2];
|
|
695
870
|
'pri(privateKey.validateV2)': [RequestSeedValidateV2, ResponsePrivateKeyValidateV2];
|
|
@@ -707,10 +882,10 @@ export interface KoniRequestSignatures {
|
|
|
707
882
|
'pri(accounts.saveRecent)': [RequestSaveRecentAccount, SingleAddress];
|
|
708
883
|
'pri(accounts.triggerSubscription)': [null, boolean];
|
|
709
884
|
'pri(currentAccount.saveAddress)': [RequestCurrentAccountAddress, boolean, CurrentAccountInfo];
|
|
710
|
-
'pri(
|
|
711
|
-
'pri(
|
|
712
|
-
'pri(
|
|
713
|
-
'pri(
|
|
885
|
+
'pri(settings.changeBalancesVisibility)': [null, boolean, ResponseSettingsType];
|
|
886
|
+
'pri(settings.subscribe)': [null, ResponseSettingsType, ResponseSettingsType];
|
|
887
|
+
'pri(settings.saveAccountAllLogo)': [string, boolean, ResponseSettingsType];
|
|
888
|
+
'pri(settings.saveTheme)': [ThemeTypes, boolean, ResponseSettingsType];
|
|
714
889
|
'pri(chainRegistry.getSubscription)': [null, Record<string, ChainRegistry>, Record<string, ChainRegistry>];
|
|
715
890
|
'pri(transaction.history.getSubscription)': [null, Record<string, TransactionHistoryItemType[]>, Record<string, TransactionHistoryItemType[]>];
|
|
716
891
|
'pri(transaction.history.add)': [RequestTransactionHistoryAdd, boolean, TransactionHistoryItemType[]];
|
|
@@ -719,8 +894,13 @@ export interface KoniRequestSignatures {
|
|
|
719
894
|
'pri(transfer.getExistentialDeposit)': [RequestTransferExistentialDeposit, string];
|
|
720
895
|
'pri(subscription.cancel)': [string, boolean];
|
|
721
896
|
'pri(freeBalance.subscribe)': [RequestFreeBalance, string, string];
|
|
897
|
+
'pri(confirmations.subscribe)': [RequestConfirmationsSubscribe, ConfirmationsQueue, ConfirmationsQueue];
|
|
898
|
+
'pri(confirmations.complete)': [RequestConfirmationComplete, boolean];
|
|
722
899
|
'pub(utils.getRandom)': [RandomTestRequest, number];
|
|
723
900
|
'pub(accounts.listV2)': [RequestAccountList, InjectedAccount[]];
|
|
724
901
|
'pub(accounts.subscribeV2)': [RequestAccountSubscribe, boolean, InjectedAccount[]];
|
|
902
|
+
'evm(events.subscribe)': [RequestEvmEvents, boolean, EvmEvent];
|
|
903
|
+
'evm(request)': [RequestArguments, unknown];
|
|
904
|
+
'evm(provider.send)': [RequestEvmProviderSend, string | number, ResponseEvmProviderSend];
|
|
725
905
|
}
|
|
726
906
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="chrome" />
|
|
2
2
|
import type { MetadataDef, ProviderMeta } from '@subwallet/extension-inject/types';
|
|
3
3
|
import type { JsonRpcResponse, ProviderInterface, ProviderInterfaceCallback } from '@polkadot/rpc-provider/types';
|
|
4
|
-
import type { AccountJson, AuthorizeRequest, MetadataRequest, RequestAuthorizeTab, RequestRpcSend, RequestRpcSubscribe, RequestRpcUnsubscribe, RequestSign, ResponseRpcListProviders, ResponseSigning, SigningRequest } from '../types';
|
|
4
|
+
import type { AccountAuthType, AccountJson, AuthorizeRequest, MetadataRequest, RequestAuthorizeTab, RequestRpcSend, RequestRpcSubscribe, RequestRpcUnsubscribe, RequestSign, ResponseRpcListProviders, ResponseSigning, SigningRequest } from '../types';
|
|
5
5
|
import { BehaviorSubject } from 'rxjs';
|
|
6
6
|
export interface Resolver<T> {
|
|
7
7
|
reject: (error: Error) => void;
|
|
@@ -20,6 +20,7 @@ export interface AuthUrlInfo {
|
|
|
20
20
|
isAllowed: boolean;
|
|
21
21
|
origin: string;
|
|
22
22
|
url: string;
|
|
23
|
+
accountAuthType?: AccountAuthType;
|
|
23
24
|
isAllowedMap: Record<string, boolean>;
|
|
24
25
|
}
|
|
25
26
|
interface MetaRequest extends Resolver<boolean> {
|
|
@@ -56,6 +57,7 @@ export default class State {
|
|
|
56
57
|
get allMetaRequests(): MetadataRequest[];
|
|
57
58
|
get allSignRequests(): SigningRequest[];
|
|
58
59
|
get authUrls(): AuthUrls;
|
|
60
|
+
protected getPopup(): number[];
|
|
59
61
|
protected popupClose(): void;
|
|
60
62
|
protected popupOpen(): void;
|
|
61
63
|
private authComplete;
|
|
@@ -12,8 +12,6 @@ const NOTIFICATION_URL = chrome.extension.getURL('notification.html');
|
|
|
12
12
|
const POPUP_WINDOW_OPTS = {
|
|
13
13
|
focused: true,
|
|
14
14
|
height: 621,
|
|
15
|
-
left: 150,
|
|
16
|
-
top: 150,
|
|
17
15
|
type: 'popup',
|
|
18
16
|
url: NOTIFICATION_URL,
|
|
19
17
|
width: 460
|
|
@@ -157,17 +155,41 @@ export default class State {
|
|
|
157
155
|
return this.#authUrls;
|
|
158
156
|
}
|
|
159
157
|
|
|
158
|
+
getPopup() {
|
|
159
|
+
return this.#windows;
|
|
160
|
+
}
|
|
161
|
+
|
|
160
162
|
popupClose() {
|
|
161
163
|
this.#windows.forEach(id => withErrorLog(() => chrome.windows.remove(id)));
|
|
162
164
|
this.#windows = [];
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
popupOpen() {
|
|
166
|
-
this.#notification !== 'extension'
|
|
167
|
-
if (window) {
|
|
168
|
-
|
|
168
|
+
if (this.#notification !== 'extension') {
|
|
169
|
+
if (this.#notification === 'window') {
|
|
170
|
+
chrome.windows.create(NORMAL_WINDOW_OPTS, window => {
|
|
171
|
+
if (window) {
|
|
172
|
+
this.#windows.push(window.id || 0);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
169
175
|
}
|
|
170
|
-
|
|
176
|
+
|
|
177
|
+
chrome.windows.getCurrent(win => {
|
|
178
|
+
const popupOptions = { ...POPUP_WINDOW_OPTS
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
if (win) {
|
|
182
|
+
popupOptions.left = (win.left || 0) + (win.width || 0) - (POPUP_WINDOW_OPTS.width || 0) - 20;
|
|
183
|
+
popupOptions.top = (win.top || 0) + 80;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
chrome.windows.create(popupOptions, window => {
|
|
187
|
+
if (window) {
|
|
188
|
+
this.#windows.push(window.id || 0);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
}
|
|
171
193
|
}
|
|
172
194
|
|
|
173
195
|
authComplete = (id, resolve, reject) => {
|
package/background/types.d.ts
CHANGED
|
@@ -38,9 +38,6 @@ export interface AccountsWithCurrentAddress {
|
|
|
38
38
|
accounts: AccountJson[];
|
|
39
39
|
currentAddress?: string;
|
|
40
40
|
}
|
|
41
|
-
export interface CurrentAccountInfo {
|
|
42
|
-
address: string;
|
|
43
|
-
}
|
|
44
41
|
export declare type AccountWithChildren = AccountJson & {
|
|
45
42
|
children?: AccountWithChildren[];
|
|
46
43
|
};
|
|
@@ -138,8 +135,12 @@ export interface TransportRequestMessage<TMessageType extends MessageTypes> {
|
|
|
138
135
|
origin: 'page' | 'extension' | string;
|
|
139
136
|
request: RequestTypes[TMessageType];
|
|
140
137
|
}
|
|
138
|
+
export declare type AccountAuthType = 'substrate' | 'evm' | 'both';
|
|
141
139
|
export interface RequestAuthorizeTab {
|
|
142
140
|
origin: string;
|
|
141
|
+
accountAuthType?: AccountAuthType;
|
|
142
|
+
allowedAccounts?: string[];
|
|
143
|
+
reConfirm?: boolean;
|
|
143
144
|
}
|
|
144
145
|
export interface RequestAuthorizeApprove {
|
|
145
146
|
id: string;
|
|
@@ -147,6 +148,9 @@ export interface RequestAuthorizeApprove {
|
|
|
147
148
|
export interface RequestAuthorizeReject {
|
|
148
149
|
id: string;
|
|
149
150
|
}
|
|
151
|
+
export interface RequestAuthorizeCancel {
|
|
152
|
+
id: string;
|
|
153
|
+
}
|
|
150
154
|
export declare type RequestAuthorizeSubscribe = null;
|
|
151
155
|
export interface RequestMetadataApprove {
|
|
152
156
|
id: string;
|
|
@@ -226,8 +230,11 @@ export interface RequestAccountBatchExport {
|
|
|
226
230
|
}
|
|
227
231
|
export interface RequestAccountList {
|
|
228
232
|
anyType?: boolean;
|
|
233
|
+
accountAuthType?: AccountAuthType;
|
|
234
|
+
}
|
|
235
|
+
export interface RequestAccountSubscribe {
|
|
236
|
+
accountAuthType?: AccountAuthType;
|
|
229
237
|
}
|
|
230
|
-
export declare type RequestAccountSubscribe = null;
|
|
231
238
|
export interface RequestRpcSend {
|
|
232
239
|
method: string;
|
|
233
240
|
params: unknown[];
|
|
@@ -29,8 +29,6 @@ const NOTIFICATION_URL = chrome.extension.getURL('notification.html');
|
|
|
29
29
|
const POPUP_WINDOW_OPTS = {
|
|
30
30
|
focused: true,
|
|
31
31
|
height: 621,
|
|
32
|
-
left: 150,
|
|
33
|
-
top: 150,
|
|
34
32
|
type: 'popup',
|
|
35
33
|
url: NOTIFICATION_URL,
|
|
36
34
|
width: 460
|
|
@@ -192,17 +190,41 @@ class State {
|
|
|
192
190
|
return this.#authUrls;
|
|
193
191
|
}
|
|
194
192
|
|
|
193
|
+
getPopup() {
|
|
194
|
+
return this.#windows;
|
|
195
|
+
}
|
|
196
|
+
|
|
195
197
|
popupClose() {
|
|
196
198
|
this.#windows.forEach(id => (0, _helpers.withErrorLog)(() => chrome.windows.remove(id)));
|
|
197
199
|
this.#windows = [];
|
|
198
200
|
}
|
|
199
201
|
|
|
200
202
|
popupOpen() {
|
|
201
|
-
this.#notification !== 'extension'
|
|
202
|
-
if (window) {
|
|
203
|
-
|
|
203
|
+
if (this.#notification !== 'extension') {
|
|
204
|
+
if (this.#notification === 'window') {
|
|
205
|
+
chrome.windows.create(NORMAL_WINDOW_OPTS, window => {
|
|
206
|
+
if (window) {
|
|
207
|
+
this.#windows.push(window.id || 0);
|
|
208
|
+
}
|
|
209
|
+
});
|
|
204
210
|
}
|
|
205
|
-
|
|
211
|
+
|
|
212
|
+
chrome.windows.getCurrent(win => {
|
|
213
|
+
const popupOptions = { ...POPUP_WINDOW_OPTS
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
if (win) {
|
|
217
|
+
popupOptions.left = (win.left || 0) + (win.width || 0) - (POPUP_WINDOW_OPTS.width || 0) - 20;
|
|
218
|
+
popupOptions.top = (win.top || 0) + 80;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
chrome.windows.create(popupOptions, window => {
|
|
222
|
+
if (window) {
|
|
223
|
+
this.#windows.push(window.id || 0);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
}
|
|
206
228
|
}
|
|
207
229
|
|
|
208
230
|
authComplete = (id, resolve, reject) => {
|
package/cjs/packageInfo.js
CHANGED
package/cjs/page/Accounts.js
CHANGED
|
@@ -16,12 +16,15 @@ class Accounts {
|
|
|
16
16
|
|
|
17
17
|
get(anyType) {
|
|
18
18
|
return sendRequest('pub(accounts.listV2)', {
|
|
19
|
-
anyType
|
|
19
|
+
anyType,
|
|
20
|
+
accountAuthType: 'substrate'
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
subscribe(cb) {
|
|
24
|
-
sendRequest('pub(accounts.subscribeV2)',
|
|
25
|
+
sendRequest('pub(accounts.subscribeV2)', {
|
|
26
|
+
accountAuthType: 'substrate'
|
|
27
|
+
}, cb).catch(error => console.error(error));
|
|
25
28
|
return () => {// FIXME we need the ability to unsubscribe
|
|
26
29
|
};
|
|
27
30
|
}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "0.4.
|
|
20
|
+
"version": "0.4.7-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -199,12 +199,14 @@
|
|
|
199
199
|
"@polkadot/ui-settings": "^0.89.1",
|
|
200
200
|
"@polkadot/util": "^8.3.1",
|
|
201
201
|
"@polkadot/util-crypto": "^8.3.1",
|
|
202
|
-
"@subwallet/extension-chains": "^0.4.
|
|
203
|
-
"@subwallet/extension-dapp": "^0.4.
|
|
204
|
-
"@subwallet/extension-inject": "^0.4.
|
|
202
|
+
"@subwallet/extension-chains": "^0.4.7-0",
|
|
203
|
+
"@subwallet/extension-dapp": "^0.4.7-0",
|
|
204
|
+
"@subwallet/extension-inject": "^0.4.7-0",
|
|
205
205
|
"ethereumjs-tx": "^2.1.2",
|
|
206
206
|
"eventemitter3": "^4.0.7",
|
|
207
207
|
"rxjs": "^7.5.1",
|
|
208
|
-
"web3": "^1.7.
|
|
208
|
+
"web3": "^1.7.3",
|
|
209
|
+
"web3-core": "^1.7.3",
|
|
210
|
+
"web3-core-helpers": "^1.7.3"
|
|
209
211
|
}
|
|
210
212
|
}
|
package/packageInfo.js
CHANGED
|
@@ -5,5 +5,5 @@ export const packageInfo = {
|
|
|
5
5
|
name: '@subwallet/extension-base',
|
|
6
6
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
7
7
|
type: 'esm',
|
|
8
|
-
version: '0.4.
|
|
8
|
+
version: '0.4.7-0'
|
|
9
9
|
};
|
package/page/Accounts.js
CHANGED
|
@@ -9,12 +9,15 @@ export default class Accounts {
|
|
|
9
9
|
|
|
10
10
|
get(anyType) {
|
|
11
11
|
return sendRequest('pub(accounts.listV2)', {
|
|
12
|
-
anyType
|
|
12
|
+
anyType,
|
|
13
|
+
accountAuthType: 'substrate'
|
|
13
14
|
});
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
subscribe(cb) {
|
|
17
|
-
sendRequest('pub(accounts.subscribeV2)',
|
|
18
|
+
sendRequest('pub(accounts.subscribeV2)', {
|
|
19
|
+
accountAuthType: 'substrate'
|
|
20
|
+
}, cb).catch(error => console.error(error));
|
|
18
21
|
return () => {// FIXME we need the ability to unsubscribe
|
|
19
22
|
};
|
|
20
23
|
}
|