@avail-project/ca-common 2.3.0 → 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.
Files changed (95) hide show
  1. package/dist/cjs/index.js +10593 -20
  2. package/dist/esm/index.mjs +10603 -0
  3. package/dist/types/index.d.ts +2608 -13
  4. package/package.json +41 -37
  5. package/dist/cjs/_polyfill.js +0 -147
  6. package/dist/cjs/balances/ub-api.js +0 -25
  7. package/dist/cjs/cosmos/index.js +0 -31
  8. package/dist/cjs/data/chaindata.js +0 -788
  9. package/dist/cjs/data/chainid.js +0 -93
  10. package/dist/cjs/data/currency.js +0 -78
  11. package/dist/cjs/data/index.js +0 -7
  12. package/dist/cjs/data/utils.js +0 -44
  13. package/dist/cjs/evmabi/erc20.abi.js +0 -349
  14. package/dist/cjs/evmabi/fibrousrouter.abi.js +0 -41
  15. package/dist/cjs/evmabi/index.js +0 -7
  16. package/dist/cjs/evmabi/vault.abi.js +0 -1021
  17. package/dist/cjs/evmabi/yakaggregator.abi.js +0 -275
  18. package/dist/cjs/permitutils/index.js +0 -186
  19. package/dist/cjs/proto/client.js +0 -48
  20. package/dist/cjs/proto/definition.js +0 -4131
  21. package/dist/cjs/proto/grpc.js +0 -298
  22. package/dist/cjs/rff/rff.js +0 -42
  23. package/dist/cjs/types/binarytypes.js +0 -2
  24. package/dist/cjs/types/index.js +0 -5
  25. package/dist/cjs/types/msgpack-axios.js +0 -22
  26. package/dist/cjs/vaultcontracts/index.js +0 -4
  27. package/dist/cjs/vaultcontracts/vaultcontracts.js +0 -222
  28. package/dist/cjs/xcs/autochoice.js +0 -575
  29. package/dist/cjs/xcs/bebop-agg.js +0 -156
  30. package/dist/cjs/xcs/fibrous-agg.js +0 -155
  31. package/dist/cjs/xcs/iface.js +0 -13
  32. package/dist/cjs/xcs/index.js +0 -9
  33. package/dist/cjs/xcs/lifi-agg.js +0 -177
  34. package/dist/cjs/xcs/selectsources.js +0 -255
  35. package/dist/esm/_polyfill.js +0 -143
  36. package/dist/esm/balances/ub-api.js +0 -21
  37. package/dist/esm/cosmos/index.js +0 -26
  38. package/dist/esm/data/chaindata.js +0 -785
  39. package/dist/esm/data/chainid.js +0 -87
  40. package/dist/esm/data/currency.js +0 -73
  41. package/dist/esm/data/index.js +0 -4
  42. package/dist/esm/data/utils.js +0 -34
  43. package/dist/esm/evmabi/erc20.abi.js +0 -346
  44. package/dist/esm/evmabi/fibrousrouter.abi.js +0 -38
  45. package/dist/esm/evmabi/index.js +0 -4
  46. package/dist/esm/evmabi/vault.abi.js +0 -1018
  47. package/dist/esm/evmabi/yakaggregator.abi.js +0 -272
  48. package/dist/esm/index.js +0 -13
  49. package/dist/esm/permitutils/index.js +0 -181
  50. package/dist/esm/proto/client.js +0 -11
  51. package/dist/esm/proto/definition.js +0 -4122
  52. package/dist/esm/proto/grpc.js +0 -292
  53. package/dist/esm/rff/rff.js +0 -38
  54. package/dist/esm/types/binarytypes.js +0 -1
  55. package/dist/esm/types/index.js +0 -2
  56. package/dist/esm/types/msgpack-axios.js +0 -18
  57. package/dist/esm/vaultcontracts/index.js +0 -1
  58. package/dist/esm/vaultcontracts/vaultcontracts.js +0 -218
  59. package/dist/esm/xcs/autochoice.js +0 -559
  60. package/dist/esm/xcs/bebop-agg.js +0 -151
  61. package/dist/esm/xcs/fibrous-agg.js +0 -150
  62. package/dist/esm/xcs/iface.js +0 -10
  63. package/dist/esm/xcs/index.js +0 -6
  64. package/dist/esm/xcs/lifi-agg.js +0 -172
  65. package/dist/esm/xcs/selectsources.js +0 -251
  66. package/dist/types/_polyfill.d.ts +0 -1
  67. package/dist/types/balances/ub-api.d.ts +0 -14
  68. package/dist/types/cosmos/index.d.ts +0 -6
  69. package/dist/types/data/chaindata.d.ts +0 -20
  70. package/dist/types/data/chainid.d.ts +0 -31
  71. package/dist/types/data/currency.d.ts +0 -30
  72. package/dist/types/data/index.d.ts +0 -4
  73. package/dist/types/data/utils.d.ts +0 -10
  74. package/dist/types/evmabi/erc20.abi.d.ts +0 -264
  75. package/dist/types/evmabi/fibrousrouter.abi.d.ts +0 -77
  76. package/dist/types/evmabi/index.d.ts +0 -4
  77. package/dist/types/evmabi/vault.abi.d.ts +0 -785
  78. package/dist/types/evmabi/yakaggregator.abi.d.ts +0 -298
  79. package/dist/types/permitutils/index.d.ts +0 -13
  80. package/dist/types/proto/client.d.ts +0 -2
  81. package/dist/types/proto/definition.d.ts +0 -382
  82. package/dist/types/proto/grpc.d.ts +0 -75
  83. package/dist/types/rff/rff.d.ts +0 -9
  84. package/dist/types/types/binarytypes.d.ts +0 -1
  85. package/dist/types/types/index.d.ts +0 -2
  86. package/dist/types/types/msgpack-axios.d.ts +0 -1
  87. package/dist/types/vaultcontracts/index.d.ts +0 -22
  88. package/dist/types/vaultcontracts/vaultcontracts.d.ts +0 -8
  89. package/dist/types/xcs/autochoice.d.ts +0 -104
  90. package/dist/types/xcs/bebop-agg.d.ts +0 -104
  91. package/dist/types/xcs/fibrous-agg.d.ts +0 -56
  92. package/dist/types/xcs/iface.d.ts +0 -69
  93. package/dist/types/xcs/index.d.ts +0 -6
  94. package/dist/types/xcs/lifi-agg.d.ts +0 -42
  95. package/dist/types/xcs/selectsources.d.ts +0 -27
