@kleo-protocol/kleo-sdk 0.1.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/LICENSE +21 -0
- package/README.md +269 -0
- package/dist/src/client.d.ts +36 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +156 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/dedot.client.d.ts +11 -0
- package/dist/src/dedot.client.d.ts.map +1 -0
- package/dist/src/dedot.client.js +28 -0
- package/dist/src/dedot.client.js.map +1 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +25 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/backed-position.d.ts +8 -0
- package/dist/src/interfaces/backed-position.d.ts.map +1 -0
- package/dist/src/interfaces/backed-position.js +3 -0
- package/dist/src/interfaces/backed-position.js.map +1 -0
- package/dist/src/interfaces/borrower-info.d.ts +11 -0
- package/dist/src/interfaces/borrower-info.d.ts.map +1 -0
- package/dist/src/interfaces/borrower-info.js +3 -0
- package/dist/src/interfaces/borrower-info.js.map +1 -0
- package/dist/src/interfaces/index.d.ts +5 -0
- package/dist/src/interfaces/index.d.ts.map +1 -0
- package/dist/src/interfaces/index.js +21 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/interfaces/loan.d.ts +5 -0
- package/dist/src/interfaces/loan.d.ts.map +1 -0
- package/dist/src/interfaces/loan.js +3 -0
- package/dist/src/interfaces/loan.js.map +1 -0
- package/dist/src/interfaces/vouch-info.d.ts +8 -0
- package/dist/src/interfaces/vouch-info.d.ts.map +1 -0
- package/dist/src/interfaces/vouch-info.js +3 -0
- package/dist/src/interfaces/vouch-info.js.map +1 -0
- package/dist/src/services/index.d.ts +6 -0
- package/dist/src/services/index.d.ts.map +1 -0
- package/dist/src/services/index.js +22 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/services/lending.service.d.ts +5 -0
- package/dist/src/services/lending.service.d.ts.map +1 -0
- package/dist/src/services/lending.service.js +26 -0
- package/dist/src/services/lending.service.js.map +1 -0
- package/dist/src/services/pool.service.d.ts +19 -0
- package/dist/src/services/pool.service.d.ts.map +1 -0
- package/dist/src/services/pool.service.js +63 -0
- package/dist/src/services/pool.service.js.map +1 -0
- package/dist/src/services/profile.service.d.ts +5 -0
- package/dist/src/services/profile.service.d.ts.map +1 -0
- package/dist/src/services/profile.service.js +25 -0
- package/dist/src/services/profile.service.js.map +1 -0
- package/dist/src/services/reputation.service.d.ts +13 -0
- package/dist/src/services/reputation.service.d.ts.map +1 -0
- package/dist/src/services/reputation.service.js +97 -0
- package/dist/src/services/reputation.service.js.map +1 -0
- package/dist/src/services/vouch.service.d.ts +7 -0
- package/dist/src/services/vouch.service.d.ts.map +1 -0
- package/dist/src/services/vouch.service.js +74 -0
- package/dist/src/services/vouch.service.js.map +1 -0
- package/dist/src/supabase.client.d.ts +3 -0
- package/dist/src/supabase.client.d.ts.map +1 -0
- package/dist/src/supabase.client.js +6 -0
- package/dist/src/supabase.client.js.map +1 -0
- package/dist/src/types.d.ts +19 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/contract-helpers.d.ts +24 -0
- package/dist/src/utils/contract-helpers.d.ts.map +1 -0
- package/dist/src/utils/contract-helpers.js +20 -0
- package/dist/src/utils/contract-helpers.js.map +1 -0
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +18 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/types/types.d.ts +19 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +3 -0
- package/dist/types/types.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./backed-position"), exports);
|
|
18
|
+
__exportStar(require("./vouch-info"), exports);
|
|
19
|
+
__exportStar(require("./borrower-info"), exports);
|
|
20
|
+
__exportStar(require("./loan"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,+CAA6B;AAC7B,kDAAgC;AAChC,yCAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loan.d.ts","sourceRoot":"","sources":["../../../src/interfaces/loan.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loan.js","sourceRoot":"","sources":["../../../src/interfaces/loan.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vouch-info.d.ts","sourceRoot":"","sources":["../../../src/interfaces/vouch-info.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,QAAQ,GAAG,WAAW,GAAG,WAAW,CAAC;CAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vouch-info.js","sourceRoot":"","sources":["../../../src/interfaces/vouch-info.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./pool.service"), exports);
|
|
18
|
+
__exportStar(require("./profile.service"), exports);
|
|
19
|
+
__exportStar(require("./lending.service"), exports);
|
|
20
|
+
__exportStar(require("./vouch.service"), exports);
|
|
21
|
+
__exportStar(require("./reputation.service"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,oDAAkC;AAClC,oDAAkC;AAClC,kDAAgC;AAChC,uDAAqC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DedotClient } from 'dedot';
|
|
2
|
+
import type { PolkadotApi } from '@dedot/chaintypes';
|
|
3
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
4
|
+
export declare function getUserDeposit(supabase: SupabaseClient, dedotClient: DedotClient<PolkadotApi>, lendingPoolMetadata: any, poolId: string, userAddress: string): Promise<string | undefined>;
|
|
5
|
+
//# sourceMappingURL=lending.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lending.service.d.ts","sourceRoot":"","sources":["../../../src/services/lending.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAYvD,wBAAsB,cAAc,CAClC,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,EACrC,mBAAmB,EAAE,GAAG,EACxB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAoC7B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUserDeposit = getUserDeposit;
|
|
4
|
+
const contracts_1 = require("dedot/contracts");
|
|
5
|
+
async function getUserDeposit(supabase, dedotClient, lendingPoolMetadata, poolId, userAddress) {
|
|
6
|
+
const { data, error } = await supabase.from('pools').select().eq('id', poolId).single();
|
|
7
|
+
if (error) {
|
|
8
|
+
throw new Error(`Error fetching pool: ${error.message}`);
|
|
9
|
+
}
|
|
10
|
+
if (!data) {
|
|
11
|
+
throw new Error(`Pool not found: ${poolId}`);
|
|
12
|
+
}
|
|
13
|
+
const contracts = data.contracts;
|
|
14
|
+
if (!contracts || !contracts.lending_pool) {
|
|
15
|
+
throw new Error(`LendingPool contract address not found in pool contracts`);
|
|
16
|
+
}
|
|
17
|
+
const lendingPoolAddress = contracts.lending_pool;
|
|
18
|
+
if (!lendingPoolMetadata) {
|
|
19
|
+
throw new Error('LendingPool metadata not provided. Pass it to the KleoClient constructor.');
|
|
20
|
+
}
|
|
21
|
+
const lendingPoolContract = new contracts_1.Contract(dedotClient, lendingPoolMetadata, lendingPoolAddress);
|
|
22
|
+
const storage = await lendingPoolContract.storage.lazy();
|
|
23
|
+
const deposit = await storage.userDeposits.get(userAddress);
|
|
24
|
+
return deposit?.toString();
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=lending.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lending.service.js","sourceRoot":"","sources":["../../../src/services/lending.service.ts"],"names":[],"mappings":";;AAeA,wCA0CC;AAxDD,+CAA2C;AAcpC,KAAK,UAAU,cAAc,CAClC,QAAwB,EACxB,WAAqC,EACrC,mBAAwB,EACxB,MAAc,EACd,WAAmB;IAGnB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;IAExF,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;IAGD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IACjC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,kBAAkB,GAAG,SAAS,CAAC,YAAY,CAAC;IAGlD,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;IAC/F,CAAC;IAED,MAAM,mBAAmB,GAAG,IAAI,oBAAQ,CACtC,WAAkB,EAClB,mBAAmB,EACnB,kBAAkB,CACnB,CAAC;IAGF,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACzD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAE5D,OAAO,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DedotClient } from 'dedot';
|
|
2
|
+
import type { PolkadotApi } from '@dedot/chaintypes';
|
|
3
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
4
|
+
export interface PoolState {
|
|
5
|
+
baseInterestRate: string;
|
|
6
|
+
optimalUtilization: string;
|
|
7
|
+
slope1: string;
|
|
8
|
+
slope2: string;
|
|
9
|
+
boost: string;
|
|
10
|
+
minStarsToVouch: number;
|
|
11
|
+
cooldownPeriod: string;
|
|
12
|
+
exposureCap: string;
|
|
13
|
+
reserveFactor: number;
|
|
14
|
+
maxRate: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function getPools(supabase: SupabaseClient): Promise<any[]>;
|
|
17
|
+
export declare function getPool(supabase: SupabaseClient, poolId: string): Promise<any[]>;
|
|
18
|
+
export declare function getPoolState(supabase: SupabaseClient, dedotClient: DedotClient<PolkadotApi>, configMetadata: any, poolId: string, defaultCaller?: string): Promise<PoolState>;
|
|
19
|
+
//# sourceMappingURL=pool.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.service.d.ts","sourceRoot":"","sources":["../../../src/services/pool.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,MAAM,WAAW,SAAS;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAKD,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAQvE;AAKD,wBAAsB,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAQtF;AAKD,wBAAsB,YAAY,CAChC,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,EACrC,cAAc,EAAE,GAAG,EACnB,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,SAAS,CAAC,CAqEpB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPools = getPools;
|
|
4
|
+
exports.getPool = getPool;
|
|
5
|
+
exports.getPoolState = getPoolState;
|
|
6
|
+
const contracts_1 = require("dedot/contracts");
|
|
7
|
+
async function getPools(supabase) {
|
|
8
|
+
const { data, error } = await supabase.from('pools').select();
|
|
9
|
+
if (error) {
|
|
10
|
+
throw new Error(`Error fetching pools: ${error.message}`);
|
|
11
|
+
}
|
|
12
|
+
return data || [];
|
|
13
|
+
}
|
|
14
|
+
async function getPool(supabase, poolId) {
|
|
15
|
+
const { data, error } = await supabase.from('pools').select().eq('id', poolId);
|
|
16
|
+
if (error) {
|
|
17
|
+
throw new Error(`Error fetching pools: ${error.message}`);
|
|
18
|
+
}
|
|
19
|
+
return data || [];
|
|
20
|
+
}
|
|
21
|
+
async function getPoolState(supabase, dedotClient, configMetadata, poolId, defaultCaller) {
|
|
22
|
+
const { data, error } = await supabase.from('pools').select().eq('id', poolId).single();
|
|
23
|
+
if (error) {
|
|
24
|
+
throw new Error(`Error fetching pool: ${error.message}`);
|
|
25
|
+
}
|
|
26
|
+
if (!data) {
|
|
27
|
+
throw new Error(`Pool not found: ${poolId}`);
|
|
28
|
+
}
|
|
29
|
+
const contracts = data.contracts;
|
|
30
|
+
if (!contracts || !contracts.config) {
|
|
31
|
+
throw new Error(`Config contract address not found in pool contracts`);
|
|
32
|
+
}
|
|
33
|
+
const configAddress = contracts.config;
|
|
34
|
+
if (!configMetadata) {
|
|
35
|
+
throw new Error('Config metadata not provided. Pass it to the KleoClient constructor.');
|
|
36
|
+
}
|
|
37
|
+
const configContract = new contracts_1.Contract(dedotClient, configMetadata, configAddress, defaultCaller ? { defaultCaller } : undefined);
|
|
38
|
+
const [baseInterestRate, optimalUtilization, slope1, slope2, boost, minStarsToVouch, cooldownPeriod, exposureCap, reserveFactor, maxRate,] = await Promise.all([
|
|
39
|
+
configContract.query.getBaseInterestRate(),
|
|
40
|
+
configContract.query.getOptimalUtilization(),
|
|
41
|
+
configContract.query.getSlope1(),
|
|
42
|
+
configContract.query.getSlope2(),
|
|
43
|
+
configContract.query.getBoost(),
|
|
44
|
+
configContract.query.getMinStarsToVouch(),
|
|
45
|
+
configContract.query.getCooldownPeriod(),
|
|
46
|
+
configContract.query.getExposureCap(),
|
|
47
|
+
configContract.query.getReserveFactor(),
|
|
48
|
+
configContract.query.getMaxRate(),
|
|
49
|
+
]);
|
|
50
|
+
return {
|
|
51
|
+
baseInterestRate: baseInterestRate.data.toString(),
|
|
52
|
+
optimalUtilization: optimalUtilization.data.toString(),
|
|
53
|
+
slope1: slope1.data.toString(),
|
|
54
|
+
slope2: slope2.data.toString(),
|
|
55
|
+
boost: boost.data.toString(),
|
|
56
|
+
minStarsToVouch: minStarsToVouch.data,
|
|
57
|
+
cooldownPeriod: cooldownPeriod.data.toString(),
|
|
58
|
+
exposureCap: exposureCap.data.toString(),
|
|
59
|
+
reserveFactor: reserveFactor.data,
|
|
60
|
+
maxRate: maxRate.data.toString(),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=pool.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.service.js","sourceRoot":"","sources":["../../../src/services/pool.service.ts"],"names":[],"mappings":";;AAsBA,4BAQC;AAKD,0BAQC;AAKD,oCA2EC;AA1HD,+CAA2C;AAqBpC,KAAK,UAAU,QAAQ,CAAC,QAAwB;IACrD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;IAE9D,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,CAAC,OAAO,EAAE,C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,IAAI,CAAC,QAAQ,EAAE;QACxC,aAAa,EAAE,aAAa,CAAC,IAAI;QACjC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
|
+
export declare function getProfile(supabase: SupabaseClient, userAddress: string): Promise<any[]>;
|
|
3
|
+
export declare function insertProfile(supabase: SupabaseClient, userAddress: string, name: string): Promise<void>;
|
|
4
|
+
export declare function updateProfile(supabase: SupabaseClient, userAddress: string, name: string): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=profile.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.service.d.ts","sourceRoot":"","sources":["../../../src/services/profile.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD,wBAAsB,UAAU,CAAC,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAQ9F;AAKD,wBAAsB,aAAa,CACjC,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAMf;AAKD,wBAAsB,aAAa,CACjC,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAMf"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProfile = getProfile;
|
|
4
|
+
exports.insertProfile = insertProfile;
|
|
5
|
+
exports.updateProfile = updateProfile;
|
|
6
|
+
async function getProfile(supabase, userAddress) {
|
|
7
|
+
const { data, error } = await supabase.from('users').select().eq('id', userAddress);
|
|
8
|
+
if (error) {
|
|
9
|
+
throw new Error(`Error fetching profile: ${error.message}`);
|
|
10
|
+
}
|
|
11
|
+
return data || [];
|
|
12
|
+
}
|
|
13
|
+
async function insertProfile(supabase, userAddress, name) {
|
|
14
|
+
const { error } = await supabase.from('users').insert({ address: userAddress, name: name });
|
|
15
|
+
if (error) {
|
|
16
|
+
throw new Error(`Error inserting profile: ${error.message}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async function updateProfile(supabase, userAddress, name) {
|
|
20
|
+
const { error } = await supabase.from('users').update({ name: name }).eq('address', userAddress);
|
|
21
|
+
if (error) {
|
|
22
|
+
throw new Error(`Error updating profile: ${error.message}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=profile.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.service.js","sourceRoot":"","sources":["../../../src/services/profile.service.ts"],"names":[],"mappings":";;AAKA,gCAQC;AAKD,sCAUC;AAKD,sCAUC;AAtCM,KAAK,UAAU,UAAU,CAAC,QAAwB,EAAE,WAAmB;IAC5E,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAEpF,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,IAAI,IAAI,EAAE,CAAC;AACpB,CAAC;AAKM,KAAK,UAAU,aAAa,CACjC,QAAwB,EACxB,WAAmB,EACnB,IAAY;IAEZ,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAE5F,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,4BAA4B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC;AAKM,KAAK,UAAU,aAAa,CACjC,QAAwB,EACxB,WAAmB,EACnB,IAAY;IAEZ,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAEjG,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DedotClient } from 'dedot';
|
|
2
|
+
import type { PolkadotApi } from '@dedot/chaintypes';
|
|
3
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
4
|
+
import { ReputationUserReputation } from '../../types/reputation/index.js';
|
|
5
|
+
import { BorrowerInfo, Loan } from '../interfaces';
|
|
6
|
+
export declare function getLenderExposure(supabase: SupabaseClient, dedotClient: DedotClient<PolkadotApi>, reputationMetadata: any, poolId: string, userAddress: string): Promise<ReputationUserReputation | undefined>;
|
|
7
|
+
export declare function getBorrowerInfo(supabase: SupabaseClient, dedotClient: DedotClient<PolkadotApi>, metadata: {
|
|
8
|
+
config: any;
|
|
9
|
+
reputation: any;
|
|
10
|
+
vouch: any;
|
|
11
|
+
}, poolId: string, userAddress: string): Promise<BorrowerInfo | undefined>;
|
|
12
|
+
export declare function getUserLoans(supabase: SupabaseClient, dedotClient: DedotClient<PolkadotApi>, reputationMetadata: any, poolId: string, userAddress: string): Promise<Loan[]>;
|
|
13
|
+
//# sourceMappingURL=reputation.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reputation.service.d.ts","sourceRoot":"","sources":["../../../src/services/reputation.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAyB,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAElG,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAKnD,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,EACrC,kBAAkB,EAAE,GAAG,EACvB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC,CAoC/C;AAKD,wBAAsB,eAAe,CACnC,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,EACrC,QAAQ,EAAE;IACR,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,EAAE,GAAG,CAAC;IAChB,KAAK,EAAE,GAAG,CAAC;CACZ,EACD,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAqEnC;AAKD,wBAAsB,YAAY,CAChC,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,EACrC,kBAAkB,EAAE,GAAG,EACvB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,EAAE,CAAC,CAsCjB"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLenderExposure = getLenderExposure;
|
|
4
|
+
exports.getBorrowerInfo = getBorrowerInfo;
|
|
5
|
+
exports.getUserLoans = getUserLoans;
|
|
6
|
+
const contracts_1 = require("dedot/contracts");
|
|
7
|
+
async function getLenderExposure(supabase, dedotClient, reputationMetadata, poolId, userAddress) {
|
|
8
|
+
const { data, error } = await supabase.from('pools').select().eq('id', poolId).single();
|
|
9
|
+
if (error) {
|
|
10
|
+
throw new Error(`Error fetching pool: ${error.message}`);
|
|
11
|
+
}
|
|
12
|
+
if (!data) {
|
|
13
|
+
throw new Error(`Pool not found: ${poolId}`);
|
|
14
|
+
}
|
|
15
|
+
const contracts = data.contracts;
|
|
16
|
+
if (!contracts || !contracts.reputation) {
|
|
17
|
+
throw new Error(`Reputation contract address not found in pool contracts`);
|
|
18
|
+
}
|
|
19
|
+
const reputationAddress = contracts.reputation;
|
|
20
|
+
if (!reputationMetadata) {
|
|
21
|
+
throw new Error('Reputation metadata not provided. Pass it to the KleoClient constructor.');
|
|
22
|
+
}
|
|
23
|
+
const reputationContract = new contracts_1.Contract(dedotClient, reputationMetadata, reputationAddress);
|
|
24
|
+
const storage = await reputationContract.storage.lazy();
|
|
25
|
+
const userRep = await storage.userReps.get(userAddress);
|
|
26
|
+
return userRep;
|
|
27
|
+
}
|
|
28
|
+
async function getBorrowerInfo(supabase, dedotClient, metadata, poolId, userAddress) {
|
|
29
|
+
const { data, error } = await supabase.from('pools').select().eq('id', poolId).single();
|
|
30
|
+
if (error) {
|
|
31
|
+
throw new Error(`Error fetching pool: ${error.message}`);
|
|
32
|
+
}
|
|
33
|
+
if (!data) {
|
|
34
|
+
throw new Error(`Pool not found: ${poolId}`);
|
|
35
|
+
}
|
|
36
|
+
const contracts = data.contracts;
|
|
37
|
+
if (!contracts || !contracts.reputation || !contracts.vouch || !contracts.config) {
|
|
38
|
+
throw new Error(`Required contract addresses not found in pool contracts`);
|
|
39
|
+
}
|
|
40
|
+
if (!metadata.reputation || !metadata.vouch || !metadata.config) {
|
|
41
|
+
throw new Error('Required metadata not provided. Pass all metadata to the KleoClient constructor.');
|
|
42
|
+
}
|
|
43
|
+
const reputationContract = new contracts_1.Contract(dedotClient, metadata.reputation, contracts.reputation);
|
|
44
|
+
const vouchContract = new contracts_1.Contract(dedotClient, metadata.vouch, contracts.vouch);
|
|
45
|
+
const configContract = new contracts_1.Contract(dedotClient, metadata.config, contracts.config);
|
|
46
|
+
const [reputationStorage, vouchStorage, minStarsResult] = await Promise.all([
|
|
47
|
+
reputationContract.storage.lazy(),
|
|
48
|
+
vouchContract.storage.lazy(),
|
|
49
|
+
configContract.query.getMinStarsToVouch(),
|
|
50
|
+
]);
|
|
51
|
+
const [userRep, borrowerExposure] = await Promise.all([
|
|
52
|
+
reputationStorage.userReps.get(userAddress),
|
|
53
|
+
vouchStorage.borrowerExposure.get(userAddress),
|
|
54
|
+
]);
|
|
55
|
+
if (!userRep) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
const minStarsToVouch = minStarsResult.data;
|
|
59
|
+
const canVouch = userRep.stars >= minStarsToVouch && !userRep.banned;
|
|
60
|
+
return {
|
|
61
|
+
stars: userRep.stars,
|
|
62
|
+
starsAtStake: userRep.starsAtStake,
|
|
63
|
+
canVouch,
|
|
64
|
+
banned: userRep.banned,
|
|
65
|
+
creationTime: userRep.creationTime.toString(),
|
|
66
|
+
loanHistoryCount: userRep.loanHistory.length,
|
|
67
|
+
vouchHistoryCount: userRep.vouchHistory.length,
|
|
68
|
+
totalExposure: (borrowerExposure || BigInt(0)).toString(),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
async function getUserLoans(supabase, dedotClient, reputationMetadata, poolId, userAddress) {
|
|
72
|
+
const { data, error } = await supabase.from('pools').select().eq('id', poolId).single();
|
|
73
|
+
if (error) {
|
|
74
|
+
throw new Error(`Error fetching pool: ${error.message}`);
|
|
75
|
+
}
|
|
76
|
+
if (!data) {
|
|
77
|
+
throw new Error(`Pool not found: ${poolId}`);
|
|
78
|
+
}
|
|
79
|
+
const contracts = data.contracts;
|
|
80
|
+
if (!contracts || !contracts.reputation) {
|
|
81
|
+
throw new Error(`Reputation contract address not found in pool contracts`);
|
|
82
|
+
}
|
|
83
|
+
if (!reputationMetadata) {
|
|
84
|
+
throw new Error('Reputation metadata not provided. Pass it to the KleoClient constructor.');
|
|
85
|
+
}
|
|
86
|
+
const reputationContract = new contracts_1.Contract(dedotClient, reputationMetadata, contracts.reputation);
|
|
87
|
+
const storage = await reputationContract.storage.lazy();
|
|
88
|
+
const userRep = await storage.userReps.get(userAddress);
|
|
89
|
+
if (!userRep) {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
return userRep.loanHistory.map((loan) => ({
|
|
93
|
+
amount: loan.amount.toString(),
|
|
94
|
+
repaid: loan.repaid,
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=reputation.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reputation.service.js","sourceRoot":"","sources":["../../../src/services/reputation.service.ts"],"names":[],"mappings":";;AAYA,8CA0CC;AAKD,0CA+EC;AAKD,oCA4CC;AA1LD,+CAA2C;AAWpC,KAAK,UAAU,iBAAiB,CACrC,QAAwB,EACxB,WAAqC,EACrC,kBAAuB,EACvB,MAAc,EACd,WAAmB;IAGnB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;IAExF,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;IAGD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IACjC,IAAI,CA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AClB,kBAAkB,EAClB,SAAS,CAAC,UAAU,CACrB,CAAC;IAEF,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACxD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAExD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACxC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QAC9B,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DedotClient } from 'dedot';
|
|
2
|
+
import type { PolkadotApi } from '@dedot/chaintypes';
|
|
3
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
4
|
+
import { BackedPosition, VouchInfo } from '../interfaces';
|
|
5
|
+
export declare function getVouchRelationship(supabase: SupabaseClient, dedotClient: DedotClient<PolkadotApi>, vouchMetadata: any, poolId: string, voucherAddress: string, borrowerAddress: string): Promise<BackedPosition | undefined>;
|
|
6
|
+
export declare function getBorrowerVouches(supabase: SupabaseClient, dedotClient: DedotClient<PolkadotApi>, vouchMetadata: any, poolId: string, borrowerAddress: string): Promise<VouchInfo[]>;
|
|
7
|
+
//# sourceMappingURL=vouch.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vouch.service.d.ts","sourceRoot":"","sources":["../../../src/services/vouch.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAK1D,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,EACrC,aAAa,EAAE,GAAG,EAClB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CA8CrC;AAKD,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,EACrC,aAAa,EAAE,GAAG,EAClB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,SAAS,EAAE,CAAC,CA0DtB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVouchRelationship = getVouchRelationship;
|
|
4
|
+
exports.getBorrowerVouches = getBorrowerVouches;
|
|
5
|
+
const contracts_1 = require("dedot/contracts");
|
|
6
|
+
async function getVouchRelationship(supabase, dedotClient, vouchMetadata, poolId, voucherAddress, borrowerAddress) {
|
|
7
|
+
const { data, error } = await supabase.from('pools').select().eq('id', poolId).single();
|
|
8
|
+
if (error) {
|
|
9
|
+
throw new Error(`Error fetching pool: ${error.message}`);
|
|
10
|
+
}
|
|
11
|
+
if (!data) {
|
|
12
|
+
throw new Error(`Pool not found: ${poolId}`);
|
|
13
|
+
}
|
|
14
|
+
const contracts = data.contracts;
|
|
15
|
+
if (!contracts || !contracts.vouch) {
|
|
16
|
+
throw new Error(`Vouch contract address not found in pool contracts`);
|
|
17
|
+
}
|
|
18
|
+
const vouchAddress = contracts.vouch;
|
|
19
|
+
if (!vouchMetadata) {
|
|
20
|
+
throw new Error('Vouch metadata not provided. Pass it to the KleoClient constructor.');
|
|
21
|
+
}
|
|
22
|
+
const vouchContract = new contracts_1.Contract(dedotClient, vouchMetadata, vouchAddress);
|
|
23
|
+
const storage = await vouchContract.storage.lazy();
|
|
24
|
+
const relationship = await storage.relationships.get([voucherAddress, borrowerAddress]);
|
|
25
|
+
if (!relationship) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
borrower: borrowerAddress,
|
|
30
|
+
stakedStars: relationship.stakedStars,
|
|
31
|
+
stakedCapital: relationship.stakedCapital.toString(),
|
|
32
|
+
createdAt: relationship.createdAt.toString(),
|
|
33
|
+
status: relationship.status,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async function getBorrowerVouches(supabase, dedotClient, vouchMetadata, poolId, borrowerAddress) {
|
|
37
|
+
const { data, error } = await supabase.from('pools').select().eq('id', poolId).single();
|
|
38
|
+
if (error) {
|
|
39
|
+
throw new Error(`Error fetching pool: ${error.message}`);
|
|
40
|
+
}
|
|
41
|
+
if (!data) {
|
|
42
|
+
throw new Error(`Pool not found: ${poolId}`);
|
|
43
|
+
}
|
|
44
|
+
const contracts = data.contracts;
|
|
45
|
+
if (!contracts || !contracts.vouch) {
|
|
46
|
+
throw new Error(`Vouch contract address not found in pool contracts`);
|
|
47
|
+
}
|
|
48
|
+
if (!vouchMetadata) {
|
|
49
|
+
throw new Error('Vouch metadata not provided. Pass it to the KleoClient constructor.');
|
|
50
|
+
}
|
|
51
|
+
const vouchContract = new contracts_1.Contract(dedotClient, vouchMetadata, contracts.vouch);
|
|
52
|
+
const storage = await vouchContract.storage.lazy();
|
|
53
|
+
const vouchers = await storage.borrowerVouchers.get(borrowerAddress);
|
|
54
|
+
if (!vouchers || vouchers.length === 0) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
const relationshipPromises = vouchers.map(async (voucher) => {
|
|
58
|
+
const voucherAddr = voucher.toString();
|
|
59
|
+
const relationship = await storage.relationships.get([voucherAddr, borrowerAddress]);
|
|
60
|
+
if (!relationship) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
voucher: voucherAddr,
|
|
65
|
+
stakedStars: relationship.stakedStars,
|
|
66
|
+
stakedCapital: relationship.stakedCapital.toString(),
|
|
67
|
+
createdAt: relationship.createdAt.toString(),
|
|
68
|
+
status: relationship.status,
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
const relationships = await Promise.all(relationshipPromises);
|
|
72
|
+
return relationships.filter((r) => r !== null);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=vouch.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vouch.service.js","sourceRoot":"","sources":["../../../src/services/vouch.service.ts"],"names":[],"mappings":";;AAUA,oDAqDC;AAKD,gDAgEC;AAnID,+CAA2C;AASpC,KAAK,UAAU,oBAAoB,CACxC,QAAwB,EACxB,WAAqC,EACrC,aAAkB,EAClB,MAAc,EACd,cAAsB,EACtB,eAAuB;IAGvB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;IAExF,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;IAGD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IACjC,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC;IA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D,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAkB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supabase.client.d.ts","sourceRoot":"","sources":["../../src/supabase.client.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,QAAQ,mFAAoF,CAAA;AAClG,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const supabase_js_1 = require("@supabase/supabase-js");
|
|
4
|
+
const supabase = (0, supabase_js_1.createClient)(process.env.SUPABASE_URL || '', process.env.SUPABASE_ANON_KEY || '');
|
|
5
|
+
exports.default = supabase;
|
|
6
|
+
//# sourceMappingURL=supabase.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supabase.client.js","sourceRoot":"","sources":["../../src/supabase.client.ts"],"names":[],"mappings":";;AAAA,uDAAoD;AAGpD,MAAM,QAAQ,GAAG,IAAA,0BAAY,EAAC,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAA;AAClG,kBAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface KleoConfig {
|
|
2
|
+
endpoint?: string;
|
|
3
|
+
timeout?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface RequestOptions {
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ApiResponse<T> {
|
|
10
|
+
data: T;
|
|
11
|
+
status: number;
|
|
12
|
+
message?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ApiError {
|
|
15
|
+
code: string;
|
|
16
|
+
message: string;
|
|
17
|
+
details?: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IAKzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAMlB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,MAAM,WAAW,cAAc;IAI7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAKjC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,MAAM,WAAW,WAAW,CAAC,CAAC;IAI5B,IAAI,EAAE,CAAC,CAAC;IAKR,MAAM,EAAE,MAAM,CAAC;IAKf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,MAAM,WAAW,QAAQ;IAIvB,IAAI,EAAE,MAAM,CAAC;IAKb,OAAO,EAAE,MAAM,CAAC;IAKhB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DedotClient } from 'dedot';
|
|
2
|
+
import { Contract } from 'dedot/contracts';
|
|
3
|
+
import type { PolkadotApi } from '@dedot/chaintypes';
|
|
4
|
+
import { ConfigContractApi } from '../../types/config/index.js';
|
|
5
|
+
import { LendingPoolContractApi } from '../../types/lending-pool/index.js';
|
|
6
|
+
import { ReputationContractApi } from '../../types/reputation/index.js';
|
|
7
|
+
import { VouchContractApi } from '../../types/vouch/index.js';
|
|
8
|
+
export interface ContractMetadata {
|
|
9
|
+
config?: any;
|
|
10
|
+
lendingPool?: any;
|
|
11
|
+
reputation?: any;
|
|
12
|
+
vouch?: any;
|
|
13
|
+
}
|
|
14
|
+
export interface PoolContracts {
|
|
15
|
+
config?: string;
|
|
16
|
+
lending_pool?: string;
|
|
17
|
+
reputation?: string;
|
|
18
|
+
vouch?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function createConfigContract(dedotClient: DedotClient<PolkadotApi>, metadata: any, address: string, defaultCaller?: string): Contract<ConfigContractApi>;
|
|
21
|
+
export declare function createLendingPoolContract(dedotClient: DedotClient<PolkadotApi>, metadata: any, address: string): Contract<LendingPoolContractApi>;
|
|
22
|
+
export declare function createReputationContract(dedotClient: DedotClient<PolkadotApi>, metadata: any, address: string): Contract<ReputationContractApi>;
|
|
23
|
+
export declare function createVouchContract(dedotClient: DedotClient<PolkadotApi>, metadata: any, address: string): Contract<VouchContractApi>;
|
|
24
|
+
//# sourceMappingURL=contract-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/contract-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAK9D,MAAM,WAAW,gBAAgB;IAE/B,MAAM,CAAC,EAAE,GAAG,CAAC;IAEb,WAAW,CAAC,EAAE,GAAG,CAAC;IAElB,UAAU,CAAC,EAAE,GAAG,CAAC;IAEjB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AAKD,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAKD,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,EACrC,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,MAAM,GACrB,QAAQ,CAAC,iBAAiB,CAAC,CAO7B;AAKD,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,EACrC,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,MAAM,GACd,QAAQ,CAAC,sBAAsB,CAAC,CAElC;AAKD,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,EACrC,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,MAAM,GACd,QAAQ,CAAC,qBAAqB,CAAC,CAEjC;AAKD,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,EACrC,QAAQ,EAAE,GAAG,EACb,OAAO,EAAE,MAAM,GACd,QAAQ,CAAC,gBAAgB,CAAC,CAE5B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createConfigContract = createConfigContract;
|
|
4
|
+
exports.createLendingPoolContract = createLendingPoolContract;
|
|
5
|
+
exports.createReputationContract = createReputationContract;
|
|
6
|
+
exports.createVouchContract = createVouchContract;
|
|
7
|
+
const contracts_1 = require("dedot/contracts");
|
|
8
|
+
function createConfigContract(dedotClient, metadata, address, defaultCaller) {
|
|
9
|
+
return new contracts_1.Contract(dedotClient, metadata, address, defaultCaller ? { defaultCaller } : undefined);
|
|
10
|
+
}
|
|
11
|
+
function createLendingPoolContract(dedotClient, metadata, address) {
|
|
12
|
+
return new contracts_1.Contract(dedotClient, metadata, address);
|
|
13
|
+
}
|
|
14
|
+
function createReputationContract(dedotClient, metadata, address) {
|
|
15
|
+
return new contracts_1.Contract(dedotClient, metadata, address);
|
|
16
|
+
}
|
|
17
|
+
function createVouchContract(dedotClient, metadata, address) {
|
|
18
|
+
return new contracts_1.Contract(dedotClient, metadata, address);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=contract-helpers.js.map
|