@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.
- package/dist/helpers/helpers.d.ts +1 -0
- package/dist/interactors/Referral.d.ts +11 -0
- package/dist/sdk.cjs.development.js +234 -93
- 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 +234 -94
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/consts/dummy.ts +6 -4
- package/src/helpers/helpers.ts +6 -0
- package/src/interactors/PlyGame.ts +12 -2
- package/src/interactors/Referral.ts +36 -3
- package/src/types/index.ts +2 -0
- package/src/a.ts.log +0 -29
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
package/src/consts/dummy.ts
CHANGED
|
@@ -30,20 +30,22 @@ export const dummyUserMarketDetails: UserMarketDetails = {
|
|
|
30
30
|
|
|
31
31
|
export const referralRewardDummy1: ReferralReward = {
|
|
32
32
|
campaign: 'testa',
|
|
33
|
-
startTime:
|
|
34
|
-
endTime:
|
|
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:
|
|
44
|
-
endTime:
|
|
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
|
};
|
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
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
2
|
-
import { ethers } from 'ethers';
|
|
3
|
-
import {
|
|
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
|
-
|
|
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 {
|
package/src/types/index.ts
CHANGED
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();
|