From 155690a86d552c5dc56dec5cc2a9b31ca827a3e9 Mon Sep 17 00:00:00 2001 From: LuminousBinary Date: Sat, 30 Mar 2024 07:42:14 +0000 Subject: [PATCH] Bug fix: Problem: 1. Typescrpt not included in dependency 2. typescript not configured 3.Argument must be byte array when pssed into senRawTransaction() 4. transaction tnx is not signed Solution: installed typescript into node dependecy using npm i @types/node ... configured typescript to be able to interact with the dom Sign transaction with signTransaction() with tnx and sender's secret key assigned it to a variable to be passed into the sendRawTransaction() and done --- challenge/index.ts | 4 +++- challenge/package-lock.json | 29 +++++++++++++++++------------ challenge/package.json | 3 +++ challenge/tsconfig.json | 4 ++++ 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/challenge/index.ts b/challenge/index.ts index 73e28a5..ea37777 100644 --- a/challenge/index.ts +++ b/challenge/index.ts @@ -29,7 +29,9 @@ const txn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({ amount: 1000000, }); -await algodClient.sendRawTransaction(txn).do(); +const signedTxn = algosdk.signTransaction(txn, sender.sk); + +await algodClient.sendRawTransaction(signedTxn.blob).do(); const result = await algosdk.waitForConfirmation( algodClient, txn.txID().toString(), diff --git a/challenge/package-lock.json b/challenge/package-lock.json index 11dbe1c..19e5e6a 100644 --- a/challenge/package-lock.json +++ b/challenge/package-lock.json @@ -11,6 +11,9 @@ "dotenv": "^16.4.1", "tsx": "^4.7.0" }, + "devDependencies": { + "@types/node": "^20.12.2" + }, "peerDependencies": { "typescript": "^5.0.0" } @@ -374,6 +377,15 @@ "node": ">=12" } }, + "node_modules/@types/node": { + "version": "20.12.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.2.tgz", + "integrity": "sha512-zQ0NYO87hyN6Xrclcqp7f8ZbXNbRfoGWNcMvHTPQp9UUrwI0mI7XBz+cu7/W6/VClYo2g63B0cjull/srU7LgQ==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, "node_modules/algo-msgpack-with-bigint": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/algo-msgpack-with-bigint/-/algo-msgpack-with-bigint-2.1.1.tgz", @@ -601,18 +613,11 @@ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" }, - "node_modules/typescript": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", - "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true }, "node_modules/vlq": { "version": "2.0.4", diff --git a/challenge/package.json b/challenge/package.json index bb407b8..fb3f599 100644 --- a/challenge/package.json +++ b/challenge/package.json @@ -13,5 +13,8 @@ "algosdk": "^2.7.0", "dotenv": "^16.4.1", "tsx": "^4.7.0" + }, + "devDependencies": { + "@types/node": "^20.12.2" } } diff --git a/challenge/tsconfig.json b/challenge/tsconfig.json index e016abc..e333c49 100644 --- a/challenge/tsconfig.json +++ b/challenge/tsconfig.json @@ -7,6 +7,10 @@ "jsx": "react-jsx", "allowJs": true, + /*adding this to use typescript*/ + "types": ["jsdom"], + + /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true,