Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@onflow/decode
Advanced tools
NOTE: Requires a Buffer polyfill
This package provides methods that can decode a response, which can include JSON-CDC payloads from the Access API into JavaScript friendly types.
This package is fairly stable, might even be the most complete package we have. We are fairly happy with how it is consumed, and how it works internally. Other than the known upcoming change listed below this package might be ready for its first major version bump.
npm install --save @onflow/decode
Decoding without ABIs
Unlike with other blockchains, Flow does not require the use of an ABI to decode responses from the blockchain! A response from the Flow Access Node is encoded in JSON-CDC, which is a self describing payload that this package uses to decode the response into JavaScript friendly types.
Decoding
You can use decodeResponse
on any type of response. If that response includes a JSON-CDC payload, it will be decoded into JavaScript friendly types. The data that is returned from decodeResponse
is the data received from the Access Node for the sent interaction.
Decoding a Response
import {decodeResponse} from "@onflow/decode"
const decoded = await decodeResponse(myResponse)
Decoding a Response, with a Custom Decoder
A Custom Decoder is a way for users to define how to decode certain encoded types from the Access API
import {decodeResponse} from "@onflow/decode"
const decoded = await decodeResponse(myResponse, {
UInt8: data => Number(data),
})
Decoding a Response, with a Custom Decoder for a Resource
A Custom Decoder is a way for users to additionally define how to decode Resources.
import {decodeResponse} from "@onflow/decode"
const decoded = await decodeResponse(myResponse, {
CryptoKitty: cryptoKitty => ({
name: cryptoKitty.kittyName || "Lil BUB The Magical Space Cat",
}),
})
Decoding a Response, with a Custom Decoder using Regex Lookup
You can specify Custom Decoders to be executed on types tested against with a regular expression. To denote a regular expression, write the key for that custom decoder between two slashes. Note that only global search is suppoted at this time.
import {decodeResponse} from "@onflow/decode"
const decoded = await decodeResponse(myResponse, {
"/.CryptoKitty$/": myCryptoKittyDecoder,
})
Decoding a JSON-CDC payload
You can additionally directly decode a JSON-CDC payload.
import {decode} from "@onflow/decode"
const jsonCDC = {type: "String", value: "https://discordapp.com/invite/WgAQhtB"}
const decoded = await deocde(jsonCDC)
expect(decoded).toStrictEqual("https://discordapp.com/invite/WgAQhtB")
FAQs
Flow SDK Decoder
The npm package @onflow/decode receives a total of 131 weekly downloads. As such, @onflow/decode popularity was classified as not popular.
We found that @onflow/decode demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.