forked from hyperledger-iroha/iroha-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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
Showing
13 changed files
with
119 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
76 changes: 76 additions & 0 deletions
76
packages/docs-recipes/src/6.query-domains-accounts-assets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.