near-daos / sputnik-dao-contract

Smart contracts for https://app.astrodao.com
https://astrodao.com/
MIT License
108 stars 77 forks source link

Add contract metadata for the DAO when storing its contract code #94

Closed ctindogaru closed 2 years ago

ctindogaru commented 2 years ago

The metadata will consist of:

Tested manually via bash.

Usage:

// first store the contract code, which will return its hash
$ BYTES=$(cat sputnikdao2/res/sputnikdao2.wasm | base64)
$ near call sputnik.ctindogaru10.testnet store $BYTES --base64 --accountId sputnik.ctindogaru10.testnet --gas 100000000000000 --amount 10
// the above command will return 7ujcmhfQgQHnq7o7Bzz2VRGTSY2Yd97j8UmBStm9aEe4
// now store the metadata
$ near call sputnik.ctindogaru10.testnet store_contract_metadata '{"metadata": {"code_hash": "7ujcmhfQgQHnq7o7Bzz2VRGTSY2Yd97j8UmBStm9aEe4", "version": "v3", "commit_id": "tobecompleted", "readme": "readme_ceva"}}' --accountId sputnik.ctindogaru10.testnet

Get the contract information:

$ near view sputnik.ctindogaru10.testnet get_contract_metadata

Output example:

[
  {
    code_hash: 'GUMFKZP6kdLgy3NjKy1EAkn77AfZFLKkj96VAgjmHXeS',
    version: '',
    commit_id: '',
    readme: ''
  },
  {
    code_hash: '7ujcmhfQgQHnq7o7Bzz2VRGTSY2Yd97j8UmBStm9aEe4',
    version: 'v3',
    commit_id: 'tobecompleted',
    readme: 'readme_ceva'
  },
  {
    code_hash: '4ptDdxS1QweMYr3RZTTsw5RjfAwQaxPoRUkm5FwxvMMP',
    version: 'v4',
    commit_id: 'some_commit_id',
    readme: 'some_readme'
  }
]
ctindogaru commented 2 years ago

@ilblackdragon this might interest you as well