@chainflip/sdk 0.1.20 → 0.2.0

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.
@@ -1,4 +1,4 @@
1
- import { BigNumber, utils, Contract } from 'ethers';
1
+ import { Interface, Contract } from 'ethers';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -144,10 +144,10 @@ var _abi = [
144
144
  ];
145
145
  var _ERC20__factory = class _ERC20__factory {
146
146
  static createInterface() {
147
- return new utils.Interface(_abi);
147
+ return new Interface(_abi);
148
148
  }
149
- static connect(address, signerOrProvider) {
150
- return new Contract(address, _abi, signerOrProvider);
149
+ static connect(address, runner) {
150
+ return new Contract(address, _abi, runner);
151
151
  }
152
152
  };
153
153
  __name(_ERC20__factory, "ERC20__factory");
@@ -815,10 +815,10 @@ var _abi2 = [
815
815
  ];
816
816
  var _StateChainGateway__factory = class _StateChainGateway__factory {
817
817
  static createInterface() {
818
- return new utils.Interface(_abi2);
818
+ return new Interface(_abi2);
819
819
  }
820
- static connect(address, signerOrProvider) {
821
- return new Contract(address, _abi2, signerOrProvider);
820
+ static connect(address, runner) {
821
+ return new Contract(address, _abi2, runner);
822
822
  }
823
823
  };
824
824
  __name(_StateChainGateway__factory, "StateChainGateway__factory");
@@ -2039,10 +2039,10 @@ var _abi3 = [
2039
2039
  ];
2040
2040
  var _Vault__factory = class _Vault__factory {
2041
2041
  static createInterface() {
2042
- return new utils.Interface(_abi3);
2042
+ return new Interface(_abi3);
2043
2043
  }
2044
- static connect(address, signerOrProvider) {
2045
- return new Contract(address, _abi3, signerOrProvider);
2044
+ static connect(address, runner) {
2045
+ return new Contract(address, _abi3, runner);
2046
2046
  }
2047
2047
  };
2048
2048
  __name(_Vault__factory, "Vault__factory");
@@ -2105,6 +2105,10 @@ var isTokenSwap = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.
2105
2105
  var isTokenCall = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.ETH, "isTokenCall");
2106
2106
 
2107
2107
  // ../shared/src/contracts.ts
2108
+ var extractOverrides = /* @__PURE__ */ __name((transactionOverrides) => {
2109
+ const { wait, ...ethersOverrides } = transactionOverrides;
2110
+ return ethersOverrides;
2111
+ }, "extractOverrides");
2108
2112
  var getTokenContractAddress = /* @__PURE__ */ __name((asset, network) => {
2109
2113
  assert(network !== ChainflipNetworks.mainnet, "Mainnet is not yet supported");
2110
2114
  if (asset === Assets.FLIP)
@@ -2122,20 +2126,15 @@ var checkAllowance = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20
2122
2126
  const allowance = await erc20.allowance(signerAddress, spenderAddress);
2123
2127
  return {
2124
2128
  allowance,
2125
- isAllowable: allowance.gte(amount),
2129
+ isAllowable: allowance >= amount,
2126
2130
  erc20
2127
2131
  };
2128
2132
  }, "checkAllowance");
2129
- var approve = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20, allowance, nonce) => {
2130
- const amountBigNumber = BigNumber.from(amount);
2131
- const allowanceBigNumber = BigNumber.from(allowance);
2132
- if (allowanceBigNumber.gte(amountBigNumber))
2133
+ var approve = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20, allowance, txOpts) => {
2134
+ if (allowance >= amount)
2133
2135
  return null;
2134
- const requiredAmount = amountBigNumber.sub(allowanceBigNumber);
2135
- const tx = await erc20.approve(spenderAddress, requiredAmount, {
2136
- nonce
2137
- });
2138
- return tx.wait(1);
2136
+ const transaction = await erc20.approve(spenderAddress, amount - allowance, extractOverrides(txOpts));
2137
+ return transaction.wait(txOpts.wait);
2139
2138
  }, "approve");
