From b73afdf1363be01dff9017ce0a41b6f3a1117016 Mon Sep 17 00:00:00 2001 From: Alex Ni <12097569+nialexsan@users.noreply.github.com> Date: Thu, 2 Nov 2023 11:46:30 -0400 Subject: [PATCH] fixed types --- package-lock.json | 7 +++++++ packages/sdk/package.json | 1 + packages/sdk/src/interaction/interaction.ts | 12 ++++++------ packages/sdk/src/test-utils/authz-fn.ts | 6 +++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index f7ffbcfc3..bfcda4586 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5288,6 +5288,12 @@ "version": "2.0.3", "license": "MIT" }, + "node_modules/@types/uuid": { + "version": "9.0.6", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.6.tgz", + "integrity": "sha512-BT2Krtx4xaO6iwzwMFUYvWBWkV2pr37zD68Vmp1CDV196MzczBRxuEpD6Pr395HAgebC/co7hOphs53r8V7jew==", + "dev": true + }, "node_modules/@types/yargs": { "version": "17.0.24", "dev": true, @@ -20453,6 +20459,7 @@ "devDependencies": { "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@onflow/typedefs": "^1.2.0-typescript.0", + "@types/uuid": "^9.0.6", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", "jest": "^29.5.0", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index ec29f38c2..e15a7b198 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -20,6 +20,7 @@ "devDependencies": { "@onflow/fcl-bundle": "^1.4.0-typescript.0", "@onflow/typedefs": "^1.2.0-typescript.0", + "@types/uuid": "^9.0.6", "eslint": "^8.35.0", "eslint-plugin-jsdoc": "^40.0.1", "jest": "^29.5.0", diff --git a/packages/sdk/src/interaction/interaction.ts b/packages/sdk/src/interaction/interaction.ts index f4c73c4d9..bff08fbf2 100644 --- a/packages/sdk/src/interaction/interaction.ts +++ b/packages/sdk/src/interaction/interaction.ts @@ -105,11 +105,11 @@ export const interaction = () => { return initInteraction() } -export const isNumber = d => typeof d === "number" -export const isArray = d => Array.isArray(d) -export const isObj = d => d !== null && typeof d === "object" -export const isNull = d => d == null -export const isFn = d => typeof d === "function" +export const isNumber = (d: any): d is number => typeof d === "number" +export const isArray = (d: any): d is any[] => Array.isArray(d) +export const isObj = (d: any): d is Record => d !== null && typeof d === "object" +export const isNull = (d: any): d is null => d == null +export const isFn = (d: any): d is Function => typeof d === "function" export const isInteraction = (ix: IIx) => { if (!isObj(ix) || isNull(ix) || isNumber(ix)) return false @@ -198,7 +198,7 @@ export const prepAccount = (acct: IAcct | IAcctFn, opts: IPrepAccountOpts = {}) return ix } -export const makeArgument = arg => ix => { +export const makeArgument = (arg: Record) => (ix: IIx) => { let tempId = uuidv4() ix.message.arguments.push(tempId) diff --git a/packages/sdk/src/test-utils/authz-fn.ts b/packages/sdk/src/test-utils/authz-fn.ts index 175c8acfe..79b5af1a2 100644 --- a/packages/sdk/src/test-utils/authz-fn.ts +++ b/packages/sdk/src/test-utils/authz-fn.ts @@ -61,7 +61,7 @@ interface IAuthzResolveMany { } export function authzResolveMany(opts: IAuthzResolveMany = {authorizations: []}) { - return function (account: IAcct) { + return function (account: IAcct): IAcct { const tempId = opts.tempId || "AUTHZ_RESOLVE_MANY" return { ...account, @@ -79,8 +79,8 @@ export function authzResolveMany(opts: IAuthzResolveMany = {authorizations: []}) } } -export function authzDeepResolveMany(opts = {}, depth = 1) { - return function (account) { +export function authzDeepResolveMany(opts: IAuthzResolveMany = {authorizations: []}, depth = 1) { + return function (account: IAcct): IAcct { const tempId = opts.tempId || "AUTHZ_DEEP_RESOLVE_MANY" return { ...account,