Skip to content

Commit

Permalink
Merge pull request #29 from tonlabs/0.7.1-rc
Browse files Browse the repository at this point in the history
0.7.1 rc
  • Loading branch information
elasticLove1 committed Nov 9, 2022
2 parents 742a411 + 21e350c commit 4765308
Show file tree
Hide file tree
Showing 494 changed files with 1,817 additions and 706 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.


## [0.7.1] – 2022-11-09

### New

- additional logic to detect errors during making/canceling of orders

### Fixed

- optimization for first step of the makeOrder and cancelOrder

## [0.7.0] – 2022-11-08

### New
Expand Down
8 changes: 5 additions & 3 deletions contracts/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,24 @@ export function resolveContractError(
export function findTransactionError(
transaction: DerivativeTransaction,
contract: AccountClass,
altErrorCode: number = 0,
): Error | undefined {
const {
id,
aborted,
compute: { exit_code },
account_addr,
} = transaction;
if (!aborted && exit_code === 0) {
const errorCode = exit_code !== 0 ? exit_code : altErrorCode;
if (!aborted && errorCode === 0) {
return undefined;
}
if (exit_code === 0) {
if (errorCode === 0) {
return Error(
`Transaction [${id}] on ${contract}[${account_addr}] was aborted.`,
);
}
const error = errorFromExitCode(contract, exit_code);
const error = errorFromExitCode(contract, errorCode);
error.data = {
...error.data,
address: account_addr,
Expand Down
2 changes: 1 addition & 1 deletion dist/contracts/errors.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export declare type ContractError = Error & {
};
export declare function errorFromExitCode(contract: AccountClass, exitCode: number): ContractError;
export declare function resolveContractError(originalError: ContractError, contract: AccountClass): ContractError;
export declare function findTransactionError(transaction: DerivativeTransaction, contract: AccountClass): Error | undefined;
export declare function findTransactionError(transaction: DerivativeTransaction, contract: AccountClass, altErrorCode?: number): Error | undefined;
//# sourceMappingURL=errors.d.ts.map
9 changes: 5 additions & 4 deletions dist/contracts/errors.js

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

2 changes: 1 addition & 1 deletion dist/examples/cancel-order.js

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

9 changes: 4 additions & 5 deletions dist/examples/make-order.js

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

36 changes: 21 additions & 15 deletions dist/flex/trader/cancel-order.js

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

2 changes: 1 addition & 1 deletion dist/flex/trader/index.js

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

4 changes: 2 additions & 2 deletions dist/flex/trader/make-order.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export declare type MakeOrderResult = {
orderId: string;
} & (MakeOrderStarting | MakeOrderFinalizing | MakeOrderSuccess | MakeOrderError);
export declare function makeOrder(flex: Flex, options: MakeOrderOptions): Promise<MakeOrderResult>;
export declare function waitForMakeOrder(flex: Flex, result: MakeOrderResult): Promise<MakeOrderResult>;
export declare function finalizeMakeOrder(flex: Flex, result: MakeOrderResult, startingTransactionId: string, priceTransactionRequired: boolean): Promise<MakeOrderResult>;
export declare function waitForMakeOrder(evr: Evr, result: MakeOrderResult): Promise<MakeOrderResult>;
export declare function finalizeMakeOrder(evr: Evr, result: MakeOrderResult, startingTransactionId: string, priceTransactionRequired: boolean): Promise<MakeOrderResult>;
export declare function generateRandomOrderId(evr: Evr): Promise<string>;
export {};
//# sourceMappingURL=make-order.d.ts.map
60 changes: 39 additions & 21 deletions dist/flex/trader/make-order.js

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

54 changes: 54 additions & 0 deletions dist/flex/trader/processing.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { DerivativeTransaction } from "../web3/accounts";
import { AccountClass } from "../../contracts/account-ex";
export declare enum ProcessingStatus {
STARTING = 0,
FINALIZING = 1,
SUCCESS = 2,
ERROR = 3
}
declare type StartingState<P> = {
status: ProcessingStatus.STARTING;
params: P;
message: string;
shard_block_id: string;
};
declare type FinalizingState<P> = {
status: ProcessingStatus.FINALIZING;
params: P;
startingTransactionId: string;
};
declare type SuccessState = {
status: ProcessingStatus.SUCCESS;
startingTransactionId: string;
finalizingTransactions: string[];
};
declare type ErrorState = {
status: ProcessingStatus.ERROR;
error: ErrorInfo;
};
declare type ErrorInfo = {
message: string;
code?: number;
data?: any;
};
export declare type SdkError = Error & {
code?: number;
data?: {
local_error?: {
code: number;
data?: {
exit_code?: number;
};
};
};
};
export declare type ProcessingResult<R, P> = R & (StartingState<P> | FinalizingState<P> | SuccessState | ErrorState);
export declare function processingError<R>(result: R, error: Error): ProcessingResult<R, any>;
export declare function resolveDerivativeTransaction<R>(transactions: {
[address: string]: DerivativeTransaction;
}, address: string, contract: AccountClass, result: R, toSuccess: (transaction: DerivativeTransaction) => R, toError: (error: Error) => R): {
result: R;
transaction: DerivativeTransaction | undefined;
};
export {};
//# sourceMappingURL=processing.d.ts.map
Loading

0 comments on commit 4765308

Please sign in to comment.