@subwallet/extension-base 1.0.7-0 → 1.0.7-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 (55) hide show
  1. package/background/KoniTypes.d.ts +4 -5
  2. package/cjs/constants/index.js +1 -1
  3. package/cjs/koni/api/staking/bonding/amplitude.js +83 -0
  4. package/cjs/koni/api/staking/bonding/astar.js +104 -1
  5. package/cjs/koni/api/staking/bonding/index.js +35 -0
  6. package/cjs/koni/api/staking/bonding/paraChain.js +97 -0
  7. package/cjs/koni/api/staking/bonding/relayChain.js +191 -12
  8. package/cjs/koni/api/staking/index.js +11 -11
  9. package/cjs/koni/api/staking/paraChain.js +200 -130
  10. package/cjs/koni/api/staking/relayChain.js +66 -68
  11. package/cjs/koni/api/staking/subsquidStaking.js +6 -11
  12. package/cjs/koni/background/cron.js +0 -25
  13. package/cjs/koni/background/handlers/State.js +17 -19
  14. package/cjs/koni/background/subscription.js +57 -12
  15. package/cjs/packageInfo.js +1 -1
  16. package/cjs/services/chain-service/utils.js +6 -1
  17. package/cjs/services/storage-service/DatabaseService.js +7 -3
  18. package/cjs/services/storage-service/db-stores/ChainStakingMetadata.js +5 -0
  19. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +4 -4
  20. package/cjs/services/transaction-service/index.js +6 -1
  21. package/constants/index.d.ts +1 -1
  22. package/constants/index.js +1 -1
  23. package/koni/api/staking/bonding/amplitude.d.ts +4 -0
  24. package/koni/api/staking/bonding/amplitude.js +81 -0
  25. package/koni/api/staking/bonding/astar.d.ts +4 -0
  26. package/koni/api/staking/bonding/astar.js +102 -1
  27. package/koni/api/staking/bonding/index.d.ts +1 -0
  28. package/koni/api/staking/bonding/index.js +38 -4
  29. package/koni/api/staking/bonding/paraChain.d.ts +4 -0
  30. package/koni/api/staking/bonding/paraChain.js +95 -0
  31. package/koni/api/staking/bonding/relayChain.d.ts +5 -0
  32. package/koni/api/staking/bonding/relayChain.js +185 -10
  33. package/koni/api/staking/index.d.ts +4 -4
  34. package/koni/api/staking/index.js +11 -11
  35. package/koni/api/staking/paraChain.d.ts +5 -5
  36. package/koni/api/staking/paraChain.js +201 -131
  37. package/koni/api/staking/relayChain.d.ts +4 -4
  38. package/koni/api/staking/relayChain.js +66 -67
  39. package/koni/api/staking/subsquidStaking.d.ts +1 -1
  40. package/koni/api/staking/subsquidStaking.js +6 -11
  41. package/koni/background/cron.js +1 -26
  42. package/koni/background/handlers/State.d.ts +2 -2
  43. package/koni/background/handlers/State.js +17 -19
  44. package/koni/background/subscription.d.ts +2 -1
  45. package/koni/background/subscription.js +58 -13
  46. package/package.json +5 -5
  47. package/packageInfo.js +1 -1
  48. package/services/chain-service/utils.js +6 -1
  49. package/services/storage-service/DatabaseService.d.ts +2 -2
  50. package/services/storage-service/DatabaseService.js +7 -3
  51. package/services/storage-service/db-stores/ChainStakingMetadata.d.ts +1 -0
  52. package/services/storage-service/db-stores/ChainStakingMetadata.js +3 -0
  53. package/services/storage-service/db-stores/NominatorMetadata.d.ts +2 -2
  54. package/services/storage-service/db-stores/NominatorMetadata.js +4 -4
  55. package/services/transaction-service/index.js +6 -1
@@ -99,8 +99,8 @@ export default class DatabaseService {
99
99
  next: data => callback && callback(data)
100
100
  });
101
101
  }
102
- subscribeNominatorMetadata(callback) {
103
- this.stores.nominatorMetadata.subscribeAll().subscribe({
102
+ subscribeNominatorMetadata(addresses, callback) {
103
+ return this.stores.nominatorMetadata.subscribeByAddresses(addresses).subscribe({
104
104
  next: data => callback && callback(data)
105
105
  });
106
106
  }
@@ -191,7 +191,11 @@ export default class DatabaseService {
191
191
  }
192
192
 
193
193
  // Staking
194
- async updateChainStakingMetadata(item) {
194
+ async updateChainStakingMetadata(item, changes) {
195
+ const existingRecord = await this.stores.chainStakingMetadata.getByChainAndType(item.chain, item.type);
196
+ if (existingRecord && changes) {
197
+ return this.stores.chainStakingMetadata.updateByChainAndType(item.chain, item.type, changes);
198
+ }
195
199
  return this.stores.chainStakingMetadata.upsert(item);
196
200
  }
197
201
  async getChainStakingMetadata() {
@@ -6,4 +6,5 @@ export default class ChainStakingMetadataStore extends BaseStoreWithChain<ChainS
6
6
  getByChains(chains: string[]): Promise<ChainStakingMetadata[]>;
7
7
  getByChainAndType(chain: string, type?: StakingType): import("dexie").PromiseExtended<ChainStakingMetadata | undefined>;
8
8
  removeByChains(chains: string[]): Promise<number>;
9
+ updateByChainAndType(chain: string, type: StakingType | undefined, changes: Record<string, unknown>): import("dexie").PromiseExtended<number>;
9
10
  }
@@ -26,4 +26,7 @@ export default class ChainStakingMetadataStore extends BaseStoreWithChain {
26
26
  async removeByChains(chains) {
27
27
  return this.table.where('chain').anyOfIgnoreCase(chains).delete();
28
28
  }
29
+ updateByChainAndType(chain, type = StakingType.NOMINATED, changes) {
30
+ return this.table.update([chain, type], changes);
31
+ }
29
32
  }
@@ -2,8 +2,8 @@ import { NominatorMetadata } from '@subwallet/extension-base/background/KoniType
2
2
  import BaseStoreWithAddressAndChain from '@subwallet/extension-base/services/storage-service/db-stores/BaseStoreWithAddressAndChain';
3
3
  export default class NominatorMetadataStore extends BaseStoreWithAddressAndChain<NominatorMetadata> {
4
4
  getAll(): Promise<NominatorMetadata[]>;
5
- subscribeByAddress(address: string): import("dexie").Observable<NominatorMetadata[]>;
5
+ subscribeByAddresses(addresses: string[]): import("dexie").Observable<NominatorMetadata[]>;
6
6
  subscribeAll(): import("dexie").Observable<NominatorMetadata[]>;
7
- getByAddress(address: string): import("dexie").PromiseExtended<NominatorMetadata[]>;
7
+ getByAddress(addresses: string[]): import("dexie").PromiseExtended<NominatorMetadata[]>;
8
8
  removeByAddress(address: string): Promise<number>;
9
9
  }
@@ -7,14 +7,14 @@ export default class NominatorMetadataStore extends BaseStoreWithAddressAndChain
7
7
  async getAll() {
8
8
  return this.table.toArray();
9
9
  }
10
- subscribeByAddress(address) {
11
- return liveQuery(() => this.getByAddress(address));
10
+ subscribeByAddresses(addresses) {
11
+ return liveQuery(() => this.getByAddress(addresses));
12
12
  }
13
13
  subscribeAll() {
14
14
  return liveQuery(() => this.getAll());
15
15
  }
16
- getByAddress(address) {
17
- return this.table.where('address').anyOfIgnoreCase(address).toArray();
16
+ getByAddress(addresses) {
17
+ return this.table.where('address').anyOfIgnoreCase(addresses).toArray();
18
18
  }
19
19
  async removeByAddress(address) {
20
20
  return this.table.where('address').anyOfIgnoreCase(address).delete();
@@ -631,7 +631,12 @@ export default class TransactionService {
631
631
  if (!payload.parseData) {
632
632
  const isToContract = await isContractAddress(payload.to || '', evmApi);
633
633
  payload.isToContract = isToContract;
634
- payload.parseData = isToContract ? payload.data ? (await parseContractInput(payload.data || '', payload.to || '', chainInfo)).result : '' : payload.data || '';
634
+ try {
635
+ payload.parseData = isToContract ? payload.data ? (await parseContractInput(payload.data || '', payload.to || '', chainInfo)).result : '' : payload.data || '';
636
+ } catch (e) {
637
+ console.warn('Unable to parse contract input data');
638
+ payload.parseData = payload.data;
639
+ }
635
640
  }
636
641
  if ('data' in payload && payload.data === undefined) {
637
642
  delete payload.data;