Skip to content

Commit

Permalink
feature/support_protobuf_txs_2
Browse files Browse the repository at this point in the history
  • Loading branch information
nazhmik committed Jul 30, 2020
1 parent 9ac6ae8 commit 8a60dde
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@waves/ledger": "^3.6.1",
"@waves/money-like-to-node": "0.0.10",
"@waves/ts-types": "^0.3.2",
"@waves/waves-transactions": "^4.0.0-beta.18",
"@waves/waves-transactions": "^4.0.0-beta.19",
"ramda": "^0.25.0"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/SeedAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export class SeedAdapter extends Adapter {
[SIGN_TYPE.CANCEL_ORDER]: [0, 1],
[SIGN_TYPE.COINOMAT_CONFIRMATION]: [1],
[SIGN_TYPE.WAVES_CONFIRMATION]: [1],
[SIGN_TYPE.ISSUE]: [2, 3],
[SIGN_TYPE.TRANSFER]: [2, 3],
[SIGN_TYPE.ISSUE]: [2, 3],
[SIGN_TYPE.REISSUE]: [2, 3],
[SIGN_TYPE.BURN]: [2, 3],
[SIGN_TYPE.EXCHANGE]: [0, 1, 2, 3],
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/WavesKeeperAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const DEFAULT_TX_VERSIONS = {
[SIGN_TYPE.CANCEL_ORDER]: [1],
[SIGN_TYPE.COINOMAT_CONFIRMATION]: [1],
[SIGN_TYPE.WAVES_CONFIRMATION]: [1],
[SIGN_TYPE.ISSUE]: [2, 3],
[SIGN_TYPE.TRANSFER]: [2, 3],
[SIGN_TYPE.ISSUE]: [2, 3],
[SIGN_TYPE.REISSUE]: [2, 3],
[SIGN_TYPE.BURN]: [2, 3],
[SIGN_TYPE.EXCHANGE]: [0, 1, 2, 3],
Expand Down
19 changes: 16 additions & 3 deletions src/prepareTx/constants.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { IAdapterSignMethods } from './interfaces';
import { libs } from '@waves/waves-transactions';
import { libs, protoPerialize } from '@waves/waves-transactions';
import * as wavesTransactions from '@waves/waves-transactions';
import { txToProtoBytes } from '@waves/waves-transactions/dist/proto-serialize';
import { toNode as mlToNode } from '@waves/money-like-to-node';
import { Money } from '@waves/data-entities';
import { prepare } from './prepare';
import processors = prepare.processors;
import { Money } from '@waves/data-entities';

const { LEN, SHORT, STRING, LONG, BASE58_STRING } = libs.marshall.serializePrimitives;
const { binary } = libs.marshall;
const { txToProtoBytes } = protoPerialize

const toNode = (data: any, convert?: Function) => {
const r = mlToNode(data);
Expand Down Expand Up @@ -173,6 +173,7 @@ export const SIGN_TYPES: Record<SIGN_TYPE, ITypesMap> = {
[SIGN_TYPE.TRANSFER]: {
getBytes: {
2: binary.serializeTx,
3: txToProtoBytes
},
toNode: (data, networkByte: number) => (toNode({
...data,
Expand All @@ -184,6 +185,7 @@ export const SIGN_TYPES: Record<SIGN_TYPE, ITypesMap> = {
[SIGN_TYPE.ISSUE]: {
getBytes: {
2: binary.serializeTx,
3: txToProtoBytes
},
toNode: data => toNode(
{
Expand All @@ -198,6 +200,7 @@ export const SIGN_TYPES: Record<SIGN_TYPE, ITypesMap> = {
[SIGN_TYPE.REISSUE]: {
getBytes: {
2: binary.serializeTx,
3: txToProtoBytes
},
toNode: data => {
const quantity = data.amount || data.quantity;
Expand All @@ -208,6 +211,7 @@ export const SIGN_TYPES: Record<SIGN_TYPE, ITypesMap> = {
[SIGN_TYPE.BURN]: {
getBytes: {
2: binary.serializeTx,
3: txToProtoBytes
},
toNode: data => {
const quantity = data.amount || data.quantity;
Expand All @@ -220,6 +224,7 @@ export const SIGN_TYPES: Record<SIGN_TYPE, ITypesMap> = {
0: (data) => binary.serializeTx({ ...data, version: 1 }),
1: binary.serializeTx,
2: binary.serializeTx,
3: txToProtoBytes
},
toNode: data => {
const tx = toNode(data);
Expand All @@ -236,6 +241,7 @@ export const SIGN_TYPES: Record<SIGN_TYPE, ITypesMap> = {
[SIGN_TYPE.LEASE]: {
getBytes: {
2: binary.serializeTx,
3: txToProtoBytes
},
toNode: (data, networkByte: number) => (toNode({
...data,
Expand All @@ -246,13 +252,15 @@ export const SIGN_TYPES: Record<SIGN_TYPE, ITypesMap> = {
[SIGN_TYPE.CANCEL_LEASING]: {
getBytes: {
2: binary.serializeTx,
3: txToProtoBytes
},
toNode: data => toNode(data, wavesTransactions.cancelLease),
adapter: 'signTransaction'
},
[SIGN_TYPE.CREATE_ALIAS]: {
getBytes: {
2: binary.serializeTx,
3: txToProtoBytes
},
toNode: data => ({ ...toNode(data, wavesTransactions.alias), chainId: data.chainId }),
adapter: 'signTransaction'
Expand All @@ -261,6 +269,7 @@ export const SIGN_TYPES: Record<SIGN_TYPE, ITypesMap> = {
getBytes: {
0: binary.serializeTx,
1: binary.serializeTx,
2: txToProtoBytes
},
toNode: (data, networkByte: number) => (toNode({
...data,
Expand All @@ -277,6 +286,7 @@ export const SIGN_TYPES: Record<SIGN_TYPE, ITypesMap> = {
getBytes: {
0: binary.serializeTx,
1: binary.serializeTx,
2: txToProtoBytes
},
toNode: data => toNode(data, wavesTransactions.data),
adapter: 'signTransaction'
Expand All @@ -300,6 +310,7 @@ export const SIGN_TYPES: Record<SIGN_TYPE, ITypesMap> = {
getBytes: {
0: binary.serializeTx,
1: binary.serializeTx,
2: txToProtoBytes
},
toNode: data => toNode(data, wavesTransactions.sponsorship),
adapter: 'signTransaction'
Expand All @@ -308,6 +319,7 @@ export const SIGN_TYPES: Record<SIGN_TYPE, ITypesMap> = {
getBytes: {
0: binary.serializeTx,
1: binary.serializeTx,
2: txToProtoBytes
},
toNode: data => toNode({
...data,
Expand All @@ -321,6 +333,7 @@ export const SIGN_TYPES: Record<SIGN_TYPE, ITypesMap> = {
getBytes: {
0: binary.serializeTx,
1: binary.serializeTx,
2: txToProtoBytes
},
toNode: (data, networkByte: number) => (toNode({
...data,
Expand Down

0 comments on commit 8a60dde

Please sign in to comment.