@huma-finance/soroban-sdk 0.0.8-beta.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/API.md +132 -0
- package/README.md +16 -0
- package/dist/cjs/helpers/CreditContractHelper.d.ts +77 -0
- package/dist/cjs/helpers/CreditContractHelper.js +180 -0
- package/dist/cjs/helpers/CreditContractHelper.js.map +1 -0
- package/dist/cjs/helpers/index.d.ts +1 -0
- package/dist/cjs/helpers/index.js +5 -0
- package/dist/cjs/helpers/index.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/services/HumaContextStellar.d.ts +19 -0
- package/dist/cjs/services/HumaContextStellar.js +47 -0
- package/dist/cjs/services/HumaContextStellar.js.map +1 -0
- package/dist/cjs/services/StellarWallet.d.ts +9 -0
- package/dist/cjs/services/StellarWallet.js +22 -0
- package/dist/cjs/services/StellarWallet.js.map +1 -0
- package/dist/cjs/services/index.d.ts +2 -0
- package/dist/cjs/services/index.js +6 -0
- package/dist/cjs/services/index.js.map +1 -0
- package/dist/cjs/utils/client.d.ts +10 -0
- package/dist/cjs/utils/client.js +63 -0
- package/dist/cjs/utils/client.js.map +1 -0
- package/dist/cjs/utils/common.d.ts +2 -0
- package/dist/cjs/utils/common.js +13 -0
- package/dist/cjs/utils/common.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +3 -0
- package/dist/cjs/utils/index.js +7 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/network.d.ts +48 -0
- package/dist/cjs/utils/network.js +101 -0
- package/dist/cjs/utils/network.js.map +1 -0
- package/dist/helpers/CreditContractHelper.d.ts +77 -0
- package/dist/helpers/CreditContractHelper.js +170 -0
- package/dist/helpers/CreditContractHelper.js.map +1 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +2 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/services/HumaContextStellar.d.ts +19 -0
- package/dist/services/HumaContextStellar.js +43 -0
- package/dist/services/HumaContextStellar.js.map +1 -0
- package/dist/services/StellarWallet.d.ts +9 -0
- package/dist/services/StellarWallet.js +18 -0
- package/dist/services/StellarWallet.js.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +3 -0
- package/dist/services/index.js.map +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/utils/client.d.ts +10 -0
- package/dist/utils/client.js +56 -0
- package/dist/utils/client.js.map +1 -0
- package/dist/utils/common.d.ts +2 -0
- package/dist/utils/common.js +9 -0
- package/dist/utils/common.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/network.d.ts +48 -0
- package/dist/utils/network.js +98 -0
- package/dist/utils/network.js.map +1 -0
- package/package.json +107 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/utils/client.ts"],"names":[],"mappings":";;;AAAA,iFAAoF;AACpF,6DAAiE;AACjE,2EAA8E;AAC9E,6EAAgF;AAGhF,qCAA2C;AAC3C,uCAKkB;AAElB,MAAM,cAAc,GAAG,CAAC,OAAuB,EAAE,MAAqB,EAAE,EAAE;IACxE,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS;QACpC,iBAAiB,EAAE,kCAAwB,CAAC,OAAO,CAAC;QACpD,MAAM,EAAE,6BAAmB,CAAC,OAAO,CAAC;QACpC,SAAS,EAAE,6BAAmB,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC;QAC7D,eAAe,EAAE,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC;KACrD,CAAA;AACH,CAAC,CAAA;AAEM,MAAM,aAAa,GAAG,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nB,OAAuB,EACvB,MAAqB,EACrB,EAAE;IACF,MAAM,YAAY,GAAG,IAAA,yBAAgB,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACxD,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO,SAAS,CAAA;KACjB;IAED,OAAO,IAAI,+BAAmB,CAAC;QAC7B,UAAU,EAAE,YAAY,CAAC,SAAS,CAAC,aAAa;QAChD,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC;KACnC,CAAC,CAAA;AACJ,CAAC,CAAA;AAdY,QAAA,sBAAsB,0BAclC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findPoolMetadata = void 0;
|
|
4
|
+
const network_1 = require("./network");
|
|
5
|
+
const findPoolMetadata = (network, poolName) => {
|
|
6
|
+
const selectedNetworkMetadata = network_1.NetworkMetadatas.find((metadata) => metadata.network === network);
|
|
7
|
+
if (selectedNetworkMetadata) {
|
|
8
|
+
return selectedNetworkMetadata.pools.find((pool) => pool.poolName === poolName);
|
|
9
|
+
}
|
|
10
|
+
return undefined;
|
|
11
|
+
};
|
|
12
|
+
exports.findPoolMetadata = findPoolMetadata;
|
|
13
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":";;;AAAA,uCAA4D;AAErD,MAAM,gBAAgB,GAAG,CAAC,OAAuB,EAAE,QAAgB,EAAE,EAAE;IAC5E,MAAM,uBAAuB,GAAG,0BAAgB,CAAC,IAAI,CACnD,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,KAAK,OAAO,CAC3C,CAAA;IACD,IAAI,uBAAuB,EAAE;QAC3B,OAAO,uBAAuB,CAAC,KAAK,CAAC,IAAI,CACvC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,QAAQ,CACrC,CAAA;KACF;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAVY,QAAA,gBAAgB,oBAU5B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./client"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./common"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./network"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,mDAAwB;AACxB,mDAAwB;AACxB,oDAAyB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare enum StellarNetwork {
|
|
2
|
+
testnet = "testnet",
|
|
3
|
+
mainnet = "mainnet",
|
|
4
|
+
futurenet = "futurenet",
|
|
5
|
+
localnet = "localnet",
|
|
6
|
+
humanet = "humanet"
|
|
7
|
+
}
|
|
8
|
+
export declare enum StellarNetworkPassphrase {
|
|
9
|
+
mainnet = "Public Global Stellar Network ; September 2015",
|
|
10
|
+
testnet = "Test SDF Network ; September 2015",
|
|
11
|
+
futurenet = "Test SDF Future Network ; October 2022",
|
|
12
|
+
localnet = "Standalone Network ; February 2017",
|
|
13
|
+
humanet = "Standalone Network ; February 2017"
|
|
14
|
+
}
|
|
15
|
+
export declare enum StellarPublicRpcUrl {
|
|
16
|
+
mainnet = "https://horizon.stellar.org",
|
|
17
|
+
testnet = "https://soroban-testnet.stellar.org",
|
|
18
|
+
futurenet = "https://rpc-futurenet.stellar.org",
|
|
19
|
+
localnet = "http://localhost:8000/soroban/rpc",
|
|
20
|
+
humanet = "http://172.31.7.67:8000/soroban/rpc"
|
|
21
|
+
}
|
|
22
|
+
export declare enum POOL_NAME {
|
|
23
|
+
Arf = "Arf"
|
|
24
|
+
}
|
|
25
|
+
export declare enum POOL_TYPE {
|
|
26
|
+
Creditline = "Creditline"
|
|
27
|
+
}
|
|
28
|
+
export type PoolMetadata = {
|
|
29
|
+
poolName: POOL_NAME;
|
|
30
|
+
poolType: POOL_TYPE;
|
|
31
|
+
contracts: {
|
|
32
|
+
humaConfig: string;
|
|
33
|
+
poolStorage: string;
|
|
34
|
+
pool: string;
|
|
35
|
+
poolManager: string;
|
|
36
|
+
poolCredit: string;
|
|
37
|
+
creditStorage: string;
|
|
38
|
+
seniorTranche: string;
|
|
39
|
+
juniorTranche: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export type NetworkMetadata = {
|
|
43
|
+
network: StellarNetwork;
|
|
44
|
+
networkPassphrase: StellarNetworkPassphrase;
|
|
45
|
+
rpcUrl: StellarPublicRpcUrl;
|
|
46
|
+
pools: PoolMetadata[];
|
|
47
|
+
};
|
|
48
|
+
export declare const NetworkMetadatas: NetworkMetadata[];
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NetworkMetadatas = exports.POOL_TYPE = exports.POOL_NAME = exports.StellarPublicRpcUrl = exports.StellarNetworkPassphrase = exports.StellarNetwork = void 0;
|
|
4
|
+
var StellarNetwork;
|
|
5
|
+
(function (StellarNetwork) {
|
|
6
|
+
StellarNetwork["testnet"] = "testnet";
|
|
7
|
+
StellarNetwork["mainnet"] = "mainnet";
|
|
8
|
+
StellarNetwork["futurenet"] = "futurenet";
|
|
9
|
+
StellarNetwork["localnet"] = "localnet";
|
|
10
|
+
StellarNetwork["humanet"] = "humanet";
|
|
11
|
+
})(StellarNetwork = exports.StellarNetwork || (exports.StellarNetwork = {}));
|
|
12
|
+
var StellarNetworkPassphrase;
|
|
13
|
+
(function (StellarNetworkPassphrase) {
|
|
14
|
+
StellarNetworkPassphrase["mainnet"] = "Public Global Stellar Network ; September 2015";
|
|
15
|
+
StellarNetworkPassphrase["testnet"] = "Test SDF Network ; September 2015";
|
|
16
|
+
StellarNetworkPassphrase["futurenet"] = "Test SDF Future Network ; October 2022";
|
|
17
|
+
StellarNetworkPassphrase["localnet"] = "Standalone Network ; February 2017";
|
|
18
|
+
StellarNetworkPassphrase["humanet"] = "Standalone Network ; February 2017";
|
|
19
|
+
})(StellarNetworkPassphrase = exports.StellarNetworkPassphrase || (exports.StellarNetworkPassphrase = {}));
|
|
20
|
+
var StellarPublicRpcUrl;
|
|
21
|
+
(function (StellarPublicRpcUrl) {
|
|
22
|
+
StellarPublicRpcUrl["mainnet"] = "https://horizon.stellar.org";
|
|
23
|
+
StellarPublicRpcUrl["testnet"] = "https://soroban-testnet.stellar.org";
|
|
24
|
+
StellarPublicRpcUrl["futurenet"] = "https://rpc-futurenet.stellar.org";
|
|
25
|
+
StellarPublicRpcUrl["localnet"] = "http://localhost:8000/soroban/rpc";
|
|
26
|
+
StellarPublicRpcUrl["humanet"] = "http://172.31.7.67:8000/soroban/rpc";
|
|
27
|
+
})(StellarPublicRpcUrl = exports.StellarPublicRpcUrl || (exports.StellarPublicRpcUrl = {}));
|
|
28
|
+
var POOL_NAME;
|
|
29
|
+
(function (POOL_NAME) {
|
|
30
|
+
POOL_NAME["Arf"] = "Arf";
|
|
31
|
+
})(POOL_NAME = exports.POOL_NAME || (exports.POOL_NAME = {}));
|
|
32
|
+
var POOL_TYPE;
|
|
33
|
+
(function (POOL_TYPE) {
|
|
34
|
+
POOL_TYPE["Creditline"] = "Creditline";
|
|
35
|
+
})(POOL_TYPE = exports.POOL_TYPE || (exports.POOL_TYPE = {}));
|
|
36
|
+
exports.NetworkMetadatas = [
|
|
37
|
+
{
|
|
38
|
+
network: StellarNetwork.testnet,
|
|
39
|
+
networkPassphrase: StellarNetworkPassphrase.testnet,
|
|
40
|
+
rpcUrl: StellarPublicRpcUrl.testnet,
|
|
41
|
+
pools: [
|
|
42
|
+
{
|
|
43
|
+
poolName: POOL_NAME.Arf,
|
|
44
|
+
poolType: POOL_TYPE.Creditline,
|
|
45
|
+
contracts: {
|
|
46
|
+
humaConfig: 'CD6E7GFRHBQ627ZXK5YNMQFBBLFCXBBEU6VYXBSQ77CYOYQC5UV3HS76',
|
|
47
|
+
poolStorage: 'CAKPKH2G3ALGKW2E5BJFUJ6WR3RXJVGIXEAPVI5S6Q4HKSDCMKEYJSBR',
|
|
48
|
+
pool: 'CC2GGLIHX5E75QIXB7G27EOC47V74PXA33KGYDQH4DFISIVZPWQRBVJV',
|
|
49
|
+
poolManager: 'CC7TGDDRSA2R7F6RIW3POEZSH22RG7DYNZX6GY2YGQ2O33E5BZWSMPDT',
|
|
50
|
+
poolCredit: 'CBI7LGEWCJFO2APREGBRTUXB5JMZHJOVD76MESEB7V6W4IJ4ZLQJILDB',
|
|
51
|
+
creditStorage: 'CCQMDMB2J6XRPZKG4QYNSXNN6W56HH5QCQXM6MDIW7ZEJRYSLL2ZEG2U',
|
|
52
|
+
juniorTranche: 'CDXI5L5EFHBW3KYY3D6JGXJTGDOG5EZAQUDAK5LWZQVH4TEUDAO7PBGU',
|
|
53
|
+
seniorTranche: 'CDFZVYABKBUBCNBW4NLTZ63JWPZFE677PQOXRZLBCKSY6MDB5CHR2IJ2',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
network: StellarNetwork.localnet,
|
|
60
|
+
networkPassphrase: StellarNetworkPassphrase.localnet,
|
|
61
|
+
rpcUrl: StellarPublicRpcUrl.localnet,
|
|
62
|
+
pools: [
|
|
63
|
+
{
|
|
64
|
+
poolName: POOL_NAME.Arf,
|
|
65
|
+
poolType: POOL_TYPE.Creditline,
|
|
66
|
+
contracts: {
|
|
67
|
+
humaConfig: 'CAYSSYDIRAFM4FIZ2RFGCCLUJZODOEGPB3GYE5ECIMOAUZKWHTR33UK7',
|
|
68
|
+
poolStorage: 'CBUPUVI4HVE6DY2QGISUP72Z77E3QFWCKMJBMOYI27MGG6E5UZCSEDQU',
|
|
69
|
+
pool: 'CASFU6P33UERVBV7XSWJ6JHKTLZBAYL2UEWRSP77V4F27OHXS4O4OHML',
|
|
70
|
+
poolManager: 'CDBZYAXIHNGPRAHOQU53AILDMSUO5UENFSCNHNT2ABXGLC2MEJ6RPV33',
|
|
71
|
+
poolCredit: 'CAC6ZM2HT2JVNS3TZ2LYVJ6JDR724J2SOV63YIWMP2RSLYA64EB5C7JH',
|
|
72
|
+
creditStorage: 'CCPTCRU7FUVQLNR4GGUBWQDHJCQTW3MXDZQYQQGB4OC2PNME7HNIV3R3',
|
|
73
|
+
juniorTranche: 'CD4TNCKN7PDNOBS2JHEXRXPHOL327EX4Z7EURDG2XFWBZ67XG5XW5Q7O',
|
|
74
|
+
seniorTranche: 'CDOB4BPE2AKSZYW27QP4IYVIIGVQD3C7E7YL6XRZ2ANM7MYJT2TKOVPC',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
network: StellarNetwork.humanet,
|
|
81
|
+
networkPassphrase: StellarNetworkPassphrase.humanet,
|
|
82
|
+
rpcUrl: StellarPublicRpcUrl.humanet,
|
|
83
|
+
pools: [
|
|
84
|
+
{
|
|
85
|
+
poolName: POOL_NAME.Arf,
|
|
86
|
+
poolType: POOL_TYPE.Creditline,
|
|
87
|
+
contracts: {
|
|
88
|
+
humaConfig: 'CDUARGZAEFXOLWPDVCYZ5Y4QD7ISG5QZL36CUVCYLGE22S4U2FQC7T5L',
|
|
89
|
+
poolStorage: 'CBO432DNOGKONUPMKY3FMN2XDOXQO6YF32RWU3AYEE6FE3ABNTLZ44AY',
|
|
90
|
+
pool: 'CDZ5RPSAEV52JRPNF5MIFIUSGPFETOB5GB4ZMHGDOYHNAMXZ6EZYYEIP',
|
|
91
|
+
poolManager: 'CDAWXL4EEOTBKRMYPCRD4SHXJ5QW2ZCYWI64P6SWMRVPEQCL7GCENDNO',
|
|
92
|
+
poolCredit: 'CC5QODELURRO4KUIHZ6IIDDDMKQ2DCUBANVEPFWC7MLGVGCGVIYRDDOZ',
|
|
93
|
+
creditStorage: 'CB2X3E7FBKWAG6EYSTKIMCSNNLM3FFVZVEWPNQVHOVTQER24DMHYYIBV',
|
|
94
|
+
juniorTranche: 'CCGIZUQOMU6FINZQHBSXTYWLGQNW2UEZD7ZSMEFHJKHJPHS64YZFDFZP',
|
|
95
|
+
seniorTranche: 'CBC2OBQATLC27ZCN2IR7YG33KL2J75O6PYJV33FPB6ZBFGJKWRZF6MVT',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
//# sourceMappingURL=network.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/utils/network.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,qCAAmB,CAAA;IACnB,yCAAuB,CAAA;IACvB,uCAAqB,CAAA;IACrB,qCAAmB,CAAA;AACrB,CAAC,EANW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAMzB;AAED,IAAY,wBAMX;AAND,WAAY,wBAAwB;IAClC,sFAA0D,CAAA;IAC1D,yEAA6C,CAAA;IAC7C,gFAAoD,CAAA;IACpD,2EAA+C,CAAA;IAC/C,0EAA8C,CAAA;AAChD,CAAC,EANW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAMnC;AAED,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC7B,8DAAuC,CAAA;IACvC,sEAA+C,CAAA;IAC/C,sEAA+C,CAAA;IAC/C,qEAA8C,CAAA;IAC9C,sEAA+C,CAAA;AACjD,CAAC,EANW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAM9B;AAED,IAAY,SAEX;AAFD,WAAY,SAAS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,iBAAiB,EAAE,wBAAwB,CAAC,OAAO;QACnD,MAAM,EAAE,mBAAmB,CAAC,OAAO;QACnC,KAAK,EAAE;YACL;gBACE,QAAQ,EAAE,SAAS,CAAC,GAAG;gBACvB,QAAQ,EAAE,SAAS,CAAC,UAAU;gBAC9B,SAAS,EAAE;oBACT,UAAU,EACR,0DAA0D;oBAC5D,WAAW,EACT,0DAA0D;oBAC5D,IAAI,EAAE,0DAA0D;oBAChE,WAAW,EACT,0DAA0D;oBAC5D,UAAU,EACR,0DAA0D;oBAC5D,aAAa,EACX,0DAA0D;oBAC5D,aAAa,EACX,0DAA0D;oBAC5D,aAAa,EACX,0DAA0D;iBAC7D;aACF;SACF;KACF;CACF,CAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Client as PoolCreditClient, CreditRecord, SentTransaction } from '@huma-finance/soroban-pool-credit';
|
|
2
|
+
import { StellarWallet } from '../services/StellarWallet';
|
|
3
|
+
import { POOL_NAME, StellarNetwork } from '../utils/network';
|
|
4
|
+
/**
|
|
5
|
+
* Returns an soroban contract client instance for the credit line contract
|
|
6
|
+
* associated with the given pool name on the current chain.
|
|
7
|
+
*
|
|
8
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
9
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
10
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
11
|
+
* @returns {PoolCreditClient | undefined} A contract client instance for the CreditLine contract or undefined if it could not be found.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getCreditLineClient(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet): PoolCreditClient | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the current pool balance available for borrowing
|
|
16
|
+
*
|
|
17
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
18
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
19
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getAvailableBalanceForPool(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet): Promise<bigint>;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the credit record of the borrower
|
|
24
|
+
*
|
|
25
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
26
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
27
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
28
|
+
* @param {string} borrower - The address of the borrower to check the credit record for.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getCreditRecordForPool(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, borrower: string): Promise<CreditRecord>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the borrower's remaining credit they can use for borrowing. Note that this might not be
|
|
33
|
+
* currently available for borrowing as the credit limit might exceed the available pool balance. Use
|
|
34
|
+
* getPoolBalance() to get the current available pool balance.
|
|
35
|
+
*
|
|
36
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
37
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
38
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
39
|
+
* @param {string} borrower - The address of the borrower to check the available credit for.
|
|
40
|
+
*/
|
|
41
|
+
export declare function getAvailableCreditForPool(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, borrower: string): Promise<bigint>;
|
|
42
|
+
/**
|
|
43
|
+
* Returns borrower's total due amount in bigint format
|
|
44
|
+
* associated with the given pool name on the current chain.
|
|
45
|
+
*
|
|
46
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
47
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
48
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
49
|
+
* @param {string} borrower - The address of the borrower to check the available credit for.
|
|
50
|
+
* @returns {bigint | null} The account's total due amount in bigint format
|
|
51
|
+
*/
|
|
52
|
+
export declare function getTotalDue(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, borrower: string): Promise<bigint | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Draws down from a pool.
|
|
55
|
+
*
|
|
56
|
+
* @async
|
|
57
|
+
* @function
|
|
58
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
59
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
60
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
61
|
+
* @param {BigNumberish} drawdownAmount - The amount to drawdown.
|
|
62
|
+
* @returns {Promise<SentTransaction>} - A Promise of the SentTransaction.
|
|
63
|
+
*/
|
|
64
|
+
export declare function drawdown(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, drawdownAmount: bigint): Promise<SentTransaction<null>>;
|
|
65
|
+
/**
|
|
66
|
+
* Makes a payment.
|
|
67
|
+
*
|
|
68
|
+
* @async
|
|
69
|
+
* @function
|
|
70
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
71
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
72
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
73
|
+
* @param {bigint} paymentAmount - The amount to payback.
|
|
74
|
+
* @param {boolean} principalOnly - Whether this payment should ONLY apply to the principal
|
|
75
|
+
* @returns {Promise<AssembledTransaction>} - A Promise of the AssembledTransaction.
|
|
76
|
+
*/
|
|
77
|
+
export declare function makePayment(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, paymentAmount: bigint, principalOnly: boolean): Promise<SentTransaction<readonly [bigint, boolean]>>;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { getCreditStorageClient, getPoolCreditClient, getPoolStorageClient, } from '../utils/client';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an soroban contract client instance for the credit line contract
|
|
4
|
+
* associated with the given pool name on the current chain.
|
|
5
|
+
*
|
|
6
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
7
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
8
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
9
|
+
* @returns {PoolCreditClient | undefined} A contract client instance for the CreditLine contract or undefined if it could not be found.
|
|
10
|
+
*/
|
|
11
|
+
export function getCreditLineClient(poolName, network, wallet) {
|
|
12
|
+
return getPoolCreditClient(poolName, network, wallet);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Returns the current pool balance available for borrowing
|
|
16
|
+
*
|
|
17
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
18
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
19
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
20
|
+
*/
|
|
21
|
+
export async function getAvailableBalanceForPool(poolName, network, wallet) {
|
|
22
|
+
const poolStorageClient = getPoolStorageClient(poolName, network, wallet);
|
|
23
|
+
if (!poolStorageClient) {
|
|
24
|
+
throw new Error('Could not find credit contract for pool');
|
|
25
|
+
}
|
|
26
|
+
const { result } = await poolStorageClient.get_available_balance();
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns the credit record of the borrower
|
|
31
|
+
*
|
|
32
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
33
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
34
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
35
|
+
* @param {string} borrower - The address of the borrower to check the credit record for.
|
|
36
|
+
*/
|
|
37
|
+
export async function getCreditRecordForPool(poolName, network, wallet, borrower) {
|
|
38
|
+
const creditStorageClient = getCreditStorageClient(poolName, network, wallet);
|
|
39
|
+
if (!creditStorageClient) {
|
|
40
|
+
throw new Error('Could not find credit storage contract for pool');
|
|
41
|
+
}
|
|
42
|
+
const { result: creditHash } = await creditStorageClient.get_credit_hash({
|
|
43
|
+
borrower,
|
|
44
|
+
});
|
|
45
|
+
if (!creditHash) {
|
|
46
|
+
throw new Error('Could not find credit hash');
|
|
47
|
+
}
|
|
48
|
+
const { result: creditRecord } = await creditStorageClient.get_credit_record({
|
|
49
|
+
credit_hash: creditHash,
|
|
50
|
+
});
|
|
51
|
+
if (!creditRecord) {
|
|
52
|
+
throw new Error('Could not find credit record');
|
|
53
|
+
}
|
|
54
|
+
return creditRecord;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns the borrower's remaining credit they can use for borrowing. Note that this might not be
|
|
58
|
+
* currently available for borrowing as the credit limit might exceed the available pool balance. Use
|
|
59
|
+
* getPoolBalance() to get the current available pool balance.
|
|
60
|
+
*
|
|
61
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
62
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
63
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
64
|
+
* @param {string} borrower - The address of the borrower to check the available credit for.
|
|
65
|
+
*/
|
|
66
|
+
export async function getAvailableCreditForPool(poolName, network, wallet, borrower) {
|
|
67
|
+
const creditStorageClient = getCreditStorageClient(poolName, network, wallet);
|
|
68
|
+
if (!creditStorageClient) {
|
|
69
|
+
throw new Error('Could not find credit storage contract for pool');
|
|
70
|
+
}
|
|
71
|
+
const { result: creditHash } = await creditStorageClient.get_credit_hash({
|
|
72
|
+
borrower,
|
|
73
|
+
});
|
|
74
|
+
if (!creditHash) {
|
|
75
|
+
throw new Error('Could not find credit hash');
|
|
76
|
+
}
|
|
77
|
+
const [{ result: creditConfig }, { result: creditRecord }] = await Promise.all([
|
|
78
|
+
creditStorageClient.get_credit_config({
|
|
79
|
+
credit_hash: creditHash,
|
|
80
|
+
}),
|
|
81
|
+
creditStorageClient.get_credit_record({
|
|
82
|
+
credit_hash: creditHash,
|
|
83
|
+
}),
|
|
84
|
+
]);
|
|
85
|
+
if (!creditConfig || !creditRecord) {
|
|
86
|
+
throw new Error('Could not find credit config or credit record');
|
|
87
|
+
}
|
|
88
|
+
return creditConfig.credit_limit - creditRecord.unbilled_principal;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns borrower's total due amount in bigint format
|
|
92
|
+
* associated with the given pool name on the current chain.
|
|
93
|
+
*
|
|
94
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
95
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
96
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
97
|
+
* @param {string} borrower - The address of the borrower to check the available credit for.
|
|
98
|
+
* @returns {bigint | null} The account's total due amount in bigint format
|
|
99
|
+
*/
|
|
100
|
+
export async function getTotalDue(poolName, network, wallet, borrower) {
|
|
101
|
+
const creditRecord = await getCreditRecordForPool(poolName, network, wallet, borrower);
|
|
102
|
+
if (!creditRecord) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return creditRecord.next_due + creditRecord.total_past_due;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Draws down from a pool.
|
|
109
|
+
*
|
|
110
|
+
* @async
|
|
111
|
+
* @function
|
|
112
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
113
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
114
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
115
|
+
* @param {BigNumberish} drawdownAmount - The amount to drawdown.
|
|
116
|
+
* @returns {Promise<SentTransaction>} - A Promise of the SentTransaction.
|
|
117
|
+
*/
|
|
118
|
+
export async function drawdown(poolName, network, wallet, drawdownAmount) {
|
|
119
|
+
const poolCreditClient = getPoolCreditClient(poolName, network, wallet);
|
|
120
|
+
if (!poolCreditClient) {
|
|
121
|
+
throw new Error('Could not find credit contract for pool');
|
|
122
|
+
}
|
|
123
|
+
const tx = await poolCreditClient.drawdown({
|
|
124
|
+
borrower: wallet.userInfo.publicKey,
|
|
125
|
+
amount: drawdownAmount,
|
|
126
|
+
}, {
|
|
127
|
+
timeoutInSeconds: 30,
|
|
128
|
+
});
|
|
129
|
+
const result = await tx.signAndSend();
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Makes a payment.
|
|
134
|
+
*
|
|
135
|
+
* @async
|
|
136
|
+
* @function
|
|
137
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
138
|
+
* @param {StellarNetwork} network - The stellar network.
|
|
139
|
+
* @param {StellarWallet} wallet - The stellar wallet.
|
|
140
|
+
* @param {bigint} paymentAmount - The amount to payback.
|
|
141
|
+
* @param {boolean} principalOnly - Whether this payment should ONLY apply to the principal
|
|
142
|
+
* @returns {Promise<AssembledTransaction>} - A Promise of the AssembledTransaction.
|
|
143
|
+
*/
|
|
144
|
+
export async function makePayment(poolName, network, wallet, paymentAmount, principalOnly) {
|
|
145
|
+
const poolCreditClient = getPoolCreditClient(poolName, network, wallet);
|
|
146
|
+
if (!poolCreditClient) {
|
|
147
|
+
throw new Error('Could not find credit contract for pool');
|
|
148
|
+
}
|
|
149
|
+
let tx;
|
|
150
|
+
if (principalOnly) {
|
|
151
|
+
tx = await poolCreditClient.make_principal_payment({
|
|
152
|
+
borrower: wallet.userInfo.publicKey,
|
|
153
|
+
amount: paymentAmount,
|
|
154
|
+
}, {
|
|
155
|
+
timeoutInSeconds: 30,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
tx = await poolCreditClient.make_payment({
|
|
160
|
+
caller: wallet.userInfo.publicKey,
|
|
161
|
+
borrower: wallet.userInfo.publicKey,
|
|
162
|
+
amount: paymentAmount,
|
|
163
|
+
}, {
|
|
164
|
+
timeoutInSeconds: 30,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
const result = await tx.signAndSend();
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=CreditContractHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CreditContractHelper.js","sourceRoot":"","sources":["../../src/helpers/CreditContractHel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ACtB,EACD;YACE,gBAAgB,EAAE,EAAE;SACrB,CACF,CAAA;KACF;SAAM;QACL,EAAE,GAAG,MAAM,gBAAgB,CAAC,YAAY,CACtC;YACE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS;YACjC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS;YACnC,MAAM,EAAE,aAAa;SACtB,EACD;YACE,gBAAgB,EAAE,EAAE;SACrB,CACF,CAAA;KACF;IAED,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,WAAW,EAAE,CAAA;IACrC,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CreditContractHelper';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StellarNetwork, POOL_NAME, POOL_TYPE } from '../utils/network';
|
|
2
|
+
import { StellarWallet } from './StellarWallet';
|
|
3
|
+
export declare class HumaContextStellar {
|
|
4
|
+
#private;
|
|
5
|
+
constructor({ wallet, network, poolName, poolType, }: {
|
|
6
|
+
wallet: StellarWallet;
|
|
7
|
+
network: StellarNetwork;
|
|
8
|
+
poolName: POOL_NAME;
|
|
9
|
+
poolType: POOL_TYPE;
|
|
10
|
+
});
|
|
11
|
+
get wallet(): StellarWallet;
|
|
12
|
+
set wallet(value: StellarWallet);
|
|
13
|
+
get network(): StellarNetwork;
|
|
14
|
+
set network(value: StellarNetwork);
|
|
15
|
+
get poolName(): POOL_NAME;
|
|
16
|
+
set poolName(value: POOL_NAME);
|
|
17
|
+
get poolType(): POOL_TYPE;
|
|
18
|
+
set poolType(value: POOL_TYPE);
|
|
19
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var _HumaContextStellar_wallet, _HumaContextStellar_network, _HumaContextStellar_poolName, _HumaContextStellar_poolType;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
+
export class HumaContextStellar {
|
|
4
|
+
constructor({ wallet, network, poolName, poolType, }) {
|
|
5
|
+
_HumaContextStellar_wallet.set(this, void 0);
|
|
6
|
+
_HumaContextStellar_network.set(this, void 0);
|
|
7
|
+
_HumaContextStellar_poolName.set(this, void 0);
|
|
8
|
+
_HumaContextStellar_poolType.set(this, void 0);
|
|
9
|
+
if (!wallet || !network || !poolName || !poolType) {
|
|
10
|
+
throw new Error('All parameters are required');
|
|
11
|
+
}
|
|
12
|
+
__classPrivateFieldSet(this, _HumaContextStellar_wallet, wallet, "f");
|
|
13
|
+
__classPrivateFieldSet(this, _HumaContextStellar_network, network, "f");
|
|
14
|
+
__classPrivateFieldSet(this, _HumaContextStellar_poolName, poolName, "f");
|
|
15
|
+
__classPrivateFieldSet(this, _HumaContextStellar_poolType, poolType, "f");
|
|
16
|
+
}
|
|
17
|
+
get wallet() {
|
|
18
|
+
return __classPrivateFieldGet(this, _HumaContextStellar_wallet, "f");
|
|
19
|
+
}
|
|
20
|
+
set wallet(value) {
|
|
21
|
+
__classPrivateFieldSet(this, _HumaContextStellar_wallet, value, "f");
|
|
22
|
+
}
|
|
23
|
+
get network() {
|
|
24
|
+
return __classPrivateFieldGet(this, _HumaContextStellar_network, "f");
|
|
25
|
+
}
|
|
26
|
+
set network(value) {
|
|
27
|
+
__classPrivateFieldSet(this, _HumaContextStellar_network, value, "f");
|
|
28
|
+
}
|
|
29
|
+
get poolName() {
|
|
30
|
+
return __classPrivateFieldGet(this, _HumaContextStellar_poolName, "f");
|
|
31
|
+
}
|
|
32
|
+
set poolName(value) {
|
|
33
|
+
__classPrivateFieldSet(this, _HumaContextStellar_poolName, value, "f");
|
|
34
|
+
}
|
|
35
|
+
get poolType() {
|
|
36
|
+
return __classPrivateFieldGet(this, _HumaContextStellar_poolType, "f");
|
|
37
|
+
}
|
|
38
|
+
set poolType(value) {
|
|
39
|
+
__classPrivateFieldSet(this, _HumaContextStellar_poolType, value, "f");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
_HumaContextStellar_wallet = new WeakMap(), _HumaContextStellar_network = new WeakMap(), _HumaContextStellar_poolName = new WeakMap(), _HumaContextStellar_poolType = new WeakMap();
|
|
43
|
+
//# sourceMappingURL=HumaContextStellar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HumaContextStellar.js","sourceRoot":"","sources":["../../src/services/HumaContextStellar.ts"],"names":[],"mappings":";;AAGA,MAAM,OAAO,kBAAkB;IAS7B,YAAY,EACV,MAAM,EACN,OAAO,EACP,QAAQ,EACR,QAAQ,GAMT;QAlBD,6CAAsB;QAEtB,8CAAwB;QAExB,+CAAoB;QAEpB,+CAAoB;QAalB,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,EAAE;YACjD,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;SAC/C;QAED,uBAAA,IAAI,8BAAW,MAAM,MAAA,CAAA;QACrB,uBAAA,IAAI,+BAAY,OAAO,MAAA,CAAA;QACvB,uBAAA,IAAI,gCAAa,QAAQ,MAAA,CAAA;QACzB,uBAAA,IAAI,gCAAa,QAAQ,MAAA,CAAA;IAC3B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,uBAAA,IAAI,kCAAQ,CAAA;IACrB,CAAC;IAED,IAAI,MAAM,CAAC,KAAoB;QAC7B,uBAAA,IAAI,8BAAW,KAAK,MAAA,CAAA;IACtB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,uBAAA,IAAI,mCAAS,CAAA;IACtB,CAAC;IAED,IAAI,OAAO,CAAC,KAAqB;QAC/B,uBAAA,IAAI,+BAAY,KAAK,MAAA,CAAA;IACvB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,uBAAA,IAAI,oCAAU,CAAA;IACvB,CAAC;IAED,IAAI,QAAQ,CAAC,KAAgB;QAC3B,uBAAA,IAAI,gCAAa,KAAK,MAAA,CAAA;IACxB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,uBAAA,IAAI,oCAAU,CAAA;IACvB,CAAC;IAED,IAAI,QAAQ,CAAC,KAAgB;QAC3B,uBAAA,IAAI,gCAAa,KAAK,MAAA,CAAA;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Keypair, Transaction } from '@stellar/stellar-sdk';
|
|
2
|
+
export class StellarWallet {
|
|
3
|
+
constructor(secretKey) {
|
|
4
|
+
this.sourceKeypair = Keypair.fromSecret(secretKey);
|
|
5
|
+
}
|
|
6
|
+
get userInfo() {
|
|
7
|
+
return {
|
|
8
|
+
publicKey: this.sourceKeypair.publicKey(),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
async signTransaction(tx, opts) {
|
|
13
|
+
const txFromXDR = new Transaction(tx, opts.networkPassphrase);
|
|
14
|
+
txFromXDR.sign(this.sourceKeypair);
|
|
15
|
+
return txFromXDR.toXDR();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=StellarWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StellarWallet.js","sourceRoot":"","sources":["../../src/services/StellarWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAE3D,MAAM,OAAO,aAAa;IAGxB,YAAY,SAAiB;QAC3B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;IACpD,CAAC;IAED,IAAI,QAAQ;QACV,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE;SAC1C,CAAA;IACH,CAAC;IAED,8DAA8D;IACvD,KAAK,CAAC,eAAe,CAAC,EAAU,EAAE,IAAS;QAChD,MAAM,SAAS,GAAG,IAAI,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAA;QAC7D,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QAClC,OAAO,SAAS,CAAC,KAAK,EAAE,CAAA;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA"}
|