Skip to content

Commit

Permalink
[documentation]: enhance docs
Browse files Browse the repository at this point in the history
- restructure recipes to be more compliant with hyperledger-iroha#130
- extend "maintenance" section in the root README
- include `lint` command into CI/CD
- fix lint errors

Signed-off-by: 0x009922 <[email protected]>
  • Loading branch information
0x009922 committed Nov 8, 2022
1 parent 0426533 commit 7d629c1
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 14 deletions.
7 changes: 4 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist
**/crypto/**/wasm_pack_output*
**/crypto/packages/target-*/index.js
**/data-model/src/__generated__.ts
dist-tsc
/packages/crypto/crypto-rs/iroha_crypto_wasm
/packages/crypto/packages/target-*/index.js
/packages/data-model/src/__generated__.ts
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def pipeline = new org.js.LibPipeline( steps: this,
libPushBranches: ['iroha2'],
npmRegistries: ['https://nexus.iroha.tech/repository/npm-soramitsu/': 'bot-soramitsu-rw'],
preBuildCmds: ['npm install -g n','n 16.17.0', 'n prune', 'pnpm install --unsafe-perm'],
testCmds: ['pnpm type-check','pnpm test','npm config set registry "https://nexus.iroha.tech/repository/npm-soramitsu/"'],
pushCmds: ['pnpm jake publish-all'],
testCmds: ['pnpm type-check','pnpm lint','pnpm test'],
pushCmds: ['npm config set registry "https://nexus.iroha.tech/repository/npm-soramitsu/"', 'pnpm jake publish-all'],
secretScannerExclusion: '.*Cargo.toml\$|.*README.md\$'
)
pipeline.runPipeline()
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,41 @@ Check out [Hyperledger Iroha 2 Tutorial](https://hyperledger.github.io/iroha-2-d

## Maintenance

### Explore Jake tasks
Make sure you have installed Node.js v16.17 or v18. As for a package manager, this project uses [PNPM](https://pnpm.io/).

Before working with the repo, install packages:

```bash
pnpm install
```

### Scripts

Most tasks are defined via [Jake](https://github.com/jakejs/jake), a JavaScript build tool. To explore available tasks, run:

```bash
pnpm jake -t
```

However, some tasks are defined directly in `package.json` and could be run with `pnpm run`:

```bash
# Run all project tests
pnpm test

# Perform type-checking
pnpm type-check

# Check/fix lint errors
pnpm lint
pnpm lint --fix

# Fix formatting
pnpm format:fix
```

Each monorepo package might have its own scripts and tasks. Please refer to a specific package's README for details.

### Manually update reference Iroha version

1. Update `packages/dev-iroha-bins/src/config.ts`:
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
"preinstall": "npx only-allow pnpm",
"test": "run-s test:unit test:crypto build test:client",
"test:unit": "vitest run",
"test:crypto": "pnpm --filter monorepo-crypto run test",
"test:client": "pnpm --filter client run test:integration",
"test:crypto": "pnpm --filter monorepo-crypto test",
"test:client": "pnpm --filter client test:integration",
"clean": "pnpm jake clean",
"build": "pnpm jake build",
"build:tsc": "pnpm --parallel --filter !monorepo --filter data-model --filter client --filter i64-fixnum run build:tsc",
"build:tsc": "pnpm --parallel --filter !monorepo --filter data-model --filter client --filter i64-fixnum build:tsc",
"build:bundle": "pnpm jake build-bundle",
"build:rollup": "rollup -c",
"publish-all": "pnpm jake publish-all",
"type-check": "tsc --noEmit",
"format:fix": "prettier-eslint \"**/*.{ts,js,vue,json}\" --write"
"format:fix": "prettier-eslint \"**/*.{ts,js,vue,json}\" --write",
"lint": "eslint ."
},
"devDependencies": {
"@changesets/cli": "^2.23.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/client/test/integration/test-web/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import CreateDomain from './components/CreateDomain.vue'
import Listener from './components/Listener.vue'
import EventListener from './components/EventListener.vue'
import StatusChecker from './components/StatusChecker.vue'
</script>

Expand All @@ -9,7 +9,7 @@ import StatusChecker from './components/StatusChecker.vue'
<hr>
<CreateDomain />
<hr>
<Listener />
<EventListener />
</template>

<style lang="scss">
Expand Down
File renamed without changes.
File renamed without changes.
76 changes: 76 additions & 0 deletions packages/docs-recipes/src/6.query-domains-accounts-assets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { Client, ToriiRequirementsForApiHttp } from '@iroha2/client'
import { QueryBox } from '@iroha2/data-model'

declare const client: Client
declare const toriiRequirements: ToriiRequirementsForApiHttp

// list all domains
{
const result = await client.requestWithQueryBox(
toriiRequirements,
QueryBox('FindAllDomains', null),
)

const domains = result
.as('Ok')
.result.as('Vec')
.map((x) => x.as('Identifiable').as('Domain'))

for (const domain of domains) {
console.log(
`Domain "${domain.id.name}" has ${domain.accounts.size} accounts` +
` and ${domain.asset_definitions.size} asset definitions`,
)
// => Domain "wonderland" has 5 accounts and 3 asset definitions
}
}

// list all accounts
{
const result = await client.requestWithQueryBox(
toriiRequirements,
QueryBox('FindAllAccounts', null),
)

const accounts = result
.as('Ok')
.result.as('Vec')
.map((x) => x.as('Identifiable').as('Account'))

for (const account of accounts) {
console.log(
`Account "${account.id.name}@${account.id.domain_id.name}" ` +
`has ${account.assets.size} assets`,
)
// => Account "alice@wonderland" has 3 assets
}
}

// list all assets
{
const result = await client.requestWithQueryBox(
toriiRequirements,
QueryBox('FindAllAssets', null),
)

const assets = result
.as('Ok')
.result.as('Vec')
.map((x) => x.as('Identifiable').as('Asset'))

for (const asset of assets) {
const assetType = asset.value.match({
Quantity: () => 'Quantity',
BigQuantity: () => 'Big Quantity',
Fixed: () => 'Fixed',
Store: () => 'Store',
})

console.log(
`Asset "${asset.id.definition_id.name}#${asset.id.definition_id.domain_id.name}" ` +
`at account "${asset.id.account_id.name}@${asset.id.account_id.domain_id.name}" ` +
`has type "${assetType}"`,
)
// => Asset "rose#wonderland" at account "alice@wonderland" has type "Quantity"
}
}
2 changes: 0 additions & 2 deletions packages/docs-recipes/src/6.ts

This file was deleted.

0 comments on commit 7d629c1

Please sign in to comment.