@aurigami/sdk 1.11.0-beta1 → 1.11.0-beta3

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.
@@ -1,5 +1,7 @@
1
+ import { TypedEvent } from '@aurigami/contracts/typechain/common';
1
2
  import { Provider } from '@ethersproject/abstract-provider';
2
3
  import BigNumber from 'bignumber.js';
4
+ import { Result } from 'ethers/lib/utils';
3
5
  import { Address } from '../types';
4
6
  export declare function assert(condition: boolean, message?: string): void;
5
7
  export declare function formatObject(object: Object): string;
@@ -29,3 +31,8 @@ export declare function getBlocksTimestamp(provider: Provider, blockNumbers: num
29
31
  */
30
32
  export declare function getBlockBeforeTimestamp(provider: Provider, timestamp: number): Promise<number>;
31
33
  export declare function devLog(message?: any, ...optionalParams: any[]): void;
34
+ /**
35
+ * Sorts (in place) an array of Events by blocknumber.
36
+ * This method mutates the array and returns a reference to the same array.
37
+ **/
38
+ export declare function sortEvents<T extends Result>(events: TypedEvent<T>[]): TypedEvent<T>[];
@@ -1,6 +1,6 @@
1
1
  import { TransactionResponse } from '@ethersproject/abstract-provider';
2
2
  import { AuriEnv, BlockchainEntity, BlockchainEntityRead, Token, TokenAmount } from '../entities';
3
- import { Address, NetworkConnection, PlyGameBetResult } from '../types';
3
+ import { Address, NetworkConnection, PlyGameBetResult, PlyGameLeaderboardItem } from '../types';
4
4
  export declare class PlyGameRead extends BlockchainEntityRead {
5
5
  readonly plyToken: Token;
6
6
  readonly pulpToken: Token;
@@ -19,6 +19,10 @@ export declare class PlyGameRead extends BlockchainEntityRead {
19
19
  nextJackpotRevealTime(): Promise<number>;
20
20
  earlyUnlockedPulpAmount(user: Address): Promise<TokenAmount>;
21
21
  getPlyGameResultsInTransaction(txHash: Address): Promise<PlyGameBetResult[]>;
22
+ /**
23
+ * Top 100 users by amount of PULP unlocked
24
+ */
25
+ leaderboard(): Promise<PlyGameLeaderboardItem[]>;
22
26
  }
23
27
  export declare class PlyGameReadWrite extends PlyGameRead {
24
28
  /**
@@ -1490,6 +1490,20 @@ function devLog(message) {
1490
1490
  (_console = console).log.apply(_console, ['[DEV LOG]', message].concat(optionalParams));
1491
1491
  }
1492
1492
  }
1493
+ /**
1494
+ * Sorts (in place) an array of Events by blocknumber.
1495
+ * This method mutates the array and returns a reference to the same array.
1496
+ **/
1497
+
1498
+ function sortEvents(events) {
1499
+ return events.sort(function (a, b) {
1500
+ if (a.blockNumber == b.blockNumber) {
1501
+ return a.logIndex - b.logIndex;
1502
+ }
1503
+
1504
+ return a.blockNumber - b.blockNumber;
1505
+ });
1506
+ }
1493
1507
 
1494
1508
  var BlockchainEntityRead = function BlockchainEntityRead(networkConnection) {
1495
1509
  this._networkConnection = networkConnection;
@@ -2598,6 +2612,7 @@ var helpers = {
2598
2612
  getBlocksTimestamp: getBlocksTimestamp,
2599
2613
  getBlockBeforeTimestamp: getBlockBeforeTimestamp,
2600
2614
  devLog: devLog,
2615
+ sortEvents: sortEvents,
2601
2616
  fetchPriceFromCoingeckoAPI: fetchPriceFromCoingeckoAPI,
2602
2617
  fetchPriceFromCoingecko: fetchPriceFromCoingecko,
2603
2618
  fetchLPPositions: fetchLPPositions,
@@ -4732,11 +4747,13 @@ var PlyGameRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4732
4747
 
4733
4748
  case 8:
4734
4749
  events = _context2.sent;
4750
+ // Sort descending by block number
4751
+ sortEvents(events).reverse();
4735
4752
  return _context2.abrupt("return", this.attachTimestamp(events.map(function (event) {
4736
4753
  return _this2.parseBetMakeEvent(event);
4737
4754
  })));
4738
4755
 
4739
- case 10:
4756
+ case 11:
4740
4757
  case "end":
4741
4758
  return _context2.stop();
4742
4759
  }
@@ -4878,6 +4895,49 @@ var PlyGameRead = /*#__PURE__*/function (_BlockchainEntityRead) {
4878
4895
  }
4879
4896
 
4880
4897
  return getPlyGameResultsInTransaction;
4898
+ }()
4899
+ /**
4900
+ * Top 100 users by amount of PULP unlocked
4901
+ */
4902
+ ;
4903
+
4904
+ _proto.leaderboard =
4905
+ /*#__PURE__*/
4906
+ function () {
4907
+ var _leaderboard = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
4908
+ var _this4 = this;
4909
+
4910
+ var result;
4911
+ return runtime_1.wrap(function _callee7$(_context7) {
4912
+ while (1) {
4913
+ switch (_context7.prev = _context7.next) {
4914
+ case 0:
4915
+ _context7.next = 2;
4916
+ return getPaginatedApi('/plygame/leaderboard');
4917
+
4918
+ case 2:
4919
+ result = _context7.sent;
4920
+ return _context7.abrupt("return", result.items.map(function (item, i) {
4921
+ return {
4922
+ player: item.user,
4923
+ unlockedPulpAmount: new TokenAmount(_this4.pulpToken, item.unlockedAmount),
4924
+ gamesPlayed: item.count
4925
+ };
4926
+ }));
4927
+
4928
+ case 4:
4929
+ case "end":
4930
+ return _context7.stop();
4931
+ }
4932
+ }
4933
+ }, _callee7);
4934
+ }));
4935
+
4936
+ function leaderboard() {
4937
+ return _leaderboard.apply(this, arguments);
4938
+ }
4939
+
4940
+ return leaderboard;
4881
4941
  }();
