diff --git a/lib/__generated__/events_pb.d.ts b/lib/__generated__/events_pb.d.ts index fb46509..a0ff39d 100644 --- a/lib/__generated__/events_pb.d.ts +++ b/lib/__generated__/events_pb.d.ts @@ -4,10 +4,10 @@ import * as access_path_pb from './access_path_pb'; import * as proof_pb from './proof_pb'; export class Event extends jspb.Message { - getAccessPath(): access_path_pb.AccessPath | undefined; - setAccessPath(value?: access_path_pb.AccessPath): void; - hasAccessPath(): boolean; - clearAccessPath(): void; + getKey(): Uint8Array | string; + getKey_asU8(): Uint8Array; + getKey_asB64(): string; + setKey(value: Uint8Array | string): void; getSequenceNumber(): number; setSequenceNumber(value: number): void; @@ -27,7 +27,7 @@ export class Event extends jspb.Message { export namespace Event { export type AsObject = { - accessPath?: access_path_pb.AccessPath.AsObject, + key: Uint8Array | string, sequenceNumber: number, eventData: Uint8Array | string, } diff --git a/lib/__generated__/events_pb.js b/lib/__generated__/events_pb.js index b32e5d0..00a284b 100644 --- a/lib/__generated__/events_pb.js +++ b/lib/__generated__/events_pb.js @@ -66,7 +66,7 @@ proto.types.Event.prototype.toObject = function(opt_includeInstance) { */ proto.types.Event.toObject = function(includeInstance, msg) { var f, obj = { - accessPath: (f = msg.getAccessPath()) && access_path_pb.AccessPath.toObject(includeInstance, f), + key: msg.getKey_asB64(), sequenceNumber: jspb.Message.getFieldWithDefault(msg, 2, 0), eventData: msg.getEventData_asB64() }; @@ -106,9 +106,8 @@ proto.types.Event.deserializeBinaryFromReader = function(msg, reader) { var field = reader.getFieldNumber(); switch (field) { case 1: - var value = new access_path_pb.AccessPath; - reader.readMessage(value,access_path_pb.AccessPath.deserializeBinaryFromReader); - msg.setAccessPath(value); + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setKey(value); break; case 2: var value = /** @type {number} */ (reader.readUint64()); @@ -147,12 +146,11 @@ proto.types.Event.prototype.serializeBinary = function() { */ proto.types.Event.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getAccessPath(); - if (f != null) { - writer.writeMessage( + f = message.getKey_asU8(); + if (f.length > 0) { + writer.writeBytes( 1, - f, - access_path_pb.AccessPath.serializeBinaryToWriter + f ); } f = message.getSequenceNumber(); @@ -173,32 +171,41 @@ proto.types.Event.serializeBinaryToWriter = function(message, writer) { /** - * optional AccessPath access_path = 1; - * @return {?proto.types.AccessPath} + * optional bytes key = 1; + * @return {!(string|Uint8Array)} */ -proto.types.Event.prototype.getAccessPath = function() { - return /** @type{?proto.types.AccessPath} */ ( - jspb.Message.getWrapperField(this, access_path_pb.AccessPath, 1)); +proto.types.Event.prototype.getKey = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); }; -/** @param {?proto.types.AccessPath|undefined} value */ -proto.types.Event.prototype.setAccessPath = function(value) { - jspb.Message.setWrapperField(this, 1, value); +/** + * optional bytes key = 1; + * This is a type-conversion wrapper around `getKey()` + * @return {string} + */ +proto.types.Event.prototype.getKey_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getKey())); }; -proto.types.Event.prototype.clearAccessPath = function() { - this.setAccessPath(undefined); +/** + * optional bytes key = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getKey()` + * @return {!Uint8Array} + */ +proto.types.Event.prototype.getKey_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getKey())); }; -/** - * Returns whether this field is set. - * @return {boolean} - */ -proto.types.Event.prototype.hasAccessPath = function() { - return jspb.Message.getField(this, 1) != null; +/** @param {!(string|Uint8Array)} value */ +proto.types.Event.prototype.setKey = function(value) { + jspb.Message.setProto3BytesField(this, 1, value); }; diff --git a/lib/__generated__/proof_pb.d.ts b/lib/__generated__/proof_pb.d.ts index d26c048..682cef6 100644 --- a/lib/__generated__/proof_pb.d.ts +++ b/lib/__generated__/proof_pb.d.ts @@ -58,6 +58,36 @@ export namespace SparseMerkleProof { } } +export class AccumulatorConsistencyProof extends jspb.Message { + getFrozenSubtreeRootsList(): Array; + setFrozenSubtreeRootsList(value: Array): void; + clearFrozenSubtreeRootsList(): void; + addFrozenSubtreeRoots(value: Uint8Array | string, index?: number): void; + + getNumSiblings(): number; + setNumSiblings(value: number): void; + + getNonDefaultSiblingsList(): Array; + setNonDefaultSiblingsList(value: Array): void; + clearNonDefaultSiblingsList(): void; + addNonDefaultSiblings(value: Uint8Array | string, index?: number): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): AccumulatorConsistencyProof.AsObject; + static toObject(includeInstance: boolean, msg: AccumulatorConsistencyProof): AccumulatorConsistencyProof.AsObject; + static serializeBinaryToWriter(message: AccumulatorConsistencyProof, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): AccumulatorConsistencyProof; + static deserializeBinaryFromReader(message: AccumulatorConsistencyProof, reader: jspb.BinaryReader): AccumulatorConsistencyProof; +} + +export namespace AccumulatorConsistencyProof { + export type AsObject = { + frozenSubtreeRootsList: Array, + numSiblings: number, + nonDefaultSiblingsList: Array, + } +} + export class SignedTransactionProof extends jspb.Message { getLedgerInfoToTransactionInfoProof(): AccumulatorProof | undefined; setLedgerInfoToTransactionInfoProof(value?: AccumulatorProof): void; diff --git a/lib/__generated__/proof_pb.js b/lib/__generated__/proof_pb.js index cccd7ba..f21a93e 100644 --- a/lib/__generated__/proof_pb.js +++ b/lib/__generated__/proof_pb.js @@ -14,6 +14,7 @@ var global = Function('return this')(); var transaction_info_pb = require('./transaction_info_pb.js'); goog.object.extend(proto, transaction_info_pb); goog.exportSymbol('proto.types.AccountStateProof', null, global); +goog.exportSymbol('proto.types.AccumulatorConsistencyProof', null, global); goog.exportSymbol('proto.types.AccumulatorProof', null, global); goog.exportSymbol('proto.types.EventProof', null, global); goog.exportSymbol('proto.types.SignedTransactionProof', null, global); @@ -522,6 +523,285 @@ proto.types.SparseMerkleProof.prototype.clearNonDefaultSiblingsList = function() +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.types.AccumulatorConsistencyProof = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.types.AccumulatorConsistencyProof.repeatedFields_, null); +}; +goog.inherits(proto.types.AccumulatorConsistencyProof, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.types.AccumulatorConsistencyProof.displayName = 'proto.types.AccumulatorConsistencyProof'; +} +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.types.AccumulatorConsistencyProof.repeatedFields_ = [1,3]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.types.AccumulatorConsistencyProof.prototype.toObject = function(opt_includeInstance) { + return proto.types.AccumulatorConsistencyProof.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.types.AccumulatorConsistencyProof} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.types.AccumulatorConsistencyProof.toObject = function(includeInstance, msg) { + var f, obj = { + frozenSubtreeRootsList: msg.getFrozenSubtreeRootsList_asB64(), + numSiblings: jspb.Message.getFieldWithDefault(msg, 2, 0), + nonDefaultSiblingsList: msg.getNonDefaultSiblingsList_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.types.AccumulatorConsistencyProof} + */ +proto.types.AccumulatorConsistencyProof.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.types.AccumulatorConsistencyProof; + return proto.types.AccumulatorConsistencyProof.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.types.AccumulatorConsistencyProof} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.types.AccumulatorConsistencyProof} + */ +proto.types.AccumulatorConsistencyProof.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.addFrozenSubtreeRoots(value); + break; + case 2: + var value = /** @type {number} */ (reader.readUint32()); + msg.setNumSiblings(value); + break; + case 3: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.addNonDefaultSiblings(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.types.AccumulatorConsistencyProof.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.types.AccumulatorConsistencyProof.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.types.AccumulatorConsistencyProof} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.types.AccumulatorConsistencyProof.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getFrozenSubtreeRootsList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( + 1, + f + ); + } + f = message.getNumSiblings(); + if (f !== 0) { + writer.writeUint32( + 2, + f + ); + } + f = message.getNonDefaultSiblingsList_asU8(); + if (f.length > 0) { + writer.writeRepeatedBytes( + 3, + f + ); + } +}; + + +/** + * repeated bytes frozen_subtree_roots = 1; + * @return {!(Array|Array)} + */ +proto.types.AccumulatorConsistencyProof.prototype.getFrozenSubtreeRootsList = function() { + return /** @type {!(Array|Array)} */ (jspb.Message.getRepeatedField(this, 1)); +}; + + +/** + * repeated bytes frozen_subtree_roots = 1; + * This is a type-conversion wrapper around `getFrozenSubtreeRootsList()` + * @return {!Array} + */ +proto.types.AccumulatorConsistencyProof.prototype.getFrozenSubtreeRootsList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getFrozenSubtreeRootsList())); +}; + + +/** + * repeated bytes frozen_subtree_roots = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getFrozenSubtreeRootsList()` + * @return {!Array} + */ +proto.types.AccumulatorConsistencyProof.prototype.getFrozenSubtreeRootsList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getFrozenSubtreeRootsList())); +}; + + +/** @param {!(Array|Array)} value */ +proto.types.AccumulatorConsistencyProof.prototype.setFrozenSubtreeRootsList = function(value) { + jspb.Message.setField(this, 1, value || []); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + */ +proto.types.AccumulatorConsistencyProof.prototype.addFrozenSubtreeRoots = function(value, opt_index) { + jspb.Message.addToRepeatedField(this, 1, value, opt_index); +}; + + +proto.types.AccumulatorConsistencyProof.prototype.clearFrozenSubtreeRootsList = function() { + this.setFrozenSubtreeRootsList([]); +}; + + +/** + * optional uint32 num_siblings = 2; + * @return {number} + */ +proto.types.AccumulatorConsistencyProof.prototype.getNumSiblings = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** @param {number} value */ +proto.types.AccumulatorConsistencyProof.prototype.setNumSiblings = function(value) { + jspb.Message.setProto3IntField(this, 2, value); +}; + + +/** + * repeated bytes non_default_siblings = 3; + * @return {!(Array|Array)} + */ +proto.types.AccumulatorConsistencyProof.prototype.getNonDefaultSiblingsList = function() { + return /** @type {!(Array|Array)} */ (jspb.Message.getRepeatedField(this, 3)); +}; + + +/** + * repeated bytes non_default_siblings = 3; + * This is a type-conversion wrapper around `getNonDefaultSiblingsList()` + * @return {!Array} + */ +proto.types.AccumulatorConsistencyProof.prototype.getNonDefaultSiblingsList_asB64 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsB64( + this.getNonDefaultSiblingsList())); +}; + + +/** + * repeated bytes non_default_siblings = 3; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getNonDefaultSiblingsList()` + * @return {!Array} + */ +proto.types.AccumulatorConsistencyProof.prototype.getNonDefaultSiblingsList_asU8 = function() { + return /** @type {!Array} */ (jspb.Message.bytesListAsU8( + this.getNonDefaultSiblingsList())); +}; + + +/** @param {!(Array|Array)} value */ +proto.types.AccumulatorConsistencyProof.prototype.setNonDefaultSiblingsList = function(value) { + jspb.Message.setField(this, 3, value || []); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @param {number=} opt_index + */ +proto.types.AccumulatorConsistencyProof.prototype.addNonDefaultSiblings = function(value, opt_index) { + jspb.Message.addToRepeatedField(this, 3, value, opt_index); +}; + + +proto.types.AccumulatorConsistencyProof.prototype.clearNonDefaultSiblingsList = function() { + this.setNonDefaultSiblingsList([]); +}; + + + /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a diff --git a/lib/__generated__/transaction_pb.d.ts b/lib/__generated__/transaction_pb.d.ts index 90d2466..4657d70 100644 --- a/lib/__generated__/transaction_pb.d.ts +++ b/lib/__generated__/transaction_pb.d.ts @@ -25,6 +25,16 @@ export class RawTransaction extends jspb.Message { hasWriteSet(): boolean; clearWriteSet(): void; + getScript(): Script | undefined; + setScript(value?: Script): void; + hasScript(): boolean; + clearScript(): void; + + getModule(): Module | undefined; + setModule(value?: Module): void; + hasModule(): boolean; + clearModule(): void; + getMaxGasAmount(): number; setMaxGasAmount(value: number): void; @@ -50,6 +60,8 @@ export namespace RawTransaction { sequenceNumber: number, program?: Program.AsObject, writeSet?: WriteSet.AsObject, + script?: Script.AsObject, + module?: Module.AsObject, maxGasAmount: number, gasUnitPrice: number, expirationTime: number, @@ -59,6 +71,8 @@ export namespace RawTransaction { PAYLOAD_NOT_SET = 0, PROGRAM = 3, WRITE_SET = 4, + SCRIPT = 8, + MODULE = 9, } } @@ -94,6 +108,32 @@ export namespace Program { } } +export class Script extends jspb.Message { + getCode(): Uint8Array | string; + getCode_asU8(): Uint8Array; + getCode_asB64(): string; + setCode(value: Uint8Array | string): void; + + getArgumentsList(): Array; + setArgumentsList(value: Array): void; + clearArgumentsList(): void; + addArguments(value?: TransactionArgument, index?: number): TransactionArgument; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): Script.AsObject; + static toObject(includeInstance: boolean, msg: Script): Script.AsObject; + static serializeBinaryToWriter(message: Script, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Script; + static deserializeBinaryFromReader(message: Script, reader: jspb.BinaryReader): Script; +} + +export namespace Script { + export type AsObject = { + code: Uint8Array | string, + argumentsList: Array, + } +} + export class TransactionArgument extends jspb.Message { getType(): TransactionArgument.ArgType; setType(value: TransactionArgument.ArgType): void; @@ -125,6 +165,26 @@ export namespace TransactionArgument { } } +export class Module extends jspb.Message { + getCode(): Uint8Array | string; + getCode_asU8(): Uint8Array; + getCode_asB64(): string; + setCode(value: Uint8Array | string): void; + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): Module.AsObject; + static toObject(includeInstance: boolean, msg: Module): Module.AsObject; + static serializeBinaryToWriter(message: Module, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Module; + static deserializeBinaryFromReader(message: Module, reader: jspb.BinaryReader): Module; +} + +export namespace Module { + export type AsObject = { + code: Uint8Array | string, + } +} + export class SignedTransaction extends jspb.Message { getRawTxnBytes(): Uint8Array | string; getRawTxnBytes_asU8(): Uint8Array; diff --git a/lib/__generated__/transaction_pb.js b/lib/__generated__/transaction_pb.js index 4ab752e..34d81b8 100644 --- a/lib/__generated__/transaction_pb.js +++ b/lib/__generated__/transaction_pb.js @@ -22,8 +22,10 @@ goog.object.extend(proto, transaction_info_pb); var google_protobuf_wrappers_pb = require('google-protobuf/google/protobuf/wrappers_pb.js'); goog.object.extend(proto, google_protobuf_wrappers_pb); goog.exportSymbol('proto.types.AccountState', null, global); +goog.exportSymbol('proto.types.Module', null, global); goog.exportSymbol('proto.types.Program', null, global); goog.exportSymbol('proto.types.RawTransaction', null, global); +goog.exportSymbol('proto.types.Script', null, global); goog.exportSymbol('proto.types.SignedTransaction', null, global); goog.exportSymbol('proto.types.SignedTransactionWithProof', null, global); goog.exportSymbol('proto.types.SignedTransactionsBlock', null, global); @@ -60,7 +62,7 @@ if (goog.DEBUG && !COMPILED) { * @private {!Array>} * @const */ -proto.types.RawTransaction.oneofGroups_ = [[3,4]]; +proto.types.RawTransaction.oneofGroups_ = [[3,4,8,9]]; /** * @enum {number} @@ -68,7 +70,9 @@ proto.types.RawTransaction.oneofGroups_ = [[3,4]]; proto.types.RawTransaction.PayloadCase = { PAYLOAD_NOT_SET: 0, PROGRAM: 3, - WRITE_SET: 4 + WRITE_SET: 4, + SCRIPT: 8, + MODULE: 9 }; /** @@ -111,6 +115,8 @@ proto.types.RawTransaction.toObject = function(includeInstance, msg) { sequenceNumber: jspb.Message.getFieldWithDefault(msg, 2, 0), program: (f = msg.getProgram()) && proto.types.Program.toObject(includeInstance, f), writeSet: (f = msg.getWriteSet()) && proto.types.WriteSet.toObject(includeInstance, f), + script: (f = msg.getScript()) && proto.types.Script.toObject(includeInstance, f), + module: (f = msg.getModule()) && proto.types.Module.toObject(includeInstance, f), maxGasAmount: jspb.Message.getFieldWithDefault(msg, 5, 0), gasUnitPrice: jspb.Message.getFieldWithDefault(msg, 6, 0), expirationTime: jspb.Message.getFieldWithDefault(msg, 7, 0) @@ -168,6 +174,16 @@ proto.types.RawTransaction.deserializeBinaryFromReader = function(msg, reader) { reader.readMessage(value,proto.types.WriteSet.deserializeBinaryFromReader); msg.setWriteSet(value); break; + case 8: + var value = new proto.types.Script; + reader.readMessage(value,proto.types.Script.deserializeBinaryFromReader); + msg.setScript(value); + break; + case 9: + var value = new proto.types.Module; + reader.readMessage(value,proto.types.Module.deserializeBinaryFromReader); + msg.setModule(value); + break; case 5: var value = /** @type {number} */ (reader.readUint64()); msg.setMaxGasAmount(value); @@ -239,6 +255,22 @@ proto.types.RawTransaction.serializeBinaryToWriter = function(message, writer) { proto.types.WriteSet.serializeBinaryToWriter ); } + f = message.getScript(); + if (f != null) { + writer.writeMessage( + 8, + f, + proto.types.Script.serializeBinaryToWriter + ); + } + f = message.getModule(); + if (f != null) { + writer.writeMessage( + 9, + f, + proto.types.Module.serializeBinaryToWriter + ); + } f = message.getMaxGasAmount(); if (f !== 0) { writer.writeUint64( @@ -377,6 +409,66 @@ proto.types.RawTransaction.prototype.hasWriteSet = function() { }; +/** + * optional Script script = 8; + * @return {?proto.types.Script} + */ +proto.types.RawTransaction.prototype.getScript = function() { + return /** @type{?proto.types.Script} */ ( + jspb.Message.getWrapperField(this, proto.types.Script, 8)); +}; + + +/** @param {?proto.types.Script|undefined} value */ +proto.types.RawTransaction.prototype.setScript = function(value) { + jspb.Message.setOneofWrapperField(this, 8, proto.types.RawTransaction.oneofGroups_[0], value); +}; + + +proto.types.RawTransaction.prototype.clearScript = function() { + this.setScript(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.types.RawTransaction.prototype.hasScript = function() { + return jspb.Message.getField(this, 8) != null; +}; + + +/** + * optional Module module = 9; + * @return {?proto.types.Module} + */ +proto.types.RawTransaction.prototype.getModule = function() { + return /** @type{?proto.types.Module} */ ( + jspb.Message.getWrapperField(this, proto.types.Module, 9)); +}; + + +/** @param {?proto.types.Module|undefined} value */ +proto.types.RawTransaction.prototype.setModule = function(value) { + jspb.Message.setOneofWrapperField(this, 9, proto.types.RawTransaction.oneofGroups_[0], value); +}; + + +proto.types.RawTransaction.prototype.clearModule = function() { + this.setModule(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.types.RawTransaction.prototype.hasModule = function() { + return jspb.Message.getField(this, 9) != null; +}; + + /** * optional uint64 max_gas_amount = 5; * @return {number} @@ -707,6 +799,225 @@ proto.types.Program.prototype.clearModulesList = function() { +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.types.Script = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.types.Script.repeatedFields_, null); +}; +goog.inherits(proto.types.Script, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.types.Script.displayName = 'proto.types.Script'; +} +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.types.Script.repeatedFields_ = [2]; + + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.types.Script.prototype.toObject = function(opt_includeInstance) { + return proto.types.Script.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.types.Script} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.types.Script.toObject = function(includeInstance, msg) { + var f, obj = { + code: msg.getCode_asB64(), + argumentsList: jspb.Message.toObjectList(msg.getArgumentsList(), + proto.types.TransactionArgument.toObject, includeInstance) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.types.Script} + */ +proto.types.Script.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.types.Script; + return proto.types.Script.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.types.Script} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.types.Script} + */ +proto.types.Script.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setCode(value); + break; + case 2: + var value = new proto.types.TransactionArgument; + reader.readMessage(value,proto.types.TransactionArgument.deserializeBinaryFromReader); + msg.addArguments(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.types.Script.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.types.Script.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.types.Script} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.types.Script.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getCode_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } + f = message.getArgumentsList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 2, + f, + proto.types.TransactionArgument.serializeBinaryToWriter + ); + } +}; + + +/** + * optional bytes code = 1; + * @return {!(string|Uint8Array)} + */ +proto.types.Script.prototype.getCode = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes code = 1; + * This is a type-conversion wrapper around `getCode()` + * @return {string} + */ +proto.types.Script.prototype.getCode_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getCode())); +}; + + +/** + * optional bytes code = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getCode()` + * @return {!Uint8Array} + */ +proto.types.Script.prototype.getCode_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getCode())); +}; + + +/** @param {!(string|Uint8Array)} value */ +proto.types.Script.prototype.setCode = function(value) { + jspb.Message.setProto3BytesField(this, 1, value); +}; + + +/** + * repeated TransactionArgument arguments = 2; + * @return {!Array} + */ +proto.types.Script.prototype.getArgumentsList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.types.TransactionArgument, 2)); +}; + + +/** @param {!Array} value */ +proto.types.Script.prototype.setArgumentsList = function(value) { + jspb.Message.setRepeatedWrapperField(this, 2, value); +}; + + +/** + * @param {!proto.types.TransactionArgument=} opt_value + * @param {number=} opt_index + * @return {!proto.types.TransactionArgument} + */ +proto.types.Script.prototype.addArguments = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 2, opt_value, proto.types.TransactionArgument, opt_index); +}; + + +proto.types.Script.prototype.clearArgumentsList = function() { + this.setArgumentsList([]); +}; + + + /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -910,6 +1221,172 @@ proto.types.TransactionArgument.prototype.setData = function(value) { +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.types.Module = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.types.Module, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.types.Module.displayName = 'proto.types.Module'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.types.Module.prototype.toObject = function(opt_includeInstance) { + return proto.types.Module.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.types.Module} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.types.Module.toObject = function(includeInstance, msg) { + var f, obj = { + code: msg.getCode_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.types.Module} + */ +proto.types.Module.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.types.Module; + return proto.types.Module.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.types.Module} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.types.Module} + */ +proto.types.Module.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setCode(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.types.Module.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.types.Module.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.types.Module} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.types.Module.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getCode_asU8(); + if (f.length > 0) { + writer.writeBytes( + 1, + f + ); + } +}; + + +/** + * optional bytes code = 1; + * @return {!(string|Uint8Array)} + */ +proto.types.Module.prototype.getCode = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * optional bytes code = 1; + * This is a type-conversion wrapper around `getCode()` + * @return {string} + */ +proto.types.Module.prototype.getCode_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getCode())); +}; + + +/** + * optional bytes code = 1; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getCode()` + * @return {!Uint8Array} + */ +proto.types.Module.prototype.getCode_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getCode())); +}; + + +/** @param {!(string|Uint8Array)} value */ +proto.types.Module.prototype.setCode = function(value) { + jspb.Message.setProto3BytesField(this, 1, value); +}; + + + /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a diff --git a/lib/__generated__/vm_errors_pb.d.ts b/lib/__generated__/vm_errors_pb.d.ts index 46688ad..86ffde5 100644 --- a/lib/__generated__/vm_errors_pb.d.ts +++ b/lib/__generated__/vm_errors_pb.d.ts @@ -274,72 +274,79 @@ export enum VMValidationStatusCode { export enum VMVerificationErrorKind { UNKNOWNVERIFICATIONERROR = 0, INDEXOUTOFBOUNDS = 1, - RANGEOUTOFBOUNDS = 2, - INVALIDSIGNATURETOKEN = 3, - INVALIDFIELDDEFREFERENCE = 4, - RECURSIVESTRUCTDEFINITION = 5, - INVALIDRESOURCEFIELD = 6, - INVALIDFALLTHROUGH = 7, - JOINFAILURE = 8, - NEGATIVESTACKSIZEWITHINBLOCK = 9, - UNBALANCEDSTACK = 10, - INVALIDMAINFUNCTIONSIGNATURE = 11, - DUPLICATEELEMENT = 12, - INVALIDMODULEHANDLE = 13, - UNIMPLEMENTEDHANDLE = 14, - INCONSISTENTFIELDS = 15, - UNUSEDFIELDS = 16, - LOOKUPFAILED = 17, - VISIBILITYMISMATCH = 18, - TYPERESOLUTIONFAILURE = 19, - TYPEMISMATCH = 20, - MISSINGDEPENDENCY = 21, - POPREFERENCEERROR = 22, - POPRESOURCEERROR = 23, - RELEASEREFTYPEMISMATCHERROR = 24, - BRTYPEMISMATCHERROR = 25, - ABORTTYPEMISMATCHERROR = 26, - STLOCTYPEMISMATCHERROR = 27, - STLOCUNSAFETODESTROYERROR = 28, - RETUNSAFETODESTROYERROR = 29, - RETTYPEMISMATCHERROR = 30, - FREEZEREFTYPEMISMATCHERROR = 31, - FREEZEREFEXISTSMUTABLEBORROWERROR = 32, - BORROWFIELDTYPEMISMATCHERROR = 33, - BORROWFIELDBADFIELDERROR = 34, - BORROWFIELDEXISTSMUTABLEBORROWERROR = 35, - COPYLOCUNAVAILABLEERROR = 36, - COPYLOCRESOURCEERROR = 37, - COPYLOCEXISTSBORROWERROR = 38, - MOVELOCUNAVAILABLEERROR = 39, - MOVELOCEXISTSBORROWERROR = 40, - BORROWLOCREFERENCEERROR = 41, - BORROWLOCUNAVAILABLEERROR = 42, - BORROWLOCEXISTSBORROWERROR = 43, - CALLTYPEMISMATCHERROR = 44, - CALLBORROWEDMUTABLEREFERENCEERROR = 45, - PACKTYPEMISMATCHERROR = 46, - UNPACKTYPEMISMATCHERROR = 47, - READREFTYPEMISMATCHERROR = 48, - READREFRESOURCEERROR = 49, - READREFEXISTSMUTABLEBORROWERROR = 50, - WRITEREFTYPEMISMATCHERROR = 51, - WRITEREFRESOURCEERROR = 52, - WRITEREFEXISTSBORROWERROR = 53, - WRITEREFNOMUTABLEREFERENCEERROR = 54, - INTEGEROPTYPEMISMATCHERROR = 55, - BOOLEANOPTYPEMISMATCHERROR = 56, - EQUALITYOPTYPEMISMATCHERROR = 57, - EXISTSRESOURCETYPEMISMATCHERROR = 58, - BORROWGLOBALTYPEMISMATCHERROR = 59, - BORROWGLOBALNORESOURCEERROR = 60, - MOVEFROMTYPEMISMATCHERROR = 61, - MOVEFROMNORESOURCEERROR = 62, - MOVETOSENDERTYPEMISMATCHERROR = 63, - MOVETOSENDERNORESOURCEERROR = 64, - CREATEACCOUNTTYPEMISMATCHERROR = 65, - MODULEADDRESSDOESNOTMATCHSENDER = 66, - NOMODULEHANDLES = 67, + CODEUNITINDEXOUTOFBOUNDS = 2, + RANGEOUTOFBOUNDS = 3, + INVALIDSIGNATURETOKEN = 4, + INVALIDFIELDDEFREFERENCE = 5, + RECURSIVESTRUCTDEFINITION = 6, + INVALIDRESOURCEFIELD = 7, + INVALIDFALLTHROUGH = 8, + JOINFAILURE = 9, + NEGATIVESTACKSIZEWITHINBLOCK = 10, + UNBALANCEDSTACK = 11, + INVALIDMAINFUNCTIONSIGNATURE = 12, + DUPLICATEELEMENT = 13, + INVALIDMODULEHANDLE = 14, + UNIMPLEMENTEDHANDLE = 15, + INCONSISTENTFIELDS = 16, + UNUSEDFIELDS = 17, + LOOKUPFAILED = 18, + VISIBILITYMISMATCH = 19, + TYPERESOLUTIONFAILURE = 20, + TYPEMISMATCH = 21, + MISSINGDEPENDENCY = 22, + POPREFERENCEERROR = 23, + POPRESOURCEERROR = 24, + RELEASEREFTYPEMISMATCHERROR = 25, + BRTYPEMISMATCHERROR = 26, + ABORTTYPEMISMATCHERROR = 27, + STLOCTYPEMISMATCHERROR = 28, + STLOCUNSAFETODESTROYERROR = 29, + RETUNSAFETODESTROYERROR = 30, + RETTYPEMISMATCHERROR = 31, + FREEZEREFTYPEMISMATCHERROR = 32, + FREEZEREFEXISTSMUTABLEBORROWERROR = 33, + BORROWFIELDTYPEMISMATCHERROR = 34, + BORROWFIELDBADFIELDERROR = 35, + BORROWFIELDEXISTSMUTABLEBORROWERROR = 36, + COPYLOCUNAVAILABLEERROR = 37, + COPYLOCRESOURCEERROR = 38, + COPYLOCEXISTSBORROWERROR = 39, + MOVELOCUNAVAILABLEERROR = 40, + MOVELOCEXISTSBORROWERROR = 41, + BORROWLOCREFERENCEERROR = 42, + BORROWLOCUNAVAILABLEERROR = 43, + BORROWLOCEXISTSBORROWERROR = 44, + CALLTYPEMISMATCHERROR = 45, + CALLBORROWEDMUTABLEREFERENCEERROR = 46, + PACKTYPEMISMATCHERROR = 47, + UNPACKTYPEMISMATCHERROR = 48, + READREFTYPEMISMATCHERROR = 49, + READREFRESOURCEERROR = 50, + READREFEXISTSMUTABLEBORROWERROR = 51, + WRITEREFTYPEMISMATCHERROR = 52, + WRITEREFRESOURCEERROR = 53, + WRITEREFEXISTSBORROWERROR = 54, + WRITEREFNOMUTABLEREFERENCEERROR = 55, + INTEGEROPTYPEMISMATCHERROR = 56, + BOOLEANOPTYPEMISMATCHERROR = 57, + EQUALITYOPTYPEMISMATCHERROR = 58, + EXISTSRESOURCETYPEMISMATCHERROR = 59, + EXISTSNORESOURCEERROR = 60, + BORROWGLOBALTYPEMISMATCHERROR = 61, + BORROWGLOBALNORESOURCEERROR = 62, + MOVEFROMTYPEMISMATCHERROR = 63, + MOVEFROMNORESOURCEERROR = 64, + MOVETOSENDERTYPEMISMATCHERROR = 65, + MOVETOSENDERNORESOURCEERROR = 66, + CREATEACCOUNTTYPEMISMATCHERROR = 67, + GLOBALREFERENCEERROR = 68, + MODULEADDRESSDOESNOTMATCHSENDER = 69, + NOMODULEHANDLES = 70, + MISSINGACQUIRESRESOURCEANNOTATIONERROR = 71, + EXTRANEOUSACQUIRESRESOURCEANNOTATIONERROR = 72, + DUPLICATEACQUIRESRESOURCEANNOTATIONERROR = 73, + INVALIDACQUIRESRESOURCEANNOTATIONERROR = 74, } export enum VMInvariantViolationError { UNKNOWNINVARIANTVIOLATIONERROR = 0, @@ -352,6 +359,7 @@ export enum VMInvariantViolationError { LOCALREFERENCEERROR = 7, STORAGEERROR = 8, INTERNALTYPEERROR = 9, + EVENTKEYMISMATCH = 10, } export enum BinaryError { UNKNOWNBINARYERROR = 0, @@ -383,4 +391,6 @@ export enum RuntimeStatus { VALUESERIALIZATIONERROR = 13, VALUEDESERIALIZATIONERROR = 14, DUPLICATEMODULENAME = 15, + EXECUTIONSTACKOVERFLOW = 16, + CALLSTACKOVERFLOW = 17, } diff --git a/lib/__generated__/vm_errors_pb.js b/lib/__generated__/vm_errors_pb.js index 2d42b01..d7a183a 100644 --- a/lib/__generated__/vm_errors_pb.js +++ b/lib/__generated__/vm_errors_pb.js @@ -1792,72 +1792,79 @@ proto.types.VMValidationStatusCode = { proto.types.VMVerificationErrorKind = { UNKNOWNVERIFICATIONERROR: 0, INDEXOUTOFBOUNDS: 1, - RANGEOUTOFBOUNDS: 2, - INVALIDSIGNATURETOKEN: 3, - INVALIDFIELDDEFREFERENCE: 4, - RECURSIVESTRUCTDEFINITION: 5, - INVALIDRESOURCEFIELD: 6, - INVALIDFALLTHROUGH: 7, - JOINFAILURE: 8, - NEGATIVESTACKSIZEWITHINBLOCK: 9, - UNBALANCEDSTACK: 10, - INVALIDMAINFUNCTIONSIGNATURE: 11, - DUPLICATEELEMENT: 12, - INVALIDMODULEHANDLE: 13, - UNIMPLEMENTEDHANDLE: 14, - INCONSISTENTFIELDS: 15, - UNUSEDFIELDS: 16, - LOOKUPFAILED: 17, - VISIBILITYMISMATCH: 18, - TYPERESOLUTIONFAILURE: 19, - TYPEMISMATCH: 20, - MISSINGDEPENDENCY: 21, - POPREFERENCEERROR: 22, - POPRESOURCEERROR: 23, - RELEASEREFTYPEMISMATCHERROR: 24, - BRTYPEMISMATCHERROR: 25, - ABORTTYPEMISMATCHERROR: 26, - STLOCTYPEMISMATCHERROR: 27, - STLOCUNSAFETODESTROYERROR: 28, - RETUNSAFETODESTROYERROR: 29, - RETTYPEMISMATCHERROR: 30, - FREEZEREFTYPEMISMATCHERROR: 31, - FREEZEREFEXISTSMUTABLEBORROWERROR: 32, - BORROWFIELDTYPEMISMATCHERROR: 33, - BORROWFIELDBADFIELDERROR: 34, - BORROWFIELDEXISTSMUTABLEBORROWERROR: 35, - COPYLOCUNAVAILABLEERROR: 36, - COPYLOCRESOURCEERROR: 37, - COPYLOCEXISTSBORROWERROR: 38, - MOVELOCUNAVAILABLEERROR: 39, - MOVELOCEXISTSBORROWERROR: 40, - BORROWLOCREFERENCEERROR: 41, - BORROWLOCUNAVAILABLEERROR: 42, - BORROWLOCEXISTSBORROWERROR: 43, - CALLTYPEMISMATCHERROR: 44, - CALLBORROWEDMUTABLEREFERENCEERROR: 45, - PACKTYPEMISMATCHERROR: 46, - UNPACKTYPEMISMATCHERROR: 47, - READREFTYPEMISMATCHERROR: 48, - READREFRESOURCEERROR: 49, - READREFEXISTSMUTABLEBORROWERROR: 50, - WRITEREFTYPEMISMATCHERROR: 51, - WRITEREFRESOURCEERROR: 52, - WRITEREFEXISTSBORROWERROR: 53, - WRITEREFNOMUTABLEREFERENCEERROR: 54, - INTEGEROPTYPEMISMATCHERROR: 55, - BOOLEANOPTYPEMISMATCHERROR: 56, - EQUALITYOPTYPEMISMATCHERROR: 57, - EXISTSRESOURCETYPEMISMATCHERROR: 58, - BORROWGLOBALTYPEMISMATCHERROR: 59, - BORROWGLOBALNORESOURCEERROR: 60, - MOVEFROMTYPEMISMATCHERROR: 61, - MOVEFROMNORESOURCEERROR: 62, - MOVETOSENDERTYPEMISMATCHERROR: 63, - MOVETOSENDERNORESOURCEERROR: 64, - CREATEACCOUNTTYPEMISMATCHERROR: 65, - MODULEADDRESSDOESNOTMATCHSENDER: 66, - NOMODULEHANDLES: 67 + CODEUNITINDEXOUTOFBOUNDS: 2, + RANGEOUTOFBOUNDS: 3, + INVALIDSIGNATURETOKEN: 4, + INVALIDFIELDDEFREFERENCE: 5, + RECURSIVESTRUCTDEFINITION: 6, + INVALIDRESOURCEFIELD: 7, + INVALIDFALLTHROUGH: 8, + JOINFAILURE: 9, + NEGATIVESTACKSIZEWITHINBLOCK: 10, + UNBALANCEDSTACK: 11, + INVALIDMAINFUNCTIONSIGNATURE: 12, + DUPLICATEELEMENT: 13, + INVALIDMODULEHANDLE: 14, + UNIMPLEMENTEDHANDLE: 15, + INCONSISTENTFIELDS: 16, + UNUSEDFIELDS: 17, + LOOKUPFAILED: 18, + VISIBILITYMISMATCH: 19, + TYPERESOLUTIONFAILURE: 20, + TYPEMISMATCH: 21, + MISSINGDEPENDENCY: 22, + POPREFERENCEERROR: 23, + POPRESOURCEERROR: 24, + RELEASEREFTYPEMISMATCHERROR: 25, + BRTYPEMISMATCHERROR: 26, + ABORTTYPEMISMATCHERROR: 27, + STLOCTYPEMISMATCHERROR: 28, + STLOCUNSAFETODESTROYERROR: 29, + RETUNSAFETODESTROYERROR: 30, + RETTYPEMISMATCHERROR: 31, + FREEZEREFTYPEMISMATCHERROR: 32, + FREEZEREFEXISTSMUTABLEBORROWERROR: 33, + BORROWFIELDTYPEMISMATCHERROR: 34, + BORROWFIELDBADFIELDERROR: 35, + BORROWFIELDEXISTSMUTABLEBORROWERROR: 36, + COPYLOCUNAVAILABLEERROR: 37, + COPYLOCRESOURCEERROR: 38, + COPYLOCEXISTSBORROWERROR: 39, + MOVELOCUNAVAILABLEERROR: 40, + MOVELOCEXISTSBORROWERROR: 41, + BORROWLOCREFERENCEERROR: 42, + BORROWLOCUNAVAILABLEERROR: 43, + BORROWLOCEXISTSBORROWERROR: 44, + CALLTYPEMISMATCHERROR: 45, + CALLBORROWEDMUTABLEREFERENCEERROR: 46, + PACKTYPEMISMATCHERROR: 47, + UNPACKTYPEMISMATCHERROR: 48, + READREFTYPEMISMATCHERROR: 49, + READREFRESOURCEERROR: 50, + READREFEXISTSMUTABLEBORROWERROR: 51, + WRITEREFTYPEMISMATCHERROR: 52, + WRITEREFRESOURCEERROR: 53, + WRITEREFEXISTSBORROWERROR: 54, + WRITEREFNOMUTABLEREFERENCEERROR: 55, + INTEGEROPTYPEMISMATCHERROR: 56, + BOOLEANOPTYPEMISMATCHERROR: 57, + EQUALITYOPTYPEMISMATCHERROR: 58, + EXISTSRESOURCETYPEMISMATCHERROR: 59, + EXISTSNORESOURCEERROR: 60, + BORROWGLOBALTYPEMISMATCHERROR: 61, + BORROWGLOBALNORESOURCEERROR: 62, + MOVEFROMTYPEMISMATCHERROR: 63, + MOVEFROMNORESOURCEERROR: 64, + MOVETOSENDERTYPEMISMATCHERROR: 65, + MOVETOSENDERNORESOURCEERROR: 66, + CREATEACCOUNTTYPEMISMATCHERROR: 67, + GLOBALREFERENCEERROR: 68, + MODULEADDRESSDOESNOTMATCHSENDER: 69, + NOMODULEHANDLES: 70, + MISSINGACQUIRESRESOURCEANNOTATIONERROR: 71, + EXTRANEOUSACQUIRESRESOURCEANNOTATIONERROR: 72, + DUPLICATEACQUIRESRESOURCEANNOTATIONERROR: 73, + INVALIDACQUIRESRESOURCEANNOTATIONERROR: 74 }; /** @@ -1873,7 +1880,8 @@ proto.types.VMInvariantViolationError = { LINKERERROR: 6, LOCALREFERENCEERROR: 7, STORAGEERROR: 8, - INTERNALTYPEERROR: 9 + INTERNALTYPEERROR: 9, + EVENTKEYMISMATCH: 10 }; /** @@ -1912,7 +1920,9 @@ proto.types.RuntimeStatus = { CANNOTWRITEEXISTINGRESOURCE: 12, VALUESERIALIZATIONERROR: 13, VALUEDESERIALIZATIONERROR: 14, - DUPLICATEMODULENAME: 15 + DUPLICATEMODULENAME: 15, + EXECUTIONSTACKOVERFLOW: 16, + CALLSTACKOVERFLOW: 17 }; goog.object.extend(exports, proto.types); diff --git a/lib/client/Decoder.ts b/lib/client/Decoder.ts index a1acf6e..d4185eb 100644 --- a/lib/client/Decoder.ts +++ b/lib/client/Decoder.ts @@ -97,20 +97,13 @@ export class ClientDecoder { if (signedTransactionWP.hasEvents()) { const events = signedTransactionWP.getEvents() as EventsList; eventsList = events.getEventsList().map(event => { - let address: AccountAddress | undefined; - let path: Uint8Array | undefined; - - if (event.hasAccessPath()) { - const accessPath = event.getAccessPath() as AccessPath; - address = new AccountAddress(accessPath.getAddress_asU8()); - path = accessPath.getPath_asU8(); - } + let key: Uint8Array | undefined; + key = event.getKey_asU8(); return new LibraTransactionEvent( event.getEventData_asU8(), new BigNumber(event.getSequenceNumber()), - address, - path, + key ); }); } diff --git a/lib/constants/ProgamBase64Codes.ts b/lib/constants/ProgamBase64Codes.ts index 221bcf0..a142ac7 100644 --- a/lib/constants/ProgamBase64Codes.ts +++ b/lib/constants/ProgamBase64Codes.ts @@ -1,4 +1,4 @@ export default { peerToPeerTxn: - 'TElCUkFWTQoBAAcBSgAAAAQAAAADTgAAAAYAAAAMVAAAAAYAAAANWgAAAAYAAAAFYAAAACkAAAAEiQAAACAAAAAHqQAAAA4AAAAAAAABAAIAAQMAAgACBAIAAwADAgQCBjxTRUxGPgxMaWJyYUFjY291bnQEbWFpbg9wYXlfZnJvbV9zZW5kZXIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgEEAAwADAERAQAC', + 'TElCUkFWTQoBAAcBSgAAAAQAAAADTgAAAAYAAAAMVAAAAAYAAAANWgAAAAYAAAAFYAAAACkAAAAEiQAAACAAAAAHqQAAAA8AAAAAAAABAAIAAQMAAgACBAIAAwADAgQCBjxTRUxGPgxMaWJyYUFjY291bnQEbWFpbg9wYXlfZnJvbV9zZW5kZXIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAIBBAAMAAwBEwEAAg==', }; diff --git a/lib/transaction/Transactions.ts b/lib/transaction/Transactions.ts index d753e9d..e7c804c 100644 --- a/lib/transaction/Transactions.ts +++ b/lib/transaction/Transactions.ts @@ -172,13 +172,11 @@ class LibraSignedTransactionProof {} export class LibraTransactionEvent { public readonly data: Uint8Array; // eventData public readonly sequenceNumber: BigNumber; - public readonly address?: AccountAddress; - public readonly path?: Uint8Array; + public readonly eventKey?: Uint8Array; - constructor(data: Uint8Array, sequenceNumber: BigNumber | string, address?: AccountAddress, path?: Uint8Array) { + constructor(data: Uint8Array, sequenceNumber: BigNumber | string, eventKey?: Uint8Array) { this.data = data; this.sequenceNumber = new BigNumber(sequenceNumber); - this.address = address; - this.path = path; + this.eventKey = eventKey; } } diff --git a/lib/wallet/Accounts.ts b/lib/wallet/Accounts.ts index eef37df..063522d 100644 --- a/lib/wallet/Accounts.ts +++ b/lib/wallet/Accounts.ts @@ -3,6 +3,7 @@ import { SHA3 } from 'sha3'; import { CursorBuffer } from '../common/CursorBuffer'; import Addresses from '../constants/Addresses'; import { KeyPair } from '../crypto/Eddsa'; +import { EventHandle } from './Events'; export type AccountStates = AccountState[]; @@ -20,8 +21,8 @@ export class AccountState { return new AccountState( new Uint8Array(Buffer.from(address, 'hex')), new BigNumber(0), - new BigNumber(0), - new BigNumber(0), + EventHandle.default(), + EventHandle.default(), new BigNumber(0), true ); @@ -35,31 +36,41 @@ export class AccountState { const balance = cursor.read64(); const delegatedWithdrawalCapability = cursor.readBool(); const receivedEventsCount = cursor.read64(); + const receivedEventsKeyLen = cursor.read32(); + const receivedEventsKey = cursor.readXBytes(receivedEventsKeyLen); const sentEventsCount = cursor.read64(); + const sentEventsKeyLen = cursor.read32(); + const sentEventsKey = cursor.readXBytes(sentEventsKeyLen); const sequenceNumber = cursor.read64(); - return new AccountState(authenticationKey, balance, receivedEventsCount, sentEventsCount, sequenceNumber, delegatedWithdrawalCapability); + return new AccountState( + authenticationKey, + balance, + new EventHandle(receivedEventsKey,receivedEventsCount), + new EventHandle(sentEventsKey,sentEventsCount), + sequenceNumber, + delegatedWithdrawalCapability); } public readonly authenticationKey: Uint8Array; public readonly balance: BigNumber; - public readonly receivedEventsCount: BigNumber; - public readonly sentEventsCount: BigNumber; + public readonly receivedEvents: EventHandle; + public readonly sentEvents: EventHandle; public readonly sequenceNumber: BigNumber; public readonly delegatedWithdrawalCapability: boolean; private constructor( authenticationKey: Uint8Array, balance: BigNumber, - receivedEventsCount: BigNumber, - sentEventsCount: BigNumber, + receivedEvents: EventHandle, + sentEvents: EventHandle, sequenceNumber: BigNumber, delegatedWithdrawalCapability: boolean, ) { this.balance = balance; this.sequenceNumber = sequenceNumber; this.authenticationKey = authenticationKey; - this.sentEventsCount = sentEventsCount; - this.receivedEventsCount = receivedEventsCount; + this.sentEvents = sentEvents; + this.receivedEvents = receivedEvents; this.delegatedWithdrawalCapability = delegatedWithdrawalCapability; } } diff --git a/lib/wallet/Events.ts b/lib/wallet/Events.ts new file mode 100644 index 0000000..acb9cb4 --- /dev/null +++ b/lib/wallet/Events.ts @@ -0,0 +1,21 @@ +import BigNumber from 'bignumber.js'; + +export class EventHandle { + public readonly key: Uint8Array; + public readonly count: BigNumber; + + public constructor( + key: Uint8Array, + count: BigNumber + ) { + this.key = key; + this.count = count; + } + + public static default(): EventHandle { + return new EventHandle( + new Uint8Array(), + new BigNumber(0)); + } + +} diff --git a/proto/events.proto b/proto/events.proto index a878d3c..8e296dc 100644 --- a/proto/events.proto +++ b/proto/events.proto @@ -14,7 +14,7 @@ import "proof.proto"; // An event emitted from a smart contract message Event { - AccessPath access_path = 1; + bytes key = 1; uint64 sequence_number = 2; bytes event_data = 3; } diff --git a/proto/proof.proto b/proto/proof.proto index 1037771..342ac21 100644 --- a/proto/proof.proto +++ b/proto/proof.proto @@ -51,6 +51,21 @@ message SparseMerkleProof { repeated bytes non_default_siblings = 3; } +message AccumulatorConsistencyProof { + // The root hashes of the frozen subtrees that form the small accumulator. + // Note that none of these hashes should be default hash. + repeated bytes frozen_subtree_roots = 1; + + // The total number of siblings. + uint32 num_siblings = 2; + + // The non-default siblings. Note that the entire list of siblings always + // start of zero or more non-default siblings, followed by zero of more + // default siblings. So given the total number of siblings and the non-default + // siblings we should be able to construct the entire sibling list. + repeated bytes non_default_siblings = 3; +} + // The complete proof used to authenticate a signed transaction. message SignedTransactionProof { AccumulatorProof ledger_info_to_transaction_info_proof = 1; diff --git a/proto/transaction.proto b/proto/transaction.proto index ac3c5f1..94077bc 100644 --- a/proto/transaction.proto +++ b/proto/transaction.proto @@ -24,6 +24,10 @@ message RawTransaction { // This bypasses the rules for regular transactions so will typically be // rejected. Only under special circumstances will it be accepted. WriteSet write_set = 4; + // The transaction script to execute. + Script script = 8; + // The MOVE Module to publish. + Module module = 9; } // Maximal total gas specified by wallet to spend for this transaction. uint64 max_gas_amount = 5; @@ -44,6 +48,12 @@ message Program { repeated bytes modules = 3; } +// The code for the transaction to execute +message Script { + bytes code = 1; + repeated TransactionArgument arguments = 2; +} + // An argument to the transaction if the transaction takes arguments message TransactionArgument { enum ArgType { @@ -56,6 +66,11 @@ message TransactionArgument { bytes data = 2; } +// A Move Module to publish +message Module { + bytes code = 1; +} + // A generic structure that represents signed RawTransaction message SignedTransaction { // The serialized Protobuf bytes for RawTransaction, for which the signature diff --git a/proto/vm_errors.proto b/proto/vm_errors.proto index 877bc17..4096939 100644 --- a/proto/vm_errors.proto +++ b/proto/vm_errors.proto @@ -102,74 +102,81 @@ enum VMVerificationErrorKind { // Likewise default to a unknown verification error UnknownVerificationError = 0; IndexOutOfBounds = 1; - RangeOutOfBounds = 2; - InvalidSignatureToken = 3; - InvalidFieldDefReference = 4; - RecursiveStructDefinition = 5; - InvalidResourceField = 6; - InvalidFallThrough = 7; - JoinFailure = 8; - NegativeStackSizeWithinBlock = 9; - UnbalancedStack = 10; - InvalidMainFunctionSignature = 11; - DuplicateElement = 12; - InvalidModuleHandle = 13; - UnimplementedHandle = 14; - InconsistentFields = 15; - UnusedFields = 16; - LookupFailed = 17; - VisibilityMismatch = 18; - TypeResolutionFailure = 19; - TypeMismatch = 20; - MissingDependency = 21; - PopReferenceError = 22; - PopResourceError = 23; - ReleaseRefTypeMismatchError = 24; - BrTypeMismatchError = 25; - AbortTypeMismatchError = 26; - StLocTypeMismatchError = 27; - StLocUnsafeToDestroyError = 28; - RetUnsafeToDestroyError = 29; - RetTypeMismatchError = 30; - FreezeRefTypeMismatchError = 31; - FreezeRefExistsMutableBorrowError = 32; - BorrowFieldTypeMismatchError = 33; - BorrowFieldBadFieldError = 34; - BorrowFieldExistsMutableBorrowError = 35; - CopyLocUnavailableError = 36; - CopyLocResourceError = 37; - CopyLocExistsBorrowError = 38; - MoveLocUnavailableError = 39; - MoveLocExistsBorrowError = 40; - BorrowLocReferenceError = 41; - BorrowLocUnavailableError = 42; - BorrowLocExistsBorrowError = 43; - CallTypeMismatchError = 44; - CallBorrowedMutableReferenceError = 45; - PackTypeMismatchError = 46; - UnpackTypeMismatchError = 47; - ReadRefTypeMismatchError = 48; - ReadRefResourceError = 49; - ReadRefExistsMutableBorrowError = 50; - WriteRefTypeMismatchError = 51; - WriteRefResourceError = 52; - WriteRefExistsBorrowError = 53; - WriteRefNoMutableReferenceError = 54; - IntegerOpTypeMismatchError = 55; - BooleanOpTypeMismatchError = 56; - EqualityOpTypeMismatchError = 57; - ExistsResourceTypeMismatchError = 58; - BorrowGlobalTypeMismatchError = 59; - BorrowGlobalNoResourceError = 60; - MoveFromTypeMismatchError = 61; - MoveFromNoResourceError = 62; - MoveToSenderTypeMismatchError = 63; - MoveToSenderNoResourceError = 64; - CreateAccountTypeMismatchError = 65; + CodeUnitIndexOutOfBounds = 2; + RangeOutOfBounds = 3; + InvalidSignatureToken = 4; + InvalidFieldDefReference = 5; + RecursiveStructDefinition = 6; + InvalidResourceField = 7; + InvalidFallThrough = 8; + JoinFailure = 9; + NegativeStackSizeWithinBlock = 10; + UnbalancedStack = 11; + InvalidMainFunctionSignature = 12; + DuplicateElement = 13; + InvalidModuleHandle = 14; + UnimplementedHandle = 15; + InconsistentFields = 16; + UnusedFields = 17; + LookupFailed = 18; + VisibilityMismatch = 19; + TypeResolutionFailure = 20; + TypeMismatch = 21; + MissingDependency = 22; + PopReferenceError = 23; + PopResourceError = 24; + ReleaseRefTypeMismatchError = 25; + BrTypeMismatchError = 26; + AbortTypeMismatchError = 27; + StLocTypeMismatchError = 28; + StLocUnsafeToDestroyError = 29; + RetUnsafeToDestroyError = 30; + RetTypeMismatchError = 31; + FreezeRefTypeMismatchError = 32; + FreezeRefExistsMutableBorrowError = 33; + BorrowFieldTypeMismatchError = 34; + BorrowFieldBadFieldError = 35; + BorrowFieldExistsMutableBorrowError = 36; + CopyLocUnavailableError = 37; + CopyLocResourceError = 38; + CopyLocExistsBorrowError = 39; + MoveLocUnavailableError = 40; + MoveLocExistsBorrowError = 41; + BorrowLocReferenceError = 42; + BorrowLocUnavailableError = 43; + BorrowLocExistsBorrowError = 44; + CallTypeMismatchError = 45; + CallBorrowedMutableReferenceError = 46; + PackTypeMismatchError = 47; + UnpackTypeMismatchError = 48; + ReadRefTypeMismatchError = 49; + ReadRefResourceError = 50; + ReadRefExistsMutableBorrowError = 51; + WriteRefTypeMismatchError = 52; + WriteRefResourceError = 53; + WriteRefExistsBorrowError = 54; + WriteRefNoMutableReferenceError = 55; + IntegerOpTypeMismatchError = 56; + BooleanOpTypeMismatchError = 57; + EqualityOpTypeMismatchError = 58; + ExistsResourceTypeMismatchError = 59; + ExistsNoResourceError = 60; + BorrowGlobalTypeMismatchError = 61; + BorrowGlobalNoResourceError = 62; + MoveFromTypeMismatchError = 63; + MoveFromNoResourceError = 64; + MoveToSenderTypeMismatchError = 65; + MoveToSenderNoResourceError = 66; + CreateAccountTypeMismatchError = 67; + GlobalReferenceError = 68; // The self address of a module the transaction is publishing is not the sender address - ModuleAddressDoesNotMatchSender = 66; + ModuleAddressDoesNotMatchSender = 69; // The module does not have any module handles. Each module or script must have at least one module handle. - NoModuleHandles = 67; + NoModuleHandles = 70; + MissingAcquiresResourceAnnotationError = 71; + ExtraneousAcquiresResourceAnnotationError = 72; + DuplicateAcquiresResourceAnnotationError = 73; + InvalidAcquiresResourceAnnotationError = 74; } // These are errors that the VM might raise if a violation of internal @@ -185,6 +192,7 @@ enum VMInvariantViolationError { LocalReferenceError = 7; StorageError = 8; InternalTypeError = 9; + EventKeyMismatch = 10; } // Errors that can arise from binary decoding (deserialization) @@ -231,6 +239,8 @@ enum RuntimeStatus { // The sender is trying to publish a module named `M`, but the sender's account already contains // a module with this name. DuplicateModuleName = 15; + ExecutionStackOverflow = 16; + CallStackOverflow = 17; } // user-defined abort error code number diff --git a/test/client.test.ts b/test/client.test.ts index 7fbae81..d90bb46 100644 --- a/test/client.test.ts +++ b/test/client.test.ts @@ -1,15 +1,31 @@ -import { LibraAdmissionControlStatus, LibraClient, LibraNetwork, LibraWallet } from '../lib'; +import { LibraAdmissionControlStatus, LibraClient, LibraNetwork, LibraWallet, Account } from '../lib'; import './utils'; +import { AccountAddress } from '../lib/wallet/Accounts'; describe('LibraClient', () => { - xit('should query account state and transfer', async () => { - // const client = new LibraClient({ + let client: LibraClient; + + beforeAll(() => { + // client = new LibraClient({ // transferProtocol: 'https', // host: 'ac-libra-testnet.kulap.io', // port: '443', // dataProtocol: 'grpc-web-text' // }) - const client = new LibraClient({ network: LibraNetwork.Testnet }); + client = new LibraClient({ network: LibraNetwork.Testnet }); + // client = new LibraClient({ port: '8000' }); + }) + + it('should use minter address and sanity test calling getAccountTransaction()', async () => { + const account1Address = AccountAddress.default().toHex(); + + // It should be safe to assume that the minter has done the 0 sequence + const trans = await client.getAccountTransaction(account1Address, 0); + expect(trans!.signedTransaction.transaction.sendersAddress.toString()).toEqual(account1Address); + + }, 5000); + + it('should query account state and transfer', async () => { const wallet = new LibraWallet({ mnemonic: 'lend arm arm addict trust release grid unlock exhibit surround deliver front link bean night dry tuna pledge expect net ankle process mammal great', @@ -29,10 +45,10 @@ describe('LibraClient', () => { const amountToTransfer = 1e6; // TEST MINITNG Amount - await client.mintWithFaucetService(account1Address, amountToTransfer); + await client.mintWithFaucetService(account1Address, amountToTransfer + 1e6); const newAccount1State = await client.getAccountState(account1Address); // ensure its balance is +xAmount - expect(newAccount1State.balance.toString(10)).toEqual(account1State.balance.plus(amountToTransfer).toString(10)); + // expect(newAccount1State.balance.toString(10)).toEqual(account1State.balance.plus(amountToTransfer).toString(10)); // TEST TRANSFER TRANSACTION OF yAmount account1State = await client.getAccountState(account1Address);