From f8e63815d876c96db8acefd9d7063aa25e58ff86 Mon Sep 17 00:00:00 2001 From: Mikhail Shautsou Date: Wed, 11 Nov 2020 18:48:53 +0300 Subject: [PATCH] echo@0.23.0 migration --- docs/API.md | 17 ++++++-- docs/Constants.md | 13 +++--- package.json | 2 +- src/constants/object-types.js | 9 ++-- src/constants/operations-ids.js | 13 +++--- src/echo/api.js | 21 +++++++-- src/echo/apis/database-api.js | 17 ++++++-- src/echo/apis/wallet-api.js | 43 +++++++++++++++++++ src/serializers/chain/id/protocol.js | 14 +++++- src/serializers/operation.js | 3 ++ src/serializers/protocol/fee_parameters.js | 3 ++ src/serializers/protocol/sidechain/btc.js | 19 +++++++- src/serializers/protocol/sidechain/eth.js | 12 +++++- src/serializers/protocol/sidechain/index.js | 3 ++ types/echo/api.d.ts | 8 +++- types/interfaces/GlobalProperties.d.ts | 2 + types/interfaces/OperationId.d.ts | 13 +++--- types/serializers/chain/id/protocol.d.ts | 5 ++- types/serializers/operation.d.ts | 3 ++ .../serializers/plugins/sidechain/config.d.ts | 5 +++ .../serializers/plugins/sidechain/index.d.ts | 1 + .../protocol/chain_parameters.d.ts | 6 +-- .../serializers/protocol/fee_parameters.d.ts | 3 ++ types/serializers/protocol/sidechain/btc.d.ts | 20 ++++++++- types/serializers/protocol/sidechain/eth.d.ts | 12 +++++- .../serializers/protocol/sidechain/index.d.ts | 4 ++ 26 files changed, 229 insertions(+), 42 deletions(-) diff --git a/docs/API.md b/docs/API.md index 65a0575a..7261b12d 100644 --- a/docs/API.md +++ b/docs/API.md @@ -124,7 +124,9 @@ try {
getContractBalances(contractId, force)Promise.<Object>
-
getRecentTransactionById(transactionId)Promise.<*>
+
getTransactionById(transactionId)Promise.<*>
+
+
getBtcStakeAddress(accountNameOrId)Promise.<*>
getFeePool(assetId)Promise.<BigNumber>
@@ -702,15 +704,24 @@ try { | contractId | String | [Id of the contract to retrieve] | | force | Boolean | [If force equal to true then he will first see if you have this object in the cache] | - + -## getRecentTransactionById(transactionId) ⇒ Promise.<\*> +## getTransactionById(transactionId) ⇒ Promise.<\*> **Kind**: global function | Param | Type | Description | | --- | --- | --- | | transactionId | String | [Id of the transaction to retrieve] | + + +## getBtcStakeAddress(accountNameOrId) ⇒ Promise.<\*> +**Kind**: global function + +| Param | Type | Description | +| --- | --- | --- | +| accountNameOrId | String | [Id or name of account] | + ## getFeePool(assetId) ⇒ Promise.<BigNumber> diff --git a/docs/Constants.md b/docs/Constants.md index 4acaae79..a6de7432 100644 --- a/docs/Constants.md +++ b/docs/Constants.md @@ -319,11 +319,14 @@ console.log(constants.OPERATIONS_IDS); // operation id SIDECHAIN_BTC_WITHDRAW = 62, SIDECHAIN_BTC_AGGREGATE = 63, SIDECHAIN_BTC_APPROVE_AGGREGATE = 64, - BLOCK_REWARD = 65,// VIRTUAL - EVM_ADDRESS_REGISTER = 66, - DID_CREATE_OPERATION = 67, - DID_UPDATE_OPERATION = 68, - DID_DELETE_OPERATION = 69, + SIDECHAIN_STAKE_ETH_UPDATE = 65, + SIDECHAIN_BTC_CREATE_STAKE_SCRIPT = 66, + SIDECHAIN_STAKE_BTC_UPDATE = 67, + BLOCK_REWARD = 68, // VIRTUAL + EVM_ADDRESS_REGISTER = 69, + DID_CREATE_OPERATION = 70, + DID_UPDATE_OPERATION = 71, + DID_DELETE_OPERATION = 72, } */ ``` diff --git a/package.json b/package.json index 61aa34e1..bb93cf40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "echojs-lib", - "version": "1.12.3-rc.1", + "version": "1.13.0", "description": "Pure JavaScript ECHO library for node.js", "main": "./dist/index.js", "types": "./types/index.d.ts", diff --git a/src/constants/object-types.js b/src/constants/object-types.js index b5c62f88..de2c29ff 100644 --- a/src/constants/object-types.js +++ b/src/constants/object-types.js @@ -22,7 +22,8 @@ export const BTC_INTERMEDIATE_DEPOSIT = 20; export const BTC_DEPOSIT = 21; export const BTC_WITHDRAW = 22; export const BTC_AGGREGATING = 23; -export const BTC_BLOCK = 24; -export const EVM_ADDRESS = 25; -export const DID_OBJECT = 26; - +export const EVM_ADDRESS = 24; +export const DID_OBJECT = 25; +export const STAKE_BTC_SCRIPT = 26; +export const STAKE_BTC_VOUT = 27; +export const STAKE_ETH_UPDATE = 28; diff --git a/src/constants/operations-ids.js b/src/constants/operations-ids.js index 1b01578d..bf761718 100644 --- a/src/constants/operations-ids.js +++ b/src/constants/operations-ids.js @@ -63,8 +63,11 @@ export const SIDECHAIN_BTC_DEPOSIT = 61; export const SIDECHAIN_BTC_WITHDRAW = 62; export const SIDECHAIN_BTC_AGGREGATE = 63; export const SIDECHAIN_BTC_APPROVE_AGGREGATE = 64; -export const BLOCK_REWARD = 65; // VIRTUAL -export const EVM_ADDRESS_REGISTER = 66; -export const DID_CREATE_OPERATION = 67; -export const DID_UPDATE_OPERATION = 68; -export const DID_DELETE_OPERATION = 69; +export const SIDECHAIN_STAKE_ETH_UPDATE = 65; +export const SIDECHAIN_BTC_CREATE_STAKE_SCRIPT = 66; +export const SIDECHAIN_STAKE_BTC_UPDATE = 67; +export const BLOCK_REWARD = 68; // VIRTUAL +export const EVM_ADDRESS_REGISTER = 69; +export const DID_CREATE_OPERATION = 70; +export const DID_UPDATE_OPERATION = 71; +export const DID_DELETE_OPERATION = 72; diff --git a/src/echo/api.js b/src/echo/api.js index b27112b7..2a10810c 100644 --- a/src/echo/api.js +++ b/src/echo/api.js @@ -2133,16 +2133,31 @@ class API { } /** - * @method getRecentTransactionById + * @method getTransactionById * * @param {String} transactionId * * @return {Promise.<*>} */ - async getRecentTransactionById(transactionId) { + async getTransactionById(transactionId) { if (!isRipemd160(transactionId)) throw new Error('Transaction id should be a 20 bytes hex string'); - return this.engine.database.getRecentTransactionById(transactionId); + return this.engine.database.getTransactionById(transactionId); + } + + /** + * @method getBtcStakeAddress + * + * @param {String} account + * + * @return {Promise.<*>} + */ + async getBtcStakeAddress(accountNameOrId) { + if (!(isAccountId(accountNameOrId) || isAccountName(accountNameOrId))) { + throw new Error('AccountNameOrId is invalid'); + } + + return this.engine.database.getBtcStakeAddress(accountNameOrId); } /** diff --git a/src/echo/apis/database-api.js b/src/echo/apis/database-api.js index ebad42f4..78e63dbc 100644 --- a/src/echo/apis/database-api.js +++ b/src/echo/apis/database-api.js @@ -651,14 +651,25 @@ class DatabaseAPI extends BaseEchoApi { } /** - * @method getRecentTransactionById + * @method getTransactionById * * @param {String} transactionId * * @return {Promise} */ - getRecentTransactionById(transactionId) { - return this.exec('get_recent_transaction_by_id', [transactionId]); + getTransactionById(transactionId) { + return this.exec('get_transaction_by_id', [transactionId]); + } + + /** + * @method getBtcStakeAddress + * + * @param {String} accountNameOrId + * + * @return {Promise} + */ + getBtcStakeAddress(accountNameOrId) { + return this.exec('get_btc_stake_address', [accountNameOrId]); } /** diff --git a/src/echo/apis/wallet-api.js b/src/echo/apis/wallet-api.js index b871bd9c..9b965451 100644 --- a/src/echo/apis/wallet-api.js +++ b/src/echo/apis/wallet-api.js @@ -311,6 +311,15 @@ class WalletAPI { */ getTransactionId(tr) { return this.wsProvider.call([0, 'get_transaction_id', [signedTransaction.toRaw(tr)]]); } + getTransactionById(trId) { return this.wsProvider.call([0, 'get_transaction_by_id', [ripemd160.toRaw(trId)]]); } + + getTransaction(blockNumber, trIndex) { + return this.wsProvider.call([0, 'get_transaction', [ + uint64.toRaw(blockNumber), + uint64.toRaw(trIndex), + ]]); + } + /** * Get the WIF private key corresponding to a public key. The private key must already be in the wallet. * @param {string} accountPublicKey public key of an account @@ -1863,6 +1872,40 @@ class WalletAPI { return this.wsProvider.call([0, 'get_btc_deposit_script', [btcDepositAddress]]); } + /** + * @method createBtcStakeAddress + * @param {string} account + * @param {string} userPubkey + * @param {bool} broadcast + * @returns {Promise} + */ + createBtcStakeAddress(accountNameOrId, userPubkey, broadcast) { + if (!isAccountIdOrName(accountNameOrId)) { + return Promise.reject(new Error('Accounts id or name should be string and valid')); + } + + return this.wsProvider.call([0, 'create_btc_stake_address', [ + string.toRaw(accountNameOrId), + string.toRaw(userPubkey), + bool.toRaw(broadcast), + ]]); + } + + /** + * @method getBtcStakeAddress + * @param {string} accountNameOrId + * @returns {Promise} + */ + getBtcStakeAddress(accountNameOrId) { + if (!isAccountIdOrName(accountNameOrId)) { + return Promise.reject(new Error('Accounts id or name should be string and valid')); + } + + return this.wsProvider.call([0, 'get_btc_stake_address', [ + string.toRaw(accountNameOrId), + ]]); + } + /** * @method withdrawBtc * @param {String} accountIdOrName diff --git a/src/serializers/chain/id/protocol.js b/src/serializers/chain/id/protocol.js index ae2643a0..d4630e78 100644 --- a/src/serializers/chain/id/protocol.js +++ b/src/serializers/chain/id/protocol.js @@ -51,7 +51,17 @@ export const btcAggregatingId = new ObjectIdSerializer( RESERVED_SPACE_ID.PROTOCOL, PROTOCOL_OBJECT_TYPE_ID.BTC_AGGREGATING, ); -export const btcBlockId = new ObjectIdSerializer(RESERVED_SPACE_ID.PROTOCOL, PROTOCOL_OBJECT_TYPE_ID.BTC_BLOCK); - export const evmAddressId = new ObjectIdSerializer(RESERVED_SPACE_ID.PROTOCOL, PROTOCOL_OBJECT_TYPE_ID.EVM_ADDRESS); export const didObjectId = new ObjectIdSerializer(RESERVED_SPACE_ID.PROTOCOL, PROTOCOL_OBJECT_TYPE_ID.DID_OBJECT); +export const stakeBtcScriptId = new ObjectIdSerializer( + RESERVED_SPACE_ID.PROTOCOL, + PROTOCOL_OBJECT_TYPE_ID.STAKE_BTC_SCRIPT, +); +export const stakeBtcVoutId = new ObjectIdSerializer( + RESERVED_SPACE_ID.PROTOCOL, + PROTOCOL_OBJECT_TYPE_ID.STAKE_BTC_VOUT, +); +export const stakeEthUpdateId = new ObjectIdSerializer( + RESERVED_SPACE_ID.PROTOCOL, + PROTOCOL_OBJECT_TYPE_ID.STAKE_ETH_UPDATE, +); diff --git a/src/serializers/operation.js b/src/serializers/operation.js index 37cce61f..cf23a526 100644 --- a/src/serializers/operation.js +++ b/src/serializers/operation.js @@ -69,6 +69,9 @@ 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_AGGREGATE]: protocol.sidechain.btc.approveAggregate, + [OPERATIONS_IDS.SIDECHAIN_STAKE_ETH_UPDATE]: protocol.sidechain.eth.stakeUpdate, + [OPERATIONS_IDS.SIDECHAIN_BTC_CREATE_STAKE_SCRIPT]: protocol.sidechain.btc.createStakeScript, + [OPERATIONS_IDS.SIDECHAIN_STAKE_BTC_UPDATE]: protocol.sidechain.btc.stakeUpdate, [OPERATIONS_IDS.BLOCK_REWARD]: protocol.blockReward, [OPERATIONS_IDS.EVM_ADDRESS_REGISTER]: protocol.evmAddress, [OPERATIONS_IDS.DID_CREATE_OPERATION]: protocol.did.create, diff --git a/src/serializers/protocol/fee_parameters.js b/src/serializers/protocol/fee_parameters.js index b7282cfb..6f5db5d0 100644 --- a/src/serializers/protocol/fee_parameters.js +++ b/src/serializers/protocol/fee_parameters.js @@ -74,6 +74,9 @@ const feeParametersSerializer = staticVariant({ [OPERATIONS_IDS.SIDECHAIN_BTC_WITHDRAW]: defaultFeeParametersSerializer, [OPERATIONS_IDS.SIDECHAIN_BTC_AGGREGATE]: defaultFeeParametersSerializer, [OPERATIONS_IDS.SIDECHAIN_BTC_APPROVE_AGGREGATE]: defaultFeeParametersSerializer, + [OPERATIONS_IDS.SIDECHAIN_STAKE_ETH_UPDATE]: defaultFeeParametersSerializer, + [OPERATIONS_IDS.SIDECHAIN_BTC_CREATE_STAKE_SCRIPT]: defaultFeeParametersSerializer, + [OPERATIONS_IDS.SIDECHAIN_STAKE_BTC_UPDATE]: defaultFeeParametersSerializer, [OPERATIONS_IDS.BLOCK_REWARD]: defaultFeeParametersSerializer, [OPERATIONS_IDS.EVM_ADDRESS_REGISTER]: defaultFeeParametersSerializer, [OPERATIONS_IDS.DID_CREATE_OPERATION]: defaultFeeParametersSerializer, diff --git a/src/serializers/protocol/sidechain/btc.js b/src/serializers/protocol/sidechain/btc.js index 217ade38..d2338016 100644 --- a/src/serializers/protocol/sidechain/btc.js +++ b/src/serializers/protocol/sidechain/btc.js @@ -1,4 +1,4 @@ -import { asset, extensions, sha256 } from '../../chain'; +import { asset, extensions, sha256, ripemd160 } from '../../chain'; import { accountId, btcAddressId, @@ -9,7 +9,7 @@ import { } from '../../chain/id/protocol'; import { btcTransactionDetailsSerializer } from '../../chain/sidechain/btc'; import { struct, set, map, optional } from '../../collections'; -import { string as stringSerializer, integers } from '../../basic'; +import { string as stringSerializer, integers, bool } from '../../basic'; import btcPublicKey from '../btcPublicKey'; import { uint8, uint32 } from '../../basic/integers'; @@ -78,3 +78,18 @@ export const sidechainBtcApproveAggregateOperationPropsSerializer = struct({ extensions, }); +export const sidechainBtcCreateStakeScriptOperationPropsSerializer = struct({ + fee: asset, + account: accountId, + user_pubkey_hash: ripemd160, + extensions, +}); + +export const sidechainStakeBtcUpdateOperationPropsSerializer = struct({ + fee: asset, + committee_member_id: accountId, + owner: accountId, + btc_tx_info: btcTransactionDetailsSerializer, + is_vin: bool, + extensions, +}); diff --git a/src/serializers/protocol/sidechain/eth.js b/src/serializers/protocol/sidechain/eth.js index 9c233852..69246c84 100644 --- a/src/serializers/protocol/sidechain/eth.js +++ b/src/serializers/protocol/sidechain/eth.js @@ -1,7 +1,7 @@ import ethAddress from '../ethAddress'; import { uint64 } from '../../basic/integers'; import { asset, extensions, sha256 } from '../../chain'; -import { accountId, ethDepositId, ethWithdrawId } from '../../chain/id/protocol'; +import { accountId, ethDepositId, ethWithdrawId, assetId } from '../../chain/id/protocol'; import { struct, vector } from '../../collections'; export const sidechainEthCreateAddressOperationPropsSerializer = struct({ @@ -65,3 +65,13 @@ export const sidechainEthUpdateContractAddressOperationPropsSerializer = struct( new_addr: ethAddress, extensions, }); + +export const sidechainStakeEthUpdateOperationPropsSerializer = struct({ + fee: asset, + committee_member_id: accountId, + asset_id: assetId, + current_balance: uint64, + account: accountId, + transaction_hash: sha256, + extensions, +}); diff --git a/src/serializers/protocol/sidechain/index.js b/src/serializers/protocol/sidechain/index.js index b73b209e..b8a1613c 100644 --- a/src/serializers/protocol/sidechain/index.js +++ b/src/serializers/protocol/sidechain/index.js @@ -42,6 +42,7 @@ export const eth = { sendWithdraw: _eth.sidechainEthSendWithdrawOperationPropsSerializer, approveWithdraw: _eth.sidechainEthApproveWithdrawOperationPropsSerializer, updateContractAddress: _eth.sidechainEthUpdateContractAddressOperationPropsSerializer, + stakeUpdate: _eth.sidechainStakeEthUpdateOperationPropsSerializer, }; export const btc = { @@ -52,4 +53,6 @@ export const btc = { withdraw: _btc.sidechainBtcWithdrawOperationPropsSerializer, aggregate: _btc.sidechainBtcAggregateOperationPropsSerializer, approveAggregate: _btc.sidechainBtcApproveAggregateOperationPropsSerializer, + createStakeScript: _btc.sidechainBtcCreateStakeScriptOperationPropsSerializer, + stakeUpdate: _btc.sidechainStakeBtcUpdateOperationPropsSerializer, }; diff --git a/types/echo/api.d.ts b/types/echo/api.d.ts index 5efe587e..cb027f85 100644 --- a/types/echo/api.d.ts +++ b/types/echo/api.d.ts @@ -202,7 +202,13 @@ export default class Api { getObjects(objectIds: string, force?: boolean): Promise>; getPotentialSignatures(tr: Object): Promise; getProposedTransactions(accountNameOrId: string): Promise; - getRecentTransactionById(transactionId: string): Promise; + getTransactionById(transactionId: string): Promise; + getBtcStakeAddress(accountNameOrId: string): Promise<{ + id: string, + account: string, + stake_script: string, + p2sh_address: string, + }>; getRelativeAccountHistory(accountId: string, stop: number, limit: number, start: number): Promise; getRequiredFees(operations: Array, assetId: string): Promise>; getRequiredSignatures(tr: Object, availableKey: Array): Promise; diff --git a/types/interfaces/GlobalProperties.d.ts b/types/interfaces/GlobalProperties.d.ts index ae305237..71bd5b3c 100644 --- a/types/interfaces/GlobalProperties.d.ts +++ b/types/interfaces/GlobalProperties.d.ts @@ -1,5 +1,7 @@ export default interface GlobalProperties { id: string, parameters: object, + pending_parameters?: object, active_committee_members: Array>, + consensus_assets_prices: Array> } diff --git a/types/interfaces/OperationId.d.ts b/types/interfaces/OperationId.d.ts index d76d682c..9262f138 100644 --- a/types/interfaces/OperationId.d.ts +++ b/types/interfaces/OperationId.d.ts @@ -65,9 +65,12 @@ declare enum OperationId { SIDECHAIN_BTC_WITHDRAW = 62, SIDECHAIN_BTC_AGGREGATE = 63, SIDECHAIN_BTC_APPROVE_AGGREGATE = 64, - BLOCK_REWARD = 65, // VIRTUAL - EVM_ADDRESS_REGISTER = 66, - DID_CREATE_OPERATION = 67, - DID_UPDATE_OPERATION = 68, - DID_DELETE_OPERATION = 69, + SIDECHAIN_STAKE_ETH_UPDATE = 65, + SIDECHAIN_BTC_CREATE_STAKE_SCRIPT = 66, + SIDECHAIN_STAKE_BTC_UPDATE = 67, + BLOCK_REWARD = 68, // VIRTUAL + EVM_ADDRESS_REGISTER = 69, + DID_CREATE_OPERATION = 70, + DID_UPDATE_OPERATION = 71, + DID_DELETE_OPERATION = 72, } diff --git a/types/serializers/chain/id/protocol.d.ts b/types/serializers/chain/id/protocol.d.ts index e71f6e2d..a296dcaf 100644 --- a/types/serializers/chain/id/protocol.d.ts +++ b/types/serializers/chain/id/protocol.d.ts @@ -19,5 +19,8 @@ export declare const btcIntermediateDepositId: ObjectIdSerializer; export declare const btcWithdrawId: ObjectIdSerializer; export declare const btcAggregatingId: ObjectIdSerializer; -export declare const evmAddressId: ObjectIdSerializer; +export declare const evmAddressId: ObjectIdSerializer; export declare const didObjectId: ObjectIdSerializer; +export declare const stakeBtcScriptId: ObjectIdSerializer; +export declare const stakeBtcVoutId: ObjectIdSerializer; +export declare const stakeEthUpdateId: ObjectIdSerializer; diff --git a/types/serializers/operation.d.ts b/types/serializers/operation.d.ts index a77aa6c2..368f8d6b 100644 --- a/types/serializers/operation.d.ts +++ b/types/serializers/operation.d.ts @@ -69,6 +69,9 @@ export type OperationPropsSerializer = { [OperationId.SIDECHAIN_BTC_WITHDRAW]: typeof protocol.sidechain.btc.withdraw, [OperationId.SIDECHAIN_BTC_AGGREGATE]: typeof protocol.sidechain.btc.aggregate, [OperationId.SIDECHAIN_BTC_APPROVE_AGGREGATE]: typeof protocol.sidechain.btc.approveAggregate, + [OperationId.SIDECHAIN_STAKE_ETH_UPDATE]: typeof protocol.sidechain.eth.stakeUpdate, + [OperationId.SIDECHAIN_BTC_CREATE_STAKE_SCRIPT]: typeof protocol.sidechain.btc.createStakeScript, + [OperationId.SIDECHAIN_STAKE_BTC_UPDATE]: typeof protocol.sidechain.btc.stakeUpdate, [OperationId.BLOCK_REWARD]: typeof protocol.blockReward, [OperationId.EVM_ADDRESS_REGISTER]: typeof protocol.evmAddress, [OperationId.DID_CREATE_OPERATION]: typeof protocol.did.create, diff --git a/types/serializers/plugins/sidechain/config.d.ts b/types/serializers/plugins/sidechain/config.d.ts index cdbc6cb7..a100b24c 100644 --- a/types/serializers/plugins/sidechain/config.d.ts +++ b/types/serializers/plugins/sidechain/config.d.ts @@ -46,3 +46,8 @@ export declare const sidechainERC20ConfigSerializer: StructSerializer<{ burn_method: typeof ethMethodSerializer, issue_method: typeof ethMethodSerializer, }>; + +export declare const sidechainStakeConfigSerializer: StructSerializer<{ + eth_address_type: typeof ethAddress, + eth_topic_type: typeof ethTopicSerializer, +}>; diff --git a/types/serializers/plugins/sidechain/index.d.ts b/types/serializers/plugins/sidechain/index.d.ts index 089329bc..47b02d80 100644 --- a/types/serializers/plugins/sidechain/index.d.ts +++ b/types/serializers/plugins/sidechain/index.d.ts @@ -4,4 +4,5 @@ export { sidechainFinesSerializer as fines, sidechainConfigSerializer as config, sidechainERC20ConfigSerializer as erc20Config, + sidechainStakeConfigSerializer as stakeConfig, } from './config'; diff --git a/types/serializers/protocol/chain_parameters.d.ts b/types/serializers/protocol/chain_parameters.d.ts index 4bfdaf15..a89085ec 100644 --- a/types/serializers/protocol/chain_parameters.d.ts +++ b/types/serializers/protocol/chain_parameters.d.ts @@ -1,6 +1,6 @@ import feeScheduleSerializer from './fee_schedule'; import { uint8, uint32, uint16, uint64 } from '../basic/integers'; -import { extensions } from '../chain'; +import { extensions, asset } from '../chain'; import { assetId } from '../chain/id/protocol'; import { StructSerializer, SetSerializer } from '../collections'; import { MapSerializer } from '../collections'; @@ -22,8 +22,6 @@ declare const chainParametersSerializer: StructSerializer<{ maximum_asset_feed_publishers: typeof uint8, maximum_authority_membership: typeof uint16, max_authority_depth: typeof uint8, - block_emission_amount: typeof uint64, - block_producer_reward_ratio: typeof uint16, committee_frozen_balance_to_activate: typeof uint64, committee_maintenance_intervals_to_deposit: typeof uint64, committee_balance_unfreeze_duration_seconds: typeof uint32, @@ -32,7 +30,9 @@ declare const chainParametersSerializer: StructSerializer<{ echorand_config: typeof echorand.config, sidechain_config: typeof sidechain.config, erc20_config: typeof sidechain.erc20Config, + stake_sidechain_config: typeof sidechain.stakeConfig, gas_price: StructSerializer<{ price: typeof uint64, gas_amount: typeof uint64 }>, + consensus_assets: SetSerializer, valid_fee_asset: SetSerializer, economy_config: typeof economy.config, extensions: typeof extensions, diff --git a/types/serializers/protocol/fee_parameters.d.ts b/types/serializers/protocol/fee_parameters.d.ts index 5f4e9824..d203482a 100644 --- a/types/serializers/protocol/fee_parameters.d.ts +++ b/types/serializers/protocol/fee_parameters.d.ts @@ -84,6 +84,9 @@ export type FeeParametersSerializer = { [OperationId.SIDECHAIN_BTC_WITHDRAW]: typeof defaultFeeParametersSerializer, [OperationId.SIDECHAIN_BTC_AGGREGATE]: typeof defaultFeeParametersSerializer, [OperationId.SIDECHAIN_BTC_APPROVE_AGGREGATE]: typeof defaultFeeParametersSerializer, + [OperationId.SIDECHAIN_STAKE_ETH_UPDATE]: typeof defaultFeeParametersSerializer, + [OperationId.SIDECHAIN_BTC_CREATE_STAKE_SCRIPT]: typeof defaultFeeParametersSerializer, + [OperationId.SIDECHAIN_STAKE_BTC_UPDATE]: typeof defaultFeeParametersSerializer, [OperationId.BLOCK_REWARD]: typeof defaultFeeParametersSerializer, [OperationId.EVM_ADDRESS_REGISTER]: typeof defaultFeeParametersSerializer, [OperationId.DID_CREATE_OPERATION]: typeof defaultFeeParametersSerializer, diff --git a/types/serializers/protocol/sidechain/btc.d.ts b/types/serializers/protocol/sidechain/btc.d.ts index 59f2218e..fd8e882a 100644 --- a/types/serializers/protocol/sidechain/btc.d.ts +++ b/types/serializers/protocol/sidechain/btc.d.ts @@ -1,7 +1,7 @@ -import { asset, extensions, sha256 } from "../../chain"; +import { asset, extensions, sha256, ripemd160 } from "../../chain"; import { accountId, btcAddressId, btcIntermediateDepositId, btcDepositId, btcWithdrawId, btcAggregatingId } from "../../chain/id/protocol"; import { StructSerializer, SetSerializer, MapSerializer } from "../../collections"; -import { StringSerializer, integers } from "../../basic"; +import { StringSerializer, integers, bool } from "../../basic"; import { BtcTransactionDetailsSerializer } from '../../chain/sidechain/btc'; import btcPublicKey from "../btcPublicKey"; import { uint8, uint64 } from "../../basic/integers"; @@ -71,3 +71,19 @@ export const sidechainBtcApproveAggregateOperationPropsSerializer: StructSeriali extensions: typeof extensions, }>; +export const sidechainBtcCreateStakeScriptOperationPropsSerializer: StructSerializer<{ + fee: typeof asset, + account: typeof accountId, + user_pubkey_hash: typeof ripemd160, + extensions: typeof extensions, +}>; + +export const sidechainStakeBtcUpdateOperationPropsSerializer: StructSerializer<{ + fee: typeof asset, + committee_member_id: typeof accountId, + owner: typeof accountId, + btc_tx_info: typeof BtcTransactionDetailsSerializer, + is_vin: typeof bool, + extensions: typeof extensions, +}>; + diff --git a/types/serializers/protocol/sidechain/eth.d.ts b/types/serializers/protocol/sidechain/eth.d.ts index 4507ad18..9e17a7bb 100644 --- a/types/serializers/protocol/sidechain/eth.d.ts +++ b/types/serializers/protocol/sidechain/eth.d.ts @@ -2,7 +2,7 @@ import ethAddress from "../ethAddress"; import { uint64 } from "../../basic/integers"; import { asset, extensions, sha256 } from "../../chain"; -import {accountId, ethDepositId, ethWithdrawId} from "../../chain/id/protocol"; +import { accountId, ethDepositId, ethWithdrawId, assetId } from "../../chain/id/protocol"; import { VectorSerializer, StructSerializer } from "../../collections"; export declare const sidechainEthCreateAddressOperationPropsSerializer: StructSerializer<{ @@ -66,3 +66,13 @@ export declare const sidechainEthUpdateContractAddressOperationPropsSerializer: new_addr: typeof ethAddress, extensions: typeof extensions, }>; + +export declare const sidechainStakeEthUpdateOperationPropsSerializer: StructSerializer<{ + fee: typeof asset, + committee_member_id: typeof accountId, + asset_id: typeof assetId, + current_balance: typeof uint64, + account: typeof accountId, + transaction_hash: typeof sha256, + extensions: typeof extensions, +}>; diff --git a/types/serializers/protocol/sidechain/index.d.ts b/types/serializers/protocol/sidechain/index.d.ts index 86634e5b..ef38e365 100644 --- a/types/serializers/protocol/sidechain/index.d.ts +++ b/types/serializers/protocol/sidechain/index.d.ts @@ -41,6 +41,8 @@ export declare const eth: { sendWithdraw: typeof _eth.sidechainEthSendWithdrawOperationPropsSerializer, approveWithdraw: typeof _eth.sidechainEthApproveWithdrawOperationPropsSerializer, updateContractAddress: typeof _eth.sidechainEthUpdateContractAddressOperationPropsSerializer, + stakeUpdate: typeof _eth.sidechainStakeEthUpdateOperationPropsSerializer, + }; export declare const btc: { @@ -51,4 +53,6 @@ export declare const btc: { withdraw: typeof _btc.sidechainBtcWithdrawOperationPropsSerializer aggregate: typeof _btc.sidechainBtcAggregateOperationPropsSerializer, approveAggregate: typeof _btc.sidechainBtcApproveAggregateOperationPropsSerializer, + createStakeScript: typeof _btc.sidechainBtcCreateStakeScriptOperationPropsSerializer, + stakeUpdate: typeof _btc.sidechainStakeBtcUpdateOperationPropsSerializer, };