You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-11
Original file line number
Diff line number
Diff line change
@@ -82,8 +82,8 @@ The directory structure should look like the image below.
82
82
This file states that the index will:
83
83
- keep track of the *issuer* field of each document
84
84
- store this index in a design document (ddoc) named *issuerIndexDoc*
85
-
- is named issuerIndex
86
-
- will be in json format
85
+
- is named *issuerIndex*
86
+
- will be in *json* format
87
87
88
88
Now let's create two more index files.
89
89
@@ -101,7 +101,7 @@ Now let's create two more index files.
101
101
}
102
102
```
103
103
104
-
This index is very similar to the previous one for the issuer field but instead we are indexing the *owner* field.
104
+
This index is very similar to the previous one for the *issuer* field but instead we are indexing the *owner* field.
105
105
106
106
5. Finally, create one last file in the **indexes** directory and name it **currentStateIndex.json**
107
107
6. Then, copy the following code into that file:
@@ -132,8 +132,8 @@ And that's all it takes to build indexes. These indexes will be deployed the nex
132
132
133
133
Now we need to implement the query logic in the transactions of the smart contract. These transactions will be invoked by the Node.js SDK to execute our queries.
134
134
135
-
1. Using VSCode, open the [papercontract.js](./papercontract.js) file found in this pattern repo
136
-
2. Replace the contents of [contract/lib/papercontract.js](./contract/lib/papercontract.js) with the new [papercontract.js](./papercontract.js)
135
+
1. Using VSCode, open the [papercontract.js](./papercontract.js) file found in this pattern repo.
136
+
2. Replace the contents of [contract/lib/papercontract.js](./contract/lib/papercontract.js) with the new [papercontract.js](./papercontract.js).
137
137
138
138
This updated contract already has the query logic added. Let's take a look at the transactions that were added.
139
139
@@ -145,7 +145,7 @@ This updated contract already has the query logic added. Let's take a look at th
145
145
146
146
Let's take a closer look at the code involved in making these queries.
147
147
148
-
Open the new [papercontract.js](./papercontract.js) in VS Code and go to line 182
148
+
Open the new [papercontract.js](./papercontract.js) in VS Code and go to line 182.
149
149
150
150
<br>
151
151
<palign="center">
@@ -162,7 +162,7 @@ The next property to note is `use_index` which allows you to specify a design do
162
162
163
163
Since we made changes to the smart contract we now need to re-deploy it to the peer.
164
164
165
-
1. Open up [contract/package.json](./contract/package.json) in VS Code
165
+
1. Open up [contract/package.json](./contract/package.json) in VS Code.
166
166
167
167
2. Change the *version* property to **0.0.2** and save the file.
168
168
@@ -274,7 +274,7 @@ Your folder structure should look similar to the picture below, with the wallet
274
274
275
275
Right now the world state is empty and there is nothing to query. Let's add some entries to the ledger so that we can see some results when we run the queries.
276
276
277
-
1. From the terminal and while in the **application** folder, run `node setup.js`
277
+
1. From the terminal and while in the **application** folder, run `node setup.js`.
278
278
279
279
This will run through a variety of transactions to populate the ledger. The process will take about 2-3 minutes. While this is running, take a look at the **setup.js** file from within VS Code to see what the transactions are doing.
280
280
@@ -283,11 +283,11 @@ This will run through a variety of transactions to populate the ledger. The proc
283
283
284
284
Now we can finally get around to querying the world state.
285
285
286
-
1. From the terminal, run `node query.js`
286
+
1. From the terminal, run `node query.js`.
287
287
288
288
This query will return absolutely everything that is in the world state. While this might be valuable in some situations, in most cases you will want to search based on certain criteria such as by owner or by status.
289
289
290
-
2. From the terminal, run `node queryByOwner.js`
290
+
2. From the terminal, run `node queryByOwner.js`.
291
291
292
292
This query will return all assets that are currently owned by MagnetoCorp. If you take a look at the `queryByOwner.js` file in VS Code you can see in line 66 that we are calling the `queryByOwner` transaction defined in the `papercontract.js` file and that we are passing in `MagnetoCorp` as the only argument. You can easily change `MagnetoCorp` to `DigiBank` and rerun the query to get all assets owned by DigiBank instead.
293
293
@@ -297,7 +297,7 @@ This query will return all assets that are currently owned by MagnetoCorp. If yo
297
297
</p>
298
298
<br>
299
299
300
-
3. From the terminal, run `node queryByCurrentState.js`
300
+
3. From the terminal, run `node queryByCurrentState.js`.
301
301
302
302
This query will return all commercial papers that have been bought. If you take a look at `queryByCurrentState.js` in VS Code you can see in line 64 that this time we are calling the `queryByCurrentState` transaction in `papercontract.js` and passing in the status code of 2 as the only parameter. The status codes for the commercial papers are as follows:
0 commit comments