
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@onflow/interaction
Advanced tools
This module provides an ADT (Abstract Data Type) that represents the underlying data required by the send
function. It provides function in which to modify the interaction.
This is a keystone data structure in how the SDK works. We will strive for backwards compatibility in any changes to this, as it also makes our lives easier. Now that we have a stable encoding package for creating what needs to be signed in transactions, we will be bringing this data structure closer to what those functions need.
Known Upcoming Changes:
@onflow/encode
npm install --save @onflow/interaction
Currently the Access Node recognizes 7 different types of interactions.
The interaction is a monomorphic data structure, that merges the 7 types of interactions together. Internally it has a bunch of properties, but not everything needs to be included for each of the 7 interaction types.
Int
-- a marker that represents the type of the interactionInt
-- a marker that represents the status of the interactionString
-- used to supply more information/feedback when a status is badInt
-- denotes the kind of account, ACCOUNT or PARAM or ARGUMENTString
-- denotes the internal tempId for this accountString
-- denotes the address of this accountInt
-- denotes the keyId in question for this accountInt
-- denotes the sequenceNum in question for this accountString
-- the signature produced by the signingFunction for this accountFunction
-- the signing function for this accountFunction
-- the resolver for this accountBoolean
-- denotes if this account is a propserBoolean
-- denotes if this account is an authorizerBoolean
-- denotes if this account is a payerBoolean
-- denotes if this account is a paramInt
-- denotes the kind of param, ACCOUNT or PARAM or ARGUMENTString
-- the internal tempId for this paramString
-- the key for this paramAny
-- the value for this paramAny
-- the asParam transformed value for this paramAny
-- the transform for this paramFunction
-- a resolver for this paramInt
-- denotes the kind of argument, ACCOUNT or PARAM or ARGUMENTString
-- the internal tempId for this argumentAny
-- the value for this argumentAny
-- the asArgument transformed value for this argumentAny
-- the transform for this argumentFunction
-- a resolver for this argumentString
-- cadence codeString
-- id of an existing block (used for timeout)Int
-- how much payer is willing to spendString
-- the tempId of the account proposer for a transactionString
-- the tempId of the payer for a transactionArray<String>
-- list of tempIds referencing the accounts of the authorizers for a transactionArray<String>
-- list of tempIds referencing the params for a transaction or scriptArray<String>
-- list of tempIds referencing the arguments for a transaction or scriptString
-- the tempId referencing the account of the proposer for a transactionString
-- the tempId referencing the account of the payer for a transactionArray<String>
-- list of tempIds referencing the accounts of the authorizers for a transactionInt
-- events after thisInt
-- events before thisString
-- type of events to getArray<String>
-- array of block ids to get events fromBoolean
-- determines if the criteria for the latest block is sealed or not.Int
-- sets the height for the block to get.Int
-- sets the id for the block to get.String
-- address of the account to get{[String]:Any}
-- a pocket to hold things in while building and resolvingTags
Label | asString |
---|---|
UNKNOWN | UNKNOWN |
SCRIPT | SCRIPT |
TRANSACTION | TRANSACTION |
GET_TRANSACTION_STATUS | GET_TRANSACTION_STATUS |
GET_ACCOUNT | GET_ACCOUNT |
GET_EVENTS | GET_EVENTS |
GET_LATEST_BLOCK | GET_LATEST_BLOCK |
PING | PING |
PING | PING |
GET_TRANSACTION | GET_TRANSACTION |
GET_BLOCK_BY_ID | GET_BLOCK_BY_ID |
GET_BLOCK | GET_BLOCK |
GET_BLOCK_HEADER | GET_BLOCK_HEADER |
Status
Label | asString |
---|---|
BAD | BAD |
OK | OK |
interaction/0
Constructs an empty interaction.
import {interaction} from "@onflow/interaction"
const emptyInteraction = interaction()
isInteraction/1
returns true if the value passed to it is an interaction
import {interaction, isInteraction} from "@onflow/interaction"
const ix = interaction()
isInteraction(ix) // true
isInteraction("i am a string") // false
Ok/1
and isOk/1
Sets the status of an interaction to
OK
import {interaction, Ok, isOk} from "@onflow/interaction"
isOk(Ok(interaction())) // true
Bad/2
, isBad/1
and why/1
Sets the status of an interaction to
BAD
, can also add a reason as to why its bad.
import {interaction, Bad, why} from "@onflow/interaction"
const ix = Bad(interaction, "You were supposed to do the thing")
isBad(ix) // true
why(ix) // "You were supposed to do the thing"
makeUnknown/1
and isUnknown/1
tags an interaction as Unknown
import {interaction, makeUnknown, isUnknown} from "@onflow/interaction"
isUnknown(makeUnknown(interaction())) // true
makeScript/1
and isScript/1
tags an interaction as a Script interaction
import {interaction, makeScript, isScript} from "@onflow/interaction"
isScript(makeScript(interaction())) // true
makeTransaction/1
and isTransaction/1
tags an interaction as a Transaction interaction
import {interaction, makeTransaction, isTransaction} from "@onflow/interaction"
isTransaction(makeTransaction(interaction())) // true
makeGetTransaction/1
and isGetTransaction/1
tags an interaction as a GetTransactionStatus interaction
import {
interaction,
makeGetTransactionStatus,
isGetTransactionStatus,
} from "@onflow/interaction"
isGetTransactionStatus(makeGetTransactionStatus(interaction())) // true
makeGetAccount/1
and isGetAccount/1
tags an interaction as a GetAccount interaction
import {interaction, makeGetAccount, isGetAccount} from "@onflow/interaction"
isGetAccount(makeGetAccount(interaction())) // true
makeGetEvents/1
and isGetEvents/1
tags an interaction as a GetEvents interaction
import {interaction, makeGetEvents, isGetEvents} from "@onflow/interaction"
isGetEvents(makeGetEvents(interaction())) // true
makeGetLatestBlock/1
and isGetLatestBlock/1
tags an interaction as a GetLatestBlock interaction
import {
interaction,
makeGetLatestBlock,
isGetLatestBlock,
} from "@onflow/interaction"
isGetLatestBlock(makeGetLatestBlock(interaction())) // true
makePing/1
and isPing/1
tags an interaction as a Ping interaction
import {interaction, makePing, isPing} from "@onflow/interaction"
isPing(makePing(interaction())) // true
makeGetTransaction/1
and isGetTransaction/1
tags an interaction as a GetTransaction interaction
import {interaction, makeGetTransaction, isGetTransaction} from "@onflow/interaction"
isGetTransaction(makeGetTransaction(interaction())) // true
makeGetBlock1
and isGetBlock/1
tags an interaction as a GetBlock interaction
import {interaction, makeGetBlock, isGetBlock} from "@onflow/interaction"
isGetBlock(makeGetBlock(interaction())) // true
makeGetBlockHeader/1
and isGetBlockHeader/1
tags an interaction as a GetBlockHeader interaction
import {interaction, makeGetBlockHeader, isGetBlockHeader} from "@onflow/interaction"
isGetBlockHeader(makeGetBlockHeader(interaction())) // true
get/3
, put/2
, update/2
and destory/1
crud operations for the assigns pocket inside the interaction. They are specifically designed to be used with
pipe
.
import {interaction, get, put, update, destory} from "@onflow/interaction"
let ix = interaction()
get(ix, "count", 0) // 0
ix = put("count", 0)(ix)
get(ix, "count", 0) // 0
ix = update("count", count => count + 1)(ix)
get(ix, "count", 0) // 1
ix = destory("count")(ix)
get(ix, "count", 0) // 0
makeAuthorizer/1
compose an Authorizer account, and registers a tempId for it in the interaction object accounts registry
import {makeAuthorizer, makeTransaction, pipe} from "@onflow/interaction"
const ix = pipe([
makeTransaction``
makeAuthorizer({ addr: "01", role: { authorizer: true } })
])
makePayer/1
compose a Payer account, and registers a tempId for it in the interaction object accounts registry
import {makePayer, makeTransaction, pipe} from "@onflow/interaction"
const ix = pipe([
makeTransaction``
makePayer({ addr: "01", role: { payer: true } })
])
makeProposer/1
compose a Proposer account, and registers a tempId for it in the interaction object accounts registry
import {makeProposer, makeTransaction, pipe} from "@onflow/interaction"
const ix = pipe([
makeTransaction``
makeProposer({ addr: "01", role: { proposer: true } })
])
makeParam/1
compose a Param, and registers a tempId for it in the interaction object params registry
import {makeParam, makeTransaction, pipe} from "@onflow/interaction"
const ix = pipe([
makeTransaction``
makeParam(...)
])
pipe/2
asynchronously composes transform functions and applys them to an interaction.
import {interaction, pipe, put, update} from "@onflow/interaction"
const ix = await pipe(interaction(), [
put("a", 5),
put("b", 6),
update("sum", (_, ix) => get(ix, "a", 0) + get(ix, "b", 0)),
])
get(ix, "sum", 0) // 11
pipe/1
gets passed an array of transform functions, returning a function that takes an interaction to apply the transform functions to asynchronously.
import {interaction, pipe, put, update} from "@onflow/interaction"
const run = await pipe([
put("a", 5),
put("b", 6),
update("sum", (_, ix) => get(ix, "a", 0) + get(ix, "b", 0)),
])
const ix = run(interaction())
get(ix, "sum", 0) // 11
// Pipes can also be composed
const p1 = pipe([put("a", 1), put("b", 2)])
const p2 = pipe([put("c", 3), put("d", 4)])
const calc = update("sum", (_, ix) =>
["a", "b", "c", "d"].reduce((acc, d) => acc + get(ix, d, 0), 0)
)
const ix = await pipe(interaction(), [p1, p2, calc])
get(ix, "sum", 0) // 10
// Pipes can be stoped
import {Bad, Ok, isBad, why} from "@onflow/interaction"
const countCantBeGreaterThan = value => ix =>
get(ix, "count", 0) > value ? Bad(ix, `Was greater than ${value}`) : Ok(ix)
const setCount = count => put("count", count)
const incCountBy = amount => update("count", count => count + amount)
const ix = await pipe(interaction(), [
setCount(5), // count: 5
countCantBeGreaterThan(10), // Ok
incCountBy(3), // count: 8
countCantBeGreaterThan(10), // Ok
incCountBy(5), // count: 13
countCantBeGreaterThan(10), // Bad
incCountBy(9), // never called
])
isBad(ix) // true
why(ix) // "Was greater than 10"
FAQs
Flow Interaction ADT and Helpers
The npm package @onflow/interaction receives a total of 14,030 weekly downloads. As such, @onflow/interaction popularity was classified as popular.
We found that @onflow/interaction 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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.