2140
2139
  var getVaultManagerContractAddress = /* @__PURE__ */ __name((network) => {
2141
2140
  assert(network !== ChainflipNetworks.mainnet, "Mainnet is not yet supported");
@@ -2144,8 +2143,7 @@ var getVaultManagerContractAddress = /* @__PURE__ */ __name((network) => {
2144
2143
  var getFlipBalance = /* @__PURE__ */ __name(async (network, signer) => {
2145
2144
  const flipAddress = getTokenContractAddress("FLIP", network);
2146
2145
  const flip = ERC20__factory.connect(flipAddress, signer);
2147
- const balance = await flip.balanceOf(await signer.getAddress());
2148
- return balance.toBigInt();
2146
+ return flip.balanceOf(await signer.getAddress());
2149
2147
  }, "getFlipBalance");
2150
2148
 
2151
- export { Assets, ChainflipNetworks, Chains, StateChainGateway__factory, Vault__factory, __name, __publicField, approve, assert, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds, checkAllowance, getFlipBalance, getMinimumDepositAmount, getMinimumSwapAmount, getStateChainGatewayContractAddress, getTokenContractAddress, getVaultManagerContractAddress, isString, isTestnet, isTokenCall, isTokenSwap };
2149
+ export { Assets, ChainflipNetworks, Chains, StateChainGateway__factory, Vault__factory, __name, __publicField, approve, assert, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds, checkAllowance, extractOverrides, getFlipBalance, getMinimumDepositAmount, getMinimumSwapAmount, getStateChainGatewayContractAddress, getTokenContractAddress, getVaultManagerContractAddress, isString, isTestnet, isTokenCall, isTokenSwap };
@@ -29,4 +29,13 @@ declare const chainAssets: {
29
29
  };
30
30
  declare const chainContractIds: Record<Chain, number>;
31
31
 
32
- export { Asset as A, Chain as C, ChainflipNetwork as a, Chains as b, chainAssets as c, Assets as d, ChainflipNetworks as e, assetChains as f, assetDecimals as g, assetContractIds as h, chainContractIds as i };
32
+ type TransactionOptions = {
33
+ gasLimit?: bigint;
34
+ gasPrice?: bigint;
35
+ maxFeePerGas?: bigint;
36
+ maxPriorityFeePerGas?: bigint;
37
+ nonce?: number;
38
+ wait?: number;
39
+ };
40
+
41
+ export { Asset as A, Chain as C, TransactionOptions as T, ChainflipNetwork as a, Chains as b, chainAssets as c, Assets as d, ChainflipNetworks as e, assetChains as f, assetDecimals as g, assetContractIds as h, chainContractIds as i };
@@ -1,5 +1,5 @@
1
1
  import { Signer } from 'ethers';
2
- import { a as ChainflipNetwork } from './enums-3131916c.js';
2
+ import { T as TransactionOptions, a as ChainflipNetwork } from './contracts-646d1727.js';
3
3
 
4
4
  type SDKOptions = {
5
5
  network?: Exclude<ChainflipNetwork, 'mainnet'>;
@@ -9,12 +9,12 @@ type TransactionHash = string;
9
9
  declare class FundingSDK {
10
10
  private readonly options;
11
11
  constructor(options: SDKOptions);
12
- fundStateChainAccount(accountId: `0x${string}`, amount: string): Promise<TransactionHash>;
13
- executeRedemption(accountId: `0x${string}`): Promise<TransactionHash>;
12
+ fundStateChainAccount(accountId: `0x${string}`, amount: bigint, txOpts?: TransactionOptions): Promise<TransactionHash>;
13
+ executeRedemption(accountId: `0x${string}`, txOpts?: TransactionOptions): Promise<TransactionHash>;
14
14
  getMinimumFunding(): Promise<bigint>;
15
- getRedemptionDelay(): Promise<number>;
15
+ getRedemptionDelay(): Promise<bigint>;
16
16
  getFlipBalance(): Promise<bigint>;
17
- approveStateChainGateway(amount: bigint | string | number, nonce?: bigint | string | number): Promise<TransactionHash | null>;
17
+ approveStateChainGateway(amount: bigint, txOpts?: TransactionOptions): Promise<TransactionHash | null>;
18
18
  }
19
19
 
20
20
  export { FundingSDK };
package/dist/funding.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Signer } from 'ethers';
2
- import { a as ChainflipNetwork } from './enums-3131916c.js';
2
+ import { T as TransactionOptions, a as ChainflipNetwork } from './contracts-646d1727.js';
3
3
 
4
4
  type SDKOptions = {
5
5
  network?: Exclude<ChainflipNetwork, 'mainnet'>;
@@ -9,12 +9,12 @@ type TransactionHash = string;
9
9
  declare class FundingSDK {
10
10
  private readonly options;
11
11
  constructor(options: SDKOptions);
12
- fundStateChainAccount(accountId: `0x${string}`, amount: string): Promise<TransactionHash>;
13
- executeRedemption(accountId: `0x${string}`): Promise<TransactionHash>;
12
+ fundStateChainAccount(accountId: `0x${string}`, amount: bigint, txOpts?: TransactionOptions): Promise<TransactionHash>;
13
+ executeRedemption(accountId: `0x${string}`, txOpts?: TransactionOptions): Promise<TransactionHash>;
14
14
  getMinimumFunding(): Promise<bigint>;
15
- getRedemptionDelay(): Promise<number>;
15
+ getRedemptionDelay(): Promise<bigint>;
16
16
  getFlipBalance(): Promise<bigint>;
17
- approveStateChainGateway(amount: bigint | string | number, nonce?: bigint | string | number): Promise<TransactionHash | null>;
17
+ approveStateChainGateway(amount: bigint, txOpts?: TransactionOptions): Promise<TransactionHash | null>;
18
18
  }
19
19
 
20
20
  export { FundingSDK };
package/dist/funding.js CHANGED
@@ -80,10 +80,10 @@ var _abi = [
80
80
  ];
81
81
  var _ERC20__factory = class _ERC20__factory {
82
82
  static createInterface() {
83
- return new ethers.utils.Interface(_abi);
83
+ return new ethers.Interface(_abi);
84
84
  }
85
- static connect(address, signerOrProvider) {
86
- return new ethers.Contract(address, _abi, signerOrProvider);
85
+ static connect(address, runner) {
86
+ return new ethers.Contract(address, _abi, runner);
87
87
  }
88
88
  };
89
89
  __name(_ERC20__factory, "ERC20__factory");
@@ -751,10 +751,10 @@ var _abi2 = [
751
751
  ];
752
752
  var _StateChainGateway__factory = class _StateChainGateway__factory {
753
753
  static createInterface() {
754
- return new ethers.utils.Interface(_abi2);
754
+ return new ethers.Interface(_abi2);
755
755
  }
756
- static connect(address, signerOrProvider) {
757
- return new ethers.Contract(address, _abi2, signerOrProvider);
756
+ static connect(address, runner) {
757
+ return new ethers.Contract(address, _abi2, runner);
758
758
  }
759
759
  };
760
760
  __name(_StateChainGateway__factory, "StateChainGateway__factory");
@@ -877,6 +877,10 @@ function assert(condition, message) {
877
877
  __name(assert, "assert");
878
878
 
879
879
  // ../shared/src/contracts.ts
880
+ var extractOverrides = /* @__PURE__ */ __name((transactionOverrides) => {
881
+ const { wait, ...ethersOverrides } = transactionOverrides;
882
+ return ethersOverrides;
883
+ }, "extractOverrides");
880
884
  var getTokenContractAddress = /* @__PURE__ */ __name((asset, network) => {
881
885
  assert(network !== ChainflipNetworks.mainnet, "Mainnet is not yet supported");
882
886
  if (asset === Assets.FLIP)
@@ -894,71 +898,62 @@ var checkAllowance = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20
894
898
  const allowance = await erc20.allowance(signerAddress, spenderAddress);
895
899
  return {
896
900
  allowance,
897
- isAllowable: allowance.gte(amount),
901
+ isAllowable: allowance >= amount,
898
902
  erc20
899
903
  };
900
904
  }, "checkAllowance");
901
- var approve = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20, allowance, nonce) => {
902
- const amountBigNumber = ethers.BigNumber.from(amount);
903
- const allowanceBigNumber = ethers.BigNumber.from(allowance);
904
- if (allowanceBigNumber.gte(amountBigNumber))
905
+ var approve = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20, allowance, txOpts) => {
906
+ if (allowance >= amount)
905
907
  return null;
906
- const requiredAmount = amountBigNumber.sub(allowanceBigNumber);
907
- const tx = await erc20.approve(spenderAddress, requiredAmount, {
908
- nonce
909
- });
910
- return tx.wait(1);
908
+ const transaction = await erc20.approve(spenderAddress, amount - allowance, extractOverrides(txOpts));
909
+ return transaction.wait(txOpts.wait);
911
910
  }, "approve");
912
911
  var getFlipBalance = /* @__PURE__ */ __name(async (network, signer) => {
913
912
  const flipAddress = getTokenContractAddress("FLIP", network);
914
913
  const flip = ERC20__factory.connect(flipAddress, signer);
915
- const balance = await flip.balanceOf(await signer.getAddress());
916
- return balance.toBigInt();
914
+ return flip.balanceOf(await signer.getAddress());
917
915
  }, "getFlipBalance");
918
916
 
919
917
  // ../shared/src/stateChainGateway/utils.ts
920
- var getStateChainGateway = /* @__PURE__ */ __name((options) => {
921
- const stateChainGatewayContractAddress = options.network === "localnet" ? options.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(options.network);
922
- return StateChainGateway__factory.connect(stateChainGatewayContractAddress, options.signer);
918
+ var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
919
+ const stateChainGatewayContractAddress = networkOpts.network === "localnet" ? networkOpts.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(networkOpts.network);
920
+ return StateChainGateway__factory.connect(stateChainGatewayContractAddress, networkOpts.signer);
923
921
  }, "getStateChainGateway");
924
922
 
925
923
  // ../shared/src/stateChainGateway/approval.ts
926
- var checkStateChainGatewayAllowance = /* @__PURE__ */ __name(async (amount, options) => {
927
- const flipContractAddress = options.network === "localnet" ? options.flipContractAddress : getTokenContractAddress(Assets.FLIP, options.network);
928
- const stateChainGatewayContractAddress = options.network === "localnet" ? options.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(options.network);
929
- return checkAllowance(amount, stateChainGatewayContractAddress, flipContractAddress, options.signer);
924
+ var checkStateChainGatewayAllowance = /* @__PURE__ */ __name(async (amount, networkOpts) => {
925
+ const flipContractAddress = networkOpts.network === "localnet" ? networkOpts.flipContractAddress : getTokenContractAddress(Assets.FLIP, networkOpts.network);
926
+ const stateChainGatewayContractAddress = networkOpts.network === "localnet" ? networkOpts.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(networkOpts.network);
927
+ return checkAllowance(amount, stateChainGatewayContractAddress, flipContractAddress, networkOpts.signer);
930
928
  }, "checkStateChainGatewayAllowance");
931
- var approveStateChainGateway = /* @__PURE__ */ __name(async (amount, options) => {
932
- const { allowance, erc20, isAllowable } = await checkStateChainGatewayAllowance(amount, options);
929
+ var approveStateChainGateway = /* @__PURE__ */ __name(async (amount, networkOpts, txOpts) => {
930
+ const { allowance, erc20, isAllowable } = await checkStateChainGatewayAllowance(amount, networkOpts);
933
931
  if (isAllowable)
934
932
  return null;
935
- const stateChainGatewayContractAddress = options.network === "localnet" ? options.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(options.network);
936
- const receipt = await approve(amount, stateChainGatewayContractAddress, erc20, allowance, options.nonce);
937
- return receipt;
933
+ const stateChainGatewayContractAddress = networkOpts.network === "localnet" ? networkOpts.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(networkOpts.network);
934
+ return approve(amount, stateChainGatewayContractAddress, erc20, allowance, txOpts);
938
935
  }, "approveStateChainGateway");
939
936
 
940
937
  // ../shared/src/stateChainGateway/index.ts
941
- var fundStateChainAccount = /* @__PURE__ */ __name(async (accountId, amount, options) => {
942
- const flipContractAddress = options.network === "localnet" ? options.flipContractAddress : getTokenContractAddress(Assets.FLIP, options.network);
943
- const stateChainGateway = getStateChainGateway(options);
944
- const { isAllowable } = await checkAllowance(amount, stateChainGateway.address, flipContractAddress, options.signer);
938
+ var fundStateChainAccount = /* @__PURE__ */ __name(async (accountId, amount, networkOpts, txOpts) => {
939
+ const flipContractAddress = networkOpts.network === "localnet" ? networkOpts.flipContractAddress : getTokenContractAddress(Assets.FLIP, networkOpts.network);
940
+ const stateChainGateway = getStateChainGateway(networkOpts);
941
+ const { isAllowable } = await checkAllowance(amount, await stateChainGateway.getAddress(), flipContractAddress, networkOpts.signer);
945
942
  assert(isAllowable, "Insufficient allowance");
946
- const transaction = await stateChainGateway.fundStateChainAccount(accountId, amount, {
947
- nonce: options.nonce
948
- });
949
- return transaction.wait(1);
943
+ const transaction = await stateChainGateway.fundStateChainAccount(accountId, amount, extractOverrides(txOpts));
944
+ return transaction.wait(txOpts.wait);
950
945
  }, "fundStateChainAccount");
951
- var executeRedemption = /* @__PURE__ */ __name(async (accountId, options) => {
952
- const stateChainGateway = getStateChainGateway(options);
953
- const transaction = await stateChainGateway.executeRedemption(accountId, options);
954
- return transaction.wait(1);
946
+ var executeRedemption = /* @__PURE__ */ __name(async (accountId, networkOpts, txOpts) => {
947
+ const stateChainGateway = getStateChainGateway(networkOpts);
948
+ const transaction = await stateChainGateway.executeRedemption(accountId, extractOverrides(txOpts));
949
+ return transaction.wait(txOpts.wait);
955
950
  }, "executeRedemption");
956
- var getMinimumFunding = /* @__PURE__ */ __name((options) => {
957
- const stateChainGateway = getStateChainGateway(options);
951
+ var getMinimumFunding = /* @__PURE__ */ __name((networkOpts) => {
952
+ const stateChainGateway = getStateChainGateway(networkOpts);
958
953
  return stateChainGateway.getMinimumFunding();
959
954
  }, "getMinimumFunding");
960
- var getRedemptionDelay = /* @__PURE__ */ __name((options) => {
961
- const stateChainGateway = getStateChainGateway(options);
955
+ var getRedemptionDelay = /* @__PURE__ */ __name((networkOpts) => {
956
+ const stateChainGateway = getStateChainGateway(networkOpts);
962
957
  return stateChainGateway.REDEMPTION_DELAY();
963
958
  }, "getRedemptionDelay");
964
959
 
@@ -974,25 +969,20 @@ var _FundingSDK = class _FundingSDK {
974
969
  /**
975
970
  * @param accountId the hex-encoded validator account id
976
971
  * @param amount the amount to fund in base units of FLIP
977
- * @param signer a signer to use for the transaction if different from the one
978
- * provided in the constructor
979
972
  */
980
- async fundStateChainAccount(accountId, amount) {
981
- const tx = await fundStateChainAccount(accountId, amount, this.options);
982
- return tx.transactionHash;
973
+ async fundStateChainAccount(accountId, amount, txOpts = {}) {
974
+ const tx = await fundStateChainAccount(accountId, amount, this.options, txOpts);
975
+ return tx.hash;
983
976
  }
984
977
  /**
985
978
  * @param accountId the hex-encoded validator account id
986
- * @param signer a signer to use for the transaction if different from the one
987
- * provided in the constructor
988
979
  */
989
- async executeRedemption(accountId) {
990
- const tx = await executeRedemption(accountId, this.options);
991
- return tx.transactionHash;
980
+ async executeRedemption(accountId, txOpts = {}) {
981
+ const tx = await executeRedemption(accountId, this.options, txOpts);
982
+ return tx.hash;
992
983
  }
993
984
  async getMinimumFunding() {
994
- const amount = await getMinimumFunding(this.options);
995
- return amount.toBigInt();
985
+ return getMinimumFunding(this.options);
996
986
  }
997
987
  async getRedemptionDelay() {
998
988
  return getRedemptionDelay(this.options);
@@ -1004,12 +994,9 @@ var _FundingSDK = class _FundingSDK {
1004
994
  * @param amount the amount of FLIP to request approval for
1005
995
  * @returns the transaction hash or null if no approval was required
1006
996
  */
1007
- async approveStateChainGateway(amount, nonce) {
1008
- const receipt = await approveStateChainGateway(amount, {
1009
- nonce,
1010
- ...this.options
1011
- });
1012
- return receipt && receipt.transactionHash;
997
+ async approveStateChainGateway(amount, txOpts = {}) {
998
+ const receipt = await approveStateChainGateway(amount, this.options, txOpts);
999
+ return receipt && receipt.hash;
1013
1000
  }
1014
1001
  };
1015
1002
  __name(_FundingSDK, "FundingSDK");
package/dist/funding.mjs CHANGED
@@ -1,48 +1,45 @@
1
- import { __name, __publicField, ChainflipNetworks, getFlipBalance, getStateChainGatewayContractAddress, approve, getTokenContractAddress, Assets, checkAllowance, assert, StateChainGateway__factory } from './chunk-VOWQWFJD.mjs';
1
+ import { __name, __publicField, ChainflipNetworks, getFlipBalance, getStateChainGatewayContractAddress, approve, getTokenContractAddress, Assets, checkAllowance, assert, extractOverrides, StateChainGateway__factory } from './chunk-UBMU3BTF.mjs';
2
2
 
3
3
  // ../shared/src/stateChainGateway/utils.ts
4
- var getStateChainGateway = /* @__PURE__ */ __name((options) => {
5
- const stateChainGatewayContractAddress = options.network === "localnet" ? options.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(options.network);
6
- return StateChainGateway__factory.connect(stateChainGatewayContractAddress, options.signer);
4
+ var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
5
+ const stateChainGatewayContractAddress = networkOpts.network === "localnet" ? networkOpts.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(networkOpts.network);
6
+ return StateChainGateway__factory.connect(stateChainGatewayContractAddress, networkOpts.signer);
7
7
  }, "getStateChainGateway");
8
8
 
9
9
  // ../shared/src/stateChainGateway/approval.ts
10
- var checkStateChainGatewayAllowance = /* @__PURE__ */ __name(async (amount, options) => {
11
- const flipContractAddress = options.network === "localnet" ? options.flipContractAddress : getTokenContractAddress(Assets.FLIP, options.network);
12
- const stateChainGatewayContractAddress = options.network === "localnet" ? options.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(options.network);
13
- return checkAllowance(amount, stateChainGatewayContractAddress, flipContractAddress, options.signer);
10
+ var checkStateChainGatewayAllowance = /* @__PURE__ */ __name(async (amount, networkOpts) => {
11
+ const flipContractAddress = networkOpts.network === "localnet" ? networkOpts.flipContractAddress : getTokenContractAddress(Assets.FLIP, networkOpts.network);
12
+ const stateChainGatewayContractAddress = networkOpts.network === "localnet" ? networkOpts.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(networkOpts.network);
13
+ return checkAllowance(amount, stateChainGatewayContractAddress, flipContractAddress, networkOpts.signer);
14
14
  }, "checkStateChainGatewayAllowance");
15
- var approveStateChainGateway = /* @__PURE__ */ __name(async (amount, options) => {
16
- const { allowance, erc20, isAllowable } = await checkStateChainGatewayAllowance(amount, options);
15
+ var approveStateChainGateway = /* @__PURE__ */ __name(async (amount, networkOpts, txOpts) => {
16
+ const { allowance, erc20, isAllowable } = await checkStateChainGatewayAllowance(amount, networkOpts);
17
17
  if (isAllowable)
18
18
  return null;
19
- const stateChainGatewayContractAddress = options.network === "localnet" ? options.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(options.network);
20
- const receipt = await approve(amount, stateChainGatewayContractAddress, erc20, allowance, options.nonce);
21
- return receipt;
19
+ const stateChainGatewayContractAddress = networkOpts.network === "localnet" ? networkOpts.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(networkOpts.network);
20
+ return approve(amount, stateChainGatewayContractAddress, erc20, allowance, txOpts);
22
21
  }, "approveStateChainGateway");
23
22
 
24
23
  // ../shared/src/stateChainGateway/index.ts
25
- var fundStateChainAccount = /* @__PURE__ */ __name(async (accountId, amount, options) => {
26
- const flipContractAddress = options.network === "localnet" ? options.flipContractAddress : getTokenContractAddress(Assets.FLIP, options.network);
27
- const stateChainGateway = getStateChainGateway(options);
28
- const { isAllowable } = await checkAllowance(amount, stateChainGateway.address, flipContractAddress, options.signer);
24
+ var fundStateChainAccount = /* @__PURE__ */ __name(async (accountId, amount, networkOpts, txOpts) => {
25
+ const flipContractAddress = networkOpts.network === "localnet" ? networkOpts.flipContractAddress : getTokenContractAddress(Assets.FLIP, networkOpts.network);
26
+ const stateChainGateway = getStateChainGateway(networkOpts);
27
+ const { isAllowable } = await checkAllowance(amount, await stateChainGateway.getAddress(), flipContractAddress, networkOpts.signer);
29
28
  assert(isAllowable, "Insufficient allowance");
30
- const transaction = await stateChainGateway.fundStateChainAccount(accountId, amount, {
31
- nonce: options.nonce
32
- });
33
- return transaction.wait(1);
29
+ const transaction = await stateChainGateway.fundStateChainAccount(accountId, amount, extractOverrides(txOpts));
30
+ return transaction.wait(txOpts.wait);
34
31
  }, "fundStateChainAccount");
35
- var executeRedemption = /* @__PURE__ */ __name(async (accountId, options) => {
36
- const stateChainGateway = getStateChainGateway(options);
37
- const transaction = await stateChainGateway.executeRedemption(accountId, options);
38
- return transaction.wait(1);
32
+ var executeRedemption = /* @__PURE__ */ __name(async (accountId, networkOpts, txOpts) => {
33
+ const stateChainGateway = getStateChainGateway(networkOpts);
34
+ const transaction = await stateChainGateway.executeRedemption(accountId, extractOverrides(txOpts));
35
+ return transaction.wait(txOpts.wait);
39
36
  }, "executeRedemption");
40
- var getMinimumFunding = /* @__PURE__ */ __name((options) => {
41
- const stateChainGateway = getStateChainGateway(options);
37
+ var getMinimumFunding = /* @__PURE__ */ __name((networkOpts) => {
38
+ const stateChainGateway = getStateChainGateway(networkOpts);
42
39
  return stateChainGateway.getMinimumFunding();
43
40
  }, "getMinimumFunding");
44
- var getRedemptionDelay = /* @__PURE__ */ __name((options) => {
45
- const stateChainGateway = getStateChainGateway(options);
41
+ var getRedemptionDelay = /* @__PURE__ */ __name((networkOpts) => {
42
+ const stateChainGateway = getStateChainGateway(networkOpts);
46
43
  return stateChainGateway.REDEMPTION_DELAY();
47
44
  }, "getRedemptionDelay");
48
45
 
@@ -58,25 +55,20 @@ var _FundingSDK = class _FundingSDK {
58
55
  /**
59
56
  * @param accountId the hex-encoded validator account id
60
57
  * @param amount the amount to fund in base units of FLIP
61
- * @param signer a signer to use for the transaction if different from the one
62
- * provided in the constructor
63
58
  */
64
- async fundStateChainAccount(accountId, amount) {
65
- const tx = await fundStateChainAccount(accountId, amount, this.options);
66
- return tx.transactionHash;
59
+ async fundStateChainAccount(accountId, amount, txOpts = {}) {
60
+ const tx = await fundStateChainAccount(accountId, amount, this.options, txOpts);
61
+ return tx.hash;
67
62
  }
68
63
  /**
69
64
  * @param accountId the hex-encoded validator account id
70
- * @param signer a signer to use for the transaction if different from the one
71
- * provided in the constructor
72
65
  */
73
- async executeRedemption(accountId) {
74
- const tx = await executeRedemption(accountId, this.options);
75
- return tx.transactionHash;
66
+ async executeRedemption(accountId, txOpts = {}) {
67
+ const tx = await executeRedemption(accountId, this.options, txOpts);
68
+ return tx.hash;
76
69
  }
77
70
  async getMinimumFunding() {
78
- const amount = await getMinimumFunding(this.options);
79
- return amount.toBigInt();
71
+ return getMinimumFunding(this.options);
80
72
  }
81
73
  async getRedemptionDelay() {
82
74
  return getRedemptionDelay(this.options);
@@ -88,12 +80,9 @@ var _FundingSDK = class _FundingSDK {
88
80
  * @param amount the amount of FLIP to request approval for
89
81
  * @returns the transaction hash or null if no approval was required
90
82
  */
91
- async approveStateChainGateway(amount, nonce) {
92
- const receipt = await approveStateChainGateway(amount, {
93
- nonce,
94
- ...this.options
95
- });
96
- return receipt && receipt.transactionHash;
83
+ async approveStateChainGateway(amount, txOpts = {}) {
84
+ const receipt = await approveStateChainGateway(amount, this.options, txOpts);
85
+ return receipt && receipt.hash;
97
86
  }
98
87
  };
99
88
  __name(_FundingSDK, "FundingSDK");