Comparing version 21.1.0-27-2e51a04 to 21.1.0-28-3664985
@@ -106,2 +106,4 @@ /** | ||
private tryGetBlockHeaderState; | ||
private tryGetBlockInfo; | ||
private tryRefBlockFromGetInfo; | ||
with(accountName: string): ActionBuilder; | ||
@@ -108,0 +110,0 @@ buildTransaction(cb?: (tx: TransactionBuilder) => void): void | TransactionBuilder; |
@@ -479,3 +479,3 @@ "use strict"; | ||
info = _c.sent(); | ||
return [4 /*yield*/, this.rpc.get_block(info.last_irreversible_block_num)]; | ||
return [4 /*yield*/, this.tryRefBlockFromGetInfo(info)]; | ||
case 2: | ||
@@ -570,3 +570,3 @@ refBlock = _c.sent(); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var taposBlockNumber, refBlock, _a; | ||
var block, taposBlockNumber, refBlock, _a; | ||
return __generator(this, function (_b) { | ||
@@ -581,14 +581,19 @@ switch (_b.label) { | ||
case 2: | ||
taposBlockNumber = useLastIrreversible | ||
? info.last_irreversible_block_num : info.head_block_num - blocksBehind; | ||
if (!(taposBlockNumber <= info.last_irreversible_block_num)) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, this.rpc.get_block(taposBlockNumber)]; | ||
if (!useLastIrreversible) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, this.tryRefBlockFromGetInfo(info)]; | ||
case 3: | ||
_a = _b.sent(); | ||
return [3 /*break*/, 6]; | ||
case 4: return [4 /*yield*/, this.tryGetBlockHeaderState(taposBlockNumber)]; | ||
block = _b.sent(); | ||
return [2 /*return*/, __assign(__assign({}, ser.transactionHeader(block, expireSeconds)), transaction)]; | ||
case 4: | ||
taposBlockNumber = info.head_block_num - blocksBehind; | ||
if (!(taposBlockNumber <= info.last_irreversible_block_num)) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, this.tryGetBlockInfo(taposBlockNumber)]; | ||
case 5: | ||
_a = _b.sent(); | ||
_b.label = 6; | ||
case 6: | ||
return [3 /*break*/, 8]; | ||
case 6: return [4 /*yield*/, this.tryGetBlockHeaderState(taposBlockNumber)]; | ||
case 7: | ||
_a = _b.sent(); | ||
_b.label = 8; | ||
case 8: | ||
refBlock = _a; | ||
@@ -616,3 +621,3 @@ return [2 /*return*/, __assign(__assign({}, ser.transactionHeader(refBlock, expireSeconds)), transaction)]; | ||
error_1 = _a.sent(); | ||
return [4 /*yield*/, this.rpc.get_block(taposBlockNumber)]; | ||
return [4 /*yield*/, this.tryGetBlockInfo(taposBlockNumber)]; | ||
case 3: return [2 /*return*/, _a.sent()]; | ||
@@ -624,2 +629,46 @@ case 4: return [2 /*return*/]; | ||
}; | ||
Api.prototype.tryGetBlockInfo = function (blockNumber) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var error_2; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 4]); | ||
return [4 /*yield*/, this.rpc.get_block_info(blockNumber)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
case 2: | ||
error_2 = _a.sent(); | ||
return [4 /*yield*/, this.rpc.get_block(blockNumber)]; | ||
case 3: return [2 /*return*/, _a.sent()]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
Api.prototype.tryRefBlockFromGetInfo = function (info) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var block; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!(info.hasOwnProperty('last_irreversible_block_id') && | ||
info.hasOwnProperty('last_irreversible_block_num') && | ||
info.hasOwnProperty('last_irreversible_block_time'))) return [3 /*break*/, 1]; | ||
return [2 /*return*/, { | ||
block_num: info.last_irreversible_block_num, | ||
id: info.last_irreversible_block_id, | ||
timestamp: info.last_irreversible_block_time, | ||
}]; | ||
case 1: return [4 /*yield*/, this.tryGetBlockInfo(info.last_irreversible_block_num)]; | ||
case 2: | ||
block = _a.sent(); | ||
return [2 /*return*/, { | ||
block_num: block.block_num, | ||
id: block.id, | ||
timestamp: block.timestamp, | ||
}]; | ||
} | ||
}); | ||
}); | ||
}; | ||
Api.prototype.with = function (accountName) { | ||
@@ -626,0 +675,0 @@ return new ActionBuilder(this, accountName); |
@@ -5,3 +5,3 @@ /** | ||
import { AbiProvider, AuthorityProvider, AuthorityProviderArgs, BinaryAbi } from './eosjs-api-interfaces'; | ||
import { GetAbiResult, GetBlockResult, GetCodeResult, GetInfoResult, GetRawCodeAndAbiResult, PushTransactionArgs, GetBlockHeaderStateResult } from './eosjs-rpc-interfaces'; | ||
import { GetAbiResult, GetBlockInfoResult, GetBlockResult, GetCodeResult, GetInfoResult, GetRawCodeAndAbiResult, GetRawAbiResult, PushTransactionArgs, GetBlockHeaderStateResult } from './eosjs-rpc-interfaces'; | ||
/** Make RPC calls */ | ||
@@ -28,2 +28,4 @@ export declare class JsonRpc implements AuthorityProvider, AbiProvider { | ||
get_block_header_state(blockNumOrId: number | string): Promise<GetBlockHeaderStateResult>; | ||
/** Raw call to `/v1/chain/get_block_info` */ | ||
get_block_info(blockNum: number): Promise<GetBlockInfoResult>; | ||
/** Raw call to `/v1/chain/get_block` */ | ||
@@ -47,2 +49,4 @@ get_block(blockNumOrId: number | string): Promise<GetBlockResult>; | ||
getRawAbi(accountName: string): Promise<BinaryAbi>; | ||
/** Raw call to `/v1/chain/get_raw_abi` */ | ||
get_raw_abi(accountName: string): Promise<GetRawAbiResult>; | ||
/** Raw call to `/v1/chain/get_scheduled_transactions` */ | ||
@@ -49,0 +53,0 @@ get_scheduled_transactions(json?: boolean, lowerBound?: string, limit?: number): Promise<any>; |
@@ -161,2 +161,13 @@ "use strict"; | ||
}; | ||
/** Raw call to `/v1/chain/get_block_info` */ | ||
JsonRpc.prototype.get_block_info = function (blockNum) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('/v1/chain/get_block_info', { block_num: blockNum })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** Raw call to `/v1/chain/get_block` */ | ||
@@ -258,13 +269,12 @@ JsonRpc.prototype.get_block = function (blockNumOrId) { | ||
/** calls `/v1/chain/get_raw_code_and_abi` and pulls out unneeded raw wasm code */ | ||
// TODO: use `/v1/chain/get_raw_abi` directly when it becomes available | ||
JsonRpc.prototype.getRawAbi = function (accountName) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var rawCodeAndAbi, abi; | ||
var rawAbi, abi; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.get_raw_code_and_abi(accountName)]; | ||
case 0: return [4 /*yield*/, this.get_raw_abi(accountName)]; | ||
case 1: | ||
rawCodeAndAbi = _a.sent(); | ||
abi = eosjs_numeric_1.base64ToBinary(rawCodeAndAbi.abi); | ||
return [2 /*return*/, { accountName: rawCodeAndAbi.account_name, abi: abi }]; | ||
rawAbi = _a.sent(); | ||
abi = eosjs_numeric_1.base64ToBinary(rawAbi.abi); | ||
return [2 /*return*/, { accountName: rawAbi.account_name, abi: abi }]; | ||
} | ||
@@ -274,2 +284,13 @@ }); | ||
}; | ||
/** Raw call to `/v1/chain/get_raw_abi` */ | ||
JsonRpc.prototype.get_raw_abi = function (accountName) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('/v1/chain/get_raw_abi', { account_name: accountName })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** Raw call to `/v1/chain/get_scheduled_transactions` */ | ||
@@ -276,0 +297,0 @@ JsonRpc.prototype.get_scheduled_transactions = function (json, lowerBound, limit) { |
@@ -68,2 +68,16 @@ /** | ||
} | ||
/** Return value of `/v1/chain/get_block_info` */ | ||
export interface GetBlockInfoResult { | ||
timestamp: string; | ||
producer: string; | ||
confirmed: number; | ||
previous: string; | ||
transaction_mroot: string; | ||
action_mroot: string; | ||
schedule_version: number; | ||
producer_signature: string; | ||
id: string; | ||
block_num: number; | ||
ref_block_prefix: number; | ||
} | ||
/** Return value of `/v1/chain/get_block` */ | ||
@@ -127,2 +141,3 @@ export interface GetBlockResult { | ||
last_irreversible_block_id: string; | ||
last_irreversible_block_time: string; | ||
head_block_id: string; | ||
@@ -142,2 +157,8 @@ head_block_time: string; | ||
} | ||
export interface GetRawAbiResult { | ||
account_name: string; | ||
code_hash: string; | ||
abi_hash: string; | ||
abi: string; | ||
} | ||
/** Arguments for `push_transaction` */ | ||
@@ -144,0 +165,0 @@ export interface PushTransactionArgs { |
{ | ||
"name": "eosjs", | ||
"version": "21.1.0-27-2e51a04", | ||
"version": "21.1.0-28-3664985", | ||
"description": "Talk to eos API", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
380162
5727