@waves/waves-transactions
Advanced tools
Comparing version 4.2.7 to 4.2.8
@@ -36,3 +36,3 @@ export { massTransfer } from './transactions/mass-transfer'; | ||
import * as validators from './validators'; | ||
import * as protoPerialize from './proto-serialize'; | ||
export { libs, seedUtils, nodeInteraction, validators, protoPerialize }; | ||
import * as protoSerialize from './proto-serialize'; | ||
export { libs, seedUtils, nodeInteraction, validators, protoSerialize }; |
@@ -24,3 +24,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.protoPerialize = exports.validators = exports.nodeInteraction = exports.seedUtils = exports.libs = void 0; | ||
exports.protoSerialize = exports.validators = exports.nodeInteraction = exports.seedUtils = exports.libs = void 0; | ||
var mass_transfer_1 = require("./transactions/mass-transfer"); | ||
@@ -97,4 +97,4 @@ Object.defineProperty(exports, "massTransfer", { enumerable: true, get: function () { return mass_transfer_1.massTransfer; } }); | ||
exports.validators = validators; | ||
const protoPerialize = __importStar(require("./proto-serialize")); | ||
exports.protoPerialize = protoPerialize; | ||
const protoSerialize = __importStar(require("./proto-serialize")); | ||
exports.protoSerialize = protoSerialize; | ||
//# sourceMappingURL=index.js.map |
@@ -248,3 +248,3 @@ import { DataTransactionEntry, GenesisTransaction, MassTransferItem, PaymentTransaction, SignedTransaction, Transaction, TRANSACTION_TYPE, TransactionType } from '@waves/ts-types/src'; | ||
args?: Array<InvokeScriptCallArgument<LONG>>; | ||
}; | ||
} | null; | ||
payment?: { | ||
@@ -251,0 +251,0 @@ assetId?: string | null; |
@@ -63,3 +63,2 @@ "use strict"; | ||
const dataEntriesWithTypes = ((_a = paramsOrTx.data) !== null && _a !== void 0 ? _a : []).map((x) => { | ||
console.log(x); | ||
if (x.value == null) | ||
@@ -66,0 +65,0 @@ return x; |
@@ -21,3 +21,3 @@ "use strict"; | ||
dApp: paramsOrTx.dApp, | ||
call: paramsOrTx.call && Object.assign({ args: [] }, paramsOrTx.call), | ||
call: callField(paramsOrTx), | ||
payment: mapPayment(paramsOrTx.payment), | ||
@@ -41,2 +41,5 @@ fee: generic_1.fee(paramsOrTx, 500000), | ||
: payments.map(pmt => (Object.assign(Object.assign({}, pmt), { assetId: pmt.assetId === 'WAVES' ? null : pmt.assetId }))); | ||
const callField = (paramsOrTx) => { | ||
return !!paramsOrTx.call ? Object.assign({ args: paramsOrTx.call.args || [] }, paramsOrTx.call) : null; | ||
}; | ||
//# sourceMappingURL=invoke-script.js.map |
{ | ||
"name": "@waves/waves-transactions", | ||
"version": "4.2.7", | ||
"version": "4.2.8", | ||
"description": "Build and sign(multi-sign) transactions for Waves blockchain.", | ||
@@ -75,4 +75,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@waves/marshall": "^0.14.0", | ||
"@waves/node-api-js": "^1.2.8", | ||
"@waves/marshall": "^0.15.0-beta.1", | ||
"@waves/node-api-js": "^1.2.10", | ||
"@waves/protobuf-serialization": "1.4.3", | ||
@@ -79,0 +79,0 @@ "@waves/ts-lib-crypto": "1.4.3", |
@@ -78,3 +78,3 @@ // This software is released under the MIT License. | ||
import * as validators from './validators' | ||
import * as protoPerialize from './proto-serialize' | ||
import * as protoSerialize from './proto-serialize' | ||
@@ -86,4 +86,4 @@ export { | ||
validators, | ||
protoPerialize | ||
protoSerialize | ||
} | ||
@@ -338,3 +338,3 @@ import * as wavesProto from '@waves/protobuf-serialization' | ||
dApp: recipientToProto(t.dApp), | ||
functionCall: binary.serializerFromSchema((schemas.invokeScriptSchemaV1 as any).schema[5][1])(t.call), //todo: export function call from marshall and use it directly | ||
functionCall: binary.serializerFromSchema((schemas.invokeScriptSchemaV1 as any).schema[5][1])(t.call), | ||
payments: t.payment == null ? null : t.payment.map(({amount, assetId}) => amountToProto(amount, assetId)), | ||
@@ -341,0 +341,0 @@ }) |
/** | ||
* @module index | ||
*/ | ||
import { base58Encode, blake2b, concat, signBytes, address } from '@waves/ts-lib-crypto' | ||
import { serializePrimitives } from '@waves/marshall' | ||
import {base58Encode, blake2b, concat, signBytes, address} from '@waves/ts-lib-crypto' | ||
import {serializePrimitives} from '@waves/marshall' | ||
const {LONG, BASE58_STRING} = serializePrimitives | ||
import { getSenderPublicKey, convertToPairs } from '../generic' | ||
import { IWavesAuthParams, IWavesAuth } from '../transactions' | ||
import { validate } from '../validators' | ||
import { TSeedTypes } from '../types' | ||
import {getSenderPublicKey, convertToPairs} from '../generic' | ||
import {IWavesAuthParams, IWavesAuth} from '../transactions' | ||
import {validate} from '../validators' | ||
import {TSeedTypes} from '../types' | ||
export const serializeWavesAuthData = (auth: {publicKey: string; timestamp: number}) => concat( | ||
export const serializeWavesAuthData = (auth: { publicKey: string; timestamp: number }) => concat( | ||
BASE58_STRING(auth.publicKey), | ||
@@ -17,24 +18,24 @@ LONG(auth.timestamp) | ||
export function wavesAuth(params: IWavesAuthParams, seed?: TSeedTypes, chainId?: string|number): IWavesAuth { | ||
const seedsAndIndexes = convertToPairs(seed) | ||
const publicKey = params.publicKey || getSenderPublicKey(seedsAndIndexes, {senderPublicKey: undefined}) | ||
const timestamp = params.timestamp || Date.now() | ||
validate.wavesAuth({ publicKey, timestamp }) | ||
const rx = { | ||
hash: '', | ||
signature: '', | ||
timestamp, | ||
publicKey, | ||
address: address({ publicKey }, chainId), | ||
} | ||
const bytes = serializeWavesAuthData(rx) | ||
rx.signature = seedsAndIndexes.map(([seed]) => signBytes(seed, bytes))[0] || '' | ||
rx.hash = base58Encode(blake2b(Uint8Array.from(bytes))) | ||
export function wavesAuth(params: IWavesAuthParams, seed?: TSeedTypes, chainId?: string | number): IWavesAuth { | ||
const seedsAndIndexes = convertToPairs(seed) | ||
const publicKey = params.publicKey || getSenderPublicKey(seedsAndIndexes, {senderPublicKey: undefined}) | ||
const timestamp = params.timestamp || Date.now() | ||
validate.wavesAuth({publicKey, timestamp}) | ||
return rx | ||
const rx = { | ||
hash: '', | ||
signature: '', | ||
timestamp, | ||
publicKey, | ||
address: address({publicKey}, chainId), | ||
} | ||
const bytes = serializeWavesAuthData(rx) | ||
rx.signature = seedsAndIndexes.map(([seed]) => signBytes(seed, bytes))[0] || '' | ||
rx.hash = base58Encode(blake2b(Uint8Array.from(bytes))) | ||
return rx | ||
} | ||
@@ -312,3 +312,3 @@ import { | ||
args?: Array<InvokeScriptCallArgument<LONG>> | ||
}, | ||
} | null, | ||
payment?: { | ||
@@ -315,0 +315,0 @@ assetId?: string | null |
@@ -5,9 +5,9 @@ /** | ||
import {IAliasParams, WithId, WithProofs, WithSender} from '../transactions' | ||
import { binary } from '@waves/marshall' | ||
import { base58Encode, blake2b, signBytes } from '@waves/ts-lib-crypto' | ||
import { txToProtoBytes } from '../proto-serialize' | ||
import {binary} from '@waves/marshall' | ||
import {base58Encode, blake2b, signBytes} from '@waves/ts-lib-crypto' | ||
import {txToProtoBytes} from '../proto-serialize' | ||
import {addProof, convertToPairs, fee, getSenderPublicKey, networkByte} from '../generic' | ||
import { TSeedTypes } from '../types' | ||
import { validate } from '../validators' | ||
import { DEFAULT_VERSIONS } from '../defaultVersions' | ||
import {TSeedTypes} from '../types' | ||
import {validate} from '../validators' | ||
import {DEFAULT_VERSIONS} from '../defaultVersions' | ||
import {AliasTransaction, TRANSACTION_TYPE} from '@waves/ts-types' | ||
@@ -19,30 +19,30 @@ | ||
export function alias(paramsOrTx: IAliasParams & WithSender | AliasTransaction, seed?: TSeedTypes): AliasTransaction & WithId & WithProofs | ||
export function alias(paramsOrTx: any, seed?: TSeedTypes): AliasTransaction & WithId & WithProofs{ | ||
const type = TRANSACTION_TYPE.ALIAS | ||
const version = paramsOrTx.version || DEFAULT_VERSIONS.ALIAS | ||
const seedsAndIndexes = convertToPairs(seed) | ||
const senderPublicKey = getSenderPublicKey(seedsAndIndexes, paramsOrTx) | ||
export function alias(paramsOrTx: any, seed?: TSeedTypes): AliasTransaction & WithId & WithProofs { | ||
const type = TRANSACTION_TYPE.ALIAS | ||
const version = paramsOrTx.version || DEFAULT_VERSIONS.ALIAS | ||
const seedsAndIndexes = convertToPairs(seed) | ||
const senderPublicKey = getSenderPublicKey(seedsAndIndexes, paramsOrTx) | ||
const tx: AliasTransaction & WithId & WithProofs = { | ||
type, | ||
version, | ||
senderPublicKey, | ||
alias: paramsOrTx.alias, | ||
fee: fee(paramsOrTx, 100000), | ||
timestamp: paramsOrTx.timestamp || Date.now(), | ||
chainId: networkByte(paramsOrTx.chainId, 87), | ||
proofs: paramsOrTx.proofs || [], | ||
id: '', | ||
} | ||
const tx: AliasTransaction & WithId & WithProofs = { | ||
type, | ||
version, | ||
senderPublicKey, | ||
alias: paramsOrTx.alias, | ||
fee: fee(paramsOrTx, 100000), | ||
timestamp: paramsOrTx.timestamp || Date.now(), | ||
chainId: networkByte(paramsOrTx.chainId, 87), | ||
proofs: paramsOrTx.proofs || [], | ||
id: '', | ||
} | ||
validate.alias(tx) | ||
validate.alias(tx) | ||
const bytes = version > 2 ? txToProtoBytes(tx) : binary.serializeTx(tx) | ||
const idBytes = version > 2 ? bytes : [bytes[0], ...bytes.slice(36, -16)] | ||
const bytes = version > 2 ? txToProtoBytes(tx) : binary.serializeTx(tx) | ||
const idBytes = version > 2 ? bytes : [bytes[0], ...bytes.slice(36, -16)] | ||
seedsAndIndexes.forEach(([s, i]) => addProof(tx, signBytes(s, bytes), i)) | ||
seedsAndIndexes.forEach(([s, i]) => addProof(tx, signBytes(s, bytes), i)) | ||
tx.id = base58Encode(blake2b(Uint8Array.from(idBytes))) | ||
tx.id = base58Encode(blake2b(Uint8Array.from(idBytes))) | ||
return tx | ||
return tx | ||
} |
@@ -62,3 +62,2 @@ /** | ||
const dataEntriesWithTypes = (paramsOrTx.data as any ?? []).map((x: DataTransactionEntry) => { | ||
console.log(x) | ||
if (x.value == null) return x | ||
@@ -65,0 +64,0 @@ if ((<any>x).type) { |
@@ -28,3 +28,3 @@ /** | ||
dApp: paramsOrTx.dApp, | ||
call: paramsOrTx.call && {args: [], ...paramsOrTx.call}, | ||
call: callField(paramsOrTx), | ||
payment: mapPayment(paramsOrTx.payment), | ||
@@ -52,1 +52,5 @@ fee: fee(paramsOrTx, 500000), | ||
: payments.map(pmt => ({...pmt, assetId: pmt.assetId === 'WAVES' ? null : pmt.assetId})) | ||
const callField = (paramsOrTx: any) => { | ||
return !!paramsOrTx.call ? {args: paramsOrTx.call.args || [], ...paramsOrTx.call} : null | ||
} |
@@ -1,2 +0,2 @@ | ||
import { base58Decode, base64Decode, keccak, blake2b, stringToBytes } from '@waves/ts-lib-crypto' | ||
import {base58Decode, base64Decode, keccak, blake2b, stringToBytes} from '@waves/ts-lib-crypto' | ||
@@ -60,19 +60,19 @@ | ||
export const orEq = (referencesList: Array<unknown>) => (value: unknown) => referencesList.some(isEq(value)); | ||
export const orEq = (referencesList: Array<unknown>) => (value: unknown) => referencesList.some(isEq(value)) | ||
export const isRequired = (required: boolean) => (value: unknown) => !required || value != null; | ||
export const isRequired = (required: boolean) => (value: unknown) => !required || value != null | ||
export const isString = (value: unknown) => typeof value === 'string' || value instanceof String; | ||
export const isString = (value: unknown) => typeof value === 'string' || value instanceof String | ||
export const isNumber = (value: unknown) => (typeof value === 'number' || value instanceof Number) && !isNaN(Number(value)); | ||
export const isNumber = (value: unknown) => (typeof value === 'number' || value instanceof Number) && !isNaN(Number(value)) | ||
export const isNumberLike = (value: unknown) => value != null && !isNaN(Number(value)) && !!(value || value === 0) | ||
export const isNaturalNumberLike = (value: unknown) => value != null && !isNaN(Number(value)) && Number(value) > 0; | ||
export const isNaturalNumberLike = (value: unknown) => value != null && !isNaN(Number(value)) && Number(value) > 0 | ||
export const isNaturalNumberOrZeroLike = (value: unknown) => value != null && !isNaN(Number(value)) && Number(value) >= 0; | ||
export const isNaturalNumberOrZeroLike = (value: unknown) => value != null && !isNaN(Number(value)) && Number(value) >= 0 | ||
export const isNaturalNumberOrNullLike = (value: unknown) => (!isNaN(Number(value)) && Number(value) > 0) || value === null; | ||
export const isNaturalNumberOrNullLike = (value: unknown) => (!isNaN(Number(value)) && Number(value) > 0) || value === null | ||
export const isBoolean = (value: unknown) => value != null && (typeof value === 'boolean' || value instanceof Boolean); | ||
export const isBoolean = (value: unknown) => value != null && (typeof value === 'boolean' || value instanceof Boolean) | ||
@@ -110,3 +110,3 @@ export const isByteArray = (value: unknown) => { | ||
try { | ||
value = (value as string).replace(/^base64:/,'') | ||
value = (value as string).replace(/^base64:/, '') | ||
base64Decode(value as string) | ||
@@ -186,5 +186,5 @@ } catch (e) { | ||
) | ||
); | ||
) | ||
export const isPublicKey = isHash; | ||
export const isPublicKey = isHash | ||
@@ -196,5 +196,5 @@ | ||
isHash | ||
); | ||
) | ||
export const isAssetId = isHash; | ||
export const isAssetId = isHash | ||
@@ -205,23 +205,22 @@ export const isAttachment = ifElse( | ||
ifElse( | ||
// if valid Data Pair | ||
validatePipe(isArray, (data: any[]) => data.every(isValidDataPair)), | ||
defaultValue(true), | ||
// else if valid base58 or bytearray | ||
pipe( | ||
ifElse( | ||
isBase58, | ||
base58Decode, | ||
nope | ||
), | ||
ifElse( | ||
isByteArray, | ||
pipe( | ||
prop('length'), | ||
lte(TX_DEFAULTS.MAX_ATTACHMENT) | ||
), | ||
defaultValue(false) | ||
// if valid Data Pair | ||
validatePipe(isArray, (data: any[]) => data.every(isValidDataPair)), | ||
defaultValue(true), | ||
// else if valid base58 or bytearray | ||
pipe( | ||
ifElse( | ||
isBase58, | ||
base58Decode, | ||
nope | ||
), | ||
ifElse( | ||
isByteArray, | ||
pipe( | ||
prop('length'), | ||
lte(TX_DEFAULTS.MAX_ATTACHMENT) | ||
), | ||
defaultValue(false) | ||
) | ||
) | ||
) | ||
) | ||
) | ||
@@ -248,5 +247,5 @@ | ||
export const isValidDeleteRequest = validatePipe( | ||
isRequired(true), | ||
pipe(prop('key'), validatePipe(isString, (key: string) => !!key)), | ||
({type, value}: any) => type ==null && value == null | ||
isRequired(true), | ||
pipe(prop('key'), validatePipe(isString, (key: string) => !!key)), | ||
({type, value}: any) => type == null && value == null | ||
) | ||
@@ -253,0 +252,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
999708
9266
+ Added@waves/marshall@0.15.0-beta.1(transitive)
- Removed@waves/marshall@0.14.0(transitive)
Updated@waves/node-api-js@^1.2.10