NEAR-DevHub / neardevhub-contract

DevHub Portal Product Contract (Hosted on NEAR Blockchain) – Includes other instances (e.g. Infrastructure, Events)
https://neardevhub.org
19 stars 15 forks source link

Proposal feature #89

Closed PolyProgrammist closed 8 months ago

PolyProgrammist commented 9 months ago

Create a proposal feature on contract side according to the design

PolyProgrammist commented 9 months ago

Main ticket here: https://github.com/NEAR-DevHub/neardevhub-contract/issues/89

PolyProgrammist commented 9 months ago

Draft pull request: https://github.com/PolyProgrammist/neardevhub-contract/pull/2

petersalomonsen commented 9 months ago

Can we add these acceptance criterias?

PolyProgrammist commented 9 months ago

Can we add these acceptance criterias?

  • [ ] Verify backend

    • [ ] Verify that the contract implements the data structure that represents the frontend
    • [ ] Verify that the contract implements the same verification mechanisms and validation messages as the frontend
  • [ ] Verify backend automatic tests

    • [ ] Verify that there are unit test on the detailed level covering multiple variants of input and expectations
    • [ ] Verify that there are integration tests using near-workspaces-rs for covering the scenarios of input and expected output from the frontend

Sure

PolyProgrammist commented 9 months ago

add_proposal

near contract \
    call-function \
    as-transaction satisfying-airplane.testnet add_proposal \
    json-args '{"body": {
                "proposal_body_version": "V0",
                "name": "another post",
                "description": "some description",
                "category": "Events",
                "summary": "sum",
                "linked_proposals": [{"link_type": "PostId", "id": 1}, {"link_type": "PostId", "id": 3}],
                "requested_sponsorship_amount": "1000000000",
                "requested_sponsorship_token": "USD",
                "receiver_account": "polyprogrammist.near",
                "supervisor": "frol.near",
                "requested_sponsor": "neardevdao.near",
                "payouts": [],
                "timeline": {"status": "DRAFT"}
            },
            "labels": ["test1", "test2"]}' \
    prepaid-gas '300 Tgas' \
    attached-deposit '0.9 NEAR' \
    sign-as satisfying-airplane.testnet  \
    network-config testnet \
    sign-with-keychain \
    send

get_proposals

near contract \
    call-function \
    as-read-only satisfying-airplane.testnet get_proposals \
    json-args '{}' \
    network-config testnet \
    now

--------------
Logs:
  get_proposals
--------------
Result:
[
  {
    "author_id": "test_proposals.testnet",
    "id": 0,
    "proposal_version": "V0",
    "snapshot": {
      "category": "Marketing",
      "description": "some description",
      "editor_id": "test_proposals.testnet",
      "labels": [
        "test1",
        "test2"
      ],
      "linked_proposals": [
        {
          "id": 1,
          "link_type": "PostId"
        },
        {
          "id": 3,
          "link_type": "PostId"
        }
      ],
      "name": "another post",
      "payouts": [],
      "proposal_body_version": "V0",
      "receiver_account": "polyprogrammist.near",
      "requested_sponsor": null,
      "requested_sponsorship_amount": "1000000000",
      "requested_sponsorship_token": "USD",
      "summary": "sum",
      "supervisor": "frol.near",
      "timeline_status": {
        "timeline_status": "DRAFT"
      },
      "timestamp": "1706889070302059184"
    },
    "snapshot_history": [],
    "social_db_post_block_height": "156586362"
  }
]

get_proposal

near contract \
    call-function \
    as-read-only satisfying-airplane.testnet get_proposal \ 
    json-args '{"proposal_id": 0}' \
    network-config testnet \
    now
--------------
Logs:
  get_proposal
--------------
Result:
{
  "author_id": "test_proposals.testnet",
  "id": 0,
  "proposal_version": "V0",
  "snapshot": {
    "category": "Marketing",
    "description": "some description",
    "editor_id": "test_proposals.testnet",
    "labels": [
      "test1",
      "test2"
    ],
    "linked_proposals": [
      {
        "id": 1,
        "link_type": "PostId"
      },
      {
        "id": 3,
        "link_type": "PostId"
      }
    ],
    "name": "another post",
    "payouts": [],
    "proposal_body_version": "V0",
    "receiver_account": "polyprogrammist.near",
    "requested_sponsor": null,
    "requested_sponsorship_amount": "1000000000",
    "requested_sponsorship_token": "USD",
    "summary": "sum",
    "supervisor": "frol.near",
    "timeline_status": {
      "timeline_status": "DRAFT"
    },
    "timestamp": "1706889070302059184"
  },
  "snapshot_history": [],
  "social_db_post_block_height": "156586362"
}

