@aurigami/sdk 1.11.0-beta2 → 1.11.0-beta4
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/helpers/helpers.d.ts +7 -0
- package/dist/sdk.cjs.development.js +25 -4
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +25 -5
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/helpers/helpers.ts +15 -0
- package/src/interactors/PlyGame.ts +9 -4
- package/src/types/index.ts +2 -2
|
@@ -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>[];
|
|
@@ -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,
|
|
@@ -4648,11 +4663,14 @@ var PlyGameRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4648
4663
|
|
|
4649
4664
|
_proto.parseBetMakeEvent = function parseBetMakeEvent(event) {
|
|
4650
4665
|
var outcome = ['bigWin', 'win', 'lose', 'noImpact'][event.args.outcome];
|
|
4651
|
-
var
|
|
4652
|
-
|
|
4666
|
+
var betAmount = event.args.amount; // 0%, 0%, 100%, 2%
|
|
4667
|
+
// big win, win, lose, no impact
|
|
4668
|
+
|
|
4669
|
+
var lostAmount = betAmount.mul([0, 0, 100, 2][event.args.outcome]).div(100);
|
|
4670
|
+
var unlock = betAmount.mul([10, 1, 0, 0][event.args.outcome]);
|
|
4653
4671
|
return {
|
|
4654
4672
|
player: event.args.player,
|
|
4655
|
-
|
|
4673
|
+
lostAmount: new TokenAmount(this.plyToken, lostAmount.toString()),
|
|
4656
4674
|
unlockedPulpAmount: new TokenAmount(this.pulpToken, unlock.toString()),
|
|
4657
4675
|
outcome: outcome,
|
|
4658
4676
|
transactionHash: event.transactionHash,
|
|
@@ -4732,11 +4750,13 @@ var PlyGameRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4732
4750
|
|
|
4733
4751
|
case 8:
|
|
4734
4752
|
events = _context2.sent;
|
|
4753
|
+
// Sort descending by block number
|
|
4754
|
+
sortEvents(events).reverse();
|
|
4735
4755
|
return _context2.abrupt("return", this.attachTimestamp(events.map(function (event) {
|
|
4736
4756
|
return _this2.parseBetMakeEvent(event);
|
|
4737
4757
|
})));
|
|
4738
4758
|
|
|
4739
|
-
case
|
|
4759
|
+
case 11:
|
|
4740
4760
|
case "end":
|
|
4741
4761
|
return _context2.stop();
|
|
4742
4762
|
}
|
|
@@ -5943,6 +5963,7 @@ exports.networkAddresses = networkAddresses;
|
|
|
5943
5963
|
exports.queryGraphQL = queryGraphQL;
|
|
5944
5964
|
exports.referralRewardDummy1 = referralRewardDummy1;
|
|
5945
5965
|
exports.referralRewardDummy2 = referralRewardDummy2;
|
|
5966
|
+
exports.sortEvents = sortEvents;
|
|
5946
5967
|
exports.symbolRecords = symbolRecords;
|
|
5947
5968
|
exports.validateAndParseAddress = validateAndParseAddress;
|
|
5948
5969
|
exports.valuateToken = valuateToken;
|