Skip to content

Commit

Permalink
nodejs: fix some block tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Dec 8, 2023
1 parent 6a4f41b commit 12a79a4
Show file tree
Hide file tree
Showing 11 changed files with 596 additions and 105 deletions.
1 change: 1 addition & 0 deletions bindings/core/src/method/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub enum UtilsMethod {
#[serde(rename_all = "camelCase")]
BlockId {
block: BlockDto,
#[serde(rename = "params")]
protocol_parameters: ProtocolParameters,
},
/// Returns the transaction ID (Blake2b256 hash of the provided transaction payload)
Expand Down
9 changes: 7 additions & 2 deletions bindings/nodejs/lib/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,13 @@ export class Client {
/**
* Get the token supply.
*/
async getTokenSupply(): Promise<u64> {
return (await this.getProtocolParameters()).tokenSupply;
async getTokenSupply(): Promise<BigInt> {

Check failure on line 343 in bindings/nodejs/lib/client/client.ts

View workflow job for this annotation

GitHub Actions / Lint

Don't use `BigInt` as a type. Use bigint instead
const tokenSupply = (await this.getProtocolParameters()).tokenSupply;
if (tokenSupply !== undefined) {
return BigInt(tokenSupply);
} else {
throw new Error("ProtocolParameters.tokenSupply is undefined");
}
}

/**
Expand Down
8 changes: 8 additions & 0 deletions bindings/nodejs/lib/types/block/core/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { BlockBody } from './block-body';
import { BasicBlockBody } from './basic';
import { ValidationBlockBody } from './validation';
import { BlockBodyDiscriminator } from '.';
import { Utils, ProtocolParameters, BlockId } from '../../..';

/**
* The block header.
Expand Down Expand Up @@ -118,6 +119,13 @@ class Block {
asValidation(): ValidationBlockBody {
return this.body.asValidation();
}

/**
* Gets the block id.
*/
id(params: ProtocolParameters): BlockId {
return Utils.blockId(this, params);
}
}

function parseBlock(data: any): Block {
Expand Down
Loading

0 comments on commit 12a79a4

Please sign in to comment.