@chainflip/sdk 1.3.0 → 1.4.0-alpha.1
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/{broker-6ZGPANTJ.mjs → broker-XWF7RRDY.mjs} +18 -9
- package/dist/{chunk-BFEB7XAP.mjs → chunk-4HLERQ4Y.mjs} +39 -65
- package/dist/chunk-KHC24Z3O.mjs +65 -0
- package/dist/{chunk-QNH6727P.mjs → chunk-LQGUI52U.mjs} +349 -110
- package/dist/{contracts-b0BB7B5m.d.mts → contracts-ZLesmWHT.d.mts} +4 -2
- package/dist/{contracts-b0BB7B5m.d.ts → contracts-ZLesmWHT.d.ts} +4 -2
- package/dist/funding.d.mts +1 -1
- package/dist/funding.d.ts +1 -1
- package/dist/funding.js +378 -170
- package/dist/funding.mjs +8 -6
- package/dist/swap.d.mts +38 -9
- package/dist/swap.d.ts +38 -9
- package/dist/swap.js +528 -279
- package/dist/swap.mjs +72 -81
- package/package.json +7 -5
- package/dist/chunk-J5DGP4KI.mjs +0 -31
package/dist/swap.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getEnvironment, getSupportedAssets, getVaultContractAddress, approve, getTokenContractAddress, getEvmChainId, checkAllowance, extractOverrides, Vault__factory } from './chunk-
|
|
2
|
-
import { ccmMetadataSchema } from './chunk-
|
|
3
|
-
import { __name, ChainflipNetworks, __publicField, Chains, assetConstants,
|
|
4
|
-
export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
1
|
+
import { getEnvironment, getSupportedAssets, getVaultContractAddress, approve, getTokenContractAddress, getEvmChainId, checkAllowance, extractOverrides, Vault__factory } from './chunk-4HLERQ4Y.mjs';
|
|
2
|
+
import { ccmMetadataSchema } from './chunk-KHC24Z3O.mjs';
|
|
3
|
+
import { __name, ChainflipNetworks, __publicField, Chains, assetConstants, getInternalAsset, isNotNullish, assert, readChainAssetValue, isTestnet, assertValidAddress, chainConstants, getInternalAssets, dotAddress } from './chunk-LQGUI52U.mjs';
|
|
4
|
+
export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-LQGUI52U.mjs';
|
|
5
|
+
import { bytesToHex } from '@chainflip/utils/bytes';
|
|
6
|
+
import * as ss58 from '@chainflip/utils/ss58';
|
|
7
7
|
import axios from 'axios';
|
|
8
8
|
|
|
9
9
|
// ../../node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/observable-ade1bad8.mjs
|
|
@@ -2207,6 +2207,7 @@ SuperJSON.registerSymbol;
|
|
|
2207
2207
|
SuperJSON.allowErrorProps;
|
|
2208
2208
|
|
|
2209
2209
|
// ../shared/src/rpc/utils.ts
|
|
2210
|
+
var MAX_SWAP_AMOUNT = 2n ** 128n - 1n;
|
|
2210
2211
|
var validateSwapAmount = /* @__PURE__ */ __name((env, asset, amount) => {
|
|
2211
2212
|
const minimumAmount = readChainAssetValue(env.ingressEgress.minimumDepositAmounts, asset);
|
|
2212
2213
|
if (amount < minimumAmount) {
|
|
@@ -2215,7 +2216,7 @@ var validateSwapAmount = /* @__PURE__ */ __name((env, asset, amount) => {
|
|
|
2215
2216
|
reason: `expected amount is below minimum swap amount (${minimumAmount})`
|
|
2216
2217
|
};
|
|
2217
2218
|
}
|
|
2218
|
-
const maxAmount = readChainAssetValue(env.swapping.maximumSwapAmounts, asset);
|
|
2219
|
+
const maxAmount = readChainAssetValue(env.swapping.maximumSwapAmounts, asset) ?? MAX_SWAP_AMOUNT;
|
|
2219
2220
|
if (maxAmount != null && amount > maxAmount) {
|
|
2220
2221
|
return {
|
|
2221
2222
|
success: false,
|
|
@@ -2245,7 +2246,7 @@ var assertSignerIsConnectedToChain = /* @__PURE__ */ __name(async (opts, chain)
|
|
|
2245
2246
|
// ../shared/src/vault/executeSwap.ts
|
|
2246
2247
|
var encodeAddress = /* @__PURE__ */ __name((chain, address) => {
|
|
2247
2248
|
if (chain === Chains.Polkadot)
|
|
2248
|
-
return
|
|
2249
|
+
return bytesToHex(ss58.decode(dotAddress.parse(address)).data);
|
|
2249
2250
|
if (chain === Chains.Bitcoin)
|
|
2250
2251
|
return `0x${Buffer.from(address).toString("hex")}`;
|
|
2251
2252
|
if (chain === Chains.Ethereum || chain === Chains.Arbitrum)
|
|
@@ -2253,15 +2254,8 @@ var encodeAddress = /* @__PURE__ */ __name((chain, address) => {
|
|
|
2253
2254
|
throw new Error(`cannot encode address for chain ${chain}`);
|
|
2254
2255
|
}, "encodeAddress");
|
|
2255
2256
|
var assertIsValidSwap = /* @__PURE__ */ __name((params) => {
|
|
2256
|
-
const
|
|
2257
|
-
|
|
2258
|
-
asset: params.srcAsset
|
|
2259
|
-
});
|
|
2260
|
-
const internalDestAsset = getInternalAsset({
|
|
2261
|
-
chain: params.destChain,
|
|
2262
|
-
asset: params.destAsset
|
|
2263
|
-
});
|
|
2264
|
-
assert(internalSrcAsset !== internalDestAsset, `source asset and destination asset cannot be the same`);
|
|
2257
|
+
const { srcAsset, destAsset } = getInternalAssets(params);
|
|
2258
|
+
assert(srcAsset !== destAsset, "source asset and destination asset cannot be the same");
|
|
2265
2259
|
}, "assertIsValidSwap");
|
|
2266
2260
|
var getVaultContract = /* @__PURE__ */ __name((chain, networkOpts) => {
|
|
2267
2261
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultContractAddress(chain, networkOpts.network);
|
|
@@ -2276,60 +2270,50 @@ var getErc20Address = /* @__PURE__ */ __name((asset, networkOpts) => {
|
|
|
2276
2270
|
return erc20Address;
|
|
2277
2271
|
}, "getErc20Address");
|
|
2278
2272
|
var swapNative = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
2279
|
-
const
|
|
2273
|
+
const destAsset = getInternalAsset({
|
|
2280
2274
|
chain: params.destChain,
|
|
2281
2275
|
asset: params.destAsset
|
|
2282
2276
|
});
|
|
2283
2277
|
const { vaultContract: vault } = getVaultContract(params.srcChain, networkOpts);
|
|
2284
|
-
const transaction = await vault.xSwapNative(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[
|
|
2278
|
+
const transaction = await vault.xSwapNative(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, "0x", {
|
|
2285
2279
|
value: params.amount,
|
|
2286
2280
|
...extractOverrides(txOpts)
|
|
2287
2281
|
});
|
|
2288
|
-
|
|
2282
|
+
await transaction.wait(txOpts.wait);
|
|
2283
|
+
return transaction;
|
|
2289
2284
|
}, "swapNative");
|
|
2290
2285
|
var swapToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
2291
|
-
const
|
|
2292
|
-
chain: params.srcChain,
|
|
2293
|
-
asset: params.srcAsset
|
|
2294
|
-
});
|
|
2295
|
-
const internalDestAsset = getInternalAsset({
|
|
2296
|
-
chain: params.destChain,
|
|
2297
|
-
asset: params.destAsset
|
|
2298
|
-
});
|
|
2286
|
+
const { srcAsset, destAsset } = getInternalAssets(params);
|
|
2299
2287
|
const { vaultContract: vault, vaultAddress } = getVaultContract(params.srcChain, networkOpts);
|
|
2300
|
-
const erc20Address = getErc20Address(
|
|
2288
|
+
const erc20Address = getErc20Address(srcAsset, networkOpts);
|
|
2301
2289
|
const { hasSufficientAllowance } = await checkAllowance(BigInt(params.amount), vaultAddress, erc20Address, networkOpts.signer);
|
|
2302
2290
|
assert(hasSufficientAllowance, "Swap amount exceeds allowance");
|
|
2303
|
-
const transaction = await vault.xSwapToken(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[
|
|
2304
|
-
|
|
2291
|
+
const transaction = await vault.xSwapToken(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
2292
|
+
await transaction.wait(txOpts.wait);
|
|
2293
|
+
return transaction;
|
|
2305
2294
|
}, "swapToken");
|
|
2306
2295
|
var callNative = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
2307
|
-
const
|
|
2296
|
+
const destAsset = getInternalAsset({
|
|
2308
2297
|
chain: params.destChain,
|
|
2309
2298
|
asset: params.destAsset
|
|
2310
2299
|
});
|
|
2311
2300
|
const { vaultContract: vault } = getVaultContract(params.srcChain, networkOpts);
|
|
2312
|
-
const transaction = await vault.xCallNative(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[
|
|
2301
|
+
const transaction = await vault.xCallNative(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmMetadata.message, params.ccmMetadata.gasBudget, "0x", {
|
|
2313
2302
|
value: params.amount,
|
|
2314
2303
|
...extractOverrides(txOpts)
|
|
2315
2304
|
});
|
|
2316
|
-
|
|
2305
|
+
await transaction.wait(txOpts.wait);
|
|
2306
|
+
return transaction;
|
|
2317
2307
|
}, "callNative");
|
|
2318
2308
|
var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
2319
|
-
const
|
|
2320
|
-
chain: params.srcChain,
|
|
2321
|
-
asset: params.srcAsset
|
|
2322
|
-
});
|
|
2323
|
-
const internalDestAsset = getInternalAsset({
|
|
2324
|
-
chain: params.destChain,
|
|
2325
|
-
asset: params.destAsset
|
|
2326
|
-
});
|
|
2309
|
+
const { srcAsset, destAsset } = getInternalAssets(params);
|
|
2327
2310
|
const { vaultContract: vault, vaultAddress } = getVaultContract(params.srcChain, networkOpts);
|
|
2328
|
-
const erc20Address = getErc20Address(
|
|
2311
|
+
const erc20Address = getErc20Address(srcAsset, networkOpts);
|
|
2329
2312
|
const { hasSufficientAllowance } = await checkAllowance(BigInt(params.amount), vaultAddress, erc20Address, networkOpts.signer);
|
|
2330
2313
|
assert(hasSufficientAllowance, "Swap amount exceeds allowance");
|
|
2331
|
-
const transaction = await vault.xCallToken(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[
|
|
2332
|
-
|
|
2314
|
+
const transaction = await vault.xCallToken(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
2315
|
+
await transaction.wait(txOpts.wait);
|
|
2316
|
+
return transaction;
|
|
2333
2317
|
}, "callToken");
|
|
2334
2318
|
var executeSwap = /* @__PURE__ */ __name(async ({ ccmMetadata: unvalidatedCcmMetadata, ...params }, networkOpts, txOpts) => {
|
|
2335
2319
|
assertIsValidSwap(params);
|
|
@@ -2375,19 +2359,22 @@ var isGasAsset = /* @__PURE__ */ __name((asset) => {
|
|
|
2375
2359
|
const { chain } = assetConstants[asset];
|
|
2376
2360
|
return assetConstants[asset].asset === chainConstants[chain].gasAsset;
|
|
2377
2361
|
}, "isGasAsset");
|
|
2378
|
-
var getAssetData = /* @__PURE__ */ __name((asset, network, env) =>
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2362
|
+
var getAssetData = /* @__PURE__ */ __name((asset, network, env) => {
|
|
2363
|
+
const assetConstant = assetConstants[asset];
|
|
2364
|
+
return {
|
|
2365
|
+
chainflipId: asset,
|
|
2366
|
+
asset: assetConstant.asset,
|
|
2367
|
+
chain: assetConstant.chain,
|
|
2368
|
+
contractAddress: !isGasAsset(asset) ? getTokenContractAddress(asset, network) : void 0,
|
|
2369
|
+
decimals: assetConstant.decimals,
|
|
2370
|
+
name: assetConstant.name,
|
|
2371
|
+
symbol: assetConstant.asset,
|
|
2372
|
+
isMainnet: !isTestnet(network),
|
|
2373
|
+
minimumSwapAmount: readChainAssetValue(env.ingressEgress.minimumDepositAmounts, asset).toString(),
|
|
2374
|
+
maximumSwapAmount: readChainAssetValue(env.swapping.maximumSwapAmounts, asset)?.toString() ?? null,
|
|
2375
|
+
minimumEgressAmount: readChainAssetValue(env.ingressEgress.minimumEgressAmounts, asset).toString()
|
|
2376
|
+
};
|
|
2377
|
+
}, "getAssetData");
|
|
2391
2378
|
|
|
2392
2379
|
// src/swap/chains.ts
|
|
2393
2380
|
var getChainData = /* @__PURE__ */ __name((chain, network, env) => ({
|
|
@@ -2406,7 +2393,7 @@ var BACKEND_SERVICE_URLS = {
|
|
|
2406
2393
|
[ChainflipNetworks.mainnet]: "https://chainflip-swap.chainflip.io/"
|
|
2407
2394
|
};
|
|
2408
2395
|
var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }) => {
|
|
2409
|
-
const { brokerCommissionBps,
|
|
2396
|
+
const { brokerCommissionBps, ...returnedRequestData } = quoteRequest;
|
|
2410
2397
|
const params = {
|
|
2411
2398
|
amount: returnedRequestData.amount,
|
|
2412
2399
|
srcChain: returnedRequestData.srcChain,
|
|
@@ -2415,9 +2402,6 @@ var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal })
|
|
|
2415
2402
|
destAsset: returnedRequestData.destAsset,
|
|
2416
2403
|
...brokerCommissionBps && {
|
|
2417
2404
|
brokerCommissionBps: String(brokerCommissionBps)
|
|
2418
|
-
},
|
|
2419
|
-
...boostFeeBps && {
|
|
2420
|
-
boostFeeBps: String(boostFeeBps)
|
|
2421
2405
|
}
|
|
2422
2406
|
};
|
|
2423
2407
|
const queryParams = new URLSearchParams(params);
|
|
@@ -2437,10 +2421,6 @@ var getStatus = /* @__PURE__ */ __name(async (baseUrl, { id }, { signal }) => {
|
|
|
2437
2421
|
});
|
|
2438
2422
|
return data;
|
|
2439
2423
|
}, "getStatus");
|
|
2440
|
-
var ApiService_default = {
|
|
2441
|
-
getQuote,
|
|
2442
|
-
getStatus
|
|
2443
|
-
};
|
|
2444
2424
|
|
|
2445
2425
|
// src/swap/sdk.ts
|
|
2446
2426
|
var _SwapSDK = class _SwapSDK {
|
|
@@ -2487,7 +2467,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2487
2467
|
return this.stateChainEnvironment;
|
|
2488
2468
|
}
|
|
2489
2469
|
async getSupportedAssets() {
|
|
2490
|
-
this.supportedAssets ?? (this.supportedAssets = (await getSupportedAssets(this.rpcConfig)).map((asset) =>
|
|
2470
|
+
this.supportedAssets ?? (this.supportedAssets = (await getSupportedAssets(this.rpcConfig)).map((asset) => getInternalAsset(asset, false)).filter(isNotNullish));
|
|
2491
2471
|
return this.supportedAssets;
|
|
2492
2472
|
}
|
|
2493
2473
|
async getAssets(chain) {
|
|
@@ -2500,30 +2480,39 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2500
2480
|
return supportedAssets.map((asset) => getAssetData(asset, this.options.network, env)).filter((asset) => !chain || asset.chain === chain);
|
|
2501
2481
|
}
|
|
2502
2482
|
getQuote(quoteRequest, options = {}) {
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2483
|
+
const { brokerCommissionBps, affiliateBrokers, ...remainingRequest } = quoteRequest;
|
|
2484
|
+
const submitterBrokerCommissionBps = brokerCommissionBps ?? this.options.broker?.commissionBps ?? 0;
|
|
2485
|
+
const affiliateBrokerCommissionBps = affiliateBrokers?.reduce((acc, affiliate) => acc + affiliate.commissionBps, 0) ?? 0;
|
|
2486
|
+
return getQuote(this.options.backendUrl, {
|
|
2487
|
+
...remainingRequest,
|
|
2488
|
+
brokerCommissionBps: submitterBrokerCommissionBps + affiliateBrokerCommissionBps
|
|
2506
2489
|
}, options);
|
|
2507
2490
|
}
|
|
2508
2491
|
async requestDepositAddress(depositAddressRequest) {
|
|
2509
|
-
const { srcChain, srcAsset, amount } = depositAddressRequest;
|
|
2492
|
+
const { srcChain, srcAsset, amount, brokerCommissionBps, affiliateBrokers } = depositAddressRequest;
|
|
2510
2493
|
await this.validateSwapAmount({
|
|
2511
2494
|
chain: srcChain,
|
|
2512
2495
|
asset: srcAsset
|
|
2513
2496
|
}, BigInt(amount));
|
|
2514
2497
|
let response;
|
|
2515
2498
|
if (this.options.broker !== void 0) {
|
|
2516
|
-
const { requestSwapDepositAddress } = await import('./broker-
|
|
2517
|
-
const result = await requestSwapDepositAddress(depositAddressRequest,
|
|
2499
|
+
const { requestSwapDepositAddress } = await import('./broker-XWF7RRDY.mjs');
|
|
2500
|
+
const result = await requestSwapDepositAddress(depositAddressRequest, {
|
|
2501
|
+
...this.options.broker,
|
|
2502
|
+
commissionBps: brokerCommissionBps ?? this.options.broker.commissionBps,
|
|
2503
|
+
affiliates: affiliateBrokers
|
|
2504
|
+
}, this.options.network);
|
|
2518
2505
|
response = {
|
|
2519
2506
|
id: `${result.issuedBlock}-${depositAddressRequest.srcChain}-${result.channelId}`,
|
|
2520
2507
|
depositAddress: result.address,
|
|
2521
2508
|
brokerCommissionBps: this.options.broker.commissionBps,
|
|
2522
2509
|
srcChainExpiryBlock: result.sourceChainExpiryBlock,
|
|
2523
|
-
|
|
2510
|
+
maxBoostFeeBps: depositAddressRequest.maxBoostFeeBps,
|
|
2524
2511
|
channelOpeningFee: result.channelOpeningFee
|
|
2525
2512
|
};
|
|
2526
2513
|
} else {
|
|
2514
|
+
assert(!depositAddressRequest.brokerCommissionBps, "Broker commission is only supported only when initializing the SDK with a brokerUrl");
|
|
2515
|
+
assert(!depositAddressRequest.affiliateBrokers?.length, "Affiliate brokers are supported only when initializing the SDK with a brokerUrl");
|
|
2527
2516
|
response = await this.trpc.openSwapDepositChannel.mutate(depositAddressRequest);
|
|
2528
2517
|
}
|
|
2529
2518
|
return {
|
|
@@ -2531,14 +2520,15 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2531
2520
|
depositChannelId: response.id,
|
|
2532
2521
|
depositAddress: response.depositAddress,
|
|
2533
2522
|
brokerCommissionBps: response.brokerCommissionBps,
|
|
2534
|
-
|
|
2523
|
+
affiliateBrokers: depositAddressRequest.affiliateBrokers ?? [],
|
|
2524
|
+
maxBoostFeeBps: Number(response.maxBoostFeeBps) || 0,
|
|
2535
2525
|
depositChannelExpiryBlock: response.srcChainExpiryBlock,
|
|
2536
2526
|
estimatedDepositChannelExpiryTime: response.estimatedExpiryTime,
|
|
2537
2527
|
channelOpeningFee: response.channelOpeningFee
|
|
2538
2528
|
};
|
|
2539
2529
|
}
|
|
2540
2530
|
getStatus(swapStatusRequest, options = {}) {
|
|
2541
|
-
return
|
|
2531
|
+
return getStatus(this.options.backendUrl, swapStatusRequest, options);
|
|
2542
2532
|
}
|
|
2543
2533
|
async executeSwap(params, txOpts = {}) {
|
|
2544
2534
|
const { srcChain, srcAsset, amount } = params;
|
|
@@ -2549,25 +2539,26 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2549
2539
|
chain: srcChain,
|
|
2550
2540
|
asset: srcAsset
|
|
2551
2541
|
}, BigInt(amount));
|
|
2552
|
-
const
|
|
2542
|
+
const tx = await executeSwap_default(params, {
|
|
2553
2543
|
network: this.options.network,
|
|
2554
2544
|
signer
|
|
2555
2545
|
}, remainingTxOpts);
|
|
2556
|
-
return
|
|
2546
|
+
return tx.hash;
|
|
2557
2547
|
}
|
|
2558
2548
|
async approveVault(params, txOpts = {}) {
|
|
2559
2549
|
const { signer: optsSigner, ...remainingTxOpts } = txOpts;
|
|
2560
2550
|
const signer = optsSigner ?? this.options.signer;
|
|
2561
2551
|
assert(signer, "No signer provided");
|
|
2562
|
-
const
|
|
2552
|
+
const tx = await approveVault(params, {
|
|
2563
2553
|
signer,
|
|
2564
2554
|
network: this.options.network
|
|
2565
2555
|
}, remainingTxOpts);
|
|
2566
|
-
return
|
|
2556
|
+
return tx ? tx.hash : null;
|
|
2567
2557
|
}
|
|
2568
2558
|
async validateSwapAmount(asset, amount) {
|
|
2569
2559
|
const stateChainEnv = await this.getStateChainEnvironment();
|
|
2570
|
-
const
|
|
2560
|
+
const internalAsset = getInternalAsset(asset);
|
|
2561
|
+
const result = validateSwapAmount(stateChainEnv, internalAsset, amount);
|
|
2571
2562
|
if (!result.success)
|
|
2572
2563
|
throw new Error(result.reason);
|
|
2573
2564
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./swap": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"license": "ISC",
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": "^18 || ^20.11.0",
|
|
36
|
-
"pnpm": ">=
|
|
36
|
+
"pnpm": ">=9"
|
|
37
37
|
},
|
|
38
38
|
"repository": "https://github.com/chainflip-io/chainflip-sdk-monorepo.git",
|
|
39
39
|
"publishConfig": {
|
|
@@ -41,8 +41,7 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"@polkadot/util-crypto": "^12.6.2",
|
|
44
|
+
"@chainflip/utils": "^0.1.2",
|
|
46
45
|
"axios": "^1.6.8",
|
|
47
46
|
"ethers": "^6.11.1"
|
|
48
47
|
},
|
|
@@ -53,7 +52,10 @@
|
|
|
53
52
|
"test": "jest --forceExit",
|
|
54
53
|
"test:ci": "CI=1 jest --forceExit",
|
|
55
54
|
"build": "rm -rf dist && tsup",
|
|
56
|
-
"
|
|
55
|
+
"eslint:check": "pnpm eslint --max-warnings 0 './**/*.ts'",
|
|
56
|
+
"prettier:base": "prettier ./** --ignore-path=../../.prettierignore",
|
|
57
|
+
"prettier:check": "pnpm prettier:base --check",
|
|
58
|
+
"prettier:write": "pnpm prettier:base --write",
|
|
57
59
|
"typecheck": "tsc --noEmit"
|
|
58
60
|
}
|
|
59
61
|
}
|
package/dist/chunk-J5DGP4KI.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { z, chain, asset, numericString, numericOrEmptyString, hexStringWithMaxByteSize } from './chunk-QNH6727P.mjs';
|
|
2
|
-
|
|
3
|
-
// ../shared/src/schemas.ts
|
|
4
|
-
z.object({
|
|
5
|
-
srcChain: chain,
|
|
6
|
-
srcAsset: asset,
|
|
7
|
-
destChain: chain,
|
|
8
|
-
destAsset: asset,
|
|
9
|
-
amount: numericString,
|
|
10
|
-
brokerCommissionBps: numericOrEmptyString.transform((v) => Number(v)).optional(),
|
|
11
|
-
boostFeeBps: numericOrEmptyString.transform((v) => Number(v)).optional()
|
|
12
|
-
});
|
|
13
|
-
var ccmMetadataSchema = z.object({
|
|
14
|
-
gasBudget: numericString,
|
|
15
|
-
message: hexStringWithMaxByteSize(1024 * 10)
|
|
16
|
-
});
|
|
17
|
-
z.object({
|
|
18
|
-
srcAsset: asset,
|
|
19
|
-
destAsset: asset,
|
|
20
|
-
srcChain: chain,
|
|
21
|
-
destChain: chain,
|
|
22
|
-
destAddress: z.string(),
|
|
23
|
-
amount: numericString,
|
|
24
|
-
ccmMetadata: ccmMetadataSchema.optional(),
|
|
25
|
-
boostFeeBps: z.number().optional()
|
|
26
|
-
}).transform(({ amount, ...rest }) => ({
|
|
27
|
-
...rest,
|
|
28
|
-
expectedDepositAmount: amount
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
export { ccmMetadataSchema };
|