@aurigami/sdk 1.11.0 → 1.11.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/sdk.esm.js CHANGED
@@ -1207,6 +1207,30 @@ var isSameAddress = function isSameAddress(address1, address2) {
1207
1207
  var getCurrentTimestamp = function getCurrentTimestamp() {
1208
1208
  return Math.trunc(Date.now() / 1000);
1209
1209
  };
1210
+ function sleep(_x) {
1211
+ return _sleep.apply(this, arguments);
1212
+ }
1213
+
1214
+ function _sleep() {
1215
+ _sleep = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(duration) {
1216
+ return runtime_1.wrap(function _callee$(_context) {
1217
+ while (1) {
1218
+ switch (_context.prev = _context.next) {
1219
+ case 0:
1220
+ return _context.abrupt("return", new Promise(function (resolve) {
1221
+ setTimeout(resolve, duration);
1222
+ }));
1223
+
1224
+ case 1:
1225
+ case "end":
1226
+ return _context.stop();
1227
+ }
1228
+ }
1229
+ }, _callee);
1230
+ }));
1231
+ return _sleep.apply(this, arguments);
1232
+ }
1233
+
1210
1234
  function validateAndParseAddress(address) {
1211
1235
  try {
1212
1236
  return utils.getAddress(address);
@@ -1248,35 +1272,35 @@ function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
1248
1272
 
1249
1273
  return rewardsValue.multipliedBy(frequencyPerYear).dividedBy(totalStakeValue);
1250
1274
  }
1251
- function getBlockTimestamp(_x, _x2) {
1275
+ function getBlockTimestamp(_x2, _x3) {
1252
1276
  return _getBlockTimestamp.apply(this, arguments);
1253
1277
  }
1254
1278
 
1255
1279
  function _getBlockTimestamp() {
1256
- _getBlockTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(provider, blockNumber) {
1280
+ _getBlockTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(provider, blockNumber) {
1257
1281
  var block;
1258
- return runtime_1.wrap(function _callee$(_context) {
1282
+ return runtime_1.wrap(function _callee2$(_context2) {
1259
1283
  while (1) {
1260
- switch (_context.prev = _context.next) {
1284
+ switch (_context2.prev = _context2.next) {
1261
1285
  case 0:
1262
- _context.next = 2;
1286
+ _context2.next = 2;
1263
1287
  return provider.getBlock(blockNumber);
1264
1288
 
1265
1289
  case 2:
1266
- block = _context.sent;
1267
- return _context.abrupt("return", block.timestamp);
1290
+ block = _context2.sent;
1291
+ return _context2.abrupt("return", block.timestamp);
1268
1292
 
1269
1293
  case 4:
1270
1294
  case "end":
1271
- return _context.stop();
1295
+ return _context2.stop();
1272
1296
  }
1273
1297
  }
1274
- }, _callee);
1298
+ }, _callee2);
1275
1299
  }));
1276
1300
  return _getBlockTimestamp.apply(this, arguments);
1277
1301
  }
1278
1302
 
1279
- function getBlocksTimestampViaRPC(_x3, _x4) {
1303
+ function getBlocksTimestampViaRPC(_x4, _x5) {
1280
1304
  return _getBlocksTimestampViaRPC.apply(this, arguments);
1281
1305
  }
1282
1306
  /**
@@ -1286,11 +1310,11 @@ function getBlocksTimestampViaRPC(_x3, _x4) {
1286
1310
  */
1287
1311
 
1288
1312
  function _getBlocksTimestampViaRPC() {
1289
- _getBlocksTimestampViaRPC = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(provider, blocksNumber) {
1313
+ _getBlocksTimestampViaRPC = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(provider, blocksNumber) {
1290
1314
  var CHUNK_SIZE, results, i, slice, promises;
1291
- return runtime_1.wrap(function _callee3$(_context3) {
1315
+ return runtime_1.wrap(function _callee4$(_context4) {
1292
1316
  while (1) {
1293
- switch (_context3.prev = _context3.next) {
1317
+ switch (_context4.prev = _context4.next) {
1294
1318
  case 0:
1295
1319
  // Promise all 200 blocks at a time, using too many blocks at once will cause the RPC call timeout.
1296
1320
  CHUNK_SIZE = 200;
@@ -1299,58 +1323,58 @@ function _getBlocksTimestampViaRPC() {
1299
1323
 
1300
1324
  case 3:
1301
1325
  if (!(i < blocksNumber.length)) {
1302
- _context3.next = 14;
1326
+ _context4.next = 14;
1303
1327
  break;
1304
1328
  }
1305
1329
 
1306
1330
  slice = blocksNumber.slice(i, i + CHUNK_SIZE);
1307
1331
  promises = slice.map( /*#__PURE__*/function () {
1308
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(blockNumber) {
1309
- return runtime_1.wrap(function _callee2$(_context2) {
1332
+ var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(blockNumber) {
1333
+ return runtime_1.wrap(function _callee3$(_context3) {
1310
1334
  while (1) {
1311
- switch (_context2.prev = _context2.next) {
1335
+ switch (_context3.prev = _context3.next) {
1312
1336
  case 0:
1313
- return _context2.abrupt("return", getBlockTimestamp(provider, blockNumber));
1337
+ return _context3.abrupt("return", getBlockTimestamp(provider, blockNumber));
1314
1338
 
1315
1339
  case 1:
1316
1340
  case "end":
1317
- return _context2.stop();
1341
+ return _context3.stop();
1318
1342
  }
1319
1343
  }
1320
- }, _callee2);
1344
+ }, _callee3);
1321
1345
  }));
1322
1346
 
1323
- return function (_x9) {
1347
+ return function (_x10) {
1324
1348
  return _ref.apply(this, arguments);
1325
1349
  };
1326
1350
  }());
1327
- _context3.t0 = results;
1328
- _context3.next = 9;
1351
+ _context4.t0 = results;
1352
+ _context4.next = 9;
1329
1353
  return Promise.all(promises);
1330
1354
 
1331
1355
  case 9:
1332
- _context3.t1 = _context3.sent;
1333
- results = _context3.t0.concat.call(_context3.t0, _context3.t1);
1356
+ _context4.t1 = _context4.sent;
1357
+ results = _context4.t0.concat.call(_context4.t0, _context4.t1);
1334
1358
 
1335
1359
  case 11:
1336
1360
  i += CHUNK_SIZE;
1337
- _context3.next = 3;
1361
+ _context4.next = 3;
1338
1362
  break;
1339
1363
 
1340
1364
  case 14:
1341
- return _context3.abrupt("return", results);
1365
+ return _context4.abrupt("return", results);
1342
1366
 
1343
1367
  case 15:
1344
1368
  case "end":
1345
- return _context3.stop();
1369
+ return _context4.stop();
1346
1370
  }
1347
1371
  }
1348
- }, _callee3);
1372
+ }, _callee4);
1349
1373
  }));
1350
1374
  return _getBlocksTimestampViaRPC.apply(this, arguments);
1351
1375
  }
1352
1376
 
1353
- function getBlocksTimestamp(_x5, _x6) {
1377
+ function getBlocksTimestamp(_x6, _x7) {
1354
1378
  return _getBlocksTimestamp.apply(this, arguments);
1355
1379
  }
1356
1380
  /**
@@ -1363,18 +1387,18 @@ function getBlocksTimestamp(_x5, _x6) {
1363
1387
  */
1364
1388
 
1365
1389
  function _getBlocksTimestamp() {
1366
- _getBlocksTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(provider, blockNumbers) {
1390
+ _getBlocksTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(provider, blockNumbers) {
1367
1391
  var CHUNK_SIZE, promises, lines, i, query, results, missingBlocks, missingBlocksTimestamps;
1368
- return runtime_1.wrap(function _callee4$(_context4) {
1392
+ return runtime_1.wrap(function _callee5$(_context5) {
1369
1393
  while (1) {
1370
- switch (_context4.prev = _context4.next) {
1394
+ switch (_context5.prev = _context5.next) {
1371
1395
  case 0:
1372
1396
  if (!(blockNumbers.length == 0)) {
1373
- _context4.next = 2;
1397
+ _context5.next = 2;
1374
1398
  break;
1375
1399
  }
1376
1400
 
1377
- return _context4.abrupt("return", []);
1401
+ return _context5.abrupt("return", []);
1378
1402
 
1379
1403
  case 2:
1380
1404
  CHUNK_SIZE = 100; // graphql query limit
@@ -1390,11 +1414,11 @@ function _getBlocksTimestamp() {
1390
1414
  } // merge all the json objects
1391
1415
 
1392
1416
 
1393
- _context4.next = 8;
1417
+ _context5.next = 8;
1394
1418
  return Promise.all(promises);
1395
1419
 
1396
1420
  case 8:
1397
- results = _context4.sent.reduce(function (acc, cur) {
1421
+ results = _context5.sent.reduce(function (acc, cur) {
1398
1422
  return _extends({}, acc, cur);
1399
1423
  });
1400
1424
  missingBlocks = blockNumbers.filter(function (blockNumber) {
@@ -1405,71 +1429,71 @@ function _getBlocksTimestamp() {
1405
1429
  devLog("These blocks are missing from Aurora GraphQL endpoint: " + missingBlocks.join(', '));
1406
1430
  }
1407
1431
 
1408
- _context4.next = 13;
1432
+ _context5.next = 13;
1409
1433
  return getBlocksTimestampViaRPC(provider, missingBlocks);
1410
1434
 
1411
1435
  case 13:
1412
- missingBlocksTimestamps = _context4.sent;
1436
+ missingBlocksTimestamps = _context5.sent;
1413
1437
  missingBlocksTimestamps.forEach(function (timestamp, index) {
1414
1438
  results["b" + missingBlocks[index]] = {
1415
1439
  timestamp: new Date(timestamp * 1000).toISOString()
1416
1440
  };
1417
1441
  });
1418
- return _context4.abrupt("return", blockNumbers.map(function (blockNumber) {
1442
+ return _context5.abrupt("return", blockNumbers.map(function (blockNumber) {
1419
1443
  return Math.trunc(new Date(results["b" + blockNumber].timestamp).getTime() / 1000);
1420
1444
  }));
1421
1445
 
1422
1446
  case 16:
1423
1447
  case "end":
1424
- return _context4.stop();
1448
+ return _context5.stop();
1425
1449
  }
1426
1450
  }
1427
- }, _callee4);
1451
+ }, _callee5);
1428
1452
  }));
1429
1453
  return _getBlocksTimestamp.apply(this, arguments);
1430
1454
  }
1431
1455
 
1432
- function getBlockBeforeTimestamp(_x7, _x8) {
1456
+ function getBlockBeforeTimestamp(_x8, _x9) {
1433
1457
  return _getBlockBeforeTimestamp.apply(this, arguments);
1434
1458
  }
1435
1459
 
1436
1460
  function _getBlockBeforeTimestamp() {
1437
- _getBlockBeforeTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(provider, timestamp) {
1461
+ _getBlockBeforeTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(provider, timestamp) {
1438
1462
  var result;
1439
- return runtime_1.wrap(function _callee5$(_context5) {
1463
+ return runtime_1.wrap(function _callee6$(_context6) {
1440
1464
  while (1) {
1441
- switch (_context5.prev = _context5.next) {
1465
+ switch (_context6.prev = _context6.next) {
1442
1466
  case 0:
1443
- _context5.next = 2;
1467
+ _context6.next = 2;
1444
1468
  return getQuery('block', 'getblocknobytime', {
1445
1469
  timestamp: timestamp,
1446
1470
  closest: 'before'
1447
1471
  });
1448
1472
 
1449
1473
  case 2:
1450
- result = _context5.sent;
1451
- _context5.t0 = parseInt(result);
1474
+ result = _context6.sent;
1475
+ _context6.t0 = parseInt(result);
1452
1476
 
1453
- if (_context5.t0) {
1454
- _context5.next = 8;
1477
+ if (_context6.t0) {
1478
+ _context6.next = 8;
1455
1479
  break;
1456
1480
  }
1457
1481
 
1458
- _context5.next = 7;
1482
+ _context6.next = 7;
1459
1483
  return provider.getBlockNumber();
1460
1484
 
1461
1485
  case 7:
1462
- _context5.t0 = _context5.sent;
1486
+ _context6.t0 = _context6.sent;
1463
1487
 
1464
1488
  case 8:
1465
- return _context5.abrupt("return", _context5.t0);
1489
+ return _context6.abrupt("return", _context6.t0);
1466
1490
 
1467
1491
  case 9:
1468
1492
  case "end":
1469
- return _context5.stop();
1493
+ return _context6.stop();
1470
1494
  }
1471
1495
  }
1472
- }, _callee5);
1496
+ }, _callee6);
1473
1497
  }));
1474
1498
  return _getBlockBeforeTimestamp.apply(this, arguments);
1475
1499
  }
@@ -2597,6 +2621,7 @@ var helpers = {
2597
2621
  decimalFactor: decimalFactor,
2598
2622
  isSameAddress: isSameAddress,
2599
2623
  getCurrentTimestamp: getCurrentTimestamp,
2624
+ sleep: sleep,
2600
2625
  validateAndParseAddress: validateAndParseAddress,
2601
2626
  getDecimal: getDecimal,
2602
2627
  getSymbol: getSymbol,
@@ -4838,16 +4863,48 @@ var PlyGameRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4838
4863
  var _getPlyGameResultsInTransaction = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(txHash) {
4839
4864
  var _this3 = this;
4840
4865
 
4841
- var tx, filter, betMadeEvents;
4866
+ var tx, i, filter, betMadeEvents;
4842
4867
  return runtime_1.wrap(function _callee5$(_context5) {
4843
4868
  while (1) {
4844
4869
  switch (_context5.prev = _context5.next) {
4845
4870
  case 0:
4846
4871
  _context5.next = 2;
4847
- return this._networkConnection.provider.waitForTransaction(txHash, 1);
4872
+ return this._networkConnection.provider.getTransactionReceipt(txHash);
4848
4873
 
4849
4874
  case 2:
4850
4875
  tx = _context5.sent;
4876
+ i = 0;
4877
+
4878
+ case 4:
4879
+ if (!(i < 100 && !tx)) {
4880
+ _context5.next = 13;
4881
+ break;
4882
+ }
4883
+
4884
+ _context5.next = 7;
4885
+ return sleep(1000);
4886
+
4887
+ case 7:
4888
+ _context5.next = 9;
4889
+ return this._networkConnection.provider.getTransactionReceipt(txHash);
4890
+
4891
+ case 9:
4892
+ tx = _context5.sent;
4893
+
4894
+ case 10:
4895
+ i++;
4896
+ _context5.next = 4;
4897
+ break;
4898
+
4899
+ case 13:
4900
+ if (tx) {
4901
+ _context5.next = 15;
4902
+ break;
4903
+ }
4904
+
4905
+ throw new Error("Transaction " + txHash + " takes too long to be mined");
4906
+
4907
+ case 15:
4851
4908
  filter = this.env.plygame.filters.BetMade();
4852
4909
  betMadeEvents = tx.logs.filter(function (log) {
4853
4910
  return isSameAddress(log.topics[0], filter.topics[0]);
@@ -4861,7 +4918,7 @@ var PlyGameRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4861
4918
  return _this3.parseBetMakeEvent(e);
4862
4919
  })));
4863
4920
 
4864
- case 6:
4921
+ case 18:
4865
4922
  case "end":
4866
4923
  return _context5.stop();
4867
4924
  }
@@ -5810,5 +5867,5 @@ BigNumber.config({
5810
5867
  DECIMAL_PLACES: 50
5811
5868
  });
5812
5869
 
5813
- export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, ALL_STAKING_POOLS, AURORA_CHAINID, Airdrop, AirdropRead, AirdropReadWrite, AuriEnv, BORROW_LIMIT_BUFFER, BORROW_NEAR_REWARDS_PER_WEEK, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, DEPOSIT_NEAR_REWARDS_PER_WEEK, DEPOSIT_ONLY_TOKENS, ETHAddress, HARDCODE_PRICE_TOKENS, INF, MarketAction, MiscRead, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_WEEK, ONE_YEAR, PLYToken, PLYWNEARToken, PLYWNEAR_POOL_ID, PLYWNEAR_REWARD_TOKENS, PRICE_WHITELISTED, Papermill, PapermillRead, PapermillReadWrite, PlyGame, PlyGameRead, PlyGameReadWrite, REFERRAL_CAMPAIGNS, REWARD_CLAIM_START, Referral, ReferralRead, ReferralReadWrite, SDK, SdkRead, SdkReadWrite, Staking, StakingRead, StakingReadWrite, Token, TokenAmount, TransferEventQuery, index as abis, assert, calcLMRewardApr, calcValuation, decimalFactor, decimalRecords, devLog, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchLPPositions, fetchLPPrice, fetchPLYPrice, fetchPULPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromOracle, fetchStNEARPrice, fetchToken0PriceByLP, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getApi, getBlockBeforeTimestamp, getBlockTimestamp, getBlocksTimestamp, getBlocksTimestampViaRPC, getCurrentTimestamp, getDecimal, getPaginatedApi, getQuery, getSymbol, getUnderlying, isSameAddress, networkAddresses, queryGraphQL, referralRewardDummy1, referralRewardDummy2, sortEvents, symbolRecords, validateAndParseAddress, valuateToken };
5870
+ export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, ALL_STAKING_POOLS, AURORA_CHAINID, Airdrop, AirdropRead, AirdropReadWrite, AuriEnv, BORROW_LIMIT_BUFFER, BORROW_NEAR_REWARDS_PER_WEEK, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, DEPOSIT_NEAR_REWARDS_PER_WEEK, DEPOSIT_ONLY_TOKENS, ETHAddress, HARDCODE_PRICE_TOKENS, INF, MarketAction, MiscRead, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_WEEK, ONE_YEAR, PLYToken, PLYWNEARToken, PLYWNEAR_POOL_ID, PLYWNEAR_REWARD_TOKENS, PRICE_WHITELISTED, Papermill, PapermillRead, PapermillReadWrite, PlyGame, PlyGameRead, PlyGameReadWrite, REFERRAL_CAMPAIGNS, REWARD_CLAIM_START, Referral, ReferralRead, ReferralReadWrite, SDK, SdkRead, SdkReadWrite, Staking, StakingRead, StakingReadWrite, Token, TokenAmount, TransferEventQuery, index as abis, assert, calcLMRewardApr, calcValuation, decimalFactor, decimalRecords, devLog, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchLPPositions, fetchLPPrice, fetchPLYPrice, fetchPULPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromOracle, fetchStNEARPrice, fetchToken0PriceByLP, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getApi, getBlockBeforeTimestamp, getBlockTimestamp, getBlocksTimestamp, getBlocksTimestampViaRPC, getCurrentTimestamp, getDecimal, getPaginatedApi, getQuery, getSymbol, getUnderlying, isSameAddress, networkAddresses, queryGraphQL, referralRewardDummy1, referralRewardDummy2, sleep, sortEvents, symbolRecords, validateAndParseAddress, valuateToken };
5814
5871
  //# sourceMappingURL=sdk.esm.js.map