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

@onflow/transport-grpc

Package Overview
Dependencies
Maintainers
11
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/transport-grpc - npm Package Compare versions

Comparing version 1.2.0-alpha.1 to 1.2.0-alpha.2

6

CHANGELOG.md
# @onflow/transport-grpc
## 1.2.0-alpha.2
### Patch Changes
- [#1608](https://github.com/onflow/fcl-js/pull/1608) [`0ec0c5d4`](https://github.com/onflow/fcl-js/commit/0ec0c5d46b780e2b277846f9271ab311aa048b19) Thanks [@nialexsan](https://github.com/nialexsan)! - prep for react-native package
## 1.2.0-alpha.1

@@ -4,0 +10,0 @@

1938

dist/sdk-send-grpc.js

@@ -5,4 +5,4 @@ 'use strict';

var _regeneratorRuntime = require('@babel/runtime/helpers/regeneratorRuntime');
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
var _regeneratorRuntime = require('@babel/runtime/regenerator');
var utilInvariant = require('@onflow/util-invariant');

@@ -19,4 +19,4 @@ var protobuf = require('@onflow/protobuf');

var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

@@ -30,39 +30,33 @@ var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);

}
function _unary() {
_unary = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(host, method, request, context) {
_unary = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(host, method, request, context) {
var metadataFromConfig;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
utilInvariant.invariant(context.config, "SDK GRPC Unary Error: context.config must be defined.");
_context.next = 3;
return context.config().get("grpc.metadata", {});
case 3:
metadataFromConfig = _context.sent;
return _context.abrupt("return", new Promise(function (resolve, reject) {
grpcWeb.grpc.unary(method, {
request: request,
host: host,
metadata: new grpcWeb.grpc.Metadata(metadataFromConfig),
onEnd: function onEnd(_ref) {
var status = _ref.status,
statusMessage = _ref.statusMessage,
message = _ref.message;
if (status === grpcWeb.grpc.Code.OK) {
resolve(message);
} else {
reject(new Error(statusMessage));
}
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
utilInvariant.invariant(context.config, "SDK GRPC Unary Error: context.config must be defined.");
_context.next = 3;
return context.config().get("grpc.metadata", {});
case 3:
metadataFromConfig = _context.sent;
return _context.abrupt("return", new Promise(function (resolve, reject) {
grpcWeb.grpc.unary(method, {
request: request,
host: host,
metadata: new grpcWeb.grpc.Metadata(metadataFromConfig),
onEnd: function onEnd(_ref) {
var status = _ref.status,
statusMessage = _ref.statusMessage,
message = _ref.message;
if (status === grpcWeb.grpc.Code.OK) {
resolve(message);
} else {
reject(new Error(statusMessage));
}
});
}));
case 5:
case "end":
return _context.stop();
}
}
});
}));
case 5:
case "end":
return _context.stop();
}

@@ -77,37 +71,30 @@ }, _callee);

};
var hexBuffer$7 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendExecuteScriptAtBlockIDRequest(_x, _x2, _x3) {
return _sendExecuteScriptAtBlockIDRequest.apply(this, arguments);
}
function _sendExecuteScriptAtBlockIDRequest() {
_sendExecuteScriptAtBlockIDRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(ix, context, opts) {
_sendExecuteScriptAtBlockIDRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(ix, context, opts) {
var unary$1, req, code, res;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.ExecuteScriptAtBlockIDRequest();
req.setBlockId(hexBuffer$7(ix.block.id, context));
code = context.Buffer.from(ix.message.cadence, "utf8");
ix.message.arguments.forEach(function (arg) {
return req.addArguments(argumentBuffer$1(ix.arguments[arg].asArgument, context));
});
req.setScript(code);
_context.next = 8;
return unary$1(opts.node, protobuf.AccessAPI.ExecuteScriptAtBlockID, req, context);
case 8:
res = _context.sent;
return _context.abrupt("return", constructResponse$4(ix, context, res));
case 10:
case "end":
return _context.stop();
}
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.ExecuteScriptAtBlockIDRequest();
req.setBlockId(hexBuffer$7(ix.block.id, context));
code = context.Buffer.from(ix.message.cadence, "utf8");
ix.message.arguments.forEach(function (arg) {
return req.addArguments(argumentBuffer$1(ix.arguments[arg].asArgument, context));
});
req.setScript(code);
_context.next = 8;
return unary$1(opts.node, protobuf.AccessAPI.ExecuteScriptAtBlockID, req, context);
case 8:
res = _context.sent;
return _context.abrupt("return", constructResponse$4(ix, context, res));
case 10:
case "end":
return _context.stop();
}

@@ -118,33 +105,27 @@ }, _callee);

}
function sendExecuteScriptAtBlockHeightRequest(_x4, _x5, _x6) {
return _sendExecuteScriptAtBlockHeightRequest.apply(this, arguments);
}
function _sendExecuteScriptAtBlockHeightRequest() {
_sendExecuteScriptAtBlockHeightRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(ix, context, opts) {
_sendExecuteScriptAtBlockHeightRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee2(ix, context, opts) {
var unary$1, req, code, res;
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.ExecuteScriptAtBlockHeightRequest();
req.setBlockHeight(Number(ix.block.height));
code = context.Buffer.from(ix.message.cadence, "utf8");
ix.message.arguments.forEach(function (arg) {
return req.addArguments(argumentBuffer$1(ix.arguments[arg].asArgument, context));
});
req.setScript(code);
_context2.next = 8;
return unary$1(opts.node, protobuf.AccessAPI.ExecuteScriptAtBlockHeight, req, context);
case 8:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$4(ix, context, res));
case 10:
case "end":
return _context2.stop();
}
return _regeneratorRuntime__default["default"]().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.ExecuteScriptAtBlockHeightRequest();
req.setBlockHeight(Number(ix.block.height));
code = context.Buffer.from(ix.message.cadence, "utf8");
ix.message.arguments.forEach(function (arg) {
return req.addArguments(argumentBuffer$1(ix.arguments[arg].asArgument, context));
});
req.setScript(code);
_context2.next = 8;
return unary$1(opts.node, protobuf.AccessAPI.ExecuteScriptAtBlockHeight, req, context);
case 8:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$4(ix, context, res));
case 10:
case "end":
return _context2.stop();
}

@@ -155,32 +136,26 @@ }, _callee2);

}
function sendExecuteScriptAtLatestBlockRequest(_x7, _x8, _x9) {
return _sendExecuteScriptAtLatestBlockRequest.apply(this, arguments);
}
function _sendExecuteScriptAtLatestBlockRequest() {
_sendExecuteScriptAtLatestBlockRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(ix, context, opts) {
_sendExecuteScriptAtLatestBlockRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee3(ix, context, opts) {
var unary$1, req, code, res;
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.ExecuteScriptAtLatestBlockRequest();
code = context.Buffer.from(ix.message.cadence, "utf8");
ix.message.arguments.forEach(function (arg) {
return req.addArguments(argumentBuffer$1(ix.arguments[arg].asArgument, context));
});
req.setScript(code);
_context3.next = 7;
return unary$1(opts.node, protobuf.AccessAPI.ExecuteScriptAtLatestBlock, req, context);
case 7:
res = _context3.sent;
return _context3.abrupt("return", constructResponse$4(ix, context, res));
case 9:
case "end":
return _context3.stop();
}
return _regeneratorRuntime__default["default"]().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.ExecuteScriptAtLatestBlockRequest();
code = context.Buffer.from(ix.message.cadence, "utf8");
ix.message.arguments.forEach(function (arg) {
return req.addArguments(argumentBuffer$1(ix.arguments[arg].asArgument, context));
});
req.setScript(code);
_context3.next = 7;
return unary$1(opts.node, protobuf.AccessAPI.ExecuteScriptAtLatestBlock, req, context);
case 7:
res = _context3.sent;
return _context3.abrupt("return", constructResponse$4(ix, context, res));
case 9:
case "end":
return _context3.stop();
}

@@ -191,3 +166,2 @@ }, _callee3);

}
function constructResponse$4(ix, context, res) {

@@ -199,61 +173,47 @@ var ret = context.response();

}
function sendExecuteScript(_x10) {
return _sendExecuteScript.apply(this, arguments);
}
function _sendExecuteScript() {
_sendExecuteScript = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(ix) {
_sendExecuteScript = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee4(ix) {
var context,
opts,
_args4 = arguments;
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
context = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
opts = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Execute Script Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Execute Script Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Execute Script Error: context.Buffer must be defined.");
_context4.next = 7;
return ix;
case 7:
ix = _context4.sent;
if (!ix.block.id) {
_context4.next = 14;
break;
}
_context4.next = 11;
return sendExecuteScriptAtBlockIDRequest(ix, context, opts);
case 11:
return _context4.abrupt("return", _context4.sent);
case 14:
if (!ix.block.height) {
_context4.next = 20;
break;
}
_context4.next = 17;
return sendExecuteScriptAtBlockHeightRequest(ix, context, opts);
case 17:
return _context4.abrupt("return", _context4.sent);
case 20:
_context4.next = 22;
return sendExecuteScriptAtLatestBlockRequest(ix, context, opts);
case 22:
return _context4.abrupt("return", _context4.sent);
case 23:
case "end":
return _context4.stop();
}
opts,
_args4 = arguments;
return _regeneratorRuntime__default["default"]().wrap(function _callee4$(_context4) {
while (1) switch (_context4.prev = _context4.next) {
case 0:
context = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
opts = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Execute Script Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Execute Script Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Execute Script Error: context.Buffer must be defined.");
_context4.next = 7;
return ix;
case 7:
ix = _context4.sent;
if (!ix.block.id) {
_context4.next = 14;
break;
}
_context4.next = 11;
return sendExecuteScriptAtBlockIDRequest(ix, context, opts);
case 11:
return _context4.abrupt("return", _context4.sent);
case 14:
if (!ix.block.height) {
_context4.next = 20;
break;
}
_context4.next = 17;
return sendExecuteScriptAtBlockHeightRequest(ix, context, opts);
case 17:
return _context4.abrupt("return", _context4.sent);
case 20:
_context4.next = 22;
return sendExecuteScriptAtLatestBlockRequest(ix, context, opts);
case 22:
return _context4.abrupt("return", _context4.sent);
case 23:
case "end":
return _context4.stop();
}

@@ -268,11 +228,8 @@ }, _callee4);

};
var paddedHexBuffer$1 = function paddedHexBuffer(hex, pad, context) {
return context.Buffer.from(hex.padStart(pad * 2, 0), "hex");
};
var addressBuffer$1 = function addressBuffer(addr, context) {
return paddedHexBuffer$1(addr, 8, context);
};
var HashAlgorithmNames = {

@@ -290,29 +247,23 @@ 1: "SHA2_256",

};
function sendGetAccountAtBlockHeightRequest(_x, _x2, _x3) {
return _sendGetAccountAtBlockHeightRequest.apply(this, arguments);
}
function _sendGetAccountAtBlockHeightRequest() {
_sendGetAccountAtBlockHeightRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(ix, context, opts) {
_sendGetAccountAtBlockHeightRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetAccountAtBlockHeightRequest();
req.setBlockHeight(Number(ix.block.height));
req.setAddress(addressBuffer$1(utilAddress.sansPrefix(ix.account.addr), context));
_context.next = 6;
return unary$1(opts.node, protobuf.AccessAPI.GetAccountAtBlockHeight, req, context);
case 6:
res = _context.sent;
return _context.abrupt("return", constructResponse$3(ix, context, res));
case 8:
case "end":
return _context.stop();
}
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetAccountAtBlockHeightRequest();
req.setBlockHeight(Number(ix.block.height));
req.setAddress(addressBuffer$1(utilAddress.sansPrefix(ix.account.addr), context));
_context.next = 6;
return unary$1(opts.node, protobuf.AccessAPI.GetAccountAtBlockHeight, req, context);
case 6:
res = _context.sent;
return _context.abrupt("return", constructResponse$3(ix, context, res));
case 8:
case "end":
return _context.stop();
}

@@ -323,28 +274,22 @@ }, _callee);

}
function sendGetAccountAtLatestBlockRequest(_x4, _x5, _x6) {
return _sendGetAccountAtLatestBlockRequest.apply(this, arguments);
}
function _sendGetAccountAtLatestBlockRequest() {
_sendGetAccountAtLatestBlockRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(ix, context, opts) {
_sendGetAccountAtLatestBlockRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee2(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetAccountAtLatestBlockRequest();
req.setAddress(addressBuffer$1(utilAddress.sansPrefix(ix.account.addr), context));
_context2.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetAccountAtLatestBlock, req, context);
case 5:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$3(ix, context, res));
case 7:
case "end":
return _context2.stop();
}
return _regeneratorRuntime__default["default"]().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetAccountAtLatestBlockRequest();
req.setAddress(addressBuffer$1(utilAddress.sansPrefix(ix.account.addr), context));
_context2.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetAccountAtLatestBlock, req, context);
case 5:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$3(ix, context, res));
case 7:
case "end":
return _context2.stop();
}

@@ -355,3 +300,2 @@ }, _callee2);

}
function constructResponse$3(ix, context, res) {

@@ -388,49 +332,38 @@ var ret = context.response();

}
function sendGetAccount(_x7) {
return _sendGetAccount.apply(this, arguments);
}
function _sendGetAccount() {
_sendGetAccount = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(ix) {
_sendGetAccount = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee3(ix) {
var context,
opts,
_args3 = arguments;
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
context = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
opts = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Account Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Get Account Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Get Account Error: context.Buffer must be defined.");
_context3.next = 7;
return ix;
case 7:
ix = _context3.sent;
if (!(ix.block.height !== null)) {
_context3.next = 14;
break;
}
_context3.next = 11;
return sendGetAccountAtBlockHeightRequest(ix, context, opts);
case 11:
return _context3.abrupt("return", _context3.sent);
case 14:
_context3.next = 16;
return sendGetAccountAtLatestBlockRequest(ix, context, opts);
case 16:
return _context3.abrupt("return", _context3.sent);
case 17:
case "end":
return _context3.stop();
}
opts,
_args3 = arguments;
return _regeneratorRuntime__default["default"]().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
context = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
opts = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Account Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Get Account Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Get Account Error: context.Buffer must be defined.");
_context3.next = 7;
return ix;
case 7:
ix = _context3.sent;
if (!(ix.block.height !== null)) {
_context3.next = 14;
break;
}
_context3.next = 11;
return sendGetAccountAtBlockHeightRequest(ix, context, opts);
case 11:
return _context3.abrupt("return", _context3.sent);
case 14:
_context3.next = 16;
return sendGetAccountAtLatestBlockRequest(ix, context, opts);
case 16:
return _context3.abrupt("return", _context3.sent);
case 17:
case "end":
return _context3.stop();
}

@@ -445,32 +378,25 @@ }, _callee3);

};
var hexBuffer$6 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendGetBlockHeaderByIDRequest(_x, _x2, _x3) {
return _sendGetBlockHeaderByIDRequest.apply(this, arguments);
}
function _sendGetBlockHeaderByIDRequest() {
_sendGetBlockHeaderByIDRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(ix, context, opts) {
_sendGetBlockHeaderByIDRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetBlockHeaderByIDRequest();
req.setId(hexBuffer$6(ix.block.id, context));
_context.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetBlockHeaderByID, req, context);
case 5:
res = _context.sent;
return _context.abrupt("return", constructResponse$2(ix, context, res));
case 7:
case "end":
return _context.stop();
}
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetBlockHeaderByIDRequest();
req.setId(hexBuffer$6(ix.block.id, context));
_context.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetBlockHeaderByID, req, context);
case 5:
res = _context.sent;
return _context.abrupt("return", constructResponse$2(ix, context, res));
case 7:
case "end":
return _context.stop();
}

