@medialane/sdk 0.53.0 → 0.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,253 @@
1
+ 'use strict';
2
+
3
+ var sha2_js = require('@noble/hashes/sha2.js');
4
+ var web3_js = require('@solana/web3.js');
5
+
6
+ // src/solana/encoding.ts
7
+ function instructionDiscriminator(name) {
8
+ return sha2_js.sha256(new TextEncoder().encode(`global:${name}`)).slice(0, 8);
9
+ }
10
+ function eventDiscriminator(name) {
11
+ return sha2_js.sha256(new TextEncoder().encode(`event:${name}`)).slice(0, 8);
12
+ }
13
+ var BorshWriter = class {
14
+ constructor() {
15
+ this.chunks = [];
16
+ }
17
+ u8(v) {
18
+ this.chunks.push(Uint8Array.of(v));
19
+ return this;
20
+ }
21
+ u16(v) {
22
+ const b = new Uint8Array(2);
23
+ new DataView(b.buffer).setUint16(0, v, true);
24
+ this.chunks.push(b);
25
+ return this;
26
+ }
27
+ u64(v) {
28
+ const b = new Uint8Array(8);
29
+ new DataView(b.buffer).setBigUint64(0, v, true);
30
+ this.chunks.push(b);
31
+ return this;
32
+ }
33
+ i64(v) {
34
+ const b = new Uint8Array(8);
35
+ new DataView(b.buffer).setBigInt64(0, v, true);
36
+ this.chunks.push(b);
37
+ return this;
38
+ }
39
+ string(v) {
40
+ const bytes = new TextEncoder().encode(v);
41
+ const len = new Uint8Array(4);
42
+ new DataView(len.buffer).setUint32(0, bytes.length, true);
43
+ this.chunks.push(len, bytes);
44
+ return this;
45
+ }
46
+ pubkey(v) {
47
+ this.chunks.push(v.toBytes());
48
+ return this;
49
+ }
50
+ option(v, write) {
51
+ if (v === null || v === void 0) {
52
+ this.u8(0);
53
+ } else {
54
+ this.u8(1);
55
+ write(v);
56
+ }
57
+ return this;
58
+ }
59
+ build(discriminator) {
60
+ const total = this.chunks.reduce((n, c) => n + c.length, discriminator.length);
61
+ const out = new Uint8Array(total);
62
+ out.set(discriminator, 0);
63
+ let offset = discriminator.length;
64
+ for (const chunk of this.chunks) {
65
+ out.set(chunk, offset);
66
+ offset += chunk.length;
67
+ }
68
+ return out;
69
+ }
70
+ };
71
+ function u64le(v) {
72
+ const b = new Uint8Array(8);
73
+ new DataView(b.buffer).setBigUint64(0, v, true);
74
+ return b;
75
+ }
76
+ function orderPda(program, offerer, salt) {
77
+ return web3_js.PublicKey.findProgramAddressSync(
78
+ [new TextEncoder().encode("order"), offerer.toBytes(), u64le(salt)],
79
+ program
80
+ )[0];
81
+ }
82
+ function counterPda(program, offerer) {
83
+ return web3_js.PublicKey.findProgramAddressSync(
84
+ [new TextEncoder().encode("counter"), offerer.toBytes()],
85
+ program
86
+ )[0];
87
+ }
88
+ function settlementPda(program) {
89
+ return web3_js.PublicKey.findProgramAddressSync([new TextEncoder().encode("authority")], program)[0];
90
+ }
91
+ function registryCounterPda(program) {
92
+ return web3_js.PublicKey.findProgramAddressSync([new TextEncoder().encode("counter")], program)[0];
93
+ }
94
+ function collectionRecordPda(program, coreCollection) {
95
+ return web3_js.PublicKey.findProgramAddressSync(
96
+ [new TextEncoder().encode("collection"), coreCollection.toBytes()],
97
+ program
98
+ )[0];
99
+ }
100
+ var MPL_CORE_PROGRAM_ID = new web3_js.PublicKey("CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d");
101
+
102
+ // src/chains.ts
103
+ var COORDINATES = {
104
+ STARKNET: {
105
+ rpcUrl: "https://rpc.starknet.lava.build",
106
+ marketplace721: "0x03eda9a2b6ad90845a43591bac8083ebaf677d51fdf20f503b2c01889e3131fc",
107
+ marketplace721ClassHash: "0x0700d9230d07e5203e27778c0dc70f9134d2b25bf319f7cf8348dc66a6923e90",
108
+ marketplace721StartBlock: 11198146,
109
+ marketplace1155: "0x07c4ce1c19ea48cc11135ed22b19ff745f5aec508c3828593002e4f76fdb1b38",
110
+ marketplace1155ClassHash: "0x0242f5c388da7cee2d99e2a69453c8159bf927fbec4e797a3cfdcbbcb5b68328",
111
+ marketplace1155StartBlock: 11198267,
112
+ collection721: "0x0225c3ae09506b8d97adc39649ca740dad5aac195b7f5f0441cc1852947acaea",
113
+ collection721StartBlock: 11198496,
114
+ ipNftClassHash: "0x012d3ae40ba35c7e2be0946532dac60e48932447912fdf96b674da67c029b9cc",
115
+ ipCollectionClassHash: "0x022155a1a130a40e57aac4b89c07fab3f616bc351b1270fc40f756b963afe8b4",
116
+ collection1155: "0x015368976d46fae5bfa1c58600f641d5aa5dbbf53ebc6b78aa3922194aad3551",
117
+ collection1155FactoryClassHash: "0x04eb6b419770f13bd191f120b9fc9ee624c0613ad4490062d293ca2016b3b1d2",
118
+ collection1155ClassHash: "0x06cf3f5a2322dac35e07a6064a5b8802f19fda8aa3f4726f0cb7bc05dea1bd78",
119
+ collection1155StartBlock: 11199527,
120
+ popFactory: "0x00b32c34b427d8f346b5843ada6a37bd3368d879fc752cd52b68a87287f60111",
121
+ popCollectionClassHash: "0x077c421686f10851872561953ea16898d933364b7f8937a5d7e2b1ba0a36263f",
122
+ dropFactory: "0x03587f42e29daee1b193f6cf83bf8627908ed6632d0d83fcb26225c50547d800",
123
+ dropCollectionClassHash: "0x00092e72cdb63067521e803aaf7d4101c3e3ce026ae6bc045ec4228027e58282",
124
+ nftComments: "0x02cdac70c94447189af0389dfea63f4d5e4154ea8a563de288a5ab1c39e37843",
125
+ creatorCoinFactory: "0x50fa807b5274079fb19374673d7bab6d2dc3af7e1032ea43eb6e44bcbde4c3c",
126
+ creatorCoinEkuboLauncher: "0x4f7fceb5ac10f12f9544a09580592e5bdf1b7f04f48765eecf12286d8ccb7b4",
127
+ creatorCoinClassHash: "0x743e4c8a5b96bb83bbf4af04edbbb482d5ece89eed9b729a79fb7df0cd0b6b6",
128
+ creatorCoinFactoryClassHash: "0x51765926b1344c9a20b8cd4b5abe7b7d47375ae97cf6804db3ea5d4b05a9b55",
129
+ creatorCoinStartBlock: 10474544,
130
+ ekuboCore: "0x00000005dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b",
131
+ ipTicketsFactory: "0x0664c2d6a4da9ee3ff053ceeba7579c01f2fedfd9d2b57b4c07af3734bd4acab",
132
+ ipTicketCollectionClassHash: "0x086f59c416e365e2bee4ceff9f1dcb96198f2342d50ba4621f60b831863adb6",
133
+ ipTicketsStartBlock: 11404656,
134
+ ipClubRegistry: "0x00e189c619b6bb07d78973a149641c59c37eb0716f8584d7520bce12d303eede",
135
+ ipClubNftClassHash: "0x02bc9b20cca21b04245e9215bf7121f4d7295b195890e449b472b573017fb889",
136
+ ipClubStartBlock: 11404776,
137
+ ipSponsorship: "0x044d9b9c3bb29b94685b0a3fe27a5e2dfa30a3637ab55979c718ebcd3268bc2f",
138
+ ipSponsorshipStartBlock: 11405085,
139
+ // Dedicated ip-erc721/MIP instance for sponsorship receipts (class hash
140
+ // 0x01bd7e39c5135b32b664e34cbbb4eafbd707a0fbc3ec2ef28657f52577d277d7) —
141
+ // never the genesis-mint instance.
142
+ ipSponsorshipLicense: "0x06bcfc4e97758a2abf95af4bd49596efdbfd88ccd740caddc56ad0a4bd095839"
143
+ }
144
+ };
145
+ function getCoordinates(chain) {
146
+ const c = COORDINATES[chain];
147
+ if (!c) throw new Error(`No coordinates configured for chain "${chain}"`);
148
+ return c;
149
+ }
150
+
151
+ // src/solana/venue.ts
152
+ var SolanaVenue = class {
153
+ constructor(opts) {
154
+ this.chain = "SOLANA";
155
+ this.connection = opts.connection;
156
+ const program = opts.programId ?? maybeCoords()?.marketplaceProgram;
157
+ if (!program) throw new Error("No Solana marketplace program configured");
158
+ this.program = new web3_js.PublicKey(program);
159
+ }
160
+ async registerOrder(signer, params) {
161
+ const offerer = signer.publicKey;
162
+ const salt = BigInt(params.salt);
163
+ const isNative = params.paymentToken === "native";
164
+ const counter = await this.getCounter(offerer.toBase58());
165
+ const writer = new BorshWriter().u64(salt).u8(params.side === "listing" ? 0 : 1).option(isNative ? null : new web3_js.PublicKey(params.paymentToken), (mint) => writer.pubkey(mint)).u64(BigInt(params.amount)).u16(params.royaltyMaxBps).i64(BigInt(params.startTime)).i64(BigInt(params.endTime)).u64(counter);
166
+ const order = orderPda(this.program, offerer, salt);
167
+ const asset = new web3_js.PublicKey(params.asset.contract);
168
+ const instruction = new web3_js.TransactionInstruction({
169
+ programId: this.program,
170
+ keys: [
171
+ { pubkey: offerer, isSigner: true, isWritable: true },
172
+ { pubkey: order, isSigner: false, isWritable: true },
173
+ { pubkey: counterPda(this.program, offerer), isSigner: false, isWritable: true },
174
+ { pubkey: settlementPda(this.program), isSigner: false, isWritable: false },
175
+ { pubkey: asset, isSigner: false, isWritable: true },
176
+ { pubkey: new web3_js.PublicKey(params.asset.tokenId), isSigner: false, isWritable: true },
177
+ { pubkey: MPL_CORE_PROGRAM_ID, isSigner: false, isWritable: false },
178
+ { pubkey: web3_js.SystemProgram.programId, isSigner: false, isWritable: false }
179
+ ],
180
+ data: Buffer.from(writer.build(instructionDiscriminator("register_order")))
181
+ });
182
+ const txHash = await this.send(signer, instruction);
183
+ return { txHash, orderRef: order.toBase58() };
184
+ }
185
+ async fulfillOrder() {
186
+ throw new Error(
187
+ "Solana fulfillment requires the order's creator remaining-accounts; use buildFulfillInstruction with explicit accounts"
188
+ );
189
+ }
190
+ async cancelOrder(signer, orderRef) {
191
+ const instruction = new web3_js.TransactionInstruction({
192
+ programId: this.program,
193
+ keys: [
194
+ { pubkey: signer.publicKey, isSigner: true, isWritable: false },
195
+ { pubkey: new web3_js.PublicKey(orderRef), isSigner: false, isWritable: true }
196
+ ],
197
+ data: Buffer.from(new BorshWriter().build(instructionDiscriminator("cancel_order")))
198
+ });
199
+ const txHash = await this.send(signer, instruction);
200
+ return { txHash };
201
+ }
202
+ async incrementCounter(signer) {
203
+ const instruction = new web3_js.TransactionInstruction({
204
+ programId: this.program,
205
+ keys: [
206
+ { pubkey: signer.publicKey, isSigner: true, isWritable: true },
207
+ { pubkey: counterPda(this.program, signer.publicKey), isSigner: false, isWritable: true },
208
+ { pubkey: web3_js.SystemProgram.programId, isSigner: false, isWritable: false }
209
+ ],
210
+ data: Buffer.from(new BorshWriter().build(instructionDiscriminator("increment_counter")))
211
+ });
212
+ const txHash = await this.send(signer, instruction);
213
+ return { txHash };
214
+ }
215
+ async getOrderDetails(orderRef) {
216
+ const info = await this.connection.getAccountInfo(new web3_js.PublicKey(orderRef));
217
+ return info?.data ?? null;
218
+ }
219
+ async getCounter(address) {
220
+ const pda = counterPda(this.program, new web3_js.PublicKey(address));
221
+ const info = await this.connection.getAccountInfo(pda);
222
+ if (!info || info.data.length < 16) return 0n;
223
+ return new DataView(info.data.buffer, info.data.byteOffset + 8, 8).getBigUint64(0, true);
224
+ }
225
+ async send(signer, instruction) {
226
+ const tx = new web3_js.Transaction().add(instruction);
227
+ tx.feePayer = signer.publicKey;
228
+ tx.recentBlockhash = (await this.connection.getLatestBlockhash()).blockhash;
229
+ const signed = await signer.signTransaction(tx);
230
+ return this.connection.sendRawTransaction(signed.serialize());
231
+ }
232
+ };
233
+ function maybeCoords() {
234
+ try {
235
+ return getCoordinates("SOLANA");
236
+ } catch {
237
+ return void 0;
238
+ }
239
+ }
240
+
241
+ exports.BorshWriter = BorshWriter;
242
+ exports.MPL_CORE_PROGRAM_ID = MPL_CORE_PROGRAM_ID;
243
+ exports.SolanaVenue = SolanaVenue;
244
+ exports.collectionRecordPda = collectionRecordPda;
245
+ exports.counterPda = counterPda;
246
+ exports.eventDiscriminator = eventDiscriminator;
247
+ exports.instructionDiscriminator = instructionDiscriminator;
248
+ exports.orderPda = orderPda;
249
+ exports.registryCounterPda = registryCounterPda;
250
+ exports.settlementPda = settlementPda;
251
+ exports.u64le = u64le;
252
+ //# sourceMappingURL=index.cjs.map
253
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/solana/encoding.ts","../../src/chains.ts","../../src/solana/venue.ts"],"names":["sha256","PublicKey","TransactionInstruction","SystemProgram","Transaction"],"mappings":";;;;;;AAUO,SAAS,yBAAyB,IA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\n\n/**\n * Anchor wire encoding for the Medialane Solana programs — discriminators,\n * a minimal borsh writer for our argument shapes, and the programs' PDAs.\n * Verified against the audited Rust (Solana-MIP-Collections,\n * Solana-Marketplace); no Anchor client dependency.\n */\n\nexport function instructionDiscriminator(name: string): Uint8Array {\n return sha256(new TextEncoder().encode(`global:${name}`)).slice(0, 8);\n}\n\nexport function eventDiscriminator(name: string): Uint8Array {\n return sha256(new TextEncoder().encode(`event:${name}`)).slice(0, 8);\n}\n\n/** Minimal borsh writer covering our programs' argument types. */\nexport class BorshWriter {\n private chunks: Uint8Array[] = [];\n\n u8(v: number): this {\n this.chunks.push(Uint8Array.of(v));\n return this;\n }\n u16(v: number): this {\n const b = new Uint8Array(2);\n new DataView(b.buffer).setUint16(0, v, true);\n this.chunks.push(b);\n return this;\n }\n u64(v: bigint): this {\n const b = new Uint8Array(8);\n new DataView(b.buffer).setBigUint64(0, v, true);\n this.chunks.push(b);\n return this;\n }\n i64(v: bigint): this {\n const b = new Uint8Array(8);\n new DataView(b.buffer).setBigInt64(0, v, true);\n this.chunks.push(b);\n return this;\n }\n string(v: string): this {\n const bytes = new TextEncoder().encode(v);\n const len = new Uint8Array(4);\n new DataView(len.buffer).setUint32(0, bytes.length, true);\n this.chunks.push(len, bytes);\n return this;\n }\n pubkey(v: PublicKey): this {\n this.chunks.push(v.toBytes());\n return this;\n }\n option<T>(v: T | null | undefined, write: (value: T) => void): this {\n if (v === null || v === undefined) {\n this.u8(0);\n } else {\n this.u8(1);\n write(v);\n }\n return this;\n }\n build(discriminator: Uint8Array): Uint8Array {\n const total = this.chunks.reduce((n, c) => n + c.length, discriminator.length);\n const out = new Uint8Array(total);\n out.set(discriminator, 0);\n let offset = discriminator.length;\n for (const chunk of this.chunks) {\n out.set(chunk, offset);\n offset += chunk.length;\n }\n return out;\n }\n}\n\nexport function u64le(v: bigint): Uint8Array {\n const b = new Uint8Array(8);\n new DataView(b.buffer).setBigUint64(0, v, true);\n return b;\n}\n\n// ─── PDAs (seeds copied from the Rust) ───────────────────────────────────────\n\nexport function orderPda(program: PublicKey, offerer: PublicKey, salt: bigint): PublicKey {\n return PublicKey.findProgramAddressSync(\n [new TextEncoder().encode(\"order\"), offerer.toBytes(), u64le(salt)],\n program,\n )[0];\n}\n\nexport function counterPda(program: PublicKey, offerer: PublicKey): PublicKey {\n return PublicKey.findProgramAddressSync(\n [new TextEncoder().encode(\"counter\"), offerer.toBytes()],\n program,\n )[0];\n}\n\nexport function settlementPda(program: PublicKey): PublicKey {\n return PublicKey.findProgramAddressSync([new TextEncoder().encode(\"authority\")], program)[0];\n}\n\nexport function registryCounterPda(program: PublicKey): PublicKey {\n return PublicKey.findProgramAddressSync([new TextEncoder().encode(\"counter\")], program)[0];\n}\n\nexport function collectionRecordPda(program: PublicKey, coreCollection: PublicKey): PublicKey {\n return PublicKey.findProgramAddressSync(\n [new TextEncoder().encode(\"collection\"), coreCollection.toBytes()],\n program,\n )[0];\n}\n\nexport const MPL_CORE_PROGRAM_ID = new PublicKey(\"CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d\");\n","// Single source of per-chain coordinates for Medialane's own services\n// (spec 2026-06-13 §3.1, Decision A). Keyed by CHAIN ALONE — Medialane is\n// mainnet-only, so there is no network axis (refines decisions.md D-9).\n\n/** Mirrors the backend Prisma `Chain` enum. */\nexport const CHAINS = [\"STARKNET\", \"ETHEREUM\", \"SOLANA\", \"BASE\", \"STELLAR\", \"BITCOIN\"] as const;\nexport type Chain = (typeof CHAINS)[number];\n\n/** Starknet coordinates of Medialane services + venues. All fields optional\n * because not every service exists on every chain. */\nexport interface StarknetCoordinates {\n rpcUrl: string;\n marketplace721?: `0x${string}`;\n marketplace721ClassHash?: `0x${string}`;\n marketplace721StartBlock?: number;\n marketplace1155?: `0x${string}`;\n marketplace1155ClassHash?: `0x${string}`;\n marketplace1155StartBlock?: number;\n collection721?: `0x${string}`;\n collection721StartBlock?: number;\n ipNftClassHash?: `0x${string}`;\n ipCollectionClassHash?: `0x${string}`;\n collection1155?: `0x${string}`;\n collection1155FactoryClassHash?: `0x${string}`;\n collection1155ClassHash?: `0x${string}`;\n collection1155StartBlock?: number;\n popFactory?: `0x${string}`;\n popCollectionClassHash?: `0x${string}`;\n dropFactory?: `0x${string}`;\n dropCollectionClassHash?: `0x${string}`;\n nftComments?: `0x${string}`;\n creatorCoinFactory?: `0x${string}`;\n creatorCoinEkuboLauncher?: `0x${string}`;\n creatorCoinClassHash?: `0x${string}`;\n creatorCoinFactoryClassHash?: `0x${string}`;\n creatorCoinStartBlock?: number;\n ekuboCore?: `0x${string}`;\n ipTicketsFactory?: `0x${string}`;\n ipTicketCollectionClassHash?: `0x${string}`;\n ipTicketsStartBlock?: number;\n ipClubRegistry?: `0x${string}`;\n ipClubNftClassHash?: `0x${string}`;\n ipClubStartBlock?: number;\n ipSponsorship?: `0x${string}`;\n ipSponsorshipStartBlock?: number;\n ipSponsorshipLicense?: `0x${string}`;\n}\n\n/** Coordinates per chain. Only STARKNET is populated today; adding a chain\n * means adding an entry here (litmus test, spec §7). */\n/** EVM coordinates — one shape for Ethereum and Base (same bytecode, two\n * chains). Populated at deploy time (federation Phase 4). */\nexport interface EvmCoordinates {\n rpcUrl: string;\n marketplace721?: `0x${string}`;\n marketplace721StartBlock?: number;\n marketplace1155?: `0x${string}`;\n marketplace1155StartBlock?: number;\n mipRegistry?: `0x${string}`;\n mipRegistryStartBlock?: number;\n mipEditionsRegistry?: `0x${string}`;\n mipEditionsRegistryStartBlock?: number;\n}\n\n/** Solana coordinates — base58 program ids. Populated at deploy time. */\nexport interface SolanaCoordinates {\n rpcUrl: string;\n mipCollectionsProgram?: string;\n marketplaceProgram?: string;\n startSlot?: number;\n}\n\n/** Stellar (Soroban) coordinates — strkey contract ids. Populated at deploy\n * time; the registry takes the collection WASM hash as a constructor arg. */\nexport interface StellarCoordinates {\n rpcUrl: string;\n mipRegistry?: string;\n marketplace?: string;\n collectionWasmHash?: string;\n startLedger?: number;\n}\n\n/** Per-chain coordinate shapes. Every chain is an equal entry — no chain is\n * privileged in core (chain-sovereignty I2/I4). */\nexport interface CoordinatesByChain {\n STARKNET?: StarknetCoordinates;\n ETHEREUM?: EvmCoordinates;\n BASE?: EvmCoordinates;\n SOLANA?: SolanaCoordinates;\n STELLAR?: StellarCoordinates;\n BITCOIN?: never;\n}\n\n/** @deprecated Renamed — use `StarknetCoordinates` (coordinates are per-chain-shaped). */\nexport type ChainCoordinates = StarknetCoordinates;\n\nconst COORDINATES: CoordinatesByChain = {\n STARKNET: {\n rpcUrl: \"https://rpc.starknet.lava.build\",\n marketplace721: \"0x03eda9a2b6ad90845a43591bac8083ebaf677d51fdf20f503b2c01889e3131fc\",\n marketplace721ClassHash: \"0x0700d9230d07e5203e27778c0dc70f9134d2b25bf319f7cf8348dc66a6923e90\",\n marketplace721StartBlock: 11198146,\n marketplace1155: \"0x07c4ce1c19ea48cc11135ed22b19ff745f5aec508c3828593002e4f76fdb1b38\",\n marketplace1155ClassHash: \"0x0242f5c388da7cee2d99e2a69453c8159bf927fbec4e797a3cfdcbbcb5b68328\",\n marketplace1155StartBlock: 11198267,\n collection721: \"0x0225c3ae09506b8d97adc39649ca740dad5aac195b7f5f0441cc1852947acaea\",\n collection721StartBlock: 11198496,\n ipNftClassHash: \"0x012d3ae40ba35c7e2be0946532dac60e48932447912fdf96b674da67c029b9cc\",\n ipCollectionClassHash: \"0x022155a1a130a40e57aac4b89c07fab3f616bc351b1270fc40f756b963afe8b4\",\n collection1155: \"0x015368976d46fae5bfa1c58600f641d5aa5dbbf53ebc6b78aa3922194aad3551\",\n collection1155FactoryClassHash: \"0x04eb6b419770f13bd191f120b9fc9ee624c0613ad4490062d293ca2016b3b1d2\",\n collection1155ClassHash: \"0x06cf3f5a2322dac35e07a6064a5b8802f19fda8aa3f4726f0cb7bc05dea1bd78\",\n collection1155StartBlock: 11199527,\n popFactory: \"0x00b32c34b427d8f346b5843ada6a37bd3368d879fc752cd52b68a87287f60111\",\n popCollectionClassHash: \"0x077c421686f10851872561953ea16898d933364b7f8937a5d7e2b1ba0a36263f\",\n dropFactory: \"0x03587f42e29daee1b193f6cf83bf8627908ed6632d0d83fcb26225c50547d800\",\n dropCollectionClassHash: \"0x00092e72cdb63067521e803aaf7d4101c3e3ce026ae6bc045ec4228027e58282\",\n nftComments: \"0x02cdac70c94447189af0389dfea63f4d5e4154ea8a563de288a5ab1c39e37843\",\n creatorCoinFactory: \"0x50fa807b5274079fb19374673d7bab6d2dc3af7e1032ea43eb6e44bcbde4c3c\",\n creatorCoinEkuboLauncher: \"0x4f7fceb5ac10f12f9544a09580592e5bdf1b7f04f48765eecf12286d8ccb7b4\",\n creatorCoinClassHash: \"0x743e4c8a5b96bb83bbf4af04edbbb482d5ece89eed9b729a79fb7df0cd0b6b6\",\n creatorCoinFactoryClassHash: \"0x51765926b1344c9a20b8cd4b5abe7b7d47375ae97cf6804db3ea5d4b05a9b55\",\n creatorCoinStartBlock: 10474544,\n ekuboCore: \"0x00000005dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b\",\n ipTicketsFactory: \"0x0664c2d6a4da9ee3ff053ceeba7579c01f2fedfd9d2b57b4c07af3734bd4acab\",\n ipTicketCollectionClassHash: \"0x086f59c416e365e2bee4ceff9f1dcb96198f2342d50ba4621f60b831863adb6\",\n ipTicketsStartBlock: 11404656,\n ipClubRegistry: \"0x00e189c619b6bb07d78973a149641c59c37eb0716f8584d7520bce12d303eede\",\n ipClubNftClassHash: \"0x02bc9b20cca21b04245e9215bf7121f4d7295b195890e449b472b573017fb889\",\n ipClubStartBlock: 11404776,\n ipSponsorship: \"0x044d9b9c3bb29b94685b0a3fe27a5e2dfa30a3637ab55979c718ebcd3268bc2f\",\n ipSponsorshipStartBlock: 11405085,\n // Dedicated ip-erc721/MIP instance for sponsorship receipts (class hash\n // 0x01bd7e39c5135b32b664e34cbbb4eafbd707a0fbc3ec2ef28657f52577d277d7) —\n // never the genesis-mint instance.\n ipSponsorshipLicense: \"0x06bcfc4e97758a2abf95af4bd49596efdbfd88ccd740caddc56ad0a4bd095839\",\n },\n};\n\nexport function getCoordinates(chain: \"STARKNET\"): StarknetCoordinates;\nexport function getCoordinates(chain: \"ETHEREUM\" | \"BASE\"): EvmCoordinates;\nexport function getCoordinates(chain: \"SOLANA\"): SolanaCoordinates;\nexport function getCoordinates(chain: \"STELLAR\"): StellarCoordinates;\nexport function getCoordinates(\n chain: Chain,\n): StarknetCoordinates | EvmCoordinates | SolanaCoordinates | StellarCoordinates;\nexport function getCoordinates(\n chain: Chain,\n): StarknetCoordinates | EvmCoordinates | SolanaCoordinates | StellarCoordinates {\n const c = COORDINATES[chain];\n if (!c) throw new Error(`No coordinates configured for chain \"${chain}\"`);\n return c;\n}\n\nexport const DEFAULT_CHAIN: Chain = \"STARKNET\";\n\n/** Typed Starknet coordinates for Starknet-only modules; throws when the\n * client is scoped to another chain. */\nexport function getStarknetCoordinates(chain: Chain): StarknetCoordinates {\n if (chain !== \"STARKNET\") {\n throw new Error(`This module is Starknet-only (client chain: \"${chain}\")`);\n }\n return getCoordinates(\"STARKNET\");\n}\n","import {\n PublicKey,\n SystemProgram,\n Transaction,\n TransactionInstruction,\n type Connection,\n} from \"@solana/web3.js\";\nimport type { Chain } from \"../chains.js\";\nimport { getCoordinates, type SolanaCoordinates } from \"../chains.js\";\nimport type {\n AdapterTxResult,\n OrderRef,\n RegisterOrderParams,\n VenueAdapter,\n} from \"../adapters/types.js\";\nimport {\n BorshWriter,\n MPL_CORE_PROGRAM_ID,\n counterPda,\n instructionDiscriminator,\n orderPda,\n settlementPda,\n} from \"./encoding.js\";\n\n/** Wallet-adapter-compatible signer. */\nexport interface SolanaSigner {\n publicKey: PublicKey;\n signTransaction(tx: Transaction): Promise<Transaction>;\n}\n\nexport interface SolanaVenueOptions {\n connection: Connection;\n /** Defaults to the chain registry's marketplace program (populated at deploy). */\n programId?: string;\n}\n\n/** The Medialane venue adapter for Solana. The canonical order id is the\n * order PDA (spec §3.2b). Native SOL is the payment when `paymentToken`\n * is the \"native\" sentinel; SPL mints otherwise (bids are SPL-only,\n * enforced by the program). */\nexport class SolanaVenue implements VenueAdapter<SolanaSigner> {\n readonly chain: Chain = \"SOLANA\";\n private readonly connection: Connection;\n private readonly program: PublicKey;\n\n constructor(opts: SolanaVenueOptions) {\n this.connection = opts.connection;\n const program = opts.programId ?? maybeCoords()?.marketplaceProgram;\n if (!program) throw new Error(\"No Solana marketplace program configured\");\n this.program = new PublicKey(program);\n }\n\n async registerOrder(\n signer: SolanaSigner,\n params: RegisterOrderParams,\n ): Promise<AdapterTxResult & { orderRef: OrderRef }> {\n const offerer = signer.publicKey;\n const salt = BigInt(params.salt);\n const isNative = params.paymentToken === \"native\";\n const counter = await this.getCounter(offerer.toBase58());\n const writer = new BorshWriter()\n .u64(salt)\n .u8(params.side === \"listing\" ? 0 : 1)\n .option(isNative ? null : new PublicKey(params.paymentToken), (mint) => writer.pubkey(mint))\n .u64(BigInt(params.amount))\n .u16(params.royaltyMaxBps)\n .i64(BigInt(params.startTime))\n .i64(BigInt(params.endTime))\n .u64(counter);\n const order = orderPda(this.program, offerer, salt);\n const asset = new PublicKey(params.asset.contract);\n const instruction = new TransactionInstruction({\n programId: this.program,\n keys: [\n { pubkey: offerer, isSigner: true, isWritable: true },\n { pubkey: order, isSigner: false, isWritable: true },\n { pubkey: counterPda(this.program, offerer), isSigner: false, isWritable: true },\n { pubkey: settlementPda(this.program), isSigner: false, isWritable: false },\n { pubkey: asset, isSigner: false, isWritable: true },\n { pubkey: new PublicKey(params.asset.tokenId), isSigner: false, isWritable: true },\n { pubkey: MPL_CORE_PROGRAM_ID, isSigner: false, isWritable: false },\n { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },\n ],\n data: Buffer.from(writer.build(instructionDiscriminator(\"register_order\"))),\n });\n const txHash = await this.send(signer, instruction);\n return { txHash, orderRef: order.toBase58() };\n }\n\n async fulfillOrder(): Promise<AdapterTxResult> {\n throw new Error(\n \"Solana fulfillment requires the order's creator remaining-accounts; use buildFulfillInstruction with explicit accounts\",\n );\n }\n\n async cancelOrder(signer: SolanaSigner, orderRef: OrderRef): Promise<AdapterTxResult> {\n const instruction = new TransactionInstruction({\n programId: this.program,\n keys: [\n { pubkey: signer.publicKey, isSigner: true, isWritable: false },\n { pubkey: new PublicKey(orderRef), isSigner: false, isWritable: true },\n ],\n data: Buffer.from(new BorshWriter().build(instructionDiscriminator(\"cancel_order\"))),\n });\n const txHash = await this.send(signer, instruction);\n return { txHash };\n }\n\n async incrementCounter(signer: SolanaSigner): Promise<AdapterTxResult> {\n const instruction = new TransactionInstruction({\n programId: this.program,\n keys: [\n { pubkey: signer.publicKey, isSigner: true, isWritable: true },\n { pubkey: counterPda(this.program, signer.publicKey), isSigner: false, isWritable: true },\n { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },\n ],\n data: Buffer.from(new BorshWriter().build(instructionDiscriminator(\"increment_counter\"))),\n });\n const txHash = await this.send(signer, instruction);\n return { txHash };\n }\n\n async getOrderDetails(orderRef: OrderRef): Promise<unknown> {\n const info = await this.connection.getAccountInfo(new PublicKey(orderRef));\n return info?.data ?? null;\n }\n\n async getCounter(address: string): Promise<bigint> {\n const pda = counterPda(this.program, new PublicKey(address));\n const info = await this.connection.getAccountInfo(pda);\n if (!info || info.data.length < 16) return 0n;\n // Anchor account: 8-byte discriminator + u64 count (LE).\n return new DataView(info.data.buffer, info.data.byteOffset + 8, 8).getBigUint64(0, true);\n }\n\n private async send(signer: SolanaSigner, instruction: TransactionInstruction): Promise<string> {\n const tx = new Transaction().add(instruction);\n tx.feePayer = signer.publicKey;\n tx.recentBlockhash = (await this.connection.getLatestBlockhash()).blockhash;\n const signed = await signer.signTransaction(tx);\n return this.connection.sendRawTransaction(signed.serialize());\n }\n}\n\nfunction maybeCoords(): SolanaCoordinates | undefined {\n try {\n return getCoordinates(\"SOLANA\");\n } catch {\n return undefined;\n }\n}\n"]}
@@ -0,0 +1,62 @@
1
+ import { PublicKey, Transaction, Connection } from '@solana/web3.js';
2
+ import { V as VenueAdapter, C as Chain, R as RegisterOrderParams, A as AdapterTxResult, O as OrderRef } from '../types-D3PWgk3x.cjs';
3
+
4
+ /**
5
+ * Anchor wire encoding for the Medialane Solana programs — discriminators,
6
+ * a minimal borsh writer for our argument shapes, and the programs' PDAs.
7
+ * Verified against the audited Rust (Solana-MIP-Collections,
8
+ * Solana-Marketplace); no Anchor client dependency.
9
+ */
10
+ declare function instructionDiscriminator(name: string): Uint8Array;
11
+ declare function eventDiscriminator(name: string): Uint8Array;
12
+ /** Minimal borsh writer covering our programs' argument types. */
13
+ declare class BorshWriter {
14
+ private chunks;
15
+ u8(v: number): this;
16
+ u16(v: number): this;
17
+ u64(v: bigint): this;
18
+ i64(v: bigint): this;
19
+ string(v: string): this;
20
+ pubkey(v: PublicKey): this;
21
+ option<T>(v: T | null | undefined, write: (value: T) => void): this;
22
+ build(discriminator: Uint8Array): Uint8Array;
23
+ }
24
+ declare function u64le(v: bigint): Uint8Array;
25
+ declare function orderPda(program: PublicKey, offerer: PublicKey, salt: bigint): PublicKey;
26
+ declare function counterPda(program: PublicKey, offerer: PublicKey): PublicKey;
27
+ declare function settlementPda(program: PublicKey): PublicKey;
28
+ declare function registryCounterPda(program: PublicKey): PublicKey;
29
+ declare function collectionRecordPda(program: PublicKey, coreCollection: PublicKey): PublicKey;
30
+ declare const MPL_CORE_PROGRAM_ID: PublicKey;
31
+
32
+ /** Wallet-adapter-compatible signer. */
33
+ interface SolanaSigner {
34
+ publicKey: PublicKey;
35
+ signTransaction(tx: Transaction): Promise<Transaction>;
36
+ }
37
+ interface SolanaVenueOptions {
38
+ connection: Connection;
39
+ /** Defaults to the chain registry's marketplace program (populated at deploy). */
40
+ programId?: string;
41
+ }
42
+ /** The Medialane venue adapter for Solana. The canonical order id is the
43
+ * order PDA (spec §3.2b). Native SOL is the payment when `paymentToken`
44
+ * is the "native" sentinel; SPL mints otherwise (bids are SPL-only,
45
+ * enforced by the program). */
46
+ declare class SolanaVenue implements VenueAdapter<SolanaSigner> {
47
+ readonly chain: Chain;
48
+ private readonly connection;
49
+ private readonly program;
50
+ constructor(opts: SolanaVenueOptions);
51
+ registerOrder(signer: SolanaSigner, params: RegisterOrderParams): Promise<AdapterTxResult & {
52
+ orderRef: OrderRef;
53
+ }>;
54
+ fulfillOrder(): Promise<AdapterTxResult>;
55
+ cancelOrder(signer: SolanaSigner, orderRef: OrderRef): Promise<AdapterTxResult>;
56
+ incrementCounter(signer: SolanaSigner): Promise<AdapterTxResult>;
57
+ getOrderDetails(orderRef: OrderRef): Promise<unknown>;
58
+ getCounter(address: string): Promise<bigint>;
59
+ private send;
60
+ }
61
+
62
+ export { BorshWriter, MPL_CORE_PROGRAM_ID, type SolanaSigner, SolanaVenue, type SolanaVenueOptions, collectionRecordPda, counterPda, eventDiscriminator, instructionDiscriminator, orderPda, registryCounterPda, settlementPda, u64le };
@@ -0,0 +1,62 @@
1
+ import { PublicKey, Transaction, Connection } from '@solana/web3.js';
2
+ import { V as VenueAdapter, C as Chain, R as RegisterOrderParams, A as AdapterTxResult, O as OrderRef } from '../types-D3PWgk3x.js';
3
+
4
+ /**
5
+ * Anchor wire encoding for the Medialane Solana programs — discriminators,
6
+ * a minimal borsh writer for our argument shapes, and the programs' PDAs.
7
+ * Verified against the audited Rust (Solana-MIP-Collections,
8
+ * Solana-Marketplace); no Anchor client dependency.
9
+ */
10
+ declare function instructionDiscriminator(name: string): Uint8Array;
11
+ declare function eventDiscriminator(name: string): Uint8Array;
12
+ /** Minimal borsh writer covering our programs' argument types. */
13
+ declare class BorshWriter {
14
+ private chunks;
15
+ u8(v: number): this;
16
+ u16(v: number): this;
17
+ u64(v: bigint): this;
18
+ i64(v: bigint): this;
19
+ string(v: string): this;
20
+ pubkey(v: PublicKey): this;
21
+ option<T>(v: T | null | undefined, write: (value: T) => void): this;
22
+ build(discriminator: Uint8Array): Uint8Array;
23
+ }
24
+ declare function u64le(v: bigint): Uint8Array;
25
+ declare function orderPda(program: PublicKey, offerer: PublicKey, salt: bigint): PublicKey;
26
+ declare function counterPda(program: PublicKey, offerer: PublicKey): PublicKey;
27
+ declare function settlementPda(program: PublicKey): PublicKey;
28
+ declare function registryCounterPda(program: PublicKey): PublicKey;
29
+ declare function collectionRecordPda(program: PublicKey, coreCollection: PublicKey): PublicKey;
30
+ declare const MPL_CORE_PROGRAM_ID: PublicKey;
31
+
32
+ /** Wallet-adapter-compatible signer. */
33
+ interface SolanaSigner {
34
+ publicKey: PublicKey;
35
+ signTransaction(tx: Transaction): Promise<Transaction>;
36
+ }
37
+ interface SolanaVenueOptions {
38
+ connection: Connection;
39
+ /** Defaults to the chain registry's marketplace program (populated at deploy). */
40
+ programId?: string;
41
+ }
42
+ /** The Medialane venue adapter for Solana. The canonical order id is the
43
+ * order PDA (spec §3.2b). Native SOL is the payment when `paymentToken`
44
+ * is the "native" sentinel; SPL mints otherwise (bids are SPL-only,
45
+ * enforced by the program). */
46
+ declare class SolanaVenue implements VenueAdapter<SolanaSigner> {
47
+ readonly chain: Chain;
48
+ private readonly connection;
49
+ private readonly program;
50
+ constructor(opts: SolanaVenueOptions);
51
+ registerOrder(signer: SolanaSigner, params: RegisterOrderParams): Promise<AdapterTxResult & {
52
+ orderRef: OrderRef;
53
+ }>;
54
+ fulfillOrder(): Promise<AdapterTxResult>;
55
+ cancelOrder(signer: SolanaSigner, orderRef: OrderRef): Promise<AdapterTxResult>;
56
+ incrementCounter(signer: SolanaSigner): Promise<AdapterTxResult>;
57
+ getOrderDetails(orderRef: OrderRef): Promise<unknown>;
58
+ getCounter(address: string): Promise<bigint>;
59
+ private send;
60
+ }
61
+
62
+ export { BorshWriter, MPL_CORE_PROGRAM_ID, type SolanaSigner, SolanaVenue, type SolanaVenueOptions, collectionRecordPda, counterPda, eventDiscriminator, instructionDiscriminator, orderPda, registryCounterPda, settlementPda, u64le };