0.1.37 • Published 2 years ago
quorum-light-node-sdk v0.1.37
quorum-light-node-sdk
Javascript SDK for quorum light node.
Install
$ npm install quorum-light-node-sdk
Usage
add group
import QuorumLightNodeSDK from 'quorum-light-node-sdk';
const seedUrl = 'rum://seed?xxx';
const result = QuorumLightNodeSDK.cache.Group.add(seedUrl);
console.log(result);
// result
{ groupId: '8136923b-8203-4e08-bfe7-50eb3b558e2c' }
get group
import QuorumLightNodeSDK from 'quorum-light-node-sdk';
const groupId = '8136923b-8203-4e08-bfe7-50eb3b558e2c';
const result = QuorumLightNodeSDK.cache.Group.get(groupId);
console.log(result);
// result
{
appKey: "group_timeline",
chainAPIs: ['http://127.0.0.1:9003'],
cipherKey: "c0f3a84920c2c5b93ba308a92302789ca991cb2376c11b16d48fefb31666d5d2",
consensusType: "poa",
encryptionType: "public",
groupId: "8136923b-8203-4e08-bfe7-50eb3b558e2c",
groupName: "chat group",
ownerPubKey: "Aqa6ngNxgrVhf2kQc4nA-0Wr4tsWiaBrshZJPujT5B9g",
signature: "GDLJ+TcXuo95q+CsUFty7pvMIYZRFRQ3VwrparvjKy00wIYSmx5pl4xT4ALb6AVgNei/is5kn1MuXfh9b5wB+QE=",
}
list groups
import QuorumLightNodeSDK from 'quorum-light-node-sdk';
const result = QuorumLightNodeSDK.cache.Group.list();
console.log(result);
// result
[
{
appKey: "group_timeline",
chainAPIs: ['http://127.0.0.1:9003'],
cipherKey: "c0f3a84920c2c5b93ba308a92302789ca991cb2376c11b16d48fefb31666d5d2",
consensusType: "poa",
encryptionType: "public",
groupId: "8136923b-8203-4e08-bfe7-50eb3b558e2c",
groupName: "chat group",
ownerPubKey: "Aqa6ngNxgrVhf2kQc4nA-0Wr4tsWiaBrshZJPujT5B9g",
signature: "GDLJ+TcXuo95q+CsUFty7pvMIYZRFRQ3VwrparvjKy00wIYSmx5pl4xT4ALb6AVgNei/is5kn1MuXfh9b5wB+QE=",
}
]
update group
import QuorumLightNodeSDK from 'quorum-light-node-sdk';
const groupId = '8136923b-8203-4e08-bfe7-50eb3b558e2c';
const group = QuorumLightNodeSDK.cache.Group.get(groupId);
group.groupName = 'new group name';
const result = QuorumLightNodeSDK.cache.Group.update(groupId, group);
console.log(result);
// result
{ groupId: '8136923b-8203-4e08-bfe7-50eb3b558e2c' }
create trx
$ yarn add ethers
import QuorumLightNodeSDK from 'quorum-light-node-sdk';
import { ethers } from 'ethers';
(async () => {
const wallet = ethers.Wallet.createRandom();
const result = await QuorumLightNodeSDK.chain.Trx.create({
groupId: '8136923b-8203-4e08-bfe7-50eb3b558e2c',
object: {
type: 'Note',
content: 'send from JavaScript SDK',
},
privateKey: wallet.privateKey,
});
console.log(result);
})();
// result
{ trx_id: '41f1e91e-5604-4539-8dee-7cf7e3ef5046' }
get trx
import QuorumLightNodeSDK from 'quorum-light-node-sdk';
(async () => {
const groupId = '8136923b-8203-4e08-bfe7-50eb3b558e2c';
const trxId = '41f1e91e-5604-4539-8dee-7cf7e3ef5046';
const result = await QuorumLightNodeSDK.chain.Trx.get(groupId, trxId);
console.log(result);
})();
// result
{
Data: "SdujS8K8zv2E6X839+J3tvIzkpYJti44Bw0cZ0weaYA4sTm0Z1rV/raKoa6zBwrAZYM9Zs+QdLS06jCVcaIvZrDqZysuAbTA/0JPmWVcLRdoiipdjAe6ov35f7WgVps6iSKUrw==",
Expired: "1657279269056000000",
GroupId: "8136923b-8203-4e08-bfe7-50eb3b558e2c",
Nonce: "1",
ResendCount: "0",
SenderPubkey: "Ak0RxoYwYhkAfg0ImkLh-ukRIHkoQ-Kw6QCRr_o83bmq",
SenderSign: "Dz436tcTh+NSUjF38oUBjXkIezVfENb/pit9BY1v8jZrjzcwu66YE8OFO9/MzRNIkhgTK2wulfmk51mzJz/9Txs=",
StorageType: "CHAIN",
TimeStamp: "1657279239056000000",
TrxId: "41f1e91e-5604-4539-8dee-7cf7e3ef5046",
Type: "POST",
Version: "1.0.0",
}
list contents
import QuorumLightNodeSDK from 'quorum-light-node-sdk';
(async () => {
const result = await QuorumLightNodeSDK.chain.Content.list({
groupId: '8136923b-8203-4e08-bfe7-50eb3b558e2c',
});
console.log(result);
})();
// result
[
{
Data: { type: 'Note', content: 'send from JavaScript SDK' },
Expired: 1657279269056000000,
GroupId: "8136923b-8203-4e08-bfe7-50eb3b558e2c",
Nonce: 1,
SenderPubkey: "Ak0RxoYwYhkAfg0ImkLh-ukRIHkoQ-Kw6QCRr_o83bmq",
SenderSign: "Dz436tcTh+NSUjF38oUBjXkIezVfENb/pit9BY1v8jZrjzcwu66YE8OFO9/MzRNIkhgTK2wulfmk51mzJz/9Txs=",
TimeStamp: "1657279239056000000",
TrxId: "41f1e91e-5604-4539-8dee-7cf7e3ef5046",
Version: "1.0.0",
}
]
Parameter | Type |
---|---|
groupId | string |
count | number |
startTrx | string |
reverse | boolean |
Demo
0.1.32
3 years ago
0.1.33
3 years ago
0.1.34
3 years ago
0.1.35
3 years ago
0.1.36
3 years ago
0.1.37
2 years ago
0.1.30
3 years ago
0.1.31
3 years ago
0.1.27
3 years ago
0.1.28
3 years ago
0.1.29
3 years ago
0.1.21
3 years ago
0.1.23
3 years ago
0.1.24
3 years ago
0.1.25
3 years ago
0.1.26
3 years ago
0.1.20
3 years ago
0.1.19
3 years ago
0.1.18
3 years ago
0.1.17
3 years ago
0.1.16
3 years ago
0.1.15
3 years ago
0.1.14
3 years ago
0.1.13
3 years ago
0.1.12
3 years ago
0.1.11
3 years ago
0.1.10
3 years ago
0.1.9
3 years ago
0.1.8
3 years ago
0.1.7
3 years ago
0.1.6
3 years ago
0.1.5
3 years ago
0.1.4
3 years ago
0.1.3
3 years ago
0.1.2
3 years ago
0.1.1
3 years ago
0.1.0
3 years ago