@sonarwatch/portfolio-plugins 0.11.29 → 0.11.31
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/CHANGELOG.md +10 -2
- package/package.json +2 -2
- package/src/plugins/tokens/fetchers/solana.js +55 -44
- package/src/plugins/tokens/fetchers/solana.js.map +1 -1
- package/src/plugins/tokens/index.js +3 -7
- package/src/plugins/tokens/index.js.map +1 -1
- package/src/utils/misc/tokenPriceToLiquidity.d.ts +2 -0
- package/src/utils/misc/tokenPriceToLiquidity.js +21 -0
- package/src/utils/misc/tokenPriceToLiquidity.js.map +1 -0
- package/src/utils/solana/constants.js.map +1 -1
- package/src/utils/solana/das/getAssetsByOwnerDas.d.ts +3 -0
- package/src/utils/solana/{getAssetsByOwnerDas.js → das/getAssetsByOwnerDas.js} +35 -23
- package/src/utils/solana/das/getAssetsByOwnerDas.js.map +1 -0
- package/src/utils/solana/das/heliusAssetToAssetCollectible.d.ts +3 -0
- package/src/utils/solana/das/heliusAssetToAssetCollectible.js +38 -0
- package/src/utils/solana/das/heliusAssetToAssetCollectible.js.map +1 -0
- package/src/utils/solana/das/isHeliusFungibleAsset.d.ts +2 -0
- package/src/utils/solana/das/isHeliusFungibleAsset.js +10 -0
- package/src/utils/solana/das/isHeliusFungibleAsset.js.map +1 -0
- package/src/utils/solana/{getAssetsByOwnerDas.d.ts → das/types.d.ts} +21 -3
- package/src/utils/solana/das/types.js +3 -0
- package/src/utils/solana/das/types.js.map +1 -0
- package/src/plugins/tokens/fetchers/solana-cnfts.d.ts +0 -3
- package/src/plugins/tokens/fetchers/solana-cnfts.js +0 -62
- package/src/plugins/tokens/fetchers/solana-cnfts.js.map +0 -1
- package/src/plugins/tokens/fetchers/solana-nfts.d.ts +0 -3
- package/src/plugins/tokens/fetchers/solana-nfts.js +0 -126
- package/src/plugins/tokens/fetchers/solana-nfts.js.map +0 -1
- package/src/utils/solana/getAssetsByOwnerDas.js.map +0 -1
package/CHANGELOG.md
CHANGED
@@ -2,14 +2,22 @@
|
|
2
2
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
4
4
|
|
5
|
-
## [0.11.
|
5
|
+
## [0.11.31](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.30...plugins-0.11.31) (2024-01-04)
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
## [0.11.
|
9
|
+
## [0.11.30](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.29...plugins-0.11.30) (2023-12-28)
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
+
## [0.11.29](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.28...plugins-0.11.29) (2023-12-22)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
## [0.11.28](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.27...plugins-0.11.28) (2023-12-21)
|
18
|
+
|
19
|
+
|
20
|
+
|
13
21
|
## [0.11.27](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.26...plugins-0.11.27) (2023-12-21)
|
14
22
|
|
15
23
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sonarwatch/portfolio-plugins",
|
3
|
-
"version": "0.11.
|
3
|
+
"version": "0.11.31",
|
4
4
|
"type": "commonjs",
|
5
5
|
"generators": "./generators.json",
|
6
6
|
"dependencies": {
|
@@ -41,7 +41,7 @@
|
|
41
41
|
"web3-v1": "npm:web3@^1.5.0"
|
42
42
|
},
|
43
43
|
"peerDependencies": {
|
44
|
-
"@sonarwatch/portfolio-core": "0.11.
|
44
|
+
"@sonarwatch/portfolio-core": "0.11.31"
|
45
45
|
},
|
46
46
|
"main": "./src/index.js",
|
47
47
|
"types": "./src/index.d.ts"
|
@@ -13,73 +13,84 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
13
|
};
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
-
const
|
16
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
17
17
|
const constants_1 = require("../constants");
|
18
|
-
const
|
19
|
-
const solana_1 = require("../../../utils/solana");
|
20
|
-
const tokenPriceToAssetTokens_1 = __importDefault(require("../../../utils/misc/tokenPriceToAssetTokens"));
|
21
|
-
const tokenPriceToAssetToken_1 = __importDefault(require("../../../utils/misc/tokenPriceToAssetToken"));
|
18
|
+
const constants_2 = require("../../../utils/clients/constants");
|
22
19
|
const helpers_1 = require("../helpers");
|
20
|
+
const tokenPriceToAssetToken_1 = __importDefault(require("../../../utils/misc/tokenPriceToAssetToken"));
|
21
|
+
const tokenPriceToLiquidity_1 = __importDefault(require("../../../utils/misc/tokenPriceToLiquidity"));
|
22
|
+
const heliusAssetToAssetCollectible_1 = require("../../../utils/solana/das/heliusAssetToAssetCollectible");
|
23
|
+
const getAssetsByOwnerDas_1 = require("../../../utils/solana/das/getAssetsByOwnerDas");
|
24
|
+
const isHeliusFungibleAsset_1 = require("../../../utils/solana/das/isHeliusFungibleAsset");
|
23
25
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
24
|
-
const
|
25
|
-
const
|
26
|
-
const
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
const rpcEndpoint = (0, constants_2.getRpcEndpoint)(portfolio_core_1.NetworkId.solana);
|
27
|
+
const items = yield (0, getAssetsByOwnerDas_1.getAssetsByOwnerDas)(rpcEndpoint, owner);
|
28
|
+
const fungibleAddresses = items.reduce((addresses, curr) => {
|
29
|
+
if ((0, isHeliusFungibleAsset_1.isHeliusFungibleAsset)(curr))
|
30
|
+
addresses.push(curr.id);
|
31
|
+
return addresses;
|
32
|
+
}, []);
|
33
|
+
const tokenPricesArray = yield cache.getTokenPrices(fungibleAddresses, portfolio_core_1.NetworkId.solana);
|
31
34
|
const tokenPrices = new Map();
|
32
35
|
tokenPricesArray.forEach((tokenPrice) => {
|
33
|
-
if (
|
34
|
-
|
35
|
-
tokenPrices.set(tokenPrice.address, tokenPrice);
|
36
|
+
if (tokenPrice)
|
37
|
+
tokenPrices.set(tokenPrice.address, tokenPrice);
|
36
38
|
});
|
37
|
-
const
|
39
|
+
const nftAssets = [];
|
40
|
+
const tokenAssets = [];
|
38
41
|
const liquiditiesByTag = {};
|
39
|
-
for (let i = 0; i <
|
40
|
-
const
|
41
|
-
|
42
|
-
|
43
|
-
const address =
|
44
|
-
const
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
if (tokenPrice.platformId !== constants_1.walletTokensPlatform.id) {
|
51
|
-
const
|
52
|
-
const liquidity = {
|
53
|
-
assets,
|
54
|
-
assetsValue: (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value)),
|
55
|
-
rewardAssets: [],
|
56
|
-
rewardAssetsValue: 0,
|
57
|
-
value: (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value)),
|
58
|
-
yields: [],
|
59
|
-
};
|
42
|
+
for (let i = 0; i < items.length; i++) {
|
43
|
+
const asset = items[i];
|
44
|
+
const isFungible = (0, isHeliusFungibleAsset_1.isHeliusFungibleAsset)(asset);
|
45
|
+
const tokenPrice = isFungible ? tokenPrices.get(asset.id) : undefined;
|
46
|
+
const address = asset.id;
|
47
|
+
const amount = asset.token_info
|
48
|
+
? (0, bignumber_js_1.default)(asset.token_info.balance)
|
49
|
+
.div(Math.pow(10, asset.token_info.decimals))
|
50
|
+
.toNumber()
|
51
|
+
: 1;
|
52
|
+
// If it's an LP Token
|
53
|
+
if (tokenPrice && tokenPrice.platformId !== constants_1.walletTokensPlatform.id) {
|
54
|
+
const liquidity = (0, tokenPriceToLiquidity_1.default)(asset.id, amount, portfolio_core_1.NetworkId.solana, tokenPrice);
|
60
55
|
const tag = (0, helpers_1.getLpTag)(tokenPrice.platformId, tokenPrice.elementName);
|
61
56
|
if (!liquiditiesByTag[tag]) {
|
62
57
|
liquiditiesByTag[tag] = [];
|
63
58
|
}
|
64
59
|
liquiditiesByTag[tag].push(liquidity);
|
65
60
|
}
|
61
|
+
// If it's a regular token
|
62
|
+
else if (tokenPrice && tokenPrice.platformId === constants_1.walletTokensPlatform.id) {
|
63
|
+
tokenAssets.push((0, tokenPriceToAssetToken_1.default)(address, amount, portfolio_core_1.NetworkId.solana, tokenPrice));
|
64
|
+
}
|
65
|
+
// If it's a NFT
|
66
66
|
else {
|
67
|
-
|
67
|
+
nftAssets.push((0, heliusAssetToAssetCollectible_1.heliusAssetToAssetCollectible)(asset));
|
68
68
|
}
|
69
69
|
}
|
70
70
|
const elements = [];
|
71
|
-
if (
|
72
|
-
|
71
|
+
if (nftAssets.length !== 0) {
|
72
|
+
elements.push({
|
73
|
+
type: portfolio_core_1.PortfolioElementType.multiple,
|
74
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
75
|
+
platformId: constants_1.walletNftsPlatform.id,
|
76
|
+
label: 'Wallet',
|
77
|
+
value: null,
|
78
|
+
data: {
|
79
|
+
assets: nftAssets,
|
80
|
+
},
|
81
|
+
});
|
82
|
+
}
|
83
|
+
if (tokenAssets.length !== 0) {
|
84
|
+
elements.push({
|
73
85
|
type: portfolio_core_1.PortfolioElementType.multiple,
|
74
86
|
networkId: portfolio_core_1.NetworkId.solana,
|
75
87
|
platformId: constants_1.walletTokensPlatform.id,
|
76
88
|
label: 'Wallet',
|
77
|
-
value: (0, portfolio_core_1.getUsdValueSum)(
|
89
|
+
value: (0, portfolio_core_1.getUsdValueSum)(tokenAssets.map((a) => a.value)),
|
78
90
|
data: {
|
79
|
-
assets:
|
91
|
+
assets: tokenAssets,
|
80
92
|
},
|
81
|
-
};
|
82
|
-
elements.push(walletTokensElement);
|
93
|
+
});
|
83
94
|
}
|
84
95
|
for (const [tag, liquidities] of Object.entries(liquiditiesByTag)) {
|
85
96
|
const { platformId, elementName } = (0, helpers_1.parseLpTag)(tag);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solana.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/tokens/fetchers/solana.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,
|
1
|
+
{"version":3,"file":"solana.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/tokens/fetchers/solana.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,gEAAqC;AAErC,4CAAwE;AACxE,gEAAkE;AAElE,wCAAkD;AAClD,wGAAgF;AAChF,sGAA8E;AAC9E,2GAAwG;AACxG,uFAAoF;AACpF,2FAAwF;AAExF,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,WAAW,GAAG,IAAA,0BAAc,EAAC,0BAAS,CAAC,MAAM,CAAC,CAAC;IACrD,MAAM,KAAK,GAAG,MAAM,IAAA,yCAAmB,EAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAE5D,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,SAAmB,EAAE,IAAI,EAAE,EAAE;QACnE,IAAI,IAAA,6CAAqB,EAAC,IAAI,CAAC;YAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzD,OAAO,SAAS,CAAC;IACnB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,gBAAgB,GAAG,MAAM,KAAK,CAAC,cAAc,CACjD,iBAAiB,EACjB,0BAAS,CAAC,MAAM,CACjB,CAAC;IACF,MAAM,WAAW,GAA4B,IAAI,GAAG,EAAE,CAAC;IACvD,gBAAgB,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QACtC,IAAI,UAAU;YAAE,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAgC,EAAE,CAAC;IAClD,MAAM,WAAW,GAA0B,EAAE,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UAAU,EAAE,WAAW,EAAE,GAAG,IAAA,oBAAU,EAAC,GAAG,CAAC,CAAC;QACpD,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,qCAAoB,CAAC,SAAS;YACpC,SAAS,EAAE,0BAAS,CAAC,MAAM;YAC3B,UAAU;YACV,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,eAAe;YACtB,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YACtD,IAAI,EAAE;gBACJ,WAAW;aACZ;SACF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,SAAS;IACvC,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -5,20 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.fetchers = exports.jobs = exports.platforms = void 0;
|
7
7
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
8
|
+
const constants_1 = require("./constants");
|
8
9
|
const jobGenerator_1 = __importDefault(require("./jobGenerator"));
|
9
10
|
const aptos_1 = __importDefault(require("./fetchers/aptos"));
|
10
|
-
const solana_1 = __importDefault(require("./fetchers/solana"));
|
11
11
|
const sui_1 = __importDefault(require("./fetchers/sui"));
|
12
12
|
const sui_nfts_1 = __importDefault(require("./fetchers/sui-nfts"));
|
13
13
|
const sei_1 = __importDefault(require("./fetchers/sei"));
|
14
14
|
const bitcoin_1 = __importDefault(require("./fetchers/bitcoin"));
|
15
|
+
const solana_1 = __importDefault(require("./fetchers/solana"));
|
15
16
|
const solana_native_1 = __importDefault(require("./fetchers/solana-native"));
|
16
|
-
const solana_cnfts_1 = __importDefault(require("./fetchers/solana-cnfts"));
|
17
|
-
const solana_nfts_1 = __importDefault(require("./fetchers/solana-nfts"));
|
18
17
|
const solana_nfts_underlyings_1 = __importDefault(require("./fetchers/solana-nfts-underlyings"));
|
19
|
-
const getTokenListsJob_1 = __importDefault(require("./getTokenListsJob"));
|
20
18
|
const evms_1 = require("./fetchers/evms");
|
21
|
-
const
|
19
|
+
const getTokenListsJob_1 = __importDefault(require("./getTokenListsJob"));
|
22
20
|
exports.platforms = [constants_1.walletTokensPlatform, constants_1.walletNftsPlatform];
|
23
21
|
exports.jobs = [
|
24
22
|
(0, jobGenerator_1.default)(portfolio_core_1.NetworkId.bitcoin),
|
@@ -36,8 +34,6 @@ exports.fetchers = [
|
|
36
34
|
aptos_1.default,
|
37
35
|
solana_1.default,
|
38
36
|
solana_native_1.default,
|
39
|
-
solana_nfts_1.default,
|
40
|
-
solana_cnfts_1.default,
|
41
37
|
solana_nfts_underlyings_1.default,
|
42
38
|
sui_1.default,
|
43
39
|
sui_nfts_1.default,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tokens/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAIoC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tokens/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAIoC;AAKpC,2CAAuE;AACvE,kEAA0C;AAC1C,6DAA4C;AAC5C,yDAAwC;AACxC,mEAAiD;AACjD,yDAAwC;AACxC,iEAAgD;AAChD,+DAA8C;AAC9C,6EAA2D;AAC3D,iGAA8E;AAC9E,0CAA0D;AAC1D,0EAAkD;AAErC,QAAA,SAAS,GAAe,CAAC,gCAAoB,EAAE,8BAAkB,CAAC,CAAC;AACnE,QAAA,IAAI,GAAU;IACzB,IAAA,sBAAY,EAAC,0BAAS,CAAC,OAAO,CAAC;IAC/B,IAAA,sBAAY,EAAC,0BAAS,CAAC,KAAK,CAAC;IAC7B,IAAA,sBAAY,EAAC,0BAAS,CAAC,MAAM,CAAC;IAC9B,IAAA,sBAAY,EAAC,0BAAS,CAAC,QAAQ,CAAC;IAChC,IAAA,sBAAY,EAAC,0BAAS,CAAC,SAAS,CAAC;IACjC,IAAA,sBAAY,EAAC,0BAAS,CAAC,OAAO,CAAC;IAC/B,IAAA,sBAAY,EAAC,0BAAS,CAAC,GAAG,CAAC;IAC3B,IAAA,sBAAY,EAAC,0BAAS,CAAC,GAAG,CAAC;IAC3B,IAAA,sBAAY,EAAC,0BAAS,CAAC,GAAG,CAAC;IAC3B,GAAG,gCAAe,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,0BAAgB,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC;CAClE,CAAC;AAEW,QAAA,QAAQ,GAAc;IACjC,eAAY;IACZ,gBAAa;IACb,uBAAmB;IACnB,iCAA4B;IAC5B,aAAU;IACV,kBAAc;IACd,aAAU;IACV,iBAAc;IACd,GAAG,eAAW;CACf,CAAC"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
7
|
+
const tokenPriceToAssetTokens_1 = __importDefault(require("./tokenPriceToAssetTokens"));
|
8
|
+
function tokenPriceToLiquidity(address, amount, networkId, tokenPrice) {
|
9
|
+
const assets = (0, tokenPriceToAssetTokens_1.default)(address, amount, networkId, tokenPrice);
|
10
|
+
const liquidity = {
|
11
|
+
assets,
|
12
|
+
assetsValue: (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value)),
|
13
|
+
rewardAssets: [],
|
14
|
+
rewardAssetsValue: 0,
|
15
|
+
value: (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value)),
|
16
|
+
yields: [],
|
17
|
+
};
|
18
|
+
return liquidity;
|
19
|
+
}
|
20
|
+
exports.default = tokenPriceToLiquidity;
|
21
|
+
//# sourceMappingURL=tokenPriceToLiquidity.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"tokenPriceToLiquidity.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/tokenPriceToLiquidity.ts"],"names":[],"mappings":";;;;;AAAA,+DAKoC;AACpC,wFAAgE;AAEhE,SAAwB,qBAAqB,CAC3C,OAAe,EACf,MAAc,EACd,SAAwB,EACxB,UAAsB;IAEtB,MAAM,MAAM,GAAG,IAAA,iCAAuB,EACpC,OAAO,EACP,MAAM,EACN,SAAS,EACT,UAAU,CACX,CAAC;IACF,MAAM,SAAS,GAAuB;QACpC,MAAM;QACN,WAAW,EAAE,IAAA,+BAAc,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACvD,YAAY,EAAE,EAAE;QAChB,iBAAiB,EAAE,CAAC;QACpB,KAAK,EAAE,IAAA,+BAAc,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACjD,MAAM,EAAE,EAAE;KACX,CAAC;IACF,OAAO,SAAS,CAAC;AACnB,CAAC;AArBD,wCAqBC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE/B,QAAA,cAAc,GAAG,IAAI,mBAAS,CACzC,6CAA6C,CAC9C,CAAC;AACW,QAAA,kBAAkB,GAAG,IAAI,mBAAS,CAC7C,6CAA6C,CAC9C,CAAC;
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE/B,QAAA,cAAc,GAAG,IAAI,mBAAS,CACzC,6CAA6C,CAC9C,CAAC;AACW,QAAA,kBAAkB,GAAG,IAAI,mBAAS,CAC7C,6CAA6C,CAC9C,CAAC;AACW,QAAA,wBAAwB,GAAG,IAAI,mBAAS,CACnD,8CAA8C,CAC/C,CAAC"}
|
@@ -14,35 +14,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
exports.getAssetsByOwnerDas = void 0;
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
17
|
-
const getBasicAuthHeaders_1 = require("
|
17
|
+
const getBasicAuthHeaders_1 = require("../../misc/getBasicAuthHeaders");
|
18
|
+
const limit = 1000;
|
19
|
+
const maxPage = 10;
|
18
20
|
function getAssetsByOwnerDas(rpcEndpoint, owner) {
|
19
21
|
return __awaiter(this, void 0, void 0, function* () {
|
20
22
|
const httpHeaders = rpcEndpoint.basicAuth
|
21
23
|
? (0, getBasicAuthHeaders_1.getBasicAuthHeaders)(rpcEndpoint.basicAuth.username, rpcEndpoint.basicAuth.password)
|
22
24
|
: undefined;
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
const items = [];
|
26
|
+
let page = 0;
|
27
|
+
while (page < maxPage) {
|
28
|
+
page += 1;
|
29
|
+
const res = yield axios_1.default.post(rpcEndpoint.url, {
|
30
|
+
jsonrpc: '2.0',
|
31
|
+
id: Math.random().toString(),
|
32
|
+
method: 'getAssetsByOwner',
|
33
|
+
params: {
|
34
|
+
ownerAddress: owner,
|
35
|
+
page,
|
36
|
+
limit,
|
37
|
+
sortBy: {
|
38
|
+
sortBy: 'id',
|
39
|
+
sortDirection: 'asc',
|
40
|
+
},
|
41
|
+
displayOptions: {
|
42
|
+
showNativeBalance: false,
|
43
|
+
showFungible: true,
|
44
|
+
showInscription: true,
|
45
|
+
showUnverifiedCollections: true,
|
46
|
+
showCollectionMetadata: true,
|
47
|
+
showGrandTotal: true,
|
48
|
+
},
|
35
49
|
},
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}
|
43
|
-
|
44
|
-
})
|
45
|
-
.then((res) => res.data.result);
|
50
|
+
}, {
|
51
|
+
headers: Object.assign({ 'Content-Type': 'application/json' }, httpHeaders),
|
52
|
+
});
|
53
|
+
items.push(...res.data.result.items);
|
54
|
+
if (res.data.result.total !== limit)
|
55
|
+
break;
|
56
|
+
}
|
57
|
+
return items;
|
46
58
|
});
|
47
59
|
}
|
48
60
|
exports.getAssetsByOwnerDas = getAssetsByOwnerDas;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getAssetsByOwnerDas.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/utils/solana/das/getAssetsByOwnerDas.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kDAA6C;AAE7C,wEAAqE;AAErE,MAAM,KAAK,GAAG,IAAI,CAAC;AACnB,MAAM,OAAO,GAAG,EAAE,CAAC;AAEnB,SAAsB,mBAAmB,CACvC,WAAwB,EACxB,KAAa;;QAEb,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS;YACvC,CAAC,CAAC,IAAA,yCAAmB,EACjB,WAAW,CAAC,SAAS,CAAC,QAAQ,EAC9B,WAAW,CAAC,SAAS,CAAC,QAAQ,CAC/B;YACH,CAAC,CAAC,SAAS,CAAC;QAEd,MAAM,KAAK,GAAkB,EAAE,CAAC;QAChC,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,OAAO,IAAI,GAAG,OAAO,EAAE,CAAC;YACtB,IAAI,IAAI,CAAC,CAAC;YACV,MAAM,GAAG,GAAG,MAAM,eAAK,CAAC,IAAI,CAK1B,WAAW,CAAC,GAAG,EACf;gBACE,OAAO,EAAE,KAAK;gBACd,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;gBAC5B,MAAM,EAAE,kBAAkB;gBAC1B,MAAM,EAAE;oBACN,YAAY,EAAE,KAAK;oBACnB,IAAI;oBACJ,KAAK;oBACL,MAAM,EAAE;wBACN,MAAM,EAAE,IAAI;wBACZ,aAAa,EAAE,KAAK;qBACrB;oBACD,cAAc,EAAE;wBACd,iBAAiB,EAAE,KAAK;wBACxB,YAAY,EAAE,IAAI;wBAClB,eAAe,EAAE,IAAI;wBACrB,yBAAyB,EAAE,IAAI;wBAC/B,sBAAsB,EAAE,IAAI;wBAC5B,cAAc,EAAE,IAAI;qBACrB;iBACF;aACF,EACD;gBACE,OAAO,kBACL,cAAc,EAAE,kBAAkB,IAC/B,WAAW,CACf;aACF,CACF,CAAC;YACF,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACrC,IAAI,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,KAAK;gBAAE,MAAM;QAC7C,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CAAA;AAtDD,kDAsDC"}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.heliusAssetToAssetCollectible = void 0;
|
4
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
5
|
+
function heliusAssetToAssetCollectible(asset) {
|
6
|
+
var _a;
|
7
|
+
let amount = 1;
|
8
|
+
if (asset.token_info && asset.token_info.decimals === 0) {
|
9
|
+
amount = asset.token_info.balance;
|
10
|
+
}
|
11
|
+
let tags = [];
|
12
|
+
if (asset.compression.compressed)
|
13
|
+
tags.push('compressed');
|
14
|
+
if (asset.spl20)
|
15
|
+
tags.push('spl20');
|
16
|
+
if (asset.inscription)
|
17
|
+
tags.push('inscription');
|
18
|
+
if (tags.length === 0)
|
19
|
+
tags = undefined;
|
20
|
+
return {
|
21
|
+
type: portfolio_core_1.PortfolioAssetType.collectible,
|
22
|
+
attributes: {
|
23
|
+
tags,
|
24
|
+
},
|
25
|
+
data: {
|
26
|
+
address: asset.id,
|
27
|
+
amount,
|
28
|
+
price: null,
|
29
|
+
name: asset.content.metadata.name,
|
30
|
+
dataUri: asset.content.json_uri,
|
31
|
+
imageUri: (_a = asset.content.links) === null || _a === void 0 ? void 0 : _a.image,
|
32
|
+
},
|
33
|
+
networkId: portfolio_core_1.NetworkId.solana,
|
34
|
+
value: null,
|
35
|
+
};
|
36
|
+
}
|
37
|
+
exports.heliusAssetToAssetCollectible = heliusAssetToAssetCollectible;
|
38
|
+
//# sourceMappingURL=heliusAssetToAssetCollectible.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"heliusAssetToAssetCollectible.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/utils/solana/das/heliusAssetToAssetCollectible.ts"],"names":[],"mappings":";;;AAAA,+DAIoC;AAGpC,SAAgB,6BAA6B,CAC3C,KAAkB;;IAElB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QACxD,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;IACpC,CAAC;IAED,IAAI,IAAI,GAAyB,EAAE,CAAC;IACpC,IAAI,KAAK,CAAC,WAAW,CAAC,UAAU;QAAE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC1D,IAAI,KAAK,CAAC,KAAK;QAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,KAAK,CAAC,WAAW;QAAE,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAChD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,IAAI,GAAG,SAAS,CAAC;IAExC,OAAO;QACL,IAAI,EAAE,mCAAkB,CAAC,WAAW;QACpC,UAAU,EAAE;YACV,IAAI;SACL;QACD,IAAI,EAAE;YACJ,OAAO,EAAE,KAAK,CAAC,EAAE;YACjB,MAAM;YACN,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI;YACjC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ;YAC/B,QAAQ,EAAE,MAAA,KAAK,CAAC,OAAO,CAAC,KAAK,0CAAE,KAAK;SACrC;QACD,SAAS,EAAE,0BAAS,CAAC,MAAM;QAC3B,KAAK,EAAE,IAAI;KACZ,CAAC;AACJ,CAAC;AA9BD,sEA8BC"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isHeliusFungibleAsset = void 0;
|
4
|
+
function isHeliusFungibleAsset(heliusAsset) {
|
5
|
+
return ((heliusAsset.interface === 'FungibleToken' ||
|
6
|
+
heliusAsset.interface === 'FungibleAsset') &&
|
7
|
+
heliusAsset.token_info !== undefined);
|
8
|
+
}
|
9
|
+
exports.isHeliusFungibleAsset = isHeliusFungibleAsset;
|
10
|
+
//# sourceMappingURL=isHeliusFungibleAsset.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"isHeliusFungibleAsset.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/utils/solana/das/isHeliusFungibleAsset.ts"],"names":[],"mappings":";;;AAEA,SAAgB,qBAAqB,CAAC,WAAwB;IAC5D,OAAO,CACL,CAAC,WAAW,CAAC,SAAS,KAAK,eAAe;QACxC,WAAW,CAAC,SAAS,KAAK,eAAe,CAAC;QAC5C,WAAW,CAAC,UAAU,KAAK,SAAS,CACrC,CAAC;AACJ,CAAC;AAND,sDAMC"}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
import { RpcEndpoint } from '@sonarwatch/portfolio-core';
|
2
|
-
export declare function getAssetsByOwnerDas(rpcEndpoint: RpcEndpoint, owner: string): Promise<HeliusAssetList>;
|
3
1
|
export type GetAssetsByOwnerOutput = {
|
4
2
|
jsonrpc: string;
|
5
3
|
result: HeliusAssetList;
|
@@ -24,9 +22,28 @@ export type HeliusAsset = {
|
|
24
22
|
supply: Supply | null;
|
25
23
|
mutable: boolean;
|
26
24
|
burnt: boolean;
|
25
|
+
token_info?: TokenInfo;
|
27
26
|
inscription: Inscription | null;
|
28
27
|
spl20: Spl20 | null;
|
29
28
|
};
|
29
|
+
export type HeliusFungibleAsset = HeliusAsset & {
|
30
|
+
interface: 'FungibleToken' | 'FungibleAsset';
|
31
|
+
token_info: TokenInfo;
|
32
|
+
};
|
33
|
+
export type TokenInfo = {
|
34
|
+
balance: number;
|
35
|
+
supply: number;
|
36
|
+
decimals: number;
|
37
|
+
token_program: string;
|
38
|
+
associated_token_address: string;
|
39
|
+
symbol?: string;
|
40
|
+
price_info?: PriceInfo;
|
41
|
+
};
|
42
|
+
export type PriceInfo = {
|
43
|
+
price_per_token: number;
|
44
|
+
total_price: number;
|
45
|
+
currency: string;
|
46
|
+
};
|
30
47
|
export type Inscription = {
|
31
48
|
order: number;
|
32
49
|
size: number;
|
@@ -70,7 +87,8 @@ export type File = {
|
|
70
87
|
mime?: string;
|
71
88
|
};
|
72
89
|
export type Links = {
|
73
|
-
external_url
|
90
|
+
external_url?: string;
|
91
|
+
image?: string;
|
74
92
|
};
|
75
93
|
export type Metadata = {
|
76
94
|
attributes?: Attribute[];
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/utils/solana/das/types.ts"],"names":[],"mappings":""}
|
@@ -1,62 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
13
|
-
const getAssetsByOwnerDas_1 = require("../../../utils/solana/getAssetsByOwnerDas");
|
14
|
-
const constants_1 = require("../constants");
|
15
|
-
const constants_2 = require("../../../utils/clients/constants");
|
16
|
-
const executor = (owner) => __awaiter(void 0, void 0, void 0, function* () {
|
17
|
-
const rpcEndpoint = (0, constants_2.getRpcEndpoint)(portfolio_core_1.NetworkId.solana);
|
18
|
-
const list = yield (0, getAssetsByOwnerDas_1.getAssetsByOwnerDas)(rpcEndpoint, owner);
|
19
|
-
const assets = [];
|
20
|
-
const items = list.items.filter((i) => {
|
21
|
-
const isCompressed = i.compression.compressed;
|
22
|
-
const isSplNft = i.spl20 === null && i.inscription !== null;
|
23
|
-
return isCompressed || isSplNft;
|
24
|
-
});
|
25
|
-
items.forEach((i) => {
|
26
|
-
var _a;
|
27
|
-
assets.push({
|
28
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
29
|
-
type: portfolio_core_1.PortfolioAssetType.collectible,
|
30
|
-
value: null,
|
31
|
-
attributes: {},
|
32
|
-
data: {
|
33
|
-
address: i.id,
|
34
|
-
amount: 1,
|
35
|
-
price: null,
|
36
|
-
name: i.content.metadata.name,
|
37
|
-
imageUri: (_a = i.content.files.find((f) => { var _a; return (_a = f.mime) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase().startsWith('image'); })) === null || _a === void 0 ? void 0 : _a.uri,
|
38
|
-
dataUri: i.content.json_uri,
|
39
|
-
},
|
40
|
-
});
|
41
|
-
});
|
42
|
-
if (assets.length === 0)
|
43
|
-
return [];
|
44
|
-
const element = {
|
45
|
-
type: portfolio_core_1.PortfolioElementType.multiple,
|
46
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
47
|
-
platformId: constants_1.walletNftsPlatform.id,
|
48
|
-
label: 'Wallet',
|
49
|
-
value: null,
|
50
|
-
data: {
|
51
|
-
assets,
|
52
|
-
},
|
53
|
-
};
|
54
|
-
return [element];
|
55
|
-
});
|
56
|
-
const fetcher = {
|
57
|
-
id: `${constants_1.walletTokensPlatform.id}-solana-cnfts`,
|
58
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
59
|
-
executor,
|
60
|
-
};
|
61
|
-
exports.default = fetcher;
|
62
|
-
//# sourceMappingURL=solana-cnfts.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"solana-cnfts.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/tokens/fetchers/solana-cnfts.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAMoC;AAEpC,mFAAgF;AAChF,4CAAwE;AACxE,gEAAkE;AAElE,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,EAAE;IACxD,MAAM,WAAW,GAAG,IAAA,0BAAc,EAAC,0BAAS,CAAC,MAAM,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,MAAM,IAAA,yCAAmB,EAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAE3D,MAAM,MAAM,GAAgC,EAAE,CAAC;IAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;QACpC,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC;QAC9C,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,WAAW,KAA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3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -1,126 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
-
const web3_js_1 = require("@solana/web3.js");
|
17
|
-
const js_1 = require("@metaplex-foundation/js");
|
18
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
19
|
-
const constants_1 = require("../constants");
|
20
|
-
const clients_1 = require("../../../utils/clients");
|
21
|
-
const runInBatch_1 = __importDefault(require("../../../utils/misc/runInBatch"));
|
22
|
-
const singleListingFetcher_1 = __importDefault(require("../../tensor/singleListingFetcher"));
|
23
|
-
const prefix = 'nft-images';
|
24
|
-
const noImageValue = 'noimage';
|
25
|
-
const cacheTtl = 60 * 60 * 24 * 2; // 2 days
|
26
|
-
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
27
|
-
const client = (0, clients_1.getClientSolana)();
|
28
|
-
const metaplex = new js_1.Metaplex(client);
|
29
|
-
const outputs = yield metaplex.nfts().findAllByOwner({
|
30
|
-
owner: new web3_js_1.PublicKey(owner),
|
31
|
-
});
|
32
|
-
const nftsOnTensor = yield (0, singleListingFetcher_1.default)(owner);
|
33
|
-
const allNfts = [...outputs, ...nftsOnTensor].filter((nft) => nft !== null);
|
34
|
-
const cachedImages = yield cache.getItems(allNfts.map((o) => o.model === 'metadata'
|
35
|
-
? o.mintAddress.toString()
|
36
|
-
: o.mint.address.toString()), {
|
37
|
-
prefix,
|
38
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
39
|
-
});
|
40
|
-
const images = new Map();
|
41
|
-
const missings = [];
|
42
|
-
allNfts.forEach((o, i) => {
|
43
|
-
const cachedImage = cachedImages[i];
|
44
|
-
if (cachedImage) {
|
45
|
-
const address = o.model === 'metadata'
|
46
|
-
? o.mintAddress.toString()
|
47
|
-
: o.mint.address.toString();
|
48
|
-
images.set(address, cachedImage);
|
49
|
-
}
|
50
|
-
else if (o.model === 'metadata') {
|
51
|
-
missings.push(o);
|
52
|
-
}
|
53
|
-
});
|
54
|
-
const res = yield (0, runInBatch_1.default)(missings.map((o) => () => metaplex.nfts().load({ metadata: o })), 7);
|
55
|
-
const promises = res.map((r, i) => {
|
56
|
-
var _a;
|
57
|
-
const image = r.status !== 'rejected' ? (_a = r.value.json) === null || _a === void 0 ? void 0 : _a.image : undefined;
|
58
|
-
if (r.status === 'rejected' || !image) {
|
59
|
-
const address = missings[i].mintAddress.toString();
|
60
|
-
return cache.setItem(address, noImageValue, {
|
61
|
-
prefix,
|
62
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
63
|
-
});
|
64
|
-
}
|
65
|
-
const address = r.value.mint.address.toString();
|
66
|
-
images.set(address, image);
|
67
|
-
return cache.setItem(address, image, {
|
68
|
-
prefix,
|
69
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
70
|
-
ttl: cacheTtl,
|
71
|
-
});
|
72
|
-
});
|
73
|
-
yield Promise.allSettled(promises);
|
74
|
-
const assets = allNfts.map((output) => {
|
75
|
-
const address = output.model === 'metadata'
|
76
|
-
? output.mintAddress.toString()
|
77
|
-
: output.mint.address.toString();
|
78
|
-
const token = (0, js_1.isNftWithToken)(output) || (0, js_1.isSftWithToken)(output) ? output.token : null;
|
79
|
-
const amount = (token === null || token === void 0 ? void 0 : token.amount)
|
80
|
-
? new bignumber_js_1.default(token.amount.basisPoints.toString())
|
81
|
-
.div(Math.pow(10, token.amount.currency.decimals))
|
82
|
-
.toNumber()
|
83
|
-
: 1;
|
84
|
-
let image = images.get(address);
|
85
|
-
if (image === noImageValue)
|
86
|
-
image = undefined;
|
87
|
-
const collection = output.collection
|
88
|
-
? { id: output.collection.address.toString(), floorPrice: null }
|
89
|
-
: undefined;
|
90
|
-
return {
|
91
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
92
|
-
type: portfolio_core_1.PortfolioAssetType.collectible,
|
93
|
-
value: null,
|
94
|
-
attributes: {},
|
95
|
-
data: {
|
96
|
-
address,
|
97
|
-
amount,
|
98
|
-
dataUri: output.uri,
|
99
|
-
price: null,
|
100
|
-
imageUri: image,
|
101
|
-
name: output.name,
|
102
|
-
collection,
|
103
|
-
},
|
104
|
-
};
|
105
|
-
});
|
106
|
-
if (assets.length === 0)
|
107
|
-
return [];
|
108
|
-
const element = {
|
109
|
-
type: portfolio_core_1.PortfolioElementType.multiple,
|
110
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
111
|
-
platformId: constants_1.walletNftsPlatform.id,
|
112
|
-
label: 'Wallet',
|
113
|
-
value: null,
|
114
|
-
data: {
|
115
|
-
assets,
|
116
|
-
},
|
117
|
-
};
|
118
|
-
return [element];
|
119
|
-
});
|
120
|
-
const fetcher = {
|
121
|
-
id: `${constants_1.walletTokensPlatform.id}-solana-nfts`,
|
122
|
-
networkId: portfolio_core_1.NetworkId.solana,
|
123
|
-
executor,
|
124
|
-
};
|
125
|
-
exports.default = fetcher;
|
126
|
-
//# sourceMappingURL=solana-nfts.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"solana-nfts.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/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,0 @@
|
|
1
|
-
{"version":3,"file":"getAssetsByOwnerDas.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/getAssetsByOwnerDas.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kDAA6C;AAC7C,qEAAkE;AAElE,SAAsB,mBAAmB,CACvC,WAAwB,EACxB,KAAa;;QAEb,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS;YACvC,CAAC,CAAC,IAAA,yCAAmB,EACjB,WAAW,CAAC,SAAS,CAAC,QAAQ,EAC9B,WAAW,CAAC,SAAS,CAAC,QAAQ,CAC/B;YACH,CAAC,CAAC,SAAS,CAAC;QAEd,OAAO,eAAK;aACT,IAAI,CACH,WAAW,CAAC,GAAG,EACf;YACE,OAAO,EAAE,KAAK;YACd,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;YAC5B,MAAM,EAAE,kBAAkB;YAC1B,MAAM,EAAE;gBACN,YAAY,EAAE,KAAK;gBACnB,IAAI,EAAE,CAAC;gBACP,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE;oBACN,MAAM,EAAE,SAAS;oBACjB,aAAa,EAAE,KAAK;iBACrB;gBACD,cAAc,EAAE;oBACd,YAAY,EAAE,KAAK;oBACnB,iBAAiB,EAAE,KAAK;oBACxB,eAAe,EAAE,IAAI;iBACtB;aACF;SACF,EACD;YACE,OAAO,kBACL,cAAc,EAAE,kBAAkB,IAC/B,WAAW,CACf;SACF,CACF;aACA,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CAAA;AAzCD,kDAyCC"}
|