@morpho-dev/router 0.0.24 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.d.cts +52 -5
- package/dist/index.browser.d.ts +52 -5
- package/dist/index.browser.js +37 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +37 -8
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.node.d.cts +53 -6
- package/dist/index.node.d.ts +53 -6
- package/dist/index.node.js +37 -8
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +37 -8
- package/dist/index.node.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.browser.d.cts
CHANGED
|
@@ -22,6 +22,7 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
|
|
|
22
22
|
name: ChainName;
|
|
23
23
|
whitelistedAssets: Set<Address>;
|
|
24
24
|
morpho: Address;
|
|
25
|
+
termsContract: Address;
|
|
25
26
|
mempool?: {
|
|
26
27
|
address: Address;
|
|
27
28
|
deploymentBlock: number;
|
|
@@ -52,6 +53,13 @@ type RouterOffer = Offer.Offer & {
|
|
|
52
53
|
status: OfferStatus;
|
|
53
54
|
metadata?: OfferMetadata;
|
|
54
55
|
};
|
|
56
|
+
type OfferConsumed = {
|
|
57
|
+
id: string;
|
|
58
|
+
chainId: bigint;
|
|
59
|
+
offering: Address;
|
|
60
|
+
nonce: bigint;
|
|
61
|
+
amount: bigint;
|
|
62
|
+
};
|
|
55
63
|
declare const RouterOfferSchema: (parameters?: {
|
|
56
64
|
omitHash?: boolean;
|
|
57
65
|
}) => zod_v4.ZodObject<{
|
|
@@ -88,6 +96,30 @@ declare const RouterOfferSchema: (parameters?: {
|
|
|
88
96
|
issue: z.ZodString;
|
|
89
97
|
}, z.core.$strip>>;
|
|
90
98
|
}, zod_v4_core.$strip>;
|
|
99
|
+
/**
|
|
100
|
+
* ABI for the Consumed event emitted by the terms contract.
|
|
101
|
+
*/
|
|
102
|
+
declare const consumedEvent: {
|
|
103
|
+
readonly type: "event";
|
|
104
|
+
readonly name: "Consumed";
|
|
105
|
+
readonly inputs: readonly [{
|
|
106
|
+
readonly name: "user";
|
|
107
|
+
readonly type: "address";
|
|
108
|
+
readonly indexed: true;
|
|
109
|
+
readonly internalType: "address";
|
|
110
|
+
}, {
|
|
111
|
+
readonly name: "nonce";
|
|
112
|
+
readonly type: "uint256";
|
|
113
|
+
readonly indexed: true;
|
|
114
|
+
readonly internalType: "uint256";
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: "amount";
|
|
117
|
+
readonly type: "uint256";
|
|
118
|
+
readonly indexed: false;
|
|
119
|
+
readonly internalType: "uint256";
|
|
120
|
+
}];
|
|
121
|
+
readonly anonymous: false;
|
|
122
|
+
};
|
|
91
123
|
/**
|
|
92
124
|
* Creates a router offer from a plain object.
|
|
93
125
|
* @throws {InvalidRouterOfferError} If the router offer is invalid.
|
|
@@ -115,6 +147,15 @@ declare namespace fromSnakeCase {
|
|
|
115
147
|
*/
|
|
116
148
|
declare function toSnakeCase(offer: RouterOffer): Format.Snake<RouterOffer>;
|
|
117
149
|
declare function random(): RouterOffer;
|
|
150
|
+
declare function fromConsumedLog(parameters: {
|
|
151
|
+
blockNumber: bigint;
|
|
152
|
+
logIndex: number;
|
|
153
|
+
chainId: number;
|
|
154
|
+
transactionHash: Hex;
|
|
155
|
+
user: Address;
|
|
156
|
+
nonce: bigint;
|
|
157
|
+
amount: bigint;
|
|
158
|
+
}): OfferConsumed;
|
|
118
159
|
declare class InvalidRouterOfferError extends Errors.BaseError<ZodError | Error> {
|
|
119
160
|
readonly name = "RouterOffer.InvalidRouterOfferError";
|
|
120
161
|
constructor(error: ZodError | Error);
|
|
@@ -122,16 +163,19 @@ declare class InvalidRouterOfferError extends Errors.BaseError<ZodError | Error>
|
|
|
122
163
|
|
|
123
164
|
type RouterOffer$1_InvalidRouterOfferError = InvalidRouterOfferError;
|
|
124
165
|
declare const RouterOffer$1_InvalidRouterOfferError: typeof InvalidRouterOfferError;
|
|
166
|
+
type RouterOffer$1_OfferConsumed = OfferConsumed;
|
|
125
167
|
type RouterOffer$1_OfferMetadata = OfferMetadata;
|
|
126
168
|
type RouterOffer$1_OfferStatus = OfferStatus;
|
|
127
169
|
declare const RouterOffer$1_OfferStatusValues: typeof OfferStatusValues;
|
|
128
170
|
type RouterOffer$1_RouterOffer = RouterOffer;
|
|
129
171
|
declare const RouterOffer$1_RouterOfferSchema: typeof RouterOfferSchema;
|
|
172
|
+
declare const RouterOffer$1_consumedEvent: typeof consumedEvent;
|
|
173
|
+
declare const RouterOffer$1_fromConsumedLog: typeof fromConsumedLog;
|
|
130
174
|
declare const RouterOffer$1_fromSnakeCase: typeof fromSnakeCase;
|
|
131
175
|
declare const RouterOffer$1_random: typeof random;
|
|
132
176
|
declare const RouterOffer$1_toSnakeCase: typeof toSnakeCase;
|
|
133
177
|
declare namespace RouterOffer$1 {
|
|
134
|
-
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, from$1 as from, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
178
|
+
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferConsumed as OfferConsumed, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, RouterOffer$1_consumedEvent as consumedEvent, from$1 as from, RouterOffer$1_fromConsumedLog as fromConsumedLog, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
135
179
|
}
|
|
136
180
|
|
|
137
181
|
type OfferResponse = {
|
|
@@ -348,6 +392,7 @@ type OfferStore = {
|
|
|
348
392
|
metadata?: OfferMetadata;
|
|
349
393
|
}) => Promise<void>;
|
|
350
394
|
updateConsumedAmount: (parameters: {
|
|
395
|
+
id: string;
|
|
351
396
|
chainId: Offer.Offer["chainId"];
|
|
352
397
|
offering: Offer.Offer["offering"];
|
|
353
398
|
nonce: Offer.Offer["nonce"];
|
|
@@ -356,13 +401,13 @@ type OfferStore = {
|
|
|
356
401
|
/** Persist latest indexing progress for a chain and event type. */
|
|
357
402
|
saveLatestBlockNumberProcessed: (parameters: {
|
|
358
403
|
chainId: Offer.Offer["chainId"];
|
|
359
|
-
eventType: "offer_created" | "
|
|
404
|
+
eventType: "offer_created" | "offer_consumed";
|
|
360
405
|
latestBlockNumber: number;
|
|
361
406
|
}) => Promise<void>;
|
|
362
407
|
/** Retrieve latest indexing progress for a chain and event type. */
|
|
363
408
|
getLatestBlockNumberProcessed: (parameters: {
|
|
364
409
|
chainId: Offer.Offer["chainId"];
|
|
365
|
-
eventType: "offer_created" | "
|
|
410
|
+
eventType: "offer_created" | "offer_consumed";
|
|
366
411
|
}) => Promise<{
|
|
367
412
|
latestBlockNumber: number;
|
|
368
413
|
} | null>;
|
|
@@ -438,13 +483,15 @@ declare namespace index$1 {
|
|
|
438
483
|
export { type index$1_FindMatchingOffersParams as FindMatchingOffersParams, type index$1_GetAllParams as GetAllParams, type index$1_GetOffersFilters as GetOffersFilters, type index$1_OfferStore as OfferStore, index$1_memory as memory };
|
|
439
484
|
}
|
|
440
485
|
|
|
441
|
-
declare const types: readonly ["offer_created", "
|
|
486
|
+
declare const types: readonly ["offer_created", "offer_consumed", "offer_validation"];
|
|
442
487
|
type Type = (typeof types)[number];
|
|
443
488
|
type BaseEvent<type extends Type = Type> = {
|
|
444
489
|
readonly id: string;
|
|
445
490
|
readonly type: type;
|
|
446
491
|
};
|
|
447
|
-
type RouterEvent<type extends Type = Type> = type extends "
|
|
492
|
+
type RouterEvent<type extends Type = Type> = type extends "offer_consumed" ? Compute<BaseEvent<type> & {
|
|
493
|
+
readonly offerConsumed: OfferConsumed;
|
|
494
|
+
}> : type extends "offer_created" | "offer_validation" ? Compute<BaseEvent<type> & {
|
|
448
495
|
readonly offer: Offer.Offer;
|
|
449
496
|
}> : never;
|
|
450
497
|
/**
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ type Chain = Compute<Omit<Chain$2, "id" | "name"> & {
|
|
|
22
22
|
name: ChainName;
|
|
23
23
|
whitelistedAssets: Set<Address>;
|
|
24
24
|
morpho: Address;
|
|
25
|
+
termsContract: Address;
|
|
25
26
|
mempool?: {
|
|
26
27
|
address: Address;
|
|
27
28
|
deploymentBlock: number;
|
|
@@ -52,6 +53,13 @@ type RouterOffer = Offer.Offer & {
|
|
|
52
53
|
status: OfferStatus;
|
|
53
54
|
metadata?: OfferMetadata;
|
|
54
55
|
};
|
|
56
|
+
type OfferConsumed = {
|
|
57
|
+
id: string;
|
|
58
|
+
chainId: bigint;
|
|
59
|
+
offering: Address;
|
|
60
|
+
nonce: bigint;
|
|
61
|
+
amount: bigint;
|
|
62
|
+
};
|
|
55
63
|
declare const RouterOfferSchema: (parameters?: {
|
|
56
64
|
omitHash?: boolean;
|
|
57
65
|
}) => zod_v4.ZodObject<{
|
|
@@ -88,6 +96,30 @@ declare const RouterOfferSchema: (parameters?: {
|
|
|
88
96
|
issue: z.ZodString;
|
|
89
97
|
}, z.core.$strip>>;
|
|
90
98
|
}, zod_v4_core.$strip>;
|
|
99
|
+
/**
|
|
100
|
+
* ABI for the Consumed event emitted by the terms contract.
|
|
101
|
+
*/
|
|
102
|
+
declare const consumedEvent: {
|
|
103
|
+
readonly type: "event";
|
|
104
|
+
readonly name: "Consumed";
|
|
105
|
+
readonly inputs: readonly [{
|
|
106
|
+
readonly name: "user";
|
|
107
|
+
readonly type: "address";
|
|
108
|
+
readonly indexed: true;
|
|
109
|
+
readonly internalType: "address";
|
|
110
|
+
}, {
|
|
111
|
+
readonly name: "nonce";
|
|
112
|
+
readonly type: "uint256";
|
|
113
|
+
readonly indexed: true;
|
|
114
|
+
readonly internalType: "uint256";
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: "amount";
|
|
117
|
+
readonly type: "uint256";
|
|
118
|
+
readonly indexed: false;
|
|
119
|
+
readonly internalType: "uint256";
|
|
120
|
+
}];
|
|
121
|
+
readonly anonymous: false;
|
|
122
|
+
};
|
|
91
123
|
/**
|
|
92
124
|
* Creates a router offer from a plain object.
|
|
93
125
|
* @throws {InvalidRouterOfferError} If the router offer is invalid.
|
|
@@ -115,6 +147,15 @@ declare namespace fromSnakeCase {
|
|
|
115
147
|
*/
|
|
116
148
|
declare function toSnakeCase(offer: RouterOffer): Format.Snake<RouterOffer>;
|
|
117
149
|
declare function random(): RouterOffer;
|
|
150
|
+
declare function fromConsumedLog(parameters: {
|
|
151
|
+
blockNumber: bigint;
|
|
152
|
+
logIndex: number;
|
|
153
|
+
chainId: number;
|
|
154
|
+
transactionHash: Hex;
|
|
155
|
+
user: Address;
|
|
156
|
+
nonce: bigint;
|
|
157
|
+
amount: bigint;
|
|
158
|
+
}): OfferConsumed;
|
|
118
159
|
declare class InvalidRouterOfferError extends Errors.BaseError<ZodError | Error> {
|
|
119
160
|
readonly name = "RouterOffer.InvalidRouterOfferError";
|
|
120
161
|
constructor(error: ZodError | Error);
|
|
@@ -122,16 +163,19 @@ declare class InvalidRouterOfferError extends Errors.BaseError<ZodError | Error>
|
|
|
122
163
|
|
|
123
164
|
type RouterOffer$1_InvalidRouterOfferError = InvalidRouterOfferError;
|
|
124
165
|
declare const RouterOffer$1_InvalidRouterOfferError: typeof InvalidRouterOfferError;
|
|
166
|
+
type RouterOffer$1_OfferConsumed = OfferConsumed;
|
|
125
167
|
type RouterOffer$1_OfferMetadata = OfferMetadata;
|
|
126
168
|
type RouterOffer$1_OfferStatus = OfferStatus;
|
|
127
169
|
declare const RouterOffer$1_OfferStatusValues: typeof OfferStatusValues;
|
|
128
170
|
type RouterOffer$1_RouterOffer = RouterOffer;
|
|
129
171
|
declare const RouterOffer$1_RouterOfferSchema: typeof RouterOfferSchema;
|
|
172
|
+
declare const RouterOffer$1_consumedEvent: typeof consumedEvent;
|
|
173
|
+
declare const RouterOffer$1_fromConsumedLog: typeof fromConsumedLog;
|
|
130
174
|
declare const RouterOffer$1_fromSnakeCase: typeof fromSnakeCase;
|
|
131
175
|
declare const RouterOffer$1_random: typeof random;
|
|
132
176
|
declare const RouterOffer$1_toSnakeCase: typeof toSnakeCase;
|
|
133
177
|
declare namespace RouterOffer$1 {
|
|
134
|
-
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, from$1 as from, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
178
|
+
export { RouterOffer$1_InvalidRouterOfferError as InvalidRouterOfferError, type RouterOffer$1_OfferConsumed as OfferConsumed, type RouterOffer$1_OfferMetadata as OfferMetadata, type RouterOffer$1_OfferStatus as OfferStatus, RouterOffer$1_OfferStatusValues as OfferStatusValues, type RouterOffer$1_RouterOffer as RouterOffer, RouterOffer$1_RouterOfferSchema as RouterOfferSchema, RouterOffer$1_consumedEvent as consumedEvent, from$1 as from, RouterOffer$1_fromConsumedLog as fromConsumedLog, RouterOffer$1_fromSnakeCase as fromSnakeCase, RouterOffer$1_random as random, RouterOffer$1_toSnakeCase as toSnakeCase };
|
|
135
179
|
}
|
|
136
180
|
|
|
137
181
|
type OfferResponse = {
|
|
@@ -348,6 +392,7 @@ type OfferStore = {
|
|
|
348
392
|
metadata?: OfferMetadata;
|
|
349
393
|
}) => Promise<void>;
|
|
350
394
|
updateConsumedAmount: (parameters: {
|
|
395
|
+
id: string;
|
|
351
396
|
chainId: Offer.Offer["chainId"];
|
|
352
397
|
offering: Offer.Offer["offering"];
|
|
353
398
|
nonce: Offer.Offer["nonce"];
|
|
@@ -356,13 +401,13 @@ type OfferStore = {
|
|
|
356
401
|
/** Persist latest indexing progress for a chain and event type. */
|
|
357
402
|
saveLatestBlockNumberProcessed: (parameters: {
|
|
358
403
|
chainId: Offer.Offer["chainId"];
|
|
359
|
-
eventType: "offer_created" | "
|
|
404
|
+
eventType: "offer_created" | "offer_consumed";
|
|
360
405
|
latestBlockNumber: number;
|
|
361
406
|
}) => Promise<void>;
|
|
362
407
|
/** Retrieve latest indexing progress for a chain and event type. */
|
|
363
408
|
getLatestBlockNumberProcessed: (parameters: {
|
|
364
409
|
chainId: Offer.Offer["chainId"];
|
|
365
|
-
eventType: "offer_created" | "
|
|
410
|
+
eventType: "offer_created" | "offer_consumed";
|
|
366
411
|
}) => Promise<{
|
|
367
412
|
latestBlockNumber: number;
|
|
368
413
|
} | null>;
|
|
@@ -438,13 +483,15 @@ declare namespace index$1 {
|
|
|
438
483
|
export { type index$1_FindMatchingOffersParams as FindMatchingOffersParams, type index$1_GetAllParams as GetAllParams, type index$1_GetOffersFilters as GetOffersFilters, type index$1_OfferStore as OfferStore, index$1_memory as memory };
|
|
439
484
|
}
|
|
440
485
|
|
|
441
|
-
declare const types: readonly ["offer_created", "
|
|
486
|
+
declare const types: readonly ["offer_created", "offer_consumed", "offer_validation"];
|
|
442
487
|
type Type = (typeof types)[number];
|
|
443
488
|
type BaseEvent<type extends Type = Type> = {
|
|
444
489
|
readonly id: string;
|
|
445
490
|
readonly type: type;
|
|
446
491
|
};
|
|
447
|
-
type RouterEvent<type extends Type = Type> = type extends "
|
|
492
|
+
type RouterEvent<type extends Type = Type> = type extends "offer_consumed" ? Compute<BaseEvent<type> & {
|
|
493
|
+
readonly offerConsumed: OfferConsumed;
|
|
494
|
+
}> : type extends "offer_created" | "offer_validation" ? Compute<BaseEvent<type> & {
|
|
448
495
|
readonly offer: Offer.Offer;
|
|
449
496
|
}> : never;
|
|
450
497
|
/**
|
package/dist/index.browser.js
CHANGED
|
@@ -28,7 +28,7 @@ var chainNames = ["ethereum", "base", "ethereum-virtual-testnet"];
|
|
|
28
28
|
var ChainId = {
|
|
29
29
|
ETHEREUM: BigInt(chains$1.mainnet.id),
|
|
30
30
|
BASE: BigInt(chains$1.base.id),
|
|
31
|
-
"ETHEREUM-VIRTUAL-TESTNET":
|
|
31
|
+
"ETHEREUM-VIRTUAL-TESTNET": 109111114n
|
|
32
32
|
};
|
|
33
33
|
var chainIds = new Set(Object.values(ChainId));
|
|
34
34
|
var chainNameLookup = new Map(Object.entries(ChainId).map(([key, value]) => [value, key]));
|
|
@@ -52,7 +52,8 @@ var chains = {
|
|
|
52
52
|
// DAI
|
|
53
53
|
].map((address) => address.toLowerCase())
|
|
54
54
|
),
|
|
55
|
-
morpho: "0x0000000000000000000000000000000000000000"
|
|
55
|
+
morpho: "0x0000000000000000000000000000000000000000",
|
|
56
|
+
termsContract: "0x0000000000000000000000000000000000000000"
|
|
56
57
|
},
|
|
57
58
|
base: {
|
|
58
59
|
...chains$1.base,
|
|
@@ -66,11 +67,12 @@ var chains = {
|
|
|
66
67
|
// DAI
|
|
67
68
|
].map((address) => address.toLowerCase())
|
|
68
69
|
),
|
|
69
|
-
morpho: "0x0000000000000000000000000000000000000000"
|
|
70
|
+
morpho: "0x0000000000000000000000000000000000000000",
|
|
71
|
+
termsContract: "0x0000000000000000000000000000000000000000"
|
|
70
72
|
},
|
|
71
73
|
"ethereum-virtual-testnet": {
|
|
72
74
|
...chains$1.mainnet,
|
|
73
|
-
id:
|
|
75
|
+
id: 109111114n,
|
|
74
76
|
name: "ethereum-virtual-testnet",
|
|
75
77
|
whitelistedAssets: new Set(
|
|
76
78
|
[
|
|
@@ -81,9 +83,10 @@ var chains = {
|
|
|
81
83
|
].map((address) => address.toLowerCase())
|
|
82
84
|
),
|
|
83
85
|
morpho: "0x0000000000000000000000000000000000000000",
|
|
86
|
+
termsContract: "0xa85d462ceb11d6f91f003072fdc701b0a1bbd8bd",
|
|
84
87
|
mempool: {
|
|
85
88
|
address: "0x7be3164eeee8b35092f6128ec32c2e6ff8f6c890",
|
|
86
|
-
deploymentBlock:
|
|
89
|
+
deploymentBlock: 23223727,
|
|
87
90
|
reindexBuffer: 10
|
|
88
91
|
}
|
|
89
92
|
}
|
|
@@ -108,7 +111,9 @@ __export(RouterOffer_exports, {
|
|
|
108
111
|
InvalidRouterOfferError: () => InvalidRouterOfferError,
|
|
109
112
|
OfferStatusValues: () => OfferStatusValues,
|
|
110
113
|
RouterOfferSchema: () => RouterOfferSchema,
|
|
114
|
+
consumedEvent: () => consumedEvent,
|
|
111
115
|
from: () => from,
|
|
116
|
+
fromConsumedLog: () => fromConsumedLog,
|
|
112
117
|
fromSnakeCase: () => fromSnakeCase,
|
|
113
118
|
random: () => random,
|
|
114
119
|
toSnakeCase: () => toSnakeCase
|
|
@@ -126,6 +131,16 @@ var RouterOfferSchema = (parameters) => mempool.Offer.OfferSchema(parameters).ex
|
|
|
126
131
|
issue: v4.z.string()
|
|
127
132
|
}).optional()
|
|
128
133
|
});
|
|
134
|
+
var consumedEvent = {
|
|
135
|
+
type: "event",
|
|
136
|
+
name: "Consumed",
|
|
137
|
+
inputs: [
|
|
138
|
+
{ name: "user", type: "address", indexed: true, internalType: "address" },
|
|
139
|
+
{ name: "nonce", type: "uint256", indexed: true, internalType: "uint256" },
|
|
140
|
+
{ name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
|
|
141
|
+
],
|
|
142
|
+
anonymous: false
|
|
143
|
+
};
|
|
129
144
|
function from(input) {
|
|
130
145
|
try {
|
|
131
146
|
const parsedOffer = RouterOfferSchema({ omitHash: true }).parse(input);
|
|
@@ -153,6 +168,16 @@ function random() {
|
|
|
153
168
|
consumed: 0n
|
|
154
169
|
});
|
|
155
170
|
}
|
|
171
|
+
function fromConsumedLog(parameters) {
|
|
172
|
+
const { blockNumber, logIndex, chainId, transactionHash, user, nonce, amount } = parameters;
|
|
173
|
+
return {
|
|
174
|
+
id: `${blockNumber.toString()}-${logIndex.toString()}-${chainId}-${transactionHash}`,
|
|
175
|
+
chainId: BigInt(chainId),
|
|
176
|
+
offering: user,
|
|
177
|
+
nonce,
|
|
178
|
+
amount
|
|
179
|
+
};
|
|
180
|
+
}
|
|
156
181
|
var InvalidRouterOfferError = class extends mempool.Errors.BaseError {
|
|
157
182
|
constructor(error) {
|
|
158
183
|
super("Invalid router offer.", { cause: error });
|
|
@@ -1090,6 +1115,7 @@ __export(OfferStore_exports, {
|
|
|
1090
1115
|
function memory(parameters) {
|
|
1091
1116
|
const map = parameters.offers;
|
|
1092
1117
|
const filled = parameters.filled;
|
|
1118
|
+
const consumedIds = /* @__PURE__ */ new Set();
|
|
1093
1119
|
const indexingProgress = /* @__PURE__ */ new Map();
|
|
1094
1120
|
const create = async (parameters2) => {
|
|
1095
1121
|
if (map.has(parameters2.offer.hash.toLowerCase())) return parameters2.offer.hash;
|
|
@@ -1423,12 +1449,15 @@ function memory(parameters) {
|
|
|
1423
1449
|
});
|
|
1424
1450
|
},
|
|
1425
1451
|
updateConsumedAmount: async (parameters2) => {
|
|
1452
|
+
if (consumedIds.has(parameters2.id)) return;
|
|
1453
|
+
consumedIds.add(parameters2.id);
|
|
1426
1454
|
const chainId = parameters2.chainId;
|
|
1427
1455
|
const address = parameters2.offering.toLowerCase();
|
|
1428
1456
|
const nonce = parameters2.nonce;
|
|
1429
1457
|
const filledForChain = filled.get(chainId) || /* @__PURE__ */ new Map();
|
|
1430
1458
|
const filledForOffering = filledForChain.get(address) || /* @__PURE__ */ new Map();
|
|
1431
|
-
filledForOffering.
|
|
1459
|
+
const current = filledForOffering.get(nonce) || 0n;
|
|
1460
|
+
filledForOffering.set(nonce, current + parameters2.consumed);
|
|
1432
1461
|
filledForChain.set(address, filledForOffering);
|
|
1433
1462
|
filled.set(chainId, filledForChain);
|
|
1434
1463
|
},
|
|
@@ -1450,9 +1479,9 @@ __export(RouterEvent_exports, {
|
|
|
1450
1479
|
from: () => from2,
|
|
1451
1480
|
types: () => types
|
|
1452
1481
|
});
|
|
1453
|
-
var types = ["offer_created", "
|
|
1482
|
+
var types = ["offer_created", "offer_consumed", "offer_validation"];
|
|
1454
1483
|
function from2(base) {
|
|
1455
|
-
const id = `${base.type}:${base.offer.hash.toLowerCase()}`;
|
|
1484
|
+
const id = base.type === "offer_consumed" ? `${base.type}:${base.offerConsumed.id}` : `${base.type}:${base.offer.hash.toLowerCase()}`;
|
|
1456
1485
|
return { id, ...base };
|
|
1457
1486
|
}
|
|
1458
1487
|
|