laconic-registry-cli/records-demo.md

3.5 KiB

Records Demo

  • Run the laconicd chain:

    # In laconcid
    make install
    ./scripts/init.sh clean
    
  • Create and populate config.yml following config.example.yml:

    # Get user key
    laconicd keys export alice --unarmored-hex --unsafe --keyring-backend test --home ~/.laconicd
    
    # Create a bond
    laconicd tx bond create 100000000000photon --fees 100photon --from alice
    
    # Get the bond id
    laconicd query bond list
    
  • Install the CLI:

    yarn && yarn build
    yarn global add file:$PWD
    
  • Publish watcher records from records/watcher:

    # Publishes records and corresponding 'deployment' records from the given directory
    yarn ts-node src/publish-endponit-records.ts -c config.yml -r records/watcher
    

Example

  • Query for ajna-watcher deployment:

    • Find the WatcherRecord for ajna-watcher:

      WATCHER_RECORD_ID=$(laconic registry record list --all --type WatcherRecord --name ajna-watcher | jq -r '.[].id')
      
    • Find corresponding deployment(s):

      laconic registry record list --all --type WatcherDeploymentRecord watcher $WATCHER_RECORD_ID
      
      # Get the deployment URL(s)
      laconic registry record list --all --type WatcherDeploymentRecord watcher $WATCHER_RECORD_ID | jq -r '.[].attributes.url'
      

Query GQL

  • View the records at laconicd GQL endpoint http://localhost:9473:

    {
      queryRecords {
        id
        bondId
        names
        attributes {
          key
          value {
            ... on BooleanValue { bool: value }
            ... on IntValue { int: value }
            ... on FloatValue { float: value }
            ... on StringValue { string: value }
            ... on BytesValue { bytes: value }
            ... on LinkValue { link: value }
            ... on ArrayValue {
              array: value {
                ... on BooleanValue { bool: value }
                ... on IntValue { int: value }
                ... on FloatValue { float: value }
                ... on StringValue { string: value }
                ... on BytesValue { bytes: value }
                ... on LinkValue { link: value }
              }
            }
            ... on MapValue { map: value { key mapping: value { __typename } } }
          }
        }
      }
    }
    
  • Query with filters, for example: query all filecoin WatcherRecords:

    {
      queryRecords (
        attributes: [
          {
            key: "type",
            value: {
              string: "WatcherRecord"
            }
          },
          {
            key: "chain",
            value: {
              string: "filecoin"
            }
          }
        ],
        all: true
      ) {
        id
        bondId
        names
        attributes {
          key
          value {
            ... on BooleanValue { bool: value }
            ... on IntValue { int: value }
            ... on FloatValue { float: value }
            ... on StringValue { string: value }
            ... on BytesValue { bytes: value }
            ... on LinkValue { link: value }
            ... on ArrayValue {
              array: value {
                ... on BooleanValue { bool: value }
                ... on IntValue { int: value }
                ... on FloatValue { float: value }
                ... on StringValue { string: value }
                ... on BytesValue { bytes: value }
                ... on LinkValue { link: value }
              }
            }
            ... on MapValue { map: value { key mapping: value {  __typename } } }
          }
        }
      }
    }