@waves/waves-transactions
Advanced tools
Comparing version 3.8.1 to 3.9.0
@@ -1,2 +0,2 @@ | ||
import { ICancelOrder, IOrder, TRANSACTION_TYPE, TTx, TTxParams } from './transactions'; | ||
import { ICancelOrder, TRANSACTION_TYPE, TTx, TTxParams, TOrder } from './transactions'; | ||
import { TSeedTypes } from './types'; | ||
@@ -21,3 +21,3 @@ export interface WithTxType { | ||
*/ | ||
export declare function serialize(obj: TTx | IOrder): Uint8Array; | ||
export declare function serialize(obj: TTx | TOrder): Uint8Array; | ||
/** | ||
@@ -29,3 +29,3 @@ * Verifies signature of transaction or order | ||
*/ | ||
export declare function verify(obj: TTx | IOrder, proofN?: number, publicKey?: string): boolean; | ||
export declare function verify(obj: TTx | TOrder, proofN?: number, publicKey?: string): boolean; | ||
/** | ||
@@ -36,3 +36,3 @@ * Sends order to matcher | ||
*/ | ||
export declare function submitOrder(ord: IOrder, matcherUrl: string): Promise<any>; | ||
export declare function submitOrder(ord: TOrder, matcherUrl: string): Promise<any>; | ||
/** | ||
@@ -39,0 +39,0 @@ * Sends cancel order command to matcher. Since matcher api requires amountAsset and priceAsset in request url, |
@@ -1,2 +0,2 @@ | ||
import { WithProofs, IOrder, IBasicParams, WithSender } from './transactions'; | ||
import { WithProofs, IBasicParams, WithSender, TOrder } from './transactions'; | ||
import { TSeedTypes } from './types'; | ||
@@ -8,4 +8,4 @@ export declare const mapObj: <T, U, K extends string>(obj: Record<K, T>, f: (v: T) => U) => Record<K, U>; | ||
export declare function convertToPairs(seedObj?: TSeedTypes): [string, number | undefined][]; | ||
export declare const isOrder: (p: any) => p is IOrder<string | number>; | ||
export declare const isOrder: (p: any) => p is TOrder; | ||
export declare function networkByte(p: number | string | undefined, def: number): number; | ||
export declare function fee(params: IBasicParams, def: number): string | number; |
@@ -19,3 +19,3 @@ export { massTransfer } from './transactions/mass-transfer'; | ||
export { waitForTx, broadcast } from './nodeInteraction'; | ||
export { ITransaction, TTx, TTxParams, IAliasTransaction, IAliasParams, IIssueTransaction, IIssueParams, IReissueTransaction, IReissueParams, IBurnTransaction, IBurnParams, IExchangeTransaction, ILeaseTransaction, ILeaseParams, ICancelLeaseTransaction, ICancelLeaseParams, ITransferTransaction, ITransferParams, IMassTransferTransaction, IMassTransferParams, ISetAssetScriptTransaction, ISetScriptParams, ISponsorshipTransaction, ISponsorshipParams, IDataTransaction, IDataParams, ISetScriptTransaction, ISetAssetScriptParams, IInvokeScriptTransaction, IInvokeScriptParams, IOrder, IOrderParams, ICancelOrder, ICancelOrderParams, WithId, WithSender, WithProofs, } from './transactions'; | ||
export { ITransaction, TTx, TTxParams, IAliasTransaction, IAliasParams, IIssueTransaction, IIssueParams, IReissueTransaction, IReissueParams, IBurnTransaction, IBurnParams, IExchangeTransaction, ILeaseTransaction, ILeaseParams, ICancelLeaseTransaction, ICancelLeaseParams, ITransferTransaction, ITransferParams, IMassTransferTransaction, IMassTransferParams, IMassTransferItem, ISetAssetScriptTransaction, ISetScriptParams, ISponsorshipTransaction, ISponsorshipParams, IDataTransaction, IDataParams, IDataEntry, ISetScriptTransaction, ISetAssetScriptParams, IInvokeScriptTransaction, IInvokeScriptParams, IOrder, IOrderV1, IOrderV2, IOrderV3, TOrder, IOrderParams, ICancelOrder, ICancelOrderParams, WithId, WithSender, WithProofs, } from './transactions'; | ||
export { TSeedTypes, TOption } from './types'; | ||
@@ -22,0 +22,0 @@ import * as crypto from '@waves/waves-crypto'; |
@@ -1,2 +0,2 @@ | ||
import { DataEntry, TTx } from './transactions'; | ||
import { IDataEntry, TTx } from './transactions'; | ||
export declare type CancellablePromise<T> = Promise<T> & { | ||
@@ -43,3 +43,3 @@ cancel: () => void; | ||
*/ | ||
export declare function accountData(address: string, nodeUrl: string): Promise<Record<string, DataEntry>>; | ||
export declare function accountData(address: string, nodeUrl: string): Promise<Record<string, IDataEntry>>; | ||
/** | ||
@@ -46,0 +46,0 @@ * Get data from account dictionary by key |
@@ -1,2 +0,2 @@ | ||
import { IOrder, IOrderParams, WithId, WithSender } from '../transactions'; | ||
import { IOrderParams, TOrder, WithId, WithSender } from '../transactions'; | ||
import { TSeedTypes } from '../types'; | ||
@@ -48,3 +48,3 @@ /** | ||
*/ | ||
export declare function order(paramsOrOrder: IOrderParams, seed: TSeedTypes): IOrder & WithId; | ||
export declare function order(paramsOrOrder: IOrderParams & WithSender | IOrder, seed?: TSeedTypes): IOrder & WithId; | ||
export declare function order(paramsOrOrder: IOrderParams, seed: TSeedTypes): TOrder & WithId; | ||
export declare function order(paramsOrOrder: IOrderParams & WithSender | TOrder, seed?: TSeedTypes): TOrder & WithId; |
@@ -33,7 +33,10 @@ "use strict"; | ||
}; | ||
if (ord.version === 3) { | ||
ord.matcherFeeAssetId = paramsOrOrder.matcherFeeAssetId; | ||
} | ||
const bytes = marshall_1.binary.serializeOrder(ord); | ||
seedsAndIndexes.forEach(([s, i]) => generic_1.addProof(ord, waves_crypto_1.signBytes(bytes, s), i)); | ||
ord.id = waves_crypto_1.hashBytes(bytes); | ||
// for versionless order use signature instead of proofs | ||
if (ord.version === undefined) | ||
// OrderV1 uses signature instead of proofs | ||
if (ord.version === undefined || ord.version === 1) | ||
ord.signature = ord.proofs[0]; | ||
@@ -40,0 +43,0 @@ return ord; |
@@ -188,3 +188,3 @@ import { TypelessDataEntry } from './transactions/data'; | ||
} | ||
export interface DataEntry { | ||
export interface IDataEntry { | ||
key: string; | ||
@@ -213,3 +213,3 @@ type: DATA_FIELD_TYPE; | ||
type: TRANSACTION_TYPE.DATA; | ||
data: DataEntry[]; | ||
data: IDataEntry[]; | ||
} | ||
@@ -262,2 +262,13 @@ /** | ||
} | ||
export interface IOrderV1<LONG = string | number> extends IOrder<LONG> { | ||
version: 1 | undefined; | ||
} | ||
export interface IOrderV2<LONG = string | number> extends IOrder<LONG> { | ||
version: 2; | ||
} | ||
export interface IOrderV3<LONG = string | number> extends IOrder<LONG> { | ||
version: 3; | ||
matcherFeeAssetId?: string | null; | ||
} | ||
export declare type TOrder = IOrderV1 | IOrderV2 | IOrderV3; | ||
/** | ||
@@ -328,3 +339,3 @@ * CancelOrder object. When this object is sent to matcher, order with 'orderId' will be canceled | ||
export interface IDataParams<LONG = string | number> extends IBasicParams<LONG> { | ||
data: Array<DataEntry | TypelessDataEntry>; | ||
data: Array<IDataEntry | TypelessDataEntry>; | ||
} | ||
@@ -381,2 +392,3 @@ /** | ||
expiration?: number; | ||
matcherFeeAssetId?: string | null; | ||
} | ||
@@ -383,0 +395,0 @@ export interface ICancelOrderParams { |
{ | ||
"name": "@waves/waves-transactions", | ||
"version": "3.8.1", | ||
"version": "3.9.0", | ||
"description": "Build and sign(multi-sign) transactions for Waves blockchain.", | ||
@@ -68,3 +68,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@waves/marshall": "^0.7.6", | ||
"@waves/marshall": "^0.8.0", | ||
"@waves/waves-crypto": "^2.0.4", | ||
@@ -71,0 +71,0 @@ "axios": "^0.19.0" |
import axios from 'axios' | ||
import { binary, json, serializePrimitives } from '@waves/marshall' | ||
import { binary, json } from '@waves/marshall' | ||
import { verifySignature } from '@waves/waves-crypto' | ||
@@ -13,3 +13,2 @@ import { | ||
IMassTransferTransaction, | ||
IOrder, | ||
IReissueTransaction, | ||
@@ -23,3 +22,3 @@ ISetAssetScriptTransaction, | ||
TTxParams, | ||
IInvokeScriptTransaction | ||
IInvokeScriptTransaction, TOrder | ||
} from './transactions' | ||
@@ -79,3 +78,3 @@ import { TSeedTypes } from './types' | ||
*/ | ||
export function serialize(obj: TTx | IOrder): Uint8Array { | ||
export function serialize(obj: TTx | TOrder): Uint8Array { | ||
if (isOrder(obj)) return binary.serializeOrder(obj) | ||
@@ -91,3 +90,3 @@ return binary.serializeTx(obj) | ||
*/ | ||
export function verify(obj: TTx | IOrder, proofN = 0, publicKey?: string): boolean { | ||
export function verify(obj: TTx | TOrder, proofN = 0, publicKey?: string): boolean { | ||
publicKey = publicKey || obj.senderPublicKey | ||
@@ -105,3 +104,3 @@ const bytes = serialize(obj) | ||
*/ | ||
export function submitOrder(ord: IOrder, matcherUrl: string) { | ||
export function submitOrder(ord: TOrder, matcherUrl: string) { | ||
return axios.post('matcher/orderbook', json.stringifyOrder(ord), { | ||
@@ -108,0 +107,0 @@ baseURL: matcherUrl, |
import { | ||
WithProofs, | ||
TTxParams, | ||
IOrderParams, | ||
TTx, | ||
IOrder, | ||
IBasicParams, | ||
ICancelOrderParams, | ||
WithSender | ||
WithSender, TOrder | ||
} from './transactions' | ||
import { TSeedTypes } from './types' | ||
import { publicKey } from '@waves/waves-crypto' | ||
import axios from 'axios' | ||
@@ -59,3 +53,3 @@ export const mapObj = <T, U, K extends string>(obj: Record<K, T>, f: (v: T) => U): Record<K, U> => | ||
export const isOrder = (p: any): p is IOrder => (<IOrder>p).assetPair !== undefined | ||
export const isOrder = (p: any): p is TOrder => (<TOrder>p).assetPair !== undefined | ||
@@ -62,0 +56,0 @@ |
@@ -47,2 +47,3 @@ // Copyright (c) 2018 Yuriy Naydenov | ||
IMassTransferParams, | ||
IMassTransferItem, | ||
ISetAssetScriptTransaction, | ||
@@ -54,2 +55,3 @@ ISetScriptParams, | ||
IDataParams, | ||
IDataEntry, | ||
ISetScriptTransaction, | ||
@@ -60,2 +62,6 @@ ISetAssetScriptParams, | ||
IOrder, | ||
IOrderV1, | ||
IOrderV2, | ||
IOrderV3, | ||
TOrder, | ||
IOrderParams, | ||
@@ -62,0 +68,0 @@ ICancelOrder, |
@@ -1,2 +0,2 @@ | ||
import { DataEntry, TTx } from './transactions' | ||
import { IDataEntry, TTx } from './transactions' | ||
import axios from 'axios' | ||
@@ -166,4 +166,4 @@ import { json } from '@waves/marshall' | ||
*/ | ||
export async function accountData(address: string, nodeUrl: string): Promise<Record<string, DataEntry>> { | ||
const data: DataEntry[] = await axios.get(`addresses/data/${address}`, { baseURL: nodeUrl, validateStatus }) | ||
export async function accountData(address: string, nodeUrl: string): Promise<Record<string, IDataEntry>> { | ||
const data: IDataEntry[] = await axios.get(`addresses/data/${address}`, { baseURL: nodeUrl, validateStatus }) | ||
.then(process400) | ||
@@ -170,0 +170,0 @@ .then(x => x.data) |
import { signBytes, hashBytes } from '@waves/waves-crypto' | ||
import { addProof, getSenderPublicKey, convertToPairs, isOrder } from '../generic' | ||
import { IOrder, IOrderParams, WithId, WithSender } from '../transactions' | ||
import { IOrder, IOrderParams, TOrder, WithId, WithSender } from '../transactions' | ||
import { TSeedTypes } from '../types' | ||
@@ -27,4 +27,4 @@ import { binary } from '@waves/marshall' | ||
* } | ||
* | ||
* | ||
* | ||
* const signedOrder = order(params, seed) | ||
@@ -54,5 +54,5 @@ * ``` | ||
*/ | ||
export function order(paramsOrOrder: IOrderParams, seed: TSeedTypes): IOrder & WithId | ||
export function order(paramsOrOrder: IOrderParams & WithSender | IOrder, seed?: TSeedTypes): IOrder & WithId | ||
export function order(paramsOrOrder: any, seed?: TSeedTypes): IOrder & WithId { | ||
export function order(paramsOrOrder: IOrderParams, seed: TSeedTypes): TOrder & WithId | ||
export function order(paramsOrOrder: IOrderParams & WithSender | TOrder, seed?: TSeedTypes): TOrder & WithId | ||
export function order(paramsOrOrder: any, seed?: TSeedTypes): TOrder & WithId { | ||
@@ -71,3 +71,3 @@ const amountAsset = isOrder(paramsOrOrder) ? paramsOrOrder.assetPair.amountAsset : paramsOrOrder.amountAsset | ||
const version = paramsOrOrder.version === null ? undefined : paramsOrOrder.version || 2 | ||
const ord: IOrder & WithId = { | ||
const ord: TOrder & WithId = { | ||
orderType, | ||
@@ -90,9 +90,13 @@ version, | ||
if (ord.version === 3) { | ||
ord.matcherFeeAssetId = paramsOrOrder.matcherFeeAssetId | ||
} | ||
const bytes = binary.serializeOrder(ord) | ||
seedsAndIndexes.forEach(([s,i]) => addProof(ord, signBytes(bytes, s),i)) | ||
seedsAndIndexes.forEach(([s, i]) => addProof(ord, signBytes(bytes, s), i)) | ||
ord.id = hashBytes(bytes) | ||
// for versionless order use signature instead of proofs | ||
if (ord.version === undefined) (ord as any).signature = ord.proofs[0] | ||
// OrderV1 uses signature instead of proofs | ||
if (ord.version === undefined || ord.version === 1) (ord as any).signature = ord.proofs[0] | ||
@@ -99,0 +103,0 @@ return ord |
@@ -225,3 +225,3 @@ import { TypelessDataEntry } from './transactions/data' | ||
export interface DataEntry { | ||
export interface IDataEntry { | ||
key: string | ||
@@ -252,3 +252,3 @@ type: DATA_FIELD_TYPE | ||
type: TRANSACTION_TYPE.DATA | ||
data: DataEntry[] | ||
data: IDataEntry[] | ||
} | ||
@@ -305,2 +305,17 @@ | ||
export interface IOrderV1<LONG = string | number> extends IOrder<LONG > { | ||
version: 1 | undefined | ||
} | ||
export interface IOrderV2<LONG = string | number> extends IOrder<LONG > { | ||
version: 2 | ||
} | ||
export interface IOrderV3<LONG = string | number> extends IOrder<LONG > { | ||
version: 3 | ||
matcherFeeAssetId?: string | null | ||
} | ||
export type TOrder = IOrderV1 | IOrderV2 | IOrderV3 | ||
/** | ||
@@ -392,3 +407,3 @@ * CancelOrder object. When this object is sent to matcher, order with 'orderId' will be canceled | ||
export interface IDataParams<LONG = string | number> extends IBasicParams<LONG> { | ||
data: Array<DataEntry | TypelessDataEntry> | ||
data: Array<IDataEntry | TypelessDataEntry> | ||
} | ||
@@ -449,2 +464,3 @@ | ||
expiration?: number | ||
matcherFeeAssetId?: string | null | ||
} | ||
@@ -451,0 +467,0 @@ |
@@ -17,3 +17,3 @@ import {serializePrimitives} from '@waves/marshall' | ||
TRANSACTION_TYPE, | ||
DataEntry, | ||
IDataEntry, | ||
DATA_FIELD_TYPE, | ||
@@ -65,3 +65,3 @@ IDataParams, | ||
BASE58_STRING(senderPublicKey), | ||
COUNT(SHORT)((x: DataEntry | TypelessDataEntry) => concat(LEN(SHORT)(STRING)(x.key), [mapType(x.value)[1]], mapType(x.value)[2](x.value)))(paramsOrTx.data), | ||
COUNT(SHORT)((x: IDataEntry | TypelessDataEntry) => concat(LEN(SHORT)(STRING)(x.key), [mapType(x.value)[1]], mapType(x.value)[2](x.value)))(paramsOrTx.data), | ||
LONG(_timestamp) | ||
@@ -80,3 +80,3 @@ ) | ||
id: '', | ||
data: paramsOrTx.data && (paramsOrTx.data as any).map((x: DataEntry | TypelessDataEntry) => { | ||
data: paramsOrTx.data && (paramsOrTx.data as any).map((x: IDataEntry | TypelessDataEntry) => { | ||
if ((<any>x).type) return x | ||
@@ -83,0 +83,0 @@ else { |
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 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
738426
5881
+ Added@waves/marshall@0.8.1(transitive)
+ Added@waves/parse-json-bignumber@1.0.3(transitive)
- Removed@waves/marshall@0.7.6(transitive)
- Removedparse-json-bignumber@0.1.3(transitive)
Updated@waves/marshall@^0.8.0