@defillama/sdk 3.0.16 → 3.0.18
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/build/ChainApi.d.ts +19 -0
- package/build/ChainApi.js +91 -0
- package/build/abi/abi2.d.ts +1 -13
- package/build/abi/abi2.js +1 -18
- package/build/abi/index.js +5 -2
- package/build/general.js +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Block, CallOptions, MulticallOptions, FetchListOptions } from "./types";
|
|
2
|
+
import { Chain } from "./general";
|
|
3
|
+
import { ethers } from "ethers";
|
|
4
|
+
export declare class ChainApi {
|
|
5
|
+
block?: Block;
|
|
6
|
+
chain?: Chain | string;
|
|
7
|
+
timestamp?: number;
|
|
8
|
+
provider: ethers.providers.BaseProvider;
|
|
9
|
+
constructor(params: {
|
|
10
|
+
block?: Block;
|
|
11
|
+
chain?: Chain | string;
|
|
12
|
+
timestamp?: number;
|
|
13
|
+
});
|
|
14
|
+
call(params: CallOptions): Promise<any>;
|
|
15
|
+
multiCall(params: MulticallOptions): Promise<any[]>;
|
|
16
|
+
fetchList(params: FetchListOptions): Promise<any[]>;
|
|
17
|
+
getBlock(): Promise<number>;
|
|
18
|
+
}
|
|
19
|
+
export default ChainApi;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.ChainApi = void 0;
|
|
51
|
+
var general_1 = require("./general");
|
|
52
|
+
var abi2_1 = require("./abi/abi2");
|
|
53
|
+
var blocks_1 = require("./computeTVL/blocks");
|
|
54
|
+
var ChainApi = /** @class */ (function () {
|
|
55
|
+
function ChainApi(params) {
|
|
56
|
+
var _a;
|
|
57
|
+
this.block = params.block;
|
|
58
|
+
this.chain = (_a = params.chain) !== null && _a !== void 0 ? _a : 'ethereum';
|
|
59
|
+
this.timestamp = params.timestamp;
|
|
60
|
+
this.provider = (0, general_1.getProvider)(this.chain);
|
|
61
|
+
}
|
|
62
|
+
ChainApi.prototype.call = function (params) {
|
|
63
|
+
return (0, abi2_1.call)(__assign(__assign({}, params), { block: this.block, chain: this.chain }));
|
|
64
|
+
};
|
|
65
|
+
ChainApi.prototype.multiCall = function (params) {
|
|
66
|
+
return (0, abi2_1.multiCall)(__assign(__assign({}, params), { block: this.block, chain: this.chain }));
|
|
67
|
+
};
|
|
68
|
+
ChainApi.prototype.fetchList = function (params) {
|
|
69
|
+
return (0, abi2_1.fetchList)(__assign(__assign({}, params), { block: this.block, chain: this.chain }));
|
|
70
|
+
};
|
|
71
|
+
ChainApi.prototype.getBlock = function () {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
var _a;
|
|
74
|
+
return __generator(this, function (_b) {
|
|
75
|
+
switch (_b.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
if (!!this.block) return [3 /*break*/, 2];
|
|
78
|
+
_a = this;
|
|
79
|
+
return [4 /*yield*/, (0, blocks_1.getBlock)(this.chain, this.timestamp)];
|
|
80
|
+
case 1:
|
|
81
|
+
_a.block = (_b.sent()).block;
|
|
82
|
+
_b.label = 2;
|
|
83
|
+
case 2: return [2 /*return*/, this.block];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
return ChainApi;
|
|
89
|
+
}());
|
|
90
|
+
exports.ChainApi = ChainApi;
|
|
91
|
+
exports.default = ChainApi;
|
package/build/abi/abi2.d.ts
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Chain } from "../general";
|
|
3
|
-
export declare class ChainApi {
|
|
4
|
-
block?: Block;
|
|
5
|
-
chain?: Chain | string;
|
|
6
|
-
constructor(params: {
|
|
7
|
-
block?: Block;
|
|
8
|
-
chain?: Chain | string;
|
|
9
|
-
});
|
|
10
|
-
call(params: CallOptions): Promise<any>;
|
|
11
|
-
multiCall(params: MulticallOptions): Promise<any[]>;
|
|
12
|
-
fetchList(params: FetchListOptions): Promise<any[]>;
|
|
13
|
-
}
|
|
1
|
+
import { CallOptions, MulticallOptions, FetchListOptions } from "../types";
|
|
14
2
|
export declare function call(params: CallOptions): Promise<any>;
|
|
15
3
|
export declare function multiCall(params: MulticallOptions): Promise<any[]>;
|
|
16
4
|
export declare function fetchList(params: FetchListOptions): Promise<any[]>;
|
package/build/abi/abi2.js
CHANGED
|
@@ -81,26 +81,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
81
81
|
return t;
|
|
82
82
|
};
|
|
83
83
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
84
|
-
exports.fetchList = exports.multiCall = exports.call =
|
|
84
|
+
exports.fetchList = exports.multiCall = exports.call = void 0;
|
|
85
85
|
var abi1 = __importStar(require("./index"));
|
|
86
86
|
var debugLog_1 = require("../util/debugLog");
|
|
87
|
-
var ChainApi = /** @class */ (function () {
|
|
88
|
-
function ChainApi(params) {
|
|
89
|
-
this.block = params.block;
|
|
90
|
-
this.chain = params.chain;
|
|
91
|
-
}
|
|
92
|
-
ChainApi.prototype.call = function (params) {
|
|
93
|
-
return call(__assign(__assign({}, params), { block: this.block, chain: this.chain }));
|
|
94
|
-
};
|
|
95
|
-
ChainApi.prototype.multiCall = function (params) {
|
|
96
|
-
return multiCall(__assign(__assign({}, params), { block: this.block, chain: this.chain }));
|
|
97
|
-
};
|
|
98
|
-
ChainApi.prototype.fetchList = function (params) {
|
|
99
|
-
return fetchList(__assign(__assign({}, params), { block: this.block, chain: this.chain }));
|
|
100
|
-
};
|
|
101
|
-
return ChainApi;
|
|
102
|
-
}());
|
|
103
|
-
exports.ChainApi = ChainApi;
|
|
104
87
|
function call(params) {
|
|
105
88
|
return __awaiter(this, void 0, void 0, function () {
|
|
106
89
|
var response;
|
package/build/abi/index.js
CHANGED
|
@@ -71,8 +71,11 @@ function resolveABI(providedAbi) {
|
|
|
71
71
|
abi = cachedABIs_1.default[abi];
|
|
72
72
|
if (abi === undefined) {
|
|
73
73
|
var _a = providedAbi.split(':'), outputType = _a[0], name_1 = _a[1];
|
|
74
|
-
if (!knownTypes.includes(outputType) || !name_1)
|
|
75
|
-
|
|
74
|
+
if (!knownTypes.includes(outputType) || !name_1) {
|
|
75
|
+
var contractInterface = new ethers_1.ethers.utils.Interface([providedAbi]);
|
|
76
|
+
var jsonAbi = contractInterface.format(ethers_1.ethers.utils.FormatTypes.json);
|
|
77
|
+
return JSON.parse(jsonAbi)[0];
|
|
78
|
+
}
|
|
76
79
|
abi = {
|
|
77
80
|
constant: true,
|
|
78
81
|
inputs: [],
|
package/build/general.js
CHANGED
|
@@ -124,7 +124,7 @@ exports.providers = {
|
|
|
124
124
|
canto: createProvider("canto", "https://jsonrpc.canto.nodestake.top,https://canto.evm.chandrastation.com/", 7700),
|
|
125
125
|
dogechain: createProvider("dogechain", "https://dogechain-sj.ankr.com,https://dogechain.ankr.com,https://rpc.dogechain.dog,https://rpc01-sg.dogechain.dog,https://rpc02-sg.dogechain.dog,https://rpc03-sg.dogechain.dog", 2000),
|
|
126
126
|
posi: createProvider("posi", "https://api.posichain.org,https://api.s0.posichain.org", 900000),
|
|
127
|
-
arbitrum_nova: createProvider("
|
|
127
|
+
arbitrum_nova: createProvider("arbitrum_nova", "https://nova.arbitrum.io/rpc", 42170),
|
|
128
128
|
ultron: createProvider("ultron", "https://ultron-rpc.net", 1231),
|
|
129
129
|
tombchain: createProvider("tombchain", "https://rpc.tombchain.com/", 6969),
|
|
130
130
|
vision: createProvider("vision", "https://infragrid.v.network/ethereum/compatible", 888888),
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -23,8 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.humanizeNumber = exports.log = exports.blocks = exports.api2 = exports.api = exports.util = void 0;
|
|
26
|
+
exports.humanizeNumber = exports.log = exports.blocks = exports.api2 = exports.api = exports.util = exports.ChainApi = void 0;
|
|
27
27
|
var debugLog_1 = require("./util/debugLog");
|
|
28
|
+
var ChainApi_1 = require("./ChainApi");
|
|
29
|
+
Object.defineProperty(exports, "ChainApi", { enumerable: true, get: function () { return ChainApi_1.ChainApi; } });
|
|
28
30
|
exports.util = __importStar(require("./generalUtil"));
|
|
29
31
|
exports.api = __importStar(require("./api"));
|
|
30
32
|
exports.api2 = __importStar(require("./api2"));
|