koilib 5.3.1 → 5.5.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 +85 -4
- package/dist/koinos.js +15717 -2629
- package/dist/koinos.min.js +1 -1
- package/lib/Contract.d.ts +49 -5
- package/lib/Contract.js +168 -98
- package/lib/Contract.js.map +1 -1
- package/lib/Serializer.d.ts +36 -15
- package/lib/Serializer.js +82 -16
- package/lib/Serializer.js.map +1 -1
- package/lib/Signer.js +1 -1
- package/lib/Signer.js.map +1 -1
- package/lib/Transaction.d.ts +109 -0
- package/lib/Transaction.js +184 -0
- package/lib/Transaction.js.map +1 -0
- package/lib/browser/Contract.d.ts +49 -5
- package/lib/browser/Contract.js +168 -98
- package/lib/browser/Contract.js.map +1 -1
- package/lib/browser/Serializer.d.ts +36 -15
- package/lib/browser/Serializer.js +82 -16
- package/lib/browser/Serializer.js.map +1 -1
- package/lib/browser/Signer.js +1 -1
- package/lib/browser/Signer.js.map +1 -1
- package/lib/browser/Transaction.d.ts +109 -0
- package/lib/browser/Transaction.js +184 -0
- package/lib/browser/Transaction.js.map +1 -0
- package/lib/browser/index.d.ts +1 -0
- package/lib/browser/index.js +1 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index2.js +2 -0
- package/lib/browser/index2.js.map +1 -1
- package/lib/browser/interface.d.ts +188 -86
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/index2.js +2 -0
- package/lib/index2.js.map +1 -1
- package/lib/interface.d.ts +188 -86
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Koilib
|
|
2
2
|
|
|
3
3
|
Koinos Library for Javascript and Typescript. It can be used in node and browsers.
|
|
4
|
+
The complete documentation can be found at https://joticajulian.github.io/koilib/
|
|
4
5
|
|
|
5
6
|
## Table of Contents
|
|
6
7
|
|
|
@@ -60,20 +61,35 @@ You can also load it directly to the browser by downloading the bunble file loca
|
|
|
60
61
|
With Typescript import the library
|
|
61
62
|
|
|
62
63
|
```typescript
|
|
63
|
-
import {
|
|
64
|
+
import {
|
|
65
|
+
Signer,
|
|
66
|
+
Contract,
|
|
67
|
+
Provider,
|
|
68
|
+
Transaction,
|
|
69
|
+
Serializer,
|
|
70
|
+
utils,
|
|
71
|
+
} from "koilib";
|
|
64
72
|
```
|
|
65
73
|
|
|
66
74
|
With Javascript import the library with require
|
|
67
75
|
|
|
68
76
|
```javascript
|
|
69
|
-
const {
|
|
77
|
+
const {
|
|
78
|
+
Signer,
|
|
79
|
+
Contract,
|
|
80
|
+
Provider,
|
|
81
|
+
Transaction,
|
|
82
|
+
Serializer,
|
|
83
|
+
utils,
|
|
84
|
+
} = require("koilib");
|
|
70
85
|
```
|
|
71
86
|
|
|
72
|
-
There are
|
|
87
|
+
There are 5 principal classes:
|
|
73
88
|
|
|
74
89
|
- **Signer**: Class containing the private key. It is used to sign.
|
|
75
90
|
- **Provider**: Class to connect with the RPC node.
|
|
76
91
|
- **Contract**: Class defining the contract to interact with.
|
|
92
|
+
- **Transaction**: Class to create transactions.
|
|
77
93
|
- **Serializer**: Class with the protocol buffers definitions to
|
|
78
94
|
serialize/deserialize data types.
|
|
79
95
|
|
|
@@ -267,6 +283,71 @@ const { transaction } = await koin.transfer(
|
|
|
267
283
|
);
|
|
268
284
|
```
|
|
269
285
|
|
|
286
|
+
### Multiple operations in a single transaction
|
|
287
|
+
|
|
288
|
+
There are 3 ways to define a transaction with several operations. Use one of them as it is more convenient for you.
|
|
289
|
+
|
|
290
|
+
Using the Contract class. You can use `previousOperations` or `nextOperations` to attach more operations in the transaction:
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
const fn = contract.functions;
|
|
294
|
+
contract.options.onlyOperation = true;
|
|
295
|
+
const { operation: op1 } = await fn.set_owner({
|
|
296
|
+
account: "16MT1VQFgsVxEfJrSGinrA5buiqBsN5ViJ",
|
|
297
|
+
});
|
|
298
|
+
const { operation: op3 } = await fn.set_address({
|
|
299
|
+
account: "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb",
|
|
300
|
+
});
|
|
301
|
+
const { transaction, receipt } = await fn.set_name(
|
|
302
|
+
{
|
|
303
|
+
name: "test",
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
previousOperations: [op1],
|
|
307
|
+
nextOperations: [op3],
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
await transaction.wait();
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
Using the Signer class with the Contract class. First all operations are created and then passed to the signer to create and send the transaction:
|
|
314
|
+
|
|
315
|
+
```ts
|
|
316
|
+
const fn = contract.functions;
|
|
317
|
+
contract.options.onlyOperation = true;
|
|
318
|
+
const { operation: op1 } = await fn.set_owner({
|
|
319
|
+
account: "16MT1VQFgsVxEfJrSGinrA5buiqBsN5ViJ",
|
|
320
|
+
});
|
|
321
|
+
const { operation: op2 } = await fn.set_name({
|
|
322
|
+
name: "test",
|
|
323
|
+
});
|
|
324
|
+
const { operation: op3 } = await fn.set_address({
|
|
325
|
+
account: "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb",
|
|
326
|
+
});
|
|
327
|
+
const tx = await signer.prepareTransaction({
|
|
328
|
+
operations: [op1, op2, op3],
|
|
329
|
+
});
|
|
330
|
+
const { transaction, receipt } = await signer.sendTransaction(tx);
|
|
331
|
+
await transaction.wait();
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Using the Transaction class:
|
|
335
|
+
|
|
336
|
+
```ts
|
|
337
|
+
const tx = new Transaction({ signer });
|
|
338
|
+
await tx.pushOperation(fn.set_owner, {
|
|
339
|
+
account: "16MT1VQFgsVxEfJrSGinrA5buiqBsN5ViJ",
|
|
340
|
+
});
|
|
341
|
+
await tx.pushOperation(fn.set_name, {
|
|
342
|
+
name: "test",
|
|
343
|
+
});
|
|
344
|
+
await tx.pushOperation(fn.set_address, {
|
|
345
|
+
account: "1Gvqdo9if6v6tFomEuTuMWP1D7H7U9yksb",
|
|
346
|
+
});
|
|
347
|
+
const receipt = await tx.send();
|
|
348
|
+
await tx.wait();
|
|
349
|
+
```
|
|
350
|
+
|
|
270
351
|
### Create ABIs
|
|
271
352
|
|
|
272
353
|
ABIs are composed of 2 elements: methods and types.
|
|
@@ -348,7 +429,7 @@ The complete documentation can be found at https://joticajulian.github.io/koilib
|
|
|
348
429
|
|
|
349
430
|
## Acknowledgments
|
|
350
431
|
|
|
351
|
-
Many thanks to the sponsors of this library: @levineam, @Amikob, @motoeng, @isaacdozier, @imjwalker, and the private sponsors.
|
|
432
|
+
Many thanks to the sponsors of this library: @levineam, @Amikob, @motoeng, @isaacdozier, @imjwalker, @brklyn8900, and the private sponsors.
|
|
352
433
|
|
|
353
434
|
If you would like to contribute to the development of this library consider becoming a sponsor in https://github.com/sponsors/joticajulian.
|
|
354
435
|
|