koilib 3.1.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -99,10 +99,12 @@ a transaction, and read contracts.
99
99
  const koin = koinContract.functions;
100
100
 
101
101
  // optional: preformat input/output
102
- koinContract.abi.methods.balanceOf.preformatInput = (owner) => ({ owner });
103
- koinContract.abi.methods.balanceOf.preformatOutput = (res) =>
102
+ koinContract.abi.methods.balanceOf.preformat_argument = (owner) => ({
103
+ owner,
104
+ });
105
+ koinContract.abi.methods.balanceOf.preformat_return = (res) =>
104
106
  utils.formatUnits(res.value, 8);
105
- koinContract.abi.methods.transfer.preformatInput = (input) => ({
107
+ koinContract.abi.methods.transfer.preformat_argument = (input) => ({
106
108
  from: signer.getAddress(),
107
109
  to: input.to,
108
110
  value: utils.parseUnits(input.value, 8),
@@ -168,7 +170,7 @@ You can also upload a contract in a new address. It is not required that this ne
168
170
 
169
171
  // create contract. Set newAccount as signer
170
172
  const contract = new Contract({
171
- signer: newAccount.address,
173
+ signer: newAccount,
172
174
  provider,
173
175
  bytecode,
174
176
  });
@@ -222,28 +224,28 @@ const tokenJson = require("./token-proto.json");
222
224
  const abiToken = {
223
225
  methods: {
224
226
  balanceOf: {
225
- entryPoint: 0x5c721497,
226
- inputs: "balance_of_arguments",
227
- outputs: "balance_of_result",
228
- readOnly: true,
229
- defaultOutput: { value: "0" },
227
+ entry_point: 0x5c721497,
228
+ argument: "balance_of_arguments",
229
+ return: "balance_of_result",
230
+ read_only: true,
231
+ default_output: { value: "0" },
230
232
  },
231
233
  transfer: {
232
- entryPoint: 0x27f576ca,
233
- inputs: "transfer_arguments",
234
- outputs: "transfer_result",
234
+ entry_point: 0x27f576ca,
235
+ argument: "transfer_arguments",
236
+ return: "transfer_result",
235
237
  },
236
238
  mint: {
237
- entryPoint: 0xdc6f17bb,
238
- inputs: "mint_argumnets",
239
- outputs: "mint_result",
239
+ entry_point: 0xdc6f17bb,
240
+ argument: "mint_argumnets",
241
+ return: "mint_result",
240
242
  },
241
243
  },
242
- types: tokenJson,
244
+ koilib_types: tokenJson,
243
245
  };
244
246
  ```
245
247
 
246
- Note that this example uses "defaultOutput" for the method
248
+ Note that this example uses "default_output" for the method
247
249
  "balanceOf". This is used when the smart contract returns an
248
250
  empty response (for instance when there are no balance records
249
251
  for a specific address) and you require a default output in
@@ -267,13 +269,14 @@ such cases.
267
269
  For the ABI you need the .proto file and the library
268
270
  [protobufjs](https://www.npmjs.com/package/protobufjs). Then follow the format
269
271
  for the ABI as described in the previous section. It's important to note that
270
- this ABI is not the same ABI used in [koinos-cli](https://docs.koinos.io/architecture/contract-abi.html).
271
- In particular, descriptors use different format (koilib using json format, cli
272
- using binary format).
272
+ this ABI has a diffence with respect to the ABI used in [koinos-cli](https://docs.koinos.io/architecture/contract-abi.html).
273
+ In particular, koilib takes the descriptor from `koilib_types`, which is a
274
+ descriptor in json format, while the ABI in koinos-cli takes the descriptor from
275
+ `types`, which is a descriptor in binary format.
273
276
 
274
277
  4. Can this library be used to interact with smart contracts?
275
278
 
276
- Yes. You can use it to call readOnly functions, or send transactions
279
+ Yes. You can use it to call read_only functions, or send transactions
277
280
  to the contract by calling write functions.
278
281
 
279
282
  ## Documentation