@huma-finance/soroban-sdk 0.0.15-beta.51 → 0.0.15-beta.56
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 +7 -14
- package/dist/cjs/helpers/CreditContractHelper.d.ts +3 -5
- package/dist/cjs/helpers/CreditContractHelper.js +2 -4
- package/dist/cjs/helpers/Sep41ContractHelper.d.ts +2 -5
- package/dist/cjs/helpers/Sep41ContractHelper.js +25 -47
- package/dist/cjs/helpers/index.js +0 -1
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/services/HumaContextStellar.js +16 -20
- package/dist/cjs/services/StellarWallet.js +5 -9
- package/dist/cjs/services/index.js +0 -1
- package/dist/cjs/utils/client.js +12 -16
- package/dist/cjs/utils/common.js +0 -1
- package/dist/cjs/utils/index.js +0 -1
- package/dist/cjs/utils/network.js +1 -2
- package/dist/cjs/utils/transaction.d.ts +2 -3
- package/dist/cjs/utils/transaction.js +0 -1
- package/dist/helpers/CreditContractHelper.d.ts +3 -5
- package/dist/helpers/CreditContractHelper.js +47 -38
- package/dist/helpers/CreditContractHelper.js.map +1 -1
- package/dist/helpers/Sep41ContractHelper.d.ts +2 -5
- package/dist/helpers/Sep41ContractHelper.js +31 -48
- package/dist/helpers/Sep41ContractHelper.js.map +1 -1
- package/dist/helpers/index.js +5 -2
- package/dist/helpers/index.js.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/services/HumaContextStellar.js +21 -20
- package/dist/services/HumaContextStellar.js.map +1 -1
- package/dist/services/StellarWallet.js +12 -11
- package/dist/services/StellarWallet.js.map +1 -1
- package/dist/services/index.js +5 -2
- package/dist/services/index.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/utils/client.js +69 -61
- package/dist/utils/client.js.map +1 -1
- package/dist/utils/common.js +25 -19
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/index.js +7 -4
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/network.js +15 -12
- package/dist/utils/network.js.map +1 -1
- package/dist/utils/transaction.d.ts +2 -3
- package/dist/utils/transaction.js +39 -31
- package/dist/utils/transaction.js.map +1 -1
- package/package.json +12 -11
- package/dist/cjs/helpers/CreditContractHelper.js.map +0 -1
- package/dist/cjs/helpers/Sep41ContractHelper.js.map +0 -1
- package/dist/cjs/helpers/index.js.map +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/services/HumaContextStellar.js.map +0 -1
- package/dist/cjs/services/StellarWallet.js.map +0 -1
- package/dist/cjs/services/index.js.map +0 -1
- package/dist/cjs/utils/client.js.map +0 -1
- package/dist/cjs/utils/common.js.map +0 -1
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/network.js.map +0 -1
- package/dist/cjs/utils/transaction.js.map +0 -1
package/API.md
CHANGED
|
@@ -12,14 +12,14 @@ getPoolBalance() to get the current available pool balance.</p></dd>
|
|
|
12
12
|
<dt><a href="#getTotalDue">getTotalDue(poolName, network, wallet, borrower)</a> ⇒ <code>bigint</code> | <code>null</code></dt>
|
|
13
13
|
<dd><p>Returns borrower's total due amount in bigint format
|
|
14
14
|
associated with the given pool name on the current chain.</p></dd>
|
|
15
|
-
<dt><a href="#approveAllowanceForSentinel">approveAllowanceForSentinel(poolName, network, wallet)</a
|
|
15
|
+
<dt><a href="#approveAllowanceForSentinel">approveAllowanceForSentinel(poolName, network, wallet)</a></dt>
|
|
16
16
|
<dd><p>Approve allowance for sentinel if not enough allowance is approved.</p></dd>
|
|
17
17
|
<dt><a href="#drawdown">drawdown(poolName, network, wallet, drawdownAmount)</a> ⇒ <code>Promise.<SentTransaction></code></dt>
|
|
18
18
|
<dd><p>Draws down from a pool.</p></dd>
|
|
19
19
|
<dt><a href="#makePayment">makePayment(poolName, network, wallet, paymentAmount, principalOnly)</a> ⇒ <code>Promise.<SentTransaction></code></dt>
|
|
20
20
|
<dd><p>Makes a payment.</p></dd>
|
|
21
|
-
<dt><a href="#
|
|
22
|
-
<dd><p>Approves an Sep41 allowance for a spender address
|
|
21
|
+
<dt><a href="#approveSep41Allowance">approveSep41Allowance(poolName, network, wallet, spenderAddress)</a></dt>
|
|
22
|
+
<dd><p>Approves an Sep41 allowance for a spender address.
|
|
23
23
|
Allowance is required to do certain actions on the Huma protocol (e.g. makePayment for Autopay)</p></dd>
|
|
24
24
|
</dl>
|
|
25
25
|
|
|
@@ -84,13 +84,10 @@ associated with the given pool name on the current chain.</p>
|
|
|
84
84
|
|
|
85
85
|
<a name="approveAllowanceForSentinel"></a>
|
|
86
86
|
|
|
87
|
-
## approveAllowanceForSentinel(poolName, network, wallet)
|
|
87
|
+
## approveAllowanceForSentinel(poolName, network, wallet)
|
|
88
88
|
<p>Approve allowance for sentinel if not enough allowance is approved.</p>
|
|
89
89
|
|
|
90
90
|
**Kind**: global function
|
|
91
|
-
**Returns**: <code>Promise.<SentTransaction></code> - <ul>
|
|
92
|
-
<li>A Promise of the SentTransaction.</li>
|
|
93
|
-
</ul>
|
|
94
91
|
|
|
95
92
|
| Param | Type | Description |
|
|
96
93
|
| --- | --- | --- |
|
|
@@ -133,16 +130,13 @@ associated with the given pool name on the current chain.</p>
|
|
|
133
130
|
| paymentAmount | <code>bigint</code> | <p>The amount to payback.</p> |
|
|
134
131
|
| principalOnly | <code>boolean</code> | <p>Whether this payment should ONLY apply to the principal</p> |
|
|
135
132
|
|
|
136
|
-
<a name="
|
|
133
|
+
<a name="approveSep41Allowance"></a>
|
|
137
134
|
|
|
138
|
-
##
|
|
139
|
-
<p>Approves an Sep41 allowance for a spender address
|
|
135
|
+
## approveSep41Allowance(poolName, network, wallet, spenderAddress)
|
|
136
|
+
<p>Approves an Sep41 allowance for a spender address.
|
|
140
137
|
Allowance is required to do certain actions on the Huma protocol (e.g. makePayment for Autopay)</p>
|
|
141
138
|
|
|
142
139
|
**Kind**: global function
|
|
143
|
-
**Returns**: <code>Promise.<(SentTransaction.<null>\|null)></code> - <ul>
|
|
144
|
-
<li>A Promise of the transaction response, or null if the allowance was already sufficient.</li>
|
|
145
|
-
</ul>
|
|
146
140
|
|
|
147
141
|
| Param | Type | Description |
|
|
148
142
|
| --- | --- | --- |
|
|
@@ -150,5 +144,4 @@ Allowance is required to do certain actions on the Huma protocol (e.g. makePayme
|
|
|
150
144
|
| network | <code>StellarNetwork</code> | <p>The stellar network.</p> |
|
|
151
145
|
| wallet | <code>StellarWallet</code> | <p>The wallet used to send the transaction.</p> |
|
|
152
146
|
| spenderAddress | <code>string</code> | <p>The address of the spender to approve an allowance for.</p> |
|
|
153
|
-
| allowanceAmount | <code>bigint</code> | <p>The amount of tokens to approve, if applicable. Denominated in the Sep41 tokens.</p> |
|
|
154
147
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CreditRecord } from '@huma-finance/soroban-pool-credit';
|
|
2
|
-
import { SentTransaction } from '@stellar/stellar-sdk/lib/contract';
|
|
3
2
|
import { StellarWallet } from '../services';
|
|
4
3
|
import { POOL_NAME, StellarNetwork } from '../utils';
|
|
5
4
|
/**
|
|
@@ -49,9 +48,8 @@ export declare function getTotalDue(poolName: POOL_NAME, network: StellarNetwork
|
|
|
49
48
|
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
50
49
|
* @param {StellarNetwork} network - The stellar network.
|
|
51
50
|
* @param {StellarWallet} wallet - The stellar wallet.
|
|
52
|
-
* @returns {Promise<SentTransaction>} - A Promise of the SentTransaction.
|
|
53
51
|
*/
|
|
54
|
-
export declare function approveAllowanceForSentinel(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet): Promise<
|
|
52
|
+
export declare function approveAllowanceForSentinel(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet): Promise<any>;
|
|
55
53
|
/**
|
|
56
54
|
* Draws down from a pool.
|
|
57
55
|
*
|
|
@@ -63,7 +61,7 @@ export declare function approveAllowanceForSentinel(poolName: POOL_NAME, network
|
|
|
63
61
|
* @param {BigNumberish} drawdownAmount - The amount to drawdown.
|
|
64
62
|
* @returns {Promise<SentTransaction>} - A Promise of the SentTransaction.
|
|
65
63
|
*/
|
|
66
|
-
export declare function drawdown(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, drawdownAmount: bigint): Promise<
|
|
64
|
+
export declare function drawdown(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, drawdownAmount: bigint): Promise<any>;
|
|
67
65
|
/**
|
|
68
66
|
* Makes a payment.
|
|
69
67
|
*
|
|
@@ -76,4 +74,4 @@ export declare function drawdown(poolName: POOL_NAME, network: StellarNetwork, w
|
|
|
76
74
|
* @param {boolean} principalOnly - Whether this payment should ONLY apply to the principal
|
|
77
75
|
* @returns {Promise<SentTransaction>} - A Promise of the SentTransaction.
|
|
78
76
|
*/
|
|
79
|
-
export declare function makePayment(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, paymentAmount: bigint, principalOnly: boolean): Promise<
|
|
77
|
+
export declare function makePayment(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, paymentAmount: bigint, principalOnly: boolean): Promise<any>;
|
|
@@ -133,7 +133,6 @@ exports.getTotalDue = getTotalDue;
|
|
|
133
133
|
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
134
134
|
* @param {StellarNetwork} network - The stellar network.
|
|
135
135
|
* @param {StellarWallet} wallet - The stellar wallet.
|
|
136
|
-
* @returns {Promise<SentTransaction>} - A Promise of the SentTransaction.
|
|
137
136
|
*/
|
|
138
137
|
async function approveAllowanceForSentinel(poolName, network, wallet) {
|
|
139
138
|
const totalDue = await getTotalDue(poolName, network, wallet, wallet.userInfo.publicKey);
|
|
@@ -145,7 +144,7 @@ async function approveAllowanceForSentinel(poolName, network, wallet) {
|
|
|
145
144
|
context: poolStorageContext,
|
|
146
145
|
method: 'get_sentinel',
|
|
147
146
|
});
|
|
148
|
-
const tx = await (0, Sep41ContractHelper_1.
|
|
147
|
+
const tx = await (0, Sep41ContractHelper_1.approveSep41Allowance)(poolName, network, wallet, sentinel);
|
|
149
148
|
return tx;
|
|
150
149
|
}
|
|
151
150
|
exports.approveAllowanceForSentinel = approveAllowanceForSentinel;
|
|
@@ -202,7 +201,7 @@ async function makePayment(poolName, network, wallet, paymentAmount, principalOn
|
|
|
202
201
|
context: poolStorageContext,
|
|
203
202
|
method: 'get_sentinel',
|
|
204
203
|
});
|
|
205
|
-
await (0, Sep41ContractHelper_1.
|
|
204
|
+
await (0, Sep41ContractHelper_1.approveSep41Allowance)(poolName, network, wallet, sentinel);
|
|
206
205
|
const poolCreditContext = new utils_1.TransactionContext(poolName, network, wallet, 'poolCredit');
|
|
207
206
|
const params = [
|
|
208
207
|
{
|
|
@@ -232,4 +231,3 @@ async function makePayment(poolName, network, wallet, paymentAmount, principalOn
|
|
|
232
231
|
return result;
|
|
233
232
|
}
|
|
234
233
|
exports.makePayment = makePayment;
|
|
235
|
-
//# sourceMappingURL=CreditContractHelper.js.map
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { SentTransaction } from '@stellar/stellar-sdk/lib/contract';
|
|
2
1
|
import { StellarWallet } from '../services';
|
|
3
2
|
import { POOL_NAME, StellarNetwork } from '../utils';
|
|
4
3
|
/**
|
|
5
|
-
* Approves an Sep41 allowance for a spender address
|
|
4
|
+
* Approves an Sep41 allowance for a spender address.
|
|
6
5
|
* Allowance is required to do certain actions on the Huma protocol (e.g. makePayment for Autopay)
|
|
7
6
|
*
|
|
8
7
|
* @async
|
|
@@ -11,7 +10,5 @@ import { POOL_NAME, StellarNetwork } from '../utils';
|
|
|
11
10
|
* @param {StellarNetwork} network - The stellar network.
|
|
12
11
|
* @param {StellarWallet} wallet - The wallet used to send the transaction.
|
|
13
12
|
* @param {string} spenderAddress - The address of the spender to approve an allowance for.
|
|
14
|
-
* @param {bigint} allowanceAmount - The amount of tokens to approve, if applicable. Denominated in the Sep41 tokens.
|
|
15
|
-
* @returns {Promise<SentTransaction<null> | null>} - A Promise of the transaction response, or null if the allowance was already sufficient.
|
|
16
13
|
*/
|
|
17
|
-
export declare function
|
|
14
|
+
export declare function approveSep41Allowance(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, spenderAddress: string): Promise<any>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.approveSep41Allowance = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
/**
|
|
6
|
-
* Approves an Sep41 allowance for a spender address
|
|
6
|
+
* Approves an Sep41 allowance for a spender address.
|
|
7
7
|
* Allowance is required to do certain actions on the Huma protocol (e.g. makePayment for Autopay)
|
|
8
8
|
*
|
|
9
9
|
* @async
|
|
@@ -12,14 +12,19 @@ const utils_1 = require("../utils");
|
|
|
12
12
|
* @param {StellarNetwork} network - The stellar network.
|
|
13
13
|
* @param {StellarWallet} wallet - The wallet used to send the transaction.
|
|
14
14
|
* @param {string} spenderAddress - The address of the spender to approve an allowance for.
|
|
15
|
-
* @param {bigint} allowanceAmount - The amount of tokens to approve, if applicable. Denominated in the Sep41 tokens.
|
|
16
|
-
* @returns {Promise<SentTransaction<null> | null>} - A Promise of the transaction response, or null if the allowance was already sufficient.
|
|
17
15
|
*/
|
|
18
|
-
async function
|
|
16
|
+
async function approveSep41Allowance(poolName, network, wallet, spenderAddress) {
|
|
19
17
|
const underlyingTokenContext = new utils_1.TransactionContext(poolName, network, wallet, 'underlyingToken');
|
|
20
|
-
const { result:
|
|
18
|
+
const { result: decimals } = await (0, utils_1.sendTransaction)({
|
|
19
|
+
context: underlyingTokenContext,
|
|
20
|
+
method: 'decimals',
|
|
21
|
+
});
|
|
22
|
+
const latestLedger = await (0, utils_1.getLatestLedger)(network);
|
|
23
|
+
// @TODO find a better to advance the ledger number
|
|
24
|
+
const advanceLedgerNum = 3_000_000;
|
|
25
|
+
const result = await (0, utils_1.sendTransaction)({
|
|
21
26
|
context: underlyingTokenContext,
|
|
22
|
-
method: '
|
|
27
|
+
method: 'approve',
|
|
23
28
|
params: [
|
|
24
29
|
{
|
|
25
30
|
name: 'from',
|
|
@@ -31,46 +36,19 @@ async function approveSep41AllowanceIfInsufficient(poolName, network, wallet, sp
|
|
|
31
36
|
type: utils_1.ScValType.address,
|
|
32
37
|
value: spenderAddress,
|
|
33
38
|
},
|
|
39
|
+
{
|
|
40
|
+
name: 'amount',
|
|
41
|
+
type: utils_1.ScValType.i128,
|
|
42
|
+
value: 1000_000_000 * Math.pow(10, Number(decimals)),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'expiration_ledger',
|
|
46
|
+
type: utils_1.ScValType.u32,
|
|
47
|
+
value: latestLedger.sequence + advanceLedgerNum,
|
|
48
|
+
},
|
|
34
49
|
],
|
|
50
|
+
shouldSignTransaction: true,
|
|
35
51
|
});
|
|
36
|
-
|
|
37
|
-
context: underlyingTokenContext,
|
|
38
|
-
method: 'decimals',
|
|
39
|
-
});
|
|
40
|
-
if (allowance < allowanceAmount) {
|
|
41
|
-
const latestLedger = await (0, utils_1.getLatestLedger)(network);
|
|
42
|
-
// @TODO find a better to advance the ledger number
|
|
43
|
-
const advanceLedgerNum = 3000000;
|
|
44
|
-
const result = await (0, utils_1.sendTransaction)({
|
|
45
|
-
context: underlyingTokenContext,
|
|
46
|
-
method: 'approve',
|
|
47
|
-
params: [
|
|
48
|
-
{
|
|
49
|
-
name: 'from',
|
|
50
|
-
type: utils_1.ScValType.address,
|
|
51
|
-
value: wallet.userInfo.publicKey,
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: 'spender',
|
|
55
|
-
type: utils_1.ScValType.address,
|
|
56
|
-
value: spenderAddress,
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: 'amount',
|
|
60
|
-
type: utils_1.ScValType.i128,
|
|
61
|
-
value: 1000000000 * Math.pow(10, Number(decimals)),
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'expiration_ledger',
|
|
65
|
-
type: utils_1.ScValType.u32,
|
|
66
|
-
value: latestLedger.sequence + advanceLedgerNum,
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
shouldSignTransaction: true,
|
|
70
|
-
});
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
return null;
|
|
52
|
+
return result;
|
|
74
53
|
}
|
|
75
|
-
exports.
|
|
76
|
-
//# sourceMappingURL=Sep41ContractHelper.js.map
|
|
54
|
+
exports.approveSep41Allowance = approveSep41Allowance;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,47 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _HumaContextStellar_wallet, _HumaContextStellar_network, _HumaContextStellar_poolName, _HumaContextStellar_poolType;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.HumaContextStellar = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
4
|
class HumaContextStellar {
|
|
5
|
+
#wallet;
|
|
6
|
+
#network;
|
|
7
|
+
#poolName;
|
|
8
|
+
#poolType;
|
|
7
9
|
constructor({ wallet, network, poolName, poolType, }) {
|
|
8
|
-
_HumaContextStellar_wallet.set(this, void 0);
|
|
9
|
-
_HumaContextStellar_network.set(this, void 0);
|
|
10
|
-
_HumaContextStellar_poolName.set(this, void 0);
|
|
11
|
-
_HumaContextStellar_poolType.set(this, void 0);
|
|
12
10
|
if (!wallet || !network || !poolName || !poolType) {
|
|
13
11
|
throw new Error('All parameters are required');
|
|
14
12
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
this.#wallet = wallet;
|
|
14
|
+
this.#network = network;
|
|
15
|
+
this.#poolName = poolName;
|
|
16
|
+
this.#poolType = poolType;
|
|
19
17
|
}
|
|
20
18
|
get wallet() {
|
|
21
|
-
return
|
|
19
|
+
return this.#wallet;
|
|
22
20
|
}
|
|
23
21
|
set wallet(value) {
|
|
24
|
-
|
|
22
|
+
this.#wallet = value;
|
|
25
23
|
}
|
|
26
24
|
get network() {
|
|
27
|
-
return
|
|
25
|
+
return this.#network;
|
|
28
26
|
}
|
|
29
27
|
set network(value) {
|
|
30
|
-
|
|
28
|
+
this.#network = value;
|
|
31
29
|
}
|
|
32
30
|
get poolName() {
|
|
33
|
-
return
|
|
31
|
+
return this.#poolName;
|
|
34
32
|
}
|
|
35
33
|
set poolName(value) {
|
|
36
|
-
|
|
34
|
+
this.#poolName = value;
|
|
37
35
|
}
|
|
38
36
|
get poolType() {
|
|
39
|
-
return
|
|
37
|
+
return this.#poolType;
|
|
40
38
|
}
|
|
41
39
|
set poolType(value) {
|
|
42
|
-
|
|
40
|
+
this.#poolType = value;
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
exports.HumaContextStellar = HumaContextStellar;
|
|
46
|
-
_HumaContextStellar_wallet = new WeakMap(), _HumaContextStellar_network = new WeakMap(), _HumaContextStellar_poolName = new WeakMap(), _HumaContextStellar_poolType = new WeakMap();
|
|
47
|
-
//# sourceMappingURL=HumaContextStellar.js.map
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _StellarWallet_sourceKeypair;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.StellarWallet = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
4
|
const stellar_sdk_1 = require("@stellar/stellar-sdk");
|
|
7
5
|
class StellarWallet {
|
|
6
|
+
#sourceKeypair;
|
|
8
7
|
constructor(secretKey) {
|
|
9
|
-
|
|
10
|
-
tslib_1.__classPrivateFieldSet(this, _StellarWallet_sourceKeypair, stellar_sdk_1.Keypair.fromSecret(secretKey), "f");
|
|
8
|
+
this.#sourceKeypair = stellar_sdk_1.Keypair.fromSecret(secretKey);
|
|
11
9
|
}
|
|
12
10
|
get keypair() {
|
|
13
|
-
return
|
|
11
|
+
return this.#sourceKeypair;
|
|
14
12
|
}
|
|
15
13
|
get userInfo() {
|
|
16
14
|
return {
|
|
17
|
-
publicKey:
|
|
15
|
+
publicKey: this.#sourceKeypair.publicKey(),
|
|
18
16
|
};
|
|
19
17
|
}
|
|
20
18
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
19
|
async signTransaction(tx, opts) {
|
|
22
20
|
const txFromXDR = new stellar_sdk_1.Transaction(tx, opts.networkPassphrase);
|
|
23
|
-
txFromXDR.sign(
|
|
21
|
+
txFromXDR.sign(this.#sourceKeypair);
|
|
24
22
|
return txFromXDR.toXDR();
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
exports.StellarWallet = StellarWallet;
|
|
28
|
-
_StellarWallet_sourceKeypair = new WeakMap();
|
|
29
|
-
//# sourceMappingURL=StellarWallet.js.map
|
package/dist/cjs/utils/client.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _TransactionContext_client, _TransactionContext_wallet, _TransactionContext_network, _TransactionContext_contractId;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.TransactionContext = exports.getUnderlyingTokenClient = exports.getTrancheVaultClient = exports.getCreditManagerClient = exports.getCreditStorageClient = exports.getPoolCreditClient = exports.getPoolStorageClient = exports.getPoolClient = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
4
|
const soroban_credit_manager_1 = require("@huma-finance/soroban-credit-manager");
|
|
7
5
|
const soroban_credit_storage_1 = require("@huma-finance/soroban-credit-storage");
|
|
8
6
|
const soroban_huma_config_1 = require("@huma-finance/soroban-huma-config");
|
|
@@ -109,11 +107,11 @@ const getUnderlyingTokenClient = (tokenAddress, network, wallet) => {
|
|
|
109
107
|
};
|
|
110
108
|
exports.getUnderlyingTokenClient = getUnderlyingTokenClient;
|
|
111
109
|
class TransactionContext {
|
|
110
|
+
#client;
|
|
111
|
+
#wallet;
|
|
112
|
+
#network;
|
|
113
|
+
#contractId;
|
|
112
114
|
constructor(poolName, network, wallet, contractType) {
|
|
113
|
-
_TransactionContext_client.set(this, void 0);
|
|
114
|
-
_TransactionContext_wallet.set(this, void 0);
|
|
115
|
-
_TransactionContext_network.set(this, void 0);
|
|
116
|
-
_TransactionContext_contractId.set(this, void 0);
|
|
117
115
|
const poolMetadata = (0, common_1.findPoolMetadata)(network, poolName);
|
|
118
116
|
if (!poolMetadata) {
|
|
119
117
|
throw new Error(`Could not find pool metadata by pool name: ${poolName}`);
|
|
@@ -130,24 +128,22 @@ class TransactionContext {
|
|
|
130
128
|
contractId: poolMetadata.contracts[contractType],
|
|
131
129
|
...getCommonProps(network, wallet),
|
|
132
130
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
this.#client = client;
|
|
132
|
+
this.#wallet = wallet;
|
|
133
|
+
this.#network = network;
|
|
134
|
+
this.#contractId = client.options.contractId;
|
|
137
135
|
}
|
|
138
136
|
get client() {
|
|
139
|
-
return
|
|
137
|
+
return this.#client;
|
|
140
138
|
}
|
|
141
139
|
get wallet() {
|
|
142
|
-
return
|
|
140
|
+
return this.#wallet;
|
|
143
141
|
}
|
|
144
142
|
get network() {
|
|
145
|
-
return
|
|
143
|
+
return this.#network;
|
|
146
144
|
}
|
|
147
145
|
get contractId() {
|
|
148
|
-
return
|
|
146
|
+
return this.#contractId;
|
|
149
147
|
}
|
|
150
148
|
}
|
|
151
149
|
exports.TransactionContext = TransactionContext;
|
|
152
|
-
_TransactionContext_client = new WeakMap(), _TransactionContext_wallet = new WeakMap(), _TransactionContext_network = new WeakMap(), _TransactionContext_contractId = new WeakMap();
|
|
153
|
-
//# sourceMappingURL=client.js.map
|
package/dist/cjs/utils/common.js
CHANGED
package/dist/cjs/utils/index.js
CHANGED
|
@@ -55,7 +55,7 @@ exports.NetworkMetadatas = [
|
|
|
55
55
|
seniorTranche: 'CAEVE6BJIXQV54DGNFZ5GRIMIIITAHXSOWTGKTDZCQZA4FXK4ZNDZYFX',
|
|
56
56
|
underlyingToken: 'CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75',
|
|
57
57
|
},
|
|
58
|
-
borrowers: ['GBQ4MIGKASCJG4GNEOQ3G6Z6YDUXCAKYARB3MNJ7QOF54MNMYW7HP62V'],
|
|
58
|
+
borrowers: ['GBQ4MIGKASCJG4GNEOQ3G6Z6YDUXCAKYARB3MNJ7QOF54MNMYW7HP62V'],
|
|
59
59
|
},
|
|
60
60
|
],
|
|
61
61
|
},
|
|
@@ -131,4 +131,3 @@ exports.NetworkMetadatas = [
|
|
|
131
131
|
],
|
|
132
132
|
},
|
|
133
133
|
];
|
|
134
|
-
//# sourceMappingURL=network.js.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { SorobanRpc, xdr } from '@stellar/stellar-sdk';
|
|
4
|
-
import { SentTransaction } from '@stellar/stellar-sdk/lib/contract';
|
|
5
4
|
import { StellarWallet } from 'services';
|
|
6
5
|
import { TransactionContext } from './client';
|
|
7
6
|
import { ScValType } from './common';
|
|
@@ -14,7 +13,7 @@ export declare const restoreAndExtendTTL: (network: StellarNetwork, wallet: Stel
|
|
|
14
13
|
type: ScValType;
|
|
15
14
|
value: string | number | bigint;
|
|
16
15
|
}[]) => Promise<void>;
|
|
17
|
-
export declare const sendTransaction:
|
|
16
|
+
export declare const sendTransaction: ({ context, method, params, shouldSignTransaction, }: {
|
|
18
17
|
context: TransactionContext;
|
|
19
18
|
method: string;
|
|
20
19
|
params?: {
|
|
@@ -23,4 +22,4 @@ export declare const sendTransaction: <T = null>({ context, method, params, shou
|
|
|
23
22
|
value: string | number | bigint | Buffer;
|
|
24
23
|
}[] | undefined;
|
|
25
24
|
shouldSignTransaction?: boolean | undefined;
|
|
26
|
-
}) => Promise<
|
|
25
|
+
}) => Promise<any>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CreditRecord } from '@huma-finance/soroban-pool-credit';
|
|
2
|
-
import { SentTransaction } from '@stellar/stellar-sdk/lib/contract';
|
|
3
2
|
import { StellarWallet } from '../services';
|
|
4
3
|
import { POOL_NAME, StellarNetwork } from '../utils';
|
|
5
4
|
/**
|
|
@@ -49,9 +48,8 @@ export declare function getTotalDue(poolName: POOL_NAME, network: StellarNetwork
|
|
|
49
48
|
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
50
49
|
* @param {StellarNetwork} network - The stellar network.
|
|
51
50
|
* @param {StellarWallet} wallet - The stellar wallet.
|
|
52
|
-
* @returns {Promise<SentTransaction>} - A Promise of the SentTransaction.
|
|
53
51
|
*/
|
|
54
|
-
export declare function approveAllowanceForSentinel(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet): Promise<
|
|
52
|
+
export declare function approveAllowanceForSentinel(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet): Promise<any>;
|
|
55
53
|
/**
|
|
56
54
|
* Draws down from a pool.
|
|
57
55
|
*
|
|
@@ -63,7 +61,7 @@ export declare function approveAllowanceForSentinel(poolName: POOL_NAME, network
|
|
|
63
61
|
* @param {BigNumberish} drawdownAmount - The amount to drawdown.
|
|
64
62
|
* @returns {Promise<SentTransaction>} - A Promise of the SentTransaction.
|
|
65
63
|
*/
|
|
66
|
-
export declare function drawdown(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, drawdownAmount: bigint): Promise<
|
|
64
|
+
export declare function drawdown(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, drawdownAmount: bigint): Promise<any>;
|
|
67
65
|
/**
|
|
68
66
|
* Makes a payment.
|
|
69
67
|
*
|
|
@@ -76,4 +74,4 @@ export declare function drawdown(poolName: POOL_NAME, network: StellarNetwork, w
|
|
|
76
74
|
* @param {boolean} principalOnly - Whether this payment should ONLY apply to the principal
|
|
77
75
|
* @returns {Promise<SentTransaction>} - A Promise of the SentTransaction.
|
|
78
76
|
*/
|
|
79
|
-
export declare function makePayment(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, paymentAmount: bigint, principalOnly: boolean): Promise<
|
|
77
|
+
export declare function makePayment(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, paymentAmount: bigint, principalOnly: boolean): Promise<any>;
|