@subwallet/extension-base 1.2.19-0 → 1.2.21-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/constants/staking.js +5 -11
- package/cjs/koni/api/nft/blobinscription/consts.js +17 -0
- package/cjs/koni/api/nft/blobinscription/index.js +159 -0
- package/cjs/koni/api/nft/blobinscription/types.js +25 -0
- package/cjs/koni/api/nft/config.js +3 -1
- package/cjs/koni/api/nft/index.js +3 -0
- package/cjs/koni/api/staking/bonding/utils.js +8 -7
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +7 -1
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +1 -1
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +1 -1
- package/cjs/utils/fetchStaticData.js +1 -0
- package/constants/staking.d.ts +1 -1
- package/constants/staking.js +3 -9
- package/koni/api/nft/blobinscription/consts.d.ts +6 -0
- package/koni/api/nft/blobinscription/consts.js +9 -0
- package/koni/api/nft/blobinscription/index.d.ts +13 -0
- package/koni/api/nft/blobinscription/index.js +151 -0
- package/koni/api/nft/blobinscription/types.d.ts +39 -0
- package/koni/api/nft/blobinscription/types.js +19 -0
- package/koni/api/nft/config.d.ts +1 -0
- package/koni/api/nft/config.js +2 -0
- package/koni/api/nft/index.js +3 -0
- package/koni/api/staking/bonding/utils.d.ts +1 -1
- package/koni/api/staking/bonding/utils.js +8 -7
- package/package.json +21 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.d.ts +1 -0
- package/services/chain-service/constants.js +7 -1
- package/services/earning-service/handlers/native-staking/relay-chain.js +1 -1
- package/services/earning-service/handlers/nomination-pool/index.js +1 -1
- package/utils/fetchStaticData.js +1 -0
package/cjs/constants/staking.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.PREDEFINED_STAKING_POOL = exports.
|
|
6
|
+
exports.PREDEFINED_STAKING_POOL = exports.PREDEFINED_EARNING_POOL_PROMISE = exports.MAX_NOMINATIONS = void 0;
|
|
7
|
+
var _utils = require("@subwallet/extension-base/utils");
|
|
7
8
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
8
9
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
10
|
|
|
@@ -15,14 +16,7 @@ const PREDEFINED_STAKING_POOL = {
|
|
|
15
16
|
availTuringTest: 11
|
|
16
17
|
};
|
|
17
18
|
exports.PREDEFINED_STAKING_POOL = PREDEFINED_STAKING_POOL;
|
|
18
|
-
const PREDEFINED_EARNING_POOL = {
|
|
19
|
-
polkadot: [39],
|
|
20
|
-
kusama: [80],
|
|
21
|
-
vara_network: [62, 29, 50],
|
|
22
|
-
aleph: [82],
|
|
23
|
-
availTuringTest: [11],
|
|
24
|
-
avail_mainnet: [12, 4]
|
|
25
|
-
};
|
|
26
|
-
exports.PREDEFINED_EARNING_POOL = PREDEFINED_EARNING_POOL;
|
|
27
19
|
const MAX_NOMINATIONS = '16';
|
|
28
|
-
exports.MAX_NOMINATIONS = MAX_NOMINATIONS;
|
|
20
|
+
exports.MAX_NOMINATIONS = MAX_NOMINATIONS;
|
|
21
|
+
const PREDEFINED_EARNING_POOL_PROMISE = (0, _utils.fetchStaticData)('nomination-pool-recommendation');
|
|
22
|
+
exports.PREDEFINED_EARNING_POOL_PROMISE = PREDEFINED_EARNING_POOL_PROMISE;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.COLLECT_ID = exports.ALC_NFT_RAW_VALUE = void 0;
|
|
7
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
|
|
10
|
+
const COLLECT_ID = 'Avail OG';
|
|
11
|
+
exports.COLLECT_ID = COLLECT_ID;
|
|
12
|
+
const ALC_NFT_RAW_VALUE = {
|
|
13
|
+
BRONZE: '{"p":"OIS-AVAIL","op":"create","tick":"AVAIL-OG","imgUrl":"https://storage.googleapis.com/blobscriptions.appspot.com/user-uploads%2Fclyy54fsc0001jpr1bi3thgp7%2F1721723052313-mkyf6c7hkfv9v0mgu0itbof7-bronzeNFT.mp4","tokenType":"NFT","totalSupply":"5000","limit":"5000","traits":{"Tier":"bronze"},"name":"Bronze #AVAIL"}',
|
|
14
|
+
SILVER: '{"p":"OIS-AVAIL","op":"create","tick":"AVAIL-OG","imgUrl":"https://storage.googleapis.com/blobscriptions.appspot.com/user-uploads%2Fclyy54fsc0001jpr1bi3thgp7%2F1721722886703-hnhan3yc1ma9v8euheq8aj21-silverNFT.mp4","tokenType":"NFT","totalSupply":"4000","limit":"4000","traits":{"Tier":"silver"},"name":"Silver #AVAIl"}',
|
|
15
|
+
GOLD: '{"p":"OIS-AVAIL","op":"create","tick":"AVAIL-OG","imgUrl":"https://storage.googleapis.com/blobscriptions.appspot.com/user-uploads%2Fclyy54fsc0001jpr1bi3thgp7%2F1721722632268-mdwdbwp1yv58iuyl4zzzr3t8-goldNFT.mp4","tokenType":"NFT","totalSupply":"1000","limit":"1000","traits":{"Tier":"gold"},"name":"Gold #AVAIL"}'
|
|
16
|
+
};
|
|
17
|
+
exports.ALC_NFT_RAW_VALUE = ALC_NFT_RAW_VALUE;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BlobInscriptionApi = void 0;
|
|
7
|
+
var _consts = require("@subwallet/extension-base/koni/api/nft/blobinscription/consts");
|
|
8
|
+
var _types = require("@subwallet/extension-base/koni/api/nft/blobinscription/types");
|
|
9
|
+
var _config = require("@subwallet/extension-base/koni/api/nft/config");
|
|
10
|
+
var _nft = require("@subwallet/extension-base/koni/api/nft/nft");
|
|
11
|
+
var _util = require("@polkadot/util");
|
|
12
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
13
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
14
|
+
|
|
15
|
+
class BlobInscriptionApi extends _nft.BaseNftApi {
|
|
16
|
+
endpoint = _config.AVAIL_LIGHT_CLIENT_NFT;
|
|
17
|
+
constructor(chain, addresses) {
|
|
18
|
+
super(chain, undefined, addresses);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Get all NFTs //
|
|
22
|
+
|
|
23
|
+
static parseNftRequestRemark() {
|
|
24
|
+
return {
|
|
25
|
+
query: `
|
|
26
|
+
query MyQuery {
|
|
27
|
+
remarks(limit: 10000, where: {extrinsicHash_eq: "0xa3974497d44d0e1e5a06dc6ceb6cae48dcd9ef2a0369e89d01276830096d32d8", OR: {extrinsicHash_eq: "0x0b789bc0ebe0505700c41cec5986948530e59f444c9383b5ff5d6d3daa14cece", OR: {extrinsicHash_eq: "0x37b0aaee83e907d445f41f769731cf8f1bc17c2c211cdb47262f6ca220e9f976"}}}) {
|
|
28
|
+
dataRaw
|
|
29
|
+
extrinsicHash
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async getAllInscriptions() {
|
|
36
|
+
const response = await fetch(this.endpoint, {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: {
|
|
39
|
+
'Content-Type': 'application/json'
|
|
40
|
+
},
|
|
41
|
+
body: JSON.stringify(BlobInscriptionApi.parseNftRequestRemark())
|
|
42
|
+
});
|
|
43
|
+
const result = await response.json();
|
|
44
|
+
return result.data.remarks;
|
|
45
|
+
}
|
|
46
|
+
async getNftMap() {
|
|
47
|
+
const nftMap = {};
|
|
48
|
+
const rawList = await this.getAllInscriptions();
|
|
49
|
+
rawList.forEach(item => {
|
|
50
|
+
const jsonData = JSON.parse((0, _util.hexToString)(item.dataRaw));
|
|
51
|
+
if (nftMap[jsonData.to]) {
|
|
52
|
+
nftMap[jsonData.to].push(jsonData.tick);
|
|
53
|
+
}
|
|
54
|
+
nftMap[jsonData.to] = [jsonData.tick];
|
|
55
|
+
});
|
|
56
|
+
return nftMap;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Get all NFTs //
|
|
60
|
+
|
|
61
|
+
// Deprecated: Old get NFTs balance //
|
|
62
|
+
|
|
63
|
+
static parseNftRequest(address) {
|
|
64
|
+
let isJson = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
65
|
+
// noted: check to handle isJson
|
|
66
|
+
return {
|
|
67
|
+
query: `
|
|
68
|
+
query MyQuery {
|
|
69
|
+
dataAvailabilities(where: {sender: {address_eq: "${address}"}, isJson_eq: ${isJson.toString()}}) {
|
|
70
|
+
id
|
|
71
|
+
extrinsicHash
|
|
72
|
+
dataRaw
|
|
73
|
+
dataValue
|
|
74
|
+
isJson
|
|
75
|
+
sender {
|
|
76
|
+
address
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
async getBalances(address) {
|
|
86
|
+
var _result$data;
|
|
87
|
+
const response = await fetch(this.endpoint, {
|
|
88
|
+
method: 'POST',
|
|
89
|
+
headers: {
|
|
90
|
+
'Content-Type': 'application/json'
|
|
91
|
+
},
|
|
92
|
+
body: JSON.stringify(BlobInscriptionApi.parseNftRequest(address))
|
|
93
|
+
});
|
|
94
|
+
const result = await response.json();
|
|
95
|
+
return result === null || result === void 0 ? void 0 : (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.dataAvailabilities;
|
|
96
|
+
}
|
|
97
|
+
handleProperties(data) {
|
|
98
|
+
const propertiesMap = {};
|
|
99
|
+
const attRecord = data.traits;
|
|
100
|
+
if (attRecord) {
|
|
101
|
+
for (const [name, value] of Object.entries(attRecord)) {
|
|
102
|
+
propertiesMap[name] = {
|
|
103
|
+
value: value
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return propertiesMap;
|
|
108
|
+
}
|
|
109
|
+
async handleNfts(params) {
|
|
110
|
+
const allInscriptionsMap = await this.getNftMap();
|
|
111
|
+
try {
|
|
112
|
+
// eslint-disable-next-line array-callback-return
|
|
113
|
+
await Promise.all(this.addresses.map(address => {
|
|
114
|
+
const nfts = allInscriptionsMap[address];
|
|
115
|
+
if (nfts) {
|
|
116
|
+
const collectionMap = {};
|
|
117
|
+
for (const nft of nfts) {
|
|
118
|
+
const nftDetail = (0, _types.getNftDetail)(nft);
|
|
119
|
+
if (!nftDetail) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const propertiesMap = this.handleProperties(nftDetail);
|
|
123
|
+
const parsedNft = {
|
|
124
|
+
id: address,
|
|
125
|
+
// is distinct?
|
|
126
|
+
chain: this.chain,
|
|
127
|
+
owner: address,
|
|
128
|
+
name: nftDetail.name,
|
|
129
|
+
image: nftDetail.imgUrl,
|
|
130
|
+
collectionId: nftDetail.tick,
|
|
131
|
+
properties: propertiesMap
|
|
132
|
+
};
|
|
133
|
+
params.updateItem(this.chain, parsedNft, address);
|
|
134
|
+
if (!collectionMap[nftDetail.tick]) {
|
|
135
|
+
const parsedCollection = {
|
|
136
|
+
collectionId: nftDetail.tick,
|
|
137
|
+
chain: this.chain,
|
|
138
|
+
collectionName: _consts.COLLECT_ID
|
|
139
|
+
};
|
|
140
|
+
collectionMap[nftDetail.tick] = parsedCollection;
|
|
141
|
+
params.updateCollection(this.chain, parsedCollection);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}));
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error('Failed to fetch blob inscription', error);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async fetchNfts(params) {
|
|
151
|
+
try {
|
|
152
|
+
await this.handleNfts(params);
|
|
153
|
+
} catch (e) {
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
return 1;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.BlobInscriptionApi = BlobInscriptionApi;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getNftDetail = getNftDetail;
|
|
7
|
+
var _consts = require("@subwallet/extension-base/koni/api/nft/blobinscription/consts");
|
|
8
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
9
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
10
|
+
|
|
11
|
+
function getNftDetail(nftSlug) {
|
|
12
|
+
if (nftSlug === 'AVAIL-OG-sqsu5a91qbu0s4oj3ldg8lrf') {
|
|
13
|
+
// Gold
|
|
14
|
+
return JSON.parse(_consts.ALC_NFT_RAW_VALUE.GOLD);
|
|
15
|
+
}
|
|
16
|
+
if (nftSlug === 'AVAIL-OG-zdttjyidincrjgsmwqbxoghz') {
|
|
17
|
+
// Silver
|
|
18
|
+
return JSON.parse(_consts.ALC_NFT_RAW_VALUE.SILVER);
|
|
19
|
+
}
|
|
20
|
+
if (nftSlug === 'AVAIL-OG-zy0n66yqtgw6z139hnf5vdxb') {
|
|
21
|
+
// Bronze
|
|
22
|
+
return JSON.parse(_consts.ALC_NFT_RAW_VALUE.BRONZE);
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.W3S_IPFS = exports.VARA_SCAN_ENDPOINT = exports.UNSUPPORTED_TRANSFER_EVM_CHAIN_NAME = exports.UNIQUE_SCAN_ENDPOINT = exports.UNIQUE_IPFS_GATEWAY = exports.TRANSFER_CHAIN_ID = exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN = exports.SUPPORTED_NFT_NETWORKS = exports.SUBWALLET_IPFS = exports.SINGULAR_V2_ENDPOINT = exports.SINGULAR_V2_COLLECTION_ENDPOINT = exports.SINGULAR_V1_ENDPOINT = exports.SINGULAR_V1_COLLECTION_ENDPOINT = exports.RMRK_PINATA_SERVER = exports.QUARTZ_SCAN_ENDPOINT = exports.PINATA_IPFS_GATEWAY = exports.OPAL_SCAN_ENDPOINT = exports.NFT_STORAGE_GATEWAY = exports.KANARIA_EXTERNAL_SERVER = exports.KANARIA_ENDPOINT = exports.IPFS_W3S_LINK = exports.IPFS_IO = exports.IPFS_GATEWAY_4EVERLAND = exports.IPFS_FLEEK = exports.IPFS_ETH_ARAGON = exports.IPFS2_RMRK = exports.GATEWAY_IPFS_IO = exports.DWEB_LINK = exports.CLOUDFLARE_PINATA_SERVER = exports.CF_IPFS_GATEWAY = exports.BIT_COUNTRY_THUMBNAIL_RESOLVER = exports.BIT_COUNTRY_LAND_ESTATE_METADATA_API = exports.BIT_COUNTRY_IPFS_SERVER = exports.BIT_AVATAR_API = void 0;
|
|
6
|
+
exports.W3S_IPFS = exports.VARA_SCAN_ENDPOINT = exports.UNSUPPORTED_TRANSFER_EVM_CHAIN_NAME = exports.UNIQUE_SCAN_ENDPOINT = exports.UNIQUE_IPFS_GATEWAY = exports.TRANSFER_CHAIN_ID = exports.SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN_NAME = exports.SUPPORTED_TRANSFER_EVM_CHAIN = exports.SUPPORTED_NFT_NETWORKS = exports.SUBWALLET_IPFS = exports.SINGULAR_V2_ENDPOINT = exports.SINGULAR_V2_COLLECTION_ENDPOINT = exports.SINGULAR_V1_ENDPOINT = exports.SINGULAR_V1_COLLECTION_ENDPOINT = exports.RMRK_PINATA_SERVER = exports.QUARTZ_SCAN_ENDPOINT = exports.PINATA_IPFS_GATEWAY = exports.OPAL_SCAN_ENDPOINT = exports.NFT_STORAGE_GATEWAY = exports.KANARIA_EXTERNAL_SERVER = exports.KANARIA_ENDPOINT = exports.IPFS_W3S_LINK = exports.IPFS_IO = exports.IPFS_GATEWAY_4EVERLAND = exports.IPFS_FLEEK = exports.IPFS_ETH_ARAGON = exports.IPFS2_RMRK = exports.GATEWAY_IPFS_IO = exports.DWEB_LINK = exports.CLOUDFLARE_PINATA_SERVER = exports.CF_IPFS_GATEWAY = exports.BIT_COUNTRY_THUMBNAIL_RESOLVER = exports.BIT_COUNTRY_LAND_ESTATE_METADATA_API = exports.BIT_COUNTRY_IPFS_SERVER = exports.BIT_AVATAR_API = exports.AVAIL_LIGHT_CLIENT_NFT = void 0;
|
|
7
7
|
exports.getRandomIpfsGateway = getRandomIpfsGateway;
|
|
8
8
|
var _environment = require("@subwallet/extension-base/utils/environment");
|
|
9
9
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -49,6 +49,8 @@ const PINATA_IPFS_GATEWAY = 'https://gateway.pinata.cloud/ipfs/';
|
|
|
49
49
|
exports.PINATA_IPFS_GATEWAY = PINATA_IPFS_GATEWAY;
|
|
50
50
|
const VARA_SCAN_ENDPOINT = 'https://nft-explorer.vara-network.io/graphql';
|
|
51
51
|
exports.VARA_SCAN_ENDPOINT = VARA_SCAN_ENDPOINT;
|
|
52
|
+
const AVAIL_LIGHT_CLIENT_NFT = 'https://indexer.availspace.app/graphql'; // 'https://indexer-nft.availspace.app/graphql';
|
|
53
|
+
exports.AVAIL_LIGHT_CLIENT_NFT = AVAIL_LIGHT_CLIENT_NFT;
|
|
52
54
|
const UNIQUE_SCAN_ENDPOINT = 'https://api-unique.uniquescan.io/v1/graphql';
|
|
53
55
|
exports.UNIQUE_SCAN_ENDPOINT = UNIQUE_SCAN_ENDPOINT;
|
|
54
56
|
const QUARTZ_SCAN_ENDPOINT = 'https://api-quartz.uniquescan.io/v1/graphql';
|
|
@@ -8,6 +8,7 @@ exports.NftHandler = void 0;
|
|
|
8
8
|
var _acala_nft = require("@subwallet/extension-base/koni/api/nft/acala_nft");
|
|
9
9
|
var _assethub_unique = _interopRequireDefault(require("@subwallet/extension-base/koni/api/nft/assethub_unique"));
|
|
10
10
|
var _bit = require("@subwallet/extension-base/koni/api/nft/bit.country");
|
|
11
|
+
var _blobinscription = require("@subwallet/extension-base/koni/api/nft/blobinscription");
|
|
11
12
|
var _evm_nft = require("@subwallet/extension-base/koni/api/nft/evm_nft");
|
|
12
13
|
var _karura_nft = require("@subwallet/extension-base/koni/api/nft/karura_nft");
|
|
13
14
|
var _ordinal_nft = _interopRequireDefault(require("@subwallet/extension-base/koni/api/nft/ordinal_nft"));
|
|
@@ -44,6 +45,8 @@ function createSubstrateNftApi(chain, substrateApi, addresses) {
|
|
|
44
45
|
return [new _bit.BitCountryNftApi(substrateApi, substrateAddresses, chain)];
|
|
45
46
|
} else if (_constants._NFT_CHAIN_GROUP.vara.includes(chain)) {
|
|
46
47
|
return [new _vara_nft.VaraNftApi(chain, substrateAddresses)];
|
|
48
|
+
} else if (_constants._NFT_CHAIN_GROUP.avail.includes(chain)) {
|
|
49
|
+
return [new _blobinscription.BlobInscriptionApi(chain, substrateAddresses)];
|
|
47
50
|
}
|
|
48
51
|
return null;
|
|
49
52
|
}
|
|
@@ -113,22 +113,23 @@ function calculateChainStakedReturn(inflation, totalEraStake, totalIssuance, net
|
|
|
113
113
|
|
|
114
114
|
return stakedReturn;
|
|
115
115
|
}
|
|
116
|
-
function calculateChainStakedReturnV2(chainInfo, totalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, isCompound) {
|
|
116
|
+
function calculateChainStakedReturnV2(chainInfo, totalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, inflation, isCompound) {
|
|
117
117
|
const DAYS_PER_YEAR = 365;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
118
|
+
const {
|
|
119
|
+
decimals
|
|
120
|
+
} = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
121
|
+
const lastTotalStakedUnit = new _bignumber.default(lastTotalStaked).dividedBy(new _bignumber.default(10 ** decimals));
|
|
122
|
+
const totalIssuanceUnit = new _bignumber.default(totalIssuance).dividedBy(new _bignumber.default(10 ** decimals));
|
|
122
123
|
const supplyStaked = lastTotalStakedUnit.dividedBy(totalIssuanceUnit);
|
|
123
124
|
const dayRewardRate = validatorEraReward.multipliedBy(erasPerDay).dividedBy(totalIssuance).multipliedBy(100);
|
|
124
|
-
let inflationToStakers
|
|
125
|
+
let inflationToStakers;
|
|
125
126
|
if (!isCompound) {
|
|
126
127
|
inflationToStakers = dayRewardRate.multipliedBy(DAYS_PER_YEAR);
|
|
127
128
|
} else {
|
|
128
129
|
const multiplier = dayRewardRate.dividedBy(100).plus(1).exponentiatedBy(365);
|
|
129
130
|
inflationToStakers = new _bignumber.default(100).multipliedBy(multiplier).minus(100);
|
|
130
131
|
}
|
|
131
|
-
const averageRewardRate = inflationToStakers.dividedBy(supplyStaked);
|
|
132
|
+
const averageRewardRate = (['avail_mainnet'].includes(chainInfo.slug) ? inflation : inflationToStakers).dividedBy(supplyStaked);
|
|
132
133
|
return averageRewardRate.toNumber();
|
|
133
134
|
}
|
|
134
135
|
function calculateAlephZeroValidatorReturn(chainStakedReturn, commission) {
|
package/cjs/packageInfo.js
CHANGED
|
@@ -63,7 +63,8 @@ const _NFT_CHAIN_GROUP = {
|
|
|
63
63
|
unique_network: ['unique_network', 'quartz', 'opal'],
|
|
64
64
|
unique_evm: ['unique_evm'],
|
|
65
65
|
bitcountry: ['bitcountry', 'pioneer', 'continuum_network'],
|
|
66
|
-
vara: ['vara_network']
|
|
66
|
+
vara: ['vara_network'],
|
|
67
|
+
avail: ['avail_mainnet']
|
|
67
68
|
};
|
|
68
69
|
|
|
69
70
|
// Staking--------------------------------------------------------------------------------------------------------------
|
|
@@ -237,6 +238,11 @@ const _KNOWN_CHAIN_INFLATION_PARAMS = {
|
|
|
237
238
|
vara_testnet: {
|
|
238
239
|
..._SUBSTRATE_DEFAULT_INFLATION_PARAMS,
|
|
239
240
|
stakeTarget: 0.8
|
|
241
|
+
},
|
|
242
|
+
avail_mainnet: {
|
|
243
|
+
..._SUBSTRATE_DEFAULT_INFLATION_PARAMS,
|
|
244
|
+
maxInflation: 0.05,
|
|
245
|
+
minInflation: 0.01
|
|
240
246
|
}
|
|
241
247
|
};
|
|
242
248
|
|
|
@@ -82,7 +82,7 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
82
82
|
const bnTotalEraStake = new _util.BN(rawTotalEraStake);
|
|
83
83
|
const bnTotalIssuance = new _util.BN(rawTotalIssuance);
|
|
84
84
|
const inflation = (0, _utils.calculateInflation)(bnTotalEraStake, bnTotalIssuance, numAuctions, chainInfo.slug);
|
|
85
|
-
const expectedReturn = (0, _utils.calculateChainStakedReturnV2)(chainInfo, rawTotalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, true);
|
|
85
|
+
const expectedReturn = (0, _utils.calculateChainStakedReturnV2)(chainInfo, rawTotalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, new _bignumber.default(inflation), true);
|
|
86
86
|
const eraTime = _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug] || _constants._STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
87
87
|
const unlockingPeriod = parseInt(unlockingEras) * eraTime; // in hours
|
|
88
88
|
const farmerCount = _counterForNominators.toPrimitive();
|
|
@@ -104,7 +104,7 @@ class NominationPoolHandler extends _base.default {
|
|
|
104
104
|
const bnTotalIssuance = new _util.BN(rawTotalIssuance);
|
|
105
105
|
const inflation = (0, _utils.calculateInflation)(bnTotalEraStake, bnTotalIssuance, numAuctions, chainInfo.slug);
|
|
106
106
|
const minPoolJoin = (_minPoolJoin === null || _minPoolJoin === void 0 ? void 0 : _minPoolJoin.toString()) || undefined;
|
|
107
|
-
const expectedReturn = (0, _utils.calculateChainStakedReturnV2)(chainInfo, rawTotalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, true);
|
|
107
|
+
const expectedReturn = (0, _utils.calculateChainStakedReturnV2)(chainInfo, rawTotalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, new _bignumber.default(inflation), true);
|
|
108
108
|
const eraTime = _constants._STAKING_ERA_LENGTH_MAP[this.chain] || _constants._STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
109
109
|
const unlockingPeriod = parseInt(unlockingEras) * eraTime; // in hours
|
|
110
110
|
|
|
@@ -22,6 +22,7 @@ async function fetchStaticData(slug, targetFile) {
|
|
|
22
22
|
return await (0, _fetch.fetchText)(`https://static-data.subwallet.app/${slug}/${fetchFile}`);
|
|
23
23
|
}
|
|
24
24
|
} catch (e) {
|
|
25
|
+
console.log('error fetching static data', e);
|
|
25
26
|
return _staticData.staticData[slug];
|
|
26
27
|
}
|
|
27
28
|
}
|
package/constants/staking.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const PREDEFINED_STAKING_POOL: Record<string, number>;
|
|
2
|
-
export declare const PREDEFINED_EARNING_POOL: Record<string, number[]>;
|
|
3
2
|
export declare const MAX_NOMINATIONS = "16";
|
|
3
|
+
export declare const PREDEFINED_EARNING_POOL_PROMISE: Promise<Record<string, number[]>>;
|
package/constants/staking.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { fetchStaticData } from '@subwallet/extension-base/utils';
|
|
4
5
|
export const PREDEFINED_STAKING_POOL = {
|
|
5
6
|
kusama: 80,
|
|
6
7
|
polkadot: 39,
|
|
@@ -8,12 +9,5 @@ export const PREDEFINED_STAKING_POOL = {
|
|
|
8
9
|
aleph: 82,
|
|
9
10
|
availTuringTest: 11
|
|
10
11
|
};
|
|
11
|
-
export const
|
|
12
|
-
|
|
13
|
-
kusama: [80],
|
|
14
|
-
vara_network: [62, 29, 50],
|
|
15
|
-
aleph: [82],
|
|
16
|
-
availTuringTest: [11],
|
|
17
|
-
avail_mainnet: [12, 4]
|
|
18
|
-
};
|
|
19
|
-
export const MAX_NOMINATIONS = '16';
|
|
12
|
+
export const MAX_NOMINATIONS = '16';
|
|
13
|
+
export const PREDEFINED_EARNING_POOL_PROMISE = fetchStaticData('nomination-pool-recommendation');
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export const COLLECT_ID = 'Avail OG';
|
|
5
|
+
export const ALC_NFT_RAW_VALUE = {
|
|
6
|
+
BRONZE: '{"p":"OIS-AVAIL","op":"create","tick":"AVAIL-OG","imgUrl":"https://storage.googleapis.com/blobscriptions.appspot.com/user-uploads%2Fclyy54fsc0001jpr1bi3thgp7%2F1721723052313-mkyf6c7hkfv9v0mgu0itbof7-bronzeNFT.mp4","tokenType":"NFT","totalSupply":"5000","limit":"5000","traits":{"Tier":"bronze"},"name":"Bronze #AVAIL"}',
|
|
7
|
+
SILVER: '{"p":"OIS-AVAIL","op":"create","tick":"AVAIL-OG","imgUrl":"https://storage.googleapis.com/blobscriptions.appspot.com/user-uploads%2Fclyy54fsc0001jpr1bi3thgp7%2F1721722886703-hnhan3yc1ma9v8euheq8aj21-silverNFT.mp4","tokenType":"NFT","totalSupply":"4000","limit":"4000","traits":{"Tier":"silver"},"name":"Silver #AVAIl"}',
|
|
8
|
+
GOLD: '{"p":"OIS-AVAIL","op":"create","tick":"AVAIL-OG","imgUrl":"https://storage.googleapis.com/blobscriptions.appspot.com/user-uploads%2Fclyy54fsc0001jpr1bi3thgp7%2F1721722632268-mdwdbwp1yv58iuyl4zzzr3t8-goldNFT.mp4","tokenType":"NFT","totalSupply":"1000","limit":"1000","traits":{"Tier":"gold"},"name":"Gold #AVAIL"}'
|
|
9
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseNftApi, HandleNftParams } from '@subwallet/extension-base/koni/api/nft/nft';
|
|
2
|
+
export declare class BlobInscriptionApi extends BaseNftApi {
|
|
3
|
+
endpoint: string;
|
|
4
|
+
constructor(chain: string, addresses: string[]);
|
|
5
|
+
private static parseNftRequestRemark;
|
|
6
|
+
private getAllInscriptions;
|
|
7
|
+
private getNftMap;
|
|
8
|
+
private static parseNftRequest;
|
|
9
|
+
private getBalances;
|
|
10
|
+
private handleProperties;
|
|
11
|
+
handleNfts(params: HandleNftParams): Promise<void>;
|
|
12
|
+
fetchNfts(params: HandleNftParams): Promise<number>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { COLLECT_ID } from '@subwallet/extension-base/koni/api/nft/blobinscription/consts';
|
|
5
|
+
import { getNftDetail } from '@subwallet/extension-base/koni/api/nft/blobinscription/types';
|
|
6
|
+
import { AVAIL_LIGHT_CLIENT_NFT } from '@subwallet/extension-base/koni/api/nft/config';
|
|
7
|
+
import { BaseNftApi } from '@subwallet/extension-base/koni/api/nft/nft';
|
|
8
|
+
import { hexToString } from '@polkadot/util';
|
|
9
|
+
export class BlobInscriptionApi extends BaseNftApi {
|
|
10
|
+
endpoint = AVAIL_LIGHT_CLIENT_NFT;
|
|
11
|
+
constructor(chain, addresses) {
|
|
12
|
+
super(chain, undefined, addresses);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Get all NFTs //
|
|
16
|
+
|
|
17
|
+
static parseNftRequestRemark() {
|
|
18
|
+
return {
|
|
19
|
+
query: `
|
|
20
|
+
query MyQuery {
|
|
21
|
+
remarks(limit: 10000, where: {extrinsicHash_eq: "0xa3974497d44d0e1e5a06dc6ceb6cae48dcd9ef2a0369e89d01276830096d32d8", OR: {extrinsicHash_eq: "0x0b789bc0ebe0505700c41cec5986948530e59f444c9383b5ff5d6d3daa14cece", OR: {extrinsicHash_eq: "0x37b0aaee83e907d445f41f769731cf8f1bc17c2c211cdb47262f6ca220e9f976"}}}) {
|
|
22
|
+
dataRaw
|
|
23
|
+
extrinsicHash
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
async getAllInscriptions() {
|
|
30
|
+
const response = await fetch(this.endpoint, {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/json'
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify(BlobInscriptionApi.parseNftRequestRemark())
|
|
36
|
+
});
|
|
37
|
+
const result = await response.json();
|
|
38
|
+
return result.data.remarks;
|
|
39
|
+
}
|
|
40
|
+
async getNftMap() {
|
|
41
|
+
const nftMap = {};
|
|
42
|
+
const rawList = await this.getAllInscriptions();
|
|
43
|
+
rawList.forEach(item => {
|
|
44
|
+
const jsonData = JSON.parse(hexToString(item.dataRaw));
|
|
45
|
+
if (nftMap[jsonData.to]) {
|
|
46
|
+
nftMap[jsonData.to].push(jsonData.tick);
|
|
47
|
+
}
|
|
48
|
+
nftMap[jsonData.to] = [jsonData.tick];
|
|
49
|
+
});
|
|
50
|
+
return nftMap;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Get all NFTs //
|
|
54
|
+
|
|
55
|
+
// Deprecated: Old get NFTs balance //
|
|
56
|
+
|
|
57
|
+
static parseNftRequest(address, isJson = true) {
|
|
58
|
+
// noted: check to handle isJson
|
|
59
|
+
return {
|
|
60
|
+
query: `
|
|
61
|
+
query MyQuery {
|
|
62
|
+
dataAvailabilities(where: {sender: {address_eq: "${address}"}, isJson_eq: ${isJson.toString()}}) {
|
|
63
|
+
id
|
|
64
|
+
extrinsicHash
|
|
65
|
+
dataRaw
|
|
66
|
+
dataValue
|
|
67
|
+
isJson
|
|
68
|
+
sender {
|
|
69
|
+
address
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
`
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// @ts-ignore
|
|
78
|
+
async getBalances(address) {
|
|
79
|
+
var _result$data;
|
|
80
|
+
const response = await fetch(this.endpoint, {
|
|
81
|
+
method: 'POST',
|
|
82
|
+
headers: {
|
|
83
|
+
'Content-Type': 'application/json'
|
|
84
|
+
},
|
|
85
|
+
body: JSON.stringify(BlobInscriptionApi.parseNftRequest(address))
|
|
86
|
+
});
|
|
87
|
+
const result = await response.json();
|
|
88
|
+
return result === null || result === void 0 ? void 0 : (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.dataAvailabilities;
|
|
89
|
+
}
|
|
90
|
+
handleProperties(data) {
|
|
91
|
+
const propertiesMap = {};
|
|
92
|
+
const attRecord = data.traits;
|
|
93
|
+
if (attRecord) {
|
|
94
|
+
for (const [name, value] of Object.entries(attRecord)) {
|
|
95
|
+
propertiesMap[name] = {
|
|
96
|
+
value: value
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return propertiesMap;
|
|
101
|
+
}
|
|
102
|
+
async handleNfts(params) {
|
|
103
|
+
const allInscriptionsMap = await this.getNftMap();
|
|
104
|
+
try {
|
|
105
|
+
// eslint-disable-next-line array-callback-return
|
|
106
|
+
await Promise.all(this.addresses.map(address => {
|
|
107
|
+
const nfts = allInscriptionsMap[address];
|
|
108
|
+
if (nfts) {
|
|
109
|
+
const collectionMap = {};
|
|
110
|
+
for (const nft of nfts) {
|
|
111
|
+
const nftDetail = getNftDetail(nft);
|
|
112
|
+
if (!nftDetail) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const propertiesMap = this.handleProperties(nftDetail);
|
|
116
|
+
const parsedNft = {
|
|
117
|
+
id: address,
|
|
118
|
+
// is distinct?
|
|
119
|
+
chain: this.chain,
|
|
120
|
+
owner: address,
|
|
121
|
+
name: nftDetail.name,
|
|
122
|
+
image: nftDetail.imgUrl,
|
|
123
|
+
collectionId: nftDetail.tick,
|
|
124
|
+
properties: propertiesMap
|
|
125
|
+
};
|
|
126
|
+
params.updateItem(this.chain, parsedNft, address);
|
|
127
|
+
if (!collectionMap[nftDetail.tick]) {
|
|
128
|
+
const parsedCollection = {
|
|
129
|
+
collectionId: nftDetail.tick,
|
|
130
|
+
chain: this.chain,
|
|
131
|
+
collectionName: COLLECT_ID
|
|
132
|
+
};
|
|
133
|
+
collectionMap[nftDetail.tick] = parsedCollection;
|
|
134
|
+
params.updateCollection(this.chain, parsedCollection);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}));
|
|
139
|
+
} catch (error) {
|
|
140
|
+
console.error('Failed to fetch blob inscription', error);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async fetchNfts(params) {
|
|
144
|
+
try {
|
|
145
|
+
await this.handleNfts(params);
|
|
146
|
+
} catch (e) {
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
return 1;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface NftResponse {
|
|
2
|
+
data: {
|
|
3
|
+
dataAvailabilities: NftData[];
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
interface NftData {
|
|
7
|
+
isJson: boolean;
|
|
8
|
+
id: string;
|
|
9
|
+
extrinsicHash: string;
|
|
10
|
+
dataValue: string;
|
|
11
|
+
dataRaw: string;
|
|
12
|
+
sender: {
|
|
13
|
+
address: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface ALC {
|
|
17
|
+
p: string;
|
|
18
|
+
op: string;
|
|
19
|
+
tick: string;
|
|
20
|
+
imgUrl: string;
|
|
21
|
+
name: string;
|
|
22
|
+
traits: Record<string, any>;
|
|
23
|
+
}
|
|
24
|
+
export interface RemarkData {
|
|
25
|
+
data: {
|
|
26
|
+
remarks: {
|
|
27
|
+
dataRaw: string;
|
|
28
|
+
}[];
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface transferPayload {
|
|
32
|
+
p: string;
|
|
33
|
+
op: string;
|
|
34
|
+
amount: string;
|
|
35
|
+
tick: string;
|
|
36
|
+
to: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function getNftDetail(nftSlug: string): ALC | undefined;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ALC_NFT_RAW_VALUE } from '@subwallet/extension-base/koni/api/nft/blobinscription/consts';
|
|
5
|
+
export function getNftDetail(nftSlug) {
|
|
6
|
+
if (nftSlug === 'AVAIL-OG-sqsu5a91qbu0s4oj3ldg8lrf') {
|
|
7
|
+
// Gold
|
|
8
|
+
return JSON.parse(ALC_NFT_RAW_VALUE.GOLD);
|
|
9
|
+
}
|
|
10
|
+
if (nftSlug === 'AVAIL-OG-zdttjyidincrjgsmwqbxoghz') {
|
|
11
|
+
// Silver
|
|
12
|
+
return JSON.parse(ALC_NFT_RAW_VALUE.SILVER);
|
|
13
|
+
}
|
|
14
|
+
if (nftSlug === 'AVAIL-OG-zy0n66yqtgw6z139hnf5vdxb') {
|
|
15
|
+
// Bronze
|
|
16
|
+
return JSON.parse(ALC_NFT_RAW_VALUE.BRONZE);
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
package/koni/api/nft/config.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare const BIT_COUNTRY_THUMBNAIL_RESOLVER = "https://res.cloudinary.co
|
|
|
13
13
|
export declare const CF_IPFS_GATEWAY = "https://cf-ipfs.com/ipfs/";
|
|
14
14
|
export declare const PINATA_IPFS_GATEWAY = "https://gateway.pinata.cloud/ipfs/";
|
|
15
15
|
export declare const VARA_SCAN_ENDPOINT = "https://nft-explorer.vara-network.io/graphql";
|
|
16
|
+
export declare const AVAIL_LIGHT_CLIENT_NFT = "https://indexer.availspace.app/graphql";
|
|
16
17
|
export declare const UNIQUE_SCAN_ENDPOINT = "https://api-unique.uniquescan.io/v1/graphql";
|
|
17
18
|
export declare const QUARTZ_SCAN_ENDPOINT = "https://api-quartz.uniquescan.io/v1/graphql";
|
|
18
19
|
export declare const OPAL_SCAN_ENDPOINT = "https://api-opal.uniquescan.io/v1/graphql";
|
package/koni/api/nft/config.js
CHANGED
|
@@ -27,6 +27,8 @@ export const PINATA_IPFS_GATEWAY = 'https://gateway.pinata.cloud/ipfs/';
|
|
|
27
27
|
// export const QUARTZ_SCAN_ENDPOINT = 'https://hasura-quartz.unique.network/v1/graphql';
|
|
28
28
|
|
|
29
29
|
export const VARA_SCAN_ENDPOINT = 'https://nft-explorer.vara-network.io/graphql';
|
|
30
|
+
export const AVAIL_LIGHT_CLIENT_NFT = 'https://indexer.availspace.app/graphql'; // 'https://indexer-nft.availspace.app/graphql';
|
|
31
|
+
|
|
30
32
|
export const UNIQUE_SCAN_ENDPOINT = 'https://api-unique.uniquescan.io/v1/graphql';
|
|
31
33
|
export const QUARTZ_SCAN_ENDPOINT = 'https://api-quartz.uniquescan.io/v1/graphql';
|
|
32
34
|
export const OPAL_SCAN_ENDPOINT = 'https://api-opal.uniquescan.io/v1/graphql';
|
package/koni/api/nft/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { AcalaNftApi } from '@subwallet/extension-base/koni/api/nft/acala_nft';
|
|
5
5
|
import AssetHubUniquesPalletApi from '@subwallet/extension-base/koni/api/nft/assethub_unique';
|
|
6
6
|
import { BitCountryNftApi } from '@subwallet/extension-base/koni/api/nft/bit.country';
|
|
7
|
+
import { BlobInscriptionApi } from '@subwallet/extension-base/koni/api/nft/blobinscription';
|
|
7
8
|
import { EvmNftApi } from '@subwallet/extension-base/koni/api/nft/evm_nft';
|
|
8
9
|
import { KaruraNftApi } from '@subwallet/extension-base/koni/api/nft/karura_nft';
|
|
9
10
|
import OrdinalNftApi from '@subwallet/extension-base/koni/api/nft/ordinal_nft';
|
|
@@ -36,6 +37,8 @@ function createSubstrateNftApi(chain, substrateApi, addresses) {
|
|
|
36
37
|
return [new BitCountryNftApi(substrateApi, substrateAddresses, chain)];
|
|
37
38
|
} else if (_NFT_CHAIN_GROUP.vara.includes(chain)) {
|
|
38
39
|
return [new VaraNftApi(chain, substrateAddresses)];
|
|
40
|
+
} else if (_NFT_CHAIN_GROUP.avail.includes(chain)) {
|
|
41
|
+
return [new BlobInscriptionApi(chain, substrateAddresses)];
|
|
39
42
|
}
|
|
40
43
|
return null;
|
|
41
44
|
}
|
|
@@ -99,7 +99,7 @@ export declare function calcInflationUniformEraPayout(totalIssuance: BN, yearlyI
|
|
|
99
99
|
export declare function calcInflationRewardCurve(minInflation: number, stakedFraction: number, idealStake: number, idealInterest: number, falloff: number): number;
|
|
100
100
|
export declare function calculateInflation(totalEraStake: BN, totalIssuance: BN, numAuctions: number, networkKey: string): number;
|
|
101
101
|
export declare function calculateChainStakedReturn(inflation: number, totalEraStake: BN, totalIssuance: BN, networkKey: string): number;
|
|
102
|
-
export declare function calculateChainStakedReturnV2(chainInfo: _ChainInfo, totalIssuance: string, erasPerDay: number, lastTotalStaked: string, validatorEraReward: BigNumber, isCompound?: boolean): number;
|
|
102
|
+
export declare function calculateChainStakedReturnV2(chainInfo: _ChainInfo, totalIssuance: string, erasPerDay: number, lastTotalStaked: string, validatorEraReward: BigNumber, inflation: BigNumber, isCompound?: boolean): number;
|
|
103
103
|
export declare function calculateAlephZeroValidatorReturn(chainStakedReturn: number, commission: number): number;
|
|
104
104
|
export declare function calculateTernoaValidatorReturn(rewardPerValidator: number, validatorStake: number, commission: number): number;
|
|
105
105
|
export declare function calculateValidatorStakedReturn(chainStakedReturn: number, totalValidatorStake: BN, avgStake: BN, commission: number): number;
|
|
@@ -72,22 +72,23 @@ export function calculateChainStakedReturn(inflation, totalEraStake, totalIssuan
|
|
|
72
72
|
|
|
73
73
|
return stakedReturn;
|
|
74
74
|
}
|
|
75
|
-
export function calculateChainStakedReturnV2(chainInfo, totalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, isCompound) {
|
|
75
|
+
export function calculateChainStakedReturnV2(chainInfo, totalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, inflation, isCompound) {
|
|
76
76
|
const DAYS_PER_YEAR = 365;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
77
|
+
const {
|
|
78
|
+
decimals
|
|
79
|
+
} = _getChainNativeTokenBasicInfo(chainInfo);
|
|
80
|
+
const lastTotalStakedUnit = new BigNumber(lastTotalStaked).dividedBy(new BigNumber(10 ** decimals));
|
|
81
|
+
const totalIssuanceUnit = new BigNumber(totalIssuance).dividedBy(new BigNumber(10 ** decimals));
|
|
81
82
|
const supplyStaked = lastTotalStakedUnit.dividedBy(totalIssuanceUnit);
|
|
82
83
|
const dayRewardRate = validatorEraReward.multipliedBy(erasPerDay).dividedBy(totalIssuance).multipliedBy(100);
|
|
83
|
-
let inflationToStakers
|
|
84
|
+
let inflationToStakers;
|
|
84
85
|
if (!isCompound) {
|
|
85
86
|
inflationToStakers = dayRewardRate.multipliedBy(DAYS_PER_YEAR);
|
|
86
87
|
} else {
|
|
87
88
|
const multiplier = dayRewardRate.dividedBy(100).plus(1).exponentiatedBy(365);
|
|
88
89
|
inflationToStakers = new BigNumber(100).multipliedBy(multiplier).minus(100);
|
|
89
90
|
}
|
|
90
|
-
const averageRewardRate = inflationToStakers.dividedBy(supplyStaked);
|
|
91
|
+
const averageRewardRate = (['avail_mainnet'].includes(chainInfo.slug) ? inflation : inflationToStakers).dividedBy(supplyStaked);
|
|
91
92
|
return averageRewardRate.toNumber();
|
|
92
93
|
}
|
|
93
94
|
export function calculateAlephZeroValidatorReturn(chainStakedReturn, commission) {
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.2.
|
|
20
|
+
"version": "1.2.21-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -263,6 +263,21 @@
|
|
|
263
263
|
"require": "./cjs/koni/api/nft/bit.country/index.js",
|
|
264
264
|
"default": "./koni/api/nft/bit.country/index.js"
|
|
265
265
|
},
|
|
266
|
+
"./koni/api/nft/blobinscription": {
|
|
267
|
+
"types": "./koni/api/nft/blobinscription/index.d.ts",
|
|
268
|
+
"require": "./cjs/koni/api/nft/blobinscription/index.js",
|
|
269
|
+
"default": "./koni/api/nft/blobinscription/index.js"
|
|
270
|
+
},
|
|
271
|
+
"./koni/api/nft/blobinscription/consts": {
|
|
272
|
+
"types": "./koni/api/nft/blobinscription/consts.d.ts",
|
|
273
|
+
"require": "./cjs/koni/api/nft/blobinscription/consts.js",
|
|
274
|
+
"default": "./koni/api/nft/blobinscription/consts.js"
|
|
275
|
+
},
|
|
276
|
+
"./koni/api/nft/blobinscription/types": {
|
|
277
|
+
"types": "./koni/api/nft/blobinscription/types.d.ts",
|
|
278
|
+
"require": "./cjs/koni/api/nft/blobinscription/types.js",
|
|
279
|
+
"default": "./koni/api/nft/blobinscription/types.js"
|
|
280
|
+
},
|
|
266
281
|
"./koni/api/nft/config": {
|
|
267
282
|
"types": "./koni/api/nft/config.d.ts",
|
|
268
283
|
"require": "./cjs/koni/api/nft/config.js",
|
|
@@ -2009,11 +2024,11 @@
|
|
|
2009
2024
|
"@reduxjs/toolkit": "^1.9.1",
|
|
2010
2025
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
2011
2026
|
"@substrate/connect": "^0.8.9",
|
|
2012
|
-
"@subwallet/chain-list": "0.2.
|
|
2013
|
-
"@subwallet/extension-base": "^1.2.
|
|
2014
|
-
"@subwallet/extension-chains": "^1.2.
|
|
2015
|
-
"@subwallet/extension-dapp": "^1.2.
|
|
2016
|
-
"@subwallet/extension-inject": "^1.2.
|
|
2027
|
+
"@subwallet/chain-list": "0.2.78",
|
|
2028
|
+
"@subwallet/extension-base": "^1.2.21-0",
|
|
2029
|
+
"@subwallet/extension-chains": "^1.2.21-0",
|
|
2030
|
+
"@subwallet/extension-dapp": "^1.2.21-0",
|
|
2031
|
+
"@subwallet/extension-inject": "^1.2.21-0",
|
|
2017
2032
|
"@subwallet/keyring": "^0.1.5",
|
|
2018
2033
|
"@subwallet/ui-keyring": "^0.1.5",
|
|
2019
2034
|
"@walletconnect/keyvaluestorage": "^1.1.1",
|
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.2.
|
|
10
|
+
version: '1.2.21-0'
|
|
11
11
|
};
|
|
@@ -35,6 +35,7 @@ export declare const _NFT_CHAIN_GROUP: {
|
|
|
35
35
|
unique_evm: string[];
|
|
36
36
|
bitcountry: string[];
|
|
37
37
|
vara: string[];
|
|
38
|
+
avail: string[];
|
|
38
39
|
};
|
|
39
40
|
export declare const _STAKING_ERA_LENGTH_MAP: Record<string, number>;
|
|
40
41
|
export declare const _EXPECTED_BLOCK_TIME: Record<string, number>;
|
|
@@ -50,7 +50,8 @@ export const _NFT_CHAIN_GROUP = {
|
|
|
50
50
|
unique_network: ['unique_network', 'quartz', 'opal'],
|
|
51
51
|
unique_evm: ['unique_evm'],
|
|
52
52
|
bitcountry: ['bitcountry', 'pioneer', 'continuum_network'],
|
|
53
|
-
vara: ['vara_network']
|
|
53
|
+
vara: ['vara_network'],
|
|
54
|
+
avail: ['avail_mainnet']
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
// Staking--------------------------------------------------------------------------------------------------------------
|
|
@@ -220,6 +221,11 @@ export const _KNOWN_CHAIN_INFLATION_PARAMS = {
|
|
|
220
221
|
vara_testnet: {
|
|
221
222
|
..._SUBSTRATE_DEFAULT_INFLATION_PARAMS,
|
|
222
223
|
stakeTarget: 0.8
|
|
224
|
+
},
|
|
225
|
+
avail_mainnet: {
|
|
226
|
+
..._SUBSTRATE_DEFAULT_INFLATION_PARAMS,
|
|
227
|
+
maxInflation: 0.05,
|
|
228
|
+
minInflation: 0.01
|
|
223
229
|
}
|
|
224
230
|
};
|
|
225
231
|
|
|
@@ -75,7 +75,7 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
75
75
|
const bnTotalEraStake = new BN(rawTotalEraStake);
|
|
76
76
|
const bnTotalIssuance = new BN(rawTotalIssuance);
|
|
77
77
|
const inflation = calculateInflation(bnTotalEraStake, bnTotalIssuance, numAuctions, chainInfo.slug);
|
|
78
|
-
const expectedReturn = calculateChainStakedReturnV2(chainInfo, rawTotalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, true);
|
|
78
|
+
const expectedReturn = calculateChainStakedReturnV2(chainInfo, rawTotalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, new BigN(inflation), true);
|
|
79
79
|
const eraTime = _STAKING_ERA_LENGTH_MAP[chainInfo.slug] || _STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
80
80
|
const unlockingPeriod = parseInt(unlockingEras) * eraTime; // in hours
|
|
81
81
|
const farmerCount = _counterForNominators.toPrimitive();
|
|
@@ -96,7 +96,7 @@ export default class NominationPoolHandler extends BasePoolHandler {
|
|
|
96
96
|
const bnTotalIssuance = new BN(rawTotalIssuance);
|
|
97
97
|
const inflation = calculateInflation(bnTotalEraStake, bnTotalIssuance, numAuctions, chainInfo.slug);
|
|
98
98
|
const minPoolJoin = (_minPoolJoin === null || _minPoolJoin === void 0 ? void 0 : _minPoolJoin.toString()) || undefined;
|
|
99
|
-
const expectedReturn = calculateChainStakedReturnV2(chainInfo, rawTotalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, true);
|
|
99
|
+
const expectedReturn = calculateChainStakedReturnV2(chainInfo, rawTotalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, new BigN(inflation), true);
|
|
100
100
|
const eraTime = _STAKING_ERA_LENGTH_MAP[this.chain] || _STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
101
101
|
const unlockingPeriod = parseInt(unlockingEras) * eraTime; // in hours
|
|
102
102
|
|
package/utils/fetchStaticData.js
CHANGED
|
@@ -15,6 +15,7 @@ export async function fetchStaticData(slug, targetFile, isJson = true) {
|
|
|
15
15
|
return await fetchText(`https://static-data.subwallet.app/${slug}/${fetchFile}`);
|
|
16
16
|
}
|
|
17
17
|
} catch (e) {
|
|
18
|
+
console.log('error fetching static data', e);
|
|
18
19
|
return staticData[slug];
|
|
19
20
|
}
|
|
20
21
|
}
|