Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • hive/wax
1 result
Show changes
Showing
with 995 additions and 878 deletions
This diff is collapsed.
......@@ -21,10 +21,6 @@ export default [
}),
replace({
values: {
// Make sure we do not include `process` in the code:
'process': null,
'process.env': null,
'process.env.REFLECT_METADATA_USE_MAP_POLYFILL': null, // Bundled dependency - reflect-metadata - uses this - we do not need it
// Hardcode package name and version for later use in the code:
'process.env.npm_package_name': `"${process.env.npm_package_name}"`,
'process.env.npm_package_version': `"${process.env.npm_package_version}"`
......
......@@ -283,7 +283,7 @@ test.describe('Wax object interface formatters tests', () => {
test('Should be able to retrieve account from the API and format it using default formatter from the hive chain interface', async({ waxTest }) => {
const retVal = await waxTest(async({ chain }) => {
const response = await chain.api.database_api.find_accounts({ accounts: [ "initminer" ] });
const response = await chain.api.database_api.find_accounts({ accounts: [ "initminer" ], delayed_votes_active: true });
return chain.formatter.extend({ asset: { displayAsNai: false, appendTokenName: true, formatAmount: true, locales: "en-US" } }).format(response.accounts[0]);
});
......
......@@ -2,7 +2,6 @@ import { expect } from '@playwright/test';
import { test } from '../assets/jest-helper';
import { protoVoteOp, recoverAccountTransaction, requiredActiveAuthorityTransaction, requiredOwnerAuthorityTransaction, signatureTransaction } from "../assets/data.proto-protocol";
import { IsArray, IsObject, IsString } from 'class-validator';
const HIVE_BLOCK_INTERVAL = 3 * 1000; // 3 seconds
......@@ -33,75 +32,6 @@ test.describe('Wax object interface chain tests', () => {
expect(retVal.digest).toBe('205c79e3d17211882b1a2ba8640ff208413d68cabdca892cf47e9a6ad46e63a1');
});
test('Should be able to transmit article transaction using hive chain interface', async ({ waxTest }) => {
const retVal = await waxTest(async({ beekeeper, chain, wax }) => {
// Create wallet:
const session = beekeeper.createSession("salt");
const { wallet } = await session.createWallet("w0");
await wallet.importKey('5JkFnXrLM2ap9t3AmAxBJvQHF7xSKtnTrCTginQCkhzU5S7ecPT');
const tx = chain.createTransactionWithTaPoS("04c1c7a566fc0da66aee465714acee7346b48ac2", "2023-08-01T15:38:48");
tx.pushOperation(new wax.BlogPostOperation({
author: "mee",
body: "how r u",
category: "test",
title: "about you",
permlink: "permlink1",
percentHbd: 0,
maxAcceptedPayout: chain.hbdSatoshis(0)
}));
tx.sign(wallet, "STM5RqVBAVNp5ufMCetQtvLGLJo7unX9nyCBMMrTXRWQ9i1Zzzizh");
console.log(tx.toApi());
return new wax.BroadcastTransactionRequest(tx);
});
retVal.trx.signatures.splice(0, 1); // We do not want to test signing here which will change due to json_metadata app version and name values
expect(retVal).toStrictEqual({
max_block_age: -1,
trx: {
operations: [
{
type: "comment_operation",
value: {
parent_author: "",
parent_permlink: "test",
author: "mee",
permlink: "permlink1",
title: "about you",
body: "how r u",
json_metadata: `{\"format\":\"markdown+html\",\"app\":\"${process.env.npm_package_name}/${process.env.npm_package_version}\"}`
}
},
{
type: "comment_options_operation",
value: {
author: "mee",
permlink: "permlink1",
max_accepted_payout: {
amount: "0",
precision: 3,
nai: "@@000000013"
},
percent_hbd: 0,
allow_votes: true,
allow_curation_rewards: true
}
}
],
extensions: [],
signatures: [],
ref_block_num: 51109,
ref_block_prefix: 2785934438,
expiration: '2023-08-01T15:38:48'
}
});
});
test('Should be able to perform example API call', async ({ waxTest }) => {
const retVal = await waxTest(async({ chain }) => {
// https://developers.hive.io/apidefinitions/#account_by_key_api.get_key_references
......@@ -169,47 +99,6 @@ test.describe('Wax object interface chain tests', () => {
expect(retVal).toStrictEqual({ args: {}, ret: [] });
});
test('Should be able to extend hive chain and validate properties interface by custom definitions', async ({}, testInfo) => {
class MyRequest {
@IsString()
method!: string;
}
class MyResponse {
@IsObject()
args!: {};
@IsArray()
ret!: [];
}
const { chain } = await createWaxTestFor('node', testInfo.outputDir);
const extended = chain.extend({
jsonrpc: {
get_signature: {
params: MyRequest,
result: MyResponse
}
}
});
await expect(async() => {
await extended.api.jsonrpc.get_signature(new MyRequest());
}).rejects.toBeInstanceOf(Array); // Array<ValidationError>
await expect(async() => {
const req = new MyRequest();
(req.method as any) = 10; // Force invalid type on the method
await extended.api.jsonrpc.get_signature(req); // This should throw after validating
}).rejects.toBeInstanceOf(Array); // Array<ValidationError>
const result = await extended.api.jsonrpc.get_signature({ method: "jsonrpc.get_methods" });
const expectedResult = new MyResponse();
expectedResult.args = {};
expectedResult.ret = [];
expect(result).toStrictEqual(expectedResult);
});
test('Should be able to extend hive chain interface by custom definitions using interfaces only', async ({ waxTest }) => {
const retVal = await waxTest(async({ chain }) => {
interface IMyRequest {
......@@ -237,58 +126,6 @@ test.describe('Wax object interface chain tests', () => {
expect(retVal).toStrictEqual({ args: {}, ret: [] });
});
test('Should throw when creating broadcast transaction request from unsigned transaction', async ({ waxTest }) => {
const retVal = await waxTest(async({ chain, wax }, protoVoteOp) => {
const tx = chain.createTransactionWithTaPoS("04c1c7a566fc0da66aee465714acee7346b48ac2", "2023-08-01T15:38:48");
tx.pushOperation(protoVoteOp).transaction;
try {
new wax.BroadcastTransactionRequest(tx);
return false;
} catch {
return true;
}
}, protoVoteOp);
expect(retVal).toBeTruthy();
});
test('Should be able to transmit protobuf transaction using hive chain interface', async ({ waxTest }) => {
const retVal = await waxTest(async({ beekeeper, chain, wax }, protoVoteOp) => {
// Create wallet:
const session = beekeeper.createSession("salt");
const { wallet } = await session.createWallet("w0");
await wallet.importKey('5JkFnXrLM2ap9t3AmAxBJvQHF7xSKtnTrCTginQCkhzU5S7ecPT');
const tx = chain.createTransactionWithTaPoS("04c1c7a566fc0da66aee465714acee7346b48ac2", "2023-08-01T15:38:48");
tx.pushOperation(protoVoteOp).sign(wallet, "STM5RqVBAVNp5ufMCetQtvLGLJo7unX9nyCBMMrTXRWQ9i1Zzzizh");
return new wax.BroadcastTransactionRequest(tx);
}, protoVoteOp);
expect(retVal).toStrictEqual({
max_block_age: -1,
trx: {
operations: [ {
type: "vote_operation",
value: {
author: "c0ff33a",
permlink: "ewxhnjbj",
voter: "otom",
weight: 2200,
}
} ],
extensions: [],
signatures: [
"1f7f0c3e89e6ccef1ae156a96fb4255e619ca3a73ef3be46746b4b40a66cc4252070eb313cc6308bbee39a0a9fc38ef99137ead3c9b003584c0a1b8f5ca2ff8707"
],
ref_block_num: 51109,
ref_block_prefix: 2785934438,
expiration: '2023-08-01T15:38:48'
}
});
});
test('Should be able to calculate current manabar value using hive chain interface', async ({ waxTest }) => {
const retVal = await waxTest(async({ chain }) => {
const { current, max, percent } = chain.calculateCurrentManabarValue(
......@@ -313,7 +150,7 @@ test.describe('Wax object interface chain tests', () => {
test('Should be able to parse user manabar from API using hive chain interface', async ({ waxTest }) => {
const retVal = await waxTest(async({ chain }) => {
const { accounts: [ account ] } = await chain.api.database_api.find_accounts({
accounts: [ "initminer" ]
accounts: [ "initminer" ], delayed_votes_active: true
});
const dgpo = await chain.api.database_api.get_dynamic_global_properties({});
......
......@@ -106,7 +106,7 @@ test.describe('Wax object interface chain tests (using custom options)', () => {
test('Should be able to find accounts from hive chain interafce', async({ waxTest }) => {
const retVal = await waxTest(async({ chain }) => {
return (await chain.api.database_api.find_accounts({ accounts: ['thatcryptodave'] })).accounts[0];
return (await chain.api.database_api.find_accounts({ accounts: ['thatcryptodave'], delayed_votes_active: true })).accounts[0];
});
expect(retVal).toHaveProperty('active');
......
......@@ -16,7 +16,7 @@ test.describe('Wax base mock tests', () => {
test('Should be able to find account based on mock interface', async ({ waxTest }) => {
const retVal = await waxTest(async({ chain }) => {
const foundAccount = await chain.api.database_api.find_accounts({ accounts: ['steem'] });
const foundAccount = await chain.api.database_api.find_accounts({ accounts: ['steem'], delayed_votes_active: true });
return foundAccount;
});
......@@ -26,7 +26,7 @@ test.describe('Wax base mock tests', () => {
test('Should be able to find NONEXISTING account based on mock interface', async ({ waxTest }) => {
const retVal = await waxTest(async({ chain }, accountData) => {
const foundAccount = await chain.api.database_api.find_accounts({ accounts: ['0steem'] }); /// Intentionally use invalid name in Hive
const foundAccount = await chain.api.database_api.find_accounts({ accounts: ['0steem'], delayed_votes_active: true }); /// Intentionally use invalid name in Hive
console.log(JSON.stringify(foundAccount));
......
import { IsString, Validate } from "class-validator";
import { IsPublicKey } from "../../decorators/is_public_key.js";
import type { TPublicKey } from "../../interfaces";
export class GetKeyReferencesRequest {
@Validate(IsPublicKey, { each: true })
public keys!: Array<TPublicKey>;
export interface GetKeyReferencesRequest {
keys: Array<TPublicKey>;
}
export class GetKeyReferencesResponse {
@Validate(IsString.bind({ each: true }), { each: true })
public accounts!: string[][];
export interface GetKeyReferencesResponse {
accounts: string[][];
}
import { IsNumber, IsOptional, Min, ValidateNested } from "class-validator";
import { Type } from "class-transformer";
import type { ApiBlock } from "../types/block.js";
import { ApiBlock } from "../types/block.js";
export class GetBlockRequest {
@IsNumber()
@Min(0)
public block_num!: number;
export interface GetBlockRequest {
block_num: number;
}
export class GetBlockResponse {
@ValidateNested()
@IsOptional()
@Type(() => ApiBlock)
public block?: ApiBlock;
export interface GetBlockResponse {
block?: ApiBlock;
}
import { IsNumber, Min, ValidateNested } from "class-validator";
import { Type } from "class-transformer";
import type { ApiBlockHeader } from "../types/block.js";
import { ApiBlockHeader } from "../types/block.js";
export class GetBlockHeaderRequest {
@IsNumber()
@Min(0)
public block_num!: number;
export interface GetBlockHeaderRequest {
block_num: number;
}
export class GetBlockHeaderResponse {
@ValidateNested()
@Type(() => ApiBlockHeader)
public header!: ApiBlockHeader;
export interface GetBlockHeaderResponse {
header: ApiBlockHeader;
}
import { IsNumber, Max, Min, ValidateNested } from "class-validator";
import { Type } from "class-transformer";
import type { ApiBlock } from "../types/block.js";
import { ApiBlock } from "../types/block.js";
export class GetBlockRangeRequest {
@IsNumber()
@Min(0)
public starting_block_num!: number;
@IsNumber()
@Min(0)
@Max(1000)
public count!: number;
export interface GetBlockRangeRequest {
starting_block_num: number;
count: number;
}
export class GetBlockRangeResponse {
@ValidateNested({ each: true })
@Type(() => ApiBlock)
public blocks!: Array<ApiBlock>;
export interface GetBlockRangeResponse {
blocks: Array<ApiBlock>;
}
import { Type } from "class-transformer";
import { IsBoolean, IsOptional, IsString, ValidateNested } from "class-validator";
import { ApiAccount } from "../types/index.js";
export class FindAccountsRequest {
@IsString({ each: true })
public accounts!: string[];
@IsOptional()
@IsBoolean()
public delayed_votes_active?: boolean = true;
export interface FindAccountsRequest {
accounts: string[];
delayed_votes_active: boolean;
}
export class FindAccountsResponse {
@Type(() => ApiAccount)
@ValidateNested({ each: true })
public accounts!: Array<ApiAccount>;
export interface FindAccountsResponse {
accounts: Array<ApiAccount>;
}
import { Type } from "class-transformer";
import { IsBoolean, IsOptional, IsString, ValidateNested } from "class-validator";
import type { ApiWitness } from "../types/index.js";
import { ApiWitness} from "../types/index.js";
export class FindWitnessesRequest {
@IsString({ each: true })
public owners!: string[];
@IsOptional()
@IsBoolean()
public delayed_votes_active?: boolean = true;
export interface FindWitnessesRequest {
owners: string[];
delayed_votes_active: boolean;
}
export class FindWitnessesResponse {
@Type(() => ApiWitness)
@ValidateNested({ each: true })
public witnesses!: Array<ApiWitness>;
export interface FindWitnessesResponse {
witnesses: Array<ApiWitness>;
}
import { IsDateString, IsHexadecimal, IsNumber, IsOptional, IsString, Validate, ValidateNested } from "class-validator";
import { Type } from "class-transformer";
import { NaiAsset } from "../types/asset.js";
import { IsNumberOrStringNumber } from "../../decorators/is_number_or_number_string.js";
export class GetDynamicGlobalPropertiesRequest {}
export class GetDynamicGlobalPropertiesResponse {
@IsNumber()
public id!: number;
@IsNumber()
public head_block_number!: number;
@IsHexadecimal()
public head_block_id!: string;
@IsDateString()
public time!: string;
@IsString()
public current_witness!: string;
@Validate(IsNumberOrStringNumber)
public total_pow!: string | number;
@IsNumber()
public num_pow_witnesses!: number;
@Type(() => NaiAsset)
@ValidateNested()
public virtual_supply!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public current_supply!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public confidential_supply!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public init_hbd_supply!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public current_hbd_supply!: NaiAsset;
@IsNumber()
public current_remove_threshold!: number;
@Type(() => NaiAsset)
@ValidateNested()
public confidential_hbd_supply!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public total_vesting_fund_hive!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public total_vesting_shares!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public total_reward_fund_hive!: NaiAsset;
@IsString()
public total_reward_shares2!: string;
@Type(() => NaiAsset)
@ValidateNested()
public pending_rewarded_vesting_shares!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public pending_rewarded_vesting_hive!: NaiAsset;
@IsNumber()
public hbd_interest_rate!: number;
@IsNumber()
public hbd_print_rate!: number;
@IsNumber()
public maximum_block_size!: number;
@Validate(IsNumberOrStringNumber)
public mid_voting_seconds!: number | string;
@IsNumber()
public min_recurrent_transfers_recurrence!: number;
@IsNumber()
@IsOptional()
public required_actions_partition_percent?: number;
@IsNumber()
public current_aslot!: number;
@IsString()
public recent_slots_filled!: string;
@IsNumber()
public participation_count!: number;
@IsNumber()
public last_irreversible_block_num!: number;
@IsNumber()
public max_consecutive_recurrent_transfer_failures!: number;
@IsNumber()
public max_open_recurrent_transfers!: number;
@IsNumber()
public max_recurrent_transfer_end_date!: number;
@IsOptional()
@IsNumber()
public target_votes_per_period?: number;
@IsNumber()
public delegation_return_period!: number;
@IsNumber()
public reverse_auction_seconds!: number;
@IsNumber()
public available_account_subsidies!: number;
@IsNumber()
public hbd_stop_percent!: number;
@IsNumber()
public hbd_start_percent!: number;
@IsDateString()
public next_daily_maintenance_time!: string;
@IsDateString()
public next_maintenance_time!: string;
@IsDateString()
public last_budget_time!: string;
@IsNumber()
public content_reward_percent!: number;
@IsNumber()
public vesting_reward_percent!: number;
@IsOptional()
@IsNumber()
public sps_fund_percent?: number;
@Type(() => NaiAsset)
@ValidateNested()
public sps_interval_ledger!: NaiAsset;
@IsNumber()
public downvote_pool_percent!: number;
@Validate(IsNumberOrStringNumber)
public early_voting_seconds!: number | string;
@Type(() => NaiAsset)
@ValidateNested()
public smt_creation_fee!: NaiAsset;
import type { NaiAsset } from "../types/asset.js";
export interface GetDynamicGlobalPropertiesRequest {}
export interface GetDynamicGlobalPropertiesResponse {
id: number;
head_block_number: number;
head_block_id: string;
time: string;
current_witness: string;
total_pow: string | number;
num_pow_witnesses: number;
virtual_supply: NaiAsset;
current_supply: NaiAsset;
confidential_supply: NaiAsset;
init_hbd_supply: NaiAsset;
current_hbd_supply: NaiAsset;
current_remove_threshold: number;
confidential_hbd_supply: NaiAsset;
total_vesting_fund_hive: NaiAsset;
total_vesting_shares: NaiAsset;
total_reward_fund_hive: NaiAsset;
total_reward_shares2: string;
pending_rewarded_vesting_shares: NaiAsset;
pending_rewarded_vesting_hive: NaiAsset;
hbd_interest_rate: number;
hbd_print_rate: number;
maximum_block_size: number;
mid_voting_seconds: number | string;
min_recurrent_transfers_recurrence: number;
required_actions_partition_percent?: number;
current_aslot: number;
recent_slots_filled: string;
participation_count: number;
last_irreversible_block_num: number;
max_consecutive_recurrent_transfer_failures: number;
max_open_recurrent_transfers: number;
max_recurrent_transfer_end_date: number;
target_votes_per_period?: number;
delegation_return_period: number;
reverse_auction_seconds: number;
available_account_subsidies: number;
hbd_stop_percent: number;
hbd_start_percent: number;
next_daily_maintenance_time: string;
next_maintenance_time: string;
last_budget_time: string;
content_reward_percent: number;
vesting_reward_percent: number;
sps_fund_percent?: number;
sps_interval_ledger: NaiAsset;
downvote_pool_percent: number;
early_voting_seconds: number | string;
smt_creation_fee: NaiAsset;
}
import { Type } from "class-transformer";
import { IsBoolean, ValidateNested, IsEnum } from "class-validator";
import { TTransactionPackType, ApiTransaction } from "../types"
export class VerifyAuthorityRequest {
@ValidateNested()
@Type(() => ApiTransaction)
public trx!: ApiTransaction;
@IsEnum(TTransactionPackType)
public pack: TTransactionPackType = TTransactionPackType.HF_26;
export interface VerifyAuthorityRequest {
trx: ApiTransaction;
pack: TTransactionPackType;
};
export class VerifyAuthorityResponse {
@IsBoolean()
public valid: boolean = false;
export interface VerifyAuthorityResponse {
valid: boolean;
};
import { Type } from "class-transformer"
import { IsNumber, ValidateNested } from "class-validator"
import type { ITransaction } from "../../interfaces";
import { ApiTransaction } from "../types/transaction.js";
import { WaxError } from "../../errors.js";
export class BroadcastTransactionRequest {
public constructor(trx?: ITransaction) {
if(typeof trx === 'undefined')
return;
if(!trx.isSigned())
throw new WaxError('Transaction requires at least one signature.');
this.trx = Object.assign(new ApiTransaction(), JSON.parse(trx.toApi()));
}
@ValidateNested()
@Type(() => ApiTransaction)
public trx!: ApiTransaction;
@IsNumber()
public max_block_age: number = -1;
export interface BroadcastTransactionRequest {
trx: ApiTransaction;
max_block_age: number;
}
export class BroadcastTransactionResponse {}
export interface BroadcastTransactionResponse {}
import { Type } from "class-transformer";
import { IsString, Validate, ValidateNested } from "class-validator";
import { ApiManabar, NaiAsset } from "../types/index.js";
import { IsNumberOrStringNumber } from "../../decorators/is_number_or_number_string.js";
export class FindRcAccountsRequest {
@IsString({ each: true })
public accounts!: string[];
export interface FindRcAccountsRequest {
accounts: string[];
}
export class RcAccount {
@IsString()
public account!: string;
@Type(() => ApiManabar)
@ValidateNested()
public rc_manabar!: ApiManabar;
@Type(() => NaiAsset)
@ValidateNested()
public max_rc_creation_adjustment!: NaiAsset;
@Validate(IsNumberOrStringNumber)
public max_rc!: string | number;
export interface RcAccount {
account: string;
rc_manabar: ApiManabar;
max_rc_creation_adjustment: NaiAsset;
max_rc: string | number;
}
export class FindRcAccountsResponse {
@Type(() => RcAccount)
@ValidateNested({ each: true })
public rc_accounts!: Array<RcAccount>;
export interface FindRcAccountsResponse {
rc_accounts: Array<RcAccount>;
}
import { Type } from "class-transformer";
import { IsArray, IsBoolean, IsDateString, IsNumber, IsNumberString, IsString, Validate, ValidateNested } from "class-validator";
import { NaiAsset } from "./asset.js";
import { IsNumberOrStringNumber } from "../../decorators/is_number_or_number_string.js";
import { IsPublicKey } from "../../decorators/is_public_key.js";
import { IsAuth } from "../../decorators/is_auth.js";
import type { TPublicKey } from "../../interfaces";
export class ApiAccountAuth {
@IsString()
public "0"!: string;
@IsNumber()
public "1"!: number;
export interface ApiAccountAuth {
"0": string;
"1": number;
}
export class ApiKeyAuth {
@Validate(IsPublicKey)
public "0"!: TPublicKey;
@IsNumber()
public "1"!: number;
export interface ApiKeyAuth {
"0": TPublicKey;
"1": number;
}
export class ApiDelayedVote {
@IsDateString()
public time!: string;
@Validate(IsNumberOrStringNumber)
public val!: number | string;
export interface ApiDelayedVote {
time: string;
val: number | string;
}
export class ApiAuthority {
@IsNumber()
public weight_threshold!: number;
@IsArray()
@Type(() => ApiAccountAuth)
@Validate(IsAuth)
public account_auths!: Array<ApiAccountAuth>;
@IsArray()
@Type(() => ApiKeyAuth)
@Validate(IsAuth)
public key_auths!: Array<ApiKeyAuth>;
export interface ApiAuthority {
weight_threshold: number;
account_auths: Array<ApiAccountAuth>;
key_auths: Array<ApiKeyAuth>;
}
export class ApiManabar {
@Validate(IsNumberOrStringNumber)
public current_mana!: string | number;
@IsNumber()
public last_update_time!: number;
export interface ApiManabar {
current_mana: string | number;
last_update_time: number;
}
export class ApiAccount {
@IsNumber()
public id!: number;
@IsString()
public name!: string;
@Type(() => ApiAuthority)
@ValidateNested()
public owner!: ApiAuthority;
@Type(() => ApiAuthority)
@ValidateNested()
public active!: ApiAuthority;
@Type(() => ApiAuthority)
@ValidateNested()
public posting!: ApiAuthority;
@Validate(IsPublicKey)
public memo_key!: TPublicKey;
@IsString()
public json_metadata!: string;
@IsString()
public posting_json_metadata!: string;
@IsString()
public proxy!: string;
@IsDateString()
public previous_owner_update!: string;
@IsDateString()
public last_owner_update!: string;
@IsDateString()
public last_account_update!: string;
@IsDateString()
public created!: string;
@IsBoolean()
public mined!: boolean;
@IsString()
public recovery_account!: string;
@IsDateString()
public last_account_recovery!: string;
@IsString()
public reset_account!: string;
@IsNumber()
public comment_count!: number;
@IsNumber()
public lifetime_vote_count!: number;
@IsNumber()
public post_count!: number;
@IsBoolean()
public can_vote!: boolean;
@Type(() => ApiManabar)
@ValidateNested()
public voting_manabar!: ApiManabar;
@Type(() => ApiManabar)
@ValidateNested()
public downvote_manabar!: ApiManabar;
@Type(() => NaiAsset)
@ValidateNested()
public balance!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public savings_balance!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public hbd_balance!: NaiAsset;
@IsNumberString()
public hbd_seconds!: string;
@IsDateString()
public hbd_seconds_last_update!: string;
@IsDateString()
public hbd_last_interest_payment!: string;
@Type(() => NaiAsset)
@ValidateNested()
public savings_hbd_balance!: NaiAsset;
@IsNumberString()
public savings_hbd_seconds!: string;
@IsDateString()
public savings_hbd_seconds_last_update!: string;
@IsDateString()
public savings_hbd_last_interest_payment!: string;
@IsNumber()
public savings_withdraw_requests!: number;
@Type(() => NaiAsset)
@ValidateNested()
public reward_hbd_balance!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public reward_hive_balance!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public reward_vesting_balance!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public reward_vesting_hive!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public vesting_shares!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public delegated_vesting_shares!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public received_vesting_shares!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public vesting_withdraw_rate!: NaiAsset;
@Type(() => NaiAsset)
@ValidateNested()
public post_voting_power!: NaiAsset;
@IsDateString()
public next_vesting_withdrawal!: string;
@Validate(IsNumberOrStringNumber)
public withdrawn!: number | string;
@Validate(IsNumberOrStringNumber)
public to_withdraw!: number | string;
@IsNumber()
public withdraw_routes!: number;
@IsNumber()
public pending_transfers!: number;
@Validate(IsNumberOrStringNumber)
public curation_rewards!: number | string;
@Validate(IsNumberOrStringNumber)
public posting_rewards!: number | string;
@Validate(IsNumberOrStringNumber, { each: true })
public proxied_vsf_votes!: Array<string | number>;
@IsNumber()
public witnesses_voted_for!: number;
@IsDateString()
public last_post!: string;
@IsDateString()
public last_root_post!: string;
@IsDateString()
public last_post_edit!: string;
@IsDateString()
public last_vote_time!: string;
@IsNumber()
public post_bandwidth!: number;
@Validate(IsNumberOrStringNumber)
public pending_claimed_accounts!: number | string;
@IsNumber()
public open_recurrent_transfers!: number;
@IsBoolean()
public is_smt!: boolean;
@IsArray()
@Type(() => ApiDelayedVote)
@ValidateNested({ each: true })
public delayed_votes!: ApiDelayedVote[];
@IsDateString()
public governance_vote_expiration_ts!: string;
export interface ApiAccount {
id: number;
name: string;
owner: ApiAuthority;
active: ApiAuthority;
posting: ApiAuthority;
memo_key: TPublicKey;
json_metadata: string;
posting_json_metadata: string;
proxy: string;
previous_owner_update: string;
last_owner_update: string;
last_account_update: string;
created: string;
mined: boolean;
recovery_account: string;
last_account_recovery: string;
reset_account: string;
comment_count: number;
lifetime_vote_count: number;
post_count: number;
can_vote: boolean;
voting_manabar: ApiManabar;
downvote_manabar: ApiManabar;
balance: NaiAsset;
savings_balance: NaiAsset;
hbd_balance: NaiAsset;
hbd_seconds: string;
hbd_seconds_last_update: string;
hbd_last_interest_payment: string;
savings_hbd_balance: NaiAsset;
savings_hbd_seconds: string;
savings_hbd_seconds_last_update: string;
savings_hbd_last_interest_payment: string;
savings_withdraw_requests: number;
reward_hbd_balance: NaiAsset;
reward_hive_balance: NaiAsset;
reward_vesting_balance: NaiAsset;
reward_vesting_hive: NaiAsset;
vesting_shares: NaiAsset;
delegated_vesting_shares: NaiAsset;
received_vesting_shares: NaiAsset;
vesting_withdraw_rate: NaiAsset;
post_voting_power: NaiAsset;
next_vesting_withdrawal: string;
withdrawn: number | string;
to_withdraw: number | string;
withdraw_routes: number;
pending_transfers: number;
curation_rewards: number | string;
posting_rewards: number | string;
proxied_vsf_votes: Array<string | number>;
witnesses_voted_for: number;
last_post: string;
last_root_post: string;
last_post_edit: string;
last_vote_time: string;
post_bandwidth: number;
pending_claimed_accounts: number | string;
open_recurrent_transfers: number;
is_smt: boolean;
delayed_votes: ApiDelayedVote[];
governance_vote_expiration_ts: string;
}
import { IsNumber, IsString, Validate } from "class-validator";
import { IsNaiString } from "../../decorators/is_nai_string.js";
export class NaiAsset {
@IsString()
public amount!: string;
@IsNumber()
public precision!: number;
@Validate(IsNaiString)
public nai!: string;
export interface NaiAsset {
amount: string;
precision: number;
nai: string;
}
import { Type } from "class-transformer";
import { IsDateString, IsHexadecimal, IsObject, IsString, Validate, ValidateNested } from "class-validator";
import { ApiTransaction } from "./transaction.js";
import { IsPublicKey } from "../../decorators/is_public_key.js";
export class ApiBlockHeader {
@IsHexadecimal()
public previous!: string;
@IsDateString()
public timestamp!: string;
@IsString()
public witness!: string;
@IsHexadecimal()
public transaction_merkle_root!: string;
@IsObject({ each: true })
public extensions: object[] = [];
export interface ApiBlockHeader {
previous: string;
timestamp: string;
witness: string;
transaction_merkle_root: string;
extensions: object[];
}
export class ApiBlock extends ApiBlockHeader {
@IsHexadecimal()
public witness_signature!: string;
@ValidateNested({ each: true })
@Type(() => ApiTransaction)
public transactions: Array<ApiTransaction> = [];
@IsHexadecimal()
public block_id!: string;
@Validate(IsPublicKey)
public signing_key!: string;
@IsHexadecimal({ each: true })
public transaction_ids: string[] = [];
export interface ApiBlock extends ApiBlockHeader {
witness_signature: string;
transactions: Array<ApiTransaction>;
block_id: string;
signing_key: string;
transaction_ids: string[];
}
import { type ITransaction } from "../../interfaces.js";
import { Type, plainToInstance } from "class-transformer";
import { Min, Max, IsDateString, IsInt, IsObject, IsString, ValidateNested } from "class-validator";
export class ApiOperation {
@IsString()
public type!: string;
@IsObject()
public value!: object;
export interface ApiOperation {
type: string;
value: object;
}
export class ApiTransaction {
/**
* Constructs new ApiTransaction object
*
* @param {?object} apiTransaction optional API object either from the remote Node or {@link ITransaction.toApiJson}
*
* @example
* ```ts
* new ApiTransaction(transactionBuilder.toApiJson());
* ```
*/
public constructor(apiTransaction?: object) {
if(apiTransaction !== undefined) {
const { operations, ...otherTransactionData } = apiTransaction as any;
Object.assign(this, otherTransactionData);
if(Array.isArray(operations))
for(const op of operations)
this.operations.push(plainToInstance(ApiOperation, op));
}
}
@IsInt()
@Min(0) // Should be set to min/max. uint16 value
@Max(65535)
public ref_block_num!: number;
@IsInt()
@Min(0)
@Max(4294967295)
public ref_block_prefix!: number;
@IsDateString()
public expiration!: string;
@ValidateNested({ each: true })
@Type(() => ApiOperation)
public operations: Array<ApiOperation> = [];
@IsObject({ each: true })
public extensions: object[] = [];
@IsString({ each: true })
public signatures: string[] = [];
export interface ApiTransaction {
ref_block_num: number;
ref_block_prefix: number;
expiration: string;
operations: Array<ApiOperation>;
extensions: object[];
signatures: string[];
}