@@ -481,28 +407,22 @@ }, _callee);

}
function sendGetBlockHeaderByHeightRequest(_x4, _x5, _x6) {
return _sendGetBlockHeaderByHeightRequest.apply(this, arguments);
}
function _sendGetBlockHeaderByHeightRequest() {
_sendGetBlockHeaderByHeightRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(ix, context, opts) {
_sendGetBlockHeaderByHeightRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee2(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetBlockHeaderByHeightRequest();
req.setHeight(Number(ix.block.height));
_context2.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetBlockHeaderByHeight, req, context);
case 5:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$2(ix, context, res));
case 7:
case "end":
return _context2.stop();
}
return _regeneratorRuntime__default["default"]().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetBlockHeaderByHeightRequest();
req.setHeight(Number(ix.block.height));
_context2.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetBlockHeaderByHeight, req, context);
case 5:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$2(ix, context, res));
case 7:
case "end":
return _context2.stop();
}

@@ -513,34 +433,25 @@ }, _callee2);

}
function sendGetLatestBlockHeaderRequest(_x7, _x8, _x9) {
return _sendGetLatestBlockHeaderRequest.apply(this, arguments);
}
function _sendGetLatestBlockHeaderRequest() {
_sendGetLatestBlockHeaderRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(ix, context, opts) {
_sendGetLatestBlockHeaderRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee3(ix, context, opts) {
var _ix$block;
var unary$1, req, res;
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetLatestBlockHeaderRequest();
if ((_ix$block = ix.block) !== null && _ix$block !== void 0 && _ix$block.isSealed) {
req.setIsSealed(ix.block.isSealed);
}
_context3.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetLatestBlockHeader, req, context);
case 5:
res = _context3.sent;
return _context3.abrupt("return", constructResponse$2(ix, context, res));
case 7:
case "end":
return _context3.stop();
}
return _regeneratorRuntime__default["default"]().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetLatestBlockHeaderRequest();
if ((_ix$block = ix.block) !== null && _ix$block !== void 0 && _ix$block.isSealed) {
req.setIsSealed(ix.block.isSealed);
}
_context3.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetLatestBlockHeader, req, context);
case 5:
res = _context3.sent;
return _context3.abrupt("return", constructResponse$2(ix, context, res));
case 7:
case "end":
return _context3.stop();
}

@@ -551,3 +462,2 @@ }, _callee3);

}
function constructResponse$2(ix, context, res) {

@@ -565,65 +475,51 @@ var blockHeader = res.getBlock();

}
function sendGetBlockHeader(_x10) {
return _sendGetBlockHeader.apply(this, arguments);
}
function _sendGetBlockHeader() {
_sendGetBlockHeader = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(ix) {
_sendGetBlockHeader = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee4(ix) {
var context,
opts,
interactionHasBlockID,
interactionHasBlockHeight,
_args4 = arguments;
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
context = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
opts = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Block Header Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Block Header Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Get Block Header Error: context.Buffer must be defined.");
_context4.next = 7;
return ix;
case 7:
ix = _context4.sent;
interactionHasBlockID = ix.block.id !== null;
interactionHasBlockHeight = ix.block.height !== null;
if (!interactionHasBlockID) {
_context4.next = 16;
break;
}
_context4.next = 13;
return sendGetBlockHeaderByIDRequest(ix, context, opts);
case 13:
return _context4.abrupt("return", _context4.sent);
case 16:
if (!interactionHasBlockHeight) {
_context4.next = 22;
break;
}
_context4.next = 19;
return sendGetBlockHeaderByHeightRequest(ix, context, opts);
case 19:
return _context4.abrupt("return", _context4.sent);
case 22:
_context4.next = 24;
return sendGetLatestBlockHeaderRequest(ix, context, opts);
case 24:
return _context4.abrupt("return", _context4.sent);
case 25:
case "end":
return _context4.stop();
}
opts,
interactionHasBlockID,
interactionHasBlockHeight,
_args4 = arguments;
return _regeneratorRuntime__default["default"]().wrap(function _callee4$(_context4) {
while (1) switch (_context4.prev = _context4.next) {
case 0:
context = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
opts = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Block Header Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Block Header Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Get Block Header Error: context.Buffer must be defined.");
_context4.next = 7;
return ix;
case 7:
ix = _context4.sent;
interactionHasBlockID = ix.block.id !== null;
interactionHasBlockHeight = ix.block.height !== null;
if (!interactionHasBlockID) {
_context4.next = 16;
break;
}
_context4.next = 13;
return sendGetBlockHeaderByIDRequest(ix, context, opts);
case 13:
return _context4.abrupt("return", _context4.sent);
case 16:
if (!interactionHasBlockHeight) {
_context4.next = 22;
break;
}
_context4.next = 19;
return sendGetBlockHeaderByHeightRequest(ix, context, opts);
case 19:
return _context4.abrupt("return", _context4.sent);
case 22:
_context4.next = 24;
return sendGetLatestBlockHeaderRequest(ix, context, opts);
case 24:
return _context4.abrupt("return", _context4.sent);
case 25:
case "end":
return _context4.stop();
}

@@ -638,32 +534,25 @@ }, _callee4);

};
var hexBuffer$5 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendGetBlockByIDRequest(_x, _x2, _x3) {
return _sendGetBlockByIDRequest.apply(this, arguments);
}
function _sendGetBlockByIDRequest() {
_sendGetBlockByIDRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(ix, context, opts) {
_sendGetBlockByIDRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetBlockByIDRequest();
req.setId(hexBuffer$5(ix.block.id, context));
_context.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetBlockByID, req, context);
case 5:
res = _context.sent;
return _context.abrupt("return", constructResponse$1(ix, context, res));
case 7:
case "end":
return _context.stop();
}
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetBlockByIDRequest();
req.setId(hexBuffer$5(ix.block.id, context));
_context.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetBlockByID, req, context);
case 5:
res = _context.sent;
return _context.abrupt("return", constructResponse$1(ix, context, res));
case 7:
case "end":
return _context.stop();
}

@@ -674,28 +563,22 @@ }, _callee);

}
function sendGetBlockByHeightRequest(_x4, _x5, _x6) {
return _sendGetBlockByHeightRequest.apply(this, arguments);
}
function _sendGetBlockByHeightRequest() {
_sendGetBlockByHeightRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(ix, context, opts) {
_sendGetBlockByHeightRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee2(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetBlockByHeightRequest();
req.setHeight(Number(ix.block.height));
_context2.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetBlockByHeight, req, context);
case 5:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$1(ix, context, res));
case 7:
case "end":
return _context2.stop();
}
return _regeneratorRuntime__default["default"]().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetBlockByHeightRequest();
req.setHeight(Number(ix.block.height));
_context2.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetBlockByHeight, req, context);
case 5:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$1(ix, context, res));
case 7:
case "end":
return _context2.stop();
}

@@ -706,34 +589,25 @@ }, _callee2);

}
function sendGetBlockRequest(_x7, _x8, _x9) {
return _sendGetBlockRequest.apply(this, arguments);
}
function _sendGetBlockRequest() {
_sendGetBlockRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(ix, context, opts) {
_sendGetBlockRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee3(ix, context, opts) {
var _ix$block;
var unary$1, req, res;
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetLatestBlockRequest();
if ((_ix$block = ix.block) !== null && _ix$block !== void 0 && _ix$block.isSealed) {
req.setIsSealed(ix.block.isSealed);
}
_context3.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetLatestBlock, req, context);
case 5:
res = _context3.sent;
return _context3.abrupt("return", constructResponse$1(ix, context, res));
case 7:
case "end":
return _context3.stop();
}
return _regeneratorRuntime__default["default"]().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetLatestBlockRequest();
if ((_ix$block = ix.block) !== null && _ix$block !== void 0 && _ix$block.isSealed) {
req.setIsSealed(ix.block.isSealed);
}
_context3.next = 5;
return unary$1(opts.node, protobuf.AccessAPI.GetLatestBlock, req, context);
case 5:
res = _context3.sent;
return _context3.abrupt("return", constructResponse$1(ix, context, res));
case 7:
case "end":
return _context3.stop();
}

@@ -744,3 +618,2 @@ }, _callee3);

}
function constructResponse$1(ix, context, res) {

@@ -774,65 +647,51 @@ var block = res.getBlock();

}
function sendGetBlock(_x10) {
return _sendGetBlock.apply(this, arguments);
}
function _sendGetBlock() {
_sendGetBlock = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee4(ix) {
_sendGetBlock = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee4(ix) {
var context,
opts,
interactionHasBlockID,
interactionHasBlockHeight,
_args4 = arguments;
return _regeneratorRuntime__default["default"].wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
context = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
opts = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Block Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Block Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Get Block Error: context.Buffer must be defined.");
_context4.next = 7;
return ix;
case 7:
ix = _context4.sent;
interactionHasBlockID = ix.block.id !== null;
interactionHasBlockHeight = ix.block.height !== null;
if (!interactionHasBlockID) {
_context4.next = 16;
break;
}
_context4.next = 13;
return sendGetBlockByIDRequest(ix, context, opts);
case 13:
return _context4.abrupt("return", _context4.sent);
case 16:
if (!interactionHasBlockHeight) {
_context4.next = 22;
break;
}
_context4.next = 19;
return sendGetBlockByHeightRequest(ix, context, opts);
case 19:
return _context4.abrupt("return", _context4.sent);
case 22:
_context4.next = 24;
return sendGetBlockRequest(ix, context, opts);
case 24:
return _context4.abrupt("return", _context4.sent);
case 25:
case "end":
return _context4.stop();
}
opts,
interactionHasBlockID,
interactionHasBlockHeight,
_args4 = arguments;
return _regeneratorRuntime__default["default"]().wrap(function _callee4$(_context4) {
while (1) switch (_context4.prev = _context4.next) {
case 0:
context = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
opts = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Block Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Block Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Get Block Error: context.Buffer must be defined.");
_context4.next = 7;
return ix;
case 7:
ix = _context4.sent;
interactionHasBlockID = ix.block.id !== null;
interactionHasBlockHeight = ix.block.height !== null;
if (!interactionHasBlockID) {
_context4.next = 16;
break;
}
_context4.next = 13;
return sendGetBlockByIDRequest(ix, context, opts);
case 13:
return _context4.abrupt("return", _context4.sent);
case 16:
if (!interactionHasBlockHeight) {
_context4.next = 22;
break;
}
_context4.next = 19;
return sendGetBlockByHeightRequest(ix, context, opts);
case 19:
return _context4.abrupt("return", _context4.sent);
case 22:
_context4.next = 24;
return sendGetBlockRequest(ix, context, opts);
case 24:
return _context4.abrupt("return", _context4.sent);
case 25:
case "end":
return _context4.stop();
}

@@ -847,58 +706,50 @@ }, _callee4);

};
var hexBuffer$4 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendGetCollection(_x) {
return _sendGetCollection.apply(this, arguments);
}
function _sendGetCollection() {
_sendGetCollection = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(ix) {
_sendGetCollection = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(ix) {
var context,
opts,
unary$1,
req,
res,
collection,
ret,
_args = arguments;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Collection Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Collection Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Get Collection Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
req = new protobuf.GetCollectionByIDRequest();
req.setId(hexBuffer$4(ix.collection.id, context));
_context.next = 13;
return unary$1(opts.node, protobuf.AccessAPI.GetCollectionByID, req, context);
case 13:
res = _context.sent;
collection = res.getCollection();
ret = context.response();
ret.tag = ix.tag;
ret.collection = {
id: u8ToHex$4(collection.getId_asU8(), context),
transactionIds: collection.getTransactionIdsList().map(function (x) {
return u8ToHex$4(x, context);
})
};
return _context.abrupt("return", ret);
case 19:
case "end":
return _context.stop();
}
opts,
unary$1,
req,
res,
collection,
ret,
_args = arguments;
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Collection Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Collection Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Get Collection Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
req = new protobuf.GetCollectionByIDRequest();
req.setId(hexBuffer$4(ix.collection.id, context));
_context.next = 13;
return unary$1(opts.node, protobuf.AccessAPI.GetCollectionByID, req, context);
case 13:
res = _context.sent;
collection = res.getCollection();
ret = context.response();
ret.tag = ix.tag;
ret.collection = {
id: u8ToHex$4(collection.getId_asU8(), context),
transactionIds: collection.getTransactionIdsList().map(function (x) {
return u8ToHex$4(x, context);
})
};
return _context.abrupt("return", ret);
case 19:
case "end":
return _context.stop();
}

@@ -913,34 +764,27 @@ }, _callee);

};
var hexBuffer$3 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendGetEventsForHeightRangeRequest(_x, _x2, _x3) {
return _sendGetEventsForHeightRangeRequest.apply(this, arguments);
}
function _sendGetEventsForHeightRangeRequest() {
_sendGetEventsForHeightRangeRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(ix, context, opts) {
_sendGetEventsForHeightRangeRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetEventsForHeightRangeRequest();
req.setType(ix.events.eventType);
req.setStartHeight(Number(ix.events.start));
req.setEndHeight(Number(ix.events.end));
_context.next = 7;
return unary$1(opts.node, protobuf.AccessAPI.GetEventsForHeightRange, req, context);
case 7:
res = _context.sent;
return _context.abrupt("return", constructResponse(ix, context, res));
case 9:
case "end":
return _context.stop();
}
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetEventsForHeightRangeRequest();
req.setType(ix.events.eventType);
req.setStartHeight(Number(ix.events.start));
req.setEndHeight(Number(ix.events.end));
_context.next = 7;
return unary$1(opts.node, protobuf.AccessAPI.GetEventsForHeightRange, req, context);
case 7:
res = _context.sent;
return _context.abrupt("return", constructResponse(ix, context, res));
case 9:
case "end":
return _context.stop();
}

