Skip to content

Commit

Permalink
[ECHOJS-198] add new operations (#94)
Browse files Browse the repository at this point in the history
* [ECHOJS-198] add new operations

* fix

* Fix echo version

* Fix echo version
  • Loading branch information
Anastasia Rudenko authored and vital-33 committed Oct 14, 2019
1 parent 3af9410 commit 3442df4
Show file tree
Hide file tree
Showing 15 changed files with 161 additions and 93 deletions.
6 changes: 3 additions & 3 deletions .test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "2"

services:
echo:
image: echoprotocol/echo:0.11.0-rc.1
image: echoprotocol/echo:0.11.1
command:
--start-echorand
--account-info="[\"1.2.6\", \"5KkYp8qdQBaRmLqLz8WVrGjzkt7E13qVcr7cpdLowgJ1mjRyDx2\"]"
Expand All @@ -24,11 +24,11 @@ services:
container_name: echo

echo-wallet:
image: echoprotocol/echo-wallet:0.11.0-rc.1
image: echoprotocol/echo-wallet:0.11.1
container_name: echo-wallet
command:
-s ws://echo:6311
--chain-id="c9b734031dfed36512d237364fdfd5631605c1594df35aca2a8feb98da1f08a7"
--chain-id="9e500608392416719b6aa206d02e75d12e479e92dd7c4ccba7dec9b63b9517ec"
--wallet-file="/echo/walletdata/wallet.json"
--history-file="/echo/walletdata/history"
-r 0.0.0.0:6312
Expand Down
60 changes: 31 additions & 29 deletions docs/Constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,35 +209,37 @@ console.log(constants.OPERATIONS_IDS); // operation id
VESTING_BALANCE_WITHDRAW: 19,
BALANCE_CLAIM: 20,
BALANCE_FREEZE: 21,
OVERRIDE_TRANSFER: 22,
ASSET_CLAIM_FEES: 23,
CONTRACT_CREATE: 24,
CONTRACT_CALL: 25,
CONTRACT_TRANSFER: 26,
CONTRACT_UPDATE: 27,
ACCOUNT_ADDRESS_CREATE: 28,
TRANSFER_TO_ADDRESS: 29,
SIDECHAIN_ETH_CREATE_ADDRESS: 30,
SIDECHAIN_ETH_APPROVE_ADDRESS: 31,
SIDECHAIN_ETH_DEPOSIT: 32,
SIDECHAIN_ETH_WITHDRAW: 33,
SIDECHAIN_ETH_APPROVE_WITHDRAW: 34,
CONTRACT_FUND_POOL: 35,
CONTRACT_WHITELIST: 36,
SIDECHAIN_ISSUE: 37,
SIDECHAIN_BURN: 38,
SIDECHAIN_ERC20_REGISTER_TOKEN: 39,
SIDECHAIN_ERC20_DEPOSIT_TOKEN: 40,
SIDECHAIN_ERC20_WITHDRAW_TOKEN: 41,
SIDECHAIN_ERC20_APPROVE_TOKEN_WITHDRAW: 42,
SIDECHAIN_ERC20_ISSUE: 43,
SIDECHAIN_ERC20_BURN: 44,
SIDECHAIN_BTC_CREATE_ADDRESS: 45,
SIDECHAIN_BTC_INTERMEDIATE_DEPOSIT: 46,
SIDECHAIN_BTC_DEPOSIT: 47,
SIDECHAIN_BTC_WITHDRAW: 48,
SIDECHAIN_BTC_APPROVE_WITHDRAW: 49,
SIDECHAIN_BTC_AGGREGATE: 50,
BALANCE_UNFREEZE: 22,
OVERRIDE_TRANSFER: 23,
ASSET_CLAIM_FEES: 24,
CONTRACT_CREATE: 25,
CONTRACT_CALL: 26,
CONTRACT_TRANSFER: 27,
CONTRACT_UPDATE: 28,
ACCOUNT_ADDRESS_CREATE: 29,
TRANSFER_TO_ADDRESS: 30,
SIDECHAIN_ETH_CREATE_ADDRESS: 31,
SIDECHAIN_ETH_APPROVE_ADDRESS: 32,
SIDECHAIN_ETH_DEPOSIT: 33,
SIDECHAIN_ETH_WITHDRAW: 34,
SIDECHAIN_ETH_APPROVE_WITHDRAW: 35,
CONTRACT_FUND_POOL: 36,
CONTRACT_WHITELIST: 37,
SIDECHAIN_ISSUE: 38,
SIDECHAIN_BURN: 39,
SIDECHAIN_ERC20_REGISTER_TOKEN: 40,
SIDECHAIN_ERC20_DEPOSIT_TOKEN: 41,
SIDECHAIN_ERC20_WITHDRAW_TOKEN: 42,
SIDECHAIN_ERC20_APPROVE_TOKEN_WITHDRAW: 43,
SIDECHAIN_ERC20_ISSUE: 44,
SIDECHAIN_ERC20_BURN: 45,
SIDECHAIN_BTC_CREATE_ADDRESS: 46,
SIDECHAIN_BTC_INTERMEDIATE_DEPOSIT: 47,
SIDECHAIN_BTC_DEPOSIT: 48,
SIDECHAIN_BTC_WITHDRAW: 49,
SIDECHAIN_BTC_APPROVE_WITHDRAW: 50,
SIDECHAIN_BTC_AGGREGATE: 51,
BLOCK_REWARD: 52
}
*/
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "echojs-lib",
"version": "1.8.1-rc.3",
"version": "1.8.1-rc.4",
"description": "Pure JavaScript ECHO library for node.js",
"main": "./dist/index.js",
"types": "./types/index.d.ts",
Expand Down
60 changes: 31 additions & 29 deletions src/constants/operations-ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,34 @@ export const VESTING_BALANCE_CREATE = 18;
export const VESTING_BALANCE_WITHDRAW = 19;
export const BALANCE_CLAIM = 20;
export const BALANCE_FREEZE = 21;
export const OVERRIDE_TRANSFER = 22;
export const ASSET_CLAIM_FEES = 23;
export const CONTRACT_CREATE = 24;
export const CONTRACT_CALL = 25;
export const CONTRACT_TRANSFER = 26;
export const CONTRACT_UPDATE = 27;
export const ACCOUNT_ADDRESS_CREATE = 28;
export const TRANSFER_TO_ADDRESS = 29;
export const SIDECHAIN_ETH_CREATE_ADDRESS = 30;
export const SIDECHAIN_ETH_APPROVE_ADDRESS = 31;
export const SIDECHAIN_ETH_DEPOSIT = 32;
export const SIDECHAIN_ETH_WITHDRAW = 33;
export const SIDECHAIN_ETH_APPROVE_WITHDRAW = 34;
export const CONTRACT_FUND_POOL = 35;
export const CONTRACT_WHITELIST = 36;
export const SIDECHAIN_ISSUE = 37;
export const SIDECHAIN_BURN = 38;
export const SIDECHAIN_ERC20_REGISTER_TOKEN = 39;
export const SIDECHAIN_ERC20_DEPOSIT_TOKEN = 40;
export const SIDECHAIN_ERC20_WITHDRAW_TOKEN = 41;
export const SIDECHAIN_ERC20_APPROVE_TOKEN_WITHDRAW = 42;
export const SIDECHAIN_ERC20_ISSUE = 43;
export const SIDECHAIN_ERC20_BURN = 44;
export const SIDECHAIN_BTC_CREATE_ADDRESS = 45;
export const SIDECHAIN_BTC_INTERMEDIATE_DEPOSIT = 46;
export const SIDECHAIN_BTC_DEPOSIT = 47;
export const SIDECHAIN_BTC_WITHDRAW = 48;
export const SIDECHAIN_BTC_APPROVE_WITHDRAW = 49;
export const SIDECHAIN_BTC_AGGREGATE = 50;
export const BALANCE_UNFREEZE = 22;
export const OVERRIDE_TRANSFER = 23;
export const ASSET_CLAIM_FEES = 24;
export const CONTRACT_CREATE = 25;
export const CONTRACT_CALL = 26;
export const CONTRACT_TRANSFER = 27;
export const CONTRACT_UPDATE = 28;
export const ACCOUNT_ADDRESS_CREATE = 29;
export const TRANSFER_TO_ADDRESS = 30;
export const SIDECHAIN_ETH_CREATE_ADDRESS = 31;
export const SIDECHAIN_ETH_APPROVE_ADDRESS = 32;
export const SIDECHAIN_ETH_DEPOSIT = 33;
export const SIDECHAIN_ETH_WITHDRAW = 34;
export const SIDECHAIN_ETH_APPROVE_WITHDRAW = 35;
export const CONTRACT_FUND_POOL = 36;
export const CONTRACT_WHITELIST = 37;
export const SIDECHAIN_ISSUE = 38;
export const SIDECHAIN_BURN = 39;
export const SIDECHAIN_ERC20_REGISTER_TOKEN = 40;
export const SIDECHAIN_ERC20_DEPOSIT_TOKEN = 41;
export const SIDECHAIN_ERC20_WITHDRAW_TOKEN = 42;
export const SIDECHAIN_ERC20_APPROVE_TOKEN_WITHDRAW = 43;
export const SIDECHAIN_ERC20_ISSUE = 44;
export const SIDECHAIN_ERC20_BURN = 45;
export const SIDECHAIN_BTC_CREATE_ADDRESS = 46;
export const SIDECHAIN_BTC_INTERMEDIATE_DEPOSIT = 47;
export const SIDECHAIN_BTC_DEPOSIT = 48;
export const SIDECHAIN_BTC_WITHDRAW = 49;
export const SIDECHAIN_BTC_APPROVE_WITHDRAW = 50;
export const SIDECHAIN_BTC_AGGREGATE = 51;
export const BLOCK_REWARD = 52;
2 changes: 2 additions & 0 deletions src/serializers/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const operationProps = {
[OPERATIONS_IDS.VESTING_BALANCE_WITHDRAW]: protocol.vesting.balanceWithdraw,
[OPERATIONS_IDS.BALANCE_CLAIM]: protocol.balance.claim,
[OPERATIONS_IDS.BALANCE_FREEZE]: protocol.balance.freeze,
[OPERATIONS_IDS.BALANCE_UNFREEZE]: protocol.balance.unfreeze,
[OPERATIONS_IDS.OVERRIDE_TRANSFER]: protocol.transfer.override,
[OPERATIONS_IDS.ASSET_CLAIM_FEES]: protocol.asset.claimFees,
[OPERATIONS_IDS.CONTRACT_CREATE]: protocol.contract.create,
Expand Down Expand Up @@ -55,6 +56,7 @@ const operationProps = {
[OPERATIONS_IDS.SIDECHAIN_BTC_WITHDRAW]: protocol.sidechain.btc.withdraw,
[OPERATIONS_IDS.SIDECHAIN_BTC_AGGREGATE]: protocol.sidechain.btc.aggregate,
[OPERATIONS_IDS.SIDECHAIN_BTC_APPROVE_WITHDRAW]: protocol.sidechain.btc.approveWithdraw,
[OPERATIONS_IDS.BLOCK_REWARD]: protocol.blockReward,
};

const operationSerializer = staticVariant(operationProps);
Expand Down
7 changes: 7 additions & 0 deletions src/serializers/protocol/balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ export const balanceFreezeOperationPropsSerializer = struct({
duration: uint16,
extensions,
});

export const balanceUnfreezeOperationPropsSerializer = struct({
fee: asset,
account: accountId,
amount: asset,
extensions,
});
12 changes: 12 additions & 0 deletions src/serializers/protocol/block_reward.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { asset, extensions } from '../chain';
import { accountId } from '../chain/id/protocol';
import { struct, map } from '../collections';
import { int64 } from '../basic/integers';

export const blockRewardOperationPropsSerializer = struct({
fee: asset,
rewards: map(accountId, int64),
extensions,
});

export default blockRewardOperationPropsSerializer;
2 changes: 2 additions & 0 deletions src/serializers/protocol/fee_parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const feeParametersSerializer = staticVariant({
[OPERATIONS_IDS.VESTING_BALANCE_WITHDRAW]: defaultFeeParametersSerializer,
[OPERATIONS_IDS.BALANCE_CLAIM]: struct({}),
[OPERATIONS_IDS.BALANCE_FREEZE]: defaultFeeParametersSerializer,
[OPERATIONS_IDS.BALANCE_UNFREEZE]: defaultFeeParametersSerializer,
[OPERATIONS_IDS.OVERRIDE_TRANSFER]: defaultFeeParametersSerializer,
[OPERATIONS_IDS.ASSET_CLAIM_FEES]: defaultFeeParametersSerializer,
[OPERATIONS_IDS.CONTRACT_CREATE]: defaultFeeParametersSerializer,
Expand Down Expand Up @@ -63,6 +64,7 @@ const feeParametersSerializer = staticVariant({
[OPERATIONS_IDS.SIDECHAIN_BTC_WITHDRAW]: defaultFeeParametersSerializer,
[OPERATIONS_IDS.SIDECHAIN_BTC_AGGREGATE]: defaultFeeParametersSerializer,
[OPERATIONS_IDS.SIDECHAIN_BTC_APPROVE_WITHDRAW]: defaultFeeParametersSerializer,
[OPERATIONS_IDS.BLOCK_REWARD]: defaultFeeParametersSerializer,
});

export default feeParametersSerializer;
9 changes: 8 additions & 1 deletion src/serializers/protocol/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import {
assetClaimFeesOperationPropsSerializer,
} from './asset';

import { balanceClaimOperationPropsSerializer, balanceFreezeOperationPropsSerializer } from './balance';
import {
balanceClaimOperationPropsSerializer,
balanceFreezeOperationPropsSerializer,
balanceUnfreezeOperationPropsSerializer,
} from './balance';

import {
committeeMemberCreateOperationPropsSerializer,
Expand Down Expand Up @@ -91,6 +95,7 @@ export { default as authority } from './authority';
export const balance = {
claim: balanceClaimOperationPropsSerializer,
freeze: balanceFreezeOperationPropsSerializer,
unfreeze: balanceUnfreezeOperationPropsSerializer,
};

export { default as chainParameters } from './chain_parameters';
Expand Down Expand Up @@ -146,3 +151,5 @@ export const vesting = {
export const voteId = new VoteIdSerializer();

export { VoteIdSerializer };

export { default as blockReward } from './block_reward';
60 changes: 31 additions & 29 deletions types/interfaces/OperationId.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,35 @@ declare enum OperationId {
VESTING_BALANCE_WITHDRAW = 19,
BALANCE_CLAIM = 20,
BALANCE_FREEZE = 21,
OVERRIDE_TRANSFER = 22,
ASSET_CLAIM_FEES = 23,
CONTRACT_CREATE = 24,
CONTRACT_CALL = 25,
CONTRACT_TRANSFER = 26,
CONTRACT_UPDATE = 27,
ACCOUNT_ADDRESS_CREATE = 28,
TRANSFER_TO_ADDRESS = 29,
SIDECHAIN_ETH_CREATE_ADDRESS = 30,
SIDECHAIN_ETH_APPROVE_ADDRESS = 31,
SIDECHAIN_ETH_DEPOSIT = 32,
SIDECHAIN_ETH_WITHDRAW = 33,
SIDECHAIN_ETH_APPROVE_WITHDRAW = 34,
CONTRACT_FUND_POOL = 35,
CONTRACT_WHITELIST = 36,
SIDECHAIN_ISSUE = 37,
SIDECHAIN_BURN = 38,
SIDECHAIN_ERC20_REGISTER_TOKEN = 39,
SIDECHAIN_ERC20_DEPOSIT_TOKEN = 40,
SIDECHAIN_ERC20_WITHDRAW_TOKEN = 41,
SIDECHAIN_ERC20_APPROVE_TOKEN_WITHDRAW = 42,
SIDECHAIN_ERC20_ISSUE = 43,
SIDECHAIN_ERC20_BURN = 44,
SIDECHAIN_BTC_CREATE_ADDRESS = 45,
SIDECHAIN_BTC_INTERMEDIATE_DEPOSIT = 46,
SIDECHAIN_BTC_DEPOSIT = 47,
SIDECHAIN_BTC_WITHDRAW = 48,
SIDECHAIN_BTC_APPROVE_WITHDRAW = 49,
SIDECHAIN_BTC_AGGREGATE = 50,
BALANCE_UNFREEZE = 22,
OVERRIDE_TRANSFER = 23,
ASSET_CLAIM_FEES = 24,
CONTRACT_CREATE = 25,
CONTRACT_CALL = 26,
CONTRACT_TRANSFER = 27,
CONTRACT_UPDATE = 28,
ACCOUNT_ADDRESS_CREATE = 29,
TRANSFER_TO_ADDRESS = 30,
SIDECHAIN_ETH_CREATE_ADDRESS = 31,
SIDECHAIN_ETH_APPROVE_ADDRESS = 32,
SIDECHAIN_ETH_DEPOSIT = 33,
SIDECHAIN_ETH_WITHDRAW = 34,
SIDECHAIN_ETH_APPROVE_WITHDRAW = 35,
CONTRACT_FUND_POOL = 36,
CONTRACT_WHITELIST = 37,
SIDECHAIN_ISSUE = 38,
SIDECHAIN_BURN = 39,
SIDECHAIN_ERC20_REGISTER_TOKEN = 40,
SIDECHAIN_ERC20_DEPOSIT_TOKEN = 41,
SIDECHAIN_ERC20_WITHDRAW_TOKEN = 42,
SIDECHAIN_ERC20_APPROVE_TOKEN_WITHDRAW = 43,
SIDECHAIN_ERC20_ISSUE = 44,
SIDECHAIN_ERC20_BURN = 45,
SIDECHAIN_BTC_CREATE_ADDRESS = 46,
SIDECHAIN_BTC_INTERMEDIATE_DEPOSIT = 47,
SIDECHAIN_BTC_DEPOSIT = 48,
SIDECHAIN_BTC_WITHDRAW = 49,
SIDECHAIN_BTC_APPROVE_WITHDRAW = 50,
SIDECHAIN_BTC_AGGREGATE = 51,
BLOCK_REWARD = 52,
}
2 changes: 2 additions & 0 deletions types/serializers/operation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type OperationPropsSerializer<T extends OperationId> = {
[OperationId.VESTING_BALANCE_WITHDRAW]: typeof protocol.vesting.balanceWithdraw,
[OperationId.BALANCE_CLAIM]: typeof protocol.balance.claim,
[OperationId.BALANCE_FREEZE]: typeof protocol.balance.freeze,
[OperationId.BALANCE_UNFREEZE]: typeof protocol.balance.unfreeze,
[OperationId.OVERRIDE_TRANSFER]: typeof protocol.transfer.override,
[OperationId.ASSET_CLAIM_FEES]: typeof protocol.asset.claimFees,
[OperationId.CONTRACT_CREATE]: typeof protocol.contract.create,
Expand Down Expand Up @@ -56,6 +57,7 @@ export type OperationPropsSerializer<T extends OperationId> = {
[OperationId.SIDECHAIN_BTC_WITHDRAW]: typeof protocol.sidechain.btc.withdraw,
[OperationId.SIDECHAIN_BTC_AGGREGATE]: typeof protocol.sidechain.btc.aggregate,
[OperationId.SIDECHAIN_BTC_APPROVE_WITHDRAW]: typeof protocol.sidechain.btc.approveWithdraw,
[OperationId.BLOCK_REWARD]: typeof protocol.blockReward,
}[T];

type OperationInput<T extends OperationId> = SerializerInput<OperationPropsSerializer<T>>;
Expand Down
7 changes: 7 additions & 0 deletions types/serializers/protocol/balance.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ export declare const balanceFreezeOperationPropsSerializer: StructSerializer<{
duration: typeof uint16,
extensions: typeof extensions,
}>;

export declare const balanceUnfreezeOperationPropsSerializer: StructSerializer<{
fee: typeof asset,
account: typeof accountId,
amount: typeof asset,
extensions: typeof extensions,
}>;
12 changes: 12 additions & 0 deletions types/serializers/protocol/block_reward.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { StructSerializer, MapSerializer } from "../collections";
import { asset, extensions } from "../chain";
import { int64 } from '../basic/integers';
import { accountId } from "../chain/id/protocol";

export declare const blockRewardOperationPropsSerializer: StructSerializer<{
fee: typeof asset,
rewards: MapSerializer<typeof accountId, typeof int64>,
extensions: typeof extensions,
}>;

export default blockRewardOperationPropsSerializer;
2 changes: 2 additions & 0 deletions types/serializers/protocol/fee_parameters.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type FeeParametersSerializer<T extends OperationId> = {
[OperationId.VESTING_BALANCE_WITHDRAW]: typeof defaultFeeParametersSerializer,
[OperationId.BALANCE_CLAIM]: StructSerializer<{}>,
[OperationId.BALANCE_FREEZE]: StructSerializer<{}>,
[OperationId.BALANCE_UNFREEZE]: typeof defaultFeeParametersSerializer,
[OperationId.OVERRIDE_TRANSFER]: typeof defaultFeeParametersSerializer,
[OperationId.ASSET_CLAIM_FEES]: typeof defaultFeeParametersSerializer,
[OperationId.CONTRACT_CREATE]: typeof defaultFeeParametersSerializer,
Expand Down Expand Up @@ -71,6 +72,7 @@ export type FeeParametersSerializer<T extends OperationId> = {
[OperationId.SIDECHAIN_BTC_WITHDRAW]: typeof defaultFeeParametersSerializer,
[OperationId.SIDECHAIN_BTC_AGGREGATE]: typeof defaultFeeParametersSerializer,
[OperationId.SIDECHAIN_BTC_APPROVE_WITHDRAW]: typeof defaultFeeParametersSerializer,
[OperationId.BLOCK_REWARD]: typeof defaultFeeParametersSerializer,
}[T];

declare const feeParametersSerializer: StaticVariantSerializer<{
Expand Down
Loading

0 comments on commit 3442df4

Please sign in to comment.