@pioneer-platform/chainflip-client 0.0.2 → 0.0.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.
Files changed (2) hide show
  1. package/lib/index.js +9 -8
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -60,9 +60,12 @@ const get_quote = function (quote) {
60
60
  throw new Error("missing recipientAddress");
61
61
  if (!quote.slippage)
62
62
  throw new Error("missing slippage");
63
- // let providerUrl = "wss://rpc.polkadot.io"
64
- // const provider = new WsProvider(providerUrl);
65
- // const api = await ApiPromise.create({ provider });
63
+ if (!networkSupport.includes(caipToNetworkId(quote.buyAsset))) {
64
+ throw new Error("unsupported buyAsset");
65
+ }
66
+ if (!networkSupport.includes(caipToNetworkId(quote.sellAsset))) {
67
+ throw new Error("unsupported sellAsset");
68
+ }
66
69
  //https://chainflip-swap.chainflip.io/quote?amount=100000000&srcChain=Bitcoin&srcAsset=BTC&destChain=Ethereum&destAsset=ETH
67
70
  //get quote
68
71
  const responseQuote = yield axios.get('https://chainflip-swap.chainflip.io/quote', {
@@ -110,18 +113,16 @@ const get_quote = function (quote) {
110
113
  // console.log(response.data); // Log the response data
111
114
  // console.log(JSON.stringify(response.data)); // Log the response data
112
115
  let result = response.data[0].result.data.json;
113
- log.info(tag, "result: ", result);
116
+ // log.info(tag,"result: ",result)
114
117
  output.id = result.id;
115
118
  output.source = 'chainflip';
116
119
  output.estimatedExpiryTime = result.estimatedExpiryTime;
117
120
  output.amountOut = responseQuote.data.egressAmount;
118
- console.log("caipToNetworkId(ChainToNetworkId[\"BTC\"]): ", caipToNetworkId(ChainToNetworkId["BTC"]));
119
- console.log("caipToNetworkId(quote.sellAsset): ", caipToNetworkId(quote.sellAsset));
120
- if (caipToNetworkId(quote.sellAsset) == caipToNetworkId(ChainToNetworkId["BTC"])) {
121
+ if (caipToNetworkId(quote.buyAsset) == caipToNetworkId(ChainToNetworkId["BTC"])) {
121
122
  // Convert from satoshis to BTC
122
123
  output.amountOut /= 1e8;
123
124
  }
124
- else if (caipToNetworkId(quote.sellAsset) == caipToNetworkId(ChainToNetworkId["ETH"])) {
125
+ else if (caipToNetworkId(quote.buyAsset) == caipToNetworkId(ChainToNetworkId["ETH"])) {
125
126
  // Convert from wei to ETH
126
127
  output.amountOut /= 1e18;
127
128
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/chainflip-client",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "dependencies": {