Skip to content

Commit

Permalink
types: add plain symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
tammo committed Oct 13, 2020
1 parent e256ade commit c370c18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Block.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AssetSymbol } from './Blockchain';
import { SigPublicKey } from './Keys';
import { StorageId } from './Storage';

Expand All @@ -9,6 +10,7 @@ export class Signature extends String {}
export type SignatureData = {
type: string;
prev: Signature | undefined;
symbol: AssetSymbol | undefined;
senderBalance: string;
senderAmount: string;
refBlock: Signature | undefined;
Expand All @@ -33,6 +35,7 @@ export class Block {
txId: string;
signature: Signature;
type: BlockType;
symbol: AssetSymbol | undefined;
prev: Signature | undefined;
refBlock: Signature | undefined;
refAsset: string | undefined;
Expand All @@ -46,11 +49,12 @@ export class Block {
state?: string;

getDataForSignature(): SignatureData {
const { type, prev, senderBalance, senderAmount, refBlock, refAsset, refAddress, claimSignature, payload } = this;
const { type, prev, symbol, senderBalance, senderAmount, refBlock, refAsset, refAddress, claimSignature, payload } = this;

return {
type,
prev,
symbol,
senderBalance,
senderAmount,
refBlock,
Expand Down Expand Up @@ -97,6 +101,7 @@ export function fromBlockObject(obj: any) {
block.signature = obj.signature;
block.type = obj.type;
block.prev = obj.prev;
block.symbol = obj.symbol;
block.refBlock = obj.refBlock;
block.refAsset = obj.refAsset;
block.claimSignature = obj.claimSignature;
Expand Down
2 changes: 1 addition & 1 deletion src/Blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class Blockchain {
prevIndex[block.prev as string] = block;
});

const assetBlock = this.blocks.find((block) => block.type === BlockType.ASSET && block.refAsset === asset);
const assetBlock = this.blocks.find((block) => block.type === BlockType.ASSET && block.symbol === asset);

// chain has no asset created yet
if (!assetBlock) return;
Expand Down

0 comments on commit c370c18

Please sign in to comment.