@huma-finance/sdk 0.0.11 → 0.0.13
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 +482 -0
- package/README.md +9 -5
- package/dist/cjs/graphql/generatedTypes.d.ts +40 -0
- package/dist/cjs/graphql/generatedTypes.js +9 -0
- package/dist/cjs/graphql/generatedTypes.js.map +1 -0
- package/dist/cjs/graphql/index.d.ts +1 -0
- package/dist/cjs/graphql/index.js +5 -0
- package/dist/cjs/graphql/index.js.map +1 -0
- package/dist/cjs/helpers/PoolContractHelper.d.ts +30 -1
- package/dist/cjs/helpers/PoolContractHelper.js +45 -1
- package/dist/cjs/helpers/PoolContractHelper.js.map +1 -1
- package/dist/cjs/services/ARWeaveService.d.ts +1 -18
- package/dist/cjs/services/ARWeaveService.js +17 -51
- package/dist/cjs/services/ARWeaveService.js.map +1 -1
- package/dist/cjs/services/ReceivableService.d.ts +11 -0
- package/dist/cjs/services/ReceivableService.js +71 -20
- package/dist/cjs/services/ReceivableService.js.map +1 -1
- package/dist/graphql/generatedTypes.d.ts +40 -0
- package/dist/graphql/generatedTypes.js +5 -0
- package/dist/graphql/generatedTypes.js.map +1 -0
- package/dist/graphql/index.d.ts +1 -0
- package/dist/graphql/index.js +2 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
- package/dist/helpers/ERC20TransferableReceivableContractHelper.js +17 -17
- package/dist/helpers/PoolContractHelper.d.ts +41 -12
- package/dist/helpers/PoolContractHelper.js +58 -16
- package/dist/helpers/PoolContractHelper.js.map +1 -1
- package/dist/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
- package/dist/helpers/RealWorldReceivableContractHelper.js +17 -17
- package/dist/helpers/index.d.ts +3 -3
- package/dist/helpers/index.js +3 -3
- package/dist/hooks/index.d.ts +4 -4
- package/dist/hooks/index.js +4 -4
- package/dist/hooks/useContract.d.ts +13 -13
- package/dist/hooks/useContract.js +26 -26
- package/dist/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
- package/dist/hooks/useERC20TransferableReceivableContract.js +16 -16
- package/dist/hooks/usePoolContract.d.ts +60 -60
- package/dist/hooks/usePoolContract.js +48 -48
- package/dist/hooks/useRealWorldReceivableContract.d.ts +10 -10
- package/dist/hooks/useRealWorldReceivableContract.js +15 -15
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/services/ARWeaveService.d.ts +81 -84
- package/dist/services/ARWeaveService.js +133 -144
- package/dist/services/ARWeaveService.js.map +1 -1
- package/dist/services/EAService.d.ts +18 -18
- package/dist/services/EAService.js +9 -9
- package/dist/services/ReceivableService.d.ts +87 -76
- package/dist/services/ReceivableService.js +182 -132
- package/dist/services/ReceivableService.js.map +1 -1
- package/dist/services/SubgraphService.d.ts +53 -53
- package/dist/services/SubgraphService.js +79 -79
- package/dist/services/index.d.ts +4 -4
- package/dist/services/index.js +4 -4
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/utils/chain.d.ts +14 -14
- package/dist/utils/chain.js +28 -28
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +3 -3
- package/dist/utils/poolInfo.d.ts +9 -9
- package/dist/utils/poolInfo.js +9 -9
- package/dist/utils/web3.d.ts +4 -4
- package/dist/utils/web3.js +23 -23
- package/getting-started.md +191 -0
- package/package.json +13 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPoolContract = void 0;
|
|
3
|
+
exports.makePaymentToPool = exports.drawdownFromPool = exports.getPoolContract = void 0;
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
/**
|
|
6
6
|
* Returns an ethers contract instance for a Huma pool contract
|
|
@@ -18,4 +18,48 @@ function getPoolContract(signerOrProvider, chainId, poolName, poolType) {
|
|
|
18
18
|
return (0, utils_1.getContract)(poolInfo.pool, poolInfo.poolAbi, signerOrProvider);
|
|
19
19
|
}
|
|
20
20
|
exports.getPoolContract = getPoolContract;
|
|
21
|
+
/**
|
|
22
|
+
* Calls drawdown on a Huma pool contract
|
|
23
|
+
*
|
|
24
|
+
* @async
|
|
25
|
+
* @function
|
|
26
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
27
|
+
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
28
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
29
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
30
|
+
* @param {BigNumberish} drawdownAmount - The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.
|
|
31
|
+
* @param {Overrides} gasOpts - The gas options to use for the transaction.
|
|
32
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
33
|
+
*/
|
|
34
|
+
function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, gasOpts = {}) {
|
|
35
|
+
const poolContract = getPoolContract(signer, chainId, poolName, poolType);
|
|
36
|
+
if (!poolContract) {
|
|
37
|
+
throw new Error('Could not find pool contract');
|
|
38
|
+
}
|
|
39
|
+
// TODO: Generate typechain for pool contract
|
|
40
|
+
return poolContract.drawdown(drawdownAmount, gasOpts);
|
|
41
|
+
}
|
|
42
|
+
exports.drawdownFromPool = drawdownFromPool;
|
|
43
|
+
/**
|
|
44
|
+
* Calls drawdown on a Huma pool contract
|
|
45
|
+
*
|
|
46
|
+
* @async
|
|
47
|
+
* @function
|
|
48
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
49
|
+
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
50
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
51
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
52
|
+
* @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
|
|
53
|
+
* @param {Overrides} gasOpts - The gas options to use for the transaction.
|
|
54
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
55
|
+
*/
|
|
56
|
+
async function makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, gasOpts = {}) {
|
|
57
|
+
const poolContract = getPoolContract(signer, chainId, poolName, poolType);
|
|
58
|
+
if (!poolContract) {
|
|
59
|
+
throw new Error('Could not find pool contract');
|
|
60
|
+
}
|
|
61
|
+
// TODO: Generate typechain for pool contract
|
|
62
|
+
return poolContract.makePayment(await signer.getAddress(), paymentAmount, gasOpts);
|
|
63
|
+
}
|
|
64
|
+
exports.makePaymentToPool = makePaymentToPool;
|
|
21
65
|
//# sourceMappingURL=PoolContractHelper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":";;;AAIA,oCAAmD;AAEnD;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAC7B,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1B,OAAO,IAAA,mBAAW,EAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;AACvE,CAAC;AAXD,0CAWC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,gBAAgB,CAC9B,MAAqB,EACrB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,cAA4B,EAC5B,UAAqB,EAAE;IAEvB,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzE,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IAED,6CAA6C;IAC7C,OAAO,YAAY,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AACvD,CAAC;AAhBD,4CAgBC;AAED;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,iBAAiB,CACrC,MAAqB,EACrB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,aAA2B,EAC3B,UAAqB,EAAE;IAEvB,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzE,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IAED,6CAA6C;IAC7C,OAAO,YAAY,CAAC,WAAW,CAC7B,MAAM,MAAM,CAAC,UAAU,EAAE,EACzB,aAAa,EACb,OAAO,CACR,CAAA;AACH,CAAC;AApBD,8CAoBC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { FundResponse, UploadResponse } from '@bundlr-network/client/build/common/types';
|
|
2
2
|
import { Web3Provider } from '@ethersproject/providers';
|
|
3
|
-
import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
4
|
-
import { BigNumber } from 'ethers';
|
|
5
3
|
/**
|
|
6
4
|
* The configuration for Bundlr network instances
|
|
7
5
|
*
|
|
@@ -38,18 +36,6 @@ export declare function getBundlrNetworkConfig(chainId: number): BundlrConfig;
|
|
|
38
36
|
* @returns {Promise<FundResponse>} - The fund response.
|
|
39
37
|
*/
|
|
40
38
|
declare function prefundBundlr(config: BundlrConfig, signer: any, amount: number): Promise<FundResponse>;
|
|
41
|
-
/**
|
|
42
|
-
* Get the running balance on Bundlr network, in atomic units (the smallest unit of a given currency)
|
|
43
|
-
*
|
|
44
|
-
* @async
|
|
45
|
-
* @function
|
|
46
|
-
* @memberof ArweaveService
|
|
47
|
-
* @param {BundlrConfig} config - The configuration for the Bundlr network.
|
|
48
|
-
* @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
|
|
49
|
-
* @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
|
|
50
|
-
* @returns {Promise<FundResponse>} - The fund response.
|
|
51
|
-
*/
|
|
52
|
-
declare function getBundlrBalance(config: BundlrConfig, signer: any): Promise<BigNumber>;
|
|
53
39
|
/**
|
|
54
40
|
* Store data on ARWeave using the Bundlr Network.
|
|
55
41
|
*
|
|
@@ -77,19 +63,16 @@ declare function storeData(config: BundlrConfig, signerOrPrivateKey: Web3Provide
|
|
|
77
63
|
* @function
|
|
78
64
|
* @memberof ArweaveService
|
|
79
65
|
* @param {number} chainId - The chain ID.
|
|
80
|
-
* @param {POOL_NAME} poolName - The pool name tag to query.
|
|
81
|
-
* @param {POOL_TYPE} poolType - The pool type tag to query.
|
|
82
66
|
* @param {string} sender - The sender tag to query.
|
|
83
67
|
* @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
|
|
84
68
|
* @returns {Promise<any>} Promise resolving with the queried data.
|
|
85
69
|
*/
|
|
86
|
-
declare function queryForMetadata(chainId: number,
|
|
70
|
+
declare function queryForMetadata(chainId: number, sender: string, referenceId: string): Promise<string | null>;
|
|
87
71
|
/**
|
|
88
72
|
* An object that contains functions to interact with Huma-related data stored on ARWeave
|
|
89
73
|
* @namespace ARWeaveService
|
|
90
74
|
*/
|
|
91
75
|
export declare const ARWeaveService: {
|
|
92
|
-
getBundlrBalance: typeof getBundlrBalance;
|
|
93
76
|
queryForMetadata: typeof queryForMetadata;
|
|
94
77
|
storeData: typeof storeData;
|
|
95
78
|
prefundBundlr: typeof prefundBundlr;
|
|
@@ -4,7 +4,6 @@ exports.ARWeaveService = exports.getBundlrNetworkConfig = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const client_1 = tslib_1.__importDefault(require("@bundlr-network/client"));
|
|
6
6
|
const graphql_request_1 = tslib_1.__importStar(require("graphql-request"));
|
|
7
|
-
const ethers_1 = require("ethers");
|
|
8
7
|
/**
|
|
9
8
|
* Get the configuration for Bundlr network given a chain ID
|
|
10
9
|
*
|
|
@@ -57,27 +56,6 @@ signer, amount) {
|
|
|
57
56
|
await bundlr.ready();
|
|
58
57
|
return bundlr.fund(amount);
|
|
59
58
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Get the running balance on Bundlr network, in atomic units (the smallest unit of a given currency)
|
|
62
|
-
*
|
|
63
|
-
* @async
|
|
64
|
-
* @function
|
|
65
|
-
* @memberof ArweaveService
|
|
66
|
-
* @param {BundlrConfig} config - The configuration for the Bundlr network.
|
|
67
|
-
* @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
|
|
68
|
-
* @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
|
|
69
|
-
* @returns {Promise<FundResponse>} - The fund response.
|
|
70
|
-
*/
|
|
71
|
-
async function getBundlrBalance(config,
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
-
signer) {
|
|
74
|
-
const bundlr = new client_1.default(config.nodeUrl, config.currency, signer, config.providerUrl
|
|
75
|
-
? {
|
|
76
|
-
providerUrl: config.providerUrl,
|
|
77
|
-
}
|
|
78
|
-
: undefined);
|
|
79
|
-
return ethers_1.BigNumber.from(await bundlr.getLoadedBalance());
|
|
80
|
-
}
|
|
81
59
|
/**
|
|
82
60
|
* Store data on ARWeave using the Bundlr Network.
|
|
83
61
|
*
|
|
@@ -119,43 +97,32 @@ async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true
|
|
|
119
97
|
* @function
|
|
120
98
|
* @memberof ArweaveService
|
|
121
99
|
* @param {number} chainId - The chain ID.
|
|
122
|
-
* @param {POOL_NAME} poolName - The pool name tag to query.
|
|
123
|
-
* @param {POOL_TYPE} poolType - The pool type tag to query.
|
|
124
100
|
* @param {string} sender - The sender tag to query.
|
|
125
101
|
* @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
|
|
126
102
|
* @returns {Promise<any>} Promise resolving with the queried data.
|
|
127
103
|
*/
|
|
128
|
-
async function queryForMetadata(chainId,
|
|
104
|
+
async function queryForMetadata(chainId, sender, referenceId) {
|
|
129
105
|
var _a, _b, _c, _d;
|
|
130
106
|
const config = getBundlrNetworkConfig(chainId);
|
|
131
|
-
const query = (0, graphql_request_1.gql) `
|
|
132
|
-
query ArweaveHumaMetadataQuery(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
edges {
|
|
148
|
-
node {
|
|
149
|
-
id
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
107
|
+
const query = (0, graphql_request_1.gql) `
|
|
108
|
+
query ArweaveHumaMetadataQuery($sender: String!, $referenceId: String!) {
|
|
109
|
+
transactions(
|
|
110
|
+
owners: [$sender]
|
|
111
|
+
tags: [
|
|
112
|
+
{ name: "appName", values: ["HumaFinance"] }
|
|
113
|
+
{ name: "referenceId", values: [$referenceId] }
|
|
114
|
+
]
|
|
115
|
+
) {
|
|
116
|
+
edges {
|
|
117
|
+
node {
|
|
118
|
+
id
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
154
123
|
`;
|
|
155
124
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
156
125
|
const data = await (0, graphql_request_1.default)(`${config.nodeUrl}/graphql`, query, {
|
|
157
|
-
poolName,
|
|
158
|
-
poolType,
|
|
159
126
|
sender,
|
|
160
127
|
referenceId,
|
|
161
128
|
});
|
|
@@ -166,7 +133,6 @@ async function queryForMetadata(chainId, poolName, poolType, sender, referenceId
|
|
|
166
133
|
* @namespace ARWeaveService
|
|
167
134
|
*/
|
|
168
135
|
exports.ARWeaveService = {
|
|
169
|
-
getBundlrBalance,
|
|
170
136
|
queryForMetadata,
|
|
171
137
|
storeData,
|
|
172
138
|
prefundBundlr,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../../src/services/ARWeaveService.ts"],"names":[],"mappings":";;;;AAAA,4EAA2C;AAM3C,2EAA8C;
|
|
1
|
+
{"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../../src/services/ARWeaveService.ts"],"names":[],"mappings":";;;;AAAA,4EAA2C;AAM3C,2EAA8C;AAkB9C;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CAAC,OAAe;IACpD,QAAQ,OAAO,EAAE;QACf,KAAK,CAAC;YACJ,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,UAAU;gBACpB,WAAW,EACT,8DAA8D;aACjE,CAAA;QACH,KAAK,KAAK;YACR,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,OAAO;gBACjB,WAAW,EAAE,gCAAgC;aAC9C,CAAA;QACH;YACE,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,EAAE;aACb,CAAA;KACJ;AACH,CAAC;AArBD,wDAqBC;AAED;;;;;;;;;;GAUG;AACH,KAAK,UAAU,aAAa,CAC1B,MAAoB;AACpB,8DAA8D;AAC9D,MAAW,EACX,MAAc;IAEd,MAAM,MAAM,GAAG,IAAI,gBAAM,CACvB,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,QAAQ,EACf,MAAM,EACN,MAAM,CAAC,WAAW;QAChB,CAAC,CAAC;YACE,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC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BAAG,EAAA;;;;;;;;;;;;;;;;GAgBhB,CAAA;IAED,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,IAAA,yBAAO,EAAC,GAAG,MAAM,CAAC,OAAO,UAAU,EAAE,KAAK,EAAE;QAClE,MAAM;QACN,WAAW;KACZ,CAAC,CAAA;IAEF,OAAO,MAAA,MAAA,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,0CAAE,KAAK,0CAAG,CAAC,CAAC,0CAAE,IAAI,0CAAE,EAAE,CAAA;AACjD,CAAC;AAED;;;GAGG;AACU,QAAA,cAAc,GAAG;IAC5B,gBAAgB;IAChB,SAAS;IACT,aAAa;IACb,sBAAsB;CACvB,CAAA"}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { TransactionResponse, Web3Provider } from '@ethersproject/providers';
|
|
2
2
|
import { BigNumberish, ethers, Overrides } from 'ethers';
|
|
3
3
|
import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
4
|
+
/**
|
|
5
|
+
* Declares a payment on a RealWorldReceivable given a reference ID of the receivable, which was used as an index for ARWeave data.
|
|
6
|
+
*
|
|
7
|
+
* @async
|
|
8
|
+
* @function
|
|
9
|
+
* @memberof ReceivableService
|
|
10
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
|
|
11
|
+
* @param {string} referenceId - An internal identifier value added as a tag on ARWeave
|
|
12
|
+
* @param {number} paymentAmount - The amount to declare paid to the receivable.
|
|
13
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
|
|
14
|
+
*/
|
|
4
15
|
declare function declareReceivablePaymentByReferenceId(signer: ethers.Signer, referenceId: string, paymentAmount: number): Promise<TransactionResponse>;
|
|
5
16
|
/**
|
|
6
17
|
* Declares a payment on a RealWorldReceivable given a tokenID of the receivable.
|
|
@@ -1,19 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReceivableService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const providers_1 = require("@ethersproject/providers");
|
|
5
6
|
const shared_1 = require("@huma-finance/shared");
|
|
6
|
-
const
|
|
7
|
+
const graphql_request_1 = tslib_1.__importStar(require("graphql-request"));
|
|
7
8
|
const ARWeaveService_1 = require("./ARWeaveService");
|
|
9
|
+
const helpers_1 = require("../helpers");
|
|
8
10
|
const chain_1 = require("../utils/chain");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Declares a payment on a RealWorldReceivable given a reference ID of the receivable, which was used as an index for ARWeave data.
|
|
13
|
+
*
|
|
14
|
+
* @async
|
|
15
|
+
* @function
|
|
16
|
+
* @memberof ReceivableService
|
|
17
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
|
|
18
|
+
* @param {string} referenceId - An internal identifier value added as a tag on ARWeave
|
|
19
|
+
* @param {number} paymentAmount - The amount to declare paid to the receivable.
|
|
20
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
|
|
21
|
+
*/
|
|
22
|
+
async function declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount) {
|
|
23
|
+
var _a, _b, _c;
|
|
24
|
+
const chainId = await (0, chain_1.getChainIdFromSignerOrProvider)(signer);
|
|
25
|
+
const signerAddress = await signer.getAddress();
|
|
26
|
+
if (!chainId) {
|
|
27
|
+
throw new Error('No Chain ID found');
|
|
28
|
+
}
|
|
29
|
+
// Get ARWeave ID
|
|
30
|
+
const dataID = await ARWeaveService_1.ARWeaveService.queryForMetadata(chainId, signerAddress, referenceId);
|
|
31
|
+
// Fetch receivables with the same ARWeave ID
|
|
32
|
+
const receivablesQuery = (0, graphql_request_1.gql) `
|
|
33
|
+
query ReceivablesByURIQuery($owner: String!, $uri: String!) {
|
|
34
|
+
receivables(where: { owner: $owner, uri: $uri }) {
|
|
35
|
+
...ReceivableFields
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
fragment ReceivableFields on Receivable {
|
|
40
|
+
tokenId
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
let receivableSubgraph;
|
|
44
|
+
switch (chainId) {
|
|
45
|
+
case shared_1.ChainEnum.Goerli:
|
|
46
|
+
receivableSubgraph = `https://api.thegraph.com/subgraphs/name/00labs/huma-receivables-goerli`;
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
throw new Error('No receivable subgraph exists for this chain');
|
|
50
|
+
}
|
|
51
|
+
const receivablesData = await (0, graphql_request_1.default)(receivableSubgraph, receivablesQuery, {
|
|
52
|
+
owner: signerAddress,
|
|
53
|
+
uri: `https://arweave.net/${dataID}`,
|
|
54
|
+
});
|
|
55
|
+
if (!(receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.receivables) || !((_a = receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.receivables) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
56
|
+
throw new Error('No receivables found with this ARWeave ID.');
|
|
57
|
+
}
|
|
58
|
+
else if (((_b = receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.receivables) === null || _b === void 0 ? void 0 : _b.length) > 1) {
|
|
59
|
+
throw new Error(`This owner has multiple receivables with the same URI. Please burn
|
|
60
|
+
unnecessary receivables or pay the correct token manually using declareReceivablePaymentByTokenId`);
|
|
61
|
+
}
|
|
62
|
+
const contract = (0, helpers_1.getRealWorldReceivableContract)(signer, chainId);
|
|
63
|
+
if (!contract) {
|
|
64
|
+
throw new Error('Could not find RealWorldReceivable contract');
|
|
65
|
+
}
|
|
66
|
+
return contract.declarePayment((_c = receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.receivables[0]) === null || _c === void 0 ? void 0 : _c.tokenId, paymentAmount);
|
|
17
67
|
}
|
|
18
68
|
/**
|
|
19
69
|
* Declares a payment on a RealWorldReceivable given a tokenID of the receivable.
|
|
@@ -30,13 +80,14 @@ paymentAmount) {
|
|
|
30
80
|
async function declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount) {
|
|
31
81
|
var _a;
|
|
32
82
|
const chainId = await (0, chain_1.getChainIdFromSignerOrProvider)(signer);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
83
|
+
if (!chainId) {
|
|
84
|
+
throw new Error('No Chain ID found');
|
|
85
|
+
}
|
|
86
|
+
const realWorldReceivable = (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.RealWorldReceivable];
|
|
36
87
|
if (!realWorldReceivable) {
|
|
37
88
|
throw new Error('RealWorldReceivable is not available on this network');
|
|
38
89
|
}
|
|
39
|
-
const contract = (0,
|
|
90
|
+
const contract = (0, helpers_1.getRealWorldReceivableContract)(signer, chainId);
|
|
40
91
|
if (!contract) {
|
|
41
92
|
throw new Error('Could not find RealWorldReceivable contract');
|
|
42
93
|
}
|
|
@@ -60,18 +111,18 @@ async function declareReceivablePaymentByTokenId(signer, receivableTokenId, paym
|
|
|
60
111
|
* @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
|
|
61
112
|
*/
|
|
62
113
|
async function createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, gasOpts = {}) {
|
|
63
|
-
var _a, _b
|
|
114
|
+
var _a, _b;
|
|
64
115
|
const chainId = await (0, chain_1.getChainIdFromSignerOrProvider)(signer);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
116
|
+
if (!chainId) {
|
|
117
|
+
throw new Error('No Chain ID found');
|
|
118
|
+
}
|
|
68
119
|
const poolInfo = chainId
|
|
69
|
-
? (
|
|
120
|
+
? (_b = (_a = shared_1.PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[poolType]) === null || _b === void 0 ? void 0 : _b[poolName]
|
|
70
121
|
: undefined;
|
|
71
|
-
if (!
|
|
122
|
+
if (!poolInfo) {
|
|
72
123
|
throw new Error('RealWorldReceivable is not available on this network');
|
|
73
124
|
}
|
|
74
|
-
const contract = (0,
|
|
125
|
+
const contract = (0, helpers_1.getRealWorldReceivableContract)(signer, chainId);
|
|
75
126
|
if (!contract) {
|
|
76
127
|
throw new Error('Could not find RealWorldReceivable contract');
|
|
77
128
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReceivableService.js","sourceRoot":"","sources":["../../../src/services/ReceivableService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ReceivableService.js","sourceRoot":"","sources":["../../../src/services/ReceivableService.ts"],"names":[],"mappings":";;;;AAAA,wDAA4E;AAE5E,iDAO6B;AAC7B,2EAA8C;AAE9C,qDAAiD;AACjD,wCAA2D;AAC3D,0CAA+D;AAG/D;;;;;;;;;;GAUG;AACH,KAAK,UAAU,qCAAqC,CAClD,MAAqB,EACrB,WAAmB,EACnB,aAAqB;;IAErB,MAAM,OAAO,GAAG,MAAM,IAAA,sCAA8B,EAAC,MAAM,CAAC,CAAA;IAC5D,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAA;IAE/C,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;KACrC;IAED,iBAAiB;IACjB,MAAM,MAAM,GAAG,MAAM,+BAAc,CAAC,gBAAgB,CAClD,OAAO,EACP,aAAa,EACb,WAAW,CACZ,CAAA;IAED,6CAA6C;IAC7C,MAAM,gBAAgB,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;GAU3B,CAAA;IAED,IAAI,kBAAkB,CAAA;IACtB,QAAQ,OAAO,EAAE;QACf,KAAK,kBAAS,CAAC,MAAM;YACnB,kBAAkB,GAAG,wEAAwE,CAAA;YAC7F,MAAK;QACP;YACE,MAAM,IAAI,KAAK,CAAC,8CAA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AAA;QAChB,MAAM,CAAC,CAAA;KACR;AACH,CAAC;AAED;;;GAGG;AACU,QAAA,iBAAiB,GAAG;IAC/B,4BAA4B;IAC5B,gBAAgB;IAChB,iCAAiC;IACjC,qCAAqC;CACtC,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { GraphQLClient } from 'graphql-request';
|
|
2
|
+
export type Maybe<T> = T | null;
|
|
3
|
+
export type InputMaybe<T> = Maybe<T>;
|
|
4
|
+
export type Exact<T extends {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}> = {
|
|
7
|
+
[K in keyof T]: T[K];
|
|
8
|
+
};
|
|
9
|
+
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
10
|
+
[SubKey in K]?: Maybe<T[SubKey]>;
|
|
11
|
+
};
|
|
12
|
+
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
|
|
13
|
+
[SubKey in K]: Maybe<T[SubKey]>;
|
|
14
|
+
};
|
|
15
|
+
/** All built-in and custom scalars, mapped to their actual values */
|
|
16
|
+
export type Scalars = {
|
|
17
|
+
ID: string;
|
|
18
|
+
String: string;
|
|
19
|
+
Boolean: boolean;
|
|
20
|
+
Int: number;
|
|
21
|
+
Float: number;
|
|
22
|
+
};
|
|
23
|
+
export type Receivable = {
|
|
24
|
+
__typename?: 'Receivable';
|
|
25
|
+
creationDate?: Maybe<Scalars['String']>;
|
|
26
|
+
currencyCode?: Maybe<Scalars['String']>;
|
|
27
|
+
id?: Maybe<Scalars['String']>;
|
|
28
|
+
lastUpdate?: Maybe<Scalars['String']>;
|
|
29
|
+
maturityDate?: Maybe<Scalars['String']>;
|
|
30
|
+
owner?: Maybe<Scalars['String']>;
|
|
31
|
+
paidAmount?: Maybe<Scalars['String']>;
|
|
32
|
+
pool?: Maybe<Scalars['String']>;
|
|
33
|
+
receivableAmount?: Maybe<Scalars['String']>;
|
|
34
|
+
status?: Maybe<Scalars['String']>;
|
|
35
|
+
tokenId?: Maybe<Scalars['String']>;
|
|
36
|
+
uri?: Maybe<Scalars['String']>;
|
|
37
|
+
};
|
|
38
|
+
export type SdkFunctionWrapper = <T>(action: (requestHeaders?: Record<string, string>) => Promise<T>, operationName: string, operationType?: string) => Promise<T>;
|
|
39
|
+
export declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper): {};
|
|
40
|
+
export type Sdk = ReturnType<typeof getSdk>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatedTypes.js","sourceRoot":"","sources":["../../src/graphql/generatedTypes.ts"],"names":[],"mappings":"AA8CA,MAAM,cAAc,GAAuB,CACzC,MAAM,EACN,cAAc,EACd,cAAc,EACd,EAAE,CAAC,MAAM,EAAE,CAAA;AAEb,MAAM,UAAU,MAAM,CACpB,MAAqB,EACrB,cAAkC,cAAc;IAEhD,OAAO,EAAE,CAAA;AACX,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './generatedTypes';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graphql/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Contract, ethers } from 'ethers';
|
|
2
|
-
/**
|
|
3
|
-
* Returns an ethers contract instance for the ERC20TransferableReceivable contract
|
|
4
|
-
* associated with the given pool name on the current chain.
|
|
5
|
-
*
|
|
6
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
7
|
-
* @param {number} chainId The chain id where the contract instance exists
|
|
8
|
-
* @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getERC20TransferableReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
|
|
1
|
+
import { Contract, ethers } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an ethers contract instance for the ERC20TransferableReceivable contract
|
|
4
|
+
* associated with the given pool name on the current chain.
|
|
5
|
+
*
|
|
6
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
7
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
8
|
+
* @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getERC20TransferableReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ERC20_TRANSFERABLE_RECEIVABLE_ABI, SupplementaryContracts, SupplementaryContractsMap, } from '@huma-finance/shared';
|
|
2
|
-
import { getContract } from '../utils';
|
|
3
|
-
/**
|
|
4
|
-
* Returns an ethers contract instance for the ERC20TransferableReceivable contract
|
|
5
|
-
* associated with the given pool name on the current chain.
|
|
6
|
-
*
|
|
7
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
8
|
-
* @param {number} chainId The chain id where the contract instance exists
|
|
9
|
-
* @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
|
|
10
|
-
*/
|
|
11
|
-
export function getERC20TransferableReceivableContract(signerOrProvider, chainId) {
|
|
12
|
-
var _a;
|
|
13
|
-
const erc20TransferableReceiable = (_a = SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[SupplementaryContracts.ERC20TransferableReceivable];
|
|
14
|
-
if (!erc20TransferableReceiable)
|
|
15
|
-
return null;
|
|
16
|
-
return getContract(erc20TransferableReceiable, ERC20_TRANSFERABLE_RECEIVABLE_ABI, signerOrProvider);
|
|
17
|
-
}
|
|
1
|
+
import { ERC20_TRANSFERABLE_RECEIVABLE_ABI, SupplementaryContracts, SupplementaryContractsMap, } from '@huma-finance/shared';
|
|
2
|
+
import { getContract } from '../utils';
|
|
3
|
+
/**
|
|
4
|
+
* Returns an ethers contract instance for the ERC20TransferableReceivable contract
|
|
5
|
+
* associated with the given pool name on the current chain.
|
|
6
|
+
*
|
|
7
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
8
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
9
|
+
* @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
|
|
10
|
+
*/
|
|
11
|
+
export function getERC20TransferableReceivableContract(signerOrProvider, chainId) {
|
|
12
|
+
var _a;
|
|
13
|
+
const erc20TransferableReceiable = (_a = SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[SupplementaryContracts.ERC20TransferableReceivable];
|
|
14
|
+
if (!erc20TransferableReceiable)
|
|
15
|
+
return null;
|
|
16
|
+
return getContract(erc20TransferableReceiable, ERC20_TRANSFERABLE_RECEIVABLE_ABI, signerOrProvider);
|
|
17
|
+
}
|
|
18
18
|
//# sourceMappingURL=ERC20TransferableReceivableContractHelper.js.map
|
|
@@ -1,12 +1,41 @@
|
|
|
1
|
-
import { Contract, ethers } from 'ethers';
|
|
2
|
-
import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
9
|
-
* @param {
|
|
10
|
-
* @
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { BigNumberish, Contract, Overrides, ethers } from 'ethers';
|
|
2
|
+
import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
3
|
+
import { TransactionResponse } from '@ethersproject/providers';
|
|
4
|
+
/**
|
|
5
|
+
* Returns an ethers contract instance for a Huma pool contract
|
|
6
|
+
*
|
|
7
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
8
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
9
|
+
* @param {POOL_NAME} poolName The name of the pool contract to get.
|
|
10
|
+
* @param {POOL_TYPE} poolType The type of the pool contract to get.
|
|
11
|
+
* @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getPoolContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Contract | null;
|
|
14
|
+
/**
|
|
15
|
+
* Calls drawdown on a Huma pool contract
|
|
16
|
+
*
|
|
17
|
+
* @async
|
|
18
|
+
* @function
|
|
19
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
20
|
+
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
21
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
22
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
23
|
+
* @param {BigNumberish} drawdownAmount - The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.
|
|
24
|
+
* @param {Overrides} gasOpts - The gas options to use for the transaction.
|
|
25
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
26
|
+
*/
|
|
27
|
+
export declare function drawdownFromPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, drawdownAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Calls drawdown on a Huma pool contract
|
|
30
|
+
*
|
|
31
|
+
* @async
|
|
32
|
+
* @function
|
|
33
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
34
|
+
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
35
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
36
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
37
|
+
* @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
|
|
38
|
+
* @param {Overrides} gasOpts - The gas options to use for the transaction.
|
|
39
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
40
|
+
*/
|
|
41
|
+
export declare function makePaymentToPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, paymentAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
|