@aurigami/sdk 1.6.11 → 1.7.0
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 +7 -0
- package/dist/helpers/aurigami-api.d.ts +13 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/sdk.cjs.development.js +145 -13
- 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 +144 -14
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +4 -1
- package/src/contracts/Referral.ts +14 -0
- package/src/helpers/aurigami-api.ts +42 -0
- package/src/helpers/index.ts +1 -0
|
@@ -24,6 +24,13 @@ export declare class ReferralRead extends BlockchainEntityRead {
|
|
|
24
24
|
* Get owner of a referral code, returns zero address if not found.
|
|
25
25
|
*/
|
|
26
26
|
getReferralCodeOwner(code: string): Promise<Address>;
|
|
27
|
+
/**
|
|
28
|
+
* Get referrals of a user, sorted descending by timestamp.
|
|
29
|
+
*/
|
|
30
|
+
getReferralsList(userAddr: Address): Promise<{
|
|
31
|
+
user: string;
|
|
32
|
+
timestamp: number;
|
|
33
|
+
}[]>;
|
|
27
34
|
}
|
|
28
35
|
export declare class ReferralReadWrite extends ReferralRead {
|
|
29
36
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function getApi(url: string, params?: Record<string, any>): Promise<any>;
|
|
2
|
+
export declare type MetaApiResponse = {
|
|
3
|
+
totalItems: number;
|
|
4
|
+
itemCount: number;
|
|
5
|
+
itemsPerPage: number;
|
|
6
|
+
totalPages: number;
|
|
7
|
+
currentPage: number;
|
|
8
|
+
};
|
|
9
|
+
export declare type PaginagedApiResponse<T> = {
|
|
10
|
+
items: T[];
|
|
11
|
+
meta: MetaApiResponse;
|
|
12
|
+
};
|
|
13
|
+
export declare function getPaginatedApi(url: string, params?: Record<string, any>, page?: number, pageSize?: number): Promise<PaginagedApiResponse<any>>;
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1343,6 +1343,91 @@ var dummyUserMarketDetails = {
|
|
|
1343
1343
|
underlyingPrice: '1'
|
|
1344
1344
|
};
|
|
1345
1345
|
|
|
1346
|
+
var AURIGAMI_API_END_POINT = 'https://api.aurigami.finance/app/';
|
|
1347
|
+
function getApi(_x, _x2) {
|
|
1348
|
+
return _getApi.apply(this, arguments);
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
function _getApi() {
|
|
1352
|
+
_getApi = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(url, params) {
|
|
1353
|
+
var resp;
|
|
1354
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1355
|
+
while (1) {
|
|
1356
|
+
switch (_context.prev = _context.next) {
|
|
1357
|
+
case 0:
|
|
1358
|
+
if (params === void 0) {
|
|
1359
|
+
params = {};
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
_context.next = 3;
|
|
1363
|
+
return axios.get(AURIGAMI_API_END_POINT + url + '?' + new URLSearchParams(params), {
|
|
1364
|
+
headers: {
|
|
1365
|
+
'Content-Type': 'application/json'
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
|
|
1369
|
+
case 3:
|
|
1370
|
+
resp = _context.sent;
|
|
1371
|
+
return _context.abrupt("return", resp.data);
|
|
1372
|
+
|
|
1373
|
+
case 5:
|
|
1374
|
+
case "end":
|
|
1375
|
+
return _context.stop();
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
}, _callee);
|
|
1379
|
+
}));
|
|
1380
|
+
return _getApi.apply(this, arguments);
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
function getPaginatedApi(_x3, _x4, _x5, _x6) {
|
|
1384
|
+
return _getPaginatedApi.apply(this, arguments);
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
function _getPaginatedApi() {
|
|
1388
|
+
_getPaginatedApi = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(url, params, page, pageSize) {
|
|
1389
|
+
var resp;
|
|
1390
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1391
|
+
while (1) {
|
|
1392
|
+
switch (_context2.prev = _context2.next) {
|
|
1393
|
+
case 0:
|
|
1394
|
+
if (params === void 0) {
|
|
1395
|
+
params = {};
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
if (page === void 0) {
|
|
1399
|
+
page = 1;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
if (pageSize === void 0) {
|
|
1403
|
+
pageSize = 50;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
params = _extends({}, params, {
|
|
1407
|
+
page: page,
|
|
1408
|
+
limit: pageSize
|
|
1409
|
+
});
|
|
1410
|
+
_context2.next = 6;
|
|
1411
|
+
return axios.get(AURIGAMI_API_END_POINT + url + '?' + new URLSearchParams(params), {
|
|
1412
|
+
headers: {
|
|
1413
|
+
'Content-Type': 'application/json'
|
|
1414
|
+
}
|
|
1415
|
+
});
|
|
1416
|
+
|
|
1417
|
+
case 6:
|
|
1418
|
+
resp = _context2.sent;
|
|
1419
|
+
return _context2.abrupt("return", resp.data);
|
|
1420
|
+
|
|
1421
|
+
case 8:
|
|
1422
|
+
case "end":
|
|
1423
|
+
return _context2.stop();
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
}, _callee2);
|
|
1427
|
+
}));
|
|
1428
|
+
return _getPaginatedApi.apply(this, arguments);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1346
1431
|
function fetchPriceFromCoingeckoAPI(_x) {
|
|
1347
1432
|
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
1348
1433
|
}
|
|
@@ -2038,6 +2123,8 @@ var TransferEventQuery = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2038
2123
|
|
|
2039
2124
|
var helpers = {
|
|
2040
2125
|
__proto__: null,
|
|
2126
|
+
getApi: getApi,
|
|
2127
|
+
getPaginatedApi: getPaginatedApi,
|
|
2041
2128
|
getQuery: getQuery,
|
|
2042
2129
|
assert: assert,
|
|
2043
2130
|
formatObject: formatObject,
|
|
@@ -4209,6 +4296,49 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4209
4296
|
}
|
|
4210
4297
|
|
|
4211
4298
|
return getReferralCodeOwner;
|
|
4299
|
+
}()
|
|
4300
|
+
/**
|
|
4301
|
+
* Get referrals of a user, sorted descending by timestamp.
|
|
4302
|
+
*/
|
|
4303
|
+
;
|
|
4304
|
+
|
|
4305
|
+
_proto.getReferralsList =
|
|
4306
|
+
/*#__PURE__*/
|
|
4307
|
+
function () {
|
|
4308
|
+
var _getReferralsList = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(userAddr) {
|
|
4309
|
+
var result, items;
|
|
4310
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
4311
|
+
while (1) {
|
|
4312
|
+
switch (_context4.prev = _context4.next) {
|
|
4313
|
+
case 0:
|
|
4314
|
+
_context4.next = 2;
|
|
4315
|
+
return getPaginatedApi('/referral/list', {
|
|
4316
|
+
address: userAddr
|
|
4317
|
+
});
|
|
4318
|
+
|
|
4319
|
+
case 2:
|
|
4320
|
+
result = _context4.sent;
|
|
4321
|
+
items = result.items.map(function (item) {
|
|
4322
|
+
return {
|
|
4323
|
+
user: item.user,
|
|
4324
|
+
timestamp: item.blockNumber
|
|
4325
|
+
};
|
|
4326
|
+
});
|
|
4327
|
+
return _context4.abrupt("return", items);
|
|
4328
|
+
|
|
4329
|
+
case 5:
|
|
4330
|
+
case "end":
|
|
4331
|
+
return _context4.stop();
|
|
4332
|
+
}
|
|
4333
|
+
}
|
|
4334
|
+
}, _callee4);
|
|
4335
|
+
}));
|
|
4336
|
+
|
|
4337
|
+
function getReferralsList(_x4) {
|
|
4338
|
+
return _getReferralsList.apply(this, arguments);
|
|
4339
|
+
}
|
|
4340
|
+
|
|
4341
|
+
return getReferralsList;
|
|
4212
4342
|
}();
|
|
4213
4343
|
|
|
4214
4344
|
return ReferralRead;
|
|
@@ -4230,21 +4360,21 @@ var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
|
|
|
4230
4360
|
_proto2.registerNewReferralCode =
|
|
4231
4361
|
/*#__PURE__*/
|
|
4232
4362
|
function () {
|
|
4233
|
-
var _registerNewReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4363
|
+
var _registerNewReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
|
|
4234
4364
|
var referralCode;
|
|
4235
|
-
return runtime_1.wrap(function
|
|
4365
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
4236
4366
|
while (1) {
|
|
4237
|
-
switch (
|
|
4367
|
+
switch (_context5.prev = _context5.next) {
|
|
4238
4368
|
case 0:
|
|
4239
4369
|
referralCode = ethers.ethers.utils.formatBytes32String(this.generateReferralCode());
|
|
4240
|
-
return
|
|
4370
|
+
return _context5.abrupt("return", this.referral.connect(this._networkConnection.signer).registerNewUserReferralCode(referralCode));
|
|
4241
4371
|
|
|
4242
4372
|
case 2:
|
|
4243
4373
|
case "end":
|
|
4244
|
-
return
|
|
4374
|
+
return _context5.stop();
|
|
4245
4375
|
}
|
|
4246
4376
|
}
|
|
4247
|
-
},
|
|
4377
|
+
}, _callee5, this);
|
|
4248
4378
|
}));
|
|
4249
4379
|
|
|
4250
4380
|
function registerNewReferralCode() {
|
|
@@ -4261,24 +4391,24 @@ var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
|
|
|
4261
4391
|
_proto2.useReferralCode =
|
|
4262
4392
|
/*#__PURE__*/
|
|
4263
4393
|
function () {
|
|
4264
|
-
var _useReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4394
|
+
var _useReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(code) {
|
|
4265
4395
|
var referralCode;
|
|
4266
|
-
return runtime_1.wrap(function
|
|
4396
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
4267
4397
|
while (1) {
|
|
4268
|
-
switch (
|
|
4398
|
+
switch (_context6.prev = _context6.next) {
|
|
4269
4399
|
case 0:
|
|
4270
4400
|
referralCode = ethers.ethers.utils.formatBytes32String(code);
|
|
4271
|
-
return
|
|
4401
|
+
return _context6.abrupt("return", this.referral.connect(this._networkConnection.signer).registerReferralCodeUsed(referralCode));
|
|
4272
4402
|
|
|
4273
4403
|
case 2:
|
|
4274
4404
|
case "end":
|
|
4275
|
-
return
|
|
4405
|
+
return _context6.stop();
|
|
4276
4406
|
}
|
|
4277
4407
|
}
|
|
4278
|
-
},
|
|
4408
|
+
}, _callee6, this);
|
|
4279
4409
|
}));
|
|
4280
4410
|
|
|
4281
|
-
function useReferralCode(
|
|
4411
|
+
function useReferralCode(_x5) {
|
|
4282
4412
|
return _useReferralCode.apply(this, arguments);
|
|
4283
4413
|
}
|
|
4284
4414
|
|
|
@@ -4793,10 +4923,12 @@ exports.fetchToken0PriceByLP = fetchToken0PriceByLP;
|
|
|
4793
4923
|
exports.fetchUnderlyingTokensPrices = fetchUnderlyingTokensPrices;
|
|
4794
4924
|
exports.fetchValuation = fetchValuation;
|
|
4795
4925
|
exports.formatObject = formatObject;
|
|
4926
|
+
exports.getApi = getApi;
|
|
4796
4927
|
exports.getBlockBeforeTimestamp = getBlockBeforeTimestamp;
|
|
4797
4928
|
exports.getBlockTimestamp = getBlockTimestamp;
|
|
4798
4929
|
exports.getCurrentTimestamp = getCurrentTimestamp;
|
|
4799
4930
|
exports.getDecimal = getDecimal;
|
|
4931
|
+
exports.getPaginatedApi = getPaginatedApi;
|
|
4800
4932
|
exports.getQuery = getQuery;
|
|
4801
4933
|
exports.getSymbol = getSymbol;
|
|
4802
4934
|
exports.isSameAddress = isSameAddress;
|