Skip to content

Commit ef99d4c

Browse files
committed
Fixing import path extension type errors
1 parent 48bb755 commit ef99d4c

11 files changed

Lines changed: 98 additions & 43 deletions

File tree

packages/services/api/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export * from './api.gen'
1+
export * from './api.gen.js'
22

3-
import { API as ApiRpc } from './api.gen'
3+
import { API as ApiRpc } from './api.gen.js'
44

55
export class SequenceAPIClient extends ApiRpc {
66
constructor(

packages/services/builder/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export * from './builder.gen'
1+
export * from './builder.gen.js'
22

3-
import { Builder as BuilderRpc } from './builder.gen'
3+
import { Builder as BuilderRpc } from './builder.gen.js'
44

55
export class SequenceBuilderClient extends BuilderRpc {
66
constructor(

packages/services/guard/test/sequence.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
2-
import { Guard } from '../src/sequence'
3-
import { PayloadType } from '../src/client/guard.gen'
2+
import { Guard } from '../src/sequence.js'
3+
import { PayloadType } from '../src/client/guard.gen.js'
44
import { Address, Bytes, Hex } from 'ox'
55

66
// Mock fetch globally for guard API calls

packages/services/indexer/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export * from './indexer.gen'
2-
export * as IndexerGateway from './indexergw.gen'
1+
export * from './indexer.gen.js'
2+
export * as IndexerGateway from './indexergw.gen.js'
33

4-
import { Indexer as IndexerRpc } from './indexer.gen'
5-
import { IndexerGateway as IndexerGatewayRpc } from './indexergw.gen'
4+
import { Indexer as IndexerRpc } from './indexer.gen.js'
5+
import { IndexerGateway as IndexerGatewayRpc } from './indexergw.gen.js'
66

77
export class SequenceIndexer extends IndexerRpc {
88
constructor(

packages/services/marketplace/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export * from './marketplace.gen'
1+
export * from './marketplace.gen.js'
22

3-
import { Marketplace as MarketplaceRpc } from './marketplace.gen'
3+
import { Marketplace as MarketplaceRpc } from './marketplace.gen.js'
44

55
export class MarketplaceIndexer extends MarketplaceRpc {
66
constructor(

packages/services/userdata/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export * from './userdata.gen'
1+
export * from './userdata.gen.js'
22

3-
import { UserData as UserdataRpc } from './userdata.gen'
3+
import { UserData as UserdataRpc } from './userdata.gen.js'
44

55
export class SequenceUserdataClient extends UserdataRpc {
66
constructor(

packages/wallet/primitives/src/attestation.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Address, Bytes, Hash } from 'ox'
1+
import { Address, Bytes, Hash, Hex } from 'ox'
22

33
export type Attestation = {
44
approvedSigner: Address.Address
@@ -14,6 +14,18 @@ export type AuthData = {
1414
issuedAt: bigint // uint64
1515
}
1616

17+
type EncodedAttestation = {
18+
approvedSigner: Address.Address
19+
identityType: Hex.Hex
20+
issuerHash: Hex.Hex
21+
audienceHash: Hex.Hex
22+
applicationData: Hex.Hex
23+
authData: {
24+
redirectUrl: string
25+
issuedAt: string
26+
}
27+
}
28+
1729
// Encoding and decoding
1830

1931
export function encode(attestation: Attestation): Bytes.Bytes {
@@ -76,9 +88,9 @@ export function toJson(attestation: Attestation, indent?: number): string {
7688
return JSON.stringify(encodeForJson(attestation), null, indent)
7789
}
7890

79-
export function encodeForJson(attestation: Attestation): any {
91+
export function encodeForJson(attestation: Attestation): EncodedAttestation {
8092
return {
81-
approvedSigner: attestation.approvedSigner.toString(),
93+
approvedSigner: attestation.approvedSigner,
8294
identityType: Bytes.toHex(attestation.identityType),
8395
issuerHash: Bytes.toHex(attestation.issuerHash),
8496
audienceHash: Bytes.toHex(attestation.audienceHash),
@@ -94,7 +106,7 @@ export function fromJson(json: string): Attestation {
94106
return fromParsed(JSON.parse(json))
95107
}
96108

97-
export function fromParsed(parsed: any): Attestation {
109+
export function fromParsed(parsed: EncodedAttestation): Attestation {
98110
return {
99111
approvedSigner: Address.from(parsed.approvedSigner),
100112
identityType: Bytes.fromHex(parsed.identityType),

packages/wallet/primitives/src/config.ts

Lines changed: 62 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Address, Bytes, Hash, Hex } from 'ox'
22
import {
33
isRawConfig,
44
isRawNestedLeaf,
5-
isRawNode,
65
isRawSignerLeaf,
76
isSignedSapientSignerLeaf,
87
isSignedSignerLeaf,
@@ -55,46 +54,89 @@ export type Leaf = SignerLeaf | SapientSignerLeaf | SubdigestLeaf | AnyAddressSu
5554

5655
export type Topology = Node | Leaf
5756

57+
/** Encoded topology types for JSON serialization */
58+
type EncodedSignerLeaf = {
59+
type: 'signer'
60+
address: Address.Address
61+
weight: string
62+
}
63+
64+
type EncodedSapientSignerLeaf = {
65+
type: 'sapient-signer'
66+
address: Address.Address
67+
weight: string
68+
imageHash: Hex.Hex
69+
}
70+
71+
type EncodedSubdigestLeaf = {
72+
type: 'subdigest'
73+
digest: Hex.Hex
74+
}
75+
76+
type EncodedAnyAddressSubdigestLeaf = {
77+
type: 'any-address-subdigest'
78+
digest: Hex.Hex
79+
}
80+
81+
type EncodedNestedLeaf = {
82+
type: 'nested'
83+
tree: EncodedTopology
84+
weight: string
85+
threshold: string
86+
}
87+
88+
type EncodedNodeLeaf = Hex.Hex
89+
90+
export type EncodedLeaf =
91+
| EncodedSignerLeaf
92+
| EncodedSapientSignerLeaf
93+
| EncodedSubdigestLeaf
94+
| EncodedAnyAddressSubdigestLeaf
95+
| EncodedNestedLeaf
96+
| EncodedNodeLeaf
97+
export type EncodedNode = [EncodedTopology, EncodedTopology]
98+
export type EncodedTopology = EncodedNode | EncodedLeaf
99+
58100
export type Config = {
59101
threshold: bigint
60102
checkpoint: bigint
61103
topology: Topology
62104
checkpointer?: Address.Address
63105
}
64106

65-
export function isSignerLeaf(cand: any): cand is SignerLeaf {
66-
return typeof cand === 'object' && cand !== null && cand.type === 'signer'
107+
export function isSignerLeaf(cand: unknown): cand is SignerLeaf {
108+
return typeof cand === 'object' && cand !== null && 'type' in cand && cand.type === 'signer'
67109
}
68110

69-
export function isSapientSignerLeaf(cand: any): cand is SapientSignerLeaf {
70-
return typeof cand === 'object' && cand !== null && cand.type === 'sapient-signer'
111+
export function isSapientSignerLeaf(cand: unknown): cand is SapientSignerLeaf {
112+
return typeof cand === 'object' && cand !== null && 'type' in cand && cand.type === 'sapient-signer'
71113
}
72114

73-
export function isSubdigestLeaf(cand: any): cand is SubdigestLeaf {
74-
return typeof cand === 'object' && cand !== null && cand.type === 'subdigest'
115+
export function isSubdigestLeaf(cand: unknown): cand is SubdigestLeaf {
116+
return typeof cand === 'object' && cand !== null && 'type' in cand && cand.type === 'subdigest'
75117
}
76118

77-
export function isAnyAddressSubdigestLeaf(cand: any): cand is AnyAddressSubdigestLeaf {
78-
return typeof cand === 'object' && cand !== null && cand.type === 'any-address-subdigest'
119+
export function isAnyAddressSubdigestLeaf(cand: unknown): cand is AnyAddressSubdigestLeaf {
120+
return typeof cand === 'object' && cand !== null && 'type' in cand && cand.type === 'any-address-subdigest'
79121
}
80122

81-
export function isNodeLeaf(cand: any): cand is NodeLeaf {
82-
return Hex.validate(cand) && cand.length === 66
123+
export function isNodeLeaf(cand: unknown): cand is NodeLeaf {
124+
return typeof cand === 'string' && Hex.validate(cand) && cand.length === 66
83125
}
84126

85-
export function isNestedLeaf(cand: any): cand is NestedLeaf {
86-
return typeof cand === 'object' && cand !== null && cand.type === 'nested'
127+
export function isNestedLeaf(cand: unknown): cand is NestedLeaf {
128+
return typeof cand === 'object' && cand !== null && 'type' in cand && cand.type === 'nested'
87129
}
88130

89-
export function isNode(cand: any): cand is Node {
131+
export function isNode(cand: unknown): cand is Node {
90132
return Array.isArray(cand) && cand.length === 2 && isTopology(cand[0]) && isTopology(cand[1])
91133
}
92134

93-
export function isConfig(cand: any): cand is Config {
94-
return typeof cand === 'object' && 'threshold' in cand && 'checkpoint' in cand && 'topology' in cand
135+
export function isConfig(cand: unknown): cand is Config {
136+
return typeof cand === 'object' && cand !== null && 'threshold' in cand && 'checkpoint' in cand && 'topology' in cand
95137
}
96138

97-
export function isLeaf(cand: Topology): cand is Leaf {
139+
export function isLeaf(cand: unknown): cand is Leaf {
98140
return (
99141
isSignerLeaf(cand) ||
100142
isSapientSignerLeaf(cand) ||
@@ -105,7 +147,7 @@ export function isLeaf(cand: Topology): cand is Leaf {
105147
)
106148
}
107149

108-
export function isTopology(cand: any): cand is Topology {
150+
export function isTopology(cand: unknown): cand is Topology {
109151
return isNode(cand) || isLeaf(cand)
110152
}
111153

@@ -310,7 +352,7 @@ export function configFromJson(json: string): Config {
310352
}
311353
}
312354

313-
function encodeTopology(top: Topology): any {
355+
function encodeTopology(top: Topology): EncodedTopology {
314356
if (isNode(top)) {
315357
return [encodeTopology(top[0]), encodeTopology(top[1])]
316358
} else if (isSignerLeaf(top)) {
@@ -350,7 +392,7 @@ function encodeTopology(top: Topology): any {
350392
throw new Error('Invalid topology')
351393
}
352394

353-
function decodeTopology(obj: any): Topology {
395+
function decodeTopology(obj: EncodedTopology): Topology {
354396
if (Array.isArray(obj)) {
355397
if (obj.length !== 2) {
356398
throw new Error('Invalid node structure in JSON')

packages/wallet/primitives/src/signature.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ export function fillLeaves(
618618
export function encodeChainedSignature(signatures: RawSignature[]): Uint8Array {
619619
let flag = 0x01
620620

621-
let sigForCheckpointer = signatures[signatures.length - 1]
621+
const sigForCheckpointer = signatures[signatures.length - 1]
622622

623623
if (sigForCheckpointer?.configuration.checkpointer) {
624624
flag |= 0x40
@@ -723,7 +723,7 @@ export function encodeTopology(
723723
const isBranching = isNode(topology[1]!) || isRawNode(topology[1]!)
724724

725725
if (isBranching) {
726-
let encoded1Size = minBytesFor(BigInt(encoded1.length))
726+
const encoded1Size = minBytesFor(BigInt(encoded1.length))
727727
if (encoded1Size > 15) {
728728
throw new Error('Branch too large')
729729
}
@@ -799,7 +799,7 @@ export function encodeTopology(
799799
} else if (topology.signature.type === 'erc1271') {
800800
let flag = FLAG_SIGNATURE_ERC1271 << 4
801801

802-
let bytesForSignatureSize = minBytesFor(BigInt(topology.signature.data.length))
802+
const bytesForSignatureSize = minBytesFor(BigInt(topology.signature.data.length))
803803
if (bytesForSignatureSize > 3) {
804804
throw new Error('Signature too large')
805805
}
@@ -826,7 +826,7 @@ export function encodeTopology(
826826
let flag = (topology.signature.type === 'sapient' ? FLAG_SIGNATURE_SAPIENT : FLAG_SIGNATURE_SAPIENT_COMPACT) << 4
827827

828828
const signatureBytes = Bytes.fromHex(topology.signature.data)
829-
let bytesForSignatureSize = minBytesFor(BigInt(signatureBytes.length))
829+
const bytesForSignatureSize = minBytesFor(BigInt(signatureBytes.length))
830830
if (bytesForSignatureSize > 3) {
831831
throw new Error('Signature too large')
832832
}

packages/wallet/primitives/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function minBytesFor(val: bigint): number {
77
// ERC-2098
88
export function packRSY({ r, s, yParity }: { r: bigint; s: bigint; yParity: number }): Bytes.Bytes {
99
const rBytes = Bytes.padLeft(Bytes.fromNumber(r), 32)
10-
let sBytes = Bytes.padLeft(Bytes.fromNumber(s), 32)
10+
const sBytes = Bytes.padLeft(Bytes.fromNumber(s), 32)
1111
if (yParity % 2 === 1) {
1212
sBytes[0]! |= 0x80
1313
}

0 commit comments

Comments
 (0)