package/package.json CHANGED
@@ -1,27 +1,21 @@
1
1
  {
2
2
  "name": "@avail-project/ca-common",
3
- "version": "2.3.0",
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.js"
13
+ "import": "./dist/esm/index.mjs"
18
14
  }
19
15
  },
20
16
  "scripts": {
21
- "build": "run-s clean build:esm build:cjs",
22
- "build:esm": "tsc --project tsconfig.json",
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": "^3.3.1",
35
- "@eslint/js": "^9.31.0",
36
- "@types/node": "^22.16.3",
37
- "@typescript-eslint/eslint-plugin": "^8.36.0",
38
- "@typescript-eslint/parser": "^8.36.0",
39
- "eslint": "^9.31.0",
40
- "eslint-config-prettier": "^10.1.5",
41
- "globals": "^16.3.0",
42
- "npm-run-all": "^4.1.5",
43
- "prettier": "^3.6.2",
44
- "release-it": "^19.2.3",
45
- "rimraf": "^6.0.1",
46
- "ts-proto": "^2.7.5",
47
- "typescript": "^5.8.3"
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
- "@cosmjs/proto-signing": "^0.34.0",
51
- "@cosmjs/stargate": "^0.34.0",
52
- "axios": "^1.10.0",
53
- "decimal.js": "^10.6.0",
54
- "long": "^5.3.2",
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": "^2.6.0",
60
- "@improbable-eng/grpc-web": "^0.15.0",
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
- "browser-headers": "^0.4.1",
63
- "es-toolkit": "^1.39.7",
64
- "tslib": "^2.8.1"
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
@@ -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
- }
@@ -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
- }