@huma-finance/widgets 0.0.7-alpha.0 → 0.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huma-finance/widgets",
3
- "version": "0.0.7-alpha.0",
3
+ "version": "0.0.8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -30,8 +30,8 @@
30
30
  "@ethersproject/experimental": "^5.7.0",
31
31
  "@ethersproject/providers": "^5.6.0",
32
32
  "@ethersproject/units": "^5.6.0",
33
- "@huma-finance/sdk": "^0.0.7-alpha.0",
34
- "@huma-finance/shared": "^0.0.6-alpha.0",
33
+ "@huma-finance/sdk": "^0.0.8",
34
+ "@huma-finance/shared": "^0.0.8",
35
35
  "@mui/icons-material": "^5.3.0",
36
36
  "@mui/material": "^5.0.6",
37
37
  "@mui/styles": "^5.0.2",
@@ -191,5 +191,5 @@
191
191
  "optionalDependencies": {
192
192
  "encoding": "^0.1.13"
193
193
  },
194
- "gitHead": "012b5f683a777fc5fdaeb0f0854748c581b2dcf8"
194
+ "gitHead": "d9e7878a7b163ccc5b29959eb8a0fbb73c988244"
195
195
  }
@@ -5,37 +5,45 @@ import { useEffect, useState } from 'react'
5
5
  import {
6
6
  EAService,
7
7
  useCreditRecordDetails,
8
- useReceivableFactoringPoolContract,
9
- mintReceivableWithMetadata,
10
- queryForMetadata,
8
+ usePoolContract,
9
+ ARWeaveService,
10
+ ReceivableService,
11
11
  } from '@huma-finance/sdk'
12
12
  import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared'
13
13
  import { useAccount } from 'wagmi'
14
- import { ethers, getDefaultProvider } from 'ethers'
15
- import { Web3Provider } from '@ethersproject/providers'
14
+ import { ethers } from 'ethers'
15
+ import { JsonRpcProvider, Web3Provider } from '@ethersproject/providers'
16
16
 
17
17
  import { WalletWrapper } from './WalletWrapper'
18
18
 
19
- const TEST_PRIVATE_KEY =
20
- '66667f446ba85d3e9e8fc0d0ce195e49089de15178ff7a42fe3e78ac3c3ad85c'
19
+ const TEST_PRIVATE_KEY = 'REPLACE_WITH_YOUR_PRIVATE_KEY'
20
+ const INFURA_PROVIDER_KEY = 'REPLACE_WITH_YOUR_INFURA_PROVIDER_KEY'
21
21
 
22
22
  function Fixture() {
23
23
  const { address, connector } = useAccount()
24
24
  const [chainId, setChainId] = useState(0)
25
25
  const [signer, setSigner] = useState<Web3Provider | null>(null)
26
26
 
27
+ if (TEST_PRIVATE_KEY === 'REPLACE_WITH_YOUR_PRIVATE_KEY') {
28
+ console.error('Please replace TEST_PRIVATE_KEY with your own private key')
29
+ }
30
+ if (INFURA_PROVIDER_KEY === 'REPLACE_WITH_YOUR_INFURA_PROVIDER_KEY') {
31
+ console.error('Please replace INFURA_PROVIDER_KEY with your own key')
32
+ }
33
+
27
34
  // useCreditRecordDetails
28
35
  const [userAddress, setUserAddress] = useState('')
29
36
  const [poolName, setPoolName] = useState<POOL_NAME>(POOL_NAME.RequestNetwork)
30
37
  const [poolType, setPoolType] = useState<POOL_TYPE>(POOL_TYPE.Invoice)
38
+ const provider = new JsonRpcProvider(
39
+ `https://goerli.infura.io/v3/${INFURA_PROVIDER_KEY}`,
40
+ {
41
+ name: 'goerli',
42
+ chainId: 5,
43
+ },
44
+ )
31
45
  const [creditRecordDetails, refreshCreditRecordDetails] =
32
- useCreditRecordDetails(
33
- userAddress,
34
- getDefaultProvider(),
35
- chainId,
36
- poolName,
37
- poolType,
38
- )
46
+ useCreditRecordDetails(userAddress, provider, chainId, poolName, poolType)
39
47
 
40
48
  // mintReceivableWithMetadata
41
49
  const [recipientAddress, setRecipientAddress] = useState(address)
@@ -47,11 +55,12 @@ function Fixture() {
47
55
  const [internalID, setInternalID] = useState('3')
48
56
  const [mintResult, setMintResult] = useState<any>('')
49
57
 
50
- // useReceivableFactoringPoolContract
51
- const poolContract = useReceivableFactoringPoolContract(
58
+ // usePoolContract
59
+ const poolContract = usePoolContract(
52
60
  signer!,
53
61
  chainId,
54
62
  POOL_NAME.RequestNetwork,
63
+ POOL_TYPE.Invoice,
55
64
  )
56
65
 
57
66
  // EAService.approve
@@ -106,11 +115,10 @@ function Fixture() {
106
115
  if (signer === null) return
107
116
 
108
117
  try {
109
- const data = await mintReceivableWithMetadata(
118
+ const data = await ReceivableService.mintReceivableWithMetadata(
110
119
  signer,
111
- TEST_PRIVATE_KEY,
120
+ TEST_PRIVATE_KEY!,
112
121
  chainId,
113
- address!,
114
122
  poolName,
115
123
  poolType,
116
124
  receivableAmount,
@@ -134,7 +142,7 @@ function Fixture() {
134
142
  if (address == null) return
135
143
 
136
144
  try {
137
- const data = await queryForMetadata(
145
+ const data = await ARWeaveService.queryForMetadata(
138
146
  chainId,
139
147
  poolName,
140
148
  poolType,
@@ -253,7 +261,7 @@ function Fixture() {
253
261
  borderRadius: '10px',
254
262
  }}
255
263
  >
256
- <h3>Test useReceivableFactoringPoolContract</h3>
264
+ <h3>Test usePoolContract</h3>
257
265
  {poolContract?.address}
258
266
  </div>
259
267
  <div
@@ -408,7 +416,7 @@ function Fixture() {
408
416
  </label>
409
417
  <br />
410
418
  <label>
411
- Internal ID (For querying through ARWeave):
419
+ Reference ID (For querying through ARWeave):
412
420
  <input
413
421
  type='text'
414
422
  value={internalID}
@@ -473,7 +481,7 @@ function Fixture() {
473
481
  </select>
474
482
  </label>
475
483
  <label>
476
- Internal ID (For querying through ARWeave):
484
+ Reference ID (For querying through ARWeave):
477
485
  <input
478
486
  type='text'
479
487
  value={internalID}