Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next Release #614

Merged
merged 82 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
1a63e7f
If a money go back to campaign set isReturn true for that
mohammadranjbarz Aug 18, 2021
96e3973
Write migration to fix isReturn of donations that go back to campaign
mohammadranjbarz Aug 18, 2021
7764005
Include Pending donations in aggregateDonations service
mohammadranjbarz Aug 18, 2021
e8ab20b
Merge pull request #586 from Giveth/f_2298_fix_leaderboard_of_campaig…
aminlatifi Aug 18, 2021
baae2bb
Comment PAN conversionRate test case
mohammadranjbarz Aug 18, 2021
d8e4428
Add Archived status, and add ability to change to archived
mohammadranjbarz Aug 19, 2021
ca49eca
Change giveth-liquiditypledging with @giveth/liquidpledging-contract
mohammadranjbarz Aug 19, 2021
89d2430
Change CI/CD config for deploy on new server
mohammadranjbarz Aug 19, 2021
4bc67c2
When someone get rate limit send exception to Sentry
mohammadranjbarz Aug 19, 2021
0b4394f
Merge pull request #593 from Giveth/f_send_rate_limit_errors_to_sentry
aminlatifi Aug 19, 2021
88a44ca
Merge pull request #592 from Giveth/f_2110_setup_new_production_server
aminlatifi Aug 19, 2021
b0f4286
Merge pull request #589 from Giveth/f_comment_pan_conversion_rate_tes…
aminlatifi Aug 19, 2021
5b4252b
Update @giveth/liquidpledging-contract
mohammadranjbarz Aug 19, 2021
30639e6
Update all dependencies about contracts
mohammadranjbarz Aug 19, 2021
29f3175
Merge branch 'develop' into change_giveth-liquiditypledging_dependency
mohammadranjbarz Aug 19, 2021
00e3b65
Remove unsed dependencies
mohammadranjbarz Aug 19, 2021
ec3f12a
Add un archiving feature for campaigns
mohammadranjbarz Aug 21, 2021
e81375f
Change an error message
mohammadranjbarz Aug 21, 2021
8e1f05a
Support embark generated artifacts
aminlatifi Aug 22, 2021
74ad6e1
Merge pull request #595 from Giveth/f_support_embark_artifacts
aminlatifi Aug 22, 2021
f57abe9
Get contracts artifacts from new giveth package
mohammadranjbarz Aug 22, 2021
b4b4fa1
Add location to userInfo in /verifiedCamapigns GET
mohammadranjbarz Aug 23, 2021
fbc3ae6
Add url to user response fetched from givethio
mohammadranjbarz Aug 23, 2021
80038c3
Merge pull request #590 from Giveth/f_2462_archive_campaign
aminlatifi Aug 24, 2021
afd7040
Merge pull request #596 from Giveth/f_add_location_to_inquiry_for_ver…
aminlatifi Aug 24, 2021
f245076
Merge pull request #591 from Giveth/change_giveth-liquiditypledging_d…
aminlatifi Aug 24, 2021
4e495a1
Allow to delete multiple entries
mohammadranjbarz Aug 25, 2021
73ab4fb
Add emails update and create to elastik search
mohammadranjbarz Aug 25, 2021
43e0ec8
Remove jobs from queue if it doesnt remove after two minutes (prevent…
mohammadranjbarz Aug 25, 2021
8cd0dca
Dont process jobs multiple times if the event status is Processed alr…
mohammadranjbarz Aug 25, 2021
e72c0b8
Merge branch 'develop' into f_594_fix_stock_event_handler_queue
mohammadranjbarz Aug 25, 2021
0f636e8
Fix bug in check eventInDb status
mohammadranjbarz Aug 25, 2021
8f7b2e3
Merge pull request #598 from Giveth/f_594_fix_stock_event_handler_queue
aminlatifi Aug 25, 2021
d464fbf
Fix migrate-mongo version to work with node 10
mohammadranjbarz Aug 25, 2021
73bd7c6
Merge pull request #599 from Giveth/fix_migrate_mongo_version
aminlatifi Aug 25, 2021
1757035
Replace giveth-bridge with @giveth/bridge package
mohammadranjbarz Aug 26, 2021
f1fe886
Merge pull request #601 from Giveth/f_600_relace_giveth_brige_library
aminlatifi Aug 26, 2021
3b9a8e3
Update README and change the deploy instruction
mohammadranjbarz Aug 28, 2021
1bc7434
Add donations create/update diagram
mohammadranjbarz Aug 29, 2021
6db20ed
Add validation for /conversionRates endpoint
mohammadranjbarz Aug 29, 2021
0def0f7
Refactor generate swagger from mongoose model
mohammadranjbarz Aug 29, 2021
39b37d8
Fix eslint error
mohammadranjbarz Aug 29, 2021
f5bddf0
Merge pull request #602 from Giveth/f_update_deploy_instruction_in_re…
aminlatifi Aug 30, 2021
bb43f28
Update README.md
aminlatifi Aug 30, 2021
dba4db9
Dont return mongo error to client
mohammadranjbarz Aug 31, 2021
1a21c00
Add mongo index for campaign title
Aug 31, 2021
1a9f832
Fix eslint error
mohammadranjbarz Sep 1, 2021
9bbe2e8
Merge pull request #605 from Giveth/f_2492_fix_mongo_erros_in_response
aminlatifi Sep 1, 2021
3314f28
Change donation documentation
mohammadranjbarz Sep 1, 2021
70e16d7
Fix index of campaign title to support search
mohammadranjbarz Sep 1, 2021
649fa13
Fix eslint errors
mohammadranjbarz Sep 1, 2021
0809644
Merge pull request #606 from Giveth/f_add_mongo_index_for_campaign_title
aminlatifi Sep 1, 2021
b09c10d
Refactor moe funcitons in tokenHelper
mohammadranjbarz Sep 2, 2021
920ade6
Add documentation for donations entity
mohammadranjbarz Sep 2, 2021
26552fe
Merge pull request #603 from Giveth/f_1825_add_donations_documentation
aminlatifi Sep 2, 2021
1b6dafe
Change @giveth/lpp-campaign to lpp-campaign, to fix running networks …
mohammadranjbarz Sep 2, 2021
3b14fd2
Merge pull request #608 from Giveth/f_change_lpp-camapign_in_deploy_s…
aminlatifi Sep 2, 2021
aecb057
Change @giveth/lpp-milestones to lpp-milestones, to fix running netwo…
mohammadranjbarz Sep 2, 2021
d7f8633
Merge pull request #609 from Giveth/f_change_lpp-milestones_in_deploy…
aminlatifi Sep 12, 2021
7b08ef6
Merge pull request #604 from Giveth/f_fix_pan_conversion_rate
aminlatifi Sep 12, 2021
8b970b3
Add whitelist ip for rate limit
mohammadranjbarz Sep 12, 2021
1c3301f
Merge pull request #611 from Giveth/f_610_add_whitelist_for_ratelimit
aminlatifi Sep 13, 2021
fc416fe
Don't return stack errors to client
mohammadranjbarz Sep 14, 2021
75de4fd
Don't change error for featherError instance
mohammadranjbarz Sep 14, 2021
512390a
Merge pull request #613 from Giveth/f_612_server_should_not_return_st…
aminlatifi Sep 14, 2021
94aa639
Fix create verified campaign for givethio projects without image and …
mohammadranjbarz Sep 26, 2021
75d37f4
Merge pull request #617 from Giveth/f_2546_fix_create_verified_campaigns
aminlatifi Sep 27, 2021
351b52b
Fix get exchange rate for native currencies
mohammadranjbarz Sep 27, 2021
23103c4
Fix test case of getValidSymbols()
mohammadranjbarz Sep 27, 2021
68a67fc
Merge branch 'develop' into f_2543_fix_get_exchange_rate_for_native_c…
mohammadranjbarz Sep 27, 2021
01e5868
Move checking of description and images to givethIoAdapter instead of…
mohammadranjbarz Sep 27, 2021
91b04a3
Merge pull request #620 from Giveth/f_2546_fill_givethio_project_data
aminlatifi Sep 28, 2021
41f55c1
Change array to set in tokenHelper
mohammadranjbarz Sep 28, 2021
6395909
Used array for validSymbols
aminlatifi Sep 28, 2021
cbd5c33
Initialized validSymbols at the start
aminlatifi Sep 28, 2021
47d8ac5
Initialized all token helpers once
aminlatifi Sep 28, 2021
a73e97d
Merge pull request #621 from Giveth/change_array_with_set_in_tokenHelper
mohammadranjbarz Sep 28, 2021
1701fd4
Resolve merge conflicts
mohammadranjbarz Sep 28, 2021
f769845
Merge pull request #619 from Giveth/f_2543_fix_get_exchange_rate_for_…
aminlatifi Oct 3, 2021
5ea5d04
Dont Allow campaign owner to un archive the campaign
mohammadranjbarz Oct 14, 2021
d9a50ae
Start mongo before install dependencies to not get mongo connection e…
mohammadranjbarz Oct 14, 2021
af4cb6f
Merge pull request #623 from Giveth/f_2559_dont_allow_campaign_owner_…
aminlatifi Oct 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions .github/workflows/CI-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
# Mongo is needed for running tests
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.3.0
with:
mongodb-version: 4.2
- uses: actions/checkout@v1
- name: Use Node.js
uses: actions/setup-node@v1
Expand All @@ -15,12 +20,6 @@ jobs:
run: npm ci
- name: run linter
run: npm run eslint

# Mongo is needed for running tests
- name: Start MongoDB
uses: supercharge/mongodb-github-action@1.3.0
with:
mongodb-version: 4.2
- name: test
run: npm run test

Expand Down Expand Up @@ -61,14 +60,13 @@ jobs:
# passphrase: ${{ secrets.PASSPHRASE }}
privateKey: ${{ secrets.DEVELOP_PRIVATE_KEY}}

- name: beta deploy
- name: production deploy
if: github.ref == 'refs/heads/master'
uses: garygrossgarten/github-action-ssh@v0.6.4
with:
# command: cd feathers-giveth-beta && git checkout master && git pull origin master && [[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh && nvm use 10 && npm ci && NODE_ENV=production ./node_modules/.bin/migrate-mongo up && npm run serve
# pull images, restart docker, then remove unused docker images
command: cd feathers-giveth-beta && git checkout master && git pull origin master && docker-compose -f docker-compose-production.yml pull && docker-compose -f docker-compose-production.yml down && docker-compose -f docker-compose-production.yml up -d && docker image prune -a --force
host: ${{ secrets.BETA_HOST }}
username: ${{ secrets.BETA_USERNAME }}
command: cd feathers-giveth-trace && git checkout master && git pull origin master && docker-compose -f docker-compose-production.yml pull && docker-compose -f docker-compose-production.yml down && docker-compose -f docker-compose-production.yml up -d && docker image prune -a --force
host: ${{ secrets.PRODUCTION_HOST }}
username: ${{ secrets.PRODUCTION_USERNAME }}
# passphrase: ${{ secrets.PASSPHRASE }}
privateKey: ${{ secrets.BETA_PRIVATE_KEY}}
privateKey: ${{ secrets.PRODUCTION_PRIVATE_KEY}}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ RUN apk add --update alpine-sdk
RUN apk add git python3
RUN npm ci
RUN npm i -g pm2
RUN npm i -g migrate-mongo
RUN npm i -g migrate-mongo@8.1.4
CMD migrate-mongo up && pm2-runtime start ./src/index.js
EXPOSE 3030
42 changes: 11 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,6 @@ If the `ipfsApi` is a valid ipfs node that we can connect to, we will pin every

### Video Walkthrough
Video tutorial walkthrough here: https://tinyurl.com/y9lx6jrl

## Deploying

1. Start a production server

```
yarn serve
```

## Scripts

Expand Down Expand Up @@ -159,30 +151,11 @@ make `isAdmin` field true, for your user in you local MongoDb

## Production

We use pm2 to manage our production servers. You can start the server using the `yarn serve` cmd. You will need to create an `ecosystem.config.js` file with the following contents:
We use docker-compose for orchestration of our docker containers in our production servers.
* make Make sure you have a file named `production.json` in config folder
* Install docker and docker-compose on your server
* run this command: `docker-compose -f docker-compose-production.yml up -d`

```
module.exports = {
/**
* Application configuration section
* http://pm2.keymetrics.io/docs/usage/application-declaration/
*/
apps: [
// First application
{
name: 'feathers',
script: 'src/index.js',
log_date_format: 'YYYY-MM-DD HH:mm',
env: {
COMMON_VARIABLE: 'true',
},
env_production: {
NODE_ENV: 'production',
},
},
],
};
```
PS: It's good to see [Github Actions config](./.github/workflows/CI-CD.yml) to better understanding of deploy structure
## RSK

Expand Down Expand Up @@ -226,6 +199,13 @@ in config to `true`, then
And then after logging in `localhost:5601` with user:`elastic`, password: `changeme`
you can see the logs

## Donations Diagram
This diagram demonstrates how donations are created and how status will be changed,
if you want to edit diagram just change `https://mermaid.ink/img/` to `https://mermaid-js.github.io/mermaid-live-editor/edit/#` in below link

A Solid arrow mean a new donation will be created after this action, and dotted arrows are used when existing donations are modified.
[![](https://mermaid.ink/img/eyJjb2RlIjoiZ3JhcGggVERcbiAgICBEb25vcltEb25vcl0gPT0-fERvbmF0ZXwgR2l2ZXJQZW5kaW5nKEdpdmVyL1BlbmRpbmcpXG4gICAgR2l2ZXJQZW5kaW5nIC0uLT4gRG9uYXRlVGFyZ2V0e1RhcmdldH1cbiAgICBHaXZlclBlbmRpbmcgLS4tPiB8VHJhbnNhY3Rpb24gaXMgbWluZWR8IEdpdmVyQ29tbWl0dGVk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0FwcHJvdmUgLS4tPiB8RG9ub3IgY29uZmlybSB0cmFjZSBkZWxlZ2F0aW9ufCBUcmFjZUNvbW1pdHRlZFxuICAgIFRvQXBwcm92ZSAtLi0-IHxEb25vciBjb25maXJtIGNhbXBhaWduIGRlbGVnYXRpb258IENhbXBhaWduQ29tbWl0dGVkXG4gICAgVG9BcHByb3ZlIC0uLT4gfFJlamVjdCBieSBkb25vciBpbiAzIGRheXN8IENvbW11bml0eVJlamVjdGVkKENvbW11bml0eS9SZWplY3RlZClcbiAgICBDb21tdW5pdHlSZWplY3RlZCA9PT4gIHxOZXcgZG9uYXRpb24gaXMgcmVhZHkgdG8gZGVsZWdhdGUgbm98Q29tbXVuaXR5V2FpdGluZ1xuICAgIFRyYWNlQ29tbWl0dGVkIC0uLT4gfENhbmNlbCB0cmFjZXxUcmFjZUNhbmNlbGVke1RyYWNlL0NhbmNlbGVkfVxuICAgIFRyYWNlQ2FuY2VsZWQgPT0-fERvbmF0aW9uIGNvbWVzIGZyb20gY29tbXVuaXR5fCBDb21tdW5pdHlXYWl0aW5nXG4gICAgVHJhY2VDYW5jZWxlZCA9PT4gIHxDYW1wYWlnbiBpcyBkb25hdGlvbiBwYXJlbnQgb3duZXJ8Q2FtcGFpZ25Db21taXR0ZWRcbiAgICBUcmFjZUNhbmNlbGVkID09PiAgfERvbmF0aW9uIGNvbWVzIGZyb20gRGlyZWN0IGRvbmF0aW9uc3xHaXZlckNvbW1pdHRlZFxuICAgICIsIm1lcm1haWQiOiJ7XG4gIFwidGhlbWVcIjogXCJkZWZhdWx0XCJcbn0iLCJ1cGRhdGVFZGl0b3IiOmZhbHNlLCJhdXRvU3luYyI6dHJ1ZSwidXBkYXRlRGlhZ3JhbSI6ZmFsc2V9)

## Help

For more info on how to work with feathers checkout out their docs on [service methods](https://docs.feathersjs.com/api/databases/common.html#service-methods), [service events](https://docs.feathersjs.com/api/events.html#service-events), and [database querying](https://docs.feathersjs.com/api/databases/querying.html).
Expand Down
3 changes: 2 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@
"createDonationTtlSeconds":3600,
"createDonationThreshold":300,
"createAuthenticationTtlSeconds":60,
"createAuthenticationThreshold":10
"createAuthenticationThreshold":10,
"whitelist": []
},
"givethIoUrl": "https://serve.giveth.io/graphql",
"givethIoProjectsReviewerAddress": "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { ObjectID } = require('mongodb');

const findParentDonation = (db, parentDonations) => {
if (parentDonations.length === 0) {
return undefined;
}
return db.collection('donations').findOne({ _id: ObjectID(parentDonations[0]) });
};
module.exports = {
async up(db, _client) {
const cursor = await db
.collection('donations')
.find({ ownerType: 'campaign', status: 'Committed', mined: true, isReturn: false });
console.log('updated donations :');
// eslint-disable-next-line no-restricted-syntax
for await (const donation of cursor) {
const { ownerTypeId, parentDonations } = donation;
const parentDonation = await findParentDonation(db, parentDonations);
// console.log('donations', { donation, parentDonation });

if (!parentDonation || !['Paid', 'Committed'].includes(parentDonation.status)) {
// eslint-disable-next-line no-continue
continue;
}
const grandParentDonation = await findParentDonation(db, parentDonation.parentDonations);
if (
grandParentDonation &&
grandParentDonation.status === 'Committed' &&
grandParentDonation.ownerType === 'campaign' &&
grandParentDonation.ownerTypeId === ownerTypeId
) {
// in this case we know that money went from campaign to a trace, the recipient of
// that trace is very campaign, so after disbursing (withdraw), the money go back to campaign
console.log(String(donation._id));
db.collection('donations').updateOne({ _id: donation._id }, { $set: { isReturn: true } });
}
}
},

// eslint-disable-next-line no-empty-function
async down(_db, _client) {},
};
Loading