@chainflip/sdk 1.4.0-alpha.2 → 1.4.0-alpha.4

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.
@@ -0,0 +1,211 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
+ var __publicField = (obj, key, value) => {
5
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
+ return value;
7
+ };
8
+
9
+ // ../shared/src/enums.ts
10
+ var arrayToMap = /* @__PURE__ */ __name((array) => Object.fromEntries(array.map((key) => [
11
+ key,
12
+ key
13
+ ])), "arrayToMap");
14
+ var InternalAssets = arrayToMap([
15
+ "Flip",
16
+ "Usdc",
17
+ "Dot",
18
+ "Eth",
19
+ "Btc",
20
+ "Usdt",
21
+ "ArbUsdc",
22
+ "ArbEth"
23
+ ]);
24
+ var Chains = arrayToMap([
25
+ "Bitcoin",
26
+ "Ethereum",
27
+ "Polkadot",
28
+ "Arbitrum"
29
+ ]);
30
+ var Assets = arrayToMap([
31
+ "FLIP",
32
+ "USDC",
33
+ "DOT",
34
+ "ETH",
35
+ "BTC",
36
+ "USDT"
37
+ ]);
38
+ var ChainflipNetworks = arrayToMap([
39
+ "backspin",
40
+ "sisyphos",
41
+ "perseverance",
42
+ "mainnet"
43
+ ]);
44
+ var isTestnet = /* @__PURE__ */ __name((network) => network !== ChainflipNetworks.mainnet, "isTestnet");
45
+ var assetConstants = {
46
+ [InternalAssets.Eth]: {
47
+ chain: Chains.Ethereum,
48
+ asset: Assets.ETH,
49
+ name: "Ether",
50
+ decimals: 18,
51
+ contractId: 1
52
+ },
53
+ [InternalAssets.Flip]: {
54
+ chain: Chains.Ethereum,
55
+ asset: Assets.FLIP,
56
+ name: "FLIP",
57
+ decimals: 18,
58
+ contractId: 2
59
+ },
60
+ [InternalAssets.Usdc]: {
61
+ chain: Chains.Ethereum,
62
+ asset: Assets.USDC,
63
+ name: "USDC",
64
+ decimals: 6,
65
+ contractId: 3
66
+ },
67
+ [InternalAssets.Usdt]: {
68
+ chain: Chains.Ethereum,
69
+ asset: Assets.USDT,
70
+ name: "USDT",
71
+ decimals: 6,
72
+ contractId: 8
73
+ },
74
+ [InternalAssets.Dot]: {
75
+ chain: Chains.Polkadot,
76
+ asset: Assets.DOT,
77
+ name: "Polkadot",
78
+ decimals: 10,
79
+ contractId: 4
80
+ },
81
+ [InternalAssets.Btc]: {
82
+ chain: Chains.Bitcoin,
83
+ asset: Assets.BTC,
84
+ name: "Bitcoin",
85
+ decimals: 8,
86
+ contractId: 5
87
+ },
88
+ [InternalAssets.ArbEth]: {
89
+ chain: Chains.Arbitrum,
90
+ asset: Assets.ETH,
91
+ name: "Arbitrum Ether",
92
+ decimals: 18,
93
+ contractId: 6
94
+ },
95
+ [InternalAssets.ArbUsdc]: {
96
+ chain: Chains.Arbitrum,
97
+ asset: Assets.USDC,
98
+ name: "Arbitrum USDC",
99
+ decimals: 6,
100
+ contractId: 7
101
+ }
102
+ };
103
+ var chainConstants = {
104
+ [Chains.Ethereum]: {
105
+ assets: [
106
+ Assets.ETH,
107
+ Assets.FLIP,
108
+ Assets.USDC,
109
+ Assets.USDT
110
+ ],
111
+ gasAsset: Assets.ETH,
112
+ contractId: 1,
113
+ blockTimeSeconds: 12
114
+ },
115
+ [Chains.Polkadot]: {
116
+ assets: [
117
+ Assets.DOT
118
+ ],
119
+ gasAsset: Assets.DOT,
120
+ contractId: 2,
121
+ blockTimeSeconds: 6
122
+ },
123
+ [Chains.Bitcoin]: {
124
+ assets: [
125
+ Assets.BTC
126
+ ],
127
+ gasAsset: Assets.BTC,
128
+ contractId: 3,
129
+ blockTimeSeconds: 10 * 60
130
+ },
131
+ [Chains.Arbitrum]: {
132
+ assets: [
133
+ Assets.ETH,
134
+ Assets.USDC
135
+ ],
136
+ gasAsset: Assets.ETH,
137
+ contractId: 4,
138
+ blockTimeSeconds: 0.26
139
+ }
140
+ };
141
+ function isValidAssetAndChain(assetAndChain) {
142
+ const { asset, chain } = assetAndChain;
143
+ if (!(chain in Chains))
144
+ return false;
145
+ const validAssets = chainConstants[chain].assets;
146
+ return validAssets.includes(asset);
147
+ }
148
+ __name(isValidAssetAndChain, "isValidAssetAndChain");
149
+ var readChainAssetValue = /* @__PURE__ */ __name((map, asset) => {
150
+ const { chain, asset: symbol } = assetConstants[asset];
151
+ const chainValues = map[chain];
152
+ return chainValues[symbol];
153
+ }, "readChainAssetValue");
154
+ function getInternalAsset(asset, assert2 = true) {
155
+ if (!isValidAssetAndChain(asset)) {
156
+ if (assert2) {
157
+ throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
158
+ }
159
+ return null;
160
+ }
161
+ const map = {
162
+ [Chains.Ethereum]: {
163
+ [Assets.USDC]: InternalAssets.Usdc,
164
+ [Assets.FLIP]: InternalAssets.Flip,
165
+ [Assets.ETH]: InternalAssets.Eth,
166
+ [Assets.USDT]: InternalAssets.Usdt
167
+ },
168
+ [Chains.Bitcoin]: {
169
+ [Assets.BTC]: InternalAssets.Btc
170
+ },
171
+ [Chains.Polkadot]: {
172
+ [Assets.DOT]: InternalAssets.Dot
173
+ },
174
+ [Chains.Arbitrum]: {
175
+ [Assets.USDC]: InternalAssets.ArbUsdc,
176
+ [Assets.ETH]: InternalAssets.ArbEth
177
+ }
178
+ };
179
+ const chain = map[asset.chain];
180
+ return chain[asset.asset];
181
+ }
182
+ __name(getInternalAsset, "getInternalAsset");
183
+ function getInternalAssets({ srcAsset, srcChain, destAsset, destChain }, assert2 = true) {
184
+ return {
185
+ srcAsset: getInternalAsset({
186
+ asset: srcAsset,
187
+ chain: srcChain
188
+ }, assert2),
189
+ destAsset: getInternalAsset({
190
+ asset: destAsset,
191
+ chain: destChain
192
+ }, assert2)
193
+ };
194
+ }
195
+ __name(getInternalAssets, "getInternalAssets");
196
+
197
+ // ../shared/src/guards.ts
198
+ var isString = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
199
+ var isNotNullish = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isNotNullish");
200
+ function assert(condition, message) {
201
+ if (condition)
202
+ return;
203
+ const error = new Error(message);
204
+ if (error.stack) {
205
+ error.stack = error.stack.replace(/\n.+/, "\n");
206
+ }
207
+ throw error;
208
+ }
209
+ __name(assert, "assert");
210
+
211
+ export { Assets, ChainflipNetworks, Chains, InternalAssets, __name, __publicField, assert, assetConstants, chainConstants, getInternalAsset, getInternalAssets, isNotNullish, isString, isTestnet, isValidAssetAndChain, readChainAssetValue };
@@ -40,6 +40,14 @@ type UncheckedAssetAndChain = {
40
40
  asset: Asset;
41
41
  chain: Chain;
42
42
  };