@@ -951,31 +795,25 @@ }, _callee);

}
function sendGetEventsForBlockIDsRequest(_x4, _x5, _x6) {
return _sendGetEventsForBlockIDsRequest.apply(this, arguments);
}
function _sendGetEventsForBlockIDsRequest() {
_sendGetEventsForBlockIDsRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee2(ix, context, opts) {
_sendGetEventsForBlockIDsRequest = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee2(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime__default["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetEventsForBlockIDsRequest();
req.setType(ix.events.eventType);
ix.events.blockIds.forEach(function (id) {
return req.addBlockIds(hexBuffer$3(id, context));
});
_context2.next = 6;
return unary$1(opts.node, protobuf.AccessAPI.GetEventsForBlockIDs, req, context);
case 6:
res = _context2.sent;
return _context2.abrupt("return", constructResponse(ix, context, res));
case 8:
case "end":
return _context2.stop();
}
return _regeneratorRuntime__default["default"]().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new protobuf.GetEventsForBlockIDsRequest();
req.setType(ix.events.eventType);
ix.events.blockIds.forEach(function (id) {
return req.addBlockIds(hexBuffer$3(id, context));
});
_context2.next = 6;
return unary$1(opts.node, protobuf.AccessAPI.GetEventsForBlockIDs, req, context);
case 6:
res = _context2.sent;
return _context2.abrupt("return", constructResponse(ix, context, res));
case 8:
case "end":
return _context2.stop();
}

@@ -986,3 +824,2 @@ }, _callee2);

}
function constructResponse(ix, context, res) {

@@ -1013,54 +850,43 @@ var ret = context.response();

}
function sendGetEvents(_x7) {
return _sendGetEvents.apply(this, arguments);
}
function _sendGetEvents() {
_sendGetEvents = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee3(ix) {
_sendGetEvents = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee3(ix) {
var context,
opts,
interactionContainsBlockHeightRange,
interactionContainsBlockIDsList,
_args3 = arguments;
return _regeneratorRuntime__default["default"].wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
context = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
opts = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Events Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Events Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Get Events Error: context.Buffer must be defined.");
_context3.next = 7;
return ix;
case 7:
ix = _context3.sent;
interactionContainsBlockHeightRange = ix.events.start !== null;
interactionContainsBlockIDsList = Array.isArray(ix.events.blockIds) && ix.events.blockIds.length > 0;
utilInvariant.invariant(interactionContainsBlockHeightRange || interactionContainsBlockIDsList, "SendGetEventsError: Unable to determine which get events request to send. Either a block height range, or block IDs must be specified.");
if (!interactionContainsBlockHeightRange) {
_context3.next = 17;
break;
}
_context3.next = 14;
return sendGetEventsForHeightRangeRequest(ix, context, opts);
case 14:
return _context3.abrupt("return", _context3.sent);
case 17:
_context3.next = 19;
return sendGetEventsForBlockIDsRequest(ix, context, opts);
case 19:
return _context3.abrupt("return", _context3.sent);
case 20:
case "end":
return _context3.stop();
}
opts,
interactionContainsBlockHeightRange,
interactionContainsBlockIDsList,
_args3 = arguments;
return _regeneratorRuntime__default["default"]().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
context = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
opts = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Events Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Events Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Get Events Error: context.Buffer must be defined.");
_context3.next = 7;
return ix;
case 7:
ix = _context3.sent;
interactionContainsBlockHeightRange = ix.events.start !== null;
interactionContainsBlockIDsList = Array.isArray(ix.events.blockIds) && ix.events.blockIds.length > 0;
utilInvariant.invariant(interactionContainsBlockHeightRange || interactionContainsBlockIDsList, "SendGetEventsError: Unable to determine which get events request to send. Either a block height range, or block IDs must be specified.");
if (!interactionContainsBlockHeightRange) {
_context3.next = 17;
break;
}
_context3.next = 14;
return sendGetEventsForHeightRangeRequest(ix, context, opts);
case 14:
return _context3.abrupt("return", _context3.sent);
case 17:
_context3.next = 19;
return sendGetEventsForBlockIDsRequest(ix, context, opts);
case 19:
return _context3.abrupt("return", _context3.sent);
case 20:
case "end":
return _context3.stop();
}

@@ -1075,86 +901,75 @@ }, _callee3);

};
var hexBuffer$2 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendGetTransaction(_x) {
return _sendGetTransaction.apply(this, arguments);
}
function _sendGetTransaction() {
_sendGetTransaction = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(ix) {
_sendGetTransaction = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(ix) {
var context,
opts,
unary$1,
req,
res,
ret,
unwrapKey,
unwrapSignature,
transaction,
_args = arguments;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Transaction Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Transaction Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Get Transaction Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
req = new protobuf.GetTransactionRequest();
req.setId(hexBuffer$2(ix.transaction.id, context));
_context.next = 13;
return unary$1(opts.node, protobuf.AccessAPI.GetTransaction, req, context);
case 13:
res = _context.sent;
ret = context.response();
ret.tag = ix.tag;
unwrapKey = function unwrapKey(key) {
return {
address: u8ToHex$2(key.getAddress_asU8(), context),
keyId: key.getKeyId(),
sequenceNumber: key.getSequenceNumber()
};
opts,
unary$1,
req,
res,
ret,
unwrapKey,
unwrapSignature,
transaction,
_args = arguments;
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Transaction Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Transaction Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Get Transaction Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
req = new protobuf.GetTransactionRequest();
req.setId(hexBuffer$2(ix.transaction.id, context));
_context.next = 13;
return unary$1(opts.node, protobuf.AccessAPI.GetTransaction, req, context);
case 13:
res = _context.sent;
ret = context.response();
ret.tag = ix.tag;
unwrapKey = function unwrapKey(key) {
return {
address: u8ToHex$2(key.getAddress_asU8(), context),
keyId: key.getKeyId(),
sequenceNumber: key.getSequenceNumber()
};
unwrapSignature = function unwrapSignature(sig) {
return {
address: u8ToHex$2(sig.getAddress_asU8(), context),
keyId: sig.getKeyId(),
signature: u8ToHex$2(sig.getSignature_asU8(), context)
};
};
unwrapSignature = function unwrapSignature(sig) {
return {
address: u8ToHex$2(sig.getAddress_asU8(), context),
keyId: sig.getKeyId(),
signature: u8ToHex$2(sig.getSignature_asU8(), context)
};
transaction = res.getTransaction();
ret.transaction = {
script: context.Buffer.from(transaction.getScript_asU8()).toString("utf8"),
args: transaction.getArgumentsList().map(function (arg) {
return JSON.parse(context.Buffer.from(arg).toString("utf8"));
}),
referenceBlockId: u8ToHex$2(transaction.getReferenceBlockId_asU8(), context),
gasLimit: transaction.getGasLimit(),
proposalKey: unwrapKey(transaction.getProposalKey()),
payer: u8ToHex$2(transaction.getPayer_asU8(), context),
authorizers: transaction.getAuthorizersList().map(function (x) {
return u8ToHex$2(x, context);
}),
payloadSignatures: transaction.getPayloadSignaturesList().map(unwrapSignature),
envelopeSignatures: transaction.getEnvelopeSignaturesList().map(unwrapSignature)
};
return _context.abrupt("return", ret);
case 21:
case "end":
return _context.stop();
}
};
transaction = res.getTransaction();
ret.transaction = {
script: context.Buffer.from(transaction.getScript_asU8()).toString("utf8"),
args: transaction.getArgumentsList().map(function (arg) {
return JSON.parse(context.Buffer.from(arg).toString("utf8"));
}),
referenceBlockId: u8ToHex$2(transaction.getReferenceBlockId_asU8(), context),
gasLimit: transaction.getGasLimit(),
proposalKey: unwrapKey(transaction.getProposalKey()),
payer: u8ToHex$2(transaction.getPayer_asU8(), context),
authorizers: transaction.getAuthorizersList().map(function (x) {
return u8ToHex$2(x, context);
}),
payloadSignatures: transaction.getPayloadSignaturesList().map(unwrapSignature),
envelopeSignatures: transaction.getEnvelopeSignaturesList().map(unwrapSignature)
};
return _context.abrupt("return", ret);
case 21:
case "end":
return _context.stop();
}

@@ -1174,7 +989,5 @@ }, _callee);

};
var u8ToHex$1 = function u8ToHex(u8, context) {
return context.Buffer.from(u8).toString("hex");
};
var nonEmptyU8ToHex = function nonEmptyU8ToHex(u8, context) {

@@ -1185,68 +998,60 @@ return !u8.reduce(function (empty, b) {

};
var hexBuffer$1 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendGetTransactionStatus(_x) {
return _sendGetTransactionStatus.apply(this, arguments);
}
function _sendGetTransactionStatus() {
_sendGetTransactionStatus = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(ix) {
_sendGetTransactionStatus = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(ix) {
var context,
opts,
unary$1,
req,
res,
events,
ret,
_args = arguments;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Transaction Status Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Transaction Status Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Get Transaction Status Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
req = new protobuf.GetTransactionRequest();
req.setId(hexBuffer$1(ix.transaction.id, context));
_context.next = 13;
return unary$1(opts.node, protobuf.AccessAPI.GetTransactionResult, req, context);
case 13:
res = _context.sent;
events = res.getEventsList();
ret = context.response();
ret.tag = ix.tag;
ret.transactionStatus = {
blockId: nonEmptyU8ToHex(res.getBlockId_asU8(), context),
status: res.getStatus(),
statusString: STATUS_MAP[res.getStatus()],
statusCode: res.getStatusCode(),
errorMessage: res.getErrorMessage(),
events: events.map(function (event) {
return {
type: event.getType(),
transactionId: u8ToHex$1(event.getTransactionId_asU8(), context),
transactionIndex: event.getTransactionIndex(),
eventIndex: event.getEventIndex(),
payload: JSON.parse(context.Buffer.from(event.getPayload_asU8()).toString("utf8"))
};
})
};
return _context.abrupt("return", ret);
case 19:
case "end":
return _context.stop();
}
opts,
unary$1,
req,
res,
events,
ret,
_args = arguments;
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Transaction Status Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Transaction Status Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Get Transaction Status Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
req = new protobuf.GetTransactionRequest();
req.setId(hexBuffer$1(ix.transaction.id, context));
_context.next = 13;
return unary$1(opts.node, protobuf.AccessAPI.GetTransactionResult, req, context);
case 13:
res = _context.sent;
events = res.getEventsList();
ret = context.response();
ret.tag = ix.tag;
ret.transactionStatus = {
blockId: nonEmptyU8ToHex(res.getBlockId_asU8(), context),
status: res.getStatus(),
statusString: STATUS_MAP[res.getStatus()],
statusCode: res.getStatusCode(),
errorMessage: res.getErrorMessage(),
events: events.map(function (event) {
return {
type: event.getType(),
transactionId: u8ToHex$1(event.getTransactionId_asU8(), context),
transactionIndex: event.getTransactionIndex(),
eventIndex: event.getEventIndex(),
payload: JSON.parse(context.Buffer.from(event.getPayload_asU8()).toString("utf8"))
};
})
};
return _context.abrupt("return", ret);
case 19:
case "end":
return _context.stop();
}

@@ -1261,39 +1066,33 @@ }, _callee);

}
function _sendPing() {
_sendPing = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(ix) {
_sendPing = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(ix) {
var context,
opts,
unary$1,
req,
ret,
_args = arguments;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Ping Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Ping Error: context.response must be defined.");
unary$1 = opts.unary || unary;
_context.next = 7;
return ix;
case 7:
ix = _context.sent;
req = new protobuf.PingRequest();
_context.next = 11;
return unary$1(opts.node, protobuf.AccessAPI.Ping, req, context);
case 11:
_context.sent;
ret = context.response();
ret.tag = ix.tag;
return _context.abrupt("return", ret);
case 15:
case "end":
return _context.stop();
}
opts,
unary$1,
req,
ret,
_args = arguments;
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Ping Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Ping Error: context.response must be defined.");
unary$1 = opts.unary || unary;
_context.next = 7;
return ix;
case 7:
ix = _context.sent;
req = new protobuf.PingRequest();
_context.next = 11;
return unary$1(opts.node, protobuf.AccessAPI.Ping, req, context);
case 11:
_context.sent;
ret = context.response();
ret.tag = ix.tag;
return _context.abrupt("return", ret);
case 15:
case "end":
return _context.stop();
}

@@ -1308,193 +1107,161 @@ }, _callee);

};
var paddedHexBuffer = function paddedHexBuffer(hex, pad, context) {
return context.Buffer.from(hex.padStart(pad * 2, 0), "hex");
};
var scriptBuffer = function scriptBuffer(script, context) {
return context.Buffer.from(script, "utf8");
};
var hexBuffer = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
var addressBuffer = function addressBuffer(addr, context) {
return paddedHexBuffer(addr, 8, context);
};
var argumentBuffer = function argumentBuffer(arg, context) {
return context.Buffer.from(JSON.stringify(arg), "utf8");
};
function sendTransaction(_x) {
return _sendTransaction.apply(this, arguments);
}
function _sendTransaction() {
_sendTransaction = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(ix) {
_sendTransaction = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(ix) {
var context,
opts,
unary$1,
tx,
proposalKey,
_i,
_Object$values,
acct,
sig,
_i2,
_Object$values2,
_acct,
_sig,
req,
t1,
res,
t2,
ret,
_args = arguments;
opts,
unary$1,
tx,
proposalKey,
_i,
_Object$values,
acct,
sig,
_i2,
_Object$values2,
_acct,
_sig,
req,
t1,
res,
t2,
ret,
_args = arguments;
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Transaction Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Transaction Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Transaction Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
tx = new protobuf.Transaction();
tx.setScript(scriptBuffer(ix.message.cadence, context));
tx.setGasLimit(ix.message.computeLimit);
tx.setReferenceBlockId(ix.message.refBlock ? hexBuffer(ix.message.refBlock, context) : null);
tx.setPayer(addressBuffer(utilAddress.sansPrefix(ix.accounts[Array.isArray(ix.payer) ? ix.payer[0] : ix.payer].addr), context));
ix.message.arguments.forEach(function (arg) {
return tx.addArguments(argumentBuffer(ix.arguments[arg].asArgument, context));
});
ix.authorizations.map(function (tempId) {
return ix.accounts[tempId].addr;
}).reduce(function (prev, current) {
return prev.find(function (item) {
return item === current;
}) ? prev : [].concat(_toConsumableArray__default["default"](prev), [current]);
}, []).forEach(function (addr) {
return tx.addAuthorizers(addressBuffer(utilAddress.sansPrefix(addr), context));
});
proposalKey = new protobuf.Transaction.ProposalKey();
proposalKey.setAddress(addressBuffer(utilAddress.sansPrefix(ix.accounts[ix.proposer].addr), context));
proposalKey.setKeyId(ix.accounts[ix.proposer].keyId);
proposalKey.setSequenceNumber(ix.accounts[ix.proposer].sequenceNum);
tx.setProposalKey(proposalKey);
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Transaction Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Transaction Error: context.response must be defined.");
utilInvariant.invariant(context.Buffer, "SDK Send Transaction Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
tx = new protobuf.Transaction();
tx.setScript(scriptBuffer(ix.message.cadence, context));
tx.setGasLimit(ix.message.computeLimit);
tx.setReferenceBlockId(ix.message.refBlock ? hexBuffer(ix.message.refBlock, context) : null);
tx.setPayer(addressBuffer(utilAddress.sansPrefix(ix.accounts[Array.isArray(ix.payer) ? ix.payer[0] : ix.payer].addr), context));
ix.message.arguments.forEach(function (arg) {
return tx.addArguments(argumentBuffer(ix.arguments[arg].asArgument, context));
});
ix.authorizations.map(function (tempId) {
return ix.accounts[tempId].addr;
}).reduce(function (prev, current) {
return prev.find(function (item) {
return item === current;
}) ? prev : [].concat(_toConsumableArray__default["default"](prev), [current]);
}, []).forEach(function (addr) {
return tx.addAuthorizers(addressBuffer(utilAddress.sansPrefix(addr), context));
});
proposalKey = new protobuf.Transaction.ProposalKey();
proposalKey.setAddress(addressBuffer(utilAddress.sansPrefix(ix.accounts[ix.proposer].addr), context));
proposalKey.setKeyId(ix.accounts[ix.proposer].keyId);
proposalKey.setSequenceNumber(ix.accounts[ix.proposer].sequenceNum);
tx.setProposalKey(proposalKey); // Apply Non Payer Signatures to Payload Signatures
_i = 0, _Object$values = Object.values(ix.accounts);
case 22:
if (!(_i < _Object$values.length)) {
_context.next = 35;
break;
}
acct = _Object$values[_i];
_context.prev = 24;
if (!acct.role.payer && acct.signature != null) {
sig = new protobuf.Transaction.Signature();
sig.setAddress(addressBuffer(utilAddress.sansPrefix(acct.addr), context));
sig.setKeyId(acct.keyId);
sig.setSignature(hexBuffer(acct.signature, context));
tx.addPayloadSignatures(sig);
}
_context.next = 32;
// Apply Non Payer Signatures to Payload Signatures
_i = 0, _Object$values = Object.values(ix.accounts);
case 22:
if (!(_i < _Object$values.length)) {
_context.next = 35;
break;
case 28:
_context.prev = 28;
_context.t0 = _context["catch"](24);
console.error("Trouble applying payload signature", {
acct: acct,
ix: ix
});
throw _context.t0;
case 32:
_i++;
_context.next = 22;
}
acct = _Object$values[_i];
_context.prev = 24;
if (!acct.role.payer && acct.signature != null) {
sig = new protobuf.Transaction.Signature();
sig.setAddress(addressBuffer(utilAddress.sansPrefix(acct.addr), context));
sig.setKeyId(acct.keyId);
sig.setSignature(hexBuffer(acct.signature, context));
tx.addPayloadSignatures(sig);
}
_context.next = 32;
break;
case 28:
_context.prev = 28;
_context.t0 = _context["catch"](24);
console.error("Trouble applying payload signature", {
acct: acct,
ix: ix
});
throw _context.t0;
case 32:
_i++;
_context.next = 22;
break;
case 35:
_i2 = 0, _Object$values2 = Object.values(ix.accounts);
case 36:
if (!(_i2 < _Object$values2.length)) {
_context.next = 49;
break;
case 35:
_i2 = 0, _Object$values2 = Object.values(ix.accounts);
case 36:
if (!(_i2 < _Object$values2.length)) {
_context.next = 49;
break;
}
_acct = _Object$values2[_i2];
_context.prev = 38;
if (_acct.role.payer && _acct.signature != null) {
_sig = new protobuf.Transaction.Signature();
_sig.setAddress(addressBuffer(utilAddress.sansPrefix(_acct.addr), context));
_sig.setKeyId(_acct.keyId);
_sig.setSignature(hexBuffer(_acct.signature, context));
tx.addEnvelopeSignatures(_sig);
}
_context.next = 46;
break;
case 42:
_context.prev = 42;
_context.t1 = _context["catch"](38);
console.error("Trouble applying envelope signature", {
acct: _acct,
ix: ix
});
throw _context.t1;
case 46:
_i2++;
_context.next = 36;
break;
case 49:
req = new protobuf.SendTransactionRequest();
req.setTransaction(tx);
t1 = Date.now();
_context.next = 54;
return unary$1(opts.node, protobuf.AccessAPI.SendTransaction, req, context);
case 54:
res = _context.sent;
t2 = Date.now();
ret = context.response();
ret.tag = ix.tag;
ret.transactionId = u8ToHex(res.getId_asU8(), context);
if (typeof window !== "undefined") {
window.dispatchEvent(new CustomEvent("FLOW::TX", {
detail: {
txId: ret.transactionId,
delta: t2 - t1
}
}));
}
return _context.abrupt("return", ret);
case 61:
case "end":
return _context.stop();
}
}
_acct = _Object$values2[_i2];
_context.prev = 38;
if (_acct.role.payer && _acct.signature != null) {
_sig = new protobuf.Transaction.Signature();
_sig.setAddress(addressBuffer(utilAddress.sansPrefix(_acct.addr), context));
_sig.setKeyId(_acct.keyId);
_sig.setSignature(hexBuffer(_acct.signature, context));
tx.addEnvelopeSignatures(_sig);
}
_context.next = 46;
break;
case 42:
_context.prev = 42;
_context.t1 = _context["catch"](38);
console.error("Trouble applying envelope signature", {
acct: _acct,
ix: ix
});
throw _context.t1;
case 46:
_i2++;
_context.next = 36;
break;
case 49:
req = new protobuf.SendTransactionRequest();
req.setTransaction(tx);
t1 = Date.now();
_context.next = 54;
return unary$1(opts.node, protobuf.AccessAPI.SendTransaction, req, context);
case 54:
res = _context.sent;
t2 = Date.now();
ret = context.response();
ret.tag = ix.tag;
ret.transactionId = u8ToHex(res.getId_asU8(), context);
if (typeof window !== "undefined" && typeof CustomEvent !== "undefined") {
window.dispatchEvent(new CustomEvent("FLOW::TX", {
detail: {
txId: ret.transactionId,
delta: t2 - t1
}
}));
}
return _context.abrupt("return", ret);
case 61:
case "end":
return _context.stop();
}

@@ -1509,45 +1276,39 @@ }, _callee, null, [[24, 28], [38, 42]]);

}
function _sendGetNetworkParameters() {
_sendGetNetworkParameters = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(ix) {
_sendGetNetworkParameters = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(ix) {
var context,
opts,
unary$1,
req,
res,
ret,
chainId,
_args = arguments;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Network Parameters Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Network Parameters Error: context.response must be defined.");
unary$1 = opts.unary || unary;
_context.next = 7;
return ix;
case 7:
ix = _context.sent;
req = new protobuf.GetNetworkParametersRequest();
_context.next = 11;
return unary$1(opts.node, protobuf.AccessAPI.GetNetworkParameters, req, context);
case 11:
res = _context.sent;
ret = context.response();
ret.tag = ix.tag;
chainId = res.getChainId();
ret.networkParameters = {
chainId: chainId
};
return _context.abrupt("return", ret);
case 17:
case "end":
return _context.stop();
}
opts,
unary$1,
req,
res,
ret,
chainId,
_args = arguments;
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Get Network Parameters Error: opts.node must be defined.");
utilInvariant.invariant(context.response, "SDK Send Get Network Parameters Error: context.response must be defined.");
unary$1 = opts.unary || unary;
_context.next = 7;
return ix;
case 7:
ix = _context.sent;
req = new protobuf.GetNetworkParametersRequest();
_context.next = 11;
return unary$1(opts.node, protobuf.AccessAPI.GetNetworkParameters, req, context);
case 11:
res = _context.sent;
ret = context.response();
ret.tag = ix.tag;
chainId = res.getChainId();
ret.networkParameters = {
chainId: chainId
};
return _context.abrupt("return", ret);
case 17:
case "end":
return _context.stop();
}

@@ -1560,67 +1321,50 @@ }, _callee);

