@onflow/send
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -1,2 +0,2 @@ | ||
var e=require("@improbable-eng/grpc-web"),t=require("@improbable-eng/grpc-web-node-http-transport"),r=require("@onflow/interaction"),n=require("@onflow/protobuf"),s=require("@onflow/response"),o=require("@onflow/bytes"),a=function(t,r,n){try{return Promise.resolve(new Promise(function(s,o){e.grpc.unary(r,{request:n,host:t,onEnd:function(t){var r=t.statusMessage;t.status===e.grpc.Code.OK?s(t.message):o(new Error(r))}})}))}catch(e){return Promise.reject(e)}};e.grpc.setDefaultTransport(t.NodeHttpTransport()),exports.send=function(e,t){void 0===t&&(t={});try{switch(!0){case r.isTransaction(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=e.authz.map(function(e){var t=new n.AccountSignature;return t.setAccount(o.addressToBuffer(o.bytes(e.acct,20))),t.setSignature(e.signature),t}),c=new n.AccountSignature;c.setAccount(o.addressToBuffer(o.bytes(e.payer.acct,20))),c.setSignature(e.payer.signature);var i=c,u=new n.Transaction;u.setScript(o.scriptToBuffer(e.payload.code)),u.setNonce(e.payload.nonce),u.setComputeLimit(e.payload.limit),u.setReferenceBlockHash(e.payload.ref?o.hashToBuffer(e.payload.ref):null),u.setPayeraccount(o.addressToBuffer(o.bytes(e.payer.acct,20))),e.authz.forEach(function(e){return u.addScriptaccounts(o.addressToBuffer(o.bytes(e.acct,20)))}),r.forEach(function(e){return u.addSignatures(e)}),r.push(i);var g=new n.SendTransactionRequest;return g.setTransaction(u),Promise.resolve(a(t.node,n.ObserveService.SendTransaction,g)).then(function(t){var r=s.response();return r.tag=e.tag,r.transactionHash=o.bufferToHexString(t.getHash_asU8()),r})}catch(e){return Promise.reject(e)}}(e,t));case r.isGetTransaction(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new n.GetTransactionRequest;return r.setHash(o.hashToBuffer(e.txId)),Promise.resolve(a(t.node,n.ObserveService.GetTransaction,r)).then(function(t){var r=t.getTransaction(),n=t.getEventsList(),a=s.response();return a.tag=e.tag,a.transaction={status:r.getStatus(),events:n.map(function(e){return{type:e.getType(),transactionHash:o.bufferToHexString(e.getTransactionHash_asU8()),index:e.getIndex(),payload:e.getPayload_asU8()}})},a})}catch(e){return Promise.reject(e)}}(e,t));case r.isScript(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new n.ExecuteScriptRequest,c=o.scriptToBuffer(e.payload.code);return r.setScript(c),Promise.resolve(a(t.node,n.ObserveService.ExecuteScript,r)).then(function(t){var r=s.response();return r.tag=e.tag,r.encodedData=t.getValue_asU8(),r.decodeInstructions=null,r})}catch(e){return Promise.reject(e)}}(e,t));case r.isGetAccount(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new n.GetAccountRequest,c=o.addressToBuffer(o.bytes(e.acct,20));return r.setAddress(c),Promise.resolve(a(t.node,n.ObserveService.GetAccount,r)).then(function(t){var r=s.response();r.tag=e.tag;var n=t.getAccount();return r.account={address:o.bufferToHexString(n.getAddress_asU8()),balance:n.getBalance(),code:n.getCode_asU8(),keys:n.getKeysList().map(function(e){return{publicKey:o.bufferToHexString(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight()}})},r})}catch(e){return Promise.reject(e)}}(e,t));case r.isGetEvents(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new n.GetEventsRequest;return r.setType(e.eventType),r.setStartBlock(Number(e.bounds.start)),r.setEndBlock(Number(e.bounds.end)),Promise.resolve(a(t.node,n.ObserveService.GetEvents,r)).then(function(t){var r=s.response();r.tag=e.tag;var n=t.getEventsList();return r.events=n.map(function(e){return{type:e.getType(),transactionHash:o.bufferToHexString(e.getTransactionHash_asU8()),index:e.getIndex(),payload:e.getPayload_asU8()}}),r})}catch(e){return Promise.reject(e)}}(e,t));case r.isGetLatestBlock(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new n.GetLatestBlockRequest;return r.setIsSealed(e.isSealed),Promise.resolve(a(t.node,n.ObserveService.GetLatestBlock,r)).then(function(t){var r=t.getBlock(),n=s.response();return n.tag=e.tag,n.latestBlock={blockHash:o.bufferToHexString(r.getHash_asU8()),previousBlockHash:o.bufferToHexString(r.getPreviousblockhash_asU8()),blockNumber:r.getNumber()},n})}catch(e){return Promise.reject(e)}}(e,t));case r.isPing(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new n.PingRequest;return Promise.resolve(a(t.node,n.ObserveService.Ping,r)).then(function(t){var r=s.response();return r.tag=e.tag,r.ping=o.bufferToHexString(t.getAddress_asU8()),r})}catch(e){return Promise.reject(e)}}(e,t));default:return Promise.resolve(e)}}catch(e){return Promise.reject(e)}}; | ||
var e=require("@onflow/interaction"),t=require("@onflow/protobuf"),r=require("@onflow/response"),n=require("@onflow/bytes"),s=require("@improbable-eng/grpc-web"),a=require("@improbable-eng/grpc-web-node-http-transport"),o=function(e,t,r){try{return Promise.resolve(new Promise(function(n,a){s.grpc.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===s.grpc.Code.OK?n(e.message):a(new Error(t))}})}))}catch(e){return Promise.reject(e)}};s.grpc.setDefaultTransport(a.NodeHttpTransport()),exports.send=function(s,a){void 0===a&&(a={});try{switch(!0){case e.isTransaction(s):return Promise.resolve(function(e,s){void 0===s&&(s={});try{var a=e.authz.map(function(e){var r=new t.AccountSignature;return r.setAccount(n.addressToBuffer(n.bytes(e.acct,20))),r.setSignature(e.signature),r}),c=new t.AccountSignature;c.setAccount(n.addressToBuffer(n.bytes(e.payer.acct,20))),c.setSignature(e.payer.signature);var i=c,u=new t.Transaction;u.setScript(n.scriptToBuffer(e.payload.code)),u.setNonce(e.payload.nonce),u.setComputeLimit(e.payload.limit),u.setReferenceBlockHash(e.payload.ref?n.hashToBuffer(e.payload.ref):null),u.setPayeraccount(n.addressToBuffer(n.bytes(e.payer.acct,20))),e.authz.forEach(function(e){return u.addScriptaccounts(n.addressToBuffer(n.bytes(e.acct,20)))}),a.forEach(function(e){return u.addSignatures(e)}),a.push(i);var g=new t.SendTransactionRequest;return g.setTransaction(u),Promise.resolve(o(s.node,t.ObserveService.SendTransaction,g)).then(function(t){var s=r.response();return s.tag=e.tag,s.transactionId=n.bufferToHexString(t.getHash_asU8()),s})}catch(e){return Promise.reject(e)}}(s,a));case e.isGetTransactionStatus(s):return Promise.resolve(function(e,s){void 0===s&&(s={});try{var a=new t.GetTransactionResultRequest;return a.setHash(n.hashToBuffer(e.txId)),Promise.resolve(o(s.node,t.AccessAPI.GetTransactionResult,a)).then(function(t){var s=t.getEventsList(),a=r.response();return a.tag=e.tag,a.transaction={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:s.map(function(e){return{type:e.getType(),transactionId:n.bufferToHexString(e.getTransactionId_asU8()),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:e.getPayload_asU8()}})},a})}catch(e){return Promise.reject(e)}}(s,a));case e.isScript(s):return Promise.resolve(function(e,s){void 0===s&&(s={});try{var a=new t.ExecuteScriptAtLatestBlockRequest,c=n.scriptToBuffer(e.payload.code);return a.setScript(c),Promise.resolve(o(s.node,t.AccessAPI.ExecuteScriptAtLatestBlock,a)).then(function(t){var n=r.response();return n.tag=e.tag,n.encodedData=t.getValue_asU8(),n})}catch(e){return Promise.reject(e)}}(s,a));case e.isGetAccount(s):return Promise.resolve(function(e,s){void 0===s&&(s={});try{var a=new t.GetAccountRequest,c=n.addressToBuffer(n.bytes(e.acct,20));return a.setAddress(c),Promise.resolve(o(s.node,t.AccessAPI.GetAccount,a)).then(function(t){var s=r.response();s.tag=e.tag;var a=t.getAccount();return s.account={address:n.bufferToHexString(a.getAddress_asU8()),balance:a.getBalance(),code:a.getCode_asU8(),keys:a.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:n.bufferToHexString(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}})},s})}catch(e){return Promise.reject(e)}}(s,a));case e.isGetEvents(s):return Promise.resolve(function(e,s){void 0===s&&(s={});try{var a=new t.GetEventsForHeightRange;return a.setType(e.eventType),a.setStartHeight(Number(e.bounds.start)),a.setEndHeight(Number(e.bounds.end)),Promise.resolve(o(s.node,t.AccessAPI.GetEvents,a)).then(function(t){var s=r.response();s.tag=e.tag;var a=t.getEventsList();return s.events=a.map(function(e){return{type:e.getType(),transactionHash:n.bufferToHexString(e.getTransactionHash_asU8()),index:e.getIndex(),payload:e.getPayload_asU8()}}),s})}catch(e){return Promise.reject(e)}}(s,a));case e.isGetLatestBlock(s):return Promise.resolve(function(e,s){void 0===s&&(s={});try{var a=new t.GetLatestBlockRequest;return a.setIsSealed(e.isSealed),Promise.resolve(o(s.node,t.AccessAPI.GetLatestBlock,a)).then(function(t){var s=t.getBlock(),a=s.getCollectionGuaranteesList(),o=s.getBlockSealsList(),c=s.getSignaturesList(),i=r.response();return i.tag=e.tag,i.latestBlock={id:n.bufferToHexString(s.getId_asU8()),parentId:n.bufferToHexString(s.getParentId_asU8()),height:s.getHeight(),timestamp:s.getTimestamp(),collectionGuarantees:a.map(function(e){return{collectionId:n.bufferToHexString(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:n.bufferToHexString(e.getBlockId_asU8()),executionReceiptId:n.bufferToHexString(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:c},i})}catch(e){return Promise.reject(e)}}(s,a));case e.isPing(s):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)}}(s,a));default:return Promise.resolve(s)}}catch(e){return Promise.reject(e)}}; | ||
//# sourceMappingURL=send.js.map |
@@ -1,2 +0,2 @@ | ||
import{grpc as e}from"@improbable-eng/grpc-web";import{NodeHttpTransport as t}from"@improbable-eng/grpc-web-node-http-transport";import{isTransaction as r,isGetTransaction as n,isScript as a,isGetAccount as o,isGetEvents as s,isGetLatestBlock as c,isPing as i}from"@onflow/interaction";import{ObserveService as u,AccountSignature as g,Transaction as d,SendTransactionRequest as l,GetTransactionRequest as v,ExecuteScriptRequest as m,GetAccountRequest as p,GetEventsRequest as f,GetLatestBlockRequest as h,PingRequest as y}from"@onflow/protobuf";import{response as P}from"@onflow/response";import{bufferToHexString as b,scriptToBuffer as w,hashToBuffer as S,addressToBuffer as H,bytes as U}from"@onflow/bytes";var _=function(t,r,n){try{return Promise.resolve(new Promise(function(a,o){e.unary(r,{request:n,host:t,onEnd:function(t){var r=t.statusMessage;t.status===e.Code.OK?a(t.message):o(new Error(r))}})}))}catch(e){return Promise.reject(e)}};e.setDefaultTransport(t());var k=function(e,t){void 0===t&&(t={});try{switch(!0){case r(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=e.authz.map(function(e){var t=new g;return t.setAccount(H(U(e.acct,20))),t.setSignature(e.signature),t}),n=new g;n.setAccount(H(U(e.payer.acct,20))),n.setSignature(e.payer.signature);var a=n,o=new d;o.setScript(w(e.payload.code)),o.setNonce(e.payload.nonce),o.setComputeLimit(e.payload.limit),o.setReferenceBlockHash(e.payload.ref?S(e.payload.ref):null),o.setPayeraccount(H(U(e.payer.acct,20))),e.authz.forEach(function(e){return o.addScriptaccounts(H(U(e.acct,20)))}),r.forEach(function(e){return o.addSignatures(e)}),r.push(a);var s=new l;return s.setTransaction(o),Promise.resolve(_(t.node,u.SendTransaction,s)).then(function(t){var r=P();return r.tag=e.tag,r.transactionHash=b(t.getHash_asU8()),r})}catch(e){return Promise.reject(e)}}(e,t));case n(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new v;return r.setHash(S(e.txId)),Promise.resolve(_(t.node,u.GetTransaction,r)).then(function(t){var r=t.getTransaction(),n=t.getEventsList(),a=P();return a.tag=e.tag,a.transaction={status:r.getStatus(),events:n.map(function(e){return{type:e.getType(),transactionHash:b(e.getTransactionHash_asU8()),index:e.getIndex(),payload:e.getPayload_asU8()}})},a})}catch(e){return Promise.reject(e)}}(e,t));case a(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new m,n=w(e.payload.code);return r.setScript(n),Promise.resolve(_(t.node,u.ExecuteScript,r)).then(function(t){var r=P();return r.tag=e.tag,r.encodedData=t.getValue_asU8(),r.decodeInstructions=null,r})}catch(e){return Promise.reject(e)}}(e,t));case o(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new p,n=H(U(e.acct,20));return r.setAddress(n),Promise.resolve(_(t.node,u.GetAccount,r)).then(function(t){var r=P();r.tag=e.tag;var n=t.getAccount();return r.account={address:b(n.getAddress_asU8()),balance:n.getBalance(),code:n.getCode_asU8(),keys:n.getKeysList().map(function(e){return{publicKey:b(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight()}})},r})}catch(e){return Promise.reject(e)}}(e,t));case s(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new f;return r.setType(e.eventType),r.setStartBlock(Number(e.bounds.start)),r.setEndBlock(Number(e.bounds.end)),Promise.resolve(_(t.node,u.GetEvents,r)).then(function(t){var r=P();r.tag=e.tag;var n=t.getEventsList();return r.events=n.map(function(e){return{type:e.getType(),transactionHash:b(e.getTransactionHash_asU8()),index:e.getIndex(),payload:e.getPayload_asU8()}}),r})}catch(e){return Promise.reject(e)}}(e,t));case c(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new h;return r.setIsSealed(e.isSealed),Promise.resolve(_(t.node,u.GetLatestBlock,r)).then(function(t){var r=t.getBlock(),n=P();return n.tag=e.tag,n.latestBlock={blockHash:b(r.getHash_asU8()),previousBlockHash:b(r.getPreviousblockhash_asU8()),blockNumber:r.getNumber()},n})}catch(e){return Promise.reject(e)}}(e,t));case i(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new y;return Promise.resolve(_(t.node,u.Ping,r)).then(function(t){var r=P();return r.tag=e.tag,r.ping=b(t.getAddress_asU8()),r})}catch(e){return Promise.reject(e)}}(e,t));default:return Promise.resolve(e)}}catch(e){return Promise.reject(e)}};export{k as send}; | ||
import{isPing as e,isGetLatestBlock as t,isGetEvents as r,isGetAccount as n,isScript as a,isGetTransactionStatus as o,isTransaction as s}from"@onflow/interaction";import{AccountSignature as c,Transaction as i,SendTransactionRequest as u,ObserveService as g,GetTransactionResultRequest as d,AccessAPI as l,ExecuteScriptAtLatestBlockRequest as m,GetAccountRequest as p,GetEventsForHeightRange as v,GetLatestBlockRequest as f,PingRequest as h}from"@onflow/protobuf";import{response as y}from"@onflow/response";import{addressToBuffer as P,bytes as S,scriptToBuffer as w,hashToBuffer as I,bufferToHexString as b}from"@onflow/bytes";import{grpc as x}from"@improbable-eng/grpc-web";import{NodeHttpTransport as U}from"@improbable-eng/grpc-web-node-http-transport";var _=function(e,t,r){try{return Promise.resolve(new Promise(function(n,a){x.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===x.Code.OK?n(e.message):a(new Error(t))}})}))}catch(e){return Promise.reject(e)}};x.setDefaultTransport(U());var A=function(x,U){void 0===U&&(U={});try{switch(!0){case s(x):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=e.authz.map(function(e){var t=new c;return t.setAccount(P(S(e.acct,20))),t.setSignature(e.signature),t}),n=new c;n.setAccount(P(S(e.payer.acct,20))),n.setSignature(e.payer.signature);var a=n,o=new i;o.setScript(w(e.payload.code)),o.setNonce(e.payload.nonce),o.setComputeLimit(e.payload.limit),o.setReferenceBlockHash(e.payload.ref?I(e.payload.ref):null),o.setPayeraccount(P(S(e.payer.acct,20))),e.authz.forEach(function(e){return o.addScriptaccounts(P(S(e.acct,20)))}),r.forEach(function(e){return o.addSignatures(e)}),r.push(a);var s=new u;return s.setTransaction(o),Promise.resolve(_(t.node,g.SendTransaction,s)).then(function(t){var r=y();return r.tag=e.tag,r.transactionId=b(t.getHash_asU8()),r})}catch(e){return Promise.reject(e)}}(x,U));case o(x):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new d;return r.setHash(I(e.txId)),Promise.resolve(_(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:b(e.getTransactionId_asU8()),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:e.getPayload_asU8()}})},n})}catch(e){return Promise.reject(e)}}(x,U));case a(x):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new m,n=w(e.payload.code);return r.setScript(n),Promise.resolve(_(t.node,l.ExecuteScriptAtLatestBlock,r)).then(function(t){var r=y();return r.tag=e.tag,r.encodedData=t.getValue_asU8(),r})}catch(e){return Promise.reject(e)}}(x,U));case n(x):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new p,n=P(S(e.acct,20));return r.setAddress(n),Promise.resolve(_(t.node,l.GetAccount,r)).then(function(t){var r=y();r.tag=e.tag;var n=t.getAccount();return r.account={address:b(n.getAddress_asU8()),balance:n.getBalance(),code:n.getCode_asU8(),keys:n.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:b(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}})},r})}catch(e){return Promise.reject(e)}}(x,U));case r(x):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new v;return r.setType(e.eventType),r.setStartHeight(Number(e.bounds.start)),r.setEndHeight(Number(e.bounds.end)),Promise.resolve(_(t.node,l.GetEvents,r)).then(function(t){var r=y();r.tag=e.tag;var n=t.getEventsList();return r.events=n.map(function(e){return{type:e.getType(),transactionHash:b(e.getTransactionHash_asU8()),index:e.getIndex(),payload:e.getPayload_asU8()}}),r})}catch(e){return Promise.reject(e)}}(x,U));case t(x):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new f;return r.setIsSealed(e.isSealed),Promise.resolve(_(t.node,l.GetLatestBlock,r)).then(function(t){var r=t.getBlock(),n=r.getCollectionGuaranteesList(),a=r.getBlockSealsList(),o=r.getSignaturesList(),s=y();return s.tag=e.tag,s.latestBlock={id:b(r.getId_asU8()),parentId:b(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:b(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:a.map(function(e){return{blockId:b(e.getBlockId_asU8()),executionReceiptId:b(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},s})}catch(e){return Promise.reject(e)}}(x,U));case e(x):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new h;return Promise.resolve(_(t.node,l.Ping,r)).then(function(t){var r=y();return r.tag=e.tag,r})}catch(e){return Promise.reject(e)}}(x,U));default:return Promise.resolve(x)}}catch(e){return Promise.reject(e)}};export{A as send}; | ||
//# sourceMappingURL=send.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@improbable-eng/grpc-web"),require("@improbable-eng/grpc-web-node-http-transport"),require("@onflow/interaction"),require("@onflow/protobuf"),require("@onflow/response"),require("@onflow/bytes")):"function"==typeof define&&define.amd?define(["exports","@improbable-eng/grpc-web","@improbable-eng/grpc-web-node-http-transport","@onflow/interaction","@onflow/protobuf","@onflow/response","@onflow/bytes"],t):t(e.send={},e.grpcWeb,e.grpcWebNodeHttpTransport,e.interaction,e.protobuf,e.response,e.bytes)}(this,function(e,t,r,n,s,o,a){var c=function(e,r,n){try{return Promise.resolve(new Promise(function(s,o){t.grpc.unary(r,{request:n,host:e,onEnd:function(e){var r=e.statusMessage;e.status===t.grpc.Code.OK?s(e.message):o(new Error(r))}})}))}catch(e){return Promise.reject(e)}};t.grpc.setDefaultTransport(r.NodeHttpTransport()),e.send=function(e,t){void 0===t&&(t={});try{switch(!0){case n.isTransaction(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=e.authz.map(function(e){var t=new s.AccountSignature;return t.setAccount(a.addressToBuffer(a.bytes(e.acct,20))),t.setSignature(e.signature),t}),n=new s.AccountSignature;n.setAccount(a.addressToBuffer(a.bytes(e.payer.acct,20))),n.setSignature(e.payer.signature);var i=n,u=new s.Transaction;u.setScript(a.scriptToBuffer(e.payload.code)),u.setNonce(e.payload.nonce),u.setComputeLimit(e.payload.limit),u.setReferenceBlockHash(e.payload.ref?a.hashToBuffer(e.payload.ref):null),u.setPayeraccount(a.addressToBuffer(a.bytes(e.payer.acct,20))),e.authz.forEach(function(e){return u.addScriptaccounts(a.addressToBuffer(a.bytes(e.acct,20)))}),r.forEach(function(e){return u.addSignatures(e)}),r.push(i);var f=new s.SendTransactionRequest;return f.setTransaction(u),Promise.resolve(c(t.node,s.ObserveService.SendTransaction,f)).then(function(t){var r=o.response();return r.tag=e.tag,r.transactionHash=a.bufferToHexString(t.getHash_asU8()),r})}catch(e){return Promise.reject(e)}}(e,t));case n.isGetTransaction(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new s.GetTransactionRequest;return r.setHash(a.hashToBuffer(e.txId)),Promise.resolve(c(t.node,s.ObserveService.GetTransaction,r)).then(function(t){var r=t.getTransaction(),n=t.getEventsList(),s=o.response();return s.tag=e.tag,s.transaction={status:r.getStatus(),events:n.map(function(e){return{type:e.getType(),transactionHash:a.bufferToHexString(e.getTransactionHash_asU8()),index:e.getIndex(),payload:e.getPayload_asU8()}})},s})}catch(e){return Promise.reject(e)}}(e,t));case n.isScript(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new s.ExecuteScriptRequest,n=a.scriptToBuffer(e.payload.code);return r.setScript(n),Promise.resolve(c(t.node,s.ObserveService.ExecuteScript,r)).then(function(t){var r=o.response();return r.tag=e.tag,r.encodedData=t.getValue_asU8(),r.decodeInstructions=null,r})}catch(e){return Promise.reject(e)}}(e,t));case n.isGetAccount(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new s.GetAccountRequest,n=a.addressToBuffer(a.bytes(e.acct,20));return r.setAddress(n),Promise.resolve(c(t.node,s.ObserveService.GetAccount,r)).then(function(t){var r=o.response();r.tag=e.tag;var n=t.getAccount();return r.account={address:a.bufferToHexString(n.getAddress_asU8()),balance:n.getBalance(),code:n.getCode_asU8(),keys:n.getKeysList().map(function(e){return{publicKey:a.bufferToHexString(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight()}})},r})}catch(e){return Promise.reject(e)}}(e,t));case n.isGetEvents(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new s.GetEventsRequest;return r.setType(e.eventType),r.setStartBlock(Number(e.bounds.start)),r.setEndBlock(Number(e.bounds.end)),Promise.resolve(c(t.node,s.ObserveService.GetEvents,r)).then(function(t){var r=o.response();r.tag=e.tag;var n=t.getEventsList();return r.events=n.map(function(e){return{type:e.getType(),transactionHash:a.bufferToHexString(e.getTransactionHash_asU8()),index:e.getIndex(),payload:e.getPayload_asU8()}}),r})}catch(e){return Promise.reject(e)}}(e,t));case n.isGetLatestBlock(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new s.GetLatestBlockRequest;return r.setIsSealed(e.isSealed),Promise.resolve(c(t.node,s.ObserveService.GetLatestBlock,r)).then(function(t){var r=t.getBlock(),n=o.response();return n.tag=e.tag,n.latestBlock={blockHash:a.bufferToHexString(r.getHash_asU8()),previousBlockHash:a.bufferToHexString(r.getPreviousblockhash_asU8()),blockNumber:r.getNumber()},n})}catch(e){return Promise.reject(e)}}(e,t));case n.isPing(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new s.PingRequest;return Promise.resolve(c(t.node,s.ObserveService.Ping,r)).then(function(t){var r=o.response();return r.tag=e.tag,r.ping=a.bufferToHexString(t.getAddress_asU8()),r})}catch(e){return Promise.reject(e)}}(e,t));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("@onflow/bytes"),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","@onflow/bytes","@improbable-eng/grpc-web","@improbable-eng/grpc-web-node-http-transport"],t):t((e=e||self).send={},e.interaction,e.protobuf,e.response,e.bytes,e.grpcWeb,e.grpcWebNodeHttpTransport)}(this,function(e,t,r,n,s,o,a){var c=function(e,t,r){try{return Promise.resolve(new Promise(function(n,s){o.grpc.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===o.grpc.Code.OK?n(e.message):s(new Error(t))}})}))}catch(e){return Promise.reject(e)}};o.grpc.setDefaultTransport(a.NodeHttpTransport()),e.send=function(e,o){void 0===o&&(o={});try{switch(!0){case t.isTransaction(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var o=e.authz.map(function(e){var t=new r.AccountSignature;return t.setAccount(s.addressToBuffer(s.bytes(e.acct,20))),t.setSignature(e.signature),t}),a=new r.AccountSignature;a.setAccount(s.addressToBuffer(s.bytes(e.payer.acct,20))),a.setSignature(e.payer.signature);var i=a,u=new r.Transaction;u.setScript(s.scriptToBuffer(e.payload.code)),u.setNonce(e.payload.nonce),u.setComputeLimit(e.payload.limit),u.setReferenceBlockHash(e.payload.ref?s.hashToBuffer(e.payload.ref):null),u.setPayeraccount(s.addressToBuffer(s.bytes(e.payer.acct,20))),e.authz.forEach(function(e){return u.addScriptaccounts(s.addressToBuffer(s.bytes(e.acct,20)))}),o.forEach(function(e){return u.addSignatures(e)}),o.push(i);var g=new r.SendTransactionRequest;return g.setTransaction(u),Promise.resolve(c(t.node,r.ObserveService.SendTransaction,g)).then(function(t){var r=n.response();return r.tag=e.tag,r.transactionId=s.bufferToHexString(t.getHash_asU8()),r})}catch(e){return Promise.reject(e)}}(e,o));case t.isGetTransactionStatus(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var o=new r.GetTransactionResultRequest;return o.setHash(s.hashToBuffer(e.txId)),Promise.resolve(c(t.node,r.AccessAPI.GetTransactionResult,o)).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:s.bufferToHexString(e.getTransactionId_asU8()),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:e.getPayload_asU8()}})},o})}catch(e){return Promise.reject(e)}}(e,o));case t.isScript(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var o=new r.ExecuteScriptAtLatestBlockRequest,a=s.scriptToBuffer(e.payload.code);return o.setScript(a),Promise.resolve(c(t.node,r.AccessAPI.ExecuteScriptAtLatestBlock,o)).then(function(t){var r=n.response();return r.tag=e.tag,r.encodedData=t.getValue_asU8(),r})}catch(e){return Promise.reject(e)}}(e,o));case t.isGetAccount(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var o=new r.GetAccountRequest,a=s.addressToBuffer(s.bytes(e.acct,20));return o.setAddress(a),Promise.resolve(c(t.node,r.AccessAPI.GetAccount,o)).then(function(t){var r=n.response();r.tag=e.tag;var o=t.getAccount();return r.account={address:s.bufferToHexString(o.getAddress_asU8()),balance:o.getBalance(),code:o.getCode_asU8(),keys:o.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:s.bufferToHexString(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber()}})},r})}catch(e){return Promise.reject(e)}}(e,o));case t.isGetEvents(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var o=new r.GetEventsForHeightRange;return o.setType(e.eventType),o.setStartHeight(Number(e.bounds.start)),o.setEndHeight(Number(e.bounds.end)),Promise.resolve(c(t.node,r.AccessAPI.GetEvents,o)).then(function(t){var r=n.response();r.tag=e.tag;var o=t.getEventsList();return r.events=o.map(function(e){return{type:e.getType(),transactionHash:s.bufferToHexString(e.getTransactionHash_asU8()),index:e.getIndex(),payload:e.getPayload_asU8()}}),r})}catch(e){return Promise.reject(e)}}(e,o));case t.isGetLatestBlock(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var o=new r.GetLatestBlockRequest;return o.setIsSealed(e.isSealed),Promise.resolve(c(t.node,r.AccessAPI.GetLatestBlock,o)).then(function(t){var r=t.getBlock(),o=r.getCollectionGuaranteesList(),a=r.getBlockSealsList(),c=r.getSignaturesList(),i=n.response();return i.tag=e.tag,i.latestBlock={id:s.bufferToHexString(r.getId_asU8()),parentId:s.bufferToHexString(r.getParentId_asU8()),height:r.getHeight(),timestamp:r.getTimestamp(),collectionGuarantees:o.map(function(e){return{collectionId:s.bufferToHexString(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:a.map(function(e){return{blockId:s.bufferToHexString(e.getBlockId_asU8()),executionReceiptId:s.bufferToHexString(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:c},i})}catch(e){return Promise.reject(e)}}(e,o));case t.isPing(e):return Promise.resolve(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,o));default:return Promise.resolve(e)}}catch(e){return Promise.reject(e)}}}); | ||
//# sourceMappingURL=send.umd.js.map |
{ | ||
"name": "@onflow/send", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Flow SDK Send", | ||
@@ -21,5 +21,5 @@ "license": "Apache-2.0", | ||
"devDependencies": { | ||
"jest": "25.1.0", | ||
"jest": "25.3.0", | ||
"jest-esm-transformer": "1.0.0", | ||
"microbundle": "0.11.0" | ||
"microbundle": "0.12.0-next.8" | ||
}, | ||
@@ -40,7 +40,7 @@ "source": "src/send.js", | ||
"@improbable-eng/grpc-web-node-http-transport": "^0.12.0", | ||
"@onflow/bytes": "0.0.1", | ||
"@onflow/interaction": "0.0.2", | ||
"@onflow/protobuf": "0.0.3", | ||
"@onflow/response": "0.0.1" | ||
"@onflow/bytes": "0.0.2", | ||
"@onflow/interaction": "0.0.3", | ||
"@onflow/protobuf": "0.1.2", | ||
"@onflow/response": "0.0.2" | ||
} | ||
} |
@@ -1,3 +0,2 @@ | ||
import {ExecuteScriptRequest, ObserveService} from "@onflow/protobuf" | ||
import {get} from "@onflow/interaction" | ||
import {ExecuteScriptAtLatestBlockRequest, AccessAPI} from "@onflow/protobuf" | ||
import {scriptToBuffer} from "@onflow/bytes" | ||
@@ -8,7 +7,7 @@ import {response} from "@onflow/response" | ||
export async function sendExecuteScript(ix, opts = {}) { | ||
const req = new ExecuteScriptRequest() | ||
const req = new ExecuteScriptAtLatestBlockRequest() | ||
const code = scriptToBuffer(ix.payload.code) | ||
req.setScript(code) | ||
const res = await unary(opts.node, ObserveService.ExecuteScript, req) | ||
const res = await unary(opts.node, AccessAPI.ExecuteScriptAtLatestBlock, req) | ||
@@ -18,5 +17,4 @@ let ret = response() | ||
ret.encodedData = res.getValue_asU8() | ||
ret.decodeInstructions = null // TODO: Populate with data the access api will eventually return | ||
return ret | ||
} |
@@ -1,2 +0,2 @@ | ||
import {GetAccountRequest, ObserveService} from "@onflow/protobuf" | ||
import {GetAccountRequest, AccessAPI} from "@onflow/protobuf" | ||
import {response} from "@onflow/response" | ||
@@ -11,3 +11,3 @@ import {unary} from "./unary" | ||
const res = await unary(opts.node, ObserveService.GetAccount, req) | ||
const res = await unary(opts.node, AccessAPI.GetAccount, req) | ||
@@ -23,2 +23,3 @@ let ret = response() | ||
keys: account.getKeysList().map(publicKey => ({ | ||
index: publicKey.getIndex(), | ||
publicKey: bufferToHexString(publicKey.getPublicKey_asU8()), | ||
@@ -28,2 +29,3 @@ signAlgo: publicKey.getSignAlgo(), | ||
weight: publicKey.getWeight(), | ||
sequenceNumber: publicKey.getSequenceNumber() | ||
})), | ||
@@ -30,0 +32,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import {GetEventsRequest, ObserveService} from "@onflow/protobuf" | ||
import {GetEventsForHeightRange, AccessAPI} from "@onflow/protobuf" | ||
import {response} from "@onflow/response" | ||
@@ -7,8 +7,8 @@ import {bufferToHexString} from "@onflow/bytes" | ||
export async function sendGetEvents(ix, opts = {}) { | ||
const req = new GetEventsRequest() | ||
const req = new GetEventsForHeightRange() | ||
req.setType(ix.eventType) | ||
req.setStartBlock(Number(ix.bounds.start)) | ||
req.setEndBlock(Number(ix.bounds.end)) | ||
req.setStartHeight(Number(ix.bounds.start)) | ||
req.setEndHeight(Number(ix.bounds.end)) | ||
const res = await unary(opts.node, ObserveService.GetEvents, req) | ||
const res = await unary(opts.node, AccessAPI.GetEvents, req) | ||
@@ -15,0 +15,0 @@ let ret = response() |
@@ -1,2 +0,2 @@ | ||
import {GetLatestBlockRequest, ObserveService} from "@onflow/protobuf" | ||
import {GetLatestBlockRequest, AccessAPI} from "@onflow/protobuf" | ||
import {response} from "@onflow/response" | ||
@@ -10,14 +10,28 @@ import {bufferToHexString} from "@onflow/bytes" | ||
const res = await unary(opts.node, ObserveService.GetLatestBlock, req) | ||
const res = await unary(opts.node, AccessAPI.GetLatestBlock, req) | ||
const latestBlock = res.getBlock() | ||
const collectionGuarantees = latestBlock.getCollectionGuaranteesList() | ||
const blockSeals = latestBlock.getBlockSealsList() | ||
const signatures = latestBlock.getSignaturesList() | ||
const ret = response() | ||
ret.tag = ix.tag | ||
ret.latestBlock = { | ||
blockHash: bufferToHexString(latestBlock.getHash_asU8()), | ||
previousBlockHash: bufferToHexString( | ||
latestBlock.getPreviousblockhash_asU8() | ||
), | ||
blockNumber: latestBlock.getNumber(), | ||
id: bufferToHexString(latestBlock.getId_asU8()), | ||
parentId: bufferToHexString(latestBlock.getParentId_asU8()), | ||
height: latestBlock.getHeight(), | ||
timestamp: latestBlock.getTimestamp(), | ||
collectionGuarantees: collectionGuarantees.map(collectionGuarantee => ({ | ||
collectionId: bufferToHexString(collectionGuarantee.getCollectionId_asU8()), | ||
signatures: collectionGuarantee.getSignaturesList() | ||
})), | ||
blockSeals: blockSeals.map(blockSeal => ({ | ||
blockId: bufferToHexString(blockSeal.getBlockId_asU8()), | ||
executionReceiptId: bufferToHexString(blockSeal.getExecutionReceiptId_asU8()), | ||
executionReceiptSignatures: blockSeal.getExecutionReceiptSignaturesList(), | ||
resultApprovalSignatures: blockSeal.getResultApprovalSignaturesList(), | ||
})), | ||
signatures: signatures, | ||
} | ||
@@ -24,0 +38,0 @@ |
@@ -1,4 +0,3 @@ | ||
import {ObserveService, PingRequest} from "@onflow/protobuf" | ||
import {AccessAPI, PingRequest} from "@onflow/protobuf" | ||
import {response} from "@onflow/response" | ||
import {bufferToHexString} from "@onflow/bytes" | ||
import {unary} from "./unary" | ||
@@ -9,9 +8,8 @@ | ||
const res = await unary(opts.node, ObserveService.Ping, req) | ||
const res = await unary(opts.node, AccessAPI.Ping, req) | ||
let ret = response() | ||
ret.tag = ix.tag | ||
ret.ping = bufferToHexString(res.getAddress_asU8()) | ||
return ret | ||
} |
@@ -34,5 +34,9 @@ import { | ||
transactionMsg.setComputeLimit(ix.payload.limit) | ||
transactionMsg.setReferenceBlockHash(ix.payload.ref ? hashToBuffer(ix.payload.ref) : null) | ||
transactionMsg.setReferenceBlockHash( | ||
ix.payload.ref ? hashToBuffer(ix.payload.ref) : null | ||
) | ||
transactionMsg.setPayeraccount(addressToBuffer(bytes(ix.payer.acct, 20))) | ||
ix.authz.forEach(a => transactionMsg.addScriptaccounts(addressToBuffer(bytes(a.acct, 20)))) | ||
ix.authz.forEach(a => | ||
transactionMsg.addScriptaccounts(addressToBuffer(bytes(a.acct, 20))) | ||
) | ||
accountSignatures.forEach(accountSignature => | ||
@@ -50,5 +54,5 @@ transactionMsg.addSignatures(accountSignature) | ||
ret.tag = ix.tag | ||
ret.transactionHash = bufferToHexString(res.getHash_asU8()) | ||
ret.transactionId = bufferToHexString(res.getHash_asU8()) | ||
return ret | ||
} |
import { | ||
isTransaction, | ||
isGetTransaction, | ||
isGetTransactionStatus, | ||
isScript, | ||
@@ -11,3 +11,3 @@ isGetAccount, | ||
import {sendTransaction} from "./send-transaction" | ||
import {sendGetTransaction} from "./send-get-transaction" | ||
import {sendGetTransactionStatus} from "./send-get-transaction-status" | ||
import {sendExecuteScript} from "./send-execute-script" | ||
@@ -23,4 +23,4 @@ import {sendGetAccount} from "./send-get-account" | ||
return sendTransaction(ix, opts) | ||
case isGetTransaction(ix): | ||
return sendGetTransaction(ix, opts) | ||
case isGetTransactionStatus(ix): | ||
return sendGetTransactionStatus(ix, opts) | ||
case isScript(ix): | ||
@@ -27,0 +27,0 @@ return sendExecuteScript(ix, opts) |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
663284
23
15728
24
+ Added@onflow/bytes@0.0.2(transitive)
+ Added@onflow/interaction@0.0.3(transitive)
+ Added@onflow/protobuf@0.1.2(transitive)
+ Added@onflow/response@0.0.2(transitive)
- Removed@onflow/bytes@0.0.1(transitive)
- Removed@onflow/interaction@0.0.2(transitive)
- Removed@onflow/protobuf@0.0.3(transitive)
- Removed@onflow/response@0.0.1(transitive)
Updated@onflow/bytes@0.0.2
Updated@onflow/interaction@0.0.3
Updated@onflow/protobuf@0.1.2
Updated@onflow/response@0.0.2