43
+ type AssetAndChain = {
44
+ [C in Chain]: {
45
+ [A in AssetOfChain<C>]: {
46
+ chain: C;
47
+ asset: A;
48
+ };
49
+ }[AssetOfChain<C>];
50
+ }[Chain];
43
51
  type ChainAssetMap<T> = {
44
52
  [C in Chain]: {
45
53
  [A in AssetOfChain<C>]: T;
@@ -61,4 +69,4 @@ type TransactionOptions = {
61
69
  wait?: number;
62
70
  };
63
71
 
64
- export { type Asset as A, type Chain as C, type InternalAsset as I, type TransactionOptions as T, type AssetOfChain as a, type ChainflipNetwork as b, type ChainAssetMap as c, type ChainMap as d, Chains as e, Assets as f, InternalAssets as g, ChainflipNetworks as h, getInternalAsset as i };
72
+ export { type AssetAndChain as A, type Chain as C, type InternalAsset as I, type TransactionOptions as T, type Asset as a, type AssetOfChain as b, type ChainflipNetwork as c, type ChainAssetMap as d, type ChainMap as e, Chains as f, Assets as g, InternalAssets as h, ChainflipNetworks as i, getInternalAsset as j };
@@ -40,6 +40,14 @@ type UncheckedAssetAndChain = {
40
40
  asset: Asset;
41
41
  chain: Chain;
42
42
  };
43
+ type AssetAndChain = {
44
+ [C in Chain]: {
45
+ [A in AssetOfChain<C>]: {
46
+ chain: C;
47
+ asset: A;
48
+ };
49
+ }[AssetOfChain<C>];
50
+ }[Chain];
43
51
  type ChainAssetMap<T> = {
44
52
  [C in Chain]: {
45
53
  [A in AssetOfChain<C>]: T;
@@ -61,4 +69,4 @@ type TransactionOptions = {
61
69
  wait?: number;
62
70
  };
63
71
 
64
- export { type Asset as A, type Chain as C, type InternalAsset as I, type TransactionOptions as T, type AssetOfChain as a, type ChainflipNetwork as b, type ChainAssetMap as c, type ChainMap as d, Chains as e, Assets as f, InternalAssets as g, ChainflipNetworks as h, getInternalAsset as i };
72
+ export { type AssetAndChain as A, type Chain as C, type InternalAsset as I, type TransactionOptions as T, type Asset as a, type AssetOfChain as b, type ChainflipNetwork as c, type ChainAssetMap as d, type ChainMap as e, Chains as f, Assets as g, InternalAssets as h, ChainflipNetworks as i, getInternalAsset as j };
@@ -1,5 +1,5 @@
1
1
  import { Signer } from 'ethers';
2
- import { b as ChainflipNetwork, T as TransactionOptions } from './contracts-ZLesmWHT.mjs';
2
+ import { c as ChainflipNetwork, T as TransactionOptions } from './contracts-49zdGryt.mjs';
3
3
 
4
4
  type PendingRedemption = {
5
5
  amount: bigint;
package/dist/funding.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Signer } from 'ethers';
2
- import { b as ChainflipNetwork, T as TransactionOptions } from './contracts-ZLesmWHT.js';
2
+ import { c as ChainflipNetwork, T as TransactionOptions } from './contracts-49zdGryt.js';
3
3
 
4
4
  type PendingRedemption = {
5
5
  amount: bigint;