@chainflip/utils 2.1.0-beta.0 → 2.1.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 → _rolldown/runtime.cjs} +1 -1
- package/dist/addresses.cjs +1 -0
- package/dist/{addresses.d.ts → addresses.d.cts} +1 -1
- package/dist/addresses.d.mts +7 -0
- package/dist/assertion.cjs +1 -0
- package/dist/assertion.d.mts +12 -0
- package/dist/{assertion.js → assertion.mjs} +1 -1
- package/dist/async.cjs +1 -0
- package/dist/async.d.mts +36 -0
- package/dist/base58.cjs +1 -0
- package/dist/{base58.d.ts → base58.d.cts} +1 -1
- package/dist/base58.d.mts +8 -0
- package/dist/{base58.js → base58.mjs} +1 -1
- package/dist/bytes.cjs +1 -0
- package/dist/{bytes.d.ts → bytes.d.cts} +1 -1
- package/dist/bytes.d.mts +11 -0
- package/dist/{bytes.js → bytes.mjs} +1 -1
- package/dist/chainflip.cjs +1 -0
- package/dist/chainflip.d.mts +239 -0
- package/dist/consts.cjs +9 -0
- package/dist/consts.d.mts +34 -0
- package/dist/{consts.js → consts.mjs} +8 -0
- package/dist/date.cjs +2 -1
- package/dist/date.d.mts +27 -0
- package/dist/{date.js → date.mjs} +1 -1
- package/dist/guard.cjs +1 -0
- package/dist/guard.d.mts +24 -0
- package/dist/math.cjs +1 -0
- package/dist/math.d.mts +5 -0
- package/dist/number.cjs +1 -0
- package/dist/{number.d.ts → number.d.cts} +1 -1
- package/dist/number.d.mts +6 -0
- package/dist/ss58.cjs +2 -1
- package/dist/{ss58.d.ts → ss58.d.cts} +1 -1
- package/dist/ss58.d.mts +17 -0
- package/dist/{ss58.js → ss58.mjs} +3 -3
- package/dist/string.cjs +1 -0
- package/dist/{string.d.ts → string.d.cts} +1 -1
- package/dist/string.d.mts +16 -0
- package/dist/tickMath.cjs +3 -2
- package/dist/{tickMath.d.ts → tickMath.d.cts} +1 -1
- package/dist/tickMath.d.mts +16 -0
- package/dist/{tickMath.js → tickMath.mjs} +1 -1
- package/dist/{types.d.ts → types.d.cts} +1 -1
- package/dist/types.d.mts +42 -0
- package/dist/url.cjs +1 -0
- package/dist/url.d.mts +7 -0
- package/package.json +4 -11
- /package/dist/{addresses.js → addresses.mjs} +0 -0
- /package/dist/{assertion.d.ts → assertion.d.cts} +0 -0
- /package/dist/{async.d.ts → async.d.cts} +0 -0
- /package/dist/{async.js → async.mjs} +0 -0
- /package/dist/{chainflip.d.ts → chainflip.d.cts} +0 -0
- /package/dist/{chainflip.js → chainflip.mjs} +0 -0
- /package/dist/{consts.d.ts → consts.d.cts} +0 -0
- /package/dist/{date.d.ts → date.d.cts} +0 -0
- /package/dist/{guard.d.ts → guard.d.cts} +0 -0
- /package/dist/{guard.js → guard.mjs} +0 -0
- /package/dist/{math.d.ts → math.d.cts} +0 -0
- /package/dist/{math.js → math.mjs} +0 -0
- /package/dist/{number.js → number.mjs} +0 -0
- /package/dist/{string.js → string.mjs} +0 -0
- /package/dist/{types.js → types.mjs} +0 -0
- /package/dist/{url.d.ts → url.d.cts} +0 -0
- /package/dist/{url.js → url.mjs} +0 -0
package/dist/addresses.cjs
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ChainflipNetwork } from "./chainflip.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/addresses.d.ts
|
|
4
|
+
declare const FLIP_CONTRACT_ADDRESSES: Record<ChainflipNetwork, `0x${string}`>;
|
|
5
|
+
declare const STATE_CHAIN_GATEWAY_ADDRESSES: Record<ChainflipNetwork, `0x${string}`>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { FLIP_CONTRACT_ADDRESSES, STATE_CHAIN_GATEWAY_ADDRESSES };
|
package/dist/assertion.cjs
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/assertion.d.ts
|
|
2
|
+
declare function assert(condition: unknown, message?: string, Constructor?: ErrorConstructor): asserts condition;
|
|
3
|
+
declare function assertString(value: unknown, message?: string): asserts value is string;
|
|
4
|
+
declare function assertNumber(value: unknown, message?: string): asserts value is number;
|
|
5
|
+
declare function assertBigInt(value: unknown, message?: string): asserts value is bigint;
|
|
6
|
+
declare function assertBoolean(value: unknown, message?: string): asserts value is boolean;
|
|
7
|
+
declare function assertSymbol(value: unknown, message?: string): asserts value is symbol;
|
|
8
|
+
declare function assertObject(value: unknown, message?: string): asserts value is object;
|
|
9
|
+
declare function assertUndefined(value: unknown, message?: string): asserts value is undefined;
|
|
10
|
+
declare const unreachable: (x: never, message?: string) => never;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { assert, assertBigInt, assertBoolean, assertNumber, assertObject, assertString, assertSymbol, assertUndefined, unreachable };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isBigInt, isBoolean, isNumber, isObject, isString, isSymbol, isUndefined } from "./guard.
|
|
1
|
+
import { isBigInt, isBoolean, isNumber, isObject, isString, isSymbol, isUndefined } from "./guard.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/assertion.ts
|
|
4
4
|
function assert(condition, message = "assertion failed", Constructor = Error) {
|
package/dist/async.cjs
CHANGED
package/dist/async.d.mts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/async.d.ts
|
|
2
|
+
declare const deferredPromise: <T>() => {
|
|
3
|
+
promise: Promise<T>;
|
|
4
|
+
resolve: (value: T) => void;
|
|
5
|
+
reject: (error: Error) => void;
|
|
6
|
+
};
|
|
7
|
+
type DeferredPromise<T> = ReturnType<typeof deferredPromise<T>>;
|
|
8
|
+
declare const sleep: (ms: number, {
|
|
9
|
+
signal
|
|
10
|
+
}?: {
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
declare class Queue {
|
|
14
|
+
private readonly debounce?;
|
|
15
|
+
private promise;
|
|
16
|
+
constructor(debounce?: number | undefined);
|
|
17
|
+
enqueue<T, Args extends unknown[]>(fn: (...args: Args) => Promise<T>, ...args: Args): Promise<T>;
|
|
18
|
+
}
|
|
19
|
+
declare class RateLimiter<T, Args extends unknown[]> {
|
|
20
|
+
fn: (...args: Args) => Promise<T>;
|
|
21
|
+
debounce: number;
|
|
22
|
+
queues: Queue[];
|
|
23
|
+
index: number;
|
|
24
|
+
constructor(opts: {
|
|
25
|
+
fn: (...args: Args) => Promise<T>;
|
|
26
|
+
debounce: number;
|
|
27
|
+
maxConcurrency: number;
|
|
28
|
+
});
|
|
29
|
+
request(...args: Args): Promise<T>;
|
|
30
|
+
}
|
|
31
|
+
declare const once: (target: EventTarget, event: string, opts?: {
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
timeout?: number;
|
|
34
|
+
}) => Promise<void>;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { DeferredPromise, Queue, RateLimiter, deferredPromise, once, sleep };
|
package/dist/base58.cjs
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Bytelike } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/base58.d.ts
|
|
4
|
+
declare const CHARSET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
5
|
+
declare const encode: (bytes: Bytelike) => string;
|
|
6
|
+
declare const decode: (input: string) => Uint8Array;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { CHARSET, decode, encode };
|
package/dist/bytes.cjs
CHANGED
package/dist/bytes.d.mts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Bytelike, HexString } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/bytes.d.ts
|
|
4
|
+
declare const bytesToHex: (input: Uint8Array | number[]) => `0x${string}`;
|
|
5
|
+
declare const hexToBytes: (input: HexString) => Uint8Array;
|
|
6
|
+
declare const encodeBytesWithCharset: (bytes: Bytelike, charset: string) => string;
|
|
7
|
+
declare const decodeBytesWithCharset: (input: string, charset: string) => Uint8Array;
|
|
8
|
+
declare function reverseBytes(input: HexString): HexString;
|
|
9
|
+
declare function reverseBytes(input: string): string;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { bytesToHex, decodeBytesWithCharset, encodeBytesWithCharset, hexToBytes, reverseBytes };
|
package/dist/chainflip.cjs
CHANGED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
//#region src/chainflip.d.ts
|
|
2
|
+
declare const chainflipAssets: readonly ["Usdc", "Usdt", "Wbtc", "Flip", "Eth", "Dot", "Btc", "ArbUsdc", "ArbUsdt", "ArbEth", "Sol", "SolUsdc", "SolUsdt", "HubDot", "HubUsdt", "HubUsdc"];
|
|
3
|
+
type ChainflipAsset = (typeof chainflipAssets)[number];
|
|
4
|
+
declare const assetSymbols: readonly ["USDC", "USDT", "WBTC", "FLIP", "DOT", "ETH", "BTC", "SOL"];
|
|
5
|
+
declare const priceAssets: readonly ["Btc", "Eth", "Sol", "Usdc", "Usdt", "Usd", "Fine"];
|
|
6
|
+
type PriceAsset = (typeof priceAssets)[number];
|
|
7
|
+
/** @deprecated use `assetSymbols` instead */
|
|
8
|
+
declare const rpcAssets: readonly ["USDC", "USDT", "WBTC", "FLIP", "DOT", "ETH", "BTC", "SOL"];
|
|
9
|
+
type AssetSymbol = (typeof assetSymbols)[number];
|
|
10
|
+
/** @deprecated use `AssetSymbol` instead */
|
|
11
|
+
type RpcAsset = AssetSymbol;
|
|
12
|
+
type BaseChainflipAsset = Exclude<ChainflipAsset, 'Usdc'>;
|
|
13
|
+
declare const baseChainflipAssets: BaseChainflipAsset[];
|
|
14
|
+
declare const chainflipEvmChains: readonly ["Ethereum", "Arbitrum"];
|
|
15
|
+
type ChainflipEvmChain = (typeof chainflipEvmChains)[number];
|
|
16
|
+
declare const chainflipChains: readonly ["Ethereum", "Arbitrum", "Bitcoin", "Polkadot", "Solana", "Assethub"];
|
|
17
|
+
type ChainflipChain = (typeof chainflipChains)[number];
|
|
18
|
+
declare const chainflipNetworks: readonly ["backspin", "sisyphos", "perseverance", "mainnet"];
|
|
19
|
+
type ChainflipNetwork = (typeof chainflipNetworks)[number];
|
|
20
|
+
declare const addressTypes: readonly ["Eth", "Btc", "Dot", "Arb", "Sol", "Hub"];
|
|
21
|
+
type AddressType = (typeof addressTypes)[number];
|
|
22
|
+
type AssetOfChain<C extends Exclude<ChainflipChain, 'Polkadot'>> = (typeof chainConstants)[C]['assets'][number];
|
|
23
|
+
type ChainAssetMap<T> = { [C in Exclude<ChainflipChain, 'Polkadot'>]: { [A in AssetOfChain<C>]: T } };
|
|
24
|
+
type BaseChainAssetMap<T> = { [C in Exclude<ChainflipChain, 'Polkadot'>]: { [A in Exclude<BaseChainflipAsset, 'Dot'> as Extract<(typeof assetConstants)[A], {
|
|
25
|
+
chain: C;
|
|
26
|
+
}>['symbol']]: T } };
|
|
27
|
+
type AssetAndChain = { [C in Exclude<ChainflipChain, 'Polkadot'>]: { [A in keyof ChainAssetMap<unknown>[C]]: {
|
|
28
|
+
chain: C;
|
|
29
|
+
asset: A;
|
|
30
|
+
} }[keyof ChainAssetMap<unknown>[C]] }[Exclude<ChainflipChain, 'Polkadot'>];
|
|
31
|
+
type BaseAssetAndChain = Exclude<AssetAndChain, {
|
|
32
|
+
chain: 'Ethereum';
|
|
33
|
+
asset: 'USDC';
|
|
34
|
+
}>;
|
|
35
|
+
type ChainMap<T> = { [C in Exclude<ChainflipChain, 'Polkadot'>]: T };
|
|
36
|
+
type InternalAssetMap<T> = { [A in Exclude<ChainflipAsset, 'Dot'>]: T };
|
|
37
|
+
type UncheckedAssetAndChain = {
|
|
38
|
+
chain: ChainflipChain;
|
|
39
|
+
asset: AssetSymbol;
|
|
40
|
+
};
|
|
41
|
+
declare function readAssetValue<T>(map: ChainAssetMap<T>, asset: ChainflipAsset | BaseChainflipAsset): T;
|
|
42
|
+
declare function readAssetValue<T>(map: BaseChainAssetMap<T>, asset: BaseChainflipAsset): T;
|
|
43
|
+
declare function readAssetValue<T>(map: ChainAssetMap<T> | BaseChainAssetMap<T>, asset: BaseChainflipAsset): T;
|
|
44
|
+
declare const assetConstants: {
|
|
45
|
+
readonly Eth: {
|
|
46
|
+
readonly chain: "Ethereum";
|
|
47
|
+
readonly symbol: "ETH";
|
|
48
|
+
readonly rpcAsset: "ETH";
|
|
49
|
+
readonly decimals: 18;
|
|
50
|
+
};
|
|
51
|
+
readonly Flip: {
|
|
52
|
+
readonly chain: "Ethereum";
|
|
53
|
+
readonly symbol: "FLIP";
|
|
54
|
+
readonly rpcAsset: "FLIP";
|
|
55
|
+
readonly decimals: 18;
|
|
56
|
+
};
|
|
57
|
+
readonly Usdc: {
|
|
58
|
+
readonly chain: "Ethereum";
|
|
59
|
+
readonly symbol: "USDC";
|
|
60
|
+
readonly rpcAsset: "USDC";
|
|
61
|
+
readonly decimals: 6;
|
|
62
|
+
};
|
|
63
|
+
readonly Usdt: {
|
|
64
|
+
readonly chain: "Ethereum";
|
|
65
|
+
readonly symbol: "USDT";
|
|
66
|
+
readonly rpcAsset: "USDT";
|
|
67
|
+
readonly decimals: 6;
|
|
68
|
+
};
|
|
69
|
+
readonly Wbtc: {
|
|
70
|
+
readonly chain: "Ethereum";
|
|
71
|
+
readonly symbol: "WBTC";
|
|
72
|
+
readonly rpcAsset: "WBTC";
|
|
73
|
+
readonly decimals: 8;
|
|
74
|
+
};
|
|
75
|
+
readonly Dot: {
|
|
76
|
+
readonly chain: "Polkadot";
|
|
77
|
+
readonly symbol: "DOT";
|
|
78
|
+
readonly rpcAsset: "DOT";
|
|
79
|
+
readonly decimals: 10;
|
|
80
|
+
};
|
|
81
|
+
readonly Btc: {
|
|
82
|
+
readonly chain: "Bitcoin";
|
|
83
|
+
readonly symbol: "BTC";
|
|
84
|
+
readonly rpcAsset: "BTC";
|
|
85
|
+
readonly decimals: 8;
|
|
86
|
+
};
|
|
87
|
+
readonly ArbUsdc: {
|
|
88
|
+
readonly chain: "Arbitrum";
|
|
89
|
+
readonly symbol: "USDC";
|
|
90
|
+
readonly rpcAsset: "USDC";
|
|
91
|
+
readonly decimals: 6;
|
|
92
|
+
};
|
|
93
|
+
readonly ArbUsdt: {
|
|
94
|
+
readonly chain: "Arbitrum";
|
|
95
|
+
readonly symbol: "USDT";
|
|
96
|
+
readonly rpcAsset: "USDT";
|
|
97
|
+
readonly decimals: 6;
|
|
98
|
+
};
|
|
99
|
+
readonly ArbEth: {
|
|
100
|
+
readonly chain: "Arbitrum";
|
|
101
|
+
readonly symbol: "ETH";
|
|
102
|
+
readonly rpcAsset: "ETH";
|
|
103
|
+
readonly decimals: 18;
|
|
104
|
+
};
|
|
105
|
+
readonly Sol: {
|
|
106
|
+
readonly chain: "Solana";
|
|
107
|
+
readonly symbol: "SOL";
|
|
108
|
+
readonly rpcAsset: "SOL";
|
|
109
|
+
readonly decimals: 9;
|
|
110
|
+
};
|
|
111
|
+
readonly SolUsdc: {
|
|
112
|
+
readonly chain: "Solana";
|
|
113
|
+
readonly symbol: "USDC";
|
|
114
|
+
readonly rpcAsset: "USDC";
|
|
115
|
+
readonly decimals: 6;
|
|
116
|
+
};
|
|
117
|
+
readonly SolUsdt: {
|
|
118
|
+
readonly chain: "Solana";
|
|
119
|
+
readonly symbol: "USDT";
|
|
120
|
+
readonly rpcAsset: "USDT";
|
|
121
|
+
readonly decimals: 6;
|
|
122
|
+
};
|
|
123
|
+
readonly HubDot: {
|
|
124
|
+
readonly chain: "Assethub";
|
|
125
|
+
readonly symbol: "DOT";
|
|
126
|
+
readonly rpcAsset: "DOT";
|
|
127
|
+
readonly decimals: 10;
|
|
128
|
+
};
|
|
129
|
+
readonly HubUsdc: {
|
|
130
|
+
readonly chain: "Assethub";
|
|
131
|
+
readonly symbol: "USDC";
|
|
132
|
+
readonly rpcAsset: "USDC";
|
|
133
|
+
readonly decimals: 6;
|
|
134
|
+
};
|
|
135
|
+
readonly HubUsdt: {
|
|
136
|
+
readonly chain: "Assethub";
|
|
137
|
+
readonly symbol: "USDT";
|
|
138
|
+
readonly rpcAsset: "USDT";
|
|
139
|
+
readonly decimals: 6;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
declare const chainConstants: {
|
|
143
|
+
readonly Ethereum: {
|
|
144
|
+
readonly chainflipAssets: ["Eth", "Flip", "Usdc", "Usdt", "Wbtc"];
|
|
145
|
+
readonly assets: ["ETH", "FLIP", "USDC", "USDT", "WBTC"];
|
|
146
|
+
readonly rpcAssets: ["ETH", "FLIP", "USDC", "USDT", "WBTC"];
|
|
147
|
+
readonly gasAsset: "Eth";
|
|
148
|
+
readonly addressType: "Eth";
|
|
149
|
+
readonly blockTimeSeconds: 12;
|
|
150
|
+
};
|
|
151
|
+
readonly Polkadot: {
|
|
152
|
+
readonly chainflipAssets: ["Dot"];
|
|
153
|
+
readonly assets: ["DOT"];
|
|
154
|
+
readonly rpcAssets: ["DOT"];
|
|
155
|
+
readonly gasAsset: "Dot";
|
|
156
|
+
readonly addressType: "Dot";
|
|
157
|
+
readonly blockTimeSeconds: 6;
|
|
158
|
+
};
|
|
159
|
+
readonly Bitcoin: {
|
|
160
|
+
readonly chainflipAssets: ["Btc"];
|
|
161
|
+
readonly assets: ["BTC"];
|
|
162
|
+
readonly rpcAssets: ["BTC"];
|
|
163
|
+
readonly gasAsset: "Btc";
|
|
164
|
+
readonly addressType: "Btc";
|
|
165
|
+
readonly blockTimeSeconds: number;
|
|
166
|
+
};
|
|
167
|
+
readonly Arbitrum: {
|
|
168
|
+
readonly chainflipAssets: ["ArbUsdc", "ArbUsdt", "ArbEth"];
|
|
169
|
+
readonly assets: ["USDC", "USDT", "ETH"];
|
|
170
|
+
readonly rpcAssets: ["USDC", "USDT", "ETH"];
|
|
171
|
+
readonly gasAsset: "ArbEth";
|
|
172
|
+
readonly addressType: "Arb";
|
|
173
|
+
readonly blockTimeSeconds: 0.26;
|
|
174
|
+
};
|
|
175
|
+
readonly Solana: {
|
|
176
|
+
readonly chainflipAssets: ["Sol", "SolUsdc", "SolUsdt"];
|
|
177
|
+
readonly assets: ["SOL", "USDC", "USDT"];
|
|
178
|
+
readonly rpcAssets: ["SOL", "USDC", "USDT"];
|
|
179
|
+
readonly gasAsset: "Sol";
|
|
180
|
+
readonly addressType: "Sol";
|
|
181
|
+
readonly blockTimeSeconds: 0.8;
|
|
182
|
+
};
|
|
183
|
+
readonly Assethub: {
|
|
184
|
+
readonly chainflipAssets: ["HubDot", "HubUsdt", "HubUsdc"];
|
|
185
|
+
readonly assets: ["DOT", "USDT", "USDC"];
|
|
186
|
+
readonly rpcAssets: ["DOT", "USDT", "USDC"];
|
|
187
|
+
readonly gasAsset: "HubDot";
|
|
188
|
+
readonly addressType: "Hub";
|
|
189
|
+
readonly blockTimeSeconds: 12;
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
declare const internalAssetToRpcAsset: InternalAssetMap<AssetAndChain> & {
|
|
193
|
+
Dot: {
|
|
194
|
+
chain: 'Polkadot';
|
|
195
|
+
asset: 'DOT';
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
declare const chainContractId: ChainMap<number> & {
|
|
199
|
+
Polkadot: 2;
|
|
200
|
+
};
|
|
201
|
+
declare const assetContractId: InternalAssetMap<number> & {
|
|
202
|
+
Dot: 4;
|
|
203
|
+
};
|
|
204
|
+
declare function getInternalAsset(asset: BaseAssetAndChain): BaseChainflipAsset;
|
|
205
|
+
declare function getInternalAsset(asset: AssetAndChain): ChainflipAsset;
|
|
206
|
+
declare function getInternalAsset(asset: UncheckedAssetAndChain): ChainflipAsset;
|
|
207
|
+
declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: true): ChainflipAsset;
|
|
208
|
+
declare function getInternalAsset(asset: UncheckedAssetAndChain, assert: boolean): ChainflipAsset | null;
|
|
209
|
+
declare function isValidAssetAndChain(assetAndChain: UncheckedAssetAndChain): assetAndChain is AssetAndChain;
|
|
210
|
+
declare function getInternalAssets(data: {
|
|
211
|
+
srcAsset: AssetSymbol;
|
|
212
|
+
srcChain: ChainflipChain;
|
|
213
|
+
destAsset: AssetSymbol;
|
|
214
|
+
destChain: ChainflipChain;
|
|
215
|
+
}): {
|
|
216
|
+
srcAsset: ChainflipAsset;
|
|
217
|
+
destAsset: ChainflipAsset;
|
|
218
|
+
};
|
|
219
|
+
declare function getInternalAssets(data: {
|
|
220
|
+
srcAsset: AssetSymbol;
|
|
221
|
+
srcChain: ChainflipChain;
|
|
222
|
+
destAsset: AssetSymbol;
|
|
223
|
+
destChain: ChainflipChain;
|
|
224
|
+
}, assert: true): {
|
|
225
|
+
srcAsset: ChainflipAsset;
|
|
226
|
+
destAsset: ChainflipAsset;
|
|
227
|
+
};
|
|
228
|
+
declare function getInternalAssets(data: {
|
|
229
|
+
srcAsset: AssetSymbol;
|
|
230
|
+
srcChain: ChainflipChain;
|
|
231
|
+
destAsset: AssetSymbol;
|
|
232
|
+
destChain: ChainflipChain;
|
|
233
|
+
}, assert: boolean): {
|
|
234
|
+
srcAsset: ChainflipAsset | null;
|
|
235
|
+
destAsset: ChainflipAsset | null;
|
|
236
|
+
};
|
|
237
|
+
declare const chainflipAssetToPriceAssetMap: Record<ChainflipAsset, Exclude<PriceAsset, 'Usd'> | null>;
|
|
238
|
+
//#endregion
|
|
239
|
+
export { AddressType, AssetAndChain, AssetOfChain, AssetSymbol, BaseAssetAndChain, BaseChainAssetMap, BaseChainflipAsset, ChainAssetMap, ChainMap, ChainflipAsset, ChainflipChain, ChainflipEvmChain, ChainflipNetwork, InternalAssetMap, PriceAsset, RpcAsset, UncheckedAssetAndChain, addressTypes, assetConstants, assetContractId, assetSymbols, baseChainflipAssets, chainConstants, chainContractId, chainflipAssetToPriceAssetMap, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, getInternalAsset, getInternalAssets, internalAssetToRpcAsset, isValidAssetAndChain, priceAssets, readAssetValue, rpcAssets };
|
package/dist/consts.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
1
2
|
|
|
2
3
|
//#region src/consts.ts
|
|
3
4
|
const HEARTBEAT_BLOCK_INTERVAL = 150;
|
|
@@ -202,6 +203,14 @@ const brokerAliasMap = {
|
|
|
202
203
|
cFJt567jd8vooomo6z86sS9qenBodSYyPb6CKgqGESYJS4cFG: {
|
|
203
204
|
name: "Ellipal Wallet",
|
|
204
205
|
twitter: "@ellipalwallet"
|
|
206
|
+
},
|
|
207
|
+
cFPZ7XoAWHFBJy2t2t5rupQ3fvMKRyCpxDHjnmtD42XAEjxcW: {
|
|
208
|
+
name: "SafePal",
|
|
209
|
+
twitter: "@SafePal"
|
|
210
|
+
},
|
|
211
|
+
cFNqDaZ9apGKt9uXaGQGucWuizVeTms2cXq8hnYM8g7y99Cpy: {
|
|
212
|
+
name: "Trocador",
|
|
213
|
+
twitter: "@TrocadorApp"
|
|
205
214
|
}
|
|
206
215
|
};
|
|
207
216
|
const lpAliasMap = {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/consts.d.ts
|
|
2
|
+
declare const HEARTBEAT_BLOCK_INTERVAL = 150;
|
|
3
|
+
declare const CHAINFLIP_SS58_PREFIX = 2112;
|
|
4
|
+
declare const POLKADOT_SS58_PREFIX = 0;
|
|
5
|
+
declare const CHAINFLIP_BLOCK_TIME_SECONDS = 6;
|
|
6
|
+
declare const CHAINFLIP_BLOCKS_PER_YEAR = 5256000;
|
|
7
|
+
declare const chainflipLinks: {
|
|
8
|
+
website: string;
|
|
9
|
+
discord: string;
|
|
10
|
+
twitter: string;
|
|
11
|
+
telegram: string;
|
|
12
|
+
blog: string;
|
|
13
|
+
docs: string;
|
|
14
|
+
};
|
|
15
|
+
declare const chainflipCommunityLinks: {
|
|
16
|
+
discord: string;
|
|
17
|
+
twitter: string;
|
|
18
|
+
telegram: string;
|
|
19
|
+
};
|
|
20
|
+
type AccountAliasMap = {
|
|
21
|
+
[account: string]: {
|
|
22
|
+
name: string;
|
|
23
|
+
twitter: string | null;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
declare const smartContractAliasMap: {
|
|
27
|
+
'0xce16f69375520ab01377ce7b88f5ba8c48f8d666': string;
|
|
28
|
+
'0xd99ac0681b904991169a4f398b9043781adbe0c3': string;
|
|
29
|
+
};
|
|
30
|
+
declare const brokerAliasMap: AccountAliasMap;
|
|
31
|
+
declare const lpAliasMap: AccountAliasMap;
|
|
32
|
+
declare const GENESIS_LP_ACCOUNT_IDS: string[];
|
|
33
|
+
//#endregion
|
|
34
|
+
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 };
|
|
@@ -201,6 +201,14 @@ const brokerAliasMap = {
|
|
|
201
201
|
cFJt567jd8vooomo6z86sS9qenBodSYyPb6CKgqGESYJS4cFG: {
|
|
202
202
|
name: "Ellipal Wallet",
|
|
203
203
|
twitter: "@ellipalwallet"
|
|
204
|
+
},
|
|
205
|
+
cFPZ7XoAWHFBJy2t2t5rupQ3fvMKRyCpxDHjnmtD42XAEjxcW: {
|
|
206
|
+
name: "SafePal",
|
|
207
|
+
twitter: "@SafePal"
|
|
208
|
+
},
|
|
209
|
+
cFNqDaZ9apGKt9uXaGQGucWuizVeTms2cXq8hnYM8g7y99Cpy: {
|
|
210
|
+
name: "Trocador",
|
|
211
|
+
twitter: "@TrocadorApp"
|
|
204
212
|
}
|
|
205
213
|
};
|
|
206
214
|
const lpAliasMap = {
|
package/dist/date.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
const require_guard = require('./guard.cjs');
|
|
3
4
|
let _date_fns_utc = require("@date-fns/utc");
|
|
4
5
|
let date_fns = require("date-fns");
|
package/dist/date.d.mts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { UTCDate } from "@date-fns/utc";
|
|
2
|
+
import { DateArg, Interval } from "date-fns";
|
|
3
|
+
|
|
4
|
+
//#region src/date.d.ts
|
|
5
|
+
declare const toISODateString: (date: Date) => string;
|
|
6
|
+
declare const fromUnixTime: (time: string | number) => Date;
|
|
7
|
+
declare const formatTimestamp: (timestamp: string, locale?: string | undefined, timeZone?: undefined | "UTC") => string;
|
|
8
|
+
declare const formatTimestampShort: (timestamp: string, locale?: string | undefined, timeZone?: undefined | "UTC") => string;
|
|
9
|
+
declare const differenceInTimeAgo: (time: string, ago?: boolean, endTime?: string) => string;
|
|
10
|
+
declare const intervalToDurationWords: (interval: Interval) => string;
|
|
11
|
+
type FNSDate = DateArg<Date>;
|
|
12
|
+
declare const subUtcDays: (date: FNSDate, days: number) => UTCDate;
|
|
13
|
+
declare const addUtcDays: (date: FNSDate, days: number) => UTCDate;
|
|
14
|
+
declare const toStartOfUtcDay: (date: FNSDate) => UTCDate;
|
|
15
|
+
declare const toStartOfUtcDayString: (date: FNSDate) => string;
|
|
16
|
+
declare const toEndOfUtcDay: (date: FNSDate) => UTCDate;
|
|
17
|
+
declare const toEndOfUtcDayString: (date: FNSDate) => string;
|
|
18
|
+
declare const differenceInUtcDays: (interval: {
|
|
19
|
+
start: FNSDate;
|
|
20
|
+
end: FNSDate;
|
|
21
|
+
}) => number;
|
|
22
|
+
declare const eachUtcDayOfInterval: (interval: {
|
|
23
|
+
start: FNSDate;
|
|
24
|
+
end: FNSDate;
|
|
25
|
+
}) => UTCDate[];
|
|
26
|
+
//#endregion
|
|
27
|
+
export { addUtcDays, differenceInTimeAgo, differenceInUtcDays, eachUtcDayOfInterval, formatTimestamp, formatTimestampShort, fromUnixTime, intervalToDurationWords, subUtcDays, toEndOfUtcDay, toEndOfUtcDayString, toISODateString, toStartOfUtcDay, toStartOfUtcDayString };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isNullish } from "./guard.
|
|
1
|
+
import { isNullish } from "./guard.mjs";
|
|
2
2
|
import { utc } from "@date-fns/utc";
|
|
3
3
|
import { addDays, differenceInDays, differenceInHours, differenceInMinutes, differenceInSeconds, eachDayOfInterval, endOfDay, intervalToDuration, startOfDay, subDays } from "date-fns";
|
|
4
4
|
|
package/dist/guard.cjs
CHANGED
package/dist/guard.d.mts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/guard.d.ts
|
|
2
|
+
type TypeMap = {
|
|
3
|
+
string: string;
|
|
4
|
+
number: number;
|
|
5
|
+
bigint: bigint;
|
|
6
|
+
boolean: boolean;
|
|
7
|
+
symbol: symbol;
|
|
8
|
+
object: object;
|
|
9
|
+
undefined: undefined;
|
|
10
|
+
};
|
|
11
|
+
declare const isString: (value: unknown) => value is TypeMap["string"];
|
|
12
|
+
declare const isNumber: (value: unknown) => value is TypeMap["number"];
|
|
13
|
+
declare const isBigInt: (value: unknown) => value is TypeMap["bigint"];
|
|
14
|
+
declare const isBoolean: (value: unknown) => value is TypeMap["boolean"];
|
|
15
|
+
declare const isSymbol: (value: unknown) => value is TypeMap["symbol"];
|
|
16
|
+
declare const isObject: (value: unknown) => value is TypeMap["object"];
|
|
17
|
+
declare const isUndefined: (value: unknown) => value is TypeMap["undefined"];
|
|
18
|
+
declare const isNotNullish: <T>(value: T) => value is NonNullable<T>;
|
|
19
|
+
declare const isNullish: (value: unknown) => value is null | undefined;
|
|
20
|
+
declare const isTruthy: <T>(value: T | null | undefined) => value is T;
|
|
21
|
+
declare const isFullfilled: <T>(value: PromiseSettledResult<T>) => value is PromiseFulfilledResult<T>;
|
|
22
|
+
declare const isRejected: <T>(value: PromiseSettledResult<T>) => value is PromiseRejectedResult;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { TypeMap, isBigInt, isBoolean, isFullfilled, isNotNullish, isNullish, isNumber, isObject, isRejected, isString, isSymbol, isTruthy, isUndefined };
|
package/dist/math.cjs
CHANGED
package/dist/math.d.mts
ADDED
package/dist/number.cjs
CHANGED
package/dist/ss58.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
const require_assertion = require('./assertion.cjs');
|
|
3
4
|
const require_bytes = require('./bytes.cjs');
|
|
4
5
|
const require_base58 = require('./base58.cjs');
|
package/dist/ss58.d.mts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Bytelike, HexString } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/ss58.d.ts
|
|
4
|
+
declare const decode: (input: string) => {
|
|
5
|
+
data: Uint8Array;
|
|
6
|
+
ss58Format: number;
|
|
7
|
+
};
|
|
8
|
+
declare const encode: ({
|
|
9
|
+
data: input,
|
|
10
|
+
ss58Format
|
|
11
|
+
}: {
|
|
12
|
+
data: Bytelike;
|
|
13
|
+
ss58Format: number;
|
|
14
|
+
}) => string;
|
|
15
|
+
declare const toPublicKey: (address: string) => HexString;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { decode, encode, toPublicKey };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { assert } from "./assertion.
|
|
2
|
-
import { bytesToHex, hexToBytes } from "./bytes.
|
|
3
|
-
import { decode as decode$1, encode as encode$1 } from "./base58.
|
|
1
|
+
import { assert } from "./assertion.mjs";
|
|
2
|
+
import { bytesToHex, hexToBytes } from "./bytes.mjs";
|
|
3
|
+
import { decode as decode$1, encode as encode$1 } from "./base58.mjs";
|
|
4
4
|
import { blake2b } from "@noble/hashes/blake2.js";
|
|
5
5
|
|
|
6
6
|
//#region src/ss58.ts
|
package/dist/string.cjs
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HexString } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/string.d.ts
|
|
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
|
+
//#endregion
|
|
16
|
+
export { abbreviate, capitalize, isBytes, isHex, isInteger, split, toLowerCase, toUpperCase, truncateString, uncapitalize };
|
package/dist/tickMath.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
3
|
const require_chainflip = require('./chainflip.cjs');
|
|
3
4
|
let bignumber_js = require("bignumber.js");
|
|
4
|
-
bignumber_js =
|
|
5
|
+
bignumber_js = require_runtime.__toESM(bignumber_js);
|
|
5
6
|
|
|
6
7
|
//#region src/tickMath.ts
|
|
7
8
|
const MIN_TICK = -887272;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ChainflipAsset } from "./chainflip.mjs";
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
|
|
4
|
+
//#region src/tickMath.d.ts
|
|
5
|
+
declare const MIN_TICK = -887272;
|
|
6
|
+
declare const MAX_TICK: number;
|
|
7
|
+
declare const FULL_TICK_RANGE: {
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
};
|
|
11
|
+
declare const tickToRate: (tick: number, baseAsset: ChainflipAsset) => number;
|
|
12
|
+
declare const rateToTick: (rate: BigNumber.Value, baseAsset: ChainflipAsset) => number;
|
|
13
|
+
declare const sqrtPriceX96ToPrice: (amount: string) => BigNumber;
|
|
14
|
+
declare const priceX128ToPrice: (amount: string) => BigNumber;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { FULL_TICK_RANGE, MAX_TICK, MIN_TICK, priceX128ToPrice, rateToTick, sqrtPriceX96ToPrice, tickToRate };
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ChainflipAsset } from "./chainflip.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
type HexString = `0x${string}`;
|
|
5
|
+
type Bytelike = Uint8Array | number[] | HexString;
|
|
6
|
+
type CcmMetadata<Data = never> = {
|
|
7
|
+
channelMetadata: {
|
|
8
|
+
message: HexString;
|
|
9
|
+
gasBudget: HexString;
|
|
10
|
+
};
|
|
11
|
+
ccmAdditionalData: Data;
|
|
12
|
+
};
|
|
13
|
+
type VaultSwapData<Broker, CcmData = never> = {
|
|
14
|
+
amount: bigint;
|
|
15
|
+
destinationAddress: string;
|
|
16
|
+
inputAsset: ChainflipAsset;
|
|
17
|
+
outputAsset: ChainflipAsset;
|
|
18
|
+
depositChainBlockHeight: number | null;
|
|
19
|
+
brokerFee: {
|
|
20
|
+
account: Broker;
|
|
21
|
+
commissionBps: number;
|
|
22
|
+
};
|
|
23
|
+
affiliateFees: {
|
|
24
|
+
accountIndex: number;
|
|
25
|
+
commissionBps: number;
|
|
26
|
+
}[];
|
|
27
|
+
maxBoostFee: number;
|
|
28
|
+
dcaParams: {
|
|
29
|
+
chunkInterval: number;
|
|
30
|
+
numberOfChunks: number;
|
|
31
|
+
} | null;
|
|
32
|
+
refundParams: {
|
|
33
|
+
refundAddress: string;
|
|
34
|
+
minPrice: bigint;
|
|
35
|
+
retryDuration: number;
|
|
36
|
+
maxOraclePriceSlippage: number | null;
|
|
37
|
+
refundCcmMetadata: CcmMetadata<CcmData> | null;
|
|
38
|
+
};
|
|
39
|
+
ccmDepositMetadata: CcmMetadata<CcmData> | null;
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { Bytelike, HexString, VaultSwapData };
|
package/dist/url.cjs
CHANGED
package/dist/url.d.mts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/utils",
|
|
3
|
-
"version": "2.1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -9,22 +9,15 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
"./*": {
|
|
11
11
|
"require": {
|
|
12
|
-
"types": "./dist/*.d.
|
|
12
|
+
"types": "./dist/*.d.cts",
|
|
13
13
|
"default": "./dist/*.cjs"
|
|
14
14
|
},
|
|
15
15
|
"import": {
|
|
16
|
-
"types": "./dist/*.d.
|
|
17
|
-
"default": "./dist/*.
|
|
16
|
+
"types": "./dist/*.d.mts",
|
|
17
|
+
"default": "./dist/*.mjs"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
|
-
"typesVersions": {
|
|
22
|
-
"*": {
|
|
23
|
-
"*": [
|
|
24
|
-
"dist/*.d.ts"
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
21
|
"devDependencies": {
|
|
29
22
|
"@vitest/ui": "4.0.18"
|
|
30
23
|
},
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{url.js → url.mjs}
RENAMED
|
File without changes
|