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

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,235 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __commonJS = (cb, mod) => function __require() {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __publicField = (obj, key, value) => {
29
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
30
+ return value;
31
+ };
32
+
33
+ // ../shared/src/enums.ts
34
+ var arrayToMap = /* @__PURE__ */ __name((array) => Object.fromEntries(array.map((key) => [
35
+ key,
36
+ key
37
+ ])), "arrayToMap");
38
+ var InternalAssets = arrayToMap([
39
+ "Flip",
40
+ "Usdc",
41
+ "Dot",
42
+ "Eth",
43
+ "Btc",
44
+ "Usdt",
45
+ "ArbUsdc",
46
+ "ArbEth"
47
+ ]);
48
+ var Chains = arrayToMap([
49
+ "Bitcoin",
50
+ "Ethereum",
51
+ "Polkadot",
52
+ "Arbitrum"
53
+ ]);
54
+ var Assets = arrayToMap([
55
+ "FLIP",
56
+ "USDC",
57
+ "DOT",
58
+ "ETH",
59
+ "BTC",
60
+ "USDT"
61
+ ]);
62
+ var ChainflipNetworks = arrayToMap([
63
+ "backspin",
64
+ "sisyphos",
65
+ "perseverance",
66
+ "mainnet"
67
+ ]);
68
+ var isTestnet = /* @__PURE__ */ __name((network) => network !== ChainflipNetworks.mainnet, "isTestnet");
69
+ var assetConstants = {
70
+ [InternalAssets.Eth]: {
71
+ chain: Chains.Ethereum,
72
+ asset: Assets.ETH,
73
+ name: "Ether",
74
+ decimals: 18,
75
+ contractId: 1
76
+ },
77
+ [InternalAssets.Flip]: {
78
+ chain: Chains.Ethereum,
79
+ asset: Assets.FLIP,
80
+ name: "FLIP",
81
+ decimals: 18,
82
+ contractId: 2
83
+ },
84
+ [InternalAssets.Usdc]: {
85
+ chain: Chains.Ethereum,
86
+ asset: Assets.USDC,
87
+ name: "USDC",
88
+ decimals: 6,
89
+ contractId: 3
90
+ },
91
+ [InternalAssets.Usdt]: {
92
+ chain: Chains.Ethereum,
93
+ asset: Assets.USDT,
94
+ name: "USDT",
95
+ decimals: 6,
96
+ contractId: 8
97
+ },
98
+ [InternalAssets.Dot]: {
99
+ chain: Chains.Polkadot,
100
+ asset: Assets.DOT,
101
+ name: "Polkadot",
102
+ decimals: 10,
103
+ contractId: 4
104
+ },
105
+ [InternalAssets.Btc]: {
106
+ chain: Chains.Bitcoin,
107
+ asset: Assets.BTC,
108
+ name: "Bitcoin",
109
+ decimals: 8,
110
+ contractId: 5
111
+ },
112
+ [InternalAssets.ArbEth]: {
113
+ chain: Chains.Arbitrum,
114
+ asset: Assets.ETH,
115
+ name: "Arbitrum Ether",
116
+ decimals: 18,
117
+ contractId: 6
118
+ },
119
+ [InternalAssets.ArbUsdc]: {
120
+ chain: Chains.Arbitrum,
121
+ asset: Assets.USDC,
122
+ name: "Arbitrum USDC",
123
+ decimals: 6,
124
+ contractId: 7
125
+ }
126
+ };
127
+ var chainConstants = {
128
+ [Chains.Ethereum]: {
129
+ assets: [
130
+ Assets.ETH,
131
+ Assets.FLIP,
132
+ Assets.USDC,
133
+ Assets.USDT
134
+ ],
135
+ gasAsset: Assets.ETH,
136
+ contractId: 1,
137
+ blockTimeSeconds: 12
138
+ },
139
+ [Chains.Polkadot]: {
140
+ assets: [
141
+ Assets.DOT
142
+ ],
143
+ gasAsset: Assets.DOT,
144
+ contractId: 2,
145
+ blockTimeSeconds: 6
146
+ },
147
+ [Chains.Bitcoin]: {
148
+ assets: [
149
+ Assets.BTC
150
+ ],
151
+ gasAsset: Assets.BTC,
152
+ contractId: 3,
153
+ blockTimeSeconds: 10 * 60
154
+ },
155
+ [Chains.Arbitrum]: {
156
+ assets: [
157
+ Assets.ETH,
158
+ Assets.USDC
159
+ ],
160
+ gasAsset: Assets.ETH,
161
+ contractId: 4,
162
+ blockTimeSeconds: 0.26
163
+ }
164
+ };
165
+ function isValidAssetAndChain(assetAndChain) {
166
+ const { asset, chain } = assetAndChain;
167
+ if (!(chain in Chains))
168
+ return false;
169
+ const validAssets = chainConstants[chain].assets;
170
+ return validAssets.includes(asset);
171
+ }
172
+ __name(isValidAssetAndChain, "isValidAssetAndChain");
173
+ var readChainAssetValue = /* @__PURE__ */ __name((map, asset) => {
174
+ const { chain, asset: symbol } = assetConstants[asset];
175
+ const chainValues = map[chain];
176
+ return chainValues[symbol];
177
+ }, "readChainAssetValue");
178
+ function getInternalAsset(asset, assert2 = true) {
179
+ if (!isValidAssetAndChain(asset)) {
180
+ if (assert2) {
181
+ throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
182
+ }
183
+ return null;
184
+ }
185
+ const map = {
186
+ [Chains.Ethereum]: {
187
+ [Assets.USDC]: InternalAssets.Usdc,
188
+ [Assets.FLIP]: InternalAssets.Flip,
189
+ [Assets.ETH]: InternalAssets.Eth,
190
+ [Assets.USDT]: InternalAssets.Usdt
191
+ },
192
+ [Chains.Bitcoin]: {
193
+ [Assets.BTC]: InternalAssets.Btc
194
+ },
195
+ [Chains.Polkadot]: {
196
+ [Assets.DOT]: InternalAssets.Dot
197
+ },
198
+ [Chains.Arbitrum]: {
199
+ [Assets.USDC]: InternalAssets.ArbUsdc,
200
+ [Assets.ETH]: InternalAssets.ArbEth
201
+ }
202
+ };
203
+ const chain = map[asset.chain];
204
+ return chain[asset.asset];
205
+ }
206
+ __name(getInternalAsset, "getInternalAsset");
207
+ function getInternalAssets({ srcAsset, srcChain, destAsset, destChain }, assert2 = true) {
208
+ return {
209
+ srcAsset: getInternalAsset({
210
+ asset: srcAsset,
211
+ chain: srcChain
212
+ }, assert2),
213
+ destAsset: getInternalAsset({
214
+ asset: destAsset,
215
+ chain: destChain
216
+ }, assert2)
217
+ };
218
+ }
219
+ __name(getInternalAssets, "getInternalAssets");
220
+
221
+ // ../shared/src/guards.ts
222
+ var isString = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
223
+ var isNotNullish = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isNotNullish");
224
+ function assert(condition, message) {
225
+ if (condition)
226
+ return;
227
+ const error = new Error(message);
228
+ if (error.stack) {
229
+ error.stack = error.stack.replace(/\n.+/, "\n");
230
+ }
231
+ throw error;
232
+ }
233
+ __name(assert, "assert");
234
+
235
+ export { Assets, ChainflipNetworks, Chains, InternalAssets, __commonJS, __name, __publicField, __toESM, 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;