@avail-project/ca-common 2.2.1 → 3.0.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/dist/cjs/index.js +10593 -20
- package/dist/esm/index.mjs +10603 -0
- package/dist/types/index.d.ts +2608 -13
- package/package.json +41 -37
- package/dist/cjs/_polyfill.js +0 -147
- package/dist/cjs/balances/ub-api.js +0 -25
- package/dist/cjs/cosmos/index.js +0 -31
- package/dist/cjs/data/chaindata.js +0 -788
- package/dist/cjs/data/chainid.js +0 -93
- package/dist/cjs/data/currency.js +0 -78
- package/dist/cjs/data/index.js +0 -7
- package/dist/cjs/data/utils.js +0 -44
- package/dist/cjs/evmabi/erc20.abi.js +0 -349
- package/dist/cjs/evmabi/fibrousrouter.abi.js +0 -41
- package/dist/cjs/evmabi/index.js +0 -7
- package/dist/cjs/evmabi/vault.abi.js +0 -1021
- package/dist/cjs/evmabi/yakaggregator.abi.js +0 -275
- package/dist/cjs/permitutils/index.js +0 -186
- package/dist/cjs/proto/client.js +0 -48
- package/dist/cjs/proto/definition.js +0 -4131
- package/dist/cjs/proto/grpc.js +0 -298
- package/dist/cjs/rff/rff.js +0 -42
- package/dist/cjs/types/binarytypes.js +0 -2
- package/dist/cjs/types/index.js +0 -5
- package/dist/cjs/types/msgpack-axios.js +0 -22
- package/dist/cjs/vaultcontracts/index.js +0 -4
- package/dist/cjs/vaultcontracts/vaultcontracts.js +0 -222
- package/dist/cjs/xcs/autochoice.js +0 -570
- package/dist/cjs/xcs/bebop-agg.js +0 -156
- package/dist/cjs/xcs/fibrous-agg.js +0 -155
- package/dist/cjs/xcs/iface.js +0 -13
- package/dist/cjs/xcs/index.js +0 -8
- package/dist/cjs/xcs/lifi-agg.js +0 -155
- package/dist/esm/_polyfill.js +0 -143
- package/dist/esm/balances/ub-api.js +0 -21
- package/dist/esm/cosmos/index.js +0 -26
- package/dist/esm/data/chaindata.js +0 -785
- package/dist/esm/data/chainid.js +0 -87
- package/dist/esm/data/currency.js +0 -73
- package/dist/esm/data/index.js +0 -4
- package/dist/esm/data/utils.js +0 -34
- package/dist/esm/evmabi/erc20.abi.js +0 -346
- package/dist/esm/evmabi/fibrousrouter.abi.js +0 -38
- package/dist/esm/evmabi/index.js +0 -4
- package/dist/esm/evmabi/vault.abi.js +0 -1018
- package/dist/esm/evmabi/yakaggregator.abi.js +0 -272
- package/dist/esm/index.js +0 -13
- package/dist/esm/permitutils/index.js +0 -181
- package/dist/esm/proto/client.js +0 -11
- package/dist/esm/proto/definition.js +0 -4122
- package/dist/esm/proto/grpc.js +0 -292
- package/dist/esm/rff/rff.js +0 -38
- package/dist/esm/types/binarytypes.js +0 -1
- package/dist/esm/types/index.js +0 -2
- package/dist/esm/types/msgpack-axios.js +0 -18
- package/dist/esm/vaultcontracts/index.js +0 -1
- package/dist/esm/vaultcontracts/vaultcontracts.js +0 -218
- package/dist/esm/xcs/autochoice.js +0 -554
- package/dist/esm/xcs/bebop-agg.js +0 -151
- package/dist/esm/xcs/fibrous-agg.js +0 -150
- package/dist/esm/xcs/iface.js +0 -10
- package/dist/esm/xcs/index.js +0 -5
- package/dist/esm/xcs/lifi-agg.js +0 -150
- package/dist/types/_polyfill.d.ts +0 -1
- package/dist/types/balances/ub-api.d.ts +0 -14
- package/dist/types/cosmos/index.d.ts +0 -6
- package/dist/types/data/chaindata.d.ts +0 -20
- package/dist/types/data/chainid.d.ts +0 -31
- package/dist/types/data/currency.d.ts +0 -30
- package/dist/types/data/index.d.ts +0 -4
- package/dist/types/data/utils.d.ts +0 -10
- package/dist/types/evmabi/erc20.abi.d.ts +0 -264
- package/dist/types/evmabi/fibrousrouter.abi.d.ts +0 -77
- package/dist/types/evmabi/index.d.ts +0 -4
- package/dist/types/evmabi/vault.abi.d.ts +0 -785
- package/dist/types/evmabi/yakaggregator.abi.d.ts +0 -298
- package/dist/types/permitutils/index.d.ts +0 -13
- package/dist/types/proto/client.d.ts +0 -2
- package/dist/types/proto/definition.d.ts +0 -382
- package/dist/types/proto/grpc.d.ts +0 -75
- package/dist/types/rff/rff.d.ts +0 -9
- package/dist/types/types/binarytypes.d.ts +0 -1
- package/dist/types/types/index.d.ts +0 -2
- package/dist/types/types/msgpack-axios.d.ts +0 -1
- package/dist/types/vaultcontracts/index.d.ts +0 -22
- package/dist/types/vaultcontracts/vaultcontracts.d.ts +0 -8
- package/dist/types/xcs/autochoice.d.ts +0 -105
- package/dist/types/xcs/bebop-agg.d.ts +0 -104
- package/dist/types/xcs/fibrous-agg.d.ts +0 -56
- package/dist/types/xcs/iface.d.ts +0 -69
- package/dist/types/xcs/index.d.ts +0 -5
- package/dist/types/xcs/lifi-agg.d.ts +0 -39
package/package.json
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avail-project/ca-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "common utilities for CA",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
7
7
|
],
|
|
8
|
-
"sideEffects":
|
|
9
|
-
"./src/_polyfill.ts",
|
|
10
|
-
"./dist/esm/_polyfill.js",
|
|
11
|
-
"./dist/cjs/_polyfill.js"
|
|
12
|
-
],
|
|
8
|
+
"sideEffects": false,
|
|
13
9
|
"exports": {
|
|
14
10
|
".": {
|
|
15
11
|
"types": "./dist/types/index.d.ts",
|
|
16
12
|
"require": "./dist/cjs/index.js",
|
|
17
|
-
"import": "./dist/esm/index.
|
|
13
|
+
"import": "./dist/esm/index.mjs"
|
|
18
14
|
}
|
|
19
15
|
},
|
|
20
16
|
"scripts": {
|
|
21
|
-
"build": "run
|
|
22
|
-
"
|
|
23
|
-
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
24
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
17
|
+
"build": "npm run clean && tsup",
|
|
18
|
+
"test": "npm run build && node --test test/*.test.cjs",
|
|
25
19
|
"lint": "eslint",
|
|
26
20
|
"clean": "rimraf dist/",
|
|
27
21
|
"prepublishOnly": "npm run build",
|
|
@@ -31,37 +25,47 @@
|
|
|
31
25
|
"author": "",
|
|
32
26
|
"license": "MIT",
|
|
33
27
|
"devDependencies": {
|
|
34
|
-
"@eslint/eslintrc": "
|
|
35
|
-
"@eslint/js": "
|
|
36
|
-
"@types/node": "
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "
|
|
38
|
-
"@typescript-eslint/parser": "
|
|
39
|
-
"eslint": "
|
|
40
|
-
"eslint-config-prettier": "
|
|
41
|
-
"globals": "
|
|
42
|
-
"npm-run-all": "
|
|
43
|
-
"prettier": "
|
|
44
|
-
"release-it": "
|
|
45
|
-
"rimraf": "
|
|
46
|
-
"ts-proto": "
|
|
47
|
-
"
|
|
28
|
+
"@eslint/eslintrc": "3.3.5",
|
|
29
|
+
"@eslint/js": "9.39.4",
|
|
30
|
+
"@types/node": "22.19.19",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "8.60.0",
|
|
32
|
+
"@typescript-eslint/parser": "8.60.0",
|
|
33
|
+
"eslint": "9.39.4",
|
|
34
|
+
"eslint-config-prettier": "10.1.8",
|
|
35
|
+
"globals": "16.5.0",
|
|
36
|
+
"npm-run-all": "4.1.5",
|
|
37
|
+
"prettier": "3.8.3",
|
|
38
|
+
"release-it": "20.0.1",
|
|
39
|
+
"rimraf": "6.1.3",
|
|
40
|
+
"ts-proto": "2.11.8",
|
|
41
|
+
"tsup": "^8.5.1",
|
|
42
|
+
"typescript": "5.9.3"
|
|
48
43
|
},
|
|
49
44
|
"peerDependencies": {
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"msgpackr": "^1.11.4",
|
|
56
|
-
"viem": "^2.31.7"
|
|
45
|
+
"axios": "1.16.1",
|
|
46
|
+
"decimal.js": "10.6.0",
|
|
47
|
+
"long": "5.3.2",
|
|
48
|
+
"msgpackr": "2.0.2",
|
|
49
|
+
"viem": "2.51.0"
|
|
57
50
|
},
|
|
58
51
|
"dependencies": {
|
|
59
|
-
"@bufbuild/protobuf": "
|
|
60
|
-
"@improbable-eng/grpc-web": "
|
|
52
|
+
"@bufbuild/protobuf": "2.12.0",
|
|
53
|
+
"@improbable-eng/grpc-web": "0.15.0",
|
|
61
54
|
"@improbable-eng/grpc-web-node-http-transport": "0.15.0",
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
55
|
+
"@noble/curves": "1.9.1",
|
|
56
|
+
"@noble/hashes": "1.8.0",
|
|
57
|
+
"@scure/base": "1.2.6",
|
|
58
|
+
"browser-headers": "0.4.1",
|
|
59
|
+
"es-toolkit": "1.47.0",
|
|
60
|
+
"tslib": "2.8.1"
|
|
61
|
+
},
|
|
62
|
+
"overrides": {
|
|
63
|
+
"bn.js": "5.2.3",
|
|
64
|
+
"flatted": "3.4.2",
|
|
65
|
+
"picomatch": "4.0.4",
|
|
66
|
+
"minimatch@3": {
|
|
67
|
+
"brace-expansion": "1.1.15"
|
|
68
|
+
}
|
|
65
69
|
},
|
|
66
70
|
"publishConfig": {
|
|
67
71
|
"provenance": true
|
package/dist/cjs/_polyfill.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureBufferPolyfill = ensureBufferPolyfill;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const bufferModule = tslib_1.__importStar(require("buffer"));
|
|
6
|
-
const buffer_1 = require("buffer");
|
|
7
|
-
const globalScope = globalThis;
|
|
8
|
-
let patched = false;
|
|
9
|
-
function collectBufferCtors() {
|
|
10
|
-
const candidates = new Set();
|
|
11
|
-
if (typeof buffer_1.Buffer === "function") {
|
|
12
|
-
candidates.add(buffer_1.Buffer);
|
|
13
|
-
}
|
|
14
|
-
const mod = bufferModule;
|
|
15
|
-
if (typeof mod?.Buffer === "function") {
|
|
16
|
-
candidates.add(mod.Buffer);
|
|
17
|
-
}
|
|
18
|
-
const defaultExport = mod?.default;
|
|
19
|
-
if (typeof defaultExport === "function") {
|
|
20
|
-
candidates.add(defaultExport);
|
|
21
|
-
}
|
|
22
|
-
else if (defaultExport &&
|
|
23
|
-
typeof defaultExport === "object" &&
|
|
24
|
-
typeof defaultExport.Buffer === "function") {
|
|
25
|
-
candidates.add(defaultExport.Buffer);
|
|
26
|
-
}
|
|
27
|
-
if (typeof globalScope.Buffer === "function") {
|
|
28
|
-
candidates.add(globalScope.Buffer);
|
|
29
|
-
}
|
|
30
|
-
return Array.from(candidates);
|
|
31
|
-
}
|
|
32
|
-
function assertOffset(buffer, offset) {
|
|
33
|
-
const numericOffset = Number(offset);
|
|
34
|
-
if (!Number.isFinite(numericOffset)) {
|
|
35
|
-
throw new TypeError("Offset must be a finite number");
|
|
36
|
-
}
|
|
37
|
-
const normalized = numericOffset >>> 0;
|
|
38
|
-
if (normalized !== numericOffset) {
|
|
39
|
-
throw new RangeError("Offset must be a non-negative integer");
|
|
40
|
-
}
|
|
41
|
-
if (normalized + 4 > buffer.length) {
|
|
42
|
-
throw new RangeError("Offset out of bounds");
|
|
43
|
-
}
|
|
44
|
-
return normalized;
|
|
45
|
-
}
|
|
46
|
-
function fallbackWriteUint32BE(value, offset = 0) {
|
|
47
|
-
const o = assertOffset(this, offset);
|
|
48
|
-
const normalized = Number(value) >>> 0;
|
|
49
|
-
this[o] = (normalized >>> 24) & 0xff;
|
|
50
|
-
this[o + 1] =
|
|
51
|
-
(normalized >>> 16) & 0xff;
|
|
52
|
-
this[o + 2] =
|
|
53
|
-
(normalized >>> 8) & 0xff;
|
|
54
|
-
this[o + 3] = normalized & 0xff;
|
|
55
|
-
return o + 4;
|
|
56
|
-
}
|
|
57
|
-
function fallbackWriteUint32LE(value, offset = 0) {
|
|
58
|
-
const o = assertOffset(this, offset);
|
|
59
|
-
const normalized = Number(value) >>> 0;
|
|
60
|
-
this[o] = normalized & 0xff;
|
|
61
|
-
this[o + 1] =
|
|
62
|
-
(normalized >>> 8) & 0xff;
|
|
63
|
-
this[o + 2] =
|
|
64
|
-
(normalized >>> 16) & 0xff;
|
|
65
|
-
this[o + 3] =
|
|
66
|
-
(normalized >>> 24) & 0xff;
|
|
67
|
-
return o + 4;
|
|
68
|
-
}
|
|
69
|
-
function fallbackReadUint32BE(offset = 0) {
|
|
70
|
-
const o = assertOffset(this, offset);
|
|
71
|
-
const store = this;
|
|
72
|
-
return ((store[o] * 0x1000000 +
|
|
73
|
-
((store[o + 1] << 16) | (store[o + 2] << 8) | store[o + 3])) >>>
|
|
74
|
-
0);
|
|
75
|
-
}
|
|
76
|
-
function fallbackReadUint32LE(offset = 0) {
|
|
77
|
-
const o = assertOffset(this, offset);
|
|
78
|
-
const store = this;
|
|
79
|
-
return ((store[o] |
|
|
80
|
-
(store[o + 1] << 8) |
|
|
81
|
-
(store[o + 2] << 16) |
|
|
82
|
-
(store[o + 3] * 0x1000000)) >>>
|
|
83
|
-
0);
|
|
84
|
-
}
|
|
85
|
-
function aliasOrDefine(proto, alias, canonical, fallback) {
|
|
86
|
-
const aliasKey = alias;
|
|
87
|
-
const canonicalKey = canonical;
|
|
88
|
-
const existingAlias = proto[aliasKey];
|
|
89
|
-
if (typeof existingAlias === "function") {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const canonicalFn = proto[canonicalKey];
|
|
93
|
-
if (typeof canonicalFn === "function") {
|
|
94
|
-
Object.defineProperty(proto, aliasKey, {
|
|
95
|
-
value: canonicalFn,
|
|
96
|
-
writable: true,
|
|
97
|
-
configurable: true,
|
|
98
|
-
});
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
Object.defineProperty(proto, aliasKey, {
|
|
102
|
-
value: fallback,
|
|
103
|
-
writable: true,
|
|
104
|
-
configurable: true,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
function patchPrototype(bufferCtor) {
|
|
108
|
-
const proto = bufferCtor.prototype;
|
|
109
|
-
if (!proto) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
aliasOrDefine(proto, "writeUint32BE", "writeUInt32BE", fallbackWriteUint32BE);
|
|
113
|
-
aliasOrDefine(proto, "writeUint32LE", "writeUInt32LE", fallbackWriteUint32LE);
|
|
114
|
-
aliasOrDefine(proto, "readUint32BE", "readUInt32BE", fallbackReadUint32BE);
|
|
115
|
-
aliasOrDefine(proto, "readUint32LE", "readUInt32LE", fallbackReadUint32LE);
|
|
116
|
-
}
|
|
117
|
-
function ensureProcessEnv() {
|
|
118
|
-
if (!globalScope.process) {
|
|
119
|
-
globalScope.process = { env: { NODE_ENV: "production" } };
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const processValue = globalScope.process;
|
|
123
|
-
if (!processValue.env) {
|
|
124
|
-
processValue.env = { NODE_ENV: "production" };
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
if (typeof processValue.env.NODE_ENV === "undefined") {
|
|
128
|
-
processValue.env.NODE_ENV = "production";
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function ensureBufferPolyfill() {
|
|
132
|
-
if (patched) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
const candidates = collectBufferCtors();
|
|
136
|
-
candidates.forEach(patchPrototype);
|
|
137
|
-
const preferred = candidates[0];
|
|
138
|
-
if (preferred &&
|
|
139
|
-
(typeof globalScope.Buffer !== "function" ||
|
|
140
|
-
typeof globalScope.Buffer.prototype?.writeUint32BE !==
|
|
141
|
-
"function")) {
|
|
142
|
-
globalScope.Buffer = preferred;
|
|
143
|
-
}
|
|
144
|
-
ensureProcessEnv();
|
|
145
|
-
patched = true;
|
|
146
|
-
}
|
|
147
|
-
ensureBufferPolyfill();
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getBalances = getBalances;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const decimal_js_1 = tslib_1.__importDefault(require("decimal.js"));
|
|
6
|
-
const definition_1 = require("../proto/definition");
|
|
7
|
-
const types_1 = require("../types");
|
|
8
|
-
const data_1 = require("../data");
|
|
9
|
-
const viem_1 = require("viem");
|
|
10
|
-
async function getBalances(vscURL, universe, address) {
|
|
11
|
-
const resp = await (0, types_1.msgpackableAxios)({
|
|
12
|
-
baseURL: vscURL,
|
|
13
|
-
url: `/api/v1/get-balance/${definition_1.Universe[universe]}/${(0, viem_1.bytesToHex)(address)}`,
|
|
14
|
-
});
|
|
15
|
-
const { data } = resp;
|
|
16
|
-
return data.balances.map(bal => ({
|
|
17
|
-
chainID: new data_1.OmniversalChainID(bal.universe, bal.chain_id),
|
|
18
|
-
totalValue: new decimal_js_1.default(bal.total_usd),
|
|
19
|
-
currencywise: bal.currencies.map(cur => ({
|
|
20
|
-
tokenAddress: cur.token_address,
|
|
21
|
-
amount: new decimal_js_1.default(cur.balance),
|
|
22
|
-
value: new decimal_js_1.default(cur.value)
|
|
23
|
-
}))
|
|
24
|
-
}));
|
|
25
|
-
}
|
package/dist/cjs/cosmos/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Registry = void 0;
|
|
4
|
-
exports.createCosmosWallet = createCosmosWallet;
|
|
5
|
-
exports.createCosmosClient = createCosmosClient;
|
|
6
|
-
const proto_signing_1 = require("@cosmjs/proto-signing");
|
|
7
|
-
const stargate_1 = require("@cosmjs/stargate");
|
|
8
|
-
const viem_1 = require("viem");
|
|
9
|
-
const definition_1 = require("../proto/definition");
|
|
10
|
-
exports.Registry = new proto_signing_1.Registry(stargate_1.defaultRegistryTypes);
|
|
11
|
-
{
|
|
12
|
-
exports.Registry.register("/xarchain.chainabstraction.MsgCreateSolverData", definition_1.MsgCreateSolverData);
|
|
13
|
-
exports.Registry.register("/xarchain.chainabstraction.MsgCreateSolverDataResponse", definition_1.MsgCreateSolverDataResponse);
|
|
14
|
-
exports.Registry.register("/xarchain.chainabstraction.MsgUpdateSolverData", definition_1.MsgUpdateSolverData);
|
|
15
|
-
exports.Registry.register("/xarchain.chainabstraction.MsgUpdateSolverDataResponse", definition_1.MsgCreateSolverDataResponse);
|
|
16
|
-
exports.Registry.register("/xarchain.chainabstraction.MsgCreateRequestForFunds", definition_1.MsgCreateRequestForFunds);
|
|
17
|
-
exports.Registry.register("/xarchain.chainabstraction.MsgCreateRequestForFundsResponse", definition_1.MsgCreateRequestForFundsResponse);
|
|
18
|
-
exports.Registry.register("/xarchain.chainabstraction.MsgRefundReq", definition_1.MsgRefundReq);
|
|
19
|
-
exports.Registry.register("/xarchain.chainabstraction.MsgRefundReqResponse", definition_1.MsgRefundReqResponse);
|
|
20
|
-
exports.Registry.register("/xarchain.chainabstraction.MsgDoubleCheckTx", definition_1.MsgDoubleCheckTx);
|
|
21
|
-
}
|
|
22
|
-
function createCosmosWallet(privateKey) {
|
|
23
|
-
const pkBytes = typeof privateKey === "string" ? (0, viem_1.hexToBytes)(privateKey) : privateKey;
|
|
24
|
-
return proto_signing_1.DirectSecp256k1Wallet.fromKey(pkBytes, "arcana");
|
|
25
|
-
}
|
|
26
|
-
function createCosmosClient(signer, endpoint, options) {
|
|
27
|
-
return stargate_1.SigningStargateClient.connectWithSigner(endpoint, signer, {
|
|
28
|
-
registry: exports.Registry,
|
|
29
|
-
...options,
|
|
30
|
-
});
|
|
31
|
-
}
|