@clonegod/ttd-base-common 1.0.0 → 1.0.1
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/common/constants.d.ts +1 -0
- package/dist/common/constants.js +9 -1
- package/dist/trade/send/alchemy_base.d.ts +5 -0
- package/dist/trade/send/alchemy_base.js +48 -0
- package/dist/trade/send/base_rpc.d.ts +5 -0
- package/dist/trade/send/base_rpc.js +48 -0
- package/dist/trade/send/bloxroute_base.d.ts +7 -0
- package/dist/trade/send/bloxroute_base.js +83 -0
- package/dist/trade/send/drpc_base.d.ts +5 -0
- package/dist/trade/send/drpc_base.js +48 -0
- package/dist/trade/send/index.d.ts +1 -3
- package/dist/trade/send/index.js +4 -6
- package/dist/trade/send/infura_base.d.ts +5 -0
- package/dist/trade/send/infura_base.js +48 -0
- package/dist/trade/send/quicknode_base.d.ts +5 -0
- package/dist/trade/send/quicknode_base.js +48 -0
- package/dist/trade/send/send_tx.d.ts +6 -3
- package/dist/trade/send/send_tx.js +49 -31
- package/package.json +1 -1
package/dist/common/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UniswapV3PoolABI = exports.EVENT_SIGNATURES = exports.EVENT_NAMES = exports.WETH_ADDRESS = exports.BASE_CHAIN_ID = void 0;
|
|
3
|
+
exports.UniswapV3RouterABI = exports.UniswapV3PoolABI = exports.EVENT_SIGNATURES = exports.EVENT_NAMES = exports.WETH_ADDRESS = exports.BASE_CHAIN_ID = void 0;
|
|
4
4
|
exports.BASE_CHAIN_ID = 8453;
|
|
5
5
|
exports.WETH_ADDRESS = '0x4200000000000000000000000000000000000006';
|
|
6
6
|
exports.EVENT_NAMES = {
|
|
@@ -32,3 +32,11 @@ exports.UniswapV3PoolABI = [
|
|
|
32
32
|
"event Mint(address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1)",
|
|
33
33
|
"event Burn(address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1)"
|
|
34
34
|
];
|
|
35
|
+
exports.UniswapV3RouterABI = [
|
|
36
|
+
'function exactInputSingle(tuple(address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountOut)',
|
|
37
|
+
'function exactInput(tuple(bytes path, address recipient, uint256 deadline, uint256 amountIn, uint256 amountOutMinimum)) external payable returns (uint256 amountOut)',
|
|
38
|
+
'function exactOutputSingle(tuple(address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 deadline, uint256 amountOut, uint256 amountInMaximum, uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountIn)',
|
|
39
|
+
'function exactOutput(tuple(bytes path, address recipient, uint256 deadline, uint256 amountOut, uint256 amountInMaximum)) external payable returns (uint256 amountIn)',
|
|
40
|
+
'function factory() external view returns (address)',
|
|
41
|
+
'function WETH9() external view returns (address)'
|
|
42
|
+
];
|
|
@@ -0,0 +1,48 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AlchemyBase = void 0;
|
|
16
|
+
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
17
|
+
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
class AlchemyBase {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.endpoint = process.env.BASE_ALCHEMY_RPC_ENDPOINT || '';
|
|
21
|
+
}
|
|
22
|
+
sendTransaction(signedTx) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
try {
|
|
25
|
+
const response = yield axios_1.default.post(this.endpoint, {
|
|
26
|
+
jsonrpc: '2.0',
|
|
27
|
+
method: 'eth_sendRawTransaction',
|
|
28
|
+
params: [signedTx],
|
|
29
|
+
id: 1
|
|
30
|
+
}, {
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json'
|
|
33
|
+
},
|
|
34
|
+
timeout: 3000
|
|
35
|
+
});
|
|
36
|
+
if (response.data.error) {
|
|
37
|
+
throw new Error(`Alchemy RPC error: ${response.data.error.message}`);
|
|
38
|
+
}
|
|
39
|
+
return response.data.result;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
(0, dist_1.log_info)(`Alchemy transaction sending failed`, { error: error.message });
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.AlchemyBase = AlchemyBase;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BaseRpc = void 0;
|
|
16
|
+
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
17
|
+
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
class BaseRpc {
|
|
19
|
+
constructor(rpc_endpoint) {
|
|
20
|
+
this.endpoint = rpc_endpoint || process.env.BASE_OFFICIAL_RPC_ENDPOINT || 'https://mainnet.base.org';
|
|
21
|
+
}
|
|
22
|
+
eth_sendRawTransaction(signedTx) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
try {
|
|
25
|
+
const response = yield axios_1.default.post(this.endpoint, {
|
|
26
|
+
jsonrpc: "2.0",
|
|
27
|
+
method: "eth_sendRawTransaction",
|
|
28
|
+
params: [signedTx],
|
|
29
|
+
id: 1
|
|
30
|
+
}, {
|
|
31
|
+
headers: {
|
|
32
|
+
"Content-Type": "application/json"
|
|
33
|
+
},
|
|
34
|
+
timeout: 3000
|
|
35
|
+
});
|
|
36
|
+
if (response.data.error) {
|
|
37
|
+
throw new Error(`Base Mainnet RPC error: ${response.data.error.message}`);
|
|
38
|
+
}
|
|
39
|
+
return response.data.result;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
(0, dist_1.log_info)(`Base Mainnet transaction sending failed`, { error: error.message });
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.BaseRpc = BaseRpc;
|
|
@@ -0,0 +1,83 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BloxrouteBase = void 0;
|
|
16
|
+
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
17
|
+
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
class BloxrouteBase {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.endpoint = process.env.BASE_BLOXROUTE_RPC_ENDPOINT || '';
|
|
21
|
+
this.authToken = process.env.BASE_BLOXROUTE_AUTH_TOKEN || '';
|
|
22
|
+
}
|
|
23
|
+
sendPrivateTransaction(signedTx) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
try {
|
|
26
|
+
const response = yield axios_1.default.post(this.endpoint, {
|
|
27
|
+
jsonrpc: "2.0",
|
|
28
|
+
id: "1",
|
|
29
|
+
method: "eth_sendPrivateTransaction",
|
|
30
|
+
params: [signedTx]
|
|
31
|
+
}, {
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/json',
|
|
34
|
+
'Authorization': this.authToken
|
|
35
|
+
},
|
|
36
|
+
timeout: 3000
|
|
37
|
+
});
|
|
38
|
+
if (response.data.error) {
|
|
39
|
+
throw new Error(`BloXroute Base Error: ${response.data.error.code} - ${response.data.error.message}`);
|
|
40
|
+
}
|
|
41
|
+
return response.data.result;
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
(0, dist_1.log_error)('BloXroute Base sendPrivateTransaction failed!!!', error);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
sendBundle(transactions, targetBlockNumber) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
try {
|
|
52
|
+
const currentBlock = targetBlockNumber || Math.floor(Date.now() / 1000);
|
|
53
|
+
const targetBlock = currentBlock + 1;
|
|
54
|
+
const response = yield axios_1.default.post(this.endpoint, {
|
|
55
|
+
jsonrpc: "2.0",
|
|
56
|
+
id: "1",
|
|
57
|
+
method: "eth_sendBundle",
|
|
58
|
+
params: [{
|
|
59
|
+
txs: transactions,
|
|
60
|
+
blockNumber: `0x${targetBlock.toString(16)}`,
|
|
61
|
+
minTimestamp: Math.floor(Date.now() / 1000),
|
|
62
|
+
maxTimestamp: Math.floor(Date.now() / 1000) + 30
|
|
63
|
+
}]
|
|
64
|
+
}, {
|
|
65
|
+
headers: {
|
|
66
|
+
'Content-Type': 'application/json',
|
|
67
|
+
'Authorization': this.authToken
|
|
68
|
+
},
|
|
69
|
+
timeout: 3000
|
|
70
|
+
});
|
|
71
|
+
if (response.data.error) {
|
|
72
|
+
throw new Error(`BloXroute Base Bundle Error: ${response.data.error.code} - ${response.data.error.message}`);
|
|
73
|
+
}
|
|
74
|
+
return response.data.result.bundleHash;
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
(0, dist_1.log_error)('BloXroute Base sendBundle failed!!!', error);
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.BloxrouteBase = BloxrouteBase;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DrpcBase = void 0;
|
|
16
|
+
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
17
|
+
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
class DrpcBase {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.endpoint = process.env.BASE_DRPC_RPC_ENDPOINT || '';
|
|
21
|
+
}
|
|
22
|
+
sendTransaction(signedTx) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
try {
|
|
25
|
+
const response = yield axios_1.default.post(this.endpoint, {
|
|
26
|
+
jsonrpc: '2.0',
|
|
27
|
+
method: 'eth_sendRawTransaction',
|
|
28
|
+
params: [signedTx],
|
|
29
|
+
id: 1
|
|
30
|
+
}, {
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json'
|
|
33
|
+
},
|
|
34
|
+
timeout: 3000
|
|
35
|
+
});
|
|
36
|
+
if (response.data.error) {
|
|
37
|
+
throw new Error(`DRPC RPC error: ${response.data.error.message}`);
|
|
38
|
+
}
|
|
39
|
+
return response.data.result;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
(0, dist_1.log_info)(`DRPC transaction sending failed`, { error: error.message });
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.DrpcBase = DrpcBase;
|
package/dist/trade/send/index.js
CHANGED
|
@@ -14,10 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.BASE_EOA_ADDRESS = void 0;
|
|
18
18
|
__exportStar(require("./send_tx"), exports);
|
|
19
|
-
var
|
|
20
|
-
(function (
|
|
21
|
-
|
|
22
|
-
BSC_EOA_ADDRESS["_48CLUB"] = "0x4848489f0b2BEdd788c696e2D79b6b69D7484848";
|
|
23
|
-
})(BSC_EOA_ADDRESS || (exports.BSC_EOA_ADDRESS = BSC_EOA_ADDRESS = {}));
|
|
19
|
+
var BASE_EOA_ADDRESS;
|
|
20
|
+
(function (BASE_EOA_ADDRESS) {
|
|
21
|
+
})(BASE_EOA_ADDRESS || (exports.BASE_EOA_ADDRESS = BASE_EOA_ADDRESS = {}));
|
|
@@ -0,0 +1,48 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.InfuraBase = void 0;
|
|
16
|
+
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
17
|
+
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
class InfuraBase {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.endpoint = process.env.BASE_INFURA_RPC_ENDPOINT || '';
|
|
21
|
+
}
|
|
22
|
+
sendTransaction(signedTx) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
try {
|
|
25
|
+
const response = yield axios_1.default.post(this.endpoint, {
|
|
26
|
+
jsonrpc: '2.0',
|
|
27
|
+
method: 'eth_sendRawTransaction',
|
|
28
|
+
params: [signedTx],
|
|
29
|
+
id: 1
|
|
30
|
+
}, {
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json'
|
|
33
|
+
},
|
|
34
|
+
timeout: 3000
|
|
35
|
+
});
|
|
36
|
+
if (response.data.error) {
|
|
37
|
+
throw new Error(`Infura RPC error: ${response.data.error.message}`);
|
|
38
|
+
}
|
|
39
|
+
return response.data.result;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
(0, dist_1.log_info)(`Infura transaction sending failed`, { error: error.message });
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.InfuraBase = InfuraBase;
|
|
@@ -0,0 +1,48 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.QuickNodeBase = void 0;
|
|
16
|
+
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
17
|
+
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
class QuickNodeBase {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.endpoint = process.env.BASE_QUICKNODE_RPC_ENDPOINT || '';
|
|
21
|
+
}
|
|
22
|
+
sendTransaction(signedTx) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
try {
|
|
25
|
+
const response = yield axios_1.default.post(this.endpoint, {
|
|
26
|
+
jsonrpc: "2.0",
|
|
27
|
+
id: "1",
|
|
28
|
+
method: "eth_sendRawTransaction",
|
|
29
|
+
params: [signedTx]
|
|
30
|
+
}, {
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json'
|
|
33
|
+
},
|
|
34
|
+
timeout: 3000
|
|
35
|
+
});
|
|
36
|
+
if (response.data.error) {
|
|
37
|
+
throw new Error(`QuickNode Base Error: ${response.data.error.code} - ${response.data.error.message}`);
|
|
38
|
+
}
|
|
39
|
+
return response.data.result;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
(0, dist_1.log_error)('QuickNode Base sendTransaction failed!!!', error);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.QuickNodeBase = QuickNodeBase;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { AppConfig } from "@clonegod/ttd-core/dist";
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class BaseTransactionSender {
|
|
3
3
|
private rpc;
|
|
4
|
-
private
|
|
5
|
-
private
|
|
4
|
+
private quicknode;
|
|
5
|
+
private bloxroute;
|
|
6
|
+
private alchemy;
|
|
7
|
+
private infura;
|
|
8
|
+
private drpc;
|
|
6
9
|
constructor(appConfig: AppConfig);
|
|
7
10
|
sendTransaction(signedMainTx: string, eoa_tip_transaction: (eoa_address: string) => Promise<string>, order_trace_id: string): Promise<string[]>;
|
|
8
11
|
}
|
|
@@ -9,56 +9,66 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.BaseTransactionSender = void 0;
|
|
13
13
|
const dist_1 = require("@clonegod/ttd-core/dist");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
14
|
+
const base_rpc_1 = require("./base_rpc");
|
|
15
|
+
const quicknode_base_1 = require("./quicknode_base");
|
|
16
|
+
const bloxroute_base_1 = require("./bloxroute_base");
|
|
17
|
+
const alchemy_base_1 = require("./alchemy_base");
|
|
18
|
+
const infura_base_1 = require("./infura_base");
|
|
19
|
+
const drpc_base_1 = require("./drpc_base");
|
|
20
|
+
class BaseTransactionSender {
|
|
19
21
|
constructor(appConfig) {
|
|
20
|
-
this.rpc = new
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
22
|
+
this.rpc = new base_rpc_1.BaseRpc(appConfig.env_args.rpc_endpoint);
|
|
23
|
+
this.quicknode = new quicknode_base_1.QuickNodeBase();
|
|
24
|
+
this.bloxroute = new bloxroute_base_1.BloxrouteBase();
|
|
25
|
+
this.alchemy = new alchemy_base_1.AlchemyBase();
|
|
26
|
+
this.infura = new infura_base_1.InfuraBase();
|
|
27
|
+
this.drpc = new drpc_base_1.DrpcBase();
|
|
23
28
|
}
|
|
24
29
|
sendTransaction(signedMainTx, eoa_tip_transaction, order_trace_id) {
|
|
25
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
31
|
const rpcProviders = [
|
|
27
32
|
{
|
|
28
|
-
name: '
|
|
29
|
-
enable: process.env.
|
|
33
|
+
name: 'Base Official RPC',
|
|
34
|
+
enable: process.env.SEND_TX_BASE_OFFICIAL_RPC === 'true' || true,
|
|
30
35
|
send: () => __awaiter(this, void 0, void 0, function* () {
|
|
31
36
|
return yield this.rpc.eth_sendRawTransaction(signedMainTx);
|
|
32
37
|
})
|
|
33
38
|
},
|
|
34
39
|
{
|
|
35
|
-
name: '
|
|
36
|
-
enable: process.env.
|
|
40
|
+
name: 'Base QuickNode RPC',
|
|
41
|
+
enable: process.env.SEND_TX_BASE_QUICKNODE_RPC === 'true',
|
|
37
42
|
send: () => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
return yield this.
|
|
43
|
+
return yield this.quicknode.sendTransaction(signedMainTx);
|
|
39
44
|
})
|
|
40
45
|
},
|
|
41
46
|
{
|
|
42
|
-
name: '
|
|
43
|
-
enable: process.env.
|
|
47
|
+
name: 'Base DRPC RPC',
|
|
48
|
+
enable: process.env.SEND_TX_BASE_DRPC_RPC === 'true',
|
|
44
49
|
send: () => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
|
|
46
|
-
return yield this.blockRazor.sendBundle(bundle);
|
|
50
|
+
return yield this.drpc.sendTransaction(signedMainTx);
|
|
47
51
|
})
|
|
48
52
|
},
|
|
49
53
|
{
|
|
50
|
-
name: '
|
|
51
|
-
enable: process.env.
|
|
54
|
+
name: 'Base Alchemy RPC',
|
|
55
|
+
enable: process.env.SEND_TX_BASE_ALCHEMY_RPC === 'true',
|
|
52
56
|
send: () => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
return yield this.
|
|
57
|
+
return yield this.alchemy.sendTransaction(signedMainTx);
|
|
54
58
|
})
|
|
55
59
|
},
|
|
56
60
|
{
|
|
57
|
-
name: '
|
|
58
|
-
enable: process.env.
|
|
61
|
+
name: 'Base Infura RPC',
|
|
62
|
+
enable: process.env.SEND_TX_BASE_INFURA_RPC === 'true',
|
|
59
63
|
send: () => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
return yield this.infura.sendTransaction(signedMainTx);
|
|
65
|
+
})
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'BloXroute - Private Transaction',
|
|
69
|
+
enable: process.env.SEND_TX_BLOXROUTE_PRIVATE === 'true',
|
|
70
|
+
send: () => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
return yield this.bloxroute.sendPrivateTransaction(signedMainTx);
|
|
62
72
|
})
|
|
63
73
|
}
|
|
64
74
|
];
|
|
@@ -68,24 +78,32 @@ class TransactionSender {
|
|
|
68
78
|
try {
|
|
69
79
|
const txHash = yield provider.send();
|
|
70
80
|
results.push(txHash);
|
|
71
|
-
(0, dist_1.log_info)(`
|
|
81
|
+
(0, dist_1.log_info)(`Base transaction sent successfully`, {
|
|
82
|
+
provider: provider.name,
|
|
83
|
+
order_trace_id,
|
|
84
|
+
txHash
|
|
85
|
+
});
|
|
72
86
|
}
|
|
73
87
|
catch (error) {
|
|
74
88
|
errors.push(`${provider.name}: ${error.message}`);
|
|
75
|
-
(0, dist_1.log_info)(`
|
|
89
|
+
(0, dist_1.log_info)(`Base transaction sending failed`, {
|
|
90
|
+
provider: provider.name,
|
|
91
|
+
order_trace_id,
|
|
92
|
+
error: error.message
|
|
93
|
+
});
|
|
76
94
|
}
|
|
77
95
|
})));
|
|
78
96
|
if (errors.some(error => error.includes('nonce'))) {
|
|
79
|
-
throw new Error(`!!!!!! Some RPC providers returned nonce error: ${JSON.stringify(errors)}`);
|
|
97
|
+
throw new Error(`!!!!!! Some Base RPC providers returned nonce error: ${JSON.stringify(errors)}`);
|
|
80
98
|
}
|
|
81
|
-
if (errors.some(error => error.includes('
|
|
99
|
+
if (errors.some(error => error.includes('already known') || error.includes('already exist'))) {
|
|
82
100
|
return results;
|
|
83
101
|
}
|
|
84
102
|
if (results.length === 0 || errors.length > 0) {
|
|
85
|
-
throw new Error(`!!!!!! Some RPC providers failed to send transactions: ${JSON.stringify(errors)}`);
|
|
103
|
+
throw new Error(`!!!!!! Some Base RPC providers failed to send transactions: ${JSON.stringify(errors)}`);
|
|
86
104
|
}
|
|
87
105
|
return results;
|
|
88
106
|
});
|
|
89
107
|
}
|
|
90
108
|
}
|
|
91
|
-
exports.
|
|
109
|
+
exports.BaseTransactionSender = BaseTransactionSender;
|