@chainflip/sdk 0.1.7 → 0.1.9

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/swap.d.ts CHANGED
@@ -380,7 +380,7 @@ type AssetData = {
380
380
  [K in keyof typeof chainAssets]: {
381
381
  id: (typeof chainAssets)[K][number];
382
382
  chain: K;
383
- contractAddress: string;
383
+ contractAddress: string | undefined;
384
384
  decimals: number;
385
385
  name: string;
386
386
  symbol: string;
@@ -429,6 +429,7 @@ type SwapStatusResponse = CommonStatusFields & ({
429
429
  depositAmount: string;
430
430
  depositReceivedAt: number;
431
431
  depositReceivedBlockIndex: string;
432
+ intermediateAmount: string | undefined;
432
433
  swapExecutedAt: number;
433
434
  swapExecutedBlockIndex: string;
434
435
  } | {
@@ -437,6 +438,7 @@ type SwapStatusResponse = CommonStatusFields & ({
437
438
  depositAmount: string;
438
439
  depositReceivedAt: number;
439
440
  depositReceivedBlockIndex: string;
441
+ intermediateAmount: string | undefined;
440
442
  swapExecutedAt: number;
441
443
  swapExecutedBlockIndex: string;
442
444
  egressAmount: string;
@@ -448,6 +450,7 @@ type SwapStatusResponse = CommonStatusFields & ({
448
450
  depositAmount: string;
449
451
  depositReceivedAt: number;
450
452
  depositReceivedBlockIndex: string;
453
+ intermediateAmount: string | undefined;
451
454
  swapExecutedAt: number;
452
455
  swapExecutedBlockIndex: string;
453
456
  egressAmount: string;
@@ -461,6 +464,7 @@ type SwapStatusResponse = CommonStatusFields & ({
461
464
  depositAmount: string;
462
465
  depositReceivedAt: number;
463
466
  depositReceivedBlockIndex: string;
467
+ intermediateAmount: string | undefined;
464
468
  swapExecutedAt: number;
465
469
  swapExecutedBlockIndex: string;
466
470
  egressAmount: string;
@@ -476,6 +480,7 @@ type SwapStatusResponse = CommonStatusFields & ({
476
480
  depositAmount: string;
477
481
  depositReceivedAt: number;
478
482
  depositReceivedBlockIndex: string;
483
+ intermediateAmount: string | undefined;
479
484
  swapExecutedAt: number;
480
485
  swapExecutedBlockIndex: string;
481
486
  egressAmount: string;
package/dist/swap.js CHANGED
@@ -1985,154 +1985,110 @@ var BACKEND_SERVICE_URLS = {
1985
1985
  [ChainflipNetworks.partnernet]: "https://chainflip-swap-partnernet.chainflip.io/"
1986
1986
  };
1987
1987
 
1988
- // src/swap/mocks.ts
1989
- var ethereum = {
1990
- id: Chains.Ethereum,
1991
- name: "Ethereum",
1992
- isMainnet: true
1993
- };
1994
- var polkadot = {
1995
- id: Chains.Polkadot,
1996
- name: "Polkadot",
1997
- isMainnet: true
1998
- };
1999
- var bitcoin = {
2000
- id: Chains.Bitcoin,
2001
- name: "Bitcoin",
2002
- isMainnet: true
2003
- };
2004
- var ethereumAssets = [
2005
- {
2006
- id: Assets.ETH,
2007
- chain: Chains.Ethereum,
2008
- contractAddress: "0xeth",
2009
- decimals: assetDecimals[Assets.ETH],
2010
- name: "ether",
2011
- symbol: "ETH",
2012
- isMainnet: true
2013
- },
2014
- {
2015
- id: Assets.USDC,
2016
- chain: Chains.Ethereum,
2017
- contractAddress: "0xusdc",
2018
- decimals: assetDecimals[Assets.USDC],
2019
- name: "usdc",
2020
- symbol: "USDC",
2021
- isMainnet: true
2022
- },
2023
- {
2024
- id: Assets.FLIP,
2025
- chain: Chains.Ethereum,
2026
- contractAddress: "0xflip",
2027
- decimals: assetDecimals[Assets.FLIP],
2028
- name: "flip",
2029
- symbol: "FLIP",
2030
- isMainnet: true
2031
- }
2032
- ];
2033
- var dot$ = {
1988
+ // src/swap/assets.ts
1989
+ var eth$ = /* @__PURE__ */ __name((network) => ({
1990
+ id: Assets.ETH,
1991
+ chain: Chains.Ethereum,
1992
+ contractAddress: void 0,
1993
+ decimals: assetDecimals[Assets.ETH],
1994
+ name: "Ether",
1995
+ symbol: "ETH",
1996
+ isMainnet: !isTestnet(network)
1997
+ }), "eth$");
1998
+ var usdc$ = /* @__PURE__ */ __name((network) => ({
1999
+ id: Assets.USDC,
2000
+ chain: Chains.Ethereum,
2001
+ contractAddress: getTokenContractAddress(Assets.USDC, network),
2002
+ decimals: assetDecimals[Assets.USDC],
2003
+ name: "USDC",
2004
+ symbol: "USDC",
2005
+ isMainnet: !isTestnet(network)
2006
+ }), "usdc$");
2007
+ var flip$ = /* @__PURE__ */ __name((network) => ({
2008
+ id: Assets.FLIP,
2009
+ chain: Chains.Ethereum,
2010
+ contractAddress: getTokenContractAddress(Assets.FLIP, network),
2011
+ decimals: assetDecimals[Assets.FLIP],
2012
+ name: "FLIP",
2013
+ symbol: "FLIP",
2014
+ isMainnet: !isTestnet(network)
2015
+ }), "flip$");
2016
+ var dot$ = /* @__PURE__ */ __name((network) => ({
2034
2017
  id: Assets.DOT,
2035
2018
  chain: Chains.Polkadot,
2036
- contractAddress: "0xdot",
2019
+ contractAddress: void 0,
2037
2020
  decimals: assetDecimals[Assets.DOT],
2038
- name: "dot",
2021
+ name: "Polkadot",
2039
2022
  symbol: "DOT",
2040
- isMainnet: true
2041
- };
2042
- var btc$ = {
2023
+ isMainnet: !isTestnet(network)
2024
+ }), "dot$");
2025
+ var btc$ = /* @__PURE__ */ __name((network) => ({
2043
2026
  id: Assets.BTC,
2044
2027
  chain: Chains.Bitcoin,
2045
- contractAddress: "0xbitcoin",
2028
+ contractAddress: void 0,
2046
2029
  decimals: assetDecimals[Assets.BTC],
2047
- name: "bitcoin",
2030
+ name: "Bitcoin",
2048
2031
  symbol: "BTC",
2049
- isMainnet: true
2050
- };
2051
- var testnetChains = /* @__PURE__ */ __name((chains) => chains.map((chain) => ({
2052
- ...chain,
2053
- isMainnet: false
2054
- })), "testnetChains");
2055
- var testnetAssets = /* @__PURE__ */ __name((assets) => assets.map((asset) => ({
2056
- ...asset,
2057
- isMainnet: false
2058
- })), "testnetAssets");
2032
+ isMainnet: !isTestnet(network)
2033
+ }), "btc$");
2034
+
2035
+ // src/swap/chains.ts
2036
+ var ethereum = /* @__PURE__ */ __name((network) => ({
2037
+ id: Chains.Ethereum,
2038
+ name: "Ethereum",
2039
+ isMainnet: !isTestnet(network)
2040
+ }), "ethereum");
2041
+ var polkadot = /* @__PURE__ */ __name((network) => ({
2042
+ id: Chains.Polkadot,
2043
+ name: "Polkadot",
2044
+ isMainnet: !isTestnet(network)
2045
+ }), "polkadot");
2046
+ var bitcoin = /* @__PURE__ */ __name((network) => ({
2047
+ id: Chains.Bitcoin,
2048
+ name: "Bitcoin",
2049
+ isMainnet: !isTestnet(network)
2050
+ }), "bitcoin");
2059
2051
 
2060
2052
  // src/swap/services/ApiService.ts
2061
- var getChains = /* @__PURE__ */ __name(async (network) => {
2062
- if (isTestnet(network)) {
2063
- return testnetChains([
2064
- ethereum,
2065
- polkadot,
2066
- bitcoin
2067
- ]);
2068
- }
2069
- return [
2070
- ethereum,
2071
- polkadot,
2072
- bitcoin
2073
- ];
2074
- }, "getChains");
2053
+ var getChains = /* @__PURE__ */ __name(async (network) => [
2054
+ ethereum(network),
2055
+ polkadot(network),
2056
+ bitcoin(network)
2057
+ ], "getChains");
2075
2058
  var getPossibleDestinationChains = /* @__PURE__ */ __name(async (sourceChain, network) => {
2076
- if (isTestnet(network)) {
2077
- if (sourceChain === Chains.Ethereum)
2078
- return testnetChains([
2079
- polkadot,
2080
- bitcoin
2081
- ]);
2082
- if (sourceChain === Chains.Polkadot)
2083
- return testnetChains([
2084
- ethereum,
2085
- bitcoin
2086
- ]);
2087
- if (sourceChain === Chains.Bitcoin)
2088
- return testnetChains([
2089
- ethereum,
2090
- polkadot
2091
- ]);
2092
- throw new Error("received testnet flag but mainnet chain");
2093
- }
2094
2059
  if (sourceChain === Chains.Ethereum)
2095
2060
  return [
2096
- bitcoin,
2097
- polkadot
2061
+ bitcoin(network),
2062
+ polkadot(network)
2098
2063
  ];
2099
2064
  if (sourceChain === Chains.Polkadot)
2100
2065
  return [
2101
- ethereum,
2102
- bitcoin
2066
+ ethereum(network),
2067
+ bitcoin(network)
2103
2068
  ];
2104
2069
  if (sourceChain === Chains.Bitcoin)
2105
2070
  return [
2106
- ethereum,
2107
- polkadot
2071
+ ethereum(network),
2072
+ polkadot(network)
2108
2073
  ];
2109
2074
  throw new Error("received unknown chain");
2110
2075
  }, "getPossibleDestinationChains");
2111
2076
  var getAssets = /* @__PURE__ */ __name(async (chain, network) => {
2112
- if (isTestnet(network)) {
2113
- if (chain === Chains.Ethereum)
2114
- return testnetAssets(ethereumAssets);
2115
- if (chain === Chains.Polkadot)
2116
- return testnetAssets([
2117
- dot$
2118
- ]);
2119
- if (chain === Chains.Bitcoin)
2120
- return testnetAssets([
2121
- btc$
2122
- ]);
2123
- throw new Error("received testnet flag but mainnet chain");
2124
- }
2125
2077
  if (chain === Chains.Ethereum)
2126
- return ethereumAssets;
2078
+ return [
2079
+ eth$(network),
2080
+ usdc$(network),
2081
+ flip$(network)
2082
+ ];
2127
2083
  if (chain === Chains.Polkadot)
2128
2084
  return [
2129
- dot$
2085
+ dot$(network)
2130
2086
  ];
2131
2087
  if (chain === Chains.Bitcoin)
2132
2088
  return [
2133
- btc$
2089
+ btc$(network)
2134
2090
  ];
2135
- throw new Error("received unknown chain");
2091
+ throw new Error("received unexpected chain");
2136
2092
  }, "getAssets");
2137
2093
  var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }) => {
2138
2094
  const params = {
package/dist/swap.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { isString, Chains, Assets, ChainflipNetworks, assetDecimals, __name, assert, getVaultManagerContractAddress, approve, isTokenSwap, isTokenCall, getTokenContractAddress, checkAllowance, isTestnet, Vault__factory, chainContractIds, assetContractIds } from './chunk-CMPMNSTZ.mjs';
1
+ import { isString, Chains, Assets, ChainflipNetworks, __name, assert, getVaultManagerContractAddress, approve, isTokenSwap, isTokenCall, getTokenContractAddress, checkAllowance, Vault__factory, chainContractIds, assetContractIds, assetDecimals, isTestnet } from './chunk-CMPMNSTZ.mjs';
2
2
  export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds } from './chunk-CMPMNSTZ.mjs';
3
3
  import { encodeAddress, decodeAddress } from '@polkadot/util-crypto';
4
4
  import * as ethers from 'ethers';
@@ -518,154 +518,110 @@ var BACKEND_SERVICE_URLS = {
518
518
  [ChainflipNetworks.partnernet]: "https://chainflip-swap-partnernet.chainflip.io/"
519
519
  };
520
520
 
521
- // src/swap/mocks.ts
522
- var ethereum = {
523
- id: Chains.Ethereum,
524
- name: "Ethereum",
525
- isMainnet: true
526
- };
527
- var polkadot = {
528
- id: Chains.Polkadot,
529
- name: "Polkadot",
530
- isMainnet: true
531
- };
532
- var bitcoin = {
533
- id: Chains.Bitcoin,
534
- name: "Bitcoin",
535
- isMainnet: true
536
- };
537
- var ethereumAssets = [
538
- {
539
- id: Assets.ETH,
540
- chain: Chains.Ethereum,
541
- contractAddress: "0xeth",
542
- decimals: assetDecimals[Assets.ETH],
543
- name: "ether",
544
- symbol: "ETH",
545
- isMainnet: true
546
- },
547
- {
548
- id: Assets.USDC,
549
- chain: Chains.Ethereum,
550
- contractAddress: "0xusdc",
551
- decimals: assetDecimals[Assets.USDC],
552
- name: "usdc",
553
- symbol: "USDC",
554
- isMainnet: true
555
- },
556
- {
557
- id: Assets.FLIP,
558
- chain: Chains.Ethereum,
559
- contractAddress: "0xflip",
560
- decimals: assetDecimals[Assets.FLIP],
561
- name: "flip",
562
- symbol: "FLIP",
563
- isMainnet: true
564
- }
565
- ];
566
- var dot$ = {
521
+ // src/swap/assets.ts
522
+ var eth$ = /* @__PURE__ */ __name((network) => ({
523
+ id: Assets.ETH,
524
+ chain: Chains.Ethereum,
525
+ contractAddress: void 0,
526
+ decimals: assetDecimals[Assets.ETH],
527
+ name: "Ether",
528
+ symbol: "ETH",
529
+ isMainnet: !isTestnet(network)
530
+ }), "eth$");
531
+ var usdc$ = /* @__PURE__ */ __name((network) => ({
532
+ id: Assets.USDC,
533
+ chain: Chains.Ethereum,
534
+ contractAddress: getTokenContractAddress(Assets.USDC, network),
535
+ decimals: assetDecimals[Assets.USDC],
536
+ name: "USDC",
537
+ symbol: "USDC",
538
+ isMainnet: !isTestnet(network)
539
+ }), "usdc$");
540
+ var flip$ = /* @__PURE__ */ __name((network) => ({
541
+ id: Assets.FLIP,
542
+ chain: Chains.Ethereum,
543
+ contractAddress: getTokenContractAddress(Assets.FLIP, network),
544
+ decimals: assetDecimals[Assets.FLIP],
545
+ name: "FLIP",
546
+ symbol: "FLIP",
547
+ isMainnet: !isTestnet(network)
548
+ }), "flip$");
549
+ var dot$ = /* @__PURE__ */ __name((network) => ({
567
550
  id: Assets.DOT,
568
551
  chain: Chains.Polkadot,
569
- contractAddress: "0xdot",
552
+ contractAddress: void 0,
570
553
  decimals: assetDecimals[Assets.DOT],
571
- name: "dot",
554
+ name: "Polkadot",
572
555
  symbol: "DOT",
573
- isMainnet: true
574
- };
575
- var btc$ = {
556
+ isMainnet: !isTestnet(network)
557
+ }), "dot$");
558
+ var btc$ = /* @__PURE__ */ __name((network) => ({
576
559
  id: Assets.BTC,
577
560
  chain: Chains.Bitcoin,
578
- contractAddress: "0xbitcoin",
561
+ contractAddress: void 0,
579
562
  decimals: assetDecimals[Assets.BTC],
580
- name: "bitcoin",
563
+ name: "Bitcoin",
581
564
  symbol: "BTC",
582
- isMainnet: true
583
- };
584
- var testnetChains = /* @__PURE__ */ __name((chains) => chains.map((chain) => ({
585
- ...chain,
586
- isMainnet: false
587
- })), "testnetChains");
588
- var testnetAssets = /* @__PURE__ */ __name((assets) => assets.map((asset) => ({
589
- ...asset,
590
- isMainnet: false
591
- })), "testnetAssets");
565
+ isMainnet: !isTestnet(network)
566
+ }), "btc$");
567
+
568
+ // src/swap/chains.ts
569
+ var ethereum = /* @__PURE__ */ __name((network) => ({
570
+ id: Chains.Ethereum,
571
+ name: "Ethereum",
572
+ isMainnet: !isTestnet(network)
573
+ }), "ethereum");
574
+ var polkadot = /* @__PURE__ */ __name((network) => ({
575
+ id: Chains.Polkadot,
576
+ name: "Polkadot",
577
+ isMainnet: !isTestnet(network)
578
+ }), "polkadot");
579
+ var bitcoin = /* @__PURE__ */ __name((network) => ({
580
+ id: Chains.Bitcoin,
581
+ name: "Bitcoin",
582
+ isMainnet: !isTestnet(network)
583
+ }), "bitcoin");
592
584
 
593
585
  // src/swap/services/ApiService.ts
594
- var getChains = /* @__PURE__ */ __name(async (network) => {
595
- if (isTestnet(network)) {
596
- return testnetChains([
597
- ethereum,
598
- polkadot,
599
- bitcoin
600
- ]);
601
- }
602
- return [
603
- ethereum,
604
- polkadot,
605
- bitcoin
606
- ];
607
- }, "getChains");
586
+ var getChains = /* @__PURE__ */ __name(async (network) => [
587
+ ethereum(network),
588
+ polkadot(network),
589
+ bitcoin(network)
590
+ ], "getChains");
608
591
  var getPossibleDestinationChains = /* @__PURE__ */ __name(async (sourceChain, network) => {
609
- if (isTestnet(network)) {
610
- if (sourceChain === Chains.Ethereum)
611
- return testnetChains([
612
- polkadot,
613
- bitcoin
614
- ]);
615
- if (sourceChain === Chains.Polkadot)
616
- return testnetChains([
617
- ethereum,
618
- bitcoin
619
- ]);
620
- if (sourceChain === Chains.Bitcoin)
621
- return testnetChains([
622
- ethereum,
623
- polkadot
624
- ]);
625
- throw new Error("received testnet flag but mainnet chain");
626
- }
627
592
  if (sourceChain === Chains.Ethereum)
628
593
  return [
629
- bitcoin,
630
- polkadot
594
+ bitcoin(network),
595
+ polkadot(network)
631
596
  ];
632
597
  if (sourceChain === Chains.Polkadot)
633
598
  return [
634
- ethereum,
635
- bitcoin
599
+ ethereum(network),
600
+ bitcoin(network)
636
601
  ];
637
602
  if (sourceChain === Chains.Bitcoin)
638
603
  return [
639
- ethereum,
640
- polkadot
604
+ ethereum(network),
605
+ polkadot(network)
641
606
  ];
642
607
  throw new Error("received unknown chain");
643
608
  }, "getPossibleDestinationChains");
644
609
  var getAssets = /* @__PURE__ */ __name(async (chain, network) => {
645
- if (isTestnet(network)) {
646
- if (chain === Chains.Ethereum)
647
- return testnetAssets(ethereumAssets);
648
- if (chain === Chains.Polkadot)
649
- return testnetAssets([
650
- dot$
651
- ]);
652
- if (chain === Chains.Bitcoin)
653
- return testnetAssets([
654
- btc$
655
- ]);
656
- throw new Error("received testnet flag but mainnet chain");
657
- }
658
610
  if (chain === Chains.Ethereum)
659
- return ethereumAssets;
611
+ return [
612
+ eth$(network),
613
+ usdc$(network),
614
+ flip$(network)
615
+ ];
660
616
  if (chain === Chains.Polkadot)
661
617
  return [
662
- dot$
618
+ dot$(network)
663
619
  ];
664
620
  if (chain === Chains.Bitcoin)
665
621
  return [
666
- btc$
622
+ btc$(network)
667
623
  ];
668
- throw new Error("received unknown chain");
624
+ throw new Error("received unexpected chain");
669
625
  }, "getAssets");
670
626
  var getQuote = /* @__PURE__ */ __name(async (baseUrl, quoteRequest, { signal }) => {
671
627
  const params = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/sdk",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "",
5
5
  "exports": {
6
6
  "./swap": {