@aurigami/sdk 1.6.1 → 1.6.2
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/contracts/Referral.d.ts +44 -0
- package/dist/contracts/index.d.ts +1 -0
- package/dist/sdk.cjs.development.js +236 -1
- 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 -2
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/consts/constants.ts +1 -0
- package/src/contracts/Referral.ts +98 -0
- package/src/contracts/index.ts +1 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ReferralDirectory } from '@aurigami/contracts/typechain';
|
|
2
|
+
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
3
|
+
import { BlockchainEntity, BlockchainEntityRead } from '../entities';
|
|
4
|
+
import { Address, NetworkConnection } from '../types';
|
|
5
|
+
export declare class ReferralRead extends BlockchainEntityRead {
|
|
6
|
+
protected _referral: ReferralDirectory;
|
|
7
|
+
constructor(networkConnection: NetworkConnection);
|
|
8
|
+
/**
|
|
9
|
+
* Generate a 10-character referral code
|
|
10
|
+
* containing alphanumeric characters.
|
|
11
|
+
*/
|
|
12
|
+
protected generateReferralCode(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Get the referral code for a given address, returns empty string if not found.
|
|
15
|
+
*
|
|
16
|
+
* Called to check if a user has a referral code.
|
|
17
|
+
*/
|
|
18
|
+
getUserReferralCode(userAddr: Address): Promise<string>;
|
|
19
|
+
/**
|
|
20
|
+
* Get referral code that a user was referred by, returns empty string if not found.
|
|
21
|
+
*/
|
|
22
|
+
getReferralCodeUsed(userAddr: Address): Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Get owner of a referral code, returns zero address if not found.
|
|
25
|
+
*/
|
|
26
|
+
getReferralCodeOwner(code: string): Promise<Address>;
|
|
27
|
+
}
|
|
28
|
+
export declare class ReferralReadWrite extends ReferralRead {
|
|
29
|
+
/**
|
|
30
|
+
* Generate a referral code for a given address.
|
|
31
|
+
*
|
|
32
|
+
* Called when an user want to creates his own referral code
|
|
33
|
+
*/
|
|
34
|
+
registerNewReferralCode(): Promise<TransactionResponse>;
|
|
35
|
+
/**
|
|
36
|
+
* Called when an user confirms he is referred by a specified code
|
|
37
|
+
*/
|
|
38
|
+
useReferralCode(code: string): Promise<TransactionResponse>;
|
|
39
|
+
}
|
|
40
|
+
export declare class Referral extends BlockchainEntity {
|
|
41
|
+
constructor();
|
|
42
|
+
read(networkConnection: NetworkConnection): ReferralRead;
|
|
43
|
+
readWrite(networkConnection: NetworkConnection): ReferralReadWrite;
|
|
44
|
+
}
|
|
@@ -21,6 +21,7 @@ var EthRepayHelperABI = _interopDefault(require('@aurigami/contracts/artifacts/c
|
|
|
21
21
|
var AuriFairLaunchABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json'));
|
|
22
22
|
var EIP20InterfaceABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json'));
|
|
23
23
|
var PulpABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json'));
|
|
24
|
+
var ReferralDirectoryABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/ReferralDirectory.sol/ReferralDirectory.json'));
|
|
24
25
|
var FaucetABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/mock/Faucet.sol/Faucet.json'));
|
|
25
26
|
var Multicall2ABI = _interopDefault(require('@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json'));
|
|
26
27
|
|
|
@@ -79,7 +80,8 @@ var networkAddresses = {
|
|
|
79
80
|
AURI_AIRDROP: /*#__PURE__*/MAINNET_ADDRESSES.auriAirdrop.toLowerCase(),
|
|
80
81
|
MULTICALL: /*#__PURE__*/MAINNET_ADDRESSES.multicall.toLowerCase(),
|
|
81
82
|
TEAM_MULTISIG: /*#__PURE__*/'0x2D05FfFE70CE64c5954710D4C308dB31C8dBd8dE'.toLowerCase(),
|
|
82
|
-
PLY_TOKEN_LOCK: /*#__PURE__*/MAINNET_ADDRESSES.plyTokenLock.toLowerCase()
|
|
83
|
+
PLY_TOKEN_LOCK: /*#__PURE__*/MAINNET_ADDRESSES.plyTokenLock.toLowerCase(),
|
|
84
|
+
REFERRAL: /*#__PURE__*/MAINNET_ADDRESSES.referralDirectory.toLocaleLowerCase()
|
|
83
85
|
},
|
|
84
86
|
tokens: {
|
|
85
87
|
AURORA: /*#__PURE__*/'0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase(),
|
|
@@ -107171,6 +107173,236 @@ var Papermill = /*#__PURE__*/function (_BlockchainEntity) {
|
|
|
107171
107173
|
return Papermill;
|
|
107172
107174
|
}(BlockchainEntity);
|
|
107173
107175
|
|
|
107176
|
+
var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
107177
|
+
_inheritsLoose(ReferralRead, _BlockchainEntityRead);
|
|
107178
|
+
|
|
107179
|
+
function ReferralRead(networkConnection) {
|
|
107180
|
+
var _this;
|
|
107181
|
+
|
|
107182
|
+
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
107183
|
+
_this._referral = new ethers.Contract(networkAddresses.misc.REFERRAL, ReferralDirectoryABI.abi, networkConnection.provider);
|
|
107184
|
+
return _this;
|
|
107185
|
+
}
|
|
107186
|
+
/**
|
|
107187
|
+
* Generate a 10-character referral code
|
|
107188
|
+
* containing alphanumeric characters.
|
|
107189
|
+
*/
|
|
107190
|
+
|
|
107191
|
+
|
|
107192
|
+
var _proto = ReferralRead.prototype;
|
|
107193
|
+
|
|
107194
|
+
_proto.generateReferralCode = function generateReferralCode() {
|
|
107195
|
+
var letters = 'abcdefghijklmnopqrstuvwxyz';
|
|
107196
|
+
var numbers = '1234567890';
|
|
107197
|
+
var charset = letters + letters.toUpperCase() + numbers;
|
|
107198
|
+
var R = '';
|
|
107199
|
+
|
|
107200
|
+
for (var i = 0; i < 10; i++) {
|
|
107201
|
+
R += charset[Math.floor(Math.random() * charset.length)];
|
|
107202
|
+
}
|
|
107203
|
+
|
|
107204
|
+
return R;
|
|
107205
|
+
}
|
|
107206
|
+
/**
|
|
107207
|
+
* Get the referral code for a given address, returns empty string if not found.
|
|
107208
|
+
*
|
|
107209
|
+
* Called to check if a user has a referral code.
|
|
107210
|
+
*/
|
|
107211
|
+
;
|
|
107212
|
+
|
|
107213
|
+
_proto.getUserReferralCode =
|
|
107214
|
+
/*#__PURE__*/
|
|
107215
|
+
function () {
|
|
107216
|
+
var _getUserReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(userAddr) {
|
|
107217
|
+
var result;
|
|
107218
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
107219
|
+
while (1) {
|
|
107220
|
+
switch (_context.prev = _context.next) {
|
|
107221
|
+
case 0:
|
|
107222
|
+
_context.next = 2;
|
|
107223
|
+
return this._referral.userReferralCode(userAddr);
|
|
107224
|
+
|
|
107225
|
+
case 2:
|
|
107226
|
+
result = _context.sent;
|
|
107227
|
+
return _context.abrupt("return", ethers.ethers.utils.parseBytes32String(result));
|
|
107228
|
+
|
|
107229
|
+
case 4:
|
|
107230
|
+
case "end":
|
|
107231
|
+
return _context.stop();
|
|
107232
|
+
}
|
|
107233
|
+
}
|
|
107234
|
+
}, _callee, this);
|
|
107235
|
+
}));
|
|
107236
|
+
|
|
107237
|
+
function getUserReferralCode(_x) {
|
|
107238
|
+
return _getUserReferralCode.apply(this, arguments);
|
|
107239
|
+
}
|
|
107240
|
+
|
|
107241
|
+
return getUserReferralCode;
|
|
107242
|
+
}()
|
|
107243
|
+
/**
|
|
107244
|
+
* Get referral code that a user was referred by, returns empty string if not found.
|
|
107245
|
+
*/
|
|
107246
|
+
;
|
|
107247
|
+
|
|
107248
|
+
_proto.getReferralCodeUsed =
|
|
107249
|
+
/*#__PURE__*/
|
|
107250
|
+
function () {
|
|
107251
|
+
var _getReferralCodeUsed = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(userAddr) {
|
|
107252
|
+
var result;
|
|
107253
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
107254
|
+
while (1) {
|
|
107255
|
+
switch (_context2.prev = _context2.next) {
|
|
107256
|
+
case 0:
|
|
107257
|
+
_context2.next = 2;
|
|
107258
|
+
return this._referral.referralCodeUsed(userAddr);
|
|
107259
|
+
|
|
107260
|
+
case 2:
|
|
107261
|
+
result = _context2.sent;
|
|
107262
|
+
return _context2.abrupt("return", ethers.ethers.utils.parseBytes32String(result));
|
|
107263
|
+
|
|
107264
|
+
case 4:
|
|
107265
|
+
case "end":
|
|
107266
|
+
return _context2.stop();
|
|
107267
|
+
}
|
|
107268
|
+
}
|
|
107269
|
+
}, _callee2, this);
|
|
107270
|
+
}));
|
|
107271
|
+
|
|
107272
|
+
function getReferralCodeUsed(_x2) {
|
|
107273
|
+
return _getReferralCodeUsed.apply(this, arguments);
|
|
107274
|
+
}
|
|
107275
|
+
|
|
107276
|
+
return getReferralCodeUsed;
|
|
107277
|
+
}()
|
|
107278
|
+
/**
|
|
107279
|
+
* Get owner of a referral code, returns zero address if not found.
|
|
107280
|
+
*/
|
|
107281
|
+
;
|
|
107282
|
+
|
|
107283
|
+
_proto.getReferralCodeOwner =
|
|
107284
|
+
/*#__PURE__*/
|
|
107285
|
+
function () {
|
|
107286
|
+
var _getReferralCodeOwner = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(code) {
|
|
107287
|
+
var referralCode;
|
|
107288
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
107289
|
+
while (1) {
|
|
107290
|
+
switch (_context3.prev = _context3.next) {
|
|
107291
|
+
case 0:
|
|
107292
|
+
referralCode = ethers.ethers.utils.formatBytes32String(code);
|
|
107293
|
+
return _context3.abrupt("return", this._referral.referralCodeOwner(referralCode));
|
|
107294
|
+
|
|
107295
|
+
case 2:
|
|
107296
|
+
case "end":
|
|
107297
|
+
return _context3.stop();
|
|
107298
|
+
}
|
|
107299
|
+
}
|
|
107300
|
+
}, _callee3, this);
|
|
107301
|
+
}));
|
|
107302
|
+
|
|
107303
|
+
function getReferralCodeOwner(_x3) {
|
|
107304
|
+
return _getReferralCodeOwner.apply(this, arguments);
|
|
107305
|
+
}
|
|
107306
|
+
|
|
107307
|
+
return getReferralCodeOwner;
|
|
107308
|
+
}();
|
|
107309
|
+
|
|
107310
|
+
return ReferralRead;
|
|
107311
|
+
}(BlockchainEntityRead);
|
|
107312
|
+
var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
|
|
107313
|
+
_inheritsLoose(ReferralReadWrite, _ReferralRead);
|
|
107314
|
+
|
|
107315
|
+
function ReferralReadWrite() {
|
|
107316
|
+
return _ReferralRead.apply(this, arguments) || this;
|
|
107317
|
+
}
|
|
107318
|
+
|
|
107319
|
+
var _proto2 = ReferralReadWrite.prototype;
|
|
107320
|
+
|
|
107321
|
+
/**
|
|
107322
|
+
* Generate a referral code for a given address.
|
|
107323
|
+
*
|
|
107324
|
+
* Called when an user want to creates his own referral code
|
|
107325
|
+
*/
|
|
107326
|
+
_proto2.registerNewReferralCode =
|
|
107327
|
+
/*#__PURE__*/
|
|
107328
|
+
function () {
|
|
107329
|
+
var _registerNewReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
107330
|
+
var referralCode;
|
|
107331
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
107332
|
+
while (1) {
|
|
107333
|
+
switch (_context4.prev = _context4.next) {
|
|
107334
|
+
case 0:
|
|
107335
|
+
referralCode = ethers.ethers.utils.formatBytes32String(this.generateReferralCode());
|
|
107336
|
+
return _context4.abrupt("return", this._referral.connect(this._networkConnection.signer).registerNewUserReferralCode(referralCode));
|
|
107337
|
+
|
|
107338
|
+
case 2:
|
|
107339
|
+
case "end":
|
|
107340
|
+
return _context4.stop();
|
|
107341
|
+
}
|
|
107342
|
+
}
|
|
107343
|
+
}, _callee4, this);
|
|
107344
|
+
}));
|
|
107345
|
+
|
|
107346
|
+
function registerNewReferralCode() {
|
|
107347
|
+
return _registerNewReferralCode.apply(this, arguments);
|
|
107348
|
+
}
|
|
107349
|
+
|
|
107350
|
+
return registerNewReferralCode;
|
|
107351
|
+
}()
|
|
107352
|
+
/**
|
|
107353
|
+
* Called when an user confirms he is referred by a specified code
|
|
107354
|
+
*/
|
|
107355
|
+
;
|
|
107356
|
+
|
|
107357
|
+
_proto2.useReferralCode =
|
|
107358
|
+
/*#__PURE__*/
|
|
107359
|
+
function () {
|
|
107360
|
+
var _useReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(code) {
|
|
107361
|
+
var referralCode;
|
|
107362
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
107363
|
+
while (1) {
|
|
107364
|
+
switch (_context5.prev = _context5.next) {
|
|
107365
|
+
case 0:
|
|
107366
|
+
referralCode = ethers.ethers.utils.formatBytes32String(code);
|
|
107367
|
+
return _context5.abrupt("return", this._referral.connect(this._networkConnection.signer).registerReferralCodeUsed(referralCode));
|
|
107368
|
+
|
|
107369
|
+
case 2:
|
|
107370
|
+
case "end":
|
|
107371
|
+
return _context5.stop();
|
|
107372
|
+
}
|
|
107373
|
+
}
|
|
107374
|
+
}, _callee5, this);
|
|
107375
|
+
}));
|
|
107376
|
+
|
|
107377
|
+
function useReferralCode(_x4) {
|
|
107378
|
+
return _useReferralCode.apply(this, arguments);
|
|
107379
|
+
}
|
|
107380
|
+
|
|
107381
|
+
return useReferralCode;
|
|
107382
|
+
}();
|
|
107383
|
+
|
|
107384
|
+
return ReferralReadWrite;
|
|
107385
|
+
}(ReferralRead);
|
|
107386
|
+
var Referral = /*#__PURE__*/function (_BlockchainEntity) {
|
|
107387
|
+
_inheritsLoose(Referral, _BlockchainEntity);
|
|
107388
|
+
|
|
107389
|
+
function Referral() {
|
|
107390
|
+
return _BlockchainEntity.call(this) || this;
|
|
107391
|
+
}
|
|
107392
|
+
|
|
107393
|
+
var _proto3 = Referral.prototype;
|
|
107394
|
+
|
|
107395
|
+
_proto3.read = function read(networkConnection) {
|
|
107396
|
+
return new ReferralRead(networkConnection);
|
|
107397
|
+
};
|
|
107398
|
+
|
|
107399
|
+
_proto3.readWrite = function readWrite(networkConnection) {
|
|
107400
|
+
return new ReferralReadWrite(networkConnection);
|
|
107401
|
+
};
|
|
107402
|
+
|
|
107403
|
+
return Referral;
|
|
107404
|
+
}(BlockchainEntity);
|
|
107405
|
+
|
|
107174
107406
|
var StakingRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
107175
107407
|
_inheritsLoose(StakingRead, _BlockchainEntityRead);
|
|
107176
107408
|
|
|
@@ -108145,6 +108377,9 @@ exports.Papermill = Papermill;
|
|
|
108145
108377
|
exports.PapermillRead = PapermillRead;
|
|
108146
108378
|
exports.PapermillReadWrite = PapermillReadWrite;
|
|
108147
108379
|
exports.REWARD_CLAIM_START = REWARD_CLAIM_START;
|
|
108380
|
+
exports.Referral = Referral;
|
|
108381
|
+
exports.ReferralRead = ReferralRead;
|
|
108382
|
+
exports.ReferralReadWrite = ReferralReadWrite;
|
|
108148
108383
|
exports.SDK = SDK;
|
|
108149
108384
|
exports.SdkRead = SdkRead;
|
|
108150
108385
|
exports.SdkReadWrite = SdkReadWrite;
|