@subwallet/extension-base 1.3.46-0 → 1.3.47-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/cjs/koni/api/nft/ordinal_nft/index.js +3 -2
- package/cjs/koni/background/handlers/State.js +3 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +8 -14
- package/cjs/services/buy-service/index.js +2 -0
- package/cjs/services/chain-service/utils/index.js +3 -0
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +32 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +18 -0
- package/cjs/services/earning-service/handlers/native-staking/base.js +37 -29
- package/cjs/services/earning-service/handlers/native-staking/dtao.js +5 -0
- package/cjs/services/earning-service/handlers/native-staking/mythos.js +28 -0
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +17 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +16 -0
- package/cjs/services/earning-service/handlers/native-staking/tao.js +5 -0
- package/cjs/services/earning-service/service.js +26 -5
- package/cjs/services/history-service/index.js +12 -7
- package/cjs/services/subscan-service/index.js +35 -104
- package/cjs/services/transaction-service/utils.js +10 -1
- package/cjs/strategy/api-request-strategy/index.js +1 -0
- package/cjs/strategy/api-request-strategy/utils/index.js +2 -2
- package/cjs/strategy/api-request-strategy-v2/index.js +138 -0
- package/cjs/strategy/api-request-strategy-v2/types.js +1 -0
- package/cjs/utils/gear/combine.js +4 -3
- package/cjs/utils/gear/vft.js +104 -135
- package/koni/api/nft/ordinal_nft/index.js +3 -2
- package/koni/background/handlers/State.js +4 -1
- package/package.json +20 -9
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +8 -14
- package/services/buy-service/index.js +2 -0
- package/services/chain-service/utils/index.js +3 -0
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +32 -0
- package/services/earning-service/handlers/native-staking/astar.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/astar.js +18 -0
- package/services/earning-service/handlers/native-staking/base.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/base.js +37 -29
- package/services/earning-service/handlers/native-staking/dtao.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/dtao.js +5 -0
- package/services/earning-service/handlers/native-staking/mythos.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/mythos.js +28 -0
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/para-chain.js +17 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +16 -0
- package/services/earning-service/handlers/native-staking/tao.d.ts +1 -0
- package/services/earning-service/handlers/native-staking/tao.js +5 -0
- package/services/earning-service/service.d.ts +1 -0
- package/services/earning-service/service.js +26 -5
- package/services/history-service/index.js +12 -7
- package/services/subscan-service/index.d.ts +13 -27
- package/services/subscan-service/index.js +26 -95
- package/services/transaction-service/utils.js +11 -2
- package/strategy/api-request-strategy/context/base.d.ts +2 -6
- package/strategy/api-request-strategy/index.js +1 -0
- package/strategy/api-request-strategy/types.d.ts +4 -2
- package/strategy/api-request-strategy/utils/index.js +2 -2
- package/strategy/api-request-strategy-v2/index.d.ts +22 -0
- package/strategy/api-request-strategy-v2/index.js +128 -0
- package/strategy/api-request-strategy-v2/types.d.ts +11 -0
- package/strategy/api-request-strategy-v2/types.js +1 -0
- package/types/buy.d.ts +1 -1
- package/utils/gear/combine.d.ts +2 -1
- package/utils/gear/combine.js +4 -4
- package/utils/gear/vft.d.ts +20 -9
- package/utils/gear/vft.js +104 -135
package/cjs/utils/gear/vft.js
CHANGED
|
@@ -3,33 +3,32 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.VftService = exports.VFT = void 0;
|
|
7
|
-
var _api = require("@gear-js/api");
|
|
6
|
+
exports.sailsCache = exports.VftService = exports.VFT = void 0;
|
|
8
7
|
var _sailsJs = require("sails-js");
|
|
9
|
-
var
|
|
8
|
+
var _sailsJsParser = require("sails-js-parser");
|
|
10
9
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
11
10
|
// SPDX-License-Identifier: Apache-2.0
|
|
12
11
|
|
|
13
12
|
class VFT {
|
|
14
13
|
constructor(api) {
|
|
15
14
|
let programId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0x';
|
|
15
|
+
let sails = arguments.length > 2 ? arguments[2] : undefined;
|
|
16
16
|
this.api = api;
|
|
17
17
|
this.programId = programId;
|
|
18
|
-
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
-
types
|
|
22
|
-
});
|
|
23
|
-
this.registry.register(types);
|
|
18
|
+
this.sails = sails;
|
|
19
|
+
this.sails.setApi(api);
|
|
20
|
+
this.sails.setProgramId(programId);
|
|
24
21
|
this.service = new VftService(this);
|
|
25
22
|
}
|
|
26
23
|
newCtorFromCode(code, name, symbol, decimals) {
|
|
27
|
-
const
|
|
24
|
+
const ctor = this.sails.ctors.New;
|
|
25
|
+
const builder = ctor.fromCode(code, name, symbol, decimals);
|
|
28
26
|
this.programId = builder.programId;
|
|
29
27
|
return builder;
|
|
30
28
|
}
|
|
31
29
|
newCtorFromCodeId(codeId, name, symbol, decimals) {
|
|
32
|
-
const
|
|
30
|
+
const ctor = this.sails.ctors.New;
|
|
31
|
+
const builder = ctor.fromCodeId(codeId, name, symbol, decimals);
|
|
33
32
|
this.programId = builder.programId;
|
|
34
33
|
return builder;
|
|
35
34
|
}
|
|
@@ -39,135 +38,105 @@ class VftService {
|
|
|
39
38
|
constructor(_program) {
|
|
40
39
|
this._program = _program;
|
|
41
40
|
}
|
|
41
|
+
get functions() {
|
|
42
|
+
return this._program.sails.services.Vft.functions;
|
|
43
|
+
}
|
|
44
|
+
get queries() {
|
|
45
|
+
return this._program.sails.services.Vft.queries;
|
|
46
|
+
}
|
|
42
47
|
approve(spender, value) {
|
|
43
|
-
|
|
44
|
-
throw new Error('Program ID is not set');
|
|
45
|
-
}
|
|
46
|
-
return new _sailsJs.TransactionBuilder(this._program.api, this._program.registry, 'send_message', ['Vft', 'Approve', spender, value], '(String, String, [u8;32], U256)', 'bool', this._program.programId);
|
|
48
|
+
return this.functions.Approve(spender, value);
|
|
47
49
|
}
|
|
48
50
|
transfer(to, value) {
|
|
49
|
-
|
|
50
|
-
throw new Error('Program ID is not set');
|
|
51
|
-
}
|
|
52
|
-
return new _sailsJs.TransactionBuilder(this._program.api, this._program.registry, 'send_message', ['Vft', 'Transfer', to, value], '(String, String, [u8;32], U256)', 'bool', this._program.programId);
|
|
51
|
+
return this.functions.Transfer(to, value);
|
|
53
52
|
}
|
|
54
53
|
transferFrom(from, to, value) {
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
return this.functions.TransferFrom(from, to, value);
|
|
55
|
+
}
|
|
56
|
+
allowance(owner, spender, originAddress, value, atBlock) {
|
|
57
|
+
return this.queries.Allowance(originAddress, BigInt(value || 0), atBlock, owner, spender);
|
|
58
|
+
}
|
|
59
|
+
balanceOf(account, originAddress, value, atBlock) {
|
|
60
|
+
return this.queries.BalanceOf(originAddress, BigInt(value || 0), atBlock, account);
|
|
61
|
+
}
|
|
62
|
+
decimals(originAddress, value, atBlock) {
|
|
63
|
+
return this.queries.Decimals(originAddress, BigInt(value || 0), atBlock);
|
|
64
|
+
}
|
|
65
|
+
name(originAddress, value, atBlock) {
|
|
66
|
+
return this.queries.Name(originAddress, BigInt(value || 0), atBlock);
|
|
67
|
+
}
|
|
68
|
+
symbol(originAddress, value, atBlock) {
|
|
69
|
+
return this.queries.Symbol(originAddress, BigInt(value || 0), atBlock);
|
|
70
|
+
}
|
|
71
|
+
totalSupply(originAddress, value, atBlock) {
|
|
72
|
+
return this.queries.TotalSupply(originAddress, BigInt(value || 0), atBlock);
|
|
73
|
+
}
|
|
74
|
+
async subscribeToApprovalEvent(callback) {
|
|
75
|
+
return this._program.sails.services.Vft.events.Approval.subscribe(callback);
|
|
76
|
+
}
|
|
77
|
+
async subscribeToTransferEvent(callback) {
|
|
78
|
+
return this._program.sails.services.Vft.events.Transfer.subscribe(callback);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Cache sai
|
|
83
|
+
exports.VftService = VftService;
|
|
84
|
+
const vftIdl = `
|
|
85
|
+
constructor {
|
|
86
|
+
New : (name: str, symbol: str, decimals: u8);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
service Vft {
|
|
90
|
+
Approve : (spender: actor_id, value: u256) -> bool;
|
|
91
|
+
Transfer : (to: actor_id, value: u256) -> bool;
|
|
92
|
+
TransferFrom : (from: actor_id, to: actor_id, value: u256) -> bool;
|
|
93
|
+
|
|
94
|
+
query Allowance : (owner: actor_id, spender: actor_id) -> u256;
|
|
95
|
+
query BalanceOf : (account: actor_id) -> u256;
|
|
96
|
+
query Decimals : () -> u8;
|
|
97
|
+
query Name : () -> str;
|
|
98
|
+
query Symbol : () -> str;
|
|
99
|
+
query TotalSupply : () -> u256;
|
|
100
|
+
|
|
101
|
+
events {
|
|
102
|
+
Approval: struct {
|
|
103
|
+
owner: actor_id,
|
|
104
|
+
spender: actor_id,
|
|
105
|
+
value: u256,
|
|
106
|
+
};
|
|
107
|
+
Transfer: struct {
|
|
108
|
+
from: actor_id,
|
|
109
|
+
to: actor_id,
|
|
110
|
+
value: u256,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
`;
|
|
115
|
+
class SailsCache {
|
|
116
|
+
static instance = null;
|
|
117
|
+
sail = null;
|
|
118
|
+
|
|
119
|
+
// eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function
|
|
120
|
+
constructor() {}
|
|
121
|
+
static getInstance() {
|
|
122
|
+
if (!SailsCache.instance) {
|
|
123
|
+
SailsCache.instance = new SailsCache();
|
|
124
|
+
}
|
|
125
|
+
return SailsCache.instance;
|
|
126
|
+
}
|
|
127
|
+
async init() {
|
|
128
|
+
if (!this.sail) {
|
|
129
|
+
const parser = await _sailsJsParser.SailsIdlParser.new();
|
|
130
|
+
const sails = new _sailsJs.Sails(parser);
|
|
131
|
+
this.sail = sails.parseIdl(vftIdl);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
get() {
|
|
135
|
+
if (!this.sail) {
|
|
136
|
+
throw new Error('Sails is not init yet');
|
|
57
137
|
}
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
async allowance(owner, spender, originAddress, value, atBlock) {
|
|
61
|
-
const payload = this._program.registry.createType('(String, String, [u8;32], [u8;32])', ['Vft', 'Allowance', owner, spender]).toHex();
|
|
62
|
-
const reply = await this._program.api.message.calculateReply({
|
|
63
|
-
destination: this._program.programId,
|
|
64
|
-
origin: (0, _api.decodeAddress)(originAddress),
|
|
65
|
-
payload,
|
|
66
|
-
value: value || 0,
|
|
67
|
-
gasLimit: this._program.api.blockGasLimit.toBigInt(),
|
|
68
|
-
at: atBlock
|
|
69
|
-
});
|
|
70
|
-
const result = this._program.registry.createType('(String, String, U256)', reply.payload);
|
|
71
|
-
return result[2].toBigInt();
|
|
72
|
-
}
|
|
73
|
-
async balanceOf(account, originAddress, value, atBlock) {
|
|
74
|
-
const payload = this._program.registry.createType('(String, String, [u8;32])', ['Vft', 'BalanceOf', account]).toHex();
|
|
75
|
-
const reply = await this._program.api.message.calculateReply({
|
|
76
|
-
destination: this._program.programId,
|
|
77
|
-
origin: (0, _api.decodeAddress)(originAddress),
|
|
78
|
-
payload,
|
|
79
|
-
value: value || 0,
|
|
80
|
-
gasLimit: this._program.api.blockGasLimit.toBigInt(),
|
|
81
|
-
at: atBlock
|
|
82
|
-
});
|
|
83
|
-
const result = this._program.registry.createType('(String, String, U256)', reply.payload);
|
|
84
|
-
return result[2].toBigInt();
|
|
85
|
-
}
|
|
86
|
-
async decimals(originAddress, value, atBlock) {
|
|
87
|
-
const payload = this._program.registry.createType('(String, String)', ['Vft', 'Decimals']).toHex();
|
|
88
|
-
const reply = await this._program.api.message.calculateReply({
|
|
89
|
-
destination: this._program.programId,
|
|
90
|
-
origin: (0, _api.decodeAddress)(originAddress),
|
|
91
|
-
payload,
|
|
92
|
-
value: value || 0,
|
|
93
|
-
gasLimit: this._program.api.blockGasLimit.toBigInt(),
|
|
94
|
-
at: atBlock
|
|
95
|
-
});
|
|
96
|
-
const result = this._program.registry.createType('(String, String, u8)', reply.payload);
|
|
97
|
-
return result[2].toNumber();
|
|
98
|
-
}
|
|
99
|
-
async name(originAddress, value, atBlock) {
|
|
100
|
-
const payload = this._program.registry.createType('(String, String)', ['Vft', 'Name']).toHex();
|
|
101
|
-
const reply = await this._program.api.message.calculateReply({
|
|
102
|
-
destination: this._program.programId,
|
|
103
|
-
origin: (0, _api.decodeAddress)(originAddress),
|
|
104
|
-
payload,
|
|
105
|
-
value: value || 0,
|
|
106
|
-
gasLimit: this._program.api.blockGasLimit.toBigInt(),
|
|
107
|
-
at: atBlock
|
|
108
|
-
});
|
|
109
|
-
const result = this._program.registry.createType('(String, String, String)', reply.payload);
|
|
110
|
-
return result[2].toString();
|
|
111
|
-
}
|
|
112
|
-
async symbol(originAddress, value, atBlock) {
|
|
113
|
-
const payload = this._program.registry.createType('(String, String)', ['Vft', 'Symbol']).toHex();
|
|
114
|
-
const reply = await this._program.api.message.calculateReply({
|
|
115
|
-
destination: this._program.programId,
|
|
116
|
-
origin: (0, _api.decodeAddress)(originAddress),
|
|
117
|
-
payload,
|
|
118
|
-
value: value || 0,
|
|
119
|
-
gasLimit: this._program.api.blockGasLimit.toBigInt(),
|
|
120
|
-
at: atBlock
|
|
121
|
-
});
|
|
122
|
-
const result = this._program.registry.createType('(String, String, String)', reply.payload);
|
|
123
|
-
return result[2].toString();
|
|
124
|
-
}
|
|
125
|
-
async totalSupply(originAddress, value, atBlock) {
|
|
126
|
-
const payload = this._program.registry.createType('(String, String)', ['Vft', 'TotalSupply']).toHex();
|
|
127
|
-
const reply = await this._program.api.message.calculateReply({
|
|
128
|
-
destination: this._program.programId,
|
|
129
|
-
origin: (0, _api.decodeAddress)(originAddress),
|
|
130
|
-
payload,
|
|
131
|
-
value: value || 0,
|
|
132
|
-
gasLimit: this._program.api.blockGasLimit.toBigInt(),
|
|
133
|
-
at: atBlock
|
|
134
|
-
});
|
|
135
|
-
const result = this._program.registry.createType('(String, String, U256)', reply.payload);
|
|
136
|
-
return result[2].toBigInt();
|
|
137
|
-
}
|
|
138
|
-
subscribeToApprovalEvent(callback) {
|
|
139
|
-
return this._program.api.gearEvents.subscribeToGearEvent('UserMessageSent', _ref => {
|
|
140
|
-
let {
|
|
141
|
-
data: {
|
|
142
|
-
message
|
|
143
|
-
}
|
|
144
|
-
} = _ref;
|
|
145
|
-
if (!message.source.eq(this._program.programId) || !message.destination.eq(_sailsJs.ZERO_ADDRESS)) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const payload = message.payload.toHex();
|
|
149
|
-
if ((0, _sailsJs.getServiceNamePrefix)(payload) === 'Vft' && (0, _sailsJs.getFnNamePrefix)(payload) === 'Approval') {
|
|
150
|
-
// eslint-disable-next-line node/no-callback-literal,@typescript-eslint/no-floating-promises
|
|
151
|
-
callback(this._program.registry.createType('(String, String, {"owner":"[u8;32]","spender":"[u8;32]","value":"U256"})', message.payload)[2].toJSON());
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
subscribeToTransferEvent(callback) {
|
|
156
|
-
return this._program.api.gearEvents.subscribeToGearEvent('UserMessageSent', _ref2 => {
|
|
157
|
-
let {
|
|
158
|
-
data: {
|
|
159
|
-
message
|
|
160
|
-
}
|
|
161
|
-
} = _ref2;
|
|
162
|
-
if (!message.source.eq(this._program.programId) || !message.destination.eq(_sailsJs.ZERO_ADDRESS)) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const payload = message.payload.toHex();
|
|
166
|
-
if ((0, _sailsJs.getServiceNamePrefix)(payload) === 'Service' && (0, _sailsJs.getFnNamePrefix)(payload) === 'Transfer') {
|
|
167
|
-
// eslint-disable-next-line node/no-callback-literal,@typescript-eslint/no-floating-promises
|
|
168
|
-
callback(this._program.registry.createType('(String, String, {"from":"[u8;32]","to":"[u8;32]","value":"U256"})', message.payload)[2].toJSON());
|
|
169
|
-
}
|
|
170
|
-
});
|
|
138
|
+
return this.sail;
|
|
171
139
|
}
|
|
172
140
|
}
|
|
173
|
-
|
|
141
|
+
const sailsCache = SailsCache.getInstance();
|
|
142
|
+
exports.sailsCache = sailsCache;
|
|
@@ -46,10 +46,11 @@ export default class OrdinalNftApi extends BaseNftApi {
|
|
|
46
46
|
this.subscanService = SubscanService.getInstance();
|
|
47
47
|
}
|
|
48
48
|
async handleNft(address, handleNftParams) {
|
|
49
|
-
const
|
|
49
|
+
const groupId = this.subscanService.getGroupId();
|
|
50
|
+
const events = await this.subscanService.getAccountRemarkEvents(groupId, this.subscanChain, address);
|
|
50
51
|
if (events && events.length) {
|
|
51
52
|
const extrinsicIds = events.map(data => data.extrinsic_index);
|
|
52
|
-
const extrinsicParams = await this.subscanService.getExtrinsicParams(this.subscanChain, extrinsicIds);
|
|
53
|
+
const extrinsicParams = await this.subscanService.getExtrinsicParams(groupId, this.subscanChain, extrinsicIds);
|
|
53
54
|
const items = [];
|
|
54
55
|
for (const data of extrinsicParams) {
|
|
55
56
|
const {
|
|
@@ -41,7 +41,7 @@ import TransactionService from '@subwallet/extension-base/services/transaction-s
|
|
|
41
41
|
import WalletConnectService from '@subwallet/extension-base/services/wallet-connect-service';
|
|
42
42
|
import { SWStorage } from '@subwallet/extension-base/storage';
|
|
43
43
|
import { BasicTxErrorType } from '@subwallet/extension-base/types';
|
|
44
|
-
import { addLazy, isManifestV3, isSameAddress, reformatAddress, stripUrl, targetIsWeb } from '@subwallet/extension-base/utils';
|
|
44
|
+
import { addLazy, isManifestV3, isSameAddress, reformatAddress, sailsCache, stripUrl, targetIsWeb } from '@subwallet/extension-base/utils';
|
|
45
45
|
import { convertCardanoHexToBech32, validateAddressNetwork } from '@subwallet/extension-base/utils/cardano';
|
|
46
46
|
import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
|
|
47
47
|
import subwalletApiSdk from '@subwallet/subwallet-api-sdk';
|
|
@@ -238,6 +238,9 @@ export default class KoniState {
|
|
|
238
238
|
this.afterChainServiceInit();
|
|
239
239
|
});
|
|
240
240
|
|
|
241
|
+
// init sails
|
|
242
|
+
await sailsCache.init();
|
|
243
|
+
|
|
241
244
|
// Mark app is ready
|
|
242
245
|
this.eventService.emit('general.init', true);
|
|
243
246
|
}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.3.
|
|
20
|
+
"version": "1.3.47-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -2201,6 +2201,16 @@
|
|
|
2201
2201
|
"require": "./cjs/strategy/api-request-strategy/index.js",
|
|
2202
2202
|
"default": "./strategy/api-request-strategy/index.js"
|
|
2203
2203
|
},
|
|
2204
|
+
"./strategy/api-request-strategy-v2": {
|
|
2205
|
+
"types": "./strategy/api-request-strategy-v2/index.d.ts",
|
|
2206
|
+
"require": "./cjs/strategy/api-request-strategy-v2/index.js",
|
|
2207
|
+
"default": "./strategy/api-request-strategy-v2/index.js"
|
|
2208
|
+
},
|
|
2209
|
+
"./strategy/api-request-strategy-v2/types": {
|
|
2210
|
+
"types": "./strategy/api-request-strategy-v2/types.d.ts",
|
|
2211
|
+
"require": "./cjs/strategy/api-request-strategy-v2/types.js",
|
|
2212
|
+
"default": "./strategy/api-request-strategy-v2/types.js"
|
|
2213
|
+
},
|
|
2204
2214
|
"./strategy/api-request-strategy/context/base": {
|
|
2205
2215
|
"types": "./strategy/api-request-strategy/context/base.d.ts",
|
|
2206
2216
|
"require": "./cjs/strategy/api-request-strategy/context/base.js",
|
|
@@ -2829,7 +2839,7 @@
|
|
|
2829
2839
|
"@ethereumjs/common": "^4.1.0",
|
|
2830
2840
|
"@ethereumjs/tx": "^5.1.0",
|
|
2831
2841
|
"@ethersproject/abi": "^5.7.0",
|
|
2832
|
-
"@gear-js/api": "^0.
|
|
2842
|
+
"@gear-js/api": "^0.42.0",
|
|
2833
2843
|
"@json-rpc-tools/utils": "^1.7.6",
|
|
2834
2844
|
"@metamask/eth-sig-util": "^7.0.3",
|
|
2835
2845
|
"@metamask/safe-event-emitter": "^2.0.0",
|
|
@@ -2855,13 +2865,13 @@
|
|
|
2855
2865
|
"@reduxjs/toolkit": "^1.9.1",
|
|
2856
2866
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
2857
2867
|
"@substrate/connect": "^0.8.9",
|
|
2858
|
-
"@subwallet/chain-list": "0.2.
|
|
2859
|
-
"@subwallet/extension-base": "^1.3.
|
|
2860
|
-
"@subwallet/extension-chains": "^1.3.
|
|
2861
|
-
"@subwallet/extension-dapp": "^1.3.
|
|
2862
|
-
"@subwallet/extension-inject": "^1.3.
|
|
2868
|
+
"@subwallet/chain-list": "0.2.109",
|
|
2869
|
+
"@subwallet/extension-base": "^1.3.47-0",
|
|
2870
|
+
"@subwallet/extension-chains": "^1.3.47-0",
|
|
2871
|
+
"@subwallet/extension-dapp": "^1.3.47-0",
|
|
2872
|
+
"@subwallet/extension-inject": "^1.3.47-0",
|
|
2863
2873
|
"@subwallet/keyring": "^0.1.12",
|
|
2864
|
-
"@subwallet/subwallet-api-sdk": "^1.3.
|
|
2874
|
+
"@subwallet/subwallet-api-sdk": "^1.3.47-0",
|
|
2865
2875
|
"@subwallet/ui-keyring": "^0.1.12",
|
|
2866
2876
|
"@ton/core": "^0.56.3",
|
|
2867
2877
|
"@ton/crypto": "^3.2.0",
|
|
@@ -2894,7 +2904,8 @@
|
|
|
2894
2904
|
"moment": "^2.29.4",
|
|
2895
2905
|
"protobufjs": "^7.2.4",
|
|
2896
2906
|
"rxjs": "^7.8.1",
|
|
2897
|
-
"sails-js": "^0.
|
|
2907
|
+
"sails-js": "^0.4.2",
|
|
2908
|
+
"sails-js-parser": "^0.4.2",
|
|
2898
2909
|
"ts-md5": "^1.3.1",
|
|
2899
2910
|
"tweetnacl": "^1.0.3",
|
|
2900
2911
|
"uuid": "^9.0.0",
|
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.
|
|
10
|
+
version: '1.3.47-0'
|
|
11
11
|
};
|
|
@@ -324,17 +324,15 @@ const subscribeTokensAccountsPallet = async ({
|
|
|
324
324
|
const tokensAccountsKey = 'query_tokens_accounts';
|
|
325
325
|
const tokenTypes = includeNativeToken ? [_AssetType.NATIVE, _AssetType.LOCAL] : [_AssetType.LOCAL];
|
|
326
326
|
const tokenMap = filterAssetsByChainAndType(assetMap, chainInfo.slug, tokenTypes);
|
|
327
|
-
|
|
328
|
-
// Hotfix balance for gdot
|
|
329
|
-
const getGdotBalance = async () => {
|
|
330
|
-
const gdotBalances = await queryGdotBalance(substrateApi, addresses, assetMap[gdotSlug], extrinsicType);
|
|
331
|
-
callback(gdotBalances);
|
|
332
|
-
};
|
|
333
327
|
const unsubList = await Promise.all(Object.values(tokenMap).map(tokenInfo => {
|
|
334
|
-
|
|
335
|
-
if (tokenInfo.
|
|
328
|
+
var _tokenInfo$metadata;
|
|
329
|
+
if ((_tokenInfo$metadata = tokenInfo.metadata) !== null && _tokenInfo$metadata !== void 0 && _tokenInfo$metadata.isGigaToken) {
|
|
336
330
|
return timer(0, CRON_REFRESH_PRICE_INTERVAL).subscribe(() => {
|
|
337
|
-
|
|
331
|
+
const getGigaTokenBalance = async () => {
|
|
332
|
+
const gigaTokenBalances = await queryGigaTokenBalance(substrateApi, addresses, assetMap[tokenInfo.slug], extrinsicType);
|
|
333
|
+
callback(gigaTokenBalances);
|
|
334
|
+
};
|
|
335
|
+
getGigaTokenBalance().catch(console.error);
|
|
338
336
|
});
|
|
339
337
|
}
|
|
340
338
|
try {
|
|
@@ -543,11 +541,7 @@ const subscribeSubnetAlphaPallet = async ({
|
|
|
543
541
|
clearInterval(interval);
|
|
544
542
|
};
|
|
545
543
|
};
|
|
546
|
-
|
|
547
|
-
// Hot fix for gdot balance
|
|
548
|
-
|
|
549
|
-
const gdotSlug = 'hydradx_main-LOCAL-GDOT';
|
|
550
|
-
async function queryGdotBalance(substrateApi, addresses, tokenInfo, extrinsicType) {
|
|
544
|
+
async function queryGigaTokenBalance(substrateApi, addresses, tokenInfo, extrinsicType) {
|
|
551
545
|
return await Promise.all(addresses.map(async address => {
|
|
552
546
|
const _balanceInfo = await substrateApi.api.call.currenciesApi.account(_getTokenOnChainAssetId(tokenInfo), address);
|
|
553
547
|
const balanceInfo = _balanceInfo.toPrimitive();
|
|
@@ -432,6 +432,9 @@ export function _getBlockExplorerFromChain(chainInfo) {
|
|
|
432
432
|
} else if (_isPureBitcoinChain(chainInfo)) {
|
|
433
433
|
var _chainInfo$bitcoinInf;
|
|
434
434
|
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$bitcoinInf = chainInfo.bitcoinInfo) === null || _chainInfo$bitcoinInf === void 0 ? void 0 : _chainInfo$bitcoinInf.blockExplorer;
|
|
435
|
+
} else if (_isPureTonChain(chainInfo)) {
|
|
436
|
+
var _chainInfo$tonInfo;
|
|
437
|
+
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$tonInfo = chainInfo.tonInfo) === null || _chainInfo$tonInfo === void 0 ? void 0 : _chainInfo$tonInfo.blockExplorer;
|
|
435
438
|
} else {
|
|
436
439
|
var _chainInfo$substrateI18;
|
|
437
440
|
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI18 = chainInfo.substrateInfo) === null || _chainInfo$substrateI18 === void 0 ? void 0 : _chainInfo$substrateI18.blockExplorer;
|
|
@@ -5,7 +5,7 @@ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
|
5
5
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
6
6
|
const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
|
|
7
7
|
const fetchFile = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
|
|
8
|
-
const ChainListVersion = '0.2.
|
|
8
|
+
const ChainListVersion = '0.2.109'; // update this when build chainlist
|
|
9
9
|
|
|
10
10
|
// todo: move this interface to chainlist
|
|
11
11
|
|
|
@@ -7,6 +7,7 @@ import BaseParaNativeStakingPoolHandler from './base-para';
|
|
|
7
7
|
export default class AmplitudeNativeStakingPoolHandler extends BaseParaNativeStakingPoolHandler {
|
|
8
8
|
subscribePoolInfo(callback: (data: YieldPoolInfo) => void): Promise<VoidFunction>;
|
|
9
9
|
parseNominatorMetadata(chainInfo: _ChainInfo, address: string, substrateApi: _SubstrateApi, delegatorState: ParachainStakingStakeOption[], unstakingInfo: Record<string, number>): Promise<Omit<YieldPositionInfo, keyof BaseYieldPositionInfo>>;
|
|
10
|
+
checkAccountHaveStake(useAddresses: string[]): Promise<string[]>;
|
|
10
11
|
subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
11
12
|
getPoolReward(useAddresses: string[], callBack: (rs: EarningRewardItem) => void): Promise<VoidFunction>;
|
|
12
13
|
getKrestPoolTargets(chainApi: _SubstrateApi): Promise<ValidatorInfo[]>;
|
|
@@ -171,6 +171,38 @@ export default class AmplitudeNativeStakingPoolHandler extends BaseParaNativeSta
|
|
|
171
171
|
unstakings: unstakingList
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
|
+
async checkAccountHaveStake(useAddresses) {
|
|
175
|
+
var _substrateApi$api$que, _substrateApi$api$que2, _substrateApi$api$que3, _substrateApi$api$que4, _substrateApi$api$que5, _substrateApi$api$que6;
|
|
176
|
+
const result = [];
|
|
177
|
+
const substrateApi = await this.substrateApi.isReady;
|
|
178
|
+
const ledgers = await ((_substrateApi$api$que = substrateApi.api.query.parachainStaking) === null || _substrateApi$api$que === void 0 ? void 0 : (_substrateApi$api$que2 = _substrateApi$api$que.delegatorState) === null || _substrateApi$api$que2 === void 0 ? void 0 : (_substrateApi$api$que3 = _substrateApi$api$que2.multi) === null || _substrateApi$api$que3 === void 0 ? void 0 : _substrateApi$api$que3.call(_substrateApi$api$que2, useAddresses));
|
|
179
|
+
const _unstakingStates = await ((_substrateApi$api$que4 = substrateApi.api.query.parachainStaking) === null || _substrateApi$api$que4 === void 0 ? void 0 : (_substrateApi$api$que5 = _substrateApi$api$que4.unstaking) === null || _substrateApi$api$que5 === void 0 ? void 0 : (_substrateApi$api$que6 = _substrateApi$api$que5.multi) === null || _substrateApi$api$que6 === void 0 ? void 0 : _substrateApi$api$que6.call(_substrateApi$api$que5, useAddresses));
|
|
180
|
+
if (!ledgers || !_unstakingStates) {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
183
|
+
for (let i = 0; i < useAddresses.length; i++) {
|
|
184
|
+
const owner = useAddresses[i];
|
|
185
|
+
const _delegatorState = ledgers[i];
|
|
186
|
+
let delegatorState = [];
|
|
187
|
+
const unstakingInfo = _unstakingStates[i].toPrimitive();
|
|
188
|
+
if (_STAKING_CHAIN_GROUP.krest_network.includes(this.chain)) {
|
|
189
|
+
const krestDelegatorState = _delegatorState.toPrimitive();
|
|
190
|
+
const delegates = krestDelegatorState === null || krestDelegatorState === void 0 ? void 0 : krestDelegatorState.delegations;
|
|
191
|
+
if (delegates) {
|
|
192
|
+
delegatorState = delegatorState.concat(delegates);
|
|
193
|
+
}
|
|
194
|
+
} else {
|
|
195
|
+
const delegate = _delegatorState.toPrimitive();
|
|
196
|
+
if (delegate) {
|
|
197
|
+
delegatorState.push(delegate);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (delegatorState.length || unstakingInfo && Object.keys(unstakingInfo).length) {
|
|
201
|
+
result.push(owner);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return Promise.resolve(result);
|
|
205
|
+
}
|
|
174
206
|
async subscribePoolPosition(useAddresses, resultCallback) {
|
|
175
207
|
let cancel = false;
|
|
176
208
|
const substrateApi = await this.substrateApi.isReady;
|
|
@@ -9,6 +9,7 @@ export default class AstarNativeStakingPoolHandler extends BaseParaNativeStaking
|
|
|
9
9
|
subscribePoolInfo(callback: (data: YieldPoolInfo) => void): Promise<VoidFunction>;
|
|
10
10
|
parseNominatorMetadata(chainInfo: _ChainInfo, address: string, substrateApi: _SubstrateApi, ledger: PalletDappsStakingAccountLedger): Promise<Omit<YieldPositionInfo, keyof BaseYieldPositionInfo>>;
|
|
11
11
|
subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
12
|
+
checkAccountHaveStake(useAddresses: string[]): Promise<Array<string>>;
|
|
12
13
|
getPoolTargets(): Promise<ValidatorInfo[]>;
|
|
13
14
|
get defaultSubmitStep(): YieldStepBaseInfo;
|
|
14
15
|
createJoinExtrinsic(data: SubmitJoinNativeStaking, positionInfo?: YieldPositionInfo, bondDest?: string): Promise<[TransactionData, YieldTokenBaseInfo]>;
|
|
@@ -286,6 +286,24 @@ export default class AstarNativeStakingPoolHandler extends BaseParaNativeStaking
|
|
|
286
286
|
unsub && unsub();
|
|
287
287
|
};
|
|
288
288
|
}
|
|
289
|
+
async checkAccountHaveStake(useAddresses) {
|
|
290
|
+
var _substrateApi$api$que2, _substrateApi$api$que3, _substrateApi$api$que4;
|
|
291
|
+
const result = [];
|
|
292
|
+
const substrateApi = await this.substrateApi.isReady;
|
|
293
|
+
const ledgers = await ((_substrateApi$api$que2 = substrateApi.api.query.dappsStaking) === null || _substrateApi$api$que2 === void 0 ? void 0 : (_substrateApi$api$que3 = _substrateApi$api$que2.ledger) === null || _substrateApi$api$que3 === void 0 ? void 0 : (_substrateApi$api$que4 = _substrateApi$api$que3.multi) === null || _substrateApi$api$que4 === void 0 ? void 0 : _substrateApi$api$que4.call(_substrateApi$api$que3, useAddresses));
|
|
294
|
+
if (!ledgers) {
|
|
295
|
+
return [];
|
|
296
|
+
}
|
|
297
|
+
for (let i = 0; i < useAddresses.length; i++) {
|
|
298
|
+
const owner = useAddresses[i];
|
|
299
|
+
const _ledger = ledgers[i];
|
|
300
|
+
const ledger = _ledger.toPrimitive();
|
|
301
|
+
if (ledger && ledger.locked > 0) {
|
|
302
|
+
result.push(owner);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return result;
|
|
306
|
+
}
|
|
289
307
|
|
|
290
308
|
/* Subscribe pool position */
|
|
291
309
|
|
|
@@ -12,6 +12,7 @@ export default abstract class BaseNativeStakingPoolHandler extends BasePoolHandl
|
|
|
12
12
|
constructor(state: KoniState, chain: string);
|
|
13
13
|
protected getDescription(amount?: string): string;
|
|
14
14
|
getPoolReward(useAddresses: string[], callBack: (rs: EarningRewardItem) => void): Promise<VoidFunction>;
|
|
15
|
+
abstract checkAccountHaveStake(useAddresses: string[]): Promise<Array<string>>;
|
|
15
16
|
getPoolRewardHistory(useAddresses: string[], callBack: (rs: EarningRewardHistoryItem) => void): Promise<VoidFunction>;
|
|
16
17
|
get defaultSubmitStep(): YieldStepBaseInfo;
|
|
17
18
|
abstract createJoinExtrinsic(data: SubmitJoinNativeStaking, positionInfo?: YieldPositionInfo, bondDest?: string, netuid?: number): Promise<[TransactionData, YieldTokenBaseInfo]>;
|
|
@@ -42,40 +42,48 @@ export default class BaseNativeStakingPoolHandler extends BasePoolHandler {
|
|
|
42
42
|
async getPoolRewardHistory(useAddresses, callBack) {
|
|
43
43
|
let cancel = false;
|
|
44
44
|
const haveSubscanService = this.state.subscanService.checkSupportedSubscanChain(this.chain);
|
|
45
|
+
const requestGroupId = this.state.subscanService.getGroupId();
|
|
45
46
|
if (haveSubscanService) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
const rs = await this.state.subscanService.getRewardHistoryList(this.chain, address);
|
|
52
|
-
const items = rs === null || rs === void 0 ? void 0 : rs.list;
|
|
53
|
-
if (items) {
|
|
54
|
-
for (const item of items) {
|
|
55
|
-
const now = new Date();
|
|
56
|
-
const isMillisecond = now.getTime().toString().length === item.block_timestamp.toString().length;
|
|
57
|
-
const timeStamp = isMillisecond ? item.block_timestamp : item.block_timestamp * 1000;
|
|
58
|
-
const data = {
|
|
59
|
-
slug: this.slug,
|
|
60
|
-
type: this.type,
|
|
61
|
-
chain: this.chain,
|
|
62
|
-
address: address,
|
|
63
|
-
group: this.group,
|
|
64
|
-
blockTimestamp: timeStamp,
|
|
65
|
-
amount: item.amount,
|
|
66
|
-
eventIndex: item.event_index
|
|
67
|
-
};
|
|
68
|
-
callBack(data);
|
|
69
|
-
}
|
|
47
|
+
this.checkAccountHaveStake(useAddresses).then(activeAddresses => {
|
|
48
|
+
for (const address of useAddresses) {
|
|
49
|
+
if (cancel) {
|
|
50
|
+
break;
|
|
70
51
|
}
|
|
71
|
-
|
|
72
|
-
|
|
52
|
+
if (!activeAddresses.includes(address)) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
this.state.subscanService.getRewardHistoryList(requestGroupId, this.chain, address).then(rs => {
|
|
56
|
+
const items = rs === null || rs === void 0 ? void 0 : rs.list;
|
|
57
|
+
if (cancel) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (items) {
|
|
61
|
+
for (const item of items) {
|
|
62
|
+
const now = new Date();
|
|
63
|
+
const isMillisecond = now.getTime().toString().length === item.block_timestamp.toString().length;
|
|
64
|
+
const timeStamp = isMillisecond ? item.block_timestamp : item.block_timestamp * 1000;
|
|
65
|
+
const data = {
|
|
66
|
+
slug: this.slug,
|
|
67
|
+
type: this.type,
|
|
68
|
+
chain: this.chain,
|
|
69
|
+
address: address,
|
|
70
|
+
group: this.group,
|
|
71
|
+
blockTimestamp: timeStamp,
|
|
72
|
+
amount: item.amount,
|
|
73
|
+
eventIndex: item.event_index
|
|
74
|
+
};
|
|
75
|
+
callBack(data);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}).catch(console.error);
|
|
73
79
|
}
|
|
74
|
-
}
|
|
80
|
+
}).catch(console.error);
|
|
75
81
|
}
|
|
76
|
-
return () => {
|
|
82
|
+
return Promise.resolve(() => {
|
|
83
|
+
console.log('Cancel get pool reward history', requestGroupId);
|
|
77
84
|
cancel = false;
|
|
78
|
-
|
|
85
|
+
this.state.subscanService.cancelGroupRequest(requestGroupId);
|
|
86
|
+
});
|
|
79
87
|
}
|
|
80
88
|
|
|
81
89
|
/* Get pool reward */
|
|
@@ -61,6 +61,7 @@ export default class SubnetTaoStakingPoolHandler extends BaseParaStakingPoolHand
|
|
|
61
61
|
subscribePoolInfo(callback: (data: YieldPoolInfo) => void): Promise<VoidFunction>;
|
|
62
62
|
parseNominatorMetadata(chainInfo: _ChainInfo, address: string, delegatorState: TaoStakingStakeOption[]): Promise<Omit<YieldPositionInfo, keyof BaseYieldPositionInfo>>;
|
|
63
63
|
subscribePoolPosition(useAddresses: string[], rsCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
64
|
+
checkAccountHaveStake(useAddresses: string[]): Promise<string[]>;
|
|
64
65
|
private getDevnetPoolTargets;
|
|
65
66
|
private getMainnetPoolTargets;
|
|
66
67
|
getPoolTargets(): Promise<ValidatorInfo[]>;
|
|
@@ -364,6 +364,11 @@ export default class SubnetTaoStakingPoolHandler extends BaseParaStakingPoolHand
|
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
+
// Because not have subscan api
|
|
368
|
+
async checkAccountHaveStake(useAddresses) {
|
|
369
|
+
return Promise.resolve([]);
|
|
370
|
+
}
|
|
371
|
+
|
|
367
372
|
/* Subscribe pool position */
|
|
368
373
|
|
|
369
374
|
/* Get pool targets */
|
|
@@ -13,6 +13,7 @@ interface PalletCollatorStakingUserStakeInfo {
|
|
|
13
13
|
export default class MythosNativeStakingPoolHandler extends BaseParaStakingPoolHandler {
|
|
14
14
|
protected readonly availableMethod: YieldPoolMethodInfo;
|
|
15
15
|
subscribePoolInfo(callback: (data: YieldPoolInfo) => void): Promise<VoidFunction>;
|
|
16
|
+
checkAccountHaveStake(useAddresses: string[]): Promise<Array<string>>;
|
|
16
17
|
subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
17
18
|
parseCollatorMetadata(chainInfo: _ChainInfo, stakerAddress: string, substrateApi: _SubstrateApi, userStake: PalletCollatorStakingUserStakeInfo): Promise<{
|
|
18
19
|
status: EarningStatus;
|