@subwallet/extension-base 1.3.73-0 → 1.3.74-1

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.
Files changed (108) hide show
  1. package/background/KoniTypes.d.ts +42 -5
  2. package/background/KoniTypes.js +14 -1
  3. package/cjs/background/KoniTypes.js +16 -2
  4. package/cjs/core/logic-validation/transfer.js +35 -57
  5. package/cjs/koni/background/handlers/Extension.js +599 -144
  6. package/cjs/koni/background/handlers/State.js +5 -2
  7. package/cjs/koni/background/handlers/Tabs.js +3 -2
  8. package/cjs/packageInfo.js +1 -1
  9. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +0 -2
  10. package/cjs/services/chain-service/handler/SubstrateApi.js +6 -1
  11. package/cjs/services/chain-service/index.js +1 -0
  12. package/cjs/services/chain-service/utils/index.js +4 -0
  13. package/cjs/services/event-service/index.js +1 -0
  14. package/cjs/services/fee-service/utils/index.js +4 -4
  15. package/cjs/services/inapp-notification-service/consts.js +4 -2
  16. package/cjs/services/inapp-notification-service/index.js +51 -6
  17. package/cjs/services/inapp-notification-service/interfaces.js +2 -0
  18. package/cjs/services/inapp-notification-service/utils/common.js +4 -0
  19. package/cjs/services/keyring-service/context/account-context.js +44 -0
  20. package/cjs/services/keyring-service/context/handlers/Multisig.js +186 -0
  21. package/cjs/services/keyring-service/context/state.js +12 -0
  22. package/cjs/services/multisig-service/index.js +627 -0
  23. package/cjs/services/multisig-service/utils.js +242 -0
  24. package/cjs/services/request-service/handler/SubstrateRequestHandler.js +25 -0
  25. package/cjs/services/request-service/index.js +5 -1
  26. package/cjs/services/storage-service/DatabaseService.js +5 -2
  27. package/cjs/services/storage-service/db-stores/InappNotification.js +20 -2
  28. package/cjs/services/substrate-proxy-service/index.js +22 -7
  29. package/cjs/services/transaction-service/helpers/index.js +8 -0
  30. package/cjs/services/transaction-service/index.js +348 -147
  31. package/cjs/services/transaction-service/types.js +18 -1
  32. package/cjs/types/account/info/keyring.js +5 -0
  33. package/cjs/types/account/info/proxy.js +1 -0
  34. package/cjs/types/multisig/index.js +14 -0
  35. package/cjs/types/transaction/error.js +9 -2
  36. package/cjs/utils/account/transform.js +28 -4
  37. package/cjs/utils/logger/Logger.js +294 -0
  38. package/cjs/utils/logger/index.js +42 -0
  39. package/cjs/utils/logger/types.js +1 -0
  40. package/core/logic-validation/transfer.d.ts +2 -2
  41. package/core/logic-validation/transfer.js +10 -32
  42. package/koni/background/handlers/Extension.d.ts +7 -0
  43. package/koni/background/handlers/Extension.js +498 -43
  44. package/koni/background/handlers/State.d.ts +2 -0
  45. package/koni/background/handlers/State.js +5 -2
  46. package/koni/background/handlers/Tabs.js +3 -2
  47. package/package.json +42 -6
  48. package/packageInfo.js +1 -1
  49. package/services/balance-service/helpers/subscribe/substrate/index.js +0 -2
  50. package/services/chain-service/handler/SubstrateApi.js +7 -2
  51. package/services/chain-service/index.js +1 -0
  52. package/services/chain-service/types.d.ts +1 -1
  53. package/services/chain-service/utils/index.js +4 -0
  54. package/services/event-service/index.d.ts +1 -0
  55. package/services/event-service/index.js +1 -0
  56. package/services/event-service/types.d.ts +1 -0
  57. package/services/fee-service/utils/index.js +4 -4
  58. package/services/inapp-notification-service/consts.d.ts +3 -1
  59. package/services/inapp-notification-service/consts.js +5 -3
  60. package/services/inapp-notification-service/index.d.ts +3 -2
  61. package/services/inapp-notification-service/index.js +51 -6
  62. package/services/inapp-notification-service/interfaces.d.ts +18 -2
  63. package/services/inapp-notification-service/interfaces.js +2 -0
  64. package/services/inapp-notification-service/utils/common.d.ts +1 -0
  65. package/services/inapp-notification-service/utils/common.js +3 -0
  66. package/services/keyring-service/context/account-context.d.ts +9 -1
  67. package/services/keyring-service/context/account-context.js +44 -0
  68. package/services/keyring-service/context/handlers/Multisig.d.ts +18 -0
  69. package/services/keyring-service/context/handlers/Multisig.js +180 -0
  70. package/services/keyring-service/context/state.d.ts +2 -0
  71. package/services/keyring-service/context/state.js +12 -0
  72. package/services/multisig-service/index.d.ts +245 -0
  73. package/services/multisig-service/index.js +620 -0
  74. package/services/multisig-service/utils.d.ts +95 -0
  75. package/services/multisig-service/utils.js +227 -0
  76. package/services/request-service/handler/SubstrateRequestHandler.d.ts +1 -0
  77. package/services/request-service/handler/SubstrateRequestHandler.js +25 -0
  78. package/services/request-service/index.d.ts +2 -1
  79. package/services/request-service/index.js +5 -1
  80. package/services/storage-service/DatabaseService.d.ts +3 -2
  81. package/services/storage-service/DatabaseService.js +5 -2
  82. package/services/storage-service/db-stores/InappNotification.d.ts +3 -2
  83. package/services/storage-service/db-stores/InappNotification.js +20 -2
  84. package/services/substrate-proxy-service/index.d.ts +4 -1
  85. package/services/substrate-proxy-service/index.js +22 -8
  86. package/services/transaction-service/helpers/index.js +8 -0
  87. package/services/transaction-service/index.d.ts +31 -0
  88. package/services/transaction-service/index.js +270 -69
  89. package/services/transaction-service/types.d.ts +28 -3
  90. package/services/transaction-service/types.js +12 -1
  91. package/types/account/info/keyring.d.ts +14 -1
  92. package/types/account/info/keyring.js +6 -0
  93. package/types/account/info/proxy.d.ts +1 -0
  94. package/types/account/info/proxy.js +1 -0
  95. package/types/multisig/index.d.ts +76 -0
  96. package/types/multisig/index.js +8 -0
  97. package/types/notification/index.d.ts +8 -0
  98. package/types/substrateProxyAccount/index.d.ts +26 -1
  99. package/types/transaction/error.d.ts +6 -1
  100. package/types/transaction/error.js +7 -1
  101. package/types/transaction/request.d.ts +0 -1
  102. package/utils/account/transform.js +28 -4
  103. package/utils/logger/Logger.d.ts +31 -0
  104. package/utils/logger/Logger.js +267 -0
  105. package/utils/logger/index.d.ts +15 -0
  106. package/utils/logger/index.js +29 -0
  107. package/utils/logger/types.d.ts +23 -0
  108. package/utils/logger/types.js +1 -0
