diff --git a/packages/abstract-provider/package.json b/packages/abstract-provider/package.json index 487c376..08c2ff2 100644 --- a/packages/abstract-provider/package.json +++ b/packages/abstract-provider/package.json @@ -1,6 +1,6 @@ { "name": "@pokt-foundation/pocketjs-abstract-provider", - "version": "1.2.0", + "version": "2.1.0", "description": "Abstract provider for all other providers to inherit", "type": "module", "source": "src/index.ts", diff --git a/packages/isomorphic-provider/package.json b/packages/isomorphic-provider/package.json index 13f6a10..94e1bbd 100644 --- a/packages/isomorphic-provider/package.json +++ b/packages/isomorphic-provider/package.json @@ -1,6 +1,6 @@ { "name": "@pokt-foundation/pocketjs-isomorphic-provider", - "version": "1.2.0", + "version": "2.1.0", "description": "", "type": "module", "source": "src/index.ts", diff --git a/packages/provider/package.json b/packages/provider/package.json index 001ff90..e8ce9da 100644 --- a/packages/provider/package.json +++ b/packages/provider/package.json @@ -1,6 +1,6 @@ { "name": "@pokt-foundation/pocketjs-provider", - "version": "1.2.0", + "version": "2.1.0", "description": "", "type": "module", "source": "src/index.ts", diff --git a/packages/relayer/package.json b/packages/relayer/package.json index e0b8eb5..3d25cc1 100644 --- a/packages/relayer/package.json +++ b/packages/relayer/package.json @@ -1,6 +1,6 @@ { "name": "@pokt-foundation/pocketjs-relayer", - "version": "1.2.0", + "version": "2.1.0", "description": "Slim relayer client for the Pocket Network v0 Protocol", "type": "module", "source": "src/index.ts", diff --git a/packages/signer/package.json b/packages/signer/package.json index b8e62b5..3f2b7ad 100644 --- a/packages/signer/package.json +++ b/packages/signer/package.json @@ -1,6 +1,6 @@ { "name": "@pokt-foundation/pocketjs-signer", - "version": "1.2.0", + "version": "2.1.0", "description": "Signer for Pocket Network V0 accounts", "type": "module", "source": "src/index.ts", diff --git a/packages/transaction-builder/package.json b/packages/transaction-builder/package.json index 54dfc66..61499df 100644 --- a/packages/transaction-builder/package.json +++ b/packages/transaction-builder/package.json @@ -1,6 +1,6 @@ { "name": "@pokt-foundation/pocketjs-transaction-builder", - "version": "1.2.0", + "version": "2.1.0", "description": "Transaction manager and utilties for the Pocket Network protocol", "type": "module", "source": "src/index.ts", diff --git a/packages/transaction-builder/src/abstract-tx-builder.ts b/packages/transaction-builder/src/abstract-tx-builder.ts index a7e1e8d..d075f70 100644 --- a/packages/transaction-builder/src/abstract-tx-builder.ts +++ b/packages/transaction-builder/src/abstract-tx-builder.ts @@ -110,6 +110,7 @@ export abstract class AbstractBuilder { /** * Adds a NodeStake TxMsg for this transaction * @param {string} nodePubKey - Node Public key + * @param {string} outputAddress - The address that the coins will be sent to when the node is unstaked * @param {string[]} chains - Network identifier list to be serviced by this node * @param {string} amount - the amount to stake, must be greater than or equal to 1 POKT * @param {URL} serviceURL - Node service url @@ -117,11 +118,13 @@ export abstract class AbstractBuilder { */ abstract nodeStake({ nodePubKey, + outputAddress, chains, amount, serviceURL, }: { nodePubKey: string + outputAddress: string chains: string[] amount: string serviceURL: URL @@ -129,15 +132,28 @@ export abstract class AbstractBuilder { /** * Adds a MsgBeginUnstake TxMsg for this transaction - * @param {string} address - Address of the Node to unstake for + * @param {string} nodeAddress - Address of the Node to unstake for + * @param {string} signerAddress - The address that the coins will be sent to when the node is unstaked. Must be the same address entered when the node was staked * @returns {MsgProtoNodeUnstake} - The unsigned Node Unstake message. */ - abstract nodeUnstake(address: string): MsgProtoNodeUnstake + abstract nodeUnstake({ + nodeAddress, + signerAddress, + }: { + nodeAddress?: string + signerAddress?: string + }): MsgProtoNodeUnstake /** * Adds a MsgUnjail TxMsg for this transaction - * @param {string} address - Address of the Node to unjail + * @param {string} nodeAddress - Address of the Node to unjail * @returns {MsgProtoNodeUnjail} - The unsigned Node Unjail message. */ - abstract nodeUnjail(address: string): MsgProtoNodeUnjail + abstract nodeUnjail({ + nodeAddress, + signerAddress, + }: { + nodeAddress?: string + signerAddress?: string + }): MsgProtoNodeUnjail } diff --git a/packages/transaction-builder/src/models/msgs/index.ts b/packages/transaction-builder/src/models/msgs/index.ts index a698873..27c8870 100755 --- a/packages/transaction-builder/src/models/msgs/index.ts +++ b/packages/transaction-builder/src/models/msgs/index.ts @@ -1,5 +1,4 @@ export * from './msg-proto-app-stake' -export * from './msg-proto-app-unjail' export * from './msg-proto-app-unstake' export * from './msg-proto-node-stake' export * from './msg-proto-node-unjail' diff --git a/packages/transaction-builder/src/models/msgs/msg-proto-node-stake.ts b/packages/transaction-builder/src/models/msgs/msg-proto-node-stake.ts index bc9f2fb..503ac00 100755 --- a/packages/transaction-builder/src/models/msgs/msg-proto-node-stake.ts +++ b/packages/transaction-builder/src/models/msgs/msg-proto-node-stake.ts @@ -1,5 +1,5 @@ import { Buffer } from 'buffer' -import { MsgProtoNodeStake } from './../proto/generated/tx-signer' +import { MsgProtoNodeStake8 } from './../proto/generated/tx-signer' import { Any } from '../proto/generated/google/protobuf/any' import { TxMsg } from './tx-msg' @@ -9,11 +9,12 @@ const MINIMUM_STAKE_AMOUNT = 15000000000 * Model representing a MsgNodeStake to stake as an Node in the Pocket Network */ export class MsgProtoNodeStakeTx extends TxMsg { - public readonly KEY: string = '/x.nodes.MsgProtoStake' - public readonly AMINO_KEY: string = 'pos/MsgStake' + public readonly KEY: string = '/x.nodes.MsgProtoStake8' + public readonly AMINO_KEY: string = 'pos/8.0MsgStake' public readonly DEFAULT_PORT: string = '443' public readonly DEFAULT_PROTOCOL: string = 'https:' public readonly pubKey: Buffer + public readonly outputAddress: Buffer public readonly chains: string[] public readonly amount: string public readonly serviceURL: URL @@ -26,12 +27,14 @@ export class MsgProtoNodeStakeTx extends TxMsg { */ constructor( pubKey: string, + outputAddress: string, chains: string[], amount: string, serviceURL: URL ) { super() this.pubKey = Buffer.from(pubKey, 'hex') + this.outputAddress = Buffer.from(outputAddress, 'hex') this.chains = chains this.amount = amount this.serviceURL = serviceURL @@ -78,6 +81,7 @@ export class MsgProtoNodeStakeTx extends TxMsg { type: this.AMINO_KEY, value: { chains: this.chains, + output_address: this.outputAddress.toString('hex'), public_key: { type: 'crypto/ed25519_public_key', value: this.pubKey.toString('hex'), @@ -99,11 +103,12 @@ export class MsgProtoNodeStakeTx extends TxMsg { Chains: this.chains, value: this.amount, ServiceUrl: this.getParsedServiceURL(), + OutAddress: this.outputAddress, } return Any.fromJSON({ typeUrl: this.KEY, - value: Buffer.from(MsgProtoNodeStake.encode(data).finish()).toString( + value: Buffer.from(MsgProtoNodeStake8.encode(data).finish()).toString( 'base64' ), }) diff --git a/packages/transaction-builder/src/models/msgs/msg-proto-node-unjail.ts b/packages/transaction-builder/src/models/msgs/msg-proto-node-unjail.ts index 546f33d..5a42ac7 100755 --- a/packages/transaction-builder/src/models/msgs/msg-proto-node-unjail.ts +++ b/packages/transaction-builder/src/models/msgs/msg-proto-node-unjail.ts @@ -1,5 +1,5 @@ import { Buffer } from 'buffer' -import { MsgNodeUnjail } from '../proto/generated/tx-signer' +import { MsgNodeUnjail8 } from '../proto/generated/tx-signer' import { Any } from '../proto/generated/google/protobuf/any' import { TxMsg } from './tx-msg' @@ -7,16 +7,19 @@ import { TxMsg } from './tx-msg' * Model representing a MsgNodeUnjail to unjail as an Node in the Pocket Network */ export class MsgProtoNodeUnjail extends TxMsg { - public readonly KEY: string = '/x.nodes.MsgUnjail' - public readonly AMINO_KEY: string = 'pos/MsgUnjail' - public readonly address: string + public readonly KEY: string = '/x.nodes.MsgUnjail8' + public readonly AMINO_KEY: string = 'pos/8.0MsgUnjail' + public readonly nodeAddress: string + public readonly signerAddress: string /** - * @param {string} address - Address value + * @param {string} nodeAddress - Node address to be unjailed + * @param {string} signerAddress - Signer address (who triggered the unjail) */ - public constructor(address: string) { + public constructor(nodeAddress: string, signerAddress: string) { super() - this.address = address + this.nodeAddress = nodeAddress + this.signerAddress = signerAddress } /** * Converts an Msg Object to StdSignDoc @@ -27,7 +30,8 @@ export class MsgProtoNodeUnjail extends TxMsg { return { type: this.AMINO_KEY, value: { - address: this.address, + address: this.nodeAddress, + signer_address: this.signerAddress, }, } } @@ -38,11 +42,14 @@ export class MsgProtoNodeUnjail extends TxMsg { * @memberof MsgNodeUnjail */ public toStdTxMsgObj(): any { - const data = { ValidatorAddr: Buffer.from(this.address, 'hex') } + const data = { + ValidatorAddr: Buffer.from(this.nodeAddress, 'hex'), + Signer: Buffer.from(this.signerAddress, 'hex'), + } return Any.fromJSON({ typeUrl: this.KEY, - value: Buffer.from(MsgNodeUnjail.encode(data).finish()).toString( + value: Buffer.from(MsgNodeUnjail8.encode(data).finish()).toString( 'base64' ), }) diff --git a/packages/transaction-builder/src/models/msgs/msg-proto-node-unstake.ts b/packages/transaction-builder/src/models/msgs/msg-proto-node-unstake.ts index 24cc48d..128304f 100755 --- a/packages/transaction-builder/src/models/msgs/msg-proto-node-unstake.ts +++ b/packages/transaction-builder/src/models/msgs/msg-proto-node-unstake.ts @@ -1,21 +1,23 @@ import { Buffer } from 'buffer' -import { MsgBeginNodeUnstake } from './../proto/generated/tx-signer' +import { MsgBeginNodeUnstake8 } from './../proto/generated/tx-signer' import { Any } from '../proto/generated/google/protobuf/any' import { TxMsg } from './tx-msg' /** * Model representing a MsgNodeStake to unstake as an Node in the Pocket Network */ export class MsgProtoNodeUnstake extends TxMsg { - public readonly KEY: string = '/x.nodes.MsgBeginUnstake' - public readonly AMINO_KEY: string = 'pos/MsgBeginUnstake' + public readonly KEY: string = '/x.nodes.MsgBeginUnstake8' + public readonly AMINO_KEY: string = 'pos/8.0MsgBeginUnstake' public readonly nodeAddress: string + public readonly signerAddress: string /** * @param {string} nodeAddress - Node address */ - public constructor(nodeAddress: string) { + public constructor(nodeAddress: string, signerAddress: string) { super() this.nodeAddress = nodeAddress + this.signerAddress = signerAddress } /** * Converts an Msg Object to StdSignDoc @@ -26,6 +28,7 @@ export class MsgProtoNodeUnstake extends TxMsg { return { type: this.AMINO_KEY, value: { + signer_address: this.signerAddress, validator_address: this.nodeAddress, }, } @@ -37,11 +40,14 @@ export class MsgProtoNodeUnstake extends TxMsg { * @memberof MsgNodeUnstake */ public toStdTxMsgObj(): any { - const data = { Address: Buffer.from(this.nodeAddress, 'hex') } + const data = { + Address: Buffer.from(this.nodeAddress, 'hex'), + Signer: Buffer.from(this.signerAddress, 'hex'), + } return Any.fromJSON({ typeUrl: this.KEY, - value: Buffer.from(MsgBeginNodeUnstake.encode(data).finish()).toString( + value: Buffer.from(MsgBeginNodeUnstake8.encode(data).finish()).toString( 'base64' ), }) diff --git a/packages/transaction-builder/src/models/proto/generated/tx-signer.ts b/packages/transaction-builder/src/models/proto/generated/tx-signer.ts index 570fc78..94eb577 100755 --- a/packages/transaction-builder/src/models/proto/generated/tx-signer.ts +++ b/packages/transaction-builder/src/models/proto/generated/tx-signer.ts @@ -1,10 +1,11 @@ -/* eslint-disable */ +/* eslint-disable no-var */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable @typescript-eslint/ban-types */ +/* eslint-disable @typescript-eslint/ban-ts-comment */ +/* tslint:disable */ import Long from "long"; -import * as proto from "protobufjs/minimal.js"; - -// @ts-ignore -const { util, configure, Reader, Writer } = proto.default - +import _m0 from "protobufjs/minimal"; import { Any } from "./google/protobuf/any"; export const protobufPackage = "pocketjs"; @@ -60,21 +61,28 @@ export interface MsgUnjail { AppAddr: Uint8Array; } -export interface MsgProtoNodeStake { +export interface MsgProtoNodeStake8 { Publickey: Uint8Array; Chains: string[]; value: string; ServiceUrl: string; + OutAddress: Uint8Array; } -export interface MsgBeginNodeUnstake { +export interface MsgBeginNodeUnstake8 { Address: Uint8Array; + Signer: Uint8Array; } export interface MsgNodeUnjail { ValidatorAddr: Uint8Array; } +export interface MsgNodeUnjail8 { + ValidatorAddr: Uint8Array; + Signer: Uint8Array; +} + export interface MsgSend { FromAddress: Uint8Array; ToAddress: Uint8Array; @@ -84,29 +92,34 @@ export interface MsgSend { const baseProtoStdTx: object = { memo: "", entropy: 0 }; export const ProtoStdTx = { - // @ts-ignore - encode(message: ProtoStdTx, writer: Writer = Writer.create()): Writer { - if (message.msg !== undefined && message.msg !== undefined) { + encode( + message: ProtoStdTx, + writer: _m0.Writer = _m0.Writer.create() + ): _m0.Writer { + if (message.msg !== undefined) { Any.encode(message.msg, writer.uint32(10).fork()).ldelim(); } for (const v of message.fee) { Coin.encode(v!, writer.uint32(18).fork()).ldelim(); } - if (message.signature !== undefined && message.signature !== undefined) { + if (message.signature !== undefined) { ProtoStdSignature.encode( message.signature, writer.uint32(26).fork() ).ldelim(); } - writer.uint32(34).string(message.memo); - writer.uint32(40).int64(message.entropy); + if (message.memo !== "") { + writer.uint32(34).string(message.memo); + } + if (message.entropy !== 0) { + writer.uint32(40).int64(message.entropy); + } return writer; }, - // @ts-ignore - decode(input: Reader | Uint8Array, length?: number): ProtoStdTx { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; + decode(input: _m0.Reader | Uint8Array, length?: number): ProtoStdTx { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseProtoStdTx } as ProtoStdTx; message.fee = []; while (reader.pos < end) { @@ -166,6 +179,24 @@ export const ProtoStdTx = { return message; }, + toJSON(message: ProtoStdTx): unknown { + const obj: any = {}; + message.msg !== undefined && + (obj.msg = message.msg ? Any.toJSON(message.msg) : undefined); + if (message.fee) { + obj.fee = message.fee.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.fee = []; + } + message.signature !== undefined && + (obj.signature = message.signature + ? ProtoStdSignature.toJSON(message.signature) + : undefined); + message.memo !== undefined && (obj.memo = message.memo); + message.entropy !== undefined && (obj.entropy = message.entropy); + return obj; + }, + fromPartial(object: DeepPartial): ProtoStdTx { const message = { ...baseProtoStdTx } as ProtoStdTx; message.fee = []; @@ -196,41 +227,30 @@ export const ProtoStdTx = { } return message; }, - - toJSON(message: ProtoStdTx): unknown { - const obj: any = {}; - message.msg !== undefined && - (obj.msg = message.msg ? Any.toJSON(message.msg) : undefined); - if (message.fee) { - obj.fee = message.fee.map((e) => (e ? Coin.toJSON(e) : undefined)); - } else { - obj.fee = []; - } - message.signature !== undefined && - (obj.signature = message.signature - ? ProtoStdSignature.toJSON(message.signature) - : undefined); - message.memo !== undefined && (obj.memo = message.memo); - message.entropy !== undefined && (obj.entropy = message.entropy); - return obj; - }, }; const baseProtoStdSignature: object = {}; export const ProtoStdSignature = { - // @ts-ignore - encode(message: ProtoStdSignature, writer: Writer = Writer.create()): Writer { - writer.uint32(10).bytes(message.publicKey); - writer.uint32(18).bytes(message.Signature); + encode( + message: ProtoStdSignature, + writer: _m0.Writer = _m0.Writer.create() + ): _m0.Writer { + if (message.publicKey.length !== 0) { + writer.uint32(10).bytes(message.publicKey); + } + if (message.Signature.length !== 0) { + writer.uint32(18).bytes(message.Signature); + } return writer; }, - // @ts-ignore - decode(input: Reader | Uint8Array, length?: number): ProtoStdSignature { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; + decode(input: _m0.Reader | Uint8Array, length?: number): ProtoStdSignature { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseProtoStdSignature } as ProtoStdSignature; + message.publicKey = new Uint8Array(); + message.Signature = new Uint8Array(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -250,6 +270,8 @@ export const ProtoStdSignature = { fromJSON(object: any): ProtoStdSignature { const message = { ...baseProtoStdSignature } as ProtoStdSignature; + message.publicKey = new Uint8Array(); + message.Signature = new Uint8Array(); if (object.publicKey !== undefined && object.publicKey !== null) { message.publicKey = bytesFromBase64(object.publicKey); } @@ -259,6 +281,19 @@ export const ProtoStdSignature = { return message; }, + toJSON(message: ProtoStdSignature): unknown { + const obj: any = {}; + message.publicKey !== undefined && + (obj.publicKey = base64FromBytes( + message.publicKey !== undefined ? message.publicKey : new Uint8Array() + )); + message.Signature !== undefined && + (obj.Signature = base64FromBytes( + message.Signature !== undefined ? message.Signature : new Uint8Array() + )); + return obj; + }, + fromPartial(object: DeepPartial): ProtoStdSignature { const message = { ...baseProtoStdSignature } as ProtoStdSignature; if (object.publicKey !== undefined && object.publicKey !== null) { @@ -273,39 +308,39 @@ export const ProtoStdSignature = { } return message; }, - - toJSON(message: ProtoStdSignature): unknown { - const obj: any = {}; - message.publicKey !== undefined && - (obj.publicKey = base64FromBytes( - message.publicKey !== undefined ? message.publicKey : new Uint8Array() - )); - message.Signature !== undefined && - (obj.Signature = base64FromBytes( - message.Signature !== undefined ? message.Signature : new Uint8Array() - )); - return obj; - }, }; const baseStdSignDoc: object = { ChainID: "", memo: "", entropy: 0 }; export const StdSignDoc = { - // @ts-ignore - encode(message: StdSignDoc, writer: Writer = Writer.create()): Writer { - writer.uint32(10).string(message.ChainID); - writer.uint32(18).bytes(message.fee); - writer.uint32(26).string(message.memo); - writer.uint32(34).bytes(message.msg); - writer.uint32(40).int64(message.entropy); + encode( + message: StdSignDoc, + writer: _m0.Writer = _m0.Writer.create() + ): _m0.Writer { + if (message.ChainID !== "") { + writer.uint32(10).string(message.ChainID); + } + if (message.fee.length !== 0) { + writer.uint32(18).bytes(message.fee); + } + if (message.memo !== "") { + writer.uint32(26).string(message.memo); + } + if (message.msg.length !== 0) { + writer.uint32(34).bytes(message.msg); + } + if (message.entropy !== 0) { + writer.uint32(40).int64(message.entropy); + } return writer; }, - // @ts-ignore - decode(input: Reader | Uint8Array, length?: number): StdSignDoc { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; + decode(input: _m0.Reader | Uint8Array, length?: number): StdSignDoc { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseStdSignDoc } as StdSignDoc; + message.fee = new Uint8Array(); + message.msg = new Uint8Array(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -334,6 +369,8 @@ export const StdSignDoc = { fromJSON(object: any): StdSignDoc { const message = { ...baseStdSignDoc } as StdSignDoc; + message.fee = new Uint8Array(); + message.msg = new Uint8Array(); if (object.ChainID !== undefined && object.ChainID !== null) { message.ChainID = String(object.ChainID); } else { @@ -358,6 +395,22 @@ export const StdSignDoc = { return message; }, + toJSON(message: StdSignDoc): unknown { + const obj: any = {}; + message.ChainID !== undefined && (obj.ChainID = message.ChainID); + message.fee !== undefined && + (obj.fee = base64FromBytes( + message.fee !== undefined ? message.fee : new Uint8Array() + )); + message.memo !== undefined && (obj.memo = message.memo); + message.msg !== undefined && + (obj.msg = base64FromBytes( + message.msg !== undefined ? message.msg : new Uint8Array() + )); + message.entropy !== undefined && (obj.entropy = message.entropy); + return obj; + }, + fromPartial(object: DeepPartial): StdSignDoc { const message = { ...baseStdSignDoc } as StdSignDoc; if (object.ChainID !== undefined && object.ChainID !== null) { @@ -387,38 +440,24 @@ export const StdSignDoc = { } return message; }, - - toJSON(message: StdSignDoc): unknown { - const obj: any = {}; - message.ChainID !== undefined && (obj.ChainID = message.ChainID); - message.fee !== undefined && - (obj.fee = base64FromBytes( - message.fee !== undefined ? message.fee : new Uint8Array() - )); - message.memo !== undefined && (obj.memo = message.memo); - message.msg !== undefined && - (obj.msg = base64FromBytes( - message.msg !== undefined ? message.msg : new Uint8Array() - )); - message.entropy !== undefined && (obj.entropy = message.entropy); - return obj; - }, }; const baseCoin: object = { denom: "", amount: "" }; export const Coin = { - // @ts-ignore - encode(message: Coin, writer: Writer = Writer.create()): Writer { - writer.uint32(10).string(message.denom); - writer.uint32(18).string(message.amount); + encode(message: Coin, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } return writer; }, - // @ts-ignore - decode(input: Reader | Uint8Array, length?: number): Coin { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; + decode(input: _m0.Reader | Uint8Array, length?: number): Coin { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseCoin } as Coin; while (reader.pos < end) { const tag = reader.uint32(); @@ -452,6 +491,13 @@ export const Coin = { return message; }, + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + fromPartial(object: DeepPartial): Coin { const message = { ...baseCoin } as Coin; if (object.denom !== undefined && object.denom !== null) { @@ -466,29 +512,27 @@ export const Coin = { } return message; }, - - toJSON(message: Coin): unknown { - const obj: any = {}; - message.denom !== undefined && (obj.denom = message.denom); - message.amount !== undefined && (obj.amount = message.amount); - return obj; - }, }; const baseDecCoin: object = { denom: "", amount: "" }; export const DecCoin = { - // @ts-ignore - encode(message: DecCoin, writer: Writer = Writer.create()): Writer { - writer.uint32(10).string(message.denom); - writer.uint32(18).string(message.amount); + encode( + message: DecCoin, + writer: _m0.Writer = _m0.Writer.create() + ): _m0.Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } return writer; }, - // @ts-ignore - decode(input: Reader | Uint8Array, length?: number): DecCoin { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; + decode(input: _m0.Reader | Uint8Array, length?: number): DecCoin { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseDecCoin } as DecCoin; while (reader.pos < end) { const tag = reader.uint32(); @@ -522,6 +566,13 @@ export const DecCoin = { return message; }, + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + fromPartial(object: DeepPartial): DecCoin { const message = { ...baseDecCoin } as DecCoin; if (object.denom !== undefined && object.denom !== null) { @@ -536,34 +587,33 @@ export const DecCoin = { } return message; }, - - toJSON(message: DecCoin): unknown { - const obj: any = {}; - message.denom !== undefined && (obj.denom = message.denom); - message.amount !== undefined && (obj.amount = message.amount); - return obj; - }, }; const baseMsgProtoStake: object = { chains: "", value: "" }; export const MsgProtoStake = { - // @ts-ignore - encode(message: MsgProtoStake, writer: Writer = Writer.create()): Writer { - writer.uint32(10).bytes(message.pubKey); + encode( + message: MsgProtoStake, + writer: _m0.Writer = _m0.Writer.create() + ): _m0.Writer { + if (message.pubKey.length !== 0) { + writer.uint32(10).bytes(message.pubKey); + } for (const v of message.chains) { writer.uint32(18).string(v!); } - writer.uint32(26).string(message.value); + if (message.value !== "") { + writer.uint32(26).string(message.value); + } return writer; }, - // @ts-ignore - decode(input: Reader | Uint8Array, length?: number): MsgProtoStake { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgProtoStake { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseMsgProtoStake } as MsgProtoStake; message.chains = []; + message.pubKey = new Uint8Array(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -587,6 +637,7 @@ export const MsgProtoStake = { fromJSON(object: any): MsgProtoStake { const message = { ...baseMsgProtoStake } as MsgProtoStake; message.chains = []; + message.pubKey = new Uint8Array(); if (object.pubKey !== undefined && object.pubKey !== null) { message.pubKey = bytesFromBase64(object.pubKey); } @@ -603,6 +654,21 @@ export const MsgProtoStake = { return message; }, + toJSON(message: MsgProtoStake): unknown { + const obj: any = {}; + message.pubKey !== undefined && + (obj.pubKey = base64FromBytes( + message.pubKey !== undefined ? message.pubKey : new Uint8Array() + )); + if (message.chains) { + obj.chains = message.chains.map((e) => e); + } else { + obj.chains = []; + } + message.value !== undefined && (obj.value = message.value); + return obj; + }, + fromPartial(object: DeepPartial): MsgProtoStake { const message = { ...baseMsgProtoStake } as MsgProtoStake; message.chains = []; @@ -623,37 +689,26 @@ export const MsgProtoStake = { } return message; }, - - toJSON(message: MsgProtoStake): unknown { - const obj: any = {}; - message.pubKey !== undefined && - (obj.pubKey = base64FromBytes( - message.pubKey !== undefined ? message.pubKey : new Uint8Array() - )); - if (message.chains) { - obj.chains = message.chains.map((e) => e); - } else { - obj.chains = []; - } - message.value !== undefined && (obj.value = message.value); - return obj; - }, }; const baseMsgBeginUnstake: object = {}; export const MsgBeginUnstake = { - // @ts-ignore - encode(message: MsgBeginUnstake, writer: Writer = Writer.create()): Writer { - writer.uint32(10).bytes(message.Address); + encode( + message: MsgBeginUnstake, + writer: _m0.Writer = _m0.Writer.create() + ): _m0.Writer { + if (message.Address.length !== 0) { + writer.uint32(10).bytes(message.Address); + } return writer; }, - // @ts-ignore - decode(input: Reader | Uint8Array, length?: number): MsgBeginUnstake { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgBeginUnstake { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseMsgBeginUnstake } as MsgBeginUnstake; + message.Address = new Uint8Array(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -670,12 +725,22 @@ export const MsgBeginUnstake = { fromJSON(object: any): MsgBeginUnstake { const message = { ...baseMsgBeginUnstake } as MsgBeginUnstake; + message.Address = new Uint8Array(); if (object.Address !== undefined && object.Address !== null) { message.Address = bytesFromBase64(object.Address); } return message; }, + toJSON(message: MsgBeginUnstake): unknown { + const obj: any = {}; + message.Address !== undefined && + (obj.Address = base64FromBytes( + message.Address !== undefined ? message.Address : new Uint8Array() + )); + return obj; + }, + fromPartial(object: DeepPartial): MsgBeginUnstake { const message = { ...baseMsgBeginUnstake } as MsgBeginUnstake; if (object.Address !== undefined && object.Address !== null) { @@ -685,31 +750,26 @@ export const MsgBeginUnstake = { } return message; }, - - toJSON(message: MsgBeginUnstake): unknown { - const obj: any = {}; - message.Address !== undefined && - (obj.Address = base64FromBytes( - message.Address !== undefined ? message.Address : new Uint8Array() - )); - return obj; - }, }; const baseMsgUnjail: object = {}; export const MsgUnjail = { - // @ts-ignore - encode(message: MsgUnjail, writer: Writer = Writer.create()): Writer { - writer.uint32(10).bytes(message.AppAddr); + encode( + message: MsgUnjail, + writer: _m0.Writer = _m0.Writer.create() + ): _m0.Writer { + if (message.AppAddr.length !== 0) { + writer.uint32(10).bytes(message.AppAddr); + } return writer; }, - // @ts-ignore - decode(input: Reader | Uint8Array, length?: number): MsgUnjail { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgUnjail { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseMsgUnjail } as MsgUnjail; + message.AppAddr = new Uint8Array(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -726,12 +786,22 @@ export const MsgUnjail = { fromJSON(object: any): MsgUnjail { const message = { ...baseMsgUnjail } as MsgUnjail; + message.AppAddr = new Uint8Array(); if (object.AppAddr !== undefined && object.AppAddr !== null) { message.AppAddr = bytesFromBase64(object.AppAddr); } return message; }, + toJSON(message: MsgUnjail): unknown { + const obj: any = {}; + message.AppAddr !== undefined && + (obj.AppAddr = base64FromBytes( + message.AppAddr !== undefined ? message.AppAddr : new Uint8Array() + )); + return obj; + }, + fromPartial(object: DeepPartial): MsgUnjail { const message = { ...baseMsgUnjail } as MsgUnjail; if (object.AppAddr !== undefined && object.AppAddr !== null) { @@ -741,37 +811,44 @@ export const MsgUnjail = { } return message; }, - - toJSON(message: MsgUnjail): unknown { - const obj: any = {}; - message.AppAddr !== undefined && - (obj.AppAddr = base64FromBytes( - message.AppAddr !== undefined ? message.AppAddr : new Uint8Array() - )); - return obj; - }, }; -const baseMsgProtoNodeStake: object = { Chains: "", value: "", ServiceUrl: "" }; +const baseMsgProtoNodeStake8: object = { + Chains: "", + value: "", + ServiceUrl: "", +}; -export const MsgProtoNodeStake = { - // @ts-ignore - encode(message: MsgProtoNodeStake, writer: Writer = Writer.create()): Writer { - writer.uint32(10).bytes(message.Publickey); +export const MsgProtoNodeStake8 = { + encode( + message: MsgProtoNodeStake8, + writer: _m0.Writer = _m0.Writer.create() + ): _m0.Writer { + if (message.Publickey.length !== 0) { + writer.uint32(10).bytes(message.Publickey); + } for (const v of message.Chains) { writer.uint32(18).string(v!); } - writer.uint32(26).string(message.value); - writer.uint32(34).string(message.ServiceUrl); + if (message.value !== "") { + writer.uint32(26).string(message.value); + } + if (message.ServiceUrl !== "") { + writer.uint32(34).string(message.ServiceUrl); + } + if (message.OutAddress.length !== 0) { + writer.uint32(42).bytes(message.OutAddress); + } return writer; }, - // @ts-ignore - decode(input: Reader | Uint8Array, length?: number): MsgProtoNodeStake { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseMsgProtoNodeStake } as MsgProtoNodeStake; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgProtoNodeStake8 { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgProtoNodeStake8 } as MsgProtoNodeStake8; message.Chains = []; + message.Publickey = new Uint8Array(); + message.OutAddress = new Uint8Array(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -787,6 +864,9 @@ export const MsgProtoNodeStake = { case 4: message.ServiceUrl = reader.string(); break; + case 5: + message.OutAddress = reader.bytes(); + break; default: reader.skipType(tag & 7); break; @@ -795,9 +875,11 @@ export const MsgProtoNodeStake = { return message; }, - fromJSON(object: any): MsgProtoNodeStake { - const message = { ...baseMsgProtoNodeStake } as MsgProtoNodeStake; + fromJSON(object: any): MsgProtoNodeStake8 { + const message = { ...baseMsgProtoNodeStake8 } as MsgProtoNodeStake8; message.Chains = []; + message.Publickey = new Uint8Array(); + message.OutAddress = new Uint8Array(); if (object.Publickey !== undefined && object.Publickey !== null) { message.Publickey = bytesFromBase64(object.Publickey); } @@ -816,11 +898,34 @@ export const MsgProtoNodeStake = { } else { message.ServiceUrl = ""; } + if (object.OutAddress !== undefined && object.OutAddress !== null) { + message.OutAddress = bytesFromBase64(object.OutAddress); + } return message; }, - fromPartial(object: DeepPartial): MsgProtoNodeStake { - const message = { ...baseMsgProtoNodeStake } as MsgProtoNodeStake; + toJSON(message: MsgProtoNodeStake8): unknown { + const obj: any = {}; + message.Publickey !== undefined && + (obj.Publickey = base64FromBytes( + message.Publickey !== undefined ? message.Publickey : new Uint8Array() + )); + if (message.Chains) { + obj.Chains = message.Chains.map((e) => e); + } else { + obj.Chains = []; + } + message.value !== undefined && (obj.value = message.value); + message.ServiceUrl !== undefined && (obj.ServiceUrl = message.ServiceUrl); + message.OutAddress !== undefined && + (obj.OutAddress = base64FromBytes( + message.OutAddress !== undefined ? message.OutAddress : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): MsgProtoNodeStake8 { + const message = { ...baseMsgProtoNodeStake8 } as MsgProtoNodeStake8; message.Chains = []; if (object.Publickey !== undefined && object.Publickey !== null) { message.Publickey = object.Publickey; @@ -842,50 +947,49 @@ export const MsgProtoNodeStake = { } else { message.ServiceUrl = ""; } - return message; - }, - - toJSON(message: MsgProtoNodeStake): unknown { - const obj: any = {}; - message.Publickey !== undefined && - (obj.Publickey = base64FromBytes( - message.Publickey !== undefined ? message.Publickey : new Uint8Array() - )); - if (message.Chains) { - obj.Chains = message.Chains.map((e) => e); + if (object.OutAddress !== undefined && object.OutAddress !== null) { + message.OutAddress = object.OutAddress; } else { - obj.Chains = []; + message.OutAddress = new Uint8Array(); } - message.value !== undefined && (obj.value = message.value); - message.ServiceUrl !== undefined && (obj.ServiceUrl = message.ServiceUrl); - return obj; + return message; }, }; -const baseMsgBeginNodeUnstake: object = {}; +const baseMsgBeginNodeUnstake8: object = {}; -export const MsgBeginNodeUnstake = { +export const MsgBeginNodeUnstake8 = { encode( - message: MsgBeginNodeUnstake, - // @ts-ignore - writer: Writer = Writer.create() - // @ts-ignore - ): Writer { - writer.uint32(10).bytes(message.Address); + message: MsgBeginNodeUnstake8, + writer: _m0.Writer = _m0.Writer.create() + ): _m0.Writer { + if (message.Address.length !== 0) { + writer.uint32(10).bytes(message.Address); + } + if (message.Signer.length !== 0) { + writer.uint32(18).bytes(message.Signer); + } return writer; }, - // @ts-ignore - decode(input: Reader | Uint8Array, length?: number): MsgBeginNodeUnstake { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; - const message = { ...baseMsgBeginNodeUnstake } as MsgBeginNodeUnstake; + decode( + input: _m0.Reader | Uint8Array, + length?: number + ): MsgBeginNodeUnstake8 { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgBeginNodeUnstake8 } as MsgBeginNodeUnstake8; + message.Address = new Uint8Array(); + message.Signer = new Uint8Array(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.Address = reader.bytes(); break; + case 2: + message.Signer = reader.bytes(); + break; default: reader.skipType(tag & 7); break; @@ -894,48 +998,66 @@ export const MsgBeginNodeUnstake = { return message; }, - fromJSON(object: any): MsgBeginNodeUnstake { - const message = { ...baseMsgBeginNodeUnstake } as MsgBeginNodeUnstake; + fromJSON(object: any): MsgBeginNodeUnstake8 { + const message = { ...baseMsgBeginNodeUnstake8 } as MsgBeginNodeUnstake8; + message.Address = new Uint8Array(); + message.Signer = new Uint8Array(); if (object.Address !== undefined && object.Address !== null) { message.Address = bytesFromBase64(object.Address); } - return message; - }, - - fromPartial(object: DeepPartial): MsgBeginNodeUnstake { - const message = { ...baseMsgBeginNodeUnstake } as MsgBeginNodeUnstake; - if (object.Address !== undefined && object.Address !== null) { - message.Address = object.Address; - } else { - message.Address = new Uint8Array(); + if (object.Signer !== undefined && object.Signer !== null) { + message.Signer = bytesFromBase64(object.Signer); } return message; }, - toJSON(message: MsgBeginNodeUnstake): unknown { + toJSON(message: MsgBeginNodeUnstake8): unknown { const obj: any = {}; message.Address !== undefined && (obj.Address = base64FromBytes( message.Address !== undefined ? message.Address : new Uint8Array() )); + message.Signer !== undefined && + (obj.Signer = base64FromBytes( + message.Signer !== undefined ? message.Signer : new Uint8Array() + )); return obj; }, + + fromPartial(object: DeepPartial): MsgBeginNodeUnstake8 { + const message = { ...baseMsgBeginNodeUnstake8 } as MsgBeginNodeUnstake8; + if (object.Address !== undefined && object.Address !== null) { + message.Address = object.Address; + } else { + message.Address = new Uint8Array(); + } + if (object.Signer !== undefined && object.Signer !== null) { + message.Signer = object.Signer; + } else { + message.Signer = new Uint8Array(); + } + return message; + }, }; const baseMsgNodeUnjail: object = {}; export const MsgNodeUnjail = { - // @ts-ignore - encode(message: MsgNodeUnjail, writer: Writer = Writer.create()): Writer { - writer.uint32(10).bytes(message.ValidatorAddr); + encode( + message: MsgNodeUnjail, + writer: _m0.Writer = _m0.Writer.create() + ): _m0.Writer { + if (message.ValidatorAddr.length !== 0) { + writer.uint32(10).bytes(message.ValidatorAddr); + } return writer; }, - // @ts-ignore - decode(input: Reader | Uint8Array, length?: number): MsgNodeUnjail { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgNodeUnjail { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseMsgNodeUnjail } as MsgNodeUnjail; + message.ValidatorAddr = new Uint8Array(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -952,12 +1074,24 @@ export const MsgNodeUnjail = { fromJSON(object: any): MsgNodeUnjail { const message = { ...baseMsgNodeUnjail } as MsgNodeUnjail; + message.ValidatorAddr = new Uint8Array(); if (object.ValidatorAddr !== undefined && object.ValidatorAddr !== null) { message.ValidatorAddr = bytesFromBase64(object.ValidatorAddr); } return message; }, + toJSON(message: MsgNodeUnjail): unknown { + const obj: any = {}; + message.ValidatorAddr !== undefined && + (obj.ValidatorAddr = base64FromBytes( + message.ValidatorAddr !== undefined + ? message.ValidatorAddr + : new Uint8Array() + )); + return obj; + }, + fromPartial(object: DeepPartial): MsgNodeUnjail { const message = { ...baseMsgNodeUnjail } as MsgNodeUnjail; if (object.ValidatorAddr !== undefined && object.ValidatorAddr !== null) { @@ -967,8 +1101,61 @@ export const MsgNodeUnjail = { } return message; }, +}; - toJSON(message: MsgNodeUnjail): unknown { +const baseMsgNodeUnjail8: object = {}; + +export const MsgNodeUnjail8 = { + encode( + message: MsgNodeUnjail8, + writer: _m0.Writer = _m0.Writer.create() + ): _m0.Writer { + if (message.ValidatorAddr.length !== 0) { + writer.uint32(10).bytes(message.ValidatorAddr); + } + if (message.Signer.length !== 0) { + writer.uint32(18).bytes(message.Signer); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): MsgNodeUnjail8 { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgNodeUnjail8 } as MsgNodeUnjail8; + message.ValidatorAddr = new Uint8Array(); + message.Signer = new Uint8Array(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ValidatorAddr = reader.bytes(); + break; + case 2: + message.Signer = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgNodeUnjail8 { + const message = { ...baseMsgNodeUnjail8 } as MsgNodeUnjail8; + message.ValidatorAddr = new Uint8Array(); + message.Signer = new Uint8Array(); + if (object.ValidatorAddr !== undefined && object.ValidatorAddr !== null) { + message.ValidatorAddr = bytesFromBase64(object.ValidatorAddr); + } + if (object.Signer !== undefined && object.Signer !== null) { + message.Signer = bytesFromBase64(object.Signer); + } + return message; + }, + + toJSON(message: MsgNodeUnjail8): unknown { const obj: any = {}; message.ValidatorAddr !== undefined && (obj.ValidatorAddr = base64FromBytes( @@ -976,26 +1163,54 @@ export const MsgNodeUnjail = { ? message.ValidatorAddr : new Uint8Array() )); + message.Signer !== undefined && + (obj.Signer = base64FromBytes( + message.Signer !== undefined ? message.Signer : new Uint8Array() + )); return obj; }, + + fromPartial(object: DeepPartial): MsgNodeUnjail8 { + const message = { ...baseMsgNodeUnjail8 } as MsgNodeUnjail8; + if (object.ValidatorAddr !== undefined && object.ValidatorAddr !== null) { + message.ValidatorAddr = object.ValidatorAddr; + } else { + message.ValidatorAddr = new Uint8Array(); + } + if (object.Signer !== undefined && object.Signer !== null) { + message.Signer = object.Signer; + } else { + message.Signer = new Uint8Array(); + } + return message; + }, }; const baseMsgSend: object = { amount: "" }; export const MsgSend = { - // @ts-ignore - encode(message: MsgSend, writer: Writer = Writer.create()): Writer { - writer.uint32(10).bytes(message.FromAddress); - writer.uint32(18).bytes(message.ToAddress); - writer.uint32(26).string(message.amount); + encode( + message: MsgSend, + writer: _m0.Writer = _m0.Writer.create() + ): _m0.Writer { + if (message.FromAddress.length !== 0) { + writer.uint32(10).bytes(message.FromAddress); + } + if (message.ToAddress.length !== 0) { + writer.uint32(18).bytes(message.ToAddress); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } return writer; }, - // @ts-ignore - decode(input: Reader | Uint8Array, length?: number): MsgSend { - const reader = input instanceof Uint8Array ? new Reader(input) : input; - let end = length === undefined ? reader.len : reader.pos + length; + decode(input: _m0.Reader | Uint8Array, length?: number): MsgSend { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + const end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseMsgSend } as MsgSend; + message.FromAddress = new Uint8Array(); + message.ToAddress = new Uint8Array(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -1018,6 +1233,8 @@ export const MsgSend = { fromJSON(object: any): MsgSend { const message = { ...baseMsgSend } as MsgSend; + message.FromAddress = new Uint8Array(); + message.ToAddress = new Uint8Array(); if (object.FromAddress !== undefined && object.FromAddress !== null) { message.FromAddress = bytesFromBase64(object.FromAddress); } @@ -1032,6 +1249,22 @@ export const MsgSend = { return message; }, + toJSON(message: MsgSend): unknown { + const obj: any = {}; + message.FromAddress !== undefined && + (obj.FromAddress = base64FromBytes( + message.FromAddress !== undefined + ? message.FromAddress + : new Uint8Array() + )); + message.ToAddress !== undefined && + (obj.ToAddress = base64FromBytes( + message.ToAddress !== undefined ? message.ToAddress : new Uint8Array() + )); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + fromPartial(object: DeepPartial): MsgSend { const message = { ...baseMsgSend } as MsgSend; if (object.FromAddress !== undefined && object.FromAddress !== null) { @@ -1051,22 +1284,6 @@ export const MsgSend = { } return message; }, - - toJSON(message: MsgSend): unknown { - const obj: any = {}; - message.FromAddress !== undefined && - (obj.FromAddress = base64FromBytes( - message.FromAddress !== undefined - ? message.FromAddress - : new Uint8Array() - )); - message.ToAddress !== undefined && - (obj.ToAddress = base64FromBytes( - message.ToAddress !== undefined ? message.ToAddress : new Uint8Array() - )); - message.amount !== undefined && (obj.amount = message.amount); - return obj; - }, }; declare var self: any | undefined; @@ -1076,7 +1293,7 @@ var globalThis: any = (() => { if (typeof self !== "undefined") return self; if (typeof window !== "undefined") return window; if (typeof global !== "undefined") return global; - throw new Error("Unable to locate global object"); + throw "Unable to locate global object"; })(); const atob: (b64: string) => string = @@ -1102,7 +1319,14 @@ function base64FromBytes(arr: Uint8Array): string { return btoa(bin.join("")); } -type Builtin = Date | Function | Uint8Array | string | number | undefined; +type Builtin = + | Date + | Function + | Uint8Array + | string + | number + | boolean + | undefined; export type DeepPartial = T extends Builtin ? T : T extends Array @@ -1120,6 +1344,7 @@ function longToNumber(long: Long): number { return long.toNumber(); } - -util.Long = Long as any; -configure(); +if (_m0.util.Long !== Long) { + _m0.util.Long = Long as any; + _m0.configure(); +} diff --git a/packages/transaction-builder/src/models/proto/tx-signer.proto b/packages/transaction-builder/src/models/proto/tx-signer.proto index e8a7064..903ab14 100755 --- a/packages/transaction-builder/src/models/proto/tx-signer.proto +++ b/packages/transaction-builder/src/models/proto/tx-signer.proto @@ -4,29 +4,29 @@ package pocketjs; import "google/protobuf/any.proto"; message ProtoStdTx { - google.protobuf.Any msg = 1; - repeated Coin fee = 2; - ProtoStdSignature signature = 3; - string memo = 4; - int64 entropy = 5; + google.protobuf.Any msg = 1; + repeated Coin fee = 2; + ProtoStdSignature signature = 3; + string memo = 4; + int64 entropy = 5; } message ProtoStdSignature { - bytes publicKey = 1; - bytes Signature = 2; + bytes publicKey = 1; + bytes Signature = 2; } message StdSignDoc { - string ChainID = 1; - bytes fee = 2; - string memo = 3; - bytes msg = 4; - int64 entropy = 5; + string ChainID = 1; + bytes fee = 2; + string memo = 3; + bytes msg = 4; + int64 entropy = 5; } message Coin { - string denom = 1; - string amount = 2; + string denom = 1; + string amount = 2; } // DecCoin defines a token with a denomination and a decimal amount. @@ -34,43 +34,48 @@ message Coin { // NOTE: The amount field is an Dec which implements the custom method // signatures required by gogoproto. message DecCoin { - string denom = 1; - string amount = 2; + string denom = 1; + string amount = 2; } message MsgProtoStake { - bytes pub_key = 1; - repeated string chains = 2; - string value = 3; + bytes pub_key = 1; + repeated string chains = 2; + string value = 3; } message MsgBeginUnstake { - bytes Address = 1; + bytes Address = 1; } message MsgUnjail { - bytes AppAddr = 1; + bytes AppAddr = 1; } -message MsgProtoNodeStake { - bytes Publickey = 1; - repeated string Chains = 2; - string value = 3; - string ServiceUrl = 4; +message MsgProtoNodeStake8 { + bytes Publickey = 1; + repeated string Chains = 2; + string value = 3; + string ServiceUrl = 4; + bytes OutAddress = 5; } -message MsgBeginNodeUnstake { - bytes Address = 1; +message MsgBeginNodeUnstake8 { + bytes Address = 1; + bytes Signer = 2; } message MsgNodeUnjail { - bytes ValidatorAddr = 1; + bytes ValidatorAddr = 1; } -message MsgSend { - bytes FromAddress = 1; - bytes ToAddress = 2; - string amount = 3; +message MsgNodeUnjail8 { + bytes ValidatorAddr = 1; + bytes Signer = 2; } - +message MsgSend { + bytes FromAddress = 1; + bytes ToAddress = 2; + string amount = 3; +} diff --git a/packages/transaction-builder/src/tx-builder.ts b/packages/transaction-builder/src/tx-builder.ts index 83edf3d..d0433d6 100644 --- a/packages/transaction-builder/src/tx-builder.ts +++ b/packages/transaction-builder/src/tx-builder.ts @@ -206,40 +206,63 @@ export class TransactionBuilder implements AbstractBuilder { /** * Adds a NodeStake TxMsg for this transaction * @param {string} nodePubKey - Node Public key + * @param {string} outputAddress - The address that the coins will be sent to when the node is unstaked * @param {string[]} chains - Network identifier list to be serviced by this node * @param {string} amount - the amount to stake, must be greater than or equal to 1 POKT * @param {URL} serviceURL - Node service url * @returns {MsgProtoNodeStakeTx} - The unsigned Node Stake message. */ public nodeStake({ - nodePubKey, + nodePubKey = this.signer.getPublicKey(), + outputAddress = this.signer.getAddress(), chains, amount, serviceURL, }: { - nodePubKey: string + nodePubKey?: string + outputAddress?: string chains: string[] amount: string serviceURL: URL }): MsgProtoNodeStakeTx { - return new MsgProtoNodeStakeTx(nodePubKey, chains, amount, serviceURL) + return new MsgProtoNodeStakeTx( + nodePubKey, + outputAddress, + chains, + amount, + serviceURL + ) } /** * Adds a MsgBeginUnstake TxMsg for this transaction - * @param {string} address - Address of the Node to unstake for + * @param {string} nodeAddress - Address of the Node to unstake for + * @param {string} signerAddress - The address that the coins will be sent to when the node is unstaked. Must be the same address entered when the node was staked * @returns {MsgProtoNodeUnstake} - The unsigned Node Unstake message. */ - public nodeUnstake(address: string): MsgProtoNodeUnstake { - return new MsgProtoNodeUnstake(address) + public nodeUnstake({ + nodeAddress = this.signer.getAddress(), + signerAddress = this.signer.getAddress(), + }: { + nodeAddress?: string + signerAddress?: string + }): MsgProtoNodeUnstake { + return new MsgProtoNodeUnstake(nodeAddress, signerAddress) } /** * Adds a MsgUnjail TxMsg for this transaction - * @param {string} address - Address of the Node to unjail + * @param {string} nodeAddress - Address of the Node to unjail + * @param {string} signerAddress - The address of where the coins will be sent to when the node is unstaked (if it is ever). Necessary to unjail the node * @returns {MsgProtoNodeUnjail} - The unsigned Node Unjail message. */ - public nodeUnjail(address: string): MsgProtoNodeUnjail { - return new MsgProtoNodeUnjail(address) + public nodeUnjail({ + nodeAddress = this.signer.getAddress(), + signerAddress = this.signer.getAddress(), + }: { + nodeAddress?: string + signerAddress?: string + }): MsgProtoNodeUnjail { + return new MsgProtoNodeUnjail(nodeAddress, signerAddress) } } diff --git a/packages/transaction-builder/tests/transactions.test.ts b/packages/transaction-builder/tests/transactions.test.ts index d02144d..8b6f333 100644 --- a/packages/transaction-builder/tests/transactions.test.ts +++ b/packages/transaction-builder/tests/transactions.test.ts @@ -87,10 +87,10 @@ describe('TransactionBuilder Tests', () => { }) expect(nodeStakeMsg instanceof MsgProtoNodeStakeTx).toBe(true) - const nodeUnstakeMsg = transactionBuilder.nodeUnstake(signer.getAddress()) + const nodeUnstakeMsg = transactionBuilder.nodeUnstake({}) expect(nodeUnstakeMsg instanceof MsgProtoNodeUnstake).toBe(true) - const nodeUnjailMsg = transactionBuilder.nodeUnjail(signer.getAddress()) + const nodeUnjailMsg = transactionBuilder.nodeUnjail({}) expect(nodeUnjailMsg instanceof MsgProtoNodeUnjail).toBe(true) }) }) @@ -235,7 +235,7 @@ describe('TransactionBuilder Tests', () => { expect(rawTxRequest.address).toBe(signer.getAddress()) }) test('Creates a RawTxRequest for MsgProtoNodeUnstake', async () => { - const txMsg = transactionBuilder.nodeUnstake(signer.getAddress()) + const txMsg = transactionBuilder.nodeUnstake({}) const rawTxRequest = await transactionBuilder.createTransaction({ txMsg }) @@ -243,7 +243,7 @@ describe('TransactionBuilder Tests', () => { expect(rawTxRequest.address).toBe(signer.getAddress()) }) test('Creates a RawTxRequest for MsgProtoNodeUnjail', async () => { - const txMsg = transactionBuilder.nodeUnjail(signer.getAddress()) + const txMsg = transactionBuilder.nodeUnjail({}) const rawTxRequest = await transactionBuilder.createTransaction({ txMsg }) diff --git a/packages/types/package.json b/packages/types/package.json index dde6c4c..f9f56d0 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@pokt-foundation/pocketjs-types", - "version": "1.2.0", + "version": "2.1.0", "description": "PocketJS types", "type": "module", "source": "src/index.ts", diff --git a/packages/utils/package.json b/packages/utils/package.json index 05cd6c3..ef4bb54 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@pokt-foundation/pocketjs-utils", - "version": "1.2.0", + "version": "2.1.0", "description": "Utilities used across pocket-js", "type": "module", "source": "src/index.ts",