@aurigami/sdk 1.11.0 → 1.11.2-dummy1

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.
@@ -133,6 +133,7 @@ export declare type ReferralReward = {
133
133
  * hash of the transaction on aurorascan (if no, return null)
134
134
  */
135
135
  transactionHash: string | null;
136
+ refereeAddress: string | null;
136
137
  };
137
138
  export declare type PlyGameBetResult = {
138
139
  player: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.11.0",
2
+ "version": "1.11.2-dummy1",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -70,4 +70,4 @@
70
70
  "jest": {
71
71
  "testURL": "https://app.aurigami.finance"
72
72
  }
73
- }
73
+ }
@@ -30,20 +30,22 @@ export const dummyUserMarketDetails: UserMarketDetails = {
30
30
 
31
31
  export const referralRewardDummy1: ReferralReward = {
32
32
  campaign: 'testa',
33
- startTime: 1652882400, // May 18, 2022 2:00:00 PM
34
- endTime: 1653573599, // May 26, 2022 1:59:59 PM
33
+ startTime: Math.trunc(new Date(2022, 8, 1).getTime() / 1000),
34
+ endTime: Math.trunc(new Date(2022, 9, 30).getTime() / 1000),
35
35
  isReferrer: false,
36
36
  rewardTokenAmount: dummyTokenAmount,
37
37
  transactionHash: null,
38
38
  userAddr: '0x...123',
39
+ refereeAddress: '0x123..123',
39
40
  };
40
41
 
41
42
  export const referralRewardDummy2: ReferralReward = {
42
43
  campaign: 'testb',
43
- startTime: 1652882400, // May 18, 2022 2:00:00 PM
44
- endTime: 1653573599, // May 26, 2022 1:59:59 PM
44
+ startTime: Math.trunc(new Date(2022, 8, 1).getTime() / 1000),
45
+ endTime: Math.trunc(new Date(2022, 8, 31).getTime() / 1000),
45
46
  isReferrer: true,
46
47
  rewardTokenAmount: dummyTokenAmount2,
47
48
  transactionHash: '0x4da9657663b46ef18d150b897b28c7b717f16421978b52e3a06d91b54ca3548b',
48
49
  userAddr: '0x...456',
50
+ refereeAddress: '0x123..123',
49
51
  };
@@ -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
- 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
+ }
87
97
 
88
98
  let filter = this.env.plygame.filters.BetMade();
89
99
  let betMadeEvents: PlyBetMadeEvent[] = tx.logs
@@ -1,6 +1,11 @@
1
1
  import { TransactionResponse } from '@ethersproject/abstract-provider';
2
- import { ethers } from 'ethers';
3
- import { REFERRAL_CAMPAIGNS } from '../consts';
2
+ import { ethers, BigNumber as BN } from 'ethers';
3
+ import {
4
+ networkAddresses,
5
+ referralRewardDummy1,
6
+ referralRewardDummy2,
7
+ REFERRAL_CAMPAIGNS,
8
+ } from '../consts';
4
9
  import { AuriEnv, BlockchainEntity, BlockchainEntityRead, TokenAmount } from '../entities';
5
10
  import { getBlocksTimestamp } from '../helpers';
6
11
  import * as AuriAPI from '../helpers/aurigami-api';
