@medialane/sdk 0.133.0 → 0.135.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/index.cjs CHANGED
@@ -377,6 +377,11 @@ var ApiClient = class {
377
377
  getActiveOrdersForToken(contract, tokenId) {
378
378
  return this.get(`/v1/orders/token/${this.addr(contract)}/${tokenId}`);
379
379
  }
380
+ /** Offers others made on the address's assets. */
381
+ getReceivedOffers(address, opts = {}) {
382
+ const params = new URLSearchParams({ page: String(opts.page ?? 1), limit: String(opts.limit ?? 50) });
383
+ return this.get(`/v1/orders/received/${this.addr(address)}?${params}`);
384
+ }
380
385
  getOrdersByUser(address, page = 1, limit = 20) {
381
386
  return this.get(
382
387
  `/v1/orders/user/${this.addr(address)}?page=${page}&limit=${limit}`
@@ -544,6 +549,11 @@ var ApiClient = class {
544
549
  uploadMetadata(metadata) {
545
550
  return this.post("/v1/metadata/upload", metadata);
546
551
  }
552
+ /** Pins several JSON files as one IPFS directory, e.g. a drop's token metadata. */
553
+ async uploadMetadataDirectory(files) {
554
+ const res = await this.post("/v1/metadata/upload-directory", { files });
555
+ return res.data;
556
+ }
547
557
  resolveMetadata(uri) {
548
558
  const params = new URLSearchParams({ uri });
549
559
  return this.get(`/v1/metadata/resolve?${params.toString()}`);
@@ -875,7 +885,7 @@ var ApiClient = class {
875
885
  });
876
886
  }
877
887
  getPopCollections(opts = {}) {
878
- return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "POP_PROTOCOL");
888
+ return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "pop-protocol");
879
889
  }
880
890
  async getPopEligibility(collection, wallet) {
881
891
  const res = await this.get(
@@ -895,6 +905,7 @@ var ApiClient = class {
895
905
  if (opts.page) params.set("page", String(opts.page));
896
906
  if (opts.limit) params.set("limit", String(opts.limit));
897
907
  if (opts.service) params.set("service", opts.service);
908
+ if (opts.sort) params.set("sort", opts.sort);
898
909
  if (opts.chain) params.set("chain", opts.chain);
899
910
  const qs = params.toString();
900
911
  return this.get(`/v1/coins${qs ? `?${qs}` : ""}`);
@@ -925,7 +936,7 @@ var ApiClient = class {
925
936
  });
926
937
  }
927
938
  getDropCollections(opts = {}) {
928
- return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "COLLECTION_DROP");
939
+ return this.getCollections(opts.page ?? 1, opts.limit ?? 20, void 0, opts.sort, "drop-collection");
929
940
  }
930
941
  async getDropMintStatus(collection, wallet) {
931
942
  const res = await this.get(
@@ -933,6 +944,123 @@ var ApiClient = class {
933
944
  );
934
945
  return res.data;
935
946
  }
947
+ async getDropInfo(contract) {
948
+ const res = await this.request(
949
+ `/v1/drop/${this.addr(contract)}/info`,
950
+ { method: "GET" },
951
+ { allow404: true }
952
+ );
953
+ return res?.data ?? null;
954
+ }
955
+ async getDropState(contract) {
956
+ const res = await this.get(`/v1/drop/${this.addr(contract)}/state`);
957
+ return res.data;
958
+ }
959
+ async getTicket(contract, tokenId) {
960
+ const res = await this.get(`/v1/tickets/${this.addr(contract)}/${tokenId}`);
961
+ return res.data;
962
+ }
963
+ async getTicketCount(contract) {
964
+ const res = await this.get(`/v1/tickets/${this.addr(contract)}/count`);
965
+ return res.data.count;
966
+ }
967
+ async getClubMembership(contract, tokenId) {
968
+ const res = await this.get(`/v1/club/${this.addr(contract)}/${tokenId}`);
969
+ return res.data;
970
+ }
971
+ async isClubMember(contract, tokenId, wallet) {
972
+ const res = await this.get(
973
+ `/v1/club/${this.addr(contract)}/${tokenId}/member/${this.addr(wallet)}`
974
+ );
975
+ return res.data.isMember;
976
+ }
977
+ async getIpNftTokenData(contract, tokenId) {
978
+ const res = await this.get(`/v1/ipnft/${this.addr(contract)}/${tokenId}`);
979
+ return res.data;
980
+ }
981
+ async getPlatformStats() {
982
+ const res = await this.get("/v1/stats");
983
+ return res.data;
984
+ }
985
+ getTokens(query = {}) {
986
+ const params = new URLSearchParams();
987
+ if (query.page !== void 0) params.set("page", String(query.page));
988
+ if (query.limit !== void 0) params.set("limit", String(query.limit));
989
+ if (query.sort) params.set("sort", query.sort);
990
+ if (query.ipType) params.set("ipType", query.ipType);
991
+ if (query.derivatives) params.set("derivatives", query.derivatives);
992
+ const qs = params.toString();
993
+ return this.get(`/v1/tokens${qs ? `?${qs}` : ""}`);
994
+ }
995
+ async isCreatorHidden(wallet) {
996
+ const res = await this.get(`/v1/creators/${this.addr(wallet)}/hidden`);
997
+ return res.isHidden;
998
+ }
999
+ getMyUsernameClaim(siwsToken) {
1000
+ return this.request("/v1/username-claims/me", {
1001
+ method: "GET",
1002
+ headers: this.bearer(siwsToken)
1003
+ });
1004
+ }
1005
+ checkUsernameAvailability(username) {
1006
+ return this.get(
1007
+ `/v1/username-claims/check/${encodeURIComponent(username)}`
1008
+ );
1009
+ }
1010
+ async submitUsernameClaim(username, siwsToken, notifyEmail) {
1011
+ const res = await this.request("/v1/username-claims", {
1012
+ method: "POST",
1013
+ headers: this.bearer(siwsToken),
1014
+ body: JSON.stringify({ username, ...notifyEmail ? { notifyEmail } : {} })
1015
+ });
1016
+ return res.claim;
1017
+ }
1018
+ async submitReport(report, siwsToken) {
1019
+ await this.request("/v1/reports", {
1020
+ method: "POST",
1021
+ headers: this.bearer(siwsToken),
1022
+ body: JSON.stringify(report)
1023
+ });
1024
+ }
1025
+ generateWallet(newWalletSiwsToken, siwsToken) {
1026
+ return this.request("/v1/users/me/generate-wallet", {
1027
+ method: "POST",
1028
+ headers: this.bearer(siwsToken),
1029
+ body: JSON.stringify({ newWalletSiwsToken })
1030
+ });
1031
+ }
1032
+ syncCoin(coinAddress, owner) {
1033
+ return this.post("/v1/coins/sync", { coinAddress, ...owner ? { owner } : {} });
1034
+ }
1035
+ registerCollection(contractAddress) {
1036
+ return this.post("/v1/collections/register", { contractAddress });
1037
+ }
1038
+ getSponsorshipOffers(query = {}) {
1039
+ const params = new URLSearchParams({ limit: String(query.limit ?? 50) });
1040
+ if (query.nftContract) params.set("nftContract", query.nftContract);
1041
+ if (query.author) params.set("author", query.author);
1042
+ if (query.owner) params.set("owner", query.owner);
1043
+ if (query.open !== void 0) params.set("open", String(query.open));
1044
+ return this.get(`/v1/sponsorship/offers?${params}`);
1045
+ }
1046
+ async getSponsorshipBids(offerId) {
1047
+ const res = await this.get(`/v1/sponsorship/offers/${encodeURIComponent(offerId)}/bids`);
1048
+ return res.data;
1049
+ }
1050
+ getSponsorshipProposals(query = {}) {
1051
+ const params = new URLSearchParams({ limit: String(query.limit ?? 50) });
1052
+ if (query.nftContract) params.set("nftContract", query.nftContract);
1053
+ if (query.proposer) params.set("proposer", query.proposer);
1054
+ if (query.owner) params.set("owner", query.owner);
1055
+ if (query.open !== void 0) params.set("open", String(query.open));
1056
+ return this.get(`/v1/sponsorship/proposals?${params}`);
1057
+ }
1058
+ getSponsorshipLicenses(query = {}) {
1059
+ const params = new URLSearchParams({ limit: String(query.limit ?? 50) });
1060
+ if (query.holder) params.set("holder", query.holder);
1061
+ if (query.author) params.set("author", query.author);
1062
+ return this.get(`/v1/sponsorship/licenses?${params}`);
1063
+ }
936
1064
  async getRewards(address) {
937
1065
  const res = await this.get(`/v1/rewards/${this.addr(address)}`);
938
1066
  return res.data;
@@ -957,6 +1085,85 @@ var ApiClient = class {
957
1085
  }
958
1086
  };
959
1087
 
1088
+ // src/api/launchpad-runs.ts
1089
+ var isDataTokenizationRun = (run) => run.service === "data-tokenization-erc721";
1090
+ var isTicketingRun = (run) => run.service === "ip-ticketing";
1091
+ var RunRequestError = class extends Error {
1092
+ constructor(message, status, body) {
1093
+ super(message);
1094
+ this.status = status;
1095
+ this.body = body;
1096
+ }
1097
+ };
1098
+ function createLaunchpadRunsClient({ baseUrl, getToken, fetchImpl = fetch }) {
1099
+ const runsUrl = `${baseUrl.replace(/\/$/, "")}/v1/portal/runs`;
1100
+ const runBase = (id) => `${runsUrl}/${id}`;
1101
+ const runBatchBase = (id, index) => `${runBase(id)}/batches/${index}`;
1102
+ const runCollectionBase = (id) => `${runBase(id)}/collection`;
1103
+ const runTierBase = (id) => `${runBase(id)}/tier`;
1104
+ const authorizedFetch = async (input, init) => {
1105
+ const token = await getToken();
1106
+ const headers2 = new Headers(init?.headers);
1107
+ if (token) headers2.set("authorization", `Bearer ${token}`);
1108
+ return fetchImpl(input, { ...init, headers: headers2, cache: "no-store" });
1109
+ };
1110
+ async function call(url, init) {
1111
+ const res = await authorizedFetch(url, {
1112
+ ...init,
1113
+ headers: { "content-type": "application/json", ...init?.headers }
1114
+ });
1115
+ const body = await res.json().catch(() => ({}));
1116
+ if (!res.ok) {
1117
+ throw new RunRequestError(String(body.error ?? "Something went wrong with this run"), res.status, body);
1118
+ }
1119
+ return { status: res.status, data: body.data };
1120
+ }
1121
+ const post = (url, body) => call(url, { method: "POST", body: body === void 0 ? void 0 : JSON.stringify(body) });
1122
+ const confirm = async (url) => {
1123
+ const { status, data } = await post(url);
1124
+ return { pending: status === 202, status: data.status, completed: data.completed };
1125
+ };
1126
+ const ticketing = {
1127
+ uploadUrl: async (id, name) => (await post(`${runBase(id)}/files/upload-url`, { name })).data.url,
1128
+ uploaded: async (id, name, cid) => (await post(`${runBase(id)}/files/uploaded`, { name, cid })).data,
1129
+ metadata: async (id, userAddress) => (await post(`${runBase(id)}/metadata`, { userAddress })).data,
1130
+ /** Guests who still need a wallet deployed; the ones who already have one are recorded on the run. */
1131
+ resolveWallets: async (id) => (await post(`${runBase(id)}/wallets/resolve`)).data.pending,
1132
+ registerWallet: async (id, request) => (await post(`${runBase(id)}/wallets`, request)).data,
1133
+ confirmCollection: (id) => confirm(`${runCollectionBase(id)}/confirm`),
1134
+ confirmTier: (id) => confirm(`${runTierBase(id)}/confirm`),
1135
+ confirmBatch: (id, index) => confirm(`${runBatchBase(id, index)}/confirm`)
1136
+ };
1137
+ return {
1138
+ authorizedFetch,
1139
+ runBase,
1140
+ runBatchBase,
1141
+ runCollectionBase,
1142
+ runTierBase,
1143
+ ticketing,
1144
+ list: async () => (await call(runsUrl)).data,
1145
+ get: async (id) => (await call(`${runBase(id)}`)).data,
1146
+ create: async (service, spec) => (await post(runsUrl, { service, spec })).data,
1147
+ update: async (id, spec) => (await call(`${runBase(id)}`, { method: "PATCH", body: JSON.stringify({ spec }) })).data,
1148
+ cancel: async (id) => (await post(`${runBase(id)}/cancel`)).data,
1149
+ checkoutWithCredits: async (id) => (await post(`${runBase(id)}/checkout`, { method: "credits" })).data,
1150
+ checkoutFromWallet: async (id, intentId) => (await post(`${runBase(id)}/checkout`, { method: "wallet", intentId })).data,
1151
+ uploadUrl: async (id, name) => (await post(`${runBase(id)}/files/upload-url`, { name })).data.url,
1152
+ uploaded: async (id, name, cid) => (await post(`${runBase(id)}/files/uploaded`, { name, cid })).data,
1153
+ itemMetadata: async (id, index, userAddress) => (await post(`${runBase(id)}/items/${index}/metadata`, { userAddress })).data,
1154
+ confirmBatch: async (id, index) => {
1155
+ const { status, data } = await post(
1156
+ `${runBase(id)}/batches/${index}/confirm`
1157
+ );
1158
+ return { pending: status === 202, status: data.status, completed: data.completed };
1159
+ },
1160
+ confirmCollection: async (id) => {
1161
+ const { status, data } = await post(`${runBase(id)}/collection/confirm`);
1162
+ return { pending: status === 202, status: data.status };
1163
+ }
1164
+ };
1165
+ }
1166
+
960
1167
  // src/constants.ts
961
1168
  var SN = getCoordinates("STARKNET");
962
1169
  var STARKNET_MARKETPLACE_721_CONTRACT = SN.marketplace721;
@@ -2068,6 +2275,7 @@ exports.OPEN_LICENSES = OPEN_LICENSES;
2068
2275
  exports.POLICY_REFUSAL_CODES = POLICY_REFUSAL_CODES;
2069
2276
  exports.PasskeyCancelledError = PasskeyCancelledError;
2070
2277
  exports.RESERVED_TRAITS = RESERVED_TRAITS;
2278
+ exports.RunRequestError = RunRequestError;
2071
2279
  exports.STARKNET_COLLECTION_1155_CLASS_HASH = STARKNET_COLLECTION_1155_CLASS_HASH;
2072
2280
  exports.STARKNET_COLLECTION_1155_CONTRACT = STARKNET_COLLECTION_1155_CONTRACT;
2073
2281
  exports.STARKNET_COLLECTION_1155_FACTORY_CLASS_HASH = STARKNET_COLLECTION_1155_FACTORY_CLASS_HASH;
@@ -2115,6 +2323,7 @@ exports.collectionHref = collectionHref;
2115
2323
  exports.createBackendProxyHandler = createBackendProxyHandler;
2116
2324
  exports.createFailoverFetch = createFailoverFetch;
2117
2325
  exports.createImageProxyHandler = createImageProxyHandler;
2326
+ exports.createLaunchpadRunsClient = createLaunchpadRunsClient;
2118
2327
  exports.createRpcProxyHandler = createRpcProxyHandler;
2119
2328
  exports.encodeU256 = encodeU256;
2120
2329
  exports.formatAmount = formatAmount;
@@ -2128,11 +2337,13 @@ exports.getStarknetCoordinates = getStarknetCoordinates;
2128
2337
  exports.getTokenByAddress = getTokenByAddress;
2129
2338
  exports.getTokenBySymbol = getTokenBySymbol;
2130
2339
  exports.hasCapability = hasCapability;
2340
+ exports.isDataTokenizationRun = isDataTokenizationRun;
2131
2341
  exports.isPolicyRefusal = isPolicyRefusal;
2132
2342
  exports.isPrivateHost = isPrivateHost;
2133
2343
  exports.isPrivateOrInsecureUrl = isPrivateOrInsecureUrl;
2134
2344
  exports.isSameOrigin = isSameOrigin;
2135
2345
  exports.isServiceId = isServiceId;
2346
+ exports.isTicketingRun = isTicketingRun;
2136
2347
  exports.isTransientRpcError = isTransientRpcError;
2137
2348
  exports.isValidIpfsCidPath = isValidIpfsCidPath;
2138
2349
  exports.issueAccountSessionToken = issueAccountSessionToken;