@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,84 +1,81 @@
|
|
|
1
|
-
import { FundResponse, UploadResponse } from '@bundlr-network/client/build/common/types';
|
|
2
|
-
import { Web3Provider } from '@ethersproject/providers';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
9
|
-
* @property {string}
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @
|
|
23
|
-
* @
|
|
24
|
-
* @
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* @
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
34
|
-
* @param {
|
|
35
|
-
* @param {
|
|
36
|
-
* @
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @
|
|
44
|
-
* @
|
|
45
|
-
* @
|
|
46
|
-
* @param {
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @param {
|
|
51
|
-
* @param {
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* @
|
|
64
|
-
* @
|
|
65
|
-
* @
|
|
66
|
-
* @param {
|
|
67
|
-
* @param {
|
|
68
|
-
* @
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
getBundlrNetworkConfig: typeof getBundlrNetworkConfig;
|
|
83
|
-
};
|
|
84
|
-
export {};
|
|
1
|
+
import { FundResponse, UploadResponse } from '@bundlr-network/client/build/common/types';
|
|
2
|
+
import { Web3Provider } from '@ethersproject/providers';
|
|
3
|
+
/**
|
|
4
|
+
* The configuration for Bundlr network instances
|
|
5
|
+
*
|
|
6
|
+
* @typedef {Object} BundlrConfig
|
|
7
|
+
* @memberof ArweaveService
|
|
8
|
+
* @property {string} nodeUrl - The Bundlr node URL to use.
|
|
9
|
+
* @property {string} currency - The currency to pay for uploads with.
|
|
10
|
+
* Please see https://docs.bundlr.network/sdk/using-other-currencies for all the supported currencies
|
|
11
|
+
* @property {string} [providerUrl] - The provider URL, required for devnets.
|
|
12
|
+
*/
|
|
13
|
+
export type BundlrConfig = {
|
|
14
|
+
nodeUrl: string;
|
|
15
|
+
currency: string;
|
|
16
|
+
providerUrl?: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Get the configuration for Bundlr network given a chain ID
|
|
20
|
+
*
|
|
21
|
+
* @function
|
|
22
|
+
* @memberof ArweaveService
|
|
23
|
+
* @param {number} chainId - The chain ID.
|
|
24
|
+
* @returns {BundlrConfig} - The configuration for the Bundlr network.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getBundlrNetworkConfig(chainId: number): BundlrConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Prefund the Bundlr network with the specified amount. Required if not lazy funding.
|
|
29
|
+
*
|
|
30
|
+
* @async
|
|
31
|
+
* @function
|
|
32
|
+
* @memberof ArweaveService
|
|
33
|
+
* @param {BundlrConfig} config - The configuration for the Bundlr network.
|
|
34
|
+
* @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
|
|
35
|
+
* @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
|
|
36
|
+
* @returns {Promise<FundResponse>} - The fund response.
|
|
37
|
+
*/
|
|
38
|
+
declare function prefundBundlr(config: BundlrConfig, signer: any, amount: number): Promise<FundResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Store data on ARWeave using the Bundlr Network.
|
|
41
|
+
*
|
|
42
|
+
* @async
|
|
43
|
+
* @function
|
|
44
|
+
* @memberof ArweaveService
|
|
45
|
+
* @param {BundlrConfig} config - Configuration object for the Bundlr instance.
|
|
46
|
+
* @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
|
|
47
|
+
* If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
|
|
48
|
+
* environment, this should be a private key string.
|
|
49
|
+
* @param {JSON} data - The data to store in the Bundlr instance.
|
|
50
|
+
* @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
|
|
51
|
+
* @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
|
|
52
|
+
* Bundlr node should already be funded or else uploads will fail.
|
|
53
|
+
* @returns {Promise<UploadResponse>} Promise resolving with the upload response.
|
|
54
|
+
*/
|
|
55
|
+
declare function storeData(config: BundlrConfig, signerOrPrivateKey: Web3Provider | string, data: JSON, tags: {
|
|
56
|
+
name: string;
|
|
57
|
+
value: string;
|
|
58
|
+
}[], lazyFund?: boolean): Promise<UploadResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* Helper method to query the Arweave network for receivables metadata previously uploaded.
|
|
61
|
+
*
|
|
62
|
+
* @async
|
|
63
|
+
* @function
|
|
64
|
+
* @memberof ArweaveService
|
|
65
|
+
* @param {number} chainId - The chain ID.
|
|
66
|
+
* @param {string} sender - The sender tag to query.
|
|
67
|
+
* @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
|
|
68
|
+
* @returns {Promise<any>} Promise resolving with the queried data.
|
|
69
|
+
*/
|
|
70
|
+
declare function queryForMetadata(chainId: number, sender: string, referenceId: string): Promise<string | null>;
|
|
71
|
+
/**
|
|
72
|
+
* An object that contains functions to interact with Huma-related data stored on ARWeave
|
|
73
|
+
* @namespace ARWeaveService
|
|
74
|
+
*/
|
|
75
|
+
export declare const ARWeaveService: {
|
|
76
|
+
queryForMetadata: typeof queryForMetadata;
|
|
77
|
+
storeData: typeof storeData;
|
|
78
|
+
prefundBundlr: typeof prefundBundlr;
|
|
79
|
+
getBundlrNetworkConfig: typeof getBundlrNetworkConfig;
|
|
80
|
+
};
|
|
81
|
+
export {};
|
|
@@ -1,147 +1,136 @@
|
|
|
1
|
-
import Bundlr from '@bundlr-network/client';
|
|
2
|
-
import request, { gql } from 'graphql-request';
|
|
3
|
-
/**
|
|
4
|
-
* Get the configuration for Bundlr network given a chain ID
|
|
5
|
-
*
|
|
6
|
-
* @function
|
|
7
|
-
* @memberof ArweaveService
|
|
8
|
-
* @param {number} chainId - The chain ID.
|
|
9
|
-
* @returns {BundlrConfig} - The configuration for the Bundlr network.
|
|
10
|
-
*/
|
|
11
|
-
export function getBundlrNetworkConfig(chainId) {
|
|
12
|
-
switch (chainId) {
|
|
13
|
-
case 5:
|
|
14
|
-
return {
|
|
15
|
-
nodeUrl: 'https://devnet.bundlr.network',
|
|
16
|
-
currency: 'ethereum',
|
|
17
|
-
providerUrl: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
|
|
18
|
-
};
|
|
19
|
-
case 80001:
|
|
20
|
-
return {
|
|
21
|
-
nodeUrl: 'https://devnet.bundlr.network',
|
|
22
|
-
currency: 'matic',
|
|
23
|
-
providerUrl: 'https://rpc-mumbai.matic.today',
|
|
24
|
-
};
|
|
25
|
-
default:
|
|
26
|
-
return {
|
|
27
|
-
nodeUrl: '',
|
|
28
|
-
currency: '',
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Prefund the Bundlr network with the specified amount. Required if not lazy funding.
|
|
34
|
-
*
|
|
35
|
-
* @async
|
|
36
|
-
* @function
|
|
37
|
-
* @memberof ArweaveService
|
|
38
|
-
* @param {BundlrConfig} config - The configuration for the Bundlr network.
|
|
39
|
-
* @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
|
|
40
|
-
* @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
|
|
41
|
-
* @returns {Promise<FundResponse>} - The fund response.
|
|
42
|
-
*/
|
|
43
|
-
async function prefundBundlr(config,
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
-
signer, amount) {
|
|
46
|
-
const bundlr = new Bundlr(config.nodeUrl, config.currency, signer, config.providerUrl
|
|
47
|
-
? {
|
|
48
|
-
providerUrl: config.providerUrl,
|
|
49
|
-
}
|
|
50
|
-
: undefined);
|
|
51
|
-
await bundlr.ready();
|
|
52
|
-
return bundlr.fund(amount);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Store data on ARWeave using the Bundlr Network.
|
|
56
|
-
*
|
|
57
|
-
* @async
|
|
58
|
-
* @function
|
|
59
|
-
* @memberof ArweaveService
|
|
60
|
-
* @param {BundlrConfig} config - Configuration object for the Bundlr instance.
|
|
61
|
-
* @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
|
|
62
|
-
* If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
|
|
63
|
-
* environment, this should be a private key string.
|
|
64
|
-
* @param {JSON} data - The data to store in the Bundlr instance.
|
|
65
|
-
* @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
|
|
66
|
-
* @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
|
|
67
|
-
* Bundlr node should already be funded or else uploads will fail.
|
|
68
|
-
* @returns {Promise<UploadResponse>} Promise resolving with the upload response.
|
|
69
|
-
*/
|
|
70
|
-
async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true) {
|
|
71
|
-
const bundlr = new Bundlr(config.nodeUrl, config.currency, signerOrPrivateKey, config.providerUrl
|
|
72
|
-
? {
|
|
73
|
-
providerUrl: config.providerUrl,
|
|
74
|
-
}
|
|
75
|
-
: undefined);
|
|
76
|
-
await bundlr.ready();
|
|
77
|
-
const dataStr = JSON.stringify(data);
|
|
78
|
-
if (lazyFund) {
|
|
79
|
-
const size = Buffer.byteLength(dataStr);
|
|
80
|
-
const price = await bundlr.getPrice(size);
|
|
81
|
-
// Add a buffer of 10% to account for fluctuations in the price
|
|
82
|
-
price.multipliedBy(1.1);
|
|
83
|
-
console.log(`Funding bundlr with ${price} ${config.currency} to upload data`);
|
|
84
|
-
await bundlr.fund(price);
|
|
85
|
-
}
|
|
86
|
-
return bundlr.upload(dataStr, { tags });
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Helper method to query the Arweave network for receivables metadata previously uploaded.
|
|
90
|
-
*
|
|
91
|
-
* @async
|
|
92
|
-
* @function
|
|
93
|
-
* @memberof ArweaveService
|
|
94
|
-
* @param {number} chainId - The chain ID.
|
|
95
|
-
* @param {POOL_NAME} poolName - The pool name tag to query.
|
|
96
|
-
* @param {POOL_TYPE} poolType - The pool type tag to query.
|
|
97
|
-
* @param {string} sender - The sender tag to query.
|
|
98
|
-
* @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
|
|
99
|
-
* @returns {Promise<any>} Promise resolving with the queried data.
|
|
100
|
-
*/
|
|
101
|
-
async function queryForMetadata(chainId, poolName, poolType, sender, referenceId) {
|
|
102
|
-
var _a, _b, _c, _d;
|
|
103
|
-
const config = getBundlrNetworkConfig(chainId);
|
|
104
|
-
const query = gql `
|
|
105
|
-
query ArweaveHumaMetadataQuery(
|
|
106
|
-
$poolName: String!
|
|
107
|
-
$poolType: String!
|
|
108
|
-
$sender: String!
|
|
109
|
-
$referenceId: String!
|
|
110
|
-
) {
|
|
111
|
-
transactions(
|
|
112
|
-
owners: [$sender]
|
|
113
|
-
tags: [
|
|
114
|
-
{ name: "appName", values: ["HumaFinance"] }
|
|
115
|
-
{ name: "poolName", values: [$poolName] }
|
|
116
|
-
{ name: "poolType", values: [$poolType] }
|
|
117
|
-
{ name: "referenceId", values: [$referenceId] }
|
|
118
|
-
]
|
|
119
|
-
) {
|
|
120
|
-
edges {
|
|
121
|
-
node {
|
|
122
|
-
id
|
|
123
|
-
}
|
|
1
|
+
import Bundlr from '@bundlr-network/client';
|
|
2
|
+
import request, { gql } from 'graphql-request';
|
|
3
|
+
/**
|
|
4
|
+
* Get the configuration for Bundlr network given a chain ID
|
|
5
|
+
*
|
|
6
|
+
* @function
|
|
7
|
+
* @memberof ArweaveService
|
|
8
|
+
* @param {number} chainId - The chain ID.
|
|
9
|
+
* @returns {BundlrConfig} - The configuration for the Bundlr network.
|
|
10
|
+
*/
|
|
11
|
+
export function getBundlrNetworkConfig(chainId) {
|
|
12
|
+
switch (chainId) {
|
|
13
|
+
case 5:
|
|
14
|
+
return {
|
|
15
|
+
nodeUrl: 'https://devnet.bundlr.network',
|
|
16
|
+
currency: 'ethereum',
|
|
17
|
+
providerUrl: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
|
|
18
|
+
};
|
|
19
|
+
case 80001:
|
|
20
|
+
return {
|
|
21
|
+
nodeUrl: 'https://devnet.bundlr.network',
|
|
22
|
+
currency: 'matic',
|
|
23
|
+
providerUrl: 'https://rpc-mumbai.matic.today',
|
|
24
|
+
};
|
|
25
|
+
default:
|
|
26
|
+
return {
|
|
27
|
+
nodeUrl: '',
|
|
28
|
+
currency: '',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Prefund the Bundlr network with the specified amount. Required if not lazy funding.
|
|
34
|
+
*
|
|
35
|
+
* @async
|
|
36
|
+
* @function
|
|
37
|
+
* @memberof ArweaveService
|
|
38
|
+
* @param {BundlrConfig} config - The configuration for the Bundlr network.
|
|
39
|
+
* @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
|
|
40
|
+
* @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
|
|
41
|
+
* @returns {Promise<FundResponse>} - The fund response.
|
|
42
|
+
*/
|
|
43
|
+
async function prefundBundlr(config,
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
+
signer, amount) {
|
|
46
|
+
const bundlr = new Bundlr(config.nodeUrl, config.currency, signer, config.providerUrl
|
|
47
|
+
? {
|
|
48
|
+
providerUrl: config.providerUrl,
|
|
49
|
+
}
|
|
50
|
+
: undefined);
|
|
51
|
+
await bundlr.ready();
|
|
52
|
+
return bundlr.fund(amount);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Store data on ARWeave using the Bundlr Network.
|
|
56
|
+
*
|
|
57
|
+
* @async
|
|
58
|
+
* @function
|
|
59
|
+
* @memberof ArweaveService
|
|
60
|
+
* @param {BundlrConfig} config - Configuration object for the Bundlr instance.
|
|
61
|
+
* @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
|
|
62
|
+
* If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
|
|
63
|
+
* environment, this should be a private key string.
|
|
64
|
+
* @param {JSON} data - The data to store in the Bundlr instance.
|
|
65
|
+
* @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
|
|
66
|
+
* @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
|
|
67
|
+
* Bundlr node should already be funded or else uploads will fail.
|
|
68
|
+
* @returns {Promise<UploadResponse>} Promise resolving with the upload response.
|
|
69
|
+
*/
|
|
70
|
+
async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true) {
|
|
71
|
+
const bundlr = new Bundlr(config.nodeUrl, config.currency, signerOrPrivateKey, config.providerUrl
|
|
72
|
+
? {
|
|
73
|
+
providerUrl: config.providerUrl,
|
|
124
74
|
}
|
|
125
|
-
|
|
75
|
+
: undefined);
|
|
76
|
+
await bundlr.ready();
|
|
77
|
+
const dataStr = JSON.stringify(data);
|
|
78
|
+
if (lazyFund) {
|
|
79
|
+
const size = Buffer.byteLength(dataStr);
|
|
80
|
+
const price = await bundlr.getPrice(size);
|
|
81
|
+
// Add a buffer of 10% to account for fluctuations in the price
|
|
82
|
+
price.multipliedBy(1.1);
|
|
83
|
+
console.log(`Funding bundlr with ${price} ${config.currency} to upload data`);
|
|
84
|
+
await bundlr.fund(price);
|
|
126
85
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
*
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
86
|
+
return bundlr.upload(dataStr, { tags });
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Helper method to query the Arweave network for receivables metadata previously uploaded.
|
|
90
|
+
*
|
|
91
|
+
* @async
|
|
92
|
+
* @function
|
|
93
|
+
* @memberof ArweaveService
|
|
94
|
+
* @param {number} chainId - The chain ID.
|
|
95
|
+
* @param {string} sender - The sender tag to query.
|
|
96
|
+
* @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
|
|
97
|
+
* @returns {Promise<any>} Promise resolving with the queried data.
|
|
98
|
+
*/
|
|
99
|
+
async function queryForMetadata(chainId, sender, referenceId) {
|
|
100
|
+
var _a, _b, _c, _d;
|
|
101
|
+
const config = getBundlrNetworkConfig(chainId);
|
|
102
|
+
const query = gql `
|
|
103
|
+
query ArweaveHumaMetadataQuery($sender: String!, $referenceId: String!) {
|
|
104
|
+
transactions(
|
|
105
|
+
owners: [$sender]
|
|
106
|
+
tags: [
|
|
107
|
+
{ name: "appName", values: ["HumaFinance"] }
|
|
108
|
+
{ name: "referenceId", values: [$referenceId] }
|
|
109
|
+
]
|
|
110
|
+
) {
|
|
111
|
+
edges {
|
|
112
|
+
node {
|
|
113
|
+
id
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
+
const data = await request(`${config.nodeUrl}/graphql`, query, {
|
|
121
|
+
sender,
|
|
122
|
+
referenceId,
|
|
123
|
+
});
|
|
124
|
+
return (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.transactions) === null || _a === void 0 ? void 0 : _a.edges) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.node) === null || _d === void 0 ? void 0 : _d.id;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* An object that contains functions to interact with Huma-related data stored on ARWeave
|
|
128
|
+
* @namespace ARWeaveService
|
|
129
|
+
*/
|
|
130
|
+
export const ARWeaveService = {
|
|
131
|
+
queryForMetadata,
|
|
132
|
+
storeData,
|
|
133
|
+
prefundBundlr,
|
|
134
|
+
getBundlrNetworkConfig,
|
|
135
|
+
};
|
|
147
136
|
//# sourceMappingURL=ARWeaveService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../src/services/ARWeaveService.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,wBAAwB,CAAA;AAM3C,OAAO,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../src/services/ARWeaveService.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object representing the response to the underwriting approval request.
|
|
3
|
-
* @typedef {Object} ApprovalResult
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Object representing an invoice payload for underwriting approval.
|
|
7
|
-
*
|
|
8
|
-
* @typedef {Object} EAPayload
|
|
9
|
-
*/
|
|
10
|
-
export type { ApprovalResult, EAPayload } from '@huma-finance/shared';
|
|
11
|
-
/**
|
|
12
|
-
* An object that contains functions to interact with Huma's EAVerse service.
|
|
13
|
-
*
|
|
14
|
-
* @namespace EAService
|
|
15
|
-
*/
|
|
16
|
-
export declare const EAService: {
|
|
17
|
-
approve: (payload: import("@huma-finance/shared").EAPayload, chainId: number, isDev?: boolean | undefined) => Promise<import("@huma-finance/shared").Approval>;
|
|
18
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Object representing the response to the underwriting approval request.
|
|
3
|
+
* @typedef {Object} ApprovalResult
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Object representing an invoice payload for underwriting approval.
|
|
7
|
+
*
|
|
8
|
+
* @typedef {Object} EAPayload
|
|
9
|
+
*/
|
|
10
|
+
export type { ApprovalResult, EAPayload } from '@huma-finance/shared';
|
|
11
|
+
/**
|
|
12
|
+
* An object that contains functions to interact with Huma's EAVerse service.
|
|
13
|
+
*
|
|
14
|
+
* @namespace EAService
|
|
15
|
+
*/
|
|
16
|
+
export declare const EAService: {
|
|
17
|
+
approve: (payload: import("@huma-finance/shared").EAPayload, chainId: number, isDev?: boolean | undefined) => Promise<import("@huma-finance/shared").Approval>;
|
|
18
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { EAService as EAServiceInternal } from '@huma-finance/shared';
|
|
2
|
-
/**
|
|
3
|
-
* An object that contains functions to interact with Huma's EAVerse service.
|
|
4
|
-
*
|
|
5
|
-
* @namespace EAService
|
|
6
|
-
*/
|
|
7
|
-
export const EAService = {
|
|
8
|
-
approve: EAServiceInternal.approve,
|
|
9
|
-
};
|
|
1
|
+
import { EAService as EAServiceInternal } from '@huma-finance/shared';
|
|
2
|
+
/**
|
|
3
|
+
* An object that contains functions to interact with Huma's EAVerse service.
|
|
4
|
+
*
|
|
5
|
+
* @namespace EAService
|
|
6
|
+
*/
|
|
7
|
+
export const EAService = {
|
|
8
|
+
approve: EAServiceInternal.approve,
|
|
9
|
+
};
|
|
10
10
|
//# sourceMappingURL=EAService.js.map
|