@@ -72,7 +77,7 @@ export class ReferralRead extends BlockchainEntityRead {
72
77
  */
73
78
  public async referralRewards(userAddr: Address): Promise<ReferralReward[]> {
74
79
  const result = await AuriAPI.getPaginatedApi('/referral/rewards', { address: userAddr });
75
- const items: ReferralReward[] = result.items.map((item, i) => ({
80
+ let items: ReferralReward[] = result.items.map((item, i) => ({
76
81
  campaign: item.campaign!,
77
82
  userAddr: userAddr,
78
83
  isReferrer: (item.campaign as string).includes('referrer'),
@@ -80,7 +85,10 @@ export class ReferralRead extends BlockchainEntityRead {
80
85
  startTime: REFERRAL_CAMPAIGNS[item.campaign].start,
81
86
  endTime: REFERRAL_CAMPAIGNS[item.campaign].end,
82
87
  transactionHash: item.transactionHash ?? null,
88
+ refereeAddress: null,
83
89
  }));
90
+
91
+ items = [referralRewardDummy1, referralRewardDummy2, ...items];
84
92
  return items;
85
93
  }
86
94
 
@@ -97,10 +105,35 @@ export class ReferralRead extends BlockchainEntityRead {
97
105
  startTime: REFERRAL_CAMPAIGNS[item.campaign].start,
98
106
  endTime: REFERRAL_CAMPAIGNS[item.campaign].end,
99
107
  transactionHash: null,
108
+ refereeAddress: null,
100
109
  }));
101
110
  items.sort((a, b) => b.rewardTokenAmount.compare(a.rewardTokenAmount));
102
111
  return items;
103
112
  }
113
+
114
+ /**
115
+ * current number of slots under a referral code being used that exceed minimum deposit amount
116
+ */
117
+ public async slotsInUse(referralCode: string): Promise<number> {
118
+ return 123;
119
+ }
120
+
121
+ public totalReferralSlots() {
122
+ return 500;
123
+ }
124
+
125
+ /**
126
+ * a way to determine qualification status of a user. null if not referred yet,
127
+ * qualified if referred + min deposit, notQualified if referred + min deposit
128
+ * not reached or withdrew too early
129
+ */
130
+ public async userReferralStatus(userAddr: Address): Promise<string> {
131
+ if ((await this.getReferralCodeUsed(userAddr)) !== '') {
132
+ return 'notQualified';
133
+ } else {
134
+ return 'notReferred';
135
+ }
136
+ }
104
137
  }
105
138
 
106
139
  export class ReferralReadWrite extends ReferralRead {
@@ -150,6 +150,8 @@ export type ReferralReward = {
150
150
  * hash of the transaction on aurorascan (if no, return null)
151
151
  */
152
152
  transactionHash: string | null;
153
+
154
+ refereeAddress: string | null;
153
155
  };
154
156
 
155
157
  export type PlyGameBetResult = {
package/src/a.ts.log DELETED
@@ -1,29 +0,0 @@
1
- import { AuToken } from '@aurigami/contracts/typechain';
2
- import { ethers } from 'ethers';
3
- import { AuriEnv, formatObject, getDecimal, MAINNET_ADDRESSES, networkAddresses, SDK, Token } from '../src';
4
- import { ask } from 'stdio';
5
- const AURORA_DEFAULT_PROVIDER_URL = `https://mainnet.aurora.dev/`;
6
-
7
- const AURORA_DEFAULT_PROVIDER = new ethers.providers.JsonRpcProvider(
8
- AURORA_DEFAULT_PROVIDER_URL
9
- );
10
-
11
- async function foo(contract: AuToken, block: number) {
12
- let data = await contract.callStatic.borrowBalanceCurrent('0x25a087dc3512e3be548f0ca13233ae29d3781bdc', {blockTag: block});
13
- console.log("c", data.toString());
14
- data = await contract.callStatic.borrowBalanceStored('0x25a087dc3512e3be548f0ca13233ae29d3781bdc', {blockTag: block});
15
- console.log("s", data.toString());
16
- }
17
-
18
- async function main() {
19
- let env = new AuriEnv({ provider: AURORA_DEFAULT_PROVIDER });
20
- let contract = env.getAuErc20Contract({address: MAINNET_ADDRESSES.auTokens.USDC});
21
- // let block = 60596417;
22
- // while (true) {
23
- // block = parseInt(eval(await ask('block')));
24
- // if (block == 0) break;
25
- // await foo(contract, block);
26
- // }
27
- }
28
-
29
- main();