@huma-finance/soroban-sdk 0.0.15-beta.33 → 0.0.15-beta.36
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 +3 -21
- package/dist/cjs/helpers/CreditContractHelper.d.ts +3 -13
- package/dist/cjs/helpers/CreditContractHelper.js +107 -91
- package/dist/cjs/helpers/CreditContractHelper.js.map +1 -1
- package/dist/cjs/helpers/Sep41ContractHelper.d.ts +3 -3
- package/dist/cjs/helpers/Sep41ContractHelper.js +49 -18
- package/dist/cjs/helpers/Sep41ContractHelper.js.map +1 -1
- package/dist/cjs/services/StellarWallet.d.ts +3 -1
- package/dist/cjs/services/StellarWallet.js +10 -3
- package/dist/cjs/services/StellarWallet.js.map +1 -1
- package/dist/cjs/utils/client.d.ts +12 -3
- package/dist/cjs/utils/client.js +57 -3
- package/dist/cjs/utils/client.js.map +1 -1
- package/dist/cjs/utils/common.d.ts +14 -1
- package/dist/cjs/utils/common.js +41 -1
- package/dist/cjs/utils/common.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/network.d.ts +4 -1
- package/dist/cjs/utils/network.js +18 -10
- package/dist/cjs/utils/network.js.map +1 -1
- package/dist/cjs/utils/transaction.d.ts +25 -0
- package/dist/cjs/utils/transaction.js +127 -0
- package/dist/cjs/utils/transaction.js.map +1 -0
- package/dist/helpers/CreditContractHelper.d.ts +3 -13
- package/dist/helpers/CreditContractHelper.js +106 -89
- package/dist/helpers/CreditContractHelper.js.map +1 -1
- package/dist/helpers/Sep41ContractHelper.d.ts +3 -3
- package/dist/helpers/Sep41ContractHelper.js +50 -19
- package/dist/helpers/Sep41ContractHelper.js.map +1 -1
- package/dist/services/StellarWallet.d.ts +3 -1
- package/dist/services/StellarWallet.js +10 -3
- package/dist/services/StellarWallet.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/utils/client.d.ts +12 -3
- package/dist/utils/client.js +55 -2
- package/dist/utils/client.js.map +1 -1
- package/dist/utils/common.d.ts +14 -1
- package/dist/utils/common.js +40 -1
- package/dist/utils/common.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/network.d.ts +4 -1
- package/dist/utils/network.js +18 -10
- package/dist/utils/network.js.map +1 -1
- package/dist/utils/transaction.d.ts +25 -0
- package/dist/utils/transaction.js +119 -0
- package/dist/utils/transaction.js.map +1 -0
- package/package.json +11 -11
package/API.md
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
## Functions
|
|
2
2
|
|
|
3
3
|
<dl>
|
|
4
|
-
<dt><a href="#getCreditLineClient">getCreditLineClient(poolName, network, wallet)</a> ⇒ <code>PoolCreditClient</code> | <code>undefined</code></dt>
|
|
5
|
-
<dd><p>Returns an soroban contract client instance for the credit line contract
|
|
6
|
-
associated with the given pool name on the current chain.</p></dd>
|
|
7
4
|
<dt><a href="#getAvailableBalanceForPool">getAvailableBalanceForPool(poolName, network, wallet)</a></dt>
|
|
8
5
|
<dd><p>Returns the current pool balance available for borrowing</p></dd>
|
|
9
6
|
<dt><a href="#getCreditRecordForPool">getCreditRecordForPool(poolName, network, wallet, borrower)</a></dt>
|
|
@@ -21,26 +18,11 @@ associated with the given pool name on the current chain.</p></dd>
|
|
|
21
18
|
<dd><p>Draws down from a pool.</p></dd>
|
|
22
19
|
<dt><a href="#makePayment">makePayment(poolName, network, wallet, paymentAmount, principalOnly)</a> ⇒ <code>Promise.<SentTransaction></code></dt>
|
|
23
20
|
<dd><p>Makes a payment.</p></dd>
|
|
24
|
-
<dt><a href="#approveSep41AllowanceIfInsufficient">approveSep41AllowanceIfInsufficient(network, wallet,
|
|
21
|
+
<dt><a href="#approveSep41AllowanceIfInsufficient">approveSep41AllowanceIfInsufficient(poolName, network, wallet, spenderAddress, allowanceAmount)</a> ⇒ <code>Promise.<(SentTransaction.<null>|null)></code></dt>
|
|
25
22
|
<dd><p>Approves an Sep41 allowance for a spender address, if the current allowance is insufficient.
|
|
26
23
|
Allowance is required to do certain actions on the Huma protocol (e.g. makePayment for Autopay)</p></dd>
|
|
27
24
|
</dl>
|
|
28
25
|
|
|
29
|
-
<a name="getCreditLineClient"></a>
|
|
30
|
-
|
|
31
|
-
## getCreditLineClient(poolName, network, wallet) ⇒ <code>PoolCreditClient</code> \| <code>undefined</code>
|
|
32
|
-
<p>Returns an soroban contract client instance for the credit line contract
|
|
33
|
-
associated with the given pool name on the current chain.</p>
|
|
34
|
-
|
|
35
|
-
**Kind**: global function
|
|
36
|
-
**Returns**: <code>PoolCreditClient</code> \| <code>undefined</code> - <p>A contract client instance for the CreditLine contract or undefined if it could not be found.</p>
|
|
37
|
-
|
|
38
|
-
| Param | Type | Description |
|
|
39
|
-
| --- | --- | --- |
|
|
40
|
-
| poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to get the contract instance for.</p> |
|
|
41
|
-
| network | <code>StellarNetwork</code> | <p>The stellar network.</p> |
|
|
42
|
-
| wallet | <code>StellarWallet</code> | <p>The stellar wallet.</p> |
|
|
43
|
-
|
|
44
26
|
<a name="getAvailableBalanceForPool"></a>
|
|
45
27
|
|
|
46
28
|
## getAvailableBalanceForPool(poolName, network, wallet)
|
|
@@ -153,7 +135,7 @@ associated with the given pool name on the current chain.</p>
|
|
|
153
135
|
|
|
154
136
|
<a name="approveSep41AllowanceIfInsufficient"></a>
|
|
155
137
|
|
|
156
|
-
## approveSep41AllowanceIfInsufficient(network, wallet,
|
|
138
|
+
## approveSep41AllowanceIfInsufficient(poolName, network, wallet, spenderAddress, allowanceAmount) ⇒ <code>Promise.<(SentTransaction.<null>\|null)></code>
|
|
157
139
|
<p>Approves an Sep41 allowance for a spender address, if the current allowance is insufficient.
|
|
158
140
|
Allowance is required to do certain actions on the Huma protocol (e.g. makePayment for Autopay)</p>
|
|
159
141
|
|
|
@@ -164,9 +146,9 @@ Allowance is required to do certain actions on the Huma protocol (e.g. makePayme
|
|
|
164
146
|
|
|
165
147
|
| Param | Type | Description |
|
|
166
148
|
| --- | --- | --- |
|
|
149
|
+
| poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to get the contract instance for.</p> |
|
|
167
150
|
| network | <code>StellarNetwork</code> | <p>The stellar network.</p> |
|
|
168
151
|
| wallet | <code>StellarWallet</code> | <p>The wallet used to send the transaction.</p> |
|
|
169
|
-
| tokenAddress | <code>string</code> | <p>The address of the Sep41 token to approve.</p> |
|
|
170
152
|
| spenderAddress | <code>string</code> | <p>The address of the spender to approve an allowance for.</p> |
|
|
171
153
|
| allowanceAmount | <code>bigint</code> | <p>The amount of tokens to approve, if applicable. Denominated in the Sep41 tokens.</p> |
|
|
172
154
|
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreditRecord } from '@huma-finance/soroban-pool-credit';
|
|
2
2
|
import { SentTransaction } from '@stellar/stellar-sdk/lib/contract';
|
|
3
|
-
import { StellarWallet } from '../services
|
|
4
|
-
import { POOL_NAME, StellarNetwork } from '../utils
|
|
5
|
-
/**
|
|
6
|
-
* Returns an soroban contract client instance for the credit line contract
|
|
7
|
-
* associated with the given pool name on the current chain.
|
|
8
|
-
*
|
|
9
|
-
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
10
|
-
* @param {StellarNetwork} network - The stellar network.
|
|
11
|
-
* @param {StellarWallet} wallet - The stellar wallet.
|
|
12
|
-
* @returns {PoolCreditClient | undefined} A contract client instance for the CreditLine contract or undefined if it could not be found.
|
|
13
|
-
*/
|
|
14
|
-
export declare function getCreditLineClient(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet): PoolCreditClient | undefined;
|
|
3
|
+
import { StellarWallet } from '../services';
|
|
4
|
+
import { POOL_NAME, StellarNetwork } from '../utils';
|
|
15
5
|
/**
|
|
16
6
|
* Returns the current pool balance available for borrowing
|
|
17
7
|
*
|
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makePayment = exports.drawdown = exports.approveAllowanceForSentinel = exports.getTotalDue = exports.getAvailableCreditForPool = exports.getCreditRecordForPool = exports.getAvailableBalanceForPool =
|
|
4
|
-
const
|
|
3
|
+
exports.makePayment = exports.drawdown = exports.approveAllowanceForSentinel = exports.getTotalDue = exports.getAvailableCreditForPool = exports.getCreditRecordForPool = exports.getAvailableBalanceForPool = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
5
|
const Sep41ContractHelper_1 = require("./Sep41ContractHelper");
|
|
6
|
-
/**
|
|
7
|
-
* Returns an soroban contract client instance for the credit line contract
|
|
8
|
-
* associated with the given pool name on the current chain.
|
|
9
|
-
*
|
|
10
|
-
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
11
|
-
* @param {StellarNetwork} network - The stellar network.
|
|
12
|
-
* @param {StellarWallet} wallet - The stellar wallet.
|
|
13
|
-
* @returns {PoolCreditClient | undefined} A contract client instance for the CreditLine contract or undefined if it could not be found.
|
|
14
|
-
*/
|
|
15
|
-
function getCreditLineClient(poolName, network, wallet) {
|
|
16
|
-
return (0, client_1.getPoolCreditClient)(poolName, network, wallet);
|
|
17
|
-
}
|
|
18
|
-
exports.getCreditLineClient = getCreditLineClient;
|
|
19
6
|
/**
|
|
20
7
|
* Returns the current pool balance available for borrowing
|
|
21
8
|
*
|
|
@@ -24,11 +11,11 @@ exports.getCreditLineClient = getCreditLineClient;
|
|
|
24
11
|
* @param {StellarWallet} wallet - The stellar wallet.
|
|
25
12
|
*/
|
|
26
13
|
async function getAvailableBalanceForPool(poolName, network, wallet) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
const poolStorageContext = new utils_1.TransactionContext(poolName, network, wallet, 'poolStorage');
|
|
15
|
+
const { result } = await (0, utils_1.sendTransaction)({
|
|
16
|
+
context: poolStorageContext,
|
|
17
|
+
method: 'get_available_balance',
|
|
18
|
+
});
|
|
32
19
|
return result;
|
|
33
20
|
}
|
|
34
21
|
exports.getAvailableBalanceForPool = getAvailableBalanceForPool;
|
|
@@ -41,18 +28,31 @@ exports.getAvailableBalanceForPool = getAvailableBalanceForPool;
|
|
|
41
28
|
* @param {string} borrower - The address of the borrower to check the credit record for.
|
|
42
29
|
*/
|
|
43
30
|
async function getCreditRecordForPool(poolName, network, wallet, borrower) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
31
|
+
const creditStorageContext = new utils_1.TransactionContext(poolName, network, wallet, 'creditStorage');
|
|
32
|
+
const { result: creditHash } = await (0, utils_1.sendTransaction)({
|
|
33
|
+
context: creditStorageContext,
|
|
34
|
+
method: 'get_credit_hash',
|
|
35
|
+
params: [
|
|
36
|
+
{
|
|
37
|
+
name: 'borrower',
|
|
38
|
+
type: utils_1.ScValType.address,
|
|
39
|
+
value: borrower,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
50
42
|
});
|
|
51
43
|
if (!creditHash) {
|
|
52
44
|
throw new Error('Could not find credit hash');
|
|
53
45
|
}
|
|
54
|
-
const { result: creditRecord } = await
|
|
55
|
-
|
|
46
|
+
const { result: creditRecord } = await (0, utils_1.sendTransaction)({
|
|
47
|
+
context: creditStorageContext,
|
|
48
|
+
method: 'get_credit_record',
|
|
49
|
+
params: [
|
|
50
|
+
{
|
|
51
|
+
name: 'credit_hash',
|
|
52
|
+
type: utils_1.ScValType.buffer,
|
|
53
|
+
value: creditHash,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
56
|
});
|
|
57
57
|
if (!creditRecord) {
|
|
58
58
|
throw new Error('Could not find credit record');
|
|
@@ -71,24 +71,36 @@ exports.getCreditRecordForPool = getCreditRecordForPool;
|
|
|
71
71
|
* @param {string} borrower - The address of the borrower to check the available credit for.
|
|
72
72
|
*/
|
|
73
73
|
async function getAvailableCreditForPool(poolName, network, wallet, borrower) {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
const creditStorageContext = new utils_1.TransactionContext(poolName, network, wallet, 'creditStorage');
|
|
75
|
+
const { result: creditHash } = await (0, utils_1.sendTransaction)({
|
|
76
|
+
context: creditStorageContext,
|
|
77
|
+
method: 'get_credit_hash',
|
|
78
|
+
params: [
|
|
79
|
+
{
|
|
80
|
+
name: 'borrower',
|
|
81
|
+
type: utils_1.ScValType.address,
|
|
82
|
+
value: borrower,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
80
85
|
});
|
|
81
86
|
if (!creditHash) {
|
|
82
87
|
throw new Error('Could not find credit hash');
|
|
83
88
|
}
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
const creditHashParam = {
|
|
90
|
+
name: 'credit_hash',
|
|
91
|
+
type: utils_1.ScValType.buffer,
|
|
92
|
+
value: creditHash,
|
|
93
|
+
};
|
|
94
|
+
const { result: creditConfig } = await (0, utils_1.sendTransaction)({
|
|
95
|
+
context: creditStorageContext,
|
|
96
|
+
method: 'get_credit_config',
|
|
97
|
+
params: [creditHashParam],
|
|
98
|
+
});
|
|
99
|
+
const { result: creditRecord } = await (0, utils_1.sendTransaction)({
|
|
100
|
+
context: creditStorageContext,
|
|
101
|
+
method: 'get_credit_record',
|
|
102
|
+
params: [creditHashParam],
|
|
103
|
+
});
|
|
92
104
|
if (!creditConfig || !creditRecord) {
|
|
93
105
|
throw new Error('Could not find credit config or credit record');
|
|
94
106
|
}
|
|
@@ -128,15 +140,12 @@ async function approveAllowanceForSentinel(poolName, network, wallet) {
|
|
|
128
140
|
if (totalDue === null) {
|
|
129
141
|
throw new Error('Could not find total due');
|
|
130
142
|
}
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
poolStorageClient.get_sentinel(),
|
|
138
|
-
]);
|
|
139
|
-
const tx = await (0, Sep41ContractHelper_1.approveSep41AllowanceIfInsufficient)(network, wallet, underlyingToken, sentinel, totalDue);
|
|
143
|
+
const poolStorageContext = new utils_1.TransactionContext(poolName, network, wallet, 'poolStorage');
|
|
144
|
+
const { result: sentinel } = await (0, utils_1.sendTransaction)({
|
|
145
|
+
context: poolStorageContext,
|
|
146
|
+
method: 'get_sentinel',
|
|
147
|
+
});
|
|
148
|
+
const tx = await (0, Sep41ContractHelper_1.approveSep41AllowanceIfInsufficient)(poolName, network, wallet, sentinel, totalDue);
|
|
140
149
|
return tx;
|
|
141
150
|
}
|
|
142
151
|
exports.approveAllowanceForSentinel = approveAllowanceForSentinel;
|
|
@@ -152,18 +161,25 @@ exports.approveAllowanceForSentinel = approveAllowanceForSentinel;
|
|
|
152
161
|
* @returns {Promise<SentTransaction>} - A Promise of the SentTransaction.
|
|
153
162
|
*/
|
|
154
163
|
async function drawdown(poolName, network, wallet, drawdownAmount) {
|
|
155
|
-
const poolCreditClient = (0, client_1.getPoolCreditClient)(poolName, network, wallet);
|
|
156
|
-
if (!poolCreditClient) {
|
|
157
|
-
throw new Error('Could not find credit contract for pool');
|
|
158
|
-
}
|
|
159
164
|
await approveAllowanceForSentinel(poolName, network, wallet);
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
+
const poolCreditContext = new utils_1.TransactionContext(poolName, network, wallet, 'poolCredit');
|
|
166
|
+
const result = await (0, utils_1.sendTransaction)({
|
|
167
|
+
context: poolCreditContext,
|
|
168
|
+
method: 'drawdown',
|
|
169
|
+
params: [
|
|
170
|
+
{
|
|
171
|
+
name: 'borrower',
|
|
172
|
+
type: utils_1.ScValType.address,
|
|
173
|
+
value: wallet.userInfo.publicKey,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: 'amount',
|
|
177
|
+
type: utils_1.ScValType.u128,
|
|
178
|
+
value: drawdownAmount,
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
shouldSignTransaction: true,
|
|
165
182
|
});
|
|
166
|
-
const result = await tx.signAndSend();
|
|
167
183
|
return result;
|
|
168
184
|
}
|
|
169
185
|
exports.drawdown = drawdown;
|
|
@@ -180,39 +196,39 @@ exports.drawdown = drawdown;
|
|
|
180
196
|
* @returns {Promise<SentTransaction>} - A Promise of the SentTransaction.
|
|
181
197
|
*/
|
|
182
198
|
async function makePayment(poolName, network, wallet, paymentAmount, principalOnly) {
|
|
183
|
-
const poolCreditClient = (0, client_1.getPoolCreditClient)(poolName, network, wallet);
|
|
184
|
-
if (!poolCreditClient) {
|
|
185
|
-
throw new Error('Could not find credit contract for pool');
|
|
186
|
-
}
|
|
187
|
-
const poolStorageClient = (0, client_1.getPoolStorageClient)(poolName, network, wallet);
|
|
188
|
-
if (!poolStorageClient) {
|
|
189
|
-
throw new Error('Could not find pool storage contract for pool');
|
|
190
|
-
}
|
|
191
199
|
await approveAllowanceForSentinel(poolName, network, wallet);
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
200
|
+
const poolStorageContext = new utils_1.TransactionContext(poolName, network, wallet, 'poolStorage');
|
|
201
|
+
const { result: sentinel } = await (0, utils_1.sendTransaction)({
|
|
202
|
+
context: poolStorageContext,
|
|
203
|
+
method: 'get_sentinel',
|
|
204
|
+
});
|
|
205
|
+
await (0, Sep41ContractHelper_1.approveSep41AllowanceIfInsufficient)(poolName, network, wallet, sentinel, paymentAmount);
|
|
206
|
+
const poolCreditContext = new utils_1.TransactionContext(poolName, network, wallet, 'poolCredit');
|
|
207
|
+
const params = [
|
|
208
|
+
{
|
|
209
|
+
name: 'borrower',
|
|
210
|
+
type: utils_1.ScValType.address,
|
|
211
|
+
value: wallet.userInfo.publicKey,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: 'amount',
|
|
215
|
+
type: utils_1.ScValType.u128,
|
|
216
|
+
value: paymentAmount,
|
|
217
|
+
},
|
|
218
|
+
];
|
|
219
|
+
if (!principalOnly) {
|
|
220
|
+
params.unshift({
|
|
221
|
+
name: 'caller',
|
|
222
|
+
type: utils_1.ScValType.address,
|
|
223
|
+
value: wallet.userInfo.publicKey,
|
|
213
224
|
});
|
|
214
225
|
}
|
|
215
|
-
const result = await
|
|
226
|
+
const result = await (0, utils_1.sendTransaction)({
|
|
227
|
+
context: poolCreditContext,
|
|
228
|
+
method: principalOnly ? 'make_principal_payment' : 'make_payment',
|
|
229
|
+
params: params,
|
|
230
|
+
shouldSignTransaction: true,
|
|
231
|
+
});
|
|
216
232
|
return result;
|
|
217
233
|
}
|
|
218
234
|
exports.makePayment = makePayment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreditContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/CreditContractHelper.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"CreditContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/CreditContractHelper.ts"],"names":[],"mappings":";;;AAKA,oCAMiB;AACjB,+DAA2E;AAE3E;;;;;;GAMG;AACI,KAAK,UAAU,0BAA0B,CAC9C,QAAmB,EACnB,OAAuB,EACvB,MAAqB;IAErB,MAAM,kBAAkB,GAAG,IAAI,0BAAkB,CAC/C,QAAQ,EACR,OAAO,EACP,MAAM,EACN,aAAa,CACd,CAAA;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,uBAAe,EAAS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CAAC,IAAI;YACpB,KAAK,EAAE,aAAa;SACrB;KACF,CAAA;IACD,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,CAAC,OAAO,CAAC;YACb,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,iBAAS,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS;SACjC,CAAC,CAAA;KACH;IACD,MAAM,MAAM,GAAG,MAAM,IAAA,uBAAe,EAA6B;QAC/D,OAAO,EAAE,iBAAiB;QAC1B,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,cAAc;QACjE,MAAM,EAAE,MAAM;QACd,qBAAqB,EAAE,IAAI;KAC5B,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC;AA5DD,kCA4DC"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { SentTransaction } from '@stellar/stellar-sdk/lib/contract';
|
|
2
2
|
import { StellarWallet } from '../services';
|
|
3
|
-
import { StellarNetwork } from '../utils';
|
|
3
|
+
import { POOL_NAME, StellarNetwork } from '../utils';
|
|
4
4
|
/**
|
|
5
5
|
* Approves an Sep41 allowance for a spender address, if the current allowance is insufficient.
|
|
6
6
|
* Allowance is required to do certain actions on the Huma protocol (e.g. makePayment for Autopay)
|
|
7
7
|
*
|
|
8
8
|
* @async
|
|
9
9
|
* @function
|
|
10
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
10
11
|
* @param {StellarNetwork} network - The stellar network.
|
|
11
12
|
* @param {StellarWallet} wallet - The wallet used to send the transaction.
|
|
12
|
-
* @param {string} tokenAddress - The address of the Sep41 token to approve.
|
|
13
13
|
* @param {string} spenderAddress - The address of the spender to approve an allowance for.
|
|
14
14
|
* @param {bigint} allowanceAmount - The amount of tokens to approve, if applicable. Denominated in the Sep41 tokens.
|
|
15
15
|
* @returns {Promise<SentTransaction<null> | null>} - A Promise of the transaction response, or null if the allowance was already sufficient.
|
|
16
16
|
*/
|
|
17
|
-
export declare function approveSep41AllowanceIfInsufficient(network: StellarNetwork, wallet: StellarWallet,
|
|
17
|
+
export declare function approveSep41AllowanceIfInsufficient(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, spenderAddress: string, allowanceAmount: bigint): Promise<SentTransaction<null> | null>;
|
|
@@ -8,35 +8,66 @@ const utils_1 = require("../utils");
|
|
|
8
8
|
*
|
|
9
9
|
* @async
|
|
10
10
|
* @function
|
|
11
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to get the contract instance for.
|
|
11
12
|
* @param {StellarNetwork} network - The stellar network.
|
|
12
13
|
* @param {StellarWallet} wallet - The wallet used to send the transaction.
|
|
13
|
-
* @param {string} tokenAddress - The address of the Sep41 token to approve.
|
|
14
14
|
* @param {string} spenderAddress - The address of the spender to approve an allowance for.
|
|
15
15
|
* @param {bigint} allowanceAmount - The amount of tokens to approve, if applicable. Denominated in the Sep41 tokens.
|
|
16
16
|
* @returns {Promise<SentTransaction<null> | null>} - A Promise of the transaction response, or null if the allowance was already sufficient.
|
|
17
17
|
*/
|
|
18
|
-
async function approveSep41AllowanceIfInsufficient(network, wallet,
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
async function approveSep41AllowanceIfInsufficient(poolName, network, wallet, spenderAddress, allowanceAmount) {
|
|
19
|
+
const underlyingTokenContext = new utils_1.TransactionContext(poolName, network, wallet, 'underlyingToken');
|
|
20
|
+
const { result: allowance } = await (0, utils_1.sendTransaction)({
|
|
21
|
+
context: underlyingTokenContext,
|
|
22
|
+
method: 'allowance',
|
|
23
|
+
params: [
|
|
24
|
+
{
|
|
25
|
+
name: 'from',
|
|
26
|
+
type: utils_1.ScValType.address,
|
|
27
|
+
value: wallet.userInfo.publicKey,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'spender',
|
|
31
|
+
type: utils_1.ScValType.address,
|
|
32
|
+
value: spenderAddress,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
});
|
|
36
|
+
const { result: decimals } = await (0, utils_1.sendTransaction)({
|
|
37
|
+
context: underlyingTokenContext,
|
|
38
|
+
method: 'decimals',
|
|
39
|
+
});
|
|
27
40
|
if (allowance < allowanceAmount) {
|
|
28
41
|
const latestLedger = await (0, utils_1.getLatestLedger)(network);
|
|
29
42
|
// @TODO find a better to advance the ledger number
|
|
30
43
|
const advanceLedgerNum = 3000000;
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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,
|
|
38
70
|
});
|
|
39
|
-
const result = await tx.signAndSend();
|
|
40
71
|
return result;
|
|
41
72
|
}
|
|
42
73
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sep41ContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/Sep41ContractHelper.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"Sep41ContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/Sep41ContractHelper.ts"],"names":[],"mappings":";;;AAGA,oCAOiB;AAEjB;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,mCAAmC,CACvD,QAAmB,EACnB,OAAuB,EACvB,MAAqB,EACrB,cAAsB,EACtB,eAAuB;IAEvB,MAAM,sBAAsB,GAAG,IAAI,0BAAkB,CACnD,QAAQ,EACR,OAAO,EACP,MAAM,EACN,iBAAiB,CAClB,CAAA;IAED,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAA,uBAAe,EAAS;QAC1D,OAAO,EAAE,sBAAsB;QAC/B,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,iBAAS,CAAC,OAAO;gBACvB,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS;aACjC;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,iBAAS,CAAC,OAAO;gBACvB,KAAK,EAAE,cAAc;aACtB;SACF;KACF,CAAC,CAAA;IACF,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAA,uBAAe,EAAS;QACzD,OAAO,EAAE,sBAAsB;QAC/B,MAAM,EAAE,UAAU;KACnB,CAAC,CAAA;IAEF,IAAI,SAAS,GAAG,eAAe,EAAE;QAC/B,MAAM,YAAY,GAAG,MAAM,IAAA,uBAAe,EAAC,OAAO,CAAC,CAAA;QACnD,mDAAmD;QACnD,MAAM,gBAAgB,GAAG,OAAS,CAAA;QAElC,MAAM,MAAM,GAAG,MAAM,IAAA,uBAAe,EAAC;YACnC,OAAO,EAAE,sBAAsB;YAC/B,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE;gBACN;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,iBAAS,CAAC,OAAO;oBACvB,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS;iBACjC;gBACD;oBACE,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,iBAAS,CAAC,OAAO;oBACvB,KAAK,EAAE,cAAc;iBACtB;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,iBAAS,CAAC,IAAI;oBACpB,KAAK,EAAE,UAAY,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;iBACrD;gBACD;oBACE,IAAI,EAAE,mBAAmB;oBACzB,IAAI,EAAE,iBAAS,CAAC,GAAG;oBACnB,KAAK,EAAE,YAAY,CAAC,QAAQ,GAAG,gBAAgB;iBAChD;aACF;YACD,qBAAqB,EAAE,IAAI;SAC5B,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;KACd;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAxED,kFAwEC"}
|
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _StellarWallet_sourceKeypair;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.StellarWallet = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
4
6
|
const stellar_sdk_1 = require("@stellar/stellar-sdk");
|
|
5
7
|
class StellarWallet {
|
|
6
8
|
constructor(secretKey) {
|
|
7
|
-
this
|
|
9
|
+
_StellarWallet_sourceKeypair.set(this, void 0);
|
|
10
|
+
tslib_1.__classPrivateFieldSet(this, _StellarWallet_sourceKeypair, stellar_sdk_1.Keypair.fromSecret(secretKey), "f");
|
|
11
|
+
}
|
|
12
|
+
get keypair() {
|
|
13
|
+
return tslib_1.__classPrivateFieldGet(this, _StellarWallet_sourceKeypair, "f");
|
|
8
14
|
}
|
|
9
15
|
get userInfo() {
|
|
10
16
|
return {
|
|
11
|
-
publicKey: this.
|
|
17
|
+
publicKey: tslib_1.__classPrivateFieldGet(this, _StellarWallet_sourceKeypair, "f").publicKey(),
|
|
12
18
|
};
|
|
13
19
|
}
|
|
14
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
21
|
async signTransaction(tx, opts) {
|
|
16
22
|
const txFromXDR = new stellar_sdk_1.Transaction(tx, opts.networkPassphrase);
|
|
17
|
-
txFromXDR.sign(this
|
|
23
|
+
txFromXDR.sign(tslib_1.__classPrivateFieldGet(this, _StellarWallet_sourceKeypair, "f"));
|
|
18
24
|
return txFromXDR.toXDR();
|
|
19
25
|
}
|
|
20
26
|
}
|
|
21
27
|
exports.StellarWallet = StellarWallet;
|
|
28
|
+
_StellarWallet_sourceKeypair = new WeakMap();
|
|
22
29
|
//# sourceMappingURL=StellarWallet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StellarWallet.js","sourceRoot":"","sources":["../../../src/services/StellarWallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StellarWallet.js","sourceRoot":"","sources":["../../../src/services/StellarWallet.ts"],"names":[],"mappings":";;;;;AAAA,sDAA2D;AAE3D,MAAa,aAAa;IAGxB,YAAY,SAAiB;QAF7B,+CAAuB;QAGrB,+BAAA,IAAI,gCAAkB,qBAAO,CAAC,UAAU,CAAC,SAAS,CAAC,MAAA,CAAA;IACrD,CAAC;IAED,IAAI,OAAO;QACT,OAAO,+BAAA,IAAI,oCAAe,CAAA;IAC5B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO;YACL,SAAS,EAAE,+BAAA,IAAI,oCAAe,CAAC,SAAS,EAAE;SAC3C,CAAA;IACH,CAAC;IAED,8DAA8D;IACvD,KAAK,CAAC,eAAe,CAAC,EAAU,EAAE,IAAS;QAChD,MAAM,SAAS,GAAG,IAAI,yBAAW,CAAC,EAAE,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAA;QAC7D,SAAS,CAAC,IAAI,CAAC,+BAAA,IAAI,oCAAe,CAAC,CAAA;QACnC,OAAO,SAAS,CAAC,KAAK,EAAE,CAAA;IAC1B,CAAC;CACF;AAvBD,sCAuBC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Client as CreditStorageClient } from '@huma-finance/soroban-credit-storage';
|
|
2
1
|
import { Client as CreditManagerClient } from '@huma-finance/soroban-credit-manager';
|
|
2
|
+
import { Client as CreditStorageClient } from '@huma-finance/soroban-credit-storage';
|
|
3
3
|
import { Client as PoolClient } from '@huma-finance/soroban-pool';
|
|
4
4
|
import { Client as PoolCreditClient } from '@huma-finance/soroban-pool-credit';
|
|
5
5
|
import { Client as PoolStorageClient } from '@huma-finance/soroban-pool-storage';
|
|
6
|
-
import { Client as TrancheVaultClient } from '@huma-finance/soroban-tranche-vault';
|
|
7
6
|
import { Client as Sep41Client } from '@huma-finance/soroban-sep41';
|
|
7
|
+
import { Client as TrancheVaultClient } from '@huma-finance/soroban-tranche-vault';
|
|
8
8
|
import { StellarWallet } from '../services/StellarWallet';
|
|
9
|
-
import { POOL_NAME, StellarNetwork } from './network';
|
|
9
|
+
import { ContractType, POOL_NAME, StellarNetwork } from './network';
|
|
10
|
+
export type Client = PoolCreditClient | CreditStorageClient | CreditManagerClient | PoolClient | PoolStorageClient | TrancheVaultClient | Sep41Client;
|
|
10
11
|
export declare const getPoolClient: (poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet) => PoolClient | undefined;
|
|
11
12
|
export declare const getPoolStorageClient: (poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet) => PoolStorageClient | undefined;
|
|
12
13
|
export declare const getPoolCreditClient: (poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet) => PoolCreditClient | undefined;
|
|
@@ -14,3 +15,11 @@ export declare const getCreditStorageClient: (poolName: POOL_NAME, network: Stel
|
|
|
14
15
|
export declare const getCreditManagerClient: (poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet) => CreditManagerClient | undefined;
|
|
15
16
|
export declare const getTrancheVaultClient: (poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, tranche: 'senior' | 'junior') => TrancheVaultClient | undefined;
|
|
16
17
|
export declare const getUnderlyingTokenClient: (tokenAddress: string, network: StellarNetwork, wallet: StellarWallet) => Sep41Client;
|
|
18
|
+
export declare class TransactionContext {
|
|
19
|
+
#private;
|
|
20
|
+
constructor(poolName: POOL_NAME, network: StellarNetwork, wallet: StellarWallet, contractType: ContractType);
|
|
21
|
+
get client(): Client;
|
|
22
|
+
get wallet(): StellarWallet;
|
|
23
|
+
get network(): StellarNetwork;
|
|
24
|
+
get contractId(): string;
|
|
25
|
+
}
|