@morpho-dev/router 0.0.25 → 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 +34 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +34 -5
- 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 +34 -5
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +34 -5
- package/dist/index.node.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.node.mjs
CHANGED
|
@@ -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
|
...base,
|
|
@@ -66,7 +67,8 @@ 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
|
...mainnet,
|
|
@@ -81,6 +83,7 @@ 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
89
|
deploymentBlock: 23223727,
|
|
@@ -105,7 +108,9 @@ __export(RouterOffer_exports, {
|
|
|
105
108
|
InvalidRouterOfferError: () => InvalidRouterOfferError,
|
|
106
109
|
OfferStatusValues: () => OfferStatusValues,
|
|
107
110
|
RouterOfferSchema: () => RouterOfferSchema,
|
|
111
|
+
consumedEvent: () => consumedEvent,
|
|
108
112
|
from: () => from,
|
|
113
|
+
fromConsumedLog: () => fromConsumedLog,
|
|
109
114
|
fromSnakeCase: () => fromSnakeCase,
|
|
110
115
|
random: () => random,
|
|
111
116
|
toSnakeCase: () => toSnakeCase
|
|
@@ -123,6 +128,16 @@ var RouterOfferSchema = (parameters) => Offer.OfferSchema(parameters).extend({
|
|
|
123
128
|
issue: z.string()
|
|
124
129
|
}).optional()
|
|
125
130
|
});
|
|
131
|
+
var consumedEvent = {
|
|
132
|
+
type: "event",
|
|
133
|
+
name: "Consumed",
|
|
134
|
+
inputs: [
|
|
135
|
+
{ name: "user", type: "address", indexed: true, internalType: "address" },
|
|
136
|
+
{ name: "nonce", type: "uint256", indexed: true, internalType: "uint256" },
|
|
137
|
+
{ name: "amount", type: "uint256", indexed: false, internalType: "uint256" }
|
|
138
|
+
],
|
|
139
|
+
anonymous: false
|
|
140
|
+
};
|
|
126
141
|
function from(input) {
|
|
127
142
|
try {
|
|
128
143
|
const parsedOffer = RouterOfferSchema({ omitHash: true }).parse(input);
|
|
@@ -150,6 +165,16 @@ function random() {
|
|
|
150
165
|
consumed: 0n
|
|
151
166
|
});
|
|
152
167
|
}
|
|
168
|
+
function fromConsumedLog(parameters) {
|
|
169
|
+
const { blockNumber, logIndex, chainId, transactionHash, user, nonce, amount } = parameters;
|
|
170
|
+
return {
|
|
171
|
+
id: `${blockNumber.toString()}-${logIndex.toString()}-${chainId}-${transactionHash}`,
|
|
172
|
+
chainId: BigInt(chainId),
|
|
173
|
+
offering: user,
|
|
174
|
+
nonce,
|
|
175
|
+
amount
|
|
176
|
+
};
|
|
177
|
+
}
|
|
153
178
|
var InvalidRouterOfferError = class extends Errors.BaseError {
|
|
154
179
|
name = "RouterOffer.InvalidRouterOfferError";
|
|
155
180
|
constructor(error2) {
|
|
@@ -1110,6 +1135,7 @@ __export(OfferStore_exports, {
|
|
|
1110
1135
|
function memory(parameters) {
|
|
1111
1136
|
const map = parameters.offers;
|
|
1112
1137
|
const filled = parameters.filled;
|
|
1138
|
+
const consumedIds = /* @__PURE__ */ new Set();
|
|
1113
1139
|
const indexingProgress = /* @__PURE__ */ new Map();
|
|
1114
1140
|
const create = async (parameters2) => {
|
|
1115
1141
|
if (map.has(parameters2.offer.hash.toLowerCase())) return parameters2.offer.hash;
|
|
@@ -1443,12 +1469,15 @@ function memory(parameters) {
|
|
|
1443
1469
|
});
|
|
1444
1470
|
},
|
|
1445
1471
|
updateConsumedAmount: async (parameters2) => {
|
|
1472
|
+
if (consumedIds.has(parameters2.id)) return;
|
|
1473
|
+
consumedIds.add(parameters2.id);
|
|
1446
1474
|
const chainId = parameters2.chainId;
|
|
1447
1475
|
const address = parameters2.offering.toLowerCase();
|
|
1448
1476
|
const nonce = parameters2.nonce;
|
|
1449
1477
|
const filledForChain = filled.get(chainId) || /* @__PURE__ */ new Map();
|
|
1450
1478
|
const filledForOffering = filledForChain.get(address) || /* @__PURE__ */ new Map();
|
|
1451
|
-
filledForOffering.
|
|
1479
|
+
const current = filledForOffering.get(nonce) || 0n;
|
|
1480
|
+
filledForOffering.set(nonce, current + parameters2.consumed);
|
|
1452
1481
|
filledForChain.set(address, filledForOffering);
|
|
1453
1482
|
filled.set(chainId, filledForChain);
|
|
1454
1483
|
},
|
|
@@ -1688,9 +1717,9 @@ __export(RouterEvent_exports, {
|
|
|
1688
1717
|
from: () => from2,
|
|
1689
1718
|
types: () => types
|
|
1690
1719
|
});
|
|
1691
|
-
var types = ["offer_created", "
|
|
1720
|
+
var types = ["offer_created", "offer_consumed", "offer_validation"];
|
|
1692
1721
|
function from2(base) {
|
|
1693
|
-
const id = `${base.type}:${base.offer.hash.toLowerCase()}`;
|
|
1722
|
+
const id = base.type === "offer_consumed" ? `${base.type}:${base.offerConsumed.id}` : `${base.type}:${base.offer.hash.toLowerCase()}`;
|
|
1694
1723
|
return { id, ...base };
|
|
1695
1724
|
}
|
|
1696
1725
|
|