@@ -19,6 +19,7 @@ import { KeyringService } from '@subwallet/extension-base/services/keyring-servi
19
19
  import MigrationService from '@subwallet/extension-base/services/migration-service';
20
20
  import MintCampaignService from '@subwallet/extension-base/services/mint-campaign-service';
21
21
  import MktCampaignService from '@subwallet/extension-base/services/mkt-campaign-service';
22
+ import { MultisigService } from '@subwallet/extension-base/services/multisig-service';
22
23
  import NftService from '@subwallet/extension-base/services/nft-service';
23
24
  import NotificationService from '@subwallet/extension-base/services/notification-service/NotificationService';
24
25
  import OpenGovService from '@subwallet/extension-base/services/open-gov';
@@ -84,6 +85,7 @@ export default class KoniState {
84
85
  readonly inappNotificationService: InappNotificationService;
85
86
  readonly chainOnlineService: ChainOnlineService;
86
87
  readonly openGovService: OpenGovService;
88
+ readonly multisigService: MultisigService;
87
89
  readonly substrateProxyAccountService: SubstrateProxyAccountService;
88
90
  private generalStatus;
89
91
  private waitSleeping;
@@ -28,6 +28,7 @@ import { KeyringService } from '@subwallet/extension-base/services/keyring-servi
28
28
  import MigrationService from '@subwallet/extension-base/services/migration-service';
29
29
  import MintCampaignService from '@subwallet/extension-base/services/mint-campaign-service';
30
30
  import MktCampaignService from '@subwallet/extension-base/services/mkt-campaign-service';
31
+ import { MultisigService } from '@subwallet/extension-base/services/multisig-service';
31
32
  import NftService from '@subwallet/extension-base/services/nft-service';
32
33
  import NotificationService from '@subwallet/extension-base/services/notification-service/NotificationService';
33
34
  import OpenGovService from '@subwallet/extension-base/services/open-gov';
@@ -125,6 +126,7 @@ export default class KoniState {
125
126
  this.inappNotificationService = new InappNotificationService(this.dbService, this.keyringService, this.eventService, this.chainService);
126
127
  this.chainOnlineService = new ChainOnlineService(this.chainService, this.settingService, this.eventService, this.dbService);
127
128
  this.openGovService = new OpenGovService(this);
129
+ this.multisigService = new MultisigService(this.eventService, this.chainService, this.keyringService, this.inappNotificationService);
128
130
  this.substrateProxyAccountService = new SubstrateProxyAccountService(this);
129
131
  this.subscription = new KoniSubscription(this, this.dbService);
130
132
  this.cron = new KoniCron(this, this.subscription, this.dbService);
@@ -230,6 +232,7 @@ export default class KoniState {
230
232
  await this.swapService.init();
231
233
  await this.inappNotificationService.init();
232
234
  await this.openGovService.init();
235
+ await this.multisigService.init();
233
236
 
234
237
  // this.onReady();
235
238
  this.onAccountAdd();
@@ -1663,7 +1666,7 @@ export default class KoniState {
1663
1666
  this.campaignService.stop();
1664
1667
  await Promise.all([this.cron.stop(), this.subscription.stop()]);
1665
1668
  await this.pauseAllNetworks(undefined, 'IDLE mode');
1666
- await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop(), this.inappNotificationService.stop(), this.openGovService.stop()]);
1669
+ await Promise.all([this.historyService.stop(), this.priceService.stop(), this.balanceService.stop(), this.earningService.stop(), this.swapService.stop(), this.inappNotificationService.stop(), this.openGovService.stop(), this.multisigService.stop()]);
1667
1670
 
1668
1671
  // Complete sleeping
1669
1672
  sleeping.resolve();
@@ -1719,7 +1722,7 @@ export default class KoniState {
1719
1722
  this.generalStatus = ServiceStatus.STARTING_FULL;
1720
1723
  const startingFull = createPromiseHandler();
1721
1724
  this.waitStartingFull = startingFull.promise;
1722
- await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start(), this.balanceService.start(), this.earningService.start(), this.swapService.start(), this.inappNotificationService.start(), this.openGovService.start()]);
1725
+ await Promise.all([this.cron.start(), this.subscription.start(), this.historyService.start(), this.priceService.start(), this.balanceService.start(), this.earningService.start(), this.swapService.start(), this.inappNotificationService.start(), this.openGovService.start(), this.multisigService.start()]);
1723
1726
  this.eventService.emit('general.start_full', true);
1724
1727
  this.waitStartingFull = null;
1725
1728
  this.generalStatus = ServiceStatus.STARTED_FULL;
@@ -69,10 +69,11 @@ function transformAccountsV2(accounts, anyType = false, authInfo, accountAuthTyp
69
69
  const injectedAccounts = Object.values(accounts).filter(({
70
70
  json: {
71
71
  meta: {
72
- isHidden
72
+ isHidden,
73
+ isMultisig
73
74
  }
74
75
  }
75
- }) => !isHidden).filter(authTypeFilter).filter(({
76
+ }) => !isHidden && !isMultisig).filter(authTypeFilter).filter(({
76
77
  json: {
77
78
  address
78
79
  }
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.3.73-0",
20
+ "version": "1.3.74-1",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -1386,6 +1386,11 @@
1386
1386
  "require": "./cjs/services/keyring-service/context/handlers/Modify.js",
1387
1387
  "default": "./services/keyring-service/context/handlers/Modify.js"
1388
1388
  },
1389
+ "./services/keyring-service/context/handlers/Multisig": {
1390
+ "types": "./services/keyring-service/context/handlers/Multisig.d.ts",
1391
+ "require": "./cjs/services/keyring-service/context/handlers/Multisig.js",
1392
+ "default": "./services/keyring-service/context/handlers/Multisig.js"
1393
+ },
1389
1394
  "./services/keyring-service/context/handlers/Secret": {
1390
1395
  "types": "./services/keyring-service/context/handlers/Secret.d.ts",
1391
1396
  "require": "./cjs/services/keyring-service/context/handlers/Secret.js",
@@ -1721,6 +1726,16 @@
1721
1726
  "require": "./cjs/services/mkt-campaign-service/types.js",
1722
1727
  "default": "./services/mkt-campaign-service/types.js"
1723
1728
  },
1729
+ "./services/multisig-service": {
1730
+ "types": "./services/multisig-service/index.d.ts",
1731
+ "require": "./cjs/services/multisig-service/index.js",
1732
+ "default": "./services/multisig-service/index.js"
1733
+ },
1734
+ "./services/multisig-service/utils": {
1735
+ "types": "./services/multisig-service/utils.d.ts",
1736
+ "require": "./cjs/services/multisig-service/utils.js",
1737
+ "default": "./services/multisig-service/utils.js"
1738
+ },
1724
1739
  "./services/nft-service": {
1725
1740
  "types": "./services/nft-service/index.d.ts",
1726
1741
  "require": "./cjs/services/nft-service/index.js",
@@ -2521,6 +2536,11 @@
2521
2536
  "require": "./cjs/types/metadata.js",
2522
2537
  "default": "./types/metadata.js"
2523
2538
  },
2539
+ "./types/multisig": {
2540
+ "types": "./types/multisig/index.d.ts",
2541
+ "require": "./cjs/types/multisig/index.js",
2542
+ "default": "./types/multisig/index.js"
2543
+ },
2524
2544
  "./types/notification": {
2525
2545
  "types": "./types/notification/index.d.ts",
2526
2546
  "require": "./cjs/types/notification/index.js",
@@ -2856,6 +2876,21 @@
2856
2876
  "require": "./cjs/utils/lazy.js",
2857
2877
  "default": "./utils/lazy.js"
2858
2878
  },
2879
+ "./utils/logger": {
2880
+ "types": "./utils/logger/index.d.ts",
2881
+ "require": "./cjs/utils/logger/index.js",
2882
+ "default": "./utils/logger/index.js"
2883
+ },
2884
+ "./utils/logger/Logger": {
2885
+ "types": "./utils/logger/Logger.d.ts",
2886
+ "require": "./cjs/utils/logger/Logger.js",
2887
+ "default": "./utils/logger/Logger.js"
2888
+ },
2889
+ "./utils/logger/types": {
2890
+ "types": "./utils/logger/types.d.ts",
2891
+ "require": "./cjs/utils/logger/types.js",
2892
+ "default": "./utils/logger/types.js"
2893
+ },
2859
2894
  "./utils/metadata": {
2860
2895
  "types": "./utils/metadata.d.ts",
2861
2896
  "require": "./cjs/utils/metadata.js",
@@ -2973,11 +3008,11 @@
2973
3008
  "@sora-substrate/type-definitions": "^1.17.7",
2974
3009
  "@substrate/connect": "^0.8.9",
2975
3010
  "@subwallet-monorepos/subwallet-services-sdk": "0.1.16",
2976
- "@subwallet/chain-list": "0.2.123",
2977
- "@subwallet/extension-base": "^1.3.73-0",
2978
- "@subwallet/extension-chains": "^1.3.73-0",
2979
- "@subwallet/extension-dapp": "^1.3.73-0",
2980
- "@subwallet/extension-inject": "^1.3.73-0",
3011
+ "@subwallet/chain-list": "0.2.124",
3012
+ "@subwallet/extension-base": "^1.3.74-1",
3013
+ "@subwallet/extension-chains": "^1.3.74-1",
3014
+ "@subwallet/extension-dapp": "^1.3.74-1",
3015
+ "@subwallet/extension-inject": "^1.3.74-1",
2981
3016
  "@subwallet/keyring": "^0.1.14",
2982
3017
  "@subwallet/ui-keyring": "^0.1.14",
2983
3018
  "@ton/core": "^0.56.3",
@@ -3006,6 +3041,7 @@
3006
3041
  "is-buffer": "^2.0.5",
3007
3042
  "joi": "^17.13.3",
3008
3043
  "json-rpc-engine": "^6.1.0",
3044
+ "loglevel": "^1.9.2",
3009
3045
  "manta-extension-sdk": "^1.1.0",
3010
3046
  "moment": "^2.29.4",
3011
3047
  "protobufjs": "^7.5.4",
package/packageInfo.js CHANGED
@@ -7,5 +7,5 @@ export const packageInfo = {
7
7
  name: '@subwallet/extension-base',
8
8
  path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
9
9
  type: 'esm',
10
- version: '1.3.73-0'
10
+ version: '1.3.74-1'
11
11
  };
@@ -135,8 +135,6 @@ const subscribeWithSystemAccountPallet = async ({
135
135
  args: addresses
136
136
  });
137
137
  }
138
-
139
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
140
138
  const subscription = substrateApi.subscribeDataWithMulti(params, async rs => {
141
139
  const balances = rs[systemAccountKey];
142
140
  const poolMemberInfos = rs[poolMembersKey];
@@ -10,7 +10,7 @@ import { getSubstrateConnectProvider } from '@subwallet/extension-base/services/
10
10
  import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
11
11
  import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
12
12
  import { goldbergRpc, goldbergTypes, spec as availSpec } from 'avail-js-sdk';
13
- import { BehaviorSubject, combineLatest, map, Observable } from 'rxjs';
13
+ import { BehaviorSubject, catchError, combineLatest, map, Observable, of } from 'rxjs';
14
14
  import { ApiPromise, WsProvider } from '@polkadot/api';
15
15
  import { typesBundle as _typesBundle } from '@polkadot/apps-config/api';
16
16
  import { TypeRegistry } from '@polkadot/types/create';
@@ -350,7 +350,12 @@ export class SubstrateApi {
350
350
  subscriber.next([]);
351
351
  });
352
352
  } else {
353
- observables[key] = apiRx[section][module][method].multi(args).pipe(map(codecs => codecs.map(codec => codec.toPrimitive())));
353
+ observables[key] = apiRx[section][module][method].multi(args).pipe(
354
+ // tap((codecs) => console.log('raw data', key, codecs)), // this line is used to debug data before transformation
355
+ map(codecs => codecs.map(codec => codec.toPrimitive())), catchError((error, caught) => {
356
+ console.error(`RxJS pipe() error for key ${key}`, error);
357
+ return of([]);
358
+ }));
354
359
  }
355
360
  });
356
361
  return combineLatest(observables).subscribe(callback);
@@ -1422,6 +1422,7 @@ export class ChainService {
1422
1422
  hasNativeNft: false,
1423
1423
  supportStaking: params.chainSpec.paraId === null,
1424
1424
  supportProxy: false,
1425
+ supportMultisig: false,
1425
1426
  supportSmartContract: null
1426
1427
  };
1427
1428
  } else if (params.chainSpec.evmChainId !== null) {
@@ -100,7 +100,7 @@ export interface _SubstrateAdapterSubscriptionArgs extends Omit<Required<_Substr
100
100
  }
101
101
  export interface _SubstrateApiAdapter {
102
102
  makeRpcQuery<T extends AnyJson | `0x${string}` | Registry | RuntimeVersion>(params: _SubstrateAdapterQueryArgs): Promise<T>;
103
- subscribeDataWithMulti(params: _SubstrateAdapterSubscriptionArgs[], callback: (rs: Record<string, AnyJson[]>) => void): Subscription;
103
+ subscribeDataWithMulti(params: _SubstrateAdapterSubscriptionArgs[], callback: (rs: Record<string, AnyJson[]>) => void | Promise<void>): Subscription;
104
104
  }
105
105
  export interface _EvmApi extends _ChainBaseApi {
106
106
  api: Web3;
@@ -644,6 +644,10 @@ export const _isChainInfoCompatibleWithAccountInfo = (chainInfo, accountInfo) =>
644
644
  type: accountType
645
645
  } = accountInfo;
646
646
  if (accountChainType === AccountChainType.SUBSTRATE) {
647
+ var _chainInfo$substrateI19;
648
+ if (accountSignMode === AccountSignMode.MULTISIG && !((_chainInfo$substrateI19 = chainInfo.substrateInfo) !== null && _chainInfo$substrateI19 !== void 0 && _chainInfo$substrateI19.supportMultisig)) {
649
+ return false;
650
+ }
647
651
  return _isPureSubstrateChain(chainInfo) && AllSubstrateKeypairTypes.includes(accountType);
648
652
  }
649
653
  if (accountChainType === AccountChainType.ETHEREUM) {
@@ -22,6 +22,7 @@ export declare class EventService extends EventEmitter<EventRegistry> {
22
22
  readonly waitEarningReady: Promise<boolean>;
23
23
  readonly waitLedgerReady: Promise<boolean>;
24
24
  readonly waitOpenGovReady: Promise<boolean>;
25
+ readonly waitMultisigReady: Promise<boolean>;
25
26
  constructor();
26
27
  private generateWaitPromise;
27
28
  private setLazyTimeout;
@@ -34,6 +34,7 @@ export class EventService extends EventEmitter {
34
34
  this.waitEarningReady = this.generateWaitPromise('earning.ready');
35
35
  this.waitLedgerReady = this.generateWaitPromise('ledger.ready');
36
36
  this.waitOpenGovReady = this.generateWaitPromise('open-gov.ready');
37
+ this.waitMultisigReady = this.generateWaitPromise('multisig-service.ready');
37
38
  }
38
39
  generateWaitPromise(eventType) {
39
40
  return new Promise(resolve => {
@@ -46,6 +46,7 @@ export interface EventRegistry {
46
46
  'swap.ready': [boolean];
47
47
  'ledger.ready': [boolean];
48
48
  'open-gov.ready': [boolean];
49
+ 'multisig-service.ready': [boolean];
49
50
  }
50
51
  export declare type EventType = keyof EventRegistry;
51
52
  export declare const COMMON_RELOAD_EVENTS: EventType[];
@@ -45,13 +45,13 @@ export const parseInfuraFee = (info, threshold) => {
45
45
  };
46
46
  export const fetchInfuraFeeData = async (chainId, infuraAuth) => {
47
47
  const baseUrl = 'https://gas.api.infura.io/networks/{{chainId}}/suggestedGasFees';
48
- const baseThressholdUrl = 'https://gas.api.infura.io/networks/{{chainId}}/busyThreshold';
48
+ const baseThresholdUrl = 'https://gas.api.infura.io/networks/{{chainId}}/busyThreshold';
49
49
  // const baseFeeHistoryUrl = 'https://gas.api.infura.io/networks/{{chainId}}/baseFeeHistory';
50
50
  // const baseFeePercentileUrl = 'https://gas.api.infura.io/networks/{{chainId}}/baseFeePercentile';
51
51
  const feeUrl = baseUrl.replaceAll('{{chainId}}', chainId.toString());
52
- const thressholdUrl = baseThressholdUrl.replaceAll('{{chainId}}', chainId.toString());
52
+ const thresholdUrl = baseThresholdUrl.replaceAll('{{chainId}}', chainId.toString());
53
53
  try {
54
- const [feeResp, thressholdResp] = await Promise.all([feeUrl, thressholdUrl].map(url => {
54
+ const [feeResp, thresholdResp] = await Promise.all([feeUrl, thresholdUrl].map(url => {
55
55
  return fetch(url, {
56
56
  method: 'GET',
57
57
  headers: {
@@ -61,7 +61,7 @@ export const fetchInfuraFeeData = async (chainId, infuraAuth) => {
61
61
  }));
62
62
 
63
63
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
64
- const [feeInfo, thresholdInfo] = await Promise.all([feeResp.json(), thressholdResp.json()]);
64
+ const [feeInfo, thresholdInfo] = await Promise.all([feeResp.json(), thresholdResp.json()]);
65
65
  return parseInfuraFee(feeInfo, thresholdInfo);
66
66
  } catch (e) {
67
67
  console.warn(e);
@@ -1,4 +1,4 @@
1
- import { getAvailBridgeClaimDescription, getClaimDescription, getPolygonBridgeClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from './utils';
1
+ import { getAvailBridgeClaimDescription, getClaimDescription, getMultisigApprovalDescription, getPolygonBridgeClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from './utils';
2
2
  export declare const NotificationTitleMap: {
3
3
  WITHDRAW: string;
4
4
  CLAIM: string;
@@ -7,6 +7,7 @@ export declare const NotificationTitleMap: {
7
7
  CLAIM_AVAIL_BRIDGE_ON_AVAIL: string;
8
8
  CLAIM_AVAIL_BRIDGE_ON_ETHEREUM: string;
9
9
  CLAIM_POLYGON_BRIDGE: string;
10
+ MULTISIG_APPROVAL: string;
10
11
  };
11
12
  export declare const NotificationDescriptionMap: {
12
13
  WITHDRAW: typeof getWithdrawDescription;
@@ -16,5 +17,6 @@ export declare const NotificationDescriptionMap: {
16
17
  CLAIM_AVAIL_BRIDGE_ON_AVAIL: typeof getAvailBridgeClaimDescription;
17
18
  CLAIM_AVAIL_BRIDGE_ON_ETHEREUM: typeof getAvailBridgeClaimDescription;
18
19
  CLAIM_POLYGON_BRIDGE: typeof getPolygonBridgeClaimDescription;
20
+ MULTISIG_APPROVAL: typeof getMultisigApprovalDescription;
19
21
  };
20
22
  export declare const ONE_DAY_MILLISECOND: number;
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { NotificationActionType } from "./interfaces.js";
5
- import { getAvailBridgeClaimDescription, getClaimDescription, getPolygonBridgeClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from "./utils/index.js";
5
+ import { getAvailBridgeClaimDescription, getClaimDescription, getMultisigApprovalDescription, getPolygonBridgeClaimDescription, getReceiveDescription, getSendDescription, getWithdrawDescription } from "./utils/index.js";
6
6
  export const NotificationTitleMap = {
7
7
  [NotificationActionType.WITHDRAW]: '[{{accountName}}] WITHDRAW {{tokenSymbol}}',
8
8
  [NotificationActionType.CLAIM]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
@@ -10,7 +10,8 @@ export const NotificationTitleMap = {
10
10
  [NotificationActionType.RECEIVE]: '[{{accountName}}] RECEIVE {{tokenSymbol}}',
11
11
  [NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
12
12
  [NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
13
- [NotificationActionType.CLAIM_POLYGON_BRIDGE]: '[{{accountName}}] CLAIM {{tokenSymbol}}'
13
+ [NotificationActionType.CLAIM_POLYGON_BRIDGE]: '[{{accountName}}] CLAIM {{tokenSymbol}}',
14
+ [NotificationActionType.MULTISIG_APPROVAL]: '[{{accountName}}] APPROVAL REQUIRED'
14
15
  };
15
16
  export const NotificationDescriptionMap = {
16
17
  [NotificationActionType.WITHDRAW]: getWithdrawDescription,
@@ -19,6 +20,7 @@ export const NotificationDescriptionMap = {
19
20
  [NotificationActionType.RECEIVE]: getReceiveDescription,
20
21
  [NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL]: getAvailBridgeClaimDescription,
21
22
  [NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM]: getAvailBridgeClaimDescription,
22
- [NotificationActionType.CLAIM_POLYGON_BRIDGE]: getPolygonBridgeClaimDescription
23
+ [NotificationActionType.CLAIM_POLYGON_BRIDGE]: getPolygonBridgeClaimDescription,
24
+ [NotificationActionType.MULTISIG_APPROVAL]: getMultisigApprovalDescription
23
25
  };
24
26
  export const ONE_DAY_MILLISECOND = 1000 * 24 * 60 * 60;
@@ -7,7 +7,7 @@ import { AvailBridgeTransaction, PolygonTransaction } from '@subwallet/extension
7
7
  import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
8
8
  import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
9
9
  import { ProcessTransactionData } from '@subwallet/extension-base/types';
10
- import { GetNotificationParams, RequestSwitchStatusParams } from '@subwallet/extension-base/types/notification';
10
+ import { GetNotificationParams, MarkAllReadParams, RequestSwitchStatusParams } from '@subwallet/extension-base/types/notification';
11
11
  export declare class InappNotificationService implements CronServiceInterface {
12
12
  private readonly dbService;
13
13
  private readonly keyringService;
@@ -17,13 +17,14 @@ export declare class InappNotificationService implements CronServiceInterface {
17
17
  private refeshAvailBridgeClaimTimeOut;
18
18
  constructor(dbService: DatabaseService, keyringService: KeyringService, eventService: EventService, chainService: ChainService);
19
19
  init(): Promise<void>;
20
- markAllRead(proxyId: string): Promise<void>;
20
+ markAllRead(params: MarkAllReadParams): Promise<void>;
21
21
  switchReadStatus(params: RequestSwitchStatusParams): Promise<void>;
22
22
  subscribeUnreadNotificationsCountMap(callback: (data: Record<string, number>) => void): import("dexie").Subscription;
23
23
  getUnreadNotificationsCountMap(): Promise<Record<string, number>>;
24
24
  fetchNotificationsByParams(params: GetNotificationParams): Promise<_NotificationInfo[]>;
25
25
  getNotificationById(id: string): Promise<_NotificationInfo | undefined>;
26
26
  cleanUpOldNotifications(overdueTime?: number): Promise<number>;
27
+ cleanUpNotificationByIds(ids: string[]): Promise<number>;
27
28
  passValidateNotification(candidateNotification: _BaseNotificationInfo, comparedNotifications: _NotificationInfo[], remindTimeConfigInHrs: Record<NotificationActionType, number>): boolean;
28
29
  validateAndWriteNotificationsToDB(notifications: _BaseNotificationInfo[], address: string): Promise<void>;
29
30
  cronCreateBridgeClaimNotification(): void;
@@ -29,8 +29,8 @@ export class InappNotificationService {
29
29
  await this.start();
30
30
  this.onAccountProxyRemove();
31
31
  }
32
- async markAllRead(proxyId) {
33
- await this.dbService.markAllRead(proxyId);
32
+ async markAllRead(params) {
33
+ await this.dbService.markAllRead(params);
34
34
  }
35
35
  async switchReadStatus(params) {
36
36
  await this.dbService.switchReadStatus(params);
@@ -52,6 +52,9 @@ export class InappNotificationService {
52
52
  cleanUpOldNotifications(overdueTime = ONE_DAY_MILLISECOND * 60) {
53
53
  return this.dbService.cleanUpOldNotifications(overdueTime);
54
54
  }
55
+ cleanUpNotificationByIds(ids) {
56
+ return this.dbService.cleanUpNotificationByIds(ids);
57
+ }
55
58
  passValidateNotification(candidateNotification, comparedNotifications, remindTimeConfigInHrs) {
56
59
  // todo: simplify condition !!
57
60
  if ([NotificationActionType.WITHDRAW, NotificationActionType.CLAIM].includes(candidateNotification.actionType)) {
@@ -87,6 +90,7 @@ export class InappNotificationService {
87
90
  }
88
91
  if ([NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_ETHEREUM, NotificationActionType.CLAIM_AVAIL_BRIDGE_ON_AVAIL].includes(candidateNotification.actionType)) {
89
92
  const {
93
+ actionType,
90
94
  address,
91
95
  metadata,
92
96
  time
@@ -97,6 +101,9 @@ export class InappNotificationService {
97
101
  if (notification.address !== address) {
98
102
  continue;
99
103
  }
104
+ if (notification.actionType !== actionType) {
105
+ continue;
106
+ }
100
107
  if (time - notification.time >= remindTime) {
101
108
  continue;
102
109
  }
@@ -109,6 +116,7 @@ export class InappNotificationService {
109
116
  }
110
117
  if ([NotificationActionType.CLAIM_POLYGON_BRIDGE].includes(candidateNotification.actionType)) {
111
118
  const {
119
+ actionType,
112
120
  address,
113
121
  metadata,
114
122
  time
@@ -119,6 +127,9 @@ export class InappNotificationService {
119
127
  if (notification.address !== address) {
120
128
  continue;
121
129
  }
130
+ if (notification.actionType !== actionType) {
131
+ continue;
132
+ }
122
133
  if (time - notification.time >= remindTime) {
123
134
  continue;
124
135
  }
@@ -130,9 +141,16 @@ export class InappNotificationService {
130
141
  }
131
142
  }
132
143
  if ([NotificationActionType.SWAP, NotificationActionType.EARNING].includes(candidateNotification.actionType)) {
133
- const candidateMetadata = candidateNotification.metadata;
144
+ const {
145
+ actionType,
146
+ metadata
147
+ } = candidateNotification;
148
+ const candidateMetadata = metadata;
134
149
  const processId = candidateMetadata.processId;
135
150
  for (const notification of comparedNotifications) {
151
+ if (notification.actionType !== actionType) {
152
+ continue;
153
+ }
136
154
  const comparedMetadata = notification.metadata;
137
155
  const _processId = comparedMetadata.processId;
138
156
  if (processId === _processId) {
@@ -140,10 +158,33 @@ export class InappNotificationService {
140
158
  }
141
159
  }
142
160
  }
161
+ if ([NotificationActionType.MULTISIG_APPROVAL].includes(candidateNotification.actionType)) {
162
+ const {
163
+ actionType,
164
+ address,
165
+ metadata
166
+ } = candidateNotification;
167
+ const candidateMetadata = metadata;
168
+
169
+ // todo: experiment without notification reminder, remove this todo if no problems raised
170
+ for (const notification of comparedNotifications) {
171
+ if (notification.address !== address) {
172
+ continue;
173
+ }
174
+ if (notification.actionType !== actionType) {
175
+ continue;
176
+ }
177
+ const comparedMetadata = notification.metadata;
178
+ const sameNotification = candidateMetadata.multisigTxType === comparedMetadata.multisigTxType && candidateMetadata.multisigKey === comparedMetadata.multisigKey;
179
+ if (sameNotification) {
180
+ return false;
181
+ }
182
+ }
183
+ }
143
184
  return true;
144
185
  }
145
186
  async validateAndWriteNotificationsToDB(notifications, address) {
146
- const proxyId = this.keyringService.context.belongUnifiedAccount(address) || address;
187
+ const proxyId = this.keyringService.context.belongUnifiedAccount(address) || reformatAddress(address);
147
188
  const accountName = this.keyringService.context.getCurrentAccountProxyName(proxyId);
148
189
  const passNotifications = [];
149
190
  const [comparedNotifications, remindTimeConfig] = await Promise.all([this.fetchNotificationsByParams({
@@ -422,7 +463,9 @@ export class InappNotificationService {
422
463
  this.status = ServiceStatus.STARTING;
423
464
  await this.startCron();
424
465
  this.status = ServiceStatus.STARTED;
425
- } catch (e) {}
466
+ } catch (e) {
467
+ console.error('Failed to start InappNotificationService', e);
468
+ }
426
469
  }
427
470
  async startCron() {
428
471
  this.cleanUpOldNotifications().catch(console.error);
@@ -434,7 +477,9 @@ export class InappNotificationService {
434
477
  this.status = ServiceStatus.STOPPING;
435
478
  await this.stopCron();
436
479
  this.status = ServiceStatus.STOPPED;
437
- } catch (e) {}
480
+ } catch (e) {
481
+ console.error('Failed to stop InappNotificationService', e);
482
+ }
438
483
  }
439
484
  stopCron() {
440
485
  return Promise.resolve(undefined);
@@ -1,5 +1,6 @@
1
1
  import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
2
2
  import { AvailBridgeSourceChain } from '@subwallet/extension-base/services/inapp-notification-service/utils';
3
+ import { MultisigTxType } from '@subwallet/extension-base/services/multisig-service';
3
4
  import { YieldPoolType } from '@subwallet/extension-base/types';
4
5
  export interface _BaseNotificationInfo {
5
6
  id: string;
@@ -30,6 +31,7 @@ export interface ActionTypeToMetadataMap {
30
31
  [NotificationActionType.CLAIM_POLYGON_BRIDGE]: ClaimPolygonBridgeNotificationMetadata;
31
32
  [NotificationActionType.SWAP]: ProcessNotificationMetadata;
32
33
  [NotificationActionType.EARNING]: ProcessNotificationMetadata;
34
+ [NotificationActionType.MULTISIG_APPROVAL]: MultisigApprovalNotificationMetadata;
33
35
  }
34
36
  export interface SendReceiveNotificationMetadata {
35
37
  chain: string;
@@ -76,6 +78,18 @@ export interface ClaimPolygonBridgeNotificationMetadata {
76
78
  export interface ProcessNotificationMetadata {
77
79
  processId: string;
78
80
  }
81
+ export interface MultisigApprovalNotificationMetadata {
82
+ multisigKey: string;
83
+ multisigTxType: MultisigTxType;
84
+ chain: string;
85
+ multisigAddress: string;
86
+ extrinsicHash: string;
87
+ callHash: string;
88
+ blockHeight: number;
89
+ extrinsicIndex: number;
90
+ currentSigner: string;
91
+ approvals: string[];
92
+ }
79
93
  export declare enum NotificationTimePeriod {
80
94
  TODAY = "TODAY",
81
95
  THIS_WEEK = "THIS_WEEK",
@@ -90,12 +104,14 @@ export declare enum NotificationActionType {
90
104
  CLAIM_AVAIL_BRIDGE_ON_ETHEREUM = "CLAIM_AVAIL_BRIDGE_ON_ETHEREUM",
91
105
  CLAIM_POLYGON_BRIDGE = "CLAIM_POLYGON_BRIDGE",
92
106
  SWAP = "SWAP",
93
- EARNING = "EARNING"
107
+ EARNING = "EARNING",
108
+ MULTISIG_APPROVAL = "MULTISIG_APPROVAL"
94
109
  }
95
110
  export declare enum NotificationTab {
96
111
  ALL = "ALL",
97
112
  UNREAD = "UNREAD",
98
- READ = "READ"
113
+ READ = "READ",
114
+ MULTISIG = "MULTISIG"
99
115
  }
100
116
  export interface ShowNotificationPayload {
101
117
  earningClaim: boolean;
@@ -24,10 +24,12 @@ export let NotificationActionType;
24
24
  NotificationActionType["CLAIM_POLYGON_BRIDGE"] = "CLAIM_POLYGON_BRIDGE";
25
25
  NotificationActionType["SWAP"] = "SWAP";
26
26
  NotificationActionType["EARNING"] = "EARNING";
27
+ NotificationActionType["MULTISIG_APPROVAL"] = "MULTISIG_APPROVAL";
27
28
  })(NotificationActionType || (NotificationActionType = {}));
28
29
  export let NotificationTab;
29
30
  (function (NotificationTab) {
30
31
  NotificationTab["ALL"] = "ALL";
31
32
  NotificationTab["UNREAD"] = "UNREAD";
32
33
  NotificationTab["READ"] = "READ";
34
+ NotificationTab["MULTISIG"] = "MULTISIG";
33
35
  })(NotificationTab || (NotificationTab = {}));
@@ -5,6 +5,7 @@ export declare function getWithdrawDescription(amount: string, symbol: string, s
5
5
  export declare function getClaimDescription(amount: string, symbol: string): string;
6
6
  export declare function getSendDescription(amount: string, symbol: string): string;
7
7
  export declare function getReceiveDescription(amount: string, symbol: string): string;
8
+ export declare function getMultisigApprovalDescription(): string;
8
9
  export declare function getIsTabRead(notificationTab: NotificationTab): boolean | undefined;
9
10
  export declare function createWithdrawNotifications(unstakingInfos: UnstakingInfo[], tokenInfo: _ChainAsset, address: string, stakingSlug: string, stakingType: YieldPoolType): _BaseNotificationInfo[];
10
11
  export declare function createClaimNotification(claimItemInfo: EarningRewardItem, tokenInfo: _ChainAsset): _BaseNotificationInfo;
@@ -24,6 +24,9 @@ export function getSendDescription(amount, symbol) {
24
24
  export function getReceiveDescription(amount, symbol) {
25
25
  return `You have just received ${amount} ${symbol}`;
26
26
  }
27
+ export function getMultisigApprovalDescription() {
28
+ return 'A multisig transaction is waiting for your approval. Click to view details';
29
+ }
27
30
 
28
31
  /* Description */
29
32
 
@@ -1,7 +1,8 @@
1
- import { AccountExternalError, RequestAccountCreateExternalV2, RequestAccountCreateHardwareMultiple, RequestAccountCreateHardwareV2, RequestAccountCreateWithSecretKey, RequestAccountExportPrivateKey, RequestChangeMasterPassword, RequestMigratePassword, RequestMigrateSoloAccount, RequestMigrateUnifiedAndFetchEligibleSoloAccounts, RequestPingSession, ResponseAccountCreateWithSecretKey, ResponseAccountExportPrivateKey, ResponseChangeMasterPassword, ResponseMigratePassword } from '@subwallet/extension-base/background/KoniTypes';
1
+ import { AccountExternalError, AccountMultisigError, RequestAccountCreateExternalV2, RequestAccountCreateHardwareMultiple, RequestAccountCreateHardwareV2, RequestAccountCreateMultisig, RequestAccountCreateWithSecretKey, RequestAccountExportPrivateKey, RequestChangeMasterPassword, RequestMigratePassword, RequestMigrateSoloAccount, RequestMigrateUnifiedAndFetchEligibleSoloAccounts, RequestPingSession, ResponseAccountCreateWithSecretKey, ResponseAccountExportPrivateKey, ResponseChangeMasterPassword, ResponseMigratePassword } from '@subwallet/extension-base/background/KoniTypes';
2
2
  import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
3
3
  import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
4
4
  import { AccountProxyMap, CurrentAccountInfo, RequestAccountBatchExportV2, RequestAccountCreateSuriV2, RequestAccountNameValidate, RequestAccountProxyEdit, RequestAccountProxyForget, RequestBatchJsonGetAccountInfo, RequestBatchRestoreV2, RequestChangeTonWalletContractVersion, RequestCheckPublicAndSecretKey, RequestDeriveCreateMultiple, RequestDeriveCreateV3, RequestDeriveValidateV2, RequestExportAccountProxyMnemonic, RequestGetAllTonWalletContractVersion, RequestGetDeriveAccounts, RequestGetDeriveSuggestion, RequestJsonGetAccountInfo, RequestJsonRestoreV2, RequestMnemonicCreateV2, RequestMnemonicValidateV2, RequestPrivateKeyValidateV2, ResponseAccountBatchExportV2, ResponseAccountCreateSuriV2, ResponseAccountNameValidate, ResponseBatchJsonGetAccountInfo, ResponseCheckPublicAndSecretKey, ResponseDeriveValidateV2, ResponseExportAccountProxyMnemonic, ResponseGetAllTonWalletContractVersion, ResponseGetDeriveAccounts, ResponseGetDeriveSuggestion, ResponseJsonGetAccountInfo, ResponseMnemonicCreateV2, ResponseMnemonicValidateV2, ResponsePrivateKeyValidateV2 } from '@subwallet/extension-base/types';
5
+ import { MultisigAccountInfo, RequestGetSignableAccountInfos, ResponseGetSignableAccountInfos } from '@subwallet/extension-base/types/multisig';
5
6
  import { InjectedAccountWithMeta } from '@subwallet/extension-inject/types';
6
7
  import { SubjectInfo } from '@subwallet/ui-keyring/observable/types';
7
8
  export declare class AccountContext {
@@ -16,6 +17,7 @@ export declare class AccountContext {
16
17
  private readonly modifyHandler;
17
18
  private readonly secretHandler;
18
19
  private readonly migrationHandler;
20
+ private readonly multisigHandler;
19
21
  constructor(koniState: KoniState, parentService: KeyringService);
20
22
  get pairs(): SubjectInfo;
21
23
  get observable(): {
@@ -55,6 +57,8 @@ export declare class AccountContext {
55
57
  accountsCreateSuriV2(request: RequestAccountCreateSuriV2): ResponseAccountCreateSuriV2;
56
58
  exportAccountProxyMnemonic(request: RequestExportAccountProxyMnemonic): ResponseExportAccountProxyMnemonic;
57
59
  accountsCreateExternalV2(request: RequestAccountCreateExternalV2): Promise<AccountExternalError[]>;
60
+ accountsCreateMultisig(request: RequestAccountCreateMultisig): Promise<AccountMultisigError[]>;
61
+ getSignableAccountInfos(request: RequestGetSignableAccountInfos): ResponseGetSignableAccountInfos;
58
62
  privateKeyValidateV2(request: RequestPrivateKeyValidateV2): ResponsePrivateKeyValidateV2;
59
63
  accountsCreateHardwareV2(request: RequestAccountCreateHardwareV2): Promise<boolean>;
60
64
  accountsCreateHardwareMultiple(request: RequestAccountCreateHardwareMultiple): Promise<boolean>;
@@ -88,6 +92,10 @@ export declare class AccountContext {
88
92
  migrateUnifiedAndFetchEligibleSoloAccounts(request: RequestMigrateUnifiedAndFetchEligibleSoloAccounts, setMigratingModeFn: () => void): Promise<import("@subwallet/extension-base/background/KoniTypes").ResponseMigrateUnifiedAndFetchEligibleSoloAccounts>;
89
93
  migrateSoloAccount(request: RequestMigrateSoloAccount): import("@subwallet/extension-base/background/KoniTypes").ResponseMigrateSoloAccount;
90
94
  pingSession(request: RequestPingSession): boolean;
95
+ getMultisigAccounts(): import("@subwallet/extension-base/types").AccountProxy[];
96
+ getMultisigAccountByAddress(address?: string): import("@subwallet/extension-base/types").AccountProxy | undefined;
97
+ getMultisigAccountInfoByAddress(address?: string): MultisigAccountInfo | undefined;
98
+ getMultisigAddresses(): string[];
91
99
  removeNoneHardwareGenesisHash(): void;
92
100
  updateMetadataForPair(): void;
93
101
  resetWallet(): void;