From daf6fb64844532ca5aed2f0e41942985c105830e Mon Sep 17 00:00:00 2001 From: inazarov Date: Fri, 15 Oct 2021 12:07:20 +0300 Subject: [PATCH 1/9] move files --- src/common.ts | 60 ++++++++++++++++++++ src/exchange.ts | 74 +++++++++++++++++++++++++ src/index.ts | 55 +------------------ src/invoke.ts | 54 ++++++++++++++++++ src/parts.ts | 142 ++---------------------------------------------- 5 files changed, 196 insertions(+), 189 deletions(-) create mode 100644 src/common.ts create mode 100644 src/exchange.ts create mode 100644 src/invoke.ts diff --git a/src/common.ts b/src/common.ts new file mode 100644 index 0000000..11dbc17 --- /dev/null +++ b/src/common.ts @@ -0,0 +1,60 @@ +export type ExchangeTransactionOrderType = 'buy' | 'sell'; +export type Base64Script = string; +export type Base58Bytes = string; +export type Proofs = Array; +export type Long = string | number; +export type AssetDecimals = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8; +export type Base64string = string; + +export const GENESIS_TYPE = 1 as 1; +export const PAYMENT_TYPE = 2 as 2; +export const ISSUE_TYPE = 3 as 3; +export const TRANSFER_TYPE = 4 as 4; +export const REISSUE_TYPE = 5 as 5; +export const BURN_TYPE = 6 as 6; +export const EXCHANGE_TYPE = 7 as 7; +export const LEASE_TYPE = 8 as 8; +export const CANCEL_LEASE_TYPE = 9 as 9; +export const ALIAS_TYPE = 10 as 10; +export const MASS_TRANSFER_TYPE = 11 as 11; +export const DATA_TYPE = 12 as 12; +export const SET_SCRIPT_TYPE = 13 as 13; +export const SPONSORSHIP_TYPE = 14 as 14; +export const SET_ASSET_SCRIPT_TYPE = 15 as 15; +export const INVOKE_SCRIPT_TYPE = 16 as 16; +export const UPDATE_ASSET_INFO_TYPE = 17 as 17; + +export const INTEGER_DATA_TYPE = 'integer' as 'integer'; +export const BOOLEAN_DATA_TYPE = 'boolean' as 'boolean'; +export const STRING_DATA_TYPE = 'string' as 'string'; +export const BINARY_DATA_TYPE = 'binary' as 'binary'; + +export const TRANSACTION_TYPE = { + GENESIS: GENESIS_TYPE, + PAYMENT: PAYMENT_TYPE, + ISSUE: ISSUE_TYPE, + TRANSFER: TRANSFER_TYPE, + REISSUE: REISSUE_TYPE, + BURN: BURN_TYPE, + EXCHANGE: EXCHANGE_TYPE, + LEASE: LEASE_TYPE, + CANCEL_LEASE: CANCEL_LEASE_TYPE, + ALIAS: ALIAS_TYPE, + MASS_TRANSFER: MASS_TRANSFER_TYPE, + DATA: DATA_TYPE, + SET_SCRIPT: SET_SCRIPT_TYPE, + SPONSORSHIP: SPONSORSHIP_TYPE, + SET_ASSET_SCRIPT: SET_ASSET_SCRIPT_TYPE, + INVOKE_SCRIPT: INVOKE_SCRIPT_TYPE, + UPDATE_ASSET_INFO: UPDATE_ASSET_INFO_TYPE, +}; + +export const DATA_FIELD_TYPE = { + INTEGER: INTEGER_DATA_TYPE, + BOOLEAN: BOOLEAN_DATA_TYPE, + STRING: STRING_DATA_TYPE, + BINARY: BINARY_DATA_TYPE, +}; + +export type TransactionType = typeof TRANSACTION_TYPE[keyof typeof TRANSACTION_TYPE]; +export type DataFiledType = typeof DATA_FIELD_TYPE[keyof typeof DATA_FIELD_TYPE]; diff --git a/src/exchange.ts b/src/exchange.ts new file mode 100644 index 0000000..33b92ac --- /dev/null +++ b/src/exchange.ts @@ -0,0 +1,74 @@ +import { ExchangeTransaction } from './index'; +import { ExchangeTransactionOrderType, Long } from './common'; + +export type ExchangeTransactionOrderData = { + version: number; + orderType: ExchangeTransactionOrderType; + assetPair: { + amountAsset: string | null; + priceAsset: string | null; + }; + price: LONG; + amount: LONG; + timestamp: number; + expiration: number; + matcherFee: LONG; + matcherPublicKey: string; + senderPublicKey: string; +}; + +export type WithVersion< + Target extends Record, + Version extends number +> = Target & { + version: Version; +}; + +type ExchangeOrderWithCustomFee = ExchangeTransactionOrderData & { + matcherFeeAssetId: string | null; +}; + +export type ExchangeTransactionOrderV1 = WithVersion< + ExchangeTransactionOrderData, + 1 +>; +export type ExchangeTransactionOrderV2 = WithVersion< + ExchangeTransactionOrderData, + 2 +>; +export type ExchangeTransactionOrderV3 = WithVersion< + ExchangeOrderWithCustomFee, + 3 +>; +export type ExchangeTransactionOrderV4 = WithVersion< + ExchangeOrderWithCustomFee, + 4 +>; + +export type ExchangeTransactionOrder = + | ExchangeTransactionOrderV1 + | ExchangeTransactionOrderV2 + | ExchangeTransactionOrderV3 + | ExchangeTransactionOrderV4; + +export type SignedIExchangeTransactionOrder< + ORDER extends ExchangeTransactionOrder +> = ORDER & + (ORDER extends { version: 1 } + ? { signature: string } + : { proofs: Array }); + +export type ExchangeTransactionOrderMap = { + 1: ExchangeTransactionOrderV1; + 2: ExchangeTransactionOrderV2; + 3: ExchangeTransactionOrderV3; + 4: ExchangeTransactionOrderV4; +}; + +export type ExchangeTransactionOrderByTx< + TX extends ExchangeTransaction +> = TX extends { version: 1 } + ? ExchangeTransactionOrderMap[1] + : TX extends { version: 2 } + ? ExchangeTransactionOrderMap[1 | 2 | 3] + : ExchangeTransactionOrder; diff --git a/src/index.ts b/src/index.ts index 7baf290..9fc1e88 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,55 +1,6 @@ export * from '../transactions'; +export * from './common'; export * from './parts'; -export const GENESIS_TYPE = 1 as 1; -export const PAYMENT_TYPE = 2 as 2; -export const ISSUE_TYPE = 3 as 3; -export const TRANSFER_TYPE = 4 as 4; -export const REISSUE_TYPE = 5 as 5; -export const BURN_TYPE = 6 as 6; -export const EXCHANGE_TYPE = 7 as 7; -export const LEASE_TYPE = 8 as 8; -export const CANCEL_LEASE_TYPE = 9 as 9; -export const ALIAS_TYPE = 10 as 10; -export const MASS_TRANSFER_TYPE = 11 as 11; -export const DATA_TYPE = 12 as 12; -export const SET_SCRIPT_TYPE = 13 as 13; -export const SPONSORSHIP_TYPE = 14 as 14; -export const SET_ASSET_SCRIPT_TYPE = 15 as 15; -export const INVOKE_SCRIPT_TYPE = 16 as 16; -export const UPDATE_ASSET_INFO_TYPE = 17 as 17; - -export const INTEGER_DATA_TYPE = 'integer' as 'integer'; -export const BOOLEAN_DATA_TYPE = 'boolean' as 'boolean'; -export const STRING_DATA_TYPE = 'string' as 'string'; -export const BINARY_DATA_TYPE = 'binary' as 'binary'; - -export const TRANSACTION_TYPE = { - GENESIS: GENESIS_TYPE, - PAYMENT: PAYMENT_TYPE, - ISSUE: ISSUE_TYPE, - TRANSFER: TRANSFER_TYPE, - REISSUE: REISSUE_TYPE, - BURN: BURN_TYPE, - EXCHANGE: EXCHANGE_TYPE, - LEASE: LEASE_TYPE, - CANCEL_LEASE: CANCEL_LEASE_TYPE, - ALIAS: ALIAS_TYPE, - MASS_TRANSFER: MASS_TRANSFER_TYPE, - DATA: DATA_TYPE, - SET_SCRIPT: SET_SCRIPT_TYPE, - SPONSORSHIP: SPONSORSHIP_TYPE, - SET_ASSET_SCRIPT: SET_ASSET_SCRIPT_TYPE, - INVOKE_SCRIPT: INVOKE_SCRIPT_TYPE, - UPDATE_ASSET_INFO: UPDATE_ASSET_INFO_TYPE, -}; - -export const DATA_FIELD_TYPE = { - INTEGER: INTEGER_DATA_TYPE, - BOOLEAN: BOOLEAN_DATA_TYPE, - STRING: STRING_DATA_TYPE, - BINARY: BINARY_DATA_TYPE, -}; - -export type TransactionType = typeof TRANSACTION_TYPE[keyof typeof TRANSACTION_TYPE]; -export type DataFiledType = typeof DATA_FIELD_TYPE[keyof typeof DATA_FIELD_TYPE]; +export * from './exchange'; +export * from './invoke'; diff --git a/src/invoke.ts b/src/invoke.ts new file mode 100644 index 0000000..ead8891 --- /dev/null +++ b/src/invoke.ts @@ -0,0 +1,54 @@ +import { Long, Base64string, } from './common'; + +export type InvokeScriptCall = { + function: string; + args: Array>; +}; + +export type InvokeScriptPayment = { + assetId: string | null; + amount: LONG; +}; + +export type InvokeScriptCallArgument = + | InvokeScriptCallStringArgument + | InvokeScriptCallBinaryArgument + | InvokeScriptCallBooleanArgument + | InvokeScriptCallIntegerArgument + | InvokeScriptCallListArgument< + LONG, + | InvokeScriptCallStringArgument + | InvokeScriptCallBinaryArgument + | InvokeScriptCallBooleanArgument + | InvokeScriptCallIntegerArgument + >; + +export type InvokeScriptCallArgumentGeneric = { + type: Type; + value: Value; +}; + +export type InvokeScriptCallStringArgument = InvokeScriptCallArgumentGeneric< + 'string', + string +>; +export type InvokeScriptCallBinaryArgument = InvokeScriptCallArgumentGeneric< + 'binary', + Base64string +>; +export type InvokeScriptCallBooleanArgument = InvokeScriptCallArgumentGeneric< + 'boolean', + boolean +>; +export type InvokeScriptCallIntegerArgument< + LONG = Long +> = InvokeScriptCallArgumentGeneric<'integer', LONG>; + +export type InvokeScriptCallListArgument< + LONG, + ITEMS extends + | InvokeScriptCallStringArgument + | InvokeScriptCallBinaryArgument + | InvokeScriptCallBooleanArgument + | InvokeScriptCallIntegerArgument +> = InvokeScriptCallArgumentGeneric<'list', Array>; diff --git a/src/parts.ts b/src/parts.ts index 0ba2b60..d8bcc73 100644 --- a/src/parts.ts +++ b/src/parts.ts @@ -1,75 +1,15 @@ -import { DATA_FIELD_TYPE, ExchangeTransaction } from './index'; +import { DATA_FIELD_TYPE } from './index'; +import { Long, Base64string } from './common'; -export type ExchangeTransactionOrderType = 'buy' | 'sell'; -export type Base64Script = string; -export type Base58Bytes = string; -export type Proofs = Array; -export type Long = string | number; -export type AssetDecimals = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8; -export type Base64string = string; +export interface WithId { + id: string; +} export type WithApiMixin = WithId & { sender: string; height: number; }; -export type InvokeScriptCall = { - function: string; - args: Array>; -}; - -export type InvokeScriptPayment = { - assetId: string | null; - amount: LONG; -}; - -export type InvokeScriptCallArgument = - | InvokeScriptCallStringArgument - | InvokeScriptCallBinaryArgument - | InvokeScriptCallBooleanArgument - | InvokeScriptCallIntegerArgument - | InvokeScriptCallListArgument< - LONG, - | InvokeScriptCallStringArgument - | InvokeScriptCallBinaryArgument - | InvokeScriptCallBooleanArgument - | InvokeScriptCallIntegerArgument - >; - -export type InvokeScriptCallArgumentGeneric = { - type: Type; - value: Value; -}; - -export type InvokeScriptCallStringArgument = InvokeScriptCallArgumentGeneric< - 'string', - string ->; -export type InvokeScriptCallBinaryArgument = InvokeScriptCallArgumentGeneric< - 'binary', - Base64string ->; -export type InvokeScriptCallBooleanArgument = InvokeScriptCallArgumentGeneric< - 'boolean', - boolean ->; -export type InvokeScriptCallIntegerArgument< - LONG = Long -> = InvokeScriptCallArgumentGeneric<'integer', LONG>; - -export type InvokeScriptCallListArgument< - LONG, - ITEMS extends - | InvokeScriptCallStringArgument - | InvokeScriptCallBinaryArgument - | InvokeScriptCallBooleanArgument - | InvokeScriptCallIntegerArgument -> = InvokeScriptCallArgumentGeneric<'list', Array>; - -export interface WithId { - id: string; -} - export type MassTransferItem = { recipient: string; amount: LONG; @@ -98,78 +38,6 @@ export type DataTransactionEntryBoolean = DataTransactionEntryGeneric< boolean >; -export type ExchangeTransactionOrderData = { - version: number; - orderType: ExchangeTransactionOrderType; - assetPair: { - amountAsset: string | null; - priceAsset: string | null; - }; - price: LONG; - amount: LONG; - timestamp: number; - expiration: number; - matcherFee: LONG; - matcherPublicKey: string; - senderPublicKey: string; -}; - -export type WithVersion< - Target extends Record, - Version extends number -> = Target & { - version: Version; -}; - -type ExchangeOrderWithCustomFee = ExchangeTransactionOrderData & { - matcherFeeAssetId: string | null; -}; - -export type ExchangeTransactionOrderV1 = WithVersion< - ExchangeTransactionOrderData, - 1 ->; -export type ExchangeTransactionOrderV2 = WithVersion< - ExchangeTransactionOrderData, - 2 ->; -export type ExchangeTransactionOrderV3 = WithVersion< - ExchangeOrderWithCustomFee, - 3 ->; -export type ExchangeTransactionOrderV4 = WithVersion< - ExchangeOrderWithCustomFee, - 4 ->; - -export type ExchangeTransactionOrder = - | ExchangeTransactionOrderV1 - | ExchangeTransactionOrderV2 - | ExchangeTransactionOrderV3 - | ExchangeTransactionOrderV4; - -export type SignedIExchangeTransactionOrder< - ORDER extends ExchangeTransactionOrder -> = ORDER & - (ORDER extends { version: 1 } - ? { signature: string } - : { proofs: Array }); - -export type ExchangeTransactionOrderMap = { - 1: ExchangeTransactionOrderV1; - 2: ExchangeTransactionOrderV2; - 3: ExchangeTransactionOrderV3; - 4: ExchangeTransactionOrderV4; -}; - -export type ExchangeTransactionOrderByTx< - TX extends ExchangeTransaction -> = TX extends { version: 1 } - ? ExchangeTransactionOrderMap[1] - : TX extends { version: 2 } - ? ExchangeTransactionOrderMap[1 | 2 | 3] - : ExchangeTransactionOrder; - export type DataTransactionEntry = | DataTransactionEntryInteger | DataTransactionEntryString From 12aa6e0b39d2d76dd597d5bef97faf721f475e96 Mon Sep 17 00:00:00 2001 From: inazarov Date: Fri, 15 Oct 2021 12:09:59 +0300 Subject: [PATCH 2/9] add union type to invoke --- src/index.ts | 1 + src/invoke.ts | 30 ++++++++++++++++++++++++------ src/network.ts | 8 ++++++++ 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 src/network.ts diff --git a/src/index.ts b/src/index.ts index 9fc1e88..848f4ac 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,7 @@ export * from '../transactions'; export * from './common'; export * from './parts'; +export * from './network'; export * from './exchange'; export * from './invoke'; diff --git a/src/invoke.ts b/src/invoke.ts index ead8891..e80a7de 100644 --- a/src/invoke.ts +++ b/src/invoke.ts @@ -1,4 +1,12 @@ -import { Long, Base64string, } from './common'; +import { Base64string, Long } from './common'; + +export enum EInvokeArgumentType { + INTEGER = 'integer', + STRING = 'string', + BOOLEAN = 'boolean', + BINARY = 'binary', + UNION = 'union', +} export type InvokeScriptCall = { function: string; @@ -15,6 +23,7 @@ export type InvokeScriptCallArgument = | InvokeScriptCallBinaryArgument | InvokeScriptCallBooleanArgument | InvokeScriptCallIntegerArgument + | InvokeScriptCallUnionArgument | InvokeScriptCallListArgument< LONG, | InvokeScriptCallStringArgument @@ -29,21 +38,29 @@ export type InvokeScriptCallArgumentGeneric = { }; export type InvokeScriptCallStringArgument = InvokeScriptCallArgumentGeneric< - 'string', + EInvokeArgumentType.STRING, string >; export type InvokeScriptCallBinaryArgument = InvokeScriptCallArgumentGeneric< - 'binary', + EInvokeArgumentType.BINARY, Base64string >; export type InvokeScriptCallBooleanArgument = InvokeScriptCallArgumentGeneric< - 'boolean', + EInvokeArgumentType.BOOLEAN, boolean >; export type InvokeScriptCallIntegerArgument< LONG = Long -> = InvokeScriptCallArgumentGeneric<'integer', LONG>; - +> = InvokeScriptCallArgumentGeneric; +export type InvokeScriptCallUnionArgument = InvokeScriptCallArgumentGeneric< + EInvokeArgumentType.UNION, + boolean | string | Base64string | Long +> & { + valueType: EInvokeArgumentType.BINARY + | EInvokeArgumentType.BOOLEAN + | EInvokeArgumentType.INTEGER + | EInvokeArgumentType.STRING +}; export type InvokeScriptCallListArgument< LONG, ITEMS extends @@ -51,4 +68,5 @@ export type InvokeScriptCallListArgument< | InvokeScriptCallBinaryArgument | InvokeScriptCallBooleanArgument | InvokeScriptCallIntegerArgument + | InvokeScriptCallUnionArgument > = InvokeScriptCallArgumentGeneric<'list', Array>; diff --git a/src/network.ts b/src/network.ts new file mode 100644 index 0000000..73c2642 --- /dev/null +++ b/src/network.ts @@ -0,0 +1,8 @@ +export enum EChainId { + MAINNET = 87, + STAGENET = 83, + TESTNET = 84, + PRIVATE = 80, + DEVNET = 68, + DEVNET_C = 67 +} From 09cad187169bd9db729a8ccbd5bf0ce3acf76cd5 Mon Sep 17 00:00:00 2001 From: inazarov Date: Fri, 15 Oct 2021 16:34:09 +0300 Subject: [PATCH 3/9] Clean EChainId --- src/network.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/network.ts b/src/network.ts index 73c2642..44f9456 100644 --- a/src/network.ts +++ b/src/network.ts @@ -3,6 +3,4 @@ export enum EChainId { STAGENET = 83, TESTNET = 84, PRIVATE = 80, - DEVNET = 68, - DEVNET_C = 67 } From 91c1a626dd2c1ff052dae160a0f6e3ccb786f4f1 Mon Sep 17 00:00:00 2001 From: inazarov Date: Tue, 2 Nov 2021 14:42:23 +0300 Subject: [PATCH 4/9] name --- src/network.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network.ts b/src/network.ts index 44f9456..4764096 100644 --- a/src/network.ts +++ b/src/network.ts @@ -1,4 +1,4 @@ -export enum EChainId { +export enum ChainId { MAINNET = 87, STAGENET = 83, TESTNET = 84, From 10bccf59f91fdcf3b967271fccb00358dda5e146 Mon Sep 17 00:00:00 2001 From: inazarov Date: Tue, 2 Nov 2021 15:37:24 +0300 Subject: [PATCH 5/9] InvokeScriptCallUnionArgument generic --- src/invoke.ts | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/invoke.ts b/src/invoke.ts index e80a7de..935d09f 100644 --- a/src/invoke.ts +++ b/src/invoke.ts @@ -1,6 +1,6 @@ import { Base64string, Long } from './common'; -export enum EInvokeArgumentType { +export enum InvokeArgumentType { INTEGER = 'integer', STRING = 'string', BOOLEAN = 'boolean', @@ -23,13 +23,13 @@ export type InvokeScriptCallArgument = | InvokeScriptCallBinaryArgument | InvokeScriptCallBooleanArgument | InvokeScriptCallIntegerArgument - | InvokeScriptCallUnionArgument + | InvokeScriptCallUnionArgument | InvokeScriptCallListArgument< LONG, | InvokeScriptCallStringArgument | InvokeScriptCallBinaryArgument | InvokeScriptCallBooleanArgument - | InvokeScriptCallIntegerArgument + | InvokeScriptCallIntegerArgument >; export type InvokeScriptCallArgumentGeneric = { @@ -38,28 +38,27 @@ export type InvokeScriptCallArgumentGeneric = { }; export type InvokeScriptCallStringArgument = InvokeScriptCallArgumentGeneric< - EInvokeArgumentType.STRING, + InvokeArgumentType.STRING, string >; export type InvokeScriptCallBinaryArgument = InvokeScriptCallArgumentGeneric< - EInvokeArgumentType.BINARY, + InvokeArgumentType.BINARY, Base64string >; export type InvokeScriptCallBooleanArgument = InvokeScriptCallArgumentGeneric< - EInvokeArgumentType.BOOLEAN, + InvokeArgumentType.BOOLEAN, boolean >; export type InvokeScriptCallIntegerArgument< LONG = Long -> = InvokeScriptCallArgumentGeneric; -export type InvokeScriptCallUnionArgument = InvokeScriptCallArgumentGeneric< - EInvokeArgumentType.UNION, - boolean | string | Base64string | Long -> & { - valueType: EInvokeArgumentType.BINARY - | EInvokeArgumentType.BOOLEAN - | EInvokeArgumentType.INTEGER - | EInvokeArgumentType.STRING +> = InvokeScriptCallArgumentGeneric; +export type InvokeScriptCallUnionArgument< +LONG = Long +> = InvokeScriptCallArgumentGeneric & { + valueType: InvokeArgumentType.BINARY + | InvokeArgumentType.BOOLEAN + | InvokeArgumentType.INTEGER + | InvokeArgumentType.STRING }; export type InvokeScriptCallListArgument< LONG, @@ -67,6 +66,6 @@ export type InvokeScriptCallListArgument< | InvokeScriptCallStringArgument | InvokeScriptCallBinaryArgument | InvokeScriptCallBooleanArgument - | InvokeScriptCallIntegerArgument - | InvokeScriptCallUnionArgument + | InvokeScriptCallIntegerArgument + | InvokeScriptCallUnionArgument > = InvokeScriptCallArgumentGeneric<'list', Array>; From ac78f0b4dc048a54008f5cd2d9e8d846f96e54c1 Mon Sep 17 00:00:00 2001 From: inazarov Date: Fri, 5 Nov 2021 19:09:38 +0300 Subject: [PATCH 6/9] imports --- package.json | 2 +- src/parts.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9449d33..b9eb6da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@waves/ts-types", - "version": "1.0.6-beta.7", + "version": "1.0.6-beta.8", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", "scripts": { diff --git a/src/parts.ts b/src/parts.ts index 272a433..73e51bb 100644 --- a/src/parts.ts +++ b/src/parts.ts @@ -1,5 +1,6 @@ import { DATA_FIELD_TYPE } from './index'; -import { Long, Base64string } from './common'; +import { AssetDecimals, Long, Base64string } from './common'; +import { InvokeScriptPayment } from './invoke'; export interface WithId { id: string; From 89215fceeb84045134a2025d5e3bc1e344f54aab Mon Sep 17 00:00:00 2001 From: inazarov Date: Tue, 9 Nov 2021 12:15:02 +0300 Subject: [PATCH 7/9] InvokeArgumentType.UNION --- src/invoke.ts | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/invoke.ts b/src/invoke.ts index 935d09f..603e3c1 100644 --- a/src/invoke.ts +++ b/src/invoke.ts @@ -1,13 +1,5 @@ import { Base64string, Long } from './common'; -export enum InvokeArgumentType { - INTEGER = 'integer', - STRING = 'string', - BOOLEAN = 'boolean', - BINARY = 'binary', - UNION = 'union', -} - export type InvokeScriptCall = { function: string; args: Array>; @@ -38,27 +30,24 @@ export type InvokeScriptCallArgumentGeneric = { }; export type InvokeScriptCallStringArgument = InvokeScriptCallArgumentGeneric< - InvokeArgumentType.STRING, + 'string', string >; export type InvokeScriptCallBinaryArgument = InvokeScriptCallArgumentGeneric< - InvokeArgumentType.BINARY, + 'binary', Base64string >; export type InvokeScriptCallBooleanArgument = InvokeScriptCallArgumentGeneric< - InvokeArgumentType.BOOLEAN, + 'boolean', boolean >; export type InvokeScriptCallIntegerArgument< LONG = Long -> = InvokeScriptCallArgumentGeneric; +> = InvokeScriptCallArgumentGeneric<'integer', LONG>; export type InvokeScriptCallUnionArgument< -LONG = Long -> = InvokeScriptCallArgumentGeneric & { - valueType: InvokeArgumentType.BINARY - | InvokeArgumentType.BOOLEAN - | InvokeArgumentType.INTEGER - | InvokeArgumentType.STRING + LONG = Long +> = InvokeScriptCallArgumentGeneric<'union', LONG> & { + valueType: 'binary' | 'boolean' | 'integer' | 'string'; }; export type InvokeScriptCallListArgument< LONG, From 618737f1a11f9b256650bceb92a7d4bc6f028954 Mon Sep 17 00:00:00 2001 From: inazarov Date: Tue, 9 Nov 2021 12:18:23 +0300 Subject: [PATCH 8/9] version 1.0.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b9eb6da..3743ee0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@waves/ts-types", - "version": "1.0.6-beta.8", + "version": "1.0.7", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", "scripts": { From 08729488dc8d6664f66e5558f3da634b61f447b6 Mon Sep 17 00:00:00 2001 From: inazarov Date: Wed, 10 Nov 2021 13:06:06 +0300 Subject: [PATCH 9/9] InvokeScriptCallArgumentGeneric --- src/invoke.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/invoke.ts b/src/invoke.ts index 603e3c1..ec13e83 100644 --- a/src/invoke.ts +++ b/src/invoke.ts @@ -46,7 +46,10 @@ export type InvokeScriptCallIntegerArgument< > = InvokeScriptCallArgumentGeneric<'integer', LONG>; export type InvokeScriptCallUnionArgument< LONG = Long -> = InvokeScriptCallArgumentGeneric<'union', LONG> & { +> = InvokeScriptCallArgumentGeneric< + 'union', + LONG | string | Base64string | boolean +> & { valueType: 'binary' | 'boolean' | 'integer' | 'string'; }; export type InvokeScriptCallListArgument<