Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,28 @@ steem.broadcast.feedPublish(wif, publisher, exchangeRate, function(err, result)
});
```
- - - - - - - - - - - - - - - - - -
### Build Witness Update Properties
```
const owner = 'starlord28'
const props = {
"key": "Public Signing Key", // MANDATORY
"new_signing_key": "Public Signing Key", // optional
"account_creation_fee": "3.000 STEEM", // optional
"account_subsidy_budget": 0, // optional
"account_subsidy_decay": 0, // optional
"maximum_block_size": 65536, // optional
"sbd_interest_rate": "0.000 STEEM", // optional
"sbd_exchange_rate": {"base": "0.237 SBD", "quote": "1.000 STEEM"}, // optional
"url": "https://steemcryptic.me", // optional
}

const witnessOps = steem.utils.buildWitnessSetProperties(props);

steem.broadcast.witnessSetProperties('Private Signing Key', owner, witnessOps, [], function(err, result) {
console.log(err, result);
});
```
- - - - - - - - - - - - - - - - - -
### Fill Convert Request
```js
steem.broadcast.fillConvertRequest(wif, owner, requestid, amountIn, amountOut, function(err, result) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@steemit/steem-js",
"version": "0.7.11",
"version": "0.7.12",
"description": "Steem.js the JavaScript API for Steem blockchain",
"main": "lib/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/auth/serializer/src/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ let account_create_with_delegation = new Serializer(
let witness_set_properties = new Serializer(
"witness_set_properties", {
owner: string,
props: string,
props: map(string, bytes()),
extensions: set(future_extensions)
}
);
Expand Down
48 changes: 48 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@

import types from "./auth/serializer/src/types"
import Serializer from "./auth/serializer/src/serializer"
import ByteBuffer from '@exodus/bytebuffer'

let price = new Serializer(
"price", {
base: types.asset,
quote: types.asset
}
);
const propTypes = {
key: types.public_key,
new_signing_key: types.public_key,
account_creation_fee: types.asset,
account_subsidy_budget: types.uint32,
account_subsidy_decay: types.uint32,
maximum_block_size: types.uint32,
sbd_interest_rate: types.uint16,
sbd_exchange_rate: price,
url: types.string
};
const snakeCaseRe = /_([a-z])/g;
export function camelCase(str) {
return str.replace(snakeCaseRe, function(_m, l) {
Expand Down Expand Up @@ -43,3 +65,29 @@ export function validateAccountName(value) {
}
return null;
}

function serialize(serializer, data) {
const buffer = new ByteBuffer(
ByteBuffer.DEFAULT_CAPACITY,
ByteBuffer.LITTLE_ENDIAN
);
serializer.appendByteBuffer(buffer, data);
buffer.flip();
return buffer.toString('hex');
}

export function buildWitnessSetProperties(props) {
const data = [];

for (const [key, value] of Object.entries(props)) {
const type = propTypes[key];

if (!type) {
throw new Error(`Unknown witness property: ${key}`);
}

data.push([key, serialize(type, value)]);
}

return data;
}