@metamask-previews/assets-controllers 27.2.0-preview-59bf6d5d → 27.2.0-preview-14be4d0
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/dist/AssetsContractController.js +6 -6
- package/dist/AssetsContractController.mjs +5 -5
- package/dist/CurrencyRateController.js +3 -3
- package/dist/CurrencyRateController.mjs +2 -2
- package/dist/NftController.js +3 -5
- package/dist/NftController.mjs +2 -4
- package/dist/NftDetectionController.js +4 -4
- package/dist/NftDetectionController.mjs +3 -3
- package/dist/Standards/ERC20Standard.js +3 -3
- package/dist/Standards/ERC20Standard.mjs +2 -2
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.js +3 -3
- package/dist/Standards/NftStandards/ERC1155/ERC1155Standard.mjs +2 -2
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.js +3 -3
- package/dist/Standards/NftStandards/ERC721/ERC721Standard.mjs +2 -2
- package/dist/TokenDetectionController.js +3 -3
- package/dist/TokenDetectionController.mjs +2 -2
- package/dist/TokenListController.js +4 -4
- package/dist/TokenListController.mjs +3 -3
- package/dist/TokenRatesController.js +4 -4
- package/dist/TokenRatesController.mjs +3 -3
- package/dist/TokensController.js +6 -6
- package/dist/TokensController.mjs +5 -5
- package/dist/assetsUtil.js +2 -8
- package/dist/assetsUtil.mjs +1 -7
- package/dist/{chunk-6NO7Z5DL.js → chunk-3PHIUBM3.js} +4 -4
- package/dist/{chunk-KCUSDOIE.mjs → chunk-4OXWUHJZ.mjs} +4 -4
- package/dist/{chunk-355MWUUQ.js → chunk-BM7EPTR6.js} +3 -3
- package/dist/{chunk-VY7TUOK2.js → chunk-D3N35ABH.js} +3 -3
- package/dist/{chunk-RELRWIJN.js → chunk-D6BDJYSK.js} +2 -68
- package/dist/chunk-D6BDJYSK.js.map +1 -0
- package/dist/{chunk-C4PQK53K.js → chunk-DYH5P3VY.js} +5 -2
- package/dist/chunk-DYH5P3VY.js.map +1 -0
- package/dist/{chunk-NUBQRDKI.js → chunk-E2SLNUD4.js} +11 -11
- package/dist/{chunk-VHCPQS4X.js → chunk-GCWWC4X3.js} +5 -5
- package/dist/{chunk-KRTEFV4Q.mjs → chunk-IURNPMBB.mjs} +2 -2
- package/dist/{chunk-WSOHBBCO.js → chunk-JEGLHDNA.js} +42 -56
- package/dist/chunk-JEGLHDNA.js.map +1 -0
- package/dist/{chunk-GLZ66IRX.mjs → chunk-KDMDWUVX.mjs} +41 -55
- package/dist/chunk-KDMDWUVX.mjs.map +1 -0
- package/dist/{chunk-MQ7TIWBK.mjs → chunk-KS4MOA2T.mjs} +2 -2
- package/dist/{chunk-XEZJ5XMV.js → chunk-LBPVKXXG.js} +5 -5
- package/dist/{chunk-H6TOSWUM.js → chunk-LRKDZWS6.js} +3 -3
- package/dist/{chunk-CEENXWOB.mjs → chunk-N5H5KDJZ.mjs} +2 -2
- package/dist/{chunk-2IZUMKMY.mjs → chunk-NHX4QGOD.mjs} +3 -3
- package/dist/{chunk-AQIXUBTK.js → chunk-NIXK7RMZ.js} +74 -127
- package/dist/chunk-NIXK7RMZ.js.map +1 -0
- package/dist/{chunk-TCO22VIO.mjs → chunk-PWZE6KJV.mjs} +5 -2
- package/dist/chunk-PWZE6KJV.mjs.map +1 -0
- package/dist/{chunk-KSGMD24G.js → chunk-Q6TLNHYC.js} +7 -7
- package/dist/{chunk-523YP4Z3.mjs → chunk-QQAG6ECS.mjs} +3 -3
- package/dist/{chunk-23F5W3A2.mjs → chunk-QWACHXRH.mjs} +2 -2
- package/dist/{chunk-PD624ZNK.js → chunk-RUPB4ELK.js} +6 -6
- package/dist/{chunk-4YU7CT4O.js → chunk-UWALRJ7V.js} +7 -7
- package/dist/{chunk-WIVSZVF4.mjs → chunk-XNVBYRLY.mjs} +2 -2
- package/dist/{chunk-ZKJSG4TA.mjs → chunk-XSFM6BLC.mjs} +2 -2
- package/dist/{chunk-IFJWX5RY.mjs → chunk-YJNCY2LB.mjs} +74 -127
- package/dist/chunk-YJNCY2LB.mjs.map +1 -0
- package/dist/{chunk-76KGJJJV.mjs → chunk-ZM42FNAQ.mjs} +5 -5
- package/dist/{chunk-E5PIGGYR.mjs → chunk-ZPAX2HLQ.mjs} +1 -67
- package/dist/chunk-ZPAX2HLQ.mjs.map +1 -0
- package/dist/crypto-compare.js +2 -2
- package/dist/crypto-compare.mjs +1 -1
- package/dist/index.js +15 -15
- package/dist/index.mjs +18 -18
- package/dist/token-service.js +3 -3
- package/dist/token-service.mjs +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/NftController.d.ts +12 -87
- package/dist/types/NftController.d.ts.map +1 -1
- package/dist/types/NftDetectionController.d.ts +184 -0
- package/dist/types/NftDetectionController.d.ts.map +1 -1
- package/dist/types/assetsUtil.d.ts +1 -21
- package/dist/types/assetsUtil.d.ts.map +1 -1
- package/dist/types/crypto-compare.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-AQIXUBTK.js.map +0 -1
- package/dist/chunk-C4PQK53K.js.map +0 -1
- package/dist/chunk-E5PIGGYR.mjs.map +0 -1
- package/dist/chunk-GLZ66IRX.mjs.map +0 -1
- package/dist/chunk-IFJWX5RY.mjs.map +0 -1
- package/dist/chunk-RELRWIJN.js.map +0 -1
- package/dist/chunk-TCO22VIO.mjs.map +0 -1
- package/dist/chunk-WSOHBBCO.js.map +0 -1
- /package/dist/{chunk-6NO7Z5DL.js.map → chunk-3PHIUBM3.js.map} +0 -0
- /package/dist/{chunk-KCUSDOIE.mjs.map → chunk-4OXWUHJZ.mjs.map} +0 -0
- /package/dist/{chunk-355MWUUQ.js.map → chunk-BM7EPTR6.js.map} +0 -0
- /package/dist/{chunk-VY7TUOK2.js.map → chunk-D3N35ABH.js.map} +0 -0
- /package/dist/{chunk-NUBQRDKI.js.map → chunk-E2SLNUD4.js.map} +0 -0
- /package/dist/{chunk-VHCPQS4X.js.map → chunk-GCWWC4X3.js.map} +0 -0
- /package/dist/{chunk-KRTEFV4Q.mjs.map → chunk-IURNPMBB.mjs.map} +0 -0
- /package/dist/{chunk-MQ7TIWBK.mjs.map → chunk-KS4MOA2T.mjs.map} +0 -0
- /package/dist/{chunk-XEZJ5XMV.js.map → chunk-LBPVKXXG.js.map} +0 -0
- /package/dist/{chunk-H6TOSWUM.js.map → chunk-LRKDZWS6.js.map} +0 -0
- /package/dist/{chunk-CEENXWOB.mjs.map → chunk-N5H5KDJZ.mjs.map} +0 -0
- /package/dist/{chunk-2IZUMKMY.mjs.map → chunk-NHX4QGOD.mjs.map} +0 -0
- /package/dist/{chunk-KSGMD24G.js.map → chunk-Q6TLNHYC.js.map} +0 -0
- /package/dist/{chunk-523YP4Z3.mjs.map → chunk-QQAG6ECS.mjs.map} +0 -0
- /package/dist/{chunk-23F5W3A2.mjs.map → chunk-QWACHXRH.mjs.map} +0 -0
- /package/dist/{chunk-PD624ZNK.js.map → chunk-RUPB4ELK.js.map} +0 -0
- /package/dist/{chunk-4YU7CT4O.js.map → chunk-UWALRJ7V.js.map} +0 -0
- /package/dist/{chunk-WIVSZVF4.mjs.map → chunk-XNVBYRLY.mjs.map} +0 -0
- /package/dist/{chunk-ZKJSG4TA.mjs.map → chunk-XSFM6BLC.mjs.map} +0 -0
- /package/dist/{chunk-76KGJJJV.mjs.map → chunk-ZM42FNAQ.mjs.map} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkD3N35ABHjs = require('./chunk-D3N35ABH.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkD6BDJYSKjs = require('./chunk-D6BDJYSK.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -97,7 +97,7 @@ var TokenListController = class extends _pollingcontroller.StaticIntervalPolling
|
|
|
97
97
|
* Start polling for the token list.
|
|
98
98
|
*/
|
|
99
99
|
async start() {
|
|
100
|
-
if (!
|
|
100
|
+
if (!_chunkD6BDJYSKjs.isTokenListSupportedForNetwork.call(void 0, this.chainId)) {
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
await this.startPolling();
|
|
@@ -173,7 +173,7 @@ var TokenListController = class extends _pollingcontroller.StaticIntervalPolling
|
|
|
173
173
|
tokenList = { ...cachedTokens };
|
|
174
174
|
} else {
|
|
175
175
|
const tokensFromAPI = await _controllerutils.safelyExecute.call(void 0,
|
|
176
|
-
() =>
|
|
176
|
+
() => _chunkD3N35ABHjs.fetchTokenListByChainId.call(void 0,
|
|
177
177
|
chainId,
|
|
178
178
|
this.abortController.signal
|
|
179
179
|
)
|
|
@@ -192,8 +192,8 @@ var TokenListController = class extends _pollingcontroller.StaticIntervalPolling
|
|
|
192
192
|
for (const token of tokensFromAPI) {
|
|
193
193
|
const formattedToken = {
|
|
194
194
|
...token,
|
|
195
|
-
aggregators:
|
|
196
|
-
iconUrl:
|
|
195
|
+
aggregators: _chunkD6BDJYSKjs.formatAggregatorNames.call(void 0, token.aggregators),
|
|
196
|
+
iconUrl: _chunkD6BDJYSKjs.formatIconUrlWithProxy.call(void 0, {
|
|
197
197
|
chainId,
|
|
198
198
|
tokenAddress: token.address
|
|
199
199
|
})
|
|
@@ -281,4 +281,4 @@ var TokenListController_default = TokenListController;
|
|
|
281
281
|
|
|
282
282
|
|
|
283
283
|
exports.getDefaultTokenListState = getDefaultTokenListState; exports.TokenListController = TokenListController; exports.TokenListController_default = TokenListController_default;
|
|
284
|
-
//# sourceMappingURL=chunk-
|
|
284
|
+
//# sourceMappingURL=chunk-Q6TLNHYC.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fetchTokenListByChainId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IURNPMBB.mjs";
|
|
4
4
|
import {
|
|
5
5
|
formatAggregatorNames,
|
|
6
6
|
formatIconUrlWithProxy,
|
|
7
7
|
isTokenListSupportedForNetwork
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZPAX2HLQ.mjs";
|
|
9
9
|
import {
|
|
10
10
|
__privateAdd,
|
|
11
11
|
__privateMethod
|
|
@@ -281,4 +281,4 @@ export {
|
|
|
281
281
|
TokenListController,
|
|
282
282
|
TokenListController_default
|
|
283
283
|
};
|
|
284
|
-
//# sourceMappingURL=chunk-
|
|
284
|
+
//# sourceMappingURL=chunk-QQAG6ECS.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
fetchExchangeRate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PWZE6KJV.mjs";
|
|
4
4
|
|
|
5
5
|
// src/CurrencyRateController.ts
|
|
6
6
|
import {
|
|
@@ -154,4 +154,4 @@ export {
|
|
|
154
154
|
CurrencyRateController,
|
|
155
155
|
CurrencyRateController_default
|
|
156
156
|
};
|
|
157
|
-
//# sourceMappingURL=chunk-
|
|
157
|
+
//# sourceMappingURL=chunk-QWACHXRH.mjs.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkDYH5P3VYjs = require('./chunk-DYH5P3VY.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkD6BDJYSKjs = require('./chunk-D6BDJYSK.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ async function getCurrencyConversionRate({
|
|
|
28
28
|
}) {
|
|
29
29
|
const includeUSDRate = false;
|
|
30
30
|
try {
|
|
31
|
-
const result = await
|
|
31
|
+
const result = await _chunkDYH5P3VYjs.fetchExchangeRate.call(void 0,
|
|
32
32
|
to,
|
|
33
33
|
from,
|
|
34
34
|
includeUSDRate
|
|
@@ -351,9 +351,9 @@ fetchAndMapExchangeRatesForSupportedNativeCurrency_fn = async function({
|
|
|
351
351
|
chainId,
|
|
352
352
|
nativeCurrency
|
|
353
353
|
}) {
|
|
354
|
-
const tokenPricesByTokenAddress = await
|
|
354
|
+
const tokenPricesByTokenAddress = await _chunkD6BDJYSKjs.reduceInBatchesSerially.call(void 0, {
|
|
355
355
|
values: [...tokenAddresses].sort(),
|
|
356
|
-
batchSize:
|
|
356
|
+
batchSize: _chunkD6BDJYSKjs.TOKEN_PRICES_BATCH_SIZE,
|
|
357
357
|
eachBatch: async (allTokenPricesByTokenAddress, batch) => {
|
|
358
358
|
const tokenPricesByTokenAddressForBatch = await _chunkZ4BLTVTBjs.__privateGet.call(void 0, this, _tokenPricesService).fetchTokenPrices({
|
|
359
359
|
tokenAddresses: batch,
|
|
@@ -415,4 +415,4 @@ var TokenRatesController_default = TokenRatesController;
|
|
|
415
415
|
|
|
416
416
|
|
|
417
417
|
exports.TokenRatesController = TokenRatesController; exports.TokenRatesController_default = TokenRatesController_default;
|
|
418
|
-
//# sourceMappingURL=chunk-
|
|
418
|
+
//# sourceMappingURL=chunk-RUPB4ELK.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk3PHIUBM3js = require('./chunk-3PHIUBM3.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkGCWWC4X3js = require('./chunk-GCWWC4X3.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkBM7EPTR6js = require('./chunk-BM7EPTR6.js');
|
|
10
10
|
|
|
11
11
|
// src/AssetsContractController.ts
|
|
12
12
|
var _contracts = require('@ethersproject/contracts');
|
|
@@ -112,7 +112,7 @@ var AssetsContractController = class extends _basecontroller.BaseControllerV1 {
|
|
|
112
112
|
*/
|
|
113
113
|
getERC20Standard(networkClientId) {
|
|
114
114
|
const provider = this.getProvider(networkClientId);
|
|
115
|
-
return new (0,
|
|
115
|
+
return new (0, _chunkBM7EPTR6js.ERC20Standard)(provider);
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* Get a ERC721Standard instance using the relevant provider instance.
|
|
@@ -122,7 +122,7 @@ var AssetsContractController = class extends _basecontroller.BaseControllerV1 {
|
|
|
122
122
|
*/
|
|
123
123
|
getERC721Standard(networkClientId) {
|
|
124
124
|
const provider = this.getProvider(networkClientId);
|
|
125
|
-
return new (0,
|
|
125
|
+
return new (0, _chunk3PHIUBM3js.ERC721Standard)(provider);
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* Get a ERC1155Standard instance using the relevant provider instance.
|
|
@@ -132,7 +132,7 @@ var AssetsContractController = class extends _basecontroller.BaseControllerV1 {
|
|
|
132
132
|
*/
|
|
133
133
|
getERC1155Standard(networkClientId) {
|
|
134
134
|
const provider = this.getProvider(networkClientId);
|
|
135
|
-
return new (0,
|
|
135
|
+
return new (0, _chunkGCWWC4X3js.ERC1155Standard)(provider);
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
138
|
* Get balance or count for current account on specific asset contract.
|
|
@@ -358,4 +358,4 @@ var AssetsContractController_default = AssetsContractController;
|
|
|
358
358
|
|
|
359
359
|
|
|
360
360
|
exports.SINGLE_CALL_BALANCES_ADDRESS_BY_CHAINID = SINGLE_CALL_BALANCES_ADDRESS_BY_CHAINID; exports.MISSING_PROVIDER_ERROR = MISSING_PROVIDER_ERROR; exports.AssetsContractController = AssetsContractController; exports.AssetsContractController_default = AssetsContractController_default;
|
|
361
|
-
//# sourceMappingURL=chunk-
|
|
361
|
+
//# sourceMappingURL=chunk-UWALRJ7V.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getFormattedIpfsUrl
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZPAX2HLQ.mjs";
|
|
4
4
|
|
|
5
5
|
// src/Standards/NftStandards/ERC721/ERC721Standard.ts
|
|
6
6
|
import { Contract } from "@ethersproject/contracts";
|
|
@@ -175,4 +175,4 @@ var ERC721Standard = class {
|
|
|
175
175
|
export {
|
|
176
176
|
ERC721Standard
|
|
177
177
|
};
|
|
178
|
-
//# sourceMappingURL=chunk-
|
|
178
|
+
//# sourceMappingURL=chunk-XNVBYRLY.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isTokenDetectionSupportedForNetwork
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZPAX2HLQ.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__privateAdd,
|
|
6
6
|
__privateGet,
|
|
@@ -408,4 +408,4 @@ export {
|
|
|
408
408
|
TokenDetectionController,
|
|
409
409
|
TokenDetectionController_default
|
|
410
410
|
};
|
|
411
|
-
//# sourceMappingURL=chunk-
|
|
411
|
+
//# sourceMappingURL=chunk-XSFM6BLC.mjs.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
compareNftMetadata,
|
|
3
|
-
getFormattedIpfsUrl
|
|
4
|
-
|
|
5
|
-
mapOpenSeaDetailedNftV2ToV1
|
|
6
|
-
} from "./chunk-E5PIGGYR.mjs";
|
|
3
|
+
getFormattedIpfsUrl
|
|
4
|
+
} from "./chunk-ZPAX2HLQ.mjs";
|
|
7
5
|
|
|
8
6
|
// src/NftController.ts
|
|
9
7
|
import { isAddress } from "@ethersproject/address";
|
|
@@ -17,8 +15,8 @@ import {
|
|
|
17
15
|
IPFS_DEFAULT_GATEWAY_URL,
|
|
18
16
|
ERC721,
|
|
19
17
|
ERC1155,
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
ApprovalType,
|
|
19
|
+
NFT_API_BASE_URL
|
|
22
20
|
} from "@metamask/controller-utils";
|
|
23
21
|
import { rpcErrors } from "@metamask/rpc-errors";
|
|
24
22
|
import { remove0x } from "@metamask/utils";
|
|
@@ -26,10 +24,6 @@ import { Mutex } from "async-mutex";
|
|
|
26
24
|
import BN from "bn.js";
|
|
27
25
|
import { EventEmitter } from "events";
|
|
28
26
|
import { v4 as random } from "uuid";
|
|
29
|
-
var OpenSeaV2ChainIds = /* @__PURE__ */ ((OpenSeaV2ChainIds2) => {
|
|
30
|
-
OpenSeaV2ChainIds2["ethereum"] = "ethereum";
|
|
31
|
-
return OpenSeaV2ChainIds2;
|
|
32
|
-
})(OpenSeaV2ChainIds || {});
|
|
33
27
|
var ALL_NFTS_STATE_KEY = "allNfts";
|
|
34
28
|
var ALL_NFTS_CONTRACTS_STATE_KEY = "allNftContracts";
|
|
35
29
|
var getDefaultNftState = () => {
|
|
@@ -123,21 +117,8 @@ var NftController = class extends BaseControllerV1 {
|
|
|
123
117
|
this.configure({ chainId });
|
|
124
118
|
});
|
|
125
119
|
}
|
|
126
|
-
getNftApi({
|
|
127
|
-
|
|
128
|
-
tokenId
|
|
129
|
-
}) {
|
|
130
|
-
return `${OPENSEA_PROXY_URL}/chain/${"ethereum" /* ethereum */}/contract/${contractAddress}/nfts/${tokenId}`;
|
|
131
|
-
}
|
|
132
|
-
getNftContractInformationApi({
|
|
133
|
-
contractAddress
|
|
134
|
-
}) {
|
|
135
|
-
return `${OPENSEA_PROXY_URL}/chain/${"ethereum" /* ethereum */}/contract/${contractAddress}`;
|
|
136
|
-
}
|
|
137
|
-
getNftCollectionInformationApi({
|
|
138
|
-
collectionSlug
|
|
139
|
-
}) {
|
|
140
|
-
return `${OPENSEA_PROXY_URL}/collections/${collectionSlug}`;
|
|
120
|
+
getNftApi() {
|
|
121
|
+
return `${NFT_API_BASE_URL}/tokens`;
|
|
141
122
|
}
|
|
142
123
|
/**
|
|
143
124
|
* Helper method to update nested state for allNfts and allNftContracts.
|
|
@@ -164,20 +145,29 @@ var NftController = class extends BaseControllerV1 {
|
|
|
164
145
|
});
|
|
165
146
|
}
|
|
166
147
|
/**
|
|
167
|
-
* Request individual NFT information from
|
|
148
|
+
* Request individual NFT information from NFT API.
|
|
168
149
|
*
|
|
169
150
|
* @param contractAddress - Hex address of the NFT contract.
|
|
170
151
|
* @param tokenId - The NFT identifier.
|
|
171
152
|
* @returns Promise resolving to the current NFT name and image.
|
|
172
153
|
*/
|
|
173
154
|
async getNftInformationFromApi(contractAddress, tokenId) {
|
|
155
|
+
const urlParams = new URLSearchParams({
|
|
156
|
+
chainIds: "1",
|
|
157
|
+
tokens: `${contractAddress}:${tokenId}`,
|
|
158
|
+
includeTopBid: "true",
|
|
159
|
+
includeAttributes: "true",
|
|
160
|
+
includeLastSale: "true"
|
|
161
|
+
}).toString();
|
|
174
162
|
const nftInformation = await fetchWithErrorHandling({
|
|
175
|
-
url: this.getNftApi({
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
163
|
+
url: `${this.getNftApi()}?${urlParams}`,
|
|
164
|
+
options: {
|
|
165
|
+
headers: {
|
|
166
|
+
Version: "1"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
179
169
|
});
|
|
180
|
-
if (!nftInformation?.
|
|
170
|
+
if (!nftInformation?.tokens?.[0]?.token) {
|
|
181
171
|
return {
|
|
182
172
|
name: null,
|
|
183
173
|
description: null,
|
|
@@ -186,39 +176,35 @@ var NftController = class extends BaseControllerV1 {
|
|
|
186
176
|
};
|
|
187
177
|
}
|
|
188
178
|
const {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
image_url,
|
|
192
|
-
image_preview_url,
|
|
193
|
-
image_thumbnail_url,
|
|
194
|
-
image_original_url,
|
|
195
|
-
animation_url,
|
|
196
|
-
animation_original_url,
|
|
179
|
+
image,
|
|
180
|
+
metadata: { imageOriginal } = {},
|
|
197
181
|
name,
|
|
198
182
|
description,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
183
|
+
collection,
|
|
184
|
+
kind,
|
|
185
|
+
rarityRank,
|
|
186
|
+
rarity,
|
|
187
|
+
attributes,
|
|
188
|
+
lastSale,
|
|
189
|
+
imageSmall
|
|
190
|
+
} = nftInformation.tokens[0].token;
|
|
204
191
|
const nftMetadata = Object.assign(
|
|
205
192
|
{},
|
|
206
193
|
{ name: name || null },
|
|
207
194
|
{ description: description || null },
|
|
208
|
-
{ image:
|
|
209
|
-
creator && { creator },
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
animationOriginal: animation_original_url
|
|
195
|
+
{ image: image || null },
|
|
196
|
+
collection?.creator && { creator: collection.creator },
|
|
197
|
+
imageOriginal && { imageOriginal },
|
|
198
|
+
imageSmall && { imageThumbnail: imageSmall },
|
|
199
|
+
kind && { standard: kind.toUpperCase() },
|
|
200
|
+
lastSale && { lastSale },
|
|
201
|
+
attributes && { attributes },
|
|
202
|
+
nftInformation.tokens[0].market?.topBid && {
|
|
203
|
+
topBid: nftInformation.tokens[0].market?.topBid
|
|
218
204
|
},
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
205
|
+
rarityRank && { rarityRank },
|
|
206
|
+
rarity && { rarity },
|
|
207
|
+
collection && { collection }
|
|
222
208
|
);
|
|
223
209
|
return nftMetadata;
|
|
224
210
|
}
|
|
@@ -334,7 +320,7 @@ var NftController = class extends BaseControllerV1 {
|
|
|
334
320
|
const chainId = this.getCorrectChainId({
|
|
335
321
|
networkClientId
|
|
336
322
|
});
|
|
337
|
-
const [blockchainMetadata,
|
|
323
|
+
const [blockchainMetadata, nftApiMetadata] = await Promise.all([
|
|
338
324
|
safelyExecute(
|
|
339
325
|
() => this.getNftInformationFromTokenURI(
|
|
340
326
|
contractAddress,
|
|
@@ -347,49 +333,14 @@ var NftController = class extends BaseControllerV1 {
|
|
|
347
333
|
) : void 0
|
|
348
334
|
]);
|
|
349
335
|
return {
|
|
350
|
-
...
|
|
351
|
-
name: blockchainMetadata?.name ??
|
|
352
|
-
description: blockchainMetadata?.description ??
|
|
353
|
-
image: blockchainMetadata?.image ??
|
|
354
|
-
standard: blockchainMetadata?.standard ??
|
|
336
|
+
...nftApiMetadata,
|
|
337
|
+
name: blockchainMetadata?.name ?? nftApiMetadata?.name ?? null,
|
|
338
|
+
description: blockchainMetadata?.description ?? nftApiMetadata?.description ?? null,
|
|
339
|
+
image: blockchainMetadata?.image ?? nftApiMetadata?.image ?? null,
|
|
340
|
+
standard: blockchainMetadata?.standard ?? nftApiMetadata?.standard ?? null,
|
|
355
341
|
tokenURI: blockchainMetadata?.tokenURI ?? null
|
|
356
342
|
};
|
|
357
343
|
}
|
|
358
|
-
/**
|
|
359
|
-
* Request NFT contract information from OpenSea API.
|
|
360
|
-
*
|
|
361
|
-
* @param contractAddress - Hex address of the NFT contract.
|
|
362
|
-
* @returns Promise resolving to the current NFT name and image.
|
|
363
|
-
*/
|
|
364
|
-
async getNftContractInformationFromApi(contractAddress) {
|
|
365
|
-
const apiNftContractObject = await fetchWithErrorHandling({
|
|
366
|
-
url: this.getNftContractInformationApi({
|
|
367
|
-
contractAddress
|
|
368
|
-
})
|
|
369
|
-
});
|
|
370
|
-
if (apiNftContractObject) {
|
|
371
|
-
const collection = await fetchWithErrorHandling({
|
|
372
|
-
url: this.getNftCollectionInformationApi({
|
|
373
|
-
collectionSlug: apiNftContractObject.collection
|
|
374
|
-
})
|
|
375
|
-
});
|
|
376
|
-
return mapOpenSeaContractV2ToV1(apiNftContractObject, collection);
|
|
377
|
-
}
|
|
378
|
-
return {
|
|
379
|
-
address: contractAddress,
|
|
380
|
-
asset_contract_type: null,
|
|
381
|
-
created_date: null,
|
|
382
|
-
schema_name: null,
|
|
383
|
-
symbol: null,
|
|
384
|
-
total_supply: null,
|
|
385
|
-
description: null,
|
|
386
|
-
external_link: null,
|
|
387
|
-
collection: {
|
|
388
|
-
name: null,
|
|
389
|
-
image_url: null
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
344
|
/**
|
|
394
345
|
* Request NFT contract information from the contract itself.
|
|
395
346
|
*
|
|
@@ -409,36 +360,30 @@ var NftController = class extends BaseControllerV1 {
|
|
|
409
360
|
};
|
|
410
361
|
}
|
|
411
362
|
/**
|
|
412
|
-
* Request NFT contract information from
|
|
363
|
+
* Request NFT contract information from Blockchain and aggregate with received data from NFTMetadata.
|
|
413
364
|
*
|
|
414
365
|
* @param contractAddress - Hex address of the NFT contract.
|
|
366
|
+
* @param nftMetadataFromApi - Received NFT information to be aggregated with blockchain contract information.
|
|
415
367
|
* @param networkClientId - The networkClientId that can be used to identify the network client to use for this request.
|
|
416
368
|
* @returns Promise resolving to the NFT contract name, image and description.
|
|
417
369
|
*/
|
|
418
|
-
async getNftContractInformation(contractAddress, networkClientId) {
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
networkClientId
|
|
427
|
-
)
|
|
428
|
-
),
|
|
429
|
-
this.config.openSeaEnabled && chainId === "0x1" ? safelyExecute(
|
|
430
|
-
() => this.getNftContractInformationFromApi(contractAddress)
|
|
431
|
-
) : void 0
|
|
432
|
-
]);
|
|
433
|
-
if (blockchainContractData || openSeaContractData) {
|
|
370
|
+
async getNftContractInformation(contractAddress, nftMetadataFromApi, networkClientId) {
|
|
371
|
+
const blockchainContractData = await safelyExecute(
|
|
372
|
+
() => this.getNftContractInformationFromContract(
|
|
373
|
+
contractAddress,
|
|
374
|
+
networkClientId
|
|
375
|
+
)
|
|
376
|
+
);
|
|
377
|
+
if (blockchainContractData || !Object.values(nftMetadataFromApi).every((value) => value === null)) {
|
|
434
378
|
return {
|
|
435
379
|
address: contractAddress,
|
|
436
|
-
...openSeaContractData,
|
|
437
380
|
...blockchainContractData,
|
|
381
|
+
schema_name: nftMetadataFromApi?.standard ?? null,
|
|
438
382
|
collection: {
|
|
439
383
|
name: null,
|
|
440
|
-
image_url: null,
|
|
441
|
-
|
|
384
|
+
image_url: nftMetadataFromApi?.collection?.image ?? nftMetadataFromApi?.collection?.imageUrl ?? null,
|
|
385
|
+
tokenCount: nftMetadataFromApi?.collection?.tokenCount ?? null,
|
|
386
|
+
...nftMetadataFromApi?.collection,
|
|
442
387
|
...blockchainContractData?.collection
|
|
443
388
|
}
|
|
444
389
|
};
|
|
@@ -524,6 +469,7 @@ var NftController = class extends BaseControllerV1 {
|
|
|
524
469
|
* @param options - options.
|
|
525
470
|
* @param options.tokenAddress - Hex address of the NFT contract.
|
|
526
471
|
* @param options.userAddress - The address of the account where the NFT is being added.
|
|
472
|
+
* @param options.nftMetadata - The retrieved NFTMetadata from API.
|
|
527
473
|
* @param options.networkClientId - The networkClientId that can be used to identify the network client to use for this request.
|
|
528
474
|
* @param options.source - Whether the NFT was detected, added manually or suggested by a dapp.
|
|
529
475
|
* @returns Promise resolving to the current NFT contracts list.
|
|
@@ -532,7 +478,8 @@ var NftController = class extends BaseControllerV1 {
|
|
|
532
478
|
tokenAddress,
|
|
533
479
|
userAddress,
|
|
534
480
|
networkClientId,
|
|
535
|
-
source
|
|
481
|
+
source,
|
|
482
|
+
nftMetadata
|
|
536
483
|
}) {
|
|
537
484
|
const releaseLock = await this.mutex.acquire();
|
|
538
485
|
try {
|
|
@@ -550,17 +497,17 @@ var NftController = class extends BaseControllerV1 {
|
|
|
550
497
|
}
|
|
551
498
|
const contractInformation = await this.getNftContractInformation(
|
|
552
499
|
tokenAddress,
|
|
500
|
+
nftMetadata,
|
|
553
501
|
networkClientId
|
|
554
502
|
);
|
|
555
503
|
const {
|
|
556
504
|
asset_contract_type,
|
|
557
505
|
created_date,
|
|
558
|
-
schema_name,
|
|
559
506
|
symbol,
|
|
560
|
-
total_supply,
|
|
561
507
|
description,
|
|
562
508
|
external_link,
|
|
563
|
-
|
|
509
|
+
schema_name,
|
|
510
|
+
collection: { name, image_url, tokenCount }
|
|
564
511
|
} = contractInformation;
|
|
565
512
|
if (source === "detected" /* Detected */ && "address" in contractInformation && typeof contractInformation.address === "string" && "collection" in contractInformation && contractInformation.collection.name === null && "image_url" in contractInformation.collection && contractInformation.collection.image_url === null && Object.entries(contractInformation).every(([key, value]) => {
|
|
566
513
|
return key === "address" || key === "collection" || !value;
|
|
@@ -574,7 +521,7 @@ var NftController = class extends BaseControllerV1 {
|
|
|
574
521
|
name && { name },
|
|
575
522
|
image_url && { logo: image_url },
|
|
576
523
|
symbol && { symbol },
|
|
577
|
-
|
|
524
|
+
tokenCount !== null && typeof tokenCount !== "undefined" && { totalSupply: tokenCount },
|
|
578
525
|
asset_contract_type && { assetContractType: asset_contract_type },
|
|
579
526
|
created_date && { createdDate: created_date },
|
|
580
527
|
schema_name && { schemaName: schema_name },
|
|
@@ -863,13 +810,14 @@ var NftController = class extends BaseControllerV1 {
|
|
|
863
810
|
} = { userAddress: this.config.selectedAddress }) {
|
|
864
811
|
tokenAddress = toChecksumHexAddress(tokenAddress);
|
|
865
812
|
const chainId = this.getCorrectChainId({ networkClientId });
|
|
813
|
+
nftMetadata = nftMetadata || await this.getNftInformation(tokenAddress, tokenId, networkClientId);
|
|
866
814
|
const newNftContracts = await this.addNftContract({
|
|
867
815
|
tokenAddress,
|
|
868
816
|
userAddress,
|
|
869
817
|
networkClientId,
|
|
870
|
-
source
|
|
818
|
+
source,
|
|
819
|
+
nftMetadata
|
|
871
820
|
});
|
|
872
|
-
nftMetadata = nftMetadata || await this.getNftInformation(tokenAddress, tokenId, networkClientId);
|
|
873
821
|
const nftContract = newNftContracts.find(
|
|
874
822
|
(contract) => contract.address.toLowerCase() === tokenAddress.toLowerCase()
|
|
875
823
|
);
|
|
@@ -1213,9 +1161,8 @@ var NftController = class extends BaseControllerV1 {
|
|
|
1213
1161
|
var NftController_default = NftController;
|
|
1214
1162
|
|
|
1215
1163
|
export {
|
|
1216
|
-
OpenSeaV2ChainIds,
|
|
1217
1164
|
getDefaultNftState,
|
|
1218
1165
|
NftController,
|
|
1219
1166
|
NftController_default
|
|
1220
1167
|
};
|
|
1221
|
-
//# sourceMappingURL=chunk-
|
|
1168
|
+
//# sourceMappingURL=chunk-YJNCY2LB.mjs.map
|