JavaScript Arrays have lots of helpful built-in methods.
These methods allow you to write more declarative/functional code as opposed to imperative code.
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
// Type definitions for @onflow/fcl 1.3.0 | |
// Project: https://github.com/onflow/fcl-js | |
declare module "@onflow/six-create-account" { | |
let template: any; | |
} | |
declare global { | |
interface Window { | |
fcl: any; |
const fcl = require("@onflow/fcl") | |
const {TransactionAuthorizer} = require("@freshmint/core") | |
const { | |
HashAlgorithm, | |
InMemoryECSigner, | |
SignatureAlgorithm, | |
InMemoryECPrivateKey, | |
} = require("@freshmint/core/crypto") | |
const PRIVATE_KEY_HEX = |
let elliptic = require('elliptic'); | |
let sha3 = require('js-sha3'); | |
let ec = new elliptic.ec('secp256k1'); | |
// let keyPair = ec.genKeyPair(); | |
let keyPair = ec.keyFromPrivate("97ddae0f3a25b92268175400149d65d6887b9cefaf28ea2c078e05cdc15a3c0a"); | |
let privKey = keyPair.getPrivate("hex"); | |
let pubKey = keyPair.getPublic(); | |
console.log(`Private key: ${privKey}`); | |
console.log("Public key :", pubKey.encode("hex").substr(2)); |
const {randomBytes} = require("crypto") | |
const secp256k1 = require("secp256k1") | |
// or require('secp256k1/elliptic') | |
// if you want to use pure js implementation in node | |
// generate message to sign | |
// message should have 32-byte length, if you have some other length you can hash message | |
// for example `msg = sha256(rawMessage)` | |
const msg = randomBytes(32) |
const isFn = v => typeof v === "function" | |
const isString = v => typeof v === "string" | |
function meta(meta) { | |
return pipe([ | |
ix => { | |
ix.meta = meta | |
return Ok(ix) | |
}, | |
]) |
let txIdCalculated = null | |
const getTxHash = async () => { | |
const txIdFromChain = await sdk.decode( | |
await sdk.send( | |
await sdk.resolve( | |
await sdk.build([ | |
sdk.transaction`transaction(msg: String) { prepare(acct: AuthAccount) {} execute { log(msg) } }`, | |
sdk.args([sdk.arg("Hello, Flow!", t.String)]), | |
sdk.payer(fcl.currentUser().authorization), | |
sdk.proposer(fcl.currentUser().authorization), |
// Authentication Proof Service | |
{ | |
"f_type": "Service", | |
"f_vsn": "1.0.0", | |
"type": "account-proof", | |
"method": "DATA", | |
"uid": "fcl-dev-wallet#account-proof", | |
"data": { | |
"f_type": "account-proof", | |
"f_vsn": "1.0.0", |
name: CICD | |
# Triggers the workflow on push to master | |
on: | |
push: | |
branches: | |
- master | |
jobs: |
export async function getData() { | |
async function userData(url = '', data = {}) { | |
// Default options are marked with * | |
const response = await fetch(url, { | |
method: 'GET', // *GET, POST, PUT, DELETE, etc. | |
mode: 'cors', // no-cors, *cors, same-origin | |
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached | |
credentials: 'same-origin', // include, *same-origin, omit | |
headers: { | |
'Content-Type': 'application/json', |