Skip to content
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.

Commit

Permalink
Updated schemas and parsers for unsigned values
Browse files Browse the repository at this point in the history
  • Loading branch information
martinayora authored Oct 6, 2020
1 parent 9b8bd95 commit 95b361b
Show file tree
Hide file tree
Showing 16 changed files with 202 additions and 143 deletions.
32 changes: 16 additions & 16 deletions catapult-sdk/src/model/ModelSchemaBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class ModelSchemaBuilder {
// region block
blockHeader: {
size: ModelType.int,
version: ModelType.int,
network: ModelType.int,
version: ModelType.uint8,
network: ModelType.uint8,
type: ModelType.int,
height: ModelType.uint64,
timestamp: ModelType.uint64,
Expand All @@ -57,7 +57,7 @@ class ModelSchemaBuilder {
receiptsHash: ModelType.binary,
stateHash: ModelType.binary,
beneficiaryAddress: ModelType.binary,
feeMultiplier: ModelType.int
feeMultiplier: ModelType.uint32
},
blockHeaderMetadata: {
hash: ModelType.binary,
Expand All @@ -84,20 +84,20 @@ class ModelSchemaBuilder {
finalizedBlock: {
height: ModelType.uint64,
hash: ModelType.binary,
finalizationEpoch: ModelType.uint,
finalizationPoint: ModelType.uint
finalizationEpoch: ModelType.uint32,
finalizationPoint: ModelType.uint32
},

finalizationProof: {
version: ModelType.uint,
finalizationEpoch: ModelType.uint,
finalizationPoint: ModelType.uint,
version: ModelType.uint32,
finalizationEpoch: ModelType.uint32,
finalizationPoint: ModelType.uint32,
height: ModelType.uint64,
hash: ModelType.binary,
messageGroups: { type: ModelType.array, schemaName: 'messageGroup' }
},
messageGroup: {
stage: ModelType.uint,
stage: ModelType.uint32,
height: ModelType.uint64,
hashes: { type: ModelType.array, schemaName: ModelType.binary },
signatures: { type: ModelType.array, schemaName: 'bmTreeSignature' }
Expand All @@ -118,8 +118,8 @@ class ModelSchemaBuilder {

transaction: {
size: ModelType.int,
version: ModelType.int,
network: ModelType.int,
version: ModelType.uint8,
network: ModelType.uint8,
type: ModelType.int,
deadline: ModelType.uint64,
maxFee: ModelType.uint64
Expand Down Expand Up @@ -167,7 +167,7 @@ class ModelSchemaBuilder {
addressHeight: ModelType.uint64,
publicKey: ModelType.binary,
publicKeyHeight: ModelType.uint64,
accountType: ModelType.int,
accountType: ModelType.uint8,
supplementalPublicKeys: { type: ModelType.object, schemaName: 'supplementalPublicKey' },
importance: ModelType.uint64,
importanceHeight: ModelType.uint64,
Expand All @@ -183,7 +183,7 @@ class ModelSchemaBuilder {
activityBucket: {
startHeight: ModelType.uint64,
totalFeesPaid: ModelType.uint64,
beneficiaryCount: ModelType.int,
beneficiaryCount: ModelType.uint32,
rawScore: ModelType.uint64
},
mosaic: {
Expand All @@ -198,8 +198,8 @@ class ModelSchemaBuilder {
},
votingPublicKey: {
publicKey: ModelType.binary,
startEpoch: ModelType.uint,
endEpoch: ModelType.uint
startEpoch: ModelType.uint32,
endEpoch: ModelType.uint32
},

// endregion
Expand All @@ -220,7 +220,7 @@ class ModelSchemaBuilder {
db: ModelType.string
},
nodeInfo: {
version: ModelType.int,
version: ModelType.uint8,
roles: ModelType.int,
port: ModelType.int,
networkIdentifier: ModelType.int,
Expand Down
15 changes: 9 additions & 6 deletions catapult-sdk/src/model/ModelType.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,26 @@ const ModelType = {
/** Schema property type indicating a string value. */
string: SchemaType.max + 4,

/** Schema property type indicating an uint value. */
uint: SchemaType.max + 5,
/** Schema property type indicating an uint byte value. */
uint8: SchemaType.max + 5,

/** Schema property type indicating an uint16 value. */
uint16: SchemaType.max + 6,

/** Schema property type indicating an uint32 value. */
uint32: SchemaType.max + 7,

/** Schema property type indicating a uint64 value as string. */
uint64: SchemaType.max + 7,
uint64: SchemaType.max + 8,

/** Schema property type indicating a uint64 identifier as hexadecimal. */
uint64HexIdentifier: SchemaType.max + 8,
uint64HexIdentifier: SchemaType.max + 9,

/** Schema property type indicating an int value. */
int: SchemaType.max + 9,
int: SchemaType.max + 10,

/** Schema property type indicating a boolean value. */
boolean: SchemaType.max + 10
boolean: SchemaType.max + 11
};

Object.assign(ModelType, SchemaType);
Expand Down
12 changes: 6 additions & 6 deletions catapult-sdk/src/plugins/accountLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ const accountLinkPlugin = {
registerSchema: builder => {
builder.addTransactionSupport(EntityType.accountLink, {
linkedPublicKey: ModelType.binary,
linkAction: ModelType.int
linkAction: ModelType.uint8
});

builder.addTransactionSupport(EntityType.nodeKeyLink, {
linkedPublicKey: ModelType.binary,
linkAction: ModelType.int
linkAction: ModelType.uint8
});

builder.addTransactionSupport(EntityType.votingKeyLink, {
linkedPublicKey: ModelType.binary,
startEpoch: ModelType.uint,
endEpoch: ModelType.uint,
linkAction: ModelType.int
startEpoch: ModelType.uint32,
endEpoch: ModelType.uint32,
linkAction: ModelType.uint8
});

builder.addTransactionSupport(EntityType.vrfKeyLink, {
linkedPublicKey: ModelType.binary,
linkAction: ModelType.int
linkAction: ModelType.uint8
});
},

Expand Down
8 changes: 4 additions & 4 deletions catapult-sdk/src/plugins/lockSecret.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const lockSecretPlugin = {
mosaicId: ModelType.uint64HexIdentifier,
amount: ModelType.uint64,
endHeight: ModelType.uint64,
status: ModelType.int,
hashAlgorithm: ModelType.int,
status: ModelType.uint8,
hashAlgorithm: ModelType.uint8,
secret: ModelType.binary,
recipientAddress: ModelType.binary,
compositeHash: ModelType.binary
Expand All @@ -53,13 +53,13 @@ const lockSecretPlugin = {
mosaicId: ModelType.uint64HexIdentifier,
amount: ModelType.uint64,
duration: ModelType.uint64,
hashAlgorithm: ModelType.int
hashAlgorithm: ModelType.uint8
});
builder.addTransactionSupport(EntityType.secretProof, {
secret: ModelType.binary,
recipientAddress: ModelType.binary,
proof: ModelType.binary,
hashAlgorithm: ModelType.int
hashAlgorithm: ModelType.uint8
});
},

Expand Down
8 changes: 4 additions & 4 deletions catapult-sdk/src/plugins/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const metadataPlugin = {
targetAddress: ModelType.binary,
scopedMetadataKey: ModelType.uint64HexIdentifier,
valueSizeDelta: ModelType.int,
valueSize: ModelType.int,
valueSize: ModelType.uint16,
value: ModelType.binary
});

Expand All @@ -45,7 +45,7 @@ const metadataPlugin = {
scopedMetadataKey: ModelType.uint64HexIdentifier,
targetMosaicId: ModelType.uint64HexIdentifier,
valueSizeDelta: ModelType.int,
valueSize: ModelType.int,
valueSize: ModelType.uint16,
value: ModelType.binary
});

Expand All @@ -54,7 +54,7 @@ const metadataPlugin = {
scopedMetadataKey: ModelType.uint64HexIdentifier,
targetNamespaceId: ModelType.uint64HexIdentifier,
valueSizeDelta: ModelType.int,
valueSize: ModelType.int,
valueSize: ModelType.uint16,
value: ModelType.binary
});

Expand All @@ -70,7 +70,7 @@ const metadataPlugin = {
scopedMetadataKey: ModelType.uint64HexIdentifier,
targetId: ModelType.uint64HexIdentifier,
metadataType: ModelType.int,
valueSize: ModelType.int,
valueSize: ModelType.uint16,
value: ModelType.binary
});
},
Expand Down
12 changes: 6 additions & 6 deletions catapult-sdk/src/plugins/mosaic.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ const mosaicPlugin = {
builder.addTransactionSupport(EntityType.mosaicDefinition, {
id: ModelType.uint64HexIdentifier,
duration: ModelType.uint64,
nonce: ModelType.int,
flags: ModelType.int,
divisibility: ModelType.int
nonce: ModelType.uint32,
flags: ModelType.uint8,
divisibility: ModelType.uint8
});

builder.addTransactionSupport(EntityType.mosaicSupplyChange, {
mosaicId: ModelType.uint64HexIdentifier,
delta: ModelType.uint64,
action: ModelType.int
action: ModelType.uint8
});

builder.addSchema('mosaicDescriptor', {
Expand All @@ -53,8 +53,8 @@ const mosaicPlugin = {
startHeight: ModelType.uint64,
ownerAddress: ModelType.binary,
revision: ModelType.int,
flags: ModelType.int,
divisibility: ModelType.int,
flags: ModelType.uint8,
divisibility: ModelType.uint8,
duration: ModelType.uint64
});
},
Expand Down
16 changes: 8 additions & 8 deletions catapult-sdk/src/plugins/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ const namespacePlugin = {
builder.addTransactionSupport(EntityType.aliasAddress, {
namespaceId: ModelType.uint64HexIdentifier,
address: ModelType.binary,
aliasAction: ModelType.int
aliasAction: ModelType.uint8
});

builder.addTransactionSupport(EntityType.aliasMosaic, {
namespaceId: ModelType.uint64HexIdentifier,
mosaicId: ModelType.uint64HexIdentifier,
aliasAction: ModelType.int
aliasAction: ModelType.uint8
});

builder.addTransactionSupport(EntityType.registerNamespace, {
id: ModelType.uint64HexIdentifier,
registrationType: ModelType.int,
registrationType: ModelType.uint8,
parentId: ModelType.uint64HexIdentifier,
duration: ModelType.uint64,
name: ModelType.string
Expand All @@ -80,8 +80,8 @@ const namespacePlugin = {
});

builder.addSchema('namespaceDescriptor.namespace', {
registrationType: ModelType.int,
depth: ModelType.int,
registrationType: ModelType.uint8,
depth: ModelType.uint8,
level0: ModelType.uint64HexIdentifier,
level1: ModelType.uint64HexIdentifier,
level2: ModelType.uint64HexIdentifier,
Expand All @@ -96,17 +96,17 @@ const namespacePlugin = {
});

builder.addSchema('namespaceDescriptor.alias.mosaic', {
type: ModelType.int,
type: ModelType.uint8,
mosaicId: ModelType.uint64HexIdentifier
});

builder.addSchema('namespaceDescriptor.alias.address', {
type: ModelType.int,
type: ModelType.uint8,
address: ModelType.binary
});

builder.addSchema('namespaceDescriptor.alias.empty', {
type: ModelType.int
type: ModelType.uint8
});

builder.addSchema('namespaceNameTuple', {
Expand Down
12 changes: 6 additions & 6 deletions catapult-sdk/src/plugins/restrictions.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ const restrictionsPlugin = {
accountRestrictionTypeDescriptors.forEach(restrictionTypeDescriptor => {
// transaction schemas
builder.addTransactionSupport(restrictionTypeDescriptor.entityType, {
restrictionFlags: ModelType.int,
restrictionFlags: ModelType.uint16,
restrictionAdditions: { type: ModelType.array, schemaName: restrictionTypeDescriptor.valueType },
restrictionDeletions: { type: ModelType.array, schemaName: restrictionTypeDescriptor.valueType }
});

// aggregated account restriction subschemas
builder.addSchema(`accountRestriction.${restrictionTypeDescriptor.schemaPrefix}AccountRestriction`, {
restrictionFlags: ModelType.int,
restrictionFlags: ModelType.uint16,
values: { type: ModelType.array, schemaName: restrictionTypeDescriptor.valueType }
});
});
Expand Down Expand Up @@ -158,8 +158,8 @@ const restrictionsPlugin = {
restrictionKey: ModelType.uint64HexIdentifier,
previousRestrictionValue: ModelType.uint64,
newRestrictionValue: ModelType.uint64,
previousRestrictionType: ModelType.int,
newRestrictionType: ModelType.int
previousRestrictionType: ModelType.uint8,
newRestrictionType: ModelType.uint8
});

// mosaic restriction schemas
Expand All @@ -169,7 +169,7 @@ const restrictionsPlugin = {
});
builder.addSchema('mosaicRestrictions.entry', {
compositeHash: ModelType.binary,
entryType: ModelType.uint,
entryType: ModelType.uint32,
mosaicId: ModelType.uint64HexIdentifier,
targetAddress: ModelType.binary,
restrictions: { type: ModelType.array, schemaName: 'mosaicRestrictions.entry.restrictions' }
Expand All @@ -182,7 +182,7 @@ const restrictionsPlugin = {
builder.addSchema('mosaicRestrictions.entry.restrictions.restriction', {
referenceMosaicId: ModelType.uint64HexIdentifier,
restrictionValue: ModelType.uint64,
restrictionType: ModelType.int
restrictionType: ModelType.uint8
});
},

Expand Down
Loading

0 comments on commit 95b361b

Please sign in to comment.