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

@onflow/send

Package Overview
Dependencies
Maintainers
8
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/send - npm Package Compare versions

Comparing version 0.0.27 to 0.0.28

2

dist/send.js

@@ -1,2 +0,2 @@

var e=require("@onflow/interaction"),t=require("@onflow/protobuf"),r=require("@onflow/response"),n=require("@onflow/util-address"),s=require("@improbable-eng/grpc-web"),o=require("@improbable-eng/grpc-web-node-http-transport"),a=require("@onflow/config"),i=function(e,t,r){try{return Promise.resolve(new Promise(function(n,o){s.grpc.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===s.grpc.Code.OK?n(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};s.grpc.setDefaultTransport(o.NodeHttpTransport());var c=function(e){return Buffer.from(e,"hex")},u=function(e){return Buffer.from(e.padStart(16,0),"hex")},g=function(e){return Buffer.from(e).toString("hex")},l=function(e){return Buffer.from(e).toString("hex")},f=function(e){return Buffer.from(e).toString("hex")},d=function(e){return Buffer.from(e).toString("hex")};console.log("%cSEND UPDATED","color:green;font-size:56px;font-family:monospace;"),exports.send=function(s,o){void 0===o&&(o={});try{var p=function(a){return o.node=a,Promise.resolve(s).then(function(a){switch(s=a,!0){case e.isTransaction(s):return function(e,s){void 0===s&&(s={});try{return Promise.resolve(e).then(function(o){e=o,console.log("111",e);var a=new t.Transaction;a.setScript(Buffer.from(e.message.cadence,"utf8")),a.setGasLimit(e.message.computeLimit),a.setReferenceBlockId(e.message.refBlock?c(e.message.refBlock):null),a.setPayer(u(n.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return a.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return a.addAuthorizers(u(n.sansPrefix(e)))});var g=new t.Transaction.ProposalKey;g.setAddress(u(n.sansPrefix(e.accounts[e.proposer].addr))),g.setKeyId(e.accounts[e.proposer].keyId),g.setSequenceNumber(e.accounts[e.proposer].sequenceNum),a.setProposalKey(g);for(var l=0,f=Object.values(e.accounts);l<f.length;l++){var d=f[l];console.log("NON-PAYER",d);try{if(null==d.signature)return;if(d.role.payer)return;var p=new t.Transaction.Signature;p.setAddress(u(n.sansPrefix(d.addr))),p.setKeyId(d.keyId),p.setSignature(c(d.signature)),a.addPayloadSignatures(p)}catch(t){throw console.error("Trouble applying payload signature",{acct:d,ix:e}),t}}for(var m=0,h=Object.values(e.accounts);m<h.length;m++){var v=h[m];console.log("PAYER",v);try{if(null==v.signature)return;if(!v.role.payer)return;var S=new t.Transaction.Signature;S.setAddress(u(n.sansPrefix(v.addr))),S.setKeyId(v.keyId),S.setSignature(c(v.signature)),a.addEnvelopeSignatures(S)}catch(t){throw console.error("Trouble applying envelope signature",{acct:v,ix:e}),t}}var I=new t.SendTransactionRequest;return I.setTransaction(a),console.log("UNARY_SEND",{req:I}),Promise.resolve(i(s.node,t.AccessAPI.SendTransaction,I)).then(function(t){console.log("UNARY_SENT",{res:t});var n,s=r.response();return s.tag=e.tag,s.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),console.log("SEND TX COMPLETE",{ret:s}),s})})}catch(e){return Promise.reject(e)}}(s,o);case e.isGetTransactionStatus(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.GetTransactionRequest;return o.setId(Buffer.from(e.transactionId,"hex")),Promise.resolve(i(n.node,t.AccessAPI.GetTransactionResult,o)).then(function(t){var n=t.getEventsList(),s=r.response();return s.tag=e.tag,s.transaction={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:n.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},s})})}catch(e){return Promise.reject(e)}}(s,o);case e.isScript(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.ExecuteScriptAtLatestBlockRequest,a=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return o.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),o.setScript(a),Promise.resolve(i(n.node,t.AccessAPI.ExecuteScriptAtLatestBlock,o)).then(function(t){var n=r.response();return n.tag=e.tag,n.encodedData=JSON.parse(Buffer.from(t.getValue_asU8()).toString("utf8")),n})})}catch(e){return Promise.reject(e)}}(s,o);case e.isGetAccount(s):return function(e,s){void 0===s&&(s={});try{return Promise.resolve(e).then(function(o){e=o;var a,c=new t.GetAccountRequest;return c.setAddress((a=n.sansPrefix(e.accountAddr),Buffer.from(a.padStart(16,0),"hex"))),Promise.resolve(i(s.node,t.AccessAPI.GetAccount,c)).then(function(t){var s=r.response();s.tag=e.tag;var o=t.getAccount();return s.account={address:n.withPrefix(g(o.getAddress_asU8())),balance:o.getBalance(),code:o.getCode_asU8(),keys:o.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:g(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}})},s})})}catch(e){return Promise.reject(e)}}(s,o);case e.isGetEvents(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.GetEventsForHeightRangeRequest;return o.setType(e.events.eventType),o.setStartHeight(Number(e.events.start)),o.setEndHeight(Number(e.events.end)),Promise.resolve(i(n.node,t.AccessAPI.GetEventsForHeightRange,o)).then(function(t){var n=r.response();n.tag=e.tag;var s=t.getResultsList();return n.events=s.reduce(function(e,t){var r=t.getBlockId(),n=t.getBlockHeight();return t.getEventsList().forEach(function(t){var s;e.push({blockId:r,blockHeight:n,type:t.getType(),transactionId:(s=t.getTransactionId_asU8(),Buffer.from(s).toString("hex")),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),n})})}catch(e){return Promise.reject(e)}}(s,o);case e.isGetLatestBlock(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(o.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(i(n.node,t.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),s=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=r.response();return i.tag=e.tag,i.block={id:l(n.getId_asU8()),parentId:l(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:s.map(function(e){return{collectionId:l(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:l(e.getBlockId_asU8()),executionReceiptId:l(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(s,o);case e.isGetBlockById(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(i(n.node,t.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),s=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=r.response();return i.tag=e.tag,i.block={id:f(n.getId_asU8()),parentId:f(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:s.map(function(e){return{collectionId:f(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:f(e.getBlockId_asU8()),executionReceiptId:f(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(s,o);case e.isGetBlockByHeight(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.GetBlockByHeightRequest;return o.setHeight(e.block.height),Promise.resolve(i(n.node,t.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),s=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=r.response();return i.tag=e.tag,i.block={id:d(n.getId_asU8()),parentId:d(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:s.map(function(e){return{collectionId:d(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:d(e.getBlockId_asU8()),executionReceiptId:d(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(s,o);case e.isPing(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.PingRequest;return Promise.resolve(i(n.node,t.AccessAPI.Ping,o)).then(function(t){var n=r.response();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(s,o);default:return s}})},m=o.node;return Promise.resolve(m?p(m):Promise.resolve(a.config().get("accessNode.api")).then(p))}catch(e){return Promise.reject(e)}};
var e=require("@onflow/interaction"),t=require("@onflow/protobuf"),r=require("@onflow/response"),n=require("@onflow/util-address"),s=require("@improbable-eng/grpc-web"),o=require("@improbable-eng/grpc-web-node-http-transport"),a=require("@onflow/config"),i=function(e,t,r){try{return Promise.resolve(new Promise(function(n,o){s.grpc.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===s.grpc.Code.OK?n(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};s.grpc.setDefaultTransport(o.NodeHttpTransport());var c=function(e){return Buffer.from(e,"hex")},u=function(e){return Buffer.from(e.padStart(16,0),"hex")},g=function(e){return Buffer.from(e).toString("hex")},l=function(e){return Buffer.from(e).toString("hex")},f=function(e){return Buffer.from(e).toString("hex")},d=function(e){return Buffer.from(e).toString("hex")};console.log("%cSEND UPDATED","color:green;font-size:56px;font-family:monospace;"),exports.send=function(s,o){void 0===o&&(o={});try{var p=function(a){return o.node=a,Promise.resolve(s).then(function(a){switch(s=a,!0){case e.isTransaction(s):return function(e,s){void 0===s&&(s={});try{return Promise.resolve(e).then(function(o){e=o,console.log("111",e);var a=new t.Transaction;a.setScript(Buffer.from(e.message.cadence,"utf8")),a.setGasLimit(e.message.computeLimit),a.setReferenceBlockId(e.message.refBlock?c(e.message.refBlock):null),a.setPayer(u(n.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return a.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return a.addAuthorizers(u(n.sansPrefix(e)))});var g=new t.Transaction.ProposalKey;g.setAddress(u(n.sansPrefix(e.accounts[e.proposer].addr))),g.setKeyId(e.accounts[e.proposer].keyId),g.setSequenceNumber(e.accounts[e.proposer].sequenceNum),a.setProposalKey(g);for(var l=0,f=Object.values(e.accounts);l<f.length;l++){var d=f[l];if(null==d.signature)return;if(d.role.payer)return;console.log("NON-PAYER",d);try{var p=new t.Transaction.Signature;p.setAddress(u(n.sansPrefix(d.addr))),p.setKeyId(d.keyId),p.setSignature(c(d.signature)),a.addPayloadSignatures(p)}catch(t){throw console.error("Trouble applying payload signature",{acct:d,ix:e}),t}}for(var m=0,h=Object.values(e.accounts);m<h.length;m++){var v=h[m];if(null==v.signature)return;if(!v.role.payer)return;console.log("PAYER",v);try{var S=new t.Transaction.Signature;S.setAddress(u(n.sansPrefix(v.addr))),S.setKeyId(v.keyId),S.setSignature(c(v.signature)),a.addEnvelopeSignatures(S)}catch(t){throw console.error("Trouble applying envelope signature",{acct:v,ix:e}),t}}var I=new t.SendTransactionRequest;return I.setTransaction(a),console.log("UNARY_SEND",{req:I}),Promise.resolve(i(s.node,t.AccessAPI.SendTransaction,I)).then(function(t){console.log("UNARY_SENT",{res:t});var n,s=r.response();return s.tag=e.tag,s.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),console.log("SEND TX COMPLETE",{ret:s}),s})})}catch(e){return Promise.reject(e)}}(s,o);case e.isGetTransactionStatus(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.GetTransactionRequest;return o.setId(Buffer.from(e.transactionId,"hex")),Promise.resolve(i(n.node,t.AccessAPI.GetTransactionResult,o)).then(function(t){var n=t.getEventsList(),s=r.response();return s.tag=e.tag,s.transaction={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:n.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},s})})}catch(e){return Promise.reject(e)}}(s,o);case e.isScript(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.ExecuteScriptAtLatestBlockRequest,a=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return o.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),o.setScript(a),Promise.resolve(i(n.node,t.AccessAPI.ExecuteScriptAtLatestBlock,o)).then(function(t){var n=r.response();return n.tag=e.tag,n.encodedData=JSON.parse(Buffer.from(t.getValue_asU8()).toString("utf8")),n})})}catch(e){return Promise.reject(e)}}(s,o);case e.isGetAccount(s):return function(e,s){void 0===s&&(s={});try{return Promise.resolve(e).then(function(o){e=o;var a,c=new t.GetAccountRequest;return c.setAddress((a=n.sansPrefix(e.accountAddr),Buffer.from(a.padStart(16,0),"hex"))),Promise.resolve(i(s.node,t.AccessAPI.GetAccount,c)).then(function(t){var s=r.response();s.tag=e.tag;var o=t.getAccount();return s.account={address:n.withPrefix(g(o.getAddress_asU8())),balance:o.getBalance(),code:o.getCode_asU8(),keys:o.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:g(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}})},s})})}catch(e){return Promise.reject(e)}}(s,o);case e.isGetEvents(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.GetEventsForHeightRangeRequest;return o.setType(e.events.eventType),o.setStartHeight(Number(e.events.start)),o.setEndHeight(Number(e.events.end)),Promise.resolve(i(n.node,t.AccessAPI.GetEventsForHeightRange,o)).then(function(t){var n=r.response();n.tag=e.tag;var s=t.getResultsList();return n.events=s.reduce(function(e,t){var r=t.getBlockId(),n=t.getBlockHeight();return t.getEventsList().forEach(function(t){var s;e.push({blockId:r,blockHeight:n,type:t.getType(),transactionId:(s=t.getTransactionId_asU8(),Buffer.from(s).toString("hex")),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),n})})}catch(e){return Promise.reject(e)}}(s,o);case e.isGetLatestBlock(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(o.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(i(n.node,t.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),s=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=r.response();return i.tag=e.tag,i.block={id:l(n.getId_asU8()),parentId:l(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:s.map(function(e){return{collectionId:l(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:l(e.getBlockId_asU8()),executionReceiptId:l(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(s,o);case e.isGetBlockById(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(i(n.node,t.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),s=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=r.response();return i.tag=e.tag,i.block={id:f(n.getId_asU8()),parentId:f(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:s.map(function(e){return{collectionId:f(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:f(e.getBlockId_asU8()),executionReceiptId:f(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(s,o);case e.isGetBlockByHeight(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.GetBlockByHeightRequest;return o.setHeight(e.block.height),Promise.resolve(i(n.node,t.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),s=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=r.response();return i.tag=e.tag,i.block={id:d(n.getId_asU8()),parentId:d(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:s.map(function(e){return{collectionId:d(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:d(e.getBlockId_asU8()),executionReceiptId:d(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(s,o);case e.isPing(s):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(s){e=s;var o=new t.PingRequest;return Promise.resolve(i(n.node,t.AccessAPI.Ping,o)).then(function(t){var n=r.response();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(s,o);default:return s}})},m=o.node;return Promise.resolve(m?p(m):Promise.resolve(a.config().get("accessNode.api")).then(p))}catch(e){return Promise.reject(e)}};
//# sourceMappingURL=send.js.map

@@ -1,2 +0,2 @@

import{isPing as e,isGetBlockByHeight as t,isGetBlockById as n,isGetLatestBlock as a,isGetEvents as s,isGetAccount as o,isScript as r,isGetTransactionStatus as i,isTransaction as c}from"@onflow/interaction";import{Transaction as g,SendTransactionRequest as u,AccessAPI as l,GetTransactionRequest as d,ExecuteScriptAtLatestBlockRequest as f,GetAccountRequest as p,GetEventsForHeightRangeRequest as m,GetLatestBlockRequest as S,GetBlockByIDRequest as I,GetBlockByHeightRequest as h,PingRequest as w}from"@onflow/protobuf";import{response as y}from"@onflow/response";import{sansPrefix as k,withPrefix as B}from"@onflow/util-address";import{grpc as b}from"@improbable-eng/grpc-web";import{NodeHttpTransport as x}from"@improbable-eng/grpc-web-node-http-transport";import{config as A}from"@onflow/config";async function E(e,t,n){return new Promise((a,s)=>{b.unary(t,{request:n,host:e,onEnd:({status:e,statusMessage:t,message:n})=>{e===b.Code.OK?a(n):s(new Error(t))}})})}b.setDefaultTransport(x());const v=e=>Buffer.from(e,"hex"),L=e=>Buffer.from(e.padStart(16,0),"hex"),U=e=>Buffer.from(e).toString("hex"),_=e=>Buffer.from(e).toString("hex"),R=e=>Buffer.from(e).toString("hex"),N=e=>Buffer.from(e).toString("hex");console.log("%cSEND UPDATED","color:green;font-size:56px;font-family:monospace;");const T=async(b,x={})=>{switch(x.node=x.node||await A().get("accessNode.api"),b=await b,!0){case c(b):return async function(e,t={}){e=await e,console.log("111",e);const n=new g;n.setScript(Buffer.from(e.message.cadence,"utf8")),n.setGasLimit(e.message.computeLimit),n.setReferenceBlockId(e.message.refBlock?v(e.message.refBlock):null),n.setPayer(L(k(e.accounts[e.payer].addr))),e.message.arguments.forEach(t=>n.addArguments((e=>Buffer.from(JSON.stringify(e),"utf8"))(e.arguments[t].asArgument))),e.authorizations.map(t=>e.accounts[t].addr).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[]).forEach(e=>n.addAuthorizers(L(k(e))));const a=new g.ProposalKey;a.setAddress(L(k(e.accounts[e.proposer].addr))),a.setKeyId(e.accounts[e.proposer].keyId),a.setSequenceNumber(e.accounts[e.proposer].sequenceNum),n.setProposalKey(a);for(let t of Object.values(e.accounts)){console.log("NON-PAYER",t);try{if(null==t.signature)continue;if(t.role.payer)continue;const e=new g.Signature;e.setAddress(L(k(t.addr))),e.setKeyId(t.keyId),e.setSignature(v(t.signature)),n.addPayloadSignatures(e)}catch(n){throw console.error("Trouble applying payload signature",{acct:t,ix:e}),n}}for(let t of Object.values(e.accounts)){console.log("PAYER",t);try{if(null==t.signature)continue;if(!t.role.payer)continue;const e=new g.Signature;e.setAddress(L(k(t.addr))),e.setKeyId(t.keyId),e.setSignature(v(t.signature)),n.addEnvelopeSignatures(e)}catch(n){throw console.error("Trouble applying envelope signature",{acct:t,ix:e}),n}}const s=new u;s.setTransaction(n),console.log("UNARY_SEND",{req:s});const o=await E(t.node,l.SendTransaction,s);console.log("UNARY_SENT",{res:o});let r=y();var i;return r.tag=e.tag,r.transactionId=(i=o.getId_asU8(),Buffer.from(i).toString("hex")),console.log("SEND TX COMPLETE",{ret:r}),r}(b,x);case i(b):return async function(e,t={}){e=await e;const n=new d;n.setId(Buffer.from(e.transactionId,"hex"));const a=await E(t.node,l.GetTransactionResult,n);let s=a.getEventsList(),o=y();return o.tag=e.tag,o.transaction={status:a.getStatus(),statusCode:a.getStatusCode(),errorMessage:a.getErrorMessage(),events:s.map(e=>{return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},o}(b,x);case r(b):return async function(e,t={}){e=await e;const n=new f,a=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>n.addArguments((e=>Buffer.from(JSON.stringify(e),"utf8"))(e.arguments[t].asArgument))),n.setScript(a);const s=await E(t.node,l.ExecuteScriptAtLatestBlock,n);let o=y();return o.tag=e.tag,o.encodedData=JSON.parse(Buffer.from(s.getValue_asU8()).toString("utf8")),o}(b,x);case o(b):return async function(e,t={}){e=await e;const n=new p;var a;n.setAddress((a=k(e.accountAddr),Buffer.from(a.padStart(16,0),"hex")));const s=await E(t.node,l.GetAccount,n);let o=y();o.tag=e.tag;const r=s.getAccount();return o.account={address:B(U(r.getAddress_asU8())),balance:r.getBalance(),code:r.getCode_asU8(),keys:r.getKeysList().map(e=>({index:e.getIndex(),publicKey:U(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}))},o}(b,x);case s(b):return async function(e,t={}){e=await e;const n=new m;n.setType(e.events.eventType),n.setStartHeight(Number(e.events.start)),n.setEndHeight(Number(e.events.end));const a=await E(t.node,l.GetEventsForHeightRange,n);let s=y();s.tag=e.tag;const o=a.getResultsList();return s.events=o.reduce((e,t)=>{const n=t.getBlockId(),a=t.getBlockHeight();return t.getEventsList().forEach(t=>{var s;e.push({blockId:n,blockHeight:a,type:t.getType(),transactionId:(s=t.getTransactionId_asU8(),Buffer.from(s).toString("hex")),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),s}(b,x);case a(b):return async function(e,t={}){e=await e;const n=new S;e.latestBlock&&e.latestBlock.isSealed&&(n.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&n.setIsSealed(e.block.isSealed);const a=(await E(t.node,l.GetLatestBlock,n)).getBlock(),s=a.getCollectionGuaranteesList(),o=a.getBlockSealsList(),r=a.getSignaturesList(),i=y();return i.tag=e.tag,i.block={id:_(a.getId_asU8()),parentId:_(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:s.map(e=>({collectionId:_(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:o.map(e=>({blockId:_(e.getBlockId_asU8()),executionReceiptId:_(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:r},i}(b,x);case n(b):return async function(e,t={}){e=await e;const n=new I;n.setId(Buffer.from(e.block.id,"hex"));const a=(await E(t.node,l.GetBlockByID,n)).getBlock(),s=a.getCollectionGuaranteesList(),o=a.getBlockSealsList(),r=a.getSignaturesList(),i=y();return i.tag=e.tag,i.block={id:R(a.getId_asU8()),parentId:R(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:s.map(e=>({collectionId:R(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:o.map(e=>({blockId:R(e.getBlockId_asU8()),executionReceiptId:R(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:r},i}(b,x);case t(b):return async function(e,t={}){e=await e;const n=new h;n.setHeight(e.block.height);const a=(await E(t.node,l.GetBlockByHeight,n)).getBlock(),s=a.getCollectionGuaranteesList(),o=a.getBlockSealsList(),r=a.getSignaturesList(),i=y();return i.tag=e.tag,i.block={id:N(a.getId_asU8()),parentId:N(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:s.map(e=>({collectionId:N(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:o.map(e=>({blockId:N(e.getBlockId_asU8()),executionReceiptId:N(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:r},i}(b,x);case e(b):return async function(e,t={}){e=await e;const n=new w;await E(t.node,l.Ping,n);let a=y();return a.tag=e.tag,a}(b,x);default:return b}};export{T as send};
import{isPing as e,isGetBlockByHeight as t,isGetBlockById as a,isGetLatestBlock as n,isGetEvents as s,isGetAccount as o,isScript as r,isGetTransactionStatus as c,isTransaction as i}from"@onflow/interaction";import{Transaction as g,SendTransactionRequest as u,AccessAPI as l,GetTransactionRequest as d,ExecuteScriptAtLatestBlockRequest as f,GetAccountRequest as p,GetEventsForHeightRangeRequest as m,GetLatestBlockRequest as S,GetBlockByIDRequest as I,GetBlockByHeightRequest as h,PingRequest as w}from"@onflow/protobuf";import{response as y}from"@onflow/response";import{sansPrefix as k,withPrefix as B}from"@onflow/util-address";import{grpc as b}from"@improbable-eng/grpc-web";import{NodeHttpTransport as x}from"@improbable-eng/grpc-web-node-http-transport";import{config as A}from"@onflow/config";async function E(e,t,a){return new Promise((n,s)=>{b.unary(t,{request:a,host:e,onEnd:({status:e,statusMessage:t,message:a})=>{e===b.Code.OK?n(a):s(new Error(t))}})})}b.setDefaultTransport(x());const v=e=>Buffer.from(e,"hex"),L=e=>Buffer.from(e.padStart(16,0),"hex"),U=e=>Buffer.from(e).toString("hex"),_=e=>Buffer.from(e).toString("hex"),R=e=>Buffer.from(e).toString("hex"),N=e=>Buffer.from(e).toString("hex");console.log("%cSEND UPDATED","color:green;font-size:56px;font-family:monospace;");const T=async(b,x={})=>{switch(x.node=x.node||await A().get("accessNode.api"),b=await b,!0){case i(b):return async function(e,t={}){e=await e,console.log("111",e);const a=new g;a.setScript(Buffer.from(e.message.cadence,"utf8")),a.setGasLimit(e.message.computeLimit),a.setReferenceBlockId(e.message.refBlock?v(e.message.refBlock):null),a.setPayer(L(k(e.accounts[e.payer].addr))),e.message.arguments.forEach(t=>a.addArguments((e=>Buffer.from(JSON.stringify(e),"utf8"))(e.arguments[t].asArgument))),e.authorizations.map(t=>e.accounts[t].addr).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[]).forEach(e=>a.addAuthorizers(L(k(e))));const n=new g.ProposalKey;n.setAddress(L(k(e.accounts[e.proposer].addr))),n.setKeyId(e.accounts[e.proposer].keyId),n.setSequenceNumber(e.accounts[e.proposer].sequenceNum),a.setProposalKey(n);for(let t of Object.values(e.accounts))if(null!=t.signature&&!t.role.payer){console.log("NON-PAYER",t);try{const e=new g.Signature;e.setAddress(L(k(t.addr))),e.setKeyId(t.keyId),e.setSignature(v(t.signature)),a.addPayloadSignatures(e)}catch(a){throw console.error("Trouble applying payload signature",{acct:t,ix:e}),a}}for(let t of Object.values(e.accounts))if(null!=t.signature&&t.role.payer){console.log("PAYER",t);try{const e=new g.Signature;e.setAddress(L(k(t.addr))),e.setKeyId(t.keyId),e.setSignature(v(t.signature)),a.addEnvelopeSignatures(e)}catch(a){throw console.error("Trouble applying envelope signature",{acct:t,ix:e}),a}}const s=new u;s.setTransaction(a),console.log("UNARY_SEND",{req:s});const o=await E(t.node,l.SendTransaction,s);console.log("UNARY_SENT",{res:o});let r=y();var c;return r.tag=e.tag,r.transactionId=(c=o.getId_asU8(),Buffer.from(c).toString("hex")),console.log("SEND TX COMPLETE",{ret:r}),r}(b,x);case c(b):return async function(e,t={}){e=await e;const a=new d;a.setId(Buffer.from(e.transactionId,"hex"));const n=await E(t.node,l.GetTransactionResult,a);let s=n.getEventsList(),o=y();return o.tag=e.tag,o.transaction={status:n.getStatus(),statusCode:n.getStatusCode(),errorMessage:n.getErrorMessage(),events:s.map(e=>{return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},o}(b,x);case r(b):return async function(e,t={}){e=await e;const a=new f,n=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments((e=>Buffer.from(JSON.stringify(e),"utf8"))(e.arguments[t].asArgument))),a.setScript(n);const s=await E(t.node,l.ExecuteScriptAtLatestBlock,a);let o=y();return o.tag=e.tag,o.encodedData=JSON.parse(Buffer.from(s.getValue_asU8()).toString("utf8")),o}(b,x);case o(b):return async function(e,t={}){e=await e;const a=new p;var n;a.setAddress((n=k(e.accountAddr),Buffer.from(n.padStart(16,0),"hex")));const s=await E(t.node,l.GetAccount,a);let o=y();o.tag=e.tag;const r=s.getAccount();return o.account={address:B(U(r.getAddress_asU8())),balance:r.getBalance(),code:r.getCode_asU8(),keys:r.getKeysList().map(e=>({index:e.getIndex(),publicKey:U(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}))},o}(b,x);case s(b):return async function(e,t={}){e=await e;const a=new m;a.setType(e.events.eventType),a.setStartHeight(Number(e.events.start)),a.setEndHeight(Number(e.events.end));const n=await E(t.node,l.GetEventsForHeightRange,a);let s=y();s.tag=e.tag;const o=n.getResultsList();return s.events=o.reduce((e,t)=>{const a=t.getBlockId(),n=t.getBlockHeight();return t.getEventsList().forEach(t=>{var s;e.push({blockId:a,blockHeight:n,type:t.getType(),transactionId:(s=t.getTransactionId_asU8(),Buffer.from(s).toString("hex")),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),s}(b,x);case n(b):return async function(e,t={}){e=await e;const a=new S;e.latestBlock&&e.latestBlock.isSealed&&(a.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed);const n=(await E(t.node,l.GetLatestBlock,a)).getBlock(),s=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),r=n.getSignaturesList(),c=y();return c.tag=e.tag,c.block={id:_(n.getId_asU8()),parentId:_(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:s.map(e=>({collectionId:_(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:o.map(e=>({blockId:_(e.getBlockId_asU8()),executionReceiptId:_(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:r},c}(b,x);case a(b):return async function(e,t={}){e=await e;const a=new I;a.setId(Buffer.from(e.block.id,"hex"));const n=(await E(t.node,l.GetBlockByID,a)).getBlock(),s=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),r=n.getSignaturesList(),c=y();return c.tag=e.tag,c.block={id:R(n.getId_asU8()),parentId:R(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:s.map(e=>({collectionId:R(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:o.map(e=>({blockId:R(e.getBlockId_asU8()),executionReceiptId:R(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:r},c}(b,x);case t(b):return async function(e,t={}){e=await e;const a=new h;a.setHeight(e.block.height);const n=(await E(t.node,l.GetBlockByHeight,a)).getBlock(),s=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),r=n.getSignaturesList(),c=y();return c.tag=e.tag,c.block={id:N(n.getId_asU8()),parentId:N(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:s.map(e=>({collectionId:N(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:o.map(e=>({blockId:N(e.getBlockId_asU8()),executionReceiptId:N(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:r},c}(b,x);case e(b):return async function(e,t={}){e=await e;const a=new w;await E(t.node,l.Ping,a);let n=y();return n.tag=e.tag,n}(b,x);default:return b}};export{T as send};
//# sourceMappingURL=send.modern.js.map

@@ -1,2 +0,2 @@

import{isPing as e,isGetBlockByHeight as t,isGetBlockById as r,isGetLatestBlock as n,isGetEvents as o,isGetAccount as s,isScript as a,isGetTransactionStatus as i,isTransaction as c}from"@onflow/interaction";import{Transaction as u,SendTransactionRequest as g,AccessAPI as l,GetTransactionRequest as f,ExecuteScriptAtLatestBlockRequest as d,GetAccountRequest as m,GetEventsForHeightRangeRequest as p,GetLatestBlockRequest as v,GetBlockByIDRequest as h,GetBlockByHeightRequest as S,PingRequest as I}from"@onflow/protobuf";import{response as y}from"@onflow/response";import{sansPrefix as P,withPrefix as k}from"@onflow/util-address";import{grpc as B}from"@improbable-eng/grpc-web";import{NodeHttpTransport as b}from"@improbable-eng/grpc-web-node-http-transport";import{config as x}from"@onflow/config";var w=function(e,t,r){try{return Promise.resolve(new Promise(function(n,o){B.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===B.Code.OK?n(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};B.setDefaultTransport(b());var A=function(e){return Buffer.from(e,"hex")},E=function(e){return Buffer.from(e.padStart(16,0),"hex")},L=function(e){return Buffer.from(e).toString("hex")},U=function(e){return Buffer.from(e).toString("hex")},_=function(e){return Buffer.from(e).toString("hex")},R=function(e){return Buffer.from(e).toString("hex")};console.log("%cSEND UPDATED","color:green;font-size:56px;font-family:monospace;");var N=function(B,b){void 0===b&&(b={});try{var N=function(x){return b.node=x,Promise.resolve(B).then(function(x){switch(B=x,!0){case c(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r,console.log("111",e);var n=new u;n.setScript(Buffer.from(e.message.cadence,"utf8")),n.setGasLimit(e.message.computeLimit),n.setReferenceBlockId(e.message.refBlock?A(e.message.refBlock):null),n.setPayer(E(P(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return n.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return n.addAuthorizers(E(P(e)))});var o=new u.ProposalKey;o.setAddress(E(P(e.accounts[e.proposer].addr))),o.setKeyId(e.accounts[e.proposer].keyId),o.setSequenceNumber(e.accounts[e.proposer].sequenceNum),n.setProposalKey(o);for(var s=0,a=Object.values(e.accounts);s<a.length;s++){var i=a[s];console.log("NON-PAYER",i);try{if(null==i.signature)return;if(i.role.payer)return;var c=new u.Signature;c.setAddress(E(P(i.addr))),c.setKeyId(i.keyId),c.setSignature(A(i.signature)),n.addPayloadSignatures(c)}catch(t){throw console.error("Trouble applying payload signature",{acct:i,ix:e}),t}}for(var f=0,d=Object.values(e.accounts);f<d.length;f++){var m=d[f];console.log("PAYER",m);try{if(null==m.signature)return;if(!m.role.payer)return;var p=new u.Signature;p.setAddress(E(P(m.addr))),p.setKeyId(m.keyId),p.setSignature(A(m.signature)),n.addEnvelopeSignatures(p)}catch(t){throw console.error("Trouble applying envelope signature",{acct:m,ix:e}),t}}var v=new g;return v.setTransaction(n),console.log("UNARY_SEND",{req:v}),Promise.resolve(w(t.node,l.SendTransaction,v)).then(function(t){console.log("UNARY_SENT",{res:t});var r,n=y();return n.tag=e.tag,n.transactionId=(r=t.getId_asU8(),Buffer.from(r).toString("hex")),console.log("SEND TX COMPLETE",{ret:n}),n})})}catch(e){return Promise.reject(e)}}(B,b);case i(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new f;return n.setId(Buffer.from(e.transactionId,"hex")),Promise.resolve(w(t.node,l.GetTransactionResult,n)).then(function(t){var r=t.getEventsList(),n=y();return n.tag=e.tag,n.transaction={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:r.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},n})})}catch(e){return Promise.reject(e)}}(B,b);case a(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new d,o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return n.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),n.setScript(o),Promise.resolve(w(t.node,l.ExecuteScriptAtLatestBlock,n)).then(function(t){var r=y();return r.tag=e.tag,r.encodedData=JSON.parse(Buffer.from(t.getValue_asU8()).toString("utf8")),r})})}catch(e){return Promise.reject(e)}}(B,b);case s(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n,o=new m;return o.setAddress((n=P(e.accountAddr),Buffer.from(n.padStart(16,0),"hex"))),Promise.resolve(w(t.node,l.GetAccount,o)).then(function(t){var r=y();r.tag=e.tag;var n=t.getAccount();return r.account={address:k(L(n.getAddress_asU8())),balance:n.getBalance(),code:n.getCode_asU8(),keys:n.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:L(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}})},r})})}catch(e){return Promise.reject(e)}}(B,b);case o(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new p;return n.setType(e.events.eventType),n.setStartHeight(Number(e.events.start)),n.setEndHeight(Number(e.events.end)),Promise.resolve(w(t.node,l.GetEventsForHeightRange,n)).then(function(t){var r=y();r.tag=e.tag;var n=t.getResultsList();return r.events=n.reduce(function(e,t){var r=t.getBlockId(),n=t.getBlockHeight();return t.getEventsList().forEach(function(t){var o;e.push({blockId:r,blockHeight:n,type:t.getType(),transactionId:(o=t.getTransactionId_asU8(),Buffer.from(o).toString("hex")),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),r})})}catch(e){return Promise.reject(e)}}(B,b);case n(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new v;return e.latestBlock&&e.latestBlock.isSealed&&(n.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&n.setIsSealed(e.block.isSealed),Promise.resolve(w(t.node,l.GetLatestBlock,n)).then(function(t){var r=t.getBlock(),n=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),s=r.getSignaturesList(),a=y();return a.tag=e.tag,a.block={id:U(r.getId_asU8()),parentId:U(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:U(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:U(e.getBlockId_asU8()),executionReceiptId:U(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})})}catch(e){return Promise.reject(e)}}(B,b);case r(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new h;return n.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(w(t.node,l.GetBlockByID,n)).then(function(t){var r=t.getBlock(),n=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),s=r.getSignaturesList(),a=y();return a.tag=e.tag,a.block={id:_(r.getId_asU8()),parentId:_(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:_(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:_(e.getBlockId_asU8()),executionReceiptId:_(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})})}catch(e){return Promise.reject(e)}}(B,b);case t(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new S;return n.setHeight(e.block.height),Promise.resolve(w(t.node,l.GetBlockByHeight,n)).then(function(t){var r=t.getBlock(),n=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),s=r.getSignaturesList(),a=y();return a.tag=e.tag,a.block={id:R(r.getId_asU8()),parentId:R(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:R(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:R(e.getBlockId_asU8()),executionReceiptId:R(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})})}catch(e){return Promise.reject(e)}}(B,b);case e(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new I;return Promise.resolve(w(t.node,l.Ping,n)).then(function(t){var r=y();return r.tag=e.tag,r})})}catch(e){return Promise.reject(e)}}(B,b);default:return B}})},T=b.node;return Promise.resolve(T?N(T):Promise.resolve(x().get("accessNode.api")).then(N))}catch(e){return Promise.reject(e)}};export{N as send};
import{isPing as e,isGetBlockByHeight as t,isGetBlockById as r,isGetLatestBlock as n,isGetEvents as o,isGetAccount as s,isScript as a,isGetTransactionStatus as i,isTransaction as c}from"@onflow/interaction";import{Transaction as u,SendTransactionRequest as g,AccessAPI as l,GetTransactionRequest as f,ExecuteScriptAtLatestBlockRequest as d,GetAccountRequest as m,GetEventsForHeightRangeRequest as p,GetLatestBlockRequest as v,GetBlockByIDRequest as h,GetBlockByHeightRequest as S,PingRequest as I}from"@onflow/protobuf";import{response as y}from"@onflow/response";import{sansPrefix as P,withPrefix as k}from"@onflow/util-address";import{grpc as B}from"@improbable-eng/grpc-web";import{NodeHttpTransport as b}from"@improbable-eng/grpc-web-node-http-transport";import{config as x}from"@onflow/config";var w=function(e,t,r){try{return Promise.resolve(new Promise(function(n,o){B.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===B.Code.OK?n(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};B.setDefaultTransport(b());var A=function(e){return Buffer.from(e,"hex")},E=function(e){return Buffer.from(e.padStart(16,0),"hex")},L=function(e){return Buffer.from(e).toString("hex")},U=function(e){return Buffer.from(e).toString("hex")},_=function(e){return Buffer.from(e).toString("hex")},R=function(e){return Buffer.from(e).toString("hex")};console.log("%cSEND UPDATED","color:green;font-size:56px;font-family:monospace;");var N=function(B,b){void 0===b&&(b={});try{var N=function(x){return b.node=x,Promise.resolve(B).then(function(x){switch(B=x,!0){case c(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r,console.log("111",e);var n=new u;n.setScript(Buffer.from(e.message.cadence,"utf8")),n.setGasLimit(e.message.computeLimit),n.setReferenceBlockId(e.message.refBlock?A(e.message.refBlock):null),n.setPayer(E(P(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return n.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return n.addAuthorizers(E(P(e)))});var o=new u.ProposalKey;o.setAddress(E(P(e.accounts[e.proposer].addr))),o.setKeyId(e.accounts[e.proposer].keyId),o.setSequenceNumber(e.accounts[e.proposer].sequenceNum),n.setProposalKey(o);for(var s=0,a=Object.values(e.accounts);s<a.length;s++){var i=a[s];if(null==i.signature)return;if(i.role.payer)return;console.log("NON-PAYER",i);try{var c=new u.Signature;c.setAddress(E(P(i.addr))),c.setKeyId(i.keyId),c.setSignature(A(i.signature)),n.addPayloadSignatures(c)}catch(t){throw console.error("Trouble applying payload signature",{acct:i,ix:e}),t}}for(var f=0,d=Object.values(e.accounts);f<d.length;f++){var m=d[f];if(null==m.signature)return;if(!m.role.payer)return;console.log("PAYER",m);try{var p=new u.Signature;p.setAddress(E(P(m.addr))),p.setKeyId(m.keyId),p.setSignature(A(m.signature)),n.addEnvelopeSignatures(p)}catch(t){throw console.error("Trouble applying envelope signature",{acct:m,ix:e}),t}}var v=new g;return v.setTransaction(n),console.log("UNARY_SEND",{req:v}),Promise.resolve(w(t.node,l.SendTransaction,v)).then(function(t){console.log("UNARY_SENT",{res:t});var r,n=y();return n.tag=e.tag,n.transactionId=(r=t.getId_asU8(),Buffer.from(r).toString("hex")),console.log("SEND TX COMPLETE",{ret:n}),n})})}catch(e){return Promise.reject(e)}}(B,b);case i(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new f;return n.setId(Buffer.from(e.transactionId,"hex")),Promise.resolve(w(t.node,l.GetTransactionResult,n)).then(function(t){var r=t.getEventsList(),n=y();return n.tag=e.tag,n.transaction={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:r.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},n})})}catch(e){return Promise.reject(e)}}(B,b);case a(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new d,o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return n.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),n.setScript(o),Promise.resolve(w(t.node,l.ExecuteScriptAtLatestBlock,n)).then(function(t){var r=y();return r.tag=e.tag,r.encodedData=JSON.parse(Buffer.from(t.getValue_asU8()).toString("utf8")),r})})}catch(e){return Promise.reject(e)}}(B,b);case s(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n,o=new m;return o.setAddress((n=P(e.accountAddr),Buffer.from(n.padStart(16,0),"hex"))),Promise.resolve(w(t.node,l.GetAccount,o)).then(function(t){var r=y();r.tag=e.tag;var n=t.getAccount();return r.account={address:k(L(n.getAddress_asU8())),balance:n.getBalance(),code:n.getCode_asU8(),keys:n.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:L(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}})},r})})}catch(e){return Promise.reject(e)}}(B,b);case o(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new p;return n.setType(e.events.eventType),n.setStartHeight(Number(e.events.start)),n.setEndHeight(Number(e.events.end)),Promise.resolve(w(t.node,l.GetEventsForHeightRange,n)).then(function(t){var r=y();r.tag=e.tag;var n=t.getResultsList();return r.events=n.reduce(function(e,t){var r=t.getBlockId(),n=t.getBlockHeight();return t.getEventsList().forEach(function(t){var o;e.push({blockId:r,blockHeight:n,type:t.getType(),transactionId:(o=t.getTransactionId_asU8(),Buffer.from(o).toString("hex")),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),r})})}catch(e){return Promise.reject(e)}}(B,b);case n(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new v;return e.latestBlock&&e.latestBlock.isSealed&&(n.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&n.setIsSealed(e.block.isSealed),Promise.resolve(w(t.node,l.GetLatestBlock,n)).then(function(t){var r=t.getBlock(),n=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),s=r.getSignaturesList(),a=y();return a.tag=e.tag,a.block={id:U(r.getId_asU8()),parentId:U(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:U(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:U(e.getBlockId_asU8()),executionReceiptId:U(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})})}catch(e){return Promise.reject(e)}}(B,b);case r(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new h;return n.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(w(t.node,l.GetBlockByID,n)).then(function(t){var r=t.getBlock(),n=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),s=r.getSignaturesList(),a=y();return a.tag=e.tag,a.block={id:_(r.getId_asU8()),parentId:_(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:_(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:_(e.getBlockId_asU8()),executionReceiptId:_(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})})}catch(e){return Promise.reject(e)}}(B,b);case t(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new S;return n.setHeight(e.block.height),Promise.resolve(w(t.node,l.GetBlockByHeight,n)).then(function(t){var r=t.getBlock(),n=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),s=r.getSignaturesList(),a=y();return a.tag=e.tag,a.block={id:R(r.getId_asU8()),parentId:R(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:R(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:R(e.getBlockId_asU8()),executionReceiptId:R(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})})}catch(e){return Promise.reject(e)}}(B,b);case e(B):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var n=new I;return Promise.resolve(w(t.node,l.Ping,n)).then(function(t){var r=y();return r.tag=e.tag,r})})}catch(e){return Promise.reject(e)}}(B,b);default:return B}})},T=b.node;return Promise.resolve(T?N(T):Promise.resolve(x().get("accessNode.api")).then(N))}catch(e){return Promise.reject(e)}};export{N as send};
//# sourceMappingURL=send.module.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@onflow/interaction"),require("@onflow/protobuf"),require("@onflow/response"),require("@onflow/util-address"),require("@improbable-eng/grpc-web"),require("@improbable-eng/grpc-web-node-http-transport"),require("@onflow/config")):"function"==typeof define&&define.amd?define(["exports","@onflow/interaction","@onflow/protobuf","@onflow/response","@onflow/util-address","@improbable-eng/grpc-web","@improbable-eng/grpc-web-node-http-transport","@onflow/config"],t):t((e=e||self).send={},e.interaction,e.protobuf,e.response,e.utilAddress,e.grpcWeb,e.grpcWebNodeHttpTransport,e.config)}(this,function(e,t,r,n,o,s,a,i){var c=function(e,t,r){try{return Promise.resolve(new Promise(function(n,o){s.grpc.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===s.grpc.Code.OK?n(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};s.grpc.setDefaultTransport(a.NodeHttpTransport());var u=function(e){return Buffer.from(e,"hex")},g=function(e){return Buffer.from(e.padStart(16,0),"hex")},l=function(e){return Buffer.from(e).toString("hex")},f=function(e){return Buffer.from(e).toString("hex")},d=function(e){return Buffer.from(e).toString("hex")},p=function(e){return Buffer.from(e).toString("hex")};console.log("%cSEND UPDATED","color:green;font-size:56px;font-family:monospace;"),e.send=function(e,s){void 0===s&&(s={});try{var a=function(a){return s.node=a,Promise.resolve(e).then(function(a){switch(e=a,!0){case t.isTransaction(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(s){e=s,console.log("111",e);var a=new r.Transaction;a.setScript(Buffer.from(e.message.cadence,"utf8")),a.setGasLimit(e.message.computeLimit),a.setReferenceBlockId(e.message.refBlock?u(e.message.refBlock):null),a.setPayer(g(o.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return a.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return a.addAuthorizers(g(o.sansPrefix(e)))});var i=new r.Transaction.ProposalKey;i.setAddress(g(o.sansPrefix(e.accounts[e.proposer].addr))),i.setKeyId(e.accounts[e.proposer].keyId),i.setSequenceNumber(e.accounts[e.proposer].sequenceNum),a.setProposalKey(i);for(var l=0,f=Object.values(e.accounts);l<f.length;l++){var d=f[l];console.log("NON-PAYER",d);try{if(null==d.signature)return;if(d.role.payer)return;var p=new r.Transaction.Signature;p.setAddress(g(o.sansPrefix(d.addr))),p.setKeyId(d.keyId),p.setSignature(u(d.signature)),a.addPayloadSignatures(p)}catch(t){throw console.error("Trouble applying payload signature",{acct:d,ix:e}),t}}for(var m=0,h=Object.values(e.accounts);m<h.length;m++){var v=h[m];console.log("PAYER",v);try{if(null==v.signature)return;if(!v.role.payer)return;var S=new r.Transaction.Signature;S.setAddress(g(o.sansPrefix(v.addr))),S.setKeyId(v.keyId),S.setSignature(u(v.signature)),a.addEnvelopeSignatures(S)}catch(t){throw console.error("Trouble applying envelope signature",{acct:v,ix:e}),t}}var I=new r.SendTransactionRequest;return I.setTransaction(a),console.log("UNARY_SEND",{req:I}),Promise.resolve(c(t.node,r.AccessAPI.SendTransaction,I)).then(function(t){console.log("UNARY_SENT",{res:t});var r,o=n.response();return o.tag=e.tag,o.transactionId=(r=t.getId_asU8(),Buffer.from(r).toString("hex")),console.log("SEND TX COMPLETE",{ret:o}),o})})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetTransactionStatus(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.GetTransactionRequest;return s.setId(Buffer.from(e.transactionId,"hex")),Promise.resolve(c(t.node,r.AccessAPI.GetTransactionResult,s)).then(function(t){var r=t.getEventsList(),o=n.response();return o.tag=e.tag,o.transaction={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:r.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},o})})}catch(e){return Promise.reject(e)}}(e,s);case t.isScript(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.ExecuteScriptAtLatestBlockRequest,a=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),s.setScript(a),Promise.resolve(c(t.node,r.AccessAPI.ExecuteScriptAtLatestBlock,s)).then(function(t){var r=n.response();return r.tag=e.tag,r.encodedData=JSON.parse(Buffer.from(t.getValue_asU8()).toString("utf8")),r})})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetAccount(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(s){e=s;var a,i=new r.GetAccountRequest;return i.setAddress((a=o.sansPrefix(e.accountAddr),Buffer.from(a.padStart(16,0),"hex"))),Promise.resolve(c(t.node,r.AccessAPI.GetAccount,i)).then(function(t){var r=n.response();r.tag=e.tag;var s=t.getAccount();return r.account={address:o.withPrefix(l(s.getAddress_asU8())),balance:s.getBalance(),code:s.getCode_asU8(),keys:s.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:l(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}})},r})})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetEvents(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.GetEventsForHeightRangeRequest;return s.setType(e.events.eventType),s.setStartHeight(Number(e.events.start)),s.setEndHeight(Number(e.events.end)),Promise.resolve(c(t.node,r.AccessAPI.GetEventsForHeightRange,s)).then(function(t){var r=n.response();r.tag=e.tag;var o=t.getResultsList();return r.events=o.reduce(function(e,t){var r=t.getBlockId(),n=t.getBlockHeight();return t.getEventsList().forEach(function(t){var o;e.push({blockId:r,blockHeight:n,type:t.getType(),transactionId:(o=t.getTransactionId_asU8(),Buffer.from(o).toString("hex")),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),r})})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetLatestBlock(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(s.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&s.setIsSealed(e.block.isSealed),Promise.resolve(c(t.node,r.AccessAPI.GetLatestBlock,s)).then(function(t){var r=t.getBlock(),o=r.getCollectionGuaranteesList(),s=r.getBlockSealsList(),a=r.getSignaturesList(),i=n.response();return i.tag=e.tag,i.block={id:f(r.getId_asU8()),parentId:f(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:o.map(function(e){return{collectionId:f(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:s.map(function(e){return{blockId:f(e.getBlockId_asU8()),executionReceiptId:f(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetBlockById(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.GetBlockByIDRequest;return s.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(c(t.node,r.AccessAPI.GetBlockByID,s)).then(function(t){var r=t.getBlock(),o=r.getCollectionGuaranteesList(),s=r.getBlockSealsList(),a=r.getSignaturesList(),i=n.response();return i.tag=e.tag,i.block={id:d(r.getId_asU8()),parentId:d(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:o.map(function(e){return{collectionId:d(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:s.map(function(e){return{blockId:d(e.getBlockId_asU8()),executionReceiptId:d(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetBlockByHeight(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.GetBlockByHeightRequest;return s.setHeight(e.block.height),Promise.resolve(c(t.node,r.AccessAPI.GetBlockByHeight,s)).then(function(t){var r=t.getBlock(),o=r.getCollectionGuaranteesList(),s=r.getBlockSealsList(),a=r.getSignaturesList(),i=n.response();return i.tag=e.tag,i.block={id:p(r.getId_asU8()),parentId:p(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:o.map(function(e){return{collectionId:p(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:s.map(function(e){return{blockId:p(e.getBlockId_asU8()),executionReceiptId:p(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,s);case t.isPing(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.PingRequest;return Promise.resolve(c(t.node,r.AccessAPI.Ping,s)).then(function(t){var r=n.response();return r.tag=e.tag,r})})}catch(e){return Promise.reject(e)}}(e,s);default:return e}})},m=s.node;return Promise.resolve(m?a(m):Promise.resolve(i.config().get("accessNode.api")).then(a))}catch(e){return Promise.reject(e)}}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@onflow/interaction"),require("@onflow/protobuf"),require("@onflow/response"),require("@onflow/util-address"),require("@improbable-eng/grpc-web"),require("@improbable-eng/grpc-web-node-http-transport"),require("@onflow/config")):"function"==typeof define&&define.amd?define(["exports","@onflow/interaction","@onflow/protobuf","@onflow/response","@onflow/util-address","@improbable-eng/grpc-web","@improbable-eng/grpc-web-node-http-transport","@onflow/config"],t):t((e=e||self).send={},e.interaction,e.protobuf,e.response,e.utilAddress,e.grpcWeb,e.grpcWebNodeHttpTransport,e.config)}(this,function(e,t,r,n,o,s,a,i){var c=function(e,t,r){try{return Promise.resolve(new Promise(function(n,o){s.grpc.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===s.grpc.Code.OK?n(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};s.grpc.setDefaultTransport(a.NodeHttpTransport());var u=function(e){return Buffer.from(e,"hex")},g=function(e){return Buffer.from(e.padStart(16,0),"hex")},l=function(e){return Buffer.from(e).toString("hex")},f=function(e){return Buffer.from(e).toString("hex")},d=function(e){return Buffer.from(e).toString("hex")},p=function(e){return Buffer.from(e).toString("hex")};console.log("%cSEND UPDATED","color:green;font-size:56px;font-family:monospace;"),e.send=function(e,s){void 0===s&&(s={});try{var a=function(a){return s.node=a,Promise.resolve(e).then(function(a){switch(e=a,!0){case t.isTransaction(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(s){e=s,console.log("111",e);var a=new r.Transaction;a.setScript(Buffer.from(e.message.cadence,"utf8")),a.setGasLimit(e.message.computeLimit),a.setReferenceBlockId(e.message.refBlock?u(e.message.refBlock):null),a.setPayer(g(o.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return a.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return a.addAuthorizers(g(o.sansPrefix(e)))});var i=new r.Transaction.ProposalKey;i.setAddress(g(o.sansPrefix(e.accounts[e.proposer].addr))),i.setKeyId(e.accounts[e.proposer].keyId),i.setSequenceNumber(e.accounts[e.proposer].sequenceNum),a.setProposalKey(i);for(var l=0,f=Object.values(e.accounts);l<f.length;l++){var d=f[l];if(null==d.signature)return;if(d.role.payer)return;console.log("NON-PAYER",d);try{var p=new r.Transaction.Signature;p.setAddress(g(o.sansPrefix(d.addr))),p.setKeyId(d.keyId),p.setSignature(u(d.signature)),a.addPayloadSignatures(p)}catch(t){throw console.error("Trouble applying payload signature",{acct:d,ix:e}),t}}for(var m=0,h=Object.values(e.accounts);m<h.length;m++){var v=h[m];if(null==v.signature)return;if(!v.role.payer)return;console.log("PAYER",v);try{var S=new r.Transaction.Signature;S.setAddress(g(o.sansPrefix(v.addr))),S.setKeyId(v.keyId),S.setSignature(u(v.signature)),a.addEnvelopeSignatures(S)}catch(t){throw console.error("Trouble applying envelope signature",{acct:v,ix:e}),t}}var I=new r.SendTransactionRequest;return I.setTransaction(a),console.log("UNARY_SEND",{req:I}),Promise.resolve(c(t.node,r.AccessAPI.SendTransaction,I)).then(function(t){console.log("UNARY_SENT",{res:t});var r,o=n.response();return o.tag=e.tag,o.transactionId=(r=t.getId_asU8(),Buffer.from(r).toString("hex")),console.log("SEND TX COMPLETE",{ret:o}),o})})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetTransactionStatus(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.GetTransactionRequest;return s.setId(Buffer.from(e.transactionId,"hex")),Promise.resolve(c(t.node,r.AccessAPI.GetTransactionResult,s)).then(function(t){var r=t.getEventsList(),o=n.response();return o.tag=e.tag,o.transaction={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:r.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},o})})}catch(e){return Promise.reject(e)}}(e,s);case t.isScript(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.ExecuteScriptAtLatestBlockRequest,a=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),s.setScript(a),Promise.resolve(c(t.node,r.AccessAPI.ExecuteScriptAtLatestBlock,s)).then(function(t){var r=n.response();return r.tag=e.tag,r.encodedData=JSON.parse(Buffer.from(t.getValue_asU8()).toString("utf8")),r})})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetAccount(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(s){e=s;var a,i=new r.GetAccountRequest;return i.setAddress((a=o.sansPrefix(e.accountAddr),Buffer.from(a.padStart(16,0),"hex"))),Promise.resolve(c(t.node,r.AccessAPI.GetAccount,i)).then(function(t){var r=n.response();r.tag=e.tag;var s=t.getAccount();return r.account={address:o.withPrefix(l(s.getAddress_asU8())),balance:s.getBalance(),code:s.getCode_asU8(),keys:s.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:l(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}})},r})})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetEvents(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.GetEventsForHeightRangeRequest;return s.setType(e.events.eventType),s.setStartHeight(Number(e.events.start)),s.setEndHeight(Number(e.events.end)),Promise.resolve(c(t.node,r.AccessAPI.GetEventsForHeightRange,s)).then(function(t){var r=n.response();r.tag=e.tag;var o=t.getResultsList();return r.events=o.reduce(function(e,t){var r=t.getBlockId(),n=t.getBlockHeight();return t.getEventsList().forEach(function(t){var o;e.push({blockId:r,blockHeight:n,type:t.getType(),transactionId:(o=t.getTransactionId_asU8(),Buffer.from(o).toString("hex")),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),r})})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetLatestBlock(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(s.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&s.setIsSealed(e.block.isSealed),Promise.resolve(c(t.node,r.AccessAPI.GetLatestBlock,s)).then(function(t){var r=t.getBlock(),o=r.getCollectionGuaranteesList(),s=r.getBlockSealsList(),a=r.getSignaturesList(),i=n.response();return i.tag=e.tag,i.block={id:f(r.getId_asU8()),parentId:f(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:o.map(function(e){return{collectionId:f(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:s.map(function(e){return{blockId:f(e.getBlockId_asU8()),executionReceiptId:f(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetBlockById(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.GetBlockByIDRequest;return s.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(c(t.node,r.AccessAPI.GetBlockByID,s)).then(function(t){var r=t.getBlock(),o=r.getCollectionGuaranteesList(),s=r.getBlockSealsList(),a=r.getSignaturesList(),i=n.response();return i.tag=e.tag,i.block={id:d(r.getId_asU8()),parentId:d(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:o.map(function(e){return{collectionId:d(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:s.map(function(e){return{blockId:d(e.getBlockId_asU8()),executionReceiptId:d(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetBlockByHeight(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.GetBlockByHeightRequest;return s.setHeight(e.block.height),Promise.resolve(c(t.node,r.AccessAPI.GetBlockByHeight,s)).then(function(t){var r=t.getBlock(),o=r.getCollectionGuaranteesList(),s=r.getBlockSealsList(),a=r.getSignaturesList(),i=n.response();return i.tag=e.tag,i.block={id:p(r.getId_asU8()),parentId:p(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:o.map(function(e){return{collectionId:p(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:s.map(function(e){return{blockId:p(e.getBlockId_asU8()),executionReceiptId:p(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,s);case t.isPing(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new r.PingRequest;return Promise.resolve(c(t.node,r.AccessAPI.Ping,s)).then(function(t){var r=n.response();return r.tag=e.tag,r})})}catch(e){return Promise.reject(e)}}(e,s);default:return e}})},m=s.node;return Promise.resolve(m?a(m):Promise.resolve(i.config().get("accessNode.api")).then(a))}catch(e){return Promise.reject(e)}}});
//# sourceMappingURL=send.umd.js.map
{
"name": "@onflow/send",
"version": "0.0.27",
"version": "0.0.28",
"description": "Flow SDK Send",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -47,7 +47,6 @@ import {AccessAPI, Transaction, SendTransactionRequest} from "@onflow/protobuf"

for (let acct of Object.values(ix.accounts)) {
if (acct.signature == null) continue // Skip -- No Signature
if (acct.role.payer) continue // Skip -- Is Payer
console.log("NON-PAYER", acct)
try {
if (acct.signature == null) continue // Skip -- No Signature
if (acct.role.payer) continue // Skip -- Is Payer
// Build Signature

@@ -69,7 +68,6 @@ const sig = new Transaction.Signature()

for (let acct of Object.values(ix.accounts)) {
if (acct.signature == null) continue // Skip -- No Signature
if (!acct.role.payer) continue // Skip -- Not Payer
console.log("PAYER", acct)
try {
if (acct.signature == null) continue // Skip -- No Signature
if (!acct.role.payer) continue // Skip -- Not Payer
// Build Signature

@@ -76,0 +74,0 @@ const sig = new Transaction.Signature()

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 not supported yet

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