@pioneer-platform/tenderly-client 8.5.0 → 8.7.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.
@@ -0,0 +1 @@
1
+ $ tsc -p .
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @pioneer-platform/tenderly-client
2
2
 
3
+ ## 8.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Automated minor version bump for all packages
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @pioneer-platform/loggerdog@8.7.0
13
+
14
+ ## 8.6.0
15
+
16
+ ### Minor Changes
17
+
18
+ - Automated minor version bump for all packages
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+ - @pioneer-platform/loggerdog@8.6.0
24
+
3
25
  ## 8.5.0
4
26
 
5
27
  ### Minor Changes
package/build.sh ADDED
@@ -0,0 +1,22 @@
1
+ #!/bin/bash
2
+ # Fast Bun build (replaces slow tsc)
3
+
4
+ OUTDIR="${1:-lib}"
5
+ ENTRY="${2:-src/index.ts}"
6
+
7
+ # Clean output
8
+ rm -rf "$OUTDIR"
9
+ mkdir -p "$OUTDIR"
10
+
11
+ # Build with Bun (10x faster than tsc)
12
+ bun build "$ENTRY" \
13
+ --outdir "$OUTDIR" \
14
+ --target node \
15
+ --format cjs \
16
+ --sourcemap \
17
+ --minify
18
+
19
+ # Generate TypeScript declarations
20
+ bunx tsc --emitDeclarationOnly --outDir "$OUTDIR" --project .
21
+
22
+ echo "✅ Built $OUTDIR"
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/lib/index.js ADDED
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var axios_1 = __importDefault(require("axios"));
43
+ var https_1 = __importDefault(require("https"));
44
+ var TAG = " | tenderly | ";
45
+ // Ensure API key is set
46
+ var TENDERLY_ACCESS_KEY = process.env.TENDERLY_ACCESS_KEY;
47
+ if (!TENDERLY_ACCESS_KEY) {
48
+ throw new Error("API key required! Set env TENDERLY_ACCESS_KEY");
49
+ }
50
+ var TENDERLY_USER = 'highlander2';
51
+ var TENDERLY_PROJECT = 'project';
52
+ // Axios instance with custom HTTPS agent
53
+ var axiosInstance = axios_1.default.create({
54
+ httpsAgent: new https_1.default.Agent({
55
+ rejectUnauthorized: false
56
+ })
57
+ });
58
+ module.exports = {
59
+ validateTransaction: function (tx) {
60
+ return simulateTransaction(tx);
61
+ },
62
+ };
63
+ // Function to simulate a transaction
64
+ function simulateTransaction(tx) {
65
+ return __awaiter(this, void 0, void 0, function () {
66
+ var tag, apiURL, body, headers, response, summary, error_1;
67
+ var _a;
68
+ return __generator(this, function (_b) {
69
+ switch (_b.label) {
70
+ case 0:
71
+ tag = " | simulateTransaction | ";
72
+ _b.label = 1;
73
+ case 1:
74
+ _b.trys.push([1, 3, , 4]);
75
+ apiURL = "https://api.tenderly.co/api/v1/account/highlander2/project/project/simulate";
76
+ body = {
77
+ network_id: tx.chainId || "1",
78
+ from: tx.from,
79
+ to: tx.to,
80
+ input: tx.data,
81
+ value: tx.value || 0,
82
+ save_if_fails: true
83
+ };
84
+ //eip1559
85
+ if (tx.gas) {
86
+ body.gas = tx.gas;
87
+ body.gas_price = tx.gasPrice;
88
+ }
89
+ if (tx.maxPriorityFeePerGas) {
90
+ body.max_priority_fee_per_gas = tx.maxPriorityFeePerGas;
91
+ body.max_fee_per_gas = tx.maxFeePerGas;
92
+ }
93
+ headers = {
94
+ headers: {
95
+ 'Content-Type': 'application/json',
96
+ 'X-Access-Key': TENDERLY_ACCESS_KEY,
97
+ }
98
+ };
99
+ return [4 /*yield*/, axiosInstance.post(apiURL, body, headers)];
100
+ case 2:
101
+ response = _b.sent();
102
+ // console.log(tag,'response: ',Object.keys(response.data))
103
+ // console.log(tag,'response simulation: ',Object.keys(response.data.simulation))
104
+ console.log(tag, 'response simulation: ', response.data.simulation);
105
+ summary = {
106
+ isValid: response.data.simulation.status,
107
+ method: response.data.simulation.method,
108
+ gas_used: response.data.simulation.gas_used,
109
+ nonce: response.data.simulation.nonce,
110
+ addresses: response.data.simulation.addresses,
111
+ };
112
+ if (!response.data.simulation.status) {
113
+ summary.error = response.data.simulation.error_message;
114
+ }
115
+ summary.raw = response.data.simulation;
116
+ return [2 /*return*/, summary];
117
+ case 3:
118
+ error_1 = _b.sent();
119
+ if (axios_1.default.isAxiosError(error_1)) {
120
+ console.error(TAG, "Axios error in simulateTransaction:", ((_a = error_1.response) === null || _a === void 0 ? void 0 : _a.data) || error_1.message);
121
+ }
122
+ else {
123
+ console.error(TAG, "Unknown error in simulateTransaction:", error_1);
124
+ }
125
+ throw new Error("Transaction simulation failed.");
126
+ case 4: return [2 /*return*/];
127
+ }
128
+ });
129
+ });
130
+ }