Contributing as a Developer

KodaDot_logo_v3

Getting Started

We are using a pnpm workspace, installing things via npm will result in broken dependencies.

Prerequisites

You're using a version of node that's on/after version 16.13.2

You have pnpm installed.

  • You can install pnpm by running in your terminal
npm install -g pnpm
1

Installation

  1. Fork our Repositoryopen in new window
  2. Go to the forked repo and click the green "Code" button
  3. Copy the HTTPS link (i.e https://github.com/your-username/nft-gallery.git)
  4. Go to your IDE and open the terminal
  5. Type in the terminal "git clone your-HTTPS-link".

For example,

git clone https://github.com/your-username/nft-gallery.git
1
  1. Then paste these two commands in the terminal
cd nft-gallery;
pnpm i;
1
2

If you come across ERR_PNPM_UNSUPPORTED_ENGINE  Unsupported environment (bad pnpm and/or Node.js version), run

nvm use 16
1
  1. Lastly, start the server by running
pnpm dev
1

KodaDot will be available at localhost:9090open in new window.

Using KodaDot on Kusama

If you want to try out our KodaDot on Kusama, you must have Docker (install hereopen in new window) and docker-compose (install hereopen in new window) installed to have a local setup and node.

Installation

  1. Build the docker image

    docker-compose up --build
    
    1
  2. Check if the container is up:

    docker ps
    
    1
  3. Run:

    docker-compose up
    
    1

KodaDot will be available at localhost:9090open in new window.

KodaDot supports Hot Module Replacement on Docker; any changes made will take effect immediately.

Running local Polkadot and Subquery nodes

To run the complete local environment, we recommend running a Polkadot/Kusama nodeopen in new window. In case you are using Apple M1, we have a tutorial for that 🍏 open in new window

Current Indexers we have/use:

Checking your code

Linting code

Show all problems

yarn lint
1

Show only errors

yarn lint --quiet
1

Fix errors

yarn lint --fix
1

Generating changelog

To generate a changelog, use GitHub CLI List only merged

If you need limit, use -L

gh pr list -s merged --json mergedAt,baseRefName,number,title,headRefName -B main -L 37 | jq -r '.[] | .number, .title' | sed '/^[0-9]/{N; s/\n/ /;}'
1

Troubleshooting

How can I resolve conflict on yarn.lock?

CONFLICT (content): Merge conflict in yarn.lock

When you see conflict on yarn.lock and you are on your pull-request branch, merge upstream branch and run yarn, unless you have conflict on package.json, that requires manual resolve.

git fetch --all 
git merge origin/main
yarn
1
2
3

How can I read some data from the GraphQL?

Every .graphql file is located in the src/queries/.

query nftByIdMinimal($id: String!) {
  nFTEntity(id: $id) {
    id
    currentOwner
    price
  }
}
1
2
3
4
5
6
7

To use it inside the .vue file, we can import it like a regular module: For specific purposes, we also need to import the PrefixMixin. Thanks to that app, know which indexer is using.

PrefixMixin is only applicable to the SubQuery indexers. To use SubSquid, please use client: 'subsquid' in the query call.

Then we can use it like this:

<script lang="ts">
  import { Component, mixins } from "nuxt-property-decorator"

  import nftByIdMinimal from "@/queries/nftByIdMinimal.graphql"
  import PrefixMixin from "~/utils/mixins/prefixMixin"

  @Component({})
  export default class GalleryItem extends mixins(PrefixMixin) {
    id: string = ""
    nft: NFT = emptyObject<NFT>()

    async fetch() {
      const { data } = await this.$apollo.query({
        client: this.urlPrefix,
        query: nftByIdMinimal,
        variables: { id: this.id },
      })

      this.nft = data.nFTEntity
      console.log("nft", this.nft)
    }
  }
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

How can I read on-chain data from the RPC node?

<script lang="ts">
  import { Component, Vue } from "nuxt-property-decorator"
  import Connector from "@kodadot1/sub-api"

  @Component({})
  export default class GalleryItem extends Vue {
    id = "0"
    collectionId = "0"

    async fetch() {
      const { api } = Connector.getInstance()
      const nft = await api.query.uniques.asset(this.collectionId, this.id)
      console.log("nft", nft)
    }
  }
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

Is it possible to subscribe to the on-chain data from the RPC node?

<script lang="ts">
  import { Component, mixins } from "nuxt-property-decorator"
  import SubscribeMixin from "@/utils/mixins/subscribeMixin"

  @Component({})
  export default class GalleryItem extends mixins(SubscribeMixin) {
    id = "0"
    collectionId = "0"

    async created() {
      this.subscribe(
        api.query.uniques.asset,
        [this.collectionId, this.id],
        (nft: any) => console.log(nft) // callback which returns the data
      )
    }
  }
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

How can I make an on-chain transaction?

<script lang="ts">
  import { Component, mixins } from "nuxt-property-decorator"
  import MetaTransactionMixin from "@/utils/mixins/metaMixin"
  // import AuthMixin from '~/utils/mixins/authMixin' // get currently logged in account

  import Connector from "@kodadot1/sub-api"

  @Component({})
  export default class GalleryItem extends mixins(MetaTransactionMixin) {
    async submit() {
      const cb = api.tx.system.remark
      const args = "Hello World"

      await this.howAboutToExecute(
        this.accountId, // sender can be obtained from the AuthMixin
        cb,
        [args],
        (blockNumber) =>
          console.log(`Remark ${args} saved in block ${blockNumber}`)
      )
    }
  }
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

How can I test Kodadot without spending KSM?

You can obtain some Westend (WND)open in new window

You can change the network in the navbar. Currently supported networks are Kusama, Westend, statemine, westmint. Do you want to add more networks? Open a PR on vuex-optionsopen in new window

Notice for contributors before January 15, 2022

If you've forked nft-gallery before January 15, 2022, you have an older fork that doesn't include our newest additions.

There's two ways you can work around this:

  1. Re-forkingopen in new window
  2. Syncing your forkopen in new window

Learn more about these issues here:

Contributing Guidelines

Before submitting your pull request, read up on our documentationopen in new window and make sure it follows:

Failure to do so can lead to your PR being rejected

We rewardopen in new window our contributors in $KSM for their time and effort with every issue they solve. If you're finding yourself to be more involved with KodaDot, we are always hiringopen in new window.

Meta-Hours

We have bi-weekly meetings with contributors of KodaDot to share each other's progress as well as future goals in our Discord severopen in new window. Before speaking, please make sure you're prepared as a speaker.

Is this your first time joining? Feel free to catch up on our past Meta_Hoursopen in new window!

Refeferences