codechain-io / codechain-sdk-js Goto Github PK
View Code? Open in Web Editor NEWCodeChain JavaScript SDK
Home Page: https://api.codechain.io
License: ISC License
CodeChain JavaScript SDK
Home Page: https://api.codechain.io
License: ISC License
constructor(nonce: U256, fee: U256, networkId: number, action: Action)
=> constructor({ nonce: U256, fee: U256, networkId: number, action: Action})
blocked-by-codechain
Pay to Public Key Hash: VERIFY opcode needed
$ yarn build
yarn run v1.7.0
$ rollup -c rollup.config.ts
src/index.ts → ./lib/index.js...
[!] (rpt2 plugin) Error: /home/sgkim126/workspace/codechain-sdk-js/src/index.ts(231,5): semantic error TS4026 Public static property 'signEcdsa' of exported class has or is using name 'ECDSASignature' from external module
getBlock(blockNumber: number): Block
StandardAssetAgent is same as PubkeyAssetAgent(#44) except that StandardAssetAgent understands standard scripts but not pubkey script.
Library should not keep yarn.lock file in the repo.
https://github.com/feross/buffer or change implementation
connect (...)
disconnect (...)
shareSecret (...)
Could you give me a sample code?
We need a high-level script language that is similar to Ivy for ease of writing scripts.
Code base
Platform Account Address
Asset Transfer Address
Currently:
class AssetTransferInput {
lockScript: Buffer;
unlockScript: Buffer;
...
}
Patch:
class AssetTransferInput {
lockScript: Script;
unlockScript: Script;
....
}
Parcel.sign
AssetAgent.createAddress
AssetScheme.mint
Asset.transfer
getAssetScheme() gets the asset scheme from the latest state only.
Since asset scheme is a part of the blockchain state, it should be able to get an asset scheme from the specific state.
Currently, the below example doesn't work
let sdk = new SDK(...);
let { getBlock, ... } = sdk.rpc.chain;
getBlock("0x123..").then(...)
Because of the function context.
Changing all the functions to the arrow function is one of the solutions.
Depends on CodeChain-io/codechain#252
Add
Current:
new SDK("http://localhost:8080")
Patch:
new SDK({
url: "http://localhost:8080",
networkId: 0xCA
})
Currently, the network id in the Parcel or Address are not validated and not auto-filled because of that SDK doesn't know what is decent.
getAsset() gets the asset from the latest state only.
Since asset is a part of the blockchain state, it should be gettable from the specific state.
See getBalance and getNonce which already have the optional block number param.
I'd like to use defined "Block" type for DB document type. And I need "Hash" value for searching transaction by hash key.
Currently, a user must run yarn build
before running integration tests, since yarn test-int
doesn't build the source.
PubkeyAssetAgent
PUSH <pubkey> CHKSIG
)Current foramt is
"transactions":[{
"payment":{
"nonce":"0x1",
"receiver":"0xa6594b7196808d161b6fb137e781abbc251385d9",
"sender":"0xa6594b7196808d161b6fb137e781abbc251385d9",
"value":"0x0"
}
}]
Modify it to
"transactions":[{
"type": "payment",
"data":{
"nonce":"0x1",
"receiver":"0xa6594b7196808d161b6fb137e781abbc251385d9",
"sender":"0xa6594b7196808d161b6fb137e781abbc251385d9",
"value":"0x0"
}
}],
import * as SDK from "codechain-sdk"
const sdk = new SDK(...)
...
Current:
var myAsset = ...
var transferTransaction = myAsset.transfer([{
address: addressAlice
amount: 10
}, {
address: addressBob
amount: 20
}])
Proposal:
var myAsset = ...
var transferTransaction = myAsset.createTransferTransaction({
recipients: [{
address: addressAlice
amount: 10
}, {
address: addressBob
amount: 20
}]
})
Currently, editor doesn't show errors when
Use ISC license.
Currently, the parcel creation could be done by below:
const SDK = require("codechain-sdk");
const { Parcel } = SDK;
const fee = new U256(10);
...
const parcel = new Parcel(fee, nonce, networkId, ...);
parcel.sign(...)
...
But, the current has some issues:
So it needs to be changed with some principles
Renewaled:
const SDK = require("codechain-sdk");
const sdk = new SDK({ networkId: 0xCA, ... });
const parcel = sdk.createParcel({ fee: 10, nonce: 10, ... })
parcel.sign(...)
...
Current:
...
var myAddress = ...
var myAsset = sdk.core.createAsset({ metadata, registrar, amount })
var mintTransaction = myAsset.mint(myAddress)
Proposal:
...
var myAddress = ...
var myAssetScheme = sdk.core.createAssetScheme({ metadata, registrar, amount })
var mintTransaction = myAssetScheme.createMintTransaction({ recipient: myAddress })
Method
Until codechain support it, SDK will implement and use SecretStoreMemory
which is not persistent.
getParcelInvoice
/getTransactionInvoice
send a RPC request repeatedly until timeout.
But, currently, the request is not aborted. So if the request takes 10 seconds when given timeout is 5 seconds, the method takes 10 seconds. It should be aborted at the moment of the timeout.
I think sendRpcRequest
should support a timeout option.
https://github.com/tedeh/jayson#client-interface-description
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.