@medialane/sdk 0.58.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -13
- package/dist/evm/index.cjs +361 -0
- package/dist/evm/index.cjs.map +1 -0
- package/dist/evm/index.d.cts +613 -0
- package/dist/evm/index.d.ts +613 -0
- package/dist/evm/index.js +350 -0
- package/dist/evm/index.js.map +1 -0
- package/dist/index-D-sFKbtL.d.ts +10376 -0
- package/dist/index-DjraRZJ1.d.cts +10376 -0
- package/dist/index.cjs +12241 -11243
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -9634
- package/dist/index.d.ts +67 -9634
- package/dist/index.js +12206 -11232
- package/dist/index.js.map +1 -1
- package/dist/solana/index.cjs +257 -0
- package/dist/solana/index.cjs.map +1 -0
- package/dist/solana/index.d.cts +62 -0
- package/dist/solana/index.d.ts +62 -0
- package/dist/solana/index.js +245 -0
- package/dist/solana/index.js.map +1 -0
- package/dist/starknet/index.cjs +13272 -0
- package/dist/starknet/index.cjs.map +1 -0
- package/dist/starknet/index.d.cts +4 -0
- package/dist/starknet/index.d.ts +4 -0
- package/dist/starknet/index.js +13201 -0
- package/dist/starknet/index.js.map +1 -0
- package/dist/stellar/index.cjs +169 -0
- package/dist/stellar/index.cjs.map +1 -0
- package/dist/stellar/index.d.cts +49 -0
- package/dist/stellar/index.d.ts +49 -0
- package/dist/stellar/index.js +166 -0
- package/dist/stellar/index.js.map +1 -0
- package/dist/types-V6imkXvR.d.cts +179 -0
- package/dist/types-V6imkXvR.d.ts +179 -0
- package/package.json +45 -5
package/README.md
CHANGED
|
@@ -75,11 +75,11 @@ const client = new MedialaneClient({
|
|
|
75
75
|
|
|
76
76
|
## Marketplace Operations (On-Chain)
|
|
77
77
|
|
|
78
|
-
All methods require a `starknet.js` `AccountInterface`.
|
|
78
|
+
All methods require a `starknet.js` `AccountInterface`. SNIP-12 signing and `waitForTransaction` are handled automatically. Fulfilment is **unsigned** — the caller is the fulfiller, so there is no `fulfiller`/`offerer` field to pass; cancellation still signs, but without a nonce (a per-offerer `counter` replaces it, see `incrementCounter`).
|
|
79
79
|
|
|
80
80
|
Two marketplace modules are available:
|
|
81
|
-
- `client.marketplace` — ERC-721 marketplace (`
|
|
82
|
-
- `client.marketplace1155` — ERC-1155 marketplace (`
|
|
81
|
+
- `client.marketplace` — ERC-721 marketplace (`Medialane721`)
|
|
82
|
+
- `client.marketplace1155` — ERC-1155 marketplace (`Medialane1155`)
|
|
83
83
|
|
|
84
84
|
### Create a Listing (ERC-721)
|
|
85
85
|
|
|
@@ -88,10 +88,10 @@ import { Account } from "starknet";
|
|
|
88
88
|
|
|
89
89
|
const result = await client.marketplace.createListing(account, {
|
|
90
90
|
nftContract: "0x05e73b7...",
|
|
91
|
-
tokenId:
|
|
91
|
+
tokenId: "42",
|
|
92
92
|
currency: "USDC",
|
|
93
93
|
price: "1000000", // 1 USDC (6 decimals)
|
|
94
|
-
|
|
94
|
+
durationSeconds: 86400 * 30, // 30 days
|
|
95
95
|
});
|
|
96
96
|
console.log("Listed:", result.txHash);
|
|
97
97
|
```
|
|
@@ -101,19 +101,23 @@ console.log("Listed:", result.txHash);
|
|
|
101
101
|
```typescript
|
|
102
102
|
const result = await client.marketplace.makeOffer(account, {
|
|
103
103
|
nftContract: "0x05e73b7...",
|
|
104
|
-
tokenId:
|
|
104
|
+
tokenId: "42",
|
|
105
105
|
currency: "USDC",
|
|
106
106
|
price: "500000", // 0.5 USDC
|
|
107
|
-
|
|
107
|
+
durationSeconds: 86400 * 7,
|
|
108
108
|
});
|
|
109
109
|
```
|
|
110
110
|
|
|
111
111
|
### Fulfill an Order
|
|
112
112
|
|
|
113
113
|
```typescript
|
|
114
|
+
// Fetch order details first to get paymentToken and totalPrice
|
|
115
|
+
const details = await client.api.getOrder(orderHash);
|
|
116
|
+
|
|
114
117
|
const result = await client.marketplace.fulfillOrder(account, {
|
|
115
118
|
orderHash: "0x...",
|
|
116
|
-
|
|
119
|
+
paymentToken: "0x033068...", // from order details
|
|
120
|
+
totalPrice: "1000000", // raw token units
|
|
117
121
|
});
|
|
118
122
|
```
|
|
119
123
|
|
|
@@ -121,8 +125,8 @@ const result = await client.marketplace.fulfillOrder(account, {
|
|
|
121
125
|
|
|
122
126
|
```typescript
|
|
123
127
|
const result = await client.marketplace.checkoutCart(account, [
|
|
124
|
-
{ orderHash: "0x...",
|
|
125
|
-
{ orderHash: "0x...",
|
|
128
|
+
{ orderHash: "0x...", considerationToken: "0x033068...", considerationAmount: "1000000" },
|
|
129
|
+
{ orderHash: "0x...", considerationToken: "0x033068...", considerationAmount: "500000" },
|
|
126
130
|
]);
|
|
127
131
|
```
|
|
128
132
|
|
|
@@ -131,10 +135,16 @@ const result = await client.marketplace.checkoutCart(account, [
|
|
|
131
135
|
```typescript
|
|
132
136
|
const result = await client.marketplace.cancelOrder(account, {
|
|
133
137
|
orderHash: "0x...",
|
|
134
|
-
offerer: account.address,
|
|
135
138
|
});
|
|
136
139
|
```
|
|
137
140
|
|
|
141
|
+
### Bulk-Cancel (Invalidate All Open Orders)
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
// Bumps the caller's counter — every previously-registered order becomes unfulfillable.
|
|
145
|
+
await client.marketplace.incrementCounter(account);
|
|
146
|
+
```
|
|
147
|
+
|
|
138
148
|
### Mint an IP Asset
|
|
139
149
|
|
|
140
150
|
```typescript
|
|
@@ -142,6 +152,7 @@ const result = await client.marketplace.mint(account, {
|
|
|
142
152
|
collectionId: "1", // collection ID on the registry
|
|
143
153
|
recipient: account.address,
|
|
144
154
|
tokenUri: "ipfs://...", // IPFS URI of the metadata JSON
|
|
155
|
+
royaltyBps: 500, // EIP-2981 secondary-sale royalty, 0-10_000 (required since MIP v0.4.0)
|
|
145
156
|
});
|
|
146
157
|
```
|
|
147
158
|
|
|
@@ -159,7 +170,7 @@ const result = await client.marketplace.createCollection(account, {
|
|
|
159
170
|
|
|
160
171
|
## ERC-1155 Marketplace (Medialane1155)
|
|
161
172
|
|
|
162
|
-
For IP assets from ERC-1155 collections (e.g. IP-Programmable-ERC1155-Collections). Contract: `
|
|
173
|
+
For IP assets from ERC-1155 collections (e.g. IP-Programmable-ERC1155-Collections). Contract address: see `getCoordinates("STARKNET").marketplace1155` in `src/chains.ts` (the single source — do not hardcode it here, it changes on redeploy).
|
|
163
174
|
|
|
164
175
|
### Create an ERC-1155 Listing
|
|
165
176
|
|
|
@@ -201,8 +212,11 @@ const result = await client.marketplace1155.cancelOrder(account, {
|
|
|
201
212
|
|
|
202
213
|
### SNIP-12 Typed Data Builders (ChipiPay / custom flows)
|
|
203
214
|
|
|
215
|
+
Listing/offer and cancellation are signed; fulfilment is an **unsigned** call (the buyer is
|
|
216
|
+
the fulfiller, since v0.26.0) — there is no fulfillment typed-data builder.
|
|
217
|
+
|
|
204
218
|
```typescript
|
|
205
|
-
import { build1155OrderTypedData,
|
|
219
|
+
import { build1155OrderTypedData, build1155CancellationTypedData } from "@medialane/sdk";
|
|
206
220
|
import { constants } from "starknet";
|
|
207
221
|
|
|
208
222
|
const typedData = build1155OrderTypedData(orderParams, constants.StarknetChainId.SN_MAIN);
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var viem = require('viem');
|
|
4
|
+
|
|
5
|
+
// src/evm/typedData.ts
|
|
6
|
+
var EVM_ORDER_TYPES = {
|
|
7
|
+
OfferItem: [
|
|
8
|
+
{ name: "itemType", type: "uint8" },
|
|
9
|
+
{ name: "token", type: "address" },
|
|
10
|
+
{ name: "identifier", type: "uint256" },
|
|
11
|
+
{ name: "amount", type: "uint256" }
|
|
12
|
+
],
|
|
13
|
+
ConsiderationItem: [
|
|
14
|
+
{ name: "itemType", type: "uint8" },
|
|
15
|
+
{ name: "token", type: "address" },
|
|
16
|
+
{ name: "identifier", type: "uint256" },
|
|
17
|
+
{ name: "amount", type: "uint256" },
|
|
18
|
+
{ name: "recipient", type: "address" }
|
|
19
|
+
],
|
|
20
|
+
OrderParameters: [
|
|
21
|
+
{ name: "offerer", type: "address" },
|
|
22
|
+
{ name: "offer", type: "OfferItem" },
|
|
23
|
+
{ name: "consideration", type: "ConsiderationItem" },
|
|
24
|
+
{ name: "royaltyMaxBps", type: "uint256" },
|
|
25
|
+
{ name: "startTime", type: "uint256" },
|
|
26
|
+
{ name: "endTime", type: "uint256" },
|
|
27
|
+
{ name: "salt", type: "uint256" },
|
|
28
|
+
{ name: "counter", type: "uint256" }
|
|
29
|
+
]
|
|
30
|
+
};
|
|
31
|
+
function evmOrderDomain(chainId, verifyingContract) {
|
|
32
|
+
return { name: "Medialane", version: "1", chainId, verifyingContract };
|
|
33
|
+
}
|
|
34
|
+
function evmOrderDigest(chainId, verifyingContract, parameters) {
|
|
35
|
+
return viem.hashTypedData({
|
|
36
|
+
domain: evmOrderDomain(chainId, verifyingContract),
|
|
37
|
+
types: EVM_ORDER_TYPES,
|
|
38
|
+
primaryType: "OrderParameters",
|
|
39
|
+
message: parameters
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/chains.ts
|
|
44
|
+
var COORDINATES = {
|
|
45
|
+
STARKNET: {
|
|
46
|
+
rpcUrl: "https://rpc.starknet.lava.build",
|
|
47
|
+
marketplace721: "0x03eda9a2b6ad90845a43591bac8083ebaf677d51fdf20f503b2c01889e3131fc",
|
|
48
|
+
marketplace721ClassHash: "0x0700d9230d07e5203e27778c0dc70f9134d2b25bf319f7cf8348dc66a6923e90",
|
|
49
|
+
marketplace721StartBlock: 11198146,
|
|
50
|
+
marketplace1155: "0x07c4ce1c19ea48cc11135ed22b19ff745f5aec508c3828593002e4f76fdb1b38",
|
|
51
|
+
marketplace1155ClassHash: "0x0242f5c388da7cee2d99e2a69453c8159bf927fbec4e797a3cfdcbbcb5b68328",
|
|
52
|
+
marketplace1155StartBlock: 11198267,
|
|
53
|
+
collection721: "0x0225c3ae09506b8d97adc39649ca740dad5aac195b7f5f0441cc1852947acaea",
|
|
54
|
+
collection721StartBlock: 11198496,
|
|
55
|
+
ipNftClassHash: "0x012d3ae40ba35c7e2be0946532dac60e48932447912fdf96b674da67c029b9cc",
|
|
56
|
+
ipCollectionClassHash: "0x022155a1a130a40e57aac4b89c07fab3f616bc351b1270fc40f756b963afe8b4",
|
|
57
|
+
collection1155: "0x015368976d46fae5bfa1c58600f641d5aa5dbbf53ebc6b78aa3922194aad3551",
|
|
58
|
+
collection1155FactoryClassHash: "0x04eb6b419770f13bd191f120b9fc9ee624c0613ad4490062d293ca2016b3b1d2",
|
|
59
|
+
collection1155ClassHash: "0x06cf3f5a2322dac35e07a6064a5b8802f19fda8aa3f4726f0cb7bc05dea1bd78",
|
|
60
|
+
collection1155StartBlock: 11199527,
|
|
61
|
+
popFactory: "0x00b32c34b427d8f346b5843ada6a37bd3368d879fc752cd52b68a87287f60111",
|
|
62
|
+
popCollectionClassHash: "0x077c421686f10851872561953ea16898d933364b7f8937a5d7e2b1ba0a36263f",
|
|
63
|
+
dropFactory: "0x03587f42e29daee1b193f6cf83bf8627908ed6632d0d83fcb26225c50547d800",
|
|
64
|
+
dropCollectionClassHash: "0x00092e72cdb63067521e803aaf7d4101c3e3ce026ae6bc045ec4228027e58282",
|
|
65
|
+
nftComments: "0x02cdac70c94447189af0389dfea63f4d5e4154ea8a563de288a5ab1c39e37843",
|
|
66
|
+
creatorCoinFactory: "0x50fa807b5274079fb19374673d7bab6d2dc3af7e1032ea43eb6e44bcbde4c3c",
|
|
67
|
+
creatorCoinEkuboLauncher: "0x4f7fceb5ac10f12f9544a09580592e5bdf1b7f04f48765eecf12286d8ccb7b4",
|
|
68
|
+
creatorCoinClassHash: "0x743e4c8a5b96bb83bbf4af04edbbb482d5ece89eed9b729a79fb7df0cd0b6b6",
|
|
69
|
+
creatorCoinFactoryClassHash: "0x51765926b1344c9a20b8cd4b5abe7b7d47375ae97cf6804db3ea5d4b05a9b55",
|
|
70
|
+
creatorCoinStartBlock: 10474544,
|
|
71
|
+
ekuboCore: "0x00000005dd3d2f4429af886cd1a3b08289dbcea99a294197e9eb43b0e0325b4b",
|
|
72
|
+
ipTicketsFactory: "0x0664c2d6a4da9ee3ff053ceeba7579c01f2fedfd9d2b57b4c07af3734bd4acab",
|
|
73
|
+
ipTicketCollectionClassHash: "0x086f59c416e365e2bee4ceff9f1dcb96198f2342d50ba4621f60b831863adb6",
|
|
74
|
+
ipTicketsStartBlock: 11404656,
|
|
75
|
+
ipClubRegistry: "0x00e189c619b6bb07d78973a149641c59c37eb0716f8584d7520bce12d303eede",
|
|
76
|
+
ipClubNftClassHash: "0x02bc9b20cca21b04245e9215bf7121f4d7295b195890e449b472b573017fb889",
|
|
77
|
+
ipClubStartBlock: 11404776,
|
|
78
|
+
ipClubFactory: "0x010726346c264d1832a7303afaf5692dbd2b05446fecc6da30d958d0227c36d0",
|
|
79
|
+
ipClubFactoryClassHash: "0x07197062578375d962b2d42d3e91560770b11b1c97a9defb74c706a2c5299473",
|
|
80
|
+
ipClubCollectionClassHash: "0x049dc5e5ff00e67d5d457c6991ee70822f36a979b76cefd1b617aeccd7051d4b",
|
|
81
|
+
ipClubFactoryStartBlock: 11652766,
|
|
82
|
+
ipSponsorship: "0x044d9b9c3bb29b94685b0a3fe27a5e2dfa30a3637ab55979c718ebcd3268bc2f",
|
|
83
|
+
ipSponsorshipStartBlock: 11405085,
|
|
84
|
+
// Dedicated ip-erc721/MIP instance for sponsorship receipts (class hash
|
|
85
|
+
// 0x01bd7e39c5135b32b664e34cbbb4eafbd707a0fbc3ec2ef28657f52577d277d7) —
|
|
86
|
+
// never the genesis-mint instance.
|
|
87
|
+
ipSponsorshipLicense: "0x06bcfc4e97758a2abf95af4bd49596efdbfd88ccd740caddc56ad0a4bd095839"
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
function getCoordinates(chain) {
|
|
91
|
+
const c = COORDINATES[chain];
|
|
92
|
+
if (!c) throw new Error(`No coordinates configured for chain "${chain}"`);
|
|
93
|
+
return c;
|
|
94
|
+
}
|
|
95
|
+
var EvmVenueABI = viem.parseAbi([
|
|
96
|
+
"struct OfferItem { uint8 itemType; address token; uint256 identifier; uint256 amount; }",
|
|
97
|
+
"struct ConsiderationItem { uint8 itemType; address token; uint256 identifier; uint256 amount; address recipient; }",
|
|
98
|
+
"struct OrderParameters { address offerer; OfferItem offer; ConsiderationItem consideration; uint256 royaltyMaxBps; uint256 startTime; uint256 endTime; uint256 salt; uint256 counter; }",
|
|
99
|
+
"function registerOrder(OrderParameters parameters, bytes signature)",
|
|
100
|
+
"function fulfillOrder(bytes32 orderHash) payable",
|
|
101
|
+
"function cancelOrder(bytes32 orderHash)",
|
|
102
|
+
"function incrementCounter()",
|
|
103
|
+
"function getOrderHash(OrderParameters parameters) view returns (bytes32)",
|
|
104
|
+
"function getCounter(address offerer) view returns (uint256)",
|
|
105
|
+
"function version() pure returns (string)",
|
|
106
|
+
"event OrderCreated(bytes32 indexed orderHash, address indexed offerer)",
|
|
107
|
+
"event OrderFulfilled(bytes32 indexed orderHash, address indexed offerer, address indexed fulfiller, uint256 saleAmount, address royaltyReceiver, uint256 royaltyAmount)",
|
|
108
|
+
"event OrderCancelled(bytes32 indexed orderHash, address indexed offerer)",
|
|
109
|
+
"event CounterIncremented(address indexed offerer, uint256 newCounter)"
|
|
110
|
+
]);
|
|
111
|
+
var EvmVenue1155ABI = viem.parseAbi([
|
|
112
|
+
"function fulfillOrder(bytes32 orderHash, uint256 quantity) payable",
|
|
113
|
+
"event OrderFulfilled(bytes32 indexed orderHash, address indexed offerer, address indexed fulfiller, uint256 quantity, uint256 remainingAmount, uint256 saleAmount, address royaltyReceiver, uint256 royaltyAmount)"
|
|
114
|
+
]);
|
|
115
|
+
var EvmMipRegistryABI = viem.parseAbi([
|
|
116
|
+
"function createCollection(string name, string symbol, string baseUri, uint96 royaltyBps) returns (uint256 collectionId, address collection)",
|
|
117
|
+
"function getCollection(uint256 collectionId) view returns (address collection, address creator)",
|
|
118
|
+
"function collectionCount() view returns (uint256)",
|
|
119
|
+
"event CollectionCreated(uint256 indexed collectionId, address indexed collection, address indexed creator, string name, string symbol, string baseUri)"
|
|
120
|
+
]);
|
|
121
|
+
var EvmMipCollectionABI = viem.parseAbi([
|
|
122
|
+
"function mint(address to, string metadataUri) returns (uint256 tokenId)",
|
|
123
|
+
"function batchMint(address[] to, string[] metadataUris) returns (uint256[] tokenIds)",
|
|
124
|
+
"function tokenURI(uint256 tokenId) view returns (string)",
|
|
125
|
+
"function ownerOf(uint256 tokenId) view returns (address)",
|
|
126
|
+
"function balanceOf(address owner) view returns (uint256)",
|
|
127
|
+
"function owner() view returns (address)",
|
|
128
|
+
"event TokenMinted(uint256 indexed tokenId, address indexed owner, string metadataUri)",
|
|
129
|
+
"event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"
|
|
130
|
+
]);
|
|
131
|
+
|
|
132
|
+
// src/evm/venue.ts
|
|
133
|
+
var EvmVenue = class {
|
|
134
|
+
constructor(opts) {
|
|
135
|
+
this.chain = opts.chain;
|
|
136
|
+
this.chainId = opts.chainId;
|
|
137
|
+
this.publicClient = opts.publicClient;
|
|
138
|
+
this.variant = opts.variant;
|
|
139
|
+
const coords = maybeCoords(opts.chain);
|
|
140
|
+
const contract = opts.contract ?? (opts.variant === "721" ? coords?.marketplace721 : coords?.marketplace1155);
|
|
141
|
+
if (!contract) throw new Error(`No ${opts.variant} venue configured for ${opts.chain}`);
|
|
142
|
+
this.contract = contract;
|
|
143
|
+
}
|
|
144
|
+
/** Builds the order struct, signs the EIP-712 digest, and registers it.
|
|
145
|
+
* The digest is the canonical order id on EVM chains. */
|
|
146
|
+
async registerOrder(signer, params) {
|
|
147
|
+
const account = signer.account;
|
|
148
|
+
if (!account) throw new Error("WalletClient has no account");
|
|
149
|
+
const counter = await this.getCounter(account.address);
|
|
150
|
+
const nft = {
|
|
151
|
+
itemType: 2,
|
|
152
|
+
token: params.asset.contract,
|
|
153
|
+
identifier: BigInt(params.asset.tokenId),
|
|
154
|
+
amount: 1n
|
|
155
|
+
};
|
|
156
|
+
const payment = {
|
|
157
|
+
itemType: params.paymentToken === NATIVE_SENTINEL ? 0 : 1,
|
|
158
|
+
token: params.paymentToken === NATIVE_SENTINEL ? "0x0000000000000000000000000000000000000000" : params.paymentToken,
|
|
159
|
+
identifier: 0n,
|
|
160
|
+
amount: BigInt(params.amount)
|
|
161
|
+
};
|
|
162
|
+
const order = params.side === "listing" ? {
|
|
163
|
+
offerer: account.address,
|
|
164
|
+
offer: nft,
|
|
165
|
+
consideration: { ...payment, recipient: account.address },
|
|
166
|
+
...commonFields(params)
|
|
167
|
+
} : {
|
|
168
|
+
offerer: account.address,
|
|
169
|
+
offer: payment,
|
|
170
|
+
consideration: { ...nft, recipient: account.address },
|
|
171
|
+
...commonFields(params)
|
|
172
|
+
};
|
|
173
|
+
order.counter = counter;
|
|
174
|
+
const signature = await signer.signTypedData({
|
|
175
|
+
account,
|
|
176
|
+
domain: evmOrderDomain(this.chainId, this.contract),
|
|
177
|
+
types: EVM_ORDER_TYPES,
|
|
178
|
+
primaryType: "OrderParameters",
|
|
179
|
+
message: order
|
|
180
|
+
});
|
|
181
|
+
const txHash = await signer.writeContract({
|
|
182
|
+
account,
|
|
183
|
+
chain: signer.chain,
|
|
184
|
+
address: this.contract,
|
|
185
|
+
abi: EvmVenueABI,
|
|
186
|
+
functionName: "registerOrder",
|
|
187
|
+
args: [order, signature]
|
|
188
|
+
});
|
|
189
|
+
return { txHash, orderRef: evmOrderDigest(this.chainId, this.contract, order) };
|
|
190
|
+
}
|
|
191
|
+
async fulfillOrder(signer, orderRef, opts) {
|
|
192
|
+
const account = signer.account;
|
|
193
|
+
if (!account) throw new Error("WalletClient has no account");
|
|
194
|
+
const value = opts?.value ? BigInt(opts.value) : void 0;
|
|
195
|
+
const txHash = this.variant === "1155" ? await signer.writeContract({
|
|
196
|
+
account,
|
|
197
|
+
chain: signer.chain,
|
|
198
|
+
address: this.contract,
|
|
199
|
+
abi: EvmVenue1155ABI,
|
|
200
|
+
functionName: "fulfillOrder",
|
|
201
|
+
args: [orderRef, BigInt(opts?.quantity ?? "1")],
|
|
202
|
+
value
|
|
203
|
+
}) : await signer.writeContract({
|
|
204
|
+
account,
|
|
205
|
+
chain: signer.chain,
|
|
206
|
+
address: this.contract,
|
|
207
|
+
abi: EvmVenueABI,
|
|
208
|
+
functionName: "fulfillOrder",
|
|
209
|
+
args: [orderRef],
|
|
210
|
+
value
|
|
211
|
+
});
|
|
212
|
+
return { txHash };
|
|
213
|
+
}
|
|
214
|
+
async cancelOrder(signer, orderRef) {
|
|
215
|
+
const account = signer.account;
|
|
216
|
+
if (!account) throw new Error("WalletClient has no account");
|
|
217
|
+
const txHash = await signer.writeContract({
|
|
218
|
+
account,
|
|
219
|
+
chain: signer.chain,
|
|
220
|
+
address: this.contract,
|
|
221
|
+
abi: EvmVenueABI,
|
|
222
|
+
functionName: "cancelOrder",
|
|
223
|
+
args: [orderRef]
|
|
224
|
+
});
|
|
225
|
+
return { txHash };
|
|
226
|
+
}
|
|
227
|
+
async incrementCounter(signer) {
|
|
228
|
+
const account = signer.account;
|
|
229
|
+
if (!account) throw new Error("WalletClient has no account");
|
|
230
|
+
const txHash = await signer.writeContract({
|
|
231
|
+
account,
|
|
232
|
+
chain: signer.chain,
|
|
233
|
+
address: this.contract,
|
|
234
|
+
abi: EvmVenueABI,
|
|
235
|
+
functionName: "incrementCounter",
|
|
236
|
+
args: []
|
|
237
|
+
});
|
|
238
|
+
return { txHash };
|
|
239
|
+
}
|
|
240
|
+
async getOrderDetails(orderRef) {
|
|
241
|
+
return this.publicClient.readContract({
|
|
242
|
+
address: this.contract,
|
|
243
|
+
abi: [
|
|
244
|
+
{
|
|
245
|
+
type: "function",
|
|
246
|
+
name: "getOrderDetails",
|
|
247
|
+
stateMutability: "view",
|
|
248
|
+
inputs: [{ name: "orderHash", type: "bytes32" }],
|
|
249
|
+
outputs: [{ name: "", type: "bytes" }]
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
functionName: "getOrderDetails",
|
|
253
|
+
args: [orderRef]
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
async getCounter(address) {
|
|
257
|
+
return this.publicClient.readContract({
|
|
258
|
+
address: this.contract,
|
|
259
|
+
abi: EvmVenueABI,
|
|
260
|
+
functionName: "getCounter",
|
|
261
|
+
args: [address]
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
var NATIVE_SENTINEL = "native";
|
|
266
|
+
function commonFields(params) {
|
|
267
|
+
return {
|
|
268
|
+
royaltyMaxBps: BigInt(params.royaltyMaxBps),
|
|
269
|
+
startTime: BigInt(params.startTime),
|
|
270
|
+
endTime: BigInt(params.endTime),
|
|
271
|
+
salt: BigInt(params.salt),
|
|
272
|
+
counter: 0n
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function maybeCoords(chain) {
|
|
276
|
+
try {
|
|
277
|
+
return getCoordinates(chain);
|
|
278
|
+
} catch {
|
|
279
|
+
return void 0;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
var EvmIssuance = class {
|
|
283
|
+
constructor(opts) {
|
|
284
|
+
this.chain = opts.chain;
|
|
285
|
+
this.publicClient = opts.publicClient;
|
|
286
|
+
const registry = opts.registry ?? maybeCoords2(opts.chain)?.mipRegistry;
|
|
287
|
+
if (!registry) throw new Error(`No MIP registry configured for ${opts.chain}`);
|
|
288
|
+
this.registry = registry;
|
|
289
|
+
}
|
|
290
|
+
async createCollection(signer, params) {
|
|
291
|
+
const account = signer.account;
|
|
292
|
+
if (!account) throw new Error("WalletClient has no account");
|
|
293
|
+
const txHash = await signer.writeContract({
|
|
294
|
+
account,
|
|
295
|
+
chain: signer.chain,
|
|
296
|
+
address: this.registry,
|
|
297
|
+
abi: EvmMipRegistryABI,
|
|
298
|
+
functionName: "createCollection",
|
|
299
|
+
args: [params.name, params.symbol, params.baseUri, BigInt(params.royaltyBps)]
|
|
300
|
+
});
|
|
301
|
+
const receipt = await this.publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
302
|
+
const [created] = viem.parseEventLogs({
|
|
303
|
+
abi: EvmMipRegistryABI,
|
|
304
|
+
eventName: "CollectionCreated",
|
|
305
|
+
logs: receipt.logs
|
|
306
|
+
});
|
|
307
|
+
return { txHash, collection: created?.args.collection ?? "" };
|
|
308
|
+
}
|
|
309
|
+
async mint(signer, params) {
|
|
310
|
+
const account = signer.account;
|
|
311
|
+
if (!account) throw new Error("WalletClient has no account");
|
|
312
|
+
const txHash = await signer.writeContract({
|
|
313
|
+
account,
|
|
314
|
+
chain: signer.chain,
|
|
315
|
+
address: params.collection,
|
|
316
|
+
abi: EvmMipCollectionABI,
|
|
317
|
+
functionName: "mint",
|
|
318
|
+
args: [params.recipient, params.tokenUri]
|
|
319
|
+
});
|
|
320
|
+
const receipt = await this.publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
321
|
+
const [minted] = viem.parseEventLogs({
|
|
322
|
+
abi: EvmMipCollectionABI,
|
|
323
|
+
eventName: "TokenMinted",
|
|
324
|
+
logs: receipt.logs
|
|
325
|
+
});
|
|
326
|
+
return { txHash, tokenId: (minted?.args.tokenId ?? 0n).toString() };
|
|
327
|
+
}
|
|
328
|
+
async batchMint(signer, params) {
|
|
329
|
+
const account = signer.account;
|
|
330
|
+
if (!account) throw new Error("WalletClient has no account");
|
|
331
|
+
const txHash = await signer.writeContract({
|
|
332
|
+
account,
|
|
333
|
+
chain: signer.chain,
|
|
334
|
+
address: params.collection,
|
|
335
|
+
abi: EvmMipCollectionABI,
|
|
336
|
+
functionName: "batchMint",
|
|
337
|
+
args: [params.recipients, params.tokenUris]
|
|
338
|
+
});
|
|
339
|
+
return { txHash };
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
function maybeCoords2(chain) {
|
|
343
|
+
try {
|
|
344
|
+
return getCoordinates(chain);
|
|
345
|
+
} catch {
|
|
346
|
+
return void 0;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
exports.EVM_ORDER_TYPES = EVM_ORDER_TYPES;
|
|
351
|
+
exports.EvmIssuance = EvmIssuance;
|
|
352
|
+
exports.EvmMipCollectionABI = EvmMipCollectionABI;
|
|
353
|
+
exports.EvmMipRegistryABI = EvmMipRegistryABI;
|
|
354
|
+
exports.EvmVenue = EvmVenue;
|
|
355
|
+
exports.EvmVenue1155ABI = EvmVenue1155ABI;
|
|
356
|
+
exports.EvmVenueABI = EvmVenueABI;
|
|
357
|
+
exports.NATIVE_SENTINEL = NATIVE_SENTINEL;
|
|
358
|
+
exports.evmOrderDigest = evmOrderDigest;
|
|
359
|
+
exports.evmOrderDomain = evmOrderDomain;
|
|
360
|
+
//# sourceMappingURL=index.cjs.map
|
|
361
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/evm/typedData.ts","../../src/chains.ts","../../src/evm/abis.ts","../../src/evm/venue.ts","../../src/evm/issuance.ts"],"names":["hashTypedData","parseAbi","maybeCoords","parseEventLogs"],"mappings":";;;;;AASO,IAAM,eAAA,GAAkB;AAAA,EAC7B,SAAA,EAAW;AAAA,IACT,EAAE,IAAA,EAAM,UAAA,EAAY,IAAA,EAAM,OAAA,EAAQ;AAAA,IAClC,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA,EAAU;AAAA,IACjC,EAAE,IAAA,EAAM,YAAA,EAAc,IAAA,EAAM,SAAA,EAAU;AAAA,IACtC,EAAE,IAAA,EAAM,QAAA,EAAU,IAAA,EAAM,SAAA;AAAU,GACpC;AAAA,EACA,iBAAA,EAAmB;AAAA,IACjB,EAAE,IAAA,EAAM,UAAA,EAAY,IAAA,EAAM,OAAA,EAAQ;AAAA,IAClC,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA,EAAU;AAAA,IACjC,EAAE,IAAA,EAAM,YAAA,EAAc,IAAA,EAAM,SAAA,EAAU;AAAA,IAC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AK,OAAA,IAAW,EAAA,EAAI,UAAS,EAAE;AAAA,EACpE;AAAA,EAEA,MAAM,SAAA,CACJ,MAAA,EACA,MAAA,EAC0B;AAC1B,IAAA,MAAM,UAAU,MAAA,CAAO,OAAA;AACvB,IAAA,IAAI,CAAC,OAAA,EAAS,MAAM,IAAI,MAAM,6BAA6B,CAAA;AAC3D,IAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,aAAA,CAAc;AAAA,MACxC,OAAA;AAAA,MACA,OAAO,MAAA,CAAO,KAAA;AAAA,MACd,SAAS,MAAA,CAAO,UAAA;AAAA,MAChB,GAAA,EAAK,mBAAA;AAAA,MACL,YAAA,EAAc,WAAA;AAAA,MACd,IAAA,EAAM,CAAC,MAAA,CAAO,UAAA,EAA+B,OAAO,SAAS;AAAA,KAC9D,CAAA;AACD,IAAA,OAAO,EAAE,MAAA,EAAO;AAAA,EAClB;AACF;AAEA,SAASD,aAAY,KAAA,EAA6C;AAChE,EAAA,IAAI;AACF,IAAA,OAAO,eAAe,KAAK,CAAA;AAAA,EAC7B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF","file":"index.cjs","sourcesContent":["import { hashTypedData, type TypedDataDomain } from \"viem\";\n\n/**\n * EIP-712 order typing for the Medialane EVM venues — byte-identical to the\n * audited Solidity (contracts/EVM-Marketplace-ERC721/src/Medialane721.sol and\n * the 1155 venue, which shares the type strings; the domain's\n * verifyingContract separates deployments and venues).\n */\n\nexport const EVM_ORDER_TYPES = {\n OfferItem: [\n { name: \"itemType\", type: \"uint8\" },\n { name: \"token\", type: \"address\" },\n { name: \"identifier\", type: \"uint256\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n ConsiderationItem: [\n { name: \"itemType\", type: \"uint8\" },\n { name: \"token\", type: \"address\" },\n { name: \"identifier\", type: \"uint256\" },\n { name: \"amount\", type: \"uint256\" },\n { name: \"recipient\", type: \"address\" },\n ],\n OrderParameters: [\n { name: \"offerer\", type: \"address\" },\n { name: \"offer\", type: \"OfferItem\" },\n { name: \"consideration\", type: \"ConsiderationItem\" },\n { name: \"royaltyMaxBps\", type: \"uint256\" },\n { name: \"startTime\", type: \"uint256\" },\n { name: \"endTime\", type: \"uint256\" },\n { name: \"salt\", type: \"uint256\" },\n { name: \"counter\", type: \"uint256\" },\n ],\n} as const;\n\n/** NATIVE=0, ERC20=1, ERC721=2 on the 721 venue; NATIVE=0, ERC20=1, ERC1155=2 on the 1155 venue. */\nexport type EvmItemType = 0 | 1 | 2;\n\nexport interface EvmOfferItem {\n itemType: EvmItemType;\n token: `0x${string}`;\n identifier: bigint;\n amount: bigint;\n}\n\nexport interface EvmConsiderationItem extends EvmOfferItem {\n recipient: `0x${string}`;\n}\n\nexport interface EvmOrderParameters {\n offerer: `0x${string}`;\n offer: EvmOfferItem;\n consideration: EvmConsiderationItem;\n royaltyMaxBps: bigint;\n startTime: bigint;\n endTime: bigint;\n salt: bigint;\n counter: bigint;\n}\n\nexport function evmOrderDomain(chainId: number, verifyingContract: `0x${string}`): TypedDataDomain {\n return { name: \"Medialane\", version: \"1\", chainId, verifyingContract };\n}\n\n/** The order's EIP-712 digest — the venue's order hash and the platform's\n * canonical order id on EVM chains. */\nexport function evmOrderDigest(\n chainId: number,\n verifyingContract: `0x${string}`,\n parameters: EvmOrderParameters,\n): `0x${string}` {\n return hashTypedData({\n domain: evmOrderDomain(chainId, verifyingContract),\n types: EVM_ORDER_TYPES,\n primaryType: \"OrderParameters\",\n message: parameters,\n });\n}\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 ipClubFactory?: `0x${string}`;\n ipClubFactoryClassHash?: `0x${string}`;\n ipClubCollectionClassHash?: `0x${string}`;\n ipClubFactoryStartBlock?: 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 ipClubFactory: \"0x010726346c264d1832a7303afaf5692dbd2b05446fecc6da30d958d0227c36d0\",\n ipClubFactoryClassHash: \"0x07197062578375d962b2d42d3e91560770b11b1c97a9defb74c706a2c5299473\",\n ipClubCollectionClassHash: \"0x049dc5e5ff00e67d5d457c6991ee70822f36a979b76cefd1b617aeccd7051d4b\",\n ipClubFactoryStartBlock: 11652766,\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 { parseAbi } from \"viem\";\n\n/** Minimal venue ABI — verified against Medialane721.sol / Medialane1155.sol.\n * The 1155 venue's fulfillOrder additionally takes a quantity. */\nexport const EvmVenueABI = parseAbi([\n \"struct OfferItem { uint8 itemType; address token; uint256 identifier; uint256 amount; }\",\n \"struct ConsiderationItem { uint8 itemType; address token; uint256 identifier; uint256 amount; address recipient; }\",\n \"struct OrderParameters { address offerer; OfferItem offer; ConsiderationItem consideration; uint256 royaltyMaxBps; uint256 startTime; uint256 endTime; uint256 salt; uint256 counter; }\",\n \"function registerOrder(OrderParameters parameters, bytes signature)\",\n \"function fulfillOrder(bytes32 orderHash) payable\",\n \"function cancelOrder(bytes32 orderHash)\",\n \"function incrementCounter()\",\n \"function getOrderHash(OrderParameters parameters) view returns (bytes32)\",\n \"function getCounter(address offerer) view returns (uint256)\",\n \"function version() pure returns (string)\",\n \"event OrderCreated(bytes32 indexed orderHash, address indexed offerer)\",\n \"event OrderFulfilled(bytes32 indexed orderHash, address indexed offerer, address indexed fulfiller, uint256 saleAmount, address royaltyReceiver, uint256 royaltyAmount)\",\n \"event OrderCancelled(bytes32 indexed orderHash, address indexed offerer)\",\n \"event CounterIncremented(address indexed offerer, uint256 newCounter)\",\n]);\n\nexport const EvmVenue1155ABI = parseAbi([\n \"function fulfillOrder(bytes32 orderHash, uint256 quantity) payable\",\n \"event OrderFulfilled(bytes32 indexed orderHash, address indexed offerer, address indexed fulfiller, uint256 quantity, uint256 remainingAmount, uint256 saleAmount, address royaltyReceiver, uint256 royaltyAmount)\",\n]);\n\n/** MIP issuance — verified against MIPRegistry.sol / MIPCollection.sol (and\n * the editions pair, which shares the registry surface). */\nexport const EvmMipRegistryABI = parseAbi([\n \"function createCollection(string name, string symbol, string baseUri, uint96 royaltyBps) returns (uint256 collectionId, address collection)\",\n \"function getCollection(uint256 collectionId) view returns (address collection, address creator)\",\n \"function collectionCount() view returns (uint256)\",\n \"event CollectionCreated(uint256 indexed collectionId, address indexed collection, address indexed creator, string name, string symbol, string baseUri)\",\n]);\n\nexport const EvmMipCollectionABI = parseAbi([\n \"function mint(address to, string metadataUri) returns (uint256 tokenId)\",\n \"function batchMint(address[] to, string[] metadataUris) returns (uint256[] tokenIds)\",\n \"function tokenURI(uint256 tokenId) view returns (string)\",\n \"function ownerOf(uint256 tokenId) view returns (address)\",\n \"function balanceOf(address owner) view returns (uint256)\",\n \"function owner() view returns (address)\",\n \"event TokenMinted(uint256 indexed tokenId, address indexed owner, string metadataUri)\",\n \"event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)\",\n]);\n","import type { PublicClient, WalletClient } from \"viem\";\nimport type { Chain } from \"../chains.js\";\nimport { getCoordinates, type EvmCoordinates } from \"../chains.js\";\nimport type {\n AdapterTxResult,\n OrderRef,\n RegisterOrderParams,\n VenueAdapter,\n} from \"../adapters/types.js\";\nimport { EvmVenueABI, EvmVenue1155ABI } from \"./abis.js\";\nimport {\n EVM_ORDER_TYPES,\n evmOrderDigest,\n evmOrderDomain,\n type EvmOrderParameters,\n} from \"./typedData.js\";\n\nexport type EvmChain = \"ETHEREUM\" | \"BASE\";\n\nexport interface EvmVenueOptions {\n chain: EvmChain;\n chainId: number;\n publicClient: PublicClient;\n /** \"721\" (unique assets) or \"1155\" (partial fills). */\n variant: \"721\" | \"1155\";\n /** Defaults to the chain registry's venue address (populated at deploy). */\n contract?: `0x${string}`;\n}\n\n/** The Medialane venue adapter for EVM chains — one implementation serves\n * Ethereum and Base (same bytecode; the EIP-712 domain separates them). */\nexport class EvmVenue implements VenueAdapter<WalletClient> {\n readonly chain: Chain;\n private readonly chainId: number;\n private readonly contract: `0x${string}`;\n private readonly publicClient: PublicClient;\n private readonly variant: \"721\" | \"1155\";\n\n constructor(opts: EvmVenueOptions) {\n this.chain = opts.chain;\n this.chainId = opts.chainId;\n this.publicClient = opts.publicClient;\n this.variant = opts.variant;\n const coords = maybeCoords(opts.chain);\n const contract =\n opts.contract ?? (opts.variant === \"721\" ? coords?.marketplace721 : coords?.marketplace1155);\n if (!contract) throw new Error(`No ${opts.variant} venue configured for ${opts.chain}`);\n this.contract = contract;\n }\n\n /** Builds the order struct, signs the EIP-712 digest, and registers it.\n * The digest is the canonical order id on EVM chains. */\n async registerOrder(\n signer: WalletClient,\n params: RegisterOrderParams,\n ): Promise<AdapterTxResult & { orderRef: OrderRef }> {\n const account = signer.account;\n if (!account) throw new Error(\"WalletClient has no account\");\n const counter = await this.getCounter(account.address);\n const nft = {\n itemType: 2 as const,\n token: params.asset.contract as `0x${string}`,\n identifier: BigInt(params.asset.tokenId),\n amount: 1n,\n };\n const payment = {\n itemType: (params.paymentToken === NATIVE_SENTINEL ? 0 : 1) as 0 | 1,\n token: (params.paymentToken === NATIVE_SENTINEL\n ? \"0x0000000000000000000000000000000000000000\"\n : params.paymentToken) as `0x${string}`,\n identifier: 0n,\n amount: BigInt(params.amount),\n };\n const order: EvmOrderParameters =\n params.side === \"listing\"\n ? {\n offerer: account.address,\n offer: nft,\n consideration: { ...payment, recipient: account.address },\n ...commonFields(params),\n }\n : {\n offerer: account.address,\n offer: payment,\n consideration: { ...nft, recipient: account.address },\n ...commonFields(params),\n };\n order.counter = counter;\n\n const signature = await signer.signTypedData({\n account,\n domain: evmOrderDomain(this.chainId, this.contract),\n types: EVM_ORDER_TYPES,\n primaryType: \"OrderParameters\",\n message: order,\n });\n const txHash = await signer.writeContract({\n account,\n chain: signer.chain,\n address: this.contract,\n abi: EvmVenueABI,\n functionName: \"registerOrder\",\n args: [order, signature],\n });\n return { txHash, orderRef: evmOrderDigest(this.chainId, this.contract, order) };\n }\n\n async fulfillOrder(\n signer: WalletClient,\n orderRef: OrderRef,\n opts?: { quantity?: string; value?: string },\n ): Promise<AdapterTxResult> {\n const account = signer.account;\n if (!account) throw new Error(\"WalletClient has no account\");\n const value = opts?.value ? BigInt(opts.value) : undefined;\n const txHash =\n this.variant === \"1155\"\n ? await signer.writeContract({\n account,\n chain: signer.chain,\n address: this.contract,\n abi: EvmVenue1155ABI,\n functionName: \"fulfillOrder\",\n args: [orderRef as `0x${string}`, BigInt(opts?.quantity ?? \"1\")],\n value,\n })\n : await signer.writeContract({\n account,\n chain: signer.chain,\n address: this.contract,\n abi: EvmVenueABI,\n functionName: \"fulfillOrder\",\n args: [orderRef as `0x${string}`],\n value,\n });\n return { txHash };\n }\n\n async cancelOrder(signer: WalletClient, orderRef: OrderRef): Promise<AdapterTxResult> {\n const account = signer.account;\n if (!account) throw new Error(\"WalletClient has no account\");\n const txHash = await signer.writeContract({\n account,\n chain: signer.chain,\n address: this.contract,\n abi: EvmVenueABI,\n functionName: \"cancelOrder\",\n args: [orderRef as `0x${string}`],\n });\n return { txHash };\n }\n\n async incrementCounter(signer: WalletClient): Promise<AdapterTxResult> {\n const account = signer.account;\n if (!account) throw new Error(\"WalletClient has no account\");\n const txHash = await signer.writeContract({\n account,\n chain: signer.chain,\n address: this.contract,\n abi: EvmVenueABI,\n functionName: \"incrementCounter\",\n args: [],\n });\n return { txHash };\n }\n\n async getOrderDetails(orderRef: OrderRef): Promise<unknown> {\n return this.publicClient.readContract({\n address: this.contract,\n abi: [\n {\n type: \"function\",\n name: \"getOrderDetails\",\n stateMutability: \"view\",\n inputs: [{ name: \"orderHash\", type: \"bytes32\" }],\n outputs: [{ name: \"\", type: \"bytes\" }],\n },\n ] as const,\n functionName: \"getOrderDetails\",\n args: [orderRef as `0x${string}`],\n });\n }\n\n async getCounter(address: string): Promise<bigint> {\n return this.publicClient.readContract({\n address: this.contract,\n abi: EvmVenueABI,\n functionName: \"getCounter\",\n args: [address as `0x${string}`],\n });\n }\n}\n\n/** Payment-token sentinel for native ETH (spec §3.2b currency encoding). */\nexport const NATIVE_SENTINEL = \"native\";\n\nfunction commonFields(params: RegisterOrderParams) {\n return {\n royaltyMaxBps: BigInt(params.royaltyMaxBps),\n startTime: BigInt(params.startTime),\n endTime: BigInt(params.endTime),\n salt: BigInt(params.salt),\n counter: 0n,\n };\n}\n\nfunction maybeCoords(chain: EvmChain): EvmCoordinates | undefined {\n try {\n return getCoordinates(chain);\n } catch {\n return undefined;\n }\n}\n","import type { PublicClient, WalletClient } from \"viem\";\nimport { parseEventLogs } from \"viem\";\nimport type { Chain } from \"../chains.js\";\nimport { getCoordinates, type EvmCoordinates } from \"../chains.js\";\nimport type { AdapterTxResult, CreateCollectionInput, IssuanceAdapter, MintInput } from \"../adapters/types.js\";\nimport { EvmMipCollectionABI, EvmMipRegistryABI } from \"./abis.js\";\nimport type { EvmChain } from \"./venue.js\";\n\nexport interface EvmIssuanceOptions {\n chain: EvmChain;\n publicClient: PublicClient;\n /** Defaults to the chain registry's MIP registry (populated at deploy). */\n registry?: `0x${string}`;\n}\n\n/** The Mediolano issuance adapter for EVM chains. */\nexport class EvmIssuance implements IssuanceAdapter<WalletClient> {\n readonly chain: Chain;\n private readonly registry: `0x${string}`;\n private readonly publicClient: PublicClient;\n\n constructor(opts: EvmIssuanceOptions) {\n this.chain = opts.chain;\n this.publicClient = opts.publicClient;\n const registry = opts.registry ?? maybeCoords(opts.chain)?.mipRegistry;\n if (!registry) throw new Error(`No MIP registry configured for ${opts.chain}`);\n this.registry = registry;\n }\n\n async createCollection(\n signer: WalletClient,\n params: CreateCollectionInput,\n ): Promise<AdapterTxResult & { collection: string }> {\n const account = signer.account;\n if (!account) throw new Error(\"WalletClient has no account\");\n const txHash = await signer.writeContract({\n account,\n chain: signer.chain,\n address: this.registry,\n abi: EvmMipRegistryABI,\n functionName: \"createCollection\",\n args: [params.name, params.symbol, params.baseUri, BigInt(params.royaltyBps)],\n });\n const receipt = await this.publicClient.waitForTransactionReceipt({ hash: txHash });\n const [created] = parseEventLogs({\n abi: EvmMipRegistryABI,\n eventName: \"CollectionCreated\",\n logs: receipt.logs,\n });\n return { txHash, collection: created?.args.collection ?? \"\" };\n }\n\n async mint(signer: WalletClient, params: MintInput): Promise<AdapterTxResult & { tokenId: string }> {\n const account = signer.account;\n if (!account) throw new Error(\"WalletClient has no account\");\n const txHash = await signer.writeContract({\n account,\n chain: signer.chain,\n address: params.collection as `0x${string}`,\n abi: EvmMipCollectionABI,\n functionName: \"mint\",\n args: [params.recipient as `0x${string}`, params.tokenUri],\n });\n const receipt = await this.publicClient.waitForTransactionReceipt({ hash: txHash });\n const [minted] = parseEventLogs({\n abi: EvmMipCollectionABI,\n eventName: \"TokenMinted\",\n logs: receipt.logs,\n });\n return { txHash, tokenId: (minted?.args.tokenId ?? 0n).toString() };\n }\n\n async batchMint(\n signer: WalletClient,\n params: { collection: string; recipients: string[]; tokenUris: string[] },\n ): Promise<AdapterTxResult> {\n const account = signer.account;\n if (!account) throw new Error(\"WalletClient has no account\");\n const txHash = await signer.writeContract({\n account,\n chain: signer.chain,\n address: params.collection as `0x${string}`,\n abi: EvmMipCollectionABI,\n functionName: \"batchMint\",\n args: [params.recipients as `0x${string}`[], params.tokenUris],\n });\n return { txHash };\n }\n}\n\nfunction maybeCoords(chain: EvmChain): EvmCoordinates | undefined {\n try {\n return getCoordinates(chain);\n } catch {\n return undefined;\n }\n}\n"]}
|