var send = /*#__PURE__*/function () {
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(ix) {
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"]().mark(function _callee(ix) {
var context,
opts,
_args = arguments;
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Error: Either opts.node or \"accessNode.api\" in config must be defined.");
utilInvariant.invariant(context.ix, "SDK Send Error: context.ix must be defined.");
_context.next = 6;
return ix;
case 6:
ix = _context.sent;
_context.t0 = true;
_context.next = _context.t0 === context.ix.isTransaction(ix) ? 10 : _context.t0 === context.ix.isGetTransactionStatus(ix) ? 11 : _context.t0 === context.ix.isGetTransaction(ix) ? 12 : _context.t0 === context.ix.isScript(ix) ? 13 : _context.t0 === context.ix.isGetAccount(ix) ? 14 : _context.t0 === context.ix.isGetEvents(ix) ? 15 : _context.t0 === context.ix.isGetBlock(ix) ? 16 : _context.t0 === context.ix.isGetBlockHeader(ix) ? 17 : _context.t0 === context.ix.isGetCollection(ix) ? 18 : _context.t0 === context.ix.isPing(ix) ? 19 : _context.t0 === context.ix.isGetNetworkParameters(ix) ? 20 : 21;
break;
case 10:
return _context.abrupt("return", opts.sendTransaction ? opts.sendTransaction(ix, context, opts) : sendTransaction(ix, context, opts));
case 11:
return _context.abrupt("return", opts.sendGetTransactionStatus ? opts.sendGetTransactionStatus(ix, context, opts) : sendGetTransactionStatus(ix, context, opts));
case 12:
return _context.abrupt("return", opts.sendGetTransaction ? opts.sendGetTransaction(ix, context, opts) : sendGetTransaction(ix, context, opts));
case 13:
return _context.abrupt("return", opts.sendExecuteScript ? opts.sendExecuteScript(ix, context, opts) : sendExecuteScript(ix, context, opts));
case 14:
return _context.abrupt("return", opts.sendGetAccount ? opts.sendGetAccount(ix, context, opts) : sendGetAccount(ix, context, opts));
case 15:
return _context.abrupt("return", opts.sendGetEvents ? opts.sendGetEvents(ix, context, opts) : sendGetEvents(ix, context, opts));
case 16:
return _context.abrupt("return", opts.sendGetBlock ? opts.sendGetBlock(ix, context, opts) : sendGetBlock(ix, context, opts));
case 17:
return _context.abrupt("return", opts.sendGetBlockHeader ? opts.sendGetBlockHeader(ix, context, opts) : sendGetBlockHeader(ix, context, opts));
case 18:
return _context.abrupt("return", opts.sendGetCollection ? opts.sendGetCollection(ix, context, opts) : sendGetCollection(ix, context, opts));
case 19:
return _context.abrupt("return", opts.sendPing ? opts.sendPing(ix, context, opts) : sendPing(ix, context, opts));
case 20:
return _context.abrupt("return", opts.sendGetNetworkParameters ? opts.sendGetNetworkParameters(ix, context, opts) : sendGetNetworkParameters(ix, context, opts));
case 21:
return _context.abrupt("return", ix);
case 22:
case "end":
return _context.stop();
}
opts,
_args = arguments;
return _regeneratorRuntime__default["default"]().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
utilInvariant.invariant(opts.node, "SDK Send Error: Either opts.node or \"accessNode.api\" in config must be defined.");
utilInvariant.invariant(context.ix, "SDK Send Error: context.ix must be defined.");
_context.next = 6;
return ix;
case 6:
ix = _context.sent;
_context.t0 = true;
_context.next = _context.t0 === context.ix.isTransaction(ix) ? 10 : _context.t0 === context.ix.isGetTransactionStatus(ix) ? 11 : _context.t0 === context.ix.isGetTransaction(ix) ? 12 : _context.t0 === context.ix.isScript(ix) ? 13 : _context.t0 === context.ix.isGetAccount(ix) ? 14 : _context.t0 === context.ix.isGetEvents(ix) ? 15 : _context.t0 === context.ix.isGetBlock(ix) ? 16 : _context.t0 === context.ix.isGetBlockHeader(ix) ? 17 : _context.t0 === context.ix.isGetCollection(ix) ? 18 : _context.t0 === context.ix.isPing(ix) ? 19 : _context.t0 === context.ix.isGetNetworkParameters(ix) ? 20 : 21;
break;
case 10:
return _context.abrupt("return", opts.sendTransaction ? opts.sendTransaction(ix, context, opts) : sendTransaction(ix, context, opts));
case 11:
return _context.abrupt("return", opts.sendGetTransactionStatus ? opts.sendGetTransactionStatus(ix, context, opts) : sendGetTransactionStatus(ix, context, opts));
case 12:
return _context.abrupt("return", opts.sendGetTransaction ? opts.sendGetTransaction(ix, context, opts) : sendGetTransaction(ix, context, opts));
case 13:
return _context.abrupt("return", opts.sendExecuteScript ? opts.sendExecuteScript(ix, context, opts) : sendExecuteScript(ix, context, opts));
case 14:
return _context.abrupt("return", opts.sendGetAccount ? opts.sendGetAccount(ix, context, opts) : sendGetAccount(ix, context, opts));
case 15:
return _context.abrupt("return", opts.sendGetEvents ? opts.sendGetEvents(ix, context, opts) : sendGetEvents(ix, context, opts));
case 16:
return _context.abrupt("return", opts.sendGetBlock ? opts.sendGetBlock(ix, context, opts) : sendGetBlock(ix, context, opts));
case 17:
return _context.abrupt("return", opts.sendGetBlockHeader ? opts.sendGetBlockHeader(ix, context, opts) : sendGetBlockHeader(ix, context, opts));
case 18:
return _context.abrupt("return", opts.sendGetCollection ? opts.sendGetCollection(ix, context, opts) : sendGetCollection(ix, context, opts));
case 19:
return _context.abrupt("return", opts.sendPing ? opts.sendPing(ix, context, opts) : sendPing(ix, context, opts));
case 20:
return _context.abrupt("return", opts.sendGetNetworkParameters ? opts.sendGetNetworkParameters(ix, context, opts) : sendGetNetworkParameters(ix, context, opts));
case 21:
return _context.abrupt("return", ix);
case 22:
case "end":
return _context.stop();
}
}, _callee);
}));
return function send(_x) {

@@ -1627,0 +1371,0 @@ return _ref.apply(this, arguments);

@@ -0,3 +1,3 @@

import _regeneratorRuntime from '@babel/runtime/helpers/regeneratorRuntime';
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
import _regeneratorRuntime from '@babel/runtime/regenerator';
import { invariant } from '@onflow/util-invariant';

@@ -16,39 +16,33 @@ import { ExecuteScriptAtBlockIDRequest, AccessAPI, ExecuteScriptAtBlockHeightRequest, ExecuteScriptAtLatestBlockRequest, GetAccountAtBlockHeightRequest, GetAccountAtLatestBlockRequest, GetBlockHeaderByIDRequest, GetLatestBlockHeaderRequest, GetBlockHeaderByHeightRequest, GetBlockByIDRequest, GetLatestBlockRequest, GetBlockByHeightRequest, GetCollectionByIDRequest, GetEventsForHeightRangeRequest, GetEventsForBlockIDsRequest, GetTransactionRequest, PingRequest, SendTransactionRequest, Transaction, GetNetworkParametersRequest } from '@onflow/protobuf';

}
function _unary() {
_unary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(host, method, request, context) {
_unary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(host, method, request, context) {
var metadataFromConfig;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
invariant(context.config, "SDK GRPC Unary Error: context.config must be defined.");
_context.next = 3;
return context.config().get("grpc.metadata", {});
case 3:
metadataFromConfig = _context.sent;
return _context.abrupt("return", new Promise(function (resolve, reject) {
grpc.unary(method, {
request: request,
host: host,
metadata: new grpc.Metadata(metadataFromConfig),
onEnd: function onEnd(_ref) {
var status = _ref.status,
statusMessage = _ref.statusMessage,
message = _ref.message;
if (status === grpc.Code.OK) {
resolve(message);
} else {
reject(new Error(statusMessage));
}
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
invariant(context.config, "SDK GRPC Unary Error: context.config must be defined.");
_context.next = 3;
return context.config().get("grpc.metadata", {});
case 3:
metadataFromConfig = _context.sent;
return _context.abrupt("return", new Promise(function (resolve, reject) {
grpc.unary(method, {
request: request,
host: host,
metadata: new grpc.Metadata(metadataFromConfig),
onEnd: function onEnd(_ref) {
var status = _ref.status,
statusMessage = _ref.statusMessage,
message = _ref.message;
if (status === grpc.Code.OK) {
resolve(message);
} else {
reject(new Error(statusMessage));
}
});
}));
case 5:
case "end":
return _context.stop();
}
}
});
}));
case 5:
case "end":
return _context.stop();
}

@@ -63,37 +57,30 @@ }, _callee);

};
var hexBuffer$7 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendExecuteScriptAtBlockIDRequest(_x, _x2, _x3) {
return _sendExecuteScriptAtBlockIDRequest.apply(this, arguments);
}
function _sendExecuteScriptAtBlockIDRequest() {
_sendExecuteScriptAtBlockIDRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ix, context, opts) {
_sendExecuteScriptAtBlockIDRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ix, context, opts) {
var unary$1, req, code, res;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new ExecuteScriptAtBlockIDRequest();
req.setBlockId(hexBuffer$7(ix.block.id, context));
code = context.Buffer.from(ix.message.cadence, "utf8");
ix.message.arguments.forEach(function (arg) {
return req.addArguments(argumentBuffer$1(ix.arguments[arg].asArgument, context));
});
req.setScript(code);
_context.next = 8;
return unary$1(opts.node, AccessAPI.ExecuteScriptAtBlockID, req, context);
case 8:
res = _context.sent;
return _context.abrupt("return", constructResponse$4(ix, context, res));
case 10:
case "end":
return _context.stop();
}
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new ExecuteScriptAtBlockIDRequest();
req.setBlockId(hexBuffer$7(ix.block.id, context));
code = context.Buffer.from(ix.message.cadence, "utf8");
ix.message.arguments.forEach(function (arg) {
return req.addArguments(argumentBuffer$1(ix.arguments[arg].asArgument, context));
});
req.setScript(code);
_context.next = 8;
return unary$1(opts.node, AccessAPI.ExecuteScriptAtBlockID, req, context);
case 8:
res = _context.sent;
return _context.abrupt("return", constructResponse$4(ix, context, res));
case 10:
case "end":
return _context.stop();
}

