@medialane/sdk 0.154.0 → 0.156.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/README.md +1 -1
- package/dist/chunk-3PZUSEAW.js +63 -0
- package/dist/chunk-3PZUSEAW.js.map +1 -0
- package/dist/chunk-ASDN46XU.js +1778 -0
- package/dist/chunk-ASDN46XU.js.map +1 -0
- package/dist/chunk-OUPVVMLK.cjs +68 -0
- package/dist/chunk-OUPVVMLK.cjs.map +1 -0
- package/dist/chunk-ZFRHADHR.cjs +1854 -0
- package/dist/chunk-ZFRHADHR.cjs.map +1 -0
- package/dist/{errors-CKO_JGDP.d.ts → errors-BKaHnCOI.d.ts} +1 -27
- package/dist/{errors-BfiX06G4.d.cts → errors-CAKnNI3N.d.cts} +1 -27
- package/dist/evm/index.cjs +3 -55
- package/dist/evm/index.cjs.map +1 -1
- package/dist/evm/index.js +1 -53
- package/dist/evm/index.js.map +1 -1
- package/dist/index.cjs +275 -1732
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -1665
- package/dist/index.js.map +1 -1
- package/dist/solana/index.cjs +2 -56
- package/dist/solana/index.cjs.map +1 -1
- package/dist/solana/index.js +1 -55
- package/dist/solana/index.js.map +1 -1
- package/dist/starknet/index.cjs +113 -1981
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +3 -113
- package/dist/starknet/index.d.ts +3 -113
- package/dist/starknet/index.js +9 -1901
- package/dist/starknet/index.js.map +1 -1
- package/dist/stellar/index.cjs +2 -56
- package/dist/stellar/index.cjs.map +1 -1
- package/dist/stellar/index.js +1 -55
- package/dist/stellar/index.js.map +1 -1
- package/package.json +1 -1
package/dist/starknet/index.js
CHANGED
|
@@ -1,1162 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { hash, cairo, uint256, RpcProvider, CairoOption, CairoOptionVariant, num, ec,
|
|
1
|
+
import { normalizeAddress, resolveConfig, ApiClient, UserFacingError, getService, STARKNET_MEDIAWALLET_CLASS_HASH, computeAccountAddress, ownerConstructorCalldata, getTokenBySymbol, signWithPrivateKey, stringifyBigInts, SUPPORTED_TOKENS, starkKeyPairFromPrivateKey, createFailoverFetch } from '../chunk-ASDN46XU.js';
|
|
2
|
+
export { InvalidStarkPrivateKeyError, PasskeyCancelledError, UserFacingError, computeAccountAddress, createPasskeyOwner, deriveAesKey, generateStarkKeyPair, ownerConstructorCalldata, sealPrivateKey, signWithPrivateKey, starkKeyPairFromPrivateKey, unsealPrivateKey } from '../chunk-ASDN46XU.js';
|
|
3
|
+
import { getStarknetCoordinates, getCoordinates } from '../chunk-3PZUSEAW.js';
|
|
4
|
+
import { hash, cairo, uint256, RpcProvider, CairoOption, CairoOptionVariant, num, ec, validateAndParseAddress, Account, typedData, stark, Contract, TypedDataRevision, constants, shortString } from 'starknet';
|
|
5
5
|
import { extract, expand } from '@noble/hashes/hkdf.js';
|
|
6
6
|
import { sha256 } from '@noble/hashes/sha2.js';
|
|
7
7
|
|
|
8
|
-
// src/config.ts
|
|
9
|
-
|
|
10
|
-
// src/chains.ts
|
|
11
|
-
var CHAINS = ["STARKNET", "ETHEREUM", "SOLANA", "BASE", "STELLAR", "BITCOIN"];
|
|
12
|
-
var COORDINATES = {
|
|
13
|
-
STARKNET: {
|
|
14
|
-
rpcUrl: "https://rpc.starknet.lava.build",
|
|
15
|
-
marketplace721: "0x03eda9a2b6ad90845a43591bac8083ebaf677d51fdf20f503b2c01889e3131fc",
|
|
16
|
-
marketplace721ClassHash: "0x0700d9230d07e5203e27778c0dc70f9134d2b25bf319f7cf8348dc66a6923e90",
|
|
17
|
-
marketplace721StartBlock: 11198146,
|
|
18
|
-
marketplace1155: "0x07c4ce1c19ea48cc11135ed22b19ff745f5aec508c3828593002e4f76fdb1b38",
|
|
19
|
-
marketplace1155ClassHash: "0x0242f5c388da7cee2d99e2a69453c8159bf927fbec4e797a3cfdcbbcb5b68328",
|
|
20
|
-
marketplace1155StartBlock: 11198267,
|
|
21
|
-
collection721: "0x0225c3ae09506b8d97adc39649ca740dad5aac195b7f5f0441cc1852947acaea",
|
|
22
|
-
collection721StartBlock: 11198496,
|
|
23
|
-
dataTokenization721: "0x07421b4442f7f2052c65408fb3561484154cf8175a0bbb41e3cd38d9087af6d2",
|
|
24
|
-
dataTokenization721StartBlock: 14670294,
|
|
25
|
-
ipNftClassHash: "0x012d3ae40ba35c7e2be0946532dac60e48932447912fdf96b674da67c029b9cc",
|
|
26
|
-
ipCollectionClassHash: "0x022155a1a130a40e57aac4b89c07fab3f616bc351b1270fc40f756b963afe8b4",
|
|
27
|
-
collection1155: "0x015368976d46fae5bfa1c58600f641d5aa5dbbf53ebc6b78aa3922194aad3551",
|
|
28
|
-
collection1155FactoryClassHash: "0x04eb6b419770f13bd191f120b9fc9ee624c0613ad4490062d293ca2016b3b1d2",
|
|
29
|
-
collection1155ClassHash: "0x06cf3f5a2322dac35e07a6064a5b8802f19fda8aa3f4726f0cb7bc05dea1bd78",
|
|
30
|
-
collection1155StartBlock: 11199527,
|
|
31
|
-
popFactory: "0x00b32c34b427d8f346b5843ada6a37bd3368d879fc752cd52b68a87287f60111",
|
|
32
|
-
popCollectionClassHash: "0x077c421686f10851872561953ea16898d933364b7f8937a5d7e2b1ba0a36263f",
|
|
33
|
-
dropFactory: "0x03587f42e29daee1b193f6cf83bf8627908ed6632d0d83fcb26225c50547d800",
|
|
34
|
-
dropCollectionClassHash: "0x00092e72cdb63067521e803aaf7d4101c3e3ce026ae6bc045ec4228027e58282",
|
|
35
|
-
nftComments: "0x02cdac70c94447189af0389dfea63f4d5e4154ea8a563de288a5ab1c39e37843",
|
|
36
|
-
creatorCoinFactory: "0x50fa807b5274079fb19374673d7bab6d2dc3af7e1032ea43eb6e44bcbde4c3c",
|
|
37
|
-
creatorCoinEkuboLauncher: "0x4f7fceb5ac10f12f9544a09580592e5bdf1b7f04f48765eecf12286d8ccb7b4",
|
|
38
|
-
creatorCoinClassHash: "0x743e4c8a5b96bb83bbf4af04edbbb482d5ece89eed9b729a79fb7df0cd0b6b6",
|
|
39
|
-
creatorCoinFactoryClassHash: "0x51765926b1344c9a20b8cd4b5abe7b7d47375ae97cf6804db3ea5d4b05a9b55",
|
|
40
|
-
creatorCoinStartBlock: 10474544,
|
|
41
|
-
ekuboCore: "0x00000005dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b",
|
|
42
|
-
ipTicketsFactory: "0x0767bf5b57e1f812463159b5ed683183e1b0c3f942b74871b5c6cd6a93c15e99",
|
|
43
|
-
ipTicketCollectionClassHash: "0x0449e8eb7c117740d07cb8e0157d32c8ba3d19d1cfd2784ed5e139f5a1e04acc",
|
|
44
|
-
ipTicketsFactoryClassHash: "0x04a739ac3a673ebd0db96bb24475600797c3ed34827e79517f9b2b1640276e6a",
|
|
45
|
-
ipTicketsStartBlock: 11933694,
|
|
46
|
-
ipClubFactory: "0x06a0b0be16d70c78f2e18119dbf90e5911cbfd5d8d484bc555dc61d96f56a2b9",
|
|
47
|
-
ipClubFactoryClassHash: "0x05d9d431bd3532b1fa4d5bab572f49c5ad8034ee3cc83951aa41ae82c9cad266",
|
|
48
|
-
ipClubCollectionClassHash: "0x05b8477c72e6bf0cf64967d71155021fd4d77d9a57e8805c6b40709121c002c5",
|
|
49
|
-
ipClubFactoryStartBlock: 11928775,
|
|
50
|
-
ipSponsorship: "0x03729ebe0fedf29ec97fca34db09174772af7f870af26a26e024a61040143e5c",
|
|
51
|
-
ipSponsorshipClassHash: "0x0626daac2ed7e2bf630ef5b10104b3202db1559216c0c1a504c0e99be2fbfec3",
|
|
52
|
-
ipSponsorshipStartBlock: 11896456,
|
|
53
|
-
mediaWalletClassHash: "0x014b210c7d47392691144bafecdca3c6c7791cc295ea305988da0a724c05ac31",
|
|
54
|
-
genesisMint: "0x06ed61abba98a44d45bed2c4b1a456df15053c3321cfd6e007afb33b7226c9f0"
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
function getCoordinates(chain) {
|
|
58
|
-
const c = COORDINATES[chain];
|
|
59
|
-
if (!c) throw new Error(`No coordinates configured for chain "${chain}"`);
|
|
60
|
-
return c;
|
|
61
|
-
}
|
|
62
|
-
var DEFAULT_CHAIN = "STARKNET";
|
|
63
|
-
function getStarknetCoordinates(chain) {
|
|
64
|
-
if (chain !== "STARKNET") {
|
|
65
|
-
throw new Error(`This module is Starknet-only (client chain: "${chain}")`);
|
|
66
|
-
}
|
|
67
|
-
return getCoordinates("STARKNET");
|
|
68
|
-
}
|
|
69
|
-
var FeeConfigSchema = z.object({
|
|
70
|
-
enabled: z.boolean().default(true),
|
|
71
|
-
fundAddress: z.string().min(1).optional(),
|
|
72
|
-
marketplaceBps: z.number().int().min(0).max(1e4).default(100),
|
|
73
|
-
launchpadBps: z.number().int().min(0).max(1e4).default(100),
|
|
74
|
-
sponsorshipBps: z.number().int().min(0).max(1e4).default(100)
|
|
75
|
-
});
|
|
76
|
-
function resolveFeeConfig(raw) {
|
|
77
|
-
const p = FeeConfigSchema.parse(raw ?? {});
|
|
78
|
-
return {
|
|
79
|
-
enabled: p.enabled,
|
|
80
|
-
fundAddress: p.fundAddress,
|
|
81
|
-
marketplaceBps: p.marketplaceBps,
|
|
82
|
-
launchpadBps: p.launchpadBps,
|
|
83
|
-
sponsorshipBps: p.sponsorshipBps
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// src/config.ts
|
|
88
|
-
var MedialaneConfigSchema = z.object({
|
|
89
|
-
chain: z.enum(CHAINS).default(DEFAULT_CHAIN),
|
|
90
|
-
rpcUrl: z.string().url().optional(),
|
|
91
|
-
backendUrl: z.string().url().optional(),
|
|
92
|
-
apiKey: z.string().optional(),
|
|
93
|
-
marketplace721Contract: z.string().optional(),
|
|
94
|
-
marketplaceContract: z.string().optional(),
|
|
95
|
-
marketplace1155Contract: z.string().optional(),
|
|
96
|
-
collection721Contract: z.string().optional(),
|
|
97
|
-
collectionContract: z.string().optional(),
|
|
98
|
-
collection1155Contract: z.string().optional(),
|
|
99
|
-
retryOptions: z.object({
|
|
100
|
-
maxAttempts: z.number().int().min(1).max(10).optional(),
|
|
101
|
-
baseDelayMs: z.number().int().min(0).optional(),
|
|
102
|
-
maxDelayMs: z.number().int().min(0).optional()
|
|
103
|
-
}).optional(),
|
|
104
|
-
feeConfig: FeeConfigSchema.optional()
|
|
105
|
-
});
|
|
106
|
-
function resolveConfig(raw) {
|
|
107
|
-
const parsed = MedialaneConfigSchema.parse(raw);
|
|
108
|
-
const coords = getCoordinates(parsed.chain);
|
|
109
|
-
const sn = parsed.chain === "STARKNET" ? coords : {};
|
|
110
|
-
const marketplace721Contract = parsed.marketplace721Contract ?? parsed.marketplaceContract ?? sn.marketplace721;
|
|
111
|
-
const collection721Contract = parsed.collection721Contract ?? parsed.collectionContract ?? sn.collection721;
|
|
112
|
-
return {
|
|
113
|
-
chain: parsed.chain,
|
|
114
|
-
rpcUrl: parsed.rpcUrl ?? coords.rpcUrl,
|
|
115
|
-
backendUrl: parsed.backendUrl,
|
|
116
|
-
apiKey: parsed.apiKey,
|
|
117
|
-
marketplace721Contract,
|
|
118
|
-
marketplaceContract: marketplace721Contract,
|
|
119
|
-
marketplace1155Contract: parsed.marketplace1155Contract ?? sn.marketplace1155,
|
|
120
|
-
collection721Contract,
|
|
121
|
-
collectionContract: collection721Contract,
|
|
122
|
-
collection1155Contract: parsed.collection1155Contract ?? sn.collection1155,
|
|
123
|
-
retryOptions: parsed.retryOptions,
|
|
124
|
-
feeConfig: resolveFeeConfig(parsed.feeConfig)
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
function normalizeAddress(chain, address) {
|
|
128
|
-
switch (chain) {
|
|
129
|
-
case "STARKNET":
|
|
130
|
-
return normalizeStarknet(address);
|
|
131
|
-
case "ETHEREUM":
|
|
132
|
-
case "BASE":
|
|
133
|
-
return normalizeEvm(address);
|
|
134
|
-
case "SOLANA":
|
|
135
|
-
return normalizeSolana(address);
|
|
136
|
-
case "STELLAR":
|
|
137
|
-
return normalizeStellar(address);
|
|
138
|
-
case "BITCOIN":
|
|
139
|
-
throw new Error("BITCOIN address normalization not implemented");
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function normalizeStarknet(address) {
|
|
143
|
-
try {
|
|
144
|
-
const hex = BigInt(address).toString(16);
|
|
145
|
-
return "0x" + hex.padStart(64, "0").toLowerCase();
|
|
146
|
-
} catch {
|
|
147
|
-
throw new Error(`Invalid STARKNET address: "${address}"`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function normalizeEvm(address) {
|
|
151
|
-
const m = /^0x([0-9a-fA-F]{40})$/.exec(address);
|
|
152
|
-
if (!m) throw new Error(`Invalid ETHEREUM/BASE address: "${address}"`);
|
|
153
|
-
const lower = m[1].toLowerCase();
|
|
154
|
-
const hash8 = keccak_256(new TextEncoder().encode(lower));
|
|
155
|
-
let out = "0x";
|
|
156
|
-
for (let i = 0; i < 40; i++) {
|
|
157
|
-
const nibble = hash8[i >> 1] >> (i % 2 === 0 ? 4 : 0) & 15;
|
|
158
|
-
out += nibble >= 8 ? lower[i].toUpperCase() : lower[i];
|
|
159
|
-
}
|
|
160
|
-
return out;
|
|
161
|
-
}
|
|
162
|
-
function normalizeSolana(address) {
|
|
163
|
-
try {
|
|
164
|
-
const bytes = base58.decode(address);
|
|
165
|
-
if (bytes.length !== 32) throw new Error("not a 32-byte key");
|
|
166
|
-
return address;
|
|
167
|
-
} catch {
|
|
168
|
-
throw new Error(`Invalid SOLANA address: "${address}"`);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
var STELLAR_VERSION_BYTES = /* @__PURE__ */ new Set([6 << 3, 2 << 3]);
|
|
172
|
-
function normalizeStellar(address) {
|
|
173
|
-
const upper = address.toUpperCase();
|
|
174
|
-
if (!/^[GC][A-Z2-7]{55}$/.test(upper)) {
|
|
175
|
-
throw new Error(`Invalid STELLAR address: "${address}"`);
|
|
176
|
-
}
|
|
177
|
-
let decoded;
|
|
178
|
-
try {
|
|
179
|
-
decoded = base32.decode(upper);
|
|
180
|
-
} catch {
|
|
181
|
-
throw new Error(`Invalid STELLAR address: "${address}"`);
|
|
182
|
-
}
|
|
183
|
-
if (decoded.length !== 35 || !STELLAR_VERSION_BYTES.has(decoded[0])) {
|
|
184
|
-
throw new Error(`Invalid STELLAR address: "${address}"`);
|
|
185
|
-
}
|
|
186
|
-
const payload = decoded.subarray(0, 33);
|
|
187
|
-
const checksum = decoded[33] | decoded[34] << 8;
|
|
188
|
-
if (crc16xmodem(payload) !== checksum) {
|
|
189
|
-
throw new Error(`Invalid STELLAR address: "${address}"`);
|
|
190
|
-
}
|
|
191
|
-
return upper;
|
|
192
|
-
}
|
|
193
|
-
function crc16xmodem(bytes) {
|
|
194
|
-
let crc = 0;
|
|
195
|
-
for (const byte of bytes) {
|
|
196
|
-
crc ^= byte << 8;
|
|
197
|
-
for (let i = 0; i < 8; i++) {
|
|
198
|
-
crc = crc & 32768 ? (crc << 1 ^ 4129) & 65535 : crc << 1 & 65535;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return crc;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// src/utils/retry.ts
|
|
205
|
-
var DEFAULT_MAX_ATTEMPTS = 3;
|
|
206
|
-
var DEFAULT_BASE_DELAY_MS = 300;
|
|
207
|
-
var DEFAULT_MAX_DELAY_MS = 5e3;
|
|
208
|
-
function sleep(ms) {
|
|
209
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
210
|
-
}
|
|
211
|
-
function isRetryableFor(method, err) {
|
|
212
|
-
if (err instanceof MedialaneApiError && err.status === 429) return true;
|
|
213
|
-
const isRead = method === "GET" || method === "HEAD";
|
|
214
|
-
if (!isRead) return false;
|
|
215
|
-
return err instanceof MedialaneApiError && err.status >= 500 || err instanceof TypeError;
|
|
216
|
-
}
|
|
217
|
-
async function withRetry(fn, opts, method = "GET") {
|
|
218
|
-
const maxAttempts = opts?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
|
|
219
|
-
const baseDelayMs = opts?.baseDelayMs ?? DEFAULT_BASE_DELAY_MS;
|
|
220
|
-
const maxDelayMs = opts?.maxDelayMs ?? DEFAULT_MAX_DELAY_MS;
|
|
221
|
-
let lastError;
|
|
222
|
-
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
223
|
-
try {
|
|
224
|
-
return await fn();
|
|
225
|
-
} catch (err) {
|
|
226
|
-
lastError = err;
|
|
227
|
-
if (!isRetryableFor(method, err) || attempt === maxAttempts - 1) {
|
|
228
|
-
throw err;
|
|
229
|
-
}
|
|
230
|
-
const retryAfterMs = err instanceof MedialaneApiError ? err.retryAfterMs : void 0;
|
|
231
|
-
const backoff = baseDelayMs * Math.pow(2, attempt) + Math.random() * baseDelayMs;
|
|
232
|
-
const delay = Math.min(retryAfterMs ?? backoff, maxDelayMs);
|
|
233
|
-
await sleep(delay);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
throw lastError;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// src/api/client.ts
|
|
240
|
-
function deriveErrorCode(status) {
|
|
241
|
-
if (status === 404) return "TOKEN_NOT_FOUND";
|
|
242
|
-
if (status === 429) return "RATE_LIMITED";
|
|
243
|
-
if (status === 410) return "INTENT_EXPIRED";
|
|
244
|
-
if (status === 401 || status === 403) return "UNAUTHORIZED";
|
|
245
|
-
if (status === 400) return "INVALID_PARAMS";
|
|
246
|
-
return "UNKNOWN";
|
|
247
|
-
}
|
|
248
|
-
var MedialaneApiError = class extends Error {
|
|
249
|
-
constructor(status, message, retryAfterMs, details) {
|
|
250
|
-
super(message);
|
|
251
|
-
this.status = status;
|
|
252
|
-
this.retryAfterMs = retryAfterMs;
|
|
253
|
-
this.details = details;
|
|
254
|
-
this.name = "MedialaneApiError";
|
|
255
|
-
this.code = deriveErrorCode(status);
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
function parseRetryAfter(value) {
|
|
259
|
-
if (!value) return void 0;
|
|
260
|
-
const seconds = Number(value);
|
|
261
|
-
if (Number.isFinite(seconds)) return Math.max(0, seconds * 1e3);
|
|
262
|
-
const date = Date.parse(value);
|
|
263
|
-
if (!Number.isNaN(date)) return Math.max(0, date - Date.now());
|
|
264
|
-
return void 0;
|
|
265
|
-
}
|
|
266
|
-
var ApiClient = class {
|
|
267
|
-
constructor(baseUrl, apiKey, retryOptions, chain = "STARKNET") {
|
|
268
|
-
this.baseUrl = baseUrl;
|
|
269
|
-
this.chain = chain;
|
|
270
|
-
this.baseHeaders = apiKey ? { "x-api-key": apiKey } : {};
|
|
271
|
-
this.retryOptions = retryOptions;
|
|
272
|
-
}
|
|
273
|
-
addr(a) {
|
|
274
|
-
return normalizeAddress(this.chain, a);
|
|
275
|
-
}
|
|
276
|
-
async request(path, init, opts) {
|
|
277
|
-
const url = `${this.baseUrl.replace(/\/$/, "")}${path}`;
|
|
278
|
-
const headers = { ...this.baseHeaders };
|
|
279
|
-
if (!(init?.body instanceof FormData)) {
|
|
280
|
-
headers["Content-Type"] = "application/json";
|
|
281
|
-
}
|
|
282
|
-
const allowed = (status) => opts?.allow404 === true && status === 404 || opts?.allow403 === true && status === 403;
|
|
283
|
-
const res = await withRetry(async () => {
|
|
284
|
-
const response = await fetch(url, {
|
|
285
|
-
...init,
|
|
286
|
-
headers: { ...headers, ...init?.headers }
|
|
287
|
-
});
|
|
288
|
-
if (!response.ok && !allowed(response.status)) {
|
|
289
|
-
const text = await response.text().catch(() => response.statusText);
|
|
290
|
-
let message = `Request failed with status ${response.status}`;
|
|
291
|
-
let details = text;
|
|
292
|
-
try {
|
|
293
|
-
const body = JSON.parse(text);
|
|
294
|
-
if (typeof body.error === "string" && body.error.trim() !== "") {
|
|
295
|
-
message = body.error;
|
|
296
|
-
}
|
|
297
|
-
details = body;
|
|
298
|
-
} catch {
|
|
299
|
-
}
|
|
300
|
-
throw new MedialaneApiError(
|
|
301
|
-
response.status,
|
|
302
|
-
message,
|
|
303
|
-
parseRetryAfter(response.headers.get("retry-after")),
|
|
304
|
-
details
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
return response;
|
|
308
|
-
}, this.retryOptions, (init?.method ?? "GET").toUpperCase());
|
|
309
|
-
if (allowed(res.status)) return null;
|
|
310
|
-
return res.json();
|
|
311
|
-
}
|
|
312
|
-
get(path) {
|
|
313
|
-
return this.request(path, { method: "GET" });
|
|
314
|
-
}
|
|
315
|
-
post(path, body) {
|
|
316
|
-
return this.request(path, { method: "POST", body: JSON.stringify(body) });
|
|
317
|
-
}
|
|
318
|
-
patch(path, body) {
|
|
319
|
-
return this.request(path, { method: "PATCH", body: JSON.stringify(body) });
|
|
320
|
-
}
|
|
321
|
-
del(path) {
|
|
322
|
-
return this.request(path, { method: "DELETE" });
|
|
323
|
-
}
|
|
324
|
-
bearer(siwsToken) {
|
|
325
|
-
return { Authorization: `Bearer ${siwsToken}` };
|
|
326
|
-
}
|
|
327
|
-
asSubject(siwsToken) {
|
|
328
|
-
return siwsToken ? this.bearer(siwsToken) : void 0;
|
|
329
|
-
}
|
|
330
|
-
getOrders(query = {}) {
|
|
331
|
-
const params = new URLSearchParams();
|
|
332
|
-
if (query.status) params.set("status", query.status);
|
|
333
|
-
if (query.collection) params.set("collection", query.collection);
|
|
334
|
-
if (query.currency) params.set("currency", query.currency);
|
|
335
|
-
if (query.sort) params.set("sort", query.sort);
|
|
336
|
-
if (query.page !== void 0) params.set("page", String(query.page));
|
|
337
|
-
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
338
|
-
if (query.offerer) params.set("offerer", this.addr(query.offerer));
|
|
339
|
-
if (query.minPrice) params.set("minPrice", query.minPrice);
|
|
340
|
-
if (query.maxPrice) params.set("maxPrice", query.maxPrice);
|
|
341
|
-
if (query.chain) params.set("chain", query.chain);
|
|
342
|
-
const qs = params.toString();
|
|
343
|
-
return this.get(`/v1/orders${qs ? `?${qs}` : ""}`);
|
|
344
|
-
}
|
|
345
|
-
getOrder(orderHash) {
|
|
346
|
-
return this.get(`/v1/orders/${orderHash}`);
|
|
347
|
-
}
|
|
348
|
-
getActiveOrdersForToken(contract, tokenId) {
|
|
349
|
-
return this.get(`/v1/orders/token/${this.addr(contract)}/${tokenId}`);
|
|
350
|
-
}
|
|
351
|
-
getReceivedOffers(address, opts = {}) {
|
|
352
|
-
const params = new URLSearchParams({ page: String(opts.page ?? 1), limit: String(opts.limit ?? 50) });
|
|
353
|
-
return this.get(`/v1/orders/received/${this.addr(address)}?${params}`);
|
|
354
|
-
}
|
|
355
|
-
getOrdersByUser(address, page = 1, limit = 20) {
|
|
356
|
-
return this.get(
|
|
357
|
-
`/v1/orders/user/${this.addr(address)}?page=${page}&limit=${limit}`
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
getToken(contract, tokenId, wait = false) {
|
|
361
|
-
return this.get(
|
|
362
|
-
`/v1/tokens/${contract}/${tokenId}${wait ? "?wait=true" : ""}`
|
|
363
|
-
);
|
|
364
|
-
}
|
|
365
|
-
getTokensByOwner(address, page = 1, limit = 20) {
|
|
366
|
-
return this.get(
|
|
367
|
-
`/v1/tokens/owned/${this.addr(address)}?page=${page}&limit=${limit}`
|
|
368
|
-
);
|
|
369
|
-
}
|
|
370
|
-
getTokenHistory(contract, tokenId, page = 1, limit = 20) {
|
|
371
|
-
return this.get(
|
|
372
|
-
`/v1/tokens/${contract}/${tokenId}/history?page=${page}&limit=${limit}`
|
|
373
|
-
);
|
|
374
|
-
}
|
|
375
|
-
getCollection(contract) {
|
|
376
|
-
return this.get(`/v1/collections/${this.addr(contract)}`);
|
|
377
|
-
}
|
|
378
|
-
getCollectionTokens(contract, page = 1, limit = 20, sort = "recent") {
|
|
379
|
-
return this.get(
|
|
380
|
-
`/v1/collections/${this.addr(contract)}/tokens?page=${page}&limit=${limit}&sort=${sort}`
|
|
381
|
-
);
|
|
382
|
-
}
|
|
383
|
-
getActivities(query = {}) {
|
|
384
|
-
const params = new URLSearchParams();
|
|
385
|
-
if (query.type) params.set("type", query.type);
|
|
386
|
-
if (query.contract) params.set("contract", query.contract);
|
|
387
|
-
if (query.page !== void 0) params.set("page", String(query.page));
|
|
388
|
-
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
389
|
-
if (query.chain) params.set("chain", query.chain);
|
|
390
|
-
const qs = params.toString();
|
|
391
|
-
return this.get(`/v1/activities${qs ? `?${qs}` : ""}`);
|
|
392
|
-
}
|
|
393
|
-
getActivitiesByAddress(address, page = 1, limit = 20) {
|
|
394
|
-
return this.get(
|
|
395
|
-
`/v1/activities/${this.addr(address)}?page=${page}&limit=${limit}`
|
|
396
|
-
);
|
|
397
|
-
}
|
|
398
|
-
getTokenComments(contract, tokenId, opts = {}) {
|
|
399
|
-
const params = new URLSearchParams();
|
|
400
|
-
if (opts.page !== void 0) params.set("page", String(opts.page));
|
|
401
|
-
if (opts.limit !== void 0) params.set("limit", String(opts.limit));
|
|
402
|
-
const qs = params.toString();
|
|
403
|
-
return this.get(
|
|
404
|
-
`/v1/tokens/${this.addr(contract)}/${tokenId}/comments${qs ? `?${qs}` : ""}`
|
|
405
|
-
);
|
|
406
|
-
}
|
|
407
|
-
search(q, limit = 10, chain) {
|
|
408
|
-
const params = new URLSearchParams({ q, limit: String(limit) });
|
|
409
|
-
if (chain) params.set("chain", chain);
|
|
410
|
-
return this.get(
|
|
411
|
-
`/v1/search?${params.toString()}`
|
|
412
|
-
);
|
|
413
|
-
}
|
|
414
|
-
createListingIntent(params) {
|
|
415
|
-
return this.post("/v1/intents/listing", params);
|
|
416
|
-
}
|
|
417
|
-
createOfferIntent(params) {
|
|
418
|
-
return this.post("/v1/intents/offer", params);
|
|
419
|
-
}
|
|
420
|
-
createFulfillIntent(params) {
|
|
421
|
-
return this.post("/v1/intents/fulfill", params);
|
|
422
|
-
}
|
|
423
|
-
createCancelIntent(params) {
|
|
424
|
-
return this.post("/v1/intents/cancel", params);
|
|
425
|
-
}
|
|
426
|
-
createCheckoutIntent(params) {
|
|
427
|
-
return this.post("/v1/intents/checkout", params);
|
|
428
|
-
}
|
|
429
|
-
getIntent(id) {
|
|
430
|
-
return this.get(`/v1/intents/${id}`);
|
|
431
|
-
}
|
|
432
|
-
submitIntentSignature(id, signature) {
|
|
433
|
-
return this.patch(`/v1/intents/${id}/signature`, { signature });
|
|
434
|
-
}
|
|
435
|
-
confirmIntent(id, txHash) {
|
|
436
|
-
return this.patch(`/v1/intents/${id}/confirm`, { txHash });
|
|
437
|
-
}
|
|
438
|
-
syncTransaction(txHash) {
|
|
439
|
-
return this.post("/v1/tx/sync", { txHash });
|
|
440
|
-
}
|
|
441
|
-
createMintIntent(params) {
|
|
442
|
-
return this.post("/v1/intents/mint", params);
|
|
443
|
-
}
|
|
444
|
-
createCollectionIntent(params) {
|
|
445
|
-
return this.post("/v1/intents/create-collection", params);
|
|
446
|
-
}
|
|
447
|
-
createTierIntent(params) {
|
|
448
|
-
return this.post("/v1/intents/create-tier", params);
|
|
449
|
-
}
|
|
450
|
-
emitToRecipients(params) {
|
|
451
|
-
return this.post("/v1/business/issuance/emission", params);
|
|
452
|
-
}
|
|
453
|
-
createCoinIntent(params) {
|
|
454
|
-
return this.post("/v1/intents/create-coin", params);
|
|
455
|
-
}
|
|
456
|
-
launchCoinIntent(params) {
|
|
457
|
-
return this.post("/v1/intents/launch-coin", params);
|
|
458
|
-
}
|
|
459
|
-
createSponsorshipOfferIntent(params) {
|
|
460
|
-
return this.post("/v1/intents/sponsorship-offer", params);
|
|
461
|
-
}
|
|
462
|
-
setSponsorshipOfferOpenIntent(params) {
|
|
463
|
-
return this.post("/v1/intents/sponsorship-offer-open", params);
|
|
464
|
-
}
|
|
465
|
-
placeSponsorshipBidIntent(params) {
|
|
466
|
-
return this.post("/v1/intents/sponsorship-bid", params);
|
|
467
|
-
}
|
|
468
|
-
retractSponsorshipBidIntent(params) {
|
|
469
|
-
return this.post("/v1/intents/sponsorship-bid-retract", params);
|
|
470
|
-
}
|
|
471
|
-
acceptSponsorshipBidIntent(params) {
|
|
472
|
-
return this.post("/v1/intents/sponsorship-bid-accept", params);
|
|
473
|
-
}
|
|
474
|
-
createSponsorshipProposalIntent(params) {
|
|
475
|
-
return this.post("/v1/intents/sponsorship-proposal", params);
|
|
476
|
-
}
|
|
477
|
-
withdrawSponsorshipProposalIntent(params) {
|
|
478
|
-
return this.post("/v1/intents/sponsorship-proposal-withdraw", params);
|
|
479
|
-
}
|
|
480
|
-
acceptSponsorshipProposalIntent(params) {
|
|
481
|
-
return this.post("/v1/intents/sponsorship-proposal-accept", params);
|
|
482
|
-
}
|
|
483
|
-
rejectSponsorshipProposalIntent(params) {
|
|
484
|
-
return this.post("/v1/intents/sponsorship-proposal-reject", params);
|
|
485
|
-
}
|
|
486
|
-
createCounterOfferIntent(params, siwsToken) {
|
|
487
|
-
const extraHeaders = siwsToken ? { "Authorization": `Bearer ${siwsToken}` } : {};
|
|
488
|
-
return this.request("/v1/intents/counter-offer", {
|
|
489
|
-
method: "POST",
|
|
490
|
-
body: JSON.stringify(params),
|
|
491
|
-
headers: extraHeaders
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
getCounterOffers(query) {
|
|
495
|
-
const params = new URLSearchParams();
|
|
496
|
-
if (query.originalOrderHash) params.set("originalOrderHash", query.originalOrderHash);
|
|
497
|
-
if (query.sellerAddress) params.set("sellerAddress", query.sellerAddress);
|
|
498
|
-
if (query.page !== void 0) params.set("page", String(query.page));
|
|
499
|
-
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
500
|
-
return this.get(`/v1/orders/counter-offers?${params}`);
|
|
501
|
-
}
|
|
502
|
-
getMetadataSignedUrl(kind) {
|
|
503
|
-
const params = kind ? `?kind=${kind}` : "";
|
|
504
|
-
return this.get(`/v1/metadata/signed-url${params}`);
|
|
505
|
-
}
|
|
506
|
-
uploadMetadata(metadata) {
|
|
507
|
-
return this.post("/v1/metadata/upload", metadata);
|
|
508
|
-
}
|
|
509
|
-
async uploadMetadataDirectory(files) {
|
|
510
|
-
const res = await this.post("/v1/metadata/upload-directory", { files });
|
|
511
|
-
return res.data;
|
|
512
|
-
}
|
|
513
|
-
resolveMetadata(uri) {
|
|
514
|
-
const params = new URLSearchParams({ uri });
|
|
515
|
-
return this.get(`/v1/metadata/resolve?${params.toString()}`);
|
|
516
|
-
}
|
|
517
|
-
uploadFile(file) {
|
|
518
|
-
const formData = new FormData();
|
|
519
|
-
formData.append("file", file);
|
|
520
|
-
return this.request("/v1/metadata/upload-file", {
|
|
521
|
-
method: "POST",
|
|
522
|
-
body: formData
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
getMe(siwsToken) {
|
|
526
|
-
return this.request("/v1/portal/me", {
|
|
527
|
-
method: "GET",
|
|
528
|
-
headers: this.asSubject(siwsToken)
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
getApiKeys(siwsToken) {
|
|
532
|
-
return this.request("/v1/portal/keys", {
|
|
533
|
-
method: "GET",
|
|
534
|
-
headers: this.asSubject(siwsToken)
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
createApiKey(input, siwsToken) {
|
|
538
|
-
return this.request("/v1/portal/keys", {
|
|
539
|
-
method: "POST",
|
|
540
|
-
body: JSON.stringify(input ?? {}),
|
|
541
|
-
headers: this.asSubject(siwsToken)
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
deleteApiKey(id, siwsToken) {
|
|
545
|
-
return this.request(`/v1/portal/keys/${id}`, {
|
|
546
|
-
method: "DELETE",
|
|
547
|
-
headers: this.asSubject(siwsToken)
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
getCreditHistory(siwsToken) {
|
|
551
|
-
return this.request("/v1/portal/credits/history", {
|
|
552
|
-
method: "GET",
|
|
553
|
-
headers: this.asSubject(siwsToken)
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
|
-
getSpend(siwsToken) {
|
|
557
|
-
return this.request("/v1/portal/credits/spend", {
|
|
558
|
-
method: "GET",
|
|
559
|
-
headers: this.asSubject(siwsToken)
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
checkDeposit(txHash, siwsToken) {
|
|
563
|
-
return this.request("/v1/portal/credits/check", {
|
|
564
|
-
method: "POST",
|
|
565
|
-
body: JSON.stringify({ txHash }),
|
|
566
|
-
headers: this.asSubject(siwsToken)
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
getFundingMethods(siwsToken) {
|
|
570
|
-
return this.request("/v1/portal/funding/methods", {
|
|
571
|
-
method: "GET",
|
|
572
|
-
headers: this.asSubject(siwsToken)
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
createFunding(input, siwsToken) {
|
|
576
|
-
return this.request("/v1/portal/funding", {
|
|
577
|
-
method: "POST",
|
|
578
|
-
body: JSON.stringify({ method: input.method, params: input.params }),
|
|
579
|
-
headers: this.asSubject(siwsToken)
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
getFunding(id, siwsToken) {
|
|
583
|
-
return this.request(`/v1/portal/funding/${encodeURIComponent(id)}`, {
|
|
584
|
-
method: "GET",
|
|
585
|
-
headers: this.asSubject(siwsToken)
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
getFundingChallenge(id, payer, siwsToken) {
|
|
589
|
-
return this.request(`/v1/portal/funding/${encodeURIComponent(id)}/challenge`, {
|
|
590
|
-
method: "POST",
|
|
591
|
-
body: JSON.stringify({ payer }),
|
|
592
|
-
headers: this.asSubject(siwsToken)
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
|
-
authorizeFunding(id, input, siwsToken) {
|
|
596
|
-
return this.request(
|
|
597
|
-
`/v1/portal/funding/${encodeURIComponent(id)}/authorize`,
|
|
598
|
-
{ method: "POST", body: JSON.stringify({ payer: input.payer, signature: input.signature }), headers: this.asSubject(siwsToken) }
|
|
599
|
-
);
|
|
600
|
-
}
|
|
601
|
-
submitFunding(id, txHash, siwsToken) {
|
|
602
|
-
return this.request(`/v1/portal/funding/${encodeURIComponent(id)}/submit`, {
|
|
603
|
-
method: "POST",
|
|
604
|
-
body: JSON.stringify({ txHash }),
|
|
605
|
-
headers: this.asSubject(siwsToken)
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
|
-
cancelFunding(id, siwsToken) {
|
|
609
|
-
return this.request(`/v1/portal/funding/${encodeURIComponent(id)}/cancel`, {
|
|
610
|
-
method: "POST",
|
|
611
|
-
body: JSON.stringify({}),
|
|
612
|
-
headers: this.asSubject(siwsToken)
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
getWebhooks() {
|
|
616
|
-
return this.get("/v1/portal/webhooks");
|
|
617
|
-
}
|
|
618
|
-
createWebhook(params) {
|
|
619
|
-
return this.post("/v1/portal/webhooks", params);
|
|
620
|
-
}
|
|
621
|
-
deleteWebhook(id) {
|
|
622
|
-
return this.del(
|
|
623
|
-
`/v1/portal/webhooks/${id}`
|
|
624
|
-
);
|
|
625
|
-
}
|
|
626
|
-
async claimCollection(contractAddress, walletAddress, siwsToken) {
|
|
627
|
-
return this.request("/v1/collections/claim", {
|
|
628
|
-
method: "POST",
|
|
629
|
-
body: JSON.stringify({ contractAddress, walletAddress }),
|
|
630
|
-
headers: this.bearer(siwsToken)
|
|
631
|
-
});
|
|
632
|
-
}
|
|
633
|
-
requestCollectionClaim(params) {
|
|
634
|
-
return this.request("/v1/collections/claim/request", {
|
|
635
|
-
method: "POST",
|
|
636
|
-
body: JSON.stringify(params)
|
|
637
|
-
});
|
|
638
|
-
}
|
|
639
|
-
registerBusinessProvisioning(params) {
|
|
640
|
-
return this.post(
|
|
641
|
-
"/v1/business/provisioning",
|
|
642
|
-
{ chain: params.chain ?? "STARKNET", email: params.email }
|
|
643
|
-
);
|
|
644
|
-
}
|
|
645
|
-
getCollectionProfile(contractAddress) {
|
|
646
|
-
return this.request(
|
|
647
|
-
`/v1/collections/${this.addr(contractAddress)}/profile`,
|
|
648
|
-
{ method: "GET" },
|
|
649
|
-
{ allow404: true }
|
|
650
|
-
);
|
|
651
|
-
}
|
|
652
|
-
updateCollectionProfile(contractAddress, data, siwsToken) {
|
|
653
|
-
return this.request(
|
|
654
|
-
`/v1/collections/${this.addr(contractAddress)}/profile`,
|
|
655
|
-
{ method: "PATCH", body: JSON.stringify(data), headers: this.bearer(siwsToken) }
|
|
656
|
-
);
|
|
657
|
-
}
|
|
658
|
-
getWalletActivity(address, chain = "STARKNET") {
|
|
659
|
-
return this.get(
|
|
660
|
-
`/v1/wallet-activity?address=${this.addr(address)}&chain=${chain}`
|
|
661
|
-
);
|
|
662
|
-
}
|
|
663
|
-
getGatedContent(contractAddress, siwsToken) {
|
|
664
|
-
return this.request(
|
|
665
|
-
`/v1/collections/${this.addr(contractAddress)}/gated-content`,
|
|
666
|
-
{ method: "GET", headers: this.bearer(siwsToken) },
|
|
667
|
-
{ allow404: true, allow403: true }
|
|
668
|
-
);
|
|
669
|
-
}
|
|
670
|
-
getCreators(opts = {}) {
|
|
671
|
-
const params = new URLSearchParams();
|
|
672
|
-
if (opts.search) params.set("search", opts.search);
|
|
673
|
-
if (opts.page) params.set("page", String(opts.page));
|
|
674
|
-
if (opts.limit) params.set("limit", String(opts.limit));
|
|
675
|
-
const qs = params.toString();
|
|
676
|
-
return this.get(`/v1/creators${qs ? `?${qs}` : ""}`);
|
|
677
|
-
}
|
|
678
|
-
getCreatorProfile(walletAddress) {
|
|
679
|
-
return this.request(
|
|
680
|
-
`/v1/creators/${this.addr(walletAddress)}/profile`,
|
|
681
|
-
{ method: "GET" },
|
|
682
|
-
{ allow404: true }
|
|
683
|
-
);
|
|
684
|
-
}
|
|
685
|
-
getCreatorByUsername(username) {
|
|
686
|
-
return this.request(
|
|
687
|
-
`/v1/creators/by-username/${encodeURIComponent(username.toLowerCase().trim())}`,
|
|
688
|
-
{ method: "GET" },
|
|
689
|
-
{ allow404: true }
|
|
690
|
-
);
|
|
691
|
-
}
|
|
692
|
-
updateCreatorProfile(walletAddress, data, siwsToken) {
|
|
693
|
-
return this.request(
|
|
694
|
-
`/v1/creators/${this.addr(walletAddress)}/profile`,
|
|
695
|
-
{ method: "PATCH", body: JSON.stringify(data), headers: this.bearer(siwsToken) }
|
|
696
|
-
);
|
|
697
|
-
}
|
|
698
|
-
checkCollectionSlugAvailability(slug) {
|
|
699
|
-
return this.get(
|
|
700
|
-
`/v1/collection-slug-claims/check/${encodeURIComponent(slug.toLowerCase().trim())}`
|
|
701
|
-
);
|
|
702
|
-
}
|
|
703
|
-
submitCollectionSlugClaim(contractAddress, slug, siwsToken, notifyEmail) {
|
|
704
|
-
return this.request("/v1/collection-slug-claims", {
|
|
705
|
-
method: "POST",
|
|
706
|
-
body: JSON.stringify({ contractAddress, slug, notifyEmail }),
|
|
707
|
-
headers: this.bearer(siwsToken)
|
|
708
|
-
});
|
|
709
|
-
}
|
|
710
|
-
getMyCollectionSlugClaims(siwsToken) {
|
|
711
|
-
return this.request("/v1/collection-slug-claims/me", {
|
|
712
|
-
method: "GET",
|
|
713
|
-
headers: this.bearer(siwsToken)
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
async getCollectionBySlug(slug) {
|
|
717
|
-
const res = await this.request(
|
|
718
|
-
`/v1/collections/by-slug/${encodeURIComponent(slug.toLowerCase().trim())}`,
|
|
719
|
-
{ method: "GET" },
|
|
720
|
-
{ allow404: true }
|
|
721
|
-
);
|
|
722
|
-
return res?.data ?? null;
|
|
723
|
-
}
|
|
724
|
-
async registerUser(params) {
|
|
725
|
-
return this.post("/v1/users/register", params);
|
|
726
|
-
}
|
|
727
|
-
async upsertMyWallet(siwsToken, options = {}) {
|
|
728
|
-
const body = {
|
|
729
|
-
walletType: options.walletType ?? "UNKNOWN"
|
|
730
|
-
};
|
|
731
|
-
if (options.chain) body.chain = options.chain;
|
|
732
|
-
if (options.email) body.email = options.email;
|
|
733
|
-
if (options.accountToken) body.accountToken = options.accountToken;
|
|
734
|
-
return this.request("/v1/users/me", {
|
|
735
|
-
method: "POST",
|
|
736
|
-
body: JSON.stringify(body),
|
|
737
|
-
headers: this.bearer(siwsToken)
|
|
738
|
-
});
|
|
739
|
-
}
|
|
740
|
-
async checkEmail(email) {
|
|
741
|
-
const body = await this.get(`/v1/auth/email/exists?email=${encodeURIComponent(email)}`);
|
|
742
|
-
return { exists: body.exists };
|
|
743
|
-
}
|
|
744
|
-
async requestEmailCode(email) {
|
|
745
|
-
await this.post("/v1/auth/email/request-code", { email });
|
|
746
|
-
}
|
|
747
|
-
async registerEmailAccount(email) {
|
|
748
|
-
await this.post("/v1/auth/email/register-account", { email });
|
|
749
|
-
}
|
|
750
|
-
async verifyEmailCode(email, code) {
|
|
751
|
-
await this.post("/v1/auth/email/verify-code", { email, code });
|
|
752
|
-
}
|
|
753
|
-
async confirmEmail(token) {
|
|
754
|
-
const body = await this.post("/v1/auth/email/confirm", { token });
|
|
755
|
-
return { email: body.email };
|
|
756
|
-
}
|
|
757
|
-
setupWalletKey(params) {
|
|
758
|
-
return this.post("/v1/users/me/wallet/key", params);
|
|
759
|
-
}
|
|
760
|
-
async getSessionWallet() {
|
|
761
|
-
const body = await this.post("/v1/users/me/wallet", {});
|
|
762
|
-
return body.walletAddress ? { walletAddress: body.walletAddress, needsKeySetup: body.needsKeySetup === true } : null;
|
|
763
|
-
}
|
|
764
|
-
getMyWallet(siwsToken) {
|
|
765
|
-
return this.request(
|
|
766
|
-
"/v1/users/me",
|
|
767
|
-
{ method: "GET", headers: this.bearer(siwsToken) },
|
|
768
|
-
{ allow404: true }
|
|
769
|
-
);
|
|
770
|
-
}
|
|
771
|
-
changeMyEmail(email, siwsToken) {
|
|
772
|
-
return this.request("/v1/users/me/email", {
|
|
773
|
-
method: "POST",
|
|
774
|
-
headers: this.bearer(siwsToken),
|
|
775
|
-
body: JSON.stringify({ email })
|
|
776
|
-
});
|
|
777
|
-
}
|
|
778
|
-
getTokenRemixes(contract, tokenId, opts = {}) {
|
|
779
|
-
const params = new URLSearchParams();
|
|
780
|
-
if (opts.page !== void 0) params.set("page", String(opts.page));
|
|
781
|
-
if (opts.limit !== void 0) params.set("limit", String(opts.limit));
|
|
782
|
-
const qs = params.toString();
|
|
783
|
-
return this.get(
|
|
784
|
-
`/v1/tokens/${this.addr(contract)}/${tokenId}/remixes${qs ? `?${qs}` : ""}`
|
|
785
|
-
);
|
|
786
|
-
}
|
|
787
|
-
submitRemixOffer(params, siwsToken) {
|
|
788
|
-
return this.request("/v1/remix-offers", {
|
|
789
|
-
method: "POST",
|
|
790
|
-
body: JSON.stringify(params),
|
|
791
|
-
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
submitAutoRemixOffer(params, siwsToken) {
|
|
795
|
-
return this.request("/v1/remix-offers/auto", {
|
|
796
|
-
method: "POST",
|
|
797
|
-
body: JSON.stringify(params),
|
|
798
|
-
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
799
|
-
});
|
|
800
|
-
}
|
|
801
|
-
confirmSelfRemix(params, siwsToken) {
|
|
802
|
-
return this.request("/v1/remix-offers/self/confirm", {
|
|
803
|
-
method: "POST",
|
|
804
|
-
body: JSON.stringify(params),
|
|
805
|
-
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
getRemixOffers(query, siwsToken) {
|
|
809
|
-
const params = new URLSearchParams({ role: query.role });
|
|
810
|
-
if (query.status) params.set("status", query.status);
|
|
811
|
-
if (query.page !== void 0) params.set("page", String(query.page));
|
|
812
|
-
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
813
|
-
return this.request(`/v1/remix-offers?${params}`, {
|
|
814
|
-
method: "GET",
|
|
815
|
-
headers: this.bearer(siwsToken)
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
|
-
getRemixOffer(id, siwsToken) {
|
|
819
|
-
return this.request(`/v1/remix-offers/${id}`, {
|
|
820
|
-
method: "GET",
|
|
821
|
-
headers: siwsToken ? this.bearer(siwsToken) : void 0
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
confirmRemixOffer(id, params, siwsToken) {
|
|
825
|
-
return this.request(`/v1/remix-offers/${id}/confirm`, {
|
|
826
|
-
method: "POST",
|
|
827
|
-
body: JSON.stringify(params),
|
|
828
|
-
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
rejectRemixOffer(id, siwsToken) {
|
|
832
|
-
return this.request(`/v1/remix-offers/${id}/reject`, {
|
|
833
|
-
method: "POST",
|
|
834
|
-
body: JSON.stringify({}),
|
|
835
|
-
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
836
|
-
});
|
|
837
|
-
}
|
|
838
|
-
extendRemixOffer(id, days, siwsToken) {
|
|
839
|
-
return this.request(`/v1/remix-offers/${id}/extend`, {
|
|
840
|
-
method: "POST",
|
|
841
|
-
body: JSON.stringify({ days }),
|
|
842
|
-
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
843
|
-
});
|
|
844
|
-
}
|
|
845
|
-
async getPopEligibility(collection, wallet) {
|
|
846
|
-
const res = await this.get(
|
|
847
|
-
`/v1/pop/eligibility/${this.addr(collection)}/${this.addr(wallet)}`
|
|
848
|
-
);
|
|
849
|
-
return res.data;
|
|
850
|
-
}
|
|
851
|
-
async getPopEligibilityBatch(collection, wallets) {
|
|
852
|
-
const params = new URLSearchParams({ wallets: wallets.map((w) => this.addr(w)).join(",") });
|
|
853
|
-
const res = await this.get(
|
|
854
|
-
`/v1/pop/eligibility/${this.addr(collection)}?${params}`
|
|
855
|
-
);
|
|
856
|
-
return res.data;
|
|
857
|
-
}
|
|
858
|
-
getCoins(opts = {}) {
|
|
859
|
-
const params = new URLSearchParams();
|
|
860
|
-
if (opts.page) params.set("page", String(opts.page));
|
|
861
|
-
if (opts.limit) params.set("limit", String(opts.limit));
|
|
862
|
-
if (opts.service) params.set("service", opts.service);
|
|
863
|
-
if (opts.sort) params.set("sort", opts.sort);
|
|
864
|
-
if (opts.creator) params.set("creator", this.addr(opts.creator));
|
|
865
|
-
if (opts.chain) params.set("chain", opts.chain);
|
|
866
|
-
const qs = params.toString();
|
|
867
|
-
return this.get(`/v1/coins${qs ? `?${qs}` : ""}`);
|
|
868
|
-
}
|
|
869
|
-
getCoin(contract) {
|
|
870
|
-
return this.get(`/v1/coins/${this.addr(contract)}`);
|
|
871
|
-
}
|
|
872
|
-
getCoinPrices() {
|
|
873
|
-
return this.get("/v1/coins/prices");
|
|
874
|
-
}
|
|
875
|
-
claimCoin(coinAddress, siwsToken) {
|
|
876
|
-
return this.request("/v1/coins/claim", {
|
|
877
|
-
method: "POST",
|
|
878
|
-
headers: { Authorization: `Bearer ${siwsToken}` },
|
|
879
|
-
body: JSON.stringify({ coinAddress })
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
getCoinClaims(status = "PENDING") {
|
|
883
|
-
return this.get(
|
|
884
|
-
`/v1/coins/claims?status=${encodeURIComponent(status)}`
|
|
885
|
-
);
|
|
886
|
-
}
|
|
887
|
-
updateCoinProfile(contract, data, siwsToken) {
|
|
888
|
-
return this.request(`/v1/coins/${this.addr(contract)}`, {
|
|
889
|
-
method: "PATCH",
|
|
890
|
-
body: JSON.stringify(data),
|
|
891
|
-
headers: this.bearer(siwsToken)
|
|
892
|
-
});
|
|
893
|
-
}
|
|
894
|
-
async getDropMintStatus(collection, wallet) {
|
|
895
|
-
const res = await this.get(
|
|
896
|
-
`/v1/drop/mint-status/${this.addr(collection)}/${this.addr(wallet)}`
|
|
897
|
-
);
|
|
898
|
-
return res.data;
|
|
899
|
-
}
|
|
900
|
-
async getDropInfo(contract) {
|
|
901
|
-
const res = await this.request(
|
|
902
|
-
`/v1/drop/${this.addr(contract)}/info`,
|
|
903
|
-
{ method: "GET" },
|
|
904
|
-
{ allow404: true }
|
|
905
|
-
);
|
|
906
|
-
return res?.data ?? null;
|
|
907
|
-
}
|
|
908
|
-
async getDropState(contract) {
|
|
909
|
-
const res = await this.get(`/v1/drop/${this.addr(contract)}/state`);
|
|
910
|
-
return res.data;
|
|
911
|
-
}
|
|
912
|
-
async getTicket(contract, tokenId) {
|
|
913
|
-
const res = await this.get(`/v1/tickets/${this.addr(contract)}/${tokenId}`);
|
|
914
|
-
return res.data;
|
|
915
|
-
}
|
|
916
|
-
async getTicketCount(contract) {
|
|
917
|
-
const res = await this.get(`/v1/tickets/${this.addr(contract)}/count`);
|
|
918
|
-
return res.data.count;
|
|
919
|
-
}
|
|
920
|
-
async getClubMembershipCount(contract) {
|
|
921
|
-
const res = await this.get(`/v1/club/${this.addr(contract)}/count`);
|
|
922
|
-
return res.data.count;
|
|
923
|
-
}
|
|
924
|
-
async getClubMembership(contract, tokenId) {
|
|
925
|
-
const res = await this.get(`/v1/club/${this.addr(contract)}/${tokenId}`);
|
|
926
|
-
return res.data;
|
|
927
|
-
}
|
|
928
|
-
async isClubMember(contract, tokenId, wallet) {
|
|
929
|
-
const res = await this.get(
|
|
930
|
-
`/v1/club/${this.addr(contract)}/${tokenId}/member/${this.addr(wallet)}`
|
|
931
|
-
);
|
|
932
|
-
return res.data.isMember;
|
|
933
|
-
}
|
|
934
|
-
async getIpNftTokenData(contract, tokenId) {
|
|
935
|
-
const res = await this.get(`/v1/ipnft/${this.addr(contract)}/${tokenId}`);
|
|
936
|
-
return res.data;
|
|
937
|
-
}
|
|
938
|
-
async getPlatformStats() {
|
|
939
|
-
const res = await this.get("/v1/stats");
|
|
940
|
-
return res.data;
|
|
941
|
-
}
|
|
942
|
-
getTokens(query = {}) {
|
|
943
|
-
const params = new URLSearchParams();
|
|
944
|
-
if (query.page !== void 0) params.set("page", String(query.page));
|
|
945
|
-
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
946
|
-
if (query.sort) params.set("sort", query.sort);
|
|
947
|
-
if (query.ipType) params.set("ipType", query.ipType);
|
|
948
|
-
if (query.derivatives) params.set("derivatives", query.derivatives);
|
|
949
|
-
const qs = params.toString();
|
|
950
|
-
return this.get(`/v1/tokens${qs ? `?${qs}` : ""}`);
|
|
951
|
-
}
|
|
952
|
-
async isCreatorHidden(wallet) {
|
|
953
|
-
const res = await this.get(`/v1/creators/${this.addr(wallet)}/hidden`);
|
|
954
|
-
return res.isHidden;
|
|
955
|
-
}
|
|
956
|
-
getMyUsernameClaim(siwsToken) {
|
|
957
|
-
return this.request("/v1/username-claims/me", {
|
|
958
|
-
method: "GET",
|
|
959
|
-
headers: this.bearer(siwsToken)
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
|
-
checkUsernameAvailability(username) {
|
|
963
|
-
return this.get(
|
|
964
|
-
`/v1/username-claims/check/${encodeURIComponent(username)}`
|
|
965
|
-
);
|
|
966
|
-
}
|
|
967
|
-
async submitUsernameClaim(username, siwsToken, notifyEmail) {
|
|
968
|
-
const res = await this.request("/v1/username-claims", {
|
|
969
|
-
method: "POST",
|
|
970
|
-
headers: this.bearer(siwsToken),
|
|
971
|
-
body: JSON.stringify({ username, ...notifyEmail ? { notifyEmail } : {} })
|
|
972
|
-
});
|
|
973
|
-
return res.claim;
|
|
974
|
-
}
|
|
975
|
-
async submitReport(report, siwsToken) {
|
|
976
|
-
const targetContract = report.targetContract ? this.addr(report.targetContract) : void 0;
|
|
977
|
-
const targetAddress = report.targetAddress ? this.addr(report.targetAddress) : void 0;
|
|
978
|
-
let targetKey = null;
|
|
979
|
-
if (report.targetType === "TOKEN" && targetContract && report.targetTokenId) {
|
|
980
|
-
targetKey = `TOKEN:${targetContract}:${report.targetTokenId}`;
|
|
981
|
-
} else if (report.targetType === "COLLECTION" && targetContract) {
|
|
982
|
-
targetKey = `COLLECTION:${targetContract}`;
|
|
983
|
-
} else if (report.targetType === "CREATOR" && targetAddress) {
|
|
984
|
-
targetKey = `CREATOR:${targetAddress}`;
|
|
985
|
-
} else if (report.targetType === "COMMENT" && report.targetId) {
|
|
986
|
-
targetKey = `COMMENT::${report.targetId}`;
|
|
987
|
-
}
|
|
988
|
-
if (!targetKey) throw new Error(`A ${report.targetType} report needs its target`);
|
|
989
|
-
await this.request("/v1/reports", {
|
|
990
|
-
method: "POST",
|
|
991
|
-
headers: this.bearer(siwsToken),
|
|
992
|
-
body: JSON.stringify({ ...report, targetKey, targetContract, targetAddress })
|
|
993
|
-
});
|
|
994
|
-
}
|
|
995
|
-
getPricing() {
|
|
996
|
-
return this.get("/v1/pricing");
|
|
997
|
-
}
|
|
998
|
-
listCollections(query = {}) {
|
|
999
|
-
const params = new URLSearchParams();
|
|
1000
|
-
if (query.page !== void 0) params.set("page", String(query.page));
|
|
1001
|
-
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
1002
|
-
if (query.owner) params.set("owner", this.addr(query.owner));
|
|
1003
|
-
if (query.service) params.set("service", query.service);
|
|
1004
|
-
if (query.sort) params.set("sort", query.sort);
|
|
1005
|
-
if (query.isFeatured !== void 0) params.set("isFeatured", String(query.isFeatured));
|
|
1006
|
-
if (query.hideEmpty !== void 0) params.set("hideEmpty", String(query.hideEmpty));
|
|
1007
|
-
if (query.standard) params.set("standard", query.standard);
|
|
1008
|
-
if (query.chain) params.set("chain", query.chain);
|
|
1009
|
-
const qs = params.toString();
|
|
1010
|
-
return this.get(`/v1/collections${qs ? `?${qs}` : ""}`);
|
|
1011
|
-
}
|
|
1012
|
-
generateWallet(newWalletSiwsToken, siwsToken) {
|
|
1013
|
-
return this.request("/v1/users/me/generate-wallet", {
|
|
1014
|
-
method: "POST",
|
|
1015
|
-
headers: this.bearer(siwsToken),
|
|
1016
|
-
body: JSON.stringify({ newWalletSiwsToken })
|
|
1017
|
-
});
|
|
1018
|
-
}
|
|
1019
|
-
syncCoin(coinAddress, owner) {
|
|
1020
|
-
return this.post("/v1/coins/sync", { coinAddress, ...owner ? { owner } : {} });
|
|
1021
|
-
}
|
|
1022
|
-
registerCollection(contractAddress) {
|
|
1023
|
-
return this.post("/v1/collections/register", { contractAddress });
|
|
1024
|
-
}
|
|
1025
|
-
getSponsorshipOffers(query = {}) {
|
|
1026
|
-
const params = new URLSearchParams({ limit: String(query.limit ?? 50) });
|
|
1027
|
-
if (query.nftContract) params.set("nftContract", query.nftContract);
|
|
1028
|
-
if (query.author) params.set("author", query.author);
|
|
1029
|
-
if (query.owner) params.set("owner", query.owner);
|
|
1030
|
-
if (query.open !== void 0) params.set("open", String(query.open));
|
|
1031
|
-
return this.get(`/v1/sponsorship/offers?${params}`);
|
|
1032
|
-
}
|
|
1033
|
-
async getSponsorshipOffer(offerId) {
|
|
1034
|
-
const res = await this.request(
|
|
1035
|
-
`/v1/sponsorship/offers/${encodeURIComponent(offerId)}`,
|
|
1036
|
-
{ method: "GET" },
|
|
1037
|
-
{ allow404: true }
|
|
1038
|
-
);
|
|
1039
|
-
return res?.data ?? null;
|
|
1040
|
-
}
|
|
1041
|
-
async getSponsorshipProposal(proposalId) {
|
|
1042
|
-
const res = await this.request(
|
|
1043
|
-
`/v1/sponsorship/proposals/${encodeURIComponent(proposalId)}`,
|
|
1044
|
-
{ method: "GET" },
|
|
1045
|
-
{ allow404: true }
|
|
1046
|
-
);
|
|
1047
|
-
return res?.data ?? null;
|
|
1048
|
-
}
|
|
1049
|
-
async getSponsorshipBids(offerId) {
|
|
1050
|
-
const res = await this.get(`/v1/sponsorship/offers/${encodeURIComponent(offerId)}/bids`);
|
|
1051
|
-
return res.data;
|
|
1052
|
-
}
|
|
1053
|
-
getSponsorshipProposals(query = {}) {
|
|
1054
|
-
const params = new URLSearchParams({ limit: String(query.limit ?? 50) });
|
|
1055
|
-
if (query.nftContract) params.set("nftContract", query.nftContract);
|
|
1056
|
-
if (query.proposer) params.set("proposer", query.proposer);
|
|
1057
|
-
if (query.owner) params.set("owner", query.owner);
|
|
1058
|
-
if (query.open !== void 0) params.set("open", String(query.open));
|
|
1059
|
-
return this.get(`/v1/sponsorship/proposals?${params}`);
|
|
1060
|
-
}
|
|
1061
|
-
getSponsorshipLicenses(query = {}) {
|
|
1062
|
-
const params = new URLSearchParams({ limit: String(query.limit ?? 50) });
|
|
1063
|
-
if (query.holder) params.set("holder", query.holder);
|
|
1064
|
-
if (query.author) params.set("author", query.author);
|
|
1065
|
-
return this.get(`/v1/sponsorship/licenses?${params}`);
|
|
1066
|
-
}
|
|
1067
|
-
async getRewards(address) {
|
|
1068
|
-
const res = await this.get(`/v1/rewards/${this.addr(address)}`);
|
|
1069
|
-
return res.data;
|
|
1070
|
-
}
|
|
1071
|
-
getRewardsLeaderboard(page = 1, limit = 50) {
|
|
1072
|
-
return this.get(`/v1/rewards?page=${page}&limit=${limit}`);
|
|
1073
|
-
}
|
|
1074
|
-
getRewardsEvents(address, page = 1, limit = 20) {
|
|
1075
|
-
return this.get(
|
|
1076
|
-
`/v1/rewards/${this.addr(address)}/events?page=${page}&limit=${limit}`
|
|
1077
|
-
);
|
|
1078
|
-
}
|
|
1079
|
-
async getRewardsConfig() {
|
|
1080
|
-
const res = await this.get(`/v1/rewards/config`);
|
|
1081
|
-
return res.data;
|
|
1082
|
-
}
|
|
1083
|
-
async getRewardsBatch(addresses) {
|
|
1084
|
-
if (addresses.length === 0) return [];
|
|
1085
|
-
const params = new URLSearchParams({ addresses: addresses.map((a) => this.addr(a)).join(",") });
|
|
1086
|
-
const res = await this.get(`/v1/rewards/batch?${params}`);
|
|
1087
|
-
return res.data;
|
|
1088
|
-
}
|
|
1089
|
-
};
|
|
1090
|
-
|
|
1091
|
-
// src/constants.ts
|
|
1092
|
-
var SN = getCoordinates("STARKNET");
|
|
1093
|
-
SN.marketplace721;
|
|
1094
|
-
SN.marketplace721ClassHash;
|
|
1095
|
-
SN.marketplace721StartBlock;
|
|
1096
|
-
SN.marketplace1155;
|
|
1097
|
-
SN.marketplace1155ClassHash;
|
|
1098
|
-
SN.marketplace1155StartBlock;
|
|
1099
|
-
SN.collection721;
|
|
1100
|
-
SN.dataTokenization721;
|
|
1101
|
-
SN.collection721StartBlock;
|
|
1102
|
-
SN.ipNftClassHash;
|
|
1103
|
-
SN.ipCollectionClassHash;
|
|
1104
|
-
SN.collection1155;
|
|
1105
|
-
SN.collection1155FactoryClassHash;
|
|
1106
|
-
SN.collection1155ClassHash;
|
|
1107
|
-
SN.collection1155StartBlock;
|
|
1108
|
-
SN.popFactory;
|
|
1109
|
-
SN.popCollectionClassHash;
|
|
1110
|
-
SN.dropFactory;
|
|
1111
|
-
SN.dropCollectionClassHash;
|
|
1112
|
-
SN.nftComments;
|
|
1113
|
-
SN.ipTicketsFactory;
|
|
1114
|
-
SN.ipTicketCollectionClassHash;
|
|
1115
|
-
SN.ipClubFactory;
|
|
1116
|
-
SN.ipClubCollectionClassHash;
|
|
1117
|
-
SN.ipSponsorship;
|
|
1118
|
-
SN.ipSponsorshipClassHash;
|
|
1119
|
-
var STARKNET_MEDIAWALLET_CLASS_HASH = SN.mediaWalletClassHash;
|
|
1120
|
-
SN.creatorCoinFactory;
|
|
1121
|
-
SN.creatorCoinEkuboLauncher;
|
|
1122
|
-
SN.creatorCoinClassHash;
|
|
1123
|
-
SN.creatorCoinFactoryClassHash;
|
|
1124
|
-
SN.creatorCoinStartBlock;
|
|
1125
|
-
SN.genesisMint;
|
|
1126
|
-
SN.ekuboCore;
|
|
1127
|
-
var SUPPORTED_TOKENS = [
|
|
1128
|
-
{
|
|
1129
|
-
symbol: "USDC",
|
|
1130
|
-
address: "0x033068f6539f8e6e6b131e6b2b814e6c34a5224bc66947c47dab9dfee93b35fb",
|
|
1131
|
-
decimals: 6,
|
|
1132
|
-
listable: true
|
|
1133
|
-
},
|
|
1134
|
-
{
|
|
1135
|
-
symbol: "USDT",
|
|
1136
|
-
address: "0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",
|
|
1137
|
-
decimals: 6,
|
|
1138
|
-
listable: true
|
|
1139
|
-
},
|
|
1140
|
-
{
|
|
1141
|
-
symbol: "ETH",
|
|
1142
|
-
address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
|
|
1143
|
-
decimals: 18,
|
|
1144
|
-
listable: true
|
|
1145
|
-
},
|
|
1146
|
-
{
|
|
1147
|
-
symbol: "STRK",
|
|
1148
|
-
address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
|
|
1149
|
-
decimals: 18,
|
|
1150
|
-
listable: true
|
|
1151
|
-
},
|
|
1152
|
-
{
|
|
1153
|
-
symbol: "WBTC",
|
|
1154
|
-
address: "0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",
|
|
1155
|
-
decimals: 8,
|
|
1156
|
-
listable: true
|
|
1157
|
-
}
|
|
1158
|
-
];
|
|
1159
|
-
|
|
1160
8
|
// src/starknet/marketplace/errors.ts
|
|
1161
9
|
var MedialaneError = class extends Error {
|
|
1162
10
|
constructor(message, code = "UNKNOWN", cause) {
|
|
@@ -1167,71 +15,6 @@ var MedialaneError = class extends Error {
|
|
|
1167
15
|
}
|
|
1168
16
|
};
|
|
1169
17
|
|
|
1170
|
-
// src/utils/rpc.ts
|
|
1171
|
-
var TRANSIENT_BODY_RE = /"code"\s*:\s*-32001|"code"\s*:\s*-32603|unable to complete|rate.?limit|too many|throttl|exceed.*quota|temporarily unavailable|service unavailable|overload|gateway.*time|upstream.*time|backend.*error/i;
|
|
1172
|
-
var POLICY_REFUSAL_CODES = [-32003, -32005, -32600];
|
|
1173
|
-
function isPolicyRefusal(input) {
|
|
1174
|
-
let body = input.body;
|
|
1175
|
-
if (typeof body === "string") {
|
|
1176
|
-
try {
|
|
1177
|
-
body = JSON.parse(body);
|
|
1178
|
-
} catch {
|
|
1179
|
-
return false;
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
const err = body?.error;
|
|
1183
|
-
const code = err && typeof err === "object" ? err.code : void 0;
|
|
1184
|
-
return typeof code === "number" && POLICY_REFUSAL_CODES.includes(code);
|
|
1185
|
-
}
|
|
1186
|
-
function isTransientRpcError(input) {
|
|
1187
|
-
const { status, body } = input;
|
|
1188
|
-
if (isPolicyRefusal({ body })) return false;
|
|
1189
|
-
if (typeof status === "number" && (status === 429 || status >= 500)) return true;
|
|
1190
|
-
if (body == null) return false;
|
|
1191
|
-
if (typeof body === "object") {
|
|
1192
|
-
const err = body.error;
|
|
1193
|
-
if (!err || typeof err !== "object") return false;
|
|
1194
|
-
const code = err.code;
|
|
1195
|
-
if (typeof code === "number") {
|
|
1196
|
-
if (code === 429) return true;
|
|
1197
|
-
if (code >= -32099 && code <= -32e3) return true;
|
|
1198
|
-
if (code === -32603) return true;
|
|
1199
|
-
}
|
|
1200
|
-
const message = err.message;
|
|
1201
|
-
return typeof message === "string" ? TRANSIENT_BODY_RE.test(message) : false;
|
|
1202
|
-
}
|
|
1203
|
-
return TRANSIENT_BODY_RE.test(String(body));
|
|
1204
|
-
}
|
|
1205
|
-
function createFailoverFetch(urls, options = {}) {
|
|
1206
|
-
const endpoints = urls.filter((u) => Boolean(u));
|
|
1207
|
-
if (endpoints.length === 0) {
|
|
1208
|
-
throw new Error("createFailoverFetch: at least one RPC URL is required");
|
|
1209
|
-
}
|
|
1210
|
-
const doFetch = options.baseFetch ?? fetch;
|
|
1211
|
-
const failover = async (_input, init) => {
|
|
1212
|
-
let lastError;
|
|
1213
|
-
for (let i = 0; i < endpoints.length; i++) {
|
|
1214
|
-
const url = endpoints[i];
|
|
1215
|
-
const isLast = i === endpoints.length - 1;
|
|
1216
|
-
try {
|
|
1217
|
-
const res = await doFetch(url, init);
|
|
1218
|
-
const text = await res.text();
|
|
1219
|
-
const rebuilt = () => new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
1220
|
-
if (isLast || !isTransientRpcError({ status: res.status, body: text })) {
|
|
1221
|
-
return rebuilt();
|
|
1222
|
-
}
|
|
1223
|
-
options.onFailover?.({ url, status: res.status });
|
|
1224
|
-
} catch (err) {
|
|
1225
|
-
lastError = err;
|
|
1226
|
-
if (isLast) throw err;
|
|
1227
|
-
options.onFailover?.({ url, error: err });
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
throw lastError ?? new Error("createFailoverFetch: all endpoints failed");
|
|
1231
|
-
};
|
|
1232
|
-
return failover;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
18
|
// src/starknet/marketplace/utils.ts
|
|
1236
19
|
var START_TIME_BUFFER_SECS = 30;
|
|
1237
20
|
function newContract(abi, address, providerOrAccount) {
|
|
@@ -11164,25 +9947,6 @@ async function getCounter1155(address, config) {
|
|
|
11164
9947
|
const contract = getContract(config);
|
|
11165
9948
|
return BigInt((await contract.get_counter(address)).toString());
|
|
11166
9949
|
}
|
|
11167
|
-
|
|
11168
|
-
// src/utils/bigint.ts
|
|
11169
|
-
function stringifyBigInts(obj) {
|
|
11170
|
-
if (typeof obj === "bigint") {
|
|
11171
|
-
return obj.toString();
|
|
11172
|
-
}
|
|
11173
|
-
if (Array.isArray(obj)) {
|
|
11174
|
-
return obj.map(stringifyBigInts);
|
|
11175
|
-
}
|
|
11176
|
-
if (obj !== null && typeof obj === "object") {
|
|
11177
|
-
return Object.fromEntries(
|
|
11178
|
-
Object.entries(obj).map(([key, value]) => [
|
|
11179
|
-
key,
|
|
11180
|
-
stringifyBigInts(value)
|
|
11181
|
-
])
|
|
11182
|
-
);
|
|
11183
|
-
}
|
|
11184
|
-
return obj;
|
|
11185
|
-
}
|
|
11186
9950
|
var STARKNET_DOMAIN = [
|
|
11187
9951
|
{ name: "name", type: "shortstring" },
|
|
11188
9952
|
{ name: "version", type: "shortstring" },
|
|
@@ -11614,135 +10378,6 @@ var StarknetVenue = class {
|
|
|
11614
10378
|
}
|
|
11615
10379
|
};
|
|
11616
10380
|
|
|
11617
|
-
// src/starknet/admin-auth/types.ts
|
|
11618
|
-
var ADMIN_SCOPE = "admin-api";
|
|
11619
|
-
function adminRequestDigest(req) {
|
|
11620
|
-
return hash.computePoseidonHashOnElements([
|
|
11621
|
-
hash.starknetKeccak(req.method.toUpperCase()),
|
|
11622
|
-
hash.starknetKeccak(req.path),
|
|
11623
|
-
hash.starknetKeccak(req.body ?? ""),
|
|
11624
|
-
num.toBigInt(req.nonce),
|
|
11625
|
-
BigInt(req.ts)
|
|
11626
|
-
]);
|
|
11627
|
-
}
|
|
11628
|
-
function signAdminRequest(sessionPrivateKey, req) {
|
|
11629
|
-
const digest = adminRequestDigest(req);
|
|
11630
|
-
return ec.starkCurve.sign(digest, sessionPrivateKey).toCompactHex();
|
|
11631
|
-
}
|
|
11632
|
-
function verifyAdminRequestSig(sessionPublicKey, req, sig) {
|
|
11633
|
-
try {
|
|
11634
|
-
return ec.starkCurve.verify(sig, adminRequestDigest(req), sessionPublicKey);
|
|
11635
|
-
} catch {
|
|
11636
|
-
return false;
|
|
11637
|
-
}
|
|
11638
|
-
}
|
|
11639
|
-
function buildAdminSessionTypedData(p) {
|
|
11640
|
-
return {
|
|
11641
|
-
types: {
|
|
11642
|
-
StarknetDomain: [
|
|
11643
|
-
{ name: "name", type: "shortstring" },
|
|
11644
|
-
{ name: "version", type: "shortstring" },
|
|
11645
|
-
{ name: "chainId", type: "shortstring" },
|
|
11646
|
-
{ name: "revision", type: "shortstring" }
|
|
11647
|
-
],
|
|
11648
|
-
AdminSession: [
|
|
11649
|
-
{ name: "sessionKeyHash", type: "felt" },
|
|
11650
|
-
{ name: "scope", type: "shortstring" },
|
|
11651
|
-
{ name: "issuedAt", type: "felt" },
|
|
11652
|
-
{ name: "expiresAt", type: "felt" }
|
|
11653
|
-
]
|
|
11654
|
-
},
|
|
11655
|
-
primaryType: "AdminSession",
|
|
11656
|
-
domain: { name: "Medialane Admin", version: "1", chainId: p.chainId ?? "SN_MAIN", revision: "1" },
|
|
11657
|
-
message: {
|
|
11658
|
-
sessionKeyHash: p.sessionKeyHash,
|
|
11659
|
-
scope: p.scope,
|
|
11660
|
-
issuedAt: String(p.issuedAt),
|
|
11661
|
-
expiresAt: String(p.expiresAt)
|
|
11662
|
-
}
|
|
11663
|
-
};
|
|
11664
|
-
}
|
|
11665
|
-
function sessionKeyHashOf(sessionPublicKey) {
|
|
11666
|
-
return num.toHex(hash.starknetKeccak(sessionPublicKey));
|
|
11667
|
-
}
|
|
11668
|
-
async function createAdminSessionGrant(signTypedData, opts) {
|
|
11669
|
-
const priv = ec.starkCurve.utils.randomPrivateKey();
|
|
11670
|
-
const sessionPrivateKey = "0x" + encode.buf2hex(priv);
|
|
11671
|
-
const sessionPublicKey = "0x" + encode.buf2hex(ec.starkCurve.getPublicKey(sessionPrivateKey, false));
|
|
11672
|
-
const sessionKeyHash = sessionKeyHashOf(sessionPublicKey);
|
|
11673
|
-
const nowSec = Math.floor((opts.now?.() ?? Date.now()) / 1e3);
|
|
11674
|
-
const issuedAt = nowSec;
|
|
11675
|
-
const expiresAt = nowSec + (opts.ttlSeconds ?? 7200);
|
|
11676
|
-
const data = buildAdminSessionTypedData({ sessionKeyHash, scope: ADMIN_SCOPE, issuedAt, expiresAt, chainId: opts.chainId });
|
|
11677
|
-
const walletSig = await signTypedData(data);
|
|
11678
|
-
const grant = {
|
|
11679
|
-
wallet: opts.wallet,
|
|
11680
|
-
chain: opts.chain ?? "STARKNET",
|
|
11681
|
-
sessionPublicKey,
|
|
11682
|
-
sessionKeyHash,
|
|
11683
|
-
scope: ADMIN_SCOPE,
|
|
11684
|
-
issuedAt,
|
|
11685
|
-
expiresAt,
|
|
11686
|
-
walletSig
|
|
11687
|
-
};
|
|
11688
|
-
return { grant, sessionPrivateKey };
|
|
11689
|
-
}
|
|
11690
|
-
|
|
11691
|
-
// src/starknet/admin-auth/headers.ts
|
|
11692
|
-
var ADMIN_HEADERS = {
|
|
11693
|
-
grant: "x-ml-admin-grant",
|
|
11694
|
-
sig: "x-ml-admin-sig",
|
|
11695
|
-
nonce: "x-ml-admin-nonce",
|
|
11696
|
-
ts: "x-ml-admin-ts"
|
|
11697
|
-
};
|
|
11698
|
-
function b64urlEncode(s) {
|
|
11699
|
-
const bytes = new TextEncoder().encode(s);
|
|
11700
|
-
let bin = "";
|
|
11701
|
-
for (const b of bytes) bin += String.fromCharCode(b);
|
|
11702
|
-
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
11703
|
-
}
|
|
11704
|
-
function b64urlDecode(s) {
|
|
11705
|
-
const pad = s.length % 4 ? "=".repeat(4 - s.length % 4) : "";
|
|
11706
|
-
const bin = atob(s.replace(/-/g, "+").replace(/_/g, "/") + pad);
|
|
11707
|
-
const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));
|
|
11708
|
-
return new TextDecoder().decode(bytes);
|
|
11709
|
-
}
|
|
11710
|
-
function randomNonce() {
|
|
11711
|
-
const b = new Uint8Array(16);
|
|
11712
|
-
crypto.getRandomValues(b);
|
|
11713
|
-
let hex = "";
|
|
11714
|
-
for (const x of b) hex += x.toString(16).padStart(2, "0");
|
|
11715
|
-
return "0x" + hex;
|
|
11716
|
-
}
|
|
11717
|
-
function encodeAdminHeaders(session, reqInit) {
|
|
11718
|
-
const nonce = randomNonce();
|
|
11719
|
-
const ts = Math.floor((reqInit.now?.() ?? Date.now()) / 1e3);
|
|
11720
|
-
const req = { method: reqInit.method, path: reqInit.path, body: reqInit.body ?? "", nonce, ts };
|
|
11721
|
-
const sig = signAdminRequest(session.sessionPrivateKey, req);
|
|
11722
|
-
return {
|
|
11723
|
-
[ADMIN_HEADERS.grant]: b64urlEncode(JSON.stringify(session.grant)),
|
|
11724
|
-
[ADMIN_HEADERS.sig]: sig,
|
|
11725
|
-
[ADMIN_HEADERS.nonce]: nonce,
|
|
11726
|
-
[ADMIN_HEADERS.ts]: String(ts)
|
|
11727
|
-
};
|
|
11728
|
-
}
|
|
11729
|
-
function parseAdminHeaders(get) {
|
|
11730
|
-
const rawGrant = get(ADMIN_HEADERS.grant);
|
|
11731
|
-
const sig = get(ADMIN_HEADERS.sig);
|
|
11732
|
-
const nonce = get(ADMIN_HEADERS.nonce);
|
|
11733
|
-
const tsRaw = get(ADMIN_HEADERS.ts);
|
|
11734
|
-
if (!rawGrant || !sig || !nonce || !tsRaw) return null;
|
|
11735
|
-
try {
|
|
11736
|
-
const grant = JSON.parse(b64urlDecode(rawGrant));
|
|
11737
|
-
if (!grant.wallet || !grant.sessionPublicKey || !grant.sessionKeyHash || !Array.isArray(grant.walletSig) || typeof grant.expiresAt !== "number") return null;
|
|
11738
|
-
const ts = Number(tsRaw);
|
|
11739
|
-
if (!Number.isFinite(ts)) return null;
|
|
11740
|
-
return { grant, sig, nonce, ts };
|
|
11741
|
-
} catch {
|
|
11742
|
-
return null;
|
|
11743
|
-
}
|
|
11744
|
-
}
|
|
11745
|
-
|
|
11746
10381
|
// src/starknet/siws/client.ts
|
|
11747
10382
|
var STORAGE_PREFIX = "ml_siws_";
|
|
11748
10383
|
function decodeBase64url(str) {
|
|
@@ -11861,7 +10496,7 @@ function buildFundingTransferCall(instructions) {
|
|
|
11861
10496
|
async function fundWithChainTransfer(api, wallet, options) {
|
|
11862
10497
|
const step = options.onStep ?? (() => {
|
|
11863
10498
|
});
|
|
11864
|
-
const
|
|
10499
|
+
const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
11865
10500
|
const pollMs = options.pollMs ?? 3e3;
|
|
11866
10501
|
const maxPolls = options.maxPolls ?? 20;
|
|
11867
10502
|
step("creating");
|
|
@@ -11891,19 +10526,11 @@ async function fundWithChainTransfer(api, wallet, options) {
|
|
|
11891
10526
|
return { status: "SETTLED", intentId: intent.id, credited: res.data.credited };
|
|
11892
10527
|
}
|
|
11893
10528
|
reason = res.data.reason;
|
|
11894
|
-
await
|
|
10529
|
+
await sleep(pollMs);
|
|
11895
10530
|
}
|
|
11896
10531
|
return { status: "PENDING", intentId: intent.id, reason };
|
|
11897
10532
|
}
|
|
11898
10533
|
|
|
11899
|
-
// src/errors.ts
|
|
11900
|
-
var UserFacingError = class extends Error {
|
|
11901
|
-
constructor(message) {
|
|
11902
|
-
super(message);
|
|
11903
|
-
this.name = "UserFacingError";
|
|
11904
|
-
}
|
|
11905
|
-
};
|
|
11906
|
-
|
|
11907
10534
|
// src/starknet/services/executeIntent.ts
|
|
11908
10535
|
async function confirmIntentBestEffort(client, intentId, txHash) {
|
|
11909
10536
|
await client.api.confirmIntent(intentId, txHash).catch(() => {
|
|
@@ -11972,323 +10599,6 @@ async function executeIntents(provider, signer, client, intents, opts = {}) {
|
|
|
11972
10599
|
]);
|
|
11973
10600
|
return { txHash, receipt };
|
|
11974
10601
|
}
|
|
11975
|
-
|
|
11976
|
-
// src/services/registry.ts
|
|
11977
|
-
var SN2 = getStarknetCoordinates("STARKNET");
|
|
11978
|
-
var SERVICES = {
|
|
11979
|
-
"mip-erc721": {
|
|
11980
|
-
id: "mip-erc721",
|
|
11981
|
-
displayName: "IP Collection",
|
|
11982
|
-
description: "Tokenize intellectual property as a per-creator ERC-721 collection.",
|
|
11983
|
-
standard: "ERC721",
|
|
11984
|
-
provenance: "MEDIALANE",
|
|
11985
|
-
onchain: {
|
|
11986
|
-
STARKNET: {
|
|
11987
|
-
factoryAddress: SN2.collection721,
|
|
11988
|
-
startBlock: SN2.collection721StartBlock
|
|
11989
|
-
}
|
|
11990
|
-
},
|
|
11991
|
-
uiVariant: "standard",
|
|
11992
|
-
capabilities: ["list", "buy", "make_offer", "cancel", "transfer", "mint", "remix", "license"],
|
|
11993
|
-
events: [
|
|
11994
|
-
{ name: "CollectionCreated", emittedBy: "factory" }
|
|
11995
|
-
],
|
|
11996
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
11997
|
-
},
|
|
11998
|
-
"ip-erc721": {
|
|
11999
|
-
id: "ip-erc721",
|
|
12000
|
-
displayName: "Programmable IP",
|
|
12001
|
-
description: "One shared ERC-721 contract any wallet can mint into.",
|
|
12002
|
-
standard: "ERC721",
|
|
12003
|
-
provenance: "MEDIALANE",
|
|
12004
|
-
uiVariant: "standard",
|
|
12005
|
-
capabilities: ["list", "buy", "make_offer", "cancel", "transfer", "mint", "remix", "license"],
|
|
12006
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12007
|
-
},
|
|
12008
|
-
"data-tokenization-erc721": {
|
|
12009
|
-
id: "data-tokenization-erc721",
|
|
12010
|
-
displayName: "Data Tokenization",
|
|
12011
|
-
description: "Establish verifiable ownership of your data, with licensing terms that hold up wherever it travels.",
|
|
12012
|
-
standard: "ERC721",
|
|
12013
|
-
provenance: "MEDIALANE",
|
|
12014
|
-
onchain: {
|
|
12015
|
-
STARKNET: {
|
|
12016
|
-
factoryAddress: SN2.dataTokenization721,
|
|
12017
|
-
startBlock: SN2.dataTokenization721StartBlock
|
|
12018
|
-
}
|
|
12019
|
-
},
|
|
12020
|
-
uiVariant: "standard",
|
|
12021
|
-
capabilities: ["list", "buy", "make_offer", "cancel", "transfer", "mint", "remix", "license"],
|
|
12022
|
-
events: [
|
|
12023
|
-
{ name: "CollectionCreated", emittedBy: "factory" }
|
|
12024
|
-
],
|
|
12025
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12026
|
-
},
|
|
12027
|
-
"mip-erc1155": {
|
|
12028
|
-
id: "mip-erc1155",
|
|
12029
|
-
displayName: "NFT Editions",
|
|
12030
|
-
description: "Per-creator ERC-1155 collection; creator mints editions.",
|
|
12031
|
-
standard: "ERC1155",
|
|
12032
|
-
provenance: "MEDIALANE",
|
|
12033
|
-
onchain: {
|
|
12034
|
-
STARKNET: {
|
|
12035
|
-
factoryAddress: SN2.collection1155,
|
|
12036
|
-
classHash: SN2.collection1155ClassHash,
|
|
12037
|
-
startBlock: SN2.collection1155StartBlock
|
|
12038
|
-
}
|
|
12039
|
-
},
|
|
12040
|
-
uiVariant: "edition",
|
|
12041
|
-
capabilities: ["list", "buy", "make_offer", "cancel", "transfer", "mint", "remix", "license"],
|
|
12042
|
-
events: [
|
|
12043
|
-
{ name: "CollectionDeployed", emittedBy: "factory" }
|
|
12044
|
-
],
|
|
12045
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12046
|
-
},
|
|
12047
|
-
"pop-protocol": {
|
|
12048
|
-
id: "pop-protocol",
|
|
12049
|
-
displayName: "POP Protocol",
|
|
12050
|
-
description: "Soulbound proof-of-presence collectibles per event.",
|
|
12051
|
-
standard: "ERC721",
|
|
12052
|
-
provenance: "MEDIALANE",
|
|
12053
|
-
onchain: {
|
|
12054
|
-
STARKNET: {
|
|
12055
|
-
factoryAddress: SN2.popFactory,
|
|
12056
|
-
classHash: SN2.popCollectionClassHash
|
|
12057
|
-
}
|
|
12058
|
-
},
|
|
12059
|
-
uiVariant: "pop",
|
|
12060
|
-
capabilities: ["claim", "mint"],
|
|
12061
|
-
events: [
|
|
12062
|
-
{ name: "CollectionCreated", emittedBy: "factory" },
|
|
12063
|
-
{ name: "AllowlistUpdated", emittedBy: "instance", poll: "slow" }
|
|
12064
|
-
],
|
|
12065
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12066
|
-
},
|
|
12067
|
-
"certificate-emission": {
|
|
12068
|
-
id: "certificate-emission",
|
|
12069
|
-
displayName: "Certificate Emission",
|
|
12070
|
-
description: "Issue a soulbound credential to a list of recipients in one run \u2014 everyone gets a wallet and their certificate.",
|
|
12071
|
-
standard: "ERC721",
|
|
12072
|
-
provenance: "MEDIALANE",
|
|
12073
|
-
onchain: {
|
|
12074
|
-
STARKNET: {
|
|
12075
|
-
factoryAddress: SN2.popFactory,
|
|
12076
|
-
classHash: SN2.popCollectionClassHash
|
|
12077
|
-
}
|
|
12078
|
-
},
|
|
12079
|
-
uiVariant: "pop",
|
|
12080
|
-
capabilities: ["mint", "airdrop"],
|
|
12081
|
-
events: [
|
|
12082
|
-
{ name: "CollectionCreated", emittedBy: "factory" }
|
|
12083
|
-
],
|
|
12084
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12085
|
-
},
|
|
12086
|
-
"drop-collection": {
|
|
12087
|
-
id: "drop-collection",
|
|
12088
|
-
displayName: "Collection Drop",
|
|
12089
|
-
description: "Sequential mint with claim windows + allowlist.",
|
|
12090
|
-
standard: "ERC721",
|
|
12091
|
-
provenance: "MEDIALANE",
|
|
12092
|
-
onchain: {
|
|
12093
|
-
STARKNET: {
|
|
12094
|
-
factoryAddress: SN2.dropFactory,
|
|
12095
|
-
classHash: SN2.dropCollectionClassHash
|
|
12096
|
-
}
|
|
12097
|
-
},
|
|
12098
|
-
uiVariant: "drop",
|
|
12099
|
-
capabilities: ["claim", "list", "buy", "make_offer", "cancel", "transfer"],
|
|
12100
|
-
events: [
|
|
12101
|
-
{ name: "DropCreated", emittedBy: "factory" },
|
|
12102
|
-
{ name: "AllowlistUpdated", emittedBy: "instance", poll: "slow" }
|
|
12103
|
-
],
|
|
12104
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12105
|
-
},
|
|
12106
|
-
"ip-tickets": {
|
|
12107
|
-
id: "ip-tickets",
|
|
12108
|
-
displayName: "IP Tickets",
|
|
12109
|
-
description: "Create verifiable on-chain tickets \u2014 mint to attendees, trade like any collection.",
|
|
12110
|
-
standard: "ERC1155",
|
|
12111
|
-
provenance: "MEDIALANE",
|
|
12112
|
-
onchain: {
|
|
12113
|
-
STARKNET: {
|
|
12114
|
-
factoryAddress: SN2.ipTicketsFactory,
|
|
12115
|
-
classHash: SN2.ipTicketCollectionClassHash
|
|
12116
|
-
}
|
|
12117
|
-
},
|
|
12118
|
-
uiVariant: "ticket",
|
|
12119
|
-
capabilities: ["mint", "redeem", "list", "buy", "make_offer", "cancel", "transfer"],
|
|
12120
|
-
events: [
|
|
12121
|
-
{ name: "CollectionDeployed", emittedBy: "factory" },
|
|
12122
|
-
{ name: "TicketCreated", emittedBy: "instance" }
|
|
12123
|
-
],
|
|
12124
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12125
|
-
},
|
|
12126
|
-
"ip-ticketing": {
|
|
12127
|
-
id: "ip-ticketing",
|
|
12128
|
-
displayName: "IP Ticketing",
|
|
12129
|
-
description: "Distribute verifiable on-chain tickets to a list of recipients in one run \u2014 everyone gets a wallet and their ticket.",
|
|
12130
|
-
standard: "ERC1155",
|
|
12131
|
-
provenance: "MEDIALANE",
|
|
12132
|
-
onchain: {
|
|
12133
|
-
STARKNET: {
|
|
12134
|
-
factoryAddress: SN2.ipTicketsFactory,
|
|
12135
|
-
classHash: SN2.ipTicketCollectionClassHash
|
|
12136
|
-
}
|
|
12137
|
-
},
|
|
12138
|
-
uiVariant: "ticket",
|
|
12139
|
-
capabilities: ["mint", "airdrop", "redeem", "list", "buy", "make_offer", "cancel", "transfer"],
|
|
12140
|
-
events: [
|
|
12141
|
-
{ name: "CollectionDeployed", emittedBy: "factory" },
|
|
12142
|
-
{ name: "TicketCreated", emittedBy: "instance" }
|
|
12143
|
-
],
|
|
12144
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12145
|
-
},
|
|
12146
|
-
"ip-club": {
|
|
12147
|
-
id: "ip-club",
|
|
12148
|
-
displayName: "IP Club",
|
|
12149
|
-
description: "Membership clubs \u2014 create tiers, mint membership cards, trade like any collection.",
|
|
12150
|
-
standard: "ERC1155",
|
|
12151
|
-
provenance: "MEDIALANE",
|
|
12152
|
-
onchain: {
|
|
12153
|
-
STARKNET: {
|
|
12154
|
-
factoryAddress: SN2.ipClubFactory,
|
|
12155
|
-
classHash: SN2.ipClubCollectionClassHash
|
|
12156
|
-
}
|
|
12157
|
-
},
|
|
12158
|
-
uiVariant: "club",
|
|
12159
|
-
capabilities: ["mint", "list", "buy", "make_offer", "cancel", "transfer"],
|
|
12160
|
-
events: [
|
|
12161
|
-
{ name: "ClubDeployed", emittedBy: "factory" },
|
|
12162
|
-
{ name: "MembershipCreated", emittedBy: "instance" }
|
|
12163
|
-
],
|
|
12164
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12165
|
-
},
|
|
12166
|
-
"ip-sponsorship": {
|
|
12167
|
-
id: "ip-sponsorship",
|
|
12168
|
-
displayName: "IP Sponsorship",
|
|
12169
|
-
description: "Sponsorship offers and licenses anchored to an existing Medialane asset.",
|
|
12170
|
-
standard: "ERC721",
|
|
12171
|
-
provenance: "MEDIALANE",
|
|
12172
|
-
onchain: {
|
|
12173
|
-
STARKNET: {
|
|
12174
|
-
factoryAddress: SN2.ipSponsorship,
|
|
12175
|
-
classHash: SN2.ipSponsorshipClassHash,
|
|
12176
|
-
startBlock: SN2.ipSponsorshipStartBlock
|
|
12177
|
-
}
|
|
12178
|
-
},
|
|
12179
|
-
uiVariant: "standard",
|
|
12180
|
-
capabilities: ["sponsor", "transfer"],
|
|
12181
|
-
events: [
|
|
12182
|
-
{ name: "OfferCreated", emittedBy: "factory" },
|
|
12183
|
-
{ name: "ProposalCreated", emittedBy: "factory" },
|
|
12184
|
-
{ name: "LicenseMinted", emittedBy: "factory" }
|
|
12185
|
-
],
|
|
12186
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12187
|
-
},
|
|
12188
|
-
"creator-coin": {
|
|
12189
|
-
id: "creator-coin",
|
|
12190
|
-
displayName: "Creator Coin",
|
|
12191
|
-
description: "Launch a fixed-supply social token with permanently-locked Ekubo liquidity.",
|
|
12192
|
-
standard: "ERC20",
|
|
12193
|
-
provenance: "MEDIALANE",
|
|
12194
|
-
onchain: {
|
|
12195
|
-
STARKNET: {
|
|
12196
|
-
factoryAddress: SN2.creatorCoinFactory,
|
|
12197
|
-
classHash: SN2.creatorCoinFactoryClassHash,
|
|
12198
|
-
startBlock: SN2.creatorCoinStartBlock
|
|
12199
|
-
}
|
|
12200
|
-
},
|
|
12201
|
-
uiVariant: "coin",
|
|
12202
|
-
capabilities: ["launch", "swap", "transfer"],
|
|
12203
|
-
events: [
|
|
12204
|
-
{ name: "CreatorCoinCreated", emittedBy: "factory" },
|
|
12205
|
-
{ name: "CreatorCoinLaunched", emittedBy: "factory" }
|
|
12206
|
-
]
|
|
12207
|
-
},
|
|
12208
|
-
"medialane-marketplace-erc721": {
|
|
12209
|
-
id: "medialane-marketplace-erc721",
|
|
12210
|
-
displayName: "Medialane Marketplace (ERC-721)",
|
|
12211
|
-
description: "ERC-721 order matching venue.",
|
|
12212
|
-
standard: "ERC721",
|
|
12213
|
-
provenance: "MEDIALANE",
|
|
12214
|
-
onchain: {
|
|
12215
|
-
STARKNET: {
|
|
12216
|
-
factoryAddress: SN2.marketplace721,
|
|
12217
|
-
classHash: SN2.marketplace721ClassHash,
|
|
12218
|
-
startBlock: SN2.marketplace721StartBlock
|
|
12219
|
-
}
|
|
12220
|
-
},
|
|
12221
|
-
uiVariant: "standard",
|
|
12222
|
-
capabilities: ["list", "buy", "make_offer", "cancel"],
|
|
12223
|
-
events: [
|
|
12224
|
-
{ name: "OrderCreated", emittedBy: "factory" },
|
|
12225
|
-
{ name: "OrderFulfilled", emittedBy: "factory" },
|
|
12226
|
-
{ name: "OrderCancelled", emittedBy: "factory" }
|
|
12227
|
-
]
|
|
12228
|
-
},
|
|
12229
|
-
"medialane-marketplace-erc1155": {
|
|
12230
|
-
id: "medialane-marketplace-erc1155",
|
|
12231
|
-
displayName: "Medialane Marketplace (ERC-1155)",
|
|
12232
|
-
description: "ERC-1155 order matching venue.",
|
|
12233
|
-
standard: "ERC1155",
|
|
12234
|
-
provenance: "MEDIALANE",
|
|
12235
|
-
onchain: {
|
|
12236
|
-
STARKNET: {
|
|
12237
|
-
factoryAddress: SN2.marketplace1155,
|
|
12238
|
-
classHash: SN2.marketplace1155ClassHash,
|
|
12239
|
-
startBlock: SN2.marketplace1155StartBlock
|
|
12240
|
-
}
|
|
12241
|
-
},
|
|
12242
|
-
uiVariant: "edition",
|
|
12243
|
-
capabilities: ["list", "buy", "make_offer", "cancel"],
|
|
12244
|
-
events: [
|
|
12245
|
-
{ name: "OrderCreated", emittedBy: "factory" },
|
|
12246
|
-
{ name: "OrderFulfilled", emittedBy: "factory" },
|
|
12247
|
-
{ name: "OrderCancelled", emittedBy: "factory" }
|
|
12248
|
-
]
|
|
12249
|
-
},
|
|
12250
|
-
"unruggable-erc20": {
|
|
12251
|
-
id: "unruggable-erc20",
|
|
12252
|
-
displayName: "Unruggable",
|
|
12253
|
-
description: "An ERC-20 launched through the unruggable.meme protocol, the same contract Medialane's Creator Coin is forked from. Not deployed via a Medialane service, but exposes the same on-chain guarantees: capped team allocation, permanently locked liquidity, fixed supply. Brought in by owner claim or admin/partnership \u2014 never bulk-indexed.",
|
|
12254
|
-
standard: "ERC20",
|
|
12255
|
-
provenance: "EXTERNAL",
|
|
12256
|
-
uiVariant: "coin",
|
|
12257
|
-
capabilities: ["swap", "transfer"]
|
|
12258
|
-
},
|
|
12259
|
-
"external-erc20": {
|
|
12260
|
-
id: "external-erc20",
|
|
12261
|
-
displayName: "Memecoin",
|
|
12262
|
-
description: "A plain ERC-20 not deployed via a Medialane service and carrying no protocol-level guarantees. Brought in by owner claim or admin/partnership \u2014 never bulk-indexed. Generalizes to future chains.",
|
|
12263
|
-
standard: "ERC20",
|
|
12264
|
-
provenance: "EXTERNAL",
|
|
12265
|
-
uiVariant: "coin",
|
|
12266
|
-
capabilities: ["swap", "transfer"]
|
|
12267
|
-
},
|
|
12268
|
-
"external-erc721": {
|
|
12269
|
-
id: "external-erc721",
|
|
12270
|
-
displayName: "External ERC-721",
|
|
12271
|
-
description: "ERC-721 contract not deployed via a Medialane service.",
|
|
12272
|
-
standard: "ERC721",
|
|
12273
|
-
provenance: "EXTERNAL",
|
|
12274
|
-
uiVariant: "standard",
|
|
12275
|
-
capabilities: ["list", "buy", "make_offer", "cancel", "transfer"]
|
|
12276
|
-
},
|
|
12277
|
-
"external-erc1155": {
|
|
12278
|
-
id: "external-erc1155",
|
|
12279
|
-
displayName: "External ERC-1155",
|
|
12280
|
-
description: "ERC-1155 contract not deployed via a Medialane service.",
|
|
12281
|
-
standard: "ERC1155",
|
|
12282
|
-
provenance: "EXTERNAL",
|
|
12283
|
-
uiVariant: "edition",
|
|
12284
|
-
capabilities: ["list", "buy", "make_offer", "cancel", "transfer"]
|
|
12285
|
-
}
|
|
12286
|
-
};
|
|
12287
|
-
function getService(id) {
|
|
12288
|
-
return id && id in SERVICES ? SERVICES[id] : void 0;
|
|
12289
|
-
}
|
|
12290
|
-
|
|
12291
|
-
// src/starknet/services/receipts.ts
|
|
12292
10602
|
var DEPLOY_EVENTS = {
|
|
12293
10603
|
"mip-erc1155": { event: "CollectionDeployed", address: (e) => e.keys?.[1] },
|
|
12294
10604
|
"ip-tickets": { event: "CollectionDeployed", address: (e) => e.keys?.[1] },
|
|
@@ -12408,17 +10718,6 @@ function deriveOwnerKeyPair(secret, recipientId) {
|
|
|
12408
10718
|
const publicKey = ec.starkCurve.getStarkKey(privateKey);
|
|
12409
10719
|
return { privateKey, publicKey };
|
|
12410
10720
|
}
|
|
12411
|
-
function ownerConstructorCalldata(ownerPubkey) {
|
|
12412
|
-
return ["0x0", num.toHex(ownerPubkey), "0x1"];
|
|
12413
|
-
}
|
|
12414
|
-
function computeAccountAddress(ownerPubkey, salt = 0) {
|
|
12415
|
-
return hash.calculateContractAddressFromHash(
|
|
12416
|
-
num.toHex(salt),
|
|
12417
|
-
STARKNET_MEDIAWALLET_CLASS_HASH,
|
|
12418
|
-
ownerConstructorCalldata(ownerPubkey),
|
|
12419
|
-
0
|
|
12420
|
-
);
|
|
12421
|
-
}
|
|
12422
10721
|
var STARKNET_SIGNER_TYPE = "0x537461726b6e6574205369676e6572";
|
|
12423
10722
|
var OPTION_NONE = "0x1";
|
|
12424
10723
|
var SIGNER_STARKNET = "0x0";
|
|
@@ -12541,53 +10840,6 @@ async function getEscapeSecurityPeriod(provider, address) {
|
|
|
12541
10840
|
});
|
|
12542
10841
|
return Number(res[0]);
|
|
12543
10842
|
}
|
|
12544
|
-
async function deriveAesKey(prfSecret, hkdfInfo) {
|
|
12545
|
-
const hkdf = await crypto.subtle.importKey("raw", prfSecret, "HKDF", false, ["deriveKey"]);
|
|
12546
|
-
return crypto.subtle.deriveKey(
|
|
12547
|
-
{ name: "HKDF", hash: "SHA-256", salt: new Uint8Array(0), info: hkdfInfo },
|
|
12548
|
-
hkdf,
|
|
12549
|
-
{ name: "AES-GCM", length: 256 },
|
|
12550
|
-
false,
|
|
12551
|
-
["encrypt", "decrypt"]
|
|
12552
|
-
);
|
|
12553
|
-
}
|
|
12554
|
-
function generateStarkKeyPair() {
|
|
12555
|
-
const privateKeyHex = "0x" + Array.from(ec.starkCurve.utils.randomPrivateKey()).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
12556
|
-
return { privateKeyHex, publicKeyHex: ec.starkCurve.getStarkKey(privateKeyHex) };
|
|
12557
|
-
}
|
|
12558
|
-
var InvalidStarkPrivateKeyError = class extends Error {
|
|
12559
|
-
constructor(reason) {
|
|
12560
|
-
super(`Not a valid Starknet private key: ${reason}`);
|
|
12561
|
-
this.name = "InvalidStarkPrivateKeyError";
|
|
12562
|
-
}
|
|
12563
|
-
};
|
|
12564
|
-
function starkKeyPairFromPrivateKey(input) {
|
|
12565
|
-
const trimmed = input.trim().replace(/\s+/g, "");
|
|
12566
|
-
const body = trimmed.startsWith("0x") || trimmed.startsWith("0X") ? trimmed.slice(2) : trimmed;
|
|
12567
|
-
if (body.length === 0) throw new InvalidStarkPrivateKeyError("it is empty");
|
|
12568
|
-
if (!/^[0-9a-fA-F]+$/.test(body)) throw new InvalidStarkPrivateKeyError("it is not hexadecimal");
|
|
12569
|
-
if (body.length > 64) throw new InvalidStarkPrivateKeyError("it is too long");
|
|
12570
|
-
const value = BigInt("0x" + body);
|
|
12571
|
-
if (value === 0n) throw new InvalidStarkPrivateKeyError("it is zero");
|
|
12572
|
-
if (value >= ec.starkCurve.CURVE.n) throw new InvalidStarkPrivateKeyError("it is outside the curve order");
|
|
12573
|
-
const privateKeyHex = "0x" + value.toString(16).padStart(64, "0");
|
|
12574
|
-
return { privateKeyHex, publicKeyHex: ec.starkCurve.getStarkKey(privateKeyHex) };
|
|
12575
|
-
}
|
|
12576
|
-
async function sealPrivateKey(aesKey, iv, privateKeyHex) {
|
|
12577
|
-
return crypto.subtle.encrypt(
|
|
12578
|
-
{ name: "AES-GCM", iv },
|
|
12579
|
-
aesKey,
|
|
12580
|
-
new TextEncoder().encode(privateKeyHex)
|
|
12581
|
-
);
|
|
12582
|
-
}
|
|
12583
|
-
async function unsealPrivateKey(aesKey, iv, ciphertext) {
|
|
12584
|
-
const buf = await crypto.subtle.decrypt({ name: "AES-GCM", iv }, aesKey, ciphertext);
|
|
12585
|
-
return new TextDecoder().decode(buf);
|
|
12586
|
-
}
|
|
12587
|
-
function signWithPrivateKey(privateKeyHex, msgHash) {
|
|
12588
|
-
const sig = ec.starkCurve.sign(msgHash, privateKeyHex);
|
|
12589
|
-
return [num.toHex(sig.r), num.toHex(sig.s)];
|
|
12590
|
-
}
|
|
12591
10843
|
|
|
12592
10844
|
// src/wallet/store.ts
|
|
12593
10845
|
function createOwnerStore(config) {
|
|
@@ -12765,150 +11017,6 @@ function createSelfFundConsent(estimateFee) {
|
|
|
12765
11017
|
}
|
|
12766
11018
|
};
|
|
12767
11019
|
}
|
|
12768
|
-
|
|
12769
|
-
// src/wallet/passkey.ts
|
|
12770
|
-
var PasskeyCancelledError = class extends Error {
|
|
12771
|
-
constructor(message = "Passkey prompt was cancelled.") {
|
|
12772
|
-
super(message);
|
|
12773
|
-
this.name = "PasskeyCancelledError";
|
|
12774
|
-
}
|
|
12775
|
-
};
|
|
12776
|
-
var encodeBase64 = (buf) => {
|
|
12777
|
-
const bytes = buf instanceof Uint8Array ? buf : new Uint8Array(buf);
|
|
12778
|
-
let binary = "";
|
|
12779
|
-
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
12780
|
-
return btoa(binary);
|
|
12781
|
-
};
|
|
12782
|
-
var decodeBase64 = (value) => {
|
|
12783
|
-
const binary = atob(value);
|
|
12784
|
-
const bytes = new Uint8Array(binary.length);
|
|
12785
|
-
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
12786
|
-
return bytes;
|
|
12787
|
-
};
|
|
12788
|
-
function isPasskeyCancellation(err) {
|
|
12789
|
-
const name = err?.name;
|
|
12790
|
-
return name === "NotAllowedError" || name === "AbortError";
|
|
12791
|
-
}
|
|
12792
|
-
function createPasskeyOwner(config) {
|
|
12793
|
-
const randomBytes = config.randomBytes ?? ((length) => crypto.getRandomValues(new Uint8Array(length)));
|
|
12794
|
-
const credentialsApi = () => {
|
|
12795
|
-
const api = config.credentials ?? (typeof navigator === "undefined" ? void 0 : navigator.credentials);
|
|
12796
|
-
if (!api) throw new Error("Passkeys are only available in a browser.");
|
|
12797
|
-
return api;
|
|
12798
|
-
};
|
|
12799
|
-
const prfUnsupportedMessage = () => {
|
|
12800
|
-
const isBrave = typeof navigator !== "undefined" && "brave" in navigator;
|
|
12801
|
-
const cause = isBrave ? "Brave doesn't currently support the WebAuthn PRF extension." : "This browser didn't return a passkey PRF secret.";
|
|
12802
|
-
return `${cause} ${config.appName} needs it to seal your key. Your device passkey (Touch ID) is fine, the limitation is the browser. Please open this in Safari or Chrome on an up-to-date OS.`;
|
|
12803
|
-
};
|
|
12804
|
-
async function registerPasskey() {
|
|
12805
|
-
let credential;
|
|
12806
|
-
try {
|
|
12807
|
-
credential = await credentialsApi().create({
|
|
12808
|
-
publicKey: {
|
|
12809
|
-
challenge: randomBytes(32),
|
|
12810
|
-
rp: { name: config.relyingPartyName, id: config.relyingPartyId() },
|
|
12811
|
-
user: await config.passkeyUser(),
|
|
12812
|
-
excludeCredentials: config.knownCredentials(),
|
|
12813
|
-
pubKeyCredParams: [
|
|
12814
|
-
{ type: "public-key", alg: -7 },
|
|
12815
|
-
{ type: "public-key", alg: -257 }
|
|
12816
|
-
],
|
|
12817
|
-
authenticatorSelection: {
|
|
12818
|
-
residentKey: "required",
|
|
12819
|
-
userVerification: "required",
|
|
12820
|
-
authenticatorAttachment: "platform"
|
|
12821
|
-
},
|
|
12822
|
-
extensions: { prf: { eval: { first: config.prfSalt } } }
|
|
12823
|
-
}
|
|
12824
|
-
});
|
|
12825
|
-
} catch (err) {
|
|
12826
|
-
if (isPasskeyCancellation(err)) throw new PasskeyCancelledError();
|
|
12827
|
-
throw err;
|
|
12828
|
-
}
|
|
12829
|
-
const prf = credential.getClientExtensionResults().prf;
|
|
12830
|
-
return { credentialId: encodeBase64(credential.rawId), prfFirst: prf?.results?.first ?? null };
|
|
12831
|
-
}
|
|
12832
|
-
async function prfSecret(credentialId) {
|
|
12833
|
-
let assertion;
|
|
12834
|
-
try {
|
|
12835
|
-
assertion = await credentialsApi().get({
|
|
12836
|
-
publicKey: {
|
|
12837
|
-
challenge: randomBytes(32),
|
|
12838
|
-
rpId: config.relyingPartyId(),
|
|
12839
|
-
allowCredentials: [{ type: "public-key", id: decodeBase64(credentialId) }],
|
|
12840
|
-
userVerification: "required",
|
|
12841
|
-
extensions: { prf: { eval: { first: config.prfSalt } } }
|
|
12842
|
-
}
|
|
12843
|
-
});
|
|
12844
|
-
} catch (err) {
|
|
12845
|
-
if (isPasskeyCancellation(err)) throw new PasskeyCancelledError();
|
|
12846
|
-
throw err;
|
|
12847
|
-
}
|
|
12848
|
-
const result = assertion.getClientExtensionResults().prf?.results?.first;
|
|
12849
|
-
if (!result) throw new Error("Passkey PRF unavailable on this device/browser.");
|
|
12850
|
-
return new Uint8Array(result);
|
|
12851
|
-
}
|
|
12852
|
-
async function secretFromRegistration(registration) {
|
|
12853
|
-
if (registration.prfFirst) return new Uint8Array(registration.prfFirst);
|
|
12854
|
-
try {
|
|
12855
|
-
return await prfSecret(registration.credentialId);
|
|
12856
|
-
} catch {
|
|
12857
|
-
throw new Error(prfUnsupportedMessage());
|
|
12858
|
-
}
|
|
12859
|
-
}
|
|
12860
|
-
async function seal(secret, privateKeyHex) {
|
|
12861
|
-
const aes = await deriveAesKey(secret, config.hkdfInfo);
|
|
12862
|
-
const iv = randomBytes(12);
|
|
12863
|
-
const ciphertext = await sealPrivateKey(aes, iv, privateKeyHex);
|
|
12864
|
-
return { iv: encodeBase64(iv), ciphertext: encodeBase64(ciphertext) };
|
|
12865
|
-
}
|
|
12866
|
-
return {
|
|
12867
|
-
async createOwnerKey() {
|
|
12868
|
-
const registration = await registerPasskey();
|
|
12869
|
-
const secret = await secretFromRegistration(registration);
|
|
12870
|
-
const { privateKeyHex, publicKeyHex } = generateStarkKeyPair();
|
|
12871
|
-
const { iv, ciphertext } = await seal(secret, privateKeyHex);
|
|
12872
|
-
return {
|
|
12873
|
-
sealed: {
|
|
12874
|
-
credentialId: registration.credentialId,
|
|
12875
|
-
ownerPubKey: publicKeyHex,
|
|
12876
|
-
address: computeAccountAddress(publicKeyHex, 0),
|
|
12877
|
-
iv,
|
|
12878
|
-
ciphertext
|
|
12879
|
-
},
|
|
12880
|
-
privateKeyHex
|
|
12881
|
-
};
|
|
12882
|
-
},
|
|
12883
|
-
async unlockOwnerKey(sealed) {
|
|
12884
|
-
const secret = await prfSecret(sealed.credentialId);
|
|
12885
|
-
const aes = await deriveAesKey(secret, config.hkdfInfo);
|
|
12886
|
-
return unsealPrivateKey(aes, decodeBase64(sealed.iv), decodeBase64(sealed.ciphertext));
|
|
12887
|
-
},
|
|
12888
|
-
async sealImportedOwnerKey(recovery) {
|
|
12889
|
-
const { privateKeyHex, publicKeyHex } = starkKeyPairFromPrivateKey(recovery.privateKey);
|
|
12890
|
-
const registration = await registerPasskey();
|
|
12891
|
-
const secret = await secretFromRegistration(registration);
|
|
12892
|
-
const { iv, ciphertext } = await seal(secret, privateKeyHex);
|
|
12893
|
-
return {
|
|
12894
|
-
credentialId: registration.credentialId,
|
|
12895
|
-
ownerPubKey: publicKeyHex,
|
|
12896
|
-
address: recovery.walletAddress,
|
|
12897
|
-
iv,
|
|
12898
|
-
ciphertext
|
|
12899
|
-
};
|
|
12900
|
-
}
|
|
12901
|
-
};
|
|
12902
|
-
}
|
|
12903
|
-
|
|
12904
|
-
// src/utils/token.ts
|
|
12905
|
-
function getTokenBySymbol(symbol) {
|
|
12906
|
-
if (typeof symbol !== "string") return void 0;
|
|
12907
|
-
const upper = symbol.toUpperCase();
|
|
12908
|
-
return SUPPORTED_TOKENS.find((t) => t.symbol === upper);
|
|
12909
|
-
}
|
|
12910
|
-
|
|
12911
|
-
// src/wallet/executors.ts
|
|
12912
11020
|
function accountFor(provider, address, privateKeyHex) {
|
|
12913
11021
|
return new Account({ provider, address, signer: privateKeyHex, cairoVersion: "1" });
|
|
12914
11022
|
}
|
|
@@ -13012,7 +11120,7 @@ async function deploySelfFunded(input) {
|
|
|
13012
11120
|
});
|
|
13013
11121
|
return { transactionHash: transaction_hash };
|
|
13014
11122
|
}
|
|
13015
|
-
async function waitUntilDeployed(provider, address, timeoutMs = 9e4,
|
|
11123
|
+
async function waitUntilDeployed(provider, address, timeoutMs = 9e4, sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))) {
|
|
13016
11124
|
const deadline = Date.now() + timeoutMs;
|
|
13017
11125
|
let wait = 1e3;
|
|
13018
11126
|
for (; ; ) {
|
|
@@ -13022,7 +11130,7 @@ async function waitUntilDeployed(provider, address, timeoutMs = 9e4, sleep2 = (m
|
|
|
13022
11130
|
"Your wallet was submitted but has not appeared on Starknet yet. Please try again in a moment."
|
|
13023
11131
|
);
|
|
13024
11132
|
}
|
|
13025
|
-
await
|
|
11133
|
+
await sleep(wait);
|
|
13026
11134
|
wait = Math.min(Math.round(wait * 1.5), 5e3);
|
|
13027
11135
|
}
|
|
13028
11136
|
}
|
|
@@ -13244,6 +11352,6 @@ async function claimSessionWallet(api, walletAddress, deps) {
|
|
|
13244
11352
|
if (removeOwnerGuid) await deps.removeOwner(sealed, removeOwnerGuid);
|
|
13245
11353
|
}
|
|
13246
11354
|
|
|
13247
|
-
export {
|
|
11355
|
+
export { MAX_SUPPLY as COIN_MAX_SUPPLY, MIN_SUPPLY as COIN_MIN_SUPPLY, ClubService, CreatorCoinFactoryABI, CreatorCoinService, DropCollectionABI, DropFactoryABI, DropService, ERC1155CollectionService, FundingTransferNotSentError, IPClubCollectionABI, IPClubFactoryABI, IPCollection1155ABI, IPCollection1155FactoryABI, IPCollectionABI, IPGenesisABI, IPMarketplaceABI, IPNftABI, IPSponsorshipABI, IPTicketCollectionABI, IPTicketCollectionFactoryABI, InvalidPairingPayloadError, InvalidRecoveryKeyError, MAX_HOLDERS_AT_LAUNCH, MAX_TEAM_ALLOCATION_PERCENT, Medialane1155ABI, MedialaneClient, MedialaneError, POPCollectionABI, POPFactoryABI, PopService, SUGGESTED_DEFAULT_PRICE, SponsoredCallRejectedError, SponsorshipService, StarknetVenue, TicketService, VALIDATED_EKUBO_PARAMS, accountFor, adoptSessionWallet, allowsFallbackFunding, assertTransactionSucceeded, build1155CancellationTypedData, build1155OrderTypedData, buildAddOwnerCall, buildCancelEscapeCall, buildCancellationTypedData, buildCompleteEscapeOwnerCall, buildCreateCreatorCoinCall, buildDeployAccountParams, buildFeeCall, buildFundingTransferCall, buildLaunchOnEkuboCalls, buildOrderTypedData, buildRemoveOwnerByGuidCall, buildRemoveOwnerCall, buildSetFirstGuardianCall, buildTriggerEscapeOwnerCall, buybackQuoteRaw, canRemoveDevice, claimSessionWallet, toRaw as coinToRaw, completeDeployment, computeOwnerGuid, confirmIntentBestEffort, createDeploymentCoordinator, createMediaWallet, createOwnerStore, createSelfFundConsent, decodeEscapeAndStatus, decodeGuardiansInfo, deploySelfFunded, deploySponsored, deployedCollectionFromReceipt, deriveOwnerKeyPair, describeDevices, describeGuardianStatus, describeRecoveryAction, encodeByteArray, encodePairingPayload, encodeRecoveryKey, estimateSelfFundedFee, executeIntent, executeIntents, executeSponsored, fdvHuman, fundWithChainTransfer, fundingApiFor, getCounter, getCounter1155, getCreatorCoinGuarantees, getEscape, getEscapeSecurityPeriod, getGuardians, getOrderDetails, getOrderDetails1155, getOwners, getSiwsStorageKey, getStoredSiwsToken, isDeployed, isSiwsTokenValid, isValidStarknetAddress, mintedTokenIdFromReceipt, normalizeSiwsSignature, normalizeWalletAddress, parseAccountAddress, parseCreatorCoinCreated, parsePairingPayload, parseRecoveryKey, priceToEkuboParams, requestSiwsToken, selfFundedExecutor, sponsoredExecutor, storeSiwsToken, syncTransactionBestEffort, teamCoinsRaw, toContractConditions as toDropContractConditions, validateName as validateCoinName, validateSupply as validateCoinSupply, validateSymbol as validateCoinSymbol, validatePrice, waitUntilDeployed };
|
|
13248
11356
|
//# sourceMappingURL=index.js.map
|
|
13249
11357
|
//# sourceMappingURL=index.js.map
|