@sonarwatch/portfolio-plugins 0.11.139 → 0.11.141
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/package.json +3 -3
- package/src/plugins/aptin/depositsFetcher.js +9 -9
- package/src/plugins/aptin/depositsFetcher.js.map +1 -1
- package/src/plugins/native-stake/activeValidatorsJob.js +9 -4
- package/src/plugins/native-stake/activeValidatorsJob.js.map +1 -1
- package/src/plugins/native-stake/aptosFetcher.js +5 -3
- package/src/plugins/native-stake/aptosFetcher.js.map +1 -1
- package/src/plugins/pancakeswap/aptosLpJob.js +22 -17
- package/src/plugins/pancakeswap/aptosLpJob.js.map +1 -1
- package/src/plugins/thala/constants.d.ts +3 -10
- package/src/plugins/thala/constants.js +4 -4
- package/src/plugins/thala/constants.js.map +1 -1
- package/src/plugins/thala/stabilityPoolFetcher.js +4 -1
- package/src/plugins/thala/stabilityPoolFetcher.js.map +1 -1
- package/src/utils/aptos/getAccountCoinsData.d.ts +26 -0
- package/src/utils/aptos/getAccountCoinsData.js +10 -0
- package/src/utils/aptos/getAccountCoinsData.js.map +1 -0
- package/src/utils/aptos/getAccountResource.d.ts +2 -3
- package/src/utils/aptos/getAccountResource.js +4 -1
- package/src/utils/aptos/getAccountResource.js.map +1 -1
- package/src/utils/aptos/getAccountResources.d.ts +2 -5
- package/src/utils/aptos/getAccountResources.js +3 -1
- package/src/utils/aptos/getAccountResources.js.map +1 -1
- package/src/utils/aptos/getCoinInfoResource.d.ts +2 -2
- package/src/utils/aptos/getCoinStoreResource.d.ts +2 -2
- package/src/utils/aptos/getCoinStoreResources.d.ts +2 -5
- package/src/utils/aptos/getDecimals.d.ts +1 -1
- package/src/utils/aptos/getDecimals.js +1 -1
- package/src/utils/aptos/getDecimals.js.map +1 -1
- package/src/utils/aptos/getNestedType.d.ts +4 -0
- package/src/utils/aptos/getNestedType.js +4 -0
- package/src/utils/aptos/getNestedType.js.map +1 -1
- package/src/utils/aptos/getTableItem.d.ts +3 -3
- package/src/utils/aptos/getTableItem.js +1 -1
- package/src/utils/aptos/getTableItem.js.map +1 -1
- package/src/utils/aptos/getTableItemsByHandles.d.ts +3 -3
- package/src/utils/aptos/getTableItemsByHandles.js.map +1 -1
- package/src/utils/aptos/getTableItemsByKeys.d.ts +2 -2
- package/src/utils/aptos/getView.d.ts +3 -3
- package/src/utils/aptos/getView.js +1 -1
- package/src/utils/aptos/getView.js.map +1 -1
- package/src/utils/aptos/types.d.ts +0 -10
- package/src/utils/blank/isBlankAddressAptos.js +5 -1
- package/src/utils/blank/isBlankAddressAptos.js.map +1 -1
- package/src/utils/clients/constants.js +1 -1
- package/src/utils/clients/constants.js.map +1 -1
- package/src/utils/clients/getClientAptos.d.ts +1 -1
- package/src/utils/clients/getClientAptos.js +8 -3
- package/src/utils/clients/getClientAptos.js.map +1 -1
- package/src/utils/clients/types.d.ts +2 -0
- package/src/utils/misc/checkComputeAndStoreTokensPrices.d.ts +8 -0
- package/src/utils/misc/checkComputeAndStoreTokensPrices.js +9 -1
- package/src/utils/misc/checkComputeAndStoreTokensPrices.js.map +1 -1
- package/src/utils/misc/getDecimalsForToken.d.ts +1 -1
- package/src/utils/misc/getDecimalsForToken.js +9 -22
- package/src/utils/misc/getDecimalsForToken.js.map +1 -1
- package/src/utils/solana/getMultipleDecimals.js +2 -13
- package/src/utils/solana/getMultipleDecimals.js.map +1 -1
- package/src/utils/solana/getMultipleDecimalsAsMap.d.ts +3 -0
- package/src/utils/solana/getMultipleDecimalsAsMap.js +39 -0
- package/src/utils/solana/getMultipleDecimalsAsMap.js.map +1 -0
- package/src/utils/sui/getDecimals.d.ts +2 -0
- package/src/utils/sui/getDecimals.js +22 -0
- package/src/utils/sui/getDecimals.js.map +1 -0
- package/src/plugins/tokens/fetchers/aptos-nfts.d.ts +0 -3
- package/src/plugins/tokens/fetchers/aptos-nfts.js +0 -117
- package/src/plugins/tokens/fetchers/aptos-nfts.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getTableItemsByHandles.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getTableItemsByHandles.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"getTableItemsByHandles.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getTableItemsByHandles.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,iDAA8C;AAE9C,MAAM,GAAG,GAAG,EAAE,CAAC;AAEf,SAAsB,sBAAsB,CAC1C,MAAmB,EACnB,OAAiB,EACjB,IAAsB;;QAEtB,MAAM,KAAK,GAAG,EAAE,CAAC;QACjB,MAAM,cAAc,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;QACpC,OAAO,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,kBAAkB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YACzD,MAAM,SAAS,GAAG,MAAM,uBAAuB,CAC7C,MAAM,EACN,kBAAkB,EAClB,IAAI,CACL,CAAC;YACF,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CAAA;AAjBD,wDAiBC;AAED,SAAe,uBAAuB,CACpC,MAAmB,EACnB,OAAiB,EACjB,IAAsB;;QAEtB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACtC,IAAA,2BAAY,EAAI,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CACtC,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACnD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YAC5B,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU;gBAAE,OAAO,IAAI,CAAC;YAC9C,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;CAAA"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { AptosClient } from '
|
2
|
-
export declare function getTableItemsByKeys<T>(client: AptosClient, handle: string, keys: string[], keyType: string, valueType: string): Promise<(Awaited<NonNullable<T
|
1
|
+
import { AptosClient } from '../clients/types';
|
2
|
+
export declare function getTableItemsByKeys<T>(client: AptosClient, handle: string, keys: string[], keyType: string, valueType: string): Promise<(Awaited<NonNullable<Awaited<T>>> | null)[]>;
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
export declare function getView(client: AptosClient, payload:
|
1
|
+
import { InputViewRequestData } from '@aptos-labs/ts-sdk';
|
2
|
+
import { AptosClient } from '../clients/types';
|
3
|
+
export declare function getView(client: AptosClient, payload: InputViewRequestData): Promise<import("@aptos-labs/ts-sdk").MoveValue[] | null>;
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getView = void 0;
|
13
13
|
function getView(client, payload) {
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
15
|
-
const resource = yield client.view(payload).catch((e) => {
|
15
|
+
const resource = yield client.view({ payload }).catch((e) => {
|
16
16
|
if (!e.status || e.status !== 404)
|
17
17
|
throw e;
|
18
18
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getView.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getView.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,SAAsB,OAAO,
|
1
|
+
{"version":3,"file":"getView.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getView.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,SAAsB,OAAO,CAC3B,MAAmB,EACnB,OAA6B;;QAE7B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YAC1D,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG;gBAAE,MAAM,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC3B,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AATD,0BASC"}
|
@@ -1,13 +1,3 @@
|
|
1
|
-
export type TableItemRequest = {
|
2
|
-
key_type: string;
|
3
|
-
value_type: string;
|
4
|
-
key: string;
|
5
|
-
};
|
6
|
-
export type ViewRequest = {
|
7
|
-
function: string;
|
8
|
-
type_arguments: string[];
|
9
|
-
arguments: string[];
|
10
|
-
};
|
11
1
|
export type MoveType = {
|
12
2
|
type: string;
|
13
3
|
root: string;
|
@@ -14,7 +14,11 @@ const clients_1 = require("../clients");
|
|
14
14
|
function isBlankAddressAptos(address) {
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
16
16
|
const client = (0, clients_1.getClientAptos)();
|
17
|
-
const ressources = yield client
|
17
|
+
const ressources = yield client
|
18
|
+
.getAccountResources({
|
19
|
+
accountAddress: address,
|
20
|
+
})
|
21
|
+
.catch(() => []);
|
18
22
|
return ressources.length === 0;
|
19
23
|
});
|
20
24
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"isBlankAddressAptos.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/blank/isBlankAddressAptos.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA4C;AAE5C,SAAsB,mBAAmB,CAAC,OAAe;;QACvD,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;QAChC,MAAM,UAAU,GAAG,MAAM,MAAM,
|
1
|
+
{"version":3,"file":"isBlankAddressAptos.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/blank/isBlankAddressAptos.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA4C;AAE5C,SAAsB,mBAAmB,CAAC,OAAe;;QACvD,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;QAChC,MAAM,UAAU,GAAG,MAAM,MAAM;aAC5B,mBAAmB,CAAC;YACnB,cAAc,EAAE,OAAO;SACxB,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QACnB,OAAO,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC;IACjC,CAAC;CAAA;AARD,kDAQC"}
|
@@ -24,7 +24,7 @@ function getUrlEndpoints() {
|
|
24
24
|
'https://api.avax.network/ext/bc/C/rpc',
|
25
25
|
polygon: process.env['PORTFOLIO_POLYGON_RPC'] || 'https://1rpc.io/matic',
|
26
26
|
aptos: process.env['PORTFOLIO_APTOS_RPC'] ||
|
27
|
-
'https://
|
27
|
+
'https://api.mainnet.aptoslabs.com/v1',
|
28
28
|
sui: process.env['PORTFOLIO_SUI_RPC'] || 'https://sui-rpc.publicnode.com',
|
29
29
|
};
|
30
30
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/clients/constants.ts"],"names":[],"mappings":";;;;;;AAKA,wCAAsE;AACtE,0EAAkD;AAErC,QAAA,qBAAqB,GAAoC;IACpE,QAAQ,EAAE,gBAAO;IACjB,SAAS,EAAT,kBAAS;IACT,OAAO,EAAP,gBAAO;IACP,GAAG,EAAE,YAAG;CACT,CAAC;AAEF,SAAgB,eAAe;IAC7B,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,+BAA+B;QACxE,OAAO,EACL,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,+BAA+B;QACzE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,8BAA8B;QACvE,MAAM,EACJ,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;YACnC,qCAAqC;QACvC,QAAQ,EACN,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,0BAA0B;QACrE,SAAS,EACP,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC;YACtC,uCAAuC;QACzC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,uBAAuB;QACxE,KAAK,EACH,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;YAClC,
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/clients/constants.ts"],"names":[],"mappings":";;;;;;AAKA,wCAAsE;AACtE,0EAAkD;AAErC,QAAA,qBAAqB,GAAoC;IACpE,QAAQ,EAAE,gBAAO;IACjB,SAAS,EAAT,kBAAS;IACT,OAAO,EAAP,gBAAO;IACP,GAAG,EAAE,YAAG;CACT,CAAC;AAEF,SAAgB,eAAe;IAC7B,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,+BAA+B;QACxE,OAAO,EACL,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,+BAA+B;QACzE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,8BAA8B;QACvE,MAAM,EACJ,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;YACnC,qCAAqC;QACvC,QAAQ,EACN,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,0BAA0B;QACrE,SAAS,EACP,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC;YACtC,uCAAuC;QACzC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,uBAAuB;QACxE,KAAK,EACH,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;YAClC,sCAAsC;QACxC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,gCAAgC;KAC1E,CAAC;AACJ,CAAC;AApBD,0CAoBC;AAED,SAAgB,cAAc,CAAC,SAAwB;IACrD,OAAO,eAAe,EAAE,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAFD,wCAEC;AAED,SAAgB,eAAe;IAC7B,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IACvC,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QACjD,GAAG;QACH,IAAA,0BAAgB,EAAC,KAAK,CAAC;KACxB,CAAC,CACmC,CAAC;AAC1C,CAAC;AARD,0CAQC;AAED,SAAgB,cAAc,CAAC,SAAwB;IACrD,OAAO,eAAe,EAAE,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAFD,wCAEC"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { AptosClient } from '
|
1
|
+
import { AptosClient } from './types';
|
2
2
|
export default function getClientAptos(): AptosClient;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
4
|
-
const
|
4
|
+
const ts_sdk_1 = require("@aptos-labs/ts-sdk");
|
5
5
|
const constants_1 = require("./constants");
|
6
6
|
const getBasicAuthHeaders_1 = require("../misc/getBasicAuthHeaders");
|
7
7
|
function getClientAptos() {
|
@@ -10,9 +10,14 @@ function getClientAptos() {
|
|
10
10
|
const headers = rpcEndpoint.basicAuth
|
11
11
|
? (0, getBasicAuthHeaders_1.getBasicAuthHeaders)((_a = rpcEndpoint.basicAuth) === null || _a === void 0 ? void 0 : _a.username, (_b = rpcEndpoint.basicAuth) === null || _b === void 0 ? void 0 : _b.password)
|
12
12
|
: undefined;
|
13
|
-
|
14
|
-
|
13
|
+
const config = new ts_sdk_1.AptosConfig({
|
14
|
+
network: ts_sdk_1.Network.MAINNET,
|
15
|
+
clientConfig: {
|
16
|
+
HEADERS: headers,
|
17
|
+
},
|
18
|
+
fullnode: rpcEndpoint.url,
|
15
19
|
});
|
20
|
+
return new ts_sdk_1.Aptos(config);
|
16
21
|
}
|
17
22
|
exports.default = getClientAptos;
|
18
23
|
//# sourceMappingURL=getClientAptos.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getClientAptos.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/clients/getClientAptos.ts"],"names":[],"mappings":";;AAAA,+DAAuD;AACvD
|
1
|
+
{"version":3,"file":"getClientAptos.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/clients/getClientAptos.ts"],"names":[],"mappings":";;AAAA,+DAAuD;AACvD,+CAAiE;AACjE,2CAA6C;AAC7C,qEAAkE;AAGlE,SAAwB,cAAc;;IACpC,MAAM,WAAW,GAAG,IAAA,0BAAc,EAAC,0BAAS,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS;QACnC,CAAC,CAAC,IAAA,yCAAmB,EACjB,MAAA,WAAW,CAAC,SAAS,0CAAE,QAAQ,EAC/B,MAAA,WAAW,CAAC,SAAS,0CAAE,QAAQ,CAChC;QACH,CAAC,CAAC,SAAS,CAAC;IACd,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC;QAC7B,OAAO,EAAE,gBAAO,CAAC,OAAO;QACxB,YAAY,EAAE;YACZ,OAAO,EAAE,OAAO;SACjB;QACD,QAAQ,EAAE,WAAW,CAAC,GAAG;KAC1B,CAAC,CAAC;IACH,OAAO,IAAI,cAAK,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AAhBD,iCAgBC"}
|
@@ -1,6 +1,8 @@
|
|
1
|
+
import { Aptos } from '@aptos-labs/ts-sdk';
|
1
2
|
import { SuiClient as MystenSuiClient } from '@mysten/sui.js/client';
|
2
3
|
import { Connection } from '@solana/web3.js';
|
3
4
|
import { PublicClient } from 'viem';
|
4
5
|
export type EvmClient = PublicClient;
|
5
6
|
export type SuiClient = MystenSuiClient;
|
6
7
|
export type SolanaClient = Connection;
|
8
|
+
export type AptosClient = Aptos;
|
@@ -23,6 +23,14 @@ export type PartialTokenUnderlying = {
|
|
23
23
|
* If you think other tokens should be added to this list, please send a PR.
|
24
24
|
*/
|
25
25
|
export declare const tokensToRelyOnByNetwork: Map<NetworkIdType, string[]>;
|
26
|
+
/**
|
27
|
+
* @deprecated
|
28
|
+
* This function has been deprecated. Use the getLpUnderlyingTokenSource instead.
|
29
|
+
* This list is used to avoid calulating low liquidity tokens with others low liquidity tokens.
|
30
|
+
* To prevent wrong prices (with very low precision) to be calculated, we setup a list of tokens to rely on.
|
31
|
+
* These tokens have very low chance of having price manipulation.
|
32
|
+
* Therefore, they can be safely used to compute other tokens prices.
|
33
|
+
*/
|
26
34
|
export default function checkComputeAndStoreTokensPrices(cache: Cache, source: string, networkId: NetworkIdType, tokenX: TokenInfo, tokenY: TokenInfo): Promise<{
|
27
35
|
partialTokenUnderlyingX: PartialTokenUnderlying;
|
28
36
|
partialTokenUnderlyingY: PartialTokenUnderlying;
|
@@ -66,6 +66,14 @@ exports.tokensToRelyOnByNetwork = new Map([
|
|
66
66
|
],
|
67
67
|
],
|
68
68
|
]);
|
69
|
+
/**
|
70
|
+
* @deprecated
|
71
|
+
* This function has been deprecated. Use the getLpUnderlyingTokenSource instead.
|
72
|
+
* This list is used to avoid calulating low liquidity tokens with others low liquidity tokens.
|
73
|
+
* To prevent wrong prices (with very low precision) to be calculated, we setup a list of tokens to rely on.
|
74
|
+
* These tokens have very low chance of having price manipulation.
|
75
|
+
* Therefore, they can be safely used to compute other tokens prices.
|
76
|
+
*/
|
69
77
|
function checkComputeAndStoreTokensPrices(cache, source, networkId, tokenX, tokenY) {
|
70
78
|
return __awaiter(this, void 0, void 0, function* () {
|
71
79
|
const tokensToRelyOn = exports.tokensToRelyOnByNetwork.get(networkId);
|
@@ -117,7 +125,7 @@ function checkComputeAndStoreTokensPrices(cache, source, networkId, tokenX, toke
|
|
117
125
|
else {
|
118
126
|
decimalsTokenY = yield (0, getDecimalsForToken_1.getDecimalsForToken)(cache, tokenY.mint, networkId);
|
119
127
|
}
|
120
|
-
if (decimalsTokenX ===
|
128
|
+
if (decimalsTokenX === null || decimalsTokenY === null)
|
121
129
|
return undefined;
|
122
130
|
const tokenXReserve = tokenX.rawReserve.dividedBy(Math.pow(10, decimalsTokenX));
|
123
131
|
const tokenYReserve = tokenY.rawReserve.dividedBy(Math.pow(10, decimalsTokenY));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"checkComputeAndStoreTokensPrices.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/checkComputeAndStoreTokensPrices.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAMoC;AAGpC,wEAAgD;AAChD,+DAA4D;AAC5D,8DAAsE;AAetE;;;;;;;;;GASG;AACU,QAAA,uBAAuB,GAAiC,IAAI,GAAG,CAAC;IAC3E;QACE,0BAAS,CAAC,GAAG;QACb;YACE,yBAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO;YAC3B,sEAAsE,EAAE,OAAO;YAC/E,qHAAqH,EAAE,SAAS;SACjI;KACF;IACD;QACE,0BAAS,CAAC,MAAM;QAChB;YACE,yBAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO;YAC9B,2CAA0B,EAAE,OAAO;YACnC,8CAA8C,EAAE,WAAW;YAC3D,6CAA6C,EAAE,OAAO;YACtD,8CAA8C,EAAE,WAAW;YAC3D,8CAA8C,EAAE,OAAO;YACvD,8CAA8C,EAAE,OAAO;SACxD;KACF;IACD;QACE,0BAAS,CAAC,KAAK;QACf;YACE,yBAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO;YAC7B,6EAA6E,EAAE,SAAS;YACxF,mFAAmF,EAAE,oBAAoB;SAC1G;KACF;IACD;QACE,0BAAS,CAAC,GAAG;QACb;YACE,yBAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO;YAC3B,gF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,CAAC;QAED,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,EAAE,CAAC;YACjC,IAAI,
|
1
|
+
{"version":3,"file":"checkComputeAndStoreTokensPrices.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/checkComputeAndStoreTokensPrices.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAMoC;AAGpC,wEAAgD;AAChD,+DAA4D;AAC5D,8DAAsE;AAetE;;;;;;;;;GASG;AACU,QAAA,uBAAuB,GAAiC,IAAI,GAAG,CAAC;IAC3E;QACE,0BAAS,CAAC,GAAG;QACb;YACE,yBAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO;YAC3B,sEAAsE,EAAE,OAAO;YAC/E,qHAAqH,EAAE,SAAS;SACjI;KACF;IACD;QACE,0BAAS,CAAC,MAAM;QAChB;YACE,yBAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO;YAC9B,2CAA0B,EAAE,OAAO;YACnC,8CAA8C,EAAE,WAAW;YAC3D,6CAA6C,EAAE,OAAO;YACtD,8CAA8C,EAAE,WAAW;YAC3D,8CAA8C,EAAE,OAAO;YACvD,8CAA8C,EAAE,OAAO;SACxD;KACF;IACD;QACE,0BAAS,CAAC,KAAK;QACf;YACE,yBAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO;YAC7B,6EAA6E,EAAE,SAAS;YACxF,mFAAmF,EAAE,oBAAoB;SAC1G;KACF;IACD;QACE,0BAAS,CAAC,GAAG;QACb;YACE,yBAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO;YAC3B,gFAAgF,EAAE,SAAS;YAC3F,iFAAiF,EAAE,QAAQ;YAC3F,eAAe;SAChB;KACF;CACF,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,SAA8B,gCAAgC,CAC5D,KAAY,EACZ,MAAc,EACd,SAAwB,EACxB,MAAiB,EACjB,MAAiB;;QAQjB,MAAM,cAAc,GAAG,+BAAuB,CAAC,GAAG,C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IC"}
|
@@ -9,4 +9,4 @@ import { Cache } from '../../Cache';
|
|
9
9
|
*
|
10
10
|
* @returns The number of decimals or undefined if unsucessful request.
|
11
11
|
*/
|
12
|
-
export declare function getDecimalsForToken(cache: Cache, address: string, networkId: NetworkIdType): Promise<number |
|
12
|
+
export declare function getDecimalsForToken(cache: Cache, address: string, networkId: NetworkIdType): Promise<number | null>;
|
@@ -14,11 +14,12 @@ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
|
14
14
|
const web3_js_1 = require("@solana/web3.js");
|
15
15
|
const core_1 = require("@sei-js/core");
|
16
16
|
const clients_1 = require("../clients");
|
17
|
-
const aptos_1 = require("../aptos");
|
18
17
|
const constants_1 = require("../clients/constants");
|
19
18
|
const sei_1 = require("../sei");
|
20
19
|
const constants_2 = require("../../plugins/tokens/constants");
|
21
|
-
const
|
20
|
+
const getDecimals_1 = require("../aptos/getDecimals");
|
21
|
+
const getDecimals_2 = require("../solana/getDecimals");
|
22
|
+
const getDecimals_3 = require("../sui/getDecimals");
|
22
23
|
/**
|
23
24
|
* Return the decimals of a token on any network using RPC calls or TokenList.
|
24
25
|
*
|
@@ -39,22 +40,11 @@ function getDecimalsForToken(cache, address, networkId) {
|
|
39
40
|
switch (networkId) {
|
40
41
|
case 'aptos': {
|
41
42
|
const client = (0, clients_1.getClientAptos)();
|
42
|
-
|
43
|
-
function: aptos_1.coinDecimals,
|
44
|
-
type_arguments: [address],
|
45
|
-
arguments: [],
|
46
|
-
}));
|
47
|
-
if (viewRes.length !== 1)
|
48
|
-
return undefined;
|
49
|
-
return viewRes[0];
|
43
|
+
return (0, getDecimals_1.getDecimals)(client, address);
|
50
44
|
}
|
51
45
|
case 'solana': {
|
52
46
|
const client = (0, clients_1.getClientSolana)();
|
53
|
-
|
54
|
-
return 9;
|
55
|
-
}
|
56
|
-
const res = yield client.getTokenSupply(new web3_js_1.PublicKey(address));
|
57
|
-
return res.value.decimals ? res.value.decimals : undefined;
|
47
|
+
return (0, getDecimals_2.getDecimals)(client, new web3_js_1.PublicKey(address));
|
58
48
|
}
|
59
49
|
case 'sei': {
|
60
50
|
if (address.startsWith('factory')) {
|
@@ -67,21 +57,18 @@ function getDecimalsForToken(cache, address, networkId) {
|
|
67
57
|
}
|
68
58
|
if (address.startsWith('ibc')) {
|
69
59
|
// No solution yet for IBC tokens
|
70
|
-
return
|
60
|
+
return null;
|
71
61
|
}
|
72
62
|
if (address.startsWith('sei')) {
|
73
63
|
const client = yield (0, core_1.getCosmWasmClient)((0, constants_1.getUrlEndpoint)(portfolio_core_1.NetworkId.sei));
|
74
64
|
const tokenInfo = (yield client.queryContractSmart(address, sei_1.tokenInfoQueryMsg));
|
75
|
-
return tokenInfo.decimals ||
|
65
|
+
return tokenInfo.decimals || null;
|
76
66
|
}
|
77
|
-
return
|
67
|
+
return null;
|
78
68
|
}
|
79
69
|
case 'sui': {
|
80
70
|
const client = (0, clients_1.getClientSui)();
|
81
|
-
|
82
|
-
if (coinMetadata)
|
83
|
-
return coinMetadata.decimals;
|
84
|
-
return undefined;
|
71
|
+
return (0, getDecimals_3.getDecimals)(client, address);
|
85
72
|
}
|
86
73
|
default:
|
87
74
|
throw new Error('getDecimalsForToken : Network not supported');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getDecimalsForToken.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getDecimalsForToken.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+
|
1
|
+
{"version":3,"file":"getDecimalsForToken.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getDecimalsForToken.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAIoC;AACpC,6CAA4C;AAC5C,uCAAiD;AACjD,wCAKoB;AACpB,oDAAsD;AACtD,gCAAsD;AAEtD,8DAAyE;AAEzE,sDAAuE;AACvE,uDAAyE;AACzE,oDAAmE;AAEnE;;;;;;;;GAQG;AACH,SAAsB,mBAAmB,CACvC,KAAY,EACZ,OAAe,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B,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAiB,EAAC,IAAA,0BAAc,EAAC,0BAAS,CAAC,GAAG,CAAC,CAAC,CAAC;oBACtE,MAAM,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAChD,OAAO,EACP,uBAAiB,CAClB,CAAc,CAAC;oBAChB,OAAO,SAAS,CAAC,QAAQ,IAAI,IAAI,CAAC;gBACpC,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;YACD,KAAK,KAAK,CAAC,CAAC,CAAC;gBACX,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;gBAC9B,OAAO,IAAA,yBAAc,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;YACD;gBACE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CAAA;AArDD,kDAqDC"}
|
@@ -10,21 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
exports.getMultipleDecimals = void 0;
|
13
|
-
const
|
14
|
-
const structs_1 = require("./structs");
|
15
|
-
const getParsedMultipleAccountsInfo_1 = require("./getParsedMultipleAccountsInfo");
|
16
|
-
const solMints = [portfolio_core_1.solanaNativeAddress, portfolio_core_1.solanaNativeWrappedAddress];
|
13
|
+
const getMultipleDecimalsAsMap_1 = require("./getMultipleDecimalsAsMap");
|
17
14
|
function getMultipleDecimals(connection, mints) {
|
18
15
|
return __awaiter(this, void 0, void 0, function* () {
|
19
|
-
const
|
20
|
-
const decimalsMap = new Map();
|
21
|
-
decimalsMap.set(portfolio_core_1.solanaNativeAddress, portfolio_core_1.solanaNativeDecimals);
|
22
|
-
decimalsMap.set(portfolio_core_1.solanaNativeWrappedAddress, portfolio_core_1.solanaNativeDecimals);
|
23
|
-
mintAccounts.forEach((acc) => {
|
24
|
-
if (!acc)
|
25
|
-
return;
|
26
|
-
decimalsMap.set(acc.pubkey.toString(), acc.decimals);
|
27
|
-
});
|
16
|
+
const decimalsMap = yield (0, getMultipleDecimalsAsMap_1.getMultipleDecimalsAsMap)(connection, mints);
|
28
17
|
return mints.map((m) => decimalsMap.get(m.toString()) || null);
|
29
18
|
});
|
30
19
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getMultipleDecimals.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/getMultipleDecimals.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"getMultipleDecimals.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/getMultipleDecimals.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yEAAsE;AAEtE,SAAsB,mBAAmB,CACvC,UAAwB,EACxB,KAAkB;;QAElB,MAAM,WAAW,GAAG,MAAM,IAAA,mDAAwB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACtE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC;IACjE,CAAC;CAAA;AAND,kDAMC"}
|
@@ -0,0 +1,39 @@
|
|
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
|
+
exports.getMultipleDecimalsAsMap = void 0;
|
13
|
+
const web3_js_1 = require("@solana/web3.js");
|
14
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
15
|
+
const structs_1 = require("./structs");
|
16
|
+
const getParsedMultipleAccountsInfo_1 = require("./getParsedMultipleAccountsInfo");
|
17
|
+
function getMultipleDecimalsAsMap(connection, mints) {
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
19
|
+
const mintsSet = new Set(mints.map((m) => m.toString()));
|
20
|
+
const decimalsMap = new Map();
|
21
|
+
if (mintsSet.has(portfolio_core_1.solanaNativeAddress)) {
|
22
|
+
decimalsMap.set(portfolio_core_1.solanaNativeAddress, portfolio_core_1.solanaNativeDecimals);
|
23
|
+
mintsSet.delete(portfolio_core_1.solanaNativeAddress);
|
24
|
+
}
|
25
|
+
if (mintsSet.has(portfolio_core_1.solanaNativeWrappedAddress)) {
|
26
|
+
decimalsMap.set(portfolio_core_1.solanaNativeWrappedAddress, portfolio_core_1.solanaNativeDecimals);
|
27
|
+
mintsSet.delete(portfolio_core_1.solanaNativeWrappedAddress);
|
28
|
+
}
|
29
|
+
const mintAccounts = yield (0, getParsedMultipleAccountsInfo_1.getParsedMultipleAccountsInfo)(connection, structs_1.mintAccountStruct, Array.from(mintsSet).map((m) => new web3_js_1.PublicKey(m)));
|
30
|
+
mintAccounts.forEach((acc) => {
|
31
|
+
if (!acc)
|
32
|
+
return;
|
33
|
+
decimalsMap.set(acc.pubkey.toString(), acc.decimals);
|
34
|
+
});
|
35
|
+
return decimalsMap;
|
36
|
+
});
|
37
|
+
}
|
38
|
+
exports.getMultipleDecimalsAsMap = getMultipleDecimalsAsMap;
|
39
|
+
//# sourceMappingURL=getMultipleDecimalsAsMap.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getMultipleDecimalsAsMap.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/solana/getMultipleDecimals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,22 @@
|
|
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
|
+
exports.getDecimals = void 0;
|
13
|
+
function getDecimals(client, coinType) {
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
15
|
+
const coinMetadata = yield client.getCoinMetadata({ coinType });
|
16
|
+
if (coinMetadata)
|
17
|
+
return coinMetadata.decimals;
|
18
|
+
return null;
|
19
|
+
});
|
20
|
+
}
|
21
|
+
exports.getDecimals = getDecimals;
|
22
|
+
//# sourceMappingURL=getDecimals.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getDecimals.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/sui/getDecimals.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,SAAsB,WAAW,CAC/B,MAAiB,EACjB,QAAgB;;QAEhB,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChE,IAAI,YAAY;YAAE,OAAO,YAAY,CAAC,QAAQ,CAAC;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;AAPD,kCAOC"}
|
@@ -1,117 +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
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
16
|
-
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
17
|
-
const aptos_1 = require("aptos");
|
18
|
-
const runInBatch_1 = __importDefault(require("../../../utils/misc/runInBatch"));
|
19
|
-
const getImagefromUri_1 = require("../../../utils/misc/getImagefromUri");
|
20
|
-
const constants_1 = require("../constants");
|
21
|
-
const prefix = 'nft-images-aptos';
|
22
|
-
const noImageValue = 'noimage';
|
23
|
-
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
24
|
-
const provider = new aptos_1.Provider(aptos_1.Network.MAINNET);
|
25
|
-
const ownedTokensRes = yield provider.getOwnedTokens(owner);
|
26
|
-
const nfts = ownedTokensRes.current_token_ownerships_v2.filter((nft) => nft.current_token_data);
|
27
|
-
const cachedImages = yield cache.getItems(nfts
|
28
|
-
.map((o) => (o.current_token_data ? o.current_token_data.token_uri : []))
|
29
|
-
.flat(), {
|
30
|
-
prefix,
|
31
|
-
networkId: portfolio_core_1.NetworkId.aptos,
|
32
|
-
});
|
33
|
-
const images = new Map();
|
34
|
-
const missings = [];
|
35
|
-
nfts.forEach((o, i) => __awaiter(void 0, void 0, void 0, function* () {
|
36
|
-
if (!o.current_token_data)
|
37
|
-
return;
|
38
|
-
const cachedImage = cachedImages[i];
|
39
|
-
const address = o.current_token_data.token_uri;
|
40
|
-
if (cachedImage) {
|
41
|
-
images.set(address, cachedImage);
|
42
|
-
}
|
43
|
-
else
|
44
|
-
missings.push(o);
|
45
|
-
}));
|
46
|
-
const res = yield (0, runInBatch_1.default)(missings.map((o) => () => { var _a; return (0, getImagefromUri_1.getImagefromUri)((_a = o.current_token_data) === null || _a === void 0 ? void 0 : _a.token_uri, portfolio_core_1.NetworkId.aptos, cache); }), 10);
|
47
|
-
const promises = res.map((r, i) => {
|
48
|
-
var _a;
|
49
|
-
const image = r.status !== 'rejected' ? r.value : undefined;
|
50
|
-
const address = (_a = missings[i].current_token_data) === null || _a === void 0 ? void 0 : _a.token_uri;
|
51
|
-
if (!address)
|
52
|
-
return undefined;
|
53
|
-
if (r.status === 'rejected' || !image) {
|
54
|
-
return cache.setItem(address, noImageValue, {
|
55
|
-
prefix,
|
56
|
-
networkId: portfolio_core_1.NetworkId.aptos,
|
57
|
-
});
|
58
|
-
}
|
59
|
-
images.set(address, image);
|
60
|
-
return cache.setItem(address, image, {
|
61
|
-
prefix,
|
62
|
-
networkId: portfolio_core_1.NetworkId.aptos,
|
63
|
-
});
|
64
|
-
});
|
65
|
-
yield Promise.allSettled(promises);
|
66
|
-
const assets = nfts
|
67
|
-
.map((nft) => {
|
68
|
-
var _a;
|
69
|
-
if (!nft.current_token_data)
|
70
|
-
return [];
|
71
|
-
const address = nft.current_token_data.token_data_id;
|
72
|
-
const dataUri = nft.current_token_data.token_uri;
|
73
|
-
const { amount } = nft;
|
74
|
-
let image = images.get(dataUri);
|
75
|
-
if (image === noImageValue)
|
76
|
-
image = undefined;
|
77
|
-
return {
|
78
|
-
networkId: portfolio_core_1.NetworkId.aptos,
|
79
|
-
type: portfolio_core_1.PortfolioAssetType.collectible,
|
80
|
-
value: null,
|
81
|
-
attributes: {},
|
82
|
-
data: {
|
83
|
-
address,
|
84
|
-
amount,
|
85
|
-
dataUri,
|
86
|
-
price: null,
|
87
|
-
value: null,
|
88
|
-
floorPrice: null,
|
89
|
-
image,
|
90
|
-
imageUri: image,
|
91
|
-
name: nft.current_token_data.token_name,
|
92
|
-
collectionId: (_a = nft.current_token_data.current_collection) === null || _a === void 0 ? void 0 : _a.collection_id,
|
93
|
-
},
|
94
|
-
};
|
95
|
-
})
|
96
|
-
.flat();
|
97
|
-
if (assets.length === 0)
|
98
|
-
return [];
|
99
|
-
const element = {
|
100
|
-
type: portfolio_core_1.PortfolioElementType.multiple,
|
101
|
-
networkId: portfolio_core_1.NetworkId.aptos,
|
102
|
-
platformId: constants_1.walletNftsPlatform.id,
|
103
|
-
label: 'Wallet',
|
104
|
-
value: null,
|
105
|
-
data: {
|
106
|
-
assets,
|
107
|
-
},
|
108
|
-
};
|
109
|
-
return [element];
|
110
|
-
});
|
111
|
-
const fetcher = {
|
112
|
-
id: `${constants_1.walletNftsPlatform.id}-${portfolio_core_1.NetworkId.aptos}`,
|
113
|
-
networkId: portfolio_core_1.NetworkId.sui,
|
114
|
-
executor,
|
115
|
-
};
|
116
|
-
exports.default = fetcher;
|
117
|
-
//# sourceMappingURL=aptos-nfts.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"aptos-nfts.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/tokens/fetchers/aptos-nfts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,+DAMoC;AACpC,iCAA0C;AAG1C,gFAAwD;AACxD,yEAAsE;AACtE,4CAAkD;AAElD,MAAM,MAAM,GAAG,kBAAkB,CAAC;AAClC,MAAM,YAAY,GAAG,SAAS,CAAC;AA2C/B,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,QAAQ,GAAG,IAAI,gBAAQ,CAAC,eAAO,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,cAAc,GAAG,MAAM,QAAQ,CAAC,cAAc,CAAC,KAAK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