@steerprotocol/data-connector-loader 3.1.0 → 3.2.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/README.md +30 -1
- package/lib/bundle/bundleBase.d.ts +10 -5
- package/lib/bundle/bundleBase.js +65 -11
- package/lib/bundle/bundleDataConnector.d.ts +11 -4
- package/lib/bundle/bundleDataConnector.js +49 -13
- package/lib/esm/bundle/bundleBase.d.ts +10 -5
- package/lib/esm/bundle/bundleBase.js +60 -11
- package/lib/esm/bundle/bundleDataConnector.d.ts +11 -4
- package/lib/esm/bundle/bundleDataConnector.js +46 -11
- package/lib/esm/execution/executionApp.d.ts +52 -7
- package/lib/esm/execution/executionApp.js +557 -113
- package/lib/esm/execution/executionBase.d.ts +4 -4
- package/lib/esm/execution/executionBase.js +11 -12
- package/lib/esm/execution/executionDataConnector.d.ts +4 -2
- package/lib/esm/execution/executionDataConnector.js +56 -25
- package/lib/esm/index.d.ts +6 -4
- package/lib/esm/index.js +3 -4
- package/lib/esm/types.d.ts +17 -4
- package/lib/esm/utils/blockFinder.d.ts +1 -1
- package/lib/esm/utils/consts.js +43 -1
- package/lib/esm/utils/pluginManager.d.ts +1 -1
- package/lib/esm/utils/providerUtils.d.ts +4 -0
- package/lib/esm/utils/providerUtils.js +37 -0
- package/lib/esm/utils/replace-old-subgraphs.d.ts +23 -0
- package/lib/esm/utils/replace-old-subgraphs.js +123 -0
- package/lib/esm/utils/utils.d.ts +7 -6
- package/lib/esm/utils/utils.js +8 -9
- package/lib/execution/executionApp.d.ts +52 -7
- package/lib/execution/executionApp.js +556 -117
- package/lib/execution/executionBase.d.ts +4 -4
- package/lib/execution/executionBase.js +11 -12
- package/lib/execution/executionDataConnector.d.ts +4 -2
- package/lib/execution/executionDataConnector.js +61 -29
- package/lib/index.d.ts +6 -4
- package/lib/index.js +6 -21
- package/lib/types.d.ts +17 -4
- package/lib/utils/blockFinder.d.ts +1 -1
- package/lib/utils/consts.js +43 -1
- package/lib/utils/pluginManager.d.ts +1 -1
- package/lib/utils/providerUtils.d.ts +4 -0
- package/lib/utils/providerUtils.js +43 -0
- package/lib/utils/replace-old-subgraphs.d.ts +23 -0
- package/lib/utils/replace-old-subgraphs.js +129 -0
- package/lib/utils/utils.d.ts +7 -6
- package/lib/utils/utils.js +15 -16
- package/package.json +13 -4
package/lib/utils/utils.js
CHANGED
|
@@ -12,10 +12,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.callWithRetry = exports.
|
|
15
|
+
exports.callWithRetry = exports.readContract = exports.fetchData = exports.extendOHLCV = void 0;
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
const ethers_1 = require("ethers");
|
|
18
|
-
const
|
|
18
|
+
const consts_js_1 = require("./consts.js");
|
|
19
19
|
// The purpose of this function is to look at the end timestamp and extend the current candle array so that it backfills any missing candles up to the end timestamp
|
|
20
20
|
const extendOHLCV = (rawData, period, endTimestamp) => {
|
|
21
21
|
// Sort rawData by timestamp
|
|
@@ -82,31 +82,31 @@ function fetchData(request, attempts) {
|
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
exports.fetchData = fetchData;
|
|
85
|
-
function
|
|
85
|
+
function readContract({ abi, address, chainId, contractArguments = [], currentExecutionContext, functionName, provider, rpc, }) {
|
|
86
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
87
|
// Create a new contract instance
|
|
88
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
88
|
if (!provider)
|
|
90
89
|
throw new Error('Provider not initialized');
|
|
91
90
|
const contract = new ethers_1.Contract(address, abi, provider);
|
|
92
91
|
// For formatting the parameters if needed
|
|
93
|
-
const paramsArray = [];
|
|
92
|
+
const paramsArray = contractArguments || [];
|
|
94
93
|
// Calculate block number for determinism
|
|
95
94
|
// Best way to handle contextually non-null values?
|
|
96
95
|
// const syncedBlock = await getBlockFromTimestamp(this.executionContext!.epochTimestamp, this.providerIdentity!) //@note uncomment for deterministic blocks
|
|
97
96
|
// Call the desired method with the specified arguments at synced block
|
|
98
97
|
// , {blockTag: syncedBlock}
|
|
99
98
|
let result;
|
|
100
|
-
if (
|
|
99
|
+
if (consts_js_1.CENTRALIZE_CONTRACT_INTERACTION_CHAINS.indexOf(chainId.toString()) === -1) {
|
|
101
100
|
result = yield contract[functionName](...paramsArray, {
|
|
102
101
|
blockTag: currentExecutionContext === null || currentExecutionContext === void 0 ? void 0 : currentExecutionContext.blockNumber,
|
|
103
|
-
});
|
|
102
|
+
}); // @note uncomment for deterministic blocks
|
|
104
103
|
}
|
|
105
104
|
else {
|
|
105
|
+
console.log('Calling the centralized view');
|
|
106
106
|
const viewContractConfig = {
|
|
107
107
|
epochTimestamp: currentExecutionContext.epochTimestamp,
|
|
108
|
-
address
|
|
109
|
-
abi
|
|
108
|
+
address,
|
|
109
|
+
abi,
|
|
110
110
|
arguments: paramsArray,
|
|
111
111
|
method: functionName,
|
|
112
112
|
rpcUrl: rpc,
|
|
@@ -117,28 +117,27 @@ function readSlot0Contract({ address, abi, currentExecutionContext, functionName
|
|
|
117
117
|
return result;
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
exports.
|
|
120
|
+
exports.readContract = readContract;
|
|
121
121
|
function callWithRetry(config) {
|
|
122
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
123
|
let retries = 0;
|
|
124
|
-
let delay =
|
|
125
|
-
while (retries <
|
|
124
|
+
let delay = consts_js_1.API_INITIAL_DELAY;
|
|
125
|
+
while (retries < consts_js_1.API_MAX_RETRIES) {
|
|
126
126
|
try {
|
|
127
|
-
const response = yield axios_1.default.post(
|
|
127
|
+
const response = yield axios_1.default.post(consts_js_1.API_BASE_URL, config);
|
|
128
128
|
return JSON.parse(response.data); // Return the data if the call was successful
|
|
129
129
|
}
|
|
130
130
|
catch (error) {
|
|
131
|
-
console.error(`Attempt ${retries + 1} failed. Retrying in to fetch the contract method ${config.method} ${delay / 1000} seconds
|
|
131
|
+
console.error(`Attempt ${retries + 1} failed. Retrying in to fetch the contract method ${config.method} ${delay / 1000} seconds...`, error);
|
|
132
132
|
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
133
133
|
delay *= 2; // Double the delay for the next retry
|
|
134
134
|
retries++;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
throw new Error(`Failed after ${
|
|
137
|
+
throw new Error(`Failed after ${consts_js_1.API_MAX_RETRIES} attempts. to call method ${config.method}`);
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
exports.callWithRetry = callWithRetry;
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
142
141
|
function log(...args) {
|
|
143
142
|
if (process.env.DEBUG === 'true') {
|
|
144
143
|
console.log(...args);
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steerprotocol/data-connector-loader",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "App Loader for Steer Protocol",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "lib/index.js",
|
|
6
7
|
"module": "lib/esm/index.js",
|
|
7
8
|
"types": "lib/index.d.ts",
|
|
@@ -20,7 +21,10 @@
|
|
|
20
21
|
"format": "prettier --write \"src/**/*.(js|ts)\"",
|
|
21
22
|
"lint": "eslint src --ext .js,.ts",
|
|
22
23
|
"lint:fix": "eslint src --fix --ext .js,.ts",
|
|
23
|
-
"test": "jest --config jest.config.
|
|
24
|
+
"test": "jest --config jest.config.cjs",
|
|
25
|
+
"pack:local": "npm pack",
|
|
26
|
+
"publish:test": "node scripts/publish-test.cjs",
|
|
27
|
+
"postinstall": "node scripts/fix-node-modules.js",
|
|
24
28
|
"prepare": "npm run build",
|
|
25
29
|
"prepublishOnly": "npm test && npm run lint",
|
|
26
30
|
"preversion": "npm run lint",
|
|
@@ -63,6 +67,9 @@
|
|
|
63
67
|
"@types/jest": "29.2.4",
|
|
64
68
|
"@typescript-eslint/eslint-plugin": "5.46.0",
|
|
65
69
|
"@typescript-eslint/parser": "5.47.1",
|
|
70
|
+
"@uniswap/sdk-core": "^7.10.0",
|
|
71
|
+
"@uniswap/v2-sdk": "^4.16.0",
|
|
72
|
+
"@uniswap/v3-sdk": "^3.26.0",
|
|
66
73
|
"date-fns": "^2.29.3",
|
|
67
74
|
"eslint": "8.30.0",
|
|
68
75
|
"eslint-plugin-jest": "27.1.7",
|
|
@@ -70,13 +77,15 @@
|
|
|
70
77
|
"prettier": "2.8.1",
|
|
71
78
|
"semantic-release": "^24.2.9",
|
|
72
79
|
"ts-jest": "29.0.3",
|
|
73
|
-
"typescript": "
|
|
80
|
+
"typescript": "5.0.4",
|
|
81
|
+
"viem": "^2.42.1"
|
|
74
82
|
},
|
|
75
83
|
"files": [
|
|
76
84
|
"lib/**/*"
|
|
77
85
|
],
|
|
78
86
|
"dependencies": {
|
|
79
|
-
"@steerprotocol/
|
|
87
|
+
"@steerprotocol/sdk": "^1.28.0",
|
|
88
|
+
"@steerprotocol/app-loader": "^2.1.1",
|
|
80
89
|
"@steerprotocol/strategy-utils": "^3.1.2",
|
|
81
90
|
"axios": "^1.3.4",
|
|
82
91
|
"ethers": "^6.16.0",
|