@ape.swap/bonds-sdk 1.0.762 → 1.0.764

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.
@@ -19,10 +19,14 @@ var BondRow = function (_a) {
19
19
  var _e = useState(false), isModalOpen = _e[0], setIsModalOpen = _e[1];
20
20
  var rowClick = function (bond) {
21
21
  if (typeof window !== "undefined") {
22
+ console.log('opening modal');
22
23
  var newUrl = "/?bondAddress=".concat(bond.billAddress, "&bondChain=").concat(bond.chainId);
23
- window.history.pushState({ path: newUrl }, '', newUrl);
24
+ // window.history.pushState({ path: newUrl }, '', newUrl);
24
25
  setIsModalOpen(true);
25
26
  }
27
+ else {
28
+ console.log('WINDOW WAS UNDEFINED');
29
+ }
26
30
  console.log('row clicked');
27
31
  console.log('bond', bond);
28
32
  console.log('isModalOpen:', isModalOpen);
@@ -78,11 +78,8 @@ var BondModal = function (_a) {
78
78
  var handleInputChange = function (event) {
79
79
  setInputValue(event.target.value);
80
80
  };
81
- //This is a temp solution, but we will force approval each time, and then once set we will set status here and allow
82
- //user to buy
83
- //Check with Fede if this needs to be temp, if we force approval everytime, isn't this fine?
84
81
  var handleBuy = function () { return __awaiter(void 0, void 0, void 0, function () {
85
- var billAddress, decimals, maxPrice, rawAmount, amount, tx, error_1;
82
+ var billAddress, decimals, maxPrice, rawAmount, amount, tx, data, response, error_1;
86
83
  return __generator(this, function (_a) {
87
84
  switch (_a.label) {
88
85
  case 0:
@@ -90,7 +87,7 @@ var BondModal = function (_a) {
90
87
  decimals = tokenDecimals !== null && tokenDecimals !== void 0 ? tokenDecimals : 18;
91
88
  _a.label = 1;
92
89
  case 1:
93
- _a.trys.push([1, 3, , 4]);
90
+ _a.trys.push([1, 5, , 6]);
94
91
  maxPrice = new BigNumber(bondData[0].trueBillPrice).times(102).div(100).toFixed(0);
95
92
  rawAmount = adjustDecimals(inputValue);
96
93
  amount = new BigNumber(rawAmount).times(new BigNumber(10).pow(decimals !== null && decimals !== void 0 ? decimals : 18)).toString();
@@ -102,15 +99,25 @@ var BondModal = function (_a) {
102
99
  })];
103
100
  case 2:
104
101
  tx = _a.sent();
105
- if (tx) {
106
- setBuyTx(tx);
107
- }
108
- return [3 /*break*/, 4];
102
+ if (!tx) return [3 /*break*/, 4];
103
+ setBuyTx(tx);
104
+ data = {
105
+ chainId: chainId,
106
+ transactionHash: tx,
107
+ referenceId: 'cgpt-sdk',
108
+ billContract: billAddress
109
+ };
110
+ return [4 /*yield*/, axios.post("https://api-v2.apeswap.finance/bills/widget", data)];
109
111
  case 3:
112
+ response = _a.sent();
113
+ console.log(response);
114
+ _a.label = 4;
115
+ case 4: return [3 /*break*/, 6];
116
+ case 5:
110
117
  error_1 = _a.sent();
111
118
  console.error('Buy error', error_1);
112
- return [3 /*break*/, 4];
113
- case 4: return [2 /*return*/];
119
+ return [3 /*break*/, 6];
120
+ case 6: return [2 /*return*/];
114
121
  }
115
122
  });
116
123
  }); };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "1.0.762",
6
+ "version": "1.0.764",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",