@@ -104,33 +91,27 @@ }, _callee);

}
function sendExecuteScriptAtBlockHeightRequest(_x4, _x5, _x6) {
return _sendExecuteScriptAtBlockHeightRequest.apply(this, arguments);
}
function _sendExecuteScriptAtBlockHeightRequest() {
_sendExecuteScriptAtBlockHeightRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ix, context, opts) {
_sendExecuteScriptAtBlockHeightRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ix, context, opts) {
var unary$1, req, code, res;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new ExecuteScriptAtBlockHeightRequest();
req.setBlockHeight(Number(ix.block.height));
code = context.Buffer.from(ix.message.cadence, "utf8");
ix.message.arguments.forEach(function (arg) {
return req.addArguments(argumentBuffer$1(ix.arguments[arg].asArgument, context));
});
req.setScript(code);
_context2.next = 8;
return unary$1(opts.node, AccessAPI.ExecuteScriptAtBlockHeight, req, context);
case 8:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$4(ix, context, res));
case 10:
case "end":
return _context2.stop();
}
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new ExecuteScriptAtBlockHeightRequest();
req.setBlockHeight(Number(ix.block.height));
code = context.Buffer.from(ix.message.cadence, "utf8");
ix.message.arguments.forEach(function (arg) {
return req.addArguments(argumentBuffer$1(ix.arguments[arg].asArgument, context));
});
req.setScript(code);
_context2.next = 8;
return unary$1(opts.node, AccessAPI.ExecuteScriptAtBlockHeight, req, context);
case 8:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$4(ix, context, res));
case 10:
case "end":
return _context2.stop();
}

@@ -141,32 +122,26 @@ }, _callee2);

}
function sendExecuteScriptAtLatestBlockRequest(_x7, _x8, _x9) {
return _sendExecuteScriptAtLatestBlockRequest.apply(this, arguments);
}
function _sendExecuteScriptAtLatestBlockRequest() {
_sendExecuteScriptAtLatestBlockRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(ix, context, opts) {
_sendExecuteScriptAtLatestBlockRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(ix, context, opts) {
var unary$1, req, code, res;
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
unary$1 = opts.unary || unary;
req = new ExecuteScriptAtLatestBlockRequest();
code = context.Buffer.from(ix.message.cadence, "utf8");
ix.message.arguments.forEach(function (arg) {
return req.addArguments(argumentBuffer$1(ix.arguments[arg].asArgument, context));
});
req.setScript(code);
_context3.next = 7;
return unary$1(opts.node, AccessAPI.ExecuteScriptAtLatestBlock, req, context);
case 7:
res = _context3.sent;
return _context3.abrupt("return", constructResponse$4(ix, context, res));
case 9:
case "end":
return _context3.stop();
}
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
unary$1 = opts.unary || unary;
req = new ExecuteScriptAtLatestBlockRequest();
code = context.Buffer.from(ix.message.cadence, "utf8");
ix.message.arguments.forEach(function (arg) {
return req.addArguments(argumentBuffer$1(ix.arguments[arg].asArgument, context));
});
req.setScript(code);
_context3.next = 7;
return unary$1(opts.node, AccessAPI.ExecuteScriptAtLatestBlock, req, context);
case 7:
res = _context3.sent;
return _context3.abrupt("return", constructResponse$4(ix, context, res));
case 9:
case "end":
return _context3.stop();
}

@@ -177,3 +152,2 @@ }, _callee3);

}
function constructResponse$4(ix, context, res) {

@@ -185,61 +159,47 @@ var ret = context.response();

}
function sendExecuteScript(_x10) {
return _sendExecuteScript.apply(this, arguments);
}
function _sendExecuteScript() {
_sendExecuteScript = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(ix) {
_sendExecuteScript = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(ix) {
var context,
opts,
_args4 = arguments;
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
context = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
opts = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
invariant(opts.node, "SDK Send Execute Script Error: opts.node must be defined.");
invariant(context.response, "SDK Send Execute Script Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Execute Script Error: context.Buffer must be defined.");
_context4.next = 7;
return ix;
case 7:
ix = _context4.sent;
if (!ix.block.id) {
_context4.next = 14;
break;
}
_context4.next = 11;
return sendExecuteScriptAtBlockIDRequest(ix, context, opts);
case 11:
return _context4.abrupt("return", _context4.sent);
case 14:
if (!ix.block.height) {
_context4.next = 20;
break;
}
_context4.next = 17;
return sendExecuteScriptAtBlockHeightRequest(ix, context, opts);
case 17:
return _context4.abrupt("return", _context4.sent);
case 20:
_context4.next = 22;
return sendExecuteScriptAtLatestBlockRequest(ix, context, opts);
case 22:
return _context4.abrupt("return", _context4.sent);
case 23:
case "end":
return _context4.stop();
}
opts,
_args4 = arguments;
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
while (1) switch (_context4.prev = _context4.next) {
case 0:
context = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
opts = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
invariant(opts.node, "SDK Send Execute Script Error: opts.node must be defined.");
invariant(context.response, "SDK Send Execute Script Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Execute Script Error: context.Buffer must be defined.");
_context4.next = 7;
return ix;
case 7:
ix = _context4.sent;
if (!ix.block.id) {
_context4.next = 14;
break;
}
_context4.next = 11;
return sendExecuteScriptAtBlockIDRequest(ix, context, opts);
case 11:
return _context4.abrupt("return", _context4.sent);
case 14:
if (!ix.block.height) {
_context4.next = 20;
break;
}
_context4.next = 17;
return sendExecuteScriptAtBlockHeightRequest(ix, context, opts);
case 17:
return _context4.abrupt("return", _context4.sent);
case 20:
_context4.next = 22;
return sendExecuteScriptAtLatestBlockRequest(ix, context, opts);
case 22:
return _context4.abrupt("return", _context4.sent);
case 23:
case "end":
return _context4.stop();
}

@@ -254,11 +214,8 @@ }, _callee4);

};
var paddedHexBuffer$1 = function paddedHexBuffer(hex, pad, context) {
return context.Buffer.from(hex.padStart(pad * 2, 0), "hex");
};
var addressBuffer$1 = function addressBuffer(addr, context) {
return paddedHexBuffer$1(addr, 8, context);
};
var HashAlgorithmNames = {

@@ -276,29 +233,23 @@ 1: "SHA2_256",

};
function sendGetAccountAtBlockHeightRequest(_x, _x2, _x3) {
return _sendGetAccountAtBlockHeightRequest.apply(this, arguments);
}
function _sendGetAccountAtBlockHeightRequest() {
_sendGetAccountAtBlockHeightRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ix, context, opts) {
_sendGetAccountAtBlockHeightRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetAccountAtBlockHeightRequest();
req.setBlockHeight(Number(ix.block.height));
req.setAddress(addressBuffer$1(sansPrefix(ix.account.addr), context));
_context.next = 6;
return unary$1(opts.node, AccessAPI.GetAccountAtBlockHeight, req, context);
case 6:
res = _context.sent;
return _context.abrupt("return", constructResponse$3(ix, context, res));
case 8:
case "end":
return _context.stop();
}
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetAccountAtBlockHeightRequest();
req.setBlockHeight(Number(ix.block.height));
req.setAddress(addressBuffer$1(sansPrefix(ix.account.addr), context));
_context.next = 6;
return unary$1(opts.node, AccessAPI.GetAccountAtBlockHeight, req, context);
case 6:
res = _context.sent;
return _context.abrupt("return", constructResponse$3(ix, context, res));
case 8:
case "end":
return _context.stop();
}

@@ -309,28 +260,22 @@ }, _callee);

}
function sendGetAccountAtLatestBlockRequest(_x4, _x5, _x6) {
return _sendGetAccountAtLatestBlockRequest.apply(this, arguments);
}
function _sendGetAccountAtLatestBlockRequest() {
_sendGetAccountAtLatestBlockRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ix, context, opts) {
_sendGetAccountAtLatestBlockRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetAccountAtLatestBlockRequest();
req.setAddress(addressBuffer$1(sansPrefix(ix.account.addr), context));
_context2.next = 5;
return unary$1(opts.node, AccessAPI.GetAccountAtLatestBlock, req, context);
case 5:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$3(ix, context, res));
case 7:
case "end":
return _context2.stop();
}
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetAccountAtLatestBlockRequest();
req.setAddress(addressBuffer$1(sansPrefix(ix.account.addr), context));
_context2.next = 5;
return unary$1(opts.node, AccessAPI.GetAccountAtLatestBlock, req, context);
case 5:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$3(ix, context, res));
case 7:
case "end":
return _context2.stop();
}

@@ -341,3 +286,2 @@ }, _callee2);

}
function constructResponse$3(ix, context, res) {

@@ -374,49 +318,38 @@ var ret = context.response();

}
function sendGetAccount(_x7) {
return _sendGetAccount.apply(this, arguments);
}
function _sendGetAccount() {
_sendGetAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(ix) {
_sendGetAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(ix) {
var context,
opts,
_args3 = arguments;
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
context = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
opts = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
invariant(opts.node, "SDK Send Get Account Error: opts.node must be defined.");
invariant(context.response, "SDK Get Account Error: context.response must be defined.");
invariant(context.Buffer, "SDK Get Account Error: context.Buffer must be defined.");
_context3.next = 7;
return ix;
case 7:
ix = _context3.sent;
if (!(ix.block.height !== null)) {
_context3.next = 14;
break;
}
_context3.next = 11;
return sendGetAccountAtBlockHeightRequest(ix, context, opts);
case 11:
return _context3.abrupt("return", _context3.sent);
case 14:
_context3.next = 16;
return sendGetAccountAtLatestBlockRequest(ix, context, opts);
case 16:
return _context3.abrupt("return", _context3.sent);
case 17:
case "end":
return _context3.stop();
}
opts,
_args3 = arguments;
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
context = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
opts = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
invariant(opts.node, "SDK Send Get Account Error: opts.node must be defined.");
invariant(context.response, "SDK Get Account Error: context.response must be defined.");
invariant(context.Buffer, "SDK Get Account Error: context.Buffer must be defined.");
_context3.next = 7;
return ix;
case 7:
ix = _context3.sent;
if (!(ix.block.height !== null)) {
_context3.next = 14;
break;
}
_context3.next = 11;
return sendGetAccountAtBlockHeightRequest(ix, context, opts);
case 11:
return _context3.abrupt("return", _context3.sent);
case 14:
_context3.next = 16;
return sendGetAccountAtLatestBlockRequest(ix, context, opts);
case 16:
return _context3.abrupt("return", _context3.sent);
case 17:
case "end":
return _context3.stop();
}

@@ -431,32 +364,25 @@ }, _callee3);

};
var hexBuffer$6 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendGetBlockHeaderByIDRequest(_x, _x2, _x3) {
return _sendGetBlockHeaderByIDRequest.apply(this, arguments);
}
function _sendGetBlockHeaderByIDRequest() {
_sendGetBlockHeaderByIDRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ix, context, opts) {
_sendGetBlockHeaderByIDRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetBlockHeaderByIDRequest();
req.setId(hexBuffer$6(ix.block.id, context));
_context.next = 5;
return unary$1(opts.node, AccessAPI.GetBlockHeaderByID, req, context);
case 5:
res = _context.sent;
return _context.abrupt("return", constructResponse$2(ix, context, res));
case 7:
case "end":
return _context.stop();
}
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetBlockHeaderByIDRequest();
req.setId(hexBuffer$6(ix.block.id, context));
_context.next = 5;
return unary$1(opts.node, AccessAPI.GetBlockHeaderByID, req, context);
case 5:
res = _context.sent;
return _context.abrupt("return", constructResponse$2(ix, context, res));
case 7:
case "end":
return _context.stop();
}

