@aurigami/sdk 1.11.0-beta5 → 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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.11.0-beta5",
2
+ "version": "1.11.1",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -62,7 +62,7 @@
62
62
  "typescript": "^4.5.4"
63
63
  },
64
64
  "dependencies": {
65
- "@aurigami/contracts": "3.12.0-beta-3",
65
+ "@aurigami/contracts": "3.12.0-beta-4",
66
66
  "axios": "^0.26.1",
67
67
  "bignumber.js": "^9.0.2",
68
68
  "ethers": "^5.6.4"
@@ -90,7 +90,7 @@ export const networkAddresses: NetworkAddresses = {
90
90
  PLY_TOKEN_LOCK: MAINNET_ADDRESSES.plyTokenLock.toLowerCase(),
91
91
  REFERRAL: MAINNET_ADDRESSES.referralDirectory.toLowerCase(),
92
92
  AURI_INTERNAL_LENS: MAINNET_ADDRESSES.auriInternalLens.toLowerCase(),
93
- PLYGAME: '0x60bf668CA101060BD83BD644531a38719586B89f'.toLowerCase(), // TODO: FIX THIS AFTER PLY GAME IS DEPLOYED
93
+ PLYGAME: MAINNET_ADDRESSES.plyGame.toLowerCase(),
94
94
  },
95
95
  tokens: {
96
96
  AURORA: '0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase(),
@@ -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,
@@ -76,10 +76,6 @@ export class PlyGameRead extends BlockchainEntityRead {
76
76
  return new TokenAmount(this.plyToken, jackpot.toString());
77
77
  }
78
78
 
79
- public async nextJackpotRevealTime(): Promise<number> {
80
- return 0; // TODO: TBD
81
- }
82
-
83
79
  public async earlyUnlockedPulpAmount(user: Address): Promise<TokenAmount> {
84
80
  let earlyUnlockedPulpAmount = await this.env.plygame.totalPlyUnlockedEarly(user);
85
81
  return new TokenAmount(this.pulpToken, earlyUnlockedPulpAmount.toString());
@@ -87,7 +83,17 @@ export class PlyGameRead extends BlockchainEntityRead {
87
83
 
88
84
  public async getPlyGameResultsInTransaction(txHash: Address): Promise<PlyGameBetResult[]> {
89
85
  // wait for the tx to be mined if needed.
90
- let tx = await this._networkConnection.provider.waitForTransaction(txHash, 1);
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
+ }
91
97
 
92
98
  let filter = this.env.plygame.filters.BetMade();
93
99
  let betMadeEvents: PlyBetMadeEvent[] = tx.logs
@@ -115,15 +121,6 @@ export class PlyGameRead extends BlockchainEntityRead {
115
121
  }
116
122
 
117
123
  export class PlyGameReadWrite extends PlyGameRead {
118
- /**
119
- * makes "times" independent bets, but consecutively, of the same amount
120
- */
121
- public async makeBetMultiple(amount: TokenAmount, times: number): Promise<TransactionResponse> {
122
- return this.env.plygame
123
- .connect(this._networkConnection.signer!)
124
- .makeBetMultiple(amount.rawAmount(), times);
125
- }
126
-
127
124
  /**
128
125
  * Make a single bet
129
126
  */
@@ -132,6 +129,7 @@ export class PlyGameReadWrite extends PlyGameRead {
132
129
  .connect(this._networkConnection.signer!)
133
130
  .makeBetOnce(amount.rawAmount());
134
131
  }
132
+
135
133
  public async approve(amount: TokenAmount): Promise<TransactionResponse> {
136
134
  return this.env.ply
137
135
  .connect(this._networkConnection.signer!)