@chainflip/sdk 0.2.15 → 0.2.17
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-2SDVPKIU.mjs → broker-37JNAV63.mjs} +12 -10
- package/dist/{chunk-LNM2TOMZ.mjs → chunk-3346ITWW.mjs} +120 -22
- package/dist/chunk-5DBPJECX.mjs +459 -0
- package/dist/funding.d.mts +4 -0
- package/dist/funding.d.ts +4 -0
- package/dist/funding.js +135 -19
- package/dist/funding.mjs +14 -2
- package/dist/swap.d.mts +819 -26
- package/dist/swap.d.ts +819 -26
- package/dist/swap.js +381 -3987
- package/dist/swap.mjs +53 -38
- package/package.json +5 -2
- package/dist/chunk-DGDQYRRV.mjs +0 -4176
package/dist/swap.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { getVaultManagerContractAddress, approve, getTokenContractAddress, checkAllowance, Vault__factory, extractOverrides
|
|
2
|
-
import {
|
|
1
|
+
import { getEnvironment, getVaultManagerContractAddress, approve, getTokenContractAddress, checkAllowance, Vault__factory, extractOverrides } from './chunk-3346ITWW.mjs';
|
|
2
|
+
import { numericString, ethereumAddress, dotAddress, btcAddress, ccmMetadataSchema } from './chunk-5DBPJECX.mjs';
|
|
3
3
|
import { __name, Chains, Assets, ChainflipNetworks, __publicField, assert, isTokenCall, isTokenSwap, chainContractIds, assetContractIds, assetDecimals, isTestnet } from './chunk-NX4K76K7.mjs';
|
|
4
4
|
export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds } from './chunk-NX4K76K7.mjs';
|
|
5
5
|
import { decodeAddress } from '@polkadot/util-crypto';
|
|
6
|
+
import { z } from 'zod';
|
|
6
7
|
import axios from 'axios';
|
|
7
8
|
|
|
8
|
-
// ../../node_modules/.pnpm/@trpc+server@10.43.
|
|
9
|
+
// ../../node_modules/.pnpm/@trpc+server@10.43.1/node_modules/@trpc/server/dist/observable-ade1bad8.mjs
|
|
9
10
|
function identity(x) {
|
|
10
11
|
return x;
|
|
11
12
|
}
|
|
@@ -84,7 +85,7 @@ function observable(subscribe) {
|
|
|
84
85
|
}
|
|
85
86
|
__name(observable, "observable");
|
|
86
87
|
|
|
87
|
-
// ../../node_modules/.pnpm/@trpc+server@10.43.
|
|
88
|
+
// ../../node_modules/.pnpm/@trpc+server@10.43.1/node_modules/@trpc/server/dist/observable/index.mjs
|
|
88
89
|
function share(_opts) {
|
|
89
90
|
return (originalObserver) => {
|
|
90
91
|
let refCount = 0;
|
|
@@ -189,7 +190,7 @@ function observableToPromise(observable2) {
|
|
|
189
190
|
}
|
|
190
191
|
__name(observableToPromise, "observableToPromise");
|
|
191
192
|
|
|
192
|
-
// ../../node_modules/.pnpm/@trpc+client@10.43.
|
|
193
|
+
// ../../node_modules/.pnpm/@trpc+client@10.43.1_@trpc+server@10.43.1/node_modules/@trpc/client/dist/splitLink-4c75f7be.mjs
|
|
193
194
|
function createChain(opts) {
|
|
194
195
|
return observable((observer) => {
|
|
195
196
|
function execute(index = 0, op = opts.op) {
|
|
@@ -213,7 +214,7 @@ function createChain(opts) {
|
|
|
213
214
|
}
|
|
214
215
|
__name(createChain, "createChain");
|
|
215
216
|
|
|
216
|
-
// ../../node_modules/.pnpm/@trpc+client@10.43.
|
|
217
|
+
// ../../node_modules/.pnpm/@trpc+client@10.43.1_@trpc+server@10.43.1/node_modules/@trpc/client/dist/transformResult-ace864b8.mjs
|
|
217
218
|
function isObject(value) {
|
|
218
219
|
return !!value && !Array.isArray(value) && typeof value === "object";
|
|
219
220
|
}
|
|
@@ -266,7 +267,7 @@ function transformResult(response, runtime) {
|
|
|
266
267
|
}
|
|
267
268
|
__name(transformResult, "transformResult");
|
|
268
269
|
|
|
269
|
-
// ../../node_modules/.pnpm/@trpc+client@10.43.
|
|
270
|
+
// ../../node_modules/.pnpm/@trpc+client@10.43.1_@trpc+server@10.43.1/node_modules/@trpc/client/dist/TRPCClientError-0de4d231.mjs
|
|
270
271
|
function isTRPCClientError(cause) {
|
|
271
272
|
return cause instanceof TRPCClientError || /**
|
|
272
273
|
* @deprecated
|
|
@@ -324,7 +325,7 @@ var _TRPCClientError = class _TRPCClientError extends Error {
|
|
|
324
325
|
__name(_TRPCClientError, "TRPCClientError");
|
|
325
326
|
var TRPCClientError = _TRPCClientError;
|
|
326
327
|
|
|
327
|
-
// ../../node_modules/.pnpm/@trpc+server@10.43.
|
|
328
|
+
// ../../node_modules/.pnpm/@trpc+server@10.43.1/node_modules/@trpc/server/dist/codes-c924c3db.mjs
|
|
328
329
|
function invert(obj) {
|
|
329
330
|
const newObj = /* @__PURE__ */ Object.create(null);
|
|
330
331
|
for (const key in obj) {
|
|
@@ -362,7 +363,7 @@ var TRPC_ERROR_CODES_BY_KEY = {
|
|
|
362
363
|
};
|
|
363
364
|
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
364
365
|
|
|
365
|
-
// ../../node_modules/.pnpm/@trpc+server@10.43.
|
|
366
|
+
// ../../node_modules/.pnpm/@trpc+server@10.43.1/node_modules/@trpc/server/dist/index-f91d720c.mjs
|
|
366
367
|
invert(TRPC_ERROR_CODES_BY_KEY);
|
|
367
368
|
var noop = /* @__PURE__ */ __name(() => {
|
|
368
369
|
}, "noop");
|
|
@@ -400,7 +401,7 @@ var createFlatProxy = /* @__PURE__ */ __name((callback) => {
|
|
|
400
401
|
});
|
|
401
402
|
}, "createFlatProxy");
|
|
402
403
|
|
|
403
|
-
// ../../node_modules/.pnpm/@trpc+client@10.43.
|
|
404
|
+
// ../../node_modules/.pnpm/@trpc+client@10.43.1_@trpc+server@10.43.1/node_modules/@trpc/client/dist/httpUtils-f58ceda1.mjs
|
|
404
405
|
var isFunction = /* @__PURE__ */ __name((fn) => typeof fn === "function", "isFunction");
|
|
405
406
|
function getFetch(customFetchImpl) {
|
|
406
407
|
if (customFetchImpl) {
|
|
@@ -544,7 +545,7 @@ function httpRequest(opts) {
|
|
|
544
545
|
}
|
|
545
546
|
__name(httpRequest, "httpRequest");
|
|
546
547
|
|
|
547
|
-
// ../../node_modules/.pnpm/@trpc+client@10.43.
|
|
548
|
+
// ../../node_modules/.pnpm/@trpc+client@10.43.1_@trpc+server@10.43.1/node_modules/@trpc/client/dist/httpBatchLink-204206a5.mjs
|
|
548
549
|
var throwFatalError = /* @__PURE__ */ __name(() => {
|
|
549
550
|
throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new");
|
|
550
551
|
}, "throwFatalError");
|
|
@@ -774,7 +775,7 @@ var batchRequester = /* @__PURE__ */ __name((requesterOpts) => {
|
|
|
774
775
|
}, "batchRequester");
|
|
775
776
|
var httpBatchLink = createHTTPBatchLink(batchRequester);
|
|
776
777
|
|
|
777
|
-
// ../../node_modules/.pnpm/@trpc+client@10.43.
|
|
778
|
+
// ../../node_modules/.pnpm/@trpc+client@10.43.1_@trpc+server@10.43.1/node_modules/@trpc/client/dist/links/httpLink.mjs
|
|
778
779
|
function httpLinkFactory(factoryOpts) {
|
|
779
780
|
return (opts) => {
|
|
780
781
|
const resolvedOpts = resolveHTTPLinkOptions(opts);
|
|
@@ -826,7 +827,7 @@ function httpLinkFactory(factoryOpts) {
|
|
|
826
827
|
}
|
|
827
828
|
__name(httpLinkFactory, "httpLinkFactory");
|
|
828
829
|
|
|
829
|
-
// ../../node_modules/.pnpm/@trpc+client@10.43.
|
|
830
|
+
// ../../node_modules/.pnpm/@trpc+client@10.43.1_@trpc+server@10.43.1/node_modules/@trpc/client/dist/index.mjs
|
|
830
831
|
var _TRPCUntypedClient = class _TRPCUntypedClient {
|
|
831
832
|
$request({ type, input, path, context = {} }) {
|
|
832
833
|
const chain$ = createChain({
|
|
@@ -2326,7 +2327,7 @@ var BACKEND_SERVICE_URLS = {
|
|
|
2326
2327
|
};
|
|
2327
2328
|
|
|
2328
2329
|
// src/swap/assets.ts
|
|
2329
|
-
var eth$ = /* @__PURE__ */ __name((network) => ({
|
|
2330
|
+
var eth$ = /* @__PURE__ */ __name((network, env) => ({
|
|
2330
2331
|
id: Assets.ETH,
|
|
2331
2332
|
chain: Chains.Ethereum,
|
|
2332
2333
|
contractAddress: void 0,
|
|
@@ -2334,10 +2335,10 @@ var eth$ = /* @__PURE__ */ __name((network) => ({
|
|
|
2334
2335
|
name: "Ether",
|
|
2335
2336
|
symbol: "ETH",
|
|
2336
2337
|
isMainnet: !isTestnet(network),
|
|
2337
|
-
minimumDepositAmount:
|
|
2338
|
-
minimumSwapAmount:
|
|
2338
|
+
minimumDepositAmount: env.ingressEgress.minimumDepositAmounts.Ethereum.ETH.toString(),
|
|
2339
|
+
minimumSwapAmount: env.swapping.minimumSwapAmounts.Ethereum.ETH.toString()
|
|
2339
2340
|
}), "eth$");
|
|
2340
|
-
var usdc$ = /* @__PURE__ */ __name((network) => ({
|
|
2341
|
+
var usdc$ = /* @__PURE__ */ __name((network, env) => ({
|
|
2341
2342
|
id: Assets.USDC,
|
|
2342
2343
|
chain: Chains.Ethereum,
|
|
2343
2344
|
contractAddress: getTokenContractAddress(Assets.USDC, network),
|
|
@@ -2345,10 +2346,10 @@ var usdc$ = /* @__PURE__ */ __name((network) => ({
|
|
|
2345
2346
|
name: "USDC",
|
|
2346
2347
|
symbol: "USDC",
|
|
2347
2348
|
isMainnet: !isTestnet(network),
|
|
2348
|
-
minimumDepositAmount:
|
|
2349
|
-
minimumSwapAmount:
|
|
2349
|
+
minimumDepositAmount: env.ingressEgress.minimumDepositAmounts.Ethereum.USDC.toString(),
|
|
2350
|
+
minimumSwapAmount: env.swapping.minimumSwapAmounts.Ethereum.USDC.toString()
|
|
2350
2351
|
}), "usdc$");
|
|
2351
|
-
var flip$ = /* @__PURE__ */ __name((network) => ({
|
|
2352
|
+
var flip$ = /* @__PURE__ */ __name((network, env) => ({
|
|
2352
2353
|
id: Assets.FLIP,
|
|
2353
2354
|
chain: Chains.Ethereum,
|
|
2354
2355
|
contractAddress: getTokenContractAddress(Assets.FLIP, network),
|
|
@@ -2356,10 +2357,10 @@ var flip$ = /* @__PURE__ */ __name((network) => ({
|
|
|
2356
2357
|
name: "FLIP",
|
|
2357
2358
|
symbol: "FLIP",
|
|
2358
2359
|
isMainnet: !isTestnet(network),
|
|
2359
|
-
minimumDepositAmount:
|
|
2360
|
-
minimumSwapAmount:
|
|
2360
|
+
minimumDepositAmount: env.ingressEgress.minimumDepositAmounts.Ethereum.FLIP.toString(),
|
|
2361
|
+
minimumSwapAmount: env.swapping.minimumSwapAmounts.Ethereum.FLIP.toString()
|
|
2361
2362
|
}), "flip$");
|
|
2362
|
-
var dot$ = /* @__PURE__ */ __name((network) => ({
|
|
2363
|
+
var dot$ = /* @__PURE__ */ __name((network, env) => ({
|
|
2363
2364
|
id: Assets.DOT,
|
|
2364
2365
|
chain: Chains.Polkadot,
|
|
2365
2366
|
contractAddress: void 0,
|
|
@@ -2367,10 +2368,10 @@ var dot$ = /* @__PURE__ */ __name((network) => ({
|
|
|
2367
2368
|
name: "Polkadot",
|
|
2368
2369
|
symbol: "DOT",
|
|
2369
2370
|
isMainnet: !isTestnet(network),
|
|
2370
|
-
minimumDepositAmount:
|
|
2371
|
-
minimumSwapAmount:
|
|
2371
|
+
minimumDepositAmount: env.ingressEgress.minimumDepositAmounts.Polkadot.DOT.toString(),
|
|
2372
|
+
minimumSwapAmount: env.swapping.minimumSwapAmounts.Polkadot.DOT.toString()
|
|
2372
2373
|
}), "dot$");
|
|
2373
|
-
var btc$ = /* @__PURE__ */ __name((network) => ({
|
|
2374
|
+
var btc$ = /* @__PURE__ */ __name((network, env) => ({
|
|
2374
2375
|
id: Assets.BTC,
|
|
2375
2376
|
chain: Chains.Bitcoin,
|
|
2376
2377
|
contractAddress: void 0,
|
|
@@ -2378,8 +2379,8 @@ var btc$ = /* @__PURE__ */ __name((network) => ({
|
|
|
2378
2379
|
name: "Bitcoin",
|
|
2379
2380
|
symbol: "BTC",
|
|
2380
2381
|
isMainnet: !isTestnet(network),
|
|
2381
|
-
minimumDepositAmount:
|
|
2382
|
-
minimumSwapAmount:
|
|
2382
|
+
minimumDepositAmount: env.ingressEgress.minimumDepositAmounts.Bitcoin.BTC.toString(),
|
|
2383
|
+
minimumSwapAmount: env.swapping.minimumSwapAmounts.Bitcoin.BTC.toString()
|
|
2383
2384
|
}), "btc$");
|
|
2384
2385
|
|
|
2385
2386
|
// src/swap/chains.ts
|
|
@@ -2424,20 +2425,20 @@ var getPossibleDestinationChains = /* @__PURE__ */ __name(async (sourceChain, ne
|
|
|
2424
2425
|
];
|
|
2425
2426
|
throw new Error("received unknown chain");
|
|
2426
2427
|
}, "getPossibleDestinationChains");
|
|
2427
|
-
var getAssets = /* @__PURE__ */ __name(async (chain, network) => {
|
|
2428
|
+
var getAssets = /* @__PURE__ */ __name(async (chain, network, env) => {
|
|
2428
2429
|
if (chain === Chains.Ethereum)
|
|
2429
2430
|
return [
|
|
2430
|
-
eth$(network),
|
|
2431
|
-
usdc$(network),
|
|
2432
|
-
flip$(network)
|
|
2431
|
+
eth$(network, env),
|
|
2432
|
+
usdc$(network, env),
|
|
2433
|
+
flip$(network, env)
|
|
2433
2434
|
];
|
|
2434
2435
|
if (chain === Chains.Polkadot)
|
|
2435
2436
|
return [
|
|
2436
|
-
dot$(network)
|
|
2437
|
+
dot$(network, env)
|
|
2437
2438
|
];
|
|
2438
2439
|
if (chain === Chains.Bitcoin)
|
|
2439
2440
|
return [
|
|
2440
|
-
btc$(network)
|
|
2441
|
+
btc$(network, env)
|
|
2441
2442
|
];
|
|
2442
2443
|
throw new Error("received unexpected chain");
|
|
2443
2444
|
}, "getAssets");
|
|
@@ -2480,6 +2481,8 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2480
2481
|
__publicField(this, "signer");
|
|
2481
2482
|
__publicField(this, "trpc");
|
|
2482
2483
|
__publicField(this, "brokerConfig");
|
|
2484
|
+
__publicField(this, "stateChainEnvironment");
|
|
2485
|
+
__publicField(this, "rpcConfig");
|
|
2483
2486
|
this.network = options.network ?? ChainflipNetworks.perseverance;
|
|
2484
2487
|
this.baseUrl = options.backendUrl ?? BACKEND_SERVICE_URLS[this.network];
|
|
2485
2488
|
this.signer = options.signer;
|
|
@@ -2492,6 +2495,11 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2492
2495
|
})
|
|
2493
2496
|
]
|
|
2494
2497
|
});
|
|
2498
|
+
this.rpcConfig = options.rpcUrl ? {
|
|
2499
|
+
rpcUrl: options.rpcUrl
|
|
2500
|
+
} : {
|
|
2501
|
+
network: this.network
|
|
2502
|
+
};
|
|
2495
2503
|
}
|
|
2496
2504
|
getChains(sourceChain) {
|
|
2497
2505
|
if (sourceChain !== void 0) {
|
|
@@ -2499,8 +2507,13 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2499
2507
|
}
|
|
2500
2508
|
return ApiService_default.getChains(this.network);
|
|
2501
2509
|
}
|
|
2502
|
-
|
|
2503
|
-
|
|
2510
|
+
async getStateChainEnvironment() {
|
|
2511
|
+
this.stateChainEnvironment ?? (this.stateChainEnvironment = await getEnvironment(this.rpcConfig));
|
|
2512
|
+
return this.stateChainEnvironment;
|
|
2513
|
+
}
|
|
2514
|
+
async getAssets(chain) {
|
|
2515
|
+
const env = await this.getStateChainEnvironment();
|
|
2516
|
+
return ApiService_default.getAssets(chain, this.network, env);
|
|
2504
2517
|
}
|
|
2505
2518
|
getQuote(quoteRequest, options = {}) {
|
|
2506
2519
|
return ApiService_default.getQuote(this.baseUrl, quoteRequest, options);
|
|
@@ -2508,7 +2521,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2508
2521
|
async requestDepositAddress(depositAddressRequest) {
|
|
2509
2522
|
let response;
|
|
2510
2523
|
if (this.brokerConfig !== void 0) {
|
|
2511
|
-
const { requestSwapDepositAddress } = await import('./broker-
|
|
2524
|
+
const { requestSwapDepositAddress } = await import('./broker-37JNAV63.mjs');
|
|
2512
2525
|
const result = await requestSwapDepositAddress(depositAddressRequest, this.brokerConfig);
|
|
2513
2526
|
response = {
|
|
2514
2527
|
id: `${result.issuedBlock}-${depositAddressRequest.srcChain}-${result.channelId}`,
|
|
@@ -2527,7 +2540,9 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2527
2540
|
};
|
|
2528
2541
|
}
|
|
2529
2542
|
getStatus(swapStatusRequest, options = {}) {
|
|
2530
|
-
return
|
|
2543
|
+
return this.trpc.getStatus.query(swapStatusRequest, {
|
|
2544
|
+
signal: options.signal
|
|
2545
|
+
});
|
|
2531
2546
|
}
|
|
2532
2547
|
async executeSwap(params, txOpts = {}) {
|
|
2533
2548
|
assert(this.signer, "No signer provided");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./swap": {
|
|
@@ -44,7 +44,10 @@
|
|
|
44
44
|
"@polkadot/util": "^12.5.1",
|
|
45
45
|
"@polkadot/util-crypto": "^12.5.1",
|
|
46
46
|
"axios": "^1.6.0",
|
|
47
|
-
"ethers": "6.8.
|
|
47
|
+
"ethers": "6.8.1"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"zod": "^3.22.4"
|
|
48
51
|
},
|
|
49
52
|
"devDependencies": {
|
|
50
53
|
"tsup": "^7.2.0"
|