@@ -467,28 +393,22 @@ }, _callee);

}
function sendGetBlockHeaderByHeightRequest(_x4, _x5, _x6) {
return _sendGetBlockHeaderByHeightRequest.apply(this, arguments);
}
function _sendGetBlockHeaderByHeightRequest() {
_sendGetBlockHeaderByHeightRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ix, context, opts) {
_sendGetBlockHeaderByHeightRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetBlockHeaderByHeightRequest();
req.setHeight(Number(ix.block.height));
_context2.next = 5;
return unary$1(opts.node, AccessAPI.GetBlockHeaderByHeight, req, context);
case 5:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$2(ix, context, res));
case 7:
case "end":
return _context2.stop();
}
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetBlockHeaderByHeightRequest();
req.setHeight(Number(ix.block.height));
_context2.next = 5;
return unary$1(opts.node, AccessAPI.GetBlockHeaderByHeight, req, context);
case 5:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$2(ix, context, res));
case 7:
case "end":
return _context2.stop();
}

@@ -499,34 +419,25 @@ }, _callee2);

}
function sendGetLatestBlockHeaderRequest(_x7, _x8, _x9) {
return _sendGetLatestBlockHeaderRequest.apply(this, arguments);
}
function _sendGetLatestBlockHeaderRequest() {
_sendGetLatestBlockHeaderRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(ix, context, opts) {
_sendGetLatestBlockHeaderRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(ix, context, opts) {
var _ix$block;
var unary$1, req, res;
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetLatestBlockHeaderRequest();
if ((_ix$block = ix.block) !== null && _ix$block !== void 0 && _ix$block.isSealed) {
req.setIsSealed(ix.block.isSealed);
}
_context3.next = 5;
return unary$1(opts.node, AccessAPI.GetLatestBlockHeader, req, context);
case 5:
res = _context3.sent;
return _context3.abrupt("return", constructResponse$2(ix, context, res));
case 7:
case "end":
return _context3.stop();
}
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetLatestBlockHeaderRequest();
if ((_ix$block = ix.block) !== null && _ix$block !== void 0 && _ix$block.isSealed) {
req.setIsSealed(ix.block.isSealed);
}
_context3.next = 5;
return unary$1(opts.node, AccessAPI.GetLatestBlockHeader, req, context);
case 5:
res = _context3.sent;
return _context3.abrupt("return", constructResponse$2(ix, context, res));
case 7:
case "end":
return _context3.stop();
}

@@ -537,3 +448,2 @@ }, _callee3);

}
function constructResponse$2(ix, context, res) {

@@ -551,65 +461,51 @@ var blockHeader = res.getBlock();

}
function sendGetBlockHeader(_x10) {
return _sendGetBlockHeader.apply(this, arguments);
}
function _sendGetBlockHeader() {
_sendGetBlockHeader = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(ix) {
_sendGetBlockHeader = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(ix) {
var context,
opts,
interactionHasBlockID,
interactionHasBlockHeight,
_args4 = arguments;
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
context = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
opts = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
invariant(opts.node, "SDK Send Get Block Header Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Block Header Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Get Block Header Error: context.Buffer must be defined.");
_context4.next = 7;
return ix;
case 7:
ix = _context4.sent;
interactionHasBlockID = ix.block.id !== null;
interactionHasBlockHeight = ix.block.height !== null;
if (!interactionHasBlockID) {
_context4.next = 16;
break;
}
_context4.next = 13;
return sendGetBlockHeaderByIDRequest(ix, context, opts);
case 13:
return _context4.abrupt("return", _context4.sent);
case 16:
if (!interactionHasBlockHeight) {
_context4.next = 22;
break;
}
_context4.next = 19;
return sendGetBlockHeaderByHeightRequest(ix, context, opts);
case 19:
return _context4.abrupt("return", _context4.sent);
case 22:
_context4.next = 24;
return sendGetLatestBlockHeaderRequest(ix, context, opts);
case 24:
return _context4.abrupt("return", _context4.sent);
case 25:
case "end":
return _context4.stop();
}
opts,
interactionHasBlockID,
interactionHasBlockHeight,
_args4 = arguments;
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
while (1) switch (_context4.prev = _context4.next) {
case 0:
context = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
opts = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
invariant(opts.node, "SDK Send Get Block Header Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Block Header Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Get Block Header Error: context.Buffer must be defined.");
_context4.next = 7;
return ix;
case 7:
ix = _context4.sent;
interactionHasBlockID = ix.block.id !== null;
interactionHasBlockHeight = ix.block.height !== null;
if (!interactionHasBlockID) {
_context4.next = 16;
break;
}
_context4.next = 13;
return sendGetBlockHeaderByIDRequest(ix, context, opts);
case 13:
return _context4.abrupt("return", _context4.sent);
case 16:
if (!interactionHasBlockHeight) {
_context4.next = 22;
break;
}
_context4.next = 19;
return sendGetBlockHeaderByHeightRequest(ix, context, opts);
case 19:
return _context4.abrupt("return", _context4.sent);
case 22:
_context4.next = 24;
return sendGetLatestBlockHeaderRequest(ix, context, opts);
case 24:
return _context4.abrupt("return", _context4.sent);
case 25:
case "end":
return _context4.stop();
}

@@ -624,32 +520,25 @@ }, _callee4);

};
var hexBuffer$5 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendGetBlockByIDRequest(_x, _x2, _x3) {
return _sendGetBlockByIDRequest.apply(this, arguments);
}
function _sendGetBlockByIDRequest() {
_sendGetBlockByIDRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ix, context, opts) {
_sendGetBlockByIDRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetBlockByIDRequest();
req.setId(hexBuffer$5(ix.block.id, context));
_context.next = 5;
return unary$1(opts.node, AccessAPI.GetBlockByID, req, context);
case 5:
res = _context.sent;
return _context.abrupt("return", constructResponse$1(ix, context, res));
case 7:
case "end":
return _context.stop();
}
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetBlockByIDRequest();
req.setId(hexBuffer$5(ix.block.id, context));
_context.next = 5;
return unary$1(opts.node, AccessAPI.GetBlockByID, req, context);
case 5:
res = _context.sent;
return _context.abrupt("return", constructResponse$1(ix, context, res));
case 7:
case "end":
return _context.stop();
}

@@ -660,28 +549,22 @@ }, _callee);

}
function sendGetBlockByHeightRequest(_x4, _x5, _x6) {
return _sendGetBlockByHeightRequest.apply(this, arguments);
}
function _sendGetBlockByHeightRequest() {
_sendGetBlockByHeightRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ix, context, opts) {
_sendGetBlockByHeightRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetBlockByHeightRequest();
req.setHeight(Number(ix.block.height));
_context2.next = 5;
return unary$1(opts.node, AccessAPI.GetBlockByHeight, req, context);
case 5:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$1(ix, context, res));
case 7:
case "end":
return _context2.stop();
}
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetBlockByHeightRequest();
req.setHeight(Number(ix.block.height));
_context2.next = 5;
return unary$1(opts.node, AccessAPI.GetBlockByHeight, req, context);
case 5:
res = _context2.sent;
return _context2.abrupt("return", constructResponse$1(ix, context, res));
case 7:
case "end":
return _context2.stop();
}

@@ -692,34 +575,25 @@ }, _callee2);

}
function sendGetBlockRequest(_x7, _x8, _x9) {
return _sendGetBlockRequest.apply(this, arguments);
}
function _sendGetBlockRequest() {
_sendGetBlockRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(ix, context, opts) {
_sendGetBlockRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(ix, context, opts) {
var _ix$block;
var unary$1, req, res;
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetLatestBlockRequest();
if ((_ix$block = ix.block) !== null && _ix$block !== void 0 && _ix$block.isSealed) {
req.setIsSealed(ix.block.isSealed);
}
_context3.next = 5;
return unary$1(opts.node, AccessAPI.GetLatestBlock, req, context);
case 5:
res = _context3.sent;
return _context3.abrupt("return", constructResponse$1(ix, context, res));
case 7:
case "end":
return _context3.stop();
}
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetLatestBlockRequest();
if ((_ix$block = ix.block) !== null && _ix$block !== void 0 && _ix$block.isSealed) {
req.setIsSealed(ix.block.isSealed);
}
_context3.next = 5;
return unary$1(opts.node, AccessAPI.GetLatestBlock, req, context);
case 5:
res = _context3.sent;
return _context3.abrupt("return", constructResponse$1(ix, context, res));
case 7:
case "end":
return _context3.stop();
}

@@ -730,3 +604,2 @@ }, _callee3);

}
function constructResponse$1(ix, context, res) {

@@ -760,65 +633,51 @@ var block = res.getBlock();

}
function sendGetBlock(_x10) {
return _sendGetBlock.apply(this, arguments);
}
function _sendGetBlock() {
_sendGetBlock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(ix) {
_sendGetBlock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(ix) {
var context,
opts,
interactionHasBlockID,
interactionHasBlockHeight,
_args4 = arguments;
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
context = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
opts = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
invariant(opts.node, "SDK Send Get Block Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Block Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Get Block Error: context.Buffer must be defined.");
_context4.next = 7;
return ix;
case 7:
ix = _context4.sent;
interactionHasBlockID = ix.block.id !== null;
interactionHasBlockHeight = ix.block.height !== null;
if (!interactionHasBlockID) {
_context4.next = 16;
break;
}
_context4.next = 13;
return sendGetBlockByIDRequest(ix, context, opts);
case 13:
return _context4.abrupt("return", _context4.sent);
case 16:
if (!interactionHasBlockHeight) {
_context4.next = 22;
break;
}
_context4.next = 19;
return sendGetBlockByHeightRequest(ix, context, opts);
case 19:
return _context4.abrupt("return", _context4.sent);
case 22:
_context4.next = 24;
return sendGetBlockRequest(ix, context, opts);
case 24:
return _context4.abrupt("return", _context4.sent);
case 25:
case "end":
return _context4.stop();
}
opts,
interactionHasBlockID,
interactionHasBlockHeight,
_args4 = arguments;
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
while (1) switch (_context4.prev = _context4.next) {
case 0:
context = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
opts = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
invariant(opts.node, "SDK Send Get Block Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Block Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Get Block Error: context.Buffer must be defined.");
_context4.next = 7;
return ix;
case 7:
ix = _context4.sent;
interactionHasBlockID = ix.block.id !== null;
interactionHasBlockHeight = ix.block.height !== null;
if (!interactionHasBlockID) {
_context4.next = 16;
break;
}
_context4.next = 13;
return sendGetBlockByIDRequest(ix, context, opts);
case 13:
return _context4.abrupt("return", _context4.sent);
case 16:
if (!interactionHasBlockHeight) {
_context4.next = 22;
break;
}
_context4.next = 19;
return sendGetBlockByHeightRequest(ix, context, opts);
case 19:
return _context4.abrupt("return", _context4.sent);
case 22:
_context4.next = 24;
return sendGetBlockRequest(ix, context, opts);
case 24:
return _context4.abrupt("return", _context4.sent);
case 25:
case "end":
return _context4.stop();
}

@@ -833,58 +692,50 @@ }, _callee4);

};
var hexBuffer$4 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendGetCollection(_x) {
return _sendGetCollection.apply(this, arguments);
}
function _sendGetCollection() {
_sendGetCollection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ix) {
_sendGetCollection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ix) {
var context,
opts,
unary$1,
req,
res,
collection,
ret,
_args = arguments;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Get Collection Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Collection Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Get Collection Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
req = new GetCollectionByIDRequest();
req.setId(hexBuffer$4(ix.collection.id, context));
_context.next = 13;
return unary$1(opts.node, AccessAPI.GetCollectionByID, req, context);
case 13:
res = _context.sent;
collection = res.getCollection();
ret = context.response();
ret.tag = ix.tag;
ret.collection = {
id: u8ToHex$4(collection.getId_asU8(), context),
transactionIds: collection.getTransactionIdsList().map(function (x) {
return u8ToHex$4(x, context);
})
};
return _context.abrupt("return", ret);
case 19:
case "end":
return _context.stop();
}
opts,
unary$1,
req,
res,
collection,
ret,
_args = arguments;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Get Collection Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Collection Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Get Collection Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
req = new GetCollectionByIDRequest();
req.setId(hexBuffer$4(ix.collection.id, context));
_context.next = 13;
return unary$1(opts.node, AccessAPI.GetCollectionByID, req, context);
case 13:
res = _context.sent;
collection = res.getCollection();
ret = context.response();
ret.tag = ix.tag;
ret.collection = {
id: u8ToHex$4(collection.getId_asU8(), context),
transactionIds: collection.getTransactionIdsList().map(function (x) {
return u8ToHex$4(x, context);
})
};
return _context.abrupt("return", ret);
case 19:
case "end":
return _context.stop();
}

@@ -899,34 +750,27 @@ }, _callee);

};
var hexBuffer$3 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendGetEventsForHeightRangeRequest(_x, _x2, _x3) {
return _sendGetEventsForHeightRangeRequest.apply(this, arguments);
}
function _sendGetEventsForHeightRangeRequest() {
_sendGetEventsForHeightRangeRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ix, context, opts) {
_sendGetEventsForHeightRangeRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetEventsForHeightRangeRequest();
req.setType(ix.events.eventType);
req.setStartHeight(Number(ix.events.start));
req.setEndHeight(Number(ix.events.end));
_context.next = 7;
return unary$1(opts.node, AccessAPI.GetEventsForHeightRange, req, context);
case 7:
res = _context.sent;
return _context.abrupt("return", constructResponse(ix, context, res));
case 9:
case "end":
return _context.stop();
}
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetEventsForHeightRangeRequest();
req.setType(ix.events.eventType);
req.setStartHeight(Number(ix.events.start));
req.setEndHeight(Number(ix.events.end));
_context.next = 7;
return unary$1(opts.node, AccessAPI.GetEventsForHeightRange, req, context);
case 7:
res = _context.sent;
return _context.abrupt("return", constructResponse(ix, context, res));
case 9:
case "end":
return _context.stop();
}

