From 276665ab111286192449f03a3f4b5b92b26d9ac7 Mon Sep 17 00:00:00 2001 From: rileystephens28 Date: Thu, 9 Jan 2025 12:38:48 -0600 Subject: [PATCH 1/2] Get blocktag using shard rather than chain id when invoking `call` --- src/providers/abstract-provider.ts | 24 ++++++++++++++---------- src/providers/provider.ts | 15 ++++++++++----- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/providers/abstract-provider.ts b/src/providers/abstract-provider.ts index f524bd39..6baca077 100644 --- a/src/providers/abstract-provider.ts +++ b/src/providers/abstract-provider.ts @@ -1403,16 +1403,20 @@ export class AbstractProvider implements Provider { }); if (request.blockTag != null) { - const blockTag = this._getBlockTag(toShard(request.chainId!.toString()), request.blockTag); - if (isPromise(blockTag)) { - promises.push( - (async function () { - request.blockTag = await blockTag; - })(), - ); - } else { - request.blockTag = blockTag; - } + const getBlockTag = async () => { + const zone = await this.zoneFromAddress(addressFromTransactionRequest(_request)); + const shard = toShard(zone); + const blockTag = this._getBlockTag(shard, request.blockTag); + if (isPromise(blockTag)) { + return await blockTag; + } + return blockTag; + }; + promises.push( + (async function () { + request.blockTag = await getBlockTag(); + })(), + ); } if (promises.length) { diff --git a/src/providers/provider.ts b/src/providers/provider.ts index 0c0c0c72..a487eef4 100644 --- a/src/providers/provider.ts +++ b/src/providers/provider.ts @@ -54,7 +54,7 @@ import { import { WorkObjectLike } from '../transaction/work-object.js'; import { QiTransactionLike } from '../transaction/qi-transaction.js'; import { QuaiTransactionLike } from '../transaction/quai-transaction.js'; -import { toShard, toZone } from '../constants/index.js'; +import { toShard, toZone, ZeroAddress } from '../constants/index.js'; import { getZoneFromNodeLocation, getZoneForAddress } from '../utils/shards.js'; import { QiPerformActionTransaction } from './abstract-provider.js'; @@ -144,8 +144,16 @@ export class FeeData { */ export function addressFromTransactionRequest(tx: TransactionRequest): AddressLike { if ('from' in tx && !!tx.from) { - return tx.from; + if (tx.from !== ZeroAddress) { + return tx.from; + } + } + if ('to' in tx && !!tx.to) { + if (tx.to !== ZeroAddress) { + return tx.to as AddressLike; + } } + if ('txInputs' in tx && !!tx.txInputs) { const inputs = tx.txInputs as TxInput[]; return computeAddress(inputs[0].pubkey); @@ -154,9 +162,6 @@ export function addressFromTransactionRequest(tx: TransactionRequest): AddressLi const inputs = tx.txIn as TxInputJson[]; return computeAddress(inputs[0].pubkey); } - if ('to' in tx && !!tx.to) { - return tx.to as AddressLike; - } throw new Error('Unable to determine address from transaction inputs, from or to field'); } From 7553d312dd7c570cc4c671ceb02ae2432f021acd Mon Sep 17 00:00:00 2001 From: rileystephens28 Date: Thu, 9 Jan 2025 12:39:01 -0600 Subject: [PATCH 2/2] Increment version value --- src/_version.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_version.ts b/src/_version.ts index dbdc3ae5..dc9e12ab 100644 --- a/src/_version.ts +++ b/src/_version.ts @@ -5,4 +5,4 @@ * * @ignore */ -export const version: string = '1.0.0-alpha.32'; +export const version: string = '1.0.0-alpha.33';