@chainflip/sdk 1.2.1-alpha.1 → 1.2.1-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.
- package/dist/{contracts-5Td0BhwY.d.mts → contracts-JL66gtg_.d.mts} +6 -1
- package/dist/{contracts-5Td0BhwY.d.ts → contracts-JL66gtg_.d.ts} +6 -1
- package/dist/funding.d.mts +1 -1
- package/dist/funding.d.ts +1 -1
- package/dist/swap.d.mts +4 -3
- package/dist/swap.d.ts +4 -3
- package/dist/swap.js +16 -15
- package/dist/swap.mjs +1 -1
- package/package.json +1 -1
|
@@ -27,11 +27,16 @@ declare const chainConstants: {
|
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
type AssetOfChain<C extends Chain> = (typeof chainConstants)[C]['assets'][number];
|
|
30
|
+
type UncheckedAssetAndChain = {
|
|
31
|
+
asset: Asset | string;
|
|
32
|
+
chain: Chain | string;
|
|
33
|
+
};
|
|
30
34
|
type ChainAssetMap<T> = {
|
|
31
35
|
[C in Chain]: {
|
|
32
36
|
[A in AssetOfChain<C>]: T;
|
|
33
37
|
};
|
|
34
38
|
};
|
|
39
|
+
declare function getInternalAsset(asset: UncheckedAssetAndChain): InternalAsset;
|
|
35
40
|
|
|
36
41
|
type TransactionOptions = {
|
|
37
42
|
gasLimit?: bigint;
|
|
@@ -42,4 +47,4 @@ type TransactionOptions = {
|
|
|
42
47
|
wait?: number;
|
|
43
48
|
};
|
|
44
49
|
|
|
45
|
-
export { type Asset as A, type ChainflipNetwork as C, type InternalAsset as I, type TransactionOptions as T, type Chain as a, type AssetOfChain as b, type ChainAssetMap as c, Chains as d, Assets as e,
|
|
50
|
+
export { type Asset as A, type ChainflipNetwork as C, type InternalAsset as I, type TransactionOptions as T, type Chain as a, type AssetOfChain as b, type ChainAssetMap as c, Chains as d, Assets as e, InternalAssets as f, ChainflipNetworks as g, getInternalAsset as h };
|
|
@@ -27,11 +27,16 @@ declare const chainConstants: {
|
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
type AssetOfChain<C extends Chain> = (typeof chainConstants)[C]['assets'][number];
|
|
30
|
+
type UncheckedAssetAndChain = {
|
|
31
|
+
asset: Asset | string;
|
|
32
|
+
chain: Chain | string;
|
|
33
|
+
};
|
|
30
34
|
type ChainAssetMap<T> = {
|
|
31
35
|
[C in Chain]: {
|
|
32
36
|
[A in AssetOfChain<C>]: T;
|
|
33
37
|
};
|
|
34
38
|
};
|
|
39
|
+
declare function getInternalAsset(asset: UncheckedAssetAndChain): InternalAsset;
|
|
35
40
|
|
|
36
41
|
type TransactionOptions = {
|
|
37
42
|
gasLimit?: bigint;
|
|
@@ -42,4 +47,4 @@ type TransactionOptions = {
|
|
|
42
47
|
wait?: number;
|
|
43
48
|
};
|
|
44
49
|
|
|
45
|
-
export { type Asset as A, type ChainflipNetwork as C, type InternalAsset as I, type TransactionOptions as T, type Chain as a, type AssetOfChain as b, type ChainAssetMap as c, Chains as d, Assets as e,
|
|
50
|
+
export { type Asset as A, type ChainflipNetwork as C, type InternalAsset as I, type TransactionOptions as T, type Chain as a, type AssetOfChain as b, type ChainAssetMap as c, Chains as d, Assets as e, InternalAssets as f, ChainflipNetworks as g, getInternalAsset as h };
|
package/dist/funding.d.mts
CHANGED
package/dist/funding.d.ts
CHANGED
package/dist/swap.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import { C as ChainflipNetwork, a as Chain, A as Asset, I as InternalAsset, b as AssetOfChain, T as TransactionOptions, c as ChainAssetMap } from './contracts-
|
|
3
|
-
export { e as Assets, f as ChainflipNetworks, d as Chains } from './contracts-
|
|
2
|
+
import { C as ChainflipNetwork, a as Chain, A as Asset, I as InternalAsset, b as AssetOfChain, T as TransactionOptions, c as ChainAssetMap } from './contracts-JL66gtg_.mjs';
|
|
3
|
+
export { e as Assets, f as ChainflipIds, g as ChainflipNetworks, d as Chains, h as getChainflipId } from './contracts-JL66gtg_.mjs';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
declare const tokenSwapParamsSchema: (network: ChainflipNetwork) => z.ZodUnion<[z.ZodObject<{
|
|
@@ -377,6 +377,7 @@ type QuoteQueryResponse = {
|
|
|
377
377
|
intermediateAmount?: string;
|
|
378
378
|
egressAmount: string;
|
|
379
379
|
includedFees: SwapFee[];
|
|
380
|
+
lowLiquidityWarning: boolean | undefined;
|
|
380
381
|
};
|
|
381
382
|
|
|
382
383
|
interface ChainData {
|
|
@@ -616,4 +617,4 @@ declare class SwapSDK {
|
|
|
616
617
|
}>;
|
|
617
618
|
}
|
|
618
619
|
|
|
619
|
-
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 };
|
|
620
|
+
export { Asset, type AssetData, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type VaultSwapStatusResponse };
|
package/dist/swap.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import { C as ChainflipNetwork, a as Chain, A as Asset, I as InternalAsset, b as AssetOfChain, T as TransactionOptions, c as ChainAssetMap } from './contracts-
|
|
3
|
-
export { e as Assets, f as ChainflipNetworks, d as Chains } from './contracts-
|
|
2
|
+
import { C as ChainflipNetwork, a as Chain, A as Asset, I as InternalAsset, b as AssetOfChain, T as TransactionOptions, c as ChainAssetMap } from './contracts-JL66gtg_.js';
|
|
3
|
+
export { e as Assets, f as ChainflipIds, g as ChainflipNetworks, d as Chains, h as getChainflipId } from './contracts-JL66gtg_.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
declare const tokenSwapParamsSchema: (network: ChainflipNetwork) => z.ZodUnion<[z.ZodObject<{
|
|
@@ -377,6 +377,7 @@ type QuoteQueryResponse = {
|
|
|
377
377
|
intermediateAmount?: string;
|
|
378
378
|
egressAmount: string;
|
|
379
379
|
includedFees: SwapFee[];
|
|
380
|
+
lowLiquidityWarning: boolean | undefined;
|
|
380
381
|
};
|
|
381
382
|
|
|
382
383
|
interface ChainData {
|
|
@@ -616,4 +617,4 @@ declare class SwapSDK {
|
|
|
616
617
|
}>;
|
|
617
618
|
}
|
|
618
619
|
|
|
619
|
-
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 };
|
|
620
|
+
export { Asset, type AssetData, Chain, type ChainData, InternalAsset as ChainflipId, ChainflipNetwork, type DepositAddressRequest, type DepositAddressResponse, type DepositAddressStatusResponse, type FailedVaultSwapStatusResponse, type QuoteRequest, type QuoteResponse, SwapSDK, type SwapSDKOptions, type SwapStatusRequest, type SwapStatusResponse, type VaultSwapStatusResponse };
|
package/dist/swap.js
CHANGED
|
@@ -83,27 +83,27 @@ function assertIsValidAssetAndChain(assetAndChain2) {
|
|
|
83
83
|
function getInternalAsset(asset2) {
|
|
84
84
|
const map = {
|
|
85
85
|
[exports.Chains.Ethereum]: {
|
|
86
|
-
[exports.Assets.USDC]:
|
|
87
|
-
[exports.Assets.FLIP]:
|
|
88
|
-
[exports.Assets.ETH]:
|
|
86
|
+
[exports.Assets.USDC]: exports.ChainflipIds.Usdc,
|
|
87
|
+
[exports.Assets.FLIP]: exports.ChainflipIds.Flip,
|
|
88
|
+
[exports.Assets.ETH]: exports.ChainflipIds.Eth
|
|
89
89
|
},
|
|
90
90
|
[exports.Chains.Bitcoin]: {
|
|
91
|
-
[exports.Assets.BTC]:
|
|
91
|
+
[exports.Assets.BTC]: exports.ChainflipIds.Btc
|
|
92
92
|
},
|
|
93
93
|
[exports.Chains.Polkadot]: {
|
|
94
|
-
[exports.Assets.DOT]:
|
|
94
|
+
[exports.Assets.DOT]: exports.ChainflipIds.Dot
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
return readChainAssetValue(map, asset2);
|
|
98
98
|
}
|
|
99
|
-
var arrayToMap
|
|
99
|
+
var arrayToMap; exports.ChainflipIds = void 0; exports.Chains = void 0; exports.Assets = void 0; exports.ChainflipNetworks = void 0; var isTestnet, assetConstants, chainConstants, readChainAssetValue;
|
|
100
100
|
var init_enums = __esm({
|
|
101
101
|
"../shared/src/enums.ts"() {
|
|
102
102
|
arrayToMap = /* @__PURE__ */ __name((array) => Object.fromEntries(array.map((key) => [
|
|
103
103
|
key,
|
|
104
104
|
key
|
|
105
105
|
])), "arrayToMap");
|
|
106
|
-
|
|
106
|
+
exports.ChainflipIds = arrayToMap([
|
|
107
107
|
"Flip",
|
|
108
108
|
"Usdc",
|
|
109
109
|
"Dot",
|
|
@@ -130,35 +130,35 @@ var init_enums = __esm({
|
|
|
130
130
|
]);
|
|
131
131
|
isTestnet = /* @__PURE__ */ __name((network) => network !== exports.ChainflipNetworks.mainnet, "isTestnet");
|
|
132
132
|
assetConstants = {
|
|
133
|
-
[
|
|
133
|
+
[exports.ChainflipIds.Eth]: {
|
|
134
134
|
chain: exports.Chains.Ethereum,
|
|
135
135
|
asset: exports.Assets.ETH,
|
|
136
136
|
name: "Ether",
|
|
137
137
|
decimals: 18,
|
|
138
138
|
contractId: 1
|
|
139
139
|
},
|
|
140
|
-
[
|
|
140
|
+
[exports.ChainflipIds.Flip]: {
|
|
141
141
|
chain: exports.Chains.Ethereum,
|
|
142
142
|
asset: exports.Assets.FLIP,
|
|
143
143
|
name: "FLIP",
|
|
144
144
|
decimals: 18,
|
|
145
145
|
contractId: 2
|
|
146
146
|
},
|
|
147
|
-
[
|
|
147
|
+
[exports.ChainflipIds.Usdc]: {
|
|
148
148
|
chain: exports.Chains.Ethereum,
|
|
149
149
|
asset: exports.Assets.USDC,
|
|
150
150
|
name: "USDC",
|
|
151
151
|
decimals: 6,
|
|
152
152
|
contractId: 3
|
|
153
153
|
},
|
|
154
|
-
[
|
|
154
|
+
[exports.ChainflipIds.Dot]: {
|
|
155
155
|
chain: exports.Chains.Polkadot,
|
|
156
156
|
asset: exports.Assets.DOT,
|
|
157
157
|
name: "Polkadot",
|
|
158
158
|
decimals: 10,
|
|
159
159
|
contractId: 4
|
|
160
160
|
},
|
|
161
|
-
[
|
|
161
|
+
[exports.ChainflipIds.Btc]: {
|
|
162
162
|
chain: exports.Chains.Bitcoin,
|
|
163
163
|
asset: exports.Assets.BTC,
|
|
164
164
|
name: "Bitcoin",
|
|
@@ -4592,7 +4592,7 @@ var init_parsers = __esm({
|
|
|
4592
4592
|
rustEnum = /* @__PURE__ */ __name((values) => z.object({
|
|
4593
4593
|
__kind: z.enum(values)
|
|
4594
4594
|
}).transform(({ __kind }) => __kind), "rustEnum");
|
|
4595
|
-
rustEnum(enumValues(
|
|
4595
|
+
rustEnum(enumValues(exports.ChainflipIds));
|
|
4596
4596
|
rustEnum(enumValues(exports.Chains));
|
|
4597
4597
|
chain = z.nativeEnum(exports.Chains);
|
|
4598
4598
|
asset = z.nativeEnum(exports.Assets);
|
|
@@ -8601,9 +8601,9 @@ var extractOverrides = /* @__PURE__ */ __name((transactionOverrides) => {
|
|
|
8601
8601
|
return ethersOverrides;
|
|
8602
8602
|
}, "extractOverrides");
|
|
8603
8603
|
function getTokenContractAddress(asset2, network, assert2 = true) {
|
|
8604
|
-
if (asset2 ===
|
|
8604
|
+
if (asset2 === exports.ChainflipIds.Flip)
|
|
8605
8605
|
return ADDRESSES[network].FLIP_CONTRACT_ADDRESS;
|
|
8606
|
-
if (asset2 ===
|
|
8606
|
+
if (asset2 === exports.ChainflipIds.Usdc)
|
|
8607
8607
|
return ADDRESSES[network].USDC_CONTRACT_ADDRESS;
|
|
8608
8608
|
if (assert2) {
|
|
8609
8609
|
throw new Error("Only FLIP and USDC are supported for now");
|
|
@@ -8987,3 +8987,4 @@ init_enums();
|
|
|
8987
8987
|
*/
|
|
8988
8988
|
|
|
8989
8989
|
exports.SwapSDK = SwapSDK;
|
|
8990
|
+
exports.getChainflipId = getInternalAsset;
|
package/dist/swap.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getTokenContractAddress, getEnvironment, getVaultManagerContractAddress, approve, checkAllowance, Vault__factory, extractOverrides } from './chunk-2GNHNTY7.mjs';
|
|
2
2
|
import { ccmMetadataSchema } from './chunk-KLVDY4K6.mjs';
|
|
3
3
|
import { __name, z, numericString, Chains, Assets, ethereumAddress, dotAddress, ChainflipNetworks, assetConstants, isTestnet, readChainAssetValue, __publicField, assert, isTokenCall, isTokenSwap, getInternalAsset, chainConstants, btcAddress } from './chunk-3LCS6BBP.mjs';
|
|
4
|
-
export { Assets, ChainflipNetworks, Chains } from './chunk-3LCS6BBP.mjs';
|
|
4
|
+
export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-3LCS6BBP.mjs';
|
|
5
5
|
import { decodeAddress } from '@polkadot/util-crypto';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
|