get_all_proposal_ids

near contract \
    call-function \
    as-read-only satisfying-airplane.testnet get_all_proposal_ids \
    json-args '{}' \                
    network-config testnet \
    now
--------------
Logs:
  get_all_proposal_ids
--------------
Result:
[
  0
]

get_proposals_by_author

near contract \
    call-function \
    as-read-only satisfying-airplane.testnet get_proposals_by_author \
    json-args '{"author": "test_proposals.testnet"}' \
    network-config testnet \
    now
--------------
Logs:
  get_proposals_by_author
--------------
Result:
[
  0
]

get_proposals_by_label

near contract \
    call-function \
    as-read-only satisfying-airplane.testnet get_proposals_by_label \ 
    json-args '{"label": "test1"}' \            
    network-config testnet \
    now
--------------
Logs:
  get_proposals_by_label
--------------
Result:
[
  0
]

get_all_proposal_labels

near contract \
    call-function \
    as-read-only satisfying-airplane.testnet get_all_proposal_labels \
    json-args '{}' \                
    network-config testnet \
    now
--------------
Logs:
  get_all_proposal_labels
--------------
Result:
[
  "test1",
  "test2"
]

get_all_proposal_authors

near contract \
    call-function \
    as-read-only satisfying-airplane.testnet get_all_proposal_authors \
    json-args '{}' \
    network-config testnet \
    now
--------------
Logs:
  get_all_proposal_authors
--------------
Result:
[
  "test_proposals.testnet"
]

is_allowed_to_edit_proposal

near contract \
    call-function \
    as-read-only satisfying-airplane.testnet is_allowed_to_edit_proposal \
    json-args '{"proposal_id": 0, "editor": "test_proposals.testnet"}' \
    network-config testnet \
    now
--------------
Logs:
  is_allowed_to_edit
--------------
Result:
true

get_all_allowed_proposal_labels

near contract \
    call-function \
    as-read-only satisfying-airplane.testnet get_all_allowed_proposal_labels \
    json-args '{"editor": "test_proposals.testnet"}' \ 
    network-config testnet \
    now
--------------
Logs:
  get_all_allowed_proposal_labels
--------------
Result:
[
  "test1",
  "test2"
]

edit_proposal

near contract \
    call-function \
    as-transaction satisfying-airplane.testnet edit_proposal \
    json-args '{"id": 0, "body": {
                "proposal_body_version": "V0",
                "name": "haha edited name",
                "description": "some description",
                "category": "Marketing",
                "summary": "sum",
                "linked_proposals": [{"link_type": "PostId", "id": 1}, {"link_type": "PostId", "id": 3}],
                "requested_sponsorship_amount": "1000000000",
                "requested_sponsorship_token": "USD",
                "receiver_account": "polyprogrammist.near",
                "supervisor": "frol.near",
                "requested_sponsor": "neardevdao.near",
                "payouts": [ "5PHaiXRvtZTYVSEBN5prT6M1odceCPxKzgpTZDmqrZsC" ],
                "timeline": {"status": "REVIEW", "sponsor_requested_review": false, "reviewer_completed_attestation": false }
            },
            "labels": ["test1", "test2"]}' \
    prepaid-gas '300 Tgas' \
    attached-deposit '0.9 NEAR' \
    sign-as satisfying-airplane.testnet  \
    network-config testnet \
    sign-with-keychain \
    send

timeline statuses:

timeline": {"status": "DRAFT"}
"timeline": {"status": "REVIEW", "sponsor_requested_review": true, "reviewer_completed_attestation": false }
"timeline": {"status": "APPROVED", "sponsor_requested_review": true, "reviewer_completed_attestation": false }
"timeline": {"status": "REJECTED", "sponsor_requested_review": true, "reviewer_completed_attestation": false }
"timeline": {"status": "APPROVED_CONDITIONALLY", "sponsor_requested_review": true, "reviewer_completed_attestation": false }
"timeline": {"status": "PAYMENT_PROCESSING", "kyc_verified": false, "test_transaction_sent": false, "request_for_trustees_created": false, "sponsor_requested_review": true, "reviewer_completed_attestation": false }
"timeline": {"status": "FUNDED", "trustees_released_payment": false, "kyc_verified": false, "test_transaction_sent": false, "request_for_trustees_created": false, "sponsor_requested_review": true, "reviewer_completed_attestation": false }

Mandatory fields: proposal_body_version name description summary category linked_proposals (can be empty array) payouts (can be empty array) timeline requested_sponsorship_amount receiver_account requested_sponsor

frol commented 8 months ago

It was implemented in #90