Skip to content

Commit

Permalink
Replace blake2b with another dep
Browse files Browse the repository at this point in the history
  • Loading branch information
manolisliolios committed Mar 28, 2024
1 parent ed2adc4 commit 73b532c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 41 deletions.
11 changes: 3 additions & 8 deletions scripts/airdrop/helper.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { TransactionArgument, TransactionBlock } from "@mysten/sui.js/transactions";
import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';
import * as blake2 from 'blake2';
import { blake2b } from '@noble/hashes/blake2b';
import fs from "fs";
import { AirdropConfig, addressConfig, mainnetConfig } from "../config/day_one";
import { Network, mainPackage } from "../config/constants";
import { execSync } from 'child_process';
import { RawSigner } from "@mysten/sui.js/src/signers/raw-signer";
import { isValidSuiAddress, normalizeSuiAddress, toB64 } from "@mysten/sui.js/utils";
import { ExecutionStatus, GasCostSummary, SuiClient, SuiTransactionBlockResponse } from "@mysten/sui.js/client";
import { bcs } from "@mysten/sui.js/bcs";
import { SignerWithProvider } from "@mysten/sui.js/src/signers/signer-with-provider";
import dotenv from "dotenv";
dotenv.config();

Expand Down Expand Up @@ -114,11 +111,9 @@ export const serializeBatchToBytes = (batch: string[]) => {

export const batchToHash = (batch: string[]) => {
const bytes = Buffer.from(serializeBatchToBytes(batch));
const digest = blake2b(bytes, { dkLen: 32});

return blake2
.createHash('blake2b', { digestLength: 32 })
.update(bytes)
.digest('hex')
return Buffer.from(digest).toString('hex');
}

export const prepareSigner = (): Ed25519Keypair => {
Expand Down
6 changes: 3 additions & 3 deletions scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "echo \"Error: no test specified\" && exit 1",
"transactions::main_package::upgrade": "ts-node transactions/main_package_upgrade.ts",
"transfer::names": "ts-node reserved-names/transfer-names.ts",
"withdraw:auction:profits":"ts-node transactions/withdraw_funds_20290927.ts",
"withdraw:auction:profits": "ts-node transactions/withdraw_funds_20290927.ts",
"authorize-utils": "ts-node transactions/authorize_utils.ts",
"authorize-discounts": "ts-node transactions/quest_3_setup.ts",
"disable-free-claims": "ts-node transactions/quest3/disable_free_claims.ts",
Expand All @@ -23,13 +23,13 @@
"@mysten/bcs": "0.11.1",
"@mysten/kiosk": "0.8.4",
"@mysten/sui.js": "0.51.0",
"@noble/hashes": "^1.4.0",
"@pythnetwork/pyth-sui-js": "2.0.0",
"@types/blake2": "^4.0.1",
"dotenv": "^16.3.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
},
"devDependencies": {
"ts-node": "^10.9.1",
"@types/node": "^20.11.30"
}
}
53 changes: 23 additions & 30 deletions scripts/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 73b532c

Please sign in to comment.