@medialane/ui 0.5.4 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/portfolio-subnav.cjs +94 -0
- package/dist/components/portfolio-subnav.cjs.map +1 -0
- package/dist/components/portfolio-subnav.d.cts +27 -0
- package/dist/components/portfolio-subnav.d.ts +27 -0
- package/dist/components/portfolio-subnav.js +60 -0
- package/dist/components/portfolio-subnav.js.map +1 -0
- package/dist/data/launchpad-services.cjs +127 -19
- package/dist/data/launchpad-services.cjs.map +1 -1
- package/dist/data/launchpad-services.d.cts +13 -1
- package/dist/data/launchpad-services.d.ts +13 -1
- package/dist/data/launchpad-services.js +128 -19
- package/dist/data/launchpad-services.js.map +1 -1
- package/dist/index.cjs +8 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/portfolio-counts.cjs +45 -0
- package/dist/utils/portfolio-counts.cjs.map +1 -0
- package/dist/utils/portfolio-counts.d.cts +33 -0
- package/dist/utils/portfolio-counts.d.ts +33 -0
- package/dist/utils/portfolio-counts.js +21 -0
- package/dist/utils/portfolio-counts.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal structural shape of a marketplace order needed to derive portfolio
|
|
3
|
+
* counts. `ApiOrder` from `@medialane/sdk` is structurally assignable to this,
|
|
4
|
+
* so callers pass their `ApiOrder[]` directly and the package stays decoupled
|
|
5
|
+
* from any specific SDK version.
|
|
6
|
+
*/
|
|
7
|
+
interface CountableOrder {
|
|
8
|
+
status: string;
|
|
9
|
+
offerer: string;
|
|
10
|
+
offer: {
|
|
11
|
+
itemType: string;
|
|
12
|
+
};
|
|
13
|
+
hasActiveCounterOffer?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface PortfolioCounts {
|
|
16
|
+
/** Active ERC-20 offers made by others on the user's assets. */
|
|
17
|
+
received: number;
|
|
18
|
+
/** Active ERC-721/ERC-1155 listings the user is selling. */
|
|
19
|
+
listings: number;
|
|
20
|
+
/** Pending remix offers awaiting the user's action. */
|
|
21
|
+
remix: number;
|
|
22
|
+
/** The user's bids that a seller has countered. */
|
|
23
|
+
counter: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Derive the portfolio header/subnav counts from the user's orders and remix
|
|
27
|
+
* offers. Pure and server-safe (no React). Guards nullish inputs.
|
|
28
|
+
*/
|
|
29
|
+
declare function derivePortfolioCounts(orders: ReadonlyArray<CountableOrder> | null | undefined, remixOffers: ReadonlyArray<{
|
|
30
|
+
status: string;
|
|
31
|
+
}> | null | undefined, address: string | null | undefined): PortfolioCounts;
|
|
32
|
+
|
|
33
|
+
export { type CountableOrder, type PortfolioCounts, derivePortfolioCounts };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function derivePortfolioCounts(orders, remixOffers, address) {
|
|
2
|
+
const list = Array.isArray(orders) ? orders : [];
|
|
3
|
+
const addr = (address ?? "").toLowerCase();
|
|
4
|
+
const received = list.filter(
|
|
5
|
+
(o) => o.status === "ACTIVE" && o.offer.itemType === "ERC20" && o.offerer.toLowerCase() !== addr
|
|
6
|
+
).length;
|
|
7
|
+
const listings = list.filter(
|
|
8
|
+
(o) => (o.offer.itemType === "ERC721" || o.offer.itemType === "ERC1155") && o.status === "ACTIVE"
|
|
9
|
+
).length;
|
|
10
|
+
const remix = Array.isArray(remixOffers) ? remixOffers.filter(
|
|
11
|
+
(o) => o.status === "PENDING" || o.status === "AUTO_PENDING"
|
|
12
|
+
).length : 0;
|
|
13
|
+
const counter = list.filter(
|
|
14
|
+
(o) => o.offer.itemType === "ERC20" && o.offerer.toLowerCase() === addr && o.hasActiveCounterOffer === true
|
|
15
|
+
).length;
|
|
16
|
+
return { received, listings, remix, counter };
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
derivePortfolioCounts
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=portfolio-counts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/portfolio-counts.ts"],"sourcesContent":["/**\n * Minimal structural shape of a marketplace order needed to derive portfolio\n * counts. `ApiOrder` from `@medialane/sdk` is structurally assignable to this,\n * so callers pass their `ApiOrder[]` directly and the package stays decoupled\n * from any specific SDK version.\n */\nexport interface CountableOrder {\n status: string;\n offerer: string;\n offer: { itemType: string };\n hasActiveCounterOffer?: boolean;\n}\n\nexport interface PortfolioCounts {\n /** Active ERC-20 offers made by others on the user's assets. */\n received: number;\n /** Active ERC-721/ERC-1155 listings the user is selling. */\n listings: number;\n /** Pending remix offers awaiting the user's action. */\n remix: number;\n /** The user's bids that a seller has countered. */\n counter: number;\n}\n\n/**\n * Derive the portfolio header/subnav counts from the user's orders and remix\n * offers. Pure and server-safe (no React). Guards nullish inputs.\n */\nexport function derivePortfolioCounts(\n orders: ReadonlyArray<CountableOrder> | null | undefined,\n remixOffers: ReadonlyArray<{ status: string }> | null | undefined,\n address: string | null | undefined,\n): PortfolioCounts {\n const list = Array.isArray(orders) ? orders : [];\n const addr = (address ?? \"\").toLowerCase();\n\n const received = list.filter(\n (o) =>\n o.status === \"ACTIVE\" &&\n o.offer.itemType === \"ERC20\" &&\n o.offerer.toLowerCase() !== 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 o.offerer.toLowerCase() === addr &&\n o.hasActiveCounterOffer === true,\n ).length;\n\n return { received, listings, remix, counter };\n}\n"],"mappings":"AA4BO,SAAS,sBACd,QACA,aACA,SACiB;AACjB,QAAM,OAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC;AAC/C,QAAM,QAAQ,WAAW,IAAI,YAAY;AAEzC,QAAM,WAAW,KAAK;AAAA,IACpB,CAAC,MACC,EAAE,WAAW,YACb,EAAE,MAAM,aAAa,WACrB,EAAE,QAAQ,YAAY,MAAM;AAAA,EAChC,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,EAAE,QAAQ,YAAY,MAAM,QAC5B,EAAE,0BAA0B;AAAA,EAChC,EAAE;AAEF,SAAO,EAAE,UAAU,UAAU,OAAO,QAAQ;AAC9C;","names":[]}
|