diff --git a/common/config/rush/deploy.json b/common/config/rush/deploy.json index 1fedb0fdb..15bd5af2b 100644 --- a/common/config/rush/deploy.json +++ b/common/config/rush/deploy.json @@ -26,8 +26,7 @@ "@subsquid/substrate-ingest", "@subsquid/substrate-metadata-service", "@subsquid/tron-dump", - "@subsquid/tron-ingest", - "chain-status-service" + "@subsquid/tron-ingest" ], /** diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index c985c36ec..000000000 --- a/package-lock.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "squid", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "devDependencies": { - "typescript": "^5.3.2" - } - }, - "node_modules/typescript": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.2.tgz", - "integrity": "sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - } - }, - "dependencies": { - "typescript": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.2.tgz", - "integrity": "sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==", - "dev": true - } - } -} diff --git a/package.json b/package.json deleted file mode 100644 index 633444bc9..000000000 --- a/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "devDependencies": { - "typescript": "^5.3.2" - } -} diff --git a/substrate/substrate-ingest/package.json b/substrate/substrate-ingest/package.json index e24a65d24..7835a9cbb 100644 --- a/substrate/substrate-ingest/package.json +++ b/substrate/substrate-ingest/package.json @@ -28,7 +28,6 @@ "@subsquid/util-internal-json": "^1.2.3" }, "devDependencies": { - "@types/node": "^18.18.14", - "typescript": "~5.2.2" + "@types/node": "^18.18.14" } } diff --git a/test/tron-usdt/package.json b/test/tron-usdt/package.json index 007ce0fba..5db5e6cb0 100644 --- a/test/tron-usdt/package.json +++ b/test/tron-usdt/package.json @@ -19,6 +19,8 @@ }, "devDependencies": { "@subsquid/evm-typegen": "^4.3.0", + "@subsquid/evm-codec": "^0.3.0", + "@subsquid/evm-abi": "^0.3.1", "@subsquid/typeorm-codegen": "^2.0.2", "@types/node": "^18.18.14", "typescript": "~5.3.2" diff --git a/test/tron-usdt/src/abi/erc20.ts b/test/tron-usdt/src/abi/erc20.ts index 649bd5bd5..1998bad0a 100644 --- a/test/tron-usdt/src/abi/erc20.ts +++ b/test/tron-usdt/src/abi/erc20.ts @@ -1,221 +1,244 @@ -import * as ethers from 'ethers' -import {LogEvent, Func, ContractBase} from './abi.support' -import {ABI_JSON} from './erc20.abi' - -export const abi = new ethers.Interface(ABI_JSON); +import * as p from '@subsquid/evm-codec' +import { event, fun, viewFun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' export const events = { - DestroyedBlackFunds: new LogEvent<([_blackListedUser: string, _balance: bigint] & {_blackListedUser: string, _balance: bigint})>( - abi, '0x61e6e66b0d6339b2980aecc6ccc0039736791f0ccde9ed512e789a7fbdd698c6' - ), - Issue: new LogEvent<([amount: bigint] & {amount: bigint})>( - abi, '0xcb8241adb0c3fdb35b70c24ce35c5eb0c17af7431c99f827d44a445ca624176a' - ), - Redeem: new LogEvent<([amount: bigint] & {amount: bigint})>( - abi, '0x702d5967f45f6513a38ffc42d6ba9bf230bd40e8f53b16363c7eb4fd2deb9a44' - ), - Deprecate: new LogEvent<([newAddress: string] & {newAddress: string})>( - abi, '0xcc358699805e9a8b7f77b522628c7cb9abd07d9efb86b6fb616af1609036a99e' - ), - AddedBlackList: new LogEvent<([_user: string] & {_user: string})>( - abi, '0x42e160154868087d6bfdc0ca23d96a1c1cfa32f1b72ba9ba27b69b98a0d819dc' - ), - RemovedBlackList: new LogEvent<([_user: string] & {_user: string})>( - abi, '0xd7e9ec6e6ecd65492dce6bf513cd6867560d49544421d0783ddf06e76c24470c' - ), - Params: new LogEvent<([feeBasisPoints: bigint, maxFee: bigint] & {feeBasisPoints: bigint, maxFee: bigint})>( - abi, '0xb044a1e409eac5c48e5af22d4af52670dd1a99059537a78b31b48c6500a6354e' - ), - Pause: new LogEvent<[]>( - abi, '0x6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff625' - ), - Unpause: new LogEvent<[]>( - abi, '0x7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b33' - ), - OwnershipTransferred: new LogEvent<([previousOwner: string, newOwner: string] & {previousOwner: string, newOwner: string})>( - abi, '0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0' - ), - Approval: new LogEvent<([owner: string, spender: string, value: bigint] & {owner: string, spender: string, value: bigint})>( - abi, '0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925' - ), - Transfer: new LogEvent<([from: string, to: string, value: bigint] & {from: string, to: string, value: bigint})>( - abi, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - ), + DestroyedBlackFunds: event("0x61e6e66b0d6339b2980aecc6ccc0039736791f0ccde9ed512e789a7fbdd698c6", "DestroyedBlackFunds(address,uint256)", {"_blackListedUser": indexed(p.address), "_balance": p.uint256}), + Issue: event("0xcb8241adb0c3fdb35b70c24ce35c5eb0c17af7431c99f827d44a445ca624176a", "Issue(uint256)", {"amount": p.uint256}), + Redeem: event("0x702d5967f45f6513a38ffc42d6ba9bf230bd40e8f53b16363c7eb4fd2deb9a44", "Redeem(uint256)", {"amount": p.uint256}), + Deprecate: event("0xcc358699805e9a8b7f77b522628c7cb9abd07d9efb86b6fb616af1609036a99e", "Deprecate(address)", {"newAddress": p.address}), + AddedBlackList: event("0x42e160154868087d6bfdc0ca23d96a1c1cfa32f1b72ba9ba27b69b98a0d819dc", "AddedBlackList(address)", {"_user": indexed(p.address)}), + RemovedBlackList: event("0xd7e9ec6e6ecd65492dce6bf513cd6867560d49544421d0783ddf06e76c24470c", "RemovedBlackList(address)", {"_user": indexed(p.address)}), + Params: event("0xb044a1e409eac5c48e5af22d4af52670dd1a99059537a78b31b48c6500a6354e", "Params(uint256,uint256)", {"feeBasisPoints": p.uint256, "maxFee": p.uint256}), + Pause: event("0x6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff625", "Pause()", {}), + Unpause: event("0x7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b33", "Unpause()", {}), + OwnershipTransferred: event("0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "OwnershipTransferred(address,address)", {"previousOwner": indexed(p.address), "newOwner": indexed(p.address)}), + Approval: event("0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925", "Approval(address,address,uint256)", {"owner": indexed(p.address), "spender": indexed(p.address), "value": p.uint256}), + Transfer: event("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "Transfer(address,address,uint256)", {"from": indexed(p.address), "to": indexed(p.address), "value": p.uint256}), } export const functions = { - name: new Func<[], {}, string>( - abi, '0x06fdde03' - ), - deprecate: new Func<[_upgradedAddress: string], {_upgradedAddress: string}, []>( - abi, '0x0753c30c' - ), - approve: new Func<[_spender: string, _value: bigint], {_spender: string, _value: bigint}, boolean>( - abi, '0x095ea7b3' - ), - deprecated: new Func<[], {}, boolean>( - abi, '0x0e136b19' - ), - addBlackList: new Func<[_evilUser: string], {_evilUser: string}, []>( - abi, '0x0ecb93c0' - ), - totalSupply: new Func<[], {}, bigint>( - abi, '0x18160ddd' - ), - transferFrom: new Func<[_from: string, _to: string, _value: bigint], {_from: string, _to: string, _value: bigint}, boolean>( - abi, '0x23b872dd' - ), - upgradedAddress: new Func<[], {}, string>( - abi, '0x26976e3f' - ), - decimals: new Func<[], {}, number>( - abi, '0x313ce567' - ), - maximumFee: new Func<[], {}, bigint>( - abi, '0x35390714' - ), - _totalSupply: new Func<[], {}, bigint>( - abi, '0x3eaaf86b' - ), - unpause: new Func<[], {}, []>( - abi, '0x3f4ba83a' - ), - getBlackListStatus: new Func<[_maker: string], {_maker: string}, boolean>( - abi, '0x59bf1abe' - ), - paused: new Func<[], {}, boolean>( - abi, '0x5c975abb' - ), - decreaseApproval: new Func<[_spender: string, _subtractedValue: bigint], {_spender: string, _subtractedValue: bigint}, boolean>( - abi, '0x66188463' - ), - balanceOf: new Func<[who: string], {who: string}, bigint>( - abi, '0x70a08231' - ), - calcFee: new Func<[_value: bigint], {_value: bigint}, bigint>( - abi, '0x75dc7d8c' - ), - pause: new Func<[], {}, []>( - abi, '0x8456cb59' - ), - owner: new Func<[], {}, string>( - abi, '0x8da5cb5b' - ), - symbol: new Func<[], {}, string>( - abi, '0x95d89b41' - ), - transfer: new Func<[_to: string, _value: bigint], {_to: string, _value: bigint}, boolean>( - abi, '0xa9059cbb' - ), - oldBalanceOf: new Func<[who: string], {who: string}, bigint>( - abi, '0xb7a3446c' - ), - setParams: new Func<[newBasisPoints: bigint, newMaxFee: bigint], {newBasisPoints: bigint, newMaxFee: bigint}, []>( - abi, '0xc0324c77' - ), - issue: new Func<[amount: bigint], {amount: bigint}, []>( - abi, '0xcc872b66' - ), - increaseApproval: new Func<[_spender: string, _addedValue: bigint], {_spender: string, _addedValue: bigint}, boolean>( - abi, '0xd73dd623' - ), - redeem: new Func<[amount: bigint], {amount: bigint}, []>( - abi, '0xdb006a75' - ), - allowance: new Func<[_owner: string, _spender: string], {_owner: string, _spender: string}, bigint>( - abi, '0xdd62ed3e' - ), - basisPointsRate: new Func<[], {}, bigint>( - abi, '0xdd644f72' - ), - isBlackListed: new Func<[_: string], {}, boolean>( - abi, '0xe47d6060' - ), - removeBlackList: new Func<[_clearedUser: string], {_clearedUser: string}, []>( - abi, '0xe4997dc5' - ), - MAX_UINT: new Func<[], {}, bigint>( - abi, '0xe5b5019a' - ), - transferOwnership: new Func<[newOwner: string], {newOwner: string}, []>( - abi, '0xf2fde38b' - ), - destroyBlackFunds: new Func<[_blackListedUser: string], {_blackListedUser: string}, []>( - abi, '0xf3bdc228' - ), + name: viewFun("0x06fdde03", "name()", {}, p.string), + deprecate: fun("0x0753c30c", "deprecate(address)", {"_upgradedAddress": p.address}, ), + approve: fun("0x095ea7b3", "approve(address,uint256)", {"_spender": p.address, "_value": p.uint256}, p.bool), + deprecated: viewFun("0x0e136b19", "deprecated()", {}, p.bool), + addBlackList: fun("0x0ecb93c0", "addBlackList(address)", {"_evilUser": p.address}, ), + totalSupply: viewFun("0x18160ddd", "totalSupply()", {}, p.uint256), + transferFrom: fun("0x23b872dd", "transferFrom(address,address,uint256)", {"_from": p.address, "_to": p.address, "_value": p.uint256}, p.bool), + upgradedAddress: viewFun("0x26976e3f", "upgradedAddress()", {}, p.address), + decimals: viewFun("0x313ce567", "decimals()", {}, p.uint8), + maximumFee: viewFun("0x35390714", "maximumFee()", {}, p.uint256), + _totalSupply: viewFun("0x3eaaf86b", "_totalSupply()", {}, p.uint256), + unpause: fun("0x3f4ba83a", "unpause()", {}, ), + getBlackListStatus: viewFun("0x59bf1abe", "getBlackListStatus(address)", {"_maker": p.address}, p.bool), + paused: viewFun("0x5c975abb", "paused()", {}, p.bool), + decreaseApproval: fun("0x66188463", "decreaseApproval(address,uint256)", {"_spender": p.address, "_subtractedValue": p.uint256}, p.bool), + balanceOf: viewFun("0x70a08231", "balanceOf(address)", {"who": p.address}, p.uint256), + calcFee: viewFun("0x75dc7d8c", "calcFee(uint256)", {"_value": p.uint256}, p.uint256), + pause: fun("0x8456cb59", "pause()", {}, ), + owner: viewFun("0x8da5cb5b", "owner()", {}, p.address), + symbol: viewFun("0x95d89b41", "symbol()", {}, p.string), + transfer: fun("0xa9059cbb", "transfer(address,uint256)", {"_to": p.address, "_value": p.uint256}, p.bool), + oldBalanceOf: viewFun("0xb7a3446c", "oldBalanceOf(address)", {"who": p.address}, p.uint256), + setParams: fun("0xc0324c77", "setParams(uint256,uint256)", {"newBasisPoints": p.uint256, "newMaxFee": p.uint256}, ), + issue: fun("0xcc872b66", "issue(uint256)", {"amount": p.uint256}, ), + increaseApproval: fun("0xd73dd623", "increaseApproval(address,uint256)", {"_spender": p.address, "_addedValue": p.uint256}, p.bool), + redeem: fun("0xdb006a75", "redeem(uint256)", {"amount": p.uint256}, ), + allowance: viewFun("0xdd62ed3e", "allowance(address,address)", {"_owner": p.address, "_spender": p.address}, p.uint256), + basisPointsRate: viewFun("0xdd644f72", "basisPointsRate()", {}, p.uint256), + isBlackListed: viewFun("0xe47d6060", "isBlackListed(address)", {"_0": p.address}, p.bool), + removeBlackList: fun("0xe4997dc5", "removeBlackList(address)", {"_clearedUser": p.address}, ), + MAX_UINT: viewFun("0xe5b5019a", "MAX_UINT()", {}, p.uint256), + transferOwnership: fun("0xf2fde38b", "transferOwnership(address)", {"newOwner": p.address}, ), + destroyBlackFunds: fun("0xf3bdc228", "destroyBlackFunds(address)", {"_blackListedUser": p.address}, ), } export class Contract extends ContractBase { - name(): Promise { - return this.eth_call(functions.name, []) + name() { + return this.eth_call(functions.name, {}) } - deprecated(): Promise { - return this.eth_call(functions.deprecated, []) + deprecated() { + return this.eth_call(functions.deprecated, {}) } - totalSupply(): Promise { - return this.eth_call(functions.totalSupply, []) + totalSupply() { + return this.eth_call(functions.totalSupply, {}) } - upgradedAddress(): Promise { - return this.eth_call(functions.upgradedAddress, []) + upgradedAddress() { + return this.eth_call(functions.upgradedAddress, {}) } - decimals(): Promise { - return this.eth_call(functions.decimals, []) + decimals() { + return this.eth_call(functions.decimals, {}) } - maximumFee(): Promise { - return this.eth_call(functions.maximumFee, []) + maximumFee() { + return this.eth_call(functions.maximumFee, {}) } - _totalSupply(): Promise { - return this.eth_call(functions._totalSupply, []) + _totalSupply() { + return this.eth_call(functions._totalSupply, {}) } - getBlackListStatus(_maker: string): Promise { - return this.eth_call(functions.getBlackListStatus, [_maker]) + getBlackListStatus(_maker: GetBlackListStatusParams["_maker"]) { + return this.eth_call(functions.getBlackListStatus, {_maker}) } - paused(): Promise { - return this.eth_call(functions.paused, []) + paused() { + return this.eth_call(functions.paused, {}) } - balanceOf(who: string): Promise { - return this.eth_call(functions.balanceOf, [who]) + balanceOf(who: BalanceOfParams["who"]) { + return this.eth_call(functions.balanceOf, {who}) } - calcFee(_value: bigint): Promise { - return this.eth_call(functions.calcFee, [_value]) + calcFee(_value: CalcFeeParams["_value"]) { + return this.eth_call(functions.calcFee, {_value}) } - owner(): Promise { - return this.eth_call(functions.owner, []) + owner() { + return this.eth_call(functions.owner, {}) } - symbol(): Promise { - return this.eth_call(functions.symbol, []) + symbol() { + return this.eth_call(functions.symbol, {}) } - oldBalanceOf(who: string): Promise { - return this.eth_call(functions.oldBalanceOf, [who]) + oldBalanceOf(who: OldBalanceOfParams["who"]) { + return this.eth_call(functions.oldBalanceOf, {who}) } - allowance(_owner: string, _spender: string): Promise { - return this.eth_call(functions.allowance, [_owner, _spender]) + allowance(_owner: AllowanceParams["_owner"], _spender: AllowanceParams["_spender"]) { + return this.eth_call(functions.allowance, {_owner, _spender}) } - basisPointsRate(): Promise { - return this.eth_call(functions.basisPointsRate, []) + basisPointsRate() { + return this.eth_call(functions.basisPointsRate, {}) } - isBlackListed(arg0: string): Promise { - return this.eth_call(functions.isBlackListed, [arg0]) + isBlackListed(_0: IsBlackListedParams["_0"]) { + return this.eth_call(functions.isBlackListed, {_0}) } - MAX_UINT(): Promise { - return this.eth_call(functions.MAX_UINT, []) + MAX_UINT() { + return this.eth_call(functions.MAX_UINT, {}) } } + +/// Event types +export type DestroyedBlackFundsEventArgs = EParams +export type IssueEventArgs = EParams +export type RedeemEventArgs = EParams +export type DeprecateEventArgs = EParams +export type AddedBlackListEventArgs = EParams +export type RemovedBlackListEventArgs = EParams +export type ParamsEventArgs = EParams +export type PauseEventArgs = EParams +export type UnpauseEventArgs = EParams +export type OwnershipTransferredEventArgs = EParams +export type ApprovalEventArgs = EParams +export type TransferEventArgs = EParams + +/// Function types +export type NameParams = FunctionArguments +export type NameReturn = FunctionReturn + +export type DeprecateParams = FunctionArguments +export type DeprecateReturn = FunctionReturn + +export type ApproveParams = FunctionArguments +export type ApproveReturn = FunctionReturn + +export type DeprecatedParams = FunctionArguments +export type DeprecatedReturn = FunctionReturn + +export type AddBlackListParams = FunctionArguments +export type AddBlackListReturn = FunctionReturn + +export type TotalSupplyParams = FunctionArguments +export type TotalSupplyReturn = FunctionReturn + +export type TransferFromParams = FunctionArguments +export type TransferFromReturn = FunctionReturn + +export type UpgradedAddressParams = FunctionArguments +export type UpgradedAddressReturn = FunctionReturn + +export type DecimalsParams = FunctionArguments +export type DecimalsReturn = FunctionReturn + +export type MaximumFeeParams = FunctionArguments +export type MaximumFeeReturn = FunctionReturn + +export type _totalSupplyParams = FunctionArguments +export type _totalSupplyReturn = FunctionReturn + +export type UnpauseParams = FunctionArguments +export type UnpauseReturn = FunctionReturn + +export type GetBlackListStatusParams = FunctionArguments +export type GetBlackListStatusReturn = FunctionReturn + +export type PausedParams = FunctionArguments +export type PausedReturn = FunctionReturn + +export type DecreaseApprovalParams = FunctionArguments +export type DecreaseApprovalReturn = FunctionReturn + +export type BalanceOfParams = FunctionArguments +export type BalanceOfReturn = FunctionReturn + +export type CalcFeeParams = FunctionArguments +export type CalcFeeReturn = FunctionReturn + +export type PauseParams = FunctionArguments +export type PauseReturn = FunctionReturn + +export type OwnerParams = FunctionArguments +export type OwnerReturn = FunctionReturn + +export type SymbolParams = FunctionArguments +export type SymbolReturn = FunctionReturn + +export type TransferParams = FunctionArguments +export type TransferReturn = FunctionReturn + +export type OldBalanceOfParams = FunctionArguments +export type OldBalanceOfReturn = FunctionReturn + +export type SetParamsParams = FunctionArguments +export type SetParamsReturn = FunctionReturn + +export type IssueParams = FunctionArguments +export type IssueReturn = FunctionReturn + +export type IncreaseApprovalParams = FunctionArguments +export type IncreaseApprovalReturn = FunctionReturn + +export type RedeemParams = FunctionArguments +export type RedeemReturn = FunctionReturn + +export type AllowanceParams = FunctionArguments +export type AllowanceReturn = FunctionReturn + +export type BasisPointsRateParams = FunctionArguments +export type BasisPointsRateReturn = FunctionReturn + +export type IsBlackListedParams = FunctionArguments +export type IsBlackListedReturn = FunctionReturn + +export type RemoveBlackListParams = FunctionArguments +export type RemoveBlackListReturn = FunctionReturn + +export type MAX_UINTParams = FunctionArguments +export type MAX_UINTReturn = FunctionReturn + +export type TransferOwnershipParams = FunctionArguments +export type TransferOwnershipReturn = FunctionReturn + +export type DestroyBlackFundsParams = FunctionArguments +export type DestroyBlackFundsReturn = FunctionReturn + diff --git a/tron/tron-ingest/README.md b/tron/tron-ingest/README.md index b83e3b108..f8cd23116 100644 --- a/tron/tron-ingest/README.md +++ b/tron/tron-ingest/README.md @@ -1,3 +1,3 @@ # @subsquid/tron-ingest -Data fetcher for tron based chains. +Data ingestion tool for tron based chains. diff --git a/tron/tron-stream/README.md b/tron/tron-stream/README.md index 832f2dd33..971101ecd 100644 --- a/tron/tron-stream/README.md +++ b/tron/tron-stream/README.md @@ -1,3 +1,4 @@ -# @subsquid/tron-processor +# @subsquid/tron-stream -Data fetcher and mappings executor for tron chains. +Tron block data source, that allows to request and fetch block data from both Subsquid Network +and traditional HTTP API endpoint. diff --git a/tron/tron-stream/package.json b/tron/tron-stream/package.json index eaf842cb6..bd03c7f10 100644 --- a/tron/tron-stream/package.json +++ b/tron/tron-stream/package.json @@ -17,7 +17,6 @@ }, "dependencies": { "@subsquid/http-client": "^1.5.0", - "@subsquid/logger": "^1.3.3", "@subsquid/tron-data": "^0.0.0", "@subsquid/tron-normalization": "^0.0.0", "@subsquid/util-internal": "^3.2.0", diff --git a/tron/tron-stream/src/data/data-request.ts b/tron/tron-stream/src/data/data-request.ts index 4d532a235..27990f60b 100644 --- a/tron/tron-stream/src/data/data-request.ts +++ b/tron/tron-stream/src/data/data-request.ts @@ -14,11 +14,11 @@ export interface DataRequest { export interface LogRequestWhere { - address?: string[] - topic0?: string[] - topic1?: string[] - topic2?: string[] - topic3?: string[] + address?: Bytes[] + topic0?: Bytes[] + topic1?: Bytes[] + topic2?: Bytes[] + topic3?: Bytes[] } @@ -51,8 +51,8 @@ export interface TransactionRequest { export interface TransferTransactionRequestWhere { - owner?: string[] - to?: string[] + owner?: Bytes[] + to?: Bytes[] } @@ -69,8 +69,8 @@ export interface TransferTransactionRequest { export interface TransferAssetTransactionRequestWhere { - owner?: string[] - to?: string[] + owner?: Bytes[] + to?: Bytes[] asset?: string[] } @@ -88,9 +88,9 @@ export interface TransferAssetTransactionRequest { export interface TriggerSmartContractTransactionRequestWhere { - owner?: string[] - contract?: string[] - sighash?: string[] + owner?: Bytes[] + contract?: Bytes[] + sighash?: Bytes[] } @@ -107,8 +107,8 @@ export interface TriggerSmartContractTransactionRequest { export interface InternalTransactionRequestWhere { - caller?: string[] - transferTo?: string[] + caller?: Bytes[] + transferTo?: Bytes[] } diff --git a/tron/tron-stream/src/data/model.ts b/tron/tron-stream/src/data/model.ts index cb62687d1..960fcafb3 100644 --- a/tron/tron-stream/src/data/model.ts +++ b/tron/tron-stream/src/data/model.ts @@ -35,7 +35,10 @@ export const DEFAULT_FIELDS = { data: true, topics: true }, - internalTransaction: {} + internalTransaction: { + callerAddress: true, + transferToAddress: true + } } as const diff --git a/util/http-client/src/client.ts b/util/http-client/src/client.ts index 81ddcadde..274d263bf 100644 --- a/util/http-client/src/client.ts +++ b/util/http-client/src/client.ts @@ -27,7 +27,7 @@ export interface HttpClientOptions { } -export interface RequestOptions { +export interface RequestOptions { query?: Record headers?: HeadersInit retryAttempts?: number @@ -35,19 +35,9 @@ export interface RequestOptions { httpTimeout?: number abort?: AbortSignal stream?: boolean - /** - * Result validator/transformer - * - * This option is mainly a way to utilize built-in retry machinery by throwing {@link RetryError}. - * Otherwise, `client.request(...).then(validateResult)` is a better option. - */ - validateResult?: ResultValidator } -type ResultValidator = (result: HttpResponse, req: FetchRequest) => R - - export interface GraphqlRequestOptions extends RequestOptions { variables?: Record url?: string @@ -56,14 +46,13 @@ export interface GraphqlRequestOptions extends RequestOptions { } -export interface FetchRequest extends RequestInit { +export interface FetchRequest extends RequestInit { id: number url: string headers: Headers timeout?: number signal?: AbortSignal stream?: boolean - validateResult?: ResultValidator } @@ -188,10 +177,6 @@ export class HttpClient { httpResponseBody }, 'http body') } - - if (req.validateResult) { - req.validateResult(res, req) - } } protected async prepareRequest( @@ -209,8 +194,7 @@ export class HttpClient { signal: options.abort, compress: true, timeout: options.httpTimeout ?? this.httpTimeout, - stream: options.stream, - validateResult: options.validateResult, + stream: options.stream } this.handleBasicAuth(req) @@ -336,7 +320,6 @@ export class HttpClient { } isRetryableError(error: HttpResponse | Error, req?: FetchRequest): boolean { - if (error instanceof RetryError) return true if (isHttpConnectionError(error)) return true if (error instanceof HttpTimeoutError) return true if (error instanceof HttpError) { @@ -495,10 +478,3 @@ export function isHttpConnectionError(err: unknown): boolean { && err.type == 'system' && (err.message.startsWith('request to') || err.code == 'ERR_STREAM_PREMATURE_CLOSE') } - - -/** - * This error can be thrown from `RequestOptions.validateResult()` to invoke built-in - * retry machinery - */ -export class RetryError extends Error {}