ZooBC-SDK is a small set of libraries written with TypeScript and compiled to be JavaScript, making it easy to implement / integrate applications so that they connect with the P2P API of the nodes in the blockchain for the Web API of the explorer servers and wallet.
For instructions on how to use web and mobile for a project, please refer to these documents:
Add 'zbc-sdk' packages to your project by executing:
$ npm install zbc-sdk
or
$ yarn add zbc-sdk
Here's an example of basic usage for connection:
import React, { useState, useEffect } from 'react';
import zoobc from 'zbc-sdk';
const App = () => {
const [blocks, setBlocks] = useState([])
const [error, setError] = useState(null)
const [detail, setDetail] = useState(null)
useEffect(() => {
const hosts = [
{ host: 'http://your-ip-address:your-port', name: 'Testnet' },
];
zoobc.Network.list(hosts)
listBlocks();
}, [])
const listBlocks = () => {
zoobc.Block
.getBlocks({height: 0})
.then(res => setBlocks(res.blocksList))
.catch(err => setError(err))
};
const onClickBlockId = (id) => {
zoobc.Block
.getBlockById(id)
.then(res => {
setDetail(res)
setError(null)
})
.catch(err => {
setError(err)
setDetail(null)
})
}
const onClickBlockHeight = (height) => {
zoobc.Block
.getBlockByHeight(height)
.then(res => {
setDetail(res)
setError(null)
})
.catch(err => {
setError(err)
setDetail(null)
})
}
return (
<>
{!!error && (
<>
<div><strong>Error</strong></div>
<code>{JSON.stringify(error)}</code>
</>
)}{!!detail && (
<>
<div><strong>Detail</strong></div>
<code>{JSON.stringify(detail)}</code>
</>
)}
<table>
<thead>
<tr>
<th>Id</th>
<th>Previous Hash</th>
<th>Height</th>
<th>Timestamp</th>
<th>Version</th>
</tr>
</thead>
<tbody>
{blocks.length > 0 &&
blocks.map((data, key) => {
return (
<tr key={key}>
<td onClick={() => onClickBlockId(data.block.id)}>
{data.block.id}
</td>
<td>{data.block.previousblockhash}</td>
<td onClick={() => onClickBlockHeight(data.block.height)}>
{data.block.height}
</td>
<td>{data.block.timestamp}</td>
<td>{data.block.version}</td>
</tr>
);
})}
</tbody>
</table>
</>
)
}
export default App;
Thanks to all who have contributed to ZooBC-SDK!
Gungde |
Eko |
Irfan |
Yandi |
Nata |
Bagas |
Kevin |
Adhiim |
Witarsana |
This project is licensed under the Apache License - see the LICENSE file for details
zoobc-sdk's People
zoobc-sdk's Issues
[EXAMPLE] Update Example for VueJs Framework
[ENHANCEMENT] Transactions - change params in all function
Add params in all function in src/Transactions.ts
file to match all params provided by blockchain
[FEATURE] Multi Signature
- Create Multisig Address
- Create
getPendingList
function fromMultisigServiceClient.getPendingTransactions
- Create
getPending
function fromMultisigServiceClient.getPendingTransactionDetailByTransactionHash
- Create
getMultiSignatureInfo
function fromMultisigServiceClient.getMultisignatureInfo
- Create
multisignatureBuilder
function to build transactions bytes from multisig params before send it to the node - Create
postTransaction
function to create new multisignature transaction
Note:
Please see https://github.com/zoobc/zoobc-core/wiki/Multi-Signature-Transaction for guidence
[EXAMPLE] Update Example for React Native Framework
[FEATURE] Convert Mempool Transactions from GRPC to ZBC Wallet Format
- Create function that filter all mempool transactions to be only send money (type = 1)
- Create function that return only one mempool transaction that has type register, update, claim, or remove
Transaction Type Code:
register node= 2
update node = 258
remove node = 514
claim node = 770
[Master] Boilerplate Project
To do:
- Initial dependencies like as mocha, grpc-pack, etc
- Create directory source (main project)
- Create directory test (unit testing)
- Create directory example (example to implementation)
- Update README
[EXAMPLE] Update Example for Angular Framework
[Example] Implement SDK To Ionic
[FEATURE] Transactions - Add getTransactionMinimumFee()
TO DO
- Implement the getTransactionMinimumFee() given by new schema on
Transactions.ts
- create unit testing for this new function
[FEATURE] Keyring - Add Passphrase Validation Function
TO DO
- adding passphrase validation function to check if the passphrase is valid or not
- adding unit test for that new function
[FEATURE] Update readme
Describe
Readme information needs to be updated in accordance with current developments.
[TEST] Keyring
generateRandomPhrase
Cases
Input: number word = 12 | 24
Result: return string that contain 12 or 24 words
Input: number word = not 12 neither 24
Result: return error
calcDerivationPath
Cases
Input: create some test case and use that as a input
Result: return BIP32Interface
object that contain expected properties value on test case result
[Linux] cant do npm/yarn install
error occured during installation
error An unexpected error occurred: "https://registry.npmjs.org/@improbable-eng%2fgrpc-web: getaddrinfo EAI_AGAIN registry.npmjs.org registry.npmjs.org:443".
[Testing] Init
Unit testing functions to ensure the function of init zoobc sdk has items message structure, error messages, etc.
[Release] SDK version 0.1.0-alpha-release
[FEATURE] Add block list and block detail
- Create function to get block list
- Create function to get block detail by blockID
- Create function to get block detail by blockHeight
[TEST] Account
getBalance
Cases
Input: Address that have transactions
Result: return object with accountbalance
properties
[ENHANCEMENT] Mempool - change params in all function
Add params in all function in src/Mempool.ts
file to match all params provided by blockchain
[Testing] Unit Test All Function From SDK
Unit testing functions to ensure the function of list blocks or block details has items message structure, error messages, etc.
-
Unit testing functions to ensure the function of list blocks or block details has items message structure, error messages, etc.
-
Unit testing functions to ensure the function of list transactions or transaction details has items message structure, error messages, etc.
[Example] Implement SDK To Web CDN
[Example] Implement SDK To Vuejs
[TEST] Wallet
encryptPassphrase
Cases
Input: create some test case and use that as a input
Result: return a base64 string that already expected on test case result
decryptPassphrase
Cases
Input: create some test case and use that as a input
Result: return a string of passphrase that already expected on test case result
[ENHANCEMENT] Network - add function set default network
Is your feature request related to a problem? Please describe.
Add function to set default network so that make easy to call function selected
will be return value with index after calling function set
[FEATURE] Convert Escrow Transactions from GRPC to ZBC Wallet Format
Create function that filter all escrow transactions to have latest = true and status = pending (status=0)
[ENHANCEMENT] Compile SDK Using Rollup Typescript Plugin
[FEATURE] Add nodeRegistration list
Create function to get all nodeRegistration
[REQ] when do we release to npmjs?
Describe
It seems like the issue of unit testing is gone, can we start publishing to npmjs at this time?
And which version should we start with for the alpha release?
[Example] Implement SDK To React
[SDK] Implement All Function From Schema
- Function to get list blocks or detail block via P2P API.
- Function to get list transactions or detail transaction via P2P API.
Refactoring CI after updating repo
Is your feature request related to a problem? Please describe.
Minor bug for refactoring CI with update repo. Please adjust working directory in config.yml with the repo used.
[TEST] Escrow
getList
Cases
Input: input correct params
Result: return object with escrowList
properties as an array
get
Cases
Input: input an correct Id
Result: return escrow object
approval
Cases
Input: input correct params
Result: return new escrow transactions object
[FEATURE] Health Check
TO DO
- implement
healthCheck()
function given by new schema - creating unit testing for this function
[EXAMPLE] Update Example for Ionic Framework
[Generator] Protogen
The initial function is to connect with the P2P API of the nodes in the blockchain.
[TEST] Node
getHardwareInfo
Cases
Input: seed and ip that owned by node
Result: stream nodeharware
object every 5 seconds
generateNodeKey
Cases
Input: seed and ip that owned by node
Result: return a new nodepublickey
getList
Cases
Input: input correct params
Result: return an object with noderegistrationsList
object
get
Cases
Input: input correct params
Result: return noderegistrationt
object
register, update, remove, claim
Cases
Input: input correct params
Result: return a new transaction
object
[BUG] Protogen syntax error
[TEST] Block
getBlocks
Cases
Input: input height and/or limit
Result: return object with blockList
properties as an array
getBlockById
Cases
Input: input an Id
Result: return block object
getBlockByHeight
Cases
Input: input an height number
Result: return block object
[EXAMPLE] Update Example for ReactJs Framework
[BUG] yarn test root directory
[BUG] getAccountBalance Endpoint Return Error "Address Not Found"
getAccountBalance endpoint in src/Account.ts
function will return error "Address not found" if address has no transaction in database
Expect:
enpoint return the result with 0 balance and 0 spendable balance
Solution
if GRPC return error with error "Not Found" (error code: 5), resolve it with 0 balance and spendable balance
[FEATURE] Convert Transactions from GRPC to ZBC Wallet Format
Convert Transactions given by getTransactions endpoint to ZBC Wallet format
[BUG] Keyring - Passphrase with White Space can Create Different Seed
Describe the bug
When creating new ZooKeyring
, passphrase with white space can produce different seed
Solution
trim passphrase so there is no space before and after passphrase. and just only one space between words
[DEPRECATE] protoc-gen-ts warning: The service=true parameter has been deprecated
[TEST] Mempool
getList
Cases
Input: input correct params
Result: return object with mempoolTransactionsList
properties as an array
get
Cases
Input: input correct Id
Result: return transaction object
[Example] Implement SDK To React Native
[Example] Implement SDK To Angular
[ENHANCEMENT] Escrow - change params in all function
Add params in all function in src/Escrow.ts
file to match all params provided by blockchain
[TEST] Transactions
getList
Cases
Input: input correct params
Result: return object with transactionsList
properties as an array
get
Cases
Input: input correct Id
Result: return transaction object
sendMoney
Cases
Input: input correct params
Result: return new transaction
object
[TEST] Poown
createAuth
Cases
Input: correct seed and request type
= 1
Result: return base64 string with 108 length
request
Cases
Input: input corrects params
Result: return bytes of array
Issue grpc-web-client on Angular
Angular : if found issues about Http/Https , add the following code on your tsconfig.json :
{
"compilerOptions": {
"paths": {
"https": [ "app/patch.js" ],
"http": [ "app/patch.js" ],
}
}
full link : improbable-eng/grpc-web#191
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.