@team-oozoo/oozoo-pay 0.2.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.

Potentially problematic release.


This version of @team-oozoo/oozoo-pay might be problematic. Click here for more details.

package/dist/index.js ADDED
@@ -0,0 +1,1553 @@
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/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ ApiError: () => ApiError,
24
+ ConfigError: () => ConfigError,
25
+ ETH: () => ETH,
26
+ ETHEREUM_MAINNET_ID: () => ETHEREUM_MAINNET_ID,
27
+ MAINNET_CHAIN_IDS: () => MAINNET_CHAIN_IDS,
28
+ OozooPayClient: () => OozooPayClient,
29
+ OozooPayError: () => OozooPayError,
30
+ PAYMENT_ROUTER: () => PAYMENT_ROUTER,
31
+ PaymentRouterAbi: () => PaymentRouterAbi,
32
+ TESTNET_CHAIN_IDS: () => TESTNET_CHAIN_IDS,
33
+ USDC_ADDRESSES: () => USDC_ADDRESSES,
34
+ USDT_ADDRESSES: () => USDT_ADDRESSES,
35
+ encodePaymentTransaction: () => encodePaymentTransaction,
36
+ estimateGasCost: () => estimateGasCost2,
37
+ getNativeBalance: () => getNativeBalance2,
38
+ getTokenBalance: () => getTokenBalance2,
39
+ isMainnetUSDT: () => isMainnetUSDT,
40
+ isNativeCoin: () => isNativeCoin,
41
+ loadOozooPay: () => loadOozooPay,
42
+ mainnetUSDTAbi: () => mainnetUSDTAbi
43
+ });
44
+ module.exports = __toCommonJS(src_exports);
45
+
46
+ // src/errors.ts
47
+ var OozooPayError = class extends Error {
48
+ constructor(message) {
49
+ super(message);
50
+ this.name = "OozooPayError";
51
+ }
52
+ };
53
+ var ApiError = class extends OozooPayError {
54
+ constructor(statusCode, code, message) {
55
+ super(message);
56
+ this.name = "ApiError";
57
+ this.statusCode = statusCode;
58
+ this.code = code;
59
+ }
60
+ };
61
+ var ConfigError = class extends OozooPayError {
62
+ constructor(message) {
63
+ super(message);
64
+ this.name = "ConfigError";
65
+ }
66
+ };
67
+
68
+ // src/constants.ts
69
+ var CHECKOUT_URL = {
70
+ DEV: "https://web-checkout.dev.oozoopay.com",
71
+ PROD: "https://checkout.oozoopay.com"
72
+ };
73
+ function resolveCheckoutUrl(clientKey) {
74
+ if (clientKey.startsWith("pk_dev_")) return CHECKOUT_URL.DEV;
75
+ return CHECKOUT_URL.PROD;
76
+ }
77
+
78
+ // src/window.ts
79
+ var WINDOW_ID = "oozoopay-window";
80
+ var SNACKBAR_ID = "oozoopay-snackbar";
81
+ var backdropBaseStyles = `
82
+ position: fixed;
83
+ inset: 0;
84
+ z-index: 99999;
85
+ display: flex;
86
+ align-items: center;
87
+ justify-content: center;
88
+ `;
89
+ var desktopBackdropStyles = `
90
+ ${backdropBaseStyles}
91
+ background-color: rgba(0, 0, 0, 0.5);
92
+ `;
93
+ var mobileBackdropStyles = `
94
+ ${backdropBaseStyles}
95
+ background-color: rgba(0, 0, 0, 0.3);
96
+ backdrop-filter: blur(8px);
97
+ -webkit-backdrop-filter: blur(8px);
98
+ `;
99
+ var desktopStyles = `
100
+ border: none;
101
+ width: 420px;
102
+ height: 650px;
103
+ max-height: 90vh;
104
+ background: transparent;
105
+ `;
106
+ var mobileStyles = `
107
+ border: 1px solid rgba(255, 255, 255, 0.12);
108
+ border-radius: 20px;
109
+ overflow: hidden;
110
+ width: 80%;
111
+ max-height: 85vh;
112
+ background: transparent;
113
+ box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
114
+ `;
115
+ function isMobile() {
116
+ return typeof window !== "undefined" && window.innerWidth < 640;
117
+ }
118
+ function openWindow(url) {
119
+ closeWindow();
120
+ const mobile = isMobile();
121
+ const backdrop = document.createElement("div");
122
+ backdrop.id = WINDOW_ID;
123
+ backdrop.style.cssText = mobile ? mobileBackdropStyles : desktopBackdropStyles;
124
+ const iframeUrl = new URL(url);
125
+ if (mobile) iframeUrl.searchParams.set("mobile", "1");
126
+ const iframe = document.createElement("iframe");
127
+ iframe.src = iframeUrl.toString();
128
+ iframe.style.cssText = mobile ? mobileStyles : desktopStyles;
129
+ iframe.allow = "clipboard-write; payment; web-share";
130
+ iframe.setAttribute("allowtransparency", "true");
131
+ iframe.setAttribute("scrolling", "no");
132
+ backdrop.appendChild(iframe);
133
+ document.body.appendChild(backdrop);
134
+ document.body.style.overflow = "hidden";
135
+ return { backdrop, iframe };
136
+ }
137
+ function closeWindow() {
138
+ const existing = document.getElementById(WINDOW_ID);
139
+ if (existing) {
140
+ existing.remove();
141
+ }
142
+ document.body.style.overflow = "";
143
+ }
144
+ function postMessage(oozooWindow, message) {
145
+ oozooWindow.iframe.contentWindow?.postMessage(message, "*");
146
+ }
147
+ var VARIANT_CONFIG = {
148
+ success: { color: "#0FAA36", icon: "\u2713" },
149
+ error: { color: "#7A80E9", icon: "\u26A0" },
150
+ info: { color: "#7A80E9", icon: "\u26A0" }
151
+ };
152
+ var snackbarTimer = null;
153
+ var currentOozooWindow = null;
154
+ function setCurrentWindow(oozooWindow) {
155
+ currentOozooWindow = oozooWindow;
156
+ }
157
+ function showSnackbar(message, variant, action) {
158
+ dismissSnackbar();
159
+ const backdrop = document.getElementById(WINDOW_ID);
160
+ if (!backdrop) return;
161
+ const iframe = backdrop.querySelector("iframe");
162
+ if (!iframe) return;
163
+ const { color, icon } = VARIANT_CONFIG[variant];
164
+ const mobile = isMobile();
165
+ const snackbar = document.createElement("div");
166
+ snackbar.id = SNACKBAR_ID;
167
+ snackbar.style.cssText = `
168
+ position: absolute;
169
+ left: 50%;
170
+ transform: translateX(-50%);
171
+ z-index: 100000;
172
+ display: flex;
173
+ align-items: center;
174
+ gap: 8px;
175
+ padding: 8px 16px;
176
+ border-radius: 8px;
177
+ background-color: #3D3D3D;
178
+ border: 1px solid ${color};
179
+ color: ${color};
180
+ font-size: 13px;
181
+ font-weight: 500;
182
+ font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
183
+ pointer-events: auto;
184
+ opacity: 0;
185
+ transition: opacity 0.2s ease;
186
+ width: ${mobile ? "80%" : "420px"};
187
+ box-sizing: border-box;
188
+ `;
189
+ const iconEl = document.createElement("span");
190
+ iconEl.textContent = icon;
191
+ iconEl.style.cssText = "flex-shrink: 0; text-align: center;";
192
+ snackbar.appendChild(iconEl);
193
+ const content = document.createElement("div");
194
+ content.style.cssText = "flex: 1; min-width: 0;";
195
+ const messageEl = document.createElement("div");
196
+ messageEl.textContent = message;
197
+ messageEl.style.cssText = "line-height: 1.4; word-wrap: break-word;";
198
+ content.appendChild(messageEl);
199
+ if (action) {
200
+ const actionEl = document.createElement("div");
201
+ actionEl.textContent = action.label;
202
+ actionEl.style.cssText = `
203
+ cursor: pointer;
204
+ text-decoration: underline;
205
+ margin-top: 4px;
206
+ font-weight: 500;
207
+ `;
208
+ actionEl.addEventListener("click", () => {
209
+ dismissSnackbar();
210
+ if (currentOozooWindow) {
211
+ postMessage(currentOozooWindow, { type: "OOZOO_SNACKBAR_ACTION", id: action.id });
212
+ }
213
+ });
214
+ content.appendChild(actionEl);
215
+ }
216
+ snackbar.appendChild(content);
217
+ const iframeRect = iframe.getBoundingClientRect();
218
+ snackbar.style.top = `${iframeRect.bottom + 12}px`;
219
+ backdrop.appendChild(snackbar);
220
+ requestAnimationFrame(() => {
221
+ snackbar.style.opacity = "1";
222
+ });
223
+ snackbarTimer = setTimeout(
224
+ () => {
225
+ dismissSnackbar();
226
+ },
227
+ action ? 8e3 : 4e3
228
+ );
229
+ }
230
+ function dismissSnackbar() {
231
+ if (snackbarTimer) {
232
+ clearTimeout(snackbarTimer);
233
+ snackbarTimer = null;
234
+ }
235
+ const existing = document.getElementById(SNACKBAR_ID);
236
+ if (existing) {
237
+ existing.remove();
238
+ }
239
+ }
240
+ var OOZOO_MESSAGE_TYPES = /* @__PURE__ */ new Set([
241
+ "OOZOO_READY",
242
+ "OOZOO_CREATE_INVOICE",
243
+ "OOZOO_CREATE_INVOICE_RESULT",
244
+ "OOZOO_SUCCESS",
245
+ "OOZOO_CANCEL",
246
+ "OOZOO_ERROR",
247
+ "OOZOO_RESIZE",
248
+ "OOZOO_SNACKBAR",
249
+ "OOZOO_SNACKBAR_ACTION"
250
+ ]);
251
+ function isOozooMessage(data) {
252
+ return typeof data === "object" && data !== null && "type" in data && OOZOO_MESSAGE_TYPES.has(data.type);
253
+ }
254
+ function listenMessages(handlers) {
255
+ const listener = (event) => {
256
+ if (!isOozooMessage(event.data)) return;
257
+ const handler = handlers[event.data.type];
258
+ if (handler) handler(event.data);
259
+ };
260
+ window.addEventListener("message", listener);
261
+ return () => window.removeEventListener("message", listener);
262
+ }
263
+
264
+ // src/client.ts
265
+ var SUPPORTED_UNITS = ["usd"];
266
+ var OozooPayClient = class {
267
+ constructor(clientKey) {
268
+ if (!clientKey) {
269
+ throw new ConfigError("clientKey is required");
270
+ }
271
+ this.clientKey = clientKey;
272
+ this.checkoutUrl = resolveCheckoutUrl(clientKey);
273
+ }
274
+ /**
275
+ * Open checkout window to collect payment from user.
276
+ */
277
+ async pay(options) {
278
+ this.validateOptions(options);
279
+ const unit = options.unit ?? "usd";
280
+ const url = new URL("/pay", this.checkoutUrl);
281
+ url.searchParams.set("clientKey", this.clientKey);
282
+ url.searchParams.set("price", options.price.toString());
283
+ url.searchParams.set("unit", unit);
284
+ return this.openFlow(url.toString(), options, "sender");
285
+ }
286
+ /**
287
+ * Open checkout window to send payout to user.
288
+ */
289
+ async transfer(options) {
290
+ this.validateOptions(options);
291
+ const unit = options.unit ?? "usd";
292
+ const url = new URL("/transfer", this.checkoutUrl);
293
+ url.searchParams.set("clientKey", this.clientKey);
294
+ url.searchParams.set("price", options.price.toString());
295
+ url.searchParams.set("unit", unit);
296
+ return this.openFlow(url.toString(), options, "receiver");
297
+ }
298
+ openFlow(url, options, addressField) {
299
+ return new Promise((resolve) => {
300
+ const oozooWindow = openWindow(url);
301
+ setCurrentWindow(oozooWindow);
302
+ oozooWindow.backdrop.addEventListener("click", (e) => {
303
+ if (e.target === oozooWindow.backdrop) {
304
+ close();
305
+ this.handleCancel(options);
306
+ resolve();
307
+ }
308
+ });
309
+ const handleKeyDown = (e) => {
310
+ if (e.key === "Escape") {
311
+ close();
312
+ this.handleCancel(options);
313
+ resolve();
314
+ }
315
+ };
316
+ document.addEventListener("keydown", handleKeyDown);
317
+ const close = () => {
318
+ cleanup();
319
+ document.removeEventListener("keydown", handleKeyDown);
320
+ setCurrentWindow(null);
321
+ closeWindow();
322
+ };
323
+ const cleanup = listenMessages({
324
+ OOZOO_CREATE_INVOICE: async (msg) => {
325
+ try {
326
+ const base = {
327
+ price: msg.params.price,
328
+ unit: msg.params.unit,
329
+ chainId: msg.params.chainId,
330
+ tokenAddress: msg.params.tokenAddress
331
+ };
332
+ const invoiceId = addressField === "sender" ? await options.onCreateInvoice({ ...base, sender: msg.params.sender ?? "" }) : await options.onCreateInvoice({ ...base, receiver: msg.params.receiver ?? "" });
333
+ postMessage(oozooWindow, {
334
+ type: "OOZOO_CREATE_INVOICE_RESULT",
335
+ requestId: msg.requestId,
336
+ invoiceId
337
+ });
338
+ } catch (err) {
339
+ postMessage(oozooWindow, {
340
+ type: "OOZOO_CREATE_INVOICE_RESULT",
341
+ requestId: msg.requestId,
342
+ error: err instanceof Error ? err.message : "Invoice creation failed"
343
+ });
344
+ }
345
+ },
346
+ OOZOO_RESIZE: (msg) => {
347
+ oozooWindow.iframe.style.height = `${msg.height}px`;
348
+ },
349
+ OOZOO_SNACKBAR: (msg) => {
350
+ showSnackbar(msg.message, msg.variant, msg.action);
351
+ },
352
+ OOZOO_SUCCESS: (msg) => {
353
+ close();
354
+ this.handleSuccess(options, msg.invoiceId);
355
+ resolve();
356
+ },
357
+ OOZOO_ERROR: (msg) => {
358
+ close();
359
+ this.handleError(options, msg.code, msg.message);
360
+ resolve();
361
+ },
362
+ OOZOO_CANCEL: () => {
363
+ close();
364
+ this.handleCancel(options);
365
+ resolve();
366
+ }
367
+ });
368
+ });
369
+ }
370
+ validateOptions(options) {
371
+ if (!options.price || options.price <= 0) throw new ConfigError("price is required");
372
+ if (!options.onCreateInvoice) throw new ConfigError("onCreateInvoice is required");
373
+ if (!options.successUrl) throw new ConfigError("successUrl is required");
374
+ if (!options.failUrl) throw new ConfigError("failUrl is required");
375
+ const unit = options.unit ?? "usd";
376
+ if (!SUPPORTED_UNITS.includes(unit)) throw new ConfigError(`unsupported unit: ${unit}`);
377
+ }
378
+ handleSuccess(options, invoiceId) {
379
+ const url = new URL(resolveUrl(options.successUrl));
380
+ url.searchParams.set("invoiceId", invoiceId);
381
+ window.location.href = url.toString();
382
+ }
383
+ handleError(options, code, message) {
384
+ const url = new URL(resolveUrl(options.failUrl));
385
+ url.searchParams.set("code", code);
386
+ url.searchParams.set("message", message);
387
+ window.location.href = url.toString();
388
+ }
389
+ handleCancel(options) {
390
+ const url = new URL(resolveUrl(options.failUrl));
391
+ url.searchParams.set("code", "CANCELLED");
392
+ window.location.href = url.toString();
393
+ }
394
+ // Deprecated method aliases
395
+ /** @deprecated Use pay() instead */
396
+ async requestPayment(options) {
397
+ return this.pay(options);
398
+ }
399
+ /** @deprecated Use transfer() instead */
400
+ async requestWithdrawal(options) {
401
+ return this.transfer(options);
402
+ }
403
+ };
404
+ function resolveUrl(path) {
405
+ return new URL(path, window.location.origin).toString();
406
+ }
407
+ async function loadOozooPay(clientKey) {
408
+ return new OozooPayClient(clientKey);
409
+ }
410
+
411
+ // src/chain/evm/constants/addresses.ts
412
+ var ETH = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
413
+ var USDT_ADDRESSES = {
414
+ /** sepolia (USDT deployed by aave) */
415
+ 11155111: "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0",
416
+ /** arbitrum sepolia (bridged sepolia USDT) */
417
+ 421614: "0x6a41aBbDc90A273c72364fB20A65E37F72Fad7EB",
418
+ /** bsc testnet (binance-peg USDT) */
419
+ 97: "0x337610d27c682E347C9cD60BD4b3b107C9d34dDd",
420
+ /** mainnet (native USDT) */
421
+ 1: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
422
+ /** arbitrum (bridged mainnet USDT) */
423
+ 42161: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
424
+ /** bsc (binance-peg USDT) */
425
+ 56: "0x55d398326f99059fF775485246999027B3197955"
426
+ };
427
+ var USDC_ADDRESSES = {
428
+ /** sepolia (native USDC) */
429
+ 11155111: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
430
+ /** arbitrum sepolia (native USDC) */
431
+ 421614: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
432
+ /** bsc testnet (binance-peg USDC) */
433
+ 97: "0x64544969ed7EBf5f083679233325356EbE738930",
434
+ /** mainnet (native USDC) */
435
+ 1: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
436
+ /** arbitrum (native USDC) */
437
+ 42161: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
438
+ /** bsc (binance-peg USDC) */
439
+ 56: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"
440
+ };
441
+ var PAYMENT_ROUTER = "0xe50342E06Ab270dfecc69C3B1EE6Da7E2e2D02f0";
442
+
443
+ // src/chain/evm/constants/chains.ts
444
+ var MAINNET_CHAIN_IDS = [
445
+ 1,
446
+ // Ethereum
447
+ 42161,
448
+ // Arbitrum
449
+ 8453,
450
+ // Base
451
+ 56,
452
+ // BSC
453
+ 137,
454
+ // Polygon
455
+ 8217
456
+ // Kaia
457
+ ];
458
+ var TESTNET_CHAIN_IDS = [
459
+ 31337,
460
+ // Anvil
461
+ 11155111,
462
+ // Sepolia
463
+ 421614,
464
+ // Arbitrum Sepolia
465
+ 84532,
466
+ // Base Sepolia
467
+ 97,
468
+ // BSC Testnet
469
+ 80002,
470
+ // Polygon Amoy
471
+ 1001
472
+ // Kairos
473
+ ];
474
+ var ETHEREUM_MAINNET_ID = 1;
475
+
476
+ // src/chain/evm/utils/token.ts
477
+ function isNativeCoin(tokenAddress) {
478
+ return tokenAddress.toLowerCase() === ETH.toLowerCase();
479
+ }
480
+ function isMainnetUSDT(chainId, tokenAddress) {
481
+ const mainnetUSDT = USDT_ADDRESSES[ETHEREUM_MAINNET_ID];
482
+ return chainId === ETHEREUM_MAINNET_ID && !!mainnetUSDT && tokenAddress.toLowerCase() === mainnetUSDT.toLowerCase();
483
+ }
484
+
485
+ // src/chain/evm/encode.ts
486
+ var PAY_ETH_SELECTOR = "a25a7b55";
487
+ var PAY_ERC20_SELECTOR = "90dbfa61";
488
+ function encodeUint256(value) {
489
+ return value.toString(16).padStart(64, "0");
490
+ }
491
+ function encodeAddress(address) {
492
+ return address.replace("0x", "").toLowerCase().padStart(64, "0");
493
+ }
494
+ function encodeBytes(hex) {
495
+ const data = hex.replace("0x", "");
496
+ const byteLength = data.length / 2;
497
+ const paddedData = data.padEnd(Math.ceil(data.length / 64) * 64, "0");
498
+ return encodeUint256(BigInt(byteLength)) + paddedData;
499
+ }
500
+ function encodePaymentTransaction(routerAddress, chainId, paymentData, signature) {
501
+ const isNative = isNativeCoin(paymentData.erc20);
502
+ let data;
503
+ let value;
504
+ if (isNative) {
505
+ const offsetToSignature = 5 * 32;
506
+ const params = encodeUint256(BigInt(paymentData.id)) + encodeAddress(paymentData.receiver) + encodeUint256(BigInt(paymentData.feeRate)) + encodeUint256(BigInt(paymentData.expirationTimestamp)) + encodeUint256(BigInt(offsetToSignature)) + encodeBytes(signature);
507
+ data = "0x" + PAY_ETH_SELECTOR + params;
508
+ value = `0x${BigInt(paymentData.amount).toString(16)}`;
509
+ } else {
510
+ const offsetToSignature = 7 * 32;
511
+ const params = encodeUint256(BigInt(paymentData.id)) + encodeAddress(paymentData.erc20) + encodeAddress(paymentData.receiver) + encodeUint256(BigInt(paymentData.amount)) + encodeUint256(BigInt(paymentData.feeRate)) + encodeUint256(BigInt(paymentData.expirationTimestamp)) + encodeUint256(BigInt(offsetToSignature)) + encodeBytes(signature);
512
+ data = "0x" + PAY_ERC20_SELECTOR + params;
513
+ value = "0x0";
514
+ }
515
+ return {
516
+ chainId: parseInt(chainId),
517
+ to: routerAddress,
518
+ data,
519
+ value
520
+ };
521
+ }
522
+
523
+ // src/chain/evm/constants/abis/PaymentRouterAbi.ts
524
+ var PaymentRouterAbi = [
525
+ {
526
+ type: "constructor",
527
+ inputs: [
528
+ {
529
+ name: "owner_",
530
+ type: "address",
531
+ internalType: "address"
532
+ },
533
+ {
534
+ name: "signer_",
535
+ type: "address",
536
+ internalType: "address"
537
+ },
538
+ {
539
+ name: "feeRecipient_",
540
+ type: "address",
541
+ internalType: "address"
542
+ }
543
+ ],
544
+ stateMutability: "nonpayable"
545
+ },
546
+ {
547
+ type: "function",
548
+ name: "ETH",
549
+ inputs: [],
550
+ outputs: [
551
+ {
552
+ name: "",
553
+ type: "address",
554
+ internalType: "address"
555
+ }
556
+ ],
557
+ stateMutability: "view"
558
+ },
559
+ {
560
+ type: "function",
561
+ name: "FEE_RATE_UNIT_DIVISOR",
562
+ inputs: [],
563
+ outputs: [
564
+ {
565
+ name: "",
566
+ type: "uint256",
567
+ internalType: "uint256"
568
+ }
569
+ ],
570
+ stateMutability: "view"
571
+ },
572
+ {
573
+ type: "function",
574
+ name: "PAYMENT_DATA_TYPE_HASH",
575
+ inputs: [],
576
+ outputs: [
577
+ {
578
+ name: "",
579
+ type: "bytes32",
580
+ internalType: "bytes32"
581
+ }
582
+ ],
583
+ stateMutability: "view"
584
+ },
585
+ {
586
+ type: "function",
587
+ name: "changeFeeRecipient",
588
+ inputs: [
589
+ {
590
+ name: "newFeeRecipient",
591
+ type: "address",
592
+ internalType: "address"
593
+ }
594
+ ],
595
+ outputs: [],
596
+ stateMutability: "nonpayable"
597
+ },
598
+ {
599
+ type: "function",
600
+ name: "changeSigner",
601
+ inputs: [
602
+ {
603
+ name: "newSigner",
604
+ type: "address",
605
+ internalType: "address"
606
+ }
607
+ ],
608
+ outputs: [],
609
+ stateMutability: "nonpayable"
610
+ },
611
+ {
612
+ type: "function",
613
+ name: "eip712Domain",
614
+ inputs: [],
615
+ outputs: [
616
+ {
617
+ name: "fields",
618
+ type: "bytes1",
619
+ internalType: "bytes1"
620
+ },
621
+ {
622
+ name: "name",
623
+ type: "string",
624
+ internalType: "string"
625
+ },
626
+ {
627
+ name: "version",
628
+ type: "string",
629
+ internalType: "string"
630
+ },
631
+ {
632
+ name: "chainId",
633
+ type: "uint256",
634
+ internalType: "uint256"
635
+ },
636
+ {
637
+ name: "verifyingContract",
638
+ type: "address",
639
+ internalType: "address"
640
+ },
641
+ {
642
+ name: "salt",
643
+ type: "bytes32",
644
+ internalType: "bytes32"
645
+ },
646
+ {
647
+ name: "extensions",
648
+ type: "uint256[]",
649
+ internalType: "uint256[]"
650
+ }
651
+ ],
652
+ stateMutability: "view"
653
+ },
654
+ {
655
+ type: "function",
656
+ name: "feeRecipient",
657
+ inputs: [],
658
+ outputs: [
659
+ {
660
+ name: "",
661
+ type: "address",
662
+ internalType: "address"
663
+ }
664
+ ],
665
+ stateMutability: "view"
666
+ },
667
+ {
668
+ type: "function",
669
+ name: "hashPaymentData",
670
+ inputs: [
671
+ {
672
+ name: "id",
673
+ type: "uint256",
674
+ internalType: "uint256"
675
+ },
676
+ {
677
+ name: "erc20",
678
+ type: "address",
679
+ internalType: "contract IERC20"
680
+ },
681
+ {
682
+ name: "sender",
683
+ type: "address",
684
+ internalType: "address"
685
+ },
686
+ {
687
+ name: "receiver",
688
+ type: "address",
689
+ internalType: "address"
690
+ },
691
+ {
692
+ name: "amount",
693
+ type: "uint256",
694
+ internalType: "uint256"
695
+ },
696
+ {
697
+ name: "feeRate",
698
+ type: "uint256",
699
+ internalType: "uint256"
700
+ },
701
+ {
702
+ name: "expirationTimestamp",
703
+ type: "uint256",
704
+ internalType: "uint256"
705
+ }
706
+ ],
707
+ outputs: [
708
+ {
709
+ name: "",
710
+ type: "bytes32",
711
+ internalType: "bytes32"
712
+ }
713
+ ],
714
+ stateMutability: "pure"
715
+ },
716
+ {
717
+ type: "function",
718
+ name: "owner",
719
+ inputs: [],
720
+ outputs: [
721
+ {
722
+ name: "",
723
+ type: "address",
724
+ internalType: "address"
725
+ }
726
+ ],
727
+ stateMutability: "view"
728
+ },
729
+ {
730
+ type: "function",
731
+ name: "pay",
732
+ inputs: [
733
+ {
734
+ name: "paramsList",
735
+ type: "tuple[]",
736
+ internalType: "struct IPaymentRouter.PaymentParams[]",
737
+ components: [
738
+ {
739
+ name: "id",
740
+ type: "uint256",
741
+ internalType: "uint256"
742
+ },
743
+ {
744
+ name: "erc20",
745
+ type: "address",
746
+ internalType: "contract IERC20"
747
+ },
748
+ {
749
+ name: "receiver",
750
+ type: "address",
751
+ internalType: "address"
752
+ },
753
+ {
754
+ name: "amount",
755
+ type: "uint256",
756
+ internalType: "uint256"
757
+ },
758
+ {
759
+ name: "feeRate",
760
+ type: "uint256",
761
+ internalType: "uint256"
762
+ },
763
+ {
764
+ name: "expirationTimestamp",
765
+ type: "uint256",
766
+ internalType: "uint256"
767
+ },
768
+ {
769
+ name: "signature",
770
+ type: "bytes",
771
+ internalType: "bytes"
772
+ }
773
+ ]
774
+ }
775
+ ],
776
+ outputs: [],
777
+ stateMutability: "payable"
778
+ },
779
+ {
780
+ type: "function",
781
+ name: "payERC20",
782
+ inputs: [
783
+ {
784
+ name: "id",
785
+ type: "uint256",
786
+ internalType: "uint256"
787
+ },
788
+ {
789
+ name: "erc20",
790
+ type: "address",
791
+ internalType: "contract IERC20"
792
+ },
793
+ {
794
+ name: "receiver",
795
+ type: "address",
796
+ internalType: "address"
797
+ },
798
+ {
799
+ name: "amount",
800
+ type: "uint256",
801
+ internalType: "uint256"
802
+ },
803
+ {
804
+ name: "feeRate",
805
+ type: "uint256",
806
+ internalType: "uint256"
807
+ },
808
+ {
809
+ name: "expirationTimestamp",
810
+ type: "uint256",
811
+ internalType: "uint256"
812
+ },
813
+ {
814
+ name: "signature",
815
+ type: "bytes",
816
+ internalType: "bytes"
817
+ }
818
+ ],
819
+ outputs: [],
820
+ stateMutability: "nonpayable"
821
+ },
822
+ {
823
+ type: "function",
824
+ name: "payETH",
825
+ inputs: [
826
+ {
827
+ name: "id",
828
+ type: "uint256",
829
+ internalType: "uint256"
830
+ },
831
+ {
832
+ name: "receiver",
833
+ type: "address",
834
+ internalType: "address"
835
+ },
836
+ {
837
+ name: "feeRate",
838
+ type: "uint256",
839
+ internalType: "uint256"
840
+ },
841
+ {
842
+ name: "expirationTimestamp",
843
+ type: "uint256",
844
+ internalType: "uint256"
845
+ },
846
+ {
847
+ name: "signature",
848
+ type: "bytes",
849
+ internalType: "bytes"
850
+ }
851
+ ],
852
+ outputs: [],
853
+ stateMutability: "payable"
854
+ },
855
+ {
856
+ type: "function",
857
+ name: "recover",
858
+ inputs: [
859
+ {
860
+ name: "structHash",
861
+ type: "bytes32",
862
+ internalType: "bytes32"
863
+ },
864
+ {
865
+ name: "signature",
866
+ type: "bytes",
867
+ internalType: "bytes"
868
+ }
869
+ ],
870
+ outputs: [
871
+ {
872
+ name: "",
873
+ type: "address",
874
+ internalType: "address"
875
+ }
876
+ ],
877
+ stateMutability: "view"
878
+ },
879
+ {
880
+ type: "function",
881
+ name: "renounceOwnership",
882
+ inputs: [],
883
+ outputs: [],
884
+ stateMutability: "nonpayable"
885
+ },
886
+ {
887
+ type: "function",
888
+ name: "signer",
889
+ inputs: [],
890
+ outputs: [
891
+ {
892
+ name: "",
893
+ type: "address",
894
+ internalType: "address"
895
+ }
896
+ ],
897
+ stateMutability: "view"
898
+ },
899
+ {
900
+ type: "function",
901
+ name: "transferOwnership",
902
+ inputs: [
903
+ {
904
+ name: "newOwner",
905
+ type: "address",
906
+ internalType: "address"
907
+ }
908
+ ],
909
+ outputs: [],
910
+ stateMutability: "nonpayable"
911
+ },
912
+ {
913
+ type: "event",
914
+ name: "EIP712DomainChanged",
915
+ inputs: [],
916
+ anonymous: false
917
+ },
918
+ {
919
+ type: "event",
920
+ name: "OwnershipTransferred",
921
+ inputs: [
922
+ {
923
+ name: "previousOwner",
924
+ type: "address",
925
+ indexed: true,
926
+ internalType: "address"
927
+ },
928
+ {
929
+ name: "newOwner",
930
+ type: "address",
931
+ indexed: true,
932
+ internalType: "address"
933
+ }
934
+ ],
935
+ anonymous: false
936
+ },
937
+ {
938
+ type: "event",
939
+ name: "Payment",
940
+ inputs: [
941
+ {
942
+ name: "id",
943
+ type: "uint256",
944
+ indexed: true,
945
+ internalType: "uint256"
946
+ },
947
+ {
948
+ name: "erc20",
949
+ type: "address",
950
+ indexed: true,
951
+ internalType: "contract IERC20"
952
+ },
953
+ {
954
+ name: "sender",
955
+ type: "address",
956
+ indexed: false,
957
+ internalType: "address"
958
+ },
959
+ {
960
+ name: "receiver",
961
+ type: "address",
962
+ indexed: true,
963
+ internalType: "address"
964
+ },
965
+ {
966
+ name: "amount",
967
+ type: "uint256",
968
+ indexed: false,
969
+ internalType: "uint256"
970
+ },
971
+ {
972
+ name: "feeRecipient",
973
+ type: "address",
974
+ indexed: false,
975
+ internalType: "address"
976
+ },
977
+ {
978
+ name: "feeRate",
979
+ type: "uint256",
980
+ indexed: false,
981
+ internalType: "uint256"
982
+ },
983
+ {
984
+ name: "fee",
985
+ type: "uint256",
986
+ indexed: false,
987
+ internalType: "uint256"
988
+ },
989
+ {
990
+ name: "amountAfterFee",
991
+ type: "uint256",
992
+ indexed: false,
993
+ internalType: "uint256"
994
+ }
995
+ ],
996
+ anonymous: false
997
+ },
998
+ {
999
+ type: "error",
1000
+ name: "ECDSAInvalidSignature",
1001
+ inputs: []
1002
+ },
1003
+ {
1004
+ type: "error",
1005
+ name: "ECDSAInvalidSignatureLength",
1006
+ inputs: [
1007
+ {
1008
+ name: "length",
1009
+ type: "uint256",
1010
+ internalType: "uint256"
1011
+ }
1012
+ ]
1013
+ },
1014
+ {
1015
+ type: "error",
1016
+ name: "ECDSAInvalidSignatureS",
1017
+ inputs: [
1018
+ {
1019
+ name: "s",
1020
+ type: "bytes32",
1021
+ internalType: "bytes32"
1022
+ }
1023
+ ]
1024
+ },
1025
+ {
1026
+ type: "error",
1027
+ name: "ETHTransferFailed",
1028
+ inputs: []
1029
+ },
1030
+ {
1031
+ type: "error",
1032
+ name: "Expired",
1033
+ inputs: []
1034
+ },
1035
+ {
1036
+ type: "error",
1037
+ name: "InsufficientETH",
1038
+ inputs: []
1039
+ },
1040
+ {
1041
+ type: "error",
1042
+ name: "InvalidAddress",
1043
+ inputs: []
1044
+ },
1045
+ {
1046
+ type: "error",
1047
+ name: "InvalidFeeRate",
1048
+ inputs: []
1049
+ },
1050
+ {
1051
+ type: "error",
1052
+ name: "InvalidId",
1053
+ inputs: []
1054
+ },
1055
+ {
1056
+ type: "error",
1057
+ name: "InvalidShortString",
1058
+ inputs: []
1059
+ },
1060
+ {
1061
+ type: "error",
1062
+ name: "InvalidSignature",
1063
+ inputs: []
1064
+ },
1065
+ {
1066
+ type: "error",
1067
+ name: "OwnableInvalidOwner",
1068
+ inputs: [
1069
+ {
1070
+ name: "owner",
1071
+ type: "address",
1072
+ internalType: "address"
1073
+ }
1074
+ ]
1075
+ },
1076
+ {
1077
+ type: "error",
1078
+ name: "OwnableUnauthorizedAccount",
1079
+ inputs: [
1080
+ {
1081
+ name: "account",
1082
+ type: "address",
1083
+ internalType: "address"
1084
+ }
1085
+ ]
1086
+ },
1087
+ {
1088
+ type: "error",
1089
+ name: "ReentrancyGuardReentrantCall",
1090
+ inputs: []
1091
+ },
1092
+ {
1093
+ type: "error",
1094
+ name: "SafeERC20FailedOperation",
1095
+ inputs: [
1096
+ {
1097
+ name: "token",
1098
+ type: "address",
1099
+ internalType: "address"
1100
+ }
1101
+ ]
1102
+ },
1103
+ {
1104
+ type: "error",
1105
+ name: "StringTooLong",
1106
+ inputs: [
1107
+ {
1108
+ name: "str",
1109
+ type: "string",
1110
+ internalType: "string"
1111
+ }
1112
+ ]
1113
+ }
1114
+ ];
1115
+
1116
+ // src/chain/evm/constants/abis/mainnetUSDTAbi.ts
1117
+ var mainnetUSDTAbi = [
1118
+ {
1119
+ constant: true,
1120
+ inputs: [],
1121
+ name: "name",
1122
+ outputs: [{ name: "", type: "string" }],
1123
+ payable: false,
1124
+ stateMutability: "view",
1125
+ type: "function"
1126
+ },
1127
+ {
1128
+ constant: false,
1129
+ inputs: [{ name: "_upgradedAddress", type: "address" }],
1130
+ name: "deprecate",
1131
+ outputs: [],
1132
+ payable: false,
1133
+ stateMutability: "nonpayable",
1134
+ type: "function"
1135
+ },
1136
+ {
1137
+ constant: false,
1138
+ inputs: [
1139
+ { name: "_spender", type: "address" },
1140
+ { name: "_value", type: "uint256" }
1141
+ ],
1142
+ name: "approve",
1143
+ outputs: [],
1144
+ payable: false,
1145
+ stateMutability: "nonpayable",
1146
+ type: "function"
1147
+ },
1148
+ {
1149
+ constant: true,
1150
+ inputs: [],
1151
+ name: "deprecated",
1152
+ outputs: [{ name: "", type: "bool" }],
1153
+ payable: false,
1154
+ stateMutability: "view",
1155
+ type: "function"
1156
+ },
1157
+ {
1158
+ constant: false,
1159
+ inputs: [{ name: "_evilUser", type: "address" }],
1160
+ name: "addBlackList",
1161
+ outputs: [],
1162
+ payable: false,
1163
+ stateMutability: "nonpayable",
1164
+ type: "function"
1165
+ },
1166
+ {
1167
+ constant: true,
1168
+ inputs: [],
1169
+ name: "totalSupply",
1170
+ outputs: [{ name: "", type: "uint256" }],
1171
+ payable: false,
1172
+ stateMutability: "view",
1173
+ type: "function"
1174
+ },
1175
+ {
1176
+ constant: false,
1177
+ inputs: [
1178
+ { name: "_from", type: "address" },
1179
+ { name: "_to", type: "address" },
1180
+ { name: "_value", type: "uint256" }
1181
+ ],
1182
+ name: "transferFrom",
1183
+ outputs: [],
1184
+ payable: false,
1185
+ stateMutability: "nonpayable",
1186
+ type: "function"
1187
+ },
1188
+ {
1189
+ constant: true,
1190
+ inputs: [],
1191
+ name: "upgradedAddress",
1192
+ outputs: [{ name: "", type: "address" }],
1193
+ payable: false,
1194
+ stateMutability: "view",
1195
+ type: "function"
1196
+ },
1197
+ {
1198
+ constant: true,
1199
+ inputs: [{ name: "", type: "address" }],
1200
+ name: "balances",
1201
+ outputs: [{ name: "", type: "uint256" }],
1202
+ payable: false,
1203
+ stateMutability: "view",
1204
+ type: "function"
1205
+ },
1206
+ {
1207
+ constant: true,
1208
+ inputs: [],
1209
+ name: "decimals",
1210
+ outputs: [{ name: "", type: "uint256" }],
1211
+ payable: false,
1212
+ stateMutability: "view",
1213
+ type: "function"
1214
+ },
1215
+ {
1216
+ constant: true,
1217
+ inputs: [],
1218
+ name: "maximumFee",
1219
+ outputs: [{ name: "", type: "uint256" }],
1220
+ payable: false,
1221
+ stateMutability: "view",
1222
+ type: "function"
1223
+ },
1224
+ {
1225
+ constant: true,
1226
+ inputs: [],
1227
+ name: "_totalSupply",
1228
+ outputs: [{ name: "", type: "uint256" }],
1229
+ payable: false,
1230
+ stateMutability: "view",
1231
+ type: "function"
1232
+ },
1233
+ {
1234
+ constant: false,
1235
+ inputs: [],
1236
+ name: "unpause",
1237
+ outputs: [],
1238
+ payable: false,
1239
+ stateMutability: "nonpayable",
1240
+ type: "function"
1241
+ },
1242
+ {
1243
+ constant: true,
1244
+ inputs: [{ name: "_maker", type: "address" }],
1245
+ name: "getBlackListStatus",
1246
+ outputs: [{ name: "", type: "bool" }],
1247
+ payable: false,
1248
+ stateMutability: "view",
1249
+ type: "function"
1250
+ },
1251
+ {
1252
+ constant: true,
1253
+ inputs: [
1254
+ { name: "", type: "address" },
1255
+ { name: "", type: "address" }
1256
+ ],
1257
+ name: "allowed",
1258
+ outputs: [{ name: "", type: "uint256" }],
1259
+ payable: false,
1260
+ stateMutability: "view",
1261
+ type: "function"
1262
+ },
1263
+ {
1264
+ constant: true,
1265
+ inputs: [],
1266
+ name: "paused",
1267
+ outputs: [{ name: "", type: "bool" }],
1268
+ payable: false,
1269
+ stateMutability: "view",
1270
+ type: "function"
1271
+ },
1272
+ {
1273
+ constant: true,
1274
+ inputs: [{ name: "who", type: "address" }],
1275
+ name: "balanceOf",
1276
+ outputs: [{ name: "", type: "uint256" }],
1277
+ payable: false,
1278
+ stateMutability: "view",
1279
+ type: "function"
1280
+ },
1281
+ {
1282
+ constant: false,
1283
+ inputs: [],
1284
+ name: "pause",
1285
+ outputs: [],
1286
+ payable: false,
1287
+ stateMutability: "nonpayable",
1288
+ type: "function"
1289
+ },
1290
+ {
1291
+ constant: true,
1292
+ inputs: [],
1293
+ name: "getOwner",
1294
+ outputs: [{ name: "", type: "address" }],
1295
+ payable: false,
1296
+ stateMutability: "view",
1297
+ type: "function"
1298
+ },
1299
+ {
1300
+ constant: true,
1301
+ inputs: [],
1302
+ name: "owner",
1303
+ outputs: [{ name: "", type: "address" }],
1304
+ payable: false,
1305
+ stateMutability: "view",
1306
+ type: "function"
1307
+ },
1308
+ {
1309
+ constant: true,
1310
+ inputs: [],
1311
+ name: "symbol",
1312
+ outputs: [{ name: "", type: "string" }],
1313
+ payable: false,
1314
+ stateMutability: "view",
1315
+ type: "function"
1316
+ },
1317
+ {
1318
+ constant: false,
1319
+ inputs: [
1320
+ { name: "_to", type: "address" },
1321
+ { name: "_value", type: "uint256" }
1322
+ ],
1323
+ name: "transfer",
1324
+ outputs: [],
1325
+ payable: false,
1326
+ stateMutability: "nonpayable",
1327
+ type: "function"
1328
+ },
1329
+ {
1330
+ constant: false,
1331
+ inputs: [
1332
+ { name: "newBasisPoints", type: "uint256" },
1333
+ { name: "newMaxFee", type: "uint256" }
1334
+ ],
1335
+ name: "setParams",
1336
+ outputs: [],
1337
+ payable: false,
1338
+ stateMutability: "nonpayable",
1339
+ type: "function"
1340
+ },
1341
+ {
1342
+ constant: false,
1343
+ inputs: [{ name: "amount", type: "uint256" }],
1344
+ name: "issue",
1345
+ outputs: [],
1346
+ payable: false,
1347
+ stateMutability: "nonpayable",
1348
+ type: "function"
1349
+ },
1350
+ {
1351
+ constant: false,
1352
+ inputs: [{ name: "amount", type: "uint256" }],
1353
+ name: "redeem",
1354
+ outputs: [],
1355
+ payable: false,
1356
+ stateMutability: "nonpayable",
1357
+ type: "function"
1358
+ },
1359
+ {
1360
+ constant: true,
1361
+ inputs: [
1362
+ { name: "_owner", type: "address" },
1363
+ { name: "_spender", type: "address" }
1364
+ ],
1365
+ name: "allowance",
1366
+ outputs: [{ name: "remaining", type: "uint256" }],
1367
+ payable: false,
1368
+ stateMutability: "view",
1369
+ type: "function"
1370
+ },
1371
+ {
1372
+ constant: true,
1373
+ inputs: [],
1374
+ name: "basisPointsRate",
1375
+ outputs: [{ name: "", type: "uint256" }],
1376
+ payable: false,
1377
+ stateMutability: "view",
1378
+ type: "function"
1379
+ },
1380
+ {
1381
+ constant: true,
1382
+ inputs: [{ name: "", type: "address" }],
1383
+ name: "isBlackListed",
1384
+ outputs: [{ name: "", type: "bool" }],
1385
+ payable: false,
1386
+ stateMutability: "view",
1387
+ type: "function"
1388
+ },
1389
+ {
1390
+ constant: false,
1391
+ inputs: [{ name: "_clearedUser", type: "address" }],
1392
+ name: "removeBlackList",
1393
+ outputs: [],
1394
+ payable: false,
1395
+ stateMutability: "nonpayable",
1396
+ type: "function"
1397
+ },
1398
+ {
1399
+ constant: true,
1400
+ inputs: [],
1401
+ name: "MAX_UINT",
1402
+ outputs: [{ name: "", type: "uint256" }],
1403
+ payable: false,
1404
+ stateMutability: "view",
1405
+ type: "function"
1406
+ },
1407
+ {
1408
+ constant: false,
1409
+ inputs: [{ name: "newOwner", type: "address" }],
1410
+ name: "transferOwnership",
1411
+ outputs: [],
1412
+ payable: false,
1413
+ stateMutability: "nonpayable",
1414
+ type: "function"
1415
+ },
1416
+ {
1417
+ constant: false,
1418
+ inputs: [{ name: "_blackListedUser", type: "address" }],
1419
+ name: "destroyBlackFunds",
1420
+ outputs: [],
1421
+ payable: false,
1422
+ stateMutability: "nonpayable",
1423
+ type: "function"
1424
+ },
1425
+ {
1426
+ inputs: [
1427
+ { name: "_initialSupply", type: "uint256" },
1428
+ { name: "_name", type: "string" },
1429
+ { name: "_symbol", type: "string" },
1430
+ { name: "_decimals", type: "uint256" }
1431
+ ],
1432
+ payable: false,
1433
+ stateMutability: "nonpayable",
1434
+ type: "constructor"
1435
+ },
1436
+ {
1437
+ anonymous: false,
1438
+ inputs: [{ indexed: false, name: "amount", type: "uint256" }],
1439
+ name: "Issue",
1440
+ type: "event"
1441
+ },
1442
+ {
1443
+ anonymous: false,
1444
+ inputs: [{ indexed: false, name: "amount", type: "uint256" }],
1445
+ name: "Redeem",
1446
+ type: "event"
1447
+ },
1448
+ {
1449
+ anonymous: false,
1450
+ inputs: [{ indexed: false, name: "newAddress", type: "address" }],
1451
+ name: "Deprecate",
1452
+ type: "event"
1453
+ },
1454
+ {
1455
+ anonymous: false,
1456
+ inputs: [
1457
+ { indexed: false, name: "feeBasisPoints", type: "uint256" },
1458
+ { indexed: false, name: "maxFee", type: "uint256" }
1459
+ ],
1460
+ name: "Params",
1461
+ type: "event"
1462
+ },
1463
+ {
1464
+ anonymous: false,
1465
+ inputs: [
1466
+ { indexed: false, name: "_blackListedUser", type: "address" },
1467
+ { indexed: false, name: "_balance", type: "uint256" }
1468
+ ],
1469
+ name: "DestroyedBlackFunds",
1470
+ type: "event"
1471
+ },
1472
+ {
1473
+ anonymous: false,
1474
+ inputs: [{ indexed: false, name: "_user", type: "address" }],
1475
+ name: "AddedBlackList",
1476
+ type: "event"
1477
+ },
1478
+ {
1479
+ anonymous: false,
1480
+ inputs: [{ indexed: false, name: "_user", type: "address" }],
1481
+ name: "RemovedBlackList",
1482
+ type: "event"
1483
+ },
1484
+ {
1485
+ anonymous: false,
1486
+ inputs: [
1487
+ { indexed: true, name: "owner", type: "address" },
1488
+ { indexed: true, name: "spender", type: "address" },
1489
+ { indexed: false, name: "value", type: "uint256" }
1490
+ ],
1491
+ name: "Approval",
1492
+ type: "event"
1493
+ },
1494
+ {
1495
+ anonymous: false,
1496
+ inputs: [
1497
+ { indexed: true, name: "from", type: "address" },
1498
+ { indexed: true, name: "to", type: "address" },
1499
+ { indexed: false, name: "value", type: "uint256" }
1500
+ ],
1501
+ name: "Transfer",
1502
+ type: "event"
1503
+ },
1504
+ { anonymous: false, inputs: [], name: "Pause", type: "event" },
1505
+ { anonymous: false, inputs: [], name: "Unpause", type: "event" }
1506
+ ];
1507
+
1508
+ // src/chain/evm/provider.ts
1509
+ var ERC20_BALANCE_OF_SELECTOR = "0x70a08231";
1510
+ async function getNativeBalance(provider, address) {
1511
+ const result = await provider.request({
1512
+ method: "eth_getBalance",
1513
+ params: [address, "latest"]
1514
+ });
1515
+ return BigInt(result);
1516
+ }
1517
+ async function getTokenBalance(provider, tokenAddress, walletAddress) {
1518
+ const paddedAddress = walletAddress.slice(2).toLowerCase().padStart(64, "0");
1519
+ const data = `${ERC20_BALANCE_OF_SELECTOR}${paddedAddress}`;
1520
+ const result = await provider.request({
1521
+ method: "eth_call",
1522
+ params: [{ to: tokenAddress, data }, "latest"]
1523
+ });
1524
+ return BigInt(result);
1525
+ }
1526
+ async function estimateGasCost(provider, gasUnits = 21000n) {
1527
+ const gasPrice = await provider.request({
1528
+ method: "eth_gasPrice",
1529
+ params: []
1530
+ });
1531
+ return gasUnits * BigInt(gasPrice);
1532
+ }
1533
+
1534
+ // src/chain/provider.ts
1535
+ async function getNativeBalance2(chainType, provider, address) {
1536
+ if (chainType !== "evm") {
1537
+ throw new Error(`Unsupported chain type: ${chainType}`);
1538
+ }
1539
+ return getNativeBalance(provider, address);
1540
+ }
1541
+ async function getTokenBalance2(chainType, provider, tokenAddress, walletAddress) {
1542
+ if (chainType !== "evm") {
1543
+ throw new Error(`Unsupported chain type: ${chainType}`);
1544
+ }
1545
+ return getTokenBalance(provider, tokenAddress, walletAddress);
1546
+ }
1547
+ async function estimateGasCost2(chainType, provider, gasUnits) {
1548
+ if (chainType !== "evm") {
1549
+ throw new Error(`Unsupported chain type: ${chainType}`);
1550
+ }
1551
+ return estimateGasCost(provider, gasUnits);
1552
+ }
1553
+ //# sourceMappingURL=index.js.map