@medialane/sdk 0.155.0 → 0.156.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/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 -1718
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -1651
- 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 +334 -2212
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.d.cts +167 -302
- package/dist/starknet/index.d.ts +167 -302
- package/dist/starknet/index.js +231 -2133
- 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,1148 +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
|
-
bearer(siwsToken) {
|
|
322
|
-
return { Authorization: `Bearer ${siwsToken}` };
|
|
323
|
-
}
|
|
324
|
-
asSubject(siwsToken) {
|
|
325
|
-
return siwsToken ? this.bearer(siwsToken) : void 0;
|
|
326
|
-
}
|
|
327
|
-
getOrders(query = {}) {
|
|
328
|
-
const params = new URLSearchParams();
|
|
329
|
-
if (query.status) params.set("status", query.status);
|
|
330
|
-
if (query.collection) params.set("collection", query.collection);
|
|
331
|
-
if (query.currency) params.set("currency", query.currency);
|
|
332
|
-
if (query.sort) params.set("sort", query.sort);
|
|
333
|
-
if (query.page !== void 0) params.set("page", String(query.page));
|
|
334
|
-
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
335
|
-
if (query.offerer) params.set("offerer", this.addr(query.offerer));
|
|
336
|
-
if (query.minPrice) params.set("minPrice", query.minPrice);
|
|
337
|
-
if (query.maxPrice) params.set("maxPrice", query.maxPrice);
|
|
338
|
-
if (query.chain) params.set("chain", query.chain);
|
|
339
|
-
const qs = params.toString();
|
|
340
|
-
return this.get(`/v1/orders${qs ? `?${qs}` : ""}`);
|
|
341
|
-
}
|
|
342
|
-
getOrder(orderHash) {
|
|
343
|
-
return this.get(`/v1/orders/${orderHash}`);
|
|
344
|
-
}
|
|
345
|
-
getActiveOrdersForToken(contract, tokenId) {
|
|
346
|
-
return this.get(`/v1/orders/token/${this.addr(contract)}/${tokenId}`);
|
|
347
|
-
}
|
|
348
|
-
getReceivedOffers(address, opts = {}) {
|
|
349
|
-
const params = new URLSearchParams({ page: String(opts.page ?? 1), limit: String(opts.limit ?? 50) });
|
|
350
|
-
return this.get(`/v1/orders/received/${this.addr(address)}?${params}`);
|
|
351
|
-
}
|
|
352
|
-
getOrdersByUser(address, page = 1, limit = 20) {
|
|
353
|
-
return this.get(
|
|
354
|
-
`/v1/orders/user/${this.addr(address)}?page=${page}&limit=${limit}`
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
getToken(contract, tokenId, wait = false) {
|
|
358
|
-
return this.get(
|
|
359
|
-
`/v1/tokens/${contract}/${tokenId}${wait ? "?wait=true" : ""}`
|
|
360
|
-
);
|
|
361
|
-
}
|
|
362
|
-
getTokensByOwner(address, page = 1, limit = 20) {
|
|
363
|
-
return this.get(
|
|
364
|
-
`/v1/tokens/owned/${this.addr(address)}?page=${page}&limit=${limit}`
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
getTokenHistory(contract, tokenId, page = 1, limit = 20) {
|
|
368
|
-
return this.get(
|
|
369
|
-
`/v1/tokens/${contract}/${tokenId}/history?page=${page}&limit=${limit}`
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
getCollection(contract) {
|
|
373
|
-
return this.get(`/v1/collections/${this.addr(contract)}`);
|
|
374
|
-
}
|
|
375
|
-
getCollectionTokens(contract, page = 1, limit = 20, sort = "recent") {
|
|
376
|
-
return this.get(
|
|
377
|
-
`/v1/collections/${this.addr(contract)}/tokens?page=${page}&limit=${limit}&sort=${sort}`
|
|
378
|
-
);
|
|
379
|
-
}
|
|
380
|
-
getActivities(query = {}) {
|
|
381
|
-
const params = new URLSearchParams();
|
|
382
|
-
if (query.type) params.set("type", query.type);
|
|
383
|
-
if (query.contract) params.set("contract", query.contract);
|
|
384
|
-
if (query.page !== void 0) params.set("page", String(query.page));
|
|
385
|
-
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
386
|
-
if (query.chain) params.set("chain", query.chain);
|
|
387
|
-
const qs = params.toString();
|
|
388
|
-
return this.get(`/v1/activities${qs ? `?${qs}` : ""}`);
|
|
389
|
-
}
|
|
390
|
-
getActivitiesByAddress(address, page = 1, limit = 20) {
|
|
391
|
-
return this.get(
|
|
392
|
-
`/v1/activities/${this.addr(address)}?page=${page}&limit=${limit}`
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
getTokenComments(contract, tokenId, opts = {}) {
|
|
396
|
-
const params = new URLSearchParams();
|
|
397
|
-
if (opts.page !== void 0) params.set("page", String(opts.page));
|
|
398
|
-
if (opts.limit !== void 0) params.set("limit", String(opts.limit));
|
|
399
|
-
const qs = params.toString();
|
|
400
|
-
return this.get(
|
|
401
|
-
`/v1/tokens/${this.addr(contract)}/${tokenId}/comments${qs ? `?${qs}` : ""}`
|
|
402
|
-
);
|
|
403
|
-
}
|
|
404
|
-
search(q, limit = 10, chain) {
|
|
405
|
-
const params = new URLSearchParams({ q, limit: String(limit) });
|
|
406
|
-
if (chain) params.set("chain", chain);
|
|
407
|
-
return this.get(
|
|
408
|
-
`/v1/search?${params.toString()}`
|
|
409
|
-
);
|
|
410
|
-
}
|
|
411
|
-
createListingIntent(params) {
|
|
412
|
-
return this.post("/v1/intents/listing", params);
|
|
413
|
-
}
|
|
414
|
-
createOfferIntent(params) {
|
|
415
|
-
return this.post("/v1/intents/offer", params);
|
|
416
|
-
}
|
|
417
|
-
createFulfillIntent(params) {
|
|
418
|
-
return this.post("/v1/intents/fulfill", params);
|
|
419
|
-
}
|
|
420
|
-
createCancelIntent(params) {
|
|
421
|
-
return this.post("/v1/intents/cancel", params);
|
|
422
|
-
}
|
|
423
|
-
createCheckoutIntent(params) {
|
|
424
|
-
return this.post("/v1/intents/checkout", params);
|
|
425
|
-
}
|
|
426
|
-
getIntent(id) {
|
|
427
|
-
return this.get(`/v1/intents/${id}`);
|
|
428
|
-
}
|
|
429
|
-
submitIntentSignature(id, signature) {
|
|
430
|
-
return this.patch(`/v1/intents/${id}/signature`, { signature });
|
|
431
|
-
}
|
|
432
|
-
confirmIntent(id, txHash) {
|
|
433
|
-
return this.patch(`/v1/intents/${id}/confirm`, { txHash });
|
|
434
|
-
}
|
|
435
|
-
syncTransaction(txHash) {
|
|
436
|
-
return this.post("/v1/tx/sync", { txHash });
|
|
437
|
-
}
|
|
438
|
-
createMintIntent(params) {
|
|
439
|
-
return this.post("/v1/intents/mint", params);
|
|
440
|
-
}
|
|
441
|
-
createCollectionIntent(params) {
|
|
442
|
-
return this.post("/v1/intents/create-collection", params);
|
|
443
|
-
}
|
|
444
|
-
createTierIntent(params) {
|
|
445
|
-
return this.post("/v1/intents/create-tier", params);
|
|
446
|
-
}
|
|
447
|
-
emitToRecipients(params) {
|
|
448
|
-
return this.post("/v1/business/issuance/emission", params);
|
|
449
|
-
}
|
|
450
|
-
createCoinIntent(params) {
|
|
451
|
-
return this.post("/v1/intents/create-coin", params);
|
|
452
|
-
}
|
|
453
|
-
launchCoinIntent(params) {
|
|
454
|
-
return this.post("/v1/intents/launch-coin", params);
|
|
455
|
-
}
|
|
456
|
-
createSponsorshipOfferIntent(params) {
|
|
457
|
-
return this.post("/v1/intents/sponsorship-offer", params);
|
|
458
|
-
}
|
|
459
|
-
setSponsorshipOfferOpenIntent(params) {
|
|
460
|
-
return this.post("/v1/intents/sponsorship-offer-open", params);
|
|
461
|
-
}
|
|
462
|
-
placeSponsorshipBidIntent(params) {
|
|
463
|
-
return this.post("/v1/intents/sponsorship-bid", params);
|
|
464
|
-
}
|
|
465
|
-
retractSponsorshipBidIntent(params) {
|
|
466
|
-
return this.post("/v1/intents/sponsorship-bid-retract", params);
|
|
467
|
-
}
|
|
468
|
-
acceptSponsorshipBidIntent(params) {
|
|
469
|
-
return this.post("/v1/intents/sponsorship-bid-accept", params);
|
|
470
|
-
}
|
|
471
|
-
createSponsorshipProposalIntent(params) {
|
|
472
|
-
return this.post("/v1/intents/sponsorship-proposal", params);
|
|
473
|
-
}
|
|
474
|
-
withdrawSponsorshipProposalIntent(params) {
|
|
475
|
-
return this.post("/v1/intents/sponsorship-proposal-withdraw", params);
|
|
476
|
-
}
|
|
477
|
-
acceptSponsorshipProposalIntent(params) {
|
|
478
|
-
return this.post("/v1/intents/sponsorship-proposal-accept", params);
|
|
479
|
-
}
|
|
480
|
-
rejectSponsorshipProposalIntent(params) {
|
|
481
|
-
return this.post("/v1/intents/sponsorship-proposal-reject", params);
|
|
482
|
-
}
|
|
483
|
-
createCounterOfferIntent(params, siwsToken) {
|
|
484
|
-
const extraHeaders = siwsToken ? { "Authorization": `Bearer ${siwsToken}` } : {};
|
|
485
|
-
return this.request("/v1/intents/counter-offer", {
|
|
486
|
-
method: "POST",
|
|
487
|
-
body: JSON.stringify(params),
|
|
488
|
-
headers: extraHeaders
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
getCounterOffers(query) {
|
|
492
|
-
const params = new URLSearchParams();
|
|
493
|
-
if (query.originalOrderHash) params.set("originalOrderHash", query.originalOrderHash);
|
|
494
|
-
if (query.sellerAddress) params.set("sellerAddress", query.sellerAddress);
|
|
495
|
-
if (query.page !== void 0) params.set("page", String(query.page));
|
|
496
|
-
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
497
|
-
return this.get(`/v1/orders/counter-offers?${params}`);
|
|
498
|
-
}
|
|
499
|
-
getMetadataSignedUrl(kind) {
|
|
500
|
-
const params = kind ? `?kind=${kind}` : "";
|
|
501
|
-
return this.get(`/v1/metadata/signed-url${params}`);
|
|
502
|
-
}
|
|
503
|
-
uploadMetadata(metadata) {
|
|
504
|
-
return this.post("/v1/metadata/upload", metadata);
|
|
505
|
-
}
|
|
506
|
-
async uploadMetadataDirectory(files) {
|
|
507
|
-
const res = await this.post("/v1/metadata/upload-directory", { files });
|
|
508
|
-
return res.data;
|
|
509
|
-
}
|
|
510
|
-
resolveMetadata(uri) {
|
|
511
|
-
const params = new URLSearchParams({ uri });
|
|
512
|
-
return this.get(`/v1/metadata/resolve?${params.toString()}`);
|
|
513
|
-
}
|
|
514
|
-
uploadFile(file) {
|
|
515
|
-
const formData = new FormData();
|
|
516
|
-
formData.append("file", file);
|
|
517
|
-
return this.request("/v1/metadata/upload-file", {
|
|
518
|
-
method: "POST",
|
|
519
|
-
body: formData
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
getMe(siwsToken) {
|
|
523
|
-
return this.request("/v1/portal/me", {
|
|
524
|
-
method: "GET",
|
|
525
|
-
headers: this.asSubject(siwsToken)
|
|
526
|
-
});
|
|
527
|
-
}
|
|
528
|
-
getApiKeys(siwsToken) {
|
|
529
|
-
return this.request("/v1/portal/keys", {
|
|
530
|
-
method: "GET",
|
|
531
|
-
headers: this.asSubject(siwsToken)
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
createApiKey(input, siwsToken) {
|
|
535
|
-
return this.request("/v1/portal/keys", {
|
|
536
|
-
method: "POST",
|
|
537
|
-
body: JSON.stringify(input ?? {}),
|
|
538
|
-
headers: this.asSubject(siwsToken)
|
|
539
|
-
});
|
|
540
|
-
}
|
|
541
|
-
deleteApiKey(id, siwsToken) {
|
|
542
|
-
return this.request(`/v1/portal/keys/${id}`, {
|
|
543
|
-
method: "DELETE",
|
|
544
|
-
headers: this.asSubject(siwsToken)
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
getCreditHistory(siwsToken) {
|
|
548
|
-
return this.request("/v1/portal/credits/history", {
|
|
549
|
-
method: "GET",
|
|
550
|
-
headers: this.asSubject(siwsToken)
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
getSpend(siwsToken) {
|
|
554
|
-
return this.request("/v1/portal/credits/spend", {
|
|
555
|
-
method: "GET",
|
|
556
|
-
headers: this.asSubject(siwsToken)
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
checkDeposit(txHash, siwsToken) {
|
|
560
|
-
return this.request("/v1/portal/credits/check", {
|
|
561
|
-
method: "POST",
|
|
562
|
-
body: JSON.stringify({ txHash }),
|
|
563
|
-
headers: this.asSubject(siwsToken)
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
getFundingMethods(siwsToken) {
|
|
567
|
-
return this.request("/v1/portal/funding/methods", {
|
|
568
|
-
method: "GET",
|
|
569
|
-
headers: this.asSubject(siwsToken)
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
createFunding(input, siwsToken) {
|
|
573
|
-
return this.request("/v1/portal/funding", {
|
|
574
|
-
method: "POST",
|
|
575
|
-
body: JSON.stringify({ method: input.method, params: input.params }),
|
|
576
|
-
headers: this.asSubject(siwsToken)
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
getFunding(id, siwsToken) {
|
|
580
|
-
return this.request(`/v1/portal/funding/${encodeURIComponent(id)}`, {
|
|
581
|
-
method: "GET",
|
|
582
|
-
headers: this.asSubject(siwsToken)
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
getFundingChallenge(id, payer, siwsToken) {
|
|
586
|
-
return this.request(`/v1/portal/funding/${encodeURIComponent(id)}/challenge`, {
|
|
587
|
-
method: "POST",
|
|
588
|
-
body: JSON.stringify({ payer }),
|
|
589
|
-
headers: this.asSubject(siwsToken)
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
authorizeFunding(id, input, siwsToken) {
|
|
593
|
-
return this.request(
|
|
594
|
-
`/v1/portal/funding/${encodeURIComponent(id)}/authorize`,
|
|
595
|
-
{ method: "POST", body: JSON.stringify({ payer: input.payer, signature: input.signature }), headers: this.asSubject(siwsToken) }
|
|
596
|
-
);
|
|
597
|
-
}
|
|
598
|
-
submitFunding(id, txHash, siwsToken) {
|
|
599
|
-
return this.request(`/v1/portal/funding/${encodeURIComponent(id)}/submit`, {
|
|
600
|
-
method: "POST",
|
|
601
|
-
body: JSON.stringify({ txHash }),
|
|
602
|
-
headers: this.asSubject(siwsToken)
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
cancelFunding(id, siwsToken) {
|
|
606
|
-
return this.request(`/v1/portal/funding/${encodeURIComponent(id)}/cancel`, {
|
|
607
|
-
method: "POST",
|
|
608
|
-
body: JSON.stringify({}),
|
|
609
|
-
headers: this.asSubject(siwsToken)
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
async claimCollection(contractAddress, walletAddress, siwsToken) {
|
|
613
|
-
return this.request("/v1/collections/claim", {
|
|
614
|
-
method: "POST",
|
|
615
|
-
body: JSON.stringify({ contractAddress, walletAddress }),
|
|
616
|
-
headers: this.bearer(siwsToken)
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
requestCollectionClaim(params) {
|
|
620
|
-
return this.request("/v1/collections/claim/request", {
|
|
621
|
-
method: "POST",
|
|
622
|
-
body: JSON.stringify(params)
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
registerBusinessProvisioning(params) {
|
|
626
|
-
return this.post(
|
|
627
|
-
"/v1/business/provisioning",
|
|
628
|
-
{ chain: params.chain ?? "STARKNET", email: params.email }
|
|
629
|
-
);
|
|
630
|
-
}
|
|
631
|
-
getCollectionProfile(contractAddress) {
|
|
632
|
-
return this.request(
|
|
633
|
-
`/v1/collections/${this.addr(contractAddress)}/profile`,
|
|
634
|
-
{ method: "GET" },
|
|
635
|
-
{ allow404: true }
|
|
636
|
-
);
|
|
637
|
-
}
|
|
638
|
-
updateCollectionProfile(contractAddress, data, siwsToken) {
|
|
639
|
-
return this.request(
|
|
640
|
-
`/v1/collections/${this.addr(contractAddress)}/profile`,
|
|
641
|
-
{ method: "PATCH", body: JSON.stringify(data), headers: this.bearer(siwsToken) }
|
|
642
|
-
);
|
|
643
|
-
}
|
|
644
|
-
getWalletActivity(address, chain = "STARKNET") {
|
|
645
|
-
return this.get(
|
|
646
|
-
`/v1/wallet-activity?address=${this.addr(address)}&chain=${chain}`
|
|
647
|
-
);
|
|
648
|
-
}
|
|
649
|
-
getGatedContent(contractAddress, siwsToken) {
|
|
650
|
-
return this.request(
|
|
651
|
-
`/v1/collections/${this.addr(contractAddress)}/gated-content`,
|
|
652
|
-
{ method: "GET", headers: this.bearer(siwsToken) },
|
|
653
|
-
{ allow404: true, allow403: true }
|
|
654
|
-
);
|
|
655
|
-
}
|
|
656
|
-
getCreators(opts = {}) {
|
|
657
|
-
const params = new URLSearchParams();
|
|
658
|
-
if (opts.search) params.set("search", opts.search);
|
|
659
|
-
if (opts.page) params.set("page", String(opts.page));
|
|
660
|
-
if (opts.limit) params.set("limit", String(opts.limit));
|
|
661
|
-
const qs = params.toString();
|
|
662
|
-
return this.get(`/v1/creators${qs ? `?${qs}` : ""}`);
|
|
663
|
-
}
|
|
664
|
-
getCreatorProfile(walletAddress) {
|
|
665
|
-
return this.request(
|
|
666
|
-
`/v1/creators/${this.addr(walletAddress)}/profile`,
|
|
667
|
-
{ method: "GET" },
|
|
668
|
-
{ allow404: true }
|
|
669
|
-
);
|
|
670
|
-
}
|
|
671
|
-
getCreatorByUsername(username) {
|
|
672
|
-
return this.request(
|
|
673
|
-
`/v1/creators/by-username/${encodeURIComponent(username.toLowerCase().trim())}`,
|
|
674
|
-
{ method: "GET" },
|
|
675
|
-
{ allow404: true }
|
|
676
|
-
);
|
|
677
|
-
}
|
|
678
|
-
updateCreatorProfile(walletAddress, data, siwsToken) {
|
|
679
|
-
return this.request(
|
|
680
|
-
`/v1/creators/${this.addr(walletAddress)}/profile`,
|
|
681
|
-
{ method: "PATCH", body: JSON.stringify(data), headers: this.bearer(siwsToken) }
|
|
682
|
-
);
|
|
683
|
-
}
|
|
684
|
-
checkCollectionSlugAvailability(slug) {
|
|
685
|
-
return this.get(
|
|
686
|
-
`/v1/collection-slug-claims/check/${encodeURIComponent(slug.toLowerCase().trim())}`
|
|
687
|
-
);
|
|
688
|
-
}
|
|
689
|
-
submitCollectionSlugClaim(contractAddress, slug, siwsToken, notifyEmail) {
|
|
690
|
-
return this.request("/v1/collection-slug-claims", {
|
|
691
|
-
method: "POST",
|
|
692
|
-
body: JSON.stringify({ contractAddress, slug, notifyEmail }),
|
|
693
|
-
headers: this.bearer(siwsToken)
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
getMyCollectionSlugClaims(siwsToken) {
|
|
697
|
-
return this.request("/v1/collection-slug-claims/me", {
|
|
698
|
-
method: "GET",
|
|
699
|
-
headers: this.bearer(siwsToken)
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
async getCollectionBySlug(slug) {
|
|
703
|
-
const res = await this.request(
|
|
704
|
-
`/v1/collections/by-slug/${encodeURIComponent(slug.toLowerCase().trim())}`,
|
|
705
|
-
{ method: "GET" },
|
|
706
|
-
{ allow404: true }
|
|
707
|
-
);
|
|
708
|
-
return res?.data ?? null;
|
|
709
|
-
}
|
|
710
|
-
async registerUser(params) {
|
|
711
|
-
return this.post("/v1/users/register", params);
|
|
712
|
-
}
|
|
713
|
-
async upsertMyWallet(siwsToken, options = {}) {
|
|
714
|
-
const body = {
|
|
715
|
-
walletType: options.walletType ?? "UNKNOWN"
|
|
716
|
-
};
|
|
717
|
-
if (options.chain) body.chain = options.chain;
|
|
718
|
-
if (options.email) body.email = options.email;
|
|
719
|
-
if (options.accountToken) body.accountToken = options.accountToken;
|
|
720
|
-
return this.request("/v1/users/me", {
|
|
721
|
-
method: "POST",
|
|
722
|
-
body: JSON.stringify(body),
|
|
723
|
-
headers: this.bearer(siwsToken)
|
|
724
|
-
});
|
|
725
|
-
}
|
|
726
|
-
async checkEmail(email) {
|
|
727
|
-
const body = await this.get(`/v1/auth/email/exists?email=${encodeURIComponent(email)}`);
|
|
728
|
-
return { exists: body.exists };
|
|
729
|
-
}
|
|
730
|
-
async requestEmailCode(email) {
|
|
731
|
-
await this.post("/v1/auth/email/request-code", { email });
|
|
732
|
-
}
|
|
733
|
-
async registerEmailAccount(email) {
|
|
734
|
-
await this.post("/v1/auth/email/register-account", { email });
|
|
735
|
-
}
|
|
736
|
-
async verifyEmailCode(email, code) {
|
|
737
|
-
await this.post("/v1/auth/email/verify-code", { email, code });
|
|
738
|
-
}
|
|
739
|
-
async confirmEmail(token) {
|
|
740
|
-
const body = await this.post("/v1/auth/email/confirm", { token });
|
|
741
|
-
return { email: body.email };
|
|
742
|
-
}
|
|
743
|
-
setupWalletKey(params) {
|
|
744
|
-
return this.post("/v1/users/me/wallet/key", params);
|
|
745
|
-
}
|
|
746
|
-
async getSessionWallet() {
|
|
747
|
-
const body = await this.post("/v1/users/me/wallet", {});
|
|
748
|
-
return body.walletAddress ? { walletAddress: body.walletAddress, needsKeySetup: body.needsKeySetup === true } : null;
|
|
749
|
-
}
|
|
750
|
-
getMyWallet(siwsToken) {
|
|
751
|
-
return this.request(
|
|
752
|
-
"/v1/users/me",
|
|
753
|
-
{ method: "GET", headers: this.bearer(siwsToken) },
|
|
754
|
-
{ allow404: true }
|
|
755
|
-
);
|
|
756
|
-
}
|
|
757
|
-
changeMyEmail(email, siwsToken) {
|
|
758
|
-
return this.request("/v1/users/me/email", {
|
|
759
|
-
method: "POST",
|
|
760
|
-
headers: this.bearer(siwsToken),
|
|
761
|
-
body: JSON.stringify({ email })
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
|
-
getTokenRemixes(contract, tokenId, opts = {}) {
|
|
765
|
-
const params = new URLSearchParams();
|
|
766
|
-
if (opts.page !== void 0) params.set("page", String(opts.page));
|
|
767
|
-
if (opts.limit !== void 0) params.set("limit", String(opts.limit));
|
|
768
|
-
const qs = params.toString();
|
|
769
|
-
return this.get(
|
|
770
|
-
`/v1/tokens/${this.addr(contract)}/${tokenId}/remixes${qs ? `?${qs}` : ""}`
|
|
771
|
-
);
|
|
772
|
-
}
|
|
773
|
-
submitRemixOffer(params, siwsToken) {
|
|
774
|
-
return this.request("/v1/remix-offers", {
|
|
775
|
-
method: "POST",
|
|
776
|
-
body: JSON.stringify(params),
|
|
777
|
-
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
submitAutoRemixOffer(params, siwsToken) {
|
|
781
|
-
return this.request("/v1/remix-offers/auto", {
|
|
782
|
-
method: "POST",
|
|
783
|
-
body: JSON.stringify(params),
|
|
784
|
-
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
confirmSelfRemix(params, siwsToken) {
|
|
788
|
-
return this.request("/v1/remix-offers/self/confirm", {
|
|
789
|
-
method: "POST",
|
|
790
|
-
body: JSON.stringify(params),
|
|
791
|
-
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
792
|
-
});
|
|
793
|
-
}
|
|
794
|
-
getRemixOffers(query, siwsToken) {
|
|
795
|
-
const params = new URLSearchParams({ role: query.role });
|
|
796
|
-
if (query.status) params.set("status", query.status);
|
|
797
|
-
if (query.page !== void 0) params.set("page", String(query.page));
|
|
798
|
-
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
799
|
-
return this.request(`/v1/remix-offers?${params}`, {
|
|
800
|
-
method: "GET",
|
|
801
|
-
headers: this.bearer(siwsToken)
|
|
802
|
-
});
|
|
803
|
-
}
|
|
804
|
-
getRemixOffer(id, siwsToken) {
|
|
805
|
-
return this.request(`/v1/remix-offers/${id}`, {
|
|
806
|
-
method: "GET",
|
|
807
|
-
headers: siwsToken ? this.bearer(siwsToken) : void 0
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
confirmRemixOffer(id, params, siwsToken) {
|
|
811
|
-
return this.request(`/v1/remix-offers/${id}/confirm`, {
|
|
812
|
-
method: "POST",
|
|
813
|
-
body: JSON.stringify(params),
|
|
814
|
-
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
|
-
rejectRemixOffer(id, siwsToken) {
|
|
818
|
-
return this.request(`/v1/remix-offers/${id}/reject`, {
|
|
819
|
-
method: "POST",
|
|
820
|
-
body: JSON.stringify({}),
|
|
821
|
-
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
extendRemixOffer(id, days, siwsToken) {
|
|
825
|
-
return this.request(`/v1/remix-offers/${id}/extend`, {
|
|
826
|
-
method: "POST",
|
|
827
|
-
body: JSON.stringify({ days }),
|
|
828
|
-
headers: { "Authorization": `Bearer ${siwsToken}` }
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
async getPopEligibility(collection, wallet) {
|
|
832
|
-
const res = await this.get(
|
|
833
|
-
`/v1/pop/eligibility/${this.addr(collection)}/${this.addr(wallet)}`
|
|
834
|
-
);
|
|
835
|
-
return res.data;
|
|
836
|
-
}
|
|
837
|
-
async getPopEligibilityBatch(collection, wallets) {
|
|
838
|
-
const params = new URLSearchParams({ wallets: wallets.map((w) => this.addr(w)).join(",") });
|
|
839
|
-
const res = await this.get(
|
|
840
|
-
`/v1/pop/eligibility/${this.addr(collection)}?${params}`
|
|
841
|
-
);
|
|
842
|
-
return res.data;
|
|
843
|
-
}
|
|
844
|
-
getCoins(opts = {}) {
|
|
845
|
-
const params = new URLSearchParams();
|
|
846
|
-
if (opts.page) params.set("page", String(opts.page));
|
|
847
|
-
if (opts.limit) params.set("limit", String(opts.limit));
|
|
848
|
-
if (opts.service) params.set("service", opts.service);
|
|
849
|
-
if (opts.sort) params.set("sort", opts.sort);
|
|
850
|
-
if (opts.creator) params.set("creator", this.addr(opts.creator));
|
|
851
|
-
if (opts.chain) params.set("chain", opts.chain);
|
|
852
|
-
const qs = params.toString();
|
|
853
|
-
return this.get(`/v1/coins${qs ? `?${qs}` : ""}`);
|
|
854
|
-
}
|
|
855
|
-
getCoin(contract) {
|
|
856
|
-
return this.get(`/v1/coins/${this.addr(contract)}`);
|
|
857
|
-
}
|
|
858
|
-
getCoinPrices() {
|
|
859
|
-
return this.get("/v1/coins/prices");
|
|
860
|
-
}
|
|
861
|
-
claimCoin(coinAddress, siwsToken) {
|
|
862
|
-
return this.request("/v1/coins/claim", {
|
|
863
|
-
method: "POST",
|
|
864
|
-
headers: { Authorization: `Bearer ${siwsToken}` },
|
|
865
|
-
body: JSON.stringify({ coinAddress })
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
getCoinClaims(status = "PENDING") {
|
|
869
|
-
return this.get(
|
|
870
|
-
`/v1/coins/claims?status=${encodeURIComponent(status)}`
|
|
871
|
-
);
|
|
872
|
-
}
|
|
873
|
-
updateCoinProfile(contract, data, siwsToken) {
|
|
874
|
-
return this.request(`/v1/coins/${this.addr(contract)}`, {
|
|
875
|
-
method: "PATCH",
|
|
876
|
-
body: JSON.stringify(data),
|
|
877
|
-
headers: this.bearer(siwsToken)
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
async getDropMintStatus(collection, wallet) {
|
|
881
|
-
const res = await this.get(
|
|
882
|
-
`/v1/drop/mint-status/${this.addr(collection)}/${this.addr(wallet)}`
|
|
883
|
-
);
|
|
884
|
-
return res.data;
|
|
885
|
-
}
|
|
886
|
-
async getDropInfo(contract) {
|
|
887
|
-
const res = await this.request(
|
|
888
|
-
`/v1/drop/${this.addr(contract)}/info`,
|
|
889
|
-
{ method: "GET" },
|
|
890
|
-
{ allow404: true }
|
|
891
|
-
);
|
|
892
|
-
return res?.data ?? null;
|
|
893
|
-
}
|
|
894
|
-
async getDropState(contract) {
|
|
895
|
-
const res = await this.get(`/v1/drop/${this.addr(contract)}/state`);
|
|
896
|
-
return res.data;
|
|
897
|
-
}
|
|
898
|
-
async getTicket(contract, tokenId) {
|
|
899
|
-
const res = await this.get(`/v1/tickets/${this.addr(contract)}/${tokenId}`);
|
|
900
|
-
return res.data;
|
|
901
|
-
}
|
|
902
|
-
async getTicketCount(contract) {
|
|
903
|
-
const res = await this.get(`/v1/tickets/${this.addr(contract)}/count`);
|
|
904
|
-
return res.data.count;
|
|
905
|
-
}
|
|
906
|
-
async getClubMembershipCount(contract) {
|
|
907
|
-
const res = await this.get(`/v1/club/${this.addr(contract)}/count`);
|
|
908
|
-
return res.data.count;
|
|
909
|
-
}
|
|
910
|
-
async getClubMembership(contract, tokenId) {
|
|
911
|
-
const res = await this.get(`/v1/club/${this.addr(contract)}/${tokenId}`);
|
|
912
|
-
return res.data;
|
|
913
|
-
}
|
|
914
|
-
async isClubMember(contract, tokenId, wallet) {
|
|
915
|
-
const res = await this.get(
|
|
916
|
-
`/v1/club/${this.addr(contract)}/${tokenId}/member/${this.addr(wallet)}`
|
|
917
|
-
);
|
|
918
|
-
return res.data.isMember;
|
|
919
|
-
}
|
|
920
|
-
async getIpNftTokenData(contract, tokenId) {
|
|
921
|
-
const res = await this.get(`/v1/ipnft/${this.addr(contract)}/${tokenId}`);
|
|
922
|
-
return res.data;
|
|
923
|
-
}
|
|
924
|
-
async getPlatformStats() {
|
|
925
|
-
const res = await this.get("/v1/stats");
|
|
926
|
-
return res.data;
|
|
927
|
-
}
|
|
928
|
-
getTokens(query = {}) {
|
|
929
|
-
const params = new URLSearchParams();
|
|
930
|
-
if (query.page !== void 0) params.set("page", String(query.page));
|
|
931
|
-
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
932
|
-
if (query.sort) params.set("sort", query.sort);
|
|
933
|
-
if (query.ipType) params.set("ipType", query.ipType);
|
|
934
|
-
if (query.derivatives) params.set("derivatives", query.derivatives);
|
|
935
|
-
const qs = params.toString();
|
|
936
|
-
return this.get(`/v1/tokens${qs ? `?${qs}` : ""}`);
|
|
937
|
-
}
|
|
938
|
-
async isCreatorHidden(wallet) {
|
|
939
|
-
const res = await this.get(`/v1/creators/${this.addr(wallet)}/hidden`);
|
|
940
|
-
return res.isHidden;
|
|
941
|
-
}
|
|
942
|
-
getMyUsernameClaim(siwsToken) {
|
|
943
|
-
return this.request("/v1/username-claims/me", {
|
|
944
|
-
method: "GET",
|
|
945
|
-
headers: this.bearer(siwsToken)
|
|
946
|
-
});
|
|
947
|
-
}
|
|
948
|
-
checkUsernameAvailability(username) {
|
|
949
|
-
return this.get(
|
|
950
|
-
`/v1/username-claims/check/${encodeURIComponent(username)}`
|
|
951
|
-
);
|
|
952
|
-
}
|
|
953
|
-
async submitUsernameClaim(username, siwsToken, notifyEmail) {
|
|
954
|
-
const res = await this.request("/v1/username-claims", {
|
|
955
|
-
method: "POST",
|
|
956
|
-
headers: this.bearer(siwsToken),
|
|
957
|
-
body: JSON.stringify({ username, ...notifyEmail ? { notifyEmail } : {} })
|
|
958
|
-
});
|
|
959
|
-
return res.claim;
|
|
960
|
-
}
|
|
961
|
-
async submitReport(report, siwsToken) {
|
|
962
|
-
const targetContract = report.targetContract ? this.addr(report.targetContract) : void 0;
|
|
963
|
-
const targetAddress = report.targetAddress ? this.addr(report.targetAddress) : void 0;
|
|
964
|
-
let targetKey = null;
|
|
965
|
-
if (report.targetType === "TOKEN" && targetContract && report.targetTokenId) {
|
|
966
|
-
targetKey = `TOKEN:${targetContract}:${report.targetTokenId}`;
|
|
967
|
-
} else if (report.targetType === "COLLECTION" && targetContract) {
|
|
968
|
-
targetKey = `COLLECTION:${targetContract}`;
|
|
969
|
-
} else if (report.targetType === "CREATOR" && targetAddress) {
|
|
970
|
-
targetKey = `CREATOR:${targetAddress}`;
|
|
971
|
-
} else if (report.targetType === "COMMENT" && report.targetId) {
|
|
972
|
-
targetKey = `COMMENT::${report.targetId}`;
|
|
973
|
-
}
|
|
974
|
-
if (!targetKey) throw new Error(`A ${report.targetType} report needs its target`);
|
|
975
|
-
await this.request("/v1/reports", {
|
|
976
|
-
method: "POST",
|
|
977
|
-
headers: this.bearer(siwsToken),
|
|
978
|
-
body: JSON.stringify({ ...report, targetKey, targetContract, targetAddress })
|
|
979
|
-
});
|
|
980
|
-
}
|
|
981
|
-
getPricing() {
|
|
982
|
-
return this.get("/v1/pricing");
|
|
983
|
-
}
|
|
984
|
-
listCollections(query = {}) {
|
|
985
|
-
const params = new URLSearchParams();
|
|
986
|
-
if (query.page !== void 0) params.set("page", String(query.page));
|
|
987
|
-
if (query.limit !== void 0) params.set("limit", String(query.limit));
|
|
988
|
-
if (query.owner) params.set("owner", this.addr(query.owner));
|
|
989
|
-
if (query.service) params.set("service", query.service);
|
|
990
|
-
if (query.sort) params.set("sort", query.sort);
|
|
991
|
-
if (query.isFeatured !== void 0) params.set("isFeatured", String(query.isFeatured));
|
|
992
|
-
if (query.hideEmpty !== void 0) params.set("hideEmpty", String(query.hideEmpty));
|
|
993
|
-
if (query.standard) params.set("standard", query.standard);
|
|
994
|
-
if (query.chain) params.set("chain", query.chain);
|
|
995
|
-
const qs = params.toString();
|
|
996
|
-
return this.get(`/v1/collections${qs ? `?${qs}` : ""}`);
|
|
997
|
-
}
|
|
998
|
-
generateWallet(newWalletSiwsToken, siwsToken) {
|
|
999
|
-
return this.request("/v1/users/me/generate-wallet", {
|
|
1000
|
-
method: "POST",
|
|
1001
|
-
headers: this.bearer(siwsToken),
|
|
1002
|
-
body: JSON.stringify({ newWalletSiwsToken })
|
|
1003
|
-
});
|
|
1004
|
-
}
|
|
1005
|
-
syncCoin(coinAddress, owner) {
|
|
1006
|
-
return this.post("/v1/coins/sync", { coinAddress, ...owner ? { owner } : {} });
|
|
1007
|
-
}
|
|
1008
|
-
registerCollection(contractAddress) {
|
|
1009
|
-
return this.post("/v1/collections/register", { contractAddress });
|
|
1010
|
-
}
|
|
1011
|
-
getSponsorshipOffers(query = {}) {
|
|
1012
|
-
const params = new URLSearchParams({ limit: String(query.limit ?? 50) });
|
|
1013
|
-
if (query.nftContract) params.set("nftContract", query.nftContract);
|
|
1014
|
-
if (query.author) params.set("author", query.author);
|
|
1015
|
-
if (query.owner) params.set("owner", query.owner);
|
|
1016
|
-
if (query.open !== void 0) params.set("open", String(query.open));
|
|
1017
|
-
return this.get(`/v1/sponsorship/offers?${params}`);
|
|
1018
|
-
}
|
|
1019
|
-
async getSponsorshipOffer(offerId) {
|
|
1020
|
-
const res = await this.request(
|
|
1021
|
-
`/v1/sponsorship/offers/${encodeURIComponent(offerId)}`,
|
|
1022
|
-
{ method: "GET" },
|
|
1023
|
-
{ allow404: true }
|
|
1024
|
-
);
|
|
1025
|
-
return res?.data ?? null;
|
|
1026
|
-
}
|
|
1027
|
-
async getSponsorshipProposal(proposalId) {
|
|
1028
|
-
const res = await this.request(
|
|
1029
|
-
`/v1/sponsorship/proposals/${encodeURIComponent(proposalId)}`,
|
|
1030
|
-
{ method: "GET" },
|
|
1031
|
-
{ allow404: true }
|
|
1032
|
-
);
|
|
1033
|
-
return res?.data ?? null;
|
|
1034
|
-
}
|
|
1035
|
-
async getSponsorshipBids(offerId) {
|
|
1036
|
-
const res = await this.get(`/v1/sponsorship/offers/${encodeURIComponent(offerId)}/bids`);
|
|
1037
|
-
return res.data;
|
|
1038
|
-
}
|
|
1039
|
-
getSponsorshipProposals(query = {}) {
|
|
1040
|
-
const params = new URLSearchParams({ limit: String(query.limit ?? 50) });
|
|
1041
|
-
if (query.nftContract) params.set("nftContract", query.nftContract);
|
|
1042
|
-
if (query.proposer) params.set("proposer", query.proposer);
|
|
1043
|
-
if (query.owner) params.set("owner", query.owner);
|
|
1044
|
-
if (query.open !== void 0) params.set("open", String(query.open));
|
|
1045
|
-
return this.get(`/v1/sponsorship/proposals?${params}`);
|
|
1046
|
-
}
|
|
1047
|
-
getSponsorshipLicenses(query = {}) {
|
|
1048
|
-
const params = new URLSearchParams({ limit: String(query.limit ?? 50) });
|
|
1049
|
-
if (query.holder) params.set("holder", query.holder);
|
|
1050
|
-
if (query.author) params.set("author", query.author);
|
|
1051
|
-
return this.get(`/v1/sponsorship/licenses?${params}`);
|
|
1052
|
-
}
|
|
1053
|
-
async getRewards(address) {
|
|
1054
|
-
const res = await this.get(`/v1/rewards/${this.addr(address)}`);
|
|
1055
|
-
return res.data;
|
|
1056
|
-
}
|
|
1057
|
-
getRewardsLeaderboard(page = 1, limit = 50) {
|
|
1058
|
-
return this.get(`/v1/rewards?page=${page}&limit=${limit}`);
|
|
1059
|
-
}
|
|
1060
|
-
getRewardsEvents(address, page = 1, limit = 20) {
|
|
1061
|
-
return this.get(
|
|
1062
|
-
`/v1/rewards/${this.addr(address)}/events?page=${page}&limit=${limit}`
|
|
1063
|
-
);
|
|
1064
|
-
}
|
|
1065
|
-
async getRewardsConfig() {
|
|
1066
|
-
const res = await this.get(`/v1/rewards/config`);
|
|
1067
|
-
return res.data;
|
|
1068
|
-
}
|
|
1069
|
-
async getRewardsBatch(addresses) {
|
|
1070
|
-
if (addresses.length === 0) return [];
|
|
1071
|
-
const params = new URLSearchParams({ addresses: addresses.map((a) => this.addr(a)).join(",") });
|
|
1072
|
-
const res = await this.get(`/v1/rewards/batch?${params}`);
|
|
1073
|
-
return res.data;
|
|
1074
|
-
}
|
|
1075
|
-
};
|
|
1076
|
-
|
|
1077
|
-
// src/constants.ts
|
|
1078
|
-
var SN = getCoordinates("STARKNET");
|
|
1079
|
-
SN.marketplace721;
|
|
1080
|
-
SN.marketplace721ClassHash;
|
|
1081
|
-
SN.marketplace721StartBlock;
|
|
1082
|
-
SN.marketplace1155;
|
|
1083
|
-
SN.marketplace1155ClassHash;
|
|
1084
|
-
SN.marketplace1155StartBlock;
|
|
1085
|
-
SN.collection721;
|
|
1086
|
-
SN.dataTokenization721;
|
|
1087
|
-
SN.collection721StartBlock;
|
|
1088
|
-
SN.ipNftClassHash;
|
|
1089
|
-
SN.ipCollectionClassHash;
|
|
1090
|
-
SN.collection1155;
|
|
1091
|
-
SN.collection1155FactoryClassHash;
|
|
1092
|
-
SN.collection1155ClassHash;
|
|
1093
|
-
SN.collection1155StartBlock;
|
|
1094
|
-
SN.popFactory;
|
|
1095
|
-
SN.popCollectionClassHash;
|
|
1096
|
-
SN.dropFactory;
|
|
1097
|
-
SN.dropCollectionClassHash;
|
|
1098
|
-
SN.nftComments;
|
|
1099
|
-
SN.ipTicketsFactory;
|
|
1100
|
-
SN.ipTicketCollectionClassHash;
|
|
1101
|
-
SN.ipClubFactory;
|
|
1102
|
-
SN.ipClubCollectionClassHash;
|
|
1103
|
-
SN.ipSponsorship;
|
|
1104
|
-
SN.ipSponsorshipClassHash;
|
|
1105
|
-
var STARKNET_MEDIAWALLET_CLASS_HASH = SN.mediaWalletClassHash;
|
|
1106
|
-
SN.creatorCoinFactory;
|
|
1107
|
-
SN.creatorCoinEkuboLauncher;
|
|
1108
|
-
SN.creatorCoinClassHash;
|
|
1109
|
-
SN.creatorCoinFactoryClassHash;
|
|
1110
|
-
SN.creatorCoinStartBlock;
|
|
1111
|
-
SN.genesisMint;
|
|
1112
|
-
SN.ekuboCore;
|
|
1113
|
-
var SUPPORTED_TOKENS = [
|
|
1114
|
-
{
|
|
1115
|
-
symbol: "USDC",
|
|
1116
|
-
address: "0x033068f6539f8e6e6b131e6b2b814e6c34a5224bc66947c47dab9dfee93b35fb",
|
|
1117
|
-
decimals: 6,
|
|
1118
|
-
listable: true
|
|
1119
|
-
},
|
|
1120
|
-
{
|
|
1121
|
-
symbol: "USDT",
|
|
1122
|
-
address: "0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",
|
|
1123
|
-
decimals: 6,
|
|
1124
|
-
listable: true
|
|
1125
|
-
},
|
|
1126
|
-
{
|
|
1127
|
-
symbol: "ETH",
|
|
1128
|
-
address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
|
|
1129
|
-
decimals: 18,
|
|
1130
|
-
listable: true
|
|
1131
|
-
},
|
|
1132
|
-
{
|
|
1133
|
-
symbol: "STRK",
|
|
1134
|
-
address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
|
|
1135
|
-
decimals: 18,
|
|
1136
|
-
listable: true
|
|
1137
|
-
},
|
|
1138
|
-
{
|
|
1139
|
-
symbol: "WBTC",
|
|
1140
|
-
address: "0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",
|
|
1141
|
-
decimals: 8,
|
|
1142
|
-
listable: true
|
|
1143
|
-
}
|
|
1144
|
-
];
|
|
1145
|
-
|
|
1146
8
|
// src/starknet/marketplace/errors.ts
|
|
1147
9
|
var MedialaneError = class extends Error {
|
|
1148
10
|
constructor(message, code = "UNKNOWN", cause) {
|
|
@@ -1153,71 +15,6 @@ var MedialaneError = class extends Error {
|
|
|
1153
15
|
}
|
|
1154
16
|
};
|
|
1155
17
|
|
|
1156
|
-
// src/utils/rpc.ts
|
|
1157
|
-
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;
|
|
1158
|
-
var POLICY_REFUSAL_CODES = [-32003, -32005, -32600];
|
|
1159
|
-
function isPolicyRefusal(input) {
|
|
1160
|
-
let body = input.body;
|
|
1161
|
-
if (typeof body === "string") {
|
|
1162
|
-
try {
|
|
1163
|
-
body = JSON.parse(body);
|
|
1164
|
-
} catch {
|
|
1165
|
-
return false;
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
const err = body?.error;
|
|
1169
|
-
const code = err && typeof err === "object" ? err.code : void 0;
|
|
1170
|
-
return typeof code === "number" && POLICY_REFUSAL_CODES.includes(code);
|
|
1171
|
-
}
|
|
1172
|
-
function isTransientRpcError(input) {
|
|
1173
|
-
const { status, body } = input;
|
|
1174
|
-
if (isPolicyRefusal({ body })) return false;
|
|
1175
|
-
if (typeof status === "number" && (status === 429 || status >= 500)) return true;
|
|
1176
|
-
if (body == null) return false;
|
|
1177
|
-
if (typeof body === "object") {
|
|
1178
|
-
const err = body.error;
|
|
1179
|
-
if (!err || typeof err !== "object") return false;
|
|
1180
|
-
const code = err.code;
|
|
1181
|
-
if (typeof code === "number") {
|
|
1182
|
-
if (code === 429) return true;
|
|
1183
|
-
if (code >= -32099 && code <= -32e3) return true;
|
|
1184
|
-
if (code === -32603) return true;
|
|
1185
|
-
}
|
|
1186
|
-
const message = err.message;
|
|
1187
|
-
return typeof message === "string" ? TRANSIENT_BODY_RE.test(message) : false;
|
|
1188
|
-
}
|
|
1189
|
-
return TRANSIENT_BODY_RE.test(String(body));
|
|
1190
|
-
}
|
|
1191
|
-
function createFailoverFetch(urls, options = {}) {
|
|
1192
|
-
const endpoints = urls.filter((u) => Boolean(u));
|
|
1193
|
-
if (endpoints.length === 0) {
|
|
1194
|
-
throw new Error("createFailoverFetch: at least one RPC URL is required");
|
|
1195
|
-
}
|
|
1196
|
-
const doFetch = options.baseFetch ?? fetch;
|
|
1197
|
-
const failover = async (_input, init) => {
|
|
1198
|
-
let lastError;
|
|
1199
|
-
for (let i = 0; i < endpoints.length; i++) {
|
|
1200
|
-
const url = endpoints[i];
|
|
1201
|
-
const isLast = i === endpoints.length - 1;
|
|
1202
|
-
try {
|
|
1203
|
-
const res = await doFetch(url, init);
|
|
1204
|
-
const text = await res.text();
|
|
1205
|
-
const rebuilt = () => new Response(text, { status: res.status, statusText: res.statusText, headers: res.headers });
|
|
1206
|
-
if (isLast || !isTransientRpcError({ status: res.status, body: text })) {
|
|
1207
|
-
return rebuilt();
|
|
1208
|
-
}
|
|
1209
|
-
options.onFailover?.({ url, status: res.status });
|
|
1210
|
-
} catch (err) {
|
|
1211
|
-
lastError = err;
|
|
1212
|
-
if (isLast) throw err;
|
|
1213
|
-
options.onFailover?.({ url, error: err });
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
throw lastError ?? new Error("createFailoverFetch: all endpoints failed");
|
|
1217
|
-
};
|
|
1218
|
-
return failover;
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
18
|
// src/starknet/marketplace/utils.ts
|
|
1222
19
|
var START_TIME_BUFFER_SECS = 30;
|
|
1223
20
|
function newContract(abi, address, providerOrAccount) {
|
|
@@ -9451,8 +8248,8 @@ var IPSponsorshipABI = [
|
|
|
9451
8248
|
var IPGenesisABI = [
|
|
9452
8249
|
{
|
|
9453
8250
|
"type": "impl",
|
|
9454
|
-
"name": "
|
|
9455
|
-
"interface_name": "
|
|
8251
|
+
"name": "ERC721MetadataImpl",
|
|
8252
|
+
"interface_name": "openzeppelin_token::erc721::interface::IERC721Metadata"
|
|
9456
8253
|
},
|
|
9457
8254
|
{
|
|
9458
8255
|
"type": "struct",
|
|
@@ -9468,7 +8265,7 @@ var IPGenesisABI = [
|
|
|
9468
8265
|
},
|
|
9469
8266
|
{
|
|
9470
8267
|
"name": "pending_word_len",
|
|
9471
|
-
"type": "core::
|
|
8268
|
+
"type": "core::integer::u32"
|
|
9472
8269
|
}
|
|
9473
8270
|
]
|
|
9474
8271
|
},
|
|
@@ -9488,70 +8285,195 @@ var IPGenesisABI = [
|
|
|
9488
8285
|
},
|
|
9489
8286
|
{
|
|
9490
8287
|
"type": "interface",
|
|
9491
|
-
"name": "
|
|
8288
|
+
"name": "openzeppelin_token::erc721::interface::IERC721Metadata",
|
|
9492
8289
|
"items": [
|
|
9493
8290
|
{
|
|
9494
8291
|
"type": "function",
|
|
9495
|
-
"name": "
|
|
9496
|
-
"inputs": [
|
|
8292
|
+
"name": "name",
|
|
8293
|
+
"inputs": [],
|
|
8294
|
+
"outputs": [
|
|
9497
8295
|
{
|
|
9498
|
-
"
|
|
9499
|
-
|
|
9500
|
-
|
|
8296
|
+
"type": "core::byte_array::ByteArray"
|
|
8297
|
+
}
|
|
8298
|
+
],
|
|
8299
|
+
"state_mutability": "view"
|
|
8300
|
+
},
|
|
8301
|
+
{
|
|
8302
|
+
"type": "function",
|
|
8303
|
+
"name": "symbol",
|
|
8304
|
+
"inputs": [],
|
|
8305
|
+
"outputs": [
|
|
9501
8306
|
{
|
|
9502
|
-
"name": "uri",
|
|
9503
8307
|
"type": "core::byte_array::ByteArray"
|
|
9504
8308
|
}
|
|
9505
8309
|
],
|
|
8310
|
+
"state_mutability": "view"
|
|
8311
|
+
},
|
|
8312
|
+
{
|
|
8313
|
+
"type": "function",
|
|
8314
|
+
"name": "token_uri",
|
|
8315
|
+
"inputs": [
|
|
8316
|
+
{
|
|
8317
|
+
"name": "token_id",
|
|
8318
|
+
"type": "core::integer::u256"
|
|
8319
|
+
}
|
|
8320
|
+
],
|
|
9506
8321
|
"outputs": [
|
|
9507
8322
|
{
|
|
8323
|
+
"type": "core::byte_array::ByteArray"
|
|
8324
|
+
}
|
|
8325
|
+
],
|
|
8326
|
+
"state_mutability": "view"
|
|
8327
|
+
}
|
|
8328
|
+
]
|
|
8329
|
+
},
|
|
8330
|
+
{
|
|
8331
|
+
"type": "impl",
|
|
8332
|
+
"name": "ERC721MetadataCamelOnlyImpl",
|
|
8333
|
+
"interface_name": "openzeppelin_token::erc721::interface::IERC721MetadataCamelOnly"
|
|
8334
|
+
},
|
|
8335
|
+
{
|
|
8336
|
+
"type": "interface",
|
|
8337
|
+
"name": "openzeppelin_token::erc721::interface::IERC721MetadataCamelOnly",
|
|
8338
|
+
"items": [
|
|
8339
|
+
{
|
|
8340
|
+
"type": "function",
|
|
8341
|
+
"name": "tokenURI",
|
|
8342
|
+
"inputs": [
|
|
8343
|
+
{
|
|
8344
|
+
"name": "tokenId",
|
|
9508
8345
|
"type": "core::integer::u256"
|
|
9509
8346
|
}
|
|
9510
8347
|
],
|
|
9511
|
-
"
|
|
8348
|
+
"outputs": [
|
|
8349
|
+
{
|
|
8350
|
+
"type": "core::byte_array::ByteArray"
|
|
8351
|
+
}
|
|
8352
|
+
],
|
|
8353
|
+
"state_mutability": "view"
|
|
9512
8354
|
}
|
|
9513
8355
|
]
|
|
9514
8356
|
},
|
|
9515
8357
|
{
|
|
9516
8358
|
"type": "impl",
|
|
9517
|
-
"name": "
|
|
9518
|
-
"interface_name": "
|
|
8359
|
+
"name": "IPCollectionImpl",
|
|
8360
|
+
"interface_name": "ip_programmable_erc_721::interfaces::IIPCollection::IIPCollection"
|
|
8361
|
+
},
|
|
8362
|
+
{
|
|
8363
|
+
"type": "struct",
|
|
8364
|
+
"name": "ip_programmable_erc_721::types::TokenData",
|
|
8365
|
+
"members": [
|
|
8366
|
+
{
|
|
8367
|
+
"name": "token_id",
|
|
8368
|
+
"type": "core::integer::u256"
|
|
8369
|
+
},
|
|
8370
|
+
{
|
|
8371
|
+
"name": "owner",
|
|
8372
|
+
"type": "core::starknet::contract_address::ContractAddress"
|
|
8373
|
+
},
|
|
8374
|
+
{
|
|
8375
|
+
"name": "metadata_uri",
|
|
8376
|
+
"type": "core::byte_array::ByteArray"
|
|
8377
|
+
},
|
|
8378
|
+
{
|
|
8379
|
+
"name": "original_creator",
|
|
8380
|
+
"type": "core::starknet::contract_address::ContractAddress"
|
|
8381
|
+
},
|
|
8382
|
+
{
|
|
8383
|
+
"name": "registered_at",
|
|
8384
|
+
"type": "core::integer::u64"
|
|
8385
|
+
}
|
|
8386
|
+
]
|
|
9519
8387
|
},
|
|
9520
8388
|
{
|
|
9521
8389
|
"type": "interface",
|
|
9522
|
-
"name": "
|
|
8390
|
+
"name": "ip_programmable_erc_721::interfaces::IIPCollection::IIPCollection",
|
|
9523
8391
|
"items": [
|
|
9524
8392
|
{
|
|
9525
8393
|
"type": "function",
|
|
9526
|
-
"name": "
|
|
8394
|
+
"name": "mint_item",
|
|
8395
|
+
"inputs": [
|
|
8396
|
+
{
|
|
8397
|
+
"name": "recipient",
|
|
8398
|
+
"type": "core::starknet::contract_address::ContractAddress"
|
|
8399
|
+
},
|
|
8400
|
+
{
|
|
8401
|
+
"name": "token_uri",
|
|
8402
|
+
"type": "core::byte_array::ByteArray"
|
|
8403
|
+
}
|
|
8404
|
+
],
|
|
8405
|
+
"outputs": [
|
|
8406
|
+
{
|
|
8407
|
+
"type": "core::integer::u256"
|
|
8408
|
+
}
|
|
8409
|
+
],
|
|
8410
|
+
"state_mutability": "external"
|
|
8411
|
+
},
|
|
8412
|
+
{
|
|
8413
|
+
"type": "function",
|
|
8414
|
+
"name": "get_collection_creator",
|
|
9527
8415
|
"inputs": [],
|
|
9528
8416
|
"outputs": [
|
|
9529
8417
|
{
|
|
8418
|
+
"type": "core::starknet::contract_address::ContractAddress"
|
|
8419
|
+
}
|
|
8420
|
+
],
|
|
8421
|
+
"state_mutability": "view"
|
|
8422
|
+
},
|
|
8423
|
+
{
|
|
8424
|
+
"type": "function",
|
|
8425
|
+
"name": "get_token_creator",
|
|
8426
|
+
"inputs": [
|
|
8427
|
+
{
|
|
8428
|
+
"name": "token_id",
|
|
9530
8429
|
"type": "core::integer::u256"
|
|
9531
8430
|
}
|
|
9532
8431
|
],
|
|
8432
|
+
"outputs": [
|
|
8433
|
+
{
|
|
8434
|
+
"type": "core::starknet::contract_address::ContractAddress"
|
|
8435
|
+
}
|
|
8436
|
+
],
|
|
9533
8437
|
"state_mutability": "view"
|
|
9534
8438
|
},
|
|
9535
8439
|
{
|
|
9536
8440
|
"type": "function",
|
|
9537
|
-
"name": "
|
|
9538
|
-
"inputs": [
|
|
9539
|
-
|
|
9540
|
-
|
|
8441
|
+
"name": "get_token_registered_at",
|
|
8442
|
+
"inputs": [
|
|
8443
|
+
{
|
|
8444
|
+
"name": "token_id",
|
|
8445
|
+
"type": "core::integer::u256"
|
|
8446
|
+
}
|
|
8447
|
+
],
|
|
8448
|
+
"outputs": [
|
|
8449
|
+
{
|
|
8450
|
+
"type": "core::integer::u64"
|
|
8451
|
+
}
|
|
8452
|
+
],
|
|
8453
|
+
"state_mutability": "view"
|
|
9541
8454
|
},
|
|
9542
8455
|
{
|
|
9543
8456
|
"type": "function",
|
|
9544
|
-
"name": "
|
|
9545
|
-
"inputs": [
|
|
9546
|
-
|
|
9547
|
-
|
|
8457
|
+
"name": "get_token_data",
|
|
8458
|
+
"inputs": [
|
|
8459
|
+
{
|
|
8460
|
+
"name": "token_id",
|
|
8461
|
+
"type": "core::integer::u256"
|
|
8462
|
+
}
|
|
8463
|
+
],
|
|
8464
|
+
"outputs": [
|
|
8465
|
+
{
|
|
8466
|
+
"type": "ip_programmable_erc_721::types::TokenData"
|
|
8467
|
+
}
|
|
8468
|
+
],
|
|
8469
|
+
"state_mutability": "view"
|
|
9548
8470
|
}
|
|
9549
8471
|
]
|
|
9550
8472
|
},
|
|
9551
8473
|
{
|
|
9552
8474
|
"type": "impl",
|
|
9553
|
-
"name": "
|
|
9554
|
-
"interface_name": "openzeppelin_token::erc721::interface::
|
|
8475
|
+
"name": "ERC721Impl",
|
|
8476
|
+
"interface_name": "openzeppelin_token::erc721::interface::IERC721"
|
|
9555
8477
|
},
|
|
9556
8478
|
{
|
|
9557
8479
|
"type": "struct",
|
|
@@ -9579,7 +8501,7 @@ var IPGenesisABI = [
|
|
|
9579
8501
|
},
|
|
9580
8502
|
{
|
|
9581
8503
|
"type": "interface",
|
|
9582
|
-
"name": "openzeppelin_token::erc721::interface::
|
|
8504
|
+
"name": "openzeppelin_token::erc721::interface::IERC721",
|
|
9583
8505
|
"items": [
|
|
9584
8506
|
{
|
|
9585
8507
|
"type": "function",
|
|
@@ -9724,61 +8646,18 @@ var IPGenesisABI = [
|
|
|
9724
8646
|
}
|
|
9725
8647
|
],
|
|
9726
8648
|
"state_mutability": "view"
|
|
9727
|
-
}
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
"type": "core::bool"
|
|
9740
|
-
}
|
|
9741
|
-
],
|
|
9742
|
-
"state_mutability": "view"
|
|
9743
|
-
},
|
|
9744
|
-
{
|
|
9745
|
-
"type": "function",
|
|
9746
|
-
"name": "name",
|
|
9747
|
-
"inputs": [],
|
|
9748
|
-
"outputs": [
|
|
9749
|
-
{
|
|
9750
|
-
"type": "core::byte_array::ByteArray"
|
|
9751
|
-
}
|
|
9752
|
-
],
|
|
9753
|
-
"state_mutability": "view"
|
|
9754
|
-
},
|
|
9755
|
-
{
|
|
9756
|
-
"type": "function",
|
|
9757
|
-
"name": "symbol",
|
|
9758
|
-
"inputs": [],
|
|
9759
|
-
"outputs": [
|
|
9760
|
-
{
|
|
9761
|
-
"type": "core::byte_array::ByteArray"
|
|
9762
|
-
}
|
|
9763
|
-
],
|
|
9764
|
-
"state_mutability": "view"
|
|
9765
|
-
},
|
|
9766
|
-
{
|
|
9767
|
-
"type": "function",
|
|
9768
|
-
"name": "token_uri",
|
|
9769
|
-
"inputs": [
|
|
9770
|
-
{
|
|
9771
|
-
"name": "token_id",
|
|
9772
|
-
"type": "core::integer::u256"
|
|
9773
|
-
}
|
|
9774
|
-
],
|
|
9775
|
-
"outputs": [
|
|
9776
|
-
{
|
|
9777
|
-
"type": "core::byte_array::ByteArray"
|
|
9778
|
-
}
|
|
9779
|
-
],
|
|
9780
|
-
"state_mutability": "view"
|
|
9781
|
-
},
|
|
8649
|
+
}
|
|
8650
|
+
]
|
|
8651
|
+
},
|
|
8652
|
+
{
|
|
8653
|
+
"type": "impl",
|
|
8654
|
+
"name": "ERC721CamelOnly",
|
|
8655
|
+
"interface_name": "openzeppelin_token::erc721::interface::IERC721CamelOnly"
|
|
8656
|
+
},
|
|
8657
|
+
{
|
|
8658
|
+
"type": "interface",
|
|
8659
|
+
"name": "openzeppelin_token::erc721::interface::IERC721CamelOnly",
|
|
8660
|
+
"items": [
|
|
9782
8661
|
{
|
|
9783
8662
|
"type": "function",
|
|
9784
8663
|
"name": "balanceOf",
|
|
@@ -9906,98 +8785,38 @@ var IPGenesisABI = [
|
|
|
9906
8785
|
}
|
|
9907
8786
|
],
|
|
9908
8787
|
"state_mutability": "view"
|
|
9909
|
-
},
|
|
9910
|
-
{
|
|
9911
|
-
"type": "function",
|
|
9912
|
-
"name": "tokenURI",
|
|
9913
|
-
"inputs": [
|
|
9914
|
-
{
|
|
9915
|
-
"name": "tokenId",
|
|
9916
|
-
"type": "core::integer::u256"
|
|
9917
|
-
}
|
|
9918
|
-
],
|
|
9919
|
-
"outputs": [
|
|
9920
|
-
{
|
|
9921
|
-
"type": "core::byte_array::ByteArray"
|
|
9922
|
-
}
|
|
9923
|
-
],
|
|
9924
|
-
"state_mutability": "view"
|
|
9925
8788
|
}
|
|
9926
8789
|
]
|
|
9927
8790
|
},
|
|
9928
8791
|
{
|
|
9929
8792
|
"type": "impl",
|
|
9930
|
-
"name": "
|
|
9931
|
-
"interface_name": "
|
|
8793
|
+
"name": "ERC721EnumerableImpl",
|
|
8794
|
+
"interface_name": "openzeppelin_token::erc721::extensions::erc721_enumerable::interface::IERC721Enumerable"
|
|
9932
8795
|
},
|
|
9933
8796
|
{
|
|
9934
8797
|
"type": "interface",
|
|
9935
|
-
"name": "
|
|
8798
|
+
"name": "openzeppelin_token::erc721::extensions::erc721_enumerable::interface::IERC721Enumerable",
|
|
9936
8799
|
"items": [
|
|
9937
8800
|
{
|
|
9938
8801
|
"type": "function",
|
|
9939
|
-
"name": "
|
|
8802
|
+
"name": "total_supply",
|
|
9940
8803
|
"inputs": [],
|
|
9941
8804
|
"outputs": [
|
|
9942
8805
|
{
|
|
9943
|
-
"type": "core::
|
|
8806
|
+
"type": "core::integer::u256"
|
|
9944
8807
|
}
|
|
9945
8808
|
],
|
|
9946
8809
|
"state_mutability": "view"
|
|
9947
8810
|
},
|
|
9948
8811
|
{
|
|
9949
8812
|
"type": "function",
|
|
9950
|
-
"name": "
|
|
9951
|
-
"inputs": [
|
|
9952
|
-
{
|
|
9953
|
-
"name": "new_owner",
|
|
9954
|
-
"type": "core::starknet::contract_address::ContractAddress"
|
|
9955
|
-
}
|
|
9956
|
-
],
|
|
9957
|
-
"outputs": [],
|
|
9958
|
-
"state_mutability": "external"
|
|
9959
|
-
},
|
|
9960
|
-
{
|
|
9961
|
-
"type": "function",
|
|
9962
|
-
"name": "renounce_ownership",
|
|
9963
|
-
"inputs": [],
|
|
9964
|
-
"outputs": [],
|
|
9965
|
-
"state_mutability": "external"
|
|
9966
|
-
},
|
|
9967
|
-
{
|
|
9968
|
-
"type": "function",
|
|
9969
|
-
"name": "transferOwnership",
|
|
8813
|
+
"name": "token_by_index",
|
|
9970
8814
|
"inputs": [
|
|
9971
8815
|
{
|
|
9972
|
-
"name": "
|
|
9973
|
-
"type": "core::
|
|
8816
|
+
"name": "index",
|
|
8817
|
+
"type": "core::integer::u256"
|
|
9974
8818
|
}
|
|
9975
8819
|
],
|
|
9976
|
-
"outputs": [],
|
|
9977
|
-
"state_mutability": "external"
|
|
9978
|
-
},
|
|
9979
|
-
{
|
|
9980
|
-
"type": "function",
|
|
9981
|
-
"name": "renounceOwnership",
|
|
9982
|
-
"inputs": [],
|
|
9983
|
-
"outputs": [],
|
|
9984
|
-
"state_mutability": "external"
|
|
9985
|
-
}
|
|
9986
|
-
]
|
|
9987
|
-
},
|
|
9988
|
-
{
|
|
9989
|
-
"type": "impl",
|
|
9990
|
-
"name": "ERC721EnumerableImpl",
|
|
9991
|
-
"interface_name": "openzeppelin_token::erc721::extensions::erc721_enumerable::interface::IERC721Enumerable"
|
|
9992
|
-
},
|
|
9993
|
-
{
|
|
9994
|
-
"type": "interface",
|
|
9995
|
-
"name": "openzeppelin_token::erc721::extensions::erc721_enumerable::interface::IERC721Enumerable",
|
|
9996
|
-
"items": [
|
|
9997
|
-
{
|
|
9998
|
-
"type": "function",
|
|
9999
|
-
"name": "total_supply",
|
|
10000
|
-
"inputs": [],
|
|
10001
8820
|
"outputs": [
|
|
10002
8821
|
{
|
|
10003
8822
|
"type": "core::integer::u256"
|
|
@@ -10007,8 +8826,12 @@ var IPGenesisABI = [
|
|
|
10007
8826
|
},
|
|
10008
8827
|
{
|
|
10009
8828
|
"type": "function",
|
|
10010
|
-
"name": "
|
|
8829
|
+
"name": "token_of_owner_by_index",
|
|
10011
8830
|
"inputs": [
|
|
8831
|
+
{
|
|
8832
|
+
"name": "owner",
|
|
8833
|
+
"type": "core::starknet::contract_address::ContractAddress"
|
|
8834
|
+
},
|
|
10012
8835
|
{
|
|
10013
8836
|
"name": "index",
|
|
10014
8837
|
"type": "core::integer::u256"
|
|
@@ -10020,23 +8843,30 @@ var IPGenesisABI = [
|
|
|
10020
8843
|
}
|
|
10021
8844
|
],
|
|
10022
8845
|
"state_mutability": "view"
|
|
10023
|
-
}
|
|
8846
|
+
}
|
|
8847
|
+
]
|
|
8848
|
+
},
|
|
8849
|
+
{
|
|
8850
|
+
"type": "impl",
|
|
8851
|
+
"name": "SRC5Impl",
|
|
8852
|
+
"interface_name": "openzeppelin_introspection::interface::ISRC5"
|
|
8853
|
+
},
|
|
8854
|
+
{
|
|
8855
|
+
"type": "interface",
|
|
8856
|
+
"name": "openzeppelin_introspection::interface::ISRC5",
|
|
8857
|
+
"items": [
|
|
10024
8858
|
{
|
|
10025
8859
|
"type": "function",
|
|
10026
|
-
"name": "
|
|
8860
|
+
"name": "supports_interface",
|
|
10027
8861
|
"inputs": [
|
|
10028
8862
|
{
|
|
10029
|
-
"name": "
|
|
10030
|
-
"type": "core::
|
|
10031
|
-
},
|
|
10032
|
-
{
|
|
10033
|
-
"name": "index",
|
|
10034
|
-
"type": "core::integer::u256"
|
|
8863
|
+
"name": "interface_id",
|
|
8864
|
+
"type": "core::felt252"
|
|
10035
8865
|
}
|
|
10036
8866
|
],
|
|
10037
8867
|
"outputs": [
|
|
10038
8868
|
{
|
|
10039
|
-
"type": "core::
|
|
8869
|
+
"type": "core::bool"
|
|
10040
8870
|
}
|
|
10041
8871
|
],
|
|
10042
8872
|
"state_mutability": "view"
|
|
@@ -10047,6 +8877,14 @@ var IPGenesisABI = [
|
|
|
10047
8877
|
"type": "constructor",
|
|
10048
8878
|
"name": "constructor",
|
|
10049
8879
|
"inputs": [
|
|
8880
|
+
{
|
|
8881
|
+
"name": "name",
|
|
8882
|
+
"type": "core::byte_array::ByteArray"
|
|
8883
|
+
},
|
|
8884
|
+
{
|
|
8885
|
+
"name": "symbol",
|
|
8886
|
+
"type": "core::byte_array::ByteArray"
|
|
8887
|
+
},
|
|
10050
8888
|
{
|
|
10051
8889
|
"name": "owner",
|
|
10052
8890
|
"type": "core::starknet::contract_address::ContractAddress"
|
|
@@ -10141,57 +8979,6 @@ var IPGenesisABI = [
|
|
|
10141
8979
|
}
|
|
10142
8980
|
]
|
|
10143
8981
|
},
|
|
10144
|
-
{
|
|
10145
|
-
"type": "event",
|
|
10146
|
-
"name": "openzeppelin_access::ownable::ownable::OwnableComponent::OwnershipTransferred",
|
|
10147
|
-
"kind": "struct",
|
|
10148
|
-
"members": [
|
|
10149
|
-
{
|
|
10150
|
-
"name": "previous_owner",
|
|
10151
|
-
"type": "core::starknet::contract_address::ContractAddress",
|
|
10152
|
-
"kind": "key"
|
|
10153
|
-
},
|
|
10154
|
-
{
|
|
10155
|
-
"name": "new_owner",
|
|
10156
|
-
"type": "core::starknet::contract_address::ContractAddress",
|
|
10157
|
-
"kind": "key"
|
|
10158
|
-
}
|
|
10159
|
-
]
|
|
10160
|
-
},
|
|
10161
|
-
{
|
|
10162
|
-
"type": "event",
|
|
10163
|
-
"name": "openzeppelin_access::ownable::ownable::OwnableComponent::OwnershipTransferStarted",
|
|
10164
|
-
"kind": "struct",
|
|
10165
|
-
"members": [
|
|
10166
|
-
{
|
|
10167
|
-
"name": "previous_owner",
|
|
10168
|
-
"type": "core::starknet::contract_address::ContractAddress",
|
|
10169
|
-
"kind": "key"
|
|
10170
|
-
},
|
|
10171
|
-
{
|
|
10172
|
-
"name": "new_owner",
|
|
10173
|
-
"type": "core::starknet::contract_address::ContractAddress",
|
|
10174
|
-
"kind": "key"
|
|
10175
|
-
}
|
|
10176
|
-
]
|
|
10177
|
-
},
|
|
10178
|
-
{
|
|
10179
|
-
"type": "event",
|
|
10180
|
-
"name": "openzeppelin_access::ownable::ownable::OwnableComponent::Event",
|
|
10181
|
-
"kind": "enum",
|
|
10182
|
-
"variants": [
|
|
10183
|
-
{
|
|
10184
|
-
"name": "OwnershipTransferred",
|
|
10185
|
-
"type": "openzeppelin_access::ownable::ownable::OwnableComponent::OwnershipTransferred",
|
|
10186
|
-
"kind": "nested"
|
|
10187
|
-
},
|
|
10188
|
-
{
|
|
10189
|
-
"name": "OwnershipTransferStarted",
|
|
10190
|
-
"type": "openzeppelin_access::ownable::ownable::OwnableComponent::OwnershipTransferStarted",
|
|
10191
|
-
"kind": "nested"
|
|
10192
|
-
}
|
|
10193
|
-
]
|
|
10194
|
-
},
|
|
10195
8982
|
{
|
|
10196
8983
|
"type": "event",
|
|
10197
8984
|
"name": "openzeppelin_introspection::src5::SRC5Component::Event",
|
|
@@ -10206,48 +8993,39 @@ var IPGenesisABI = [
|
|
|
10206
8993
|
},
|
|
10207
8994
|
{
|
|
10208
8995
|
"type": "event",
|
|
10209
|
-
"name": "
|
|
8996
|
+
"name": "ip_programmable_erc_721::IPCollection::IPCollection::IPMinted",
|
|
10210
8997
|
"kind": "struct",
|
|
10211
8998
|
"members": [
|
|
10212
8999
|
{
|
|
10213
|
-
"name": "
|
|
9000
|
+
"name": "token_id",
|
|
10214
9001
|
"type": "core::integer::u256",
|
|
10215
|
-
"kind": "
|
|
10216
|
-
}
|
|
10217
|
-
]
|
|
10218
|
-
},
|
|
10219
|
-
{
|
|
10220
|
-
"type": "event",
|
|
10221
|
-
"name": "mip::mip::MIP::CounterComponent::CounterDecremented",
|
|
10222
|
-
"kind": "struct",
|
|
10223
|
-
"members": [
|
|
9002
|
+
"kind": "key"
|
|
9003
|
+
},
|
|
10224
9004
|
{
|
|
10225
|
-
"name": "
|
|
10226
|
-
"type": "core::
|
|
9005
|
+
"name": "recipient",
|
|
9006
|
+
"type": "core::starknet::contract_address::ContractAddress",
|
|
9007
|
+
"kind": "key"
|
|
9008
|
+
},
|
|
9009
|
+
{
|
|
9010
|
+
"name": "uri",
|
|
9011
|
+
"type": "core::byte_array::ByteArray",
|
|
10227
9012
|
"kind": "data"
|
|
10228
|
-
}
|
|
10229
|
-
]
|
|
10230
|
-
},
|
|
10231
|
-
{
|
|
10232
|
-
"type": "event",
|
|
10233
|
-
"name": "mip::mip::MIP::CounterComponent::Event",
|
|
10234
|
-
"kind": "enum",
|
|
10235
|
-
"variants": [
|
|
9013
|
+
},
|
|
10236
9014
|
{
|
|
10237
|
-
"name": "
|
|
10238
|
-
"type": "
|
|
10239
|
-
"kind": "
|
|
9015
|
+
"name": "creator",
|
|
9016
|
+
"type": "core::starknet::contract_address::ContractAddress",
|
|
9017
|
+
"kind": "data"
|
|
10240
9018
|
},
|
|
10241
9019
|
{
|
|
10242
|
-
"name": "
|
|
10243
|
-
"type": "
|
|
10244
|
-
"kind": "
|
|
9020
|
+
"name": "registered_at",
|
|
9021
|
+
"type": "core::integer::u64",
|
|
9022
|
+
"kind": "data"
|
|
10245
9023
|
}
|
|
10246
9024
|
]
|
|
10247
9025
|
},
|
|
10248
9026
|
{
|
|
10249
9027
|
"type": "event",
|
|
10250
|
-
"name": "
|
|
9028
|
+
"name": "ip_programmable_erc_721::IPCollection::IPCollection::Event",
|
|
10251
9029
|
"kind": "enum",
|
|
10252
9030
|
"variants": [
|
|
10253
9031
|
{
|
|
@@ -10255,11 +9033,6 @@ var IPGenesisABI = [
|
|
|
10255
9033
|
"type": "openzeppelin_token::erc721::erc721::ERC721Component::Event",
|
|
10256
9034
|
"kind": "flat"
|
|
10257
9035
|
},
|
|
10258
|
-
{
|
|
10259
|
-
"name": "OwnableEvent",
|
|
10260
|
-
"type": "openzeppelin_access::ownable::ownable::OwnableComponent::Event",
|
|
10261
|
-
"kind": "flat"
|
|
10262
|
-
},
|
|
10263
9036
|
{
|
|
10264
9037
|
"name": "SRC5Event",
|
|
10265
9038
|
"type": "openzeppelin_introspection::src5::SRC5Component::Event",
|
|
@@ -10271,9 +9044,9 @@ var IPGenesisABI = [
|
|
|
10271
9044
|
"kind": "flat"
|
|
10272
9045
|
},
|
|
10273
9046
|
{
|
|
10274
|
-
"name": "
|
|
10275
|
-
"type": "
|
|
10276
|
-
"kind": "
|
|
9047
|
+
"name": "IPMinted",
|
|
9048
|
+
"type": "ip_programmable_erc_721::IPCollection::IPCollection::IPMinted",
|
|
9049
|
+
"kind": "nested"
|
|
10277
9050
|
}
|
|
10278
9051
|
]
|
|
10279
9052
|
}
|
|
@@ -11150,25 +9923,6 @@ async function getCounter1155(address, config) {
|
|
|
11150
9923
|
const contract = getContract(config);
|
|
11151
9924
|
return BigInt((await contract.get_counter(address)).toString());
|
|
11152
9925
|
}
|
|
11153
|
-
|
|
11154
|
-
// src/utils/bigint.ts
|
|
11155
|
-
function stringifyBigInts(obj) {
|
|
11156
|
-
if (typeof obj === "bigint") {
|
|
11157
|
-
return obj.toString();
|
|
11158
|
-
}
|
|
11159
|
-
if (Array.isArray(obj)) {
|
|
11160
|
-
return obj.map(stringifyBigInts);
|
|
11161
|
-
}
|
|
11162
|
-
if (obj !== null && typeof obj === "object") {
|
|
11163
|
-
return Object.fromEntries(
|
|
11164
|
-
Object.entries(obj).map(([key, value]) => [
|
|
11165
|
-
key,
|
|
11166
|
-
stringifyBigInts(value)
|
|
11167
|
-
])
|
|
11168
|
-
);
|
|
11169
|
-
}
|
|
11170
|
-
return obj;
|
|
11171
|
-
}
|
|
11172
9926
|
var STARKNET_DOMAIN = [
|
|
11173
9927
|
{ name: "name", type: "shortstring" },
|
|
11174
9928
|
{ name: "version", type: "shortstring" },
|
|
@@ -11600,135 +10354,6 @@ var StarknetVenue = class {
|
|
|
11600
10354
|
}
|
|
11601
10355
|
};
|
|
11602
10356
|
|
|
11603
|
-
// src/starknet/admin-auth/types.ts
|
|
11604
|
-
var ADMIN_SCOPE = "admin-api";
|
|
11605
|
-
function adminRequestDigest(req) {
|
|
11606
|
-
return hash.computePoseidonHashOnElements([
|
|
11607
|
-
hash.starknetKeccak(req.method.toUpperCase()),
|
|
11608
|
-
hash.starknetKeccak(req.path),
|
|
11609
|
-
hash.starknetKeccak(req.body ?? ""),
|
|
11610
|
-
num.toBigInt(req.nonce),
|
|
11611
|
-
BigInt(req.ts)
|
|
11612
|
-
]);
|
|
11613
|
-
}
|
|
11614
|
-
function signAdminRequest(sessionPrivateKey, req) {
|
|
11615
|
-
const digest = adminRequestDigest(req);
|
|
11616
|
-
return ec.starkCurve.sign(digest, sessionPrivateKey).toCompactHex();
|
|
11617
|
-
}
|
|
11618
|
-
function verifyAdminRequestSig(sessionPublicKey, req, sig) {
|
|
11619
|
-
try {
|
|
11620
|
-
return ec.starkCurve.verify(sig, adminRequestDigest(req), sessionPublicKey);
|
|
11621
|
-
} catch {
|
|
11622
|
-
return false;
|
|
11623
|
-
}
|
|
11624
|
-
}
|
|
11625
|
-
function buildAdminSessionTypedData(p) {
|
|
11626
|
-
return {
|
|
11627
|
-
types: {
|
|
11628
|
-
StarknetDomain: [
|
|
11629
|
-
{ name: "name", type: "shortstring" },
|
|
11630
|
-
{ name: "version", type: "shortstring" },
|
|
11631
|
-
{ name: "chainId", type: "shortstring" },
|
|
11632
|
-
{ name: "revision", type: "shortstring" }
|
|
11633
|
-
],
|
|
11634
|
-
AdminSession: [
|
|
11635
|
-
{ name: "sessionKeyHash", type: "felt" },
|
|
11636
|
-
{ name: "scope", type: "shortstring" },
|
|
11637
|
-
{ name: "issuedAt", type: "felt" },
|
|
11638
|
-
{ name: "expiresAt", type: "felt" }
|
|
11639
|
-
]
|
|
11640
|
-
},
|
|
11641
|
-
primaryType: "AdminSession",
|
|
11642
|
-
domain: { name: "Medialane Admin", version: "1", chainId: p.chainId ?? "SN_MAIN", revision: "1" },
|
|
11643
|
-
message: {
|
|
11644
|
-
sessionKeyHash: p.sessionKeyHash,
|
|
11645
|
-
scope: p.scope,
|
|
11646
|
-
issuedAt: String(p.issuedAt),
|
|
11647
|
-
expiresAt: String(p.expiresAt)
|
|
11648
|
-
}
|
|
11649
|
-
};
|
|
11650
|
-
}
|
|
11651
|
-
function sessionKeyHashOf(sessionPublicKey) {
|
|
11652
|
-
return num.toHex(hash.starknetKeccak(sessionPublicKey));
|
|
11653
|
-
}
|
|
11654
|
-
async function createAdminSessionGrant(signTypedData, opts) {
|
|
11655
|
-
const priv = ec.starkCurve.utils.randomPrivateKey();
|
|
11656
|
-
const sessionPrivateKey = "0x" + encode.buf2hex(priv);
|
|
11657
|
-
const sessionPublicKey = "0x" + encode.buf2hex(ec.starkCurve.getPublicKey(sessionPrivateKey, false));
|
|
11658
|
-
const sessionKeyHash = sessionKeyHashOf(sessionPublicKey);
|
|
11659
|
-
const nowSec = Math.floor((opts.now?.() ?? Date.now()) / 1e3);
|
|
11660
|
-
const issuedAt = nowSec;
|
|
11661
|
-
const expiresAt = nowSec + (opts.ttlSeconds ?? 7200);
|
|
11662
|
-
const data = buildAdminSessionTypedData({ sessionKeyHash, scope: ADMIN_SCOPE, issuedAt, expiresAt, chainId: opts.chainId });
|
|
11663
|
-
const walletSig = await signTypedData(data);
|
|
11664
|
-
const grant = {
|
|
11665
|
-
wallet: opts.wallet,
|
|
11666
|
-
chain: opts.chain ?? "STARKNET",
|
|
11667
|
-
sessionPublicKey,
|
|
11668
|
-
sessionKeyHash,
|
|
11669
|
-
scope: ADMIN_SCOPE,
|
|
11670
|
-
issuedAt,
|
|
11671
|
-
expiresAt,
|
|
11672
|
-
walletSig
|
|
11673
|
-
};
|
|
11674
|
-
return { grant, sessionPrivateKey };
|
|
11675
|
-
}
|
|
11676
|
-
|
|
11677
|
-
// src/starknet/admin-auth/headers.ts
|
|
11678
|
-
var ADMIN_HEADERS = {
|
|
11679
|
-
grant: "x-ml-admin-grant",
|
|
11680
|
-
sig: "x-ml-admin-sig",
|
|
11681
|
-
nonce: "x-ml-admin-nonce",
|
|
11682
|
-
ts: "x-ml-admin-ts"
|
|
11683
|
-
};
|
|
11684
|
-
function b64urlEncode(s) {
|
|
11685
|
-
const bytes = new TextEncoder().encode(s);
|
|
11686
|
-
let bin = "";
|
|
11687
|
-
for (const b of bytes) bin += String.fromCharCode(b);
|
|
11688
|
-
return btoa(bin).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
11689
|
-
}
|
|
11690
|
-
function b64urlDecode(s) {
|
|
11691
|
-
const pad = s.length % 4 ? "=".repeat(4 - s.length % 4) : "";
|
|
11692
|
-
const bin = atob(s.replace(/-/g, "+").replace(/_/g, "/") + pad);
|
|
11693
|
-
const bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));
|
|
11694
|
-
return new TextDecoder().decode(bytes);
|
|
11695
|
-
}
|
|
11696
|
-
function randomNonce() {
|
|
11697
|
-
const b = new Uint8Array(16);
|
|
11698
|
-
crypto.getRandomValues(b);
|
|
11699
|
-
let hex = "";
|
|
11700
|
-
for (const x of b) hex += x.toString(16).padStart(2, "0");
|
|
11701
|
-
return "0x" + hex;
|
|
11702
|
-
}
|
|
11703
|
-
function encodeAdminHeaders(session, reqInit) {
|
|
11704
|
-
const nonce = randomNonce();
|
|
11705
|
-
const ts = Math.floor((reqInit.now?.() ?? Date.now()) / 1e3);
|
|
11706
|
-
const req = { method: reqInit.method, path: reqInit.path, body: reqInit.body ?? "", nonce, ts };
|
|
11707
|
-
const sig = signAdminRequest(session.sessionPrivateKey, req);
|
|
11708
|
-
return {
|
|
11709
|
-
[ADMIN_HEADERS.grant]: b64urlEncode(JSON.stringify(session.grant)),
|
|
11710
|
-
[ADMIN_HEADERS.sig]: sig,
|
|
11711
|
-
[ADMIN_HEADERS.nonce]: nonce,
|
|
11712
|
-
[ADMIN_HEADERS.ts]: String(ts)
|
|
11713
|
-
};
|
|
11714
|
-
}
|
|
11715
|
-
function parseAdminHeaders(get) {
|
|
11716
|
-
const rawGrant = get(ADMIN_HEADERS.grant);
|
|
11717
|
-
const sig = get(ADMIN_HEADERS.sig);
|
|
11718
|
-
const nonce = get(ADMIN_HEADERS.nonce);
|
|
11719
|
-
const tsRaw = get(ADMIN_HEADERS.ts);
|
|
11720
|
-
if (!rawGrant || !sig || !nonce || !tsRaw) return null;
|
|
11721
|
-
try {
|
|
11722
|
-
const grant = JSON.parse(b64urlDecode(rawGrant));
|
|
11723
|
-
if (!grant.wallet || !grant.sessionPublicKey || !grant.sessionKeyHash || !Array.isArray(grant.walletSig) || typeof grant.expiresAt !== "number") return null;
|
|
11724
|
-
const ts = Number(tsRaw);
|
|
11725
|
-
if (!Number.isFinite(ts)) return null;
|
|
11726
|
-
return { grant, sig, nonce, ts };
|
|
11727
|
-
} catch {
|
|
11728
|
-
return null;
|
|
11729
|
-
}
|
|
11730
|
-
}
|
|
11731
|
-
|
|
11732
10357
|
// src/starknet/siws/client.ts
|
|
11733
10358
|
var STORAGE_PREFIX = "ml_siws_";
|
|
11734
10359
|
function decodeBase64url(str) {
|
|
@@ -11847,7 +10472,7 @@ function buildFundingTransferCall(instructions) {
|
|
|
11847
10472
|
async function fundWithChainTransfer(api, wallet, options) {
|
|
11848
10473
|
const step = options.onStep ?? (() => {
|
|
11849
10474
|
});
|
|
11850
|
-
const
|
|
10475
|
+
const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
11851
10476
|
const pollMs = options.pollMs ?? 3e3;
|
|
11852
10477
|
const maxPolls = options.maxPolls ?? 20;
|
|
11853
10478
|
step("creating");
|
|
@@ -11877,19 +10502,11 @@ async function fundWithChainTransfer(api, wallet, options) {
|
|
|
11877
10502
|
return { status: "SETTLED", intentId: intent.id, credited: res.data.credited };
|
|
11878
10503
|
}
|
|
11879
10504
|
reason = res.data.reason;
|
|
11880
|
-
await
|
|
10505
|
+
await sleep(pollMs);
|
|
11881
10506
|
}
|
|
11882
10507
|
return { status: "PENDING", intentId: intent.id, reason };
|
|
11883
10508
|
}
|
|
11884
10509
|
|
|
11885
|
-
// src/errors.ts
|
|
11886
|
-
var UserFacingError = class extends Error {
|
|
11887
|
-
constructor(message) {
|
|
11888
|
-
super(message);
|
|
11889
|
-
this.name = "UserFacingError";
|
|
11890
|
-
}
|
|
11891
|
-
};
|
|
11892
|
-
|
|
11893
10510
|
// src/starknet/services/executeIntent.ts
|
|
11894
10511
|
async function confirmIntentBestEffort(client, intentId, txHash) {
|
|
11895
10512
|
await client.api.confirmIntent(intentId, txHash).catch(() => {
|
|
@@ -11958,323 +10575,6 @@ async function executeIntents(provider, signer, client, intents, opts = {}) {
|
|
|
11958
10575
|
]);
|
|
11959
10576
|
return { txHash, receipt };
|
|
11960
10577
|
}
|
|
11961
|
-
|
|
11962
|
-
// src/services/registry.ts
|
|
11963
|
-
var SN2 = getStarknetCoordinates("STARKNET");
|
|
11964
|
-
var SERVICES = {
|
|
11965
|
-
"mip-erc721": {
|
|
11966
|
-
id: "mip-erc721",
|
|
11967
|
-
displayName: "IP Collection",
|
|
11968
|
-
description: "Tokenize intellectual property as a per-creator ERC-721 collection.",
|
|
11969
|
-
standard: "ERC721",
|
|
11970
|
-
provenance: "MEDIALANE",
|
|
11971
|
-
onchain: {
|
|
11972
|
-
STARKNET: {
|
|
11973
|
-
factoryAddress: SN2.collection721,
|
|
11974
|
-
startBlock: SN2.collection721StartBlock
|
|
11975
|
-
}
|
|
11976
|
-
},
|
|
11977
|
-
uiVariant: "standard",
|
|
11978
|
-
capabilities: ["list", "buy", "make_offer", "cancel", "transfer", "mint", "remix", "license"],
|
|
11979
|
-
events: [
|
|
11980
|
-
{ name: "CollectionCreated", emittedBy: "factory" }
|
|
11981
|
-
],
|
|
11982
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
11983
|
-
},
|
|
11984
|
-
"ip-erc721": {
|
|
11985
|
-
id: "ip-erc721",
|
|
11986
|
-
displayName: "Programmable IP",
|
|
11987
|
-
description: "One shared ERC-721 contract any wallet can mint into.",
|
|
11988
|
-
standard: "ERC721",
|
|
11989
|
-
provenance: "MEDIALANE",
|
|
11990
|
-
uiVariant: "standard",
|
|
11991
|
-
capabilities: ["list", "buy", "make_offer", "cancel", "transfer", "mint", "remix", "license"],
|
|
11992
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
11993
|
-
},
|
|
11994
|
-
"data-tokenization-erc721": {
|
|
11995
|
-
id: "data-tokenization-erc721",
|
|
11996
|
-
displayName: "Data Tokenization",
|
|
11997
|
-
description: "Establish verifiable ownership of your data, with licensing terms that hold up wherever it travels.",
|
|
11998
|
-
standard: "ERC721",
|
|
11999
|
-
provenance: "MEDIALANE",
|
|
12000
|
-
onchain: {
|
|
12001
|
-
STARKNET: {
|
|
12002
|
-
factoryAddress: SN2.dataTokenization721,
|
|
12003
|
-
startBlock: SN2.dataTokenization721StartBlock
|
|
12004
|
-
}
|
|
12005
|
-
},
|
|
12006
|
-
uiVariant: "standard",
|
|
12007
|
-
capabilities: ["list", "buy", "make_offer", "cancel", "transfer", "mint", "remix", "license"],
|
|
12008
|
-
events: [
|
|
12009
|
-
{ name: "CollectionCreated", emittedBy: "factory" }
|
|
12010
|
-
],
|
|
12011
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12012
|
-
},
|
|
12013
|
-
"mip-erc1155": {
|
|
12014
|
-
id: "mip-erc1155",
|
|
12015
|
-
displayName: "NFT Editions",
|
|
12016
|
-
description: "Per-creator ERC-1155 collection; creator mints editions.",
|
|
12017
|
-
standard: "ERC1155",
|
|
12018
|
-
provenance: "MEDIALANE",
|
|
12019
|
-
onchain: {
|
|
12020
|
-
STARKNET: {
|
|
12021
|
-
factoryAddress: SN2.collection1155,
|
|
12022
|
-
classHash: SN2.collection1155ClassHash,
|
|
12023
|
-
startBlock: SN2.collection1155StartBlock
|
|
12024
|
-
}
|
|
12025
|
-
},
|
|
12026
|
-
uiVariant: "edition",
|
|
12027
|
-
capabilities: ["list", "buy", "make_offer", "cancel", "transfer", "mint", "remix", "license"],
|
|
12028
|
-
events: [
|
|
12029
|
-
{ name: "CollectionDeployed", emittedBy: "factory" }
|
|
12030
|
-
],
|
|
12031
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12032
|
-
},
|
|
12033
|
-
"pop-protocol": {
|
|
12034
|
-
id: "pop-protocol",
|
|
12035
|
-
displayName: "POP Protocol",
|
|
12036
|
-
description: "Soulbound proof-of-presence collectibles per event.",
|
|
12037
|
-
standard: "ERC721",
|
|
12038
|
-
provenance: "MEDIALANE",
|
|
12039
|
-
onchain: {
|
|
12040
|
-
STARKNET: {
|
|
12041
|
-
factoryAddress: SN2.popFactory,
|
|
12042
|
-
classHash: SN2.popCollectionClassHash
|
|
12043
|
-
}
|
|
12044
|
-
},
|
|
12045
|
-
uiVariant: "pop",
|
|
12046
|
-
capabilities: ["claim", "mint"],
|
|
12047
|
-
events: [
|
|
12048
|
-
{ name: "CollectionCreated", emittedBy: "factory" },
|
|
12049
|
-
{ name: "AllowlistUpdated", emittedBy: "instance", poll: "slow" }
|
|
12050
|
-
],
|
|
12051
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12052
|
-
},
|
|
12053
|
-
"certificate-emission": {
|
|
12054
|
-
id: "certificate-emission",
|
|
12055
|
-
displayName: "Certificate Emission",
|
|
12056
|
-
description: "Issue a soulbound credential to a list of recipients in one run \u2014 everyone gets a wallet and their certificate.",
|
|
12057
|
-
standard: "ERC721",
|
|
12058
|
-
provenance: "MEDIALANE",
|
|
12059
|
-
onchain: {
|
|
12060
|
-
STARKNET: {
|
|
12061
|
-
factoryAddress: SN2.popFactory,
|
|
12062
|
-
classHash: SN2.popCollectionClassHash
|
|
12063
|
-
}
|
|
12064
|
-
},
|
|
12065
|
-
uiVariant: "pop",
|
|
12066
|
-
capabilities: ["mint", "airdrop"],
|
|
12067
|
-
events: [
|
|
12068
|
-
{ name: "CollectionCreated", emittedBy: "factory" }
|
|
12069
|
-
],
|
|
12070
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12071
|
-
},
|
|
12072
|
-
"drop-collection": {
|
|
12073
|
-
id: "drop-collection",
|
|
12074
|
-
displayName: "Collection Drop",
|
|
12075
|
-
description: "Sequential mint with claim windows + allowlist.",
|
|
12076
|
-
standard: "ERC721",
|
|
12077
|
-
provenance: "MEDIALANE",
|
|
12078
|
-
onchain: {
|
|
12079
|
-
STARKNET: {
|
|
12080
|
-
factoryAddress: SN2.dropFactory,
|
|
12081
|
-
classHash: SN2.dropCollectionClassHash
|
|
12082
|
-
}
|
|
12083
|
-
},
|
|
12084
|
-
uiVariant: "drop",
|
|
12085
|
-
capabilities: ["claim", "list", "buy", "make_offer", "cancel", "transfer"],
|
|
12086
|
-
events: [
|
|
12087
|
-
{ name: "DropCreated", emittedBy: "factory" },
|
|
12088
|
-
{ name: "AllowlistUpdated", emittedBy: "instance", poll: "slow" }
|
|
12089
|
-
],
|
|
12090
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12091
|
-
},
|
|
12092
|
-
"ip-tickets": {
|
|
12093
|
-
id: "ip-tickets",
|
|
12094
|
-
displayName: "IP Tickets",
|
|
12095
|
-
description: "Create verifiable on-chain tickets \u2014 mint to attendees, trade like any collection.",
|
|
12096
|
-
standard: "ERC1155",
|
|
12097
|
-
provenance: "MEDIALANE",
|
|
12098
|
-
onchain: {
|
|
12099
|
-
STARKNET: {
|
|
12100
|
-
factoryAddress: SN2.ipTicketsFactory,
|
|
12101
|
-
classHash: SN2.ipTicketCollectionClassHash
|
|
12102
|
-
}
|
|
12103
|
-
},
|
|
12104
|
-
uiVariant: "ticket",
|
|
12105
|
-
capabilities: ["mint", "redeem", "list", "buy", "make_offer", "cancel", "transfer"],
|
|
12106
|
-
events: [
|
|
12107
|
-
{ name: "CollectionDeployed", emittedBy: "factory" },
|
|
12108
|
-
{ name: "TicketCreated", emittedBy: "instance" }
|
|
12109
|
-
],
|
|
12110
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12111
|
-
},
|
|
12112
|
-
"ip-ticketing": {
|
|
12113
|
-
id: "ip-ticketing",
|
|
12114
|
-
displayName: "IP Ticketing",
|
|
12115
|
-
description: "Distribute verifiable on-chain tickets to a list of recipients in one run \u2014 everyone gets a wallet and their ticket.",
|
|
12116
|
-
standard: "ERC1155",
|
|
12117
|
-
provenance: "MEDIALANE",
|
|
12118
|
-
onchain: {
|
|
12119
|
-
STARKNET: {
|
|
12120
|
-
factoryAddress: SN2.ipTicketsFactory,
|
|
12121
|
-
classHash: SN2.ipTicketCollectionClassHash
|
|
12122
|
-
}
|
|
12123
|
-
},
|
|
12124
|
-
uiVariant: "ticket",
|
|
12125
|
-
capabilities: ["mint", "airdrop", "redeem", "list", "buy", "make_offer", "cancel", "transfer"],
|
|
12126
|
-
events: [
|
|
12127
|
-
{ name: "CollectionDeployed", emittedBy: "factory" },
|
|
12128
|
-
{ name: "TicketCreated", emittedBy: "instance" }
|
|
12129
|
-
],
|
|
12130
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12131
|
-
},
|
|
12132
|
-
"ip-club": {
|
|
12133
|
-
id: "ip-club",
|
|
12134
|
-
displayName: "IP Club",
|
|
12135
|
-
description: "Membership clubs \u2014 create tiers, mint membership cards, trade like any collection.",
|
|
12136
|
-
standard: "ERC1155",
|
|
12137
|
-
provenance: "MEDIALANE",
|
|
12138
|
-
onchain: {
|
|
12139
|
-
STARKNET: {
|
|
12140
|
-
factoryAddress: SN2.ipClubFactory,
|
|
12141
|
-
classHash: SN2.ipClubCollectionClassHash
|
|
12142
|
-
}
|
|
12143
|
-
},
|
|
12144
|
-
uiVariant: "club",
|
|
12145
|
-
capabilities: ["mint", "list", "buy", "make_offer", "cancel", "transfer"],
|
|
12146
|
-
events: [
|
|
12147
|
-
{ name: "ClubDeployed", emittedBy: "factory" },
|
|
12148
|
-
{ name: "MembershipCreated", emittedBy: "instance" }
|
|
12149
|
-
],
|
|
12150
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12151
|
-
},
|
|
12152
|
-
"ip-sponsorship": {
|
|
12153
|
-
id: "ip-sponsorship",
|
|
12154
|
-
displayName: "IP Sponsorship",
|
|
12155
|
-
description: "Sponsorship offers and licenses anchored to an existing Medialane asset.",
|
|
12156
|
-
standard: "ERC721",
|
|
12157
|
-
provenance: "MEDIALANE",
|
|
12158
|
-
onchain: {
|
|
12159
|
-
STARKNET: {
|
|
12160
|
-
factoryAddress: SN2.ipSponsorship,
|
|
12161
|
-
classHash: SN2.ipSponsorshipClassHash,
|
|
12162
|
-
startBlock: SN2.ipSponsorshipStartBlock
|
|
12163
|
-
}
|
|
12164
|
-
},
|
|
12165
|
-
uiVariant: "standard",
|
|
12166
|
-
capabilities: ["sponsor", "transfer"],
|
|
12167
|
-
events: [
|
|
12168
|
-
{ name: "OfferCreated", emittedBy: "factory" },
|
|
12169
|
-
{ name: "ProposalCreated", emittedBy: "factory" },
|
|
12170
|
-
{ name: "LicenseMinted", emittedBy: "factory" }
|
|
12171
|
-
],
|
|
12172
|
-
metadataSchema: { licenseDefault: "CC BY-SA" }
|
|
12173
|
-
},
|
|
12174
|
-
"creator-coin": {
|
|
12175
|
-
id: "creator-coin",
|
|
12176
|
-
displayName: "Creator Coin",
|
|
12177
|
-
description: "Launch a fixed-supply social token with permanently-locked Ekubo liquidity.",
|
|
12178
|
-
standard: "ERC20",
|
|
12179
|
-
provenance: "MEDIALANE",
|
|
12180
|
-
onchain: {
|
|
12181
|
-
STARKNET: {
|
|
12182
|
-
factoryAddress: SN2.creatorCoinFactory,
|
|
12183
|
-
classHash: SN2.creatorCoinFactoryClassHash,
|
|
12184
|
-
startBlock: SN2.creatorCoinStartBlock
|
|
12185
|
-
}
|
|
12186
|
-
},
|
|
12187
|
-
uiVariant: "coin",
|
|
12188
|
-
capabilities: ["launch", "swap", "transfer"],
|
|
12189
|
-
events: [
|
|
12190
|
-
{ name: "CreatorCoinCreated", emittedBy: "factory" },
|
|
12191
|
-
{ name: "CreatorCoinLaunched", emittedBy: "factory" }
|
|
12192
|
-
]
|
|
12193
|
-
},
|
|
12194
|
-
"medialane-marketplace-erc721": {
|
|
12195
|
-
id: "medialane-marketplace-erc721",
|
|
12196
|
-
displayName: "Medialane Marketplace (ERC-721)",
|
|
12197
|
-
description: "ERC-721 order matching venue.",
|
|
12198
|
-
standard: "ERC721",
|
|
12199
|
-
provenance: "MEDIALANE",
|
|
12200
|
-
onchain: {
|
|
12201
|
-
STARKNET: {
|
|
12202
|
-
factoryAddress: SN2.marketplace721,
|
|
12203
|
-
classHash: SN2.marketplace721ClassHash,
|
|
12204
|
-
startBlock: SN2.marketplace721StartBlock
|
|
12205
|
-
}
|
|
12206
|
-
},
|
|
12207
|
-
uiVariant: "standard",
|
|
12208
|
-
capabilities: ["list", "buy", "make_offer", "cancel"],
|
|
12209
|
-
events: [
|
|
12210
|
-
{ name: "OrderCreated", emittedBy: "factory" },
|
|
12211
|
-
{ name: "OrderFulfilled", emittedBy: "factory" },
|
|
12212
|
-
{ name: "OrderCancelled", emittedBy: "factory" }
|
|
12213
|
-
]
|
|
12214
|
-
},
|
|
12215
|
-
"medialane-marketplace-erc1155": {
|
|
12216
|
-
id: "medialane-marketplace-erc1155",
|
|
12217
|
-
displayName: "Medialane Marketplace (ERC-1155)",
|
|
12218
|
-
description: "ERC-1155 order matching venue.",
|
|
12219
|
-
standard: "ERC1155",
|
|
12220
|
-
provenance: "MEDIALANE",
|
|
12221
|
-
onchain: {
|
|
12222
|
-
STARKNET: {
|
|
12223
|
-
factoryAddress: SN2.marketplace1155,
|
|
12224
|
-
classHash: SN2.marketplace1155ClassHash,
|
|
12225
|
-
startBlock: SN2.marketplace1155StartBlock
|
|
12226
|
-
}
|
|
12227
|
-
},
|
|
12228
|
-
uiVariant: "edition",
|
|
12229
|
-
capabilities: ["list", "buy", "make_offer", "cancel"],
|
|
12230
|
-
events: [
|
|
12231
|
-
{ name: "OrderCreated", emittedBy: "factory" },
|
|
12232
|
-
{ name: "OrderFulfilled", emittedBy: "factory" },
|
|
12233
|
-
{ name: "OrderCancelled", emittedBy: "factory" }
|
|
12234
|
-
]
|
|
12235
|
-
},
|
|
12236
|
-
"unruggable-erc20": {
|
|
12237
|
-
id: "unruggable-erc20",
|
|
12238
|
-
displayName: "Unruggable",
|
|
12239
|
-
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.",
|
|
12240
|
-
standard: "ERC20",
|
|
12241
|
-
provenance: "EXTERNAL",
|
|
12242
|
-
uiVariant: "coin",
|
|
12243
|
-
capabilities: ["swap", "transfer"]
|
|
12244
|
-
},
|
|
12245
|
-
"external-erc20": {
|
|
12246
|
-
id: "external-erc20",
|
|
12247
|
-
displayName: "Memecoin",
|
|
12248
|
-
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.",
|
|
12249
|
-
standard: "ERC20",
|
|
12250
|
-
provenance: "EXTERNAL",
|
|
12251
|
-
uiVariant: "coin",
|
|
12252
|
-
capabilities: ["swap", "transfer"]
|
|
12253
|
-
},
|
|
12254
|
-
"external-erc721": {
|
|
12255
|
-
id: "external-erc721",
|
|
12256
|
-
displayName: "External ERC-721",
|
|
12257
|
-
description: "ERC-721 contract not deployed via a Medialane service.",
|
|
12258
|
-
standard: "ERC721",
|
|
12259
|
-
provenance: "EXTERNAL",
|
|
12260
|
-
uiVariant: "standard",
|
|
12261
|
-
capabilities: ["list", "buy", "make_offer", "cancel", "transfer"]
|
|
12262
|
-
},
|
|
12263
|
-
"external-erc1155": {
|
|
12264
|
-
id: "external-erc1155",
|
|
12265
|
-
displayName: "External ERC-1155",
|
|
12266
|
-
description: "ERC-1155 contract not deployed via a Medialane service.",
|
|
12267
|
-
standard: "ERC1155",
|
|
12268
|
-
provenance: "EXTERNAL",
|
|
12269
|
-
uiVariant: "edition",
|
|
12270
|
-
capabilities: ["list", "buy", "make_offer", "cancel", "transfer"]
|
|
12271
|
-
}
|
|
12272
|
-
};
|
|
12273
|
-
function getService(id) {
|
|
12274
|
-
return id && id in SERVICES ? SERVICES[id] : void 0;
|
|
12275
|
-
}
|
|
12276
|
-
|
|
12277
|
-
// src/starknet/services/receipts.ts
|
|
12278
10578
|
var DEPLOY_EVENTS = {
|
|
12279
10579
|
"mip-erc1155": { event: "CollectionDeployed", address: (e) => e.keys?.[1] },
|
|
12280
10580
|
"ip-tickets": { event: "CollectionDeployed", address: (e) => e.keys?.[1] },
|
|
@@ -12394,17 +10694,6 @@ function deriveOwnerKeyPair(secret, recipientId) {
|
|
|
12394
10694
|
const publicKey = ec.starkCurve.getStarkKey(privateKey);
|
|
12395
10695
|
return { privateKey, publicKey };
|
|
12396
10696
|
}
|
|
12397
|
-
function ownerConstructorCalldata(ownerPubkey) {
|
|
12398
|
-
return ["0x0", num.toHex(ownerPubkey), "0x1"];
|
|
12399
|
-
}
|
|
12400
|
-
function computeAccountAddress(ownerPubkey, salt = 0) {
|
|
12401
|
-
return hash.calculateContractAddressFromHash(
|
|
12402
|
-
num.toHex(salt),
|
|
12403
|
-
STARKNET_MEDIAWALLET_CLASS_HASH,
|
|
12404
|
-
ownerConstructorCalldata(ownerPubkey),
|
|
12405
|
-
0
|
|
12406
|
-
);
|
|
12407
|
-
}
|
|
12408
10697
|
var STARKNET_SIGNER_TYPE = "0x537461726b6e6574205369676e6572";
|
|
12409
10698
|
var OPTION_NONE = "0x1";
|
|
12410
10699
|
var SIGNER_STARKNET = "0x0";
|
|
@@ -12527,53 +10816,6 @@ async function getEscapeSecurityPeriod(provider, address) {
|
|
|
12527
10816
|
});
|
|
12528
10817
|
return Number(res[0]);
|
|
12529
10818
|
}
|
|
12530
|
-
async function deriveAesKey(prfSecret, hkdfInfo) {
|
|
12531
|
-
const hkdf = await crypto.subtle.importKey("raw", prfSecret, "HKDF", false, ["deriveKey"]);
|
|
12532
|
-
return crypto.subtle.deriveKey(
|
|
12533
|
-
{ name: "HKDF", hash: "SHA-256", salt: new Uint8Array(0), info: hkdfInfo },
|
|
12534
|
-
hkdf,
|
|
12535
|
-
{ name: "AES-GCM", length: 256 },
|
|
12536
|
-
false,
|
|
12537
|
-
["encrypt", "decrypt"]
|
|
12538
|
-
);
|
|
12539
|
-
}
|
|
12540
|
-
function generateStarkKeyPair() {
|
|
12541
|
-
const privateKeyHex = "0x" + Array.from(ec.starkCurve.utils.randomPrivateKey()).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
12542
|
-
return { privateKeyHex, publicKeyHex: ec.starkCurve.getStarkKey(privateKeyHex) };
|
|
12543
|
-
}
|
|
12544
|
-
var InvalidStarkPrivateKeyError = class extends Error {
|
|
12545
|
-
constructor(reason) {
|
|
12546
|
-
super(`Not a valid Starknet private key: ${reason}`);
|
|
12547
|
-
this.name = "InvalidStarkPrivateKeyError";
|
|
12548
|
-
}
|
|
12549
|
-
};
|
|
12550
|
-
function starkKeyPairFromPrivateKey(input) {
|
|
12551
|
-
const trimmed = input.trim().replace(/\s+/g, "");
|
|
12552
|
-
const body = trimmed.startsWith("0x") || trimmed.startsWith("0X") ? trimmed.slice(2) : trimmed;
|
|
12553
|
-
if (body.length === 0) throw new InvalidStarkPrivateKeyError("it is empty");
|
|
12554
|
-
if (!/^[0-9a-fA-F]+$/.test(body)) throw new InvalidStarkPrivateKeyError("it is not hexadecimal");
|
|
12555
|
-
if (body.length > 64) throw new InvalidStarkPrivateKeyError("it is too long");
|
|
12556
|
-
const value = BigInt("0x" + body);
|
|
12557
|
-
if (value === 0n) throw new InvalidStarkPrivateKeyError("it is zero");
|
|
12558
|
-
if (value >= ec.starkCurve.CURVE.n) throw new InvalidStarkPrivateKeyError("it is outside the curve order");
|
|
12559
|
-
const privateKeyHex = "0x" + value.toString(16).padStart(64, "0");
|
|
12560
|
-
return { privateKeyHex, publicKeyHex: ec.starkCurve.getStarkKey(privateKeyHex) };
|
|
12561
|
-
}
|
|
12562
|
-
async function sealPrivateKey(aesKey, iv, privateKeyHex) {
|
|
12563
|
-
return crypto.subtle.encrypt(
|
|
12564
|
-
{ name: "AES-GCM", iv },
|
|
12565
|
-
aesKey,
|
|
12566
|
-
new TextEncoder().encode(privateKeyHex)
|
|
12567
|
-
);
|
|
12568
|
-
}
|
|
12569
|
-
async function unsealPrivateKey(aesKey, iv, ciphertext) {
|
|
12570
|
-
const buf = await crypto.subtle.decrypt({ name: "AES-GCM", iv }, aesKey, ciphertext);
|
|
12571
|
-
return new TextDecoder().decode(buf);
|
|
12572
|
-
}
|
|
12573
|
-
function signWithPrivateKey(privateKeyHex, msgHash) {
|
|
12574
|
-
const sig = ec.starkCurve.sign(msgHash, privateKeyHex);
|
|
12575
|
-
return [num.toHex(sig.r), num.toHex(sig.s)];
|
|
12576
|
-
}
|
|
12577
10819
|
|
|
12578
10820
|
// src/wallet/store.ts
|
|
12579
10821
|
function createOwnerStore(config) {
|
|
@@ -12751,150 +10993,6 @@ function createSelfFundConsent(estimateFee) {
|
|
|
12751
10993
|
}
|
|
12752
10994
|
};
|
|
12753
10995
|
}
|
|
12754
|
-
|
|
12755
|
-
// src/wallet/passkey.ts
|
|
12756
|
-
var PasskeyCancelledError = class extends Error {
|
|
12757
|
-
constructor(message = "Passkey prompt was cancelled.") {
|
|
12758
|
-
super(message);
|
|
12759
|
-
this.name = "PasskeyCancelledError";
|
|
12760
|
-
}
|
|
12761
|
-
};
|
|
12762
|
-
var encodeBase64 = (buf) => {
|
|
12763
|
-
const bytes = buf instanceof Uint8Array ? buf : new Uint8Array(buf);
|
|
12764
|
-
let binary = "";
|
|
12765
|
-
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
12766
|
-
return btoa(binary);
|
|
12767
|
-
};
|
|
12768
|
-
var decodeBase64 = (value) => {
|
|
12769
|
-
const binary = atob(value);
|
|
12770
|
-
const bytes = new Uint8Array(binary.length);
|
|
12771
|
-
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
12772
|
-
return bytes;
|
|
12773
|
-
};
|
|
12774
|
-
function isPasskeyCancellation(err) {
|
|
12775
|
-
const name = err?.name;
|
|
12776
|
-
return name === "NotAllowedError" || name === "AbortError";
|
|
12777
|
-
}
|
|
12778
|
-
function createPasskeyOwner(config) {
|
|
12779
|
-
const randomBytes = config.randomBytes ?? ((length) => crypto.getRandomValues(new Uint8Array(length)));
|
|
12780
|
-
const credentialsApi = () => {
|
|
12781
|
-
const api = config.credentials ?? (typeof navigator === "undefined" ? void 0 : navigator.credentials);
|
|
12782
|
-
if (!api) throw new Error("Passkeys are only available in a browser.");
|
|
12783
|
-
return api;
|
|
12784
|
-
};
|
|
12785
|
-
const prfUnsupportedMessage = () => {
|
|
12786
|
-
const isBrave = typeof navigator !== "undefined" && "brave" in navigator;
|
|
12787
|
-
const cause = isBrave ? "Brave doesn't currently support the WebAuthn PRF extension." : "This browser didn't return a passkey PRF secret.";
|
|
12788
|
-
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.`;
|
|
12789
|
-
};
|
|
12790
|
-
async function registerPasskey() {
|
|
12791
|
-
let credential;
|
|
12792
|
-
try {
|
|
12793
|
-
credential = await credentialsApi().create({
|
|
12794
|
-
publicKey: {
|
|
12795
|
-
challenge: randomBytes(32),
|
|
12796
|
-
rp: { name: config.relyingPartyName, id: config.relyingPartyId() },
|
|
12797
|
-
user: await config.passkeyUser(),
|
|
12798
|
-
excludeCredentials: config.knownCredentials(),
|
|
12799
|
-
pubKeyCredParams: [
|
|
12800
|
-
{ type: "public-key", alg: -7 },
|
|
12801
|
-
{ type: "public-key", alg: -257 }
|
|
12802
|
-
],
|
|
12803
|
-
authenticatorSelection: {
|
|
12804
|
-
residentKey: "required",
|
|
12805
|
-
userVerification: "required",
|
|
12806
|
-
authenticatorAttachment: "platform"
|
|
12807
|
-
},
|
|
12808
|
-
extensions: { prf: { eval: { first: config.prfSalt } } }
|
|
12809
|
-
}
|
|
12810
|
-
});
|
|
12811
|
-
} catch (err) {
|
|
12812
|
-
if (isPasskeyCancellation(err)) throw new PasskeyCancelledError();
|
|
12813
|
-
throw err;
|
|
12814
|
-
}
|
|
12815
|
-
const prf = credential.getClientExtensionResults().prf;
|
|
12816
|
-
return { credentialId: encodeBase64(credential.rawId), prfFirst: prf?.results?.first ?? null };
|
|
12817
|
-
}
|
|
12818
|
-
async function prfSecret(credentialId) {
|
|
12819
|
-
let assertion;
|
|
12820
|
-
try {
|
|
12821
|
-
assertion = await credentialsApi().get({
|
|
12822
|
-
publicKey: {
|
|
12823
|
-
challenge: randomBytes(32),
|
|
12824
|
-
rpId: config.relyingPartyId(),
|
|
12825
|
-
allowCredentials: [{ type: "public-key", id: decodeBase64(credentialId) }],
|
|
12826
|
-
userVerification: "required",
|
|
12827
|
-
extensions: { prf: { eval: { first: config.prfSalt } } }
|
|
12828
|
-
}
|
|
12829
|
-
});
|
|
12830
|
-
} catch (err) {
|
|
12831
|
-
if (isPasskeyCancellation(err)) throw new PasskeyCancelledError();
|
|
12832
|
-
throw err;
|
|
12833
|
-
}
|
|
12834
|
-
const result = assertion.getClientExtensionResults().prf?.results?.first;
|
|
12835
|
-
if (!result) throw new Error("Passkey PRF unavailable on this device/browser.");
|
|
12836
|
-
return new Uint8Array(result);
|
|
12837
|
-
}
|
|
12838
|
-
async function secretFromRegistration(registration) {
|
|
12839
|
-
if (registration.prfFirst) return new Uint8Array(registration.prfFirst);
|
|
12840
|
-
try {
|
|
12841
|
-
return await prfSecret(registration.credentialId);
|
|
12842
|
-
} catch {
|
|
12843
|
-
throw new Error(prfUnsupportedMessage());
|
|
12844
|
-
}
|
|
12845
|
-
}
|
|
12846
|
-
async function seal(secret, privateKeyHex) {
|
|
12847
|
-
const aes = await deriveAesKey(secret, config.hkdfInfo);
|
|
12848
|
-
const iv = randomBytes(12);
|
|
12849
|
-
const ciphertext = await sealPrivateKey(aes, iv, privateKeyHex);
|
|
12850
|
-
return { iv: encodeBase64(iv), ciphertext: encodeBase64(ciphertext) };
|
|
12851
|
-
}
|
|
12852
|
-
return {
|
|
12853
|
-
async createOwnerKey() {
|
|
12854
|
-
const registration = await registerPasskey();
|
|
12855
|
-
const secret = await secretFromRegistration(registration);
|
|
12856
|
-
const { privateKeyHex, publicKeyHex } = generateStarkKeyPair();
|
|
12857
|
-
const { iv, ciphertext } = await seal(secret, privateKeyHex);
|
|
12858
|
-
return {
|
|
12859
|
-
sealed: {
|
|
12860
|
-
credentialId: registration.credentialId,
|
|
12861
|
-
ownerPubKey: publicKeyHex,
|
|
12862
|
-
address: computeAccountAddress(publicKeyHex, 0),
|
|
12863
|
-
iv,
|
|
12864
|
-
ciphertext
|
|
12865
|
-
},
|
|
12866
|
-
privateKeyHex
|
|
12867
|
-
};
|
|
12868
|
-
},
|
|
12869
|
-
async unlockOwnerKey(sealed) {
|
|
12870
|
-
const secret = await prfSecret(sealed.credentialId);
|
|
12871
|
-
const aes = await deriveAesKey(secret, config.hkdfInfo);
|
|
12872
|
-
return unsealPrivateKey(aes, decodeBase64(sealed.iv), decodeBase64(sealed.ciphertext));
|
|
12873
|
-
},
|
|
12874
|
-
async sealImportedOwnerKey(recovery) {
|
|
12875
|
-
const { privateKeyHex, publicKeyHex } = starkKeyPairFromPrivateKey(recovery.privateKey);
|
|
12876
|
-
const registration = await registerPasskey();
|
|
12877
|
-
const secret = await secretFromRegistration(registration);
|
|
12878
|
-
const { iv, ciphertext } = await seal(secret, privateKeyHex);
|
|
12879
|
-
return {
|
|
12880
|
-
credentialId: registration.credentialId,
|
|
12881
|
-
ownerPubKey: publicKeyHex,
|
|
12882
|
-
address: recovery.walletAddress,
|
|
12883
|
-
iv,
|
|
12884
|
-
ciphertext
|
|
12885
|
-
};
|
|
12886
|
-
}
|
|
12887
|
-
};
|
|
12888
|
-
}
|
|
12889
|
-
|
|
12890
|
-
// src/utils/token.ts
|
|
12891
|
-
function getTokenBySymbol(symbol) {
|
|
12892
|
-
if (typeof symbol !== "string") return void 0;
|
|
12893
|
-
const upper = symbol.toUpperCase();
|
|
12894
|
-
return SUPPORTED_TOKENS.find((t) => t.symbol === upper);
|
|
12895
|
-
}
|
|
12896
|
-
|
|
12897
|
-
// src/wallet/executors.ts
|
|
12898
10996
|
function accountFor(provider, address, privateKeyHex) {
|
|
12899
10997
|
return new Account({ provider, address, signer: privateKeyHex, cairoVersion: "1" });
|
|
12900
10998
|
}
|
|
@@ -12998,7 +11096,7 @@ async function deploySelfFunded(input) {
|
|
|
12998
11096
|
});
|
|
12999
11097
|
return { transactionHash: transaction_hash };
|
|
13000
11098
|
}
|
|
13001
|
-
async function waitUntilDeployed(provider, address, timeoutMs = 9e4,
|
|
11099
|
+
async function waitUntilDeployed(provider, address, timeoutMs = 9e4, sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))) {
|
|
13002
11100
|
const deadline = Date.now() + timeoutMs;
|
|
13003
11101
|
let wait = 1e3;
|
|
13004
11102
|
for (; ; ) {
|
|
@@ -13008,7 +11106,7 @@ async function waitUntilDeployed(provider, address, timeoutMs = 9e4, sleep2 = (m
|
|
|
13008
11106
|
"Your wallet was submitted but has not appeared on Starknet yet. Please try again in a moment."
|
|
13009
11107
|
);
|
|
13010
11108
|
}
|
|
13011
|
-
await
|
|
11109
|
+
await sleep(wait);
|
|
13012
11110
|
wait = Math.min(Math.round(wait * 1.5), 5e3);
|
|
13013
11111
|
}
|
|
13014
11112
|
}
|
|
@@ -13230,6 +11328,6 @@ async function claimSessionWallet(api, walletAddress, deps) {
|
|
|
13230
11328
|
if (removeOwnerGuid) await deps.removeOwner(sealed, removeOwnerGuid);
|
|
13231
11329
|
}
|
|
13232
11330
|
|
|
13233
|
-
export {
|
|
11331
|
+
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 };
|
|
13234
11332
|
//# sourceMappingURL=index.js.map
|
|
13235
11333
|
//# sourceMappingURL=index.js.map
|