Skip to content

Commit

Permalink
chore(blockchain-utils-validation): Make TS strict
Browse files Browse the repository at this point in the history
  • Loading branch information
ukstv committed Aug 2, 2023
1 parent c4d482f commit 25c5d6c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 15 deletions.
14 changes: 1 addition & 13 deletions packages/blockchain-utils-linking/src/filecoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,7 @@ import { AuthProvider } from './auth-provider.js'
import { AccountId } from 'caip'
import { asOldCaipString, getConsentMessage, LinkProof } from './util.js'
import * as uint8arrays from 'uint8arrays'

type MessageParams = {
From: string
To: string
Value: '0'
Method: 0
GasPrice: '1'
GasLimit: 1000
Nonce: 0
Params: string
GasFeeCap: string
GasPremium: string
}
import type { MessageParams } from '@zondax/filecoin-signing-tools'

export class FilecoinAuthProvider implements AuthProvider {
readonly isAuthProvider = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function validateErc1271Link(proof: LinkProof): Promise<LinkProof | null>
const provider = getEthersProvider(account.chainId.reference)
const contract = new Contract(account.address, ERC1271_ABI, provider)
const message = utf8toHex(proof.message)
const returnValue = await contract.isValidSignature(message, proof.signature)
const returnValue = await contract['isValidSignature'](message, proof.signature)

return returnValue === MAGIC_ERC1271_VALUE ? proof : null
}
Expand Down
10 changes: 9 additions & 1 deletion packages/blockchain-utils-validation/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
"rootDir": "src",
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": [
"./src/**/*"
Expand Down
12 changes: 12 additions & 0 deletions types/@smontero__eosio-signing-tools/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
declare module '@smontero/eosio-signing-tools' {
type VerifySignatureArgs = {
chainId: string
account: string
signature: string
data: string
}

export class SigningTools {
static verifySignature(args: VerifySignatureArgs): Promise<boolean>
}
}
21 changes: 21 additions & 0 deletions types/@zondax__filecoin-signing-tools/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// <reference types="node" />
declare module '@zondax/filecoin-signing-tools' {
export type MessageParams = {
From: string
To: string
Value: string
Method: 0
GasPrice: string
GasLimit: 1000
Nonce: 0
Params: string
GasFeeCap: string
GasPremium: string
}

export function transactionSerialize(message: MessageParams): string
export function verifySignature(
signature: string | Buffer,
message: MessageParams | string
): boolean
}

0 comments on commit 25c5d6c

Please sign in to comment.