Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onflow/sdk

Package Overview
Dependencies
Maintainers
11
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/sdk - npm Package Compare versions

Comparing version 1.2.0-alpha.10 to 1.2.0

38

CHANGELOG.md
# @onflow/sdk
## 1.2.0
### Minor Changes
- [#1573](https://github.com/onflow/fcl-js/pull/1573) [`74c75d51`](https://github.com/onflow/fcl-js/commit/74c75d5167560eb07da6e21f9f7835b5639ee7d5) Thanks [@chasefleming](https://github.com/chasefleming)! - Add JSDoc to SDK and generate types
- [#1564](https://github.com/onflow/fcl-js/pull/1564) [`66fe102a`](https://github.com/onflow/fcl-js/commit/66fe102a269aca71bd82c6ac55bb23527d04db01) Thanks [@justinbarry](https://github.com/justinbarry)! - Add support for import "ContractName" syntax in scripts and transactions.
- [#1420](https://github.com/onflow/fcl-js/pull/1420) [`c20bc344`](https://github.com/onflow/fcl-js/commit/c20bc34448a22966d349b0b1c4c0f742ae93a355) Thanks [@huyndo](https://github.com/huyndo)! - Add GetNetworkParameters interaction and a util to get chain ID
- [#1575](https://github.com/onflow/fcl-js/pull/1575) [`bbdeea32`](https://github.com/onflow/fcl-js/commit/bbdeea32f024d6eea4a74c94023e01688a38b6cb) Thanks [@chasefleming](https://github.com/chasefleming)! - Exclude tests from type gen
- [#1577](https://github.com/onflow/fcl-js/pull/1577) [`d9a49531`](https://github.com/onflow/fcl-js/commit/d9a495316cd03ed0de99e0f01d1b8850a1f0eec4) Thanks [@chasefleming](https://github.com/chasefleming)! - Add npmignore file for build
- [#1591](https://github.com/onflow/fcl-js/pull/1591) [`7b122a49`](https://github.com/onflow/fcl-js/commit/7b122a49b47b2f261e67d4b08d0d8d32d35d3a72) Thanks [@chasefleming](https://github.com/chasefleming)! - Create typedefs package for JSDoc typedefs and TypeScript types
### Patch Changes
- [#1663](https://github.com/onflow/fcl-js/pull/1663) [`62dfafa9`](https://github.com/onflow/fcl-js/commit/62dfafa9c7adc3933822b0d3171d6eb025f1719e) Thanks [@nialexsan](https://github.com/nialexsan)! - Export 'response' function for testing
- [#1663](https://github.com/onflow/fcl-js/pull/1663) [`62dfafa9`](https://github.com/onflow/fcl-js/commit/62dfafa9c7adc3933822b0d3171d6eb025f1719e) Thanks [@nialexsan](https://github.com/nialexsan)! - Upgrade jest to v29.5 and update tests accordingly. Change build to transpile with ESM modules.
- [#1658](https://github.com/onflow/fcl-js/pull/1658) [`2512b5c5`](https://github.com/onflow/fcl-js/commit/2512b5c53dff708fca97cd8afdbb1f4a46b2f106) Thanks [@nialexsan](https://github.com/nialexsan)! - Align jest version
- [#1610](https://github.com/onflow/fcl-js/pull/1610) [`bd6ebb8e`](https://github.com/onflow/fcl-js/commit/bd6ebb8eea5b0de26c0de9b2e0e7561006783040) Thanks [@nialexsan](https://github.com/nialexsan)! - Updated transport-http dependency
- [#1565](https://github.com/onflow/fcl-js/pull/1565) [`8c921ba2`](https://github.com/onflow/fcl-js/commit/8c921ba2098d2449846bb4a3fdf44a633f4cb11e) Thanks [@justinbarry](https://github.com/justinbarry)! - Prefix contract addresses with 0x if not preset in the config during Address replacement.
- Updated dependencies [[`e10e3c9c`](https://github.com/onflow/fcl-js/commit/e10e3c9c1f611e7dfd8a0bf7292473c71c2e04b9), [`2d143bc7`](https://github.com/onflow/fcl-js/commit/2d143bc7b30f59e9f9289eee020cfaae74b4f4e1), [`82810ef0`](https://github.com/onflow/fcl-js/commit/82810ef000ebdf4dde4dbd7846d31dd335cd9cbb), [`62dfafa9`](https://github.com/onflow/fcl-js/commit/62dfafa9c7adc3933822b0d3171d6eb025f1719e), [`c20bc344`](https://github.com/onflow/fcl-js/commit/c20bc34448a22966d349b0b1c4c0f742ae93a355), [`de7ffa47`](https://github.com/onflow/fcl-js/commit/de7ffa4768ea19e9378e7db74c85750b6554027c), [`bbdeea32`](https://github.com/onflow/fcl-js/commit/bbdeea32f024d6eea4a74c94023e01688a38b6cb), [`2512b5c5`](https://github.com/onflow/fcl-js/commit/2512b5c53dff708fca97cd8afdbb1f4a46b2f106), [`544d8ebb`](https://github.com/onflow/fcl-js/commit/544d8ebb298ce1be8491d5609729110211b83242), [`0ec0c5d4`](https://github.com/onflow/fcl-js/commit/0ec0c5d46b780e2b277846f9271ab311aa048b19), [`35052784`](https://github.com/onflow/fcl-js/commit/3505278418e64045248c04fd21f0c09ddbb3132e), [`5bec5576`](https://github.com/onflow/fcl-js/commit/5bec5576a79809d0684411736e3f4c02b8051c22), [`48ff4330`](https://github.com/onflow/fcl-js/commit/48ff43303c30bab86274bd281f6af28affdb2f25), [`d9a49531`](https://github.com/onflow/fcl-js/commit/d9a495316cd03ed0de99e0f01d1b8850a1f0eec4), [`f68c1433`](https://github.com/onflow/fcl-js/commit/f68c14337b5470b4d79ec682f7bb41ddeae2e020), [`9276f6ea`](https://github.com/onflow/fcl-js/commit/9276f6ea37367dfacce19bbffbad6fda56a1a645), [`a4a1c7bf`](https://github.com/onflow/fcl-js/commit/a4a1c7bf0be9facb213f56a91d1a66b60bdea64b)]:
- @onflow/config@1.1.0
- @onflow/util-address@1.1.0
- @onflow/transport-http@1.6.0
- @onflow/rlp@1.1.0
- @onflow/util-actor@1.2.0
- @onflow/util-invariant@1.1.0
- @onflow/util-logger@1.2.0
- @onflow/util-template@1.1.0
## 1.2.0-alpha.10

@@ -4,0 +42,0 @@

438

dist/sdk.module.js

@@ -13,62 +13,22 @@ import * as logger from '@onflow/util-logger';

const UNKNOWN
/* */
= "UNKNOWN";
const SCRIPT
/* */
= "SCRIPT";
const TRANSACTION
/* */
= "TRANSACTION";
const GET_TRANSACTION_STATUS
/* */
= "GET_TRANSACTION_STATUS";
const GET_ACCOUNT
/* */
= "GET_ACCOUNT";
const GET_EVENTS
/* */
= "GET_EVENTS";
const PING
/* */
= "PING";
const GET_TRANSACTION
/* */
= "GET_TRANSACTION";
const GET_BLOCK
/* */
= "GET_BLOCK";
const GET_BLOCK_HEADER
/* */
= "GET_BLOCK_HEADER";
const GET_COLLECTION
/* */
= "GET_COLLECTION";
const GET_NETWORK_PARAMETERS
/* */
= "GET_NETWORK_PARAMETERS";
const BAD
/* */
= "BAD";
const OK
/* */
= "OK";
const ACCOUNT
/* */
= "ACCOUNT";
const PARAM
/* */
= "PARAM";
const ARGUMENT
/* */
= "ARGUMENT";
const AUTHORIZER
/* */
= "authorizer";
const PAYER
/* */
= "payer";
const PROPOSER
/* */
= "proposer";
const UNKNOWN /* */ = "UNKNOWN";
const SCRIPT /* */ = "SCRIPT";
const TRANSACTION /* */ = "TRANSACTION";
const GET_TRANSACTION_STATUS /* */ = "GET_TRANSACTION_STATUS";
const GET_ACCOUNT /* */ = "GET_ACCOUNT";
const GET_EVENTS /* */ = "GET_EVENTS";
const PING /* */ = "PING";
const GET_TRANSACTION /* */ = "GET_TRANSACTION";
const GET_BLOCK /* */ = "GET_BLOCK";
const GET_BLOCK_HEADER /* */ = "GET_BLOCK_HEADER";
const GET_COLLECTION /* */ = "GET_COLLECTION";
const GET_NETWORK_PARAMETERS /* */ = "GET_NETWORK_PARAMETERS";
const BAD /* */ = "BAD";
const OK /* */ = "OK";
const ACCOUNT /* */ = "ACCOUNT";
const PARAM /* */ = "PARAM";
const ARGUMENT /* */ = "ARGUMENT";
const AUTHORIZER /* */ = "authorizer";
const PAYER /* */ = "payer";
const PROPOSER /* */ = "proposer";
const ACCT = `{

@@ -144,5 +104,3 @@ "kind":"${ACCOUNT}",

const CHARS = "abcdefghijklmnopqrstuvwxyz0123456789".split("");
const randChar = () => CHARS[~~(Math.random() * CHARS.length)];
const uuid = () => Array.from({

@@ -158,5 +116,3 @@ length: 10

if (!isObj(ix) || isNull(ix) || isNumber$1(ix)) return false;
for (let key of KEYS) if (!ix.hasOwnProperty(key)) return false;
return true;

@@ -173,3 +129,2 @@ };

};
const makeIx = wat => ix => {

@@ -179,11 +134,10 @@ ix.tag = wat;

};
const prepAccountKeyId = acct => {
if (acct.keyId == null) return acct;
invariant$1(!isNaN(parseInt(acct.keyId)), "account.keyId must be an integer");
return { ...acct,
return {
...acct,
keyId: parseInt(acct.keyId)
};
};
const prepAccount = function (acct) {

@@ -208,10 +162,11 @@ let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

}
return [resolve, prepAccountKeyId].reduce(async (d, fn) => fn(await d, ...rest), acct);
};
acct = prepAccountKeyId(acct);
ix.accounts[tempId] = { ...ACCOUNT,
ix.accounts[tempId] = {
...ACCOUNT,
tempId,
...acct,
role: { ...ACCOUNT.role,
role: {
...ACCOUNT.role,
...(typeof acct.role === "object" ? acct.role : {}),

@@ -221,3 +176,2 @@ [role]: true

};
if (role === AUTHORIZER) {

@@ -230,3 +184,2 @@ ix.authorizations.push(tempId);

}
return ix;

@@ -247,96 +200,33 @@ };

};
const makeUnknown
/* */
= makeIx(UNKNOWN);
const makeScript
/* */
= makeIx(SCRIPT);
const makeTransaction
/* */
= makeIx(TRANSACTION);
const makeGetTransactionStatus
/* */
= makeIx(GET_TRANSACTION_STATUS);
const makeGetTransaction
/* */
= makeIx(GET_TRANSACTION);
const makeGetAccount
/* */
= makeIx(GET_ACCOUNT);
const makeGetEvents
/* */
= makeIx(GET_EVENTS);
const makePing
/* */
= makeIx(PING);
const makeGetBlock
/* */
= makeIx(GET_BLOCK);
const makeGetBlockHeader
/* */
= makeIx(GET_BLOCK_HEADER);
const makeGetCollection
/* */
= makeIx(GET_COLLECTION);
const makeGetNetworkParameters
/* */
= makeIx(GET_NETWORK_PARAMETERS);
const makeUnknown /* */ = makeIx(UNKNOWN);
const makeScript /* */ = makeIx(SCRIPT);
const makeTransaction /* */ = makeIx(TRANSACTION);
const makeGetTransactionStatus /* */ = makeIx(GET_TRANSACTION_STATUS);
const makeGetTransaction /* */ = makeIx(GET_TRANSACTION);
const makeGetAccount /* */ = makeIx(GET_ACCOUNT);
const makeGetEvents /* */ = makeIx(GET_EVENTS);
const makePing /* */ = makeIx(PING);
const makeGetBlock /* */ = makeIx(GET_BLOCK);
const makeGetBlockHeader /* */ = makeIx(GET_BLOCK_HEADER);
const makeGetCollection /* */ = makeIx(GET_COLLECTION);
const makeGetNetworkParameters /* */ = makeIx(GET_NETWORK_PARAMETERS);
const is = wat => ix => ix.tag === wat;
const isUnknown
/* */
= is(UNKNOWN);
const isScript
/* */
= is(SCRIPT);
const isTransaction
/* */
= is(TRANSACTION);
const isGetTransactionStatus
/* */
= is(GET_TRANSACTION_STATUS);
const isGetTransaction
/* */
= is(GET_TRANSACTION);
const isGetAccount
/* */
= is(GET_ACCOUNT);
const isGetEvents
/* */
= is(GET_EVENTS);
const isPing
/* */
= is(PING);
const isGetBlock
/* */
= is(GET_BLOCK);
const isGetBlockHeader
/* */
= is(GET_BLOCK_HEADER);
const isGetCollection
/* */
= is(GET_COLLECTION);
const isGetNetworkParameters
/* */
= is(GET_NETWORK_PARAMETERS);
const isOk
/* */
= ix => ix.status === OK;
const isBad
/* */
= ix => ix.status === BAD;
const why
/* */
= ix => ix.reason;
const isAccount
/* */
= account => account.kind === ACCOUNT;
const isParam
/* */
= param => param.kind === PARAM;
const isArgument
/* */
= argument => argument.kind === ARGUMENT;
const isUnknown /* */ = is(UNKNOWN);
const isScript /* */ = is(SCRIPT);
const isTransaction /* */ = is(TRANSACTION);
const isGetTransactionStatus /* */ = is(GET_TRANSACTION_STATUS);
const isGetTransaction /* */ = is(GET_TRANSACTION);
const isGetAccount /* */ = is(GET_ACCOUNT);
const isGetEvents /* */ = is(GET_EVENTS);
const isPing /* */ = is(PING);
const isGetBlock /* */ = is(GET_BLOCK);
const isGetBlockHeader /* */ = is(GET_BLOCK_HEADER);
const isGetCollection /* */ = is(GET_COLLECTION);
const isGetNetworkParameters /* */ = is(GET_NETWORK_PARAMETERS);
const isOk /* */ = ix => ix.status === OK;
const isBad /* */ = ix => ix.status === BAD;
const why /* */ = ix => ix.reason;
const isAccount /* */ = account => account.kind === ACCOUNT;
const isParam /* */ = param => param.kind === PARAM;
const isArgument /* */ = argument => argument.kind === ARGUMENT;
const hardMode = ix => {

@@ -346,9 +236,6 @@ for (let key of Object.keys(ix)) {

}
return ix;
};
const recPipe = async function (ix) {
let fns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
try {

@@ -368,3 +255,2 @@ ix = hardMode(await ix);

};
const pipe = function () {

@@ -374,3 +260,2 @@ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

}
const [arg1, arg2] = args;

@@ -380,5 +265,3 @@ if (isArray$1(arg1) && arg2 == null) return d => pipe(d, arg1);

};
const identity$1 = v => v;
const get = (ix, key, fallback) => {

@@ -500,3 +383,2 @@ return ix.assigns[key] == null ? fallback : ix.assigns[key];

*/
function getBlock() {

@@ -515,3 +397,2 @@ let isSealed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;

*/
function getAccount(addr) {

@@ -531,11 +412,7 @@ return pipe([makeGetAccount, ix => {

};
const decodeImplicit = async i => i;
const decodeVoid = async () => null;
const decodeType = async type => {
return type.staticType;
};
const decodePath = async path => {

@@ -547,3 +424,2 @@ return {

};
const decodeCapability = async cap => {

@@ -556,5 +432,3 @@ return {

};
const decodeOptional = async (optional, decoders, stack) => optional ? await recurseDecode(optional, decoders, stack) : null;
const decodeReference = async v => ({

@@ -564,5 +438,3 @@ address: v.address,

});
const decodeArray = async (array, decoders, stack) => await Promise.all(array.map(v => new Promise(async res => res(await recurseDecode(v, decoders, [...stack, v.type])))));
const decodeDictionary = async (dictionary, decoders, stack) => await dictionary.reduce(async (acc, v) => {

@@ -573,3 +445,2 @@ acc = await acc;

}, Promise.resolve({}));
const decodeComposite = async (composite, decoders, stack) => {

@@ -584,3 +455,2 @@ const decoded = await composite.fields.reduce(async (acc, v) => {

};
const defaultDecoders = {

@@ -624,3 +494,2 @@ UInt: decodeImplicit,

};
const decoderLookup = (decoders, lookup) => {

@@ -632,3 +501,2 @@ const found = Object.keys(decoders).find(decoder => {

}
return decoder === lookup;

@@ -638,3 +506,2 @@ });

};
const recurseDecode = async (decodeInstructions, decoders, stack) => {

@@ -645,2 +512,3 @@ let decoder = decoderLookup(decoders, decodeInstructions.type);

};
/**

@@ -653,4 +521,2 @@ * @description - Decodes a response from Flow into JSON

*/
const decode$1 = async function (decodeInstructions) {

@@ -664,3 +530,4 @@ let customDecoders = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

}, customDecoders);
const decoders = { ...filteredDecoders,
const decoders = {
...filteredDecoders,
...customDecoders

@@ -672,7 +539,7 @@ };

let customDecoders = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (response.encodedData) {
return decode$1(response.encodedData, customDecoders);
} else if (response.transactionStatus) {
return { ...response.transactionStatus,
return {
...response.transactionStatus,
events: await Promise.all(response.transactionStatus.events.map(async function decodeEvents(e) {

@@ -726,3 +593,2 @@ return {

}
return null;

@@ -732,21 +598,14 @@ };

const isFn$2 = v => typeof v === "function";
const isString$1 = v => typeof v === "string";
const oldIdentifierPatternFn = () => /\b(0x\w+)\b/g;
function isOldIdentifierSyntax(cadence) {
return oldIdentifierPatternFn().test(cadence);
}
const newIdentifierPatternFn = () => /import\s+"(\w+)"/g;
function isNewIdentifierSyntax(cadence) {
return newIdentifierPatternFn().test(cadence);
}
function getContractIdentifierSyntaxMatches(cadence) {
return cadence.matchAll(newIdentifierPatternFn());
}
async function resolveCadence(ix) {

@@ -759,3 +618,2 @@ if (!isTransaction(ix) && !isScript(ix)) return ix;

invariant$1(!isOldIdentifierSyntax(cadence) || !isNewIdentifierSyntax(cadence), "Both account identifier and contract identifier syntax not simultaneously supported.");
if (isOldIdentifierSyntax(cadence)) {

@@ -768,7 +626,5 @@ cadence = await config().where(/^0x/).then(d => Object.entries(d).reduce((cadence, _ref) => {

}
if (isNewIdentifierSyntax(cadence)) {
for (const [fullMatch, contractName] of getContractIdentifierSyntaxMatches(cadence)) {
const address = await config().get(`system.contracts.${contractName}`);
if (address) {

@@ -784,5 +640,5 @@ cadence = cadence.replace(fullMatch, `import ${contractName} from ${withPrefix(address)}`);

}
} // We need to move this over in any case.
}
// We need to move this over in any case.
ix.message.cadence = cadence;

@@ -793,3 +649,2 @@ return ix;

const isFn$1 = v => typeof v === "function";
function cast(arg) {

@@ -799,11 +654,10 @@ // prettier-ignore

if (isFn$1(arg.xform)) return arg.xform(arg.value);
if (isFn$1(arg.xform.asArgument)) return arg.xform.asArgument(arg.value); // prettier-ignore
if (isFn$1(arg.xform.asArgument)) return arg.xform.asArgument(arg.value);
// prettier-ignore
invariant$1(false, `Invalid Argument`, arg);
}
async function handleArgResolution(arg) {
let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
invariant$1(depth > 0, `Argument Resolve Recursion Limit Exceeded for Arg: ${arg.tempId}`);
if (isFn$1(arg.resolveArgument)) {

@@ -816,3 +670,2 @@ const resolvedArg = await arg.resolveArgument();

}
async function resolveArguments(ix) {

@@ -825,3 +678,2 @@ if (isTransaction(ix) || isScript(ix)) {

}
return ix;

@@ -833,25 +685,14 @@ }

const encodeTxIdFromVoucher = voucher => sha3_256(rlpEncode(prepareVoucher(voucher)));
const rightPaddedHexBuffer = (value, pad) => Buffer.from(value.padEnd(pad * 2, 0), "hex");
const leftPaddedHexBuffer = (value, pad) => Buffer.from(value.padStart(pad * 2, 0), "hex");
const TRANSACTION_DOMAIN_TAG = rightPaddedHexBuffer(Buffer.from("FLOW-V0.0-transaction").toString("hex"), 32).toString("hex");
const prependTransactionDomainTag = tx => TRANSACTION_DOMAIN_TAG + tx;
const addressBuffer = addr => leftPaddedHexBuffer(addr, 8);
const blockBuffer = block => leftPaddedHexBuffer(block, 32);
const argumentToString = arg => Buffer.from(JSON.stringify(arg), "utf8");
const scriptBuffer = script => Buffer.from(script, "utf8");
const signatureBuffer = signature => Buffer.from(signature, "hex");
const rlpEncode = v => {
return encode(v).toString("hex");
};
const sha3_256 = msg => {

@@ -862,3 +703,2 @@ const sha = new SHA3(256);

};
const preparePayload = tx => {

@@ -868,3 +708,2 @@ validatePayload(tx);

};
const prepareEnvelope = tx => {

@@ -874,3 +713,2 @@ validateEnvelope(tx);

};
const preparePayloadSignatures = tx => {

@@ -893,7 +731,5 @@ const signers = collectSigners(tx);

};
const collectSigners = tx => {
const signers = new Map();
let i = 0;
const addSigner = addr => {

@@ -905,3 +741,2 @@ if (!signers.has(addr)) {

};
addSigner(tx.proposalKey.address);

@@ -912,7 +747,5 @@ addSigner(tx.payer);

};
const prepareVoucher = voucher => {
validateVoucher(voucher);
const signers = collectSigners(voucher);
const prepareSigs = sigs => {

@@ -939,6 +772,4 @@ return sigs.map(_ref => {

};
return [[scriptBuffer(voucher.cadence), voucher.arguments.map(argumentToString), blockBuffer(voucher.refBlock), voucher.computeLimit, addressBuffer(sansPrefix(voucher.proposalKey.address)), voucher.proposalKey.keyId, voucher.proposalKey.sequenceNum, addressBuffer(sansPrefix(voucher.payer)), voucher.authorizers.map(authorizer => addressBuffer(sansPrefix(authorizer)))], prepareSigs(voucher.payloadSigs), prepareSigs(voucher.envelopeSigs)];
};
const validatePayload = tx => {

@@ -948,3 +779,2 @@ payloadFields.forEach(field => checkField(tx, field));

};
const validateEnvelope = tx => {

@@ -956,3 +786,2 @@ payloadSigsFields.forEach(field => checkField(tx, field));

};
const validateVoucher = voucher => {

@@ -970,11 +799,6 @@ payloadFields.forEach(field => checkField(voucher, field));

};
const isNumber = v => typeof v === "number";
const isString = v => typeof v === "string";
const isObject = v => v !== null && typeof v === "object";
const isArray = v => isObject(v) && v instanceof Array;
const payloadFields = [{

@@ -1041,3 +865,2 @@ name: "cadence",

}];
const checkField = (obj, field, base, index) => {

@@ -1053,3 +876,2 @@ const {

};
const printFieldName = (field, base, index) => {

@@ -1059,5 +881,3 @@ if (!!base) return index == null ? `${base}.${field}` : `${base}.${index}.${field}`;

};
const missingFieldError = (field, base, index) => new Error(`Missing field ${printFieldName(field, base, index)}`);
const invalidFieldError = (field, base, index) => new Error(`Invalid field ${printFieldName(field, base, index)}`);

@@ -1069,3 +889,2 @@

inside.add(ix.proposer);
if (Array.isArray(ix.payer)) {

@@ -1076,3 +895,2 @@ ix.payer.forEach(p => inside.delete(p));

}
return Array.from(inside);

@@ -1092,3 +910,2 @@ }

};
const buildInsideSigners = () => findInsideSigners(ix).map(id => ({

@@ -1099,3 +916,2 @@ address: withPrefix(ix.accounts[id].addr),

}));
const buildOutsideSigners = () => findOutsideSigners(ix).map(id => ({

@@ -1106,3 +922,2 @@ address: withPrefix(ix.accounts[id].addr),

}));
return {

@@ -1129,5 +944,3 @@ cadence: ix.message.cadence,

const idof$1 = acct => `${withPrefix(acct.addr)}-${acct.keyId}`;
const isFn = v => typeof v === "function";
function buildPreSignable(acct, ix) {

@@ -1150,3 +963,2 @@ try {

}
async function collectAccounts(ix, accounts, last) {

@@ -1159,3 +971,2 @@ let depth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 3;

let authorizations = [];
for (let ax of accounts) {

@@ -1166,3 +977,2 @@ let resolve = ax.resolve;

if (isFn(resolve)) ax = await resolve(ax, buildPreSignable(ax, ix));
if (Array.isArray(ax)) {

@@ -1174,7 +984,5 @@ await collectAccounts(ix, ax, old, depth - 1);

}
if (ax.addr != null && ax.keyId != null) {
ax.tempId = idof$1(ax);
}
ix.accounts[ax.tempId] = ix.accounts[ax.tempId] || ax;

@@ -1184,7 +992,5 @@ ix.accounts[ax.tempId].role.proposer = ix.accounts[ax.tempId].role.proposer || ax.role.proposer;

ix.accounts[ax.tempId].role.authorizer = ix.accounts[ax.tempId].role.authorizer || ax.role.authorizer;
if (ix.accounts[ax.tempId].role.proposer && ix.proposer === old.tempId) {
ix.proposer = ax.tempId;
}
if (ix.accounts[ax.tempId].role.payer) {

@@ -1196,3 +1002,2 @@ if (Array.isArray(ix.payer)) {

}
if (ix.payer.length > 1) {

@@ -1213,3 +1018,2 @@ // remove payer dups based on addr and keyId

const multiAccts = Array.from(new Set(payerAccts));
if (multiAccts.length > 1) {

@@ -1220,3 +1024,2 @@ throw new Error("Payer can not be different accounts");

}
if (ix.accounts[ax.tempId].role.authorizer) {

@@ -1232,6 +1035,4 @@ if (last) {

}
if (old.tempId != ax.tempId) delete ix.accounts[old.tempId];
}
if (last) {

@@ -1242,3 +1043,2 @@ // complete (flatmap) group replacement

}
async function resolveAccounts(ix) {

@@ -1253,3 +1053,2 @@ if (isTransaction(ix)) {

}
try {

@@ -1263,3 +1062,2 @@ await collectAccounts(ix, Object.values(ix.accounts));

}
return ix;

@@ -1275,3 +1073,4 @@ }

let outsideSigners = findOutsideSigners(ix);
const outsidePayload = encodeTransactionEnvelope({ ...prepForEncoding(ix),
const outsidePayload = encodeTransactionEnvelope({
...prepForEncoding(ix),
payloadSigs: insideSigners.map(id => ({

@@ -1291,6 +1090,4 @@ address: ix.accounts[id].addr,

}
return ix;
}
function fetchSignature(ix, payload) {

@@ -1306,3 +1103,2 @@ return async function innerFetchSignature(id) {

}
function buildSignable(acct, message, ix) {

@@ -1328,3 +1124,2 @@ try {

}
function prepForEncoding(ix) {

@@ -1361,3 +1156,2 @@ const payerAddress = sansPrefix((Array.isArray(ix.payer) ? ix.accounts[ix.payer[0]] : ix.accounts[ix.payer]).addr);

}
return ix;

@@ -1368,7 +1162,5 @@ }

const fn = get(ix, "ix.voucher-intercept");
if (isFn$3(fn)) {
await fn(createSignableVoucher(ix));
}
return ix;

@@ -1381,3 +1173,2 @@ }

ix.message.computeLimit = ix.message.computeLimit || (await config.get("fcl.limit"));
if (!ix.message.computeLimit) {

@@ -1392,3 +1183,2 @@ logger.log.deprecate({

}
return ix;

@@ -1398,7 +1188,5 @@ }

const noop = v => v;
const debug = function (key) {
let fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
return async ix => {
const accts = ix => ["\nAccounts:", {

@@ -1409,3 +1197,2 @@ proposer: ix.proposer,

}, "\n\nDetails:", ix.accounts].filter(Boolean);
const log = function () {

@@ -1415,6 +1202,4 @@ for (var _len = arguments.length, msg = new Array(_len), _key = 0; _key < _len; _key++) {

}
console.log(`debug[${key}] ---\n`, ...msg, "\n\n\n---");
};
if (await config.get(`debug.${key}`)) await fn(ix, log, accts);

@@ -1424,9 +1209,3 @@ return ix;

};
const resolve = pipe([resolveCadence, debug("cadence", (ix, log) => log(ix.message.cadence)), resolveComputeLimit, debug("compute limit", (ix, log) => log(ix.message.computeLimit)), resolveArguments, debug("arguments", (ix, log) => log(ix.message.arguments, ix.message)), resolveAccounts, debug("accounts", (ix, log, accts) => log(...accts(ix))),
/* special */
execFetchRef,
/* special */
execFetchSequenceNumber, resolveSignatures, debug("signatures", (ix, log, accts) => log(...accts(ix))), resolveFinalNormalization, resolveValidators, resolveVoucherIntercept, debug("resolved", (ix, log) => log(ix))]);
const resolve = pipe([resolveCadence, debug("cadence", (ix, log) => log(ix.message.cadence)), resolveComputeLimit, debug("compute limit", (ix, log) => log(ix.message.computeLimit)), resolveArguments, debug("arguments", (ix, log) => log(ix.message.arguments, ix.message)), resolveAccounts, debug("accounts", (ix, log, accts) => log(...accts(ix))), /* special */execFetchRef, /* special */execFetchSequenceNumber, resolveSignatures, debug("signatures", (ix, log, accts) => log(...accts(ix))), resolveFinalNormalization, resolveValidators, resolveVoucherIntercept, debug("resolved", (ix, log) => log(ix))]);
async function execFetchRef(ix) {

@@ -1446,6 +1225,4 @@ if (isTransaction(ix) && ix.message.refBlock == null) {

}
return ix;
}
async function execFetchSequenceNumber(ix) {

@@ -1455,3 +1232,2 @@ if (isTransaction(ix)) {

invariant$1(acct, `Transactions require a proposer`);
if (acct.sequenceNum == null) {

@@ -1471,3 +1247,2 @@ const node = await config().get("accessNode.api");

}
return ix;

@@ -1480,3 +1255,2 @@ }

}
if (args.length > 1) {

@@ -1492,3 +1266,2 @@ const [predicate, message] = args;

}
const [fn] = args;

@@ -1507,3 +1280,2 @@ return ix => fn(ix, {

*/
const send = async function () {

@@ -1542,3 +1314,2 @@ let args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];

};
const findEnvelopeSigners = voucher => {

@@ -1549,3 +1320,2 @@ // Envelope Signers Are: (payer)

};
class UnableToDetermineMessageEncodingTypeForSignerAddress extends Error {

@@ -1560,3 +1330,2 @@ constructor(signerAddress) {

}
}

@@ -1568,7 +1337,5 @@ const encodeMessageFromSignable = (signable, signerAddress) => {

const isEnvelopeSigner = envelopeSigners.includes(withPrefix(signerAddress));
if (!isPayloadSigner && !isEnvelopeSigner) {
throw new UnableToDetermineMessageEncodingTypeForSignerAddress(signerAddress);
}
const message = {

@@ -1579,3 +1346,4 @@ cadence: signable.voucher.cadence,

arguments: signable.voucher.arguments,
proposalKey: { ...signable.voucher.proposalKey,
proposalKey: {
...signable.voucher.proposalKey,
address: sansPrefix(signable.voucher.proposalKey.address)

@@ -1585,3 +1353,4 @@ },

authorizers: signable.voucher.authorizers.map(sansPrefix),
payloadSigs: signable.voucher.payloadSigs.map(ps => ({ ...ps,
payloadSigs: signable.voucher.payloadSigs.map(ps => ({
...ps,
address: sansPrefix(ps.address)

@@ -1602,3 +1371,2 @@ }))

*/
function atBlockHeight(height) {

@@ -1644,3 +1412,2 @@ return pipe([ix => {

*/
function account(address) {

@@ -1652,6 +1419,8 @@ let {

let opts = arguments.length > 2 ? arguments[2] : undefined;
invariant$1(!(id && height), `Method: account -- Cannot pass "id" and "height" simultaneously`); // Get account by ID
invariant$1(!(id && height), `Method: account -- Cannot pass "id" and "height" simultaneously`);
if (id) return send([getAccount(address), atBlockId(id)], opts).then(decodeResponse); // Get account by height
// Get account by ID
if (id) return send([getAccount(address), atBlockId(id)], opts).then(decodeResponse);
// Get account by height
if (height) return send([getAccount(address), atBlockHeight(height)], opts).then(decodeResponse);

@@ -1674,3 +1443,2 @@ return send([getAccount(address)], opts).then(decodeResponse);

*/
function block() {

@@ -1684,8 +1452,11 @@ let {

invariant$1(!(sealed && id || sealed && height), `Method: block -- Cannot pass "sealed" with "id" or "height"`);
invariant$1(!(id && height), `Method: block -- Cannot pass "id" and "height" simultaneously`); // Get block by ID
invariant$1(!(id && height), `Method: block -- Cannot pass "id" and "height" simultaneously`);
if (id) return send([getBlock(), atBlockId(id)], opts).then(decodeResponse); // Get block by height
// Get block by ID
if (id) return send([getBlock(), atBlockId(id)], opts).then(decodeResponse);
if (height) return send([getBlock(), atBlockHeight(height)], opts).then(decodeResponse); // Get latest block
// Get block by height
if (height) return send([getBlock(), atBlockHeight(height)], opts).then(decodeResponse);
// Get latest block
return send([getBlock(sealed)], opts).then(decodeResponse);

@@ -1719,3 +1490,2 @@ }

}
return pipe([makeGetEvents, ix => {

@@ -1739,3 +1509,2 @@ ix.events.eventType = eventType;

*/
function getEventsAtBlockHeightRange(eventName, fromBlockHeight, toBlockHeight) {

@@ -1758,3 +1527,2 @@ return pipe([makeGetEvents, ix => {

*/
function getEventsAtBlockIds(eventName) {

@@ -1774,3 +1542,2 @@ let blockIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];

*/
function getBlockHeader() {

@@ -1791,3 +1558,2 @@ let isSealed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;

*/
function getCollection() {

@@ -1807,3 +1573,2 @@ let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;

*/
function getTransactionStatus(transactionId) {

@@ -1822,3 +1587,2 @@ return pipe([makeGetTransactionStatus, ix => {

*/
function getTransaction(transactionId) {

@@ -1849,3 +1613,2 @@ return pipe([makeGetTransaction, ix => {

*/
function args() {

@@ -1855,2 +1618,3 @@ let ax = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];

}
/**

@@ -1862,3 +1626,2 @@ * @description - A utility builder to be used with fcl.args[...] to create FCL supported arguments for interactions

*/
function arg(value, xform) {

@@ -1900,2 +1663,3 @@ return {

const DEFUALT_REF = null;
/**

@@ -1906,3 +1670,2 @@ * @description - A template builder to use a Cadence transaction for an interaction

*/
function transaction() {

@@ -1960,3 +1723,2 @@ return pipe([makeTransaction, put("ix.cadence", template(...arguments)), ix => {

}
function resolveRefBlockId(opts) {

@@ -1974,4 +1736,4 @@ return async ix => {

// prettier-ignore
invariant$1(ix.account, "mockAccountResponse(ix) -- ix.account is missing", ix); // prettier-ignore
invariant$1(ix.account, "mockAccountResponse(ix) -- ix.account is missing", ix);
// prettier-ignore
invariant$1(ix.account.addr, "mockAccountResponse(ix) -- ix.account.addr is missing", ix);

@@ -1999,5 +1761,3 @@ const address = ix.account.addr;

}
const identity = v => v;
function mockSend() {

@@ -2007,10 +1767,7 @@ let fallback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity;

ix = await ix;
switch (true) {
case isGetAccount(ix):
return mockAccountResponse(ix);
case isGetBlock(ix):
return mockGetBlockResponse();
default:

@@ -2029,3 +1786,4 @@ return fallback(ix);

return function (account) {
const acct = { ...account,
const acct = {
...account,
...opts,

@@ -2035,3 +1793,2 @@ signingFunction: opts.signingFunction || account.signingFunction || fallbackSigningFunction

return acct;
function fallbackSigningFunction(signable) {

@@ -2053,3 +1810,4 @@ return {

} = opts;
return { ...account,
return {
...account,
tempId: tempId || "WITH_RESOLVE",

@@ -2065,3 +1823,2 @@ resolve: authzFn(rest)

};
function authzResolveMany() {

@@ -2071,14 +1828,18 @@ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

const tempId = opts.tempId || "AUTHZ_RESOLVE_MANY";
return { ...account,
return {
...account,
tempId,
resolve: () => [opts.proposer && authzFn(opts.proposer)({
role: { ...ROLE,
role: {
...ROLE,
proposer: true
}
}), ...opts.authorizations.map(authzFn).map(d => d({
role: { ...ROLE,
role: {
...ROLE,
authorizer: true
}
})), opts.payer && authzFn(opts.payer)({
role: { ...ROLE,
role: {
...ROLE,
payer: true

@@ -2107,4 +1868,5 @@ }

const VERSION = "1.2.0-alpha.10" ;
const VERSION = "1.2.0" ;
// Deprecated
const params = params => logger.log.deprecate({

@@ -2111,0 +1873,0 @@ pkg: "FCL/SDK",

{
"name": "@onflow/sdk",
"version": "1.2.0-alpha.10",
"version": "1.2.0",
"description": "Flow SDK",

@@ -21,4 +21,4 @@ "license": "Apache-2.0",

"devDependencies": {
"@onflow/fcl-bundle": "^1.3.0-alpha.0",
"@onflow/typedefs": "^1.1.0-alpha.6",
"@onflow/fcl-bundle": "^1.3.0",
"@onflow/typedefs": "^1.1.0",
"eslint": "^8.35.0",

@@ -46,10 +46,10 @@ "eslint-plugin-jsdoc": "^40.0.1",

"@babel/runtime": "^7.18.6",
"@onflow/config": "^1.1.0-alpha.8",
"@onflow/rlp": "^1.1.0-alpha.2",
"@onflow/transport-http": "^1.6.0-alpha.6",
"@onflow/util-actor": "^1.2.0-alpha.3",
"@onflow/util-address": "^1.1.0-alpha.5",
"@onflow/util-invariant": "^1.1.0-alpha.2",
"@onflow/util-logger": "^1.2.0-alpha.3",
"@onflow/util-template": "^1.1.0-alpha.2",
"@onflow/config": "^1.1.0",
"@onflow/rlp": "^1.1.0",
"@onflow/transport-http": "^1.6.0",
"@onflow/util-actor": "^1.2.0",
"@onflow/util-address": "^1.1.0",
"@onflow/util-invariant": "^1.1.0",
"@onflow/util-logger": "^1.2.0",
"@onflow/util-template": "^1.1.0",
"deepmerge": "^4.2.2",

@@ -56,0 +56,0 @@ "sha3": "^2.1.4"

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc