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

@onflow/send

Package Overview
Dependencies
Maintainers
7
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.20 to 0.0.21

4

CHANGELOG.md

@@ -5,2 +5,6 @@ ### Unreleased

### 0.0.21 - 2020-09-29
- 2020-09-29 -- Fallback to config accessNode.api for node value
### 0.0.20 -- 2020-08-24

@@ -7,0 +11,0 @@

2

dist/send.js

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

var e=require("@onflow/interaction"),t=require("@onflow/protobuf"),r=require("@onflow/response"),n=require("@improbable-eng/grpc-web"),s=require("@improbable-eng/grpc-web-node-http-transport"),o=function(e,t,r){try{return Promise.resolve(new Promise(function(s,o){n.grpc.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===n.grpc.Code.OK?s(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};n.grpc.setDefaultTransport(s.NodeHttpTransport());var a=function(e){return Buffer.from(e,"hex")},i=function(e){return Buffer.from(e.padStart(16,0),"hex")},c=function(e){return Buffer.from(e).toString("hex")},u=function(e){return Buffer.from(e).toString("hex")},g=function(e){return Buffer.from(e).toString("hex")},l=function(e){return Buffer.from(e).toString("hex")};exports.send=function(n,s){void 0===s&&(s={});try{switch(!0){case e.isTransaction(n):return Promise.resolve(function(e,n){void 0===n&&(n={});try{var s=new t.Transaction;s.setScript(Buffer.from(e.message.cadence,"utf8")),s.setGasLimit(e.message.computeLimit),s.setReferenceBlockId(e.message.refBlock?a(e.message.refBlock):null),s.setPayer(i(e.accounts[e.payer].addr)),e.message.arguments.forEach(function(t){return s.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.forEach(function(t){return s.addAuthorizers(i(e.accounts[t].addr))});var c=new t.Transaction.ProposalKey;c.setAddress(i(e.accounts[e.proposer].addr)),c.setKeyId(e.accounts[e.proposer].keyId),c.setSequenceNumber(e.accounts[e.proposer].sequenceNum),s.setProposalKey(c),e.authorizations.forEach(function(r){if(null!==e.accounts[r].signature&&!e.accounts[r].role.payer){var n=new t.Transaction.Signature;n.setAddress(i(e.accounts[r].addr)),n.setKeyId(e.accounts[r].keyId),n.setSignature(a(e.accounts[r].signature)),s.addPayloadSignatures(n)}});var u=new t.Transaction.Signature;u.setAddress(i(e.accounts[e.payer].addr)),u.setKeyId(e.accounts[e.payer].keyId),u.setSignature(a(e.accounts[e.payer].signature)),s.addEnvelopeSignatures(u);var g=new t.SendTransactionRequest;return g.setTransaction(s),Promise.resolve(o(n.node,t.AccessAPI.SendTransaction,g)).then(function(t){var n,s=r.response();return s.tag=e.tag,s.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),s})}catch(e){return Promise.reject(e)}}(n,s));case e.isGetTransactionStatus(n):return Promise.resolve(function(e,n){void 0===n&&(n={});try{var s=new t.GetTransactionRequest;return s.setId(Buffer.from(e.transactionId,"hex")),Promise.resolve(o(n.node,t.AccessAPI.GetTransactionResult,s)).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)}}(n,s));case e.isScript(n):return Promise.resolve(function(e,n){void 0===n&&(n={});try{var s=new t.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(o(n.node,t.AccessAPI.ExecuteScriptAtLatestBlock,s)).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)}}(n,s));case e.isGetAccount(n):return Promise.resolve(function(e,n){void 0===n&&(n={});try{var s=new t.GetAccountRequest;return s.setAddress(Buffer.from(e.accountAddr.padStart(16,0),"hex")),Promise.resolve(o(n.node,t.AccessAPI.GetAccount,s)).then(function(t){var n=r.response();n.tag=e.tag;var s=t.getAccount();return n.account={address:c(s.getAddress_asU8()),balance:s.getBalance(),code:s.getCode_asU8(),keys:s.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:c(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}})},n})}catch(e){return Promise.reject(e)}}(n,s));case e.isGetEvents(n):return Promise.resolve(function(e,n){void 0===n&&(n={});try{var s=new t.GetEventsForHeightRangeRequest;return s.setType(e.events.eventType),s.setStartHeight(Number(e.events.start)),s.setEndHeight(Number(e.events.end)),Promise.resolve(o(n.node,t.AccessAPI.GetEventsForHeightRange,s)).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)}}(n,s));case e.isGetLatestBlock(n):return Promise.resolve(function(e,n){void 0===n&&(n={});try{var s=new t.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(o(n.node,t.AccessAPI.GetLatestBlock,s)).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:u(n.getId_asU8()),parentId:u(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:s.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:a},i})}catch(e){return Promise.reject(e)}}(n,s));case e.isGetBlockById(n):return Promise.resolve(function(e,n){void 0===n&&(n={});try{var s=new t.GetBlockByIDRequest;return s.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(o(n.node,t.AccessAPI.GetBlockByID,s)).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:g(n.getId_asU8()),parentId:g(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:s.map(function(e){return{collectionId:g(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:g(e.getBlockId_asU8()),executionReceiptId:g(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})}catch(e){return Promise.reject(e)}}(n,s));case e.isGetBlockByHeight(n):return Promise.resolve(function(e,n){void 0===n&&(n={});try{var s=new t.GetBlockByHeightRequest;return s.setHeight(e.block.height),Promise.resolve(o(n.node,t.AccessAPI.GetBlockByHeight,s)).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)}}(n,s));case e.isPing(n):return Promise.resolve(function(e,n){void 0===n&&(n={});try{var s=new t.PingRequest;return Promise.resolve(o(n.node,t.AccessAPI.Ping,s)).then(function(t){var n=r.response();return n.tag=e.tag,n})}catch(e){return Promise.reject(e)}}(n,s));default:return Promise.resolve(n)}}catch(e){return Promise.reject(e)}};
var e=require("@onflow/interaction"),t=require("@onflow/protobuf"),r=require("@onflow/response"),n=require("@improbable-eng/grpc-web"),s=require("@improbable-eng/grpc-web-node-http-transport"),o=require("@onflow/config"),a=function(e,t,r){try{return Promise.resolve(new Promise(function(s,o){n.grpc.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===n.grpc.Code.OK?s(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};n.grpc.setDefaultTransport(s.NodeHttpTransport());var c=function(e){return Buffer.from(e,"hex")},i=function(e){return Buffer.from(e.padStart(16,0),"hex")},u=function(e){return Buffer.from(e).toString("hex")},g=function(e){return Buffer.from(e).toString("hex")},d=function(e){return Buffer.from(e).toString("hex")},l=function(e){return Buffer.from(e).toString("hex")};exports.send=function(n,s){void 0===s&&(s={});try{var f=function(o){switch(s.node=o,!0){case e.isTransaction(n):return function(e,n){void 0===n&&(n={});try{var s=new t.Transaction;s.setScript(Buffer.from(e.message.cadence,"utf8")),s.setGasLimit(e.message.computeLimit),s.setReferenceBlockId(e.message.refBlock?c(e.message.refBlock):null),s.setPayer(i(e.accounts[e.payer].addr)),e.message.arguments.forEach(function(t){return s.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.forEach(function(t){return s.addAuthorizers(i(e.accounts[t].addr))});var o=new t.Transaction.ProposalKey;o.setAddress(i(e.accounts[e.proposer].addr)),o.setKeyId(e.accounts[e.proposer].keyId),o.setSequenceNumber(e.accounts[e.proposer].sequenceNum),s.setProposalKey(o),e.authorizations.forEach(function(r){if(null!==e.accounts[r].signature&&!e.accounts[r].role.payer){var n=new t.Transaction.Signature;n.setAddress(i(e.accounts[r].addr)),n.setKeyId(e.accounts[r].keyId),n.setSignature(c(e.accounts[r].signature)),s.addPayloadSignatures(n)}});var u=new t.Transaction.Signature;u.setAddress(i(e.accounts[e.payer].addr)),u.setKeyId(e.accounts[e.payer].keyId),u.setSignature(c(e.accounts[e.payer].signature)),s.addEnvelopeSignatures(u);var g=new t.SendTransactionRequest;return g.setTransaction(s),Promise.resolve(a(n.node,t.AccessAPI.SendTransaction,g)).then(function(t){var n,s=r.response();return s.tag=e.tag,s.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),s})}catch(e){return Promise.reject(e)}}(n,s);case e.isGetTransactionStatus(n):return function(e,n){void 0===n&&(n={});try{var s=new t.GetTransactionRequest;return s.setId(Buffer.from(e.transactionId,"hex")),Promise.resolve(a(n.node,t.AccessAPI.GetTransactionResult,s)).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)}}(n,s);case e.isScript(n):return function(e,n){void 0===n&&(n={});try{var s=new t.ExecuteScriptAtLatestBlockRequest,o=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(o),Promise.resolve(a(n.node,t.AccessAPI.ExecuteScriptAtLatestBlock,s)).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)}}(n,s);case e.isGetAccount(n):return function(e,n){void 0===n&&(n={});try{var s=new t.GetAccountRequest;return s.setAddress(Buffer.from(e.accountAddr.padStart(16,0),"hex")),Promise.resolve(a(n.node,t.AccessAPI.GetAccount,s)).then(function(t){var n=r.response();n.tag=e.tag;var s=t.getAccount();return n.account={address:u(s.getAddress_asU8()),balance:s.getBalance(),code:s.getCode_asU8(),keys:s.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:u(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}})},n})}catch(e){return Promise.reject(e)}}(n,s);case e.isGetEvents(n):return function(e,n){void 0===n&&(n={});try{var s=new t.GetEventsForHeightRangeRequest;return s.setType(e.events.eventType),s.setStartHeight(Number(e.events.start)),s.setEndHeight(Number(e.events.end)),Promise.resolve(a(n.node,t.AccessAPI.GetEventsForHeightRange,s)).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)}}(n,s);case e.isGetLatestBlock(n):return function(e,n){void 0===n&&(n={});try{var s=new t.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(a(n.node,t.AccessAPI.GetLatestBlock,s)).then(function(t){var n=t.getBlock(),s=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),c=r.response();return c.tag=e.tag,c.block={id:g(n.getId_asU8()),parentId:g(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:s.map(function(e){return{collectionId:g(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:g(e.getBlockId_asU8()),executionReceiptId:g(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},c})}catch(e){return Promise.reject(e)}}(n,s);case e.isGetBlockById(n):return function(e,n){void 0===n&&(n={});try{var s=new t.GetBlockByIDRequest;return s.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(a(n.node,t.AccessAPI.GetBlockByID,s)).then(function(t){var n=t.getBlock(),s=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),c=r.response();return c.tag=e.tag,c.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},c})}catch(e){return Promise.reject(e)}}(n,s);case e.isGetBlockByHeight(n):return function(e,n){void 0===n&&(n={});try{var s=new t.GetBlockByHeightRequest;return s.setHeight(e.block.height),Promise.resolve(a(n.node,t.AccessAPI.GetBlockByHeight,s)).then(function(t){var n=t.getBlock(),s=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),c=r.response();return c.tag=e.tag,c.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},c})}catch(e){return Promise.reject(e)}}(n,s);case e.isPing(n):return function(e,n){void 0===n&&(n={});try{var s=new t.PingRequest;return Promise.resolve(a(n.node,t.AccessAPI.Ping,s)).then(function(t){var n=r.response();return n.tag=e.tag,n})}catch(e){return Promise.reject(e)}}(n,s);default:return n}},p=s.node;return Promise.resolve(p?f(p):Promise.resolve(o.config().get("accessNode.api")).then(f))}catch(e){return Promise.reject(e)}};
//# sourceMappingURL=send.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 d,ExecuteScriptAtLatestBlockRequest as f,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{grpc as k}from"@improbable-eng/grpc-web";import{NodeHttpTransport as B}from"@improbable-eng/grpc-web-node-http-transport";var P=function(e,t,r){try{return Promise.resolve(new Promise(function(n,o){k.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===k.Code.OK?n(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};k.setDefaultTransport(B());var b=function(e){return Buffer.from(e,"hex")},x=function(e){return Buffer.from(e.padStart(16,0),"hex")},w=function(e){return Buffer.from(e).toString("hex")},L=function(e){return Buffer.from(e).toString("hex")},A=function(e){return Buffer.from(e).toString("hex")},U=function(e){return Buffer.from(e).toString("hex")},_=function(k,B){void 0===B&&(B={});try{switch(!0){case c(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new u;r.setScript(Buffer.from(e.message.cadence,"utf8")),r.setGasLimit(e.message.computeLimit),r.setReferenceBlockId(e.message.refBlock?b(e.message.refBlock):null),r.setPayer(x(e.accounts[e.payer].addr)),e.message.arguments.forEach(function(t){return r.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.forEach(function(t){return r.addAuthorizers(x(e.accounts[t].addr))});var n=new u.ProposalKey;n.setAddress(x(e.accounts[e.proposer].addr)),n.setKeyId(e.accounts[e.proposer].keyId),n.setSequenceNumber(e.accounts[e.proposer].sequenceNum),r.setProposalKey(n),e.authorizations.forEach(function(t){if(null!==e.accounts[t].signature&&!e.accounts[t].role.payer){var n=new u.Signature;n.setAddress(x(e.accounts[t].addr)),n.setKeyId(e.accounts[t].keyId),n.setSignature(b(e.accounts[t].signature)),r.addPayloadSignatures(n)}});var o=new u.Signature;o.setAddress(x(e.accounts[e.payer].addr)),o.setKeyId(e.accounts[e.payer].keyId),o.setSignature(b(e.accounts[e.payer].signature)),r.addEnvelopeSignatures(o);var s=new g;return s.setTransaction(r),Promise.resolve(P(t.node,l.SendTransaction,s)).then(function(t){var r,n=y();return n.tag=e.tag,n.transactionId=(r=t.getId_asU8(),Buffer.from(r).toString("hex")),n})}catch(e){return Promise.reject(e)}}(k,B));case i(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new d;return r.setId(Buffer.from(e.transactionId,"hex")),Promise.resolve(P(t.node,l.GetTransactionResult,r)).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)}}(k,B));case a(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new f,n=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return r.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),r.setScript(n),Promise.resolve(P(t.node,l.ExecuteScriptAtLatestBlock,r)).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)}}(k,B));case s(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new m;return r.setAddress(Buffer.from(e.accountAddr.padStart(16,0),"hex")),Promise.resolve(P(t.node,l.GetAccount,r)).then(function(t){var r=y();r.tag=e.tag;var n=t.getAccount();return r.account={address:w(n.getAddress_asU8()),balance:n.getBalance(),code:n.getCode_asU8(),keys:n.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:w(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}})},r})}catch(e){return Promise.reject(e)}}(k,B));case o(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new p;return r.setType(e.events.eventType),r.setStartHeight(Number(e.events.start)),r.setEndHeight(Number(e.events.end)),Promise.resolve(P(t.node,l.GetEventsForHeightRange,r)).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)}}(k,B));case n(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new v;return e.latestBlock&&e.latestBlock.isSealed&&(r.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&&r.setIsSealed(e.block.isSealed),Promise.resolve(P(t.node,l.GetLatestBlock,r)).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:L(r.getId_asU8()),parentId:L(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:n.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:s},a})}catch(e){return Promise.reject(e)}}(k,B));case r(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new h;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(P(t.node,l.GetBlockByID,r)).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:A(r.getId_asU8()),parentId:A(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:A(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:A(e.getBlockId_asU8()),executionReceiptId:A(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})}catch(e){return Promise.reject(e)}}(k,B));case t(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new S;return r.setHeight(e.block.height),Promise.resolve(P(t.node,l.GetBlockByHeight,r)).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)}}(k,B));case e(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new I;return Promise.resolve(P(t.node,l.Ping,r)).then(function(t){var r=y();return r.tag=e.tag,r})}catch(e){return Promise.reject(e)}}(k,B));default:return Promise.resolve(k)}}catch(e){return Promise.reject(e)}};export{_ as send};
import{isPing as e,isGetBlockByHeight as t,isGetBlockById as n,isGetLatestBlock as a,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 d,GetTransactionRequest as l,ExecuteScriptAtLatestBlockRequest as f,GetAccountRequest as p,GetEventsForHeightRangeRequest as m,GetLatestBlockRequest as S,GetBlockByIDRequest as I,GetBlockByHeightRequest as h,PingRequest as y}from"@onflow/protobuf";import{response as k}from"@onflow/response";import{grpc as B}from"@improbable-eng/grpc-web";import{NodeHttpTransport as w}from"@improbable-eng/grpc-web-node-http-transport";import{config as b}from"@onflow/config";async function x(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(w());const L=e=>Buffer.from(e,"hex"),A=e=>Buffer.from(e.padStart(16,0),"hex"),U=e=>Buffer.from(e).toString("hex"),_=e=>Buffer.from(e).toString("hex"),v=e=>Buffer.from(e).toString("hex"),E=e=>Buffer.from(e).toString("hex"),R=async(B,w={})=>{switch(w.node=w.node||await b().get("accessNode.api"),!0){case i(B):return async function(e,t={}){const n=new g;n.setScript(Buffer.from(e.message.cadence,"utf8")),n.setGasLimit(e.message.computeLimit),n.setReferenceBlockId(e.message.refBlock?L(e.message.refBlock):null),n.setPayer(A(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.forEach(t=>n.addAuthorizers(A(e.accounts[t].addr)));const a=new g.ProposalKey;a.setAddress(A(e.accounts[e.proposer].addr)),a.setKeyId(e.accounts[e.proposer].keyId),a.setSequenceNumber(e.accounts[e.proposer].sequenceNum),n.setProposalKey(a),e.authorizations.forEach(t=>{if(null===e.accounts[t].signature||e.accounts[t].role.payer)return;const a=new g.Signature;a.setAddress(A(e.accounts[t].addr)),a.setKeyId(e.accounts[t].keyId),a.setSignature(L(e.accounts[t].signature)),n.addPayloadSignatures(a)});const s=new g.Signature;s.setAddress(A(e.accounts[e.payer].addr)),s.setKeyId(e.accounts[e.payer].keyId),s.setSignature(L(e.accounts[e.payer].signature)),n.addEnvelopeSignatures(s);const o=new u;o.setTransaction(n);const r=await x(t.node,d.SendTransaction,o);let c=k();var i;return c.tag=e.tag,c.transactionId=(i=r.getId_asU8(),Buffer.from(i).toString("hex")),c}(B,w);case c(B):return async function(e,t={}){const n=new l;n.setId(Buffer.from(e.transactionId,"hex"));const a=await x(t.node,d.GetTransactionResult,n);let s=a.getEventsList(),o=k();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,w);case r(B):return async function(e,t={}){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 x(t.node,d.ExecuteScriptAtLatestBlock,n);let o=k();return o.tag=e.tag,o.encodedData=JSON.parse(Buffer.from(s.getValue_asU8()).toString("utf8")),o}(B,w);case o(B):return async function(e,t={}){const n=new p;n.setAddress(Buffer.from(e.accountAddr.padStart(16,0),"hex"));const a=await x(t.node,d.GetAccount,n);let s=k();s.tag=e.tag;const o=a.getAccount();return s.account={address:U(o.getAddress_asU8()),balance:o.getBalance(),code:o.getCode_asU8(),keys:o.getKeysList().map(e=>({index:e.getIndex(),publicKey:U(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}))},s}(B,w);case s(B):return async function(e,t={}){const n=new m;n.setType(e.events.eventType),n.setStartHeight(Number(e.events.start)),n.setEndHeight(Number(e.events.end));const a=await x(t.node,d.GetEventsForHeightRange,n);let s=k();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,w);case a(B):return async function(e,t={}){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 x(t.node,d.GetLatestBlock,n)).getBlock(),s=a.getCollectionGuaranteesList(),o=a.getBlockSealsList(),r=a.getSignaturesList(),c=k();return c.tag=e.tag,c.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},c}(B,w);case n(B):return async function(e,t={}){const n=new I;n.setId(Buffer.from(e.block.id,"hex"));const a=(await x(t.node,d.GetBlockByID,n)).getBlock(),s=a.getCollectionGuaranteesList(),o=a.getBlockSealsList(),r=a.getSignaturesList(),c=k();return c.tag=e.tag,c.block={id:v(a.getId_asU8()),parentId:v(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:s.map(e=>({collectionId:v(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:o.map(e=>({blockId:v(e.getBlockId_asU8()),executionReceiptId:v(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:r},c}(B,w);case t(B):return async function(e,t={}){const n=new h;n.setHeight(e.block.height);const a=(await x(t.node,d.GetBlockByHeight,n)).getBlock(),s=a.getCollectionGuaranteesList(),o=a.getBlockSealsList(),r=a.getSignaturesList(),c=k();return c.tag=e.tag,c.block={id:E(a.getId_asU8()),parentId:E(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:s.map(e=>({collectionId:E(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:o.map(e=>({blockId:E(e.getBlockId_asU8()),executionReceiptId:E(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:r},c}(B,w);case e(B):return async function(e,t={}){const n=new y;await x(t.node,d.Ping,n);let a=k();return a.tag=e.tag,a}(B,w);default:return B}};export{R 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 d,ExecuteScriptAtLatestBlockRequest as f,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{grpc as k}from"@improbable-eng/grpc-web";import{NodeHttpTransport as B}from"@improbable-eng/grpc-web-node-http-transport";var P=function(e,t,r){try{return Promise.resolve(new Promise(function(n,o){k.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===k.Code.OK?n(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};k.setDefaultTransport(B());var b=function(e){return Buffer.from(e,"hex")},x=function(e){return Buffer.from(e.padStart(16,0),"hex")},w=function(e){return Buffer.from(e).toString("hex")},L=function(e){return Buffer.from(e).toString("hex")},A=function(e){return Buffer.from(e).toString("hex")},U=function(e){return Buffer.from(e).toString("hex")},_=function(k,B){void 0===B&&(B={});try{switch(!0){case c(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new u;r.setScript(Buffer.from(e.message.cadence,"utf8")),r.setGasLimit(e.message.computeLimit),r.setReferenceBlockId(e.message.refBlock?b(e.message.refBlock):null),r.setPayer(x(e.accounts[e.payer].addr)),e.message.arguments.forEach(function(t){return r.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.forEach(function(t){return r.addAuthorizers(x(e.accounts[t].addr))});var n=new u.ProposalKey;n.setAddress(x(e.accounts[e.proposer].addr)),n.setKeyId(e.accounts[e.proposer].keyId),n.setSequenceNumber(e.accounts[e.proposer].sequenceNum),r.setProposalKey(n),e.authorizations.forEach(function(t){if(null!==e.accounts[t].signature&&!e.accounts[t].role.payer){var n=new u.Signature;n.setAddress(x(e.accounts[t].addr)),n.setKeyId(e.accounts[t].keyId),n.setSignature(b(e.accounts[t].signature)),r.addPayloadSignatures(n)}});var o=new u.Signature;o.setAddress(x(e.accounts[e.payer].addr)),o.setKeyId(e.accounts[e.payer].keyId),o.setSignature(b(e.accounts[e.payer].signature)),r.addEnvelopeSignatures(o);var s=new g;return s.setTransaction(r),Promise.resolve(P(t.node,l.SendTransaction,s)).then(function(t){var r,n=y();return n.tag=e.tag,n.transactionId=(r=t.getId_asU8(),Buffer.from(r).toString("hex")),n})}catch(e){return Promise.reject(e)}}(k,B));case i(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new d;return r.setId(Buffer.from(e.transactionId,"hex")),Promise.resolve(P(t.node,l.GetTransactionResult,r)).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)}}(k,B));case a(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new f,n=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return r.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),r.setScript(n),Promise.resolve(P(t.node,l.ExecuteScriptAtLatestBlock,r)).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)}}(k,B));case s(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new m;return r.setAddress(Buffer.from(e.accountAddr.padStart(16,0),"hex")),Promise.resolve(P(t.node,l.GetAccount,r)).then(function(t){var r=y();r.tag=e.tag;var n=t.getAccount();return r.account={address:w(n.getAddress_asU8()),balance:n.getBalance(),code:n.getCode_asU8(),keys:n.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:w(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}})},r})}catch(e){return Promise.reject(e)}}(k,B));case o(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new p;return r.setType(e.events.eventType),r.setStartHeight(Number(e.events.start)),r.setEndHeight(Number(e.events.end)),Promise.resolve(P(t.node,l.GetEventsForHeightRange,r)).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)}}(k,B));case n(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new v;return e.latestBlock&&e.latestBlock.isSealed&&(r.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&&r.setIsSealed(e.block.isSealed),Promise.resolve(P(t.node,l.GetLatestBlock,r)).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:L(r.getId_asU8()),parentId:L(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:n.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:s},a})}catch(e){return Promise.reject(e)}}(k,B));case r(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new h;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(P(t.node,l.GetBlockByID,r)).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:A(r.getId_asU8()),parentId:A(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:A(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:A(e.getBlockId_asU8()),executionReceiptId:A(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})}catch(e){return Promise.reject(e)}}(k,B));case t(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new S;return r.setHeight(e.block.height),Promise.resolve(P(t.node,l.GetBlockByHeight,r)).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)}}(k,B));case e(k):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new I;return Promise.resolve(P(t.node,l.Ping,r)).then(function(t){var r=y();return r.tag=e.tag,r})}catch(e){return Promise.reject(e)}}(k,B));default:return Promise.resolve(k)}}catch(e){return Promise.reject(e)}};export{_ as send};
import{isPing as e,isGetBlockByHeight as t,isGetBlockById as r,isGetLatestBlock as n,isGetEvents as o,isGetAccount as a,isScript as s,isGetTransactionStatus as i,isTransaction as c}from"@onflow/interaction";import{Transaction as u,SendTransactionRequest as g,AccessAPI as d,GetTransactionRequest as l,ExecuteScriptAtLatestBlockRequest as f,GetAccountRequest as m,GetEventsForHeightRangeRequest as p,GetLatestBlockRequest as h,GetBlockByIDRequest as v,GetBlockByHeightRequest as S,PingRequest as I}from"@onflow/protobuf";import{response as y}from"@onflow/response";import{grpc as k}from"@improbable-eng/grpc-web";import{NodeHttpTransport as B}from"@improbable-eng/grpc-web-node-http-transport";import{config as b}from"@onflow/config";var x=function(e,t,r){try{return Promise.resolve(new Promise(function(n,o){k.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===k.Code.OK?n(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};k.setDefaultTransport(B());var P=function(e){return Buffer.from(e,"hex")},w=function(e){return Buffer.from(e.padStart(16,0),"hex")},L=function(e){return Buffer.from(e).toString("hex")},A=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")},E=function(k,B){void 0===B&&(B={});try{var E=function(b){switch(B.node=b,!0){case c(k):return function(e,t){void 0===t&&(t={});try{var r=new u;r.setScript(Buffer.from(e.message.cadence,"utf8")),r.setGasLimit(e.message.computeLimit),r.setReferenceBlockId(e.message.refBlock?P(e.message.refBlock):null),r.setPayer(w(e.accounts[e.payer].addr)),e.message.arguments.forEach(function(t){return r.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.forEach(function(t){return r.addAuthorizers(w(e.accounts[t].addr))});var n=new u.ProposalKey;n.setAddress(w(e.accounts[e.proposer].addr)),n.setKeyId(e.accounts[e.proposer].keyId),n.setSequenceNumber(e.accounts[e.proposer].sequenceNum),r.setProposalKey(n),e.authorizations.forEach(function(t){if(null!==e.accounts[t].signature&&!e.accounts[t].role.payer){var n=new u.Signature;n.setAddress(w(e.accounts[t].addr)),n.setKeyId(e.accounts[t].keyId),n.setSignature(P(e.accounts[t].signature)),r.addPayloadSignatures(n)}});var o=new u.Signature;o.setAddress(w(e.accounts[e.payer].addr)),o.setKeyId(e.accounts[e.payer].keyId),o.setSignature(P(e.accounts[e.payer].signature)),r.addEnvelopeSignatures(o);var a=new g;return a.setTransaction(r),Promise.resolve(x(t.node,d.SendTransaction,a)).then(function(t){var r,n=y();return n.tag=e.tag,n.transactionId=(r=t.getId_asU8(),Buffer.from(r).toString("hex")),n})}catch(e){return Promise.reject(e)}}(k,B);case i(k):return function(e,t){void 0===t&&(t={});try{var r=new l;return r.setId(Buffer.from(e.transactionId,"hex")),Promise.resolve(x(t.node,d.GetTransactionResult,r)).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)}}(k,B);case s(k):return function(e,t){void 0===t&&(t={});try{var r=new f,n=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return r.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),r.setScript(n),Promise.resolve(x(t.node,d.ExecuteScriptAtLatestBlock,r)).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)}}(k,B);case a(k):return function(e,t){void 0===t&&(t={});try{var r=new m;return r.setAddress(Buffer.from(e.accountAddr.padStart(16,0),"hex")),Promise.resolve(x(t.node,d.GetAccount,r)).then(function(t){var r=y();r.tag=e.tag;var n=t.getAccount();return r.account={address: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)}}(k,B);case o(k):return function(e,t){void 0===t&&(t={});try{var r=new p;return r.setType(e.events.eventType),r.setStartHeight(Number(e.events.start)),r.setEndHeight(Number(e.events.end)),Promise.resolve(x(t.node,d.GetEventsForHeightRange,r)).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)}}(k,B);case n(k):return function(e,t){void 0===t&&(t={});try{var r=new h;return e.latestBlock&&e.latestBlock.isSealed&&(r.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&&r.setIsSealed(e.block.isSealed),Promise.resolve(x(t.node,d.GetLatestBlock,r)).then(function(t){var r=t.getBlock(),n=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),a=r.getSignaturesList(),s=y();return s.tag=e.tag,s.block={id:A(r.getId_asU8()),parentId:A(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:A(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:A(e.getBlockId_asU8()),executionReceiptId:A(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},s})}catch(e){return Promise.reject(e)}}(k,B);case r(k):return function(e,t){void 0===t&&(t={});try{var r=new v;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(x(t.node,d.GetBlockByID,r)).then(function(t){var r=t.getBlock(),n=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),a=r.getSignaturesList(),s=y();return s.tag=e.tag,s.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:a},s})}catch(e){return Promise.reject(e)}}(k,B);case t(k):return function(e,t){void 0===t&&(t={});try{var r=new S;return r.setHeight(e.block.height),Promise.resolve(x(t.node,d.GetBlockByHeight,r)).then(function(t){var r=t.getBlock(),n=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),a=r.getSignaturesList(),s=y();return s.tag=e.tag,s.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:a},s})}catch(e){return Promise.reject(e)}}(k,B);case e(k):return function(e,t){void 0===t&&(t={});try{var r=new I;return Promise.resolve(x(t.node,d.Ping,r)).then(function(t){var r=y();return r.tag=e.tag,r})}catch(e){return Promise.reject(e)}}(k,B);default:return k}},R=B.node;return Promise.resolve(R?E(R):Promise.resolve(b().get("accessNode.api")).then(E))}catch(e){return Promise.reject(e)}};export{E 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("@improbable-eng/grpc-web"),require("@improbable-eng/grpc-web-node-http-transport")):"function"==typeof define&&define.amd?define(["exports","@onflow/interaction","@onflow/protobuf","@onflow/response","@improbable-eng/grpc-web","@improbable-eng/grpc-web-node-http-transport"],t):t((e=e||self).send={},e.interaction,e.protobuf,e.response,e.grpcWeb,e.grpcWebNodeHttpTransport)}(this,function(e,t,r,n,s,o){var a=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 i=function(e){return Buffer.from(e,"hex")},c=function(e){return Buffer.from(e.padStart(16,0),"hex")},u=function(e){return Buffer.from(e).toString("hex")},g=function(e){return Buffer.from(e).toString("hex")},l=function(e){return Buffer.from(e).toString("hex")},d=function(e){return Buffer.from(e).toString("hex")};e.send=function(e,s){void 0===s&&(s={});try{switch(!0){case t.isTransaction(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var s=new r.Transaction;s.setScript(Buffer.from(e.message.cadence,"utf8")),s.setGasLimit(e.message.computeLimit),s.setReferenceBlockId(e.message.refBlock?i(e.message.refBlock):null),s.setPayer(c(e.accounts[e.payer].addr)),e.message.arguments.forEach(function(t){return s.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.forEach(function(t){return s.addAuthorizers(c(e.accounts[t].addr))});var o=new r.Transaction.ProposalKey;o.setAddress(c(e.accounts[e.proposer].addr)),o.setKeyId(e.accounts[e.proposer].keyId),o.setSequenceNumber(e.accounts[e.proposer].sequenceNum),s.setProposalKey(o),e.authorizations.forEach(function(t){if(null!==e.accounts[t].signature&&!e.accounts[t].role.payer){var n=new r.Transaction.Signature;n.setAddress(c(e.accounts[t].addr)),n.setKeyId(e.accounts[t].keyId),n.setSignature(i(e.accounts[t].signature)),s.addPayloadSignatures(n)}});var u=new r.Transaction.Signature;u.setAddress(c(e.accounts[e.payer].addr)),u.setKeyId(e.accounts[e.payer].keyId),u.setSignature(i(e.accounts[e.payer].signature)),s.addEnvelopeSignatures(u);var g=new r.SendTransactionRequest;return g.setTransaction(s),Promise.resolve(a(t.node,r.AccessAPI.SendTransaction,g)).then(function(t){var r,s=n.response();return s.tag=e.tag,s.transactionId=(r=t.getId_asU8(),Buffer.from(r).toString("hex")),s})}catch(e){return Promise.reject(e)}}(e,s));case t.isGetTransactionStatus(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var s=new r.GetTransactionRequest;return s.setId(Buffer.from(e.transactionId,"hex")),Promise.resolve(a(t.node,r.AccessAPI.GetTransactionResult,s)).then(function(t){var r=t.getEventsList(),s=n.response();return s.tag=e.tag,s.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})},s})}catch(e){return Promise.reject(e)}}(e,s));case t.isScript(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var s=new r.ExecuteScriptAtLatestBlockRequest,o=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(o),Promise.resolve(a(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 Promise.resolve(function(e,t){void 0===t&&(t={});try{var s=new r.GetAccountRequest;return s.setAddress(Buffer.from(e.accountAddr.padStart(16,0),"hex")),Promise.resolve(a(t.node,r.AccessAPI.GetAccount,s)).then(function(t){var r=n.response();r.tag=e.tag;var s=t.getAccount();return r.account={address:u(s.getAddress_asU8()),balance:s.getBalance(),code:s.getCode_asU8(),keys:s.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:u(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 Promise.resolve(function(e,t){void 0===t&&(t={});try{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(a(t.node,r.AccessAPI.GetEventsForHeightRange,s)).then(function(t){var r=n.response();r.tag=e.tag;var s=t.getResultsList();return r.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},[]),r})}catch(e){return Promise.reject(e)}}(e,s));case t.isGetLatestBlock(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{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(a(t.node,r.AccessAPI.GetLatestBlock,s)).then(function(t){var r=t.getBlock(),s=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),a=r.getSignaturesList(),i=n.response();return i.tag=e.tag,i.block={id:g(r.getId_asU8()),parentId:g(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:s.map(function(e){return{collectionId:g(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:g(e.getBlockId_asU8()),executionReceiptId:g(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 Promise.resolve(function(e,t){void 0===t&&(t={});try{var s=new r.GetBlockByIDRequest;return s.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(a(t.node,r.AccessAPI.GetBlockByID,s)).then(function(t){var r=t.getBlock(),s=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),a=r.getSignaturesList(),i=n.response();return i.tag=e.tag,i.block={id:l(r.getId_asU8()),parentId:l(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.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)}}(e,s));case t.isGetBlockByHeight(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var s=new r.GetBlockByHeightRequest;return s.setHeight(e.block.height),Promise.resolve(a(t.node,r.AccessAPI.GetBlockByHeight,s)).then(function(t){var r=t.getBlock(),s=r.getCollectionGuaranteesList(),o=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: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)}}(e,s));case t.isPing(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var s=new r.PingRequest;return Promise.resolve(a(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 Promise.resolve(e)}}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("@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","@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.grpcWeb,e.grpcWebNodeHttpTransport,e.config)}(this,function(e,t,r,n,s,o,a){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(o.NodeHttpTransport());var i=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")},d=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")};e.send=function(e,s){void 0===s&&(s={});try{var o=function(o){switch(s.node=o,!0){case t.isTransaction(e):return function(e,t){void 0===t&&(t={});try{var s=new r.Transaction;s.setScript(Buffer.from(e.message.cadence,"utf8")),s.setGasLimit(e.message.computeLimit),s.setReferenceBlockId(e.message.refBlock?i(e.message.refBlock):null),s.setPayer(u(e.accounts[e.payer].addr)),e.message.arguments.forEach(function(t){return s.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.forEach(function(t){return s.addAuthorizers(u(e.accounts[t].addr))});var o=new r.Transaction.ProposalKey;o.setAddress(u(e.accounts[e.proposer].addr)),o.setKeyId(e.accounts[e.proposer].keyId),o.setSequenceNumber(e.accounts[e.proposer].sequenceNum),s.setProposalKey(o),e.authorizations.forEach(function(t){if(null!==e.accounts[t].signature&&!e.accounts[t].role.payer){var n=new r.Transaction.Signature;n.setAddress(u(e.accounts[t].addr)),n.setKeyId(e.accounts[t].keyId),n.setSignature(i(e.accounts[t].signature)),s.addPayloadSignatures(n)}});var a=new r.Transaction.Signature;a.setAddress(u(e.accounts[e.payer].addr)),a.setKeyId(e.accounts[e.payer].keyId),a.setSignature(i(e.accounts[e.payer].signature)),s.addEnvelopeSignatures(a);var g=new r.SendTransactionRequest;return g.setTransaction(s),Promise.resolve(c(t.node,r.AccessAPI.SendTransaction,g)).then(function(t){var r,s=n.response();return s.tag=e.tag,s.transactionId=(r=t.getId_asU8(),Buffer.from(r).toString("hex")),s})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetTransactionStatus(e):return function(e,t){void 0===t&&(t={});try{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(),s=n.response();return s.tag=e.tag,s.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})},s})}catch(e){return Promise.reject(e)}}(e,s);case t.isScript(e):return function(e,t){void 0===t&&(t={});try{var s=new r.ExecuteScriptAtLatestBlockRequest,o=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(o),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{var s=new r.GetAccountRequest;return s.setAddress(Buffer.from(e.accountAddr.padStart(16,0),"hex")),Promise.resolve(c(t.node,r.AccessAPI.GetAccount,s)).then(function(t){var r=n.response();r.tag=e.tag;var s=t.getAccount();return r.account={address:g(s.getAddress_asU8()),balance:s.getBalance(),code:s.getCode_asU8(),keys:s.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()}})},r})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetEvents(e):return function(e,t){void 0===t&&(t={});try{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 s=t.getResultsList();return r.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},[]),r})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetLatestBlock(e):return function(e,t){void 0===t&&(t={});try{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(),s=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),a=r.getSignaturesList(),c=n.response();return c.tag=e.tag,c.block={id:d(r.getId_asU8()),parentId:d(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.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},c})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetBlockById(e):return function(e,t){void 0===t&&(t={});try{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(),s=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),a=r.getSignaturesList(),c=n.response();return c.tag=e.tag,c.block={id:l(r.getId_asU8()),parentId:l(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.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},c})}catch(e){return Promise.reject(e)}}(e,s);case t.isGetBlockByHeight(e):return function(e,t){void 0===t&&(t={});try{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(),s=r.getCollectionGuaranteesList(),o=r.getBlockSealsList(),a=r.getSignaturesList(),c=n.response();return c.tag=e.tag,c.block={id:f(r.getId_asU8()),parentId:f(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.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},c})}catch(e){return Promise.reject(e)}}(e,s);case t.isPing(e):return function(e,t){void 0===t&&(t={});try{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}},p=s.node;return Promise.resolve(p?o(p):Promise.resolve(a.config().get("accessNode.api")).then(o))}catch(e){return Promise.reject(e)}}});
//# sourceMappingURL=send.umd.js.map
{
"name": "@onflow/send",
"version": "0.0.20",
"version": "0.0.21",
"description": "Flow SDK Send",

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

"devDependencies": {
"jest": "25.3.0",
"jest": "26.4.2",
"jest-esm-transformer": "1.0.0",
"microbundle": "0.12.0-next.8"
"microbundle": "0.12.4"
},

@@ -40,2 +40,3 @@ "source": "src/send.js",

"@improbable-eng/grpc-web-node-http-transport": "0.12.0",
"@onflow/config": "0.0.2",
"@onflow/interaction": "0.0.10",

@@ -42,0 +43,0 @@ "@onflow/protobuf": "0.1.6",

@@ -21,4 +21,7 @@ import {

import {sendPing} from "./send-ping"
import {config} from "@onflow/config"
export const send = async (ix, opts = {}) => {
opts.node = opts.node || await config().get("accessNode.api")
switch (true) {

@@ -25,0 +28,0 @@ case isTransaction(ix):

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