@latticexyz/common 2.2.18-90aac1d4acce19ac592d47a090732dd11c1c3e7a → 2.2.18-9fa07c8489f1fbf167d0db01cd9aaa645a29c8e2
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/actions.cjs +334 -0
- package/dist/actions.cjs.map +1 -0
- package/dist/actions.d.cts +27 -0
- package/dist/actions.js +39 -1
- package/dist/actions.js.map +1 -1
- package/dist/chains.cjs +106 -0
- package/dist/chains.cjs.map +1 -0
- package/dist/chains.d.cts +968 -0
- package/dist/chains.js +75 -1
- package/dist/chains.js.map +1 -1
- package/dist/chunk-D4GDXAMP.js +64 -0
- package/dist/{chunk-ZIUX7JCQ.js.map → chunk-D4GDXAMP.js.map} +1 -1
- package/dist/chunk-IYZZFDNO.js +16 -0
- package/dist/{chunk-ZV2KGJCD.js.map → chunk-IYZZFDNO.js.map} +1 -1
- package/dist/chunk-MF5NFUW7.js +12 -0
- package/dist/{chunk-QQCZY3XJ.js.map → chunk-MF5NFUW7.js.map} +1 -1
- package/dist/chunk-MK6UECU7.js +11 -0
- package/dist/{chunk-TCWGPC6G.js.map → chunk-MK6UECU7.js.map} +1 -1
- package/dist/chunk-MYWRXQQH.js +208 -0
- package/dist/{chunk-6FIKI2CG.js.map → chunk-MYWRXQQH.js.map} +1 -1
- package/dist/chunk-Z6SVAIZN.js +70 -0
- package/dist/{chunk-DPUUE7NM.js.map → chunk-Z6SVAIZN.js.map} +1 -1
- package/dist/codegen.cjs +889 -0
- package/dist/codegen.cjs.map +1 -0
- package/dist/codegen.d.cts +228 -0
- package/dist/codegen.js +706 -49
- package/dist/codegen.js.map +1 -1
- package/dist/errors.cjs +38 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +5 -0
- package/dist/errors.js +6 -1
- package/dist/foundry.cjs +105 -0
- package/dist/foundry.cjs.map +1 -0
- package/dist/foundry.d.cts +69 -0
- package/dist/foundry.js +71 -2
- package/dist/foundry.js.map +1 -1
- package/dist/getContract-CA0EdVg6.d.cts +20 -0
- package/dist/index.cjs +597 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +160 -0
- package/dist/index.js +233 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +459 -0
- package/dist/internal.cjs.map +1 -0
- package/dist/internal.d.cts +36 -0
- package/dist/internal.js +205 -9
- package/dist/internal.js.map +1 -1
- package/dist/kms.cjs +204 -0
- package/dist/kms.cjs.map +1 -0
- package/dist/kms.d.cts +18 -0
- package/dist/kms.js +168 -1
- package/dist/kms.js.map +1 -1
- package/dist/type-utils.cjs +19 -0
- package/dist/type-utils.cjs.map +1 -0
- package/dist/type-utils.d.cts +19 -0
- package/dist/utils.cjs +174 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +40 -0
- package/dist/utils.js +122 -1
- package/dist/utils.js.map +1 -1
- package/package.json +104 -16
- package/dist/chunk-6FIKI2CG.js +0 -2
- package/dist/chunk-DPUUE7NM.js +0 -2
- package/dist/chunk-QQCZY3XJ.js +0 -2
- package/dist/chunk-TCWGPC6G.js +0 -2
- package/dist/chunk-ZIUX7JCQ.js +0 -2
- package/dist/chunk-ZV2KGJCD.js +0 -2
package/dist/actions.cjs
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/actions/index.ts
|
|
31
|
+
var actions_exports = {};
|
|
32
|
+
__export(actions_exports, {
|
|
33
|
+
transactionQueue: () => transactionQueue,
|
|
34
|
+
writeObserver: () => writeObserver
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(actions_exports);
|
|
37
|
+
|
|
38
|
+
// src/writeContract.ts
|
|
39
|
+
var import_actions5 = require("viem/actions");
|
|
40
|
+
var import_p_retry = __toESM(require("p-retry"), 1);
|
|
41
|
+
|
|
42
|
+
// src/debug.ts
|
|
43
|
+
var import_debug = __toESM(require("debug"), 1);
|
|
44
|
+
var debug = (0, import_debug.default)("mud:common");
|
|
45
|
+
var error = (0, import_debug.default)("mud:common");
|
|
46
|
+
debug.log = console.debug.bind(console);
|
|
47
|
+
error.log = console.error.bind(console);
|
|
48
|
+
|
|
49
|
+
// src/getNonceManagerId.ts
|
|
50
|
+
var import_viem = require("viem");
|
|
51
|
+
var import_actions = require("viem/actions");
|
|
52
|
+
var import_utils = require("viem/utils");
|
|
53
|
+
async function getNonceManagerId({
|
|
54
|
+
client,
|
|
55
|
+
address,
|
|
56
|
+
blockTag
|
|
57
|
+
}) {
|
|
58
|
+
const chainId = client.chain?.id ?? await (0, import_utils.getAction)(client, import_actions.getChainId, "getChainId")({});
|
|
59
|
+
return `mud:createNonceManager:${chainId}:${(0, import_viem.getAddress)(address)}:${blockTag}`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/createNonceManager.ts
|
|
63
|
+
var import_actions2 = require("viem/actions");
|
|
64
|
+
var import_p_queue = __toESM(require("p-queue"), 1);
|
|
65
|
+
var import_utils2 = require("viem/utils");
|
|
66
|
+
|
|
67
|
+
// src/findCause.ts
|
|
68
|
+
function findCause(error2, fn) {
|
|
69
|
+
if (fn?.(error2)) return error2;
|
|
70
|
+
if (error2.cause instanceof Error) return findCause(error2.cause, fn);
|
|
71
|
+
return fn ? null : error2;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/createNonceManager.ts
|
|
75
|
+
var debug2 = debug.extend("createNonceManager");
|
|
76
|
+
function createNonceManager({
|
|
77
|
+
client,
|
|
78
|
+
address,
|
|
79
|
+
// TODO: rename to account?
|
|
80
|
+
blockTag = "latest",
|
|
81
|
+
broadcastChannelName,
|
|
82
|
+
queueConcurrency = 1
|
|
83
|
+
}) {
|
|
84
|
+
const ref = { nonce: -1, noncePromise: null };
|
|
85
|
+
let channel = null;
|
|
86
|
+
if (typeof BroadcastChannel !== "undefined") {
|
|
87
|
+
const channelName = broadcastChannelName ? Promise.resolve(broadcastChannelName) : getNonceManagerId({ client, address, blockTag });
|
|
88
|
+
channelName.then((name) => {
|
|
89
|
+
channel = new BroadcastChannel(name);
|
|
90
|
+
channel.addEventListener("message", (event) => {
|
|
91
|
+
const nonce = JSON.parse(event.data);
|
|
92
|
+
debug2("got nonce from broadcast channel", nonce);
|
|
93
|
+
ref.nonce = nonce;
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function hasNonce() {
|
|
98
|
+
return ref.nonce >= 0;
|
|
99
|
+
}
|
|
100
|
+
function getNonce() {
|
|
101
|
+
if (!hasNonce()) throw new Error("call resetNonce before using getNonce");
|
|
102
|
+
return ref.nonce;
|
|
103
|
+
}
|
|
104
|
+
function nextNonce() {
|
|
105
|
+
if (!hasNonce()) throw new Error("call resetNonce before using nextNonce");
|
|
106
|
+
const nonce = ref.nonce++;
|
|
107
|
+
channel?.postMessage(JSON.stringify(ref.nonce));
|
|
108
|
+
return nonce;
|
|
109
|
+
}
|
|
110
|
+
async function resetNonce() {
|
|
111
|
+
ref.noncePromise ??= (async () => {
|
|
112
|
+
ref.nonce = await (0, import_utils2.getAction)(client, import_actions2.getTransactionCount, "getTransactionCount")({ address, blockTag });
|
|
113
|
+
ref.noncePromise = null;
|
|
114
|
+
channel?.postMessage(JSON.stringify(ref.nonce));
|
|
115
|
+
debug2("reset nonce to", ref.nonce);
|
|
116
|
+
})();
|
|
117
|
+
await ref.noncePromise;
|
|
118
|
+
}
|
|
119
|
+
function shouldResetNonce(error2) {
|
|
120
|
+
const nonceError = findCause(error2, ({ name }) => name === "NonceTooLowError" || name === "NonceTooHighError");
|
|
121
|
+
return nonceError != null;
|
|
122
|
+
}
|
|
123
|
+
const mempoolQueue = new import_p_queue.default({ concurrency: queueConcurrency });
|
|
124
|
+
return {
|
|
125
|
+
hasNonce,
|
|
126
|
+
getNonce,
|
|
127
|
+
nextNonce,
|
|
128
|
+
resetNonce,
|
|
129
|
+
shouldResetNonce,
|
|
130
|
+
mempoolQueue
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/getNonceManager.ts
|
|
135
|
+
var nonceManagers = /* @__PURE__ */ new Map();
|
|
136
|
+
async function getNonceManager({
|
|
137
|
+
client,
|
|
138
|
+
address,
|
|
139
|
+
// TODO: rename to account?
|
|
140
|
+
blockTag = "latest",
|
|
141
|
+
...opts
|
|
142
|
+
}) {
|
|
143
|
+
const id = await getNonceManagerId({ client, address, blockTag });
|
|
144
|
+
const nonceManager = nonceManagers.get(id) ?? createNonceManager({ client, address, blockTag, ...opts });
|
|
145
|
+
if (!nonceManagers.has(id)) {
|
|
146
|
+
nonceManagers.set(id, nonceManager);
|
|
147
|
+
}
|
|
148
|
+
if (!nonceManager.hasNonce()) {
|
|
149
|
+
await nonceManager.resetNonce();
|
|
150
|
+
}
|
|
151
|
+
return nonceManager;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/writeContract.ts
|
|
155
|
+
var import_accounts = require("viem/accounts");
|
|
156
|
+
|
|
157
|
+
// src/getFeeRef.ts
|
|
158
|
+
var import_actions4 = require("viem/actions");
|
|
159
|
+
|
|
160
|
+
// src/createFeeRef.ts
|
|
161
|
+
var import_actions3 = require("viem/actions");
|
|
162
|
+
var import_utils3 = require("viem/utils");
|
|
163
|
+
async function createFeeRef({ client, args, refreshInterval }) {
|
|
164
|
+
const feeRef = { fees: {}, lastUpdatedTimestamp: 0 };
|
|
165
|
+
async function updateFees() {
|
|
166
|
+
const fees = await (0, import_utils3.getAction)(client, import_actions3.estimateFeesPerGas, "estimateFeesPerGas")(args);
|
|
167
|
+
feeRef.fees = fees;
|
|
168
|
+
feeRef.lastUpdatedTimestamp = Date.now();
|
|
169
|
+
}
|
|
170
|
+
setInterval(updateFees, refreshInterval);
|
|
171
|
+
await updateFees();
|
|
172
|
+
return feeRef;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/getFeeRef.ts
|
|
176
|
+
var import_utils4 = require("viem/utils");
|
|
177
|
+
var feeRefs = /* @__PURE__ */ new Map();
|
|
178
|
+
async function getFeeRef(opts) {
|
|
179
|
+
const chainId = opts.args?.chain?.id ?? opts.client.chain?.id ?? await (0, import_utils4.getAction)(opts.client, import_actions4.getChainId, "getChainId")({});
|
|
180
|
+
const existingFeeRef = feeRefs.get(chainId);
|
|
181
|
+
if (existingFeeRef) {
|
|
182
|
+
return existingFeeRef;
|
|
183
|
+
}
|
|
184
|
+
const feeRef = await createFeeRef(opts);
|
|
185
|
+
feeRefs.set(chainId, feeRef);
|
|
186
|
+
return feeRef;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// src/writeContract.ts
|
|
190
|
+
var import_utils5 = require("viem/utils");
|
|
191
|
+
var debug3 = debug.extend("writeContract");
|
|
192
|
+
async function writeContract(client, request, opts = {}) {
|
|
193
|
+
const rawAccount = request.account ?? client.account;
|
|
194
|
+
if (!rawAccount) {
|
|
195
|
+
throw new Error("No account provided");
|
|
196
|
+
}
|
|
197
|
+
const account = (0, import_accounts.parseAccount)(rawAccount);
|
|
198
|
+
const chain = client.chain;
|
|
199
|
+
const nonceManager = await getNonceManager({
|
|
200
|
+
client: opts.publicClient ?? client,
|
|
201
|
+
address: account.address,
|
|
202
|
+
queueConcurrency: opts.queueConcurrency
|
|
203
|
+
});
|
|
204
|
+
const feeRef = await getFeeRef({
|
|
205
|
+
client: opts.publicClient ?? client,
|
|
206
|
+
refreshInterval: 1e4,
|
|
207
|
+
args: { chain }
|
|
208
|
+
});
|
|
209
|
+
return nonceManager.mempoolQueue.add(
|
|
210
|
+
() => (0, import_p_retry.default)(
|
|
211
|
+
async () => {
|
|
212
|
+
const nonce = nonceManager.nextNonce();
|
|
213
|
+
const params = {
|
|
214
|
+
// viem_writeContract internally estimates gas, which we want to happen on the pending block
|
|
215
|
+
blockTag: "pending",
|
|
216
|
+
...feeRef.fees,
|
|
217
|
+
...request,
|
|
218
|
+
nonce
|
|
219
|
+
};
|
|
220
|
+
debug3("calling", params.functionName, "at", params.address, "with nonce", nonce);
|
|
221
|
+
return await (0, import_utils5.getAction)(client, import_actions5.writeContract, "writeContract")(params);
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
retries: 3,
|
|
225
|
+
onFailedAttempt: async (error2) => {
|
|
226
|
+
debug3("failed, resetting nonce");
|
|
227
|
+
await nonceManager.resetNonce();
|
|
228
|
+
if (nonceManager.shouldResetNonce(error2)) {
|
|
229
|
+
debug3("got nonce error, retrying", error2.message);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (String(error2).includes("transaction underpriced")) {
|
|
233
|
+
debug3("got transaction underpriced error, retrying", error2.message);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
throw error2;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
),
|
|
240
|
+
{ throwOnTimeout: true }
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// src/sendTransaction.ts
|
|
245
|
+
var import_actions6 = require("viem/actions");
|
|
246
|
+
var import_p_retry2 = __toESM(require("p-retry"), 1);
|
|
247
|
+
var import_accounts2 = require("viem/accounts");
|
|
248
|
+
var import_utils6 = require("viem/utils");
|
|
249
|
+
var debug4 = debug.extend("sendTransaction");
|
|
250
|
+
async function sendTransaction(client, request, opts = {}) {
|
|
251
|
+
const rawAccount = request.account ?? client.account;
|
|
252
|
+
if (!rawAccount) {
|
|
253
|
+
throw new Error("No account provided");
|
|
254
|
+
}
|
|
255
|
+
const account = (0, import_accounts2.parseAccount)(rawAccount);
|
|
256
|
+
const chain = client.chain;
|
|
257
|
+
const nonceManager = await getNonceManager({
|
|
258
|
+
client: opts.publicClient ?? client,
|
|
259
|
+
address: account.address,
|
|
260
|
+
queueConcurrency: opts.queueConcurrency
|
|
261
|
+
});
|
|
262
|
+
const feeRef = await getFeeRef({
|
|
263
|
+
client: opts.publicClient ?? client,
|
|
264
|
+
refreshInterval: 1e4,
|
|
265
|
+
args: { chain }
|
|
266
|
+
});
|
|
267
|
+
return await nonceManager.mempoolQueue.add(
|
|
268
|
+
() => (0, import_p_retry2.default)(
|
|
269
|
+
async () => {
|
|
270
|
+
const nonce = nonceManager.nextNonce();
|
|
271
|
+
const params = {
|
|
272
|
+
// viem_sendTransaction internally estimates gas, which we want to happen on the pending block
|
|
273
|
+
blockTag: "pending",
|
|
274
|
+
...feeRef.fees,
|
|
275
|
+
...request,
|
|
276
|
+
nonce
|
|
277
|
+
};
|
|
278
|
+
debug4("sending tx to", request.to, "with nonce", nonce);
|
|
279
|
+
return await (0, import_utils6.getAction)(client, import_actions6.sendTransaction, "sendTransaction")(params);
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
retries: 3,
|
|
283
|
+
onFailedAttempt: async (error2) => {
|
|
284
|
+
debug4("failed, resetting nonce");
|
|
285
|
+
await nonceManager.resetNonce();
|
|
286
|
+
if (nonceManager.shouldResetNonce(error2)) {
|
|
287
|
+
debug4("got nonce error, retrying", error2.message);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (String(error2).includes("transaction underpriced")) {
|
|
291
|
+
debug4("got transaction underpriced error, retrying", error2.message);
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
throw error2;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
),
|
|
298
|
+
{ throwOnTimeout: true }
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/actions/transactionQueue.ts
|
|
303
|
+
function transactionQueue(opts = {}) {
|
|
304
|
+
return (client) => ({
|
|
305
|
+
// Applies to: `client.writeContract`, `getContract(client, ...).write`
|
|
306
|
+
writeContract: (args) => writeContract(client, args, opts),
|
|
307
|
+
// Applies to: `client.sendTransaction`
|
|
308
|
+
sendTransaction: (args) => sendTransaction(client, args, opts)
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// src/actions/writeObserver.ts
|
|
313
|
+
var import_utils7 = require("viem/utils");
|
|
314
|
+
var import_actions7 = require("viem/actions");
|
|
315
|
+
function writeObserver({
|
|
316
|
+
onWrite
|
|
317
|
+
}) {
|
|
318
|
+
let nextWriteId = 0;
|
|
319
|
+
return (client) => ({
|
|
320
|
+
// Applies to: `client.writeContract`, `getContract(client, ...).write`
|
|
321
|
+
writeContract: (args) => {
|
|
322
|
+
const result = (0, import_utils7.getAction)(client, import_actions7.writeContract, "writeContract")(args);
|
|
323
|
+
const id = `${client.chain.id}:${client.account.address}:${nextWriteId++}`;
|
|
324
|
+
onWrite({ id, request: args, result });
|
|
325
|
+
return result;
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
330
|
+
0 && (module.exports = {
|
|
331
|
+
transactionQueue,
|
|
332
|
+
writeObserver
|
|
333
|
+
});
|
|
334
|
+
//# sourceMappingURL=actions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/actions/index.ts","../src/writeContract.ts","../src/debug.ts","../src/getNonceManagerId.ts","../src/createNonceManager.ts","../src/findCause.ts","../src/getNonceManager.ts","../src/getFeeRef.ts","../src/createFeeRef.ts","../src/sendTransaction.ts","../src/actions/transactionQueue.ts","../src/actions/writeObserver.ts"],"sourcesContent":["export * from \"./transactionQueue\";\nexport * from \"./writeObserver\";\n","import {\n Abi,\n Account,\n Chain,\n Client,\n Transport,\n WriteContractParameters,\n WriteContractReturnType,\n ContractFunctionName,\n ContractFunctionArgs,\n} from \"viem\";\nimport { writeContract as viem_writeContract } from \"viem/actions\";\nimport pRetry from \"p-retry\";\nimport { debug as parentDebug } from \"./debug\";\nimport { getNonceManager } from \"./getNonceManager\";\nimport { parseAccount } from \"viem/accounts\";\nimport { getFeeRef } from \"./getFeeRef\";\nimport { getAction } from \"viem/utils\";\n\nconst debug = parentDebug.extend(\"writeContract\");\n\nexport type WriteContractExtraOptions<chain extends Chain | undefined> = {\n /**\n * `publicClient` can be provided to be used in place of the extended viem client for making public action calls\n * (`getChainId`, `getTransactionCount`, `simulateContract`). This helps in cases where the extended\n * viem client is a smart account client, like in [permissionless.js](https://github.com/pimlicolabs/permissionless.js),\n * where the transport is the bundler, not an RPC.\n */\n publicClient?: Client<Transport, chain>;\n /**\n * Adjust the number of concurrent calls to the mempool. This defaults to `1` to ensure transactions are ordered\n * and nonces are handled properly. Any number greater than that is likely to see nonce errors and/or transactions\n * arriving out of order, but this may be an acceptable trade-off for some applications that can safely retry.\n * @default 1\n */\n queueConcurrency?: number;\n};\n\n/** @deprecated Use `walletClient.extend(transactionQueue())` instead. */\nexport async function writeContract<\n chain extends Chain | undefined,\n account extends Account | undefined,\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, \"nonpayable\" | \"payable\">,\n args extends ContractFunctionArgs<abi, \"nonpayable\" | \"payable\", functionName>,\n chainOverride extends Chain | undefined,\n>(\n client: Client<Transport, chain, account>,\n request: WriteContractParameters<abi, functionName, args, chain, account, chainOverride>,\n opts: WriteContractExtraOptions<chain> = {},\n): Promise<WriteContractReturnType> {\n const rawAccount = request.account ?? client.account;\n if (!rawAccount) {\n // TODO: replace with viem AccountNotFoundError once its exported\n throw new Error(\"No account provided\");\n }\n const account = parseAccount(rawAccount);\n const chain = client.chain;\n\n const nonceManager = await getNonceManager({\n client: opts.publicClient ?? client,\n address: account.address,\n queueConcurrency: opts.queueConcurrency,\n });\n\n const feeRef = await getFeeRef({\n client: opts.publicClient ?? client,\n refreshInterval: 10000,\n args: { chain },\n });\n\n return nonceManager.mempoolQueue.add(\n () =>\n pRetry(\n async () => {\n const nonce = nonceManager.nextNonce();\n const params = {\n // viem_writeContract internally estimates gas, which we want to happen on the pending block\n blockTag: \"pending\",\n ...feeRef.fees,\n ...request,\n nonce,\n } as const satisfies WriteContractParameters<abi, functionName, args, chain, account, chainOverride>;\n debug(\"calling\", params.functionName, \"at\", params.address, \"with nonce\", nonce);\n return await getAction(client, viem_writeContract, \"writeContract\")(params as never);\n },\n {\n retries: 3,\n onFailedAttempt: async (error) => {\n // in case this tx failed before hitting the mempool (i.e. gas estimation error), reset nonce so we don't skip past the unused nonce\n debug(\"failed, resetting nonce\");\n await nonceManager.resetNonce();\n // retry nonce errors\n // TODO: upgrade p-retry and move this to shouldRetry\n if (nonceManager.shouldResetNonce(error)) {\n debug(\"got nonce error, retrying\", error.message);\n return;\n }\n\n if (String(error).includes(\"transaction underpriced\")) {\n debug(\"got transaction underpriced error, retrying\", error.message);\n return;\n }\n\n throw error;\n },\n },\n ),\n { throwOnTimeout: true },\n );\n}\n","import createDebug from \"debug\";\n\nexport const debug = createDebug(\"mud:common\");\nexport const error = createDebug(\"mud:common\");\n\n// Pipe debug output to stdout instead of stderr\ndebug.log = console.debug.bind(console);\n\n// Pipe error output to stderr\nerror.log = console.error.bind(console);\n","import { BlockTag, Client, Hex, getAddress } from \"viem\";\nimport { getChainId } from \"viem/actions\";\nimport { getAction } from \"viem/utils\";\n\nexport async function getNonceManagerId({\n client,\n address,\n blockTag,\n}: {\n client: Client;\n address: Hex;\n blockTag: BlockTag;\n}): Promise<string> {\n // TODO: improve this so we don't have to call getChainId every time\n const chainId = client.chain?.id ?? (await getAction(client, getChainId, \"getChainId\")({}));\n return `mud:createNonceManager:${chainId}:${getAddress(address)}:${blockTag}`;\n}\n","import { BlockTag, Client, Hex } from \"viem\";\nimport { debug as parentDebug } from \"./debug\";\nimport { getNonceManagerId } from \"./getNonceManagerId\";\nimport { getTransactionCount } from \"viem/actions\";\nimport PQueue from \"p-queue\";\nimport { getAction } from \"viem/utils\";\nimport { findCause } from \"./findCause\";\n\nconst debug = parentDebug.extend(\"createNonceManager\");\n\nexport type CreateNonceManagerOptions = {\n client: Client;\n address: Hex;\n blockTag?: BlockTag;\n broadcastChannelName?: string;\n queueConcurrency?: number;\n};\n\nexport type CreateNonceManagerResult = {\n hasNonce: () => boolean;\n getNonce: () => number;\n nextNonce: () => number;\n resetNonce: () => Promise<void>;\n shouldResetNonce: (error: Error) => boolean;\n mempoolQueue: PQueue;\n};\n\nexport function createNonceManager({\n client,\n address, // TODO: rename to account?\n blockTag = \"latest\",\n broadcastChannelName,\n queueConcurrency = 1,\n}: CreateNonceManagerOptions): CreateNonceManagerResult {\n const ref = { nonce: -1, noncePromise: null as Promise<void> | null };\n let channel: BroadcastChannel | null = null;\n\n if (typeof BroadcastChannel !== \"undefined\") {\n const channelName = broadcastChannelName\n ? Promise.resolve(broadcastChannelName)\n : getNonceManagerId({ client, address, blockTag });\n channelName.then((name) => {\n channel = new BroadcastChannel(name);\n // TODO: emit some sort of \"connected\" event so other channels can broadcast current nonce\n channel.addEventListener(\"message\", (event) => {\n const nonce = JSON.parse(event.data);\n debug(\"got nonce from broadcast channel\", nonce);\n ref.nonce = nonce;\n });\n });\n }\n\n function hasNonce(): boolean {\n return ref.nonce >= 0;\n }\n\n function getNonce(): number {\n if (!hasNonce()) throw new Error(\"call resetNonce before using getNonce\");\n return ref.nonce;\n }\n\n function nextNonce(): number {\n if (!hasNonce()) throw new Error(\"call resetNonce before using nextNonce\");\n const nonce = ref.nonce++;\n channel?.postMessage(JSON.stringify(ref.nonce));\n return nonce;\n }\n\n async function resetNonce(): Promise<void> {\n ref.noncePromise ??= (async (): Promise<void> => {\n ref.nonce = await getAction(client, getTransactionCount, \"getTransactionCount\")({ address, blockTag });\n ref.noncePromise = null;\n channel?.postMessage(JSON.stringify(ref.nonce));\n debug(\"reset nonce to\", ref.nonce);\n })();\n await ref.noncePromise;\n }\n\n function shouldResetNonce(error: Error): boolean {\n const nonceError = findCause(error, ({ name }) => name === \"NonceTooLowError\" || name === \"NonceTooHighError\");\n return nonceError != null;\n }\n\n const mempoolQueue = new PQueue({ concurrency: queueConcurrency });\n\n return {\n hasNonce,\n getNonce,\n nextNonce,\n resetNonce,\n shouldResetNonce,\n mempoolQueue,\n };\n}\n","export function findCause(error: Error, fn?: (error: Error) => boolean): Error | null {\n if (fn?.(error)) return error;\n if (error.cause instanceof Error) return findCause(error.cause, fn);\n return fn ? null : error;\n}\n","import { CreateNonceManagerOptions, CreateNonceManagerResult, createNonceManager } from \"./createNonceManager\";\nimport { getNonceManagerId } from \"./getNonceManagerId\";\n\nconst nonceManagers = new Map<string, CreateNonceManagerResult>();\n\nexport async function getNonceManager({\n client,\n address, // TODO: rename to account?\n blockTag = \"latest\",\n ...opts\n}: CreateNonceManagerOptions): Promise<CreateNonceManagerResult> {\n const id = await getNonceManagerId({ client, address, blockTag });\n\n const nonceManager = nonceManagers.get(id) ?? createNonceManager({ client, address, blockTag, ...opts });\n if (!nonceManagers.has(id)) {\n nonceManagers.set(id, nonceManager);\n }\n\n if (!nonceManager.hasNonce()) {\n await nonceManager.resetNonce();\n }\n\n return nonceManager;\n}\n","import { getChainId } from \"viem/actions\";\nimport { CreateFeeRefOptions, FeeRef, createFeeRef } from \"./createFeeRef\";\nimport { getAction } from \"viem/utils\";\n\nconst feeRefs = new Map<number, FeeRef>();\n\nexport async function getFeeRef(opts: CreateFeeRefOptions): Promise<FeeRef> {\n const chainId =\n opts.args?.chain?.id ?? opts.client.chain?.id ?? (await getAction(opts.client, getChainId, \"getChainId\")({}));\n\n const existingFeeRef = feeRefs.get(chainId);\n if (existingFeeRef) {\n return existingFeeRef;\n }\n\n const feeRef = await createFeeRef(opts);\n feeRefs.set(chainId, feeRef);\n return feeRef;\n}\n","import { EstimateFeesPerGasParameters, Client, EstimateFeesPerGasReturnType } from \"viem\";\nimport { estimateFeesPerGas } from \"viem/actions\";\nimport { getAction } from \"viem/utils\";\n\nexport type CreateFeeRefOptions = {\n client: Client;\n refreshInterval: number;\n args?: EstimateFeesPerGasParameters;\n};\n\nexport type FeeRef = {\n fees: EstimateFeesPerGasReturnType | {};\n lastUpdatedTimestamp: number;\n};\n\n/** Update fee values once every `refreshInterval` instead of right before every request */\nexport async function createFeeRef({ client, args, refreshInterval }: CreateFeeRefOptions): Promise<FeeRef> {\n const feeRef: FeeRef = { fees: {}, lastUpdatedTimestamp: 0 };\n\n async function updateFees(): Promise<void> {\n const fees = await getAction(client, estimateFeesPerGas, \"estimateFeesPerGas\")(args);\n feeRef.fees = fees;\n feeRef.lastUpdatedTimestamp = Date.now();\n }\n\n setInterval(updateFees, refreshInterval);\n await updateFees();\n\n return feeRef;\n}\n","import {\n Account,\n Chain,\n Client,\n SendTransactionParameters,\n Transport,\n SendTransactionReturnType,\n SendTransactionRequest,\n} from \"viem\";\nimport { sendTransaction as viem_sendTransaction } from \"viem/actions\";\nimport pRetry from \"p-retry\";\nimport { debug as parentDebug } from \"./debug\";\nimport { getNonceManager } from \"./getNonceManager\";\nimport { parseAccount } from \"viem/accounts\";\nimport { getFeeRef } from \"./getFeeRef\";\nimport { getAction } from \"viem/utils\";\n\nconst debug = parentDebug.extend(\"sendTransaction\");\n\nexport type SendTransactionExtraOptions<chain extends Chain | undefined> = {\n /**\n * `publicClient` can be provided to be used in place of the extended viem client for making public action calls\n * (`getChainId`, `getTransactionCount`, `call`). This helps in cases where the extended\n * viem client is a smart account client, like in [permissionless.js](https://github.com/pimlicolabs/permissionless.js),\n * where the transport is the bundler, not an RPC.\n */\n publicClient?: Client<Transport, chain>;\n /**\n * Adjust the number of concurrent calls to the mempool. This defaults to `1` to ensure transactions are ordered\n * and nonces are handled properly. Any number greater than that is likely to see nonce errors and/or transactions\n * arriving out of order, but this may be an acceptable trade-off for some applications that can safely retry.\n * @default 1\n */\n queueConcurrency?: number;\n};\n\n/** @deprecated Use `walletClient.extend(transactionQueue())` instead. */\nexport async function sendTransaction<\n chain extends Chain | undefined,\n account extends Account | undefined,\n const request extends SendTransactionRequest<chain, chainOverride>,\n chainOverride extends Chain | undefined = undefined,\n>(\n client: Client<Transport, chain, account>,\n request: SendTransactionParameters<chain, account, chainOverride, request>,\n opts: SendTransactionExtraOptions<chain> = {},\n): Promise<SendTransactionReturnType> {\n const rawAccount = request.account ?? client.account;\n if (!rawAccount) {\n // TODO: replace with viem AccountNotFoundError once its exported\n throw new Error(\"No account provided\");\n }\n const account = parseAccount(rawAccount);\n const chain = client.chain;\n\n const nonceManager = await getNonceManager({\n client: opts.publicClient ?? client,\n address: account.address,\n queueConcurrency: opts.queueConcurrency,\n });\n\n const feeRef = await getFeeRef({\n client: opts.publicClient ?? client,\n refreshInterval: 10000,\n args: { chain },\n });\n\n return await nonceManager.mempoolQueue.add(\n () =>\n pRetry(\n async () => {\n const nonce = nonceManager.nextNonce();\n const params = {\n // viem_sendTransaction internally estimates gas, which we want to happen on the pending block\n blockTag: \"pending\",\n ...feeRef.fees,\n ...request,\n nonce,\n } as const satisfies SendTransactionParameters<chain, account, chainOverride, request>;\n debug(\"sending tx to\", request.to, \"with nonce\", nonce);\n return await getAction(client, viem_sendTransaction, \"sendTransaction\")(params as never);\n },\n {\n retries: 3,\n onFailedAttempt: async (error) => {\n // in case this tx failed before hitting the mempool (i.e. gas estimation error), reset nonce so we don't skip past the unused nonce\n debug(\"failed, resetting nonce\");\n await nonceManager.resetNonce();\n // retry nonce errors\n // TODO: upgrade p-retry and move this to shouldRetry\n if (nonceManager.shouldResetNonce(error)) {\n debug(\"got nonce error, retrying\", error.message);\n return;\n }\n\n if (String(error).includes(\"transaction underpriced\")) {\n debug(\"got transaction underpriced error, retrying\", error.message);\n return;\n }\n\n throw error;\n },\n },\n ),\n { throwOnTimeout: true },\n );\n}\n","import type { Transport, Chain, Account, WalletActions, Client } from \"viem\";\nimport { writeContract as mud_writeContract } from \"../writeContract\";\nimport { sendTransaction as mud_sendTransaction } from \"../sendTransaction\";\n\nexport type TransactionQueueOptions<chain extends Chain | undefined> = {\n /**\n * `publicClient` can be provided to be used in place of the extended viem client for making public action calls\n * (`getChainId`, `getTransactionCount`, `simulateContract`, `call`). This helps in cases where the extended\n * viem client is a smart account client, like in [permissionless.js](https://github.com/pimlicolabs/permissionless.js),\n * where the transport is the bundler, not an RPC.\n */\n publicClient?: Client<Transport, chain>;\n /**\n * Adjust the number of concurrent calls to the mempool. This defaults to `1` to ensure transactions are ordered\n * and nonces are handled properly. Any number greater than that is likely to see nonce errors and/or transactions\n * arriving out of order, but this may be an acceptable trade-off for some applications that can safely retry.\n * @default 1\n */\n queueConcurrency?: number;\n};\n\nexport function transactionQueue<chain extends Chain | undefined>(\n opts: TransactionQueueOptions<chain> = {},\n): <transport extends Transport, account extends Account | undefined = Account | undefined>(\n client: Client<transport, chain, account>,\n) => Pick<WalletActions<chain, account>, \"writeContract\" | \"sendTransaction\"> {\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: (args) => mud_writeContract(client, args, opts),\n // Applies to: `client.sendTransaction`\n sendTransaction: (args) => mud_sendTransaction(client, args, opts),\n });\n}\n","import type {\n WriteContractParameters,\n Transport,\n Chain,\n Account,\n WalletActions,\n WriteContractReturnType,\n Client,\n} from \"viem\";\nimport { getAction } from \"viem/utils\";\nimport { writeContract } from \"viem/actions\";\nimport { type ContractWrite } from \"../getContract\";\n\ntype WriteObserverParameters = { onWrite: (write: ContractWrite) => void };\n\nexport function writeObserver<TChain extends Chain, TAccount extends Account>({\n onWrite,\n}: WriteObserverParameters): (\n client: Client<Transport, TChain, TAccount>,\n) => Pick<WalletActions<TChain, TAccount>, \"writeContract\"> {\n let nextWriteId = 0;\n\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: (args): Promise<WriteContractReturnType> => {\n const result = getAction(client, writeContract, \"writeContract\")(args);\n\n const id = `${client.chain.id}:${client.account.address}:${nextWriteId++}`;\n onWrite({ id, request: args as WriteContractParameters, result });\n\n return result;\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWA,IAAAA,kBAAoD;AACpD,qBAAmB;;;ACZnB,mBAAwB;AAEjB,IAAM,YAAQ,aAAAC,SAAY,YAAY;AACtC,IAAM,YAAQ,aAAAA,SAAY,YAAY;AAG7C,MAAM,MAAM,QAAQ,MAAM,KAAK,OAAO;AAGtC,MAAM,MAAM,QAAQ,MAAM,KAAK,OAAO;;;ACTtC,kBAAkD;AAClD,qBAA2B;AAC3B,mBAA0B;AAE1B,eAAsB,kBAAkB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACF,GAIoB;AAElB,QAAM,UAAU,OAAO,OAAO,MAAO,UAAM,wBAAU,QAAQ,2BAAY,YAAY,EAAE,CAAC,CAAC;AACzF,SAAO,0BAA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;AACzD,YAAM,aAAS,yBAAU,QAAQ,+BAAe,eAAe,EAAE,IAAI;AAErE,YAAM,KAAK,GAAG,OAAO,MAAM,EAAE,IAAI,OAAO,QAAQ,OAAO,IAAI,aAAa;AACxE,cAAQ,EAAE,IAAI,SAAS,MAAiC,OAAO,CAAC;AAEhE,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["import_actions","createDebug","import_actions","import_utils","error","debug","error","PQueue","import_actions","import_actions","import_utils","import_utils","import_utils","debug","pRetry","viem_writeContract","error","import_actions","import_p_retry","import_accounts","import_utils","debug","pRetry","viem_sendTransaction","error","import_utils","import_actions"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Chain, Client, Transport, Account, WalletActions } from 'viem';
|
|
2
|
+
import { C as ContractWrite } from './getContract-CA0EdVg6.cjs';
|
|
3
|
+
|
|
4
|
+
type TransactionQueueOptions<chain extends Chain | undefined> = {
|
|
5
|
+
/**
|
|
6
|
+
* `publicClient` can be provided to be used in place of the extended viem client for making public action calls
|
|
7
|
+
* (`getChainId`, `getTransactionCount`, `simulateContract`, `call`). This helps in cases where the extended
|
|
8
|
+
* viem client is a smart account client, like in [permissionless.js](https://github.com/pimlicolabs/permissionless.js),
|
|
9
|
+
* where the transport is the bundler, not an RPC.
|
|
10
|
+
*/
|
|
11
|
+
publicClient?: Client<Transport, chain>;
|
|
12
|
+
/**
|
|
13
|
+
* Adjust the number of concurrent calls to the mempool. This defaults to `1` to ensure transactions are ordered
|
|
14
|
+
* and nonces are handled properly. Any number greater than that is likely to see nonce errors and/or transactions
|
|
15
|
+
* arriving out of order, but this may be an acceptable trade-off for some applications that can safely retry.
|
|
16
|
+
* @default 1
|
|
17
|
+
*/
|
|
18
|
+
queueConcurrency?: number;
|
|
19
|
+
};
|
|
20
|
+
declare function transactionQueue<chain extends Chain | undefined>(opts?: TransactionQueueOptions<chain>): <transport extends Transport, account extends Account | undefined = Account | undefined>(client: Client<transport, chain, account>) => Pick<WalletActions<chain, account>, "writeContract" | "sendTransaction">;
|
|
21
|
+
|
|
22
|
+
type WriteObserverParameters = {
|
|
23
|
+
onWrite: (write: ContractWrite) => void;
|
|
24
|
+
};
|
|
25
|
+
declare function writeObserver<TChain extends Chain, TAccount extends Account>({ onWrite, }: WriteObserverParameters): (client: Client<Transport, TChain, TAccount>) => Pick<WalletActions<TChain, TAccount>, "writeContract">;
|
|
26
|
+
|
|
27
|
+
export { type TransactionQueueOptions, transactionQueue, writeObserver };
|
package/dist/actions.js
CHANGED
|
@@ -1,2 +1,40 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
writeContract
|
|
3
|
+
} from "./chunk-Z6SVAIZN.js";
|
|
4
|
+
import {
|
|
5
|
+
sendTransaction
|
|
6
|
+
} from "./chunk-MYWRXQQH.js";
|
|
7
|
+
import "./chunk-MK6UECU7.js";
|
|
8
|
+
|
|
9
|
+
// src/actions/transactionQueue.ts
|
|
10
|
+
function transactionQueue(opts = {}) {
|
|
11
|
+
return (client) => ({
|
|
12
|
+
// Applies to: `client.writeContract`, `getContract(client, ...).write`
|
|
13
|
+
writeContract: (args) => writeContract(client, args, opts),
|
|
14
|
+
// Applies to: `client.sendTransaction`
|
|
15
|
+
sendTransaction: (args) => sendTransaction(client, args, opts)
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/actions/writeObserver.ts
|
|
20
|
+
import { getAction } from "viem/utils";
|
|
21
|
+
import { writeContract as writeContract2 } from "viem/actions";
|
|
22
|
+
function writeObserver({
|
|
23
|
+
onWrite
|
|
24
|
+
}) {
|
|
25
|
+
let nextWriteId = 0;
|
|
26
|
+
return (client) => ({
|
|
27
|
+
// Applies to: `client.writeContract`, `getContract(client, ...).write`
|
|
28
|
+
writeContract: (args) => {
|
|
29
|
+
const result = getAction(client, writeContract2, "writeContract")(args);
|
|
30
|
+
const id = `${client.chain.id}:${client.account.address}:${nextWriteId++}`;
|
|
31
|
+
onWrite({ id, request: args, result });
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
transactionQueue,
|
|
38
|
+
writeObserver
|
|
39
|
+
};
|
|
2
40
|
//# sourceMappingURL=actions.js.map
|
package/dist/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/actions/transactionQueue.ts","../src/actions/writeObserver.ts"],"sourcesContent":["import type { Transport, Chain, Account, WalletActions, Client } from \"viem\";\nimport { writeContract as mud_writeContract } from \"../writeContract\";\nimport { sendTransaction as mud_sendTransaction } from \"../sendTransaction\";\n\nexport type TransactionQueueOptions<chain extends Chain | undefined> = {\n /**\n * `publicClient` can be provided to be used in place of the extended viem client for making public action calls\n * (`getChainId`, `getTransactionCount`, `simulateContract`, `call`). This helps in cases where the extended\n * viem client is a smart account client, like in [permissionless.js](https://github.com/pimlicolabs/permissionless.js),\n * where the transport is the bundler, not an RPC.\n */\n publicClient?: Client<Transport, chain>;\n /**\n * Adjust the number of concurrent calls to the mempool. This defaults to `1` to ensure transactions are ordered\n * and nonces are handled properly. Any number greater than that is likely to see nonce errors and/or transactions\n * arriving out of order, but this may be an acceptable trade-off for some applications that can safely retry.\n * @default 1\n */\n queueConcurrency?: number;\n};\n\nexport function transactionQueue<chain extends Chain | undefined>(\n opts: TransactionQueueOptions<chain> = {},\n): <transport extends Transport, account extends Account | undefined = Account | undefined>(\n client: Client<transport, chain, account>,\n) => Pick<WalletActions<chain, account>, \"writeContract\" | \"sendTransaction\"> {\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: (args) => mud_writeContract(client, args, opts),\n // Applies to: `client.sendTransaction`\n sendTransaction: (args) => mud_sendTransaction(client, args, opts),\n });\n}\n","import type {\n WriteContractParameters,\n Transport,\n Chain,\n Account,\n WalletActions,\n WriteContractReturnType,\n Client,\n} from \"viem\";\nimport { getAction } from \"viem/utils\";\nimport { writeContract } from \"viem/actions\";\nimport { type ContractWrite } from \"../getContract\";\n\ntype WriteObserverParameters = { onWrite: (write: ContractWrite) => void };\n\nexport function writeObserver<TChain extends Chain, TAccount extends Account>({\n onWrite,\n}: WriteObserverParameters): (\n client: Client<Transport, TChain, TAccount>,\n) => Pick<WalletActions<TChain, TAccount>, \"writeContract\"> {\n let nextWriteId = 0;\n\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: (args): Promise<WriteContractReturnType> => {\n const result = getAction(client, writeContract, \"writeContract\")(args);\n\n const id = `${client.chain.id}:${client.account.address}:${nextWriteId++}`;\n onWrite({ id, request: args as WriteContractParameters, result });\n\n return result;\n },\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/actions/transactionQueue.ts","../src/actions/writeObserver.ts"],"sourcesContent":["import type { Transport, Chain, Account, WalletActions, Client } from \"viem\";\nimport { writeContract as mud_writeContract } from \"../writeContract\";\nimport { sendTransaction as mud_sendTransaction } from \"../sendTransaction\";\n\nexport type TransactionQueueOptions<chain extends Chain | undefined> = {\n /**\n * `publicClient` can be provided to be used in place of the extended viem client for making public action calls\n * (`getChainId`, `getTransactionCount`, `simulateContract`, `call`). This helps in cases where the extended\n * viem client is a smart account client, like in [permissionless.js](https://github.com/pimlicolabs/permissionless.js),\n * where the transport is the bundler, not an RPC.\n */\n publicClient?: Client<Transport, chain>;\n /**\n * Adjust the number of concurrent calls to the mempool. This defaults to `1` to ensure transactions are ordered\n * and nonces are handled properly. Any number greater than that is likely to see nonce errors and/or transactions\n * arriving out of order, but this may be an acceptable trade-off for some applications that can safely retry.\n * @default 1\n */\n queueConcurrency?: number;\n};\n\nexport function transactionQueue<chain extends Chain | undefined>(\n opts: TransactionQueueOptions<chain> = {},\n): <transport extends Transport, account extends Account | undefined = Account | undefined>(\n client: Client<transport, chain, account>,\n) => Pick<WalletActions<chain, account>, \"writeContract\" | \"sendTransaction\"> {\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: (args) => mud_writeContract(client, args, opts),\n // Applies to: `client.sendTransaction`\n sendTransaction: (args) => mud_sendTransaction(client, args, opts),\n });\n}\n","import type {\n WriteContractParameters,\n Transport,\n Chain,\n Account,\n WalletActions,\n WriteContractReturnType,\n Client,\n} from \"viem\";\nimport { getAction } from \"viem/utils\";\nimport { writeContract } from \"viem/actions\";\nimport { type ContractWrite } from \"../getContract\";\n\ntype WriteObserverParameters = { onWrite: (write: ContractWrite) => void };\n\nexport function writeObserver<TChain extends Chain, TAccount extends Account>({\n onWrite,\n}: WriteObserverParameters): (\n client: Client<Transport, TChain, TAccount>,\n) => Pick<WalletActions<TChain, TAccount>, \"writeContract\"> {\n let nextWriteId = 0;\n\n return (client) => ({\n // Applies to: `client.writeContract`, `getContract(client, ...).write`\n writeContract: (args): Promise<WriteContractReturnType> => {\n const result = getAction(client, writeContract, \"writeContract\")(args);\n\n const id = `${client.chain.id}:${client.account.address}:${nextWriteId++}`;\n onWrite({ id, request: args as WriteContractParameters, result });\n\n return result;\n },\n });\n}\n"],"mappings":";;;;;;;;;AAqBO,SAAS,iBACd,OAAuC,CAAC,GAGoC;AAC5E,SAAO,CAAC,YAAY;AAAA;AAAA,IAElB,eAAe,CAAC,SAAS,cAAkB,QAAQ,MAAM,IAAI;AAAA;AAAA,IAE7D,iBAAiB,CAAC,SAAS,gBAAoB,QAAQ,MAAM,IAAI;AAAA,EACnE;AACF;;;ACvBA,SAAS,iBAAiB;AAC1B,SAAS,iBAAAA,sBAAqB;AAKvB,SAAS,cAA8D;AAAA,EAC5E;AACF,GAE4D;AAC1D,MAAI,cAAc;AAElB,SAAO,CAAC,YAAY;AAAA;AAAA,IAElB,eAAe,CAAC,SAA2C;AACzD,YAAM,SAAS,UAAU,QAAQA,gBAAe,eAAe,EAAE,IAAI;AAErE,YAAM,KAAK,GAAG,OAAO,MAAM,EAAE,IAAI,OAAO,QAAQ,OAAO,IAAI,aAAa;AACxE,cAAQ,EAAE,IAAI,SAAS,MAAiC,OAAO,CAAC;AAEhE,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["writeContract"]}
|
package/dist/chains.cjs
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/chains/index.ts
|
|
21
|
+
var chains_exports = {};
|
|
22
|
+
__export(chains_exports, {
|
|
23
|
+
garnet: () => garnet,
|
|
24
|
+
mudFoundry: () => mudFoundry,
|
|
25
|
+
redstone: () => redstone,
|
|
26
|
+
rhodolite: () => rhodolite
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(chains_exports);
|
|
29
|
+
|
|
30
|
+
// src/chains/mudFoundry.ts
|
|
31
|
+
var import_chains = require("viem/chains");
|
|
32
|
+
var mudFoundry = {
|
|
33
|
+
...import_chains.foundry,
|
|
34
|
+
fees: {
|
|
35
|
+
defaultPriorityFee: 0n
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/chains/redstone.ts
|
|
40
|
+
var import_chains2 = require("viem/chains");
|
|
41
|
+
var redstone = {
|
|
42
|
+
...import_chains2.redstone,
|
|
43
|
+
iconUrls: ["https://redstone.xyz/chain-icons/redstone.png"],
|
|
44
|
+
indexerUrl: "https://indexer.mud.redstonechain.com"
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/chains/garnet.ts
|
|
48
|
+
var import_chains3 = require("viem/chains");
|
|
49
|
+
var garnet = {
|
|
50
|
+
...import_chains3.garnet,
|
|
51
|
+
iconUrls: ["https://redstone.xyz/chain-icons/garnet.png"],
|
|
52
|
+
indexerUrl: "https://indexer.mud.garnetchain.com"
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/chains/rhodolite.ts
|
|
56
|
+
var import_op_stack = require("viem/op-stack");
|
|
57
|
+
var sourceId = 17e3;
|
|
58
|
+
var defaultRpcUrls = {
|
|
59
|
+
http: ["https://rpc.rhodolitechain.com"],
|
|
60
|
+
webSocket: ["wss://rpc.rhodolitechain.com"]
|
|
61
|
+
};
|
|
62
|
+
var rhodolite = {
|
|
63
|
+
...import_op_stack.chainConfig,
|
|
64
|
+
name: "Rhodolite Devnet",
|
|
65
|
+
testnet: true,
|
|
66
|
+
id: 17420,
|
|
67
|
+
sourceId,
|
|
68
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
69
|
+
rpcUrls: {
|
|
70
|
+
default: defaultRpcUrls,
|
|
71
|
+
bundler: defaultRpcUrls,
|
|
72
|
+
quarryPassIssuer: defaultRpcUrls,
|
|
73
|
+
wiresaw: defaultRpcUrls
|
|
74
|
+
},
|
|
75
|
+
contracts: {
|
|
76
|
+
...import_op_stack.chainConfig.contracts,
|
|
77
|
+
l1StandardBridge: {
|
|
78
|
+
[sourceId]: {
|
|
79
|
+
address: "0x6487446e0B9FAEa90F6a9772A6448cFa780E30F9"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
quarryPaymaster: {
|
|
83
|
+
address: "0x7ca1b85aca23fccf2fbac14c02b5e8a6432639b9"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
blockExplorers: {
|
|
87
|
+
default: {
|
|
88
|
+
name: "Blockscout",
|
|
89
|
+
url: "https://explorer.rhodolitechain.com"
|
|
90
|
+
},
|
|
91
|
+
worldsExplorer: {
|
|
92
|
+
name: "MUD Worlds Explorer",
|
|
93
|
+
url: "https://explorer.mud.dev/rhodolite/worlds"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
iconUrls: ["https://redstone.xyz/chain-icons/rhodolite.png"],
|
|
97
|
+
indexerUrl: "https://indexer.mud.rhodolitechain.com"
|
|
98
|
+
};
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
garnet,
|
|
102
|
+
mudFoundry,
|
|
103
|
+
redstone,
|
|
104
|
+
rhodolite
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=chains.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/chains/index.ts","../src/chains/mudFoundry.ts","../src/chains/redstone.ts","../src/chains/garnet.ts","../src/chains/rhodolite.ts"],"sourcesContent":["export type { MUDChain } from \"./types\";\nexport { mudFoundry } from \"./mudFoundry\";\nexport { redstone } from \"./redstone\";\nexport { garnet } from \"./garnet\";\nexport { rhodolite } from \"./rhodolite\";\n","import { foundry } from \"viem/chains\";\nimport { MUDChain } from \"./types\";\n\nexport const mudFoundry = {\n ...foundry,\n fees: {\n defaultPriorityFee: 0n,\n },\n} as const satisfies MUDChain;\n","import { redstone as redstoneConfig } from \"viem/chains\";\nimport type { MUDChain } from \"./types\";\n\nexport const redstone = {\n ...redstoneConfig,\n iconUrls: [\"https://redstone.xyz/chain-icons/redstone.png\"],\n indexerUrl: \"https://indexer.mud.redstonechain.com\",\n} as const satisfies MUDChain;\n","import { garnet as garnetConfig } from \"viem/chains\";\nimport type { MUDChain } from \"./types\";\n\nexport const garnet = {\n ...garnetConfig,\n iconUrls: [\"https://redstone.xyz/chain-icons/garnet.png\"],\n indexerUrl: \"https://indexer.mud.garnetchain.com\",\n} as const satisfies MUDChain;\n","import { chainConfig } from \"viem/op-stack\";\nimport { MUDChain } from \"./types\";\nimport { Chain } from \"viem\";\n\nconst sourceId = 17000;\n\nconst defaultRpcUrls = {\n http: [\"https://rpc.rhodolitechain.com\"],\n webSocket: [\"wss://rpc.rhodolitechain.com\"],\n} as const satisfies Chain[\"rpcUrls\"][\"default\"];\n\nexport const rhodolite = {\n ...chainConfig,\n name: \"Rhodolite Devnet\",\n testnet: true,\n id: 17420,\n sourceId,\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: defaultRpcUrls,\n bundler: defaultRpcUrls,\n quarryPassIssuer: defaultRpcUrls,\n wiresaw: defaultRpcUrls,\n },\n contracts: {\n ...chainConfig.contracts,\n l1StandardBridge: {\n [sourceId]: {\n address: \"0x6487446e0B9FAEa90F6a9772A6448cFa780E30F9\",\n },\n },\n quarryPaymaster: {\n address: \"0x7ca1b85aca23fccf2fbac14c02b5e8a6432639b9\",\n },\n },\n blockExplorers: {\n default: {\n name: \"Blockscout\",\n url: \"https://explorer.rhodolitechain.com\",\n },\n worldsExplorer: {\n name: \"MUD Worlds Explorer\",\n url: \"https://explorer.mud.dev/rhodolite/worlds\",\n },\n },\n iconUrls: [\"https://redstone.xyz/chain-icons/rhodolite.png\"],\n indexerUrl: \"https://indexer.mud.rhodolitechain.com\",\n} as const satisfies MUDChain;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAwB;AAGjB,IAAM,aAAa;AAAA,EACxB,GAAG;AAAA,EACH,MAAM;AAAA,IACJ,oBAAoB;AAAA,EACtB;AACF;;;ACRA,IAAAA,iBAA2C;AAGpC,IAAM,WAAW;AAAA,EACtB,GAAG,eAAAC;AAAA,EACH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