4882
4942
 
4883
4943
  return PlyGameRead;
@@ -4897,19 +4957,19 @@ var PlyGameReadWrite = /*#__PURE__*/function (_PlyGameRead) {
4897
4957
  _proto2.makeBetMultiple =
4898
4958
  /*#__PURE__*/
4899
4959
  function () {
4900
- var _makeBetMultiple = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(amount, times) {
4901
- return runtime_1.wrap(function _callee7$(_context7) {
4960
+ var _makeBetMultiple = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(amount, times) {
4961
+ return runtime_1.wrap(function _callee8$(_context8) {
4902
4962
  while (1) {
4903
- switch (_context7.prev = _context7.next) {
4963
+ switch (_context8.prev = _context8.next) {
4904
4964
  case 0:
4905
- return _context7.abrupt("return", this.env.plygame.connect(this._networkConnection.signer).makeBetMultiple(amount.rawAmount(), times));
4965
+ return _context8.abrupt("return", this.env.plygame.connect(this._networkConnection.signer).makeBetMultiple(amount.rawAmount(), times));
4906
4966
 
4907
4967
  case 1:
4908
4968
  case "end":
4909
- return _context7.stop();
4969
+ return _context8.stop();
4910
4970
  }
4911
4971
  }
4912
- }, _callee7, this);
4972
+ }, _callee8, this);
4913
4973
  }));
4914
4974
 
4915
4975
  function makeBetMultiple(_x5, _x6) {
@@ -4926,19 +4986,19 @@ var PlyGameReadWrite = /*#__PURE__*/function (_PlyGameRead) {
4926
4986
  _proto2.makeBetOnce =
4927
4987
  /*#__PURE__*/
4928
4988
  function () {
4929
- var _makeBetOnce = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(amount) {
4930
- return runtime_1.wrap(function _callee8$(_context8) {
4989
+ var _makeBetOnce = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(amount) {
4990
+ return runtime_1.wrap(function _callee9$(_context9) {
4931
4991
  while (1) {
4932
- switch (_context8.prev = _context8.next) {
4992
+ switch (_context9.prev = _context9.next) {
4933
4993
  case 0:
4934
- return _context8.abrupt("return", this.env.plygame.connect(this._networkConnection.signer).makeBetOnce(amount.rawAmount()));
4994
+ return _context9.abrupt("return", this.env.plygame.connect(this._networkConnection.signer).makeBetOnce(amount.rawAmount()));
4935
4995
 
4936
4996
  case 1:
4937
4997
  case "end":
4938
- return _context8.stop();
4998
+ return _context9.stop();
4939
4999
  }
4940
5000
  }
4941
- }, _callee8, this);
5001
+ }, _callee9, this);
4942
5002
  }));
4943
5003
 
4944
5004
  function makeBetOnce(_x7) {
@@ -4949,19 +5009,19 @@ var PlyGameReadWrite = /*#__PURE__*/function (_PlyGameRead) {
4949
5009
  }();
4950
5010
 
4951
5011
  _proto2.approve = /*#__PURE__*/function () {
4952
- var _approve = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(amount) {
4953
- return runtime_1.wrap(function _callee9$(_context9) {
5012
+ var _approve = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(amount) {
5013
+ return runtime_1.wrap(function _callee10$(_context10) {
4954
5014
  while (1) {
4955
- switch (_context9.prev = _context9.next) {
5015
+ switch (_context10.prev = _context10.next) {
4956
5016
  case 0:
4957
- return _context9.abrupt("return", this.env.ply.connect(this._networkConnection.signer).approve(this.env.plygame.address, amount.rawAmount()));
5017
+ return _context10.abrupt("return", this.env.ply.connect(this._networkConnection.signer).approve(this.env.plygame.address, amount.rawAmount()));
4958
5018
 
4959
5019
  case 1:
4960
5020
  case "end":
4961
- return _context9.stop();
5021
+ return _context10.stop();
4962
5022
  }
4963
5023
  }
4964
- }, _callee9, this);
5024
+ }, _callee10, this);
4965
5025
  }));
4966
5026
 
4967
5027
  function approve(_x8) {
@@ -5900,6 +5960,7 @@ exports.networkAddresses = networkAddresses;
5900
5960
  exports.queryGraphQL = queryGraphQL;
5901
5961
  exports.referralRewardDummy1 = referralRewardDummy1;
5902
5962
  exports.referralRewardDummy2 = referralRewardDummy2;
5963
+ exports.sortEvents = sortEvents;
5903
5964
  exports.symbolRecords = symbolRecords;
5904
5965
  exports.validateAndParseAddress = validateAndParseAddress;
5905
5966
  exports.valuateToken = valuateToken;