@stfy/test-contract-sdk
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -8,3 +8,3 @@ import { ContractTransactionResponse } from "@wavesenterprise/js-contract-grpc-client/contract/contract_contract_service"; | ||
start(): void; | ||
handle: (msg: ContractTransactionResponse) => Promise<void>; | ||
handle: (resp: ContractTransactionResponse) => Promise<void>; | ||
} |
@@ -12,10 +12,21 @@ "use strict"; | ||
this.log = (0, logger_1.logger)(this); | ||
this.handle = async (msg) => { | ||
this.log.info(JSON.stringify(msg)); | ||
this.handle = async (resp) => { | ||
this.log.info(JSON.stringify(resp)); | ||
if (!resp.transaction) { | ||
throw new Error('Transaction not provided'); | ||
} | ||
try { | ||
const entries = await this.workerPool.runTask(msg); | ||
const entries = await this.workerPool.runTask(resp); | ||
await this.rpc.Contract.commitExecutionSuccess({ | ||
txId: resp.transaction.id, | ||
results: entries | ||
}); | ||
this.log.info('worker result', entries); | ||
} | ||
catch (e) { | ||
this.log.error(e); | ||
await this.rpc.Contract.commitExecutionError({ | ||
txId: resp.transaction.id, | ||
code: e.number || 0, | ||
message: e.message, | ||
}); | ||
} | ||
@@ -22,0 +33,0 @@ }; |
@@ -7,3 +7,3 @@ import { ContractTransactionResponse } from "@wavesenterprise/js-contract-grpc-client/contract/contract_contract_service"; | ||
constructor(messagePort: MessagePort); | ||
handle: (resp: ContractTransactionResponse) => void; | ||
handle: (resp: ContractTransactionResponse) => Promise<void>; | ||
} |
@@ -12,3 +12,3 @@ "use strict"; | ||
this.messagePort = messagePort; | ||
this.handle = (resp) => { | ||
this.handle = async (resp) => { | ||
const ctx = new context_1.Context(resp); | ||
@@ -18,3 +18,3 @@ this.rpc.Contract | ||
try { | ||
const entries = this.processor.process(ctx); | ||
const entries = await this.processor.process(ctx); | ||
this.messagePort.postMessage(entries); | ||
@@ -21,0 +21,0 @@ } |
{ | ||
"name": "@stfy/test-contract-sdk", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Implements JS Contract SDK core functionality, rpc services, tools and utilities.", | ||
@@ -5,0 +5,0 @@ "private": false, |
@@ -7,2 +7,3 @@ import {ContractTransactionResponse} from "@wavesenterprise/js-contract-grpc-client/contract/contract_contract_service"; | ||
import * as path from "path"; | ||
import {DataEntry} from "@wavesenterprise/js-contract-grpc-client/data_entry"; | ||
@@ -32,14 +33,25 @@ export class Kernel { | ||
handle = async (msg: ContractTransactionResponse) => { | ||
this.log.info(JSON.stringify(msg)) | ||
handle = async (resp: ContractTransactionResponse) => { | ||
this.log.info(JSON.stringify(resp)) | ||
if (!resp.transaction) { | ||
throw new Error('Transaction not provided'); | ||
} | ||
try { | ||
const entries = await this.workerPool.runTask(msg); | ||
const entries = await this.workerPool.runTask<ContractTransactionResponse, DataEntry[]>(resp); | ||
await this.rpc.Contract.commitExecutionSuccess({ | ||
txId: resp.transaction.id, | ||
results: entries | ||
}) | ||
this.log.info('worker result', entries); | ||
}catch (e) { | ||
this.log.error(e) | ||
await this.rpc.Contract.commitExecutionError({ | ||
txId: resp.transaction.id, | ||
code: e.number || 0, | ||
message: e.message, | ||
}) | ||
} | ||
} | ||
} |
@@ -21,3 +21,3 @@ import {RPC} from "../../rpc"; | ||
handle = (resp: ContractTransactionResponse) => { | ||
handle = async (resp: ContractTransactionResponse) => { | ||
const ctx = new Context(resp); | ||
@@ -29,3 +29,3 @@ | ||
try { | ||
const entries = this.processor.process(ctx); | ||
const entries = await this.processor.process(ctx); | ||
@@ -32,0 +32,0 @@ this.messagePort.postMessage(entries); |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
196189
2918