@onflow/send
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -1,2 +0,2 @@ | ||
var e=require("@onflow/interaction"),t=require("@improbable-eng/grpc-web"),r=require("@improbable-eng/grpc-web-node-http-transport"),n=require("@onflow/protobuf"),s=require("@onflow/response"),o=require("@onflow/bytes"),a=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()),exports.send=function(t,r){void 0===r&&(r={});try{switch(!0){case e.isTransaction(t):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=e.signatures.map(function(e){var t=new n.AccountSignature;return t.setAccount(e.acct),t.setSignature(e.signature),t}),c=new n.Transaction;c.setScript(e.code),c.setNonce(e.nonce),c.setComputeLimit(e.computeLimit),c.setPayeraccount(e.payerAuthorization.acct),r.forEach(function(e){return c.addSignatures(e)});var i=new n.SendTransactionRequest;return i.setTransaction(c),Promise.resolve(a(t.node,n.ObserveService.SendTransaction,i)).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)}}(t,r));case e.isGetTransaction(t):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new n.GetTransactionRequest;return r.setHash(e.hash),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)}}(t,r));case e.isScript(t):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new n.ExecuteScriptRequest;return r.setScript(e.code),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)}}(t,r));case e.isGetAccount(t):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new n.GetAccountRequest;return r.setAddress(e.address),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)}}(t,r));case e.isGetEvents(t):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new n.GetEventsRequest;return r.setType(e.eventType),r.setStartBlock(e.startBlock),r.setEndBlock(e.endBlock),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)}}(t,r));case e.isGetLatestBlock(t):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)}}(t,r));case e.isPing(t):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)}}(t,r));default:return Promise.resolve(t)}}catch(e){return Promise.reject(e)}}; | ||
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)}}; | ||
//# sourceMappingURL=send.js.map |
@@ -1,2 +0,2 @@ | ||
import{isTransaction as e,isGetTransaction as t,isScript as r,isGetAccount as n,isGetEvents as o,isGetLatestBlock as s,isPing as a}from"@onflow/interaction";import{grpc as c}from"@improbable-eng/grpc-web";import{NodeHttpTransport as i}from"@improbable-eng/grpc-web-node-http-transport";import{ObserveService as u,AccountSignature as g,Transaction as l,SendTransactionRequest as v,GetTransactionRequest as d,ExecuteScriptRequest as m,GetAccountRequest as h,GetEventsRequest as f,GetLatestBlockRequest as p,PingRequest as P}from"@onflow/protobuf";import{response as y}from"@onflow/response";import{bufferToHexString as w}from"@onflow/bytes";var b=function(e,t,r){try{return Promise.resolve(new Promise(function(n,o){c.unary(t,{request:r,host:e,onEnd:function(e){var t=e.statusMessage;e.status===c.Code.OK?n(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};c.setDefaultTransport(i());var k=function(c,i){void 0===i&&(i={});try{switch(!0){case e(c):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=e.signatures.map(function(e){var t=new g;return t.setAccount(e.acct),t.setSignature(e.signature),t}),n=new l;n.setScript(e.code),n.setNonce(e.nonce),n.setComputeLimit(e.computeLimit),n.setPayeraccount(e.payerAuthorization.acct),r.forEach(function(e){return n.addSignatures(e)});var o=new v;return o.setTransaction(n),Promise.resolve(b(t.node,u.SendTransaction,o)).then(function(t){var r=y();return r.tag=e.tag,r.transactionHash=w(t.getHash_asU8()),r})}catch(e){return Promise.reject(e)}}(c,i));case t(c):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new d;return r.setHash(e.hash),Promise.resolve(b(t.node,u.GetTransaction,r)).then(function(t){var r=t.getTransaction(),n=t.getEventsList(),o=y();return o.tag=e.tag,o.transaction={status:r.getStatus(),events:n.map(function(e){return{type:e.getType(),transactionHash:w(e.getTransactionHash_asU8()),index:e.getIndex(),payload:e.getPayload_asU8()}})},o})}catch(e){return Promise.reject(e)}}(c,i));case r(c):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new m;return r.setScript(e.code),Promise.resolve(b(t.node,u.ExecuteScript,r)).then(function(t){var r=y();return r.tag=e.tag,r.encodedData=t.getValue_asU8(),r.decodeInstructions=null,r})}catch(e){return Promise.reject(e)}}(c,i));case n(c):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new h;return r.setAddress(e.address),Promise.resolve(b(t.node,u.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{publicKey:w(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight()}})},r})}catch(e){return Promise.reject(e)}}(c,i));case o(c):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new f;return r.setType(e.eventType),r.setStartBlock(e.startBlock),r.setEndBlock(e.endBlock),Promise.resolve(b(t.node,u.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:w(e.getTransactionHash_asU8()),index:e.getIndex(),payload:e.getPayload_asU8()}}),r})}catch(e){return Promise.reject(e)}}(c,i));case s(c):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new p;return r.setIsSealed(e.isSealed),Promise.resolve(b(t.node,u.GetLatestBlock,r)).then(function(t){var r=t.getBlock(),n=y();return n.tag=e.tag,n.latestBlock={blockHash:w(r.getHash_asU8()),previousBlockHash:w(r.getPreviousblockhash_asU8()),blockNumber:r.getNumber()},n})}catch(e){return Promise.reject(e)}}(c,i));case a(c):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new P;return Promise.resolve(b(t.node,u.Ping,r)).then(function(t){var r=y();return r.tag=e.tag,r.ping=w(t.getAddress_asU8()),r})}catch(e){return Promise.reject(e)}}(c,i));default:return Promise.resolve(c)}}catch(e){return Promise.reject(e)}};export{k as send}; | ||
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}; | ||
//# sourceMappingURL=send.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@onflow/interaction"),require("@improbable-eng/grpc-web"),require("@improbable-eng/grpc-web-node-http-transport"),require("@onflow/protobuf"),require("@onflow/response"),require("@onflow/bytes")):"function"==typeof define&&define.amd?define(["exports","@onflow/interaction","@improbable-eng/grpc-web","@improbable-eng/grpc-web-node-http-transport","@onflow/protobuf","@onflow/response","@onflow/bytes"],t):t(e.send={},e.interaction,e.grpcWeb,e.grpcWebNodeHttpTransport,e.protobuf,e.response,e.bytes)}(this,function(e,t,r,n,s,o,a){var i=function(e,t,n){try{return Promise.resolve(new Promise(function(s,o){r.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===r.grpc.Code.OK?s(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};r.grpc.setDefaultTransport(n.NodeHttpTransport()),e.send=function(e,r){void 0===r&&(r={});try{switch(!0){case t.isTransaction(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=e.signatures.map(function(e){var t=new s.AccountSignature;return t.setAccount(e.acct),t.setSignature(e.signature),t}),n=new s.Transaction;n.setScript(e.code),n.setNonce(e.nonce),n.setComputeLimit(e.computeLimit),n.setPayeraccount(e.payerAuthorization.acct),r.forEach(function(e){return n.addSignatures(e)});var c=new s.SendTransactionRequest;return c.setTransaction(n),Promise.resolve(i(t.node,s.ObserveService.SendTransaction,c)).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,r));case t.isGetTransaction(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new s.GetTransactionRequest;return r.setHash(e.hash),Promise.resolve(i(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,r));case t.isScript(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new s.ExecuteScriptRequest;return r.setScript(e.code),Promise.resolve(i(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,r));case t.isGetAccount(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new s.GetAccountRequest;return r.setAddress(e.address),Promise.resolve(i(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,r));case t.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(e.startBlock),r.setEndBlock(e.endBlock),Promise.resolve(i(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,r));case t.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(i(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,r));case t.isPing(e):return Promise.resolve(function(e,t){void 0===t&&(t={});try{var r=new s.PingRequest;return Promise.resolve(i(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,r));default:return Promise.resolve(e)}}catch(e){return Promise.reject(e)}}}); | ||
!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)}}}); | ||
//# sourceMappingURL=send.umd.js.map |
{ | ||
"name": "@onflow/send", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Flow SDK Send", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
import {ExecuteScriptRequest, ObserveService} from "@onflow/protobuf" | ||
import {get} from "@onflow/interaction" | ||
import {scriptToBuffer} from "@onflow/bytes" | ||
import {response} from "@onflow/response" | ||
@@ -7,3 +9,4 @@ import {unary} from "./unary" | ||
const req = new ExecuteScriptRequest() | ||
req.setScript(ix.code) | ||
const code = scriptToBuffer(ix.payload.code) | ||
req.setScript(code) | ||
@@ -10,0 +13,0 @@ const res = await unary(opts.node, ObserveService.ExecuteScript, req) |
import {GetAccountRequest, ObserveService} from "@onflow/protobuf" | ||
import {response} from "@onflow/response" | ||
import {unary} from "./unary" | ||
import {bufferToHexString} from "@onflow/bytes" | ||
import {bufferToHexString, addressToBuffer, bytes} from "@onflow/bytes" | ||
export async function sendGetAccount(ix, opts = {}) { | ||
const req = new GetAccountRequest() | ||
req.setAddress(ix.address) | ||
const address = addressToBuffer(bytes(ix.acct, 20)) | ||
req.setAddress(address) | ||
@@ -10,0 +11,0 @@ const res = await unary(opts.node, ObserveService.GetAccount, req) |
@@ -9,4 +9,4 @@ import {GetEventsRequest, ObserveService} from "@onflow/protobuf" | ||
req.setType(ix.eventType) | ||
req.setStartBlock(ix.startBlock) | ||
req.setEndBlock(ix.endBlock) | ||
req.setStartBlock(Number(ix.bounds.start)) | ||
req.setEndBlock(Number(ix.bounds.end)) | ||
@@ -13,0 +13,0 @@ const res = await unary(opts.node, ObserveService.GetEvents, req) |
import {ObserveService, GetTransactionRequest} from "@onflow/protobuf" | ||
import {response} from "@onflow/response" | ||
import {bufferToHexString} from "@onflow/bytes" | ||
import {bufferToHexString, hashToBuffer} from "@onflow/bytes" | ||
import {unary} from "./unary" | ||
@@ -8,3 +8,3 @@ | ||
const req = new GetTransactionRequest() | ||
req.setHash(ix.hash) | ||
req.setHash(hashToBuffer(ix.txId)) | ||
@@ -11,0 +11,0 @@ const res = await unary(opts.node, ObserveService.GetTransaction, req) |
@@ -8,21 +8,35 @@ import { | ||
import {response} from "@onflow/response" | ||
import {bufferToHexString} from "@onflow/bytes" | ||
import { | ||
bufferToHexString, | ||
scriptToBuffer, | ||
hashToBuffer, | ||
addressToBuffer, | ||
bytes, | ||
} from "@onflow/bytes" | ||
import {unary} from "./unary" | ||
export async function sendTransaction(ix, opts = {}) { | ||
const accountSignatures = ix.signatures.map(signature => { | ||
const accountSignatures = ix.authz.map(sig => { | ||
const accountSig = new AccountSignature() | ||
accountSig.setAccount(signature.acct) | ||
accountSig.setSignature(signature.signature) | ||
accountSig.setAccount(addressToBuffer(bytes(sig.acct, 20))) | ||
accountSig.setSignature(sig.signature) | ||
return accountSig | ||
}) | ||
const payerSig = new AccountSignature() | ||
payerSig.setAccount(addressToBuffer(bytes(ix.payer.acct, 20))) | ||
payerSig.setSignature(ix.payer.signature) | ||
const payerSignature = payerSig | ||
const transactionMsg = new TransactionMessage() | ||
transactionMsg.setScript(ix.code) | ||
transactionMsg.setNonce(ix.nonce) | ||
transactionMsg.setComputeLimit(ix.computeLimit) | ||
transactionMsg.setPayeraccount(ix.payerAuthorization.acct) | ||
transactionMsg.setScript(scriptToBuffer(ix.payload.code)) | ||
transactionMsg.setNonce(ix.payload.nonce) | ||
transactionMsg.setComputeLimit(ix.payload.limit) | ||
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)))) | ||
accountSignatures.forEach(accountSignature => | ||
transactionMsg.addSignatures(accountSignature) | ||
) | ||
accountSignatures.push(payerSignature) | ||
@@ -29,0 +43,0 @@ const req = new SendTransactionRequest() |
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
631018
15661