@medialane/ui 0.140.2 → 0.140.3
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.
|
@@ -21,11 +21,19 @@ __export(portfolio_counts_exports, {
|
|
|
21
21
|
derivePortfolioCounts: () => derivePortfolioCounts
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(portfolio_counts_exports);
|
|
24
|
+
var import_sdk = require("@medialane/sdk");
|
|
25
|
+
function safeNormalize(address) {
|
|
26
|
+
try {
|
|
27
|
+
return (0, import_sdk.normalizeAddress)("STARKNET", address);
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
24
32
|
function derivePortfolioCounts(orders, remixOffers, address, sponsorshipPendingCount = 0) {
|
|
25
33
|
const list = Array.isArray(orders) ? orders : [];
|
|
26
|
-
const addr =
|
|
34
|
+
const addr = address ? safeNormalize(address) : null;
|
|
27
35
|
const received = list.filter(
|
|
28
|
-
(o) => o.status === "ACTIVE" && o.offer.itemType === "ERC20" && o.offerer
|
|
36
|
+
(o) => o.status === "ACTIVE" && o.offer.itemType === "ERC20" && safeNormalize(o.offerer) !== addr
|
|
29
37
|
).length;
|
|
30
38
|
const listings = list.filter(
|
|
31
39
|
(o) => (o.offer.itemType === "ERC721" || o.offer.itemType === "ERC1155") && o.status === "ACTIVE"
|
|
@@ -34,7 +42,7 @@ function derivePortfolioCounts(orders, remixOffers, address, sponsorshipPendingC
|
|
|
34
42
|
(o) => o.status === "PENDING" || o.status === "AUTO_PENDING"
|
|
35
43
|
).length : 0;
|
|
36
44
|
const counter = list.filter(
|
|
37
|
-
(o) => o.offer.itemType === "ERC20" && o.offerer
|
|
45
|
+
(o) => o.offer.itemType === "ERC20" && addr !== null && safeNormalize(o.offerer) === addr && o.hasActiveCounterOffer === true
|
|
38
46
|
).length;
|
|
39
47
|
return { received, listings, remix, counter, sponsorships: Math.max(0, sponsorshipPendingCount) };
|
|
40
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/portfolio-counts.ts"],"sourcesContent":["\nexport interface CountableOrder {\n status: string;\n offerer: string;\n offer: { itemType: string };\n hasActiveCounterOffer?: boolean;\n}\n\nexport interface PortfolioCounts {\n\n received: number;\n\n listings: number;\n\n remix: number;\n\n counter: number;\n\n sponsorships: number;\n}\n\nexport function derivePortfolioCounts(\n orders: ReadonlyArray<CountableOrder> | null | undefined,\n remixOffers: ReadonlyArray<{ status: string }> | null | undefined,\n address: string | null | undefined,\n sponsorshipPendingCount = 0,\n): PortfolioCounts {\n const list = Array.isArray(orders) ? orders : [];\n const addr =
|
|
1
|
+
{"version":3,"sources":["../../src/utils/portfolio-counts.ts"],"sourcesContent":["import { normalizeAddress } from \"@medialane/sdk\";\n\nexport interface CountableOrder {\n status: string;\n offerer: string;\n offer: { itemType: string };\n hasActiveCounterOffer?: boolean;\n}\n\nexport interface PortfolioCounts {\n\n received: number;\n\n listings: number;\n\n remix: number;\n\n counter: number;\n\n sponsorships: number;\n}\n\nfunction safeNormalize(address: string): string | null {\n try {\n return normalizeAddress(\"STARKNET\", address);\n } catch {\n return null;\n }\n}\n\nexport function derivePortfolioCounts(\n orders: ReadonlyArray<CountableOrder> | null | undefined,\n remixOffers: ReadonlyArray<{ status: string }> | null | undefined,\n address: string | null | undefined,\n sponsorshipPendingCount = 0,\n): PortfolioCounts {\n const list = Array.isArray(orders) ? orders : [];\n const addr = address ? safeNormalize(address) : null;\n\n const received = list.filter(\n (o) =>\n o.status === \"ACTIVE\" &&\n o.offer.itemType === \"ERC20\" &&\n safeNormalize(o.offerer) !== addr,\n ).length;\n\n const listings = list.filter(\n (o) =>\n (o.offer.itemType === \"ERC721\" || o.offer.itemType === \"ERC1155\") &&\n o.status === \"ACTIVE\",\n ).length;\n\n const remix = Array.isArray(remixOffers)\n ? remixOffers.filter(\n (o) => o.status === \"PENDING\" || o.status === \"AUTO_PENDING\",\n ).length\n : 0;\n\n const counter = list.filter(\n (o) =>\n o.offer.itemType === \"ERC20\" &&\n addr !== null &&\n safeNormalize(o.offerer) === addr &&\n o.hasActiveCounterOffer === true,\n ).length;\n\n return { received, listings, remix, counter, sponsorships: Math.max(0, sponsorshipPendingCount) };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAiC;AAsBjC,SAAS,cAAc,SAAgC;AACrD,MAAI;AACF,eAAO,6BAAiB,YAAY,OAAO;AAAA,EAC7C,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,sBACd,QACA,aACA,SACA,0BAA0B,GACT;AACjB,QAAM,OAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC/C,QAAM,OAAO,UAAU,cAAc,OAAO,IAAI;AAEhD,QAAM,WAAW,KAAK;AAAA,IACpB,CAAC,MACC,EAAE,WAAW,YACb,EAAE,MAAM,aAAa,WACrB,cAAc,EAAE,OAAO,MAAM;AAAA,EACjC,EAAE;AAEF,QAAM,WAAW,KAAK;AAAA,IACpB,CAAC,OACE,EAAE,MAAM,aAAa,YAAY,EAAE,MAAM,aAAa,cACvD,EAAE,WAAW;AAAA,EACjB,EAAE;AAEF,QAAM,QAAQ,MAAM,QAAQ,WAAW,IACnC,YAAY;AAAA,IACV,CAAC,MAAM,EAAE,WAAW,aAAa,EAAE,WAAW;AAAA,EAChD,EAAE,SACF;AAEJ,QAAM,UAAU,KAAK;AAAA,IACnB,CAAC,MACC,EAAE,MAAM,aAAa,WACrB,SAAS,QACT,cAAc,EAAE,OAAO,MAAM,QAC7B,EAAE,0BAA0B;AAAA,EAChC,EAAE;AAEF,SAAO,EAAE,UAAU,UAAU,OAAO,SAAS,cAAc,KAAK,IAAI,GAAG,uBAAuB,EAAE;AAClG;","names":[]}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { normalizeAddress } from "@medialane/sdk";
|
|
2
|
+
function safeNormalize(address) {
|
|
3
|
+
try {
|
|
4
|
+
return normalizeAddress("STARKNET", address);
|
|
5
|
+
} catch {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
1
9
|
function derivePortfolioCounts(orders, remixOffers, address, sponsorshipPendingCount = 0) {
|
|
2
10
|
const list = Array.isArray(orders) ? orders : [];
|
|
3
|
-
const addr =
|
|
11
|
+
const addr = address ? safeNormalize(address) : null;
|
|
4
12
|
const received = list.filter(
|
|
5
|
-
(o) => o.status === "ACTIVE" && o.offer.itemType === "ERC20" && o.offerer
|
|
13
|
+
(o) => o.status === "ACTIVE" && o.offer.itemType === "ERC20" && safeNormalize(o.offerer) !== addr
|
|
6
14
|
).length;
|
|
7
15
|
const listings = list.filter(
|
|
8
16
|
(o) => (o.offer.itemType === "ERC721" || o.offer.itemType === "ERC1155") && o.status === "ACTIVE"
|
|
@@ -11,7 +19,7 @@ function derivePortfolioCounts(orders, remixOffers, address, sponsorshipPendingC
|
|
|
11
19
|
(o) => o.status === "PENDING" || o.status === "AUTO_PENDING"
|
|
12
20
|
).length : 0;
|
|
13
21
|
const counter = list.filter(
|
|
14
|
-
(o) => o.offer.itemType === "ERC20" && o.offerer
|
|
22
|
+
(o) => o.offer.itemType === "ERC20" && addr !== null && safeNormalize(o.offerer) === addr && o.hasActiveCounterOffer === true
|
|
15
23
|
).length;
|
|
16
24
|
return { received, listings, remix, counter, sponsorships: Math.max(0, sponsorshipPendingCount) };
|
|
17
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/portfolio-counts.ts"],"sourcesContent":["\nexport interface CountableOrder {\n status: string;\n offerer: string;\n offer: { itemType: string };\n hasActiveCounterOffer?: boolean;\n}\n\nexport interface PortfolioCounts {\n\n received: number;\n\n listings: number;\n\n remix: number;\n\n counter: number;\n\n sponsorships: number;\n}\n\nexport function derivePortfolioCounts(\n orders: ReadonlyArray<CountableOrder> | null | undefined,\n remixOffers: ReadonlyArray<{ status: string }> | null | undefined,\n address: string | null | undefined,\n sponsorshipPendingCount = 0,\n): PortfolioCounts {\n const list = Array.isArray(orders) ? orders : [];\n const addr =
|
|
1
|
+
{"version":3,"sources":["../../src/utils/portfolio-counts.ts"],"sourcesContent":["import { normalizeAddress } from \"@medialane/sdk\";\n\nexport interface CountableOrder {\n status: string;\n offerer: string;\n offer: { itemType: string };\n hasActiveCounterOffer?: boolean;\n}\n\nexport interface PortfolioCounts {\n\n received: number;\n\n listings: number;\n\n remix: number;\n\n counter: number;\n\n sponsorships: number;\n}\n\nfunction safeNormalize(address: string): string | null {\n try {\n return normalizeAddress(\"STARKNET\", address);\n } catch {\n return null;\n }\n}\n\nexport function derivePortfolioCounts(\n orders: ReadonlyArray<CountableOrder> | null | undefined,\n remixOffers: ReadonlyArray<{ status: string }> | null | undefined,\n address: string | null | undefined,\n sponsorshipPendingCount = 0,\n): PortfolioCounts {\n const list = Array.isArray(orders) ? orders : [];\n const addr = address ? safeNormalize(address) : null;\n\n const received = list.filter(\n (o) =>\n o.status === \"ACTIVE\" &&\n o.offer.itemType === \"ERC20\" &&\n safeNormalize(o.offerer) !== addr,\n ).length;\n\n const listings = list.filter(\n (o) =>\n (o.offer.itemType === \"ERC721\" || o.offer.itemType === \"ERC1155\") &&\n o.status === \"ACTIVE\",\n ).length;\n\n const remix = Array.isArray(remixOffers)\n ? remixOffers.filter(\n (o) => o.status === \"PENDING\" || o.status === \"AUTO_PENDING\",\n ).length\n : 0;\n\n const counter = list.filter(\n (o) =>\n o.offer.itemType === \"ERC20\" &&\n addr !== null &&\n safeNormalize(o.offerer) === addr &&\n o.hasActiveCounterOffer === true,\n ).length;\n\n return { received, listings, remix, counter, sponsorships: Math.max(0, sponsorshipPendingCount) };\n}\n"],"mappings":"AAAA,SAAS,wBAAwB;AAsBjC,SAAS,cAAc,SAAgC;AACrD,MAAI;AACF,WAAO,iBAAiB,YAAY,OAAO;AAAA,EAC7C,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,sBACd,QACA,aACA,SACA,0BAA0B,GACT;AACjB,QAAM,OAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC/C,QAAM,OAAO,UAAU,cAAc,OAAO,IAAI;AAEhD,QAAM,WAAW,KAAK;AAAA,IACpB,CAAC,MACC,EAAE,WAAW,YACb,EAAE,MAAM,aAAa,WACrB,cAAc,EAAE,OAAO,MAAM;AAAA,EACjC,EAAE;AAEF,QAAM,WAAW,KAAK;AAAA,IACpB,CAAC,OACE,EAAE,MAAM,aAAa,YAAY,EAAE,MAAM,aAAa,cACvD,EAAE,WAAW;AAAA,EACjB,EAAE;AAEF,QAAM,QAAQ,MAAM,QAAQ,WAAW,IACnC,YAAY;AAAA,IACV,CAAC,MAAM,EAAE,WAAW,aAAa,EAAE,WAAW;AAAA,EAChD,EAAE,SACF;AAEJ,QAAM,UAAU,KAAK;AAAA,IACnB,CAAC,MACC,EAAE,MAAM,aAAa,WACrB,SAAS,QACT,cAAc,EAAE,OAAO,MAAM,QAC7B,EAAE,0BAA0B;AAAA,EAChC,EAAE;AAEF,SAAO,EAAE,UAAU,UAAU,OAAO,SAAS,cAAc,KAAK,IAAI,GAAG,uBAAuB,EAAE;AAClG;","names":[]}
|