From b2f1305bffb39d3b97f4a3687d59748d28fafff7 Mon Sep 17 00:00:00 2001 From: "mavis.tan" Date: Thu, 22 Aug 2019 19:09:44 +0800 Subject: [PATCH 1/5] bring transfer test back due to broken mint service * related to isDefault check of senderAddress in encode transaction * this change should have been included in https://github.com/perfectmak/libra-core/commit/c5cce923cb3e076341cff5e1ac83069b29628d73 --- lib/transaction/Transactions.ts | 2 +- test/client.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/transaction/Transactions.ts b/lib/transaction/Transactions.ts index ca66373..01e2251 100644 --- a/lib/transaction/Transactions.ts +++ b/lib/transaction/Transactions.ts @@ -54,7 +54,7 @@ export class LibraTransaction { maxGasAmount: new BigNumber(1000000), }, `${Math.floor(new Date().getTime() / 1000) + 100}`, - new Uint8Array(Addresses.AddressLength), + new Uint8Array(Buffer.from(Addresses.MinterAddress, 'hex')), '-1', ); } diff --git a/test/client.test.ts b/test/client.test.ts index 331aa5a..6ee9bb1 100644 --- a/test/client.test.ts +++ b/test/client.test.ts @@ -2,7 +2,7 @@ import { LibraAdmissionControlStatus, LibraClient, LibraNetwork, LibraWallet } f import './utils'; describe('LibraClient', () => { - xit('should query account state and transfer', async () => { + it('should query account state and transfer', async () => { const client = new LibraClient({ network: LibraNetwork.Testnet }); const wallet = new LibraWallet({ mnemonic: From 8bc71a49f0235f9e436f8db6bfa41d5217902aaf Mon Sep 17 00:00:00 2001 From: "mavis.tan" Date: Fri, 23 Aug 2019 16:35:13 +0800 Subject: [PATCH 2/5] rename minter to association address to be consistent with below: https://github.com/libra/libra/blob/171a766095954ff6eecf7147a4847b3c3590cdae/types/src/account_config.rs#L49 --- lib/constants/Addresses.ts | 2 +- lib/transaction/Transactions.ts | 2 +- lib/wallet/Accounts.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/constants/Addresses.ts b/lib/constants/Addresses.ts index 9b26fb6..0115da1 100644 --- a/lib/constants/Addresses.ts +++ b/lib/constants/Addresses.ts @@ -1,4 +1,4 @@ export default { AddressLength: 32, - MinterAddress: '000000000000000000000000000000000000000000000000000000000a550c18', + AssociationAddress: '000000000000000000000000000000000000000000000000000000000a550c18', }; diff --git a/lib/transaction/Transactions.ts b/lib/transaction/Transactions.ts index 01e2251..9a3624b 100644 --- a/lib/transaction/Transactions.ts +++ b/lib/transaction/Transactions.ts @@ -54,7 +54,7 @@ export class LibraTransaction { maxGasAmount: new BigNumber(1000000), }, `${Math.floor(new Date().getTime() / 1000) + 100}`, - new Uint8Array(Buffer.from(Addresses.MinterAddress, 'hex')), + new Uint8Array(Buffer.from(Addresses.AssociationAddress, 'hex')), '-1', ); } diff --git a/lib/wallet/Accounts.ts b/lib/wallet/Accounts.ts index fcb2231..eef37df 100644 --- a/lib/wallet/Accounts.ts +++ b/lib/wallet/Accounts.ts @@ -115,7 +115,7 @@ export class AccountAddress { } public static default(): AccountAddress { - return new AccountAddress(new Uint8Array(Buffer.from(Addresses.MinterAddress, 'hex'))); + return new AccountAddress(new Uint8Array(Buffer.from(Addresses.AssociationAddress, 'hex'))); } private readonly addressBytes: Uint8Array; From 5f78b1a43108d49027af4655f728b0ddf354b0a5 Mon Sep 17 00:00:00 2001 From: Gerry LaChac Date: Thu, 5 Sep 2019 12:12:25 -0400 Subject: [PATCH 3/5] Added EventHandle and changed parsing of the AccountState blob --- lib/wallet/Accounts.ts | 29 ++++++++++++++++++++--------- lib/wallet/Events.ts | 21 +++++++++++++++++++++ 2 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 lib/wallet/Events.ts diff --git a/lib/wallet/Accounts.ts b/lib/wallet/Accounts.ts index fcb2231..c9db6d3 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..0f8b28a --- /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)); + } + +} \ No newline at end of file From 608e0f9914d001c044e4cb96bcdf5a03f3cb14ea Mon Sep 17 00:00:00 2001 From: Gerry LaChac Date: Fri, 6 Sep 2019 14:11:37 -0400 Subject: [PATCH 4/5] Updated proto files and changed LibraTransactionEvent class to match the protobuf definition change since address and path are no longer parameters --- lib/__generated__/events_pb.d.ts | 11 +- lib/__generated__/events_pb.js | 57 +-- lib/__generated__/proof_pb.d.ts | 37 ++ lib/__generated__/proof_pb.js | 280 +++++++++++++++ lib/__generated__/transaction_pb.d.ts | 70 ++++ lib/__generated__/transaction_pb.js | 481 +++++++++++++++++++++++++- lib/__generated__/vm_errors_pb.d.ts | 175 +++++----- lib/__generated__/vm_errors_pb.js | 245 ++++++------- lib/client/Decoder.ts | 12 +- lib/transaction/Transactions.ts | 8 +- proto/events.proto | 2 +- proto/proof.proto | 15 + proto/transaction.proto | 15 + proto/vm_errors.proto | 151 ++++---- test/client.test.ts | 15 +- 15 files changed, 1256 insertions(+), 318 deletions(-) diff --git a/lib/__generated__/events_pb.d.ts b/lib/__generated__/events_pb.d.ts index f751348..7b775cc 100644 --- a/lib/__generated__/events_pb.d.ts +++ b/lib/__generated__/events_pb.d.ts @@ -8,11 +8,10 @@ import * as access_path_pb from "./access_path_pb"; import * as proof_pb from "./proof_pb"; export class Event extends jspb.Message { - - hasAccessPath(): boolean; - clearAccessPath(): void; - getAccessPath(): access_path_pb.AccessPath | undefined; - setAccessPath(value?: access_path_pb.AccessPath): void; + getKey(): Uint8Array | string; + getKey_asU8(): Uint8Array; + getKey_asB64(): string; + setKey(value: Uint8Array | string): void; getSequenceNumber(): string; setSequenceNumber(value: string): void; @@ -35,7 +34,7 @@ export class Event extends jspb.Message { export namespace Event { export type AsObject = { - accessPath?: access_path_pb.AccessPath.AsObject, + key: Uint8Array | string, sequenceNumber: string, eventData: Uint8Array | string, } diff --git a/lib/__generated__/events_pb.js b/lib/__generated__/events_pb.js index 31aa23a..5046291 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 {string} */ (reader.readUint64String()); @@ -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 48b3f12..53b02cd 100644 --- a/lib/__generated__/proof_pb.d.ts +++ b/lib/__generated__/proof_pb.d.ts @@ -72,6 +72,43 @@ export namespace SparseMerkleProof { } } +export class AccumulatorConsistencyProof extends jspb.Message { + clearFrozenSubtreeRootsList(): void; + getFrozenSubtreeRootsList(): Array; + getFrozenSubtreeRootsList_asU8(): Array; + getFrozenSubtreeRootsList_asB64(): Array; + setFrozenSubtreeRootsList(value: Array): void; + addFrozenSubtreeRoots(value: Uint8Array | string, index?: number): Uint8Array | string; + + getNumSiblings(): number; + setNumSiblings(value: number): void; + + clearNonDefaultSiblingsList(): void; + getNonDefaultSiblingsList(): Array; + getNonDefaultSiblingsList_asU8(): Array; + getNonDefaultSiblingsList_asB64(): Array; + setNonDefaultSiblingsList(value: Array): void; + addNonDefaultSiblings(value: Uint8Array | string, index?: number): Uint8Array | string; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): AccumulatorConsistencyProof.AsObject; + static toObject(includeInstance: boolean, msg: AccumulatorConsistencyProof): AccumulatorConsistencyProof.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + 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 { hasLedgerInfoToTransactionInfoProof(): boolean; diff --git a/lib/__generated__/proof_pb.js b/lib/__generated__/proof_pb.js index 8611567..7dc1411 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 1321074..ee3aa04 100644 --- a/lib/__generated__/transaction_pb.d.ts +++ b/lib/__generated__/transaction_pb.d.ts @@ -31,6 +31,18 @@ export class RawTransaction extends jspb.Message { getWriteSet(): WriteSet | undefined; setWriteSet(value?: WriteSet): void; + + hasScript(): boolean; + clearScript(): void; + getScript(): Script | undefined; + setScript(value?: Script): void; + + + hasModule(): boolean; + clearModule(): void; + getModule(): Module | undefined; + setModule(value?: Module): void; + getMaxGasAmount(): string; setMaxGasAmount(value: string): void; @@ -59,6 +71,8 @@ export namespace RawTransaction { sequenceNumber: string, program?: Program.AsObject, writeSet?: WriteSet.AsObject, + script?: Script.AsObject, + module?: Module.AsObject, maxGasAmount: string, gasUnitPrice: string, expirationTime: string, @@ -71,6 +85,10 @@ export namespace RawTransaction { WRITE_SET = 4, + SCRIPT = 8, + + MODULE = 9, + } } @@ -112,6 +130,35 @@ export namespace Program { } } +export class Script extends jspb.Message { + getCode(): Uint8Array | string; + getCode_asU8(): Uint8Array; + getCode_asB64(): string; + setCode(value: Uint8Array | string): void; + + clearArgumentsList(): void; + getArgumentsList(): Array; + setArgumentsList(value: Array): void; + addArguments(value?: TransactionArgument, index?: number): TransactionArgument; + + + serializeBinary(): Uint8Array; + toObject(includeInstance?: boolean): Script.AsObject; + static toObject(includeInstance: boolean, msg: Script): Script.AsObject; + static extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + 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; @@ -147,6 +194,29 @@ 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 extensions: {[key: number]: jspb.ExtensionFieldInfo}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + 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 babd563..6e5a935 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 {string} */ (reader.readUint64String()); 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 (parseInt(f, 10) !== 0) { writer.writeUint64String( @@ -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 {string} @@ -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 92caf23..bd2ceb3 100644 --- a/lib/__generated__/vm_errors_pb.d.ts +++ b/lib/__generated__/vm_errors_pb.d.ts @@ -101,24 +101,24 @@ export namespace VMVerificationStatus { } -export class AssertionFailure extends jspb.Message { - getAssertionErrorCode(): string; - setAssertionErrorCode(value: string): void; +export class Aborted extends jspb.Message { + getAbortedErrorCode(): number; + setAbortedErrorCode(value: number): void; serializeBinary(): Uint8Array; - toObject(includeInstance?: boolean): AssertionFailure.AsObject; - static toObject(includeInstance: boolean, msg: AssertionFailure): AssertionFailure.AsObject; + toObject(includeInstance?: boolean): Aborted.AsObject; + static toObject(includeInstance: boolean, msg: Aborted): Aborted.AsObject; static extensions: {[key: number]: jspb.ExtensionFieldInfo}; static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; - static serializeBinaryToWriter(message: AssertionFailure, writer: jspb.BinaryWriter): void; - static deserializeBinary(bytes: Uint8Array): AssertionFailure; - static deserializeBinaryFromReader(message: AssertionFailure, reader: jspb.BinaryReader): AssertionFailure; + static serializeBinaryToWriter(message: Aborted, writer: jspb.BinaryWriter): void; + static deserializeBinary(bytes: Uint8Array): Aborted; + static deserializeBinaryFromReader(message: Aborted, reader: jspb.BinaryReader): Aborted; } -export namespace AssertionFailure { +export namespace Aborted { export type AsObject = { - assertionErrorCode: string, + abortedErrorCode: number, } } @@ -189,10 +189,10 @@ export class ExecutionStatus extends jspb.Message { setRuntimeStatus(value: RuntimeStatus): void; - hasAssertionFailure(): boolean; - clearAssertionFailure(): void; - getAssertionFailure(): AssertionFailure | undefined; - setAssertionFailure(value?: AssertionFailure): void; + hasAborted(): boolean; + clearAborted(): void; + getAborted(): Aborted | undefined; + setAborted(value?: Aborted): void; hasArithmeticError(): boolean; @@ -222,7 +222,7 @@ export class ExecutionStatus extends jspb.Message { export namespace ExecutionStatus { export type AsObject = { runtimeStatus: RuntimeStatus, - assertionFailure?: AssertionFailure.AsObject, + aborted?: Aborted.AsObject, arithmeticError?: ArithmeticError.AsObject, referenceError?: DynamicReferenceError.AsObject, } @@ -232,7 +232,7 @@ export namespace ExecutionStatus { RUNTIME_STATUS = 1, - ASSERTION_FAILURE = 2, + ABORTED = 2, ARITHMETIC_ERROR = 3, @@ -335,72 +335,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, - ASSERTTYPEMISMATCHERROR = 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 { @@ -413,6 +420,8 @@ export enum VMInvariantViolationError { LINKERERROR = 6, LOCALREFERENCEERROR = 7, STORAGEERROR = 8, + INTERNALTYPEERROR = 9, + EVENTKEYMISMATCH = 10, } export enum BinaryError { @@ -446,4 +455,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 f7a28c7..d7a183a 100644 --- a/lib/__generated__/vm_errors_pb.js +++ b/lib/__generated__/vm_errors_pb.js @@ -13,9 +13,9 @@ var global = Function('return this')(); var language_storage_pb = require('./language_storage_pb.js'); goog.object.extend(proto, language_storage_pb); +goog.exportSymbol('proto.types.Aborted', null, global); goog.exportSymbol('proto.types.ArithmeticError', null, global); goog.exportSymbol('proto.types.ArithmeticError.ArithmeticErrorType', null, global); -goog.exportSymbol('proto.types.AssertionFailure', null, global); goog.exportSymbol('proto.types.BinaryError', null, global); goog.exportSymbol('proto.types.DynamicReferenceError', null, global); goog.exportSymbol('proto.types.DynamicReferenceError.DynamicReferenceErrorType', null, global); @@ -653,12 +653,12 @@ proto.types.VMVerificationStatus.prototype.hasDependencyId = function() { * @extends {jspb.Message} * @constructor */ -proto.types.AssertionFailure = function(opt_data) { +proto.types.Aborted = function(opt_data) { jspb.Message.initialize(this, opt_data, 0, -1, null, null); }; -goog.inherits(proto.types.AssertionFailure, jspb.Message); +goog.inherits(proto.types.Aborted, jspb.Message); if (goog.DEBUG && !COMPILED) { - proto.types.AssertionFailure.displayName = 'proto.types.AssertionFailure'; + proto.types.Aborted.displayName = 'proto.types.Aborted'; } @@ -673,8 +673,8 @@ if (jspb.Message.GENERATE_TO_OBJECT) { * for transitional soy proto support: http://goto/soy-param-migration * @return {!Object} */ -proto.types.AssertionFailure.prototype.toObject = function(opt_includeInstance) { - return proto.types.AssertionFailure.toObject(opt_includeInstance, this); +proto.types.Aborted.prototype.toObject = function(opt_includeInstance) { + return proto.types.Aborted.toObject(opt_includeInstance, this); }; @@ -683,13 +683,13 @@ proto.types.AssertionFailure.prototype.toObject = function(opt_includeInstance) * @param {boolean|undefined} includeInstance Whether to include the JSPB * instance for transitional soy proto support: * http://goto/soy-param-migration - * @param {!proto.types.AssertionFailure} msg The msg instance to transform. + * @param {!proto.types.Aborted} msg The msg instance to transform. * @return {!Object} * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.types.AssertionFailure.toObject = function(includeInstance, msg) { +proto.types.Aborted.toObject = function(includeInstance, msg) { var f, obj = { - assertionErrorCode: jspb.Message.getFieldWithDefault(msg, 1, "0") + abortedErrorCode: jspb.Message.getFieldWithDefault(msg, 1, 0) }; if (includeInstance) { @@ -703,23 +703,23 @@ proto.types.AssertionFailure.toObject = function(includeInstance, msg) { /** * Deserializes binary data (in protobuf wire format). * @param {jspb.ByteSource} bytes The bytes to deserialize. - * @return {!proto.types.AssertionFailure} + * @return {!proto.types.Aborted} */ -proto.types.AssertionFailure.deserializeBinary = function(bytes) { +proto.types.Aborted.deserializeBinary = function(bytes) { var reader = new jspb.BinaryReader(bytes); - var msg = new proto.types.AssertionFailure; - return proto.types.AssertionFailure.deserializeBinaryFromReader(msg, reader); + var msg = new proto.types.Aborted; + return proto.types.Aborted.deserializeBinaryFromReader(msg, reader); }; /** * Deserializes binary data (in protobuf wire format) from the * given reader into the given message object. - * @param {!proto.types.AssertionFailure} msg The message object to deserialize into. + * @param {!proto.types.Aborted} msg The message object to deserialize into. * @param {!jspb.BinaryReader} reader The BinaryReader to use. - * @return {!proto.types.AssertionFailure} + * @return {!proto.types.Aborted} */ -proto.types.AssertionFailure.deserializeBinaryFromReader = function(msg, reader) { +proto.types.Aborted.deserializeBinaryFromReader = function(msg, reader) { while (reader.nextField()) { if (reader.isEndGroup()) { break; @@ -727,8 +727,8 @@ proto.types.AssertionFailure.deserializeBinaryFromReader = function(msg, reader) var field = reader.getFieldNumber(); switch (field) { case 1: - var value = /** @type {string} */ (reader.readUint64String()); - msg.setAssertionErrorCode(value); + var value = /** @type {number} */ (reader.readUint64()); + msg.setAbortedErrorCode(value); break; default: reader.skipField(); @@ -743,9 +743,9 @@ proto.types.AssertionFailure.deserializeBinaryFromReader = function(msg, reader) * Serializes the message to binary data (in protobuf wire format). * @return {!Uint8Array} */ -proto.types.AssertionFailure.prototype.serializeBinary = function() { +proto.types.Aborted.prototype.serializeBinary = function() { var writer = new jspb.BinaryWriter(); - proto.types.AssertionFailure.serializeBinaryToWriter(this, writer); + proto.types.Aborted.serializeBinaryToWriter(this, writer); return writer.getResultBuffer(); }; @@ -753,15 +753,15 @@ proto.types.AssertionFailure.prototype.serializeBinary = function() { /** * Serializes the given message to binary data (in protobuf wire * format), writing to the given BinaryWriter. - * @param {!proto.types.AssertionFailure} message + * @param {!proto.types.Aborted} message * @param {!jspb.BinaryWriter} writer * @suppress {unusedLocalVariables} f is only used for nested messages */ -proto.types.AssertionFailure.serializeBinaryToWriter = function(message, writer) { +proto.types.Aborted.serializeBinaryToWriter = function(message, writer) { var f = undefined; - f = message.getAssertionErrorCode(); - if (parseInt(f, 10) !== 0) { - writer.writeUint64String( + f = message.getAbortedErrorCode(); + if (f !== 0) { + writer.writeUint64( 1, f ); @@ -770,17 +770,17 @@ proto.types.AssertionFailure.serializeBinaryToWriter = function(message, writer) /** - * optional uint64 assertion_error_code = 1; - * @return {string} + * optional uint64 aborted_error_code = 1; + * @return {number} */ -proto.types.AssertionFailure.prototype.getAssertionErrorCode = function() { - return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "0")); +proto.types.Aborted.prototype.getAbortedErrorCode = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); }; -/** @param {string} value */ -proto.types.AssertionFailure.prototype.setAssertionErrorCode = function(value) { - jspb.Message.setProto3StringIntField(this, 1, value); +/** @param {number} value */ +proto.types.Aborted.prototype.setAbortedErrorCode = function(value) { + jspb.Message.setProto3IntField(this, 1, value); }; @@ -1123,7 +1123,7 @@ proto.types.ExecutionStatus.oneofGroups_ = [[1,2,3,4]]; proto.types.ExecutionStatus.ExecutionStatusCase = { EXECUTION_STATUS_NOT_SET: 0, RUNTIME_STATUS: 1, - ASSERTION_FAILURE: 2, + ABORTED: 2, ARITHMETIC_ERROR: 3, REFERENCE_ERROR: 4 }; @@ -1165,7 +1165,7 @@ proto.types.ExecutionStatus.prototype.toObject = function(opt_includeInstance) { proto.types.ExecutionStatus.toObject = function(includeInstance, msg) { var f, obj = { runtimeStatus: jspb.Message.getFieldWithDefault(msg, 1, 0), - assertionFailure: (f = msg.getAssertionFailure()) && proto.types.AssertionFailure.toObject(includeInstance, f), + aborted: (f = msg.getAborted()) && proto.types.Aborted.toObject(includeInstance, f), arithmeticError: (f = msg.getArithmeticError()) && proto.types.ArithmeticError.toObject(includeInstance, f), referenceError: (f = msg.getReferenceError()) && proto.types.DynamicReferenceError.toObject(includeInstance, f) }; @@ -1209,9 +1209,9 @@ proto.types.ExecutionStatus.deserializeBinaryFromReader = function(msg, reader) msg.setRuntimeStatus(value); break; case 2: - var value = new proto.types.AssertionFailure; - reader.readMessage(value,proto.types.AssertionFailure.deserializeBinaryFromReader); - msg.setAssertionFailure(value); + var value = new proto.types.Aborted; + reader.readMessage(value,proto.types.Aborted.deserializeBinaryFromReader); + msg.setAborted(value); break; case 3: var value = new proto.types.ArithmeticError; @@ -1259,12 +1259,12 @@ proto.types.ExecutionStatus.serializeBinaryToWriter = function(message, writer) f ); } - f = message.getAssertionFailure(); + f = message.getAborted(); if (f != null) { writer.writeMessage( 2, f, - proto.types.AssertionFailure.serializeBinaryToWriter + proto.types.Aborted.serializeBinaryToWriter ); } f = message.getArithmeticError(); @@ -1316,23 +1316,23 @@ proto.types.ExecutionStatus.prototype.hasRuntimeStatus = function() { /** - * optional AssertionFailure assertion_failure = 2; - * @return {?proto.types.AssertionFailure} + * optional Aborted aborted = 2; + * @return {?proto.types.Aborted} */ -proto.types.ExecutionStatus.prototype.getAssertionFailure = function() { - return /** @type{?proto.types.AssertionFailure} */ ( - jspb.Message.getWrapperField(this, proto.types.AssertionFailure, 2)); +proto.types.ExecutionStatus.prototype.getAborted = function() { + return /** @type{?proto.types.Aborted} */ ( + jspb.Message.getWrapperField(this, proto.types.Aborted, 2)); }; -/** @param {?proto.types.AssertionFailure|undefined} value */ -proto.types.ExecutionStatus.prototype.setAssertionFailure = function(value) { +/** @param {?proto.types.Aborted|undefined} value */ +proto.types.ExecutionStatus.prototype.setAborted = function(value) { jspb.Message.setOneofWrapperField(this, 2, proto.types.ExecutionStatus.oneofGroups_[0], value); }; -proto.types.ExecutionStatus.prototype.clearAssertionFailure = function() { - this.setAssertionFailure(undefined); +proto.types.ExecutionStatus.prototype.clearAborted = function() { + this.setAborted(undefined); }; @@ -1340,7 +1340,7 @@ proto.types.ExecutionStatus.prototype.clearAssertionFailure = function() { * Returns whether this field is set. * @return {boolean} */ -proto.types.ExecutionStatus.prototype.hasAssertionFailure = function() { +proto.types.ExecutionStatus.prototype.hasAborted = function() { return jspb.Message.getField(this, 2) != null; }; @@ -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, - ASSERTTYPEMISMATCHERROR: 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 }; /** @@ -1872,7 +1879,9 @@ proto.types.VMInvariantViolationError = { PCOVERFLOW: 5, LINKERERROR: 6, LOCALREFERENCEERROR: 7, - STORAGEERROR: 8 + STORAGEERROR: 8, + INTERNALTYPEERROR: 9, + EVENTKEYMISMATCH: 10 }; /** @@ -1911,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 bbfa363..1a0a557 100644 --- a/lib/client/Decoder.ts +++ b/lib/client/Decoder.ts @@ -95,20 +95,14 @@ 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; + let key: Uint8Array | undefined; - if (event.hasAccessPath()) { - const accessPath = event.getAccessPath() as AccessPath; - address = new AccountAddress(accessPath.getAddress_asU8()); - path = accessPath.getPath_asU8(); - } + key = event.getKey_asU8(); return new LibraTransactionEvent( event.getEventData_asU8(), new BigNumber(event.getSequenceNumber()), - address, - path, + key, ); }); } diff --git a/lib/transaction/Transactions.ts b/lib/transaction/Transactions.ts index ca66373..968ed6c 100644 --- a/lib/transaction/Transactions.ts +++ b/lib/transaction/Transactions.ts @@ -165,13 +165,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/proto/events.proto b/proto/events.proto index 2acb321..b7cffbc 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 [jstype = JS_STRING]; bytes event_data = 3; } diff --git a/proto/proof.proto b/proto/proof.proto index 02784c8..8340331 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 ff088eb..6dc64f1 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 [jstype = JS_STRING]; @@ -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 da7e83e..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; - AssertTypeMismatchError = 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 @@ -184,6 +191,8 @@ enum VMInvariantViolationError { LinkerError = 6; LocalReferenceError = 7; StorageError = 8; + InternalTypeError = 9; + EventKeyMismatch = 10; } // Errors that can arise from binary decoding (deserialization) @@ -230,11 +239,13 @@ 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 assertion error code number -message AssertionFailure { - uint64 assertion_error_code = 1 [jstype = JS_STRING]; +// user-defined abort error code number +message Aborted { + uint64 aborted_error_code = 1; } message ArithmeticError { @@ -263,7 +274,7 @@ message DynamicReferenceError { message ExecutionStatus { oneof execution_status { RuntimeStatus runtime_status = 1; - AssertionFailure assertion_failure = 2; + Aborted aborted = 2; ArithmeticError arithmetic_error = 3; DynamicReferenceError reference_error = 4; } diff --git a/test/client.test.ts b/test/client.test.ts index 331aa5a..6895fbb 100644 --- a/test/client.test.ts +++ b/test/client.test.ts @@ -1,7 +1,20 @@ -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', () => { + it('should use minter address and sanity test calling getAccountTransaction()', async () => { + const client = new LibraClient({ network: LibraNetwork.Testnet }); + + 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); + + xit('should query account state and transfer', async () => { const client = new LibraClient({ network: LibraNetwork.Testnet }); const wallet = new LibraWallet({ From dd24cdf208860a2bd86fb67e898fecb618dacab6 Mon Sep 17 00:00:00 2001 From: Gerry LaChac Date: Mon, 9 Sep 2019 11:32:23 -0400 Subject: [PATCH 5/5] Updated peerToPeerTxn program code to fix tranferCoin --- lib/constants/ProgamBase64Codes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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==', };