@@ -937,31 +781,25 @@ }, _callee);

}
function sendGetEventsForBlockIDsRequest(_x4, _x5, _x6) {
return _sendGetEventsForBlockIDsRequest.apply(this, arguments);
}
function _sendGetEventsForBlockIDsRequest() {
_sendGetEventsForBlockIDsRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ix, context, opts) {
_sendGetEventsForBlockIDsRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ix, context, opts) {
var unary$1, req, res;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetEventsForBlockIDsRequest();
req.setType(ix.events.eventType);
ix.events.blockIds.forEach(function (id) {
return req.addBlockIds(hexBuffer$3(id, context));
});
_context2.next = 6;
return unary$1(opts.node, AccessAPI.GetEventsForBlockIDs, req, context);
case 6:
res = _context2.sent;
return _context2.abrupt("return", constructResponse(ix, context, res));
case 8:
case "end":
return _context2.stop();
}
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
unary$1 = opts.unary || unary;
req = new GetEventsForBlockIDsRequest();
req.setType(ix.events.eventType);
ix.events.blockIds.forEach(function (id) {
return req.addBlockIds(hexBuffer$3(id, context));
});
_context2.next = 6;
return unary$1(opts.node, AccessAPI.GetEventsForBlockIDs, req, context);
case 6:
res = _context2.sent;
return _context2.abrupt("return", constructResponse(ix, context, res));
case 8:
case "end":
return _context2.stop();
}

@@ -972,3 +810,2 @@ }, _callee2);

}
function constructResponse(ix, context, res) {

@@ -999,54 +836,43 @@ var ret = context.response();

}
function sendGetEvents(_x7) {
return _sendGetEvents.apply(this, arguments);
}
function _sendGetEvents() {
_sendGetEvents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(ix) {
_sendGetEvents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(ix) {
var context,
opts,
interactionContainsBlockHeightRange,
interactionContainsBlockIDsList,
_args3 = arguments;
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
context = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
opts = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
invariant(opts.node, "SDK Send Get Events Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Events Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Get Events Error: context.Buffer must be defined.");
_context3.next = 7;
return ix;
case 7:
ix = _context3.sent;
interactionContainsBlockHeightRange = ix.events.start !== null;
interactionContainsBlockIDsList = Array.isArray(ix.events.blockIds) && ix.events.blockIds.length > 0;
invariant(interactionContainsBlockHeightRange || interactionContainsBlockIDsList, "SendGetEventsError: Unable to determine which get events request to send. Either a block height range, or block IDs must be specified.");
if (!interactionContainsBlockHeightRange) {
_context3.next = 17;
break;
}
_context3.next = 14;
return sendGetEventsForHeightRangeRequest(ix, context, opts);
case 14:
return _context3.abrupt("return", _context3.sent);
case 17:
_context3.next = 19;
return sendGetEventsForBlockIDsRequest(ix, context, opts);
case 19:
return _context3.abrupt("return", _context3.sent);
case 20:
case "end":
return _context3.stop();
}
opts,
interactionContainsBlockHeightRange,
interactionContainsBlockIDsList,
_args3 = arguments;
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
context = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
opts = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
invariant(opts.node, "SDK Send Get Events Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Events Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Get Events Error: context.Buffer must be defined.");
_context3.next = 7;
return ix;
case 7:
ix = _context3.sent;
interactionContainsBlockHeightRange = ix.events.start !== null;
interactionContainsBlockIDsList = Array.isArray(ix.events.blockIds) && ix.events.blockIds.length > 0;
invariant(interactionContainsBlockHeightRange || interactionContainsBlockIDsList, "SendGetEventsError: Unable to determine which get events request to send. Either a block height range, or block IDs must be specified.");
if (!interactionContainsBlockHeightRange) {
_context3.next = 17;
break;
}
_context3.next = 14;
return sendGetEventsForHeightRangeRequest(ix, context, opts);
case 14:
return _context3.abrupt("return", _context3.sent);
case 17:
_context3.next = 19;
return sendGetEventsForBlockIDsRequest(ix, context, opts);
case 19:
return _context3.abrupt("return", _context3.sent);
case 20:
case "end":
return _context3.stop();
}

@@ -1061,86 +887,75 @@ }, _callee3);

};
var hexBuffer$2 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendGetTransaction(_x) {
return _sendGetTransaction.apply(this, arguments);
}
function _sendGetTransaction() {
_sendGetTransaction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ix) {
_sendGetTransaction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ix) {
var context,
opts,
unary$1,
req,
res,
ret,
unwrapKey,
unwrapSignature,
transaction,
_args = arguments;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Get Transaction Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Transaction Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Get Transaction Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
req = new GetTransactionRequest();
req.setId(hexBuffer$2(ix.transaction.id, context));
_context.next = 13;
return unary$1(opts.node, AccessAPI.GetTransaction, req, context);
case 13:
res = _context.sent;
ret = context.response();
ret.tag = ix.tag;
unwrapKey = function unwrapKey(key) {
return {
address: u8ToHex$2(key.getAddress_asU8(), context),
keyId: key.getKeyId(),
sequenceNumber: key.getSequenceNumber()
};
opts,
unary$1,
req,
res,
ret,
unwrapKey,
unwrapSignature,
transaction,
_args = arguments;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Get Transaction Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Transaction Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Get Transaction Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
req = new GetTransactionRequest();
req.setId(hexBuffer$2(ix.transaction.id, context));
_context.next = 13;
return unary$1(opts.node, AccessAPI.GetTransaction, req, context);
case 13:
res = _context.sent;
ret = context.response();
ret.tag = ix.tag;
unwrapKey = function unwrapKey(key) {
return {
address: u8ToHex$2(key.getAddress_asU8(), context),
keyId: key.getKeyId(),
sequenceNumber: key.getSequenceNumber()
};
unwrapSignature = function unwrapSignature(sig) {
return {
address: u8ToHex$2(sig.getAddress_asU8(), context),
keyId: sig.getKeyId(),
signature: u8ToHex$2(sig.getSignature_asU8(), context)
};
};
unwrapSignature = function unwrapSignature(sig) {
return {
address: u8ToHex$2(sig.getAddress_asU8(), context),
keyId: sig.getKeyId(),
signature: u8ToHex$2(sig.getSignature_asU8(), context)
};
transaction = res.getTransaction();
ret.transaction = {
script: context.Buffer.from(transaction.getScript_asU8()).toString("utf8"),
args: transaction.getArgumentsList().map(function (arg) {
return JSON.parse(context.Buffer.from(arg).toString("utf8"));
}),
referenceBlockId: u8ToHex$2(transaction.getReferenceBlockId_asU8(), context),
gasLimit: transaction.getGasLimit(),
proposalKey: unwrapKey(transaction.getProposalKey()),
payer: u8ToHex$2(transaction.getPayer_asU8(), context),
authorizers: transaction.getAuthorizersList().map(function (x) {
return u8ToHex$2(x, context);
}),
payloadSignatures: transaction.getPayloadSignaturesList().map(unwrapSignature),
envelopeSignatures: transaction.getEnvelopeSignaturesList().map(unwrapSignature)
};
return _context.abrupt("return", ret);
case 21:
case "end":
return _context.stop();
}
};
transaction = res.getTransaction();
ret.transaction = {
script: context.Buffer.from(transaction.getScript_asU8()).toString("utf8"),
args: transaction.getArgumentsList().map(function (arg) {
return JSON.parse(context.Buffer.from(arg).toString("utf8"));
}),
referenceBlockId: u8ToHex$2(transaction.getReferenceBlockId_asU8(), context),
gasLimit: transaction.getGasLimit(),
proposalKey: unwrapKey(transaction.getProposalKey()),
payer: u8ToHex$2(transaction.getPayer_asU8(), context),
authorizers: transaction.getAuthorizersList().map(function (x) {
return u8ToHex$2(x, context);
}),
payloadSignatures: transaction.getPayloadSignaturesList().map(unwrapSignature),
envelopeSignatures: transaction.getEnvelopeSignaturesList().map(unwrapSignature)
};
return _context.abrupt("return", ret);
case 21:
case "end":
return _context.stop();
}

@@ -1160,7 +975,5 @@ }, _callee);

};
var u8ToHex$1 = function u8ToHex(u8, context) {
return context.Buffer.from(u8).toString("hex");
};
var nonEmptyU8ToHex = function nonEmptyU8ToHex(u8, context) {

@@ -1171,68 +984,60 @@ return !u8.reduce(function (empty, b) {

};
var hexBuffer$1 = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
function sendGetTransactionStatus(_x) {
return _sendGetTransactionStatus.apply(this, arguments);
}
function _sendGetTransactionStatus() {
_sendGetTransactionStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ix) {
_sendGetTransactionStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ix) {
var context,
opts,
unary$1,
req,
res,
events,
ret,
_args = arguments;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Get Transaction Status Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Transaction Status Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Get Transaction Status Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
req = new GetTransactionRequest();
req.setId(hexBuffer$1(ix.transaction.id, context));
_context.next = 13;
return unary$1(opts.node, AccessAPI.GetTransactionResult, req, context);
case 13:
res = _context.sent;
events = res.getEventsList();
ret = context.response();
ret.tag = ix.tag;
ret.transactionStatus = {
blockId: nonEmptyU8ToHex(res.getBlockId_asU8(), context),
status: res.getStatus(),
statusString: STATUS_MAP[res.getStatus()],
statusCode: res.getStatusCode(),
errorMessage: res.getErrorMessage(),
events: events.map(function (event) {
return {
type: event.getType(),
transactionId: u8ToHex$1(event.getTransactionId_asU8(), context),
transactionIndex: event.getTransactionIndex(),
eventIndex: event.getEventIndex(),
payload: JSON.parse(context.Buffer.from(event.getPayload_asU8()).toString("utf8"))
};
})
};
return _context.abrupt("return", ret);
case 19:
case "end":
return _context.stop();
}
opts,
unary$1,
req,
res,
events,
ret,
_args = arguments;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Get Transaction Status Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Transaction Status Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Get Transaction Status Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
req = new GetTransactionRequest();
req.setId(hexBuffer$1(ix.transaction.id, context));
_context.next = 13;
return unary$1(opts.node, AccessAPI.GetTransactionResult, req, context);
case 13:
res = _context.sent;
events = res.getEventsList();
ret = context.response();
ret.tag = ix.tag;
ret.transactionStatus = {
blockId: nonEmptyU8ToHex(res.getBlockId_asU8(), context),
status: res.getStatus(),
statusString: STATUS_MAP[res.getStatus()],
statusCode: res.getStatusCode(),
errorMessage: res.getErrorMessage(),
events: events.map(function (event) {
return {
type: event.getType(),
transactionId: u8ToHex$1(event.getTransactionId_asU8(), context),
transactionIndex: event.getTransactionIndex(),
eventIndex: event.getEventIndex(),
payload: JSON.parse(context.Buffer.from(event.getPayload_asU8()).toString("utf8"))
};
})
};
return _context.abrupt("return", ret);
case 19:
case "end":
return _context.stop();
}

@@ -1247,39 +1052,33 @@ }, _callee);

}
function _sendPing() {
_sendPing = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ix) {
_sendPing = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ix) {
var context,
opts,
unary$1,
req,
ret,
_args = arguments;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Ping Error: opts.node must be defined.");
invariant(context.response, "SDK Send Ping Error: context.response must be defined.");
unary$1 = opts.unary || unary;
_context.next = 7;
return ix;
case 7:
ix = _context.sent;
req = new PingRequest();
_context.next = 11;
return unary$1(opts.node, AccessAPI.Ping, req, context);
case 11:
_context.sent;
ret = context.response();
ret.tag = ix.tag;
return _context.abrupt("return", ret);
case 15:
case "end":
return _context.stop();
}
opts,
unary$1,
req,
ret,
_args = arguments;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Ping Error: opts.node must be defined.");
invariant(context.response, "SDK Send Ping Error: context.response must be defined.");
unary$1 = opts.unary || unary;
_context.next = 7;
return ix;
case 7:
ix = _context.sent;
req = new PingRequest();
_context.next = 11;
return unary$1(opts.node, AccessAPI.Ping, req, context);
case 11:
_context.sent;
ret = context.response();
ret.tag = ix.tag;
return _context.abrupt("return", ret);
case 15:
case "end":
return _context.stop();
}

