diff --git a/sdk/evm/tbrv3/contract.ts b/sdk/evm/tbrv3/contract.ts index f18220eb..2a8e52c5 100644 --- a/sdk/evm/tbrv3/contract.ts +++ b/sdk/evm/tbrv3/contract.ts @@ -377,7 +377,7 @@ export class Tbrv3 { const selectorOf = (funcSig: string) => keccak256(funcSig).subarray(0, 4); -type Tuple = readonly [unknown, ...unknown[]] | readonly []; +type Tuple = readonly [T, ...T[]] | readonly []; //always return the passed arguments along with the result //this makes it easier to match queries to results without having to muck around with types @@ -458,6 +458,7 @@ type RootQueryToResults = : never; type EnsureTuple = T extends Tuple ? T : [T]; +type StripArray = T extends RoArray ? E : T; type RootQueryTupleResults> = CA extends readonly [ @@ -469,7 +470,12 @@ type RootQueryTupleResults> = type QueryResults> = CA extends Tuple - ? RootQueryTupleResults + ? RootQueryTupleResults extends infer R extends RoArray + //if any of the internal queries are not tuples, then we can't return a tuple ourselves + ? any[] extends R[number] + ? StripArray[] + : R + : never : CA extends RoArray ? RootQueryToResults[] : never;