@medialane/sdk 0.4.0 → 0.4.2
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/README.md +41 -21
- package/dist/index.cjs +92 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -5
- package/dist/index.d.ts +92 -5
- package/dist/index.js +92 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -306,16 +306,16 @@ token.data.metadata.attributes; // IpAttribute[] | null
|
|
|
306
306
|
|
|
307
307
|
## Supported Tokens
|
|
308
308
|
|
|
309
|
-
| Symbol |
|
|
310
|
-
|
|
311
|
-
| USDC |
|
|
312
|
-
|
|
|
313
|
-
|
|
|
314
|
-
|
|
|
315
|
-
|
|
|
309
|
+
| Symbol | Address | Decimals | Listable |
|
|
310
|
+
|--------|---------|----------|----------|
|
|
311
|
+
| USDC | `0x033068f6539f8e6e6b131e6b2b814e6c34a5224bc66947c47dab9dfee93b35fb` | 6 | ✓ |
|
|
312
|
+
| USDT | `0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8` | 6 | ✓ |
|
|
313
|
+
| ETH | `0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7` | 18 | ✓ |
|
|
314
|
+
| STRK | `0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d` | 18 | ✓ |
|
|
315
|
+
| WBTC | `0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac` | 8 | ✓ |
|
|
316
316
|
|
|
317
317
|
```typescript
|
|
318
|
-
import { getTokenBySymbol, getTokenByAddress, SUPPORTED_TOKENS } from "@medialane/sdk";
|
|
318
|
+
import { getTokenBySymbol, getTokenByAddress, getListableTokens, SUPPORTED_TOKENS } from "@medialane/sdk";
|
|
319
319
|
|
|
320
320
|
const usdc = getTokenBySymbol("USDC");
|
|
321
321
|
const token = getTokenByAddress("0x033068...");
|
|
@@ -327,12 +327,13 @@ const token = getTokenByAddress("0x033068...");
|
|
|
327
327
|
|
|
328
328
|
```typescript
|
|
329
329
|
import {
|
|
330
|
-
normalizeAddress,
|
|
331
|
-
shortenAddress,
|
|
332
|
-
parseAmount,
|
|
333
|
-
formatAmount,
|
|
334
|
-
stringifyBigInts,
|
|
335
|
-
u256ToBigInt,
|
|
330
|
+
normalizeAddress, // Pad to 64-char 0x-prefixed lowercase hex
|
|
331
|
+
shortenAddress, // → "0x1234...5678"
|
|
332
|
+
parseAmount, // Human-readable → smallest unit BigInt ("1.5", 6) → 1500000n
|
|
333
|
+
formatAmount, // Smallest unit → human-readable ("1500000", 6) → "1.5"
|
|
334
|
+
stringifyBigInts, // Recursively convert BigInt → string (for JSON)
|
|
335
|
+
u256ToBigInt, // u256 { low, high } → BigInt
|
|
336
|
+
getListableTokens, // ReadonlyArray<SupportedToken> filtered to listable: true (for dialogs)
|
|
336
337
|
} from "@medialane/sdk";
|
|
337
338
|
```
|
|
338
339
|
|
|
@@ -413,6 +414,28 @@ Built with:
|
|
|
413
414
|
|
|
414
415
|
## Changelog
|
|
415
416
|
|
|
417
|
+
### v0.4.2
|
|
418
|
+
- **WBTC** added to `SUPPORTED_TOKENS` (`0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac`, 8 decimals)
|
|
419
|
+
- **`listable` field** on every `SUPPORTED_TOKENS` entry — controls whether a token appears in listing/offer dialogs vs filter-only
|
|
420
|
+
- **`getListableTokens()`** — returns tokens filtered to `listable: true`; exported from package root
|
|
421
|
+
- **ETH** promoted to `listable: true` — now available in listing and offer dialogs
|
|
422
|
+
- **USDC.e removed** — bridged USDC (`0x053c91...`) removed entirely; only Circle-native USDC remains, to avoid user confusion
|
|
423
|
+
|
|
424
|
+
### v0.4.1
|
|
425
|
+
- **Collection claims** — `claimCollection(contractAddress, walletAddress, clerkToken)` for on-chain ownership verification; `requestCollectionClaim({ contractAddress, walletAddress?, email, notes? })` for manual review
|
|
426
|
+
- **Collection profiles** — `getCollectionProfile(contractAddress)` and `updateCollectionProfile(contractAddress, data, clerkToken)` for enriched display metadata (displayName, description, image, bannerImage, social links)
|
|
427
|
+
- **Creator profiles** — `getCreatorProfile(walletAddress)` and `updateCreatorProfile(walletAddress, data, clerkToken)` for creator display metadata
|
|
428
|
+
- **New types** — `ApiCollectionClaim`, `ApiAdminCollectionClaim`, `ApiCollectionProfile`, `ApiCreatorProfile`
|
|
429
|
+
- **`ApiCollection`** extended with `source` (`"MEDIALANE_REGISTRY" | "EXTERNAL" | "PARTNERSHIP" | "IP_TICKET" | "IP_CLUB" | "GAME"`) and `claimedBy: string | null`
|
|
430
|
+
- `profile?: ApiCollectionProfile | null` optionally embedded on `ApiCollection` when `?include=profile`
|
|
431
|
+
|
|
432
|
+
### v0.4.0
|
|
433
|
+
- **Typed error codes** — `MedialaneError` and `MedialaneApiError` now expose a `.code: MedialaneErrorCode` property (`"TOKEN_NOT_FOUND"` | `"RATE_LIMITED"` | `"INTENT_EXPIRED"` | `"UNAUTHORIZED"` | `"INVALID_PARAMS"` | `"NETWORK_NOT_SUPPORTED"` | `"UNKNOWN"`)
|
|
434
|
+
- **Automatic retry** — all API requests retry up to 3 times with exponential backoff (300ms base, 5s cap); 4xx errors are not retried. Configure via `retryOptions` in `MedialaneConfig`
|
|
435
|
+
- **`RetryOptions`** type exported from index
|
|
436
|
+
- **`CollectionSort`** named union type exported (`"recent" | "supply" | "floor" | "volume" | "name"`)
|
|
437
|
+
- **Sepolia guard** — constructing a client with `network: "sepolia"` and no explicit contract addresses now throws `NETWORK_NOT_SUPPORTED` immediately
|
|
438
|
+
|
|
416
439
|
### v0.3.3
|
|
417
440
|
- `getCollections(page?, limit?, isKnown?, sort?)` — added `sort` parameter: `"recent"` (default) | `"supply"` | `"floor"` | `"volume"` | `"name"`
|
|
418
441
|
- Default sort changed from `totalSupply DESC` to `createdAt DESC` (newest first) — matches backend default
|
|
@@ -421,15 +444,12 @@ Built with:
|
|
|
421
444
|
- `ApiCollection.collectionId: string | null` — on-chain registry numeric ID (decimal string). Required for `createMintIntent`. Populated for collections indexed after 2026-03-09.
|
|
422
445
|
|
|
423
446
|
### v0.3.0
|
|
424
|
-
- `normalizeAddress()`
|
|
425
|
-
- `
|
|
426
|
-
|
|
427
|
-
### v0.2.8
|
|
428
|
-
- `ApiCollection.owner: string | null`
|
|
429
|
-
- `ApiClient.getCollectionsByOwner(owner)`
|
|
447
|
+
- `normalizeAddress()` applied internally before all API calls — callers no longer need to normalize Starknet addresses
|
|
448
|
+
- `ApiCollection.owner: string | null` — populated from intent typedData or on-chain `owner()` call
|
|
449
|
+
- `getCollectionsByOwner(owner)` — fetch collections by wallet address via `GET /v1/collections?owner=`
|
|
430
450
|
|
|
431
451
|
### v0.2.6
|
|
432
|
-
- `ApiOrder.token: ApiOrderTokenMeta | null` — token name/image/description on orders (batchTokenMeta)
|
|
452
|
+
- `ApiOrder.token: ApiOrderTokenMeta | null` — token name/image/description embedded on orders (batchTokenMeta); no per-row `getToken` calls needed
|
|
433
453
|
|
|
434
454
|
### v0.2.0
|
|
435
455
|
- `IpAttribute` and `IpNftMetadata` interfaces for IP metadata
|
package/dist/index.cjs
CHANGED
|
@@ -12,31 +12,35 @@ var MARKETPLACE_CONTRACT_SEPOLIA = "";
|
|
|
12
12
|
var COLLECTION_CONTRACT_SEPOLIA = "";
|
|
13
13
|
var SUPPORTED_TOKENS = [
|
|
14
14
|
{
|
|
15
|
-
// Circle-native USDC on Starknet (canonical
|
|
15
|
+
// Circle-native USDC on Starknet (canonical)
|
|
16
16
|
symbol: "USDC",
|
|
17
17
|
address: "0x033068f6539f8e6e6b131e6b2b814e6c34a5224bc66947c47dab9dfee93b35fb",
|
|
18
|
-
decimals: 6
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
// Bridged USDC.e (Ethereum USDC bridged via Starkgate)
|
|
22
|
-
symbol: "USDC.e",
|
|
23
|
-
address: "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
|
|
24
|
-
decimals: 6
|
|
18
|
+
decimals: 6,
|
|
19
|
+
listable: true
|
|
25
20
|
},
|
|
26
21
|
{
|
|
27
22
|
symbol: "USDT",
|
|
28
23
|
address: "0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",
|
|
29
|
-
decimals: 6
|
|
24
|
+
decimals: 6,
|
|
25
|
+
listable: true
|
|
30
26
|
},
|
|
31
27
|
{
|
|
32
28
|
symbol: "ETH",
|
|
33
29
|
address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
|
|
34
|
-
decimals: 18
|
|
30
|
+
decimals: 18,
|
|
31
|
+
listable: true
|
|
35
32
|
},
|
|
36
33
|
{
|
|
37
34
|
symbol: "STRK",
|
|
38
35
|
address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
|
|
39
|
-
decimals: 18
|
|
36
|
+
decimals: 18,
|
|
37
|
+
listable: true
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
symbol: "WBTC",
|
|
41
|
+
address: "0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",
|
|
42
|
+
decimals: 8,
|
|
43
|
+
listable: true
|
|
40
44
|
}
|
|
41
45
|
];
|
|
42
46
|
var DEFAULT_CURRENCY = "USDC";
|
|
@@ -398,6 +402,9 @@ function getTokenBySymbol(symbol) {
|
|
|
398
402
|
const upper = symbol.toUpperCase();
|
|
399
403
|
return SUPPORTED_TOKENS.find((t) => t.symbol === upper);
|
|
400
404
|
}
|
|
405
|
+
function getListableTokens() {
|
|
406
|
+
return SUPPORTED_TOKENS.filter((t) => t.listable);
|
|
407
|
+
}
|
|
401
408
|
function buildOrderTypedData(message, chainId) {
|
|
402
409
|
return {
|
|
403
410
|
domain: {
|
|
@@ -1176,6 +1183,79 @@ var ApiClient = class {
|
|
|
1176
1183
|
`/v1/portal/webhooks/${id}`
|
|
1177
1184
|
);
|
|
1178
1185
|
}
|
|
1186
|
+
// ─── Collection Claims ──────────────────────────────────────────────────────
|
|
1187
|
+
/**
|
|
1188
|
+
* Path 1: On-chain auto claim. Sends both x-api-key (tenant auth) and
|
|
1189
|
+
* Authorization: Bearer (Clerk JWT) simultaneously.
|
|
1190
|
+
*/
|
|
1191
|
+
async claimCollection(contractAddress, walletAddress, clerkToken) {
|
|
1192
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collections/claim`;
|
|
1193
|
+
const res = await fetch(url, {
|
|
1194
|
+
method: "POST",
|
|
1195
|
+
headers: {
|
|
1196
|
+
"x-api-key": this.baseHeaders["x-api-key"] ?? "",
|
|
1197
|
+
"Content-Type": "application/json",
|
|
1198
|
+
"Authorization": `Bearer ${clerkToken}`
|
|
1199
|
+
},
|
|
1200
|
+
body: JSON.stringify({ contractAddress, walletAddress })
|
|
1201
|
+
});
|
|
1202
|
+
return res.json();
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Path 3: Manual off-chain claim request (email-based).
|
|
1206
|
+
*/
|
|
1207
|
+
requestCollectionClaim(params) {
|
|
1208
|
+
return this.request("/v1/collections/claim/request", {
|
|
1209
|
+
method: "POST",
|
|
1210
|
+
body: JSON.stringify(params)
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
// ─── Collection Profiles ────────────────────────────────────────────────────
|
|
1214
|
+
async getCollectionProfile(contractAddress) {
|
|
1215
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collections/${normalizeAddress(contractAddress)}/profile`;
|
|
1216
|
+
const res = await fetch(url, { headers: this.baseHeaders });
|
|
1217
|
+
if (res.status === 404) return null;
|
|
1218
|
+
return res.json();
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Update collection profile. Requires Clerk JWT for ownership check.
|
|
1222
|
+
*/
|
|
1223
|
+
async updateCollectionProfile(contractAddress, data, clerkToken) {
|
|
1224
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/collections/${normalizeAddress(contractAddress)}/profile`;
|
|
1225
|
+
const res = await fetch(url, {
|
|
1226
|
+
method: "PATCH",
|
|
1227
|
+
headers: {
|
|
1228
|
+
"x-api-key": this.baseHeaders["x-api-key"] ?? "",
|
|
1229
|
+
"Content-Type": "application/json",
|
|
1230
|
+
"Authorization": `Bearer ${clerkToken}`
|
|
1231
|
+
},
|
|
1232
|
+
body: JSON.stringify(data)
|
|
1233
|
+
});
|
|
1234
|
+
return res.json();
|
|
1235
|
+
}
|
|
1236
|
+
// ─── Creator Profiles ───────────────────────────────────────────────────────
|
|
1237
|
+
async getCreatorProfile(walletAddress) {
|
|
1238
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/creators/${normalizeAddress(walletAddress)}/profile`;
|
|
1239
|
+
const res = await fetch(url, { headers: this.baseHeaders });
|
|
1240
|
+
if (res.status === 404) return null;
|
|
1241
|
+
return res.json();
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Update creator profile. Requires Clerk JWT; wallet must match authenticated user.
|
|
1245
|
+
*/
|
|
1246
|
+
async updateCreatorProfile(walletAddress, data, clerkToken) {
|
|
1247
|
+
const url = `${this.baseUrl.replace(/\/$/, "")}/v1/creators/${normalizeAddress(walletAddress)}/profile`;
|
|
1248
|
+
const res = await fetch(url, {
|
|
1249
|
+
method: "PATCH",
|
|
1250
|
+
headers: {
|
|
1251
|
+
"x-api-key": this.baseHeaders["x-api-key"] ?? "",
|
|
1252
|
+
"Content-Type": "application/json",
|
|
1253
|
+
"Authorization": `Bearer ${clerkToken}`
|
|
1254
|
+
},
|
|
1255
|
+
body: JSON.stringify(data)
|
|
1256
|
+
});
|
|
1257
|
+
return res.json();
|
|
1258
|
+
}
|
|
1179
1259
|
};
|
|
1180
1260
|
|
|
1181
1261
|
// src/client.ts
|
|
@@ -1223,6 +1303,7 @@ exports.buildCancellationTypedData = buildCancellationTypedData;
|
|
|
1223
1303
|
exports.buildFulfillmentTypedData = buildFulfillmentTypedData;
|
|
1224
1304
|
exports.buildOrderTypedData = buildOrderTypedData;
|
|
1225
1305
|
exports.formatAmount = formatAmount;
|
|
1306
|
+
exports.getListableTokens = getListableTokens;
|
|
1226
1307
|
exports.getTokenByAddress = getTokenByAddress;
|
|
1227
1308
|
exports.getTokenBySymbol = getTokenBySymbol;
|
|
1228
1309
|
exports.normalizeAddress = normalizeAddress;
|