@@ -1294,193 +1093,161 @@ }, _callee);

};
var paddedHexBuffer = function paddedHexBuffer(hex, pad, context) {
return context.Buffer.from(hex.padStart(pad * 2, 0), "hex");
};
var scriptBuffer = function scriptBuffer(script, context) {
return context.Buffer.from(script, "utf8");
};
var hexBuffer = function hexBuffer(hex, context) {
return context.Buffer.from(hex, "hex");
};
var addressBuffer = function addressBuffer(addr, context) {
return paddedHexBuffer(addr, 8, context);
};
var argumentBuffer = function argumentBuffer(arg, context) {
return context.Buffer.from(JSON.stringify(arg), "utf8");
};
function sendTransaction(_x) {
return _sendTransaction.apply(this, arguments);
}
function _sendTransaction() {
_sendTransaction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ix) {
_sendTransaction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ix) {
var context,
opts,
unary$1,
tx,
proposalKey,
_i,
_Object$values,
acct,
sig,
_i2,
_Object$values2,
_acct,
_sig,
req,
t1,
res,
t2,
ret,
_args = arguments;
opts,
unary$1,
tx,
proposalKey,
_i,
_Object$values,
acct,
sig,
_i2,
_Object$values2,
_acct,
_sig,
req,
t1,
res,
t2,
ret,
_args = arguments;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Transaction Error: opts.node must be defined.");
invariant(context.response, "SDK Send Transaction Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Transaction Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
tx = new Transaction();
tx.setScript(scriptBuffer(ix.message.cadence, context));
tx.setGasLimit(ix.message.computeLimit);
tx.setReferenceBlockId(ix.message.refBlock ? hexBuffer(ix.message.refBlock, context) : null);
tx.setPayer(addressBuffer(sansPrefix(ix.accounts[Array.isArray(ix.payer) ? ix.payer[0] : ix.payer].addr), context));
ix.message.arguments.forEach(function (arg) {
return tx.addArguments(argumentBuffer(ix.arguments[arg].asArgument, context));
});
ix.authorizations.map(function (tempId) {
return ix.accounts[tempId].addr;
}).reduce(function (prev, current) {
return prev.find(function (item) {
return item === current;
}) ? prev : [].concat(_toConsumableArray(prev), [current]);
}, []).forEach(function (addr) {
return tx.addAuthorizers(addressBuffer(sansPrefix(addr), context));
});
proposalKey = new Transaction.ProposalKey();
proposalKey.setAddress(addressBuffer(sansPrefix(ix.accounts[ix.proposer].addr), context));
proposalKey.setKeyId(ix.accounts[ix.proposer].keyId);
proposalKey.setSequenceNumber(ix.accounts[ix.proposer].sequenceNum);
tx.setProposalKey(proposalKey);
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Transaction Error: opts.node must be defined.");
invariant(context.response, "SDK Send Transaction Error: context.response must be defined.");
invariant(context.Buffer, "SDK Send Transaction Error: context.Buffer must be defined.");
unary$1 = opts.unary || unary;
_context.next = 8;
return ix;
case 8:
ix = _context.sent;
tx = new Transaction();
tx.setScript(scriptBuffer(ix.message.cadence, context));
tx.setGasLimit(ix.message.computeLimit);
tx.setReferenceBlockId(ix.message.refBlock ? hexBuffer(ix.message.refBlock, context) : null);
tx.setPayer(addressBuffer(sansPrefix(ix.accounts[Array.isArray(ix.payer) ? ix.payer[0] : ix.payer].addr), context));
ix.message.arguments.forEach(function (arg) {
return tx.addArguments(argumentBuffer(ix.arguments[arg].asArgument, context));
});
ix.authorizations.map(function (tempId) {
return ix.accounts[tempId].addr;
}).reduce(function (prev, current) {
return prev.find(function (item) {
return item === current;
}) ? prev : [].concat(_toConsumableArray(prev), [current]);
}, []).forEach(function (addr) {
return tx.addAuthorizers(addressBuffer(sansPrefix(addr), context));
});
proposalKey = new Transaction.ProposalKey();
proposalKey.setAddress(addressBuffer(sansPrefix(ix.accounts[ix.proposer].addr), context));
proposalKey.setKeyId(ix.accounts[ix.proposer].keyId);
proposalKey.setSequenceNumber(ix.accounts[ix.proposer].sequenceNum);
tx.setProposalKey(proposalKey); // Apply Non Payer Signatures to Payload Signatures
_i = 0, _Object$values = Object.values(ix.accounts);
case 22:
if (!(_i < _Object$values.length)) {
_context.next = 35;
break;
}
acct = _Object$values[_i];
_context.prev = 24;
if (!acct.role.payer && acct.signature != null) {
sig = new Transaction.Signature();
sig.setAddress(addressBuffer(sansPrefix(acct.addr), context));
sig.setKeyId(acct.keyId);
sig.setSignature(hexBuffer(acct.signature, context));
tx.addPayloadSignatures(sig);
}
_context.next = 32;
// Apply Non Payer Signatures to Payload Signatures
_i = 0, _Object$values = Object.values(ix.accounts);
case 22:
if (!(_i < _Object$values.length)) {
_context.next = 35;
break;
case 28:
_context.prev = 28;
_context.t0 = _context["catch"](24);
console.error("Trouble applying payload signature", {
acct: acct,
ix: ix
});
throw _context.t0;
case 32:
_i++;
_context.next = 22;
}
acct = _Object$values[_i];
_context.prev = 24;
if (!acct.role.payer && acct.signature != null) {
sig = new Transaction.Signature();
sig.setAddress(addressBuffer(sansPrefix(acct.addr), context));
sig.setKeyId(acct.keyId);
sig.setSignature(hexBuffer(acct.signature, context));
tx.addPayloadSignatures(sig);
}
_context.next = 32;
break;
case 28:
_context.prev = 28;
_context.t0 = _context["catch"](24);
console.error("Trouble applying payload signature", {
acct: acct,
ix: ix
});
throw _context.t0;
case 32:
_i++;
_context.next = 22;
break;
case 35:
_i2 = 0, _Object$values2 = Object.values(ix.accounts);
case 36:
if (!(_i2 < _Object$values2.length)) {
_context.next = 49;
break;
case 35:
_i2 = 0, _Object$values2 = Object.values(ix.accounts);
case 36:
if (!(_i2 < _Object$values2.length)) {
_context.next = 49;
break;
}
_acct = _Object$values2[_i2];
_context.prev = 38;
if (_acct.role.payer && _acct.signature != null) {
_sig = new Transaction.Signature();
_sig.setAddress(addressBuffer(sansPrefix(_acct.addr), context));
_sig.setKeyId(_acct.keyId);
_sig.setSignature(hexBuffer(_acct.signature, context));
tx.addEnvelopeSignatures(_sig);
}
_context.next = 46;
break;
case 42:
_context.prev = 42;
_context.t1 = _context["catch"](38);
console.error("Trouble applying envelope signature", {
acct: _acct,
ix: ix
});
throw _context.t1;
case 46:
_i2++;
_context.next = 36;
break;
case 49:
req = new SendTransactionRequest();
req.setTransaction(tx);
t1 = Date.now();
_context.next = 54;
return unary$1(opts.node, AccessAPI.SendTransaction, req, context);
case 54:
res = _context.sent;
t2 = Date.now();
ret = context.response();
ret.tag = ix.tag;
ret.transactionId = u8ToHex(res.getId_asU8(), context);
if (typeof window !== "undefined") {
window.dispatchEvent(new CustomEvent("FLOW::TX", {
detail: {
txId: ret.transactionId,
delta: t2 - t1
}
}));
}
return _context.abrupt("return", ret);
case 61:
case "end":
return _context.stop();
}
}
_acct = _Object$values2[_i2];
_context.prev = 38;
if (_acct.role.payer && _acct.signature != null) {
_sig = new Transaction.Signature();
_sig.setAddress(addressBuffer(sansPrefix(_acct.addr), context));
_sig.setKeyId(_acct.keyId);
_sig.setSignature(hexBuffer(_acct.signature, context));
tx.addEnvelopeSignatures(_sig);
}
_context.next = 46;
break;
case 42:
_context.prev = 42;
_context.t1 = _context["catch"](38);
console.error("Trouble applying envelope signature", {
acct: _acct,
ix: ix
});
throw _context.t1;
case 46:
_i2++;
_context.next = 36;
break;
case 49:
req = new SendTransactionRequest();
req.setTransaction(tx);
t1 = Date.now();
_context.next = 54;
return unary$1(opts.node, AccessAPI.SendTransaction, req, context);
case 54:
res = _context.sent;
t2 = Date.now();
ret = context.response();
ret.tag = ix.tag;
ret.transactionId = u8ToHex(res.getId_asU8(), context);
if (typeof window !== "undefined" && typeof CustomEvent !== "undefined") {
window.dispatchEvent(new CustomEvent("FLOW::TX", {
detail: {
txId: ret.transactionId,
delta: t2 - t1
}
}));
}
return _context.abrupt("return", ret);
case 61:
case "end":
return _context.stop();
}

@@ -1495,45 +1262,39 @@ }, _callee, null, [[24, 28], [38, 42]]);

}
function _sendGetNetworkParameters() {
_sendGetNetworkParameters = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ix) {
_sendGetNetworkParameters = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ix) {
var context,
opts,
unary$1,
req,
res,
ret,
chainId,
_args = arguments;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Get Network Parameters Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Network Parameters Error: context.response must be defined.");
unary$1 = opts.unary || unary;
_context.next = 7;
return ix;
case 7:
ix = _context.sent;
req = new GetNetworkParametersRequest();
_context.next = 11;
return unary$1(opts.node, AccessAPI.GetNetworkParameters, req, context);
case 11:
res = _context.sent;
ret = context.response();
ret.tag = ix.tag;
chainId = res.getChainId();
ret.networkParameters = {
chainId: chainId
};
return _context.abrupt("return", ret);
case 17:
case "end":
return _context.stop();
}
opts,
unary$1,
req,
res,
ret,
chainId,
_args = arguments;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Get Network Parameters Error: opts.node must be defined.");
invariant(context.response, "SDK Send Get Network Parameters Error: context.response must be defined.");
unary$1 = opts.unary || unary;
_context.next = 7;
return ix;
case 7:
ix = _context.sent;
req = new GetNetworkParametersRequest();
_context.next = 11;
return unary$1(opts.node, AccessAPI.GetNetworkParameters, req, context);
case 11:
res = _context.sent;
ret = context.response();
ret.tag = ix.tag;
chainId = res.getChainId();
ret.networkParameters = {
chainId: chainId
};
return _context.abrupt("return", ret);
case 17:
case "end":
return _context.stop();
}

@@ -1546,67 +1307,50 @@ }, _callee);

var send = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ix) {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(ix) {
var context,
opts,
_args = arguments;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Error: Either opts.node or \"accessNode.api\" in config must be defined.");
invariant(context.ix, "SDK Send Error: context.ix must be defined.");
_context.next = 6;
return ix;
case 6:
ix = _context.sent;
_context.t0 = true;
_context.next = _context.t0 === context.ix.isTransaction(ix) ? 10 : _context.t0 === context.ix.isGetTransactionStatus(ix) ? 11 : _context.t0 === context.ix.isGetTransaction(ix) ? 12 : _context.t0 === context.ix.isScript(ix) ? 13 : _context.t0 === context.ix.isGetAccount(ix) ? 14 : _context.t0 === context.ix.isGetEvents(ix) ? 15 : _context.t0 === context.ix.isGetBlock(ix) ? 16 : _context.t0 === context.ix.isGetBlockHeader(ix) ? 17 : _context.t0 === context.ix.isGetCollection(ix) ? 18 : _context.t0 === context.ix.isPing(ix) ? 19 : _context.t0 === context.ix.isGetNetworkParameters(ix) ? 20 : 21;
break;
case 10:
return _context.abrupt("return", opts.sendTransaction ? opts.sendTransaction(ix, context, opts) : sendTransaction(ix, context, opts));
case 11:
return _context.abrupt("return", opts.sendGetTransactionStatus ? opts.sendGetTransactionStatus(ix, context, opts) : sendGetTransactionStatus(ix, context, opts));
case 12:
return _context.abrupt("return", opts.sendGetTransaction ? opts.sendGetTransaction(ix, context, opts) : sendGetTransaction(ix, context, opts));
case 13:
return _context.abrupt("return", opts.sendExecuteScript ? opts.sendExecuteScript(ix, context, opts) : sendExecuteScript(ix, context, opts));
case 14:
return _context.abrupt("return", opts.sendGetAccount ? opts.sendGetAccount(ix, context, opts) : sendGetAccount(ix, context, opts));
case 15:
return _context.abrupt("return", opts.sendGetEvents ? opts.sendGetEvents(ix, context, opts) : sendGetEvents(ix, context, opts));
case 16:
return _context.abrupt("return", opts.sendGetBlock ? opts.sendGetBlock(ix, context, opts) : sendGetBlock(ix, context, opts));
case 17:
return _context.abrupt("return", opts.sendGetBlockHeader ? opts.sendGetBlockHeader(ix, context, opts) : sendGetBlockHeader(ix, context, opts));
case 18:
return _context.abrupt("return", opts.sendGetCollection ? opts.sendGetCollection(ix, context, opts) : sendGetCollection(ix, context, opts));
case 19:
return _context.abrupt("return", opts.sendPing ? opts.sendPing(ix, context, opts) : sendPing(ix, context, opts));
case 20:
return _context.abrupt("return", opts.sendGetNetworkParameters ? opts.sendGetNetworkParameters(ix, context, opts) : sendGetNetworkParameters(ix, context, opts));
case 21:
return _context.abrupt("return", ix);
case 22:
case "end":
return _context.stop();
}
opts,
_args = arguments;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
context = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
opts = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
invariant(opts.node, "SDK Send Error: Either opts.node or \"accessNode.api\" in config must be defined.");
invariant(context.ix, "SDK Send Error: context.ix must be defined.");
_context.next = 6;
return ix;
case 6:
ix = _context.sent;
_context.t0 = true;
_context.next = _context.t0 === context.ix.isTransaction(ix) ? 10 : _context.t0 === context.ix.isGetTransactionStatus(ix) ? 11 : _context.t0 === context.ix.isGetTransaction(ix) ? 12 : _context.t0 === context.ix.isScript(ix) ? 13 : _context.t0 === context.ix.isGetAccount(ix) ? 14 : _context.t0 === context.ix.isGetEvents(ix) ? 15 : _context.t0 === context.ix.isGetBlock(ix) ? 16 : _context.t0 === context.ix.isGetBlockHeader(ix) ? 17 : _context.t0 === context.ix.isGetCollection(ix) ? 18 : _context.t0 === context.ix.isPing(ix) ? 19 : _context.t0 === context.ix.isGetNetworkParameters(ix) ? 20 : 21;
break;
case 10:
return _context.abrupt("return", opts.sendTransaction ? opts.sendTransaction(ix, context, opts) : sendTransaction(ix, context, opts));
case 11:
return _context.abrupt("return", opts.sendGetTransactionStatus ? opts.sendGetTransactionStatus(ix, context, opts) : sendGetTransactionStatus(ix, context, opts));
case 12:
return _context.abrupt("return", opts.sendGetTransaction ? opts.sendGetTransaction(ix, context, opts) : sendGetTransaction(ix, context, opts));
case 13:
return _context.abrupt("return", opts.sendExecuteScript ? opts.sendExecuteScript(ix, context, opts) : sendExecuteScript(ix, context, opts));
case 14:
return _context.abrupt("return", opts.sendGetAccount ? opts.sendGetAccount(ix, context, opts) : sendGetAccount(ix, context, opts));
case 15:
return _context.abrupt("return", opts.sendGetEvents ? opts.sendGetEvents(ix, context, opts) : sendGetEvents(ix, context, opts));
case 16:
return _context.abrupt("return", opts.sendGetBlock ? opts.sendGetBlock(ix, context, opts) : sendGetBlock(ix, context, opts));
case 17:
return _context.abrupt("return", opts.sendGetBlockHeader ? opts.sendGetBlockHeader(ix, context, opts) : sendGetBlockHeader(ix, context, opts));
case 18:
return _context.abrupt("return", opts.sendGetCollection ? opts.sendGetCollection(ix, context, opts) : sendGetCollection(ix, context, opts));
case 19:
return _context.abrupt("return", opts.sendPing ? opts.sendPing(ix, context, opts) : sendPing(ix, context, opts));
case 20:
return _context.abrupt("return", opts.sendGetNetworkParameters ? opts.sendGetNetworkParameters(ix, context, opts) : sendGetNetworkParameters(ix, context, opts));
case 21:
return _context.abrupt("return", ix);
case 22:
case "end":
return _context.stop();
}
}, _callee);
}));
return function send(_x) {

@@ -1613,0 +1357,0 @@ return _ref.apply(this, arguments);

{
"name": "@onflow/transport-grpc",
"version": "1.2.0-alpha.1",
"version": "1.2.0-alpha.2",
"description": "Flow SDK GRPC Transport Module",

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

@@ -109,3 +109,3 @@ import {invariant} from "@onflow/util-invariant"

if (typeof window !== "undefined") {
if (typeof window !== "undefined" && typeof CustomEvent !== "undefined") {
window.dispatchEvent(

@@ -112,0 +112,0 @@ new CustomEvent("FLOW::TX", {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc