@pioneer-platform/tenderly-client 8.4.0 → 8.5.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.
- package/CHANGELOG.md +19 -0
- package/package.json +10 -10
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -130
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# @pioneer-platform/tenderly-client
|
2
2
|
|
3
|
+
## 8.5.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.5.0
|
13
|
+
|
14
|
+
## 8.4.1
|
15
|
+
|
16
|
+
### Patch Changes
|
17
|
+
|
18
|
+
- Automated patch version bump for all packages
|
19
|
+
- Updated dependencies
|
20
|
+
- @pioneer-platform/loggerdog@8.4.1
|
21
|
+
|
3
22
|
## 8.4.0
|
4
23
|
|
5
24
|
### Minor Changes
|
package/package.json
CHANGED
@@ -1,14 +1,21 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pioneer-platform/tenderly-client",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.5.0",
|
4
4
|
"main": "./lib/index.js",
|
5
5
|
"types": "./lib/index.d.ts",
|
6
6
|
"dependencies": {
|
7
|
-
"@pioneer-platform/loggerdog": "^8.
|
7
|
+
"@pioneer-platform/loggerdog": "^8.5.0",
|
8
8
|
"axios": "^1.8.4",
|
9
9
|
"dotenv": "^8.2.0",
|
10
10
|
"ethers": "5.7.2"
|
11
11
|
},
|
12
|
+
"scripts": {
|
13
|
+
"npm": "pnpm i",
|
14
|
+
"test": "pnpm run build && node __tests__/test-module.js",
|
15
|
+
"build": "tsc -p .",
|
16
|
+
"prepublish": "pnpm run build",
|
17
|
+
"refresh": "rm -rf ./node_modules ./package-lock.json && pnpm install"
|
18
|
+
},
|
12
19
|
"devDependencies": {
|
13
20
|
"@types/jest": "^25.2.3",
|
14
21
|
"@types/node": "^18.16.0",
|
@@ -20,12 +27,5 @@
|
|
20
27
|
"ts-jest": "^29.0.5",
|
21
28
|
"typescript": "^5.0.4"
|
22
29
|
},
|
23
|
-
"gitHead": "aeae28273014ab69b42f22abec159c6693a56c40"
|
24
|
-
"scripts": {
|
25
|
-
"npm": "pnpm i",
|
26
|
-
"test": "pnpm run build && node __tests__/test-module.js",
|
27
|
-
"build": "tsc -p .",
|
28
|
-
"prepublish": "pnpm run build",
|
29
|
-
"refresh": "rm -rf ./node_modules ./package-lock.json && pnpm install"
|
30
|
-
}
|
30
|
+
"gitHead": "aeae28273014ab69b42f22abec159c6693a56c40"
|
31
31
|
}
|
package/lib/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/lib/index.js
DELETED
@@ -1,130 +0,0 @@
|
|
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
|
-
}
|