Skip to content

Commit

Permalink
refactor useBeneficiary (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardo Vieira authored Apr 12, 2023
1 parent 37548c4 commit e986a6f
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 145 deletions.
4 changes: 2 additions & 2 deletions example-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"lint": "next lint"
},
"dependencies": {
"@celo/contractkit": "2.3.0",
"@celo/contractkit": "3.2.0",
"@celo/react-celo": "4.2.1",
"@celo/utils": "2.3.0",
"@celo/utils": "3.2.0",
"@impact-market/utils": "link:..",
"@sentry/nextjs": "^7.36.0",
"@walletconnect/client": "1.8.0",
Expand Down
9 changes: 4 additions & 5 deletions example-web/pages/components/Community/Beneficiary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { useBeneficiary } from '@impact-market/utils/useBeneficiary';
const Beneficiary = () => {
const {
beneficiary,
claimCooldown,
isClaimable,
isReady,
claim,
community,
fundsRemainingDays
claim
} = useBeneficiary('0x13d9d460Bf4bbEE7c3ab53a29c5f23AeC64F8CB6');
const { claimCooldown, isClaimable, community, fundsRemainingDays } = beneficiary;

console.log('reload useBeneficiary');

if(!isReady) {
return <div>Loading</div>;
Expand Down
2 changes: 1 addition & 1 deletion example-web/pages/components/Intro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Intro = (props: IntroProps) => {
<h1 style={{ display: 'inline-block', marginRight: 16 }}>Development feature</h1>
<select value={selected} onChange={event => handleSelectChange(event?.target?.value)}>
<option value="">---</option>
{options.map((option, index) => <option key={index}>{option}</option>)}
{(options ?? []).map((option, index) => <option key={index}>{option}</option>)}
</select>
</div>
)
Expand Down
6 changes: 3 additions & 3 deletions example-web/pages/components/MicroCredit/UserLoans.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const UserLoans = () => {

const checkLoan = async () => {
const loanId = await getActiveLoanId((address ?? '').toString());
await userLoans((address ?? '').toString(), loanId.toString());
await userLoans((address ?? '').toString(), loanId);
};

const checkWalletMetadata = async () => {
Expand All @@ -22,12 +22,12 @@ const UserLoans = () => {
const loanId = await getActiveLoanId((address ?? '').toString());

await approve(token, amount);
await repayLoan(loanId.toString(), amount);
await repayLoan(loanId, amount);
};

const claim = async () => {
const loanId = await getActiveLoanId((address ?? '').toString());
await claimLoan(loanId.toString());
await claimLoan(loanId);
};

return (
Expand Down
3 changes: 2 additions & 1 deletion example-web/sentry.client.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Sentry.init({
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1.0,
debug: true,
environment: 'development'
environment: 'development',
enabled: false
// ...
// Note: if you want to override the automatic release value, do not set a
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
Expand Down
1 change: 1 addition & 0 deletions example-web/sentry.server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Sentry.init({
dsn: SENTRY_DSN || 'https://b0203ca1cbd548c493cae5dd009f66be@o442089.ingest.sentry.io/6171011',
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 1.0,
enabled: false
// ...
// Note: if you want to override the automatic release value, do not set a
// `release` value here - use the environment variable `SENTRY_RELEASE`, so
Expand Down
45 changes: 36 additions & 9 deletions example-web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@
debug "^4.1.1"
utf8 "3.0.0"

"@celo/contractkit@2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@celo/contractkit/-/contractkit-2.3.0.tgz#b34a0b8cca8daf2242738214a6ed88f818f0af92"
integrity sha512-mctnQBp7GZAsuV4I47kTK3fBtjoL4uqd0LZ8wUmck+COJT9yW3DuQjPQwQvBxN6InKET9IeUmTuoTW4oAbW/FQ==
"@celo/contractkit@3.2.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@celo/contractkit/-/contractkit-3.2.0.tgz#c0886e3a01534a199618fce65c6861cecb0c5ed1"
integrity sha512-kt4ViBRMg7ezCPi2SdcrYdDorA1Meg/qk97/u4izEIthl9GM4QSRfhhHYsbXYm0NV/MZ2BkS0cCsQ/SHcILSaA==
dependencies:
"@celo/base" "2.3.0"
"@celo/connect" "2.3.0"
"@celo/utils" "2.3.0"
"@celo/wallet-local" "2.3.0"
"@celo/base" "3.2.0"
"@celo/connect" "3.2.0"
"@celo/utils" "3.2.0"
"@celo/wallet-local" "3.2.0"
"@types/bn.js" "^5.1.0"
"@types/debug" "^4.1.5"
bignumber.js "^9.0.0"
Expand Down Expand Up @@ -218,6 +218,21 @@
eth-lib "^0.2.8"
ethereumjs-util "^5.2.0"

"@celo/wallet-base@3.2.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@celo/wallet-base/-/wallet-base-3.2.0.tgz#feff094fd43fb651f3f742b6a73dc3b740b0c39c"
integrity sha512-lwhesT2BkXIyPI/ox/QbVVCRtLzTAGO25M3TlWBfSCzkRAf/AiV41lzEf9J7A1ozDKXS9s7bj8odiRkMAcelyQ==
dependencies:
"@celo/base" "3.2.0"
"@celo/connect" "3.2.0"
"@celo/utils" "3.2.0"
"@types/debug" "^4.1.5"
"@types/ethereumjs-util" "^5.2.0"
bignumber.js "^9.0.0"
debug "^4.1.1"
eth-lib "^0.2.8"
ethereumjs-util "^5.2.0"

"@celo/wallet-ledger@^2.2.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@celo/wallet-ledger/-/wallet-ledger-2.3.0.tgz#5d5309cabba602c5ba29abebcb92a1d14103bba8"
Expand All @@ -234,7 +249,19 @@
eth-lib "^0.2.8"
ethereumjs-util "^5.2.0"

"@celo/wallet-local@2.3.0", "@celo/wallet-local@^2.2.0":
"@celo/wallet-local@3.2.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@celo/wallet-local/-/wallet-local-3.2.0.tgz#905dd18a3285852a8341e5683beda94512c0f4f8"
integrity sha512-hR70gzNCDHgf/GskaaLtB7Jz4AqJEW0b+1jG1rsuAyaXLJomSRADGBwUUgMy1dKU87fcQ9h7Uh+AuRAP4/5COQ==
dependencies:
"@celo/connect" "3.2.0"
"@celo/utils" "3.2.0"
"@celo/wallet-base" "3.2.0"
"@types/ethereumjs-util" "^5.2.0"
eth-lib "^0.2.8"
ethereumjs-util "^5.2.0"

"@celo/wallet-local@^2.2.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@celo/wallet-local/-/wallet-local-2.3.0.tgz#fca3adfcbaebc6951a0251e510d59a658a9d0eb9"
integrity sha512-B2rg6DmKnHP98ixkIRH7I4aNFZVcj4e7wmB9z2LB08wAiuBFS4qsGp4ciplLb+AQuwbUSe8SpRSuKYxKUTQmFA==
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@impact-market/utils",
"version": "3.3.7",
"version": "3.4.0-alpha.6",
"description": "impactMarket utils",
"repository": {
"type": "git",
Expand Down
19 changes: 19 additions & 0 deletions src/abi/CommunityABI.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,5 +319,24 @@
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_beneficiaryAddress",
"type": "address"
}
],
"name": "beneficiaryClaimedAmounts",
"outputs": [
{
"internalType": "uint256[]",
"name": "claimedAmounts",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
}
]
Loading

0 comments on commit e986a6f

Please sign in to comment.