@chainflip/sdk 1.8.0-assethub.2 → 1.8.0-beta.1

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.js CHANGED
@@ -3,10 +3,7 @@
3
3
  var ethers = require('ethers');
4
4
  var rpc = require('@chainflip/rpc');
5
5
 
6
- var __defProp = Object.defineProperty;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
+ // ../shared/src/abis/factories/ERC20__factory.ts
10
7
  var _abi = [
11
8
  {
12
9
  inputs: [
@@ -76,7 +73,7 @@ var _abi = [
76
73
  type: "function"
77
74
  }
78
75
  ];
79
- var _ERC20__factory = class _ERC20__factory {
76
+ var ERC20__factory = class {
80
77
  static createInterface() {
81
78
  return new ethers.Interface(_abi);
82
79
  }
@@ -84,9 +81,7 @@ var _ERC20__factory = class _ERC20__factory {
84
81
  return new ethers.Contract(address, _abi, runner);
85
82
  }
86
83
  };
87
- __name(_ERC20__factory, "ERC20__factory");
88
- __publicField(_ERC20__factory, "abi", _abi);
89
- var ERC20__factory = _ERC20__factory;
84
+ ERC20__factory.abi = _abi;
90
85
  var _abi2 = [
91
86
  {
92
87
  inputs: [
@@ -747,7 +742,7 @@ var _abi2 = [
747
742
  type: "function"
748
743
  }
749
744
  ];
750
- var _StateChainGateway__factory = class _StateChainGateway__factory {
745
+ var StateChainGateway__factory = class {
751
746
  static createInterface() {
752
747
  return new ethers.Interface(_abi2);
753
748
  }
@@ -755,272 +750,25 @@ var _StateChainGateway__factory = class _StateChainGateway__factory {
755
750
  return new ethers.Contract(address, _abi2, runner);
756
751
  }
757
752
  };
758
- __name(_StateChainGateway__factory, "StateChainGateway__factory");
759
- __publicField(_StateChainGateway__factory, "abi", _abi2);
760
- var StateChainGateway__factory = _StateChainGateway__factory;
753
+ StateChainGateway__factory.abi = _abi2;
761
754
 
762
755
  // ../shared/src/enums.ts
763
- var arrayToMap = /* @__PURE__ */ __name((array) => Object.fromEntries(array.map((key) => [
764
- key,
765
- key
766
- ])), "arrayToMap");
767
- var InternalAssets = arrayToMap([
768
- "Btc",
756
+ var arrayToMap = (array) => Object.fromEntries(array.map((key) => [key, key]));
757
+ arrayToMap([
758
+ "Flip",
759
+ "Usdc",
769
760
  "Dot",
770
- // ethereum
771
761
  "Eth",
772
- "Usdc",
773
- "Flip",
762
+ "Btc",
774
763
  "Usdt",
775
- // solana
776
- "Sol",
777
- "SolUsdc",
778
- // arbitrum
779
764
  "ArbUsdc",
780
765
  "ArbEth",
781
- // asset hub
782
- "HubDot",
783
- "HubUsdc",
784
- "HubUsdt"
785
- ]);
786
- var Chains = arrayToMap([
787
- "Bitcoin",
788
- "Ethereum",
789
- "Polkadot",
790
- "Arbitrum",
791
- "Solana",
792
- "Assethub"
793
- ]);
794
- var Assets = arrayToMap([
795
- "FLIP",
796
- "USDC",
797
- "DOT",
798
- "ETH",
799
- "BTC",
800
- "USDT",
801
- "SOL"
802
- ]);
803
- var ChainflipNetworks = arrayToMap([
804
- "backspin",
805
- "sisyphos",
806
- "perseverance",
807
- "mainnet"
766
+ "Sol",
767
+ "SolUsdc"
808
768
  ]);
809
- ({
810
- [InternalAssets.Eth]: {
811
- chain: Chains.Ethereum,
812
- asset: Assets.ETH,
813
- name: "Ether",
814
- decimals: 18,
815
- contractId: 1
816
- },
817
- [InternalAssets.Flip]: {
818
- chain: Chains.Ethereum,
819
- asset: Assets.FLIP,
820
- name: "FLIP",
821
- decimals: 18,
822
- contractId: 2
823
- },
824
- [InternalAssets.Usdc]: {
825
- chain: Chains.Ethereum,
826
- asset: Assets.USDC,
827
- name: "USDC",
828
- decimals: 6,
829
- contractId: 3
830
- },
831
- [InternalAssets.Usdt]: {
832
- chain: Chains.Ethereum,
833
- asset: Assets.USDT,
834
- name: "USDT",
835
- decimals: 6,
836
- contractId: 8
837
- },
838
- [InternalAssets.Dot]: {
839
- chain: Chains.Polkadot,
840
- asset: Assets.DOT,
841
- name: "Polkadot",
842
- decimals: 10,
843
- contractId: 4
844
- },
845
- [InternalAssets.Btc]: {
846
- chain: Chains.Bitcoin,
847
- asset: Assets.BTC,
848
- name: "Bitcoin",
849
- decimals: 8,
850
- contractId: 5
851
- },
852
- [InternalAssets.ArbEth]: {
853
- chain: Chains.Arbitrum,
854
- asset: Assets.ETH,
855
- name: "Arbitrum Ether",
856
- decimals: 18,
857
- contractId: 6
858
- },
859
- [InternalAssets.ArbUsdc]: {
860
- chain: Chains.Arbitrum,
861
- asset: Assets.USDC,
862
- name: "Arbitrum USDC",
863
- decimals: 6,
864
- contractId: 7
865
- },
866
- [InternalAssets.Sol]: {
867
- chain: Chains.Solana,
868
- asset: Assets.SOL,
869
- name: "Solana",
870
- decimals: 9,
871
- contractId: 9
872
- },
873
- [InternalAssets.SolUsdc]: {
874
- chain: Chains.Solana,
875
- asset: Assets.USDC,
876
- name: "Solana USDC",
877
- decimals: 6,
878
- contractId: 10
879
- },
880
- [InternalAssets.HubDot]: {
881
- chain: Chains.Assethub,
882
- asset: Assets.DOT,
883
- name: "AssetHub DOT",
884
- decimals: 10,
885
- contractId: 11
886
- },
887
- [InternalAssets.HubUsdc]: {
888
- chain: Chains.Assethub,
889
- asset: Assets.USDC,
890
- name: "AssetHub USDC",
891
- decimals: 6,
892
- contractId: 12
893
- },
894
- [InternalAssets.HubUsdt]: {
895
- chain: Chains.Assethub,
896
- asset: Assets.USDT,
897
- name: "AssetHub USDT",
898
- decimals: 6,
899
- contractId: 13
900
- }
901
- });
902
- var chainConstants = {
903
- [Chains.Ethereum]: {
904
- assets: [
905
- Assets.ETH,
906
- Assets.FLIP,
907
- Assets.USDC,
908
- Assets.USDT
909
- ],
910
- gasAsset: InternalAssets.Eth,
911
- contractId: 1,
912
- blockTimeSeconds: 12
913
- },
914
- [Chains.Polkadot]: {
915
- assets: [
916
- Assets.DOT
917
- ],
918
- gasAsset: InternalAssets.Dot,
919
- contractId: 2,
920
- blockTimeSeconds: 6
921
- },
922
- [Chains.Bitcoin]: {
923
- assets: [
924
- Assets.BTC
925
- ],
926
- gasAsset: InternalAssets.Btc,
927
- contractId: 3,
928
- blockTimeSeconds: 10 * 60
929
- },
930
- [Chains.Arbitrum]: {
931
- assets: [
932
- Assets.ETH,
933
- Assets.USDC
934
- ],
935
- gasAsset: InternalAssets.ArbEth,
936
- contractId: 4,
937
- blockTimeSeconds: 0.26
938
- },
939
- [Chains.Solana]: {
940
- assets: [
941
- Assets.SOL,
942
- Assets.USDC
943
- ],
944
- gasAsset: InternalAssets.Sol,
945
- contractId: 5,
946
- blockTimeSeconds: (400 + 800) / 2 / 1e3
947
- },
948
- [Chains.Assethub]: {
949
- assets: [
950
- Assets.DOT,
951
- Assets.USDC,
952
- Assets.USDT
953
- ],
954
- gasAsset: InternalAssets.HubDot,
955
- contractId: 6,
956
- blockTimeSeconds: 12
957
- }
958
- };
959
- function isValidAssetAndChain(assetAndChain) {
960
- const { asset, chain } = assetAndChain;
961
- if (!(chain in Chains)) return false;
962
- const validAssets = chainConstants[chain].assets;
963
- return validAssets.includes(asset);
964
- }
965
- __name(isValidAssetAndChain, "isValidAssetAndChain");
966
- function getInternalAsset(asset, assert2 = true) {
967
- if (!isValidAssetAndChain(asset)) {
968
- if (assert2) {
969
- throw new Error(`invalid asset and chain combination: ${JSON.stringify(asset)}`);
970
- }
971
- return null;
972
- }
973
- const map = {
974
- [Chains.Ethereum]: {
975
- [Assets.USDC]: InternalAssets.Usdc,
976
- [Assets.FLIP]: InternalAssets.Flip,
977
- [Assets.ETH]: InternalAssets.Eth,
978
- [Assets.USDT]: InternalAssets.Usdt
979
- },
980
- [Chains.Bitcoin]: {
981
- [Assets.BTC]: InternalAssets.Btc
982
- },
983
- [Chains.Polkadot]: {
984
- [Assets.DOT]: InternalAssets.Dot
985
- },
986
- [Chains.Arbitrum]: {
987
- [Assets.USDC]: InternalAssets.ArbUsdc,
988
- [Assets.ETH]: InternalAssets.ArbEth
989
- },
990
- [Chains.Solana]: {
991
- [Assets.SOL]: InternalAssets.Sol,
992
- [Assets.USDC]: InternalAssets.SolUsdc
993
- },
994
- [Chains.Assethub]: {
995
- [Assets.DOT]: InternalAssets.HubDot,
996
- [Assets.USDC]: InternalAssets.HubUsdc,
997
- [Assets.USDT]: InternalAssets.HubUsdt
998
- }
999
- };
1000
- const chain = map[asset.chain];
1001
- return chain[asset.asset];
1002
- }
1003
- __name(getInternalAsset, "getInternalAsset");
1004
-
1005
- // ../shared/src/consts.ts
1006
- ({
1007
- [ChainflipNetworks.backspin]: 1e3,
1008
- [ChainflipNetworks.sisyphos]: 1e3,
1009
- [ChainflipNetworks.perseverance]: 1e3,
1010
- [ChainflipNetworks.mainnet]: 1e3
1011
- });
1012
- ({
1013
- [ChainflipNetworks.backspin]: 10997,
1014
- [ChainflipNetworks.sisyphos]: 11155111,
1015
- [ChainflipNetworks.perseverance]: 11155111,
1016
- [ChainflipNetworks.mainnet]: 1
1017
- });
1018
- ({
1019
- [ChainflipNetworks.backspin]: 412346,
1020
- [ChainflipNetworks.sisyphos]: 421614,
1021
- [ChainflipNetworks.perseverance]: 421614,
1022
- [ChainflipNetworks.mainnet]: 42161
1023
- });
769
+ arrayToMap(["Bitcoin", "Ethereum", "Polkadot", "Arbitrum", "Solana"]);
770
+ arrayToMap(["FLIP", "USDC", "DOT", "ETH", "BTC", "USDT", "SOL"]);
771
+ var ChainflipNetworks = arrayToMap(["backspin", "sisyphos", "perseverance", "mainnet"]);
1024
772
  var SEPOLIA_USDC_CONTRACT_ADDRESS = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238";
1025
773
  var SEPOLIA_USDT_CONTRACT_ADDRESS = "0x27CEA6Eb8a21Aae05Eb29C91c5CA10592892F584";
1026
774
  var ADDRESSES = {
@@ -1029,20 +777,15 @@ var ADDRESSES = {
1029
777
  USDC_CONTRACT_ADDRESS: "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
1030
778
  USDT_CONTRACT_ADDRESS: "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
1031
779
  ARBUSDC_CONTRACT_ADDRESS: "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
1032
- VAULT_CONTRACT_ADDRESS: "0xB7A5bd0345EF1Cc5E66bf61BdeC17D2461fBd968",
1033
780
  STATE_CHAIN_GATEWAY_ADDRESS: "0xeEBe00Ac0756308ac4AaBfD76c05c4F3088B8883",
1034
- ARB_VAULT_CONTRACT_ADDRESS: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
1035
- // TODO(solana)
1036
- SOLUSDC_CONTRACT_ADDRESS: ""
781
+ SOLUSDC_CONTRACT_ADDRESS: "24PNhTaNtomHhoy3fTRaMhAFCRj4uHqhZEEoWrKDbR5p"
1037
782
  },
1038
783
  [ChainflipNetworks.sisyphos]: {
1039
784
  FLIP_CONTRACT_ADDRESS: "0xcD079EAB6B5443b545788Fd210C8800FEADd87fa",
1040
785
  USDC_CONTRACT_ADDRESS: SEPOLIA_USDC_CONTRACT_ADDRESS,
1041
786
  USDT_CONTRACT_ADDRESS: SEPOLIA_USDT_CONTRACT_ADDRESS,
1042
787
  ARBUSDC_CONTRACT_ADDRESS: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
1043
- VAULT_CONTRACT_ADDRESS: "0xa94d6b1853F3cb611Ed3cCb701b4fdA5a9DACe85",
1044
788
  STATE_CHAIN_GATEWAY_ADDRESS: "0x1F7fE41C798cc7b1D34BdC8de2dDDA4a4bE744D9",
1045
- ARB_VAULT_CONTRACT_ADDRESS: "0x8155BdD48CD011e1118b51A1C82be020A3E5c2f2",
1046
789
  SOLUSDC_CONTRACT_ADDRESS: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"
1047
790
  },
1048
791
  [ChainflipNetworks.perseverance]: {
@@ -1050,9 +793,7 @@ var ADDRESSES = {
1050
793
  USDC_CONTRACT_ADDRESS: SEPOLIA_USDC_CONTRACT_ADDRESS,
1051
794
  USDT_CONTRACT_ADDRESS: SEPOLIA_USDT_CONTRACT_ADDRESS,
1052
795
  ARBUSDC_CONTRACT_ADDRESS: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
1053
- VAULT_CONTRACT_ADDRESS: "0x36eaD71325604DC15d35FAE584D7b50646D81753",
1054
796
  STATE_CHAIN_GATEWAY_ADDRESS: "0xA34a967197Ee90BB7fb28e928388a573c5CFd099",
1055
- ARB_VAULT_CONTRACT_ADDRESS: "0x2bb150e6d4366A1BDBC4275D1F35892CD63F27e3",
1056
797
  SOLUSDC_CONTRACT_ADDRESS: "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"
1057
798
  },
1058
799
  [ChainflipNetworks.mainnet]: {
@@ -1060,90 +801,59 @@ var ADDRESSES = {
1060
801
  USDC_CONTRACT_ADDRESS: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
1061
802
  USDT_CONTRACT_ADDRESS: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
1062
803
  ARBUSDC_CONTRACT_ADDRESS: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
1063
- VAULT_CONTRACT_ADDRESS: "0xF5e10380213880111522dd0efD3dbb45b9f62Bcc",
1064
804
  STATE_CHAIN_GATEWAY_ADDRESS: "0x6995Ab7c4D7F4B03f467Cf4c8E920427d9621DBd",
1065
- ARB_VAULT_CONTRACT_ADDRESS: "0x79001a5e762f3bEFC8e5871b42F6734e00498920",
1066
805
  SOLUSDC_CONTRACT_ADDRESS: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
1067
806
  }
1068
807
  };
1069
808
 
1070
809
  // ../shared/src/contracts.ts
1071
- var extractOverrides = /* @__PURE__ */ __name((transactionOverrides) => {
810
+ var extractOverrides = (transactionOverrides) => {
1072
811
  const { wait, ...ethersOverrides } = transactionOverrides;
1073
812
  return ethersOverrides;
1074
- }, "extractOverrides");
1075
- function getTokenContractAddress(asset, network) {
1076
- if (asset === InternalAssets.Flip) return ADDRESSES[network].FLIP_CONTRACT_ADDRESS;
1077
- if (asset === InternalAssets.Usdc) return ADDRESSES[network].USDC_CONTRACT_ADDRESS;
1078
- if (asset === InternalAssets.Usdt) return ADDRESSES[network].USDT_CONTRACT_ADDRESS;
1079
- if (asset === InternalAssets.ArbUsdc) return ADDRESSES[network].ARBUSDC_CONTRACT_ADDRESS;
1080
- if (asset === InternalAssets.SolUsdc) return ADDRESSES[network].SOLUSDC_CONTRACT_ADDRESS;
1081
- throw new Error(`No contract address for ${asset} on ${network}`);
1082
- }
1083
- __name(getTokenContractAddress, "getTokenContractAddress");
1084
- var getStateChainGatewayContractAddress = /* @__PURE__ */ __name((network) => ADDRESSES[network].STATE_CHAIN_GATEWAY_ADDRESS, "getStateChainGatewayContractAddress");
1085
- var checkAllowance = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20Address, signer) => {
813
+ };
814
+ var getFlipContractAddress = (network) => ADDRESSES[network].FLIP_CONTRACT_ADDRESS;
815
+ var getStateChainGatewayContractAddress = (network) => ADDRESSES[network].STATE_CHAIN_GATEWAY_ADDRESS;
816
+ var checkAllowance = async (amount, spenderAddress, erc20Address, signer) => {
1086
817
  const erc20 = ERC20__factory.connect(erc20Address, signer);
1087
818
  const signerAddress = await signer.getAddress();
1088
819
  const allowance = await erc20.allowance(signerAddress, spenderAddress);
1089
- return {
1090
- allowance,
1091
- hasSufficientAllowance: allowance >= amount,
1092
- erc20
1093
- };
1094
- }, "checkAllowance");
1095
- var approve = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20, allowance, txOpts) => {
820
+ return { allowance, hasSufficientAllowance: allowance >= amount, erc20 };
821
+ };
822
+ var approve = async (amount, spenderAddress, erc20, allowance, txOpts) => {
1096
823
  if (allowance >= amount) return null;
1097
- const transaction = await erc20.approve(spenderAddress, amount - allowance, extractOverrides(txOpts));
824
+ const transaction = await erc20.approve(
825
+ spenderAddress,
826
+ amount - allowance,
827
+ extractOverrides(txOpts)
828
+ );
1098
829
  await transaction.wait(txOpts.wait);
1099
830
  return transaction;
1100
- }, "approve");
1101
- var getFlipBalance = /* @__PURE__ */ __name(async (network, signer) => {
1102
- const flipAddress = getTokenContractAddress(InternalAssets.Flip, network);
831
+ };
832
+ var getFlipBalance = async (network, signer) => {
833
+ const flipAddress = getFlipContractAddress(network);
1103
834
  const flip = ERC20__factory.connect(flipAddress, signer);
1104
835
  return flip.balanceOf(await signer.getAddress());
1105
- }, "getFlipBalance");
1106
- var camelCase = /* @__PURE__ */ __name((str) => str.replace(/_([a-z])/g, (_, char) => char.toUpperCase()), "camelCase");
1107
- var camelCaseKeys = /* @__PURE__ */ __name((obj) => {
836
+ };
837
+ var camelCase = (str) => str.replace(/_([a-z])/g, (_, char) => char.toUpperCase());
838
+ var camelCaseKeys = (obj) => {
1108
839
  if (typeof obj !== "object" || obj === null) return obj;
1109
840
  if (Array.isArray(obj)) return obj.map((item) => camelCaseKeys(item));
1110
- return Object.fromEntries(Object.entries(obj).map(([key, value]) => [
1111
- camelCase(key),
1112
- camelCaseKeys(value)
1113
- ]));
1114
- }, "camelCaseKeys");
1115
- var createRequest = /* @__PURE__ */ __name((method) => async (urlOrNetwork, ...params) => {
841
+ return Object.fromEntries(
842
+ Object.entries(obj).map(([key, value]) => [camelCase(key), camelCaseKeys(value)])
843
+ );
844
+ };
845
+ var createRequest = (method) => async (urlOrNetwork, ...params) => {
1116
846
  const url = "network" in urlOrNetwork ? rpc.constants.PUBLIC_RPC_ENDPOINTS[urlOrNetwork.network] : urlOrNetwork.rpcUrl;
1117
847
  const result = await new rpc.HttpClient(url).sendRequest(method, ...params);
1118
848
  return camelCaseKeys(result);
1119
- }, "createRequest");
1120
- var transform = /* @__PURE__ */ __name((fn, cb) => (...args) => fn(...args).then(cb), "transform");
849
+ };
1121
850
  var getFundingEnvironment = createRequest("cf_funding_environment");
1122
- createRequest("cf_swapping_environment");
1123
- createRequest("cf_ingress_egress_environment");
1124
- createRequest("cf_environment");
1125
- createRequest("cf_swap_rate");
1126
- createRequest("state_getMetadata");
1127
- createRequest("cf_supported_assets");
1128
- createRequest("state_getRuntimeVersion");
1129
- createRequest("chain_getBlockHash");
1130
- createRequest("cf_pool_depth");
1131
- createRequest("cf_accounts");
1132
- createRequest("cf_account_info");
1133
- transform(createRequest("cf_boost_pools_depth"), (result) => result.map(({ chain, asset, ...rest }) => ({
1134
- asset: getInternalAsset({
1135
- chain,
1136
- asset
1137
- }),
1138
- ...rest
1139
- })));
1140
- createRequest("cf_swap_rate_v2");
1141
851
 
1142
852
  // ../shared/src/stateChainGateway/utils.ts
1143
- var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
853
+ var getStateChainGateway = (networkOpts) => {
1144
854
  const stateChainGatewayContractAddress = networkOpts.network === "localnet" ? networkOpts.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(networkOpts.network);
1145
855
  return StateChainGateway__factory.connect(stateChainGatewayContractAddress, networkOpts.signer);
1146
- }, "getStateChainGateway");
856
+ };
1147
857
 
1148
858
  // ../shared/src/guards.ts
1149
859
  function assert(condition, message, Constructor = Error) {
@@ -1154,79 +864,91 @@ function assert(condition, message, Constructor = Error) {
1154
864
  }
1155
865
  throw error;
1156
866
  }
1157
- __name(assert, "assert");
1158
867
 
1159
868
  // ../shared/src/stateChainGateway/approval.ts
1160
- var checkStateChainGatewayAllowance = /* @__PURE__ */ __name(async (amount, networkOpts) => {
1161
- const flipContractAddress = networkOpts.network === "localnet" ? networkOpts.flipContractAddress : getTokenContractAddress(InternalAssets.Flip, networkOpts.network);
869
+ var checkStateChainGatewayAllowance = async (amount, networkOpts) => {
870
+ const flipContractAddress = networkOpts.network === "localnet" ? networkOpts.flipContractAddress : getFlipContractAddress(networkOpts.network);
1162
871
  const stateChainGatewayContractAddress = networkOpts.network === "localnet" ? networkOpts.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(networkOpts.network);
1163
- return checkAllowance(amount, stateChainGatewayContractAddress, flipContractAddress, networkOpts.signer);
1164
- }, "checkStateChainGatewayAllowance");
1165
- var approveStateChainGateway = /* @__PURE__ */ __name(async (amount, networkOpts, txOpts) => {
1166
- const { allowance, erc20, hasSufficientAllowance } = await checkStateChainGatewayAllowance(amount, networkOpts);
872
+ return checkAllowance(
873
+ amount,
874
+ stateChainGatewayContractAddress,
875
+ flipContractAddress,
876
+ networkOpts.signer
877
+ );
878
+ };
879
+ var approveStateChainGateway = async (amount, networkOpts, txOpts) => {
880
+ const { allowance, erc20, hasSufficientAllowance } = await checkStateChainGatewayAllowance(
881
+ amount,
882
+ networkOpts
883
+ );
1167
884
  if (hasSufficientAllowance) return null;
1168
885
  const stateChainGatewayContractAddress = networkOpts.network === "localnet" ? networkOpts.stateChainGatewayContractAddress : getStateChainGatewayContractAddress(networkOpts.network);
1169
886
  return approve(amount, stateChainGatewayContractAddress, erc20, allowance, txOpts);
1170
- }, "approveStateChainGateway");
887
+ };
1171
888
 
1172
889
  // ../shared/src/stateChainGateway/index.ts
1173
- var fundStateChainAccount = /* @__PURE__ */ __name(async (accountId, amount, networkOpts, txOpts) => {
1174
- const flipContractAddress = networkOpts.network === "localnet" ? networkOpts.flipContractAddress : getTokenContractAddress(InternalAssets.Flip, networkOpts.network);
890
+ var fundStateChainAccount = async (accountId, amount, networkOpts, txOpts) => {
891
+ const flipContractAddress = networkOpts.network === "localnet" ? networkOpts.flipContractAddress : getFlipContractAddress(networkOpts.network);
1175
892
  const stateChainGateway = getStateChainGateway(networkOpts);
1176
- const { hasSufficientAllowance } = await checkAllowance(amount, await stateChainGateway.getAddress(), flipContractAddress, networkOpts.signer);
893
+ const { hasSufficientAllowance } = await checkAllowance(
894
+ amount,
895
+ await stateChainGateway.getAddress(),
896
+ flipContractAddress,
897
+ networkOpts.signer
898
+ );
1177
899
  assert(hasSufficientAllowance, "Insufficient allowance");
1178
- const transaction = await stateChainGateway.fundStateChainAccount(accountId, amount, extractOverrides(txOpts));
900
+ const transaction = await stateChainGateway.fundStateChainAccount(
901
+ accountId,
902
+ amount,
903
+ extractOverrides(txOpts)
904
+ );
1179
905
  await transaction.wait(txOpts.wait);
1180
906
  return transaction;
1181
- }, "fundStateChainAccount");
1182
- var executeRedemption = /* @__PURE__ */ __name(async (accountId, networkOpts, txOpts) => {
907
+ };
908
+ var executeRedemption = async (accountId, networkOpts, txOpts) => {
1183
909
  const stateChainGateway = getStateChainGateway(networkOpts);
1184
- const transaction = await stateChainGateway.executeRedemption(accountId, extractOverrides(txOpts));
910
+ const transaction = await stateChainGateway.executeRedemption(
911
+ accountId,
912
+ extractOverrides(txOpts)
913
+ );
1185
914
  await transaction.wait(txOpts.wait);
1186
915
  return transaction;
1187
- }, "executeRedemption");
1188
- var getMinimumFunding = /* @__PURE__ */ __name((networkOpts) => {
916
+ };
917
+ var getMinimumFunding = (networkOpts) => {
1189
918
  const stateChainGateway = getStateChainGateway(networkOpts);
1190
919
  return stateChainGateway.getMinimumFunding();
1191
- }, "getMinimumFunding");
1192
- var getRedemptionDelay = /* @__PURE__ */ __name((networkOpts) => {
920
+ };
921
+ var getRedemptionDelay = (networkOpts) => {
1193
922
  const stateChainGateway = getStateChainGateway(networkOpts);
1194
923
  return stateChainGateway.REDEMPTION_DELAY();
1195
- }, "getRedemptionDelay");
1196
- var getPendingRedemption = /* @__PURE__ */ __name(async (accountId, networkOpts) => {
924
+ };
925
+ var getPendingRedemption = async (accountId, networkOpts) => {
1197
926
  const stateChainGateway = getStateChainGateway(networkOpts);
1198
927
  const pendingRedemption = await stateChainGateway.getPendingRedemption(accountId);
1199
928
  return pendingRedemption.amount !== 0n ? stateChainGateway.getPendingRedemption(accountId) : void 0;
1200
- }, "getPendingRedemption");
929
+ };
1201
930
 
1202
931
  // src/funding/sdk.ts
1203
- var _FundingSDK = class _FundingSDK {
932
+ var FundingSDK = class {
1204
933
  constructor(options) {
1205
- __publicField(this, "options");
1206
- __publicField(this, "rpcConfig");
1207
- __publicField(this, "redemptionTax");
1208
934
  const network = options.network ?? ChainflipNetworks.perseverance;
1209
935
  this.options = {
1210
936
  ...options,
1211
937
  network
1212
938
  };
1213
- this.rpcConfig = options.rpcUrl ? {
1214
- rpcUrl: options.rpcUrl
1215
- } : {
1216
- network
1217
- };
939
+ this.rpcConfig = options.rpcUrl ? { rpcUrl: options.rpcUrl } : { network };
1218
940
  }
1219
941
  /**
1220
- * @param accountId the hex-encoded validator account id
1221
- * @param amount the amount to fund in base units of FLIP
1222
- */
942
+ * @param accountId the hex-encoded validator account id
943
+ * @param amount the amount to fund in base units of FLIP
944
+ */
1223
945
  async fundStateChainAccount(accountId, amount, txOpts = {}) {
1224
946
  const tx = await fundStateChainAccount(accountId, amount, this.options, txOpts);
1225
947
  return tx.hash;
1226
948
  }
1227
949
  /**
1228
- * @param accountId the hex-encoded validator account id
1229
- */
950
+ * @param accountId the hex-encoded validator account id
951
+ */
1230
952
  async executeRedemption(accountId, txOpts = {}) {
1231
953
  const tx = await executeRedemption(accountId, this.options, txOpts);
1232
954
  return tx.hash;
@@ -1244,9 +966,9 @@ var _FundingSDK = class _FundingSDK {
1244
966
  return getPendingRedemption(accountId, this.options);
1245
967
  }
1246
968
  /**
1247
- * @param the amount of FLIP to request approval for
1248
- * @returns the transaction hash or null if no approval was required
1249
- */
969
+ * @param the amount of FLIP to request approval for
970
+ * @returns the transaction hash or null if no approval was required
971
+ */
1250
972
  async approveStateChainGateway(amount, txOpts = {}) {
1251
973
  const tx = await approveStateChainGateway(amount, this.options, txOpts);
1252
974
  return tx ? tx.hash : null;
@@ -1256,7 +978,5 @@ var _FundingSDK = class _FundingSDK {
1256
978
  return this.redemptionTax;
1257
979
  }
1258
980
  };
1259
- __name(_FundingSDK, "FundingSDK");
1260
- var FundingSDK = _FundingSDK;
1261
981
 
1262
982
  exports.FundingSDK = FundingSDK;