@waves/money-like-to-node
Advanced tools
Comparing version 0.0.4 to 0.0.6
@@ -18,4 +18,5 @@ "use strict"; | ||
SPONSORSHIP: 14, | ||
SET_ASSET_SCRIPT: 15 | ||
SET_ASSET_SCRIPT: 15, | ||
INVOKE_SCRIPT: 16 | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { IAliasTransaction, IBurnTransaction, ICancelLeaseTransaction, IDataTransaction, IExchangeTransaction, IIssueTransaction, ILeaseTransaction, IMassTransferTransaction, IReissueTransaction, ISetAssetScriptTransaction, ISetScriptTransaction, ISponsorshipTransaction, ITransferTransaction, TTransaction, IExchangeTransactionOrderWithProofs, IMassTransferItem, TDataTransactionEntry } from '@waves/ts-types'; | ||
import { IAliasTransaction, IBurnTransaction, ICancelLeaseTransaction, IDataTransaction, IExchangeTransaction, IIssueTransaction, ILeaseTransaction, IMassTransferTransaction, IReissueTransaction, ISetAssetScriptTransaction, ISetScriptTransaction, ISponsorshipTransaction, ITransferTransaction, TTransaction, IExchangeTransactionOrderWithProofs, IMassTransferItem, TDataTransactionEntry, IInvokeScriptCall, IInvokeScriptTransaction, IInvokeScriptPayment, TInvokeScriptCallArgument } from '@waves/ts-types'; | ||
import { TYPES } from '../constants'; | ||
@@ -17,2 +17,3 @@ declare type TConvertMap<TO, T extends TTransaction<any>> = { | ||
[TYPES.SET_ASSET_SCRIPT]: TReplaceParam<T, 'fee', TO>; | ||
[TYPES.INVOKE_SCRIPT]: TReplaceParam<TReplaceParam<TReplaceParam<T, 'fee', TO>, 'payment', Array<IInvokeScriptPayment<TO>>>, 'call', IInvokeScriptCall<TO>>; | ||
}; | ||
@@ -36,4 +37,4 @@ declare type TReplaceParam<T, KEYS, NEW_VALUE> = { | ||
export declare const exchange: <FROM, TO, TX extends IExchangeTransaction<FROM>>(tx: TX, factory: IFactory<FROM, TO>) => TReplaceParam<TX, "fee", TO> & { | ||
buyOrder: TReplaceParam<import("@waves/ts-types").IExchangeTransactionOrder<FROM> & import("@waves/ts-types").IWithProofs, "amount" | "price" | "matcherFee", TO>; | ||
sellOrder: TReplaceParam<import("@waves/ts-types").IExchangeTransactionOrder<FROM> & import("@waves/ts-types").IWithProofs, "amount" | "price" | "matcherFee", TO>; | ||
buyOrder: TReplaceParam<import("@waves/ts-types/src").IExchangeTransactionOrder<FROM> & import("@waves/ts-types/src").IWithProofs, "amount" | "price" | "matcherFee", TO>; | ||
sellOrder: TReplaceParam<import("@waves/ts-types/src").IExchangeTransactionOrder<FROM> & import("@waves/ts-types/src").IWithProofs, "amount" | "price" | "matcherFee", TO>; | ||
amount: TO; | ||
@@ -56,3 +57,3 @@ price: TO; | ||
export declare const data: <FROM, TO, TX extends IDataTransaction<FROM>>(tx: TX, factory: IFactory<FROM, TO>) => TReplaceParam<TX, "fee", TO> & { | ||
data: (import("@waves/ts-types").IDataTransactionEntryBoolean | import("@waves/ts-types").IDataTransactionEntryString | import("@waves/ts-types").IDataTransactionEntryBinary | { | ||
data: (import("@waves/ts-types/src").IDataTransactionEntryBoolean | import("@waves/ts-types/src").IDataTransactionEntryString | import("@waves/ts-types/src").IDataTransactionEntryBinary | { | ||
value: TO; | ||
@@ -67,2 +68,12 @@ key: string; | ||
}; | ||
export declare const invokeScript: <FROM, TO, TX extends IInvokeScriptTransaction<FROM>>(tx: TX, factory: IFactory<FROM, TO>) => TReplaceParam<TX, "fee", TO> & { | ||
payment: { | ||
amount: TO; | ||
assetId: string; | ||
}[]; | ||
call: { | ||
args: TInvokeScriptCallArgument<TO>[]; | ||
function: string; | ||
}; | ||
}; | ||
export declare const setAssetScript: <FROM, TO, TX extends ISetAssetScriptTransaction<FROM>>(tx: TX, factory: IFactory<FROM, TO>) => TReplaceParam<TX, "fee", TO>; | ||
@@ -69,0 +80,0 @@ export declare function convert<FROM, TO, TX extends TTransaction<FROM>, TYPE extends TX['type'] = TX['type']>(tx: TX, factory: IFactory<FROM, TO>): TConvertMap<TO, TX>[TYPE]; |
@@ -39,2 +39,3 @@ "use strict"; | ||
exports.sponsorship = function (tx, factory) { return (__assign({}, defaultConvert(tx, factory), { minSponsoredAssetFee: factory(tx.minSponsoredAssetFee) })); }; | ||
exports.invokeScript = function (tx, factory) { return (__assign({}, defaultConvert(tx, factory), { payment: tx.payment.map(function (item) { return (__assign({}, item, { amount: factory(item.amount) })); }), call: __assign({}, tx.call, { args: tx.call.args.map(function (item) { return (__assign({}, item, { value: item.type === 'integer' ? factory(item.value) : item.value })); }) }) })); }; | ||
exports.setAssetScript = function (tx, factory) { return defaultConvert(tx, factory); }; | ||
@@ -72,2 +73,4 @@ function convert(tx, factory) { | ||
return exports.setAssetScript(tx, factory); | ||
case constants_1.TYPES.INVOKE_SCRIPT: | ||
return exports.invokeScript(tx, factory); | ||
default: | ||
@@ -74,0 +77,0 @@ throw new Error('Unknown transaction type!'); |
import { TYPES } from '../constants'; | ||
import { IBurnTransaction } from '@waves/ts-types'; | ||
import { TMoney, TWithPartialFee } from '../types'; | ||
import { TLong, TMoney, TWithPartialFee } from '../types'; | ||
import { IDefaultGuiTx } from './general'; | ||
export declare const burn: (data: IWavesGuiBurn) => TWithPartialFee<IBurnTransaction<string>>; | ||
export interface IWavesGuiBurn extends IDefaultGuiTx<typeof TYPES.BURN> { | ||
export declare const burn: (data: TWavesGuiBurn) => TWithPartialFee<IBurnTransaction<string>>; | ||
export interface IWavesGuiBurnMoney extends IDefaultGuiTx<typeof TYPES.BURN> { | ||
quantity: TMoney; | ||
chainId: number; | ||
} | ||
export interface IWavesGuiBurnLong extends IDefaultGuiTx<typeof TYPES.BURN> { | ||
quantity: TLong; | ||
assetId: string; | ||
chainId: number; | ||
} | ||
export declare type TWavesGuiBurn = IWavesGuiBurnMoney | IWavesGuiBurnLong; |
@@ -17,3 +17,3 @@ "use strict"; | ||
var utils_1 = require("../utils"); | ||
exports.burn = factory_1.factory(__assign({}, general_1.getDefaultTransform(), { assetId: utils_1.pipe(utils_1.prop('quantity'), utils_1.getAssetId), quantity: utils_1.pipe(utils_1.prop('quantity'), utils_1.getCoins) })); | ||
exports.burn = factory_1.factory(__assign({}, general_1.getDefaultTransform(), { assetId: utils_1.pipe(utils_1.ifElse(utils_1.has('assetId'), utils_1.prop('assetId'), utils_1.pipe(utils_1.prop('quantity'), utils_1.getAssetId)), utils_1.emptyError('Has no assetId!')), quantity: utils_1.pipe(utils_1.prop('quantity'), utils_1.getCoins), chainId: utils_1.prop('chainId') })); | ||
//# sourceMappingURL=burn.js.map |
@@ -8,2 +8,3 @@ import { TYPES } from '../constants'; | ||
leaseId: string; | ||
chainId: number; | ||
} |
@@ -17,3 +17,3 @@ "use strict"; | ||
var utils_1 = require("../utils"); | ||
exports.cancelLease = factory_1.factory(__assign({}, general_1.getDefaultTransform(), { leaseId: utils_1.prop('leaseId') })); | ||
exports.cancelLease = factory_1.factory(__assign({}, general_1.getDefaultTransform(), { leaseId: utils_1.prop('leaseId'), chainId: utils_1.prop('chainId') })); | ||
//# sourceMappingURL=cancelLease.js.map |
import { TLong, TMoney } from '../types'; | ||
export declare const getDefaultTransform: <TYPE extends 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15, T extends IDefaultGuiTx<TYPE>>() => { | ||
export declare const getDefaultTransform: <TYPE extends 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16, T extends IDefaultGuiTx<TYPE>>() => { | ||
type: (data: T) => TYPE; | ||
@@ -4,0 +4,0 @@ senderPublicKey: (data: T) => string; |
import { IWavesGuiAlias } from './alias'; | ||
import { IWavesGuiBurn } from './burn'; | ||
import { TWavesGuiBurn } from './burn'; | ||
import { IWavesGuiCancelLease } from './cancelLease'; | ||
@@ -7,5 +7,5 @@ import { IWavesGuiData } from './data'; | ||
import { IWavesGuiIssue } from './issue'; | ||
import { IWavesGuiReissue } from './reissue'; | ||
import { TWavesGuiReissue } from './reissue'; | ||
import { IWavesGuiLease } from './lease'; | ||
import { IWavesGuiMassTransfer } from './massTransfer'; | ||
import { TWavesGuiMassTransfer } from './massTransfer'; | ||
import { IWavesGuiSetAssetScript } from './setAssetScript'; | ||
@@ -17,5 +17,6 @@ import { IWavesGuiSetScript } from './setScript'; | ||
import { TWithPartialFee } from '../types'; | ||
import { IWavesGuiInvokeScript } from './invokeScript'; | ||
export declare const node: { | ||
alias: (data: IWavesGuiAlias) => TWithPartialFee<import("@waves/ts-types").IAliasTransaction<string>>; | ||
burn: (data: IWavesGuiBurn) => TWithPartialFee<import("@waves/ts-types").IBurnTransaction<string>>; | ||
burn: (data: TWavesGuiBurn) => TWithPartialFee<import("@waves/ts-types").IBurnTransaction<string>>; | ||
cancelLease: (data: IWavesGuiCancelLease) => TWithPartialFee<import("@waves/ts-types").ICancelLeaseTransaction<string>>; | ||
@@ -25,5 +26,5 @@ data: (data: IWavesGuiData) => TWithPartialFee<import("@waves/ts-types").IDataTransaction<string>>; | ||
issue: (data: IWavesGuiIssue) => TWithPartialFee<import("@waves/ts-types").IIssueTransaction<string>>; | ||
reissue: (data: IWavesGuiReissue) => TWithPartialFee<import("@waves/ts-types").IReissueTransaction<string>>; | ||
reissue: (data: TWavesGuiReissue) => TWithPartialFee<import("@waves/ts-types").IReissueTransaction<string>>; | ||
lease: (data: IWavesGuiLease) => TWithPartialFee<import("@waves/ts-types").ILeaseTransaction<string>>; | ||
massTransfer: (data: IWavesGuiMassTransfer) => TWithPartialFee<import("@waves/ts-types").IMassTransferTransaction<string>>; | ||
massTransfer: (data: TWavesGuiMassTransfer) => TWithPartialFee<import("@waves/ts-types").IMassTransferTransaction<string>>; | ||
setAssetScript: (data: IWavesGuiSetAssetScript) => TWithPartialFee<import("@waves/ts-types").ISetAssetScriptTransaction<string>>; | ||
@@ -34,6 +35,7 @@ setScript: (data: IWavesGuiSetScript) => TWithPartialFee<import("@waves/ts-types").ISetScriptTransaction<string>>; | ||
order: (data: IWavesGuiExchangeOrder) => IExchangeTransactionOrderWithProofs<string>; | ||
invokeScript: (data: IWavesGuiInvokeScript) => TWithPartialFee<import("@waves/ts-types").IInvokeScriptTransaction<string>>; | ||
}; | ||
export { IWavesGuiAlias, IWavesGuiBurn, IWavesGuiCancelLease, IWavesGuiData, IWavesGuiExchange, IWavesGuiIssue, IWavesGuiReissue, IWavesGuiLease, IWavesGuiMassTransfer, IWavesGuiSetAssetScript, IWavesGuiSetScript, IWavesGuiSponsorship, IWavesGuiTransfer, }; | ||
export { IWavesGuiAlias, TWavesGuiBurn, IWavesGuiCancelLease, IWavesGuiData, IWavesGuiExchange, IWavesGuiIssue, TWavesGuiReissue, IWavesGuiLease, TWavesGuiMassTransfer, IWavesGuiSetAssetScript, IWavesGuiSetScript, IWavesGuiSponsorship, IWavesGuiTransfer, }; | ||
export declare function toNode(item: IWavesGuiExchangeOrder): IExchangeTransactionOrderWithProofs<string>; | ||
export declare function toNode<TX extends TWavesGuiEntity, TYPE extends TX['type'] = TX['type']>(item: TX): TWithPartialFee<TTransactionMap<string>[TYPE]>; | ||
export declare type TWavesGuiEntity = IWavesGuiAlias | IWavesGuiBurn | IWavesGuiCancelLease | IWavesGuiData | IWavesGuiExchange | IWavesGuiIssue | IWavesGuiReissue | IWavesGuiLease | IWavesGuiMassTransfer | IWavesGuiSetAssetScript | IWavesGuiSetScript | IWavesGuiSponsorship | IWavesGuiTransfer; | ||
export declare type TWavesGuiEntity = IWavesGuiAlias | TWavesGuiBurn | IWavesGuiCancelLease | IWavesGuiData | IWavesGuiExchange | IWavesGuiIssue | TWavesGuiReissue | IWavesGuiLease | TWavesGuiMassTransfer | IWavesGuiSetAssetScript | IWavesGuiSetScript | IWavesGuiSponsorship | IWavesGuiTransfer | IWavesGuiInvokeScript; |
@@ -18,2 +18,3 @@ "use strict"; | ||
var utils_1 = require("../utils"); | ||
var invokeScript_1 = require("./invokeScript"); | ||
exports.node = { | ||
@@ -24,3 +25,3 @@ alias: alias_1.alias, burn: burn_1.burn, cancelLease: cancelLease_1.cancelLease, | ||
setAssetScript: setAssetScript_1.setAssetScript, setScript: setScript_1.setScript, sponsorship: sponsorship_1.sponsorship, | ||
transfer: transfer_1.transfer, order: exchange_1.remapOrder | ||
transfer: transfer_1.transfer, order: exchange_1.remapOrder, invokeScript: invokeScript_1.invokeScript | ||
}; | ||
@@ -58,2 +59,4 @@ function toNode(item) { | ||
return setAssetScript_1.setAssetScript(item); | ||
case constants_1.TYPES.INVOKE_SCRIPT: | ||
return invokeScript_1.invokeScript(item); | ||
default: | ||
@@ -60,0 +63,0 @@ throw new Error('Unknown transaction type!'); |
import { TYPES } from '../constants'; | ||
import { IMassTransferTransaction } from '@waves/ts-types'; | ||
import { TMoney, TWithPartialFee } from '../types'; | ||
import { TLong, TMoney, TWithPartialFee } from '../types'; | ||
import { IDefaultGuiTx } from './general'; | ||
export declare const massTransfer: (data: IWavesGuiMassTransfer) => TWithPartialFee<IMassTransferTransaction<string>>; | ||
export interface IWavesGuiMassTransfer extends IDefaultGuiTx<typeof TYPES.MASS_TRANSFER> { | ||
export declare const massTransfer: (data: TWavesGuiMassTransfer) => TWithPartialFee<IMassTransferTransaction<string>>; | ||
export interface IWavesGuiMassTransferMoney extends IDefaultGuiTx<typeof TYPES.MASS_TRANSFER> { | ||
attachment?: string; | ||
transfers: Array<IWavesGuiMassTransferItem>; | ||
transfers: Array<IWavesGuiMassTransferItem<TMoney>>; | ||
} | ||
interface IWavesGuiMassTransferItem { | ||
export interface IWavesGuiMassTransferLong extends IDefaultGuiTx<typeof TYPES.MASS_TRANSFER> { | ||
attachment?: string; | ||
assetId: string; | ||
transfers: Array<IWavesGuiMassTransferItem<TLong>>; | ||
} | ||
export declare type TWavesGuiMassTransfer = IWavesGuiMassTransferMoney | IWavesGuiMassTransferLong; | ||
interface IWavesGuiMassTransferItem<T extends TMoney | TLong> { | ||
recipient: string; | ||
amount: TMoney; | ||
amount: T; | ||
} | ||
export {}; |
@@ -21,8 +21,9 @@ "use strict"; | ||
}); | ||
exports.massTransfer = factory_1.factory(__assign({}, general_1.getDefaultTransform(), { transfers: utils_1.pipe(utils_1.prop('transfers'), utils_1.map(remapTransferItem)), assetId: utils_1.pipe(utils_1.prop('transfers'), function (list) { | ||
if (!list.length) { | ||
throw new Error('MassTransfer transaction must have one transfer!'); | ||
} | ||
return list[0]; | ||
}, utils_1.prop('amount'), utils_1.getAssetId), attachment: utils_1.prop('attachment') })); | ||
var getFirstMassTransferItem = function (list) { | ||
if (!list.length) { | ||
throw new Error('MassTransfer transaction must have one transfer!'); | ||
} | ||
return list[0]; | ||
}; | ||
exports.massTransfer = factory_1.factory(__assign({}, general_1.getDefaultTransform(), { transfers: utils_1.pipe(utils_1.prop('transfers'), utils_1.map(remapTransferItem)), assetId: utils_1.pipe(utils_1.ifElse(utils_1.has('assetId'), utils_1.prop('assetId'), utils_1.pipe(utils_1.prop('transfers'), getFirstMassTransferItem, utils_1.prop('amount'), utils_1.getAssetId)), utils_1.emptyError('Has no assetId!')), attachment: utils_1.prop('attachment') })); | ||
//# sourceMappingURL=massTransfer.js.map |
import { TYPES } from '../constants'; | ||
import { IReissueTransaction } from '@waves/ts-types'; | ||
import { TMoney, TWithPartialFee } from '../types'; | ||
import { TLong, TMoney, TWithPartialFee } from '../types'; | ||
import { IDefaultGuiTx } from './general'; | ||
export declare const reissue: (data: IWavesGuiReissue) => TWithPartialFee<IReissueTransaction<string>>; | ||
export interface IWavesGuiReissue extends IDefaultGuiTx<typeof TYPES.REISSUE> { | ||
amount: TMoney; | ||
export declare const reissue: (data: TWavesGuiReissue) => TWithPartialFee<IReissueTransaction<string>>; | ||
export interface IWavesGuiReissueMoney extends IDefaultGuiTx<typeof TYPES.REISSUE> { | ||
quantity: TMoney; | ||
reissuable: boolean; | ||
chainId: number; | ||
} | ||
export interface IWavesGuiReissueLong extends IDefaultGuiTx<typeof TYPES.REISSUE> { | ||
assetId: string; | ||
quantity: TLong; | ||
reissuable: boolean; | ||
chainId: number; | ||
} | ||
export declare type TWavesGuiReissue = IWavesGuiReissueMoney | IWavesGuiReissueLong; |
@@ -17,3 +17,3 @@ "use strict"; | ||
var utils_1 = require("../utils"); | ||
exports.reissue = factory_1.factory(__assign({}, general_1.getDefaultTransform(), { assetId: utils_1.pipe(utils_1.prop('amount'), utils_1.getAssetId), quantity: utils_1.pipe(utils_1.prop('amount'), utils_1.getCoins), reissuable: utils_1.prop('reissuable') })); | ||
exports.reissue = factory_1.factory(__assign({}, general_1.getDefaultTransform(), { assetId: utils_1.pipe(utils_1.ifElse(utils_1.has('assetId'), utils_1.prop('assetId'), utils_1.pipe(utils_1.prop('quantity'), utils_1.getAssetId)), utils_1.emptyError('Has no assetId!')), quantity: utils_1.pipe(utils_1.prop('quantity'), utils_1.getCoins), reissuable: utils_1.prop('reissuable'), chainId: utils_1.prop('chainId') })); | ||
//# sourceMappingURL=reissue.js.map |
@@ -8,2 +8,3 @@ import { TYPES } from '../constants'; | ||
script: string | null; | ||
chainId: number; | ||
} |
@@ -17,3 +17,3 @@ "use strict"; | ||
var utils_1 = require("../utils"); | ||
exports.setScript = factory_1.factory(__assign({}, general_1.getDefaultTransform(), { script: utils_1.prop('script') })); | ||
exports.setScript = factory_1.factory(__assign({}, general_1.getDefaultTransform(), { script: utils_1.prop('script'), chainId: utils_1.prop('chainId') })); | ||
//# sourceMappingURL=setScript.js.map |
@@ -9,2 +9,4 @@ import { TLong, TMoney } from '../types'; | ||
export declare const curry: ICurry; | ||
export declare const ifElse: <T, Y, N>(expression: (data: T) => boolean, resolve: (data: T) => Y, reject: (data: T) => N) => (data: T) => Y | N; | ||
export declare const has: IHas; | ||
export declare const emptyError: <T>(message: string) => (value: T | null | undefined) => T; | ||
@@ -19,2 +21,10 @@ export declare function isOrder<T extends { | ||
export declare const pipe: IPipe; | ||
interface IHas { | ||
<T extends { | ||
[Key: string]: any; | ||
}>(prop: string | number | symbol, data: T): prop is keyof T; | ||
<K extends keyof any, T extends { | ||
[Key: string]: any; | ||
}>(prop: K): (data: T) => boolean; | ||
} | ||
interface IMap { | ||
@@ -21,0 +31,0 @@ <T, R>(cb: (item: T) => R, list: Array<T>): Array<R>; |
@@ -67,2 +67,4 @@ "use strict"; | ||
}; | ||
exports.ifElse = function (expression, resolve, reject) { return function (data) { return expression(data) ? resolve(data) : reject(data); }; }; | ||
exports.has = exports.curry(function (prop, data) { return Object.prototype.hasOwnProperty.call(data, prop); }); | ||
exports.emptyError = function (message) { return function (value) { | ||
@@ -69,0 +71,0 @@ if (value == null) { |
{ | ||
"name": "@waves/money-like-to-node", | ||
"version": "0.0.4", | ||
"version": "0.0.6", | ||
"main": "dist/index.js", | ||
@@ -10,3 +10,3 @@ "typings": "dist/index.d.ts", | ||
"dependencies": { | ||
"@waves/ts-types": "^0.2.0-beta-3" | ||
"@waves/ts-types": "^0.2.0-beta-6" | ||
}, | ||
@@ -13,0 +13,0 @@ "scripts": { |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
69073
70
997
0