@chainflip/sdk 0.2.2 → 0.2.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/funding.d.mts +12 -4
- package/dist/funding.d.ts +12 -4
- package/dist/funding.js +10 -2
- package/dist/funding.mjs +11 -3
- package/dist/swap.d.mts +3 -3
- package/dist/swap.d.ts +3 -3
- package/dist/swap.mjs +2 -2
- package/package.json +1 -1
- package/dist/{chunk-UBMU3BTF.mjs → chunk-FTLY2OML.mjs} +15 -15
package/dist/funding.d.mts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import {
|
|
2
|
+
import { a as ChainflipNetwork, T as TransactionOptions } from './contracts-646d1727.js';
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
type PendingRedemption = {
|
|
5
|
+
amount: bigint;
|
|
6
|
+
redeemAddress: string;
|
|
7
|
+
startTime: bigint;
|
|
8
|
+
expiryTime: bigint;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type FundingSDKOption = {
|
|
5
12
|
network?: Exclude<ChainflipNetwork, 'mainnet'>;
|
|
6
13
|
signer: Signer;
|
|
7
14
|
};
|
|
8
15
|
type TransactionHash = `0x${string}`;
|
|
9
16
|
declare class FundingSDK {
|
|
10
17
|
private readonly options;
|
|
11
|
-
constructor(options:
|
|
18
|
+
constructor(options: FundingSDKOption);
|
|
12
19
|
fundStateChainAccount(accountId: `0x${string}`, amount: bigint, txOpts?: TransactionOptions): Promise<TransactionHash>;
|
|
13
20
|
executeRedemption(accountId: `0x${string}`, txOpts?: TransactionOptions): Promise<TransactionHash>;
|
|
14
21
|
getMinimumFunding(): Promise<bigint>;
|
|
15
22
|
getRedemptionDelay(): Promise<bigint>;
|
|
16
23
|
getFlipBalance(): Promise<bigint>;
|
|
24
|
+
getPendingRedemption(accountId: `0x${string}`): Promise<PendingRedemption | undefined>;
|
|
17
25
|
approveStateChainGateway(amount: bigint, txOpts?: TransactionOptions): Promise<TransactionHash | null>;
|
|
18
26
|
}
|
|
19
27
|
|
|
20
|
-
export { FundingSDK };
|
|
28
|
+
export { FundingSDK, FundingSDKOption, PendingRedemption };
|
package/dist/funding.d.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import {
|
|
2
|
+
import { a as ChainflipNetwork, T as TransactionOptions } from './contracts-646d1727.js';
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
type PendingRedemption = {
|
|
5
|
+
amount: bigint;
|
|
6
|
+
redeemAddress: string;
|
|
7
|
+
startTime: bigint;
|
|
8
|
+
expiryTime: bigint;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type FundingSDKOption = {
|
|
5
12
|
network?: Exclude<ChainflipNetwork, 'mainnet'>;
|
|
6
13
|
signer: Signer;
|
|
7
14
|
};
|
|
8
15
|
type TransactionHash = `0x${string}`;
|
|
9
16
|
declare class FundingSDK {
|
|
10
17
|
private readonly options;
|
|
11
|
-
constructor(options:
|
|
18
|
+
constructor(options: FundingSDKOption);
|
|
12
19
|
fundStateChainAccount(accountId: `0x${string}`, amount: bigint, txOpts?: TransactionOptions): Promise<TransactionHash>;
|
|
13
20
|
executeRedemption(accountId: `0x${string}`, txOpts?: TransactionOptions): Promise<TransactionHash>;
|
|
14
21
|
getMinimumFunding(): Promise<bigint>;
|
|
15
22
|
getRedemptionDelay(): Promise<bigint>;
|
|
16
23
|
getFlipBalance(): Promise<bigint>;
|
|
24
|
+
getPendingRedemption(accountId: `0x${string}`): Promise<PendingRedemption | undefined>;
|
|
17
25
|
approveStateChainGateway(amount: bigint, txOpts?: TransactionOptions): Promise<TransactionHash | null>;
|
|
18
26
|
}
|
|
19
27
|
|
|
20
|
-
export { FundingSDK };
|
|
28
|
+
export { FundingSDK, FundingSDKOption, PendingRedemption };
|
package/dist/funding.js
CHANGED
|
@@ -956,8 +956,13 @@ var getRedemptionDelay = /* @__PURE__ */ __name((networkOpts) => {
|
|
|
956
956
|
const stateChainGateway = getStateChainGateway(networkOpts);
|
|
957
957
|
return stateChainGateway.REDEMPTION_DELAY();
|
|
958
958
|
}, "getRedemptionDelay");
|
|
959
|
+
var getPendingRedemption = /* @__PURE__ */ __name(async (accountId, networkOpts) => {
|
|
960
|
+
const stateChainGateway = getStateChainGateway(networkOpts);
|
|
961
|
+
const pendingRedemption = await stateChainGateway.getPendingRedemption(accountId);
|
|
962
|
+
return pendingRedemption.amount !== 0n ? stateChainGateway.getPendingRedemption(accountId) : void 0;
|
|
963
|
+
}, "getPendingRedemption");
|
|
959
964
|
|
|
960
|
-
// src/funding/
|
|
965
|
+
// src/funding/sdk.ts
|
|
961
966
|
var _FundingSDK = class _FundingSDK {
|
|
962
967
|
constructor(options) {
|
|
963
968
|
__publicField(this, "options");
|
|
@@ -990,8 +995,11 @@ var _FundingSDK = class _FundingSDK {
|
|
|
990
995
|
async getFlipBalance() {
|
|
991
996
|
return getFlipBalance(this.options.network, this.options.signer);
|
|
992
997
|
}
|
|
998
|
+
async getPendingRedemption(accountId) {
|
|
999
|
+
return getPendingRedemption(accountId, this.options);
|
|
1000
|
+
}
|
|
993
1001
|
/**
|
|
994
|
-
* @param
|
|
1002
|
+
* @param the amount of FLIP to request approval for
|
|
995
1003
|
* @returns the transaction hash or null if no approval was required
|
|
996
1004
|
*/
|
|
997
1005
|
async approveStateChainGateway(amount, txOpts = {}) {
|
package/dist/funding.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name, __publicField, ChainflipNetworks, getFlipBalance, getStateChainGatewayContractAddress, approve, getTokenContractAddress, Assets, checkAllowance, assert, extractOverrides, StateChainGateway__factory } from './chunk-
|
|
1
|
+
import { __name, __publicField, ChainflipNetworks, getFlipBalance, getStateChainGatewayContractAddress, approve, getTokenContractAddress, Assets, checkAllowance, assert, extractOverrides, StateChainGateway__factory } from './chunk-FTLY2OML.mjs';
|
|
2
2
|
|
|
3
3
|
// ../shared/src/stateChainGateway/utils.ts
|
|
4
4
|
var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
|
|
@@ -42,8 +42,13 @@ var getRedemptionDelay = /* @__PURE__ */ __name((networkOpts) => {
|
|
|
42
42
|
const stateChainGateway = getStateChainGateway(networkOpts);
|
|
43
43
|
return stateChainGateway.REDEMPTION_DELAY();
|
|
44
44
|
}, "getRedemptionDelay");
|
|
45
|
+
var getPendingRedemption = /* @__PURE__ */ __name(async (accountId, networkOpts) => {
|
|
46
|
+
const stateChainGateway = getStateChainGateway(networkOpts);
|
|
47
|
+
const pendingRedemption = await stateChainGateway.getPendingRedemption(accountId);
|
|
48
|
+
return pendingRedemption.amount !== 0n ? stateChainGateway.getPendingRedemption(accountId) : void 0;
|
|
49
|
+
}, "getPendingRedemption");
|
|
45
50
|
|
|
46
|
-
// src/funding/
|
|
51
|
+
// src/funding/sdk.ts
|
|
47
52
|
var _FundingSDK = class _FundingSDK {
|
|
48
53
|
constructor(options) {
|
|
49
54
|
__publicField(this, "options");
|
|
@@ -76,8 +81,11 @@ var _FundingSDK = class _FundingSDK {
|
|
|
76
81
|
async getFlipBalance() {
|
|
77
82
|
return getFlipBalance(this.options.network, this.options.signer);
|
|
78
83
|
}
|
|
84
|
+
async getPendingRedemption(accountId) {
|
|
85
|
+
return getPendingRedemption(accountId, this.options);
|
|
86
|
+
}
|
|
79
87
|
/**
|
|
80
|
-
* @param
|
|
88
|
+
* @param the amount of FLIP to request approval for
|
|
81
89
|
* @returns the transaction hash or null if no approval was required
|
|
82
90
|
*/
|
|
83
91
|
async approveStateChainGateway(amount, txOpts = {}) {
|
package/dist/swap.d.mts
CHANGED
|
@@ -537,7 +537,7 @@ type RequestOptions = {
|
|
|
537
537
|
};
|
|
538
538
|
|
|
539
539
|
type TransactionHash = `0x${string}`;
|
|
540
|
-
type
|
|
540
|
+
type SwapSDKOptions = {
|
|
541
541
|
network?: Exclude<ChainflipNetwork, 'mainnet'>;
|
|
542
542
|
signer?: Signer;
|
|
543
543
|
backendUrl?: string;
|
|
@@ -546,7 +546,7 @@ declare class SwapSDK {
|
|
|
546
546
|
private readonly baseUrl;
|
|
547
547
|
private readonly network;
|
|
548
548
|
private readonly signer?;
|
|
549
|
-
constructor(options?:
|
|
549
|
+
constructor(options?: SwapSDKOptions);
|
|
550
550
|
getChains(sourceChain?: Chain): Promise<ChainData[]>;
|
|
551
551
|
getAssets(chain: Chain): Promise<AssetData[]>;
|
|
552
552
|
getQuote(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponse>;
|
|
@@ -556,4 +556,4 @@ declare class SwapSDK {
|
|
|
556
556
|
approveVault(params: Pick<TokenSwapParams, 'srcAsset' | 'amount'>, txOpts?: TransactionOptions): Promise<TransactionHash | null>;
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
-
export { Asset, AssetData, Chain, ChainData, ChainflipNetwork, DepositAddressRequest, DepositAddressResponse, QuoteRequest, QuoteResponse,
|
|
559
|
+
export { Asset, AssetData, Chain, ChainData, ChainflipNetwork, DepositAddressRequest, DepositAddressResponse, QuoteRequest, QuoteResponse, SwapSDK, SwapSDKOptions, SwapStatusRequest, SwapStatusResponse, chainAssets };
|
package/dist/swap.d.ts
CHANGED
|
@@ -537,7 +537,7 @@ type RequestOptions = {
|
|
|
537
537
|
};
|
|
538
538
|
|
|
539
539
|
type TransactionHash = `0x${string}`;
|
|
540
|
-
type
|
|
540
|
+
type SwapSDKOptions = {
|
|
541
541
|
network?: Exclude<ChainflipNetwork, 'mainnet'>;
|
|
542
542
|
signer?: Signer;
|
|
543
543
|
backendUrl?: string;
|
|
@@ -546,7 +546,7 @@ declare class SwapSDK {
|
|
|
546
546
|
private readonly baseUrl;
|
|
547
547
|
private readonly network;
|
|
548
548
|
private readonly signer?;
|
|
549
|
-
constructor(options?:
|
|
549
|
+
constructor(options?: SwapSDKOptions);
|
|
550
550
|
getChains(sourceChain?: Chain): Promise<ChainData[]>;
|
|
551
551
|
getAssets(chain: Chain): Promise<AssetData[]>;
|
|
552
552
|
getQuote(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponse>;
|
|
@@ -556,4 +556,4 @@ declare class SwapSDK {
|
|
|
556
556
|
approveVault(params: Pick<TokenSwapParams, 'srcAsset' | 'amount'>, txOpts?: TransactionOptions): Promise<TransactionHash | null>;
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
-
export { Asset, AssetData, Chain, ChainData, ChainflipNetwork, DepositAddressRequest, DepositAddressResponse, QuoteRequest, QuoteResponse,
|
|
559
|
+
export { Asset, AssetData, Chain, ChainData, ChainflipNetwork, DepositAddressRequest, DepositAddressResponse, QuoteRequest, QuoteResponse, SwapSDK, SwapSDKOptions, SwapStatusRequest, SwapStatusResponse, chainAssets };
|
package/dist/swap.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isString, Chains, Assets, ChainflipNetworks, __name, __publicField, assert, getVaultManagerContractAddress, approve, isTokenCall, isTokenSwap, getTokenContractAddress, checkAllowance, Vault__factory, chainContractIds, assetContractIds, extractOverrides, assetDecimals, isTestnet, getMinimumDepositAmount, getMinimumSwapAmount } from './chunk-
|
|
2
|
-
export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds } from './chunk-
|
|
1
|
+
import { isString, Chains, Assets, ChainflipNetworks, __name, __publicField, assert, getVaultManagerContractAddress, approve, isTokenCall, isTokenSwap, getTokenContractAddress, checkAllowance, Vault__factory, chainContractIds, assetContractIds, extractOverrides, assetDecimals, isTestnet, getMinimumDepositAmount, getMinimumSwapAmount } from './chunk-FTLY2OML.mjs';
|
|
2
|
+
export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds } from './chunk-FTLY2OML.mjs';
|
|
3
3
|
import { encodeAddress, decodeAddress, base58Decode } from '@polkadot/util-crypto';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { hexToU8a } from '@polkadot/util';
|
package/package.json
CHANGED
|
@@ -73,6 +73,21 @@ var chainContractIds = {
|
|
|
73
73
|
[Chains.Polkadot]: 2,
|
|
74
74
|
[Chains.Bitcoin]: 3
|
|
75
75
|
};
|
|
76
|
+
|
|
77
|
+
// ../shared/src/guards.ts
|
|
78
|
+
var isString = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
|
|
79
|
+
function assert(condition, message) {
|
|
80
|
+
if (condition)
|
|
81
|
+
return;
|
|
82
|
+
const error = new Error(message);
|
|
83
|
+
if (error.stack) {
|
|
84
|
+
error.stack = error.stack.replace(/\n.+/, "\n");
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
__name(assert, "assert");
|
|
89
|
+
var isTokenSwap = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.ETH, "isTokenSwap");
|
|
90
|
+
var isTokenCall = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.ETH, "isTokenCall");
|
|
76
91
|
var _abi = [
|
|
77
92
|
{
|
|
78
93
|
inputs: [
|
|
@@ -2089,21 +2104,6 @@ var ADDRESSES = {
|
|
|
2089
2104
|
};
|
|
2090
2105
|
var GOERLI_USDC_CONTRACT_ADDRESS = "0x07865c6E87B9F70255377e024ace6630C1Eaa37F";
|
|
2091
2106
|
|
|
2092
|
-
// ../shared/src/guards.ts
|
|
2093
|
-
var isString = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
|
|
2094
|
-
function assert(condition, message) {
|
|
2095
|
-
if (condition)
|
|
2096
|
-
return;
|
|
2097
|
-
const error = new Error(message);
|
|
2098
|
-
if (error.stack) {
|
|
2099
|
-
error.stack = error.stack.replace(/\n.+/, "\n");
|
|
2100
|
-
}
|
|
2101
|
-
throw error;
|
|
2102
|
-
}
|
|
2103
|
-
__name(assert, "assert");
|
|
2104
|
-
var isTokenSwap = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.ETH, "isTokenSwap");
|
|
2105
|
-
var isTokenCall = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.ETH, "isTokenCall");
|
|
2106
|
-
|
|
2107
2107
|
// ../shared/src/contracts.ts
|
|
2108
2108
|
var extractOverrides = /* @__PURE__ */ __name((transactionOverrides) => {
|
|
2109
2109
|
const { wait, ...ethersOverrides } = transactionOverrides;
|