Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix CI #13

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"indentSize": 2,
"lineWidth": 80
},
"linter": {
Expand All @@ -36,23 +36,20 @@
"noUnusedVariables": "error"
},
"complexity": {
"noForEach": "off",
"noBannedTypes": "off"
"noForEach": "off"
},
"performance": {
"noDelete": "off"
},
"style": {
"noNonNullAssertion": "off",
"useShorthandArrayType": "error",
"noUselessElse": "off"
"useShorthandArrayType": "error"
},
"suspicious": {
"noArrayIndexKey": "off",
"noAssignInExpressions": "off",
"noExplicitAny": "off",
"noRedeclare": "off",
"noConfusingVoidType": "off"
"noRedeclare": "off"
}
}
},
Expand Down
6 changes: 2 additions & 4 deletions src/accounts/utils/signTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import {
import { type SignErrorType, sign } from './sign.js'

export type SignTransactionParameters<
TTransactionSerializable extends
TransactionSerializable = TransactionSerializable,
TTransactionSerializable extends TransactionSerializable = TransactionSerializable,
> = {
privateKey: Hex
transaction: TTransactionSerializable
Expand All @@ -28,8 +27,7 @@ export type SignTransactionParameters<
}

export type SignTransactionReturnType<
TTransactionSerializable extends
TransactionSerializable = TransactionSerializable,
TTransactionSerializable extends TransactionSerializable = TransactionSerializable,
> = TransactionSerialized<GetTransactionType<TTransactionSerializable>>

export type SignTransactionErrorType =
Expand Down
20 changes: 9 additions & 11 deletions src/actions/public/createContractEventFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,15 @@ export type CreateContractEventFilterParameters<
args?: never
}
: MaybeExtractEventArgsFromAbi<
TAbi,
TEventName
> extends infer TEventFilterArgs
? {
args?:
| TEventFilterArgs
| (TArgs extends TEventFilterArgs ? TArgs : never)
}
: {
args?: never
})
TAbi,
TEventName
> extends infer TEventFilterArgs
? {
args?: TEventFilterArgs | (TArgs extends TEventFilterArgs ? TArgs : never)
}
: {
args?: never
})

export type CreateContractEventFilterReturnType<
TAbi extends Abi | readonly unknown[] = Abi,
Expand Down
2 changes: 1 addition & 1 deletion src/chains/suave/formatters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ describe('transactionRequest', () => {
chainId: suaveRigil.id,
nonce: 13,
data: '0x0',
type: SuaveTxTypes.ConfidentialRequest,
type: '0x43',
}
const formattedRequest = transactionRequest.format(inputRequest)
expect(formattedRequest).toMatchInlineSnapshot(`
Expand Down
8 changes: 4 additions & 4 deletions src/chains/suave/parsers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import { suaveRigil } from '../index.js'
import { parseSignedComputeRequest, parseTransactionSuave } from './parsers.js'
import {
type SuaveTxType,
SuaveTxTypes,
type TransactionRequestSuave,
SuaveTxRequestTypes,
} from './types.js'
import { getSuaveWallet } from './wallet.js'

describe('Suave Transaction Parsers', () => {
const wallet = getSuaveWallet(
{
transport: http(suaveRigil.rpcUrls.local.http[0]),
transport: http('http://localhost:8545'),
chain: suaveRigil,
privateKey: accounts[0].privateKey,
},
accounts[0].privateKey,
)
const sampleTx = {
to: accounts[1].address,
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('Suave Transaction Parsers', () => {
const serializedTx2 =
'0x43f902aaf90184098412504db4830f4240949a151aa453329f3cdf04d8e4e81585a423f7fc2580b8e4d8f55db90000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c012e8eff6ead85d9d948631a18c41afb60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000009a151aa453329f3cdf04d8e4e81585a423f7fc25000000000000000000000000000000000000000000000000000000000000000094b5feafbdd752ad52afb7e1bd2e40432a485bbb7fa0249c92db3766bc250ffe17682d363e78dbd3aa1fff59a3b5ca242c872910effa8401008c4580a04a0e49a3711af960c5e76d10a21ae318912702b4cfdb37e6baf087edc84feedca02304c28a2a6cb07efa0643e4e2a78bdd2980ccc1d23b359c9cc67543461eb98ab90120000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000dc7b22747873223a5b2230786638363538303064383235336163393431633638353738353161333737633866613736343130396435353933383261393235376334393962383230336538383038343032303131386164613037613861313734613333643136353432363938616538353061303965303530333262373865353934616164613061343164313137376136383333636266633630613031633465663334313031626161363665376338393438376365353062343239653138623733663535323064366130656633396630366234386362343862373064225d7d00000000'
const parsedTx2 = parseTransactionSuave(serializedTx2)
expect(parsedTx2.type).toBe(SuaveTxTypes.ConfidentialRequest)
expect(parsedTx2.type).toBe(SuaveTxRequestTypes.ConfidentialRequest)

const serializedTx3 = await wallet.signTransaction({
to: accounts[1].address,
Expand Down
5 changes: 2 additions & 3 deletions src/chains/suave/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ const AllSuaveTypes = {
}

// syntactical sugar to allow inline string literals
export type SuaveTxType =
`${(typeof AllSuaveTypes)[keyof typeof AllSuaveTypes]}`
export type SuaveTxType = `${typeof AllSuaveTypes[keyof typeof AllSuaveTypes]}`
export type SuaveTxRequestType =
`${(typeof SuaveTxRequestTypes)[keyof typeof SuaveTxRequestTypes]}`
`${typeof SuaveTxRequestTypes[keyof typeof SuaveTxRequestTypes]}`

type ConfidentialOverrides = {
kettleAddress?: Address
Expand Down
4 changes: 2 additions & 2 deletions src/errors/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export class BaseError extends Error {
args.cause instanceof BaseError
? args.cause.details
: args.cause?.message
? args.cause.message
: args.details!
? args.cause.message
: args.details!
const docsPath =
args.cause instanceof BaseError
? args.cause.docsPath || args.docsPath
Expand Down
127 changes: 64 additions & 63 deletions src/types/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ export type ContractFunctionResult<
> = true extends FailedToParseArgs
? unknown
: TArgs extends readonly []
? void
: TArgs extends readonly [infer Arg]
? Arg
: TArgs
? void
: TArgs extends readonly [infer Arg]
? Arg
: TArgs

export type GetValue<
TAbi extends Abi | readonly unknown[],
Expand All @@ -75,8 +75,8 @@ export type GetValue<
? TAbiFunction['stateMutability'] extends 'payable'
? { value?: NoUndefined<TValueType> }
: TAbiFunction['payable'] extends true
? { value?: NoUndefined<TValueType> }
: { value?: never }
? { value?: NoUndefined<TValueType> }
: { value?: never }
: { value?: TValueType }

export type MaybeAbiEventName<TAbiEvent extends AbiEvent | undefined> =
Expand Down Expand Up @@ -170,10 +170,10 @@ export type GetFunctionArgs<
args?: readonly unknown[]
}
: TArgs extends readonly []
? { args?: never }
: {
/** Arguments to pass contract method */ args: TArgs
}
? { args?: never }
: {
/** Arguments to pass contract method */ args: TArgs
}

export type GetConstructorArgs<
TAbi extends Abi | readonly unknown[],
Expand All @@ -194,10 +194,10 @@ export type GetConstructorArgs<
args?: readonly unknown[]
}
: TArgs extends readonly []
? { args?: never }
: {
/** Arguments to pass contract constructor */ args: TArgs
}
? { args?: never }
: {
/** Arguments to pass contract constructor */ args: TArgs
}

export type GetErrorArgs<
TAbi extends Abi | readonly unknown[],
Expand All @@ -219,10 +219,10 @@ export type GetErrorArgs<
args?: readonly unknown[]
}
: TArgs extends readonly []
? { args?: never }
: {
/** Arguments to pass contract method */ args: TArgs
}
? { args?: never }
: {
/** Arguments to pass contract method */ args: TArgs
}

export type GetEventArgs<
TAbi extends Abi | readonly unknown[],
Expand Down Expand Up @@ -296,10 +296,10 @@ export type LogTopicType<
> = TTopic extends Hex
? TPrimitiveType
: TTopic extends Hex[]
? TPrimitiveType[]
: TTopic extends null
? null
: never
? TPrimitiveType[]
: TTopic extends null
? null
: never

/**
* @internal
Expand Down Expand Up @@ -328,45 +328,46 @@ export type AbiEventParametersToPrimitiveTypes<
> = TAbiParameters extends readonly []
? readonly []
: Filter<
TAbiParameters,
Options['IndexedOnly'] extends true ? { indexed: true } : object
> extends infer Filtered extends readonly AbiParameter[]
? _HasUnnamedAbiParameter<Filtered> extends true
? // Has unnamed tuple parameters so return as array
| readonly [
...{
[K in keyof Filtered]: AbiEventParameterToPrimitiveType<
Filtered[K],
Options
>
},
]
// Distribute over tuple to represent optional parameters
| (Options['Required'] extends true
? never
: // Distribute over tuple to represent optional parameters
Filtered extends readonly [
...infer Head extends readonly AbiParameter[],
infer _,
]
? AbiEventParametersToPrimitiveTypes<
readonly [...{ [K in keyof Head]: Omit<Head[K], 'name'> }],
Options
>
: never)
: // All tuple parameters are named so return as object
{
[Parameter in Filtered[number] as Parameter extends {
name: infer Name extends string
}
? Name
: never]?: AbiEventParameterToPrimitiveType<Parameter, Options>
} extends infer Mapped
? Prettify<
MaybeRequired<
Mapped,
Options['Required'] extends boolean ? Options['Required'] : false
>
>
: never
TAbiParameters,
Options['IndexedOnly'] extends true ? { indexed: true } : object
> extends infer Filtered extends readonly AbiParameter[]
? _HasUnnamedAbiParameter<Filtered> extends true
? // Has unnamed tuple parameters so return as array
| readonly [
...{
[K in keyof Filtered]: AbiEventParameterToPrimitiveType<
Filtered[K],
Options
>
},
]
// Distribute over tuple to represent optional parameters
| (Options['Required'] extends true
? never
: // Distribute over tuple to represent optional parameters
Filtered extends readonly [
...infer Head extends readonly AbiParameter[],
infer _,
]
? AbiEventParametersToPrimitiveTypes<
readonly [...{ [K in keyof Head]: Omit<Head[K], 'name'> }],
Options
>
: never)
: // All tuple parameters are named so return as object
{
[Parameter in
Filtered[number] as Parameter extends {
name: infer Name extends string
}
? Name
: never]?: AbiEventParameterToPrimitiveType<Parameter, Options>
} extends infer Mapped
? Prettify<
MaybeRequired<
Mapped,
Options['Required'] extends boolean ? Options['Required'] : false
>
>
: never
: never
24 changes: 12 additions & 12 deletions src/types/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ export type Filter<
strict: TStrict
}
: TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName>
? {
abi: TAbi
args: TArgs
eventName: TEventName
strict: TStrict
}
: {
abi: TAbi
args?: never
eventName: TEventName
strict: TStrict
}
? {
abi: TAbi
args: TArgs
eventName: TEventName
strict: TStrict
}
: {
abi: TAbi
args?: never
eventName: TEventName
strict: TStrict
}
: {
abi?: never
args?: never
Expand Down
8 changes: 4 additions & 4 deletions src/types/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ type GetTopics<
> = true extends _FailedToParseArgs
? [Hex, ...Hex[]] | []
: TAbiEvent extends AbiEvent
? Topics<TAbiEvent['inputs']>
: _AbiEvent extends AbiEvent
? Topics<_AbiEvent['inputs']>
: [Hex, ...Hex[]] | []
? Topics<TAbiEvent['inputs']>
: _AbiEvent extends AbiEvent
? Topics<_AbiEvent['inputs']>
: [Hex, ...Hex[]] | []

type GetInferredLogValues<
TAbiEvent extends AbiEvent | undefined = undefined,
Expand Down
Loading
Loading