@chainflip/utils 0.11.3 → 2.1.0-beta.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/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/addresses.cjs +15 -40
- package/dist/addresses.d.ts +4 -3
- package/dist/addresses.js +14 -15
- package/dist/assertion.cjs +23 -82
- package/dist/assertion.d.ts +3 -2
- package/dist/assertion.js +32 -22
- package/dist/async.cjs +96 -115
- package/dist/async.d.ts +24 -21
- package/dist/async.js +92 -87
- package/dist/base58.cjs +9 -93
- package/dist/base58.d.ts +4 -4
- package/dist/base58.js +9 -13
- package/dist/bytes.cjs +49 -97
- package/dist/bytes.d.ts +4 -4
- package/dist/bytes.js +51 -15
- package/dist/chainflip.cjs +428 -327
- package/dist/chainflip.d.ts +188 -185
- package/dist/chainflip.js +425 -41
- package/dist/consts.cjs +306 -277
- package/dist/consts.d.ts +18 -17
- package/dist/consts.js +296 -243
- package/dist/date.cjs +74 -131
- package/dist/date.d.ts +9 -8
- package/dist/date.js +60 -95
- package/dist/guard.cjs +28 -63
- package/dist/guard.d.ts +10 -9
- package/dist/guard.js +17 -28
- package/dist/math.cjs +7 -32
- package/dist/math.d.ts +3 -2
- package/dist/math.js +6 -7
- package/dist/number.cjs +5 -29
- package/dist/number.d.ts +4 -4
- package/dist/number.js +5 -5
- package/dist/ss58.cjs +62 -794
- package/dist/ss58.d.ts +12 -9
- package/dist/ss58.js +59 -712
- package/dist/string.cjs +29 -66
- package/dist/string.d.ts +4 -4
- package/dist/string.js +20 -33
- package/dist/tickMath.cjs +32 -232
- package/dist/tickMath.d.ts +7 -6
- package/dist/tickMath.js +24 -29
- package/dist/types.cjs +0 -18
- package/dist/types.d.ts +35 -34
- package/dist/types.js +1 -0
- package/dist/url.cjs +16 -37
- package/dist/url.d.ts +5 -4
- package/dist/url.js +16 -13
- package/package.json +5 -5
- package/dist/addresses.d.cts +0 -6
- package/dist/assertion.d.cts +0 -11
- package/dist/async.d.cts +0 -33
- package/dist/base58.d.cts +0 -8
- package/dist/bytes.d.cts +0 -11
- package/dist/chainflip.d.cts +0 -236
- package/dist/chunk-3P6TXYEI.js +0 -15
- package/dist/chunk-HBIFE4XN.js +0 -29
- package/dist/chunk-LJJH7U4M.js +0 -302
- package/dist/chunk-XGNPN5CY.js +0 -61
- package/dist/chunk-ZHIKNZLU.js +0 -66
- package/dist/consts.d.cts +0 -33
- package/dist/date.d.cts +0 -26
- package/dist/guard.d.cts +0 -23
- package/dist/math.d.cts +0 -4
- package/dist/number.d.cts +0 -6
- package/dist/ss58.d.cts +0 -14
- package/dist/string.d.cts +0 -16
- package/dist/tickMath.d.cts +0 -15
- package/dist/types.d.cts +0 -41
- package/dist/url.d.cts +0 -6
package/dist/chunk-LJJH7U4M.js
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
// src/chainflip.ts
|
|
2
|
-
var chainflipAssets = [
|
|
3
|
-
// Ethereum
|
|
4
|
-
"Usdc",
|
|
5
|
-
"Usdt",
|
|
6
|
-
"Flip",
|
|
7
|
-
"Eth",
|
|
8
|
-
// Polkadot
|
|
9
|
-
"Dot",
|
|
10
|
-
// Bitcoin
|
|
11
|
-
"Btc",
|
|
12
|
-
// Arbitrum
|
|
13
|
-
"ArbUsdc",
|
|
14
|
-
"ArbEth",
|
|
15
|
-
// Solana
|
|
16
|
-
"Sol",
|
|
17
|
-
"SolUsdc",
|
|
18
|
-
// Assethub
|
|
19
|
-
"HubDot",
|
|
20
|
-
"HubUsdt",
|
|
21
|
-
"HubUsdc"
|
|
22
|
-
];
|
|
23
|
-
var assetSymbols = ["USDC", "USDT", "FLIP", "DOT", "ETH", "BTC", "SOL"];
|
|
24
|
-
var priceAssets = [
|
|
25
|
-
"Btc",
|
|
26
|
-
"Eth",
|
|
27
|
-
"Sol",
|
|
28
|
-
"Usdc",
|
|
29
|
-
"Usdt",
|
|
30
|
-
"Usd",
|
|
31
|
-
"Fine"
|
|
32
|
-
// not used
|
|
33
|
-
];
|
|
34
|
-
var rpcAssets = assetSymbols;
|
|
35
|
-
var baseChainflipAssets = chainflipAssets.filter(
|
|
36
|
-
(asset) => asset !== "Usdc"
|
|
37
|
-
);
|
|
38
|
-
var chainflipEvmChains = ["Ethereum", "Arbitrum"];
|
|
39
|
-
var chainflipChains = [
|
|
40
|
-
...chainflipEvmChains,
|
|
41
|
-
"Bitcoin",
|
|
42
|
-
"Polkadot",
|
|
43
|
-
"Solana",
|
|
44
|
-
"Assethub"
|
|
45
|
-
];
|
|
46
|
-
var chainflipNetworks = ["backspin", "sisyphos", "perseverance", "mainnet"];
|
|
47
|
-
var addressTypes = ["Eth", "Btc", "Dot", "Arb", "Sol", "Hub"];
|
|
48
|
-
function readAssetValue(map, asset) {
|
|
49
|
-
const chainValues = map[assetConstants[asset].chain];
|
|
50
|
-
return chainValues[assetConstants[asset].symbol];
|
|
51
|
-
}
|
|
52
|
-
var assetConstants = {
|
|
53
|
-
Eth: {
|
|
54
|
-
chain: "Ethereum",
|
|
55
|
-
symbol: "ETH",
|
|
56
|
-
rpcAsset: "ETH",
|
|
57
|
-
decimals: 18
|
|
58
|
-
},
|
|
59
|
-
Flip: {
|
|
60
|
-
chain: "Ethereum",
|
|
61
|
-
symbol: "FLIP",
|
|
62
|
-
rpcAsset: "FLIP",
|
|
63
|
-
decimals: 18
|
|
64
|
-
},
|
|
65
|
-
Usdc: {
|
|
66
|
-
chain: "Ethereum",
|
|
67
|
-
symbol: "USDC",
|
|
68
|
-
rpcAsset: "USDC",
|
|
69
|
-
decimals: 6
|
|
70
|
-
},
|
|
71
|
-
Usdt: {
|
|
72
|
-
chain: "Ethereum",
|
|
73
|
-
symbol: "USDT",
|
|
74
|
-
rpcAsset: "USDT",
|
|
75
|
-
decimals: 6
|
|
76
|
-
},
|
|
77
|
-
Dot: {
|
|
78
|
-
chain: "Polkadot",
|
|
79
|
-
symbol: "DOT",
|
|
80
|
-
rpcAsset: "DOT",
|
|
81
|
-
decimals: 10
|
|
82
|
-
},
|
|
83
|
-
Btc: {
|
|
84
|
-
chain: "Bitcoin",
|
|
85
|
-
symbol: "BTC",
|
|
86
|
-
rpcAsset: "BTC",
|
|
87
|
-
decimals: 8
|
|
88
|
-
},
|
|
89
|
-
ArbUsdc: {
|
|
90
|
-
chain: "Arbitrum",
|
|
91
|
-
symbol: "USDC",
|
|
92
|
-
rpcAsset: "USDC",
|
|
93
|
-
decimals: 6
|
|
94
|
-
},
|
|
95
|
-
ArbEth: {
|
|
96
|
-
chain: "Arbitrum",
|
|
97
|
-
symbol: "ETH",
|
|
98
|
-
rpcAsset: "ETH",
|
|
99
|
-
decimals: 18
|
|
100
|
-
},
|
|
101
|
-
Sol: {
|
|
102
|
-
chain: "Solana",
|
|
103
|
-
symbol: "SOL",
|
|
104
|
-
rpcAsset: "SOL",
|
|
105
|
-
decimals: 9
|
|
106
|
-
},
|
|
107
|
-
SolUsdc: {
|
|
108
|
-
chain: "Solana",
|
|
109
|
-
symbol: "USDC",
|
|
110
|
-
rpcAsset: "USDC",
|
|
111
|
-
decimals: 6
|
|
112
|
-
},
|
|
113
|
-
HubDot: {
|
|
114
|
-
chain: "Assethub",
|
|
115
|
-
symbol: "DOT",
|
|
116
|
-
rpcAsset: "DOT",
|
|
117
|
-
decimals: 10
|
|
118
|
-
},
|
|
119
|
-
HubUsdc: {
|
|
120
|
-
chain: "Assethub",
|
|
121
|
-
symbol: "USDC",
|
|
122
|
-
rpcAsset: "USDC",
|
|
123
|
-
decimals: 6
|
|
124
|
-
},
|
|
125
|
-
HubUsdt: {
|
|
126
|
-
chain: "Assethub",
|
|
127
|
-
symbol: "USDT",
|
|
128
|
-
rpcAsset: "USDT",
|
|
129
|
-
decimals: 6
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
var chainConstants = {
|
|
133
|
-
Ethereum: {
|
|
134
|
-
chainflipAssets: ["Eth", "Flip", "Usdc", "Usdt"],
|
|
135
|
-
assets: ["ETH", "FLIP", "USDC", "USDT"],
|
|
136
|
-
rpcAssets: ["ETH", "FLIP", "USDC", "USDT"],
|
|
137
|
-
gasAsset: "Eth",
|
|
138
|
-
addressType: "Eth",
|
|
139
|
-
blockTimeSeconds: 12
|
|
140
|
-
},
|
|
141
|
-
Polkadot: {
|
|
142
|
-
chainflipAssets: ["Dot"],
|
|
143
|
-
assets: ["DOT"],
|
|
144
|
-
rpcAssets: ["DOT"],
|
|
145
|
-
gasAsset: "Dot",
|
|
146
|
-
addressType: "Dot",
|
|
147
|
-
blockTimeSeconds: 6
|
|
148
|
-
},
|
|
149
|
-
Bitcoin: {
|
|
150
|
-
chainflipAssets: ["Btc"],
|
|
151
|
-
assets: ["BTC"],
|
|
152
|
-
rpcAssets: ["BTC"],
|
|
153
|
-
gasAsset: "Btc",
|
|
154
|
-
addressType: "Btc",
|
|
155
|
-
blockTimeSeconds: 10 * 60
|
|
156
|
-
},
|
|
157
|
-
Arbitrum: {
|
|
158
|
-
chainflipAssets: ["ArbUsdc", "ArbEth"],
|
|
159
|
-
assets: ["USDC", "ETH"],
|
|
160
|
-
rpcAssets: ["USDC", "ETH"],
|
|
161
|
-
gasAsset: "ArbEth",
|
|
162
|
-
addressType: "Arb",
|
|
163
|
-
blockTimeSeconds: 0.26
|
|
164
|
-
},
|
|
165
|
-
Solana: {
|
|
166
|
-
chainflipAssets: ["Sol", "SolUsdc"],
|
|
167
|
-
assets: ["SOL", "USDC"],
|
|
168
|
-
rpcAssets: ["SOL", "USDC"],
|
|
169
|
-
gasAsset: "Sol",
|
|
170
|
-
addressType: "Sol",
|
|
171
|
-
blockTimeSeconds: 0.8
|
|
172
|
-
},
|
|
173
|
-
Assethub: {
|
|
174
|
-
chainflipAssets: ["HubDot", "HubUsdt", "HubUsdc"],
|
|
175
|
-
assets: ["DOT", "USDT", "USDC"],
|
|
176
|
-
rpcAssets: ["DOT", "USDT", "USDC"],
|
|
177
|
-
gasAsset: "HubDot",
|
|
178
|
-
addressType: "Hub",
|
|
179
|
-
blockTimeSeconds: 12
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
var internalAssetToRpcAsset = {
|
|
183
|
-
Eth: { chain: "Ethereum", asset: "ETH" },
|
|
184
|
-
Flip: { chain: "Ethereum", asset: "FLIP" },
|
|
185
|
-
Usdc: { chain: "Ethereum", asset: "USDC" },
|
|
186
|
-
Usdt: { chain: "Ethereum", asset: "USDT" },
|
|
187
|
-
Dot: { chain: "Polkadot", asset: "DOT" },
|
|
188
|
-
Btc: { chain: "Bitcoin", asset: "BTC" },
|
|
189
|
-
ArbUsdc: { chain: "Arbitrum", asset: "USDC" },
|
|
190
|
-
ArbEth: { chain: "Arbitrum", asset: "ETH" },
|
|
191
|
-
Sol: { chain: "Solana", asset: "SOL" },
|
|
192
|
-
SolUsdc: { chain: "Solana", asset: "USDC" },
|
|
193
|
-
HubDot: { chain: "Assethub", asset: "DOT" },
|
|
194
|
-
HubUsdt: { chain: "Assethub", asset: "USDT" },
|
|
195
|
-
HubUsdc: { chain: "Assethub", asset: "USDC" }
|
|
196
|
-
};
|
|
197
|
-
var chainContractId = {
|
|
198
|
-
Ethereum: 1,
|
|
199
|
-
Polkadot: 2,
|
|
200
|
-
Bitcoin: 3,
|
|
201
|
-
Arbitrum: 4,
|
|
202
|
-
Solana: 5,
|
|
203
|
-
Assethub: 6
|
|
204
|
-
};
|
|
205
|
-
var assetContractId = {
|
|
206
|
-
Eth: 1,
|
|
207
|
-
Flip: 2,
|
|
208
|
-
Usdc: 3,
|
|
209
|
-
Dot: 4,
|
|
210
|
-
Usdt: 8,
|
|
211
|
-
Btc: 5,
|
|
212
|
-
ArbEth: 6,
|
|
213
|
-
ArbUsdc: 7,
|
|
214
|
-
Sol: 9,
|
|
215
|
-
SolUsdc: 10,
|
|
216
|
-
HubDot: 11,
|
|
217
|
-
HubUsdt: 12,
|
|
218
|
-
HubUsdc: 13
|
|
219
|
-
};
|
|
220
|
-
function getInternalAsset(asset, assert = true) {
|
|
221
|
-
const map = {
|
|
222
|
-
Ethereum: {
|
|
223
|
-
USDC: "Usdc",
|
|
224
|
-
FLIP: "Flip",
|
|
225
|
-
ETH: "Eth",
|
|
226
|
-
USDT: "Usdt"
|
|
227
|
-
},
|
|
228
|
-
Bitcoin: {
|
|
229
|
-
BTC: "Btc"
|
|
230
|
-
},
|
|
231
|
-
Arbitrum: {
|
|
232
|
-
USDC: "ArbUsdc",
|
|
233
|
-
ETH: "ArbEth"
|
|
234
|
-
},
|
|
235
|
-
Solana: {
|
|
236
|
-
SOL: "Sol",
|
|
237
|
-
USDC: "SolUsdc"
|
|
238
|
-
},
|
|
239
|
-
Assethub: {
|
|
240
|
-
USDC: "HubUsdc",
|
|
241
|
-
USDT: "HubUsdt",
|
|
242
|
-
DOT: "HubDot"
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
const chain = map[asset.chain];
|
|
246
|
-
const internalAsset = chain?.[asset.asset];
|
|
247
|
-
if (internalAsset) return internalAsset;
|
|
248
|
-
if (assert) throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
|
|
249
|
-
return null;
|
|
250
|
-
}
|
|
251
|
-
function isValidAssetAndChain(assetAndChain) {
|
|
252
|
-
const asset = getInternalAsset(assetAndChain, false);
|
|
253
|
-
return asset !== null;
|
|
254
|
-
}
|
|
255
|
-
function getInternalAssets({
|
|
256
|
-
srcAsset,
|
|
257
|
-
srcChain,
|
|
258
|
-
destAsset,
|
|
259
|
-
destChain
|
|
260
|
-
}, assert = true) {
|
|
261
|
-
return {
|
|
262
|
-
srcAsset: getInternalAsset({ asset: srcAsset, chain: srcChain }, assert),
|
|
263
|
-
destAsset: getInternalAsset({ asset: destAsset, chain: destChain }, assert)
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
var chainflipAssetToPriceAssetMap = {
|
|
267
|
-
Btc: "Btc",
|
|
268
|
-
Sol: "Sol",
|
|
269
|
-
Eth: "Eth",
|
|
270
|
-
ArbEth: "Eth",
|
|
271
|
-
Usdc: "Usdc",
|
|
272
|
-
ArbUsdc: "Usdc",
|
|
273
|
-
SolUsdc: "Usdc",
|
|
274
|
-
HubUsdc: "Usdc",
|
|
275
|
-
Usdt: "Usdt",
|
|
276
|
-
HubUsdt: "Usdt",
|
|
277
|
-
Dot: null,
|
|
278
|
-
Flip: null,
|
|
279
|
-
HubDot: null
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
export {
|
|
283
|
-
chainflipAssets,
|
|
284
|
-
assetSymbols,
|
|
285
|
-
priceAssets,
|
|
286
|
-
rpcAssets,
|
|
287
|
-
baseChainflipAssets,
|
|
288
|
-
chainflipEvmChains,
|
|
289
|
-
chainflipChains,
|
|
290
|
-
chainflipNetworks,
|
|
291
|
-
addressTypes,
|
|
292
|
-
readAssetValue,
|
|
293
|
-
assetConstants,
|
|
294
|
-
chainConstants,
|
|
295
|
-
internalAssetToRpcAsset,
|
|
296
|
-
chainContractId,
|
|
297
|
-
assetContractId,
|
|
298
|
-
getInternalAsset,
|
|
299
|
-
isValidAssetAndChain,
|
|
300
|
-
getInternalAssets,
|
|
301
|
-
chainflipAssetToPriceAssetMap
|
|
302
|
-
};
|
package/dist/chunk-XGNPN5CY.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
assert
|
|
3
|
-
} from "./chunk-ZHIKNZLU.js";
|
|
4
|
-
|
|
5
|
-
// src/bytes.ts
|
|
6
|
-
var bytesToHex = (input) => {
|
|
7
|
-
const bytes = new Uint8Array(input);
|
|
8
|
-
return `0x${Array.from(bytes).map((byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
9
|
-
};
|
|
10
|
-
var hexToBytes = (input) => {
|
|
11
|
-
assert(/^0x[\da-f]*$/i.test(input) && input.length % 2 === 0, "Invalid hex string");
|
|
12
|
-
const hex = input.slice(2);
|
|
13
|
-
const bytes = new Uint8Array(hex.length / 2);
|
|
14
|
-
for (let i = 0; i < hex.length; i += 2) {
|
|
15
|
-
bytes[i / 2] = Number.parseInt(hex.slice(i, i + 2), 16);
|
|
16
|
-
}
|
|
17
|
-
return bytes;
|
|
18
|
-
};
|
|
19
|
-
var convertBase = (inputBytes, fromBase, toBase) => {
|
|
20
|
-
const bytes = typeof inputBytes === "string" ? hexToBytes(inputBytes) : new Uint8Array(inputBytes);
|
|
21
|
-
const result = [];
|
|
22
|
-
for (const byte of bytes) {
|
|
23
|
-
let carry = byte;
|
|
24
|
-
for (let i = 0; i < result.length; i += 1) {
|
|
25
|
-
carry += result[i] * fromBase;
|
|
26
|
-
result[i] = carry % toBase;
|
|
27
|
-
carry = Math.floor(carry / toBase);
|
|
28
|
-
}
|
|
29
|
-
while (carry !== 0) {
|
|
30
|
-
result.push(carry % toBase);
|
|
31
|
-
carry = Math.floor(carry / toBase);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
let leadingZeros = 0;
|
|
35
|
-
while (bytes[leadingZeros] === 0) {
|
|
36
|
-
leadingZeros += 1;
|
|
37
|
-
result.push(0);
|
|
38
|
-
}
|
|
39
|
-
return result.reverse();
|
|
40
|
-
};
|
|
41
|
-
var encodeBytesWithCharset = (bytes, charset) => convertBase(bytes, 256, charset.length).map((charCode) => charset.charAt(charCode)).join("");
|
|
42
|
-
var decodeBytesWithCharset = (input, charset) => {
|
|
43
|
-
assert(new RegExp(`^[${charset}]*$`).test(input), "Invalid input");
|
|
44
|
-
const charMap = Object.fromEntries([...charset].map((char, index) => [char, index]));
|
|
45
|
-
const bytes = input.split("").map((char) => charMap[char]);
|
|
46
|
-
return new Uint8Array(convertBase(bytes, charset.length, 256));
|
|
47
|
-
};
|
|
48
|
-
function reverseBytes(input) {
|
|
49
|
-
const bytes = /^(?:0x)?([\da-f]+)$/gi.exec(input)?.[1];
|
|
50
|
-
assert(bytes && bytes.length % 2 === 0 && bytes.length > 0, "Invalid hex string");
|
|
51
|
-
const reversed = bytes.match(/.{2}/g).reverse().join("");
|
|
52
|
-
return input.startsWith("0x") ? `0x${reversed}` : reversed;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export {
|
|
56
|
-
bytesToHex,
|
|
57
|
-
hexToBytes,
|
|
58
|
-
encodeBytesWithCharset,
|
|
59
|
-
decodeBytesWithCharset,
|
|
60
|
-
reverseBytes
|
|
61
|
-
};
|
package/dist/chunk-ZHIKNZLU.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isBigInt,
|
|
3
|
-
isBoolean,
|
|
4
|
-
isNumber,
|
|
5
|
-
isObject,
|
|
6
|
-
isString,
|
|
7
|
-
isSymbol,
|
|
8
|
-
isUndefined
|
|
9
|
-
} from "./chunk-HBIFE4XN.js";
|
|
10
|
-
|
|
11
|
-
// src/assertion.ts
|
|
12
|
-
function assert(condition, message = "assertion failed", Constructor = Error) {
|
|
13
|
-
if (!condition) {
|
|
14
|
-
throw new Constructor(message);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function assertString(value, message) {
|
|
18
|
-
if (!isString(value)) {
|
|
19
|
-
throw new TypeError(message ?? `expected a "string", got "${typeof value}"`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function assertNumber(value, message) {
|
|
23
|
-
if (!isNumber(value)) {
|
|
24
|
-
throw new TypeError(message ?? `expected a "number", got "${typeof value}"`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function assertBigInt(value, message) {
|
|
28
|
-
if (!isBigInt(value)) {
|
|
29
|
-
throw new TypeError(message ?? `expected a "bigint", got "${typeof value}"`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function assertBoolean(value, message) {
|
|
33
|
-
if (!isBoolean(value)) {
|
|
34
|
-
throw new TypeError(message ?? `expected a "boolean", got "${typeof value}"`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function assertSymbol(value, message) {
|
|
38
|
-
if (!isSymbol(value)) {
|
|
39
|
-
throw new TypeError(message ?? `expected a "symbol", got "${typeof value}"`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function assertObject(value, message) {
|
|
43
|
-
if (!isObject(value)) {
|
|
44
|
-
throw new TypeError(message ?? `expected an "object", got "${typeof value}"`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function assertUndefined(value, message) {
|
|
48
|
-
if (!isUndefined(value)) {
|
|
49
|
-
throw new TypeError(message ?? `expected "undefined", got "${typeof value}"`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
var unreachable = (x, message = "unreachable") => {
|
|
53
|
-
throw new Error(message);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export {
|
|
57
|
-
assert,
|
|
58
|
-
assertString,
|
|
59
|
-
assertNumber,
|
|
60
|
-
assertBigInt,
|
|
61
|
-
assertBoolean,
|
|
62
|
-
assertSymbol,
|
|
63
|
-
assertObject,
|
|
64
|
-
assertUndefined,
|
|
65
|
-
unreachable
|
|
66
|
-
};
|
package/dist/consts.d.cts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
declare const HEARTBEAT_BLOCK_INTERVAL = 150;
|
|
2
|
-
declare const CHAINFLIP_SS58_PREFIX = 2112;
|
|
3
|
-
declare const POLKADOT_SS58_PREFIX = 0;
|
|
4
|
-
declare const CHAINFLIP_BLOCK_TIME_SECONDS = 6;
|
|
5
|
-
declare const CHAINFLIP_BLOCKS_PER_YEAR = 5256000;
|
|
6
|
-
declare const chainflipLinks: {
|
|
7
|
-
website: string;
|
|
8
|
-
discord: string;
|
|
9
|
-
twitter: string;
|
|
10
|
-
telegram: string;
|
|
11
|
-
blog: string;
|
|
12
|
-
docs: string;
|
|
13
|
-
};
|
|
14
|
-
declare const chainflipCommunityLinks: {
|
|
15
|
-
discord: string;
|
|
16
|
-
twitter: string;
|
|
17
|
-
telegram: string;
|
|
18
|
-
};
|
|
19
|
-
type AccountAliasMap = {
|
|
20
|
-
[account: string]: {
|
|
21
|
-
name: string;
|
|
22
|
-
twitter: string | null;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
declare const smartContractAliasMap: {
|
|
26
|
-
'0xce16f69375520ab01377ce7b88f5ba8c48f8d666': string;
|
|
27
|
-
'0xd99ac0681b904991169a4f398b9043781adbe0c3': string;
|
|
28
|
-
};
|
|
29
|
-
declare const brokerAliasMap: AccountAliasMap;
|
|
30
|
-
declare const lpAliasMap: AccountAliasMap;
|
|
31
|
-
declare const GENESIS_LP_ACCOUNT_IDS: string[];
|
|
32
|
-
|
|
33
|
-
export { CHAINFLIP_BLOCKS_PER_YEAR, CHAINFLIP_BLOCK_TIME_SECONDS, CHAINFLIP_SS58_PREFIX, GENESIS_LP_ACCOUNT_IDS, HEARTBEAT_BLOCK_INTERVAL, POLKADOT_SS58_PREFIX, brokerAliasMap, chainflipCommunityLinks, chainflipLinks, lpAliasMap, smartContractAliasMap };
|
package/dist/date.d.cts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { UTCDate } from '@date-fns/utc';
|
|
2
|
-
import { Interval, DateArg } from 'date-fns';
|
|
3
|
-
|
|
4
|
-
declare const toISODateString: (date: Date) => string;
|
|
5
|
-
declare const fromUnixTime: (time: string | number) => Date;
|
|
6
|
-
declare const formatTimestamp: (timestamp: string, locale?: string | undefined, timeZone?: undefined | "UTC") => string;
|
|
7
|
-
declare const formatTimestampShort: (timestamp: string, locale?: string | undefined, timeZone?: undefined | "UTC") => string;
|
|
8
|
-
declare const differenceInTimeAgo: (time: string, ago?: boolean, endTime?: string) => string;
|
|
9
|
-
declare const intervalToDurationWords: (interval: Interval) => string;
|
|
10
|
-
type FNSDate = DateArg<Date>;
|
|
11
|
-
declare const subUtcDays: (date: FNSDate, days: number) => UTCDate;
|
|
12
|
-
declare const addUtcDays: (date: FNSDate, days: number) => UTCDate;
|
|
13
|
-
declare const toStartOfUtcDay: (date: FNSDate) => UTCDate;
|
|
14
|
-
declare const toStartOfUtcDayString: (date: FNSDate) => string;
|
|
15
|
-
declare const toEndOfUtcDay: (date: FNSDate) => UTCDate;
|
|
16
|
-
declare const toEndOfUtcDayString: (date: FNSDate) => string;
|
|
17
|
-
declare const differenceInUtcDays: (interval: {
|
|
18
|
-
start: FNSDate;
|
|
19
|
-
end: FNSDate;
|
|
20
|
-
}) => number;
|
|
21
|
-
declare const eachUtcDayOfInterval: (interval: {
|
|
22
|
-
start: FNSDate;
|
|
23
|
-
end: FNSDate;
|
|
24
|
-
}) => UTCDate[];
|
|
25
|
-
|
|
26
|
-
export { addUtcDays, differenceInTimeAgo, differenceInUtcDays, eachUtcDayOfInterval, formatTimestamp, formatTimestampShort, fromUnixTime, intervalToDurationWords, subUtcDays, toEndOfUtcDay, toEndOfUtcDayString, toISODateString, toStartOfUtcDay, toStartOfUtcDayString };
|
package/dist/guard.d.cts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
type TypeMap = {
|
|
2
|
-
string: string;
|
|
3
|
-
number: number;
|
|
4
|
-
bigint: bigint;
|
|
5
|
-
boolean: boolean;
|
|
6
|
-
symbol: symbol;
|
|
7
|
-
object: object;
|
|
8
|
-
undefined: undefined;
|
|
9
|
-
};
|
|
10
|
-
declare const isString: (value: unknown) => value is TypeMap["string"];
|
|
11
|
-
declare const isNumber: (value: unknown) => value is TypeMap["number"];
|
|
12
|
-
declare const isBigInt: (value: unknown) => value is TypeMap["bigint"];
|
|
13
|
-
declare const isBoolean: (value: unknown) => value is TypeMap["boolean"];
|
|
14
|
-
declare const isSymbol: (value: unknown) => value is TypeMap["symbol"];
|
|
15
|
-
declare const isObject: (value: unknown) => value is TypeMap["object"];
|
|
16
|
-
declare const isUndefined: (value: unknown) => value is TypeMap["undefined"];
|
|
17
|
-
declare const isNotNullish: <T>(value: T) => value is NonNullable<T>;
|
|
18
|
-
declare const isNullish: (value: unknown) => value is null | undefined;
|
|
19
|
-
declare const isTruthy: <T>(value: T | null | undefined) => value is T;
|
|
20
|
-
declare const isFullfilled: <T>(value: PromiseSettledResult<T>) => value is PromiseFulfilledResult<T>;
|
|
21
|
-
declare const isRejected: <T>(value: PromiseSettledResult<T>) => value is PromiseRejectedResult;
|
|
22
|
-
|
|
23
|
-
export { type TypeMap, isBigInt, isBoolean, isFullfilled, isNotNullish, isNullish, isNumber, isObject, isRejected, isString, isSymbol, isTruthy, isUndefined };
|
package/dist/math.d.cts
DELETED
package/dist/number.d.cts
DELETED
package/dist/ss58.d.cts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Bytelike, HexString } from './types.cjs';
|
|
2
|
-
import './chainflip.cjs';
|
|
3
|
-
|
|
4
|
-
declare const decode: (input: string) => {
|
|
5
|
-
data: Uint8Array;
|
|
6
|
-
ss58Format: number;
|
|
7
|
-
};
|
|
8
|
-
declare const encode: ({ data: input, ss58Format, }: {
|
|
9
|
-
data: Bytelike;
|
|
10
|
-
ss58Format: number;
|
|
11
|
-
}) => string;
|
|
12
|
-
declare const toPublicKey: (address: string) => HexString;
|
|
13
|
-
|
|
14
|
-
export { decode, encode, toPublicKey };
|
package/dist/string.d.cts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { HexString } from './types.cjs';
|
|
2
|
-
import './chainflip.cjs';
|
|
3
|
-
|
|
4
|
-
declare const toUpperCase: <const T extends string>(str: T) => Uppercase<T>;
|
|
5
|
-
declare const toLowerCase: <const T extends string>(str: T) => Lowercase<T>;
|
|
6
|
-
declare const isInteger: (string: string) => boolean;
|
|
7
|
-
type Split<T extends string, D extends string> = T extends `${infer L}${D}${infer R}` ? [L, ...Split<R, D>] : [T];
|
|
8
|
-
declare const split: <const T extends string, D extends string>(str: T, delimiter: D) => Split<T, D>;
|
|
9
|
-
declare const capitalize: <const T extends string>(str: T) => Capitalize<T>;
|
|
10
|
-
declare const uncapitalize: <const T extends string>(str: T) => Uncapitalize<T>;
|
|
11
|
-
declare const isHex: (str: string) => str is HexString;
|
|
12
|
-
declare const isBytes: (str: string) => boolean;
|
|
13
|
-
declare const abbreviate: (text: string | undefined | null, showLength?: number, space?: boolean) => string;
|
|
14
|
-
declare const truncateString: (string: string, numCharacters?: number, ellipsis?: boolean) => string;
|
|
15
|
-
|
|
16
|
-
export { abbreviate, capitalize, isBytes, isHex, isInteger, split, toLowerCase, toUpperCase, truncateString, uncapitalize };
|
package/dist/tickMath.d.cts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { ChainflipAsset } from './chainflip.cjs';
|
|
3
|
-
|
|
4
|
-
declare const MIN_TICK = -887272;
|
|
5
|
-
declare const MAX_TICK: number;
|
|
6
|
-
declare const FULL_TICK_RANGE: {
|
|
7
|
-
start: number;
|
|
8
|
-
end: number;
|
|
9
|
-
};
|
|
10
|
-
declare const tickToRate: (tick: number, baseAsset: ChainflipAsset) => number;
|
|
11
|
-
declare const rateToTick: (rate: BigNumber.Value, baseAsset: ChainflipAsset) => number;
|
|
12
|
-
declare const sqrtPriceX96ToPrice: (amount: string) => BigNumber;
|
|
13
|
-
declare const priceX128ToPrice: (amount: string) => BigNumber;
|
|
14
|
-
|
|
15
|
-
export { FULL_TICK_RANGE, MAX_TICK, MIN_TICK, priceX128ToPrice, rateToTick, sqrtPriceX96ToPrice, tickToRate };
|
package/dist/types.d.cts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { ChainflipAsset } from './chainflip.cjs';
|
|
2
|
-
|
|
3
|
-
type HexString = `0x${string}`;
|
|
4
|
-
type Bytelike = Uint8Array | number[] | HexString;
|
|
5
|
-
type CcmMetadata<Data = never> = {
|
|
6
|
-
channelMetadata: {
|
|
7
|
-
message: HexString;
|
|
8
|
-
gasBudget: HexString;
|
|
9
|
-
};
|
|
10
|
-
ccmAdditionalData: Data;
|
|
11
|
-
};
|
|
12
|
-
type VaultSwapData<Broker, CcmData = never> = {
|
|
13
|
-
amount: bigint;
|
|
14
|
-
destinationAddress: string;
|
|
15
|
-
inputAsset: ChainflipAsset;
|
|
16
|
-
outputAsset: ChainflipAsset;
|
|
17
|
-
depositChainBlockHeight: number | null;
|
|
18
|
-
brokerFee: {
|
|
19
|
-
account: Broker;
|
|
20
|
-
commissionBps: number;
|
|
21
|
-
};
|
|
22
|
-
affiliateFees: {
|
|
23
|
-
accountIndex: number;
|
|
24
|
-
commissionBps: number;
|
|
25
|
-
}[];
|
|
26
|
-
maxBoostFee: number;
|
|
27
|
-
dcaParams: {
|
|
28
|
-
chunkInterval: number;
|
|
29
|
-
numberOfChunks: number;
|
|
30
|
-
} | null;
|
|
31
|
-
refundParams: {
|
|
32
|
-
refundAddress: string;
|
|
33
|
-
minPrice: bigint;
|
|
34
|
-
retryDuration: number;
|
|
35
|
-
maxOraclePriceSlippage: number | null;
|
|
36
|
-
refundCcmMetadata: CcmMetadata<CcmData> | null;
|
|
37
|
-
};
|
|
38
|
-
ccmDepositMetadata: CcmMetadata<CcmData> | null;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export type { Bytelike, HexString, VaultSwapData };
|