@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/helpers/helpers.d.ts +1 -0
- package/dist/sdk.cjs.development.js +117 -59
- 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 +117 -60
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/helpers.ts +6 -0
- package/src/interactors/PlyGame.ts +12 -2
package/package.json
CHANGED
package/src/helpers/helpers.ts
CHANGED
|
@@ -33,6 +33,12 @@ export const getCurrentTimestamp = (): number => {
|
|
|
33
33
|
return Math.trunc(Date.now() / 1000);
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
export async function sleep(duration: number): Promise<void> {
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
setTimeout(resolve, duration);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
36
42
|
export function validateAndParseAddress(address: Address): Address {
|
|
37
43
|
try {
|
|
38
44
|
return utils.getAddress(address);
|
|
@@ -2,7 +2,7 @@ import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
|
2
2
|
import * as consts from '../consts';
|
|
3
3
|
import { AuriEnv, BlockchainEntity, BlockchainEntityRead, Token, TokenAmount } from '../entities';
|
|
4
4
|
import * as helpers from '../helpers';
|
|
5
|
-
import { getBlocksTimestamp, isSameAddress, sortEvents } from '../helpers';
|
|
5
|
+
import { getBlocksTimestamp, isSameAddress, sleep, sortEvents } from '../helpers';
|
|
6
6
|
import * as AuriAPI from '../helpers/aurigami-api';
|
|
7
7
|
import {
|
|
8
8
|
Address,
|
|
@@ -83,7 +83,17 @@ export class PlyGameRead extends BlockchainEntityRead {
|
|
|
83
83
|
|
|
84
84
|
public async getPlyGameResultsInTransaction(txHash: Address): Promise<PlyGameBetResult[]> {
|
|
85
85
|
// wait for the tx to be mined if needed.
|
|
86
|
-
|
|
86
|
+
// Don't use `waitForTransaction` because it will wait for longer than needed.
|
|
87
|
+
let tx = await this._networkConnection.provider.getTransactionReceipt(txHash);
|
|
88
|
+
|
|
89
|
+
for (let i = 0; i < 100 && !tx; i++) {
|
|
90
|
+
await sleep(1000); // Sleep for 1 second before retrying
|
|
91
|
+
tx = await this._networkConnection.provider.getTransactionReceipt(txHash);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!tx) {
|
|
95
|
+
throw new Error(`Transaction ${txHash} takes too long to be mined`);
|
|
96
|
+
}
|
|
87
97
|
|
|
88
98
|
let filter = this.env.plygame.filters.BetMade();
|
|
89
99
|
let betMadeEvents: PlyBetMadeEvent[] = tx.logs
|