@subwallet/extension-base 1.3.68-1 → 1.3.70-2
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 +11 -0
- package/background/KoniTypes.js +3 -0
- package/cjs/background/KoniTypes.js +3 -0
- package/cjs/koni/background/handlers/Extension.js +62 -0
- package/cjs/koni/background/handlers/State.js +5 -2
- package/cjs/koni/background/handlers/Tabs.js +11 -4
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/transfer/token.js +34 -3
- package/cjs/services/chain-service/constants.js +17 -5
- package/cjs/services/chain-service/utils/index.js +13 -5
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/event-service/index.js +1 -0
- package/cjs/services/open-gov/handler.js +563 -0
- package/cjs/services/open-gov/index.js +273 -0
- package/cjs/services/open-gov/interface.js +28 -0
- package/cjs/services/open-gov/utils.js +66 -0
- package/cjs/services/storage-service/DatabaseService.js +19 -1
- package/cjs/services/storage-service/databases/index.js +3 -0
- package/cjs/services/storage-service/db-stores/GovLockedInfoStore.js +35 -0
- package/cjs/services/transaction-service/helpers/index.js +6 -0
- package/cjs/services/transaction-service/index.js +43 -0
- package/cjs/services/transaction-service/utils.js +3 -3
- package/cjs/utils/account/transform.js +5 -4
- package/koni/background/handlers/Extension.d.ts +4 -0
- package/koni/background/handlers/Extension.js +62 -0
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +5 -2
- package/koni/background/handlers/Tabs.js +11 -4
- package/package.json +31 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/transfer/token.d.ts +4 -0
- package/services/balance-service/transfer/token.js +31 -1
- package/services/chain-service/constants.d.ts +9 -0
- package/services/chain-service/constants.js +14 -3
- package/services/chain-service/utils/index.js +13 -5
- package/services/chain-service/utils/patch.d.ts +1 -1
- package/services/chain-service/utils/patch.js +1 -1
- package/services/event-service/index.d.ts +1 -0
- package/services/event-service/index.js +1 -0
- package/services/event-service/types.d.ts +1 -0
- package/services/open-gov/handler.d.ts +27 -0
- package/services/open-gov/handler.js +547 -0
- package/services/open-gov/index.d.ts +45 -0
- package/services/open-gov/index.js +265 -0
- package/services/open-gov/interface.d.ts +141 -0
- package/services/open-gov/interface.js +21 -0
- package/services/open-gov/utils.d.ts +14 -0
- package/services/open-gov/utils.js +52 -0
- package/services/storage-service/DatabaseService.d.ts +7 -0
- package/services/storage-service/DatabaseService.js +19 -1
- package/services/storage-service/databases/index.d.ts +2 -0
- package/services/storage-service/databases/index.js +3 -0
- package/services/storage-service/db-stores/GovLockedInfoStore.d.ts +10 -0
- package/services/storage-service/db-stores/GovLockedInfoStore.js +27 -0
- package/services/transaction-service/helpers/index.js +6 -0
- package/services/transaction-service/index.js +43 -0
- package/services/transaction-service/utils.js +3 -3
- package/utils/account/transform.js +5 -4
|
@@ -28,6 +28,7 @@ import EventEmitter from 'eventemitter3';
|
|
|
28
28
|
import { t } from 'i18next';
|
|
29
29
|
import { BehaviorSubject, interval as rxjsInterval, map as rxjsMap } from 'rxjs';
|
|
30
30
|
import { hexToU8a, isHex } from '@polkadot/util';
|
|
31
|
+
import { GovVoteType } from "../open-gov/interface.js";
|
|
31
32
|
export default class TransactionService {
|
|
32
33
|
watchTransactionSubscribes = {};
|
|
33
34
|
aliveProcessMap = new Map();
|
|
@@ -1071,6 +1072,48 @@ export default class TransactionService {
|
|
|
1071
1072
|
historyItem.additionalInfo = data;
|
|
1072
1073
|
break;
|
|
1073
1074
|
}
|
|
1075
|
+
case ExtrinsicType.GOV_VOTE:
|
|
1076
|
+
{
|
|
1077
|
+
const data = parseTransactionData(transaction.data);
|
|
1078
|
+
let totalAmount = new BigN(0);
|
|
1079
|
+
switch (data.type) {
|
|
1080
|
+
case GovVoteType.AYE:
|
|
1081
|
+
case GovVoteType.NAY:
|
|
1082
|
+
totalAmount = new BigN(data.amount || '0');
|
|
1083
|
+
break;
|
|
1084
|
+
case GovVoteType.SPLIT:
|
|
1085
|
+
totalAmount = new BigN(data.ayeAmount || '0').plus(data.nayAmount || '0');
|
|
1086
|
+
break;
|
|
1087
|
+
case GovVoteType.ABSTAIN:
|
|
1088
|
+
totalAmount = new BigN(data.ayeAmount || '0').plus(data.nayAmount || '0').plus(data.abstainAmount || '0');
|
|
1089
|
+
break;
|
|
1090
|
+
}
|
|
1091
|
+
historyItem.amount = {
|
|
1092
|
+
...baseNativeAmount,
|
|
1093
|
+
value: totalAmount.toString()
|
|
1094
|
+
};
|
|
1095
|
+
historyItem.additionalInfo = data;
|
|
1096
|
+
break;
|
|
1097
|
+
}
|
|
1098
|
+
case ExtrinsicType.GOV_UNVOTE:
|
|
1099
|
+
{
|
|
1100
|
+
const data = parseTransactionData(transaction.data);
|
|
1101
|
+
historyItem.amount = {
|
|
1102
|
+
...baseNativeAmount,
|
|
1103
|
+
value: new BigN(data.ayeAmount || '0').plus(data.nayAmount || '0').plus(data.abstainAmount || '0').plus(data.amount || 0).toString()
|
|
1104
|
+
};
|
|
1105
|
+
historyItem.additionalInfo = data;
|
|
1106
|
+
break;
|
|
1107
|
+
}
|
|
1108
|
+
case ExtrinsicType.GOV_UNLOCK_VOTE:
|
|
1109
|
+
{
|
|
1110
|
+
const data = parseTransactionData(transaction.data);
|
|
1111
|
+
historyItem.amount = {
|
|
1112
|
+
...baseNativeAmount,
|
|
1113
|
+
value: data.amount
|
|
1114
|
+
};
|
|
1115
|
+
break;
|
|
1116
|
+
}
|
|
1074
1117
|
case ExtrinsicType.UNKNOWN:
|
|
1075
1118
|
break;
|
|
1076
1119
|
}
|
|
@@ -46,7 +46,7 @@ function getBlockExplorerAccountRoute(explorerLink) {
|
|
|
46
46
|
if (explorerLink.includes('main.dentnet.io')) {
|
|
47
47
|
return 'account';
|
|
48
48
|
}
|
|
49
|
-
if (explorerLink.includes('taostats.io')) {
|
|
49
|
+
if (explorerLink.includes('/taostats.io')) {
|
|
50
50
|
return 'account';
|
|
51
51
|
}
|
|
52
52
|
if (explorerLink.includes('uniquescan.io')) {
|
|
@@ -115,7 +115,7 @@ export function getExplorerLink(chainInfo, value, type) {
|
|
|
115
115
|
const explorerLink = _getBlockExplorerFromChain(chainInfo);
|
|
116
116
|
if (explorerLink && type === 'account') {
|
|
117
117
|
const route = getBlockExplorerAccountRoute(explorerLink);
|
|
118
|
-
if (chainInfo.slug
|
|
118
|
+
if (['truth_network', 'aventus'].includes(chainInfo.slug)) {
|
|
119
119
|
const address = u8aToHex(decodeAddress(value));
|
|
120
120
|
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${address}`;
|
|
121
121
|
}
|
|
@@ -129,7 +129,7 @@ export function getExplorerLink(chainInfo, value, type) {
|
|
|
129
129
|
if (chainInfo.slug === 'xode') {
|
|
130
130
|
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}polkadot-chain-transaction?search=${value}`;
|
|
131
131
|
}
|
|
132
|
-
if (chainInfo.slug
|
|
132
|
+
if (['truth_network', 'aventus'].includes(chainInfo.slug)) {
|
|
133
133
|
// getTransactionId(value)
|
|
134
134
|
// .then((transactionId) => {
|
|
135
135
|
// return (`${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${transactionId}`);
|
|
@@ -153,12 +153,13 @@ const EARN_STDOT_ACTIONS = [ExtrinsicType.MINT_STDOT, ExtrinsicType.REDEEM_STDOT
|
|
|
153
153
|
const EARN_VMANTA_ACTIONS = [ExtrinsicType.MINT_VMANTA, ExtrinsicType.REDEEM_VMANTA, ExtrinsicType.UNSTAKE_VMANTA];
|
|
154
154
|
const EVM_ACTIONS = [ExtrinsicType.TOKEN_SPENDING_APPROVAL, ExtrinsicType.EVM_EXECUTE];
|
|
155
155
|
const CLAIM_AVAIL_BRIDGE = [ExtrinsicType.CLAIM_BRIDGE];
|
|
156
|
+
const OPEN_GOV_ACTIONS = [ExtrinsicType.GOV_VOTE, ExtrinsicType.GOV_UNVOTE, ExtrinsicType.GOV_UNLOCK_VOTE];
|
|
156
157
|
const OTHER_ACTIONS = [ExtrinsicType.TRANSFER_XCM, ExtrinsicType.SEND_NFT, ExtrinsicType.SWAP, ExtrinsicType.CROWDLOAN];
|
|
157
158
|
export const getAccountTransactionActions = (signMode, networkType, type, _meta, _specialNetwork) => {
|
|
158
159
|
if ([AccountSignMode.PASSWORD, AccountSignMode.INJECTED].includes(signMode)) {
|
|
159
160
|
switch (networkType) {
|
|
160
161
|
case AccountChainType.SUBSTRATE:
|
|
161
|
-
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS];
|
|
162
|
+
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OPEN_GOV_ACTIONS, ...OTHER_ACTIONS];
|
|
162
163
|
case AccountChainType.ETHEREUM:
|
|
163
164
|
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...OTHER_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...EVM_ACTIONS];
|
|
164
165
|
case AccountChainType.TON:
|
|
@@ -171,7 +172,7 @@ export const getAccountTransactionActions = (signMode, networkType, type, _meta,
|
|
|
171
172
|
} else if (signMode === AccountSignMode.QR) {
|
|
172
173
|
switch (networkType) {
|
|
173
174
|
case AccountChainType.SUBSTRATE:
|
|
174
|
-
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS];
|
|
175
|
+
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS, ...EARN_QDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OPEN_GOV_ACTIONS, ...OTHER_ACTIONS];
|
|
175
176
|
case AccountChainType.ETHEREUM:
|
|
176
177
|
return [...(isProductionMode ? [] : [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_STDOT_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ...OTHER_ACTIONS, ...EVM_ACTIONS])];
|
|
177
178
|
case AccountChainType.TON:
|
|
@@ -186,7 +187,7 @@ export const getAccountTransactionActions = (signMode, networkType, type, _meta,
|
|
|
186
187
|
case AccountChainType.SUBSTRATE:
|
|
187
188
|
return [...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...EARN_VDOT_ACTIONS, ...EARN_VMANTA_ACTIONS, ...EARN_LDOT_ACTIONS, ...EARN_SDOT_ACTIONS,
|
|
188
189
|
// ...EARN_QDOT_ACTIONS,
|
|
189
|
-
...OTHER_ACTIONS];
|
|
190
|
+
...OPEN_GOV_ACTIONS, ...OTHER_ACTIONS];
|
|
190
191
|
case AccountChainType.ETHEREUM:
|
|
191
192
|
return [...BASE_TRANSFER_ACTIONS, ...EARN_STDOT_ACTIONS, ...EVM_ACTIONS, ...CLAIM_AVAIL_BRIDGE, ExtrinsicType.STAKING_WITHDRAW,
|
|
192
193
|
// For liquid staking
|
|
@@ -235,7 +236,7 @@ export const getAccountTransactionActions = (signMode, networkType, type, _meta,
|
|
|
235
236
|
} else if (signMode === AccountSignMode.ECDSA_SUBSTRATE_LEDGER) {
|
|
236
237
|
// Only for account substrate with ECDSA scheme format
|
|
237
238
|
const result = [];
|
|
238
|
-
result.push(...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ExtrinsicType.TRANSFER_XCM, ExtrinsicType.SWAP, ExtrinsicType.CROWDLOAN);
|
|
239
|
+
result.push(...BASE_TRANSFER_ACTIONS, ...NATIVE_STAKE_ACTIONS, ...POOL_STAKE_ACTIONS, ...OPEN_GOV_ACTIONS, ExtrinsicType.TRANSFER_XCM, ExtrinsicType.SWAP, ExtrinsicType.CROWDLOAN);
|
|
239
240
|
return result;
|
|
240
241
|
}
|
|
241
242
|
return [];
|