@chainflip/sdk 1.2.0-rc.1 → 1.2.0-rc.2
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-Z7ASKYS2.mjs → broker-AQ4TYGXK.mjs} +10 -8
- package/dist/{chunk-M2FID654.mjs → chunk-TKSJD3PK.mjs} +3 -2
- package/dist/{chunk-DV4HDL4K.mjs → chunk-XMGPLWGR.mjs} +16 -17
- package/dist/{chunk-OV3KFLWM.mjs → chunk-ZIIOHBEG.mjs} +1 -1
- package/dist/funding.mjs +2 -2
- package/dist/swap.d.mts +3 -2
- package/dist/swap.d.ts +3 -2
- package/dist/swap.js +14 -11
- package/dist/swap.mjs +8 -6
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ccmMetadataSchema } from './chunk-
|
|
2
|
-
import { z, __name, Assets, chainflipAssetAndChain, numericString, hexString, btcAddress, hexStringFromNumber,
|
|
1
|
+
import { ccmMetadataSchema } from './chunk-TKSJD3PK.mjs';
|
|
2
|
+
import { z, __name, Assets, chainflipAssetAndChain, numericString, hexString, btcAddress, hexStringFromNumber, dotAddress, unsignedInteger } from './chunk-XMGPLWGR.mjs';
|
|
3
3
|
import { u8aToHex } from '@polkadot/util';
|
|
4
4
|
import { decodeAddress } from '@polkadot/util-crypto';
|
|
5
5
|
import axios from 'axios';
|
|
@@ -53,14 +53,16 @@ var requestValidators = /* @__PURE__ */ __name((network) => ({
|
|
|
53
53
|
hexString,
|
|
54
54
|
z.string()
|
|
55
55
|
]).optional()
|
|
56
|
-
})).optional()
|
|
57
|
-
|
|
56
|
+
})).optional(),
|
|
57
|
+
z.number().optional()
|
|
58
|
+
]).transform(([a, b, c, d, e, f]) => [
|
|
58
59
|
a,
|
|
59
60
|
b,
|
|
60
61
|
c,
|
|
61
62
|
d,
|
|
62
|
-
transformObjToSnakeCase(e)
|
|
63
|
-
|
|
63
|
+
transformObjToSnakeCase(e),
|
|
64
|
+
f
|
|
65
|
+
])
|
|
64
66
|
}), "requestValidators");
|
|
65
67
|
var responseValidators = /* @__PURE__ */ __name((network) => ({
|
|
66
68
|
requestSwapDepositAddress: z.object({
|
|
@@ -94,7 +96,7 @@ var makeRpcRequest = /* @__PURE__ */ __name(async (network, url, method, ...para
|
|
|
94
96
|
return responseValidators(network)[method].parse(result.result);
|
|
95
97
|
}, "makeRpcRequest");
|
|
96
98
|
async function requestSwapDepositAddress(swapRequest, opts, chainflipNetwork) {
|
|
97
|
-
const { srcAsset, srcChain, destAsset, destChain, destAddress } = swapRequest;
|
|
99
|
+
const { srcAsset, srcChain, destAsset, destChain, destAddress, boostFeeBps } = swapRequest;
|
|
98
100
|
return makeRpcRequest(chainflipNetwork, opts.url, "requestSwapDepositAddress", {
|
|
99
101
|
asset: srcAsset,
|
|
100
102
|
chain: srcChain
|
|
@@ -104,7 +106,7 @@ async function requestSwapDepositAddress(swapRequest, opts, chainflipNetwork) {
|
|
|
104
106
|
}, submitAddress(destAsset, destAddress), opts.commissionBps, swapRequest.ccmMetadata && {
|
|
105
107
|
...swapRequest.ccmMetadata,
|
|
106
108
|
cfParameters: void 0
|
|
107
|
-
});
|
|
109
|
+
}, boostFeeBps);
|
|
108
110
|
}
|
|
109
111
|
__name(requestSwapDepositAddress, "requestSwapDepositAddress");
|
|
110
112
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z, chainflipAssetAndChain, numericString, hexStringWithMaxByteSize, chainflipAsset, chainflipChain } from './chunk-
|
|
1
|
+
import { z, chainflipAssetAndChain, numericString, hexStringWithMaxByteSize, chainflipAsset, chainflipChain } from './chunk-XMGPLWGR.mjs';
|
|
2
2
|
|
|
3
3
|
// ../shared/src/schemas.ts
|
|
4
4
|
z.object({
|
|
@@ -18,7 +18,8 @@ z.object({
|
|
|
18
18
|
destChain: chainflipChain,
|
|
19
19
|
destAddress: z.string(),
|
|
20
20
|
amount: numericString,
|
|
21
|
-
ccmMetadata: ccmMetadataSchema.optional()
|
|
21
|
+
ccmMetadata: ccmMetadataSchema.optional(),
|
|
22
|
+
boostFeeBps: z.number().optional()
|
|
22
23
|
}).transform(({ amount, ...rest }) => ({
|
|
23
24
|
...rest,
|
|
24
25
|
expectedDepositAmount: amount
|
|
@@ -535,22 +535,6 @@ function assertIsValidAssetAndChain(assetAndChain) {
|
|
|
535
535
|
}
|
|
536
536
|
__name(assertIsValidAssetAndChain, "assertIsValidAssetAndChain");
|
|
537
537
|
|
|
538
|
-
// ../shared/src/guards.ts
|
|
539
|
-
var isString = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
|
|
540
|
-
var isNotNullish = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isNotNullish");
|
|
541
|
-
function assert(condition, message) {
|
|
542
|
-
if (condition)
|
|
543
|
-
return;
|
|
544
|
-
const error = new Error(message);
|
|
545
|
-
if (error.stack) {
|
|
546
|
-
error.stack = error.stack.replace(/\n.+/, "\n");
|
|
547
|
-
}
|
|
548
|
-
throw error;
|
|
549
|
-
}
|
|
550
|
-
__name(assert, "assert");
|
|
551
|
-
var isTokenSwap = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.ETH, "isTokenSwap");
|
|
552
|
-
var isTokenCall = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.ETH, "isTokenCall");
|
|
553
|
-
|
|
554
538
|
// ../../node_modules/.pnpm/zod@3.22.4/node_modules/zod/lib/index.mjs
|
|
555
539
|
var util;
|
|
556
540
|
(function(util2) {
|
|
@@ -4380,6 +4364,21 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
4380
4364
|
ZodError
|
|
4381
4365
|
});
|
|
4382
4366
|
|
|
4367
|
+
// ../shared/src/guards.ts
|
|
4368
|
+
var isString = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
|
|
4369
|
+
function assert(condition, message) {
|
|
4370
|
+
if (condition)
|
|
4371
|
+
return;
|
|
4372
|
+
const error = new Error(message);
|
|
4373
|
+
if (error.stack) {
|
|
4374
|
+
error.stack = error.stack.replace(/\n.+/, "\n");
|
|
4375
|
+
}
|
|
4376
|
+
throw error;
|
|
4377
|
+
}
|
|
4378
|
+
__name(assert, "assert");
|
|
4379
|
+
var isTokenSwap = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.ETH, "isTokenSwap");
|
|
4380
|
+
var isTokenCall = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.ETH, "isTokenCall");
|
|
4381
|
+
|
|
4383
4382
|
// ../shared/src/bitcoin.ts
|
|
4384
4383
|
var import_bech32_buffer = __toESM(require_lib());
|
|
4385
4384
|
var isValidSegwitAddress = /* @__PURE__ */ __name((address) => {
|
|
@@ -4539,4 +4538,4 @@ z.union([
|
|
|
4539
4538
|
}))
|
|
4540
4539
|
]);
|
|
4541
4540
|
|
|
4542
|
-
export { Assets, ChainflipNetworks, Chains, __name, __publicField, assert, assertIsValidAssetAndChain, assetChains, assetContractIds, assetDecimals, btcAddress, chainAssets, chainContractIds, chainflipAsset, chainflipAssetAndChain, chainflipChain, dotAddress, ethereumAddress, hexString, hexStringFromNumber, hexStringWithMaxByteSize,
|
|
4541
|
+
export { Assets, ChainflipNetworks, Chains, __name, __publicField, assert, assertIsValidAssetAndChain, assetChains, assetContractIds, assetDecimals, btcAddress, chainAssets, chainContractIds, chainflipAsset, chainflipAssetAndChain, chainflipChain, dotAddress, ethereumAddress, hexString, hexStringFromNumber, hexStringWithMaxByteSize, isTestnet, isTokenCall, isTokenSwap, numericString, unsignedInteger, z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z, ChainflipNetworks, hexString, __name, __publicField, Assets } from './chunk-
|
|
1
|
+
import { z, ChainflipNetworks, hexString, __name, __publicField, Assets } from './chunk-XMGPLWGR.mjs';
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { Interface, Contract } from 'ethers';
|
|
4
4
|
|
package/dist/funding.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, checkAllowance, extractOverrides, StateChainGateway__factory } from './chunk-
|
|
2
|
-
import { __name, __publicField, ChainflipNetworks, Assets, assert } from './chunk-
|
|
1
|
+
import { getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, checkAllowance, extractOverrides, StateChainGateway__factory } from './chunk-ZIIOHBEG.mjs';
|
|
2
|
+
import { __name, __publicField, ChainflipNetworks, Assets, assert } from './chunk-XMGPLWGR.mjs';
|
|
3
3
|
|
|
4
4
|
// ../shared/src/stateChainGateway/utils.ts
|
|
5
5
|
var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
|
package/dist/swap.d.mts
CHANGED
|
@@ -427,6 +427,7 @@ interface QuoteResponse extends QuoteRequest {
|
|
|
427
427
|
interface DepositAddressRequest extends QuoteRequest {
|
|
428
428
|
destAddress: string;
|
|
429
429
|
ccmMetadata?: CcmMetadata;
|
|
430
|
+
boostFeeBps?: number;
|
|
430
431
|
}
|
|
431
432
|
interface DepositAddressResponse extends DepositAddressRequest {
|
|
432
433
|
depositChannelId: string;
|
|
@@ -438,7 +439,7 @@ interface DepositAddressResponse extends DepositAddressRequest {
|
|
|
438
439
|
interface SwapStatusRequest {
|
|
439
440
|
id: string;
|
|
440
441
|
}
|
|
441
|
-
interface SwapStatusResponseCommonFields {
|
|
442
|
+
interface SwapStatusResponseCommonFields extends ChainsAndAssets {
|
|
442
443
|
destAddress: string;
|
|
443
444
|
ccmDepositReceivedBlockIndex: string | undefined;
|
|
444
445
|
ccmMetadata: {
|
|
@@ -628,4 +629,4 @@ declare class SwapSDK {
|
|
|
628
629
|
}>;
|
|
629
630
|
}
|
|
630
631
|
|
|
631
|
-
export { Asset, type AssetData, Chain, type ChainData, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, chainAssets };
|
|
632
|
+
export { Asset, type AssetData, Chain, type ChainData, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type VaultSwapStatusResponse, chainAssets };
|
package/dist/swap.d.ts
CHANGED
|
@@ -427,6 +427,7 @@ interface QuoteResponse extends QuoteRequest {
|
|
|
427
427
|
interface DepositAddressRequest extends QuoteRequest {
|
|
428
428
|
destAddress: string;
|
|
429
429
|
ccmMetadata?: CcmMetadata;
|
|
430
|
+
boostFeeBps?: number;
|
|
430
431
|
}
|
|
431
432
|
interface DepositAddressResponse extends DepositAddressRequest {
|
|
432
433
|
depositChannelId: string;
|
|
@@ -438,7 +439,7 @@ interface DepositAddressResponse extends DepositAddressRequest {
|
|
|
438
439
|
interface SwapStatusRequest {
|
|
439
440
|
id: string;
|
|
440
441
|
}
|
|
441
|
-
interface SwapStatusResponseCommonFields {
|
|
442
|
+
interface SwapStatusResponseCommonFields extends ChainsAndAssets {
|
|
442
443
|
destAddress: string;
|
|
443
444
|
ccmDepositReceivedBlockIndex: string | undefined;
|
|
444
445
|
ccmMetadata: {
|
|
@@ -628,4 +629,4 @@ declare class SwapSDK {
|
|
|
628
629
|
}>;
|
|
629
630
|
}
|
|
630
631
|
|
|
631
|
-
export { Asset, type AssetData, Chain, type ChainData, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, chainAssets };
|
|
632
|
+
export { Asset, type AssetData, Chain, type ChainData, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type VaultSwapStatusResponse, chainAssets };
|
package/dist/swap.js
CHANGED
|
@@ -166,12 +166,11 @@ function assert(condition, message) {
|
|
|
166
166
|
}
|
|
167
167
|
throw error;
|
|
168
168
|
}
|
|
169
|
-
var isString2,
|
|
169
|
+
var isString2, isTokenSwap, isTokenCall;
|
|
170
170
|
var init_guards = __esm({
|
|
171
171
|
"../shared/src/guards.ts"() {
|
|
172
172
|
init_enums();
|
|
173
173
|
isString2 = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
|
|
174
|
-
isNotNullish = /* @__PURE__ */ __name((value) => value !== null && value !== void 0, "isNotNullish");
|
|
175
174
|
__name(assert, "assert");
|
|
176
175
|
isTokenSwap = /* @__PURE__ */ __name((params) => params.srcAsset !== exports.Assets.ETH, "isTokenSwap");
|
|
177
176
|
isTokenCall = /* @__PURE__ */ __name((params) => params.srcAsset !== exports.Assets.ETH, "isTokenCall");
|
|
@@ -4623,7 +4622,8 @@ var init_schemas = __esm({
|
|
|
4623
4622
|
destChain: chainflipChain,
|
|
4624
4623
|
destAddress: z.string(),
|
|
4625
4624
|
amount: numericString,
|
|
4626
|
-
ccmMetadata: ccmMetadataSchema.optional()
|
|
4625
|
+
ccmMetadata: ccmMetadataSchema.optional(),
|
|
4626
|
+
boostFeeBps: z.number().optional()
|
|
4627
4627
|
}).transform(({ amount, ...rest }) => ({
|
|
4628
4628
|
...rest,
|
|
4629
4629
|
expectedDepositAmount: amount
|
|
@@ -4645,7 +4645,7 @@ __export(broker_exports, {
|
|
|
4645
4645
|
requestSwapDepositAddress: () => requestSwapDepositAddress
|
|
4646
4646
|
});
|
|
4647
4647
|
async function requestSwapDepositAddress(swapRequest, opts, chainflipNetwork2) {
|
|
4648
|
-
const { srcAsset, srcChain, destAsset, destChain, destAddress } = swapRequest;
|
|
4648
|
+
const { srcAsset, srcChain, destAsset, destChain, destAddress, boostFeeBps } = swapRequest;
|
|
4649
4649
|
return makeRpcRequest(chainflipNetwork2, opts.url, "requestSwapDepositAddress", {
|
|
4650
4650
|
asset: srcAsset,
|
|
4651
4651
|
chain: srcChain
|
|
@@ -4655,14 +4655,13 @@ async function requestSwapDepositAddress(swapRequest, opts, chainflipNetwork2) {
|
|
|
4655
4655
|
}, submitAddress(destAsset, destAddress), opts.commissionBps, swapRequest.ccmMetadata && {
|
|
4656
4656
|
...swapRequest.ccmMetadata,
|
|
4657
4657
|
cfParameters: void 0
|
|
4658
|
-
});
|
|
4658
|
+
}, boostFeeBps);
|
|
4659
4659
|
}
|
|
4660
4660
|
var transformObjToSnakeCase, submitAddress, rpcResult, requestValidators, responseValidators, makeRpcRequest;
|
|
4661
4661
|
var init_broker = __esm({
|
|
4662
4662
|
"../shared/src/broker.ts"() {
|
|
4663
4663
|
init_lib();
|
|
4664
4664
|
init_enums();
|
|
4665
|
-
init_guards();
|
|
4666
4665
|
init_parsers();
|
|
4667
4666
|
init_schemas();
|
|
4668
4667
|
init_strings();
|
|
@@ -4711,14 +4710,16 @@ var init_broker = __esm({
|
|
|
4711
4710
|
hexString,
|
|
4712
4711
|
z.string()
|
|
4713
4712
|
]).optional()
|
|
4714
|
-
})).optional()
|
|
4715
|
-
|
|
4713
|
+
})).optional(),
|
|
4714
|
+
z.number().optional()
|
|
4715
|
+
]).transform(([a, b, c, d, e, f]) => [
|
|
4716
4716
|
a,
|
|
4717
4717
|
b,
|
|
4718
4718
|
c,
|
|
4719
4719
|
d,
|
|
4720
|
-
transformObjToSnakeCase(e)
|
|
4721
|
-
|
|
4720
|
+
transformObjToSnakeCase(e),
|
|
4721
|
+
f
|
|
4722
|
+
])
|
|
4722
4723
|
}), "requestValidators");
|
|
4723
4724
|
responseValidators = /* @__PURE__ */ __name((network) => ({
|
|
4724
4725
|
requestSwapDepositAddress: z.object({
|
|
@@ -8875,7 +8876,8 @@ var _SwapSDK = class _SwapSDK {
|
|
|
8875
8876
|
id: `${result.issuedBlock}-${depositAddressRequest.srcChain}-${result.channelId}`,
|
|
8876
8877
|
depositAddress: result.address,
|
|
8877
8878
|
brokerCommissionBps: this.brokerConfig.commissionBps,
|
|
8878
|
-
srcChainExpiryBlock: result.sourceChainExpiryBlock
|
|
8879
|
+
srcChainExpiryBlock: result.sourceChainExpiryBlock,
|
|
8880
|
+
boostFeeBps: depositAddressRequest.boostFeeBps
|
|
8879
8881
|
};
|
|
8880
8882
|
} else {
|
|
8881
8883
|
response = await this.trpc.openSwapDepositChannel.mutate(depositAddressRequest);
|
|
@@ -8885,6 +8887,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
8885
8887
|
depositChannelId: response.id,
|
|
8886
8888
|
depositAddress: response.depositAddress,
|
|
8887
8889
|
brokerCommissionBps: response.brokerCommissionBps,
|
|
8890
|
+
boostFeeBps: Number(response.boostFeeBps) || 0,
|
|
8888
8891
|
depositChannelExpiryBlock: response.srcChainExpiryBlock,
|
|
8889
8892
|
estimatedDepositChannelExpiryTime: response.estimatedExpiryTime
|
|
8890
8893
|
};
|
package/dist/swap.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getTokenContractAddress, getEnvironment, getVaultManagerContractAddress, approve, checkAllowance, Vault__factory, extractOverrides } from './chunk-
|
|
2
|
-
import { ccmMetadataSchema } from './chunk-
|
|
3
|
-
import { __name, z, numericString, Chains, Assets, ethereumAddress, dotAddress, ChainflipNetworks, assetChains, assetDecimals, isTestnet, __publicField, assert, assertIsValidAssetAndChain, isTokenCall, isTokenSwap, chainContractIds, assetContractIds, btcAddress } from './chunk-
|
|
4
|
-
export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds } from './chunk-
|
|
1
|
+
import { getTokenContractAddress, getEnvironment, getVaultManagerContractAddress, approve, checkAllowance, Vault__factory, extractOverrides } from './chunk-ZIIOHBEG.mjs';
|
|
2
|
+
import { ccmMetadataSchema } from './chunk-TKSJD3PK.mjs';
|
|
3
|
+
import { __name, z, numericString, Chains, Assets, ethereumAddress, dotAddress, ChainflipNetworks, assetChains, assetDecimals, isTestnet, __publicField, assert, assertIsValidAssetAndChain, isTokenCall, isTokenSwap, chainContractIds, assetContractIds, btcAddress } from './chunk-XMGPLWGR.mjs';
|
|
4
|
+
export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds } from './chunk-XMGPLWGR.mjs';
|
|
5
5
|
import { decodeAddress } from '@polkadot/util-crypto';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
|
|
@@ -2567,13 +2567,14 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2567
2567
|
}, BigInt(amount));
|
|
2568
2568
|
let response;
|
|
2569
2569
|
if (this.brokerConfig !== void 0) {
|
|
2570
|
-
const { requestSwapDepositAddress } = await import('./broker-
|
|
2570
|
+
const { requestSwapDepositAddress } = await import('./broker-AQ4TYGXK.mjs');
|
|
2571
2571
|
const result = await requestSwapDepositAddress(depositAddressRequest, this.brokerConfig, this.network);
|
|
2572
2572
|
response = {
|
|
2573
2573
|
id: `${result.issuedBlock}-${depositAddressRequest.srcChain}-${result.channelId}`,
|
|
2574
2574
|
depositAddress: result.address,
|
|
2575
2575
|
brokerCommissionBps: this.brokerConfig.commissionBps,
|
|
2576
|
-
srcChainExpiryBlock: result.sourceChainExpiryBlock
|
|
2576
|
+
srcChainExpiryBlock: result.sourceChainExpiryBlock,
|
|
2577
|
+
boostFeeBps: depositAddressRequest.boostFeeBps
|
|
2577
2578
|
};
|
|
2578
2579
|
} else {
|
|
2579
2580
|
response = await this.trpc.openSwapDepositChannel.mutate(depositAddressRequest);
|
|
@@ -2583,6 +2584,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2583
2584
|
depositChannelId: response.id,
|
|
2584
2585
|
depositAddress: response.depositAddress,
|
|
2585
2586
|
brokerCommissionBps: response.brokerCommissionBps,
|
|
2587
|
+
boostFeeBps: Number(response.boostFeeBps) || 0,
|
|
2586
2588
|
depositChannelExpiryBlock: response.srcChainExpiryBlock,
|
|
2587
2589
|
estimatedDepositChannelExpiryTime: response.estimatedExpiryTime
|
|
2588
2590
|
};
|