diff --git a/packages/core/package.json b/packages/core/package.json index c224725..2430e76 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@emeraldpay/api", - "version": "0.4.3", + "version": "0.4.4-dev", "description": "Common code for Emerald gRPC APIs", "license": "Apache-2.0", "main": "lib/index.js", diff --git a/packages/core/src/typesTransaction.ts b/packages/core/src/typesTransaction.ts index dca5f60..4b8aec6 100644 --- a/packages/core/src/typesTransaction.ts +++ b/packages/core/src/typesTransaction.ts @@ -1,12 +1,6 @@ import * as transaction_message_pb from './generated/transaction.message_pb'; import { DataMapper } from './Publisher'; -import { - AnyAddress, - BlockInfo, - Blockchain, - ConvertCommon, - SingleAddress, -} from './typesCommon'; +import { AnyAddress, BlockInfo, Blockchain, ConvertCommon, SingleAddress } from './typesCommon'; import { MessageFactory } from './typesConvert'; export enum Direction { @@ -47,9 +41,10 @@ export interface AddressTransaction { cursor?: string; /** True if transaction is removed from blockchain */ removed: boolean; - /** True if transaction is failed */ + /** True if the transaction is failed */ failed: boolean; changes: Change[]; + txIndexInBlock?: number; } export interface AddressAmount { @@ -82,20 +77,31 @@ export class ConvertTransaction { } public getTransactionsRequest(req: GetTransactionsRequest): transaction_message_pb.GetTransactionsRequest { - const result: transaction_message_pb.GetTransactionsRequest = this.factory('transaction_message_pb.GetTransactionsRequest'); - return result - .setChain(req.blockchain.valueOf()) + const result: transaction_message_pb.GetTransactionsRequest = this.factory( + 'transaction_message_pb.GetTransactionsRequest', + ); + + result .setAddress(this.common.pbAnyAddress(req.address)) - .setCursor(req.cursor) + .setChain(req.blockchain.valueOf()) .setLimit(req.limit) .setUnspentOnly(req.onlyUnspent); + + if (req.cursor != null) { + result.setCursor(req.cursor); + } + + return result; } - public subscribeTransactionsRequest(req: SubscribeTransactionsRequest): transaction_message_pb.SubscribeTransactionsRequest { - const result: transaction_message_pb.SubscribeTransactionsRequest = this.factory('transaction_message_pb.SubscribeTransactionsRequest'); - return result - .setChain(req.blockchain.valueOf()) - .setAddress(this.common.pbAnyAddress(req.address)) + public subscribeTransactionsRequest( + req: SubscribeTransactionsRequest, + ): transaction_message_pb.SubscribeTransactionsRequest { + const result: transaction_message_pb.SubscribeTransactionsRequest = this.factory( + 'transaction_message_pb.SubscribeTransactionsRequest', + ); + + return result.setChain(req.blockchain.valueOf()).setAddress(this.common.pbAnyAddress(req.address)); } private static change(change: transaction_message_pb.Change): Change { @@ -117,25 +123,21 @@ export class ConvertTransaction { block = this.common.blockInfo(resp.getBlock()); } - const blockchain = resp.getChain().valueOf(); - const changes = resp.getChangesList().map((value) => ConvertTransaction.change(value)); const cursor = resp.getCursor(); - const mempool = resp.getMempool(); - const xpubIndex = resp.hasXpubIndex() ? resp.getXpubIndex().getValue() : undefined; return { block, - blockchain, - changes, - mempool, - xpubIndex, address: resp.getAddress().getAddress(), + blockchain: resp.getChain().valueOf(), + changes: resp.getChangesList().map((value) => ConvertTransaction.change(value)), cursor: cursor.length > 0 ? cursor : undefined, failed: resp.getFailed(), + mempool: resp.getMempool(), removed: resp.getRemoved(), txId: resp.getTxId(), + txIndexInBlock: block == null ? undefined : resp.getTxIndexInBlock(), + xpubIndex: resp.hasXpubIndex() ? resp.getXpubIndex().getValue() : undefined, }; }; } - } diff --git a/packages/node/package.json b/packages/node/package.json index 5794280..437a220 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -1,6 +1,6 @@ { "name": "@emeraldpay/api-node", - "version": "0.4.3", + "version": "0.4.4-dev", "description": "Node client for Emerald gRPC APIs", "license": "Apache-2.0", "main": "lib/index.js", @@ -32,7 +32,7 @@ "test": "jest" }, "dependencies": { - "@emeraldpay/api": "0.4.3", + "@emeraldpay/api": "0.4.4-dev", "@grpc/grpc-js": "^1.9.0", "google-protobuf": "^3.21.2", "protobufjs": "^7.2.4" diff --git a/packages/web/package.json b/packages/web/package.json index 90befc3..c0d18ae 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "@emeraldpay/api-web", - "version": "0.4.3", + "version": "0.4.4-dev", "description": "Browser client for Emerald gRPC APIs", "license": "Apache-2.0", "main": "lib/index.js", @@ -31,7 +31,7 @@ "test": "jest" }, "dependencies": { - "@emeraldpay/api": "0.4.3", + "@emeraldpay/api": "0.4.4-dev", "google-protobuf": "^3.21.2", "grpc-web": "^1.4.2", "protobufjs": "^7.2.4" diff --git a/yarn.lock b/yarn.lock index 93ed023..17dc62c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -480,7 +480,7 @@ __metadata: version: 0.0.0-use.local resolution: "@emeraldpay/api-node@workspace:packages/node" dependencies: - "@emeraldpay/api": 0.4.3 + "@emeraldpay/api": 0.4.4-dev "@grpc/grpc-js": ^1.9.0 "@grpc/proto-loader": ^0.7.8 "@types/google-protobuf": ^3.15.6 @@ -502,7 +502,7 @@ __metadata: version: 0.0.0-use.local resolution: "@emeraldpay/api-web@workspace:packages/web" dependencies: - "@emeraldpay/api": 0.4.3 + "@emeraldpay/api": 0.4.4-dev "@types/google-protobuf": ^3.15.6 "@types/jest": ^29.5.3 google-protobuf: ^3.21.2 @@ -520,7 +520,7 @@ __metadata: languageName: unknown linkType: soft -"@emeraldpay/api@0.4.3, @emeraldpay/api@workspace:packages/core": +"@emeraldpay/api@0.4.4-dev, @emeraldpay/api@workspace:packages/core": version: 0.0.0-use.local resolution: "@emeraldpay/api@workspace:packages/core" dependencies: