From 069a25327931a8ed664b673ac301661c1b2904e1 Mon Sep 17 00:00:00 2001 From: tom Date: Mon, 14 Dec 2020 10:09:36 -0600 Subject: [PATCH 1/2] add support for personal->external add movement --- src/payload/payload.ts | 3 +++ src/payload/signingPayloadID.ts | 18 +++++++++++++----- src/signPayload/signPayload.ts | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/payload/payload.ts b/src/payload/payload.ts index 4f4fdafd..509964d9 100644 --- a/src/payload/payload.ts +++ b/src/payload/payload.ts @@ -14,6 +14,9 @@ export interface SignedState extends SyncState { export const MovementTypeDeposit = 'DEPOSIT' export const MovementTypeWithdrawal = 'WITHDRAWAL' +// This is used for personal -> external +export const MovementTypeTransfer = 'TRANSFER' + export const BuyOrSellBuy = 'BUY' export const BuyOrSellSell = 'SELL' diff --git a/src/payload/signingPayloadID.ts b/src/payload/signingPayloadID.ts index c1d3d645..cfa74f75 100644 --- a/src/payload/signingPayloadID.ts +++ b/src/payload/signingPayloadID.ts @@ -1,4 +1,4 @@ -import { MovementTypeWithdrawal, MovementTypeDeposit } from './payload' +import { MovementTypeWithdrawal, MovementTypeDeposit, MovementTypeTransfer } from './payload' /** * IDs mapping Nash Matching Engine operations with handling strategies. @@ -101,15 +101,20 @@ export function isStateSigning(kind: SigningPayloadID): boolean { return kind === SigningPayloadID.signStatesPayload } -export function needBlockchainSignature(kind: SigningPayloadID): boolean { - return ( +export function needBlockchainSignature(kind: SigningPayloadID, payload): boolean { + if ( [ SigningPayloadID.placeLimitOrderPayload, SigningPayloadID.placeMarketOrderPayload, SigningPayloadID.placeStopLimitOrderPayload, - SigningPayloadID.placeStopMarketOrderPayload, - SigningPayloadID.addMovementPayload + SigningPayloadID.placeStopMarketOrderPayload ].indexOf(kind) > -1 + ) { + return true + } + + return ( + kind === SigningPayloadID.addMovementPayload && [MovementTypeDeposit, MovementTypeWithdrawal].includes(payload.type) ) } @@ -139,6 +144,9 @@ export function kindToOrderPrefix(kind: SigningPayloadID, payload?: any): string if (kind === SigningPayloadID.addMovementPayload && payload.type === MovementTypeWithdrawal) { return '03' } + if (kind === SigningPayloadID.addMovementPayload && payload.type === MovementTypeTransfer) { + return '' + } throw new Error(`invalid kind given ${kindToName(kind)}`) } diff --git a/src/signPayload/signPayload.ts b/src/signPayload/signPayload.ts index 1698e2f5..40d38fd2 100644 --- a/src/signPayload/signPayload.ts +++ b/src/signPayload/signPayload.ts @@ -134,7 +134,7 @@ export default function signPayload( pers: null }) - if (needBlockchainSignature(kind)) { + if (needBlockchainSignature(kind, payload)) { if (config === undefined) { throw new Error('blockchain signatures needs a Config object') } @@ -208,7 +208,7 @@ export async function preSignPayload( pers: null }) - if (needBlockchainSignature(kind)) { + if (needBlockchainSignature(kind, payload)) { if (config == null) { throw new Error('blockchain signatures needs a Config object') } From bef69e8e4c17f08a7b1bf68ef288eb3a62563c43 Mon Sep 17 00:00:00 2001 From: tom Date: Wed, 16 Dec 2020 16:05:41 -0600 Subject: [PATCH 2/2] chore(release): 3.3.21 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f489c89..45a48feb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [3.3.21](https://github.com/nash-io/nash-protocol/compare/v3.3.11...v3.3.21) (2020-12-16) + ### [3.3.11](https://github.com/nash-io/nash-protocol/compare/v3.4.7...v3.3.11) (2020-08-11) ### [3.3.7](https://github.com/nash-io/nash-protocol/compare/v3.3.5...v3.3.7) (2020-07-16) diff --git a/package.json b/package.json index 2e1f54d7..a770fc8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@neon-exchange/nash-protocol", - "version": "3.3.12", + "version": "3.3.21", "description": "TypeScript implementation of Nash crypto routines", "main": "build/main/index.js", "typings